blob: e4f7e49c3a2c604460557f878b31f32d8899fa0c (
plain)
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
#include "dos_lemm_sim.h"
#include "utils.h" /* imin() */
uint8_t is_solid(uint16_t x, uint16_t y);
// Code segment 0x0208, offsets in comments
void move_lemmings(struct game_data *g) {
uint8_t *g_raw = (uint8_t *) g;
struct _lemm_data *lemm;
uint8_t *lemm_raw;
uint16_t y_test=0x55AA; //=21930 remarkable value if we hit a bug
int i;
//182F
if ( g->paused ) {
g_raw[0x4d] = FALSE;
return;
}
//1839
//TODO vga_set_read_mode1_compare_plan3_to_color_8();
//183C
g_raw[0x4d] = TRUE;
//1841
lemm=&(g->lemmings[0]);
lemm_raw = (uint8_t *) lemm; // Instrumentation
// Replaced (instrumentation)
//g->lemm_count_to_process = g->lemm_spawned_count;
g->lemm_count_to_process = imin(g->lemm_spawned_count, (sizeof(g->lemmings) / sizeof(struct _lemm_data)));
//184A
while ( g->lemm_count_to_process != 0 ) {
//XXX push es
//1852
if ( lemm->is_gone ) {
goto next_lemming;
}
//185B
if ( lemm->expl_countdown != 0 ) {
//TODO if ( commit_suicide() != FALSE ) goto next_lemming;
}
//186A
if ( lemm->flags1.bits.walk_pause_for_shruggling ) {
goto lbl_anim_but_no_move;
}
//1877
if ( lemm->state.raw == 0x0 ) goto lbl_walking;
if ( lemm->state.bits.s_exploding_spe ) goto lbl_exploding_spe;
if ( lemm->state.bits.s_exploding ) goto lbl_exploding;
if ( lemm->state.bits.s_falling ) goto lbl_falling;
if ( lemm->state.bits.s_floating ) goto lbl_floating;
if ( lemm->state.bits.s_splatting ) goto lbl_splatting;
if ( lemm->state.bits.s_ascending ) goto lbl_ascending;
if ( lemm->state.bits.s_digging ) goto lbl_digging;
if ( lemm->state.bits.s_climbing ) goto lbl_climbing;
if ( lemm->state.bits.s_climb_ending ) goto lbl_climb_ending;
if ( lemm->state.bits.s_building ) goto lbl_building;
if ( lemm->state.bits.s_blocking ) goto lbl_blocking;
if ( lemm->state.bits.s_bashing ) goto lbl_bashing;
if ( lemm->state.bits.s_mining ) goto lbl_mining;
if ( lemm->state.bits.s_drawning ) goto lbl_drawning;
if ( lemm->state.bits.s_ending ) goto lbl_ending;
if ( lemm->state.bits.s_dying ) goto lbl_dying;
check_this_and_go_next_lemming: //18FE
//TODO process_if_in_special_zone();
next_lemming: //1901
//XXX pop es
lemm++;
g->lemm_count_to_process--;
//1909
if ( g->lemm_count_to_process != 0 ) continue;
//190E
if ( g->nuke_all_in_progress ) {
goto nuke_one_by_one;
}
} //1913 end while
g_raw[0x4d] = FALSE;
//191A
return; // General case end point
nuke_one_by_one: //191B
if ( g->nuke_i == g->lemm_spawned_count ) {
//1952
g->nuke_all_in_progress = 0;
g_raw[0x4d] = FALSE;
return;
}
//1924
lemm=&(g->lemmings[g->nuke_i]);
//1930
if ( lemm->expl_countdown == 0 ) {
//1936
if ( lemm->is_gone ) {
//193C
g->nuke_i++;
goto nuke_one_by_one;
}
//1942
if ( ( lemm->state.raw & (s_exploding | s_splatting | s_exploding_spe) ) == 0 ) {
lemm->expl_countdown = 79;
}
}
//194D
g->nuke_i++;
return;
lbl_walking: //195D
lemm->spr_frame = (lemm->spr_frame + 1) % 8;
lemm->x_effective += lemm->direction;
//196D
if ( lemm->x_effective<16 || lemm->x_effective>=LEVEL_WIDTH ) {
//1A5B
lemm->direction = - lemm->direction;
goto check_this_and_go_next_lemming;
}
//197E
//TODO vga_mem_read_prepare_registers();
y_test = lemm->y_effective;
lemm->y_effective--;//XXX rustine
if ( ! is_solid(lemm->x_effective, y_test) ) {
//19FF
for (i=0;i<3;i++) {
if ( ! is_solid(lemm->x_effective, y_test) ) {
goto walker_adjust_y_or_U_turn;
}
y_test--;
}
//1A26
for (i=0;i<3;i++) {
if ( ! is_solid(lemm->x_effective, y_test) ) {
//1A82
//walker_become_ascender
lemm->state.bits.s_ascending=1;
lemm->spr_frame = 8;
y_test = lemm->y_effective - 2;
goto walker_adjust_y_or_U_turn;
}
y_test--;
}
//1A55
//XXX Seems opposite cond in disassembly
if ( lemm->flags1.bits.cap_climber ) {
//1A92
//walker_become_climber
lemm_raw[0x28]=0;
lemm_raw[0xa]=0;
lemm_raw[0xb]=0;
lemm_raw[0xc]=0;
lemm_raw[0xd]=0;
lemm->state.bits.s_climbing = 1;
lemm_raw[0x10]=0x48;
lemm_raw[0x11]=0x00;
lemm_raw[0x12]=0x30;
lemm_raw[0x13]=0x00;
lemm->x_spr_offset=-8;
lemm->y_spr_offset=-12;
lemm_raw[0x14]=g_raw[0x2d];
lemm_raw[0x15]=g_raw[0x2e];
lemm->draw_trick1 = TRUE;
lemm->draw_hint = 8;
} else {
//1A5B
lemm->direction = - lemm->direction;
}
goto check_this_and_go_next_lemming;
}
//198B
for (i=0; i<3; i++) {
lemm->y_effective++;
if ( is_solid(lemm->x_effective, lemm->y_effective) ) {
goto walker_check_fall_out_of_screen;
}
}
//walker_become_faller: //19AF
lemm->y_effective++;
lemm->state.bits.s_falling=1;
lemm_raw[0xa]=0;
lemm->spr_data_ptr = 0xa42;
lemm_raw[0x10]=0x5a;
lemm_raw[0x11]=0x00;
lemm_raw[0x12]=0x3c;
lemm_raw[0x13]=0x00;
lemm->spr_frame = 0;
lemm->falldist = 3;
lemm->x_spr_offset = -8;
lemm->y_spr_offset = -10;
lemm->draw_hint = hint_falling;
//19DE
lemm->ptr2 = g_raw[0x2b];
lemm->draw_trick1 = FALSE;
lemm->flags1.bits.walk_pause_for_shruggling = 0;
walker_check_fall_out_of_screen: //19EC
y_test = lemm->y_effective;
if ( y_test >= 180 /* LEVEL_HEIGHT + 20 */ ) {
lemm->is_gone=TRUE;
goto next_lemming;
}
//19F5
goto check_this_and_go_next_lemming;
walker_adjust_y_or_U_turn: //1A61
lemm->y_effective = y_test;
if ( y_test + lemm->y_spr_offset <= 10 ) {
//1A6F
lemm->y_effective = 9 - lemm->y_spr_offset;
lemm->direction = -lemm->direction;
lemm->state.bits.s_ascending=0;
}
//1A7F
goto check_this_and_go_next_lemming;
lbl_falling:
//1AC9
lemm->spr_frame = (lemm->spr_frame + 1) % 4;
if ( lemm->falldist >= 16 && lemm->cap_floater ) {
//1ADF
lemm->state.raw = s_floating;
lemm_raw[0xa]=0;
lemm_raw[0xc]=0x0b;
lemm_raw[0xd]=0xaa;
lemm_raw[0x10]=0x80;
lemm_raw[0x11]=0x00;
lemm_raw[0x12]=0x60;
lemm_raw[0x13]=0x00;
lemm->spr_frame = 0;
lemm->floattime_dble = 0;
lemm->y_spr_offset = -16;
lemm->draw_hint = hint_special1;
//1B0A
lemm->ptr2 = g_raw[0x37];
lemm->draw_trick1 = TRUE;
lemm->flags1.bits.walk_pause_for_shruggling = 0;
goto check_this_and_go_next_lemming;
}
//1B1B
//TODO vga_mem_read_prepare_registers();
//TODO
goto check_this_and_go_next_lemming;
lbl_splatting:
//TODO
goto next_lemming;
lbl_drawning:
//TODO
goto next_lemming;
lbl_ending:
//TODO
goto next_lemming;
lbl_dying:
//TODO
goto next_lemming;
lbl_exploding_spe:
//TODO
goto next_lemming;
lbl_ascending:
//TODO
goto walker_adjust_y_or_U_turn;
lbl_digging:
//TODO
goto check_this_and_go_next_lemming;
lbl_climbing:
//TODO
goto walker_adjust_y_or_U_turn;
lbl_climb_ending:
//TODO
goto next_lemming;
lbl_building:
//TODO
goto check_this_and_go_next_lemming;
lbl_blocking:
//TODO
goto next_lemming;
lbl_bashing:
//TODO
goto check_this_and_go_next_lemming;
lbl_floating:
//TODO
goto check_this_and_go_next_lemming;
lbl_mining:
//TODO
goto check_this_and_go_next_lemming;
lbl_exploding:
//TODO
goto next_lemming;
lbl_anim_but_no_move:
//TODO
goto check_this_and_go_next_lemming;
} // 26F5 end move_lemmings()
uint8_t is_solid(uint16_t x, uint16_t y) {
//FIXME : memdump the video memory once at start
return TRUE;
}
void spawn_lemming(struct game_data *g) {
// 0208:299A
//TODO ecrit à l'intuitive, cf disassembly
g->next_spawn_ticks = ( g->next_spawn_ticks - 1) % g->spawn_rate_ticks;
return;
}
void draw_lemmings(struct game_data *g) {
// 0208:2F23
//TODO très incomplet
((uint8_t *) g)[0x4d] = FALSE;
}
void fixups_before(struct game_data *g) {
((uint8_t *) g)[0x4f]++;
}
void fixups_after(struct game_data *g) {
((uint8_t *) g)[0x53] += 0x10;
if ( ((uint8_t *) g)[0x53] == 0xD0 ) {
((uint8_t *) g)[0x53] = 0;
}
//0F4F
if ( ! g->paused ) {
((uint8_t *) g)[0x82]--;
if ( ((uint8_t *) g)[0x82] == 0 ) {
((uint8_t *) g)[0x82] = ((uint8_t *) g)[0x83];
}
}
}
void main_loop_ingame(struct game_data *g) {
//TODO
fixups_before(g);
move_lemmings(g);
draw_lemmings(g);
spawn_lemming(g);
fixups_after(g);
}
|