Prev: 28115 Up: Map Next: 28668
28561: Handler: Laser Beam
Used by the routine at JetmanThrust.
Only handle the laser beam on every 4th frame.
Handler_LaserBeam 28561 LD A,(23672) A=FRAMES.
28564 AND %00000011 Keep only bits 0-1.
28566 RET NZ Return if FRAMES is non-zero.
Search for a "free" laser beam slot.
28567 LD HL,23816 HL=Laser_Param_1.
28570 LD DE,8 DE=0008 (each slot is 8 bytes).
28573 LD B,4 B=4 (counter; there are 4 "slots").
LaserBeam_Slot 28575 LD A,(HL) If the slot is not in use, jump to Init_LaserBeam.
28576 AND A
28577 JR Z,Init_LaserBeam
28579 ADD HL,DE HL=HL+DE (move onto the next slot).
28580 DJNZ LaserBeam_Slot Decrease counter by one and loop back to LaserBeam_Slot until counter is zero.
All laser beam slots are in use so just return...
28582 RET Return.
Initialise a new laser beam.
Init_LaserBeam 28583 LD (HL),16 Mark the laser beam slot as "in-use".
28585 INC HL HL=Laser beam Y position.
28586 LD DE,23808 B=JETMAN_FRAME.
28589 LD A,(DE)
28590 LD B,A
28591 INC DE A=Jetman_Pos_X.
28592 LD A,(DE)
28593 AND %11111000 Keep only bits 3-7.
28595 OR %00000101 Set bits 0 and 2.
28597 LD C,A
28598 BIT 6,B
28600 JR Z,LaserBeam_Right
28602 SUB 8
28604 LD C,A
LaserBeam_Left 28605 INC DE
28606 LD A,(DE)
28607 SUB 13
28609 LD (HL),A
28610 INC HL
28611 LD B,3
28613 LD (HL),C
28614 LD A,C
28615 AND 251
Handler_LaserBeam_0 28617 INC HL
28618 LD (HL),A
28619 DJNZ Handler_LaserBeam_0
28621 INC HL
28622 LD A,(24014) A=Random_Number.
28625 AND %00111000 Keep only bits 3-5.
28627 OR %10000100 Set bits 2 and 7.
28629 LD (HL),A
28630 INC HL
28631 EX DE,HL
28632 LD HL,28649 HL=LaserBeam_Attributes.
28635 LD A,(24014) A=Random_Number.
28638 AND %00000011 Keep only bits 0-1.
28640 LD C,A
28641 LD B,0
28643 ADD HL,BC
28644 LD A,(HL)
28645 LD (DE),A
28646 JP SoundsLaserBeam Jump to SoundsLaserBeam.
All the attributes a laser beam can be.
LaserBeam_Attributes 28649 DEFB 71,67,67,69
Handle drawing the laser beam moving to the right.
LaserBeam_Right 28653 LD A,(DE) A=Jetman X position.
28654 AND %00000111 Keep only bits 0-2.
28656 LD A,C A=.
28657 JR Z,Handler_LaserBeam_1
28659 ADD A,8
Handler_LaserBeam_1 28661 ADD A,16
28663 AND %11111110 Keep only bits 1-7.
28665 LD C,A Store the result in C.
28666 JR LaserBeam_Left Jump to LaserBeam_Left.
Prev: 28115 Up: Map Next: 28668