Prev: F30B Up: Map Next: F39E
F311: Reset the play for a new life
Used by the routine at play.
Called by play at the start of every life (and of every level). Sets the ship's colour back to white, clears the death byte death_count, the hit-immunity timer shield_timer, the end-of-level byte launch_state, the hit count and two more flags, and empties or resets the game's tables: bit 0 of the first byte of 18 two-byte entries of star_layer_pointer, 96 bytes at shot_records, the first byte of the eight 5-byte entries of rocket_part_table, 16 bytes of beam_grace's table; then copies four records back from the starting copies that follow them (trail_frame, lift_jet_record, side_jet_record, and the 32 bytes of the ship's state in bare_ship), and resets with free_object the nine 24-byte records at object_records and the six 26-byte records at ground_objects.
Which of these tables is which is for the ranges that hold them; here they are named by address only.
reset_for_life F311 LD A,$47 The ship's colour back to white
F313 LD ($F201),A
F316 XOR A Clear the death byte, the immunity timer, the end of the level, the hits and two more flags
F317 LD (death_count),A
F31A LD (shield_timer),A
F31D LD (launch_state),A
F320 LD (hit_count),A
F323 LD (carried_part_redraw),A
F326 LD (meteor_shower),A
F329 LD A,$18 beam_grace to 24
F32B LD (beam_grace),A
F32E LD HL,star_positions Bit 0 of the first byte of 18 entries of star_layer_pointer
F331 LD B,$12
reset_for_life_0 F333 LD A,(HL)
F334 AND $FE
F336 LD (HL),A
F337 INC HL
F338 INC HL
F339 DJNZ reset_for_life_0
F33B LD HL,shot_records 96 bytes at shot_records
F33E LD B,$60
F340 CALL clear_bytes
F343 LD HL,rocket_part_table The first byte of the eight 5-byte entries of rocket_part_table
F346 LD B,$08
reset_for_life_1 F348 LD (HL),$00
F34A LD A,$05
F34C CALL add_a_to_hl
F34F DJNZ reset_for_life_1
F351 LD HL,flicker_beam_records 16 bytes of beam_grace's table
F354 LD B,$10
F356 CALL clear_bytes
F359 LD DE,trail_frame Four records back to their starting values
F35C LD HL,trail_start
F35F LD BC,$0006
F362 LDIR
F364 LD DE,lift_jet_record
F367 LD HL,lift_jet_start
F36A LD C,$06
F36C LDIR
F36E LD DE,side_jet_record
F371 LD HL,side_jet_start
F374 LD C,$07
F376 LDIR
F378 LD C,$20
F37A LD DE,ship_record
F37D LD HL,ship_record_start
F380 LDIR
F382 LD IX,object_records Reset the nine records at object_records
F386 LD B,$09
F388 LD DE,$0018
F38B CALL reset_for_life_2
F38E LD IX,ground_objects And the six at ground_objects
F392 LD E,$1A
F394 LD B,$06
reset_for_life_2 F396 CALL free_object The loop: B records of DE bytes from IX
F399 ADD IX,DE
F39B DJNZ reset_for_life_2
F39D RET
Prev: F30B Up: Map Next: F39E