Prev: A647 Up: Map Next: A749
A6C0: After each object's update routine; the end of a turn
Every update routine returns here: the main loop pushes this address before it jumps to one. The refresh register is stirred into the random number, so the sequence depends on how much work the turn did, and the loop goes on to the next record -- or, after the last, ends the turn.
The end of a turn, MAIN_END_OF_TURN: count the turn, stir the random number again, note that a turn has been played, list and draw what changed, and then pad the turn out: the drawing counts its work in DRAW_WORK, and the loop waits six units less that, a unit being 768 turns of a 26 T-state loop, about 20,000 T-states. A room where little moves runs at the speed of one where six things are drawn; a busier room runs slower. Then the clock, which can end the game (RUN_CLOCK).
On the first turn in a room the panel is drawn and coloured (DISPLAY_PANEL, COLOUR_PANEL) and the whole buffer copied to the screen. Then the pause key (HANDLE_PAUSE), and a new life if both of the robot's records have emptied -- they do when his dying sparkle ends -- or the next turn.
While the scene after a game runs (GAME_OVER) there is no waiting and no clock.
OBJECT_DONE A6C0 LD A,R R changes with every instruction fetched
A6C2 LD C,A
A6C3 LD A,(RANDOM)
A6C6 ADD A,C
A6C7 LD (RANDOM),A
A6CA LD BC,$0020 the next record, until BELOW_BLOCK, the end of the records
A6CD ADD IX,BC
A6CF PUSH IX
A6D1 POP HL
A6D2 LD BC,BELOW_BLOCK
A6D5 AND A
A6D6 SBC HL,BC
A6D8 JR NC,MAIN_END_OF_TURN not there yet: the next object
A6DA JR MAIN_NEXT_OBJECT
MAIN_END_OF_TURN A6DC LD HL,(TURNS) count the turn
A6DF INC HL
A6E0 LD (TURNS),HL
A6E3 LD A,(RANDOM) stir in the turn counter and whatever byte it addresses
A6E6 ADD A,(HL)
A6E7 ADD A,L
A6E8 ADD A,H
A6E9 LD (RANDOM),A
A6EC LD HL,PLAYED a turn has been played: the next room built writes back the valves
A6EF SET 0,(HL)
A6F1 CALL LIST_DRAWN list the records flagged to be drawn
A6F4 CALL RENDER_DYNAMIC_OBJECTS wipe, draw in depth order and copy the changes to the screen
A6F7 LD A,(GAME_OVER) the scene after a game: no delay, no clock
A6FA AND A
A6FB JP NZ,OBJECT_DONE_5
A6FE LD A,(DRAW_WORK) six units, less the turn's drawing; none if that is six or more
A701 NEG
A703 ADD A,$06
A705 LD B,A
A706 JP M,OBJECT_DONE_2
A709 JR Z,OBJECT_DONE_2
OBJECT_DONE_0 A70B LD HL,$0300 about 20,000 T-states a unit
OBJECT_DONE_1 A70E DEC HL 26 T-states a turn
A70F LD A,L
A710 OR H
A711 JR NZ,OBJECT_DONE_1
A713 DJNZ OBJECT_DONE_0
OBJECT_DONE_2 A715 CALL RUN_CLOCK the light years: may end the game
A718 LD A,(NEW_ROOM) not the first turn in a room
A71B AND A
A71C JR Z,OBJECT_DONE_4
A71E CALL DISPLAY_PANEL draw the panel, and colour the screen and the panel
A721 CALL COLOUR_PANEL
OBJECT_DONE_3 A724 XOR A once only; the whole buffer to the screen
A725 LD (NEW_ROOM),A
A728 CALL SHOW_BUFFER
A72B CALL CLEAR_WIPE_FLAGS nothing drawn so far needs wiping
OBJECT_DONE_4 A72E CALL HANDLE_PAUSE pause, if SPACE or CAPS SHIFT alone is pressed
A731 LD IX,OBJECTS his legs and top both empty: start a life
A735 LD A,(IX+$00)
A738 OR (IX+$20)
A73B JP Z,MAIN_NEW_LIFE
A73E JP MAIN_NEXT_TURN the next turn
OBJECT_DONE_5 A741 LD A,(NEW_ROOM) in the scene: only the whole-screen copy of its first turn
A744 AND A
A745 JR Z,OBJECT_DONE_4
A747 JR OBJECT_DONE_3
Prev: A647 Up: Map Next: A749