Prev: 5F8F Up: Map Next: 5FDA
5F91: Main gameplay loop
Central game loop that runs continuously during active gameplay. Orchestrates all game subsystems in a fixed sequence each frame.
  • Input: Check Enter key (Caps+Enter → restart, Symbol+Enter → control select)
  • Timing: Increment tick counter (state_tick)
  • Render: Explosions, plane/terrain, viewport objects
  • Missiles: Two-pass player missile (erase then draw)
  • Projectiles: Tank shells, helicopter missiles
  • Scroll: Advance game world (advance_scroll)
  • Fuel: Consume fuel (consume_fuel)
  • Controls: Dispatch to input handler based on state_input_interface
The loop is infinite. It terminates only via: game over (fuel empty, collision) or player death (jumps to death handler). Pressing Enter calls handle_enter (Caps+Enter → start_gameplay to restart gameplay; Symbol+Enter → select_controls to return to control selection). The H key pause is handled entirely by the interrupt handler (int_handler) and does not exit the loop.
main_loop 5F91 LD A,$BF Check Enter key for mode transitions.
5F93 IN A,($FE)
5F95 BIT 0,A
5F97 CALL Z,handle_enter
5F9A LD HL,$5EEF Increment tick counter at state_tick.
5F9D INC (HL)
5F9E CALL render_explosions
5FA1 CALL render_plane_and_terrain
5FA4 CALL operate_viewport_slots
5FA7 LD A,$01 Player missile pass 1: erase at old position.
5FA9 LD ($673C),A
5FAC CALL animate_plane_missile
5FAF LD A,$00 Player missile pass 2: draw at new position.
5FB1 LD ($673C),A
5FB4 CALL animate_plane_missile
5FB7 CALL operate_tank_shell
5FBA CALL operate_helicopter_missile
5FBD CALL advance_scroll
5FC0 CALL consume_fuel
5FC3 LD A,$00 Reset plane sprite bank.
5FC5 LD ($5F69),A
5FC8 LD A,($5F67) Dispatch to input handler.
5FCB CP $02
5FCD JP Z,scan_kempston
5FD0 CP $01
5FD2 JP Z,scan_sinclair
5FD5 CP $00
5FD7 JP Z,scan_keyboard
Prev: 5F8F Up: Map Next: 5FDA