![]() |
Routines |
| Prev: AE2F | Up: Map | Next: B00C |
|
Used by the routine at ENTRY.
Reached from ENTRY when the game has loaded. Clears the variables and the object records, and then does what every game does: clears the screen, builds the drawing tables (MAKE_TABLES), gives five lives, stirs the random number, and runs the menu (MENU) until 0 is pressed. Then the tune a game starts with, the quest's records afresh with the collectables placed (NEW_QUEST), and a start room chosen (CHOOSE_START).
From there it is three loops, one inside another. RESTART starts a life: RESTART_PLAYER copies the player template over his two records and takes a life, and ends the game when there are none. GAME_LOOP enters a room: it files the quest things of the room being left back in their records, builds the room he is in (ENTER_ROOM), puts the quest things that are there into it, decides whether anything may fall from the sky there, prints the score and sets the drop timer. EXIT_LOW_U jumps back to it when he walks through a doorway. MAIN_LOOP is a turn: a chance of something falling, then every one of the 54 object records' update routines in turn, and OBJECT_DONE, which ends the turn, draws what changed and goes round again.
Each object's update routine is found in UPDATES by its graphic and entered by a jump, with the address of OBJECT_DONE pushed first so that it ends with a RET. Unlike Knight Lore's loop, this one does not reset the stack pointer for each object: the routines keep the stack straight themselves.
|
||||
| START | AF87 | XOR A | A black border, and the speaker off | |
| AF88 | OUT ($FE),A | |||
| AF8A | LD HL,CONTROL | Clear the variables and all 54 object records, up to the update table | ||
| AF8D | LD BC,$0726 | |||
| AF90 | CALL CLEAR_MEMORY | |||
|
This entry point is used by the routine at WON.
|
||||
| AFTER_GAME | AF93 | LD HL,BUCKET_OUT | After a game (WON): the same from BUCKET_OUT on, which keeps the control method, the menu's bytes and the random number | |
| AF96 | LD BC,$0721 | |||
| AF99 | CALL CLEAR_MEMORY | |||
| AF9C | CALL CLEAR_SCREEN | Clear the screen | ||
| AF9F | LD A,$43 | Bright magenta ink on black, the whole screen | ||
| AFA1 | CALL FILL_ATTRS | |||
| AFA4 | CALL MAKE_TABLES | The shift tables and the bit reversal table | ||
| AFA7 | LD A,$05 | Five lives: the first start of a life takes one | ||
| AFA9 | LD (LIVES),A | |||
| AFAC | LD A,R | Stir R into the random number, which then decides the rest | ||
| AFAE | LD B,A | |||
| AFAF | LD A,(RANDOM) | |||
| AFB2 | ADD A,B | |||
| AFB3 | LD (RANDOM),A | |||
| AFB6 | CALL MENU | The menu, until 0 is pressed | ||
| AFB9 | LD DE,TUNE_START | The tune a game starts with | ||
| AFBC | CALL PLAY_TUNE | |||
| AFBF | CALL NEW_QUEST | The quest records afresh, and the collectables' starting spots | ||
| AFC2 | CALL CHOOSE_START | One of four start rooms, into the player template | ||
|
This entry point is used by the routine at OBJECT_DONE.
|
||||
| RESTART | AFC5 | CALL RESTART_PLAYER | Start a life: the player template over both his records, and a life fewer; with none left the game is over | |
|
This entry point is used by the routine at EXIT_LOW_U.
|
||||
| GAME_LOOP | AFC8 | CALL QUEST_OUT_OF_ROOM | Enter a room: first the quest things of the room he was in go back to their records | |
| AFCB | CALL ENTER_ROOM | Build the room he is now in | ||
| AFCE | CALL QUEST_INTO_ROOM | Put the quest things that are in it into the room's records | ||
| AFD1 | CALL BAN_DROPS | Nothing falls from the sky in a room with the well, a quest item or a piece of the pentagram | ||
| AFD4 | CALL PRINT_SCORE | The score, and its heading | ||
| AFD7 | CALL RESET_DROP_TIMER | Turns until something may fall | ||
|
This entry point is used by the routine at OBJECT_DONE.
|
||||
| MAIN_LOOP | AFDA | CALL SKY_DROP | A turn: first, perhaps, something falls from the sky | |
| AFDD | LD IX,OBJECTS | IX on the first record, the player's legs | ||
|
This entry point is used by the routine at OBJECT_DONE.
|
||||
| NEXT_OBJECT | AFE1 | LD HL,OBJECT_DONE | The update routine returns to OBJECT_DONE | |
| AFE4 | PUSH HL | |||
| AFE5 | LD BC,UPDATES | The update routines | ||
| AFE8 | LD A,(IX+$18) | Keep last turn's drawn width, height and position in +1C to +1F, so the old picture can be wiped | ||
| AFEB | LD (IX+$1C),A | |||
| AFEE | LD A,(IX+$19) | |||
| AFF1 | LD (IX+$1D),A | |||
| AFF4 | LD A,(IX+$1A) | |||
| AFF7 | LD (IX+$1E),A | |||
| AFFA | LD A,(IX+$1B) | |||
| AFFD | LD (IX+$1F),A | |||
| UPDATE_OBJECT | B000 | LD L,(IX+$00) | The graphic is the index | |
|
|
||||
| JUMP_TO_TBL_ENTRY | B003 | LD H,$00 | HL = BC + 2 * L: a word in a table of routines. SORT_AND_DRAW, CALC_PLYR_DUV and HANDLE_EXIT_SCREEN jump in here with tables of their own | |
| B005 | ADD HL,HL | |||
| B006 | ADD HL,BC | |||
| B007 | LD A,(HL) | Load the address, and go | ||
| B008 | INC HL | |||
| B009 | LD H,(HL) | |||
| B00A | LD L,A | |||
| B00B | JP (HL) | |||
| Prev: AE2F | Up: Map | Next: B00C |