Prev: 43339 Up: Map Next: 43595
43411: Move Debris Particle
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 43411 LD A,(IX+0) Fetch the particle X.
43414 ADD A,(IX+2) Add the X velocity.
43417 LD L,A Copy the new X into L.
43418 LD A,(IX+1) Fetch the particle Y.
43421 ADD A,(IX+3) Add the Y velocity.
43424 LD H,A Copy the new Y into H.
Discard the particle if it has left the play area.
MoveDebrisParticle_TestX 43425 LD A,L Fetch the new X.
43426 CP 8 Return if it is less than 8.
43428 RET C
43429 CP 248 Return if it is at least 248.
43431 RET NC
43432 LD A,H Fetch the new Y.
43433 CP 48 Return if it is less than 48.
43435 RET C
43436 CP 168 Return if it is at least 168.
43438 RET NC
Write the new position and count a live particle.
43439 LD (IX+0),L Write the new X.
43442 LD (IX+1),H Write the new Y.
43445 LD A,(24169) Fetch DebrisCount.
43448 INC A Increase it by one.
43449 LD (24169),A Write it back.
Colour the attribute square under the particle.
43452 LD BC,514 BC=514.
43455 PUSH HL Stash the particle position on the stack.
43456 EXX Switch to the shadow registers.
43457 POP DE Restore the particle position from the stack.
43458 LD L,E Copy it into HL'.
43459 LD H,D
43460 CALL AttributeAddress Call AttributeAddress.
Colour the square with the particle colour unless its attribute is zero.
43463 LD A,(HL) Fetch the attribute byte.
43464 AND A Jump to MoveDebrisParticle_ScreenAddress if it is already zero.
43465 JR Z,MoveDebrisParticle_ScreenAddress
43467 LD A,(IX+4) Fetch the particle colour.
43470 LD (HL),A Write it to the attribute square.
XOR the particle pixels onto the screen.
MoveDebrisParticle_ScreenAddress 43471 EXX Switch back to the main registers.
43472 CALL ScreenAddress Call ScreenAddress.
MoveDebrisParticle_Loop 43475 PUSH BC Stash the counters and the screen address on the stack.
43476 PUSH HL
43477 LD A,(IX+0) Fetch the particle X.
MoveDebrisParticle_PixelIndex 43480 AND %00000111 Keep only bits 0-2.
43482 LD E,A Copy the pixel index into E.
Look up the pixel mask for this column and XOR it onto the screen.
43483 EX AF,AF' Stash A in AF'.
43484 LD A,E Copy the pixel index into A.
43485 LD DE,43539 DE=MoveDebrisParticle_Masks.
43488 ADD A,E Add the pixel index.
43489 LD E,A Copy the low byte into E.
43490 LD A,D Fetch the high byte.
43491 ADC A,0 Add the carry.
43493 LD D,A Write it back to D.
43494 LD A,(DE) Fetch the pixel mask.
43495 XOR (HL) Invert the screen byte.
43496 LD (HL),A Write it back.
43497 EX AF,AF' Restore A from AF'.
Advance the pixel index, moving to the next screen and attribute column at a byte boundary.
43498 INC A Increase the pixel index by one.
43499 AND %00000111 Keep only bits 0-2.
43501 JR NZ,MoveDebrisParticle_NextRow Jump to MoveDebrisParticle_NextRow if the byte boundary was not crossed.
43503 INC L Move onto the next screen column.
43504 EXX Switch to the shadow registers.
43505 INC E Increase the attribute column by one.
Colour this column's attribute square the same way.
MoveDebrisParticle_Attribute 43506 LD L,E Copy the attribute address into HL'.
43507 LD H,D
43508 EX AF,AF' Stash A in AF'.
43509 CALL AttributeAddress Call AttributeAddress.
43512 LD A,(HL) Fetch the attribute byte.
43513 AND A Jump to MoveDebrisParticle_NextColumn if it is already zero.
43514 JR Z,MoveDebrisParticle_NextColumn
43516 LD A,(IX+4) Fetch the particle colour.
43519 LD (HL),A Write it to the attribute square.
Step to the next column or up one pixel row.
MoveDebrisParticle_NextColumn 43520 EXX Switch back to the main registers.
43521 EX AF,AF' Restore A from AF'.
43522 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.
43524 POP HL Restore the screen address from the stack.
43525 CALL ScreenPosition1PixelAbove Call ScreenPosition1PixelAbove.
43528 EXX Switch to the shadow registers.
43529 DEC D Move the shadow copy of the particle Y up by one pixel.
43530 EXX Switch back to the main registers.
43531 POP BC Restore the counters from the stack.
43532 DEC C Decrease the row counter by one.
43533 JR NZ,MoveDebrisParticle_Loop Jump back to MoveDebrisParticle_Loop if any rows remain.
43535 RET Return.
MoveDebrisParticle_NextRow 43536 EXX Switch to the shadow registers.
43537 JR MoveDebrisParticle_Attribute Jump to MoveDebrisParticle_Attribute.
MoveDebrisParticle_Masks 43539 DEFB 128,64,32,16,8,4,2,1 Pixel masks, then debris velocity and colour triples.
43547 DEFB 0,254,65,1,254,66,2,254
43555 DEFB 67,2,255,68,2,0,69,2
43563 DEFB 1,70,2,2,71,1,2,70
43571 DEFB 0,2,69,255,2,68,254,2
43579 DEFB 67,254,1,66,254,0,65,254
43587 DEFB 255,66,254,254,67,255,254,68
Prev: 43339 Up: Map Next: 43595