-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmg-asm-analysis.txt
282 lines (248 loc) · 5.54 KB
/
mg-asm-analysis.txt
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
mg screen stuff...
Code for picking up items: 8fdb
don't act on p-bomb, min, missile, ration, ammo.
for weapons, hl = c520; for equipment, hl = c5a0 and a -= 8
hl[a-1] = 1: found object
41df: hl += 2*a
41e0: hl += a
41e5: de += a
41ea: jp (sp[2a])
4248: *** set pages 1, 2, 3 ***
424e: *** set pages 4, 5, 6 *** (store values at 0xf0f1 too)
426a: *** set pages 7, 8, 9 ***
4270: *** set pages a, b, c ***
4276: *** set pages d, e, f ***
42b4: *** de = de[a]
42d4: *** read nybble from hl[a] -> a *** {{{
c=a
hl += a / 2
a=(hl)
if c & 1:
a >>=4
a &= 0x0f
}}}
Palette stuff {{{
4ab5: pages a,b,c
a=6185[room]
pages 4,5,6
de=8cb4
set palette hl[a]
return 1,2,3
4acb: set palette for room (4,5,6:8b40 or special for no light/ir goggles) {{{
hl = 8b40
pages 4,5,6
b = room
if room == 0xfb: # this room does not exist?!
goto 4aff # No goggles
if room in (0xdc, 0xdd): # Middle of dark corridor
goto 4ae9
if not 0x7b <= room <= 0x7e: # Rest of dark corridor
goto 4af4
4ae9: *c135 (selected item) == 3 (light): goto 4af4
4af4: *c135 (selected item) != 4 (goggl): goto 4aff
4aff: No special lights
read nybble from 8b40[room]
set pages 4,5,6
hl = 8bbe[a]
set palette from hl:
while True:
a = *hl++
if a == 0xff: return
de = *hl++
4e66: set palette data for color a to de (rb:g)
return with pages 1,2,3
}}}
goggles: a = 0xa
dark: a = 0xb
normal: a = 456:8b40[room] (nybble)
4a92:
set pages 4,5,6
set_palette(0x8b0b)
4a66 = 4248: set pages 1,2,3; return
4b09:
set palette(hl[a])
return pages 1,2,3
4ec4: *** Set palette from *hl *** (store values in vram at 0x.... too) {{{
while True:
a=*hl++
if a == 0xff: return
de = *hl++++
call 4e66
}}}
4e66: *** Set single palette value *** {{{
[0x99] = a
[0x99] = 0x90 register 16: palette address
[0x9a] = d palette data
[0x9a] = e palette data
hl = 0xf680 + 2 * a
call 4d93 write to vram at hl
[0x99] = d
[0x99] = e
}}}
}}}
4d93: *** Prepare vdp for vram write at hl *** {{{
[0x99] = (h >> 6) & 3
[0x99] = 0x8e register 14: top vram address bits
[0x99] = l
[0x99] = (h & 0x3f) | 40 write data to this address
}}}
4ed2: *** Wait for vdp command to complete ***
5011: vdp copy vram to vram {{{
src: 0:h, a[6:7]:l
dst: 0:d, a[5:4]:e
cnt: 0:b, 0:c
col: 0
arg: 0
cmd: 0x90 | a[3:0] (vram copy; filter type)
}}}
4acb: set palette for room tiles
42bd: hl = 4*(a-1)
42d1: read nybble from hl[room]
4cf0: draw screen {{{
4276: set d,e,f
4e1b: clear screen with hmmv
42b1 (de=0x6000): de = de[room]
4c9a:
ec06 = loop counter (8 blocks)
ec00 = dest pointer
ec04 = src pointer for block list
a = 61f6[room] (nybble)
de = 6274[a-1]
ec02 = src pointer for block content
a = *ec04
*ec04 += 1
hl = de + 16 * (a-1)
copy hl->de (4x4)
in pages d,e,f
copy hl to de, de = e000, hl = 6a60
ec04 = hl = 6000[room] (word)
a = 61f6[room] (nybble)
ec02 = 6274[a-1]
hl = (ec02) + 16 * ((++ec04) - 1)
hl = 84b0
}}}
4935: write charset {{{
42c4: ldir(src=4b13, dst=e700,cnt=8)
426a: page 7,8,9
a=nybble 6000[room]
if a==c157: return
4bbc:
pages d,e,f
42c4: ldir(src=4b13, dst=e700,cnt=8)
524c(hl=b2bf,de=9048,b=4) Write lift buttons.
426a: page 7,8,9
ix = 607e[a]
3*:
ix[0].7 ? ->skip
49a7:
ix[0].6 ? -> other stuff:
b = last_b
hl = 49df(a = ix[1])
de = last_de
5265: b*:
hl'=e708
527e (build character from hl)
50b1(hl=e707, b=1): b*:
8*:
nybble-swap e707[0:4]->ec43[::-1]
de += 8
5087 (hl = 0xec40) (write char from hl to vram de)
de += 4 with weird overflow (next character)
b = ix[1]
49df(a = ix[2]):
hl = 8000 + (a & 0xe0) << 5 + (a & 0x1f) << 2
de = hl
hl = ix[3:4]
524c: build b characters from hl to vram de
for _ in range(b):
hl' = e708
527e: 8*
e=*hl++
d=*hl++
c=*hl++
4*:
e=00000cde (bits 7 of all)
d=e7
c'=*de * 16
e=00000cde (bits 6 of all)
d=e7
*hl'++ = c' | *de
509c(hl = e708, b=1): b*
5087: write character from hl to vram de
8*:
4d59(bc=4): write bc bytes to vram hl
4d93: write to vram at hl
4d51: a = b + (c != 0); b = c
98 << *hl * bc
de += 4 for next character
}}}
4b33: draw items
4bcf:
pages 7,8,9
42c4: set palette
draw boxes and mirorred boxes
return 1,2,3
pages 4,5,6
42c7: set palette
write characters (hl=a75d, de=b000, b=0x84)
5fa6:
4a9d:
(pages=1,2,3)
hl=4aa3
4ec4: set palette from *hl
41e5: de += a
store *(c450 + door - 1)
*(b046 + door - 1)
1 2 1 gas mask
2 41 elevator
3 5 4 courtyard prisoner
4 5 4 exit courtyard
5 5 4 doorsteek
6 45 4 exit building 1
7 5 4 petro gone
8 42 1 prisoner
9 3 2 smg
a 43 2 prisoner
b 41 elevator
c 2f f secret cell exit
d 7 6 north
e 7 6 ellen
f 4 3 shoot gunner
10 30 b uniform
2-9: need card 1-8, remains open
b (69)
d: jennifer (compass)
e: auto open at event (mg dead; big boss dead)
10: explode
2f: punch
30: explode
41: elevator
42-49: need card 1-8, auto close
81: already open
8a: moving lorry?
8b: lorry
4c: uniform
4411: read doors in new screen.
de = 0xa7c0[2*a]
hl = c3d0
++ix[0]
c=*de
*hl++ = *de++
*hl++ = c450[c-1]
*hl++ = b046[c-1] ; door type.
*hl++ = *de++
if de[-1] == 6:
hl[-2] = de[-1]
*hl++ = 0
*hl++ = *de++
*hl++ = *de++
; do something with a720[2*(a-1)]
find door drawing...
771c: read c3d1
7722: read c3d3
7725: read c3d5
7728: read c3d6
5011: draw door character: hl = src; de = dst; bc = size; a = high y bits and operation (h,0,l,a[6:7]; d,0,e,a[4:5]; b,0,c,0; 0,0,0x90|a[0:3]
77d8: draw N door
77f3: draw S? door
7738: draw door with jump map @773c