Prev: FCDC Up: Map Next: FE15
FD20: Enter the room in ROOM, or end the quest (the author's ROOMST)
Used by the routines at TITLE_SCREEN and BUMPED.
Called by a new game (TITLE_SCREEN, at TELE) and jumped to from the door code (BUMPED) once the knight's record has its new place. It does not return until the game is over: the main loop (MAIN_LOOP) runs inside it and returns from it when LIFE is gone, or on SYMBOL SHIFT and 0, back to TITLE_SCREEN for GAME OVER. A door, and the thing that carries the knight off, come back in here with the stack as it was.
Room 81 is the end of the quest. Its picture is drawn and the verdict printed: success if any of the five things carried is number 5 in the object table (+$13; the thing that lies in room 33), failure if not. An empty place reads as a record at address 0, whose +$13 is a ROM byte ($FF) and never matches. Then the two lines of MESS2, a key (WAIT), and back to GAME OVER.
Any other room is entered at LOAD_ROOM (the author's ROS). First the carried things: their records, wherever the last room left them, are copied to the first places after the knight's, in the order of the five places, and each place is pointed at its record's new home. They go by way of BUFFER_D900, as one record may be moved onto another that has still to be copied. IY steps two bytes a place through the loop (the author's OBJD to OB2) so that IY+$1F and IY+$20 are each place in turn. OBJECT_COUNT becomes 7 and one for each thing carried; FREE_RECORD the next place. Then the room is drawn (DRAW_CURRENT_ROOM), which also makes the records of its objects, the six strike counters are set to 4, LIFE's label is printed, and the bare room is copied to the clean copy of the screen (RESTOR) before DRAW_STILL_THINGS draws the still things and starts the main loop.
ROOMST FD20 LD DE,RECORDS DE = the first record after the knight's: where the carried things go
FD23 LD A,(IY+ROOM-V) Room 0 (room 10's hole): the game ends
FD26 AND A
FD27 RET Z
FD28 CP $51 Any room but 81: LOAD_ROOM
FD2A JR NZ,LOAD_ROOM
FD2C CALL DRAW_CURRENT_ROOM Draw room 81's picture and colour the screen; then print the start of the verdict
FD2F CALL ATTRI
FD32 CALL PRINT
FD35 DEFB $C8,$48,$78 Print at x 72, y 120
FD38 DEFB $19,$0F,$15,$00,$08,$01,$16,$05 "YOU HAVE "
FD40 DEFB $00
FD41 DEFB $A4 End of the string
FD42 LD HL,CARRIED
FD45 LD B,$05
ROOMST_0 FD47 LD E,(HL) IX = the record in this place
FD48 INC HL
FD49 LD D,(HL)
FD4A INC HL
FD4B PUSH DE
FD4C POP IX
FD4E LD A,(IX+OBJ_NUMBER) Number 5 in the object table: print success
FD51 CP $05
FD53 JR Z,ROOMST_1
FD55 DJNZ ROOMST_0 Try the next place; after the last, print failure
FD57 CALL PRINT
FD5A DEFB $06,$01,$09,$0C,$05,$04 "FAILED"
FD60 DEFB $A4 End of the string
FD61 JR ROOMST_2
ROOMST_1 FD63 CALL PRINT
FD66 DEFB $13,$15,$03,$03,$05,$04,$05,$04 "SUCCEDED"
FD6E DEFB $A4 End of the string
ROOMST_2 FD6F CALL PRINT
FD72 DEFB $00,$09,$0E " IN"
FD75 DEFB $C8,$14,$64 Print at x 20, y 100
FD78 DEFB $19,$0F,$15,$12,$00,$11,$15,$05 "YOUR QUEST THE WIZARD IS FREE"
FD80 DEFB $13,$14,$00,$14,$08,$05,$00,$17
FD88 DEFB $09,$1A,$01,$12,$04,$00,$09,$13
FD90 DEFB $00,$06,$12,$05,$05
FD95 DEFB $A4 End of the string
FD96 CALL MESS2
FD99 JP WAIT Wait for a key, and return to the new game's code: GAME OVER
LOAD_ROOM FD9C LD (IY+OBJECT_COUNT-V),$07 LOAD_ROOM: seven records, the six fixed ones and the knight's
FDA0 LD B,$05 Five places; the records gather in BUFFER_D900 first, the pointer in POINT (the author's T)
FDA2 LD HL,BUFFER_D900
FDA5 LD (POINT),HL
ROOMST_3 FDA8 LD L,(IY+$1F) HL = the record in the next place, IY moved on two
FDAB INC IY
FDAD LD H,(IY+$1F)
FDB0 INC IY
FDB2 LD A,L
FDB3 OR H
FDB4 JR Z,ROOMST_4
FDB6 LD (IY+$1D),E Point the place at DE, the record's new home
FDB9 LD (IY+$1E),D
FDBC PUSH BC DE on to the next home
FDBD LD BC,$0014
FDC0 EX DE,HL
FDC1 ADD HL,BC
FDC2 EX DE,HL
FDC3 PUSH DE Copy the record's 20 bytes to the buffer
FDC4 LD DE,(POINT)
FDC8 LDIR
FDCA LD (POINT),DE
FDCE POP DE
FDCF POP BC
FDD0 LD A,(OBJECT_COUNT) One more record in use
FDD3 INC A
FDD4 LD (OBJECT_COUNT),A
ROOMST_4 FDD7 DJNZ ROOMST_3 Next place (the author's OB2)
FDD9 LD (FREE_RECORD),DE The room's own records start after the carried things
FDDD LD DE,RECORDS Copy the carried things into place (five records' worth, whatever was carried)
FDE0 LD HL,BUFFER_D900
FDE3 LD BC,$0064
FDE6 LDIR
FDE8 LD IY,OBJECT_COUNT IY back on the variables
FDEC CALL DRAW_CURRENT_ROOM Draw the room and make its objects' records
FDEF LD A,$04 Four strikes in each of the six counters; then print LIFE's label
FDF1 LD HL,STRIKES_LEFT
FDF4 LD B,$06
ROOMST_5 FDF6 LD (HL),A
FDF7 INC HL
FDF8 DJNZ ROOMST_5
FDFA CALL PRINT
FDFD DEFB $C8,$30,$14 Print at x 48, y 20
FE00 DEFB $0C,$09,$06,$05 "LIFE"
FE04 DEFB $A4 End of the string
FE05 CALL RESTOR
FE08 LD HL,RECORDS From the first record after the knight's, with bit 4 of GAME_FLAGS set: still things are drawn into the room
FE0B LD (IY+THIS_RECORD-V),$07
FE0F SET 4,(IY+GAME_FLAGS-V)
FE13 JR DRAW_STILL_THINGS_1 Draw them (DRAW_STILL_THINGS)
Room 0 returns at once, which ends the game: a new game's room comes from the master copy (MASTER_OBJECTS), where it is 29, but door record 185, a hole in room 10's floor, leads to room 0, so falling through it ends the game with LIFE still full (measured for the Facts page).
Prev: FCDC Up: Map Next: FE15