Repository navigation
Expand file tree
/
Copy pathshadowload.asm
More file actions
75 lines (58 loc) · 2.29 KB
/
Copy pathshadowload.asm
File metadata and controls
75 lines (58 loc) · 2.29 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
;DSTR1: equ 0x5CD6 ; extended sysvar - D_STR1 - 2-byte drive number
NSTR1: equ 0x5CDA ; extended sysvar - N_STR1 - 2-byte name length
FSTR1: equ 0x5CDC ; extended sysvar - F_STR1 - Address of filename
HD11: equ 0x5CED ; address of a routine to call w/ Shadow ROM in
CHECKM2: equ 0x066D ; check drive number is 1–8 (Shadow ROM routine)
start: equ 0x8000
org start
rst 8 ; hook code 0x31
db 0x31 ; "create sys vars"
exx
push hl ; save HL' for ret to BASIC
exx
ld hl,CHECKM2 ; routine to test whether DSTR1=[1..8]
ld (HD11),hl ; store address in HD11
rst 8 ; hook code 0x32
defb 0x32 ; "Shadow ROM"
ld hl,(fnlen) ; get filename length
ld (NSTR1),hl ; store it in sysvar NSTR1
ld hl,fnloc ; get filename location
ld (FSTR1),hl ; store it in sysvar FSTR1
rst 8 ; hook code 0x22
db 0x22 ; "Open M channel" (i.e. "open file")
ld hl,shady ; pointer to our custom routine
ld (HD11),hl ; store address in HD11
rst 8 ; hook code 0x32
defb 0x32 ; "Shadow ROM"
shady:
defb 0xE1 ; [pop hl] remove 0x0700 from stack
defb 0xE1 ; [pop hl] remove shadowbusiness from stack
;; ---------------------------------------------------------------------
;; IF1 ROM version-independent code by JPNZ
;; https://spectrumcomputing.co.uk/forums/viewtopic.php?p=177887#p177887
;; ---------------------------------------------------------------------
ld hl,(0x00E5) ; fetch AUTO-RUN/LOAD-RUN address
ld bc,0x002E ; step back 46 instructions to GETBL/LV-ANY
sbc hl,bc ; calculate
ld e,(hl) ; fetch lsb of call to GETMBL/LV-MCH
inc hl ; move on
ld d,(hl) ; fetch msb of call to GETMBL/LV-MCH
ex de,hl ; exchange
ld bc,0x0010 ; step back a further 16 instructions to LOAD25/F-HD-3
sbc hl,bc ; calculate
ld (smc1+1),hl ; and insert
ld bc,0x0013 ; step forward to GETMBL/LV-MCH +3
adc hl,bc ; calculate
ld (smc2+1),hl ; and insert
smc1: call 0x0000 ; call LOAD25/F-HD-3
smc2: call 0x0000 ; call GETMBL/LV-MCH +3
call 0x0700 ; page Shadow ROM out
rst 8 ; hook code 0x23
db 0x23 ; "Close M channel" (i.e. close file; also stops motor)
exx
pop hl ; restore HL' for BASIC
exx
ret ; back to BASIC
fnloc: db "example " ; name of file to load (max 10 characters)
fnlen: dw 7 ; length of filename (word even tho max is 10)
end start