-
Notifications
You must be signed in to change notification settings - Fork 2
/
copyscreenROM.asm
201 lines (183 loc) · 3.18 KB
/
copyscreenROM.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
194
195
196
197
198
199
200
;Copy a screen from 16384 to OZ Map
;Needs to be reworked for each game..
;Rewriting so can ROM it..
;
;Now fixed for Lemmings (redundant code also removed!)
MODULE screen
SECTION code
INCLUDE "interrpt.def"
XREF cksound
XREF myflags
XREF varbase
XREF ozbank
XREF ozaddr
XREF screen
XDEF ozscrcpy
XDEF ozscrcpy_noc
XDEF oztitlecopy
;Myflags
;bit 0 = sound on/off
;bit 1 = title music
;bit 2 = samples
;bit 3 = resoluion
;bit 4 = inverse
.oztitlecopy
ld a,(myflags)
push af
ld a,(varbase+27)
push af
xor a
ld (myflags),a
ld (varbase+27),a
call ozscrcpy_noc
pop af
ld (varbase+27),a
pop af
ld (myflags),a
ret
.ozscrcpy
call cksound ;might as well do it here!
.ozscrcpy_noc
ld hl,$4D1
ld a,(hl)
push af
ld a,(varbase+27)
ld d,a
ld a,(myflags)
ld e,a
ld a,(ozbank)
ld (hl),a
ld bc,(ozaddr)
push bc
out ($D1),a
ld b,d ;varbase
ld a,e ;myflags
ld de,ozfullcpy
bit 3,a ;bit 3
jr z,ozskhalf
ld de,ozhalfcpy
.ozskhalf
exx
ld c,0
bit 4,a
jr z,ozskinv
ld c,255
.ozskinv
pop hl ;screen address
exx
call oz_di
push af
call ozcallch
pop af
call oz_ei
pop af
ld ($4D1),a
out ($D1),a
ret
.ozcallch
push de
ret
.ozfullcpy
ld a,b ;varbase+27
rrca
rrca
rrca
and 15
cp 12
jr c,scrcpya
ld a,11
.scrcpya
sub 3
jr nc,scrcpy0
xor a
.scrcpy0
ld b,a
ld c,8
.scrcpy1
push bc
ld a,b
and 248
add a,+(screen/256)
ld d,a
ld a,b
and 7
rrca
rrca
rrca
ld e,a
;OZ screen is handled like characters..grrr!
ld c,32
.scrcpy2
ld b,8
push de
.scrcpy3
ld a,(de)
exx
xor c
ld (hl),a
inc hl
exx
inc d
djnz scrcpy3
pop de
inc e
dec c
jp nz,scrcpy2
pop bc
inc b
.scrcpy36
ex af,af
dec c
jp nz,scrcpy1
ret
;Screen copy for half size
.ozhalfcpy
ld de,screen
.ozhalfcpy1
ld b,4
.ozhalfcpy2
ld a,(de)
exx
xor c
ld (hl),a
inc hl
exx
inc d
inc d
djnz ozhalfcpy2
ld a,d
sub 8
ld d,a
ld a,e
add a,32
ld e,a
ld b,4
.ozhalfcpy3
ld a,(de)
exx
xor c
ld (hl),a
inc hl
exx
inc d
inc d
djnz ozhalfcpy3
ld a,d
sub 8
ld d,a
ld a,e
sub 31
ld e,a
and 31
jp nz,ozhalfcpy1
ld a,e
add a,32
ld e,a
and a
jp nz,ozhalfcpy1
ld a,d
add a,8
ld d,a
cp 32+16
jp c,ozhalfcpy1
ret