Prev: C72B Up: Map Next: C8BF
C745: Initialize graphic and attribute data buffers for current room
Used by the routine at A89D.
C745 LD A,($A05F) If atoms of Rex ar not flushing on teleporting reset sound volume
C748 OR A
C749 CALL Z,$D5D7
C74C LD HL,$DE9F Reset tile type and tile counter buffer
C74F LD DE,$DEA0
C752 LD BC,$065F
C755 LD (HL),$00
C757 LDIR
C759 LD A,$01 Initialize counter for tile drawn on room grahics buffer
C75B LD ($A01D),A
C75E LD IX,$EB00 Set IX to the base address of room graphic buffer
C762 LD HL,$D962 Set HL to the base address of mapping table for tile grahic data and room graphic buffer
C765 LD ($A0B9),HL Copy at A0B9 this base address
C768 LD A,($A0B8) Set DE to the current room number
C76B LD E,A
C76C LD D,$00
C76E LD B,$46 Set B to the number of supertiles in the room
C770 CALL $C8E8 Computes the offset in the room layout table for the current room (70 x number of room)
C773 LD DE,$75E0 Set HL to the base address in the room layout table for the current room
C776 ADD HL,DE
C777 PUSH HL Copy the base address into IY
C778 POP IY
C77A LD B,$07 Set B to the number of supertiles row for a room (10x7)
C77C PUSH BC Save REGbc and REGix
C77D PUSH IX
C77F LD B,$0A Set B to the number of supertiles columns for a room (10x7)
C781 PUSH BC Save BC
C782 LD A,(IY+$00) Pickup into DE the number of supertile pointed by IY
C785 LD E,A
C786 LD D,$00
C788 LD B,$09 Set B to the number of tiles for each supertile (3x3)
C78A CALL $C8E8 Computes the base addres for the supertile layout
C78D LD DE,$6CE0
C790 ADD HL,DE
C791 CALL $C7C5 Initialize the supertile
C794 LD DE,$0003 Point IX to the next supertile location in the room graphic buffer
C797 ADD IX,DE
C799 INC IY Point IY to the next supertile
C79B POP BC Restore BC
C79C DJNZ $C781 Jump back until all supertiles in a row are drawn
C79E POP IX Restore IX
C7A0 LD DE,$0300 Point IX to the first supertile of the next row in the room graphics buffer
C7A3 ADD IX,DE
C7A5 POP BC Restore BC
C7A6 DJNZ $C77C Jump back until all the seven rows of supertiles are drawn
C7A8 LD HL,$5860 Fill the attribute file with color attribute $47 if the current color attribute is $00
C7AB LD BC,$02A0
C7AE LD A,(HL)
C7AF OR A
C7B0 JP NZ,$C7B5
C7B3 LD (HL),$47
C7B5 DEC BC
C7B6 INC HL
C7B7 LD A,B
C7B8 OR C
C7B9 JP NZ,$C7AE
C7BC LD A,($A05F) Is A05F = 0 ?
C7BF OR A
C7C0 RET NZ Return if it isn't
C7C1 CALL $D5AE Reset sound data buffer
C7C4 RET
Initialize a supertile
C7C5 PUSH IX Save IX
C7C7 LD B,$03 Set B to the number of rows per supertile (3x3)
C7C9 PUSH BC Save BC
C7CA LD B,$03 Set B to the number of columns per supertile (3x3)
C7CC PUSH BC Save BC
C7CD LD A,(HL) Set A to the value of the tile
C7CE CALL $C7E2 Copy color attribute, type and graphic data of the tile into corresponding buffers and drawn tile
C7D1 INC HL Point HL to the next tile in the supertile layout
C7D2 INC IX Point IX to the next address into room graphic buffer
C7D4 POP BC Restore BC
C7D5 DJNZ $C7CC Jump back until all the tiles in a row are drawn
C7D7 LD DE,$00FD Point IX to the addres into room graphics buffer for the next row of tiles
C7DA ADD IX,DE
C7DC POP BC Restore BC
C7DD DJNZ $C7C9 Jump back until all three rows of tiles are drawn
C7DF POP IX Restore IX
C7E1 RET
Copy the color attribute of the file to the attribute buffer, the tile type into the tile type buffer, the mapping of the address for the graphic data and the address of the location of the tile into graphics data buffer and drawn the tile into the room graphics buffer
C7E2 PUSH HL Save HL and AF
C7E3 PUSH AF
C7E4 LD ($A095),A Save the tile value into temporal variable A095
C7E7 LD E,A Computes the address into the tile attributes table for the corresponent tile
C7E8 LD D,$00
C7EA LD HL,$6BE0
C7ED ADD HL,DE
C7EE LD A,(HL) Set A to the color attribute for the tile
C7EF PUSH IX Copy IX into HL
C7F1 POP HL
C7F2 CALL $C893 Computes into HL the position of the tile in the attribute buffer
C7F5 LD (HL),A Save the color attribute for the tile into attribute buffer
C7F6 LD DE,$E55F Computes into HL the offset of the tile into the attribute buffer
C7F9 AND A
C7FA SBC HL,DE
C7FC LD DE,$E1FF And add this offset to the base address of the tile type buffer
C7FF ADD HL,DE
C800 PUSH HL Save HL
C801 LD ($A01E),HL Save the address into tile type buffer of the tile at A01E
C804 LD A,($A095) Pick up the tile value from A095
C807 LD E,A Set HL to the address of the tile type table for the tile
C808 LD D,$00
C80A LD HL,$62E0
C80D ADD HL,DE
C80E LD A,(HL) Set A to the tile type value of the tile
C80F POP HL Restore into HL the address of the tile type buffer
C810 LD (HL),A Copy the value of the tile type into the tile type buffer
C811 POP AF Restore AF
C812 LD L,A Computes address for the graphics data of the tile into HL
C813 LD H,$00
C815 ADD HL,HL
C816 ADD HL,HL
C817 ADD HL,HL
C818 LD DE,$63E0
C81B ADD HL,DE
C81C EX DE,HL Exchange DE and HL
C81D LD B,$08 Set B to the number of bytes to copy into graphics buffer
C81F PUSH IX Copy IX into HL
C821 POP HL
Check if the tile is visible
C822 LD A,($A095) Set A to the tile value
C825 OR A is a background (blank) tile?
C826 JP Z,$C87F Jump forward (this will not be drawn in display file)
C829 CP $01 ia an S (space) tile?
C82B JP Z,$C87F Jump forward (this will not be drawn in display file)
C82E CP $10 is an RJ (random jump) tile?
C830 JP Z,$C87F Jump forward (this will not be drawn in display file)
C833 CP $71 is a D (always crouch) tile?
C835 JP Z,$C87F Jump forward (this will not be drawn in display file)
C838 CP $81 is a J (always jump) tile?
C83A JP Z,$C87F Jump forward (this will not be drawn in display file)
C83D CP $91 is a RD (random crouch) tile?
C83F JP Z,$C87F Jump forward
Establish mapping between tile graphic data and room graphics buffer
C842 PUSH IY Save IY
C844 LD IY,($A0B9) Set IY to the address pointer into the mapping table of tile graphics and room graphics buffer
C848 LD (IY+$00),L Save into the first word the address of the room graphics buffer where tile will be draw
C84B LD (IY+$01),H
C84E LD (IY+$02),E Save into the second word the address of the tile graphics data for the tile drawn
C851 LD (IY+$03),D
C854 LD (IY+$04),$FF Set in the fifth byte the end marker
C858 PUSH HL Save HL and DE
C859 PUSH DE
C85A LD HL,($A01E) Set HL to the address pointer into the tile type buffer
C85D LD DE,$E19F Computes the offset of the current tile into the tile type buffer
C860 AND A
C861 SBC HL,DE
C863 LD DE,$DE9F Add the offset to the base address of the tile count buffer to obtain the address for the current tile
C866 ADD HL,DE
C867 LD A,($A01D) Save the current count tile into this address
C86A LD (HL),A
C86B INC A Increment the tile count number
C86C LD ($A01D),A
C86F POP DE Restore DE and HL
C870 POP HL
C871 INC IY Point to the next address into the mapping table of tile graphics and room graphics buffer
C873 INC IY
C875 INC IY
C877 INC IY
C879 LD ($A0B9),IY Point A0B9 to the new address
C87D POP IY Restore IY
Copy tile graphics into room graphics buffer
C87F LD A,(DE) Copy the tile graphic data into room graphic buffer
C880 LD (HL),A
C881 INC DE
C882 PUSH DE
C883 LD DE,$0020
C886 ADD HL,DE
C887 POP DE
C888 DJNZ $C87F
C88A LD HL,($A01E) Increment the tile type address at A01E
C88D INC HL
C88E LD ($A01E),HL
C891 POP HL Restore HL
C892 RET
Computes into HL the position of the tile in the attribute buffer
C893 PUSH AF Save AF and DE
C894 PUSH DE
C895 LD DE,$EAFF Set DE to the address of the room graphics buffer
C898 AND A Reset carry bit
C899 SBC HL,DE Set HL to the offset of the current tile into graphic buffer
C89B LD A,L Computes into A the horizontal position of the tile
C89C AND $1F
C89E LD ($A093),A Save this into A093
C8A1 LD A,L Computes into HL the offset for the vertical position of the tile
C8A2 AND $E0
C8A4 LD L,A
C8A5 SRL H
C8A7 RR L
C8A9 SRL H
C8AB RR L
C8AD SRL H
C8AF RR L
C8B1 LD A,($A093) Restore horizontal position into A
C8B4 LD E,A And add the horizontal position to the computed offset for the vertical position
C8B5 LD D,$00
C8B7 ADD HL,DE
C8B8 LD DE,$E55F Set HL to the address of the tile into the attribute buffer
C8BB ADD HL,DE
C8BC POP DE Restore DE and AF
C8BD POP AF
C8BE RET
Prev: C72B Up: Map Next: C8BF