![]() |
Routines |
| Prev: AF05 | Up: Map | Next: AF79 |
|
Used by the routine at InitialiseGame.
Chooses the objects in SpecialObjects at the start of a game. Each is given a random shape of valve (60 to 63), except that every sixteenth entry, counting from a number taken from the random number seed, is an extra life (object 0C). The starting position of each entry is copied to the current position.
|
||||
|
Stir the seeds and fill the table.
|
||||
| InitialiseSpecialObjects | AF3F | LD HL,$76E3 | Point HL at SpecialObjects. | |
| AF42 | LD A,($5B00) | Fetch RandomSeed1. | ||
| AF45 | LD E,A | Keep it in E. | ||
| AF46 | LD A,R | Fetch the refresh register. | ||
| AF48 | ADD A,E | Add the seed to it. | ||
| AF49 | LD E,A | Keep the result in E. | ||
| AF4A | LD A,($5B05) | Fetch RandomSeed2. | ||
| AF4D | LD D,A | Keep it in D. | ||
| InitialiseSpecialObjects_NextEntry | AF4E | DEC D | Count down. | |
| AF4F | LD A,D | Copy the counter to A. | ||
| AF50 | AND %00001111 | Keep bits 0 to 3. | ||
| AF52 | JR Z,InitialiseSpecialObjects_ExtraLife | Jump to InitialiseSpecialObjects_ExtraLife if every sixteenth entry has been reached. | ||
| AF54 | LD A,E | Fetch the random number. | ||
| AF55 | AND %00000011 | Keep bits 0 and 1. | ||
| AF57 | OR %01100000 | Make it a valve. | ||
| InitialiseSpecialObjects_StoreNumber | AF59 | LD (HL),A | Store the object number. | |
| AF5A | INC HL | Move on to the starting position. | ||
| AF5B | INC E | Change the random number. | ||
| AF5C | PUSH DE | Stash the counter and the random number on the stack. | ||
| AF5D | EX DE,HL | Swap the entry pointer into DE. | ||
| AF5E | LD HL,$0004 | Set HL to 0004. | ||
| AF61 | ADD HL,DE | Add it to the starting position. | ||
| AF62 | EX DE,HL | Swap the pointers back. | ||
| AF63 | LD BC,$0004 | Set BC to 0004. | ||
| AF66 | LDIR | Copy the starting position and room. | ||
| AF68 | EX DE,HL | Point HL at the next entry. | ||
| AF69 | PUSH HL | Stash the next entry on the stack. | ||
| AF6A | LD BC,$7827 | Point BC at SpritePointers. | ||
| AF6D | AND A | Subtract SpritePointers from HL. | ||
| AF6E | SBC HL,BC | |||
| AF70 | POP HL | Restore the next entry from the stack. | ||
| AF71 | POP DE | Restore the counter and the random number from the stack. | ||
| AF72 | JR C,InitialiseSpecialObjects_NextEntry | Jump to InitialiseSpecialObjects_NextEntry if there are more entries. | ||
| AF74 | RET | Return. | ||
| InitialiseSpecialObjects_ExtraLife | AF75 | LD A,$0C | Set the object number to 0C. | |
| AF77 | JR InitialiseSpecialObjects_StoreNumber | Jump to InitialiseSpecialObjects_StoreNumber. | ||
|
View the equivalent code in;
|
||||
| Prev: AF05 | Up: Map | Next: AF79 |