Prev: 6F7A Up: Map Next: 6FBB
6F80: Spawn objects from level data slot
Called when a new attribute row scrolls into view (every 8 terrain fragments). Reads the level data slot for the current scroll position and spawns the appropriate object (rock, fuel depot, or enemy).
  • Level data starts at level_objects, with SIZE_LEVEL_SLOTS ($100) bytes per level
  • Slot format: 2 bytes [D, E] where E = X position (0 = empty), D = type/flags
  • D bit 3: rock flag, D bits 0-2: object type (7 = fuel depot)
spawn_objects_from_level_slot 6F80 LD A,$00 Clear collision mode (state_collision_mode).
6F82 LD ($5EF5),A
6F85 LD HL,$C800 Calculate level base address: HL = level_objects + (state_bridge_index * SIZE_LEVEL_SLOTS).
6F88 LD DE,$0100
6F8B LD A,($5EF0)
6F8E OR A
6F8F SBC HL,DE
locate_level 6F91 ADD HL,DE Loop: advance HL by SIZE_LEVEL_SLOTS for each level up to current.
6F92 DEC A
6F93 JR NZ,locate_level
6F95 LD BC,($5F70) Calculate slot offset: BC = (state_scroll_offset >> 2) with bit 0 cleared. Read [D, E] from (HL + BC).
6F99 SRL B
6F9B RR C
6F9D SRL B
6F9F RR C
6FA1 RES 0,C
6FA3 ADD HL,BC
6FA4 LD D,(HL)
6FA5 INC HL
6FA6 LD E,(HL)
6FA7 LD A,E If E == 0 (empty slot), return.
6FA8 CP $00
6FAA RET Z
6FAB BIT 3,D If D bit 3 set (rock), jump to render_rock.
6FAD JP NZ,render_rock
6FB0 LD A,D Get object type (D AND $07). If type == OBJECT_FUEL (7), jump to render_fuel.
6FB1 AND $07
6FB3 CP $07
6FB5 JP Z,render_fuel Otherwise render enemy.
6FB8 JP render_enemy
Prev: 6F7A Up: Map Next: 6FBB