forked from z80playground/cpm-fat
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbios.asm
193 lines (171 loc) · 4.35 KB
/
bios.asm
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
; BIOS for CP/M v2.2 on Z80 Playground v1.2
;
; This occupies less than 0.5K
include "locations.asm"
include "core_jump.asm"
org BIOS_START
bios_entry:
JP BOOT ;COLD START
WBOOTE:
JP WBOOT ;WARM START
JP CONST ;CONSOLE STATUS
JP CONIN ;CONSOLE CHARACTER IN
JP CONOUT ;CONSOLE CHARACTER OUT
JP LIST ;LIST CHARACTER OUT
JP PUNCH ;PUNCH CHARACTER OUT
JP READER ;READER CHARACTER OUT
JP HOME ;MOVE HEAD TO HOME POSITION
JP SELDSK ;SELECT DISK
JP SETTRK ;SET TRACK NUMBER
JP SETSEC ;SET SECTOR NUMBER
JP SETDMA ;SET DMA ADDRESS
JP READ ;READ DISK
JP WRITE ;WRITE DISK
JP LISTST ;RETURN LIST STATUS
JP SECTRAN ;SECTOR TRANSLATE
BOOT:
ld sp, BIOS_STACK
call CORE_message
db 27,'[2J' ; clear screen
db 27,'[H' ; cursor home
db 27,'[0m' ; clear attributes
db 27,'[?25h' ; Show cursor
db 'CP/M v2.2',13,10
db 'Z80 Playground - 8bitStack.co.uk',13,10
db 'Rel 1.10',13,10
db 'Inspired by Digital Research',13,10
db 13,10
db '64K system with drives A thru P',13,10
db 13,10
db 0
call CORE_message
db 'CORE ',0
ld hl, CORE_START
call CORE_show_hl_as_hex
call CORE_newline
call CORE_message
db 'BIOS ',0
ld hl, BIOS_START
call CORE_show_hl_as_hex
call CORE_newline
call CORE_message
db 'BDOS ',0
ld hl, BDOS_START
call CORE_show_hl_as_hex
call CORE_newline
ld hl, ccp_name
show_ccp_name_loop:
ld a, (hl)
cp 0
jr z, shown_ccp_name
call CORE_print_a
inc hl
jr show_ccp_name_loop
shown_ccp_name:
call CORE_space
ld hl, (ccp_location)
call CORE_show_hl_as_hex
call CORE_newline
call CORE_rom_off
call CORE_user_off
; Set the drive and user to 0
xor a
ld (UDFLAG), a
; Roll through to the warm boot...
WBOOT:
ld sp, BIOS_STACK
call CORE_message
db 27,'[0m',0 ; clear attributes
;call CORE_message
; Load the CCP to the proper location
ld hl, ccp_name
call CORE_copy_filename_to_buffer
ld de, (ccp_location)
call CORE_load_bin_file
; Load the BDOS to the proper location - so we can do disk access etc
ld hl, NAME_OF_BDOS
call CORE_copy_filename_to_buffer
ld de, BDOS_START
call CORE_load_bin_file
; Pass the current drive and user to the CCP to start it
ld a, (UDFLAG)
ld c, a
ld hl, (ccp_location)
inc hl
inc hl
inc hl
jp (hl) ; Note this means jump to hl, not jump to (hl)
CONST:
; RETURN 0FFH IF CHARACTER READY, 00H IF NOT
in a,(uart_LSR) ; get status from Line Status Register
bit 0,a ; zero flag set to true if bit 0 is 0 (bit 0 = Receive Data Ready)
; "logic 0 = no data in receive holding register."
jp z,CONST1 ; zero = no char received
ld a, $FF ; return true
ret ; in A
CONST1:
xor a ; Return a zero in A
ret
CONIN:
; CONSOLE CHARACTER INTO REGISTER A
in a,(uart_LSR) ; get status from Line Status Register
bit 0,a ; zero flag set to true if bit 0 is 0 (bit 0 = Receive Data Ready)
; "logic 0 = no data in receive holding register."
jp z,CONIN ; zero = no char received
in a,(uart_tx_rx) ; Get the incoming char
ret
CONOUT:
ld a, c
call CORE_print_a
ret
LIST:
jp CONOUT
PUNCH:
jp CONOUT
READER:
ld a, 'R'
jp BIOS_MOAN
HOME:
ld a, 'H'
jp BIOS_MOAN
SELDSK:
ld a, 'D'
jp BIOS_MOAN
SETTRK:
ld a, 'T'
jp BIOS_MOAN
SETSEC:
ld a, 'S'
jp BIOS_MOAN
SETDMA:
ld a, 'D'
jp BIOS_MOAN
READ:
ld a, '<'
jp BIOS_MOAN
WRITE:
ld a, '>'
jp BIOS_MOAN
LISTST:
ld a, ':'
jp BIOS_MOAN
SECTRAN:
ld a, '+'
jp BIOS_MOAN
BIOS_MOAN:
call CORE_message
db 'BAD BIOS CALL: ',0
call CORE_print_a
call CORE_newline
jp $0000 ; Totally abandon anything after a bad BIOS call!
NAME_OF_BDOS:
db 'BDOS.BIN',0
NAME_OF_BIOS:
db 'BIOS.BIN',0
BIOS_STACK_START:
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
BIOS_STACK:
db 0,0
UDFLAG EQU 4 ;current drive name and user number.