Routines |
Prev: C107 | Up: Map | Next: C1C0 |
|
||||
Find the current's room data set in the table at 61A9:
|
||||
C15A | LD HL,($DAF7) | Pointer to series of room data sets at 61A9. | ||
C15D | LD A,($EAB7) | Get room number | ||
C160 | LD C,A | Store in C register | ||
C161 | LD B,$01 | Set incremental compare counter to compare room number against | ||
Identify data set for current room from list at 61A9
|
||||
C163 | LD A,C | |||
C164 | CP B | |||
C165 | JR Z,$C170 | If room data byte (A) = counter (B), we're at the right place, so skip out of the loop | ||
Not this set. Move to the end of the set (set length will vary)
|
||||
C167 | LD A,(HL) | Get byte of room data set | ||
C168 | INC HL | Increment it | ||
C169 | CP $FF | Are we at an end-of-data-set marker? | ||
C16B | JR NZ,$C167 | Continue till we are | ||
C16D | INC B | We're at the end of this set. Increment the counter | ||
C16E | JR $C163 | Keep comparing until we're at the right place for the room | ||
Data set for current room identified
|
||||
C170 | LD ($EB7A),HL | Store address pointer for current room data bank. | ||
Check if the room is a vertical tunnel
|
||||
C173 | CP $E0 | Tunnel rooms are room number 224 and above | ||
C175 | JP NC,$C5B5 | If we're in one of these, skip out of this routine as tunnel data is different from room data | ||
Identify offset for room scenery graphics.
|
||||
C178 | CP $53 | Rooms 1-82 are 'brick' style levels (e.g. Gatehouse Level). Is the room number less than 83? | ||
C17A | LD A,$00 | ...If so, graphic address pointer offset is zero | ||
C17C | JR C,$C180 | |||
C17E | LD A,$0C | If room number is 83 or above (e.g. Mines of Madness), graphic address offset is 12 | ||
C180 | LD ($EB77),A | Store level type graphic address offset | ||
The next set of instructions reset the room position:
|
||||
C183 | LD HL,$0000 | |||
C186 | LD ($EB4C),HL | Set horizontal (EB4C) & vertical (EB4D) movement speed to zero | ||
C189 | LD ($EB47),HL | Set horizontal room position to zero | ||
C18C | LD ($EB49),HL | Set vertical room position to zero | ||
C18F | LD A,$40 | |||
C191 | LD ($EB4B),A | This byte is set to 64 for 'standard' rooms, 254/255 for tunnels (byte 9 of data set at 7C00) | ||
C194 | LD A,$20 | |||
C196 | LD ($EB43),A | Room item type = room (general). This is the first data set stored in the room data sets at 7C00 and indicates the base room position/attributes | ||
C199 | LD A,$02 | Item properties byte. Because this is just the general room/viewport position & data, can just set bit 1 (2) = hidden (nothing to draw) | ||
C19B | LD ($EB4E),A | |||
C19E | CALL $E0B0 | Copy the 16 bytes of room data from working buffer at EB43 to the first of the room item data sets at 7C00 | ||
C1A1 | LD A,$05 | Resets the item properties ready for the next room item. Default setting sets bits 0 (visible on-screen) and 2 (needs to be erased before re-drawing) | ||
C1A3 | LD ($EB4E),A | |||
C1A6 | LD A,$50 | Starting value for the room's vertical position (viewport), in pixels, from top of room area (room alignment) | ||
C1A8 | LD ($EB79),A | |||
C1AB | LD A,$04 | Starting value for the room's horizontal position (viewport), in half-character (4 pixel) steps from left of room area | ||
C1AD | LD ($EB78),A | |||
Prepare address pointers for the start of the room's data set:
|
||||
C1B0 | LD HL,($EB7A) | Get address pointer for the room data set in the table at 61A9 | ||
C1B3 | LD A,(HL) | Get (first) room data set byte - this indicates the room size, in sections Trivia - Setting the scene(ry) | ||
C1B4 | INC HL | Increment address pointer to the second byte in the table (containing scenery data) | ||
C1B5 | LD ($EB7A),HL | ...and re-store the pointer. | ||
C1B8 | LD ($EB7C),A | Store the first byte, which indicates room size | ||
C1BB | LD A,$01 | |||
C1BD | LD ($EB7D),A | Incremental counter byte starting at 1, to compare with the first data byte of the current room when positioning room scenery. Used shortly in the routine at C1E0. |
Prev: C107 | Up: Map | Next: C1C0 |