Prev: C1B9 Up: Map Next: C1FD
C1DB: Stock the buildings with finds, then the third protection check
Used by the routine at NEW_GAME.
At every new game each cell type from 2 to 35 is given 16-31 finds, the low four bits of bytes read from a random place in the first 4K of the ROM, plus 16 (STOCKS). Types 0, open ground, and 1 get none.
Then the third protection check: bit 7 of R must be set. The refresh counter the Z80 keeps in R counts only its low seven bits, so bit 7 changes only when a program loads R, and the loader did (LOADER). A copy started by any other means has it clear, and falls into RESET, which jumps to address 0: the Spectrum starts again as if just switched on. NEW_LIFE jumps to RESET as well when its own check fails.
STOCK_BUILDINGS C1DB CALL NEXT_TURN count a turn, and stir the random number
C1DE LD HL,(RANDOM) HL = somewhere in the first 4K of the ROM
C1E1 LD A,H
C1E2 AND $0F
C1E4 LD H,A
C1E5 LD DE,$BBD0 16-31 for each type from 2 to 35
C1E8 LD B,$22
STOCK_BUILDINGS_0 C1EA LD A,(HL)
C1EB INC HL
C1EC AND $0F
C1EE OR $10
C1F0 LD (DE),A
C1F1 INC DE
C1F2 DJNZ STOCK_BUILDINGS_0
C1F4 LD A,R protection check 3: R's bit 7, the loader's mark, still set: carry on
C1F6 BIT 7,A
C1F8 RET NZ
This entry point is used by the routine at NEW_LIFE.
RESET C1F9 XOR A RESET: start the Spectrum again (never ran in the sessions)
C1FA LD L,A
C1FB LD H,A
C1FC JP (HL)
Prev: C1B9 Up: Map Next: C1FD