Prev: A522 Up: Map Next: A579
A53A: Spawn Linked Object
If the next actor slot is free, write type C8 into it and copy a speed and thrust pair from Handler_PlayerShot_Table.
Input
IX Actor slot
Write type C8 into the next slot if it is free.
SpawnLinkedObject A53A PUSH IX Copy the slot pointer into HL (using the stack).
A53C POP HL
A53D LD DE,$0018 DE=0018.
A540 ADD HL,DE Move onto the next slot.
A541 LD A,(HL) Return if that slot is already in use.
A542 AND A
A543 RET NZ
A544 LD (HL),$C8 Write type C8.
A546 INC HL Move onto the new world X.
A547 INC HL
A548 EX DE,HL Switch the destination into DE.
Select a speed and thrust pair from Handler_PlayerShot_Table for the new slot.
A549 LD A,($5E42) Fetch GameTimer.
A54C LD C,A Stash it in C.
A54D LD A,($5E40) Fetch RandomNumber.
A550 ADD A,C Add the timer.
A551 LD ($5E40),A Write it back to RandomNumber.
Use bits 2-5 of the timer to index the table.
A554 LD A,($5E40) Fetch RandomNumber.
A557 AND %00111100 Keep only bits 2-5.
A559 LD C,A Create an offset in BC.
A55A LD B,$00
A55C LD HL,$A68B HL=Handler_PlayerShot_Table.
A55F ADD HL,BC Add the offset.
A560 INC HL Skip the X and Y offsets to reach the speed in the table.
A561 INC HL
Place the new object beside and above this one.
A562 LD A,(IX+$02) Fetch the actor world X.
A565 ADD A,$08 Add 08.
A567 LD (DE),A Write it as the new world X.
Carry the addition into the high byte of the new world X.
A568 INC DE Move onto the high byte.
A569 LD A,(IX+$03) Fetch the actor world X high byte.
A56C ADC A,$00 Add the carry.
A56E AND %00011111 Keep only bits 0-4.
A570 LD (DE),A Write the high byte.
Put the new Y 10 above the actor Y.
A571 INC DE Move onto the new Y.
A572 LD A,(IX+$04) Fetch the actor Y.
A575 SUB $10 Subtract 10.
A577 JR Handler_PlayerShot_WriteFields Jump to Handler_PlayerShot_WriteFields.
Prev: A522 Up: Map Next: A579