Prev: B759 Up: Map Next: B7F5
B761: The game is over
Used by the routines at RUN_CLOCK, LOOSE_VALVE and NEW_LIFE.
Jumped to when the last life is lost (NEW_LIFE), when the clock runs out (RUN_CLOCK), and when the twenty-fourth chamber is activated (LOOSE_VALVE). The valves in the room are put back in their places first (UPDATE_SPECIAL_OBJS). A won game shows the arrival screen (ARRIVAL_SCREEN) first, which comes back to SUMMARY_SCREEN.
The summary: the buffer cleared, the screen blanked with bright red attributes, and seven lines from the text list at SUMMARY_COLOURS -- the heading, the activated and unactivated chambers, the crew lost, and the overall rating -- then the rating, one of eight from the table after it, printed at x 88, line 39 of the buffer; then the counts are worked out (SUMMARISE_CHAMBERS) and printed (PRINT_SUMMARY_COUNTS), the border drawn and the whole shown. The game-over tune plays until a key is pressed (after any key held is let go), and then the summary stays up for about fourteen seconds more or until another key.
The rating: bit 0 of WON picks the better four of the eight, and bits 5 and 6 of the number of rooms seen less one (COUNT_ROOMS_SEEN) one of those four -- so it goes up a step for every 32 rooms seen, and a player who wins is rated above any who does not. As Knight Lore's game_over_summary.
Then the scene: GAME_OVER is set, the buffer and the object records are cleared, the attributes made bright red, and the scene's objects put in the records (SET_UP_SCENE) -- the re-programming of the robot (SCENE_LOST) after a lost game, with the flashing text RE-PROGRAMMING (REPROGRAMMING) at x 72, line 159; the robot and an oil can (the list at SCENE_WON in SCENE_LOST_END) after a won one. NEW_ROOM is set and the main loop takes over: the scene's update routines run it, and one of them returns to the menu (AFTER_GAME).
Output
SP the main loop resets it
GAME_ENDED B761 CALL UPDATE_SPECIAL_OBJS the valves in the room back in their places
B764 LD A,(WON) won: the arrival screen first
B767 AND A
B768 JP NZ,ARRIVAL_SCREEN
This entry point is used by the routine at ARRIVAL_SCREEN.
SUMMARY_SCREEN B76B CALL CLEAR_SCRN_BUFFER clear the buffer; the border black, the attributes bright red, the screen blank
B76E CALL CLEAR_SCRN
B771 LD DE,SUMMARY_COLOURS colours from SUMMARY_COLOURS, then positions and strings from the two tables after it: seven lines. The screen was shown once this game already, so the list only draws into the buffer
B774 EXX
B775 LD HL,SUMMARY_XY
B778 LD DE,SUMMARY_TEXT
B77B LD B,$07
B77D CALL DISPLAY_TEXT_LIST
B780 CALL COUNT_ROOMS_SEEN the rooms seen less one: bits 5 and 6, as bits 6 and 7
B783 RLCA
B784 AND $C0
B786 LD C,A
B787 LD A,(WON) with WON as bit 0
B78A AND $01
B78C OR C
B78D RLCA rotated into a word offset: WON * 8 + the rooms' bits * 2
B78E RLCA
B78F RLCA
B790 AND $0E
B792 LD L,A
B793 LD H,$00
B795 LD BC,RATINGS DE = the rating's text, from the table of ratings in SUMMARY_RATING_LAST
B798 ADD HL,BC
B799 LD E,(HL)
B79A INC HL
B79B LD D,(HL)
B79C LD HL,$2758 print it at x 88, line 39; its first byte is its colour
B79F CALL PRINT_TEXT
B7A2 CALL SUMMARISE_CHAMBERS work out the summary's counts, and print them into the buffer
B7A5 CALL PRINT_SUMMARY_COUNTS
B7A8 CALL PRINT_BORDER the border; show it all
B7AB CALL SHOW_BUFFER
GAME_ENDED_0 B7AE XOR A wait until no key is held
B7AF CALL READ_KEYS
B7B2 JR NZ,GAME_ENDED_0
B7B4 LD DE,TUNE_GAME_OVER the game-over tune, until a key
B7B7 CALL PLAY_TUNE_TILL_KEY
B7BA LD B,$08 then about 14 seconds more, or until a key
B7BC CALL WAIT_KEY_OR_TIME
B7BF LD A,$01 the scene after a game is on
B7C1 LD (GAME_OVER),A
B7C4 CALL CLEAR_SCRN_BUFFER clear the buffer; the border; show it
B7C7 CALL PRINT_BORDER
B7CA CALL SHOW_BUFFER
B7CD CALL CLEAR_OBJECTS clear the object records
B7D0 CALL CLR_ATTRIBUTE_MEMORY the attributes bright red
B7D3 LD A,(WON) won?
B7D6 AND A
B7D7 JR NZ,GAME_ENDED_2
B7D9 LD HL,$9F48 lost: RE-PROGRAMMING at x 72, line 159
B7DC LD DE,REPROGRAMMING
B7DF CALL PRINT_TEXT
B7E2 LD DE,SCENE_LOST the lost game's scene
GAME_ENDED_1 B7E5 CALL SET_UP_SCENE its objects into the records
B7E8 LD A,$01 a new room: the main loop redraws it all, and runs the scene
B7EA LD (NEW_ROOM),A
B7ED JP MAIN_NEXT_TURN
GAME_ENDED_2 B7F0 LD DE,SCENE_WON won: the won game's scene
B7F3 JR GAME_ENDED_1
Prev: B759 Up: Map Next: B7F5