Prev: D8D7 Up: Map Next: D932
D8E7: Put the four villains in random cells at a new game
Used by the routine at NEW_GAME.
The same as PLACE_OBJECTS, with VILLAIN_RECORD and the villains' graphics: 108, 104, 100 and 96 for records 0 to 3 (four pictures each, FACING_PICTURE). Called just before it, and each call advances the turn count and stirs the random number, so the two start from different places in the ROM. A villain can be placed in the knight's first cell; he then dies there as he appears, as often as he comes back.
PLACE_VILLAINS D8E7 CALL NEXT_TURN Advance the turn count and stir the random number
D8EA LD IY,VILLAINS Four records from VILLAINS
D8EE LD B,$04
D8F0 LD DE,(RANDOM) DE: an address in the ROM, from the random number
D8F4 LD A,D
D8F5 AND $0F
D8F7 LD D,A
PLACE_VILLAINS_0 D8F8 LD A,(DE) Read a column and a row from it
D8F9 INC DE
D8FA AND $1F
D8FC LD L,A
D8FD LD A,(DE)
D8FE INC DE
D8FF AND $1F
D901 LD H,A
D902 PUSH BC Look the cell up; try the next pair if it is solid (type 1 or 2)
D903 PUSH HL
D904 CALL LOOK_UP_CELL
D907 POP HL
D908 POP BC
D909 DEC A
D90A CP $02
D90C JR C,PLACE_VILLAINS_0
D90E PUSH BC Copy VILLAIN_RECORD into the record, and point IY at the next one
D90F PUSH DE
D910 PUSH HL
D911 LD HL,VILLAIN_RECORD
D914 LD BC,$0010
D917 PUSH IY
D919 POP DE
D91A ADD IY,BC
D91C LDIR
D91E POP HL Graphic 4 times the count plus 92: 108 for record 0 down to 96 for record 3
D91F POP DE
D920 POP BC
D921 LD A,B
D922 ADD A,A
D923 ADD A,A
D924 ADD A,$5C
D926 LD (IY-$10),A
D929 LD (IY-$0E),L The cell's column and row
D92C LD (IY-$0C),H
D92F DJNZ PLACE_VILLAINS_0 Next record
D931 RET
Prev: D8D7 Up: Map Next: D932