![]() |
Routines |
| Prev: D8D7 | Up: Map | Next: D932 |
|
Used by the routine at StartGame.
Places the four monsters (type 60, 64, 68 and 6C) in random cells of the village that are not solid, in the objects from ObjectTable_Monsters. The cells come from bytes of the ROM, starting from a random place.
|
||||
|
Point at the first monster and a random place in the ROM.
|
||||
| PlaceMonsters | D8E7 | CALL IncrementFrameCounter | Increase the frame counter, and update the random number generator. | |
| D8EA | LD IY,$BD5E | Point IY at the first object, and set a counter of four monsters. | ||
| D8EE | LD B,$04 | |||
| D8F0 | LD DE,($BBAA) | Make a random address in the first 1000 bytes of the ROM. | ||
| D8F4 | LD A,D | |||
| D8F5 | AND $0F | |||
| D8F7 | LD D,A | |||
|
Place a monster in a cell that is not solid.
|
||||
| PlaceMonsters_Cell | D8F8 | LD A,(DE) | Fetch a column from the ROM. | |
| D8F9 | INC DE | |||
| D8FA | AND $1F | |||
| D8FC | LD L,A | |||
| D8FD | LD A,(DE) | Fetch a row from the ROM. | ||
| D8FE | INC DE | |||
| D8FF | AND $1F | |||
| D901 | LD H,A | |||
| D902 | PUSH BC | Find the tile of the cell. | ||
| D903 | PUSH HL | |||
| D904 | CALL GetMapCell | |||
| D907 | POP HL | |||
| D908 | POP BC | |||
| D909 | DEC A | Try another cell if the tile is solid (01 or 02). | ||
| D90A | CP $02 | |||
| D90C | JR C,PlaceMonsters_Cell | |||
| D90E | PUSH BC | Keep the counter, the address in the ROM and the cell. | ||
| D90F | PUSH DE | |||
| D910 | PUSH HL | |||
| D911 | LD HL,$D932 | Copy the template for a monster into the object, and move on to the next object. | ||
| D914 | LD BC,$0010 | |||
| D917 | PUSH IY | |||
| D919 | POP DE | |||
| D91A | ADD IY,BC | |||
| D91C | LDIR | |||
| D91E | POP HL | Restore the cell, the ROM address and the counter from the stack. | ||
| D91F | POP DE | |||
| D920 | POP BC | |||
| D921 | LD A,B | Set the type of the monster from the counter. | ||
| D922 | ADD A,A | |||
| D923 | ADD A,A | |||
| D924 | ADD A,$5C | |||
| D926 | LD (IY-$10),A | |||
| D929 | LD (IY-$0E),L | Set the column and the row of the monster. | ||
| D92C | LD (IY-$0C),H | |||
| D92F | DJNZ PlaceMonsters_Cell | Loop back until all four monsters have been placed. | ||
| D931 | RET | Return. | ||
| Prev: D8D7 | Up: Map | Next: D932 |