![]() |
Routines |
| Prev: 9DB0 | Up: Map | Next: 9E2C |
|
On even frames, find a free slot at Laser_Parameter_1 and copy Jetman's column and Y into a new beam.
|
||||
|
Only fire on even values of GameTimer.
|
||||
| Handler_LaserBeam | 9DC0 | LD A,($5E42) | Fetch GameTimer. | |
| 9DC3 | AND %00000001 | Keep only bit 0. | ||
| 9DC5 | RET NZ | Return if this is an odd frame. | ||
|
Search for a free laser beam slot.
|
||||
| Handler_LaserBeam_FindSlot | 9DC6 | LD HL,$6000 | HL=Laser_Parameter_1. | |
| 9DC9 | LD DE,$0018 | DE=0018. | ||
| 9DCC | LD B,$04 | Set a slot counter in B for 04 loops. | ||
| LaserBeam_Slot | 9DCE | LD A,(HL) | Jump to Initialise_LaserBeam if this slot is free. | |
| 9DCF | AND A | |||
| 9DD0 | JR Z,Initialise_LaserBeam | |||
| 9DD2 | ADD HL,DE | Move onto the next slot. | ||
| 9DD3 | DJNZ LaserBeam_Slot | Decrease the slot counter by one and loop back to LaserBeam_Slot until every slot has been tried. | ||
|
All four laser beam slots are in use.
|
||||
| 9DD5 | RET | Return. | ||
|
When firing to the right, step the column on by 10.
|
||||
| Handler_LaserBeam_Loop | 9DD6 | ADD A,$10 | Add 10 to the screen column. | |
| 9DD8 | OR %00000100 | Set bit 2. | ||
| 9DDA | AND %11111110 | Keep only bits 1-7. | ||
| 9DDC | JR Handler_LaserBeam_StoreColumn | Jump to Handler_LaserBeam_StoreColumn. | ||
|
Initialise a new laser beam from Jetman.
|
||||
| Initialise_LaserBeam | 9DDE | LD (HL),$11 | Write type 11 to mark the slot in use. | |
| 9DE0 | INC HL | Move onto the beam Y. | ||
| 9DE1 | LD DE,$6078 | DE=Jetman_Slot. | ||
| 9DE4 | LD B,$0D | B=0D. | ||
| 9DE6 | LD A,(DE) | Fetch Jetman's type. | ||
| 9DE7 | INC DE | Move onto Jetman's screen column. | ||
|
The actor type is a 1-based sprite ID. Decrease it to work on the 0-based index: bit 3 is set when walking and reset when flying, bit 2 is facing.
|
||||
| 9DE8 | DEC A | Decrease it to a 0-based sprite index. | ||
| 9DE9 | BIT 3,A | Jump to Handler_LaserBeam_TestFacing if Jetman is flying. | ||
| 9DEB | JR Z,Handler_LaserBeam_TestFacing | |||
| 9DED | DEC B | Decrease the Y offset by two. | ||
| 9DEE | DEC B | |||
| Handler_LaserBeam_TestFacing | 9DEF | AND %00000100 | Keep only bit 2. | |
| 9DF1 | LD A,(DE) | Fetch Jetman's screen column. | ||
| 9DF2 | JR NZ,Handler_LaserBeam_Loop | Jump to Handler_LaserBeam_Loop if Jetman is facing right. | ||
| 9DF4 | SUB $08 | Subtract 08 from the screen column. | ||
| 9DF6 | AND %11111000 | Keep only bits 3-7. | ||
| 9DF8 | OR %00000101 | Set bits 0 and 2. | ||
|
Write the beam Y and the X of each of the four pulses.
|
||||
| Handler_LaserBeam_StoreColumn | 9DFA | LD C,A | Stash the beam column in C. | |
| 9DFB | INC DE | Move onto Jetman's Y. | ||
| 9DFC | INC DE | |||
| 9DFD | INC DE | |||
| 9DFE | LD A,(DE) | Fetch Jetman's Y. | ||
| 9DFF | SUB B | Subtract the Y offset. | ||
| 9E00 | LD (HL),A | Write it as the beam Y. | ||
| 9E01 | INC HL | Move onto the first pulse X. | ||
|
Write the beam column into the four pulses, clearing bit 2 in all but the first.
|
||||
| 9E02 | LD B,$03 | Set a pulse counter in B for 03 loops. | ||
| 9E04 | LD (HL),C | Write the beam column as pulse 01. | ||
| 9E05 | LD A,C | Copy it into A. | ||
| 9E06 | AND %11111011 | Reset bit 2. | ||
| Handler_LaserBeam_WritePulse | 9E08 | INC HL | Move onto the next pulse X. | |
| 9E09 | LD (HL),A | Write the column without bit 2. | ||
| 9E0A | DJNZ Handler_LaserBeam_WritePulse | Decrease the pulse counter by one and loop back to Handler_LaserBeam_WritePulse until pulses 02-04 are written. | ||
|
Set the beam timer, pick the beam colour and play the laser sound.
|
||||
| 9E0C | INC HL | Move onto the beam timer. | ||
| 9E0D | LD A,($5E40) | Fetch RandomNumber. | ||
| 9E10 | AND %00011000 | Keep only bits 3-4. | ||
| 9E12 | ADD A,$60 | Add 60. | ||
| 9E14 | LD (HL),A | Write it as the beam timer. | ||
|
Pick the beam colour from the table at Attributes_LaserBeam using bits 0-1 of RandomNumber.
|
||||
| 9E15 | INC HL | Move onto the beam colour. | ||
| 9E16 | EX DE,HL | Switch the slot pointer into DE. | ||
| 9E17 | LD HL,$9E28 | HL=Attributes_LaserBeam. | ||
| 9E1A | LD A,($5E40) | Fetch RandomNumber. | ||
| 9E1D | AND %00000011 | Keep only bits 0-1. | ||
| 9E1F | LD C,A | Create an offset in BC. | ||
| 9E20 | LD B,$00 | |||
| 9E22 | ADD HL,BC | Point HL at that colour. | ||
| 9E23 | LD A,(HL) | Fetch the colour. | ||
| 9E24 | LD (DE),A | Write it to the beam colour. | ||
| 9E25 | JP SoundsLaserBeam | Jump to SoundsLaserBeam. | ||
|
The four colours a laser beam can be.
|
||||
| Attributes_LaserBeam | 9E28 | DEFB $47 | INK:WHITE, PAPER:BLACK (BRIGHT). | |
|
The four colours a laser beam can be.
|
||||
| 9E29 | DEFB $43 | INK:MAGENTA, PAPER:BLACK (BRIGHT). | ||
|
The four colours a laser beam can be.
|
||||
| 9E2A | DEFB $43 | INK:MAGENTA, PAPER:BLACK (BRIGHT). | ||
|
The four colours a laser beam can be.
|
||||
| 9E2B | DEFB $45 | INK:CYAN, PAPER:BLACK (BRIGHT). | ||
|
View the equivalent code in;
|
||||
| Prev: 9DB0 | Up: Map | Next: 9E2C |