![]() |
Routines |
| Prev: E027 | Up: Map | Next: E0A9 |
|
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 10), or when the type of Sabreman is 3C 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 1A 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 58 its y position is BF (the bottom of the room), its attribute is 46 (yellow) and its x position is 40 or C0 depending on bit 7 of the tick counter. The handler is Handle_Bubble.
|
||||
| Spawn_Bubble | E05F | LD A,($8F1A) | Fetch the type of Sabreman. | |
| E062 | CP $3C | Return if the type is 3C or more. | ||
| E064 | RET NC | |||
| E065 | LD A,($8F1E) | Fetch the room y of Sabreman. | ||
| E068 | CP $10 | Return if it is a special room. | ||
| E06A | RET C | |||
| E06B | LD HL,$8F5A | Point HL at First_Bubble_Record. | ||
| E06E | LD DE,$0010 | Set DE to the size of an object record. | ||
| E071 | LD B,$04 | Set a counter in B for the four bubble records. | ||
| Spawn_Bubble_Find_Record | E073 | LD A,(HL) | Fetch the type of the record. | |
| E074 | AND A | Jump to Spawn_Bubble_Create if the record is free. | ||
| E075 | JR Z,Spawn_Bubble_Create | |||
| E077 | ADD HL,DE | Move on to the next record. | ||
| E078 | DJNZ Spawn_Bubble_Find_Record | Decrease the record counter and loop back for the next record. | ||
| E07A | RET | Return, as all four bubble records are in use. | ||
| Spawn_Bubble_Create | E07B | EX DE,HL | Point DE at the free record. | |
| E07C | LD HL,$8F1A | Point HL at Sabreman_Record. | ||
| E07F | LD A,($5C78) | Fetch the low byte of the frame counter. | ||
| E082 | ADD A,L | Add the low byte of the address of the record of Sabreman. | ||
| E083 | AND %00111111 | Keep only the low six bits. | ||
| E085 | RET NZ | Return unless they are zero. | ||
| E086 | LD BC,$000F | Set a counter of 0F bytes. | ||
| E089 | PUSH DE | Stash the address of the bubble record. | ||
| E08A | LDIR | Copy the record of Sabreman to the bubble record, except for the redraw flags. | ||
| E08C | POP HL | Restore the address of the bubble record to HL. | ||
| E08D | LD A,$58 | Set the type to 58. | ||
| E08F | LD (HL),A | |||
| E090 | LD A,($8ED6) | Fetch the tick counter. | ||
| E093 | AND %10000000 | Keep only bit 7. | ||
| E095 | ADD A,$40 | Add 40 which makes 40 or C0. | ||
| E097 | INC HL | Move to the x position. | ||
| E098 | LD (HL),A | Set the x position. | ||
| E099 | INC HL | Move to the y position. | ||
| E09A | INC HL | |||
| E09B | LD (HL),$BF | Set the y position to BF. | ||
| E09D | INC HL | Move to the attribute. | ||
| E09E | INC HL | |||
| E09F | LD (HL),$46 | Set the attribute to 46 (yellow). | ||
| E0A1 | LD A,$01 | A=01 (the value of the redraw flags). | ||
| E0A3 | LD DE,$000A | Set the offset from the attribute to the redraw flags of the record (0A). | ||
| E0A6 | ADD HL,DE | Move to the redraw flags. | ||
| E0A7 | LD (HL),A | Set the redraw flags to 01 so that the bubble is drawn without being erased first. | ||
| E0A8 | RET | Return. | ||
| Prev: E027 | Up: Map | Next: E0A9 |