Prev: 59903 Up: Map Next: 60658
59906: Unpack Rooms
Used by the routine at Initialise_Rooms.
Builds Table_RoomData and copies each packed room into Buffer_UnpackedRooms. A=255 initialises every room, otherwise it loads that room.
Unpack_Rooms 59906 CP 30 Return if A is 30.
59908 RET Z
59909 CP 255 Jump to Load_Room unless A is 255.
59911 JP NZ,Load_Room
59914 CALL Clear_RoomBuffers Call Clear_RoomBuffers.
59917 LD HL,31856 Write Buffer_ActiveFont to *Pointer_ActiveFont.
59920 LD (25614),HL
59923 CALL Reset_Player Call Reset_Player.
59926 LD HL,0 Clear the collection and score words.
59929 LD (25787),HL
59932 LD (25789),HL
59935 LD (25791),HL
59938 LD (25793),HL
59941 LD (25795),HL
59944 LD A,4 Write 4 to *Player_Lives.
59946 LD (25780),A
59949 LD (25623),HL Write 0 to *CollectedCount and *GameCompleteFlag.
59952 XOR A
59953 LD (25761),A
59956 LD (25725),A
Point at the packed rooms and the unpack buffers.
59959 LD HL,48145 HL=Data_Rooms.
59962 LD IX,25797 IX=Table_RoomData.
59966 LD DE,25847 DE=Buffer_UnpackedRooms.
59969 LD B,23 B=23.
Unpack_Rooms_Loop 59971 PUSH BC Stash the room count on the stack.
59972 LD (IX+0),E Write the destination address into the next Table_RoomData slot.
59975 INC IX
59977 LD (IX+0),D
59980 INC IX
59982 LD A,(HL) Copy the room header byte.
59983 LD (DE),A
59984 INC HL
59985 INC DE
59986 LD BC,5 Copy each header-furniture record.
59989 CALL Copy_TerminatedField
59992 LD BC,4 Copy each furniture record.
59995 CALL Copy_TerminatedField
59998 LD BC,4 Copy each door record.
60001 CALL Copy_TerminatedField
60004 LD BC,2 Copy each collectible record.
60007 CALL Copy_TerminatedField
60010 LD BC,1 Copy each inventory record.
60013 CALL Copy_TerminatedField
60016 LD BC,2 Copy each ladder record.
60019 CALL Copy_TerminatedField
60022 LD BC,5 Copy each decoration record.
60025 CALL Copy_TerminatedField
60028 LD BC,12 Copy each actor record.
60031 CALL Copy_TerminatedField
60034 LD BC,13 Copy each enemy record.
60037 CALL Copy_TerminatedField
60040 LD BC,18 Copy each moving-object record.
60043 CALL Copy_TerminatedField
60046 POP BC Restore the room count and loop back to Unpack_Rooms_Loop.
60047 DJNZ Unpack_Rooms_Loop
60049 LD (IX+0),E Store the final pointer.
60052 LD (IX+1),D
60055 XOR A A=0.
60056 JR Load_Room Jump to Load_Room.
Copy_TerminatedField 60058 LD A,(HL) Copy the next byte and advance both pointers.
60059 LD (DE),A
60060 INC HL
60061 INC DE
60062 INC A Return if that byte was 255.
60063 RET Z
Copy the remaining bytes of this field.
60064 PUSH BC Stash the count on the stack.
60065 LDIR Copy the remaining BC bytes.
60067 POP BC Restore the count from the stack.
60068 JR Copy_TerminatedField Jump to Copy_TerminatedField.
Load the room in A.
Load_Room 60070 LD (25762),A Write A to *CurrentRoom.
60073 AND %01111111 Keep only bits 0-6.
60075 LD E,A Look up that room's pointer from Table_RoomData.
60076 LD D,0
60078 LD HL,25797
60081 ADD HL,DE
60082 ADD HL,DE
60083 LD E,(HL)
60084 INC HL
60085 LD D,(HL)
60086 PUSH DE
60087 LD A,(25762) A=*CurrentRoom.
Refresh the working copy when this room is not already current.
60090 BIT 7,A Jump to Load_Room_Draw if bit 7 of *CurrentRoom is set.
60092 JR NZ,Load_Room_Draw
60094 LD A,(DE) A=*DE.
60095 AND %10000000 Keep only bit 7.
60097 JR Z,Load_Room_Draw Jump to Load_Room_Draw if the working copy is already current.
60099 INC HL Fetch the next pointer and copy it to HL.
60100 LD C,(HL)
60101 INC HL
60102 LD B,(HL)
60103 LD L,C
60104 LD H,B
60105 XOR A BC=HL-DE (length of this room).
60106 SBC HL,DE
60108 LD C,L
60109 LD B,H
60110 LD HL,25847 Point HL at Buffer_UnpackedRooms relative to the packed source.
60113 PUSH DE
60114 XOR A
60115 EX DE,HL
60116 SBC HL,DE
60118 LD DE,48145 Add Data_Rooms and copy the packed room into the working buffer.
60121 ADD HL,DE
60122 POP DE
60123 LDIR
Load_Room_Draw 60125 LD A,(25762) Clear bit 7 of *CurrentRoom.
60128 RES 7,A
60130 LD (25762),A
60133 POP IX Restore the room pointer from the stack into IX.
60135 LD HL,31856 Write Buffer_ActiveFont to *CHARS.
60138 LD (23606),HL
60141 CALL Clear_RoomBuffers Call Clear_RoomBuffers.
60144 LD A,1 Write BLUE to *Active_BorderColour and the border.
60146 LD (25629),A
60149 OUT (254),A
Copy the matching font bank for this room.
60151 LD A,(IX+0) A=the room header.
60154 AND %00110000 Keep only bits 4-5.
60156 CALL Z,Copy_FontBank1 Call Copy_FontBank1 if the font bank is 0.
60159 CP 16 Call Copy_FontBank2 if the font bank is 16.
60161 CALL Z,Copy_FontBank2
60164 CP 32 Call Copy_FontBank3 if the font bank is 32.
60166 CALL Z,Copy_FontBank3
60169 INC IX Write IX to *Pointer_RoomHeader.
60171 LD (25630),IX
Draw each visible header-furniture record.
Load_Room_Header 60175 LD A,(IX+0) Jump to Load_Room_Furniture if the terminator 255 is reached.
60178 CP 255
60180 JR Z,Load_Room_Furniture
60182 BIT 7,A Call Draw_HeaderFurniture if this record is visible.
60184 CALL Z,Draw_HeaderFurniture
60187 LD BC,6 IX+=0006.
60190 ADD IX,BC
60192 JR Load_Room_Header Jump to Load_Room_Header.
Draw each visible furniture record into *ReferenceFurniture.
Load_Room_Furniture 60194 INC IX Write IX to *ReferenceFurniture.
60196 LD (25632),IX
Load_Room_Furniture_Target 60200 LD A,(IX+0) Jump to Load_Room_Doors if the terminator 255 is reached.
60203 CP 255
60205 JR Z,Load_Room_Doors
60207 BIT 7,A Jump to Load_Room_Furniture_Continue if this record is hidden.
60209 JR NZ,Load_Room_Furniture_Continue
60211 CALL Draw_FurnitureItem Call Draw_FurnitureItem.
Load_Room_Furniture_Continue 60214 LD DE,5 IX+=0005.
60217 ADD IX,DE
60219 JR Load_Room_Furniture_Target Jump to Load_Room_Furniture_Target.
Draw each visible door record into *ReferenceDoors.
Load_Room_Doors 60221 INC IX Write IX to *ReferenceDoors.
60223 LD (25634),IX
Load_Room_Doors_Target 60227 LD A,(IX+0) Jump to Load_Room_Collectibles if the terminator 255 is reached.
60230 CP 255
60232 JR Z,Load_Room_Collectibles
60234 BIT 7,A Jump to Load_Room_Doors_Continue if this record is hidden.
60236 JR NZ,Load_Room_Doors_Continue
60238 CALL Draw_Door Call Draw_Door.
Load_Room_Doors_Continue 60241 LD DE,5 IX+=0005.
60244 ADD IX,DE
60246 JR Load_Room_Doors_Target Jump to Load_Room_Doors_Target.
Skip each collectible record into *ReferenceCollectibles.
Load_Room_Collectibles 60248 INC IX Write IX to *ReferenceCollectibles.
60250 LD (25636),IX
Load_Room_Collectibles_Target 60254 LD A,(IX+0) Jump to Load_Room_Inventory if the terminator 255 is reached.
60257 CP 255
60259 JR Z,Load_Room_Inventory
60261 LD DE,3 IX+=0003.
60264 ADD IX,DE
60266 JR Load_Room_Collectibles_Target Jump to Load_Room_Collectibles_Target.
Draw each visible inventory item into *ReferenceInventoryItems.
Load_Room_Inventory 60268 INC IX Write IX to *ReferenceInventoryItems.
60270 LD (25638),IX
Load_Room_Inventory_Target 60274 LD A,(IX+0) Jump to Load_Room_Ladders if the terminator 255 is reached.
60277 CP 255
60279 JR Z,Load_Room_Ladders
60281 BIT 7,A Jump to Load_Room_Inventory_Continue if this record is hidden.
60283 JR NZ,Load_Room_Inventory_Continue
60285 LD C,A Call JumpTable_SetPrintPosition at the item's column and row.
60286 LD B,(IX+1)
60289 CALL JumpTable_SetPrintPosition
60292 LD A,7 Write WHITE to *ATTR_T.
60294 LD (23695),A
60297 LD A,128 Call JumpTable_PrintSprite with glyph 128 and size 2 by 2.
60299 LD DE,514
60302 CALL JumpTable_PrintSprite
Load_Room_Inventory_Continue 60305 INC IX Advance IX by two.
60307 INC IX
60309 JR Load_Room_Inventory_Target Jump to Load_Room_Inventory_Target.
Draw each visible ladder into *ReferenceLadders.
Load_Room_Ladders 60311 INC IX Write IX to *ReferenceLadders.
60313 LD (25640),IX
Load_Room_Ladders_Target 60317 LD A,(IX+0) Jump to Load_Room_Decorations if the terminator 255 is reached.
60320 CP 255
60322 JR Z,Load_Room_Decorations
60324 BIT 7,A Jump to Load_Room_Ladders_Continue if this record is hidden.
60326 JR NZ,Load_Room_Ladders_Continue
60328 LD C,A Call JumpTable_SetPrintPosition at the ladder's column and row.
60329 LD B,(IX+1)
60332 PUSH BC
60333 CALL JumpTable_SetPrintPosition
60336 LD A,(IX+2) Write the ladder colour to *ATTR_T.
60339 LD (23695),A
60342 LD A,14 Call JumpTable_PrintSprite with glyph 14 and size 1 by 2.
60344 LD DE,258
60347 CALL JumpTable_PrintSprite
60350 POP BC Call JumpTable_SetPrintPosition one row higher.
60351 DEC B
60352 CALL JumpTable_SetPrintPosition
60355 LD A,219 Call JumpTable_PrintSprite with glyph 219 and size 4 by 2.
60357 LD DE,1026
60360 CALL JumpTable_PrintSprite
Load_Room_Ladders_Continue 60363 INC IX Advance IX by three.
60365 INC IX
60367 INC IX
60369 JR Load_Room_Ladders_Target Jump to Load_Room_Ladders_Target.
Draw each visible decoration into *ReferenceDecorations.
Load_Room_Decorations 60371 INC IX Write IX to *ReferenceDecorations.
60373 LD (25646),IX
Load_Room_Decorations_Target 60377 LD A,(IX+0) Jump to Load_Room_Actors if the terminator 255 is reached.
60380 CP 255
60382 JR Z,Load_Room_Actors
60384 BIT 7,A Jump to Load_Room_Decorations_Continue if this record is hidden.
60386 JR NZ,Load_Room_Decorations_Continue
60388 LD C,A Call JumpTable_SetPrintPosition at the decoration's column and row.
60389 LD B,(IX+1)
60392 CALL JumpTable_SetPrintPosition
60395 LD A,(IX+2) Write the decoration colour to *ATTR_T.
60398 LD (23695),A
60401 LD A,(IX+3) Call JumpTable_PrintSprite with the stored glyph and size.
60404 LD E,(IX+4)
60407 LD D,(IX+5)
60410 CALL JumpTable_PrintSprite
Load_Room_Decorations_Continue 60413 LD DE,6 IX+=0006.
60416 ADD IX,DE
60418 JR Load_Room_Decorations_Target Jump to Load_Room_Decorations_Target.
Draw each visible actor into *ReferenceActors.
Load_Room_Actors 60420 INC IX Write IX to *ReferenceActors.
60422 LD (25648),IX
Load_Room_Actors_Target 60426 LD A,(IX+0) Jump to Load_Room_Enemies if the terminator 255 is reached.
60429 CP 255
60431 JR Z,Load_Room_Enemies
60433 BIT 7,A Jump to Load_Room_Actors_Continue if this record is hidden.
60435 JR NZ,Load_Room_Actors_Continue
60437 CALL JumpTable_DrawActor Call JumpTable_DrawActor.
Load_Room_Actors_Continue 60440 LD DE,13 IX+=0013.
60443 ADD IX,DE
60445 JR Load_Room_Actors_Target Jump to Load_Room_Actors_Target.
Draw each visible enemy into *ReferenceEnemies.
Load_Room_Enemies 60447 LD HL,36976 Write Graphics_TileFont to *CHARS.
60450 LD (23606),HL
60453 INC IX Write IX to *ReferenceEnemies.
60455 LD (25650),IX
Load_Room_Enemies_Target 60459 LD A,(IX+0) Jump to Load_Room_Movers if the terminator 255 is reached.
60462 CP 255
60464 JR Z,Load_Room_Movers
60466 BIT 7,A Jump to Load_Room_Enemies_Continue if this record is hidden.
60468 JR NZ,Load_Room_Enemies_Continue
60470 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
Load_Room_Enemies_Continue 60473 LD DE,14 IX+=0014.
60476 ADD IX,DE
60478 JR Load_Room_Enemies_Target Jump to Load_Room_Enemies_Target.
Draw each visible moving object into *ReferenceMovingObjects.
Load_Room_Movers 60480 INC IX Write IX to *ReferenceMovingObjects.
60482 LD (25642),IX
Load_Room_Movers_Target 60486 LD A,(IX+0) Jump to Load_Room_Status if the terminator 255 is reached.
60489 CP 255
60491 JR Z,Load_Room_Status
60493 BIT 7,A Jump to Load_Room_Movers_Continue if this record is hidden.
60495 JR NZ,Load_Room_Movers_Continue
60497 LD C,(IX+16) Write the object's clip window to *ClipWindow.
60500 LD B,(IX+17)
60503 LD (25625),BC
60507 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
Load_Room_Movers_Continue 60510 LD DE,19 IX+=0019.
60513 ADD IX,DE
60515 JR Load_Room_Movers_Target Jump to Load_Room_Movers_Target.
Draw the status bar and reset the per-room flags.
Load_Room_Status 60517 INC IX Advance past the terminator.
60519 LD BC,545 Convert column 33 row 2 into a Buffer_RoomTiles offset.
60522 CALL JumpTable_ConvertCoordinate
60525 LD DE,22528 Point HL at the matching attribute cell.
60528 ADD HL,DE
60529 LD DE,544 Fill 544 attribute cells with BLACK.
60532 LD A,8
60534 CALL JumpTable_FillAttributes
60537 CALL Print_Inventory Call Print_Inventory.
Draw the status icons.
60540 LD BC,287 BC=287.
60543 LD HL,31856 Write Buffer_ActiveFont to *CHARS.
60546 LD (23606),HL
60549 CALL JumpTable_DrawStatus Call JumpTable_DrawStatus.
60552 LD A,(25617) Call Reset_Player when *RestartRoomFlag is set.
60555 OR A
60556 CALL NZ,Reset_Player
60559 LD BC,536 Write the default clip window to *ClipWindow.
60562 LD (25625),BC
60566 LD BC,289
60569 LD (25627),BC
60573 XOR A A=0.
60574 LD DE,25715 Clear 10 bytes from *SoundFlags.
60577 LD HL,25714
60580 LD (HL),A
60581 LD BC,9
60584 LDIR
60586 LD HL,258 Write 258 to *KempstonMasks.
60589 LD (25734),HL
60592 LD HL,(25732) Copy *SavedKeys back to *UserDefinedKeys.
60595 LD (25727),HL
60598 LD (25737),A Clear *ActionTimer and *ClimbRow.
60601 LD (25738),A
60604 LD (25675),A Clear *Pointer_CollidedActor.
60607 LD (25676),A
60610 LD (25759),A Clear *EventTimer, *Player_JumpTimer and *RestartRoomFlag.
60613 LD (25616),A
60616 LD (25617),A
60619 LD (25653),A Clear *Player_HitTimer and the stand timers.
60622 LD (25654),A
60625 LD (25655),A
60628 LD (25656),A
60631 LD (25657),A
60634 LD (25763),A Clear *TempCurrentRoom and *CollisionState.
60637 LD (25652),A
60640 DEC A Write 255 to SpecialActor and 25691.
60641 LD (25677),A
60644 LD (25691),A
60647 LD A,96 Write 96 to *Player_SpriteFrame.
60649 LD (25770),A
60652 LD A,128 Write 128 to *CarriedObject.
60654 LD (25739),A
60657 RET Return.
Prev: 59903 Up: Map Next: 60658