![]() |
Routines |
| Prev: 39196 | Up: Map | Next: 39266 |
|
Used by the routine at DrawRoom.
Called by the main loop. When the counter at CounterLow is zero and bit 0 of CounterHigh is reset, the next of the food items from FoodItems to 60888 is looked at (the food pointer in FoodPointer moves on by 8 bytes, and starts again at FoodItems after the last one). If the item is not in the room of the player and is not already in use then it is made one of the foods (sprite IDs 80 to 87), using FRAMES.
|
||||
| SpawnFood | 39204 | LD A,(24082) | Fetch the counter from CounterLow and keep the low byte of the counter in C. | |
| 39207 | LD C,A | |||
| 39208 | LD A,(24083) | Fetch the high byte of the counter from CounterHigh. | ||
| 39211 | AND %00000001 | Keep only bit 0. | ||
| 39213 | OR C | Return unless the counter is zero and bit 0 of its high byte is reset. | ||
| 39214 | RET NZ | |||
| 39215 | LD HL,(24149) | HL=*FoodPointer. | ||
| 39218 | LD DE,8 | DE=0008 (the size of a food item). | ||
| 39221 | ADD HL,DE | Move HL on to the next food item. | ||
| 39222 | LD (24149),HL | Write HL back to FoodPointer. | ||
| 39225 | PUSH HL | Copy HL into IX, as the food item. | ||
| 39226 | POP IX | |||
| 39228 | LD DE,60888 | DE=60888 (the end of the food items). | ||
| 39231 | AND A | Subtract DE from HL. | ||
| 39232 | SBC HL,DE | |||
| 39234 | JR NC,SpawnFood_Restart | Jump to SpawnFood_Restart if the food pointer is past the last item. | ||
| 39236 | LD A,(60049) | Fetch the room of the player from PlayerRoom. | ||
| 39239 | CP (IX+1) | Return if the player is in the same room. | ||
| 39242 | RET Z | |||
| 39243 | LD A,(IX+0) | Fetch the sprite ID of the item. | ||
| 39246 | AND A | Return if the item is in use. | ||
| 39247 | RET NZ | |||
| 39248 | LD A,(23672) | Fetch FRAMES. | ||
| 39251 | AND %00000111 | Keep only bits 0-2. | ||
| 39253 | ADD A,80 | Add 80 to make the sprite ID of the food. | ||
| 39255 | LD (IX+0),A | Update the sprite ID of the item. | ||
| 39258 | RET | Return. | ||
| SpawnFood_Restart | 39259 | LD HL,60248 | HL=60248. | |
| 39262 | LD (24149),HL | Write HL to FoodPointer. | ||
| 39265 | RET | Return. | ||
| Prev: 39196 | Up: Map | Next: 39266 |