![]() |
Routines |
| Prev: 40368 | Up: Map | Next: 40492 |
|
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 | 40384 | LD A,(24130) | Fetch GameTimer. | |
| 40387 | AND %00000001 | Keep only bit 0. | ||
| 40389 | RET NZ | Return if this is an odd frame. | ||
|
Search for a free laser beam slot.
|
||||
| Handler_LaserBeam_FindSlot | 40390 | LD HL,24576 | HL=Laser_Parameter_1. | |
| 40393 | LD DE,24 | DE=0024. | ||
| 40396 | LD B,4 | Set a slot counter in B for 4 loops. | ||
| LaserBeam_Slot | 40398 | LD A,(HL) | Jump to Initialise_LaserBeam if this slot is free. | |
| 40399 | AND A | |||
| 40400 | JR Z,Initialise_LaserBeam | |||
| 40402 | ADD HL,DE | Move onto the next slot. | ||
| 40403 | 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.
|
||||
| 40405 | RET | Return. | ||
|
When firing to the right, step the column on by 16.
|
||||
| Handler_LaserBeam_Loop | 40406 | ADD A,16 | Add 16 to the screen column. | |
| 40408 | OR %00000100 | Set bit 2. | ||
| 40410 | AND %11111110 | Keep only bits 1-7. | ||
| 40412 | JR Handler_LaserBeam_StoreColumn | Jump to Handler_LaserBeam_StoreColumn. | ||
|
Initialise a new laser beam from Jetman.
|
||||
| Initialise_LaserBeam | 40414 | LD (HL),17 | Write type 17 to mark the slot in use. | |
| 40416 | INC HL | Move onto the beam Y. | ||
| 40417 | LD DE,24696 | DE=Jetman_Slot. | ||
| 40420 | LD B,13 | B=13. | ||
| 40422 | LD A,(DE) | Fetch Jetman's type. | ||
| 40423 | 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.
|
||||
| 40424 | DEC A | Decrease it to a 0-based sprite index. | ||
| 40425 | BIT 3,A | Jump to Handler_LaserBeam_TestFacing if Jetman is flying. | ||
| 40427 | JR Z,Handler_LaserBeam_TestFacing | |||
| 40429 | DEC B | Decrease the Y offset by two. | ||
| 40430 | DEC B | |||
| Handler_LaserBeam_TestFacing | 40431 | AND %00000100 | Keep only bit 2. | |
| 40433 | LD A,(DE) | Fetch Jetman's screen column. | ||
| 40434 | JR NZ,Handler_LaserBeam_Loop | Jump to Handler_LaserBeam_Loop if Jetman is facing right. | ||
| 40436 | SUB 8 | Subtract 8 from the screen column. | ||
| 40438 | AND %11111000 | Keep only bits 3-7. | ||
| 40440 | OR %00000101 | Set bits 0 and 2. | ||
|
Write the beam Y and the X of each of the four pulses.
|
||||
| Handler_LaserBeam_StoreColumn | 40442 | LD C,A | Stash the beam column in C. | |
| 40443 | INC DE | Move onto Jetman's Y. | ||
| 40444 | INC DE | |||
| 40445 | INC DE | |||
| 40446 | LD A,(DE) | Fetch Jetman's Y. | ||
| 40447 | SUB B | Subtract the Y offset. | ||
| 40448 | LD (HL),A | Write it as the beam Y. | ||
| 40449 | INC HL | Move onto the first pulse X. | ||
|
Write the beam column into the four pulses, clearing bit 2 in all but the first.
|
||||
| 40450 | LD B,3 | Set a pulse counter in B for 3 loops. | ||
| 40452 | LD (HL),C | Write the beam column as pulse 1. | ||
| 40453 | LD A,C | Copy it into A. | ||
| 40454 | AND %11111011 | Reset bit 2. | ||
| Handler_LaserBeam_WritePulse | 40456 | INC HL | Move onto the next pulse X. | |
| 40457 | LD (HL),A | Write the column without bit 2. | ||
| 40458 | DJNZ Handler_LaserBeam_WritePulse | Decrease the pulse counter by one and loop back to Handler_LaserBeam_WritePulse until pulses 2-4 are written. | ||
|
Set the beam timer, pick the beam colour and play the laser sound.
|
||||
| 40460 | INC HL | Move onto the beam timer. | ||
| 40461 | LD A,(24128) | Fetch RandomNumber. | ||
| 40464 | AND %00011000 | Keep only bits 3-4. | ||
| 40466 | ADD A,96 | Add 96. | ||
| 40468 | 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.
|
||||
| 40469 | INC HL | Move onto the beam colour. | ||
| 40470 | EX DE,HL | Switch the slot pointer into DE. | ||
| 40471 | LD HL,40488 | HL=Attributes_LaserBeam. | ||
| 40474 | LD A,(24128) | Fetch RandomNumber. | ||
| 40477 | AND %00000011 | Keep only bits 0-1. | ||
| 40479 | LD C,A | Create an offset in BC. | ||
| 40480 | LD B,0 | |||
| 40482 | ADD HL,BC | Point HL at that colour. | ||
| 40483 | LD A,(HL) | Fetch the colour. | ||
| 40484 | LD (DE),A | Write it to the beam colour. | ||
| 40485 | JP SoundsLaserBeam | Jump to SoundsLaserBeam. | ||
|
The four colours a laser beam can be.
|
||||
| Attributes_LaserBeam | 40488 | DEFB 71 | INK:WHITE, PAPER:BLACK (BRIGHT). | |
|
The four colours a laser beam can be.
|
||||
| 40489 | DEFB 67 | INK:MAGENTA, PAPER:BLACK (BRIGHT). | ||
|
The four colours a laser beam can be.
|
||||
| 40490 | DEFB 67 | INK:MAGENTA, PAPER:BLACK (BRIGHT). | ||
|
The four colours a laser beam can be.
|
||||
| 40491 | DEFB 69 | INK:CYAN, PAPER:BLACK (BRIGHT). | ||
|
View the equivalent code in;
|
||||
| Prev: 40368 | Up: Map | Next: 40492 |