Prev: B414 Up: Map Next: B5B5
B483: Update Shot
Used by the routine at UpdateShots.
Updates one of the shots that the ship has fired. Shots that have bit 7 of offset 15 set go to UpdateSpecialShot. A shot that is starting (with a length of zero at offset 0E) is given a starting vertical position from ShipRow with a random step, and a random colour. Shots that are facing right continue at UpdateShot_Right and ones that are facing left at UpdateLeftShot.
Input
IX Address of the shot
UpdateShot B483 LD A,($C8EC) The high byte of the ship's horizontal speed.
B486 LD (IX+$07),A Write the high byte of the horizontal speed.
B489 LD A,$80 A=80.
B48B LD ($5C25),A The shot stops on the terrain.
B48E BIT 7,(IX+$15) Jump to UpdateSpecialShot if bit 7 of offset 15 of IX is set.
B492 JP NZ,UpdateSpecialShot
B495 LD A,$01 A=01.
B497 LD ($A1D7),A One row to erase.
B49A LD ($A1D8),A One row to draw.
B49D LD A,(IX+$0E) The high byte of the vertical acceleration.
B4A0 AND A Jump to UpdateShot_Right if A is not zero.
B4A1 JR NZ,UpdateShot_Right
B4A3 LD (IX+$10),$00 Store 00 at offset 10 of IX.
B4A7 LD (IX+$07),$00 Store 00 at offset 07 of IX.
B4AB CALL ChooseRandomStep Call ChooseRandomStep.
B4AE LD A,($CCBA) The vertical scroll speed.
B4B1 NEG Negate A.
B4B3 ADD A,B A gains B.
B4B4 LD (IX+$09),B Write the high byte of the vertical speed.
B4B7 LD B,A B=A.
B4B8 LD A,($5C38) The ship row.
B4BB ADD A,B A gains B.
B4BC LD (IX+$0C),A Write the low byte of the horizontal acceleration.
B4BF CALL ChooseRandomColour Call ChooseRandomColour.
B4C2 CALL MoveObject Call MoveObject.
B4C5 LD (IX+$09),$00 Store 00 at offset 09 of IX.
UpdateShot_Right B4C9 BIT 7,(IX+$00) Jump to UpdateLeftShot if bit 7 of offset 00 of IX is set.
B4CD JP NZ,UpdateLeftShot
B4D0 LD DE,$B3DA The shot offsets.
B4D3 CALL AddShotOffset Call AddShotOffset.
B4D6 CALL FindObjectScreenAddress Call FindObjectScreenAddress.
B4D9 LD B,(IX+$0E) The high byte of the vertical acceleration.
B4DC EXX Switch to the alternate registers.
B4DD BIT 7,(IX+$10) Jump to UpdateShot_Hit if bit 7 of offset 10 of IX is set.
B4E1 JR NZ,UpdateShot_Hit
B4E3 LD A,(IX+$0E) The high byte of the vertical acceleration.
B4E6 AND A Jump to UpdateShot_Longer if A is not zero.
B4E7 JR NZ,UpdateShot_Longer
B4E9 LD (IX+$0F),$08 Store 08 at offset 0F of IX.
B4ED LD (IX+$0B),$88 Store 88 at offset 0B of IX.
UpdateShot_Longer B4F1 LD A,$10 A=10.
B4F3 ADD A,(IX+$07) Add the byte at offset 07 of IX to A.
B4F6 LD (IX+$07),A Write the high byte of the horizontal speed.
B4F9 CALL TestShotHitsGround Call TestShotHitsGround.
B4FC JR Z,UpdateShot_Move Jump to UpdateShot_Move if the zero flag is set.
B4FE LD A,$F0 A=F0.
B500 ADD A,(IX+$07) Add the byte at offset 07 of IX to A.
B503 LD (IX+$07),A Write the high byte of the horizontal speed.
B506 SET 7,(IX+$10) Set bit 7 of offset 10 of IX.
B50A SET 5,(IX+$10) Set bit 5 of offset 10 of IX.
B50E JP UpdateShot_Count Jump to UpdateShot_Count.
UpdateShot_Move B511 LD A,$08 A=08.
B513 ADD A,(IX+$0B) Add the byte at offset 0B of IX to A.
B516 LD (IX+$0B),A Write the high byte of the horizontal acceleration.
B519 CP $B8 Jump to UpdateShot_Length if A is not B8.
B51B JR NZ,UpdateShot_Length
B51D SET 7,(IX+$10) Set bit 7 of offset 10 of IX.
UpdateShot_Length B521 LD A,(IX+$0E) The high byte of the vertical acceleration.
B524 INC A Advance A.
B525 LD (IX+$0E),A Write the high byte of the vertical acceleration.
B528 LD A,(IX+$0F) The low byte of the vertical acceleration.
B52B DEC A Step A back.
B52C LD (IX+$0F),A Write the low byte of the vertical acceleration.
B52F JP UpdateShot_Table Jump to UpdateShot_Table.
UpdateShot_Hit B532 BIT 5,(IX+$10) Jump to UpdateShot_Stopped if bit 5 of offset 10 of IX is set.
B536 JR NZ,UpdateShot_Stopped
B538 CALL TestShotHitsGround Call TestShotHitsGround.
B53B JR Z,UpdateShot_Facing Jump to UpdateShot_Facing if the zero flag is set.
B53D SET 5,(IX+$10) Set bit 5 of offset 10 of IX.
UpdateShot_Stopped B541 LD A,(IX+$07) The high byte of the horizontal speed.
B544 NEG Negate A.
B546 ADD A,(IX+$0B) Add the byte at offset 0B of IX to A.
B549 LD (IX+$0B),A Write the high byte of the horizontal acceleration.
B54C LD (IX+$07),$00 Store 00 at offset 07 of IX.
B550 BIT 6,(IX+$10) Test bit 6 of offset 10 of IX.
B554 LD B,(IX+$0E) The high byte of the vertical acceleration.
B557 LD C,(IX+$0B) The high byte of the horizontal acceleration.
B55A JR Z,UpdateShot_Clip Jump to UpdateShot_Clip if the zero flag is set.
B55C DEC B Step B back.
B55D LD A,C A=C.
B55E ADD A,$08 Add 08 to A.
B560 LD C,A C=A.
UpdateShot_Clip B561 SLA B Shift B left.
B563 SLA B Shift B left.
B565 SLA B Shift B left.
B567 LD A,B A=B.
B568 ADD A,C A gains C.
B569 AND %11111000 Keep the bits of A that are set in F8.
B56B CP $E4 Jump to UpdateShot_Facing if A is less than E4.
B56D JR C,UpdateShot_Facing
B56F CP $F0 Jump to UpdateShot_Shorten if A is less than F0.
B571 JR C,UpdateShot_Shorten
B573 LD (IX+$0E),$00 Store 00 at offset 0E of IX.
UpdateShot_Shorten B577 LD A,(IX+$0E) The high byte of the vertical acceleration.
B57A DEC A Step A back.
B57B LD (IX+$0E),A Write the high byte of the vertical acceleration.
B57E LD A,(IX+$0B) The high byte of the horizontal acceleration.
B581 SUB $08 Subtract 08 from A.
B583 LD (IX+$0B),A Write the high byte of the horizontal acceleration.
UpdateShot_Facing B586 BIT 6,(IX+$10) Jump to UpdateShot_Count if bit 6 of offset 10 of IX is clear.
B58A JR Z,UpdateShot_Count
B58C LD A,(IX+$0E) The high byte of the vertical acceleration.
B58F DEC A Step A back.
B590 LD (IX+$0E),A Write the high byte of the vertical acceleration.
B593 LD A,(IX+$0B) The high byte of the horizontal acceleration.
B596 ADD A,$08 Add 08 to A.
B598 LD (IX+$0B),A Write the high byte of the horizontal acceleration.
B59B JR UpdateShot_Table Jump to UpdateShot_Table.
UpdateShot_Count B59D LD A,(IX+$0F) The low byte of the vertical acceleration.
B5A0 DEC A Step A back.
B5A1 LD (IX+$0F),A Write the low byte of the vertical acceleration.
B5A4 JR NZ,UpdateShot_Table Jump to UpdateShot_Table if the zero flag is clear.
B5A6 SET 6,(IX+$10) Set bit 6 of offset 10 of IX.
UpdateShot_Table B5AA LD DE,$B3DA The shot offsets.
B5AD JR UpdateShot_Offset Jump to UpdateShot_Offset.
This entry point is used by the routine at UpdateLeftShot.
UpdateShot_LeftTable B5AF LD DE,$B3E2 The second shot offset.
UpdateShot_Offset B5B2 CALL AddShotOffset Call AddShotOffset.
Prev: B414 Up: Map Next: B5B5