![]() |
Routines |
| Prev: C46D | Up: Map | Next: C4AA |
|
Used by the routine at InitialiseGame.
Chooses the objects in SpecialObjectsTable at the start of a game. Each is given a graphic number from 60 to 67 taken from a number made from the random number seed and the refresh register. The starting position of each entry is copied to the current position.
|
||||
|
Stir the seed and fill the table.
|
||||
| InitialiseSpecialObjects | C47E | LD HL,$6FF2 | Point HL at the first special object, SpecialObjectsTable. | |
| C481 | LD A,($5BA0) | Fetch the first random seed from RandomSeed1. | ||
| C484 | LD E,A | Keep it in E. | ||
| C485 | LD A,R | Fetch the refresh register. | ||
| C487 | ADD A,E | Add the seed to it. | ||
| C488 | LD E,A | Keep the result in E. | ||
| InitialiseSpecialObjects_Next | C489 | LD A,E | Copy the number to A. | |
| C48A | AND %00000111 | Keep bits 0 to 2. | ||
| C48C | OR %01100000 | Make it a graphic number from 60 to 67. | ||
| C48E | LD (HL),A | Set the graphic number of the object. | ||
| C48F | INC HL | Move on to the starting position. | ||
| C490 | INC E | Change the number, for the next object. | ||
| C491 | PUSH DE | Stash the number on the stack. | ||
| C492 | EX DE,HL | Swap the entry pointer into DE. | ||
| C493 | LD HL,$0004 | Set HL to 0004. | ||
| C496 | ADD HL,DE | Add it to the starting position. | ||
| C497 | EX DE,HL | Swap the pointers back. | ||
| C498 | LD BC,$0004 | Set BC to 0004. | ||
| C49B | LDIR | Copy the starting position and room. | ||
| C49D | EX DE,HL | Point HL at the next object. | ||
| C49E | PUSH HL | Stash the next entry on the stack. | ||
| C49F | LD BC,$7112 | Point BC at SpriteTable. | ||
| C4A2 | AND A | Subtract SpriteTable from HL. | ||
| C4A3 | SBC HL,BC | |||
| C4A5 | POP HL | Restore the address of the next object from the stack. | ||
| C4A6 | POP DE | Restore the number from the stack. | ||
| C4A7 | JR C,InitialiseSpecialObjects_Next | Jump to InitialiseSpecialObjects_Next until every object has been done. | ||
| C4A9 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: C46D | Up: Map | Next: C4AA |