![]() |
Routines |
| Prev: 44805 | Up: Map | Next: 44921 |
|
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 (96 to 99), except that every sixteenth entry, counting from a number taken from the random number seed, is an extra life (object 12). The starting position of each entry is copied to the current position.
|
||||
|
Stir the seeds and fill the table.
|
||||
| InitialiseSpecialObjects | 44863 | LD HL,30435 | Point HL at SpecialObjects. | |
| 44866 | LD A,(23296) | Fetch RandomSeed1. | ||
| 44869 | LD E,A | Keep it in E. | ||
| 44870 | LD A,R | Fetch the refresh register. | ||
| 44872 | ADD A,E | Add the seed to it. | ||
| 44873 | LD E,A | Keep the result in E. | ||
| 44874 | LD A,(23301) | Fetch RandomSeed2. | ||
| 44877 | LD D,A | Keep it in D. | ||
| InitialiseSpecialObjects_NextEntry | 44878 | DEC D | Count down. | |
| 44879 | LD A,D | Copy the counter to A. | ||
| 44880 | AND %00001111 | Keep bits 0 to 3. | ||
| 44882 | JR Z,InitialiseSpecialObjects_ExtraLife | Jump to InitialiseSpecialObjects_ExtraLife if every sixteenth entry has been reached. | ||
| 44884 | LD A,E | Fetch the random number. | ||
| 44885 | AND %00000011 | Keep bits 0 and 1. | ||
| 44887 | OR %01100000 | Make it a valve. | ||
| InitialiseSpecialObjects_StoreNumber | 44889 | LD (HL),A | Store the object number. | |
| 44890 | INC HL | Move on to the starting position. | ||
| 44891 | INC E | Change the random number. | ||
| 44892 | PUSH DE | Stash the counter and the random number on the stack. | ||
| 44893 | EX DE,HL | Swap the entry pointer into DE. | ||
| 44894 | LD HL,4 | Set HL to 0004. | ||
| 44897 | ADD HL,DE | Add it to the starting position. | ||
| 44898 | EX DE,HL | Swap the pointers back. | ||
| 44899 | LD BC,4 | Set BC to 0004. | ||
| 44902 | LDIR | Copy the starting position and room. | ||
| 44904 | EX DE,HL | Point HL at the next entry. | ||
| 44905 | PUSH HL | Stash the next entry on the stack. | ||
| 44906 | LD BC,30759 | Point BC at SpritePointers. | ||
| 44909 | AND A | Subtract SpritePointers from HL. | ||
| 44910 | SBC HL,BC | |||
| 44912 | POP HL | Restore the next entry from the stack. | ||
| 44913 | POP DE | Restore the counter and the random number from the stack. | ||
| 44914 | JR C,InitialiseSpecialObjects_NextEntry | Jump to InitialiseSpecialObjects_NextEntry if there are more entries. | ||
| 44916 | RET | Return. | ||
| InitialiseSpecialObjects_ExtraLife | 44917 | LD A,12 | Set the object number to 12. | |
| 44919 | JR InitialiseSpecialObjects_StoreNumber | Jump to InitialiseSpecialObjects_StoreNumber. | ||
|
View the equivalent code in;
|
||||
| Prev: 44805 | Up: Map | Next: 44921 |