git @ Cat's Eye Technologies SixtyPical / 443c318
Change global instead of returning with carry set. Chris Pressey 3 years ago
1 changed file(s) with 24 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
3535 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
3636 outputs dispatch_game_state,
3737 actor_pos, actor_delta, actor_logic,
38 player_died,
3839 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
3940 trashes a, x, y, c, z, n, v, pos, new_pos, delta, ptr, dispatch_logic
4041 game_state_routine
4445 //
4546 // Routines that conform to this type also follow this convention:
4647 //
47 // Set carry if the player perished. Carry clear otherwise.
48 // Set player_died to 1 if the player perished. Unchanged otherwise.
4849 //
4950
5051 typedef routine
51 inputs pos, delta, joy2, screen
52 outputs pos, delta, new_pos, screen, c
53 trashes a, x, y, z, n, v, ptr
52 inputs pos, delta, joy2, screen, player_died
53 outputs pos, delta, new_pos, screen, player_died
54 trashes a, x, y, z, n, v, c, ptr
5455 logic_routine
5556
5657 // ----------------------------------------------------------------
8586
8687 word table[256] actor_delta
8788 word delta
89
90 byte player_died
8891
8992 vector logic_routine table[256] actor_logic
9093 vector logic_routine dispatch_logic
240243
241244 routine init_game
242245 inputs actor_pos, actor_delta, actor_logic
243 outputs actor_pos, actor_delta, actor_logic
246 outputs actor_pos, actor_delta, actor_logic, player_died
244247 trashes pos, a, y, z, n, c, v
245248 {
246249 ld y, 0
258261 } until z
259262
260263 ld y, 0
261 copy word 0, actor_pos + y
264 copy word 40, actor_pos + y
262265 copy word 0, actor_delta + y
263266 copy player_logic, actor_logic + y
267
268 st y, player_died
264269 }
265270
266271 // ----------------------------------------------------------------
300305 st off, c
301306 add ptr, pos
302307 copy 81, [ptr] + y
303
304 st off, c
305308 } else {
306 st on, c
309 ld a, 1
310 st a, player_died
307311 }
308312
309313 // FIXME these trashes, strictly speaking, probably shouldn't be needed,
313317 trash ptr
314318 trash y
315319 trash v
316 } else {
317 st off, c
318320 }
319321 }
320322
350352 st off, c
351353 add ptr, pos
352354 copy 82, [ptr] + y
353
354 st off, c
355 } else {
356 st on, c
357355 }
358356
359357 // FIXME these trashes, strictly speaking, probably shouldn't be needed,
372370 copy $ffd8, delta
373371 }
374372 }
375
376 st off, c
377373 }
378374
379375 // ----------------------------------------------------------------
383379 define game_state_title_screen game_state_routine
384380 {
385381 ld y, 0
382 st y, player_died
386383 for y up to 17 {
387384 ld a, press_fire_msg + y
388385
407404 define game_state_play game_state_routine
408405 {
409406 ld x, 0
407 st x, player_died
410408 for x up to 15 {
411409 copy actor_pos + x, pos
412410 copy actor_delta + x, delta
419417 save x {
420418 copy actor_logic + x, dispatch_logic
421419 call dispatch_logic
422
423 if c {
424 // Player died! Want no dead!
425 call clear_screen
426 copy game_state_game_over, dispatch_game_state
427 }
428420 }
429421
430422 copy pos, actor_pos + x
431423 copy delta, actor_delta + x
432424 }
433425
426 ld a, player_died
427 if not z {
428 // Player died! Want no dead!
429 call clear_screen
430 copy game_state_game_over, dispatch_game_state
431 }
432
434433 goto save_cinv
435434 }
436435
437436 define game_state_game_over game_state_routine
438437 {
438 ld y, 0
439 st y, player_died
439440 st off, c
440441 call check_button
441442