git @ Cat's Eye Technologies SixtyPical / c3a1bdb
Use save block (and a for loop) in the flagship demo game source. Chris Pressey 7 years ago
1 changed file(s) with 17 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
405405 }
406406
407407 define game_state_play game_state_routine
408 static byte save_x : 0
409408 {
410409 ld x, 0
411 repeat {
410 for x up to 15 {
412411 copy actor_pos + x, pos
413412 copy actor_delta + x, delta
414413
415 st x, save_x
416
417 copy actor_logic + x, dispatch_logic
418 call dispatch_logic
419
420 if c {
421 // Player died! Want no dead!
422 call clear_screen
423 copy game_state_game_over, dispatch_game_state
424 }
425 ld x, save_x
414 //
415 // Save our loop counter on the stack temporarily. This means that routines
416 // like `dispatch_logic` and `clear_screen` are allowed to do whatever they
417 // want with the `x` register; we will restore it at the end of this block.
418 //
419 save x {
420 copy actor_logic + x, dispatch_logic
421 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 }
428 }
426429
427430 copy pos, actor_pos + x
428431 copy delta, actor_delta + x
429
430 inc x
431 cmp x, 16
432 } until z
432 }
433433
434434 goto save_cinv
435435 }