Prev: E9FF Up: Map Next: ECF2
EA02: Unpack Rooms
Used by the routine at Initialise_Rooms.
Builds Table_RoomData and copies each packed room into Buffer_UnpackedRooms. A=FF initialises every room, otherwise it loads that room.
Unpack_Rooms EA02 CP $1E Return if A is 1E.
EA04 RET Z
EA05 CP $FF Jump to Load_Room unless A is FF.
EA07 JP NZ,Load_Room
EA0A CALL Clear_RoomBuffers Call Clear_RoomBuffers.
EA0D LD HL,$7C70 Write Buffer_ActiveFont to *Pointer_ActiveFont.
EA10 LD ($640E),HL
EA13 CALL Reset_Player Call Reset_Player.
EA16 LD HL,$0000 Clear the collection and score words.
EA19 LD ($64BB),HL
EA1C LD ($64BD),HL
EA1F LD ($64BF),HL
EA22 LD ($64C1),HL
EA25 LD ($64C3),HL
EA28 LD A,$04 Write 04 to *Player_Lives.
EA2A LD ($64B4),A
EA2D LD ($6417),HL Write 00 to *CollectedCount and *GameCompleteFlag.
EA30 XOR A
EA31 LD ($64A1),A
EA34 LD ($647D),A
Point at the packed rooms and the unpack buffers.
EA37 LD HL,$BC11 HL=Data_Rooms.
EA3A LD IX,$64C5 IX=Table_RoomData.
EA3E LD DE,$64F7 DE=Buffer_UnpackedRooms.
EA41 LD B,$17 B=17.
Unpack_Rooms_Loop EA43 PUSH BC Stash the room count on the stack.
EA44 LD (IX+$00),E Write the destination address into the next Table_RoomData slot.
EA47 INC IX
EA49 LD (IX+$00),D
EA4C INC IX
EA4E LD A,(HL) Copy the room header byte.
EA4F LD (DE),A
EA50 INC HL
EA51 INC DE
EA52 LD BC,$0005 Copy each header-furniture record.
EA55 CALL Copy_TerminatedField
EA58 LD BC,$0004 Copy each furniture record.
EA5B CALL Copy_TerminatedField
EA5E LD BC,$0004 Copy each door record.
EA61 CALL Copy_TerminatedField
EA64 LD BC,$0002 Copy each collectible record.
EA67 CALL Copy_TerminatedField
EA6A LD BC,$0001 Copy each inventory record.
EA6D CALL Copy_TerminatedField
EA70 LD BC,$0002 Copy each ladder record.
EA73 CALL Copy_TerminatedField
EA76 LD BC,$0005 Copy each decoration record.
EA79 CALL Copy_TerminatedField
EA7C LD BC,$000C Copy each actor record.
EA7F CALL Copy_TerminatedField
EA82 LD BC,$000D Copy each enemy record.
EA85 CALL Copy_TerminatedField
EA88 LD BC,$0012 Copy each moving-object record.
EA8B CALL Copy_TerminatedField
EA8E POP BC Restore the room count and loop back to Unpack_Rooms_Loop.
EA8F DJNZ Unpack_Rooms_Loop
EA91 LD (IX+$00),E Store the final pointer.
EA94 LD (IX+$01),D
EA97 XOR A A=00.
EA98 JR Load_Room Jump to Load_Room.
Copy_TerminatedField EA9A LD A,(HL) Copy the next byte and advance both pointers.
EA9B LD (DE),A
EA9C INC HL
EA9D INC DE
EA9E INC A Return if that byte was FF.
EA9F RET Z
Copy the remaining bytes of this field.
EAA0 PUSH BC Stash the count on the stack.
EAA1 LDIR Copy the remaining BC bytes.
EAA3 POP BC Restore the count from the stack.
EAA4 JR Copy_TerminatedField Jump to Copy_TerminatedField.
Load the room in A.
Load_Room EAA6 LD ($64A2),A Write A to *CurrentRoom.
EAA9 AND %01111111 Keep only bits 0-6.
EAAB LD E,A Look up that room's pointer from Table_RoomData.
EAAC LD D,$00
EAAE LD HL,$64C5
EAB1 ADD HL,DE
EAB2 ADD HL,DE
EAB3 LD E,(HL)
EAB4 INC HL
EAB5 LD D,(HL)
EAB6 PUSH DE
EAB7 LD A,($64A2) A=*CurrentRoom.
Refresh the working copy when this room is not already current.
EABA BIT 7,A Jump to Load_Room_Draw if bit 7 of *CurrentRoom is set.
EABC JR NZ,Load_Room_Draw
EABE LD A,(DE) A=*DE.
EABF AND %10000000 Keep only bit 7.
EAC1 JR Z,Load_Room_Draw Jump to Load_Room_Draw if the working copy is already current.
EAC3 INC HL Fetch the next pointer and copy it to HL.
EAC4 LD C,(HL)
EAC5 INC HL
EAC6 LD B,(HL)
EAC7 LD L,C
EAC8 LD H,B
EAC9 XOR A BC=HL-DE (length of this room).
EACA SBC HL,DE
EACC LD C,L
EACD LD B,H
EACE LD HL,$64F7 Point HL at Buffer_UnpackedRooms relative to the packed source.
EAD1 PUSH DE
EAD2 XOR A
EAD3 EX DE,HL
EAD4 SBC HL,DE
EAD6 LD DE,$BC11 Add Data_Rooms and copy the packed room into the working buffer.
EAD9 ADD HL,DE
EADA POP DE
EADB LDIR
Load_Room_Draw EADD LD A,($64A2) Clear bit 7 of *CurrentRoom.
EAE0 RES 7,A
EAE2 LD ($64A2),A
EAE5 POP IX Restore the room pointer from the stack into IX.
EAE7 LD HL,$7C70 Write Buffer_ActiveFont to *CHARS.
EAEA LD ($5C36),HL
EAED CALL Clear_RoomBuffers Call Clear_RoomBuffers.
EAF0 LD A,$01 Write BLUE to *Active_BorderColour and the border.
EAF2 LD ($641D),A
EAF5 OUT ($FE),A
Copy the matching font bank for this room.
EAF7 LD A,(IX+$00) A=the room header.
EAFA AND %00110000 Keep only bits 4-5.
EAFC CALL Z,Copy_FontBank1 Call Copy_FontBank1 if the font bank is 00.
EAFF CP $10 Call Copy_FontBank2 if the font bank is 10.
EB01 CALL Z,Copy_FontBank2
EB04 CP $20 Call Copy_FontBank3 if the font bank is 20.
EB06 CALL Z,Copy_FontBank3
EB09 INC IX Write IX to *Pointer_RoomHeader.
EB0B LD ($641E),IX
Draw each visible header-furniture record.
Load_Room_Header EB0F LD A,(IX+$00) Jump to Load_Room_Furniture if the terminator FF is reached.
EB12 CP $FF
EB14 JR Z,Load_Room_Furniture
EB16 BIT 7,A Call Draw_HeaderFurniture if this record is visible.
EB18 CALL Z,Draw_HeaderFurniture
EB1B LD BC,$0006 IX+=0006.
EB1E ADD IX,BC
EB20 JR Load_Room_Header Jump to Load_Room_Header.
Draw each visible furniture record into *ReferenceFurniture.
Load_Room_Furniture EB22 INC IX Write IX to *ReferenceFurniture.
EB24 LD ($6420),IX
Load_Room_Furniture_Target EB28 LD A,(IX+$00) Jump to Load_Room_Doors if the terminator FF is reached.
EB2B CP $FF
EB2D JR Z,Load_Room_Doors
EB2F BIT 7,A Jump to Load_Room_Furniture_Continue if this record is hidden.
EB31 JR NZ,Load_Room_Furniture_Continue
EB33 CALL Draw_FurnitureItem Call Draw_FurnitureItem.
Load_Room_Furniture_Continue EB36 LD DE,$0005 IX+=0005.
EB39 ADD IX,DE
EB3B JR Load_Room_Furniture_Target Jump to Load_Room_Furniture_Target.
Draw each visible door record into *ReferenceDoors.
Load_Room_Doors EB3D INC IX Write IX to *ReferenceDoors.
EB3F LD ($6422),IX
Load_Room_Doors_Target EB43 LD A,(IX+$00) Jump to Load_Room_Collectibles if the terminator FF is reached.
EB46 CP $FF
EB48 JR Z,Load_Room_Collectibles
EB4A BIT 7,A Jump to Load_Room_Doors_Continue if this record is hidden.
EB4C JR NZ,Load_Room_Doors_Continue
EB4E CALL Draw_Door Call Draw_Door.
Load_Room_Doors_Continue EB51 LD DE,$0005 IX+=0005.
EB54 ADD IX,DE
EB56 JR Load_Room_Doors_Target Jump to Load_Room_Doors_Target.
Skip each collectible record into *ReferenceCollectibles.
Load_Room_Collectibles EB58 INC IX Write IX to *ReferenceCollectibles.
EB5A LD ($6424),IX
Load_Room_Collectibles_Target EB5E LD A,(IX+$00) Jump to Load_Room_Inventory if the terminator FF is reached.
EB61 CP $FF
EB63 JR Z,Load_Room_Inventory
EB65 LD DE,$0003 IX+=0003.
EB68 ADD IX,DE
EB6A JR Load_Room_Collectibles_Target Jump to Load_Room_Collectibles_Target.
Draw each visible inventory item into *ReferenceInventoryItems.
Load_Room_Inventory EB6C INC IX Write IX to *ReferenceInventoryItems.
EB6E LD ($6426),IX
Load_Room_Inventory_Target EB72 LD A,(IX+$00) Jump to Load_Room_Ladders if the terminator FF is reached.
EB75 CP $FF
EB77 JR Z,Load_Room_Ladders
EB79 BIT 7,A Jump to Load_Room_Inventory_Continue if this record is hidden.
EB7B JR NZ,Load_Room_Inventory_Continue
EB7D LD C,A Call JumpTable_SetPrintPosition at the item's column and row.
EB7E LD B,(IX+$01)
EB81 CALL JumpTable_SetPrintPosition
EB84 LD A,$07 Write WHITE to *ATTR_T.
EB86 LD ($5C8F),A
EB89 LD A,$80 Call JumpTable_PrintSprite with glyph 80 and size 02 by 02.
EB8B LD DE,$0202
EB8E CALL JumpTable_PrintSprite
Load_Room_Inventory_Continue EB91 INC IX Advance IX by two.
EB93 INC IX
EB95 JR Load_Room_Inventory_Target Jump to Load_Room_Inventory_Target.
Draw each visible ladder into *ReferenceLadders.
Load_Room_Ladders EB97 INC IX Write IX to *ReferenceLadders.
EB99 LD ($6428),IX
Load_Room_Ladders_Target EB9D LD A,(IX+$00) Jump to Load_Room_Decorations if the terminator FF is reached.
EBA0 CP $FF
EBA2 JR Z,Load_Room_Decorations
EBA4 BIT 7,A Jump to Load_Room_Ladders_Continue if this record is hidden.
EBA6 JR NZ,Load_Room_Ladders_Continue
EBA8 LD C,A Call JumpTable_SetPrintPosition at the ladder's column and row.
EBA9 LD B,(IX+$01)
EBAC PUSH BC
EBAD CALL JumpTable_SetPrintPosition
EBB0 LD A,(IX+$02) Write the ladder colour to *ATTR_T.
EBB3 LD ($5C8F),A
EBB6 LD A,$0E Call JumpTable_PrintSprite with glyph 0E and size 01 by 02.
EBB8 LD DE,$0102
EBBB CALL JumpTable_PrintSprite
EBBE POP BC Call JumpTable_SetPrintPosition one row higher.
EBBF DEC B
EBC0 CALL JumpTable_SetPrintPosition
EBC3 LD A,$DB Call JumpTable_PrintSprite with glyph DB and size 04 by 02.
EBC5 LD DE,$0402
EBC8 CALL JumpTable_PrintSprite
Load_Room_Ladders_Continue EBCB INC IX Advance IX by three.
EBCD INC IX
EBCF INC IX
EBD1 JR Load_Room_Ladders_Target Jump to Load_Room_Ladders_Target.
Draw each visible decoration into *ReferenceDecorations.
Load_Room_Decorations EBD3 INC IX Write IX to *ReferenceDecorations.
EBD5 LD ($642E),IX
Load_Room_Decorations_Target EBD9 LD A,(IX+$00) Jump to Load_Room_Actors if the terminator FF is reached.
EBDC CP $FF
EBDE JR Z,Load_Room_Actors
EBE0 BIT 7,A Jump to Load_Room_Decorations_Continue if this record is hidden.
EBE2 JR NZ,Load_Room_Decorations_Continue
EBE4 LD C,A Call JumpTable_SetPrintPosition at the decoration's column and row.
EBE5 LD B,(IX+$01)
EBE8 CALL JumpTable_SetPrintPosition
EBEB LD A,(IX+$02) Write the decoration colour to *ATTR_T.
EBEE LD ($5C8F),A
EBF1 LD A,(IX+$03) Call JumpTable_PrintSprite with the stored glyph and size.
EBF4 LD E,(IX+$04)
EBF7 LD D,(IX+$05)
EBFA CALL JumpTable_PrintSprite
Load_Room_Decorations_Continue EBFD LD DE,$0006 IX+=0006.
EC00 ADD IX,DE
EC02 JR Load_Room_Decorations_Target Jump to Load_Room_Decorations_Target.
Draw each visible actor into *ReferenceActors.
Load_Room_Actors EC04 INC IX Write IX to *ReferenceActors.
EC06 LD ($6430),IX
Load_Room_Actors_Target EC0A LD A,(IX+$00) Jump to Load_Room_Enemies if the terminator FF is reached.
EC0D CP $FF
EC0F JR Z,Load_Room_Enemies
EC11 BIT 7,A Jump to Load_Room_Actors_Continue if this record is hidden.
EC13 JR NZ,Load_Room_Actors_Continue
EC15 CALL JumpTable_DrawActor Call JumpTable_DrawActor.
Load_Room_Actors_Continue EC18 LD DE,$000D IX+=000D.
EC1B ADD IX,DE
EC1D JR Load_Room_Actors_Target Jump to Load_Room_Actors_Target.
Draw each visible enemy into *ReferenceEnemies.
Load_Room_Enemies EC1F LD HL,$9070 Write Graphics_TileFont to *CHARS.
EC22 LD ($5C36),HL
EC25 INC IX Write IX to *ReferenceEnemies.
EC27 LD ($6432),IX
Load_Room_Enemies_Target EC2B LD A,(IX+$00) Jump to Load_Room_Movers if the terminator FF is reached.
EC2E CP $FF
EC30 JR Z,Load_Room_Movers
EC32 BIT 7,A Jump to Load_Room_Enemies_Continue if this record is hidden.
EC34 JR NZ,Load_Room_Enemies_Continue
EC36 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
Load_Room_Enemies_Continue EC39 LD DE,$000E IX+=000E.
EC3C ADD IX,DE
EC3E JR Load_Room_Enemies_Target Jump to Load_Room_Enemies_Target.
Draw each visible moving object into *ReferenceMovingObjects.
Load_Room_Movers EC40 INC IX Write IX to *ReferenceMovingObjects.
EC42 LD ($642A),IX
Load_Room_Movers_Target EC46 LD A,(IX+$00) Jump to Load_Room_Status if the terminator FF is reached.
EC49 CP $FF
EC4B JR Z,Load_Room_Status
EC4D BIT 7,A Jump to Load_Room_Movers_Continue if this record is hidden.
EC4F JR NZ,Load_Room_Movers_Continue
EC51 LD C,(IX+$10) Write the object's clip window to *ClipWindow.
EC54 LD B,(IX+$11)
EC57 LD ($6419),BC
EC5B CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
Load_Room_Movers_Continue EC5E LD DE,$0013 IX+=0013.
EC61 ADD IX,DE
EC63 JR Load_Room_Movers_Target Jump to Load_Room_Movers_Target.
Draw the status bar and reset the per-room flags.
Load_Room_Status EC65 INC IX Advance past the terminator.
EC67 LD BC,$0221 Convert column 21 row 02 into a Buffer_RoomTiles offset.
EC6A CALL JumpTable_ConvertCoordinate
EC6D LD DE,$5800 Point HL at the matching attribute cell.
EC70 ADD HL,DE
EC71 LD DE,$0220 Fill 0220 attribute cells with BLACK.
EC74 LD A,$08
EC76 CALL JumpTable_FillAttributes
EC79 CALL Print_Inventory Call Print_Inventory.
Draw the status icons.
EC7C LD BC,$011F BC=011F.
EC7F LD HL,$7C70 Write Buffer_ActiveFont to *CHARS.
EC82 LD ($5C36),HL
EC85 CALL JumpTable_DrawStatus Call JumpTable_DrawStatus.
EC88 LD A,($6411) Call Reset_Player when *RestartRoomFlag is set.
EC8B OR A
EC8C CALL NZ,Reset_Player
EC8F LD BC,$0218 Write the default clip window to *ClipWindow.
EC92 LD ($6419),BC
EC96 LD BC,$0121
EC99 LD ($641B),BC
EC9D XOR A A=00.
EC9E LD DE,$6473 Clear 0A bytes from *SoundFlags.
ECA1 LD HL,$6472
ECA4 LD (HL),A
ECA5 LD BC,$0009
ECA8 LDIR
ECAA LD HL,$0102 Write 0102 to *KempstonMasks.
ECAD LD ($6486),HL
ECB0 LD HL,($6484) Copy *SavedKeys back to *UserDefinedKeys.
ECB3 LD ($647F),HL
ECB6 LD ($6489),A Clear *ActionTimer and *ClimbRow.
ECB9 LD ($648A),A
ECBC LD ($644B),A Clear *Pointer_CollidedActor.
ECBF LD ($644C),A
ECC2 LD ($649F),A Clear *EventTimer, *Player_JumpTimer and *RestartRoomFlag.
ECC5 LD ($6410),A
ECC8 LD ($6411),A
ECCB LD ($6435),A Clear *Player_HitTimer and the stand timers.
ECCE LD ($6436),A
ECD1 LD ($6437),A
ECD4 LD ($6438),A
ECD7 LD ($6439),A
ECDA LD ($64A3),A Clear *TempCurrentRoom and *CollisionState.
ECDD LD ($6434),A
ECE0 DEC A Write FF to SpecialActor and 645B.
ECE1 LD ($644D),A
ECE4 LD ($645B),A
ECE7 LD A,$60 Write 60 to *Player_SpriteFrame.
ECE9 LD ($64AA),A
ECEC LD A,$80 Write 80 to *CarriedObject.
ECEE LD ($648B),A
ECF1 RET Return.
Prev: E9FF Up: Map Next: ECF2