![]() |
Routines |
| Prev: 57383 | Up: Map | Next: 57513 |
|
Used by the routine at Run_Game.
Starts a bubble at the bottom of the room every now and then.
Nothing happens in a special room (a room y below 16), or when the type of Sabreman is 60 or more, which means that he is dying or being carried. The bubble takes one of the four bubble records that start at First_Bubble_Record, if one is free. A bubble is only made when the low byte of the frame counter plus 26 has its low six bits clear.
The record is a copy of the record of Sabreman, so the bubble is in his room. Its type is 88 its y position is 191 (the bottom of the room), its attribute is 70 (yellow) and its x position is 64 or 192 depending on bit 7 of the tick counter. The handler is Handle_Bubble.
|
||||
| Spawn_Bubble | 57439 | LD A,(36634) | Fetch the type of Sabreman. | |
| 57442 | CP 60 | Return if the type is 60 or more. | ||
| 57444 | RET NC | |||
| 57445 | LD A,(36638) | Fetch the room y of Sabreman. | ||
| 57448 | CP 16 | Return if it is a special room. | ||
| 57450 | RET C | |||
| 57451 | LD HL,36698 | Point HL at First_Bubble_Record. | ||
| 57454 | LD DE,16 | Set DE to the size of an object record. | ||
| 57457 | LD B,4 | Set a counter in B for the four bubble records. | ||
| Spawn_Bubble_Find_Record | 57459 | LD A,(HL) | Fetch the type of the record. | |
| 57460 | AND A | Jump to Spawn_Bubble_Create if the record is free. | ||
| 57461 | JR Z,Spawn_Bubble_Create | |||
| 57463 | ADD HL,DE | Move on to the next record. | ||
| 57464 | DJNZ Spawn_Bubble_Find_Record | Decrease the record counter and loop back for the next record. | ||
| 57466 | RET | Return, as all four bubble records are in use. | ||
| Spawn_Bubble_Create | 57467 | EX DE,HL | Point DE at the free record. | |
| 57468 | LD HL,36634 | Point HL at Sabreman_Record. | ||
| 57471 | LD A,(23672) | Fetch the low byte of the frame counter. | ||
| 57474 | ADD A,L | Add the low byte of the address of the record of Sabreman. | ||
| 57475 | AND %00111111 | Keep only the low six bits. | ||
| 57477 | RET NZ | Return unless they are zero. | ||
| 57478 | LD BC,15 | Set a counter of 15 bytes. | ||
| 57481 | PUSH DE | Stash the address of the bubble record. | ||
| 57482 | LDIR | Copy the record of Sabreman to the bubble record, except for the redraw flags. | ||
| 57484 | POP HL | Restore the address of the bubble record to HL. | ||
| 57485 | LD A,88 | Set the type to 88. | ||
| 57487 | LD (HL),A | |||
| 57488 | LD A,(36566) | Fetch the tick counter. | ||
| 57491 | AND %10000000 | Keep only bit 7. | ||
| 57493 | ADD A,64 | Add 64 which makes 64 or 192. | ||
| 57495 | INC HL | Move to the x position. | ||
| 57496 | LD (HL),A | Set the x position. | ||
| 57497 | INC HL | Move to the y position. | ||
| 57498 | INC HL | |||
| 57499 | LD (HL),191 | Set the y position to 191. | ||
| 57501 | INC HL | Move to the attribute. | ||
| 57502 | INC HL | |||
| 57503 | LD (HL),70 | Set the attribute to 70 (yellow). | ||
| 57505 | LD A,1 | A=1 (the value of the redraw flags). | ||
| 57507 | LD DE,10 | Set the offset from the attribute to the redraw flags of the record (10). | ||
| 57510 | ADD HL,DE | Move to the redraw flags. | ||
| 57511 | LD (HL),A | Set the redraw flags to 1 so that the bubble is drawn without being erased first. | ||
| 57512 | RET | Return. | ||
| Prev: 57383 | Up: Map | Next: 57513 |