![]() |
Routines |
| Prev: CB71 | Up: Map | Next: CBAC |
|
Used by the routine at NEW_GAME.
Called by NEW_GAME at every new game. The random number, stirred (NEXT_TURN), gives a cell of the town map at random; if it is solid (types 1 and 2) the next cell in the map is tried, and the next, until one is not. Its column and row go into the start records (START_RECORDS), where NEW_LIFE takes them from; he starts in the middle of the cell. Only the cells a knight can stand in are chosen, but not all equally: a cell just after a run of solid ones in the map is chosen for the whole run as well as for itself.
|
||||
| RANDOM_START_CELL | CB7B | CALL STIR_RANDOM | stir the random number with R | |
| CB7E | LD DE,(RANDOM) | DE = a cell, 0-1023: the row in bits 5-9, the column in bits 0-4 | ||
| RANDOM_START_CELL_0 | CB82 | LD A,D | ||
| CB83 | AND $03 | |||
| CB85 | LD D,A | |||
| CB86 | LD HL,TOWN | is it solid, type 1 or 2? | ||
| CB89 | ADD HL,DE | |||
| CB8A | LD A,(HL) | |||
| CB8B | DEC A | |||
| CB8C | CP $02 | |||
| CB8E | JR NC,RANDOM_START_CELL_1 | |||
| CB90 | INC DE | then the next one | ||
| CB91 | JR RANDOM_START_CELL_0 | |||
| RANDOM_START_CELL_1 | CB93 | LD A,E | the column | |
| CB94 | AND $1F | |||
| CB96 | LD (START_U_CELL),A | |||
| CB99 | RL E | and the row, from bits 5-9 | ||
| CB9B | RL D | |||
| CB9D | RL E | |||
| CB9F | RL D | |||
| CBA1 | RL E | |||
| CBA3 | RL D | |||
| CBA5 | LD A,D | |||
| CBA6 | AND $1F | |||
| CBA8 | LD (START_V_CELL),A | |||
| CBAB | RET | |||
| Prev: CB71 | Up: Map | Next: CBAC |