Prev: 6F43 Up: Map Next: 6FDD
6F93: Handler: Update Ship Attributes
Updates the two attribute rows that surround the player's ship. If the shield is active and bit 2 of the shield timer is set, white (INK:WHITE, PAPER:BLACK) is used to create a flashing visual effect; otherwise the default colour (INK:YELLOW, PAPER:BLACK (BRIGHT)) is written.
Bail out if a collision/ explosion is active, otherwise fetch the player attribute position and check the shield flags.
Handler_UpdateShipPosition 6F93 LD A,($66A4) Jump to Handler_PlayerBullets if *Flag_Collision is not zero.
6F96 OR A
6F97 JP NZ,Handler_PlayerBullets
6F9A LD HL,($66ED) Load the player attribute address from PlayerAttributeBufferPosition into HL.
6F9D LD A,($6693) Jump to UpdateShip_SetDefaultColour if the shield flag *Flag_Shield is zero.
6FA0 OR A
6FA1 JR Z,UpdateShip_SetDefaultColour
6FA3 LD A,($6694) Jump to UpdateShip_SetDefaultColour if bit 2 of the shield timer *ShieldTimer is clear.
6FA6 BIT 2,A
6FA8 JR Z,UpdateShip_SetDefaultColour
Choose the attribute byte to write: white (INK:WHITE, PAPER:BLACK) when shield is active with timer bit 2 set, or default (INK:YELLOW, PAPER:BLACK (BRIGHT)).
6FAA LD A,$07 Load INK:WHITE, PAPER:BLACK into A (white for shield effect).
6FAC JR UpdateShip_SetupRows Jump to UpdateShip_SetupRows.
The shield is not active - use the standard ship colour.
UpdateShip_SetDefaultColour 6FAE LD A,$46 Load INK:YELLOW, PAPER:BLACK (BRIGHT) into A.
Prepare to write two rows of attributes (above and below the ship).
UpdateShip_SetupRows 6FB0 LD B,$02 Set a row counter in B for 02 rows.
UpdateShip_RowLoop 6FB2 PUSH BC Stash the row counter and attribute pointer on the stack.
6FB3 PUSH HL
6FB4 DEC L Move left one attribute cell (point to column before ship).
6FB5 PUSH AF Stash the attribute byte on the stack.
6FB6 CP $46 Jump to UpdateShip_BlankLeft if the colour is INK:YELLOW, PAPER:BLACK (BRIGHT).
6FB8 JR Z,UpdateShip_BlankLeft
6FBA CP $07 Jump to UpdateShip_WriteRow if the colour is not WHITE (no need to blank).
6FBC JR NZ,UpdateShip_WriteRow
UpdateShip_BlankLeft 6FBE LD (HL),$00 Write 00 to the left neighbour attribute (clear highlight).
UpdateShip_WriteRow 6FC0 POP AF Restore the attribute byte from the stack.
6FC1 INC L Move right to the first ship column.
6FC2 LD B,$03 Set a width counter in B for 03 columns.
UpdateShip_WriteColumns 6FC4 LD (HL),A Write the chosen colour to *HL.
6FC5 INC HL Move to the next column.
6FC6 DJNZ UpdateShip_WriteColumns Decrease the width counter by one and loop back to UpdateShip_WriteColumns until all 03 columns are updated.
Clean up the right-hand neighbour attribute if required.
6FC8 PUSH AF Stash the attribute byte on the stack.
6FC9 LD A,(HL) Jump to UpdateShip_BlankRight if the neighbour already holds INK:YELLOW, PAPER:BLACK (BRIGHT).
6FCA CP $46
6FCC JR Z,UpdateShip_BlankRight
6FCE CP $07 Jump to UpdateShip_NextRow if the neighbour is not WHITE (nothing to clear).
6FD0 JR NZ,UpdateShip_NextRow
UpdateShip_BlankRight 6FD2 LD (HL),$00 Write 00 to the right neighbour attribute.
UpdateShip_NextRow 6FD4 POP AF Restore the attribute byte and attribute pointer from the stack.
6FD5 POP HL
6FD6 SET 5,L Move down one attribute row (set bit 5 of L).
6FD8 POP BC Restore the row counter from the stack.
6FD9 DJNZ UpdateShip_RowLoop Decrease the row counter by one and loop back to UpdateShip_RowLoop until both rows are processed.
6FDB JR Handler_PlayerBullets Jump to Handler_PlayerBullets.
Continue on to Handler_PlayerBullets.
Prev: 6F43 Up: Map Next: 6FDD