Prev: 8705 Up: Map Next: 8997
871A: Room : Initialise
Used by the routine at Door_HandleEntry.
Input
Output
Room_InitialiseInner 871A XOR A
871B LD (Flag_DoorEntry),A
871E LD (Hero_ArrestCount),A
8721 LD IX,(RoomEntered_DataPtr)
8725 LD A,(IX+$01) Calculate room type.
8728 RRA
8729 RRA
872A RRA
872B RRA
872C AND $0F
872E LD (Temp_RoomType),A
8731 JP NZ,Room_InitialiseInner_0
Room Type 00 (Outside)
8734 LD IX,(RoomEntered_EntryPtr) Get pointer to room info (midway pointer).
8738 LD HL,(RoomEntered_EntryPtr) With same info, get the last position when hero was outside, put back into hero's data.
873B LD DE,$0003
873E ADD HL,DE
873F LD DE,Coords_NS
8742 LD BC,$0004
8745 LDIR
8747 LD A,(IX+$02)
874A CALL CurrentRoomType_CopyDataStruct
874D XOR A
874E LD (Room_CurrentIndex),A
8751 LD A,$12
8753 LD (Hero_Frame),A
8756 JP Room_Initialise
Handle rooms.
Room_InitialiseInner_0 8759 LD BC,(ExitFound_RoomIndex) Create a seemingly random pattern on the gallery pictures using the room index. This uses a rotated value to create indices to the picture 'static' character bitmaps.
875D LD HL,PictureMatrix_Gallery
8760 LD B,$09
Room_InitialiseInner_1 8762 LD A,C
8763 ADD A,$6F
8765 LD C,A
8766 AND $0F
8768 CP $09
876A JR C,Room_InitialiseInner_2
876C LD A,$03
Room_InitialiseInner_2 876E ADD A,$58
8770 LD (HL),A
8771 INC HL
8772 RRC C
8774 DJNZ Room_InitialiseInner_1
8776 LD HL,PictureMatrix_Gallery Copy the results over to the deposit pictures too.
8779 LD DE,PictureMatrix_Deposit
877C LD BC,$001B
877F LDIR
8781 LD HL,(Camera_Compass) Based on the compass, get a predefined exit mask. This will hold just a single exit from the direction the player came from.
8784 LD H,$00
8786 LD DE,Exits_Predefined
8789 ADD HL,DE
878A LD C,(HL)
878B LD A,(IX+$01) Get room exit mask.
878E AND $0F If no exits are defined, then just create an exit based on direction player entered the room.
8790 JR Z,Room_InitialiseInner_3
8792 LD C,A Use defined exits.
Create a copy of the door insert table.
Room_InitialiseInner_3 8793 PUSH BC These are pointers to description data to insert door codes.
8794 LD HL,(Temp_RoomType)
8797 LD H,$00
8799 ADD HL,HL
879A ADD HL,HL
879B ADD HL,HL
879C LD DE,Room_DoorInsertTbl The east and west backgrounds are different depending on the room type. So the position of the exits within the background are different too. This works out the correct description and the position of the exit code within.
879F ADD HL,DE
87A0 LD DE,Exit_EastDescrPtr
87A3 LD BC,$0004
87A6 LDIR
87A8 LD DE,Exit_WestDescrPtr
87AB LD BC,$0004
87AE LDIR
Setup exits.
87B0 LD HL,Exits_StoreTable
87B3 POP BC
87B4 LD IX,(RoomEnter_ExitDataPtr)
87B8 LD B,$04 Number of possible exits.
Room_InitialiseInner_4 87BA RRC C Get next exit bit.
87BC PUSH BC
87BD JR C,Room_InitialiseInner_5
No exit.
87BF LD DE,$0004 Skip data
87C2 ADD HL,DE
87C3 LD A,$05 Store a gap, instead of a door, in description string.
87C5 LD BC,$0000 Clear number of bytes to skip, stays on same exit data for next check.
87C8 JR Room_InitialiseInner_10
Exit of some sort.
Room_InitialiseInner_5 87CA LD A,(IX+$00) Get exit type.
87CD AND $0F
87CF JR NZ,Room_InitialiseInner_6
Exit Type 0 (External)
87D1 LD E,(HL)
87D2 INC HL
87D3 LD D,(HL)
87D4 INC HL
87D5 PUSH HL
87D6 PUSH IX
87D8 POP HL
87D9 LD BC,$0007 Size of exit data.
87DC LDIR Copy exit data across.
87DE POP HL
87DF XOR A
87E0 LD BC,$0007
87E3 JR Room_InitialiseInner_9
Is it exit type 1?
Room_InitialiseInner_6 87E5 CP $01
87E7 JR NZ,Room_InitialiseInner_7
Exit Type 1 (Internal)
87E9 INC HL
87EA INC HL
87EB LD BC,$0003 Size of exit data.
87EE LD A,(IX+$02)
87F1 JR Room_InitialiseInner_9
Exit Type 2 (Create exit out)
Creates an exit back from where hero came from.
Room_InitialiseInner_7 87F3 LD E,(HL)
87F4 INC HL
87F5 LD D,(HL)
87F6 INC HL
87F7 PUSH HL
87F8 LD A,(IX+$01) Get key for exit
87FB PUSH DE
Get info required to put hero back outside.
87FC EX (SP),IX
87FE LD (IX+$01),A Set key
8801 LD (IX+$00),$00 Set [door type / exit type]
8805 LD A,(Room_CurrentType) Set the goto value, room index.
8808 LD (IX+$02),A
880B LD HL,(Hero_PathPtr) Set the position of the exit on the map. This is where the hero will appear once outside.
880E LD E,(HL)
880F INC HL
8810 LD D,(HL)
8811 LD HL,(ExitFound_Coords)
8814 LD A,(Camera_Compass)
8817 BIT 0,A
8819 JR NZ,Room_InitialiseInner_8
881B EX DE,HL
Setup exit leading to outside.
Room_InitialiseInner_8 881C LD (IX+$03),L Store info as exit data.
881F LD (IX+$04),H
8822 LD (IX+$05),E
8825 LD (IX+$06),D
8828 POP IX
882A POP HL
882B LD BC,$0002 Size of exit data.
882E XOR A
_
Room_InitialiseInner_9 882F LD E,(HL)
8830 INC HL
8831 LD D,(HL)
8832 INC HL
8833 LD (DE),A
8834 LD A,(IX+$00) Get door type.
8837 RRCA
8838 RRCA
8839 RRCA
883A RRCA
883B AND $0F
883D ADD A,$92 Convert into bitmap.
Store gap or door into description.
Room_InitialiseInner_10 883F LD E,(HL) Get address of description string to insert data into.
8840 INC HL
8841 LD D,(HL)
8842 LD (DE),A
8843 INC HL
8844 ADD IX,BC Move onto next exit data.
8846 POP BC Get exit count and count down.
8847 DEC B
8848 JP NZ,Room_InitialiseInner_4
_
884B LD IX,(RoomEntered_DataPtr)
884F LD A,(ExitFound_RoomIndex)
8852 LD (Room_CurrentIndex),A
8855 LD (Room_CurrentDataPtr),IX
8859 LD DE,Exit_coords Copy exit coords into heros position.
885C LD HL,(Camera_Compass)
885F LD H,$00
8861 ADD HL,HL
8862 ADD HL,HL
8863 ADD HL,DE
8864 LD DE,Coords_NS
8867 LD BC,$0004
886A LDIR
886C LD A,(Temp_RoomType) Base on room type,
886F INC A
8870 CALL CurrentRoomType_CopyDataStruct
8873 LD DE,$0007 Beep!
8876 LD HL,$0159
8879 CALL $03B5
887C LD IX,(RoomEntered_DataPtr)
8880 LD A,(IX+$02)
8883 LD (CurrentRoom_AreaColour),A
Handle room based on type.
8886 LD A,(Temp_RoomType)
8889 CP $01
888B JR NZ,Room_InitialiseInner_15
Room Type 01 Seller
888D LD A,(IX+$03) Get object being sold and fill shelves with item.
8890 LD HL,Shop_Shelves
8893 LD B,$02 Number of shelves.
8895 OR $80 Mark as stolen.
Room_InitialiseInner_11 8897 LD (HL),A Put onto next shelf.
8898 INC HL
8899 DJNZ Room_InitialiseInner_11
889B LD (HL),B Clear.
889C INC HL
889D LD (HL),B
Room_InitialiseInner_12 889E LD HL,Shop_InfoData
88A1 LD (Room_CurrentInfoDataPtr),HL
88A4 LD A,(IX+$03) Keep a copy of the object linked to room. (sold or bought)
88A7 LD (Shop_ObjIndex),A
88AA LD HL,$0000
88AD LD ($B0E6),HL
88B0 LD L,(IX+$04) Get price of object (sold or bought).
88B3 LD H,(IX+$05)
88B6 LD (Obj_Price),HL
88B9 LD A,H
88BA AND A
88BB JP NZ,Room_Initialise
88BE LD A,L
88BF AND $0F
88C1 LD (Obj_Price),A
88C4 LD A,L
88C5 RRA
88C6 RRA
88C7 RRA
88C8 RRA
88C9 AND $0F
88CB LD C,A
Room_InitialiseInner_13 88CC LD B,$04
88CE LD HL,Obj_Price
88D1 XOR A
Room_InitialiseInner_14 88D2 RLD
88D4 INC HL
88D5 DJNZ Room_InitialiseInner_14
88D7 DEC C
88D8 JR NZ,Room_InitialiseInner_13
88DA JP Room_Initialise
Room Type 02 Broker
Room_InitialiseInner_15 88DD CP $02
88DF JR NZ,Room_InitialiseInner_16
88E1 CALL Block_ClearMem Clear shelves.
88E4 DEFW Shop_Shelves
88E6 DEFB $05
88E7 JR Room_InitialiseInner_12
Room_InitialiseInner_16 88E9 CP $0B
88EB JR Z,Room_InitialiseInner_17
88ED CP $03
88EF JR NZ,Room_InitialiseInner_19
Room Type 03 Deposit, 0B
Room_InitialiseInner_17 88F1 LD A,(IX+$03) Get index of bitmap to display in picture.
88F4 AND A
88F5 JR Z,Room_InitialiseInner_18
88F7 LD HL,PictureMatrix_Deposit Clear picture.
88FA LD DE,$B103
88FD LD BC,$0008
8900 LD (HL),$7C
8902 LDIR
8904 LD (PictureMatrix_Deposit_Image),A Store image index.
Room_InitialiseInner_18 8907 LD HL,(RoomEntered_DataPtr) Offset to info data in room data.
890A LD DE,$0003
890D JR Room_InitialiseInner_21
Room Type 04, 08 Castle, 09 Bank, 0A Portal, 05 Gambling
Room_InitialiseInner_19 890F CP $04
8911 JR Z,Room_InitialiseInner_20
8913 CP $08
8915 JR Z,Room_InitialiseInner_20
8917 CP $09
8919 JR Z,Room_InitialiseInner_20
891B CP $0A
891D JR Z,Room_InitialiseInner_20
891F CP $05
8921 JR NZ,Room_InitialiseInner_22
05 Gambling Room.
8923 CALL Block_ClearMem Clear gambling room variables and data.
8926 DEFW Gamble_Counter
8928 DEFB $0C
Room_InitialiseInner_20 8929 LD HL,(RoomEntered_DataPtr)
892C LD DE,$0002
Initialise and Exit.
Room_InitialiseInner_21 892F ADD HL,DE Offset to info data in room data and store it.
8930 LD (Room_CurrentInfoDataPtr),HL
8933 LD HL,Inv_Pocket1 Make a copy of items carried.
8936 LD DE,Shop_Shelves
8939 LD BC,$0003
893C LDIR
893E JP Room_Initialise
Check room type.
Room_InitialiseInner_22 8941 CP $06
8943 JR NZ,Room_InitialiseInner_24
Room Type 06 Shield room
8945 LD HL,PictureMatrix_Deposit Blank out the picture.
8948 LD DE,$B103
894B LD BC,$0008
894E LD (HL),$7C
8950 LDIR
8952 LD A,(IX+$05) Index of bitmap to display in picture.
8955 LD (PictureMatrix_Deposit_Image),A
8958 AND A
8959 JR NZ,Room_InitialiseInner_23
895B LD HL,(RoomEntered_DataPtr) A zero means the shield has been placed, copy the text of the reward from the room data.
895E LD DE,$0007
8961 ADD HL,DE
8962 LD DE,$B105
8965 LD BC,$0003
8968 LDIR
Room_InitialiseInner_23 896A JP Room_InitialiseInner_20
Room Type 07 Gallery
Room_InitialiseInner_24 896D LD HL,PictureMatrix_Gallery Fill the Gallery's picture matrix with spaces.
8970 LD DE,$B0FA
8973 LD BC,$0023
8976 LD (HL),$7C
8978 LDIR
897A LD HL,PictureMatrix_Gallery_Image1 Starting with the byte that represent the first picture image.
897D LD B,$04 Repeat for 4 pictures.
Room_InitialiseInner_25 897F LD A,(IX+$05) Get the index of the image that represents the object to find.
8982 AND A
8983 JR NZ,Room_InitialiseInner_26
8985 LD A,(IX+$07) If its a zero, then use the image that represents the object has been found.
Room_InitialiseInner_26 8988 LD (HL),A Store the correct index into the part of the matrix that is the picture.
8989 LD DE,$0009 Move onto the next picture matrix.
898C ADD HL,DE
898D LD DE,$0003 Move onto next next item for the room.
8990 ADD IX,DE
8992 DJNZ Room_InitialiseInner_25
8994 JP Room_InitialiseInner_20
Prev: 8705 Up: Map Next: 8997