-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
quiet.z80
130 lines (108 loc) · 2.82 KB
/
quiet.z80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
;; quiet.asm - Enable quiet-mode
;;
;; This uses the custom BIOS function we've added to the BIOS, which was never
;; present in real CP/M. Consider it a hook into the emulator.
;;
;; Quiet mode stops the display of the version-banner when reloading the CCP
;;
FCB1: EQU 0x5C
BDOS_ENTRY_POINT: EQU 5
BDOS_OUTPUT_STRING: EQU 9
;;
;; CP/M programs start at 0x100.
;;
ORG 100H
;; Test that we're running under cpmulator by calling the
;; "is cpmulator" function.
ld HL, 0x0000
ld a, 31
out (0xff), a
;; We expect SKX to appear in registers HLA
CP 'X'
jr nz, not_cpmulator
LD A, H
CP 'S'
jr nz, not_cpmulator
LD A, L
CP 'K'
jr nz, not_cpmulator
;; The FCB will be populated with the number/first argument,
;; if the first character of that region is a space-character
;; then we've got nothing specified
ld a, (FCB1 + 1)
cp 0x20 ; 0x20 = 32 == SPACE
jp z, show_value ; Got a space, just show the value.
;; Otherwise we set
cp '1'
jr z, set_quiet
cp '0'
jr z, set_non_quiet
jr unknown_argument
set_non_quiet:
ld c, 0x01
jr set_quiet_middle
set_quiet:
ld c, 0x00
set_quiet_middle:
ld HL, 0x04
ld a, 31
out (0xff), a
jr exit
;; get the value of the quiet flag
show_value:
ld c, 0xff
ld HL, 0x04
ld a, 31
out (0xff), a
ld a,c
cp 0x00
jr z,show_quiet_on
cp 0x01
jr z, show_quiet_off
jr show_quiet_wtf
;; Exit
exit:
LD C,0x00
CALL BDOS_ENTRY_POINT
show_quiet_off:
LD DE, QUIET_MODE_OFF
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
jr exit
show_quiet_on:
LD DE, QUIET_MODE_ON
LD C, BDOS_OUTPUT_STRING
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
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
jr exit
;;
;; Text output strings.
;;
WRONG_ARGUMENT:
db "Usage: QUIET [0|1]", 0x0a, 0x0d, "$"
WRONG_EMULATOR:
db "This binary is not running under cpmulator, aborting.", 0x0a, 0x0d, "$"
QUIET_MODE_ON:
db "Quiet mode is on.", 0x0a, 0x0d, "$"
QUIET_MODE_OFF:
db "Quiet mode is off.", 0x0a, 0x0d, "$"
QUIET_MODE_UNKNOWN:
db "Failed to determine the state of quiet mode", 0x0a, 0x0d, "$"
END