![]() |
Routines |
| Prev: CEF8 | Up: Map | Next: CFAF |
|
Used by the routine at NEW_GAME.
Called every turn by NEW_GAME. The view shows the knight's cell and the eight round it; they are drawn back to front, the back ones in an order that depends on which of them are built on. Everything here is in the view's coordinates: with the town turned round (VIEW) his cell is turned round first (TURN_CELL), and the map is read through the view (LOOK_UP_CELL), so U-1 is always further back.
Five cells lie behind or beside his: U-1 V+1, U-1, V+1, U-1 V-1 and U+1 V+1. A bit for each that is not open ground, bits 0 to 4 in that order, picks one of 32 records of five steps in DRAW_ORDER. Each step byte gives a cell as an offset from his -- bits 4-5 for U, bits 6-7 for V: bit 5 (or 7) the same, bit 4 (or 6) one more, neither one less -- and in bits 0-1 what to draw there: 0 the things in it (LIST_THINGS_IN_CELL, SORT_AND_DRAW_THINGS), 1 its walls (DRAW_WALLS), 2 its walls by DRAW_OUTLINE, 3 nothing.
Every record gives the five cells, each with action 1 if it is built on and 0 if not: actions 2 and 3 are in no record, and their instructions never ran. Last come his own cell and the three in front of it, V-1, U+1 and U+1 V-1, each with its walls by DRAW_OUTLINE -- the routine action 2 would have used -- and then the things in it.
|
||||
| DRAW_CELLS | CF08 | LD HL,$E001 | no columns drawn yet this turn (DRAW_WALL_COLUMN) | |
| CF0B | LD (COLUMNS_DRAWN),HL | |||
| CF0E | LD A,(KNIGHT_COLUMN) | HL = his cell, as the view sees it | ||
| CF11 | LD L,A | |||
| CF12 | LD A,(KNIGHT_ROW) | |||
| CF15 | LD H,A | |||
| CF16 | CALL TURN_CELL | |||
| CF19 | PUSH HL | kept, for every step | ||
| CF1A | LD E,$00 | bit 0: U-1 V+1 not open | ||
| CF1C | DEC L | |||
| CF1D | INC H | |||
| CF1E | CALL LOOK_UP_CELL | |||
| CF21 | JR Z,DRAW_CELLS_0 | |||
| CF23 | SET 0,E | |||
| DRAW_CELLS_0 | CF25 | POP HL | bit 1: U-1 | |
| CF26 | PUSH HL | |||
| CF27 | DEC L | |||
| CF28 | CALL LOOK_UP_CELL | |||
| CF2B | JR Z,DRAW_CELLS_1 | |||
| CF2D | SET 1,E | |||
| DRAW_CELLS_1 | CF2F | POP HL | bit 2: V+1 | |
| CF30 | PUSH HL | |||
| CF31 | INC H | |||
| CF32 | CALL LOOK_UP_CELL | |||
| CF35 | JR Z,DRAW_CELLS_2 | |||
| CF37 | SET 2,E | |||
| DRAW_CELLS_2 | CF39 | POP HL | bit 3: U-1 V-1 | |
| CF3A | PUSH HL | |||
| CF3B | DEC L | |||
| CF3C | DEC H | |||
| CF3D | CALL LOOK_UP_CELL | |||
| CF40 | JR Z,DRAW_CELLS_3 | |||
| CF42 | SET 3,E | |||
| DRAW_CELLS_3 | CF44 | POP HL | bit 4: U+1 V+1 | |
| CF45 | PUSH HL | |||
| CF46 | INC L | |||
| CF47 | INC H | |||
| CF48 | CALL LOOK_UP_CELL | |||
| CF4B | JR Z,DRAW_CELLS_4 | |||
| CF4D | SET 4,E | |||
| DRAW_CELLS_4 | CF4F | LD D,$00 | DE = the drawing order's record for them, five bytes each; five steps | |
| CF51 | LD A,E | |||
| CF52 | EX DE,HL | |||
| CF53 | LD E,L | |||
| CF54 | LD D,H | |||
| CF55 | ADD HL,HL | |||
| CF56 | ADD HL,HL | |||
| CF57 | ADD HL,DE | |||
| CF58 | LD DE,DRAW_ORDER | |||
| CF5B | ADD HL,DE | |||
| CF5C | EX DE,HL | |||
| CF5D | LD B,$05 | |||
| DRAW_STEP | CF5F | POP HL | his cell again; the step's byte | |
| CF60 | PUSH HL | |||
| CF61 | LD A,(DE) | |||
| CF62 | INC DE | |||
| CF63 | BIT 5,A | U: bit 5 the same, bit 4 one more, neither one less | ||
| CF65 | JR NZ,DRAW_CELLS_6 | |||
| CF67 | BIT 4,A | |||
| CF69 | JR Z,DRAW_CELLS_5 | |||
| CF6B | INC L | |||
| CF6C | INC L | |||
| DRAW_CELLS_5 | CF6D | DEC L | ||
| DRAW_CELLS_6 | CF6E | BIT 7,A | V: bit 7 the same, bit 6 one more, neither one less | |
| CF70 | JR NZ,DRAW_CELLS_8 | |||
| CF72 | BIT 6,A | |||
| CF74 | JR Z,DRAW_CELLS_7 | |||
| CF76 | INC H | |||
| CF77 | INC H | |||
| DRAW_CELLS_7 | CF78 | DEC H | ||
| DRAW_CELLS_8 | CF79 | AND $03 | the action; the count and the record kept, and DRAW_STEP_DONE to return to | |
| CF7B | PUSH BC | |||
| CF7C | PUSH DE | |||
| CF7D | LD DE,DRAW_STEP_DONE | |||
| CF80 | PUSH DE | |||
| CF81 | JP Z,DRAW_CELL_THINGS | 0: the things in it | ||
| CF84 | DEC A | 1: its walls | ||
| CF85 | JP Z,DRAW_WALLS | |||
| CF88 | DEC A | 2: its outline on the ground by DRAW_OUTLINE (no record has it; never ran) | ||
| CF89 | JP Z,DRAW_OUTLINE | |||
| CF8C | POP DE | 3: nothing -- the return address dropped (never ran either) | ||
| DRAW_STEP_DONE | CF8D | POP DE | the next step | |
| CF8E | POP BC | |||
| CF8F | DJNZ DRAW_STEP | |||
| CF91 | POP HL | his own cell | ||
| CF92 | PUSH HL | |||
| CF93 | CALL DRAW_FRONT_CELL | |||
| CF96 | POP HL | V-1 | ||
| CF97 | PUSH HL | |||
| CF98 | DEC H | |||
| CF99 | CALL DRAW_FRONT_CELL | |||
| CF9C | POP HL | U+1 | ||
| CF9D | PUSH HL | |||
| CF9E | INC L | |||
| CF9F | CALL DRAW_FRONT_CELL | |||
| CFA2 | POP HL | U+1 V-1, whose RET ends the routine | ||
| CFA3 | INC L | |||
| CFA4 | DEC H | |||
| DRAW_FRONT_CELL | CFA5 | PUSH HL | a front cell: its walls by DRAW_OUTLINE, if it is built on... | |
| CFA6 | CALL DRAW_OUTLINE | |||
| CFA9 | POP HL | |||
| DRAW_CELL_THINGS | CFAA | CALL LIST_THINGS_IN_CELL | ...then the things in it: listed (LIST_THINGS_IN_CELL), and drawn in depth order (SORT_AND_DRAW_THINGS) | |
| CFAD | JR SORT_AND_DRAW_THINGS | |||
| Prev: CEF8 | Up: Map | Next: CFAF |