-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinput.z80
More file actions
88 lines (70 loc) · 2.03 KB
/
Copy pathinput.z80
File metadata and controls
88 lines (70 loc) · 2.03 KB
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
;; input.z80 - Set the name of the console driver to use for input.
;;
;; 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.
;;
BDOS_ENTRY_POINT: EQU 5
BDOS_OUTPUT_STRING: EQU 9
CMDLINE: EQU 0x80 ; default DMA area too
;;
;; CP/M programs start at 0x100.
;;
ORG 100H
;; Copy the DMA area, which holds our command-line
;; flags, to a safe area at the foot of our binary.
;;
LD HL, CMDLINE
LD DE, DEST
LD BC, 128
LDIR
;;
;; Now we can test if we're running under cpmulator
;; which will trash the DMA area
;;
call exit_if_not_cpmulator
;;
;; If we didn't get an argument then show the driver
;;
LD HL,DEST
LD A,(HL)
INC HL
CP 0x00
JR Z,show_value
;; OK we're running under cpmulator, and we did get a parameter
;; Point DE to that and invoke the function.
;;
;; DEST+0 contains the length of the command-line. i.e. pascal-string
;; DEST+1 contains " "
;; DEST+2 contains the argument, assuming no extra space.
;;
ld HL, 07
ld de, DEST+2
ld a, 31
out (0xff), a
exit:
RST 0x00
;; Show the current value
show_value:
LD DE, CONSOLE_PREFIX ; Print a prefix
LD C, BDOS_OUTPUT_STRING
CALL BDOS_ENTRY_POINT
;; Use the given function to call a custom BIOS
;; routine which will the result as ASCII text
;; in the DMA-buffer.
ld hl, 0x0007
call show_bios_value
LD DE, CONSOLE_SUFFIX ; Print a suffix
LD C, BDOS_OUTPUT_STRING
CALL BDOS_ENTRY_POINT
jr exit
;;
;; Text output strings.
;;
CONSOLE_PREFIX:
db "The input driver is set to $"
CONSOLE_SUFFIX:
db ".", 0x0a, 0x0d, "$"
include "common.inc"
;; Copied area
DEST:
END