Skip to content

Commit

Permalink
Updated the quiet-flag to be more logical (#137)
Browse files Browse the repository at this point in the history
Now the quiet flag behaves in a more predictable way, being 1 when
quiet mode is active - rather than zero.

This closes #136
  • Loading branch information
skx authored Jun 24, 2024
1 parent 180ca09 commit 0333b9b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
10 changes: 5 additions & 5 deletions EXTENSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ Demonstrated in [samples/ccp.z80](samples/ccp.z80)



## Function 0x04: Get/Set Quiet
## Function 0x04: Get/Set Quiet Flag

* If C is 0x00 quiet-mode is enabled.
* If C is 0x01 quiet-mode is disabled.
* If C is 0x01 quiet-mode is enabled.
* If C is 0x00 quiet-mode is disabled.
* If C is 0xFF quiet-mode is queried.
* 0x00 means it is active
* 0x01 means it is not active.
* 0x00 means it is disabled.
* 0x01 means it is active

Quiet mode prevents the display of a banner every time the CCP is restarted.

Expand Down
39 changes: 19 additions & 20 deletions cpm/cpm_bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,7 @@ func BiosSysCallReserved1(cpm *CPM) error {
// HL == 1
// C == 0xff to get the ctrl-c count
// C != 0xff to set the ctrl-c count
//
// HL == 2
// DE points to a string containing the console driver to use.
//
// HL == 3
// DE points to a string containing the CCP to use.
//
// HL == 4
// C == 0 - Quiet mode on.
// C != 0 - Quiet mode off
// ...
//
hl := cpm.CPU.States.HL.U16()
c := cpm.CPU.States.BC.Lo
Expand All @@ -157,8 +148,8 @@ func BiosSysCallReserved1(cpm *CPM) error {
// Helper to read a null/space terminated string from
// memory.
//
// Here because our custom syscalls read a string when
// setting both CCP and DisplayDriver.
// Here because several of our custom syscalls need to
// read a string from the caller.
//
getStringFromMemory := func(addr uint16) string {
str := ""
Expand All @@ -176,6 +167,7 @@ func BiosSysCallReserved1(cpm *CPM) error {

switch hl {

// Is this a CPMUlator?
case 0x0000:
// Magic values in the registers
cpm.CPU.States.HL.Hi = 'S'
Expand All @@ -200,13 +192,15 @@ func BiosSysCallReserved1(cpm *CPM) error {
}
return nil

// Get/Set the ctrl-c flag
case 0x0001:
if c == 0xFF {
cpm.CPU.States.AF.Hi = uint8(cpm.input.GetInterruptCount())
} else {
cpm.input.SetInterruptCount(int(c))
}

// Get/Set the console driver.
case 0x0002:

if de == 0x0000 {
Expand Down Expand Up @@ -254,6 +248,7 @@ func BiosSysCallReserved1(cpm *CPM) error {
fmt.Printf("Console driver is already %s, making no change.\n", str)
}

// Get/Set the CCP
case 0x0003:

if de == 0x0000 {
Expand Down Expand Up @@ -299,30 +294,34 @@ func BiosSysCallReserved1(cpm *CPM) error {
fmt.Printf("CCP is already %s, making no change.\n", str)
}

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

// if C == 00
// Set the quiet flag to be false
//
// if C == 01
// Set the quiet flag to be true
//
// If C == 0xFF
// Return the statues of the flag in C (0 = quiet, 1 = non-quiet)
//
// Set the quiet flag
// Return the statues of the flag in C
// (1 = quiet, 0 = non-quiet)

if c == 0x00 {
cpm.SetQuiet(true)
cpm.SetQuiet(false)
}
if c == 0x01 {
cpm.SetQuiet(false)
cpm.SetQuiet(true)
}
if c == 0xFF {
if cpm.GetQuiet() {
cpm.CPU.States.BC.Lo = 0x00
} else {
cpm.CPU.States.BC.Lo = 0x01
} else {
cpm.CPU.States.BC.Lo = 0x00
}

}

// Get terminal size in HL
case 0x0005:
width, height, err := term.GetSize(int(os.Stdin.Fd()))
if err != nil {
Expand Down
Binary file modified static/A/QUIET.COM
Binary file not shown.
37 changes: 19 additions & 18 deletions static/quiet.z80
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,28 @@ BDOS_OUTPUT_STRING: EQU 9
cp '1'
jr z, set_quiet
cp '0'
jr z, set_non_quiet
jr z, unset_quiet

;; unknown argument
LD DE, WRONG_ARGUMENT
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
jr exit

jr unknown_argument


set_non_quiet:
set_quiet:
ld c, 0x01
jr set_quiet_middle

set_quiet:
unset_quiet:
ld c, 0x00
set_quiet_middle:
ld HL, 0x04
ld a, 31
out (0xff), a
jr exit

;; fall-through

;; get the value of the quiet flag
show_value:
Expand All @@ -70,10 +76,15 @@ show_value:

ld a,c
cp 0x00
jr z,show_quiet_on
jr z,show_quiet_off
cp 0x01
jr z, show_quiet_off
jr show_quiet_wtf
jr z, show_quiet_on
;; fall-through

LD DE, QUIET_MODE_UNKNOWN
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
;; fall-through

;; Exit
exit:
Expand All @@ -93,20 +104,10 @@ show_quiet_on:
call BDOS_ENTRY_POINT
jr exit

show_quiet_wtf:
LD DE, QUIET_MODE_UNKNOWN
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
jr exit

;;
;; Error Routines
;;
unknown_argument:
LD DE, WRONG_ARGUMENT
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
jr exit

not_cpmulator:
LD DE, WRONG_EMULATOR
Expand Down

0 comments on commit 0333b9b

Please sign in to comment.