Prev: 88FC Up: Map Next: 898B
8912: Initialise the current room
Used by the routines at 8B07 (to teleport into a room), 8C01 (to reinitialise the room after Willy has lost a life), 948A (when Willy has entered the room from the right), 949E (when Willy has entered the room from the left), 94B0 (when Willy has entered the room from below) and 94D2 (when Willy has entered the room from above). The routine at 88FC also continues here.
Input
Output
8912 LD A,($8420) Pick up the current room number from 8420
8915 OR $C0 Point HL at the first byte of the room definition
8917 LD H,A
8918 LD L,$00
891A LD DE,$8000 Copy the room definition into the game status buffer at 8000
891D LD BC,$0100
8920 LDIR
8922 LD IX,$80F0 Point IX at the first byte of the first entity specification for the current room at 80F0
8926 LD DE,$8100 Point DE at the first byte of the first entity buffer at 8100; this instruction is redundant, since DE already holds 8100
8929 LD A,$08 There are at most eight entities in a room
892B LD L,(IX+$00) Pick up the first byte of the entity specification
892E RES 7,L Point HL at the corresponding entry in the table of entity definitions at A000
8930 LD H,$14
8932 ADD HL,HL
8933 ADD HL,HL
8934 ADD HL,HL
8935 LD BC,$0002 Copy the first two bytes of the entity definition into the entity buffer
8938 LDIR
893A LD C,(IX+$01) Copy the second byte of the entity specification into the third byte of the entity definition
893D LD (HL),C
893E LD BC,$0006 Copy the remaining six bytes of the entity definition into the entity buffer
8941 LDIR
8943 INC IX Point IX at the first byte of the next entity specification
8945 INC IX
8947 DEC A Have we copied all eight entity definitions into the entity buffers yet?
8948 JR NZ,$892B If not, jump back to copy the next one
894A LD HL,$85CF Copy the seven bytes that define Willy's state (position, animation frame etc.) on entry to this room from 85CF-85D5 to 85D7
894D LD DE,$85D7
8950 LD BC,$0007
8953 LDIR
8955 CALL $8D33 Draw the current room to the screen buffer at 7000 and the attribute buffer at 5E00
8958 LD HL,$5000 Clear the bottom third of the display file
895B LD DE,$5001
895E LD BC,$07FF
8961 LD (HL),$00
8963 LDIR
8965 LD IX,$8080 Print the room name (see 8080) at (16,0)
8969 LD C,$20
896B LD DE,$5000
896E CALL $9680
8971 LD IX,$8554 Print "Items collected 000 Time 00:00 m" (see 8554) at (19,0)
8975 LD DE,$5060
8978 LD C,$20
897A CALL $9680
897D LD A,($80DE) Pick up the border colour for the current room from 80DE
8980 LD C,$FE Set the border colour
8982 OUT (C),A
8984 XOR A Initialise the rope status indicator at 85D6 to 0
8985 LD ($85D6),A
8988 JP $89AD Enter the main loop
Prev: 88FC Up: Map Next: 898B