Prev: AF87 Up: Map Next: B097
B00C: One object done; at the end of a turn, draw and wait
Every update routine returns here. It stirs R into the random number -- R counts instructions, so the numbers depend on how long each update took -- and moves IX to the next record, going back to START until all 54 have had their turn.
Then the turn is finished. The turn counter goes up, the objects to be drawn are listed (LIST_DRAWN), and RENDER_DYNAMIC_OBJECTS wipes what moved, draws the objects in depth order and copies the changes to the screen. SPACE or CAPS SHIFT on its own pauses (PAUSE). Then it burns whatever time is left, so that the game runs at an even speed: it waits six units less the turn's drawing work (DRAW_WORK, CONTROL), which SORT_AND_DRAW and RENDER_DYNAMIC_OBJECTS count in objects drawn and areas wiped. A unit is 1280 turns of a 26 T-state loop, about 33,300 T-states, just under half a frame. So a room where fewer than six things change runs as fast as one where six do, and a busier one runs slower: the wait can only pad, never take time back.
On the first turn in a room the whole screen is redrawn: the room's colour over every attribute, the carried things, the panel, the lives and the score, and the whole buffer copied to the screen, with a short sound. Last, if both of the player's records are empty -- they become so when his dying is over -- a life is lost; otherwise the next turn.
OBJECT_DONE B00C LD A,R Stir R, the turn counter's low byte plus one, and the ROM byte at that address into the random number
B00E LD B,A
B00F LD A,(TURNS)
B012 INC A
B013 LD H,$00
B015 LD L,A
B016 ADD A,(HL)
B017 ADD A,B
B018 LD B,A
B019 LD A,(RANDOM)
B01C ADD A,B
B01D LD (RANDOM),A
B020 LD DE,$0020 32 bytes a record
B023 ADD IX,DE
B025 PUSH IX Round again until IX reaches the update table, just past the last record
B027 POP HL
B028 LD DE,UPDATES
B02B AND A
B02C SBC HL,DE
B02E JP C,NEXT_OBJECT
B031 LD HL,(TURNS) The turn is over: count it
B034 INC HL
B035 LD (TURNS),HL
B038 CALL LIST_DRAWN List the records flagged to be drawn
B03B CALL RENDER_DYNAMIC_OBJECTS Wipe what moved, draw in depth order into the buffer, and copy the changes to the screen
B03E LD (MAIN_SP),SP Kept, and never read back
B042 CALL PAUSE SPACE or CAPS SHIFT on its own pauses
B045 LD A,(DRAW_WORK) Six units, less what the turn's drawing already used
B048 NEG
B04A ADD A,$06
B04C LD B,A
B04D JP M,OBJECT_DONE_2 None left to wait
B050 JR Z,OBJECT_DONE_2
OBJECT_DONE_0 B052 LD HL,$0500 One unit: 1280 turns of 26 T-states
OBJECT_DONE_1 B055 DEC HL
B056 LD A,L
B057 OR H
B058 JR NZ,OBJECT_DONE_1
B05A DJNZ OBJECT_DONE_0 The next unit
OBJECT_DONE_2 B05C LD A,(NEW_ROOM) Not the first turn in the room: on to the sound
B05F AND A
B060 JR Z,OBJECT_DONE_3
B062 XOR A Once only
B063 LD (NEW_ROOM),A
B066 LD A,(ROOM_ATTR) The room's colour over the whole screen
B069 CALL FILL_ATTRS
B06C CALL SHOW_CARRIED_NOW The three things he carries
B06F CALL DISPLAY_PANEL The panel's artwork
B072 CALL DRAW_LIVES The lives icon, and the lives
B075 CALL SHOW_BUFFER The whole buffer to the screen
B078 CALL PRINT_SCORE The score, and its heading
B07B CALL CLEAR_COPY_BITS Nothing drawn so far needs wiping: bit 5 of every record's flags cleared
B07E LD HL,$0004 The sound of arriving: sound 0, for four turns
B081 LD (SOUND_COUNT),HL
OBJECT_DONE_3 B084 CALL EFFECT_NOTE A turn of the sound effect under way
B087 LD IX,OBJECTS Both his records empty: a life is lost
B08B LD A,(IX+$00)
B08E OR (IX+$20)
B091 JP Z,RESTART
B094 JP MAIN_LOOP The next turn
Prev: AF87 Up: Map Next: B097