This repository was archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzxedit2.asm
More file actions
219 lines (173 loc) · 3.62 KB
/
Copy pathzxedit2.asm
File metadata and controls
219 lines (173 loc) · 3.62 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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
ERR_SP equ 0x5c3d ; BASIC system variables
ERR_NR equ 0x5c3a
PROG equ 0x5c53
NEWPPC equ 0x5c42
NSPPC equ 0x5c44
VARS equ 0x5c4b
NXTLIN equ 0x5c55
RST_HOOK equ 8
__ESXDOS_SYS_M_GETSETDRV equ 0x89
HOOK_VERSION equ 0xfc
org 0x8000
jp getDiskIO
memoryType:
defb 0
jp (hl)
;-------------------------------------
; getDiskIO
getDiskIO:
;check for residos. if it's not present then continue on to the check for esxdos
ld a,(0x12a0)
cp 0xcf
jr nz, esxcheck
ld a,(0x12a1)
cp 0xfe
jr z, resicheck
;-------------------------------------
; esxcheck
esxcheck:
push ix
push iy
; temporarily route error handling back here
ld hl, (ERR_SP)
push hl ; save the existing ERR_SP
ld hl, esxfail
push hl
ld hl, 0
add hl, sp
ld (ERR_SP), hl
xor a ; ld a, 0
rst RST_HOOK
defb __ESXDOS_SYS_M_GETSETDRV
pop hl ; if the code doesn't work, comment out this line
jr esxcont
esxfail:
xor a ; ld a, 0
esxcont:
pop hl
ld (ERR_SP), hl
pop iy
pop ix
cp 0
jp z, plus3check
; is 128k present?
;ld a, (memoryType)
;cp 0
;jr nz, esxgot128
; '4'
;...
;jp reenter
;esxgot128:
; '5'
jp reenter
;-------------------------------------
; resicheck
resicheck:
ld hl, (ERR_SP)
push hl ; save the existing ERR_SP
ld hl, resicont
push hl ; stack error-handler return address
ld hl, 0
add hl, sp
ld (ERR_SP), hl ; set the error-handler SP
rst RST_HOOK ; invoke the version info hook code
defb HOOK_VERSION
pop hl ; ResiDOS doesn't return, so if we get
jr plus3check ; here, some other hardware is present
resicont:
pop hl
ld (ERR_SP), hl ; restore the old ERR_SP
ld a, (ERR_NR)
inc a ; is the error code now "OK"?
jr nz, plus3check ; if not, ResiDOS was not detected
ex de, hl ; get HL=ResiDOS version
ld de, 0x0140 ; DE=minimum version to run with
and a
sbc hl, de
jr c, plus3check
ld a, 0xff
ld (ERR_NR), a ; clear er
; is 128k present?
;ld a, (memoryType)
;cp 0
;jr nz, resigot128
; '2'
;jp reenter
;resigot128:
; '3'
ld hl, loadPrefix
ld a, $25 ; '%'
ld (hl), a
ld hl, loadPostfix
ld a, $72 ; 'r'
ld (hl), a
jp reenter
;-------------------------------------
; plus3check
plus3check:
ld a, 0xff
ld (ERR_NR), a ; clear error
; is plus3dos present?
ld a, (memoryType)
cp 2
jr nz, plus3fail
; '1'
ld hl, loadPrefix
ld a, $20 ; ' '
ld (hl), a
ld hl, loadPostfix
ld a, $70 ; p
ld (hl), a
jp reenter
plus3fail:
; if its not then show a message
ld bc, failProgEnd-failProg
ld de, failProg
jr loadBasic
reenter:
ld bc, newProgEnd-newProg
ld de, newProg
loadBasic:
;set NEWPPC to $000a (line 10)
ld hl, $000a
ld (NEWPPC), hl
;set NSPPC to 0 (first statement on line 10)
push af
ld a, 0
ld (NSPPC), a
pop af
;set VARS to prog + (newProgEnd-newProg)
ld hl, (PROG)
add hl, bc
ld (VARS), hl
;set NXTLIN to prog + (newProgEnd-newProg) - 2
dec hl
dec hl
ld (NXTLIN), hl
;copy the new program
ld hl, (PROG)
ex de, hl
di
ldir
ei
;restore original registers
ld a, 0xff
ld (ERR_NR), a
pop hl
pop de
pop af
ret
newProg:
;10 CLEAR VAL "32767":LOAD *"ed-e.bin"CODE:RANDOMIZE USR VAL "32768"
defb $00, $0a, $27, $00, $fd, $b0, $22, $33, $32, $37, $36, $37, $22, $3a
defb $ef
loadPrefix:
defb $2a, $22, "ed"
loadPostfix:
defb "e.bin", $22, $af, $3a
defb $f9, $c0, $b0, $22, $33, $32, $37, $36, $38, $22, $0d, $ff, $0d, $80
newProgEnd:
failProg:
;10 PRINT "Either ESXDOS, ResiDOS v1.40+ or PLUS3DOS is required"
defb $00, $0a, $39, $00, $f5, $22, "Either ESXDOS, ResiDOS v1.40+ or PLUS3DOS is required", $22, $0d, $ff, $0d, $80
failProgEnd: