-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsavelow.s
More file actions
149 lines (120 loc) · 2.62 KB
/
savelow.s
File metadata and controls
149 lines (120 loc) · 2.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
; Duke - 2021
;
; Lower rom(s) dumper (assemble with RASM)
; Short example of using the newly introduced C_ROMLOW (0x433D) command in v.2.0.7 firmware
; With this you can toggle between the SYSTEM lower rom, the M4 board lower rom and the HACK-menu lower rom
;
org 0x4000
nolist
DATAPORT equ 0xFE00
ACKPORT equ 0xFC00
km_wait_key equ 0xBB18
txt_output equ 0xBB5A
txt_set_column equ 0xBB6F
scr_reset equ 0xBC0E
scr_set_ink equ 0xBC32
scr_set_border equ 0xBC38
cas_in_open equ 0xBC77
cas_in_close equ 0xBC7A
cas_in_char equ 0xBC80
cas_out_open equ 0xBC8C
cas_out_close equ 0xBC8F
cas_out_char equ 0xBC95
cas_out_direct equ 0xBC98
kl_init_back equ 0xBCCE
; re-init M4rom
ld de,0x40
ld hl,0xB0FF
call 0xBCCB
; setup screen
ld a,2
call scr_reset ; set mode 2
xor a
ld b,a
call scr_set_border
xor a
ld b,a
ld c,b
call scr_set_ink
ld a,1
ld b,26
ld c,b
call scr_set_ink
ld a,20
call txt_set_column
ld hl,txt_title
call wrt
ld a,2
call copy_lower_rom
ld hl,filename3
call save_file
ld a,1
call copy_lower_rom
ld hl,filename2
call save_file
ld a,0
call copy_lower_rom
ld hl,filename1
call save_file
ld hl,txt_done
call wrt
jp km_wait_key ; wait and reset
; copy lowerrom to 0x5000
copy_lower_rom:
di
ld de,0x433D ; C_ROMLOW
ld bc,DATAPORT ; data out port
out (c),c ; ignore size, its not used.
out (c),e ; command lo
out (c),d ; command hi
out (c),a ; 0 = system lower, 1 = m4 board loader, 2 = hack rom
ld bc,ACKPORT
out (c),c
ld bc,0x7F8A ; enable lowerrom
out (c),c
ld hl,0
ld de,0x5000
ld bc,0x4000
ldir
xor a
ld de,0x433D ; C_ROMLOW
ld bc,DATAPORT ; data out port
out (c),c ; ignore size, its not used.
out (c),e ; command lo
out (c),d ; command hi
out (c),a ; 0 = system lower
ld bc,ACKPORT
out (c),c
ld bc,0x7F8E
out (c),c ; disable lowerrom
ei
ret
save_file:
ld de,buf
ld b,12
call cas_out_open
ld hl,0x5000 ; addr
ld de,0x4000 ; len
ld bc,0 ; exec
ld a,2 ; bin
call cas_out_direct
call cas_out_close
ret
wrt:
ld a,(hl)
or a
ret z
call txt_output
inc hl
jr wrt
filename1:
db "rom-lsys.rom"
filename2:
db "rom-lwm4.rom"
filename3:
db "rom-hack.rom"
txt_title:
db "Lower rom(s) dumper - Duke 2021",10,13,10,13,0
txt_done:
db 10,13,10,13,"Done! Power-cycle CPC",0
buf: ds 2048