Prev: A94B Up: Map Next: AA4B
A993: Move Debris Particle
Used by the routine at AnimatePickupDebris.
Add the particle velocity and discard it if it leaves the play area.
Input
IX Particle
Add the particle velocity to its X/Y position.
MoveDebrisParticle A993 LD A,(IX+$00) Fetch the particle X.
A996 ADD A,(IX+$02) Add the X velocity.
A999 LD L,A Copy the new X into L.
A99A LD A,(IX+$01) Fetch the particle Y.
A99D ADD A,(IX+$03) Add the Y velocity.
A9A0 LD H,A Copy the new Y into H.
This entry point is used by the routine at AnimateDebrisBurst.
Discard the particle if it has left the play area.
MoveDebrisParticle_TestX A9A1 LD A,L Fetch the new X.
A9A2 CP $08 Return if it is less than 08.
A9A4 RET C
A9A5 CP $F8 Return if it is at least F8.
A9A7 RET NC
A9A8 LD A,H Fetch the new Y.
A9A9 CP $30 Return if it is less than 30.
A9AB RET C
A9AC CP $A8 Return if it is at least A8.
A9AE RET NC
Write the new position and count a live particle.
A9AF LD (IX+$00),L Write the new X.
A9B2 LD (IX+$01),H Write the new Y.
A9B5 LD A,($5E69) Fetch DebrisCount.
A9B8 INC A Increase it by one.
A9B9 LD ($5E69),A Write it back.
Colour the attribute square under the particle.
A9BC LD BC,$0202 BC=0202.
A9BF PUSH HL Stash the particle position on the stack.
A9C0 EXX Switch to the shadow registers.
A9C1 POP DE Restore the particle position from the stack.
A9C2 LD L,E Copy it into HL'.
A9C3 LD H,D
A9C4 CALL AttributeAddress Call AttributeAddress.
Colour the square with the particle colour unless its attribute is zero.
A9C7 LD A,(HL) Fetch the attribute byte.
A9C8 AND A Jump to MoveDebrisParticle_ScreenAddress if it is already zero.
A9C9 JR Z,MoveDebrisParticle_ScreenAddress
A9CB LD A,(IX+$04) Fetch the particle colour.
A9CE LD (HL),A Write it to the attribute square.
XOR the particle pixels onto the screen.
MoveDebrisParticle_ScreenAddress A9CF EXX Switch back to the main registers.
A9D0 CALL ScreenAddress Call ScreenAddress.
MoveDebrisParticle_Loop A9D3 PUSH BC Stash the counters and the screen address on the stack.
A9D4 PUSH HL
A9D5 LD A,(IX+$00) Fetch the particle X.
MoveDebrisParticle_PixelIndex A9D8 AND %00000111 Keep only bits 0-2.
A9DA LD E,A Copy the pixel index into E.
Look up the pixel mask for this column and XOR it onto the screen.
A9DB EX AF,AF' Stash A in AF'.
A9DC LD A,E Copy the pixel index into A.
A9DD LD DE,$AA13 DE=MoveDebrisParticle_Masks.
A9E0 ADD A,E Add the pixel index.
A9E1 LD E,A Copy the low byte into E.
A9E2 LD A,D Fetch the high byte.
A9E3 ADC A,$00 Add the carry.
A9E5 LD D,A Write it back to D.
A9E6 LD A,(DE) Fetch the pixel mask.
A9E7 XOR (HL) Invert the screen byte.
A9E8 LD (HL),A Write it back.
A9E9 EX AF,AF' Restore A from AF'.
Advance the pixel index, moving to the next screen and attribute column at a byte boundary.
A9EA INC A Increase the pixel index by one.
A9EB AND %00000111 Keep only bits 0-2.
A9ED JR NZ,MoveDebrisParticle_NextRow Jump to MoveDebrisParticle_NextRow if the byte boundary was not crossed.
A9EF INC L Move onto the next screen column.
A9F0 EXX Switch to the shadow registers.
A9F1 INC E Increase the attribute column by one.
Colour this column's attribute square the same way.
MoveDebrisParticle_Attribute A9F2 LD L,E Copy the attribute address into HL'.
A9F3 LD H,D
A9F4 EX AF,AF' Stash A in AF'.
A9F5 CALL AttributeAddress Call AttributeAddress.
A9F8 LD A,(HL) Fetch the attribute byte.
A9F9 AND A Jump to MoveDebrisParticle_NextColumn if it is already zero.
A9FA JR Z,MoveDebrisParticle_NextColumn
A9FC LD A,(IX+$04) Fetch the particle colour.
A9FF LD (HL),A Write it to the attribute square.
Step to the next column or up one pixel row.
MoveDebrisParticle_NextColumn AA00 EXX Switch back to the main registers.
AA01 EX AF,AF' Restore A from AF'.
AA02 DJNZ MoveDebrisParticle_PixelIndex Decrease the column counter by one and loop back to MoveDebrisParticle_PixelIndex until the pair is drawn.
Move up one pixel row and repeat until every row is drawn.
AA04 POP HL Restore the screen address from the stack.
AA05 CALL ScreenPosition1PixelAbove Call ScreenPosition1PixelAbove.
AA08 EXX Switch to the shadow registers.
AA09 DEC D Move the shadow copy of the particle Y up by one pixel.
AA0A EXX Switch back to the main registers.
AA0B POP BC Restore the counters from the stack.
AA0C DEC C Decrease the row counter by one.
AA0D JR NZ,MoveDebrisParticle_Loop Jump back to MoveDebrisParticle_Loop if any rows remain.
AA0F RET Return.
MoveDebrisParticle_NextRow AA10 EXX Switch to the shadow registers.
AA11 JR MoveDebrisParticle_Attribute Jump to MoveDebrisParticle_Attribute.
MoveDebrisParticle_Masks AA13 DEFB $80,$40,$20,$10,$08,$04,$02,$01 Pixel masks, then debris velocity and colour triples.
AA1B DEFB $00,$FE,$41,$01,$FE,$42,$02,$FE
AA23 DEFB $43,$02,$FF,$44,$02,$00,$45,$02
AA2B DEFB $01,$46,$02,$02,$47,$01,$02,$46
AA33 DEFB $00,$02,$45,$FF,$02,$44,$FE,$02
AA3B DEFB $43,$FE,$01,$42,$FE,$00,$41,$FE
AA43 DEFB $FF,$42,$FE,$FE,$43,$FF,$FE,$44
Prev: A94B Up: Map Next: AA4B