Prev: C5B4 Up: Map Next: C63D
C5CE: Every sixteen turns, a find in the knight's cell if its type has any left
Used by the routine at NEW_GAME.
Not while he is appearing. If a find record is free and the type of cell he stands in still has finds in STOCKS, one is taken from the stock and a find (graphic 48, 52, 56 or 60, by the type's low two bits) put in his cell at a random place 64-191 across it each way, half-size 8. The stock is shared by every cell of the type, and the find keeps the type at +5 so that FIND_WANDER can put it back if he leaves it behind. Open ground, type 0, has no stock: finds come only in cells with buildings.
SPAWN_FIND C5CE LD A,(ARRIVING) not while he appears
C5D1 CP $70
C5D3 RET NZ
C5D4 LD A,(TURNS) one turn in sixteen
C5D7 AND $0F
C5D9 RET NZ
C5DA LD IY,FINDS the first empty find record; none: no find
C5DE LD DE,$0010
C5E1 LD B,$04
SPAWN_FIND_0 C5E3 LD A,(IY+$00)
C5E6 AND A
C5E7 JR Z,SPAWN_FIND_1
C5E9 ADD IY,DE
C5EB DJNZ SPAWN_FIND_0
C5ED RET
SPAWN_FIND_1 C5EE LD A,(KNIGHT_COLUMN) his cell, and its type from the map
C5F1 LD L,A
C5F2 LD A,(KNIGHT_ROW)
C5F5 LD H,A
C5F6 LD E,L
C5F7 LD D,H
C5F8 CALL TOWN_CELL
C5FB LD C,A none left of that type: no find
C5FC LD B,$00
C5FE LD HL,STOCKS
C601 ADD HL,BC
C602 LD A,(HL)
C603 AND A
C604 RET Z
C605 DEC (HL) one fewer; the find in his cell, its type kept at +5
C606 LD (IY+$02),E
C609 LD (IY+$04),D
C60C LD (IY+$05),C
C60F LD A,C graphic 48, 52, 56 or 60 by the type's low two bits
C610 AND $03
C612 ADD A,A
C613 ADD A,A
C614 OR $30
C616 LD (IY+$00),A
C619 LD HL,(RANDOM) a random place in the cell, 64-191 each way
C61C LD A,L
C61D AND $7F
C61F ADD A,$40
C621 LD (IY+$01),A
C624 LD A,H
C625 AND $7F
C627 ADD A,$40
C629 LD (IY+$03),A
C62C LD A,$08 half-size 8 each way; the drawing offset
C62E LD (IY+$08),A
C631 LD (IY+$09),A
C634 LD (IY+$0C),$F8
C638 LD (IY+$0D),$04
C63C RET
Prev: C5B4 Up: Map Next: C63D