From 7c2cbbe4f8371aacbeb77e633b11269cf47bc27d Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 24 Jun 2024 09:25:39 +0300 Subject: [PATCH] Updated the quiet-flag to be more logical Now the quiet flag behaves in a more predictable way, being 1 when quiet mode is active - rather than zero. This closes #136 --- EXTENSIONS.md | 10 +++++----- cpm/cpm_bios.go | 39 +++++++++++++++++++-------------------- static/A/QUIET.COM | Bin 293 -> 285 bytes static/quiet.z80 | 37 +++++++++++++++++++------------------ 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/EXTENSIONS.md b/EXTENSIONS.md index 121993a..904e809 100644 --- a/EXTENSIONS.md +++ b/EXTENSIONS.md @@ -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. diff --git a/cpm/cpm_bios.go b/cpm/cpm_bios.go index 2a91d76..447cc3b 100644 --- a/cpm/cpm_bios.go +++ b/cpm/cpm_bios.go @@ -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 @@ -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 := "" @@ -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' @@ -200,6 +192,7 @@ 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()) @@ -207,6 +200,7 @@ func BiosSysCallReserved1(cpm *CPM) error { cpm.input.SetInterruptCount(int(c)) } + // Get/Set the console driver. case 0x0002: if de == 0x0000 { @@ -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 { @@ -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 { diff --git a/static/A/QUIET.COM b/static/A/QUIET.COM index c857f1ebfccb0fc0299315725290bf83c0b2f2eb..10b1bd9c749fd39cd75f52eb7eecdcdce94f2841 100644 GIT binary patch delta 135 zcmZ3=G?%Gfk%7TZ{__8S5eg|a|AH0bYyWvGL|Mf${8Kn(!}!logYTb#2A^OhBOm8k zRt5=mK1K;9J_bb=uqM9$P)6lH1`WY~j2hyC?;#5L7=Wq;Z$Wi^6g&oHJs0eQvhIc! MC#I)bO>CbB0A3y`SpWb4 delta 138 zcmbQsw3Mk{k%7TZ{__8S5ehjq|AH0LYyWvGBw58W{8Kn(#`w=rgX^Dx29tyvAEN{l zAA=$bSh0i%-+w5x@*jhS=s!jcb_q#7hO?{;f{z&aIDxdpN5OMY)^ow{P}W_+MkwpD O;4}z}N#f+h$|V5vcPWYh diff --git a/static/quiet.z80 b/static/quiet.z80 index a979401..a731bd5 100644 --- a/static/quiet.z80 +++ b/static/quiet.z80 @@ -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: @@ -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: @@ -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