Hasty Briefsbeta

Bilingual

Finishing the ZX Spectrum Shooting Gallery

2 days ago
  • Porting Shooting Gallery to ZX Spectrum, focusing on shot mechanics including data structures, movement, deletion, spawning, display lists, rendering, and collision detection.
  • Designed data using structure-of-arrays: max_shot_y, shot_y (16), shot_x (16), shot_collide (16), num_shots, shot_tails, and shot_heads arrays.
  • Autonomous movement updates shot Y coordinates by subtracting 2 each frame; shots at Y=0 are retired.
  • Retiring shots uses a compacting scan with IX register to copy non-deleted entries, updating max_shot_y and reducing array size.
  • Spawning new shots checks constraints (shot_requested, max_shot_y<124, num_shots<16) then sets Y=146, X based on blaster_x with facing adjustment.
  • record_display_list generates shot_tails (erase locations) and shot_heads (draw addresses, masks, indices) from shot arrays, handling collisions and off-screen shots.
  • Rendering: erase_shot_tails clears bytes at stored addresses; draw_shots composites pixels using OR and detects collisions via AND with screen memory, updating shot_collide.
  • Main game loop order: halt, erase targets and shot tails, draw targets, update blaster, draw shots, handle input, move autonomous, compact shots, new shot, record display list.
  • Efficiency measurement using border color shows solid 50 FPS; spikes occur only when hitting targets due to score header redraw.
  • Project concluded as most involved port; lessons learned on Z80 instruction selection and using IX for structure-of-arrays, but overall successful and fast enough.