Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit d05d2dc

Browse files
authored
Improve how changing the CCP at run-time is handled. (#204)
Much like recent changes this pull-request improves the handling of changing the CCP at runtime: * Show output in a way that is testable. * Add the tests. * Recognize a "no-change change". * Remove needless quotes.
1 parent e223c90 commit d05d2dc

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

ccp/ccp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ func Get(name string) (Flavour, error) {
8686
valid = append(valid, ent.Name)
8787
}
8888

89-
return Flavour{}, fmt.Errorf("ccp %s not found - valid choices are: %s", name, strings.Join(valid, ","))
89+
return Flavour{}, fmt.Errorf("CCP %s not found - valid choices are: %s", name, strings.Join(valid, ","))
9090
}

cpm/cpm_bios.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ func BiosSysCallReserved1(cpm *CPM) error {
269269
// Get/Set the CCP
270270
case 0x0003:
271271

272+
// If DE is null then we're just being asked to return
273+
// the current CCP name
272274
if de == 0x0000 {
273275
// Fill the DMA area with NULL bytes
274276
addr := cpm.dma
@@ -290,10 +292,16 @@ func BiosSysCallReserved1(cpm *CPM) error {
290292
// Get the string pointed to by DE
291293
str := getStringFromMemory(de)
292294

295+
// If there is no change do nothing
296+
if str == cpm.ccp {
297+
cpm.output.WriteString("CCP is already set to " + str + ", doing nothing.\r\n")
298+
return nil
299+
}
300+
293301
// See if the CCP exists
294302
entry, err := ccp.Get(str)
295303
if err != nil {
296-
fmt.Printf("Invalid CCP name %s\r\n", str)
304+
cpm.output.WriteString("Error changing CCP to " + str + ", " + err.Error() + "\r\n")
297305
return nil
298306
}
299307

@@ -302,8 +310,9 @@ func BiosSysCallReserved1(cpm *CPM) error {
302310
cpm.ccp = str
303311

304312
if old != str {
305-
fmt.Printf("CCP changed to %s [%s] Size:0x%04X Entry-Point:0x%04X\r\n", str, entry.Description, len(entry.Bytes), entry.Start)
313+
cpm.output.WriteString(fmt.Sprintf("CCP changed to %s [%s] Size:0x%04X Entry-Point:0x%04X\r\n", str, entry.Description, len(entry.Bytes), entry.Start))
306314
}
315+
return nil
307316

308317
// Get/Set the quiet flag
309318
case 0x0004:

static/A/!CCP.COM

-1 Bytes
Binary file not shown.

static/ccp.z80

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ not_cpmulator:
9393
;; Text output strings.
9494
;;
9595
CCP_PREFIX:
96-
db "CCP is set to '$"
96+
db "CCP is set to $"
9797
CCP_SUFFIX:
98-
db "'", 0x0a, 0x0d, "$"
98+
db ".", 0x0a, 0x0d, "$"
9999

100100
WRONG_EMULATOR:
101101
db "This binary is not running under cpmulator, aborting.", 0x0a, 0x0d, "$"

test/ccp2.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
A:!ctrlc
66
!hostcmd
77
!ccp ccp
8+
!ccp ccp
9+
!ccp ccpz
810
!ccp ccpz
11+
!ccp Monday
912
Exit

test/ccp2.pat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
The Ctrl-C count is currently set to
22
The prefix for executing commands on the host is unset.
33
Running commands on the host is disabled.
4-
CCP changed to ccp
4+
CCP is already set to ccp, doing nothing.
55
CCP changed to ccpz
6+
CCP is already set to ccpz, doing nothing.
7+
Error changing CCP to monday, CCP monday not found - valid choices are: ccp,ccpz

0 commit comments

Comments
 (0)