Prev: C794 Up: Map Next: C932
C7AE: Initialize graphic and attribute data buffers for current room
Used by the routine at A939.
C7AE LD A,($A1F8) If atoms of Rex are not flushing on teleporting reset sound volume
C7B1 OR A
C7B2 CALL Z,$D36F
C7B5 LD HL,$DE9F Reset tile type and tile counter buffer
C7B8 LD DE,$DEA0
C7BB LD BC,$065F
C7BE LD (HL),$00
C7C0 LDIR
C7C2 LD A,$01 Initialize counter for tile drawn on room grahics buffer
C7C4 LD ($A1B6),A
C7C7 LD IX,$EB00 Set IX to the base address of room graphic buffer
C7CB LD HL,$D962 Set HL to the base address of mapping table for tile grahic data and room graphic buffer
C7CE LD ($A252),HL Copy at A252 this base address
C7D1 LD A,($A251) Set DE to the current room number
C7D4 LD E,A
C7D5 LD D,$00
C7D7 LD B,$46 Set B to the number of supertiles in the room
C7D9 CALL $C95B Computes the offset in the room layout table for the current room (70 x number of room)
C7DC LD DE,$7806 Set HL to the base address in the room layout table for the current room
C7DF ADD HL,DE
C7E0 PUSH HL Copy the base address into IY
C7E1 POP IY
C7E3 LD B,$07 Set B to the number of supertiles row for a room (10x7)
C7E5 PUSH BC Save REGbc and REGix
C7E6 PUSH IX
C7E8 LD B,$0A Set B to the number of supertiles columns for a room (10x7)
C7EA PUSH BC Save BC
C7EB LD A,(IY+$00) Pickup into DE the number of supertile pointed by IY
C7EE LD E,A
C7EF LD D,$00
C7F1 LD B,$09 Set B to the number of tiles for each supertile (3x3)
C7F3 CALL $C95B Computes the base addres for the supertile layout
C7F6 LD DE,$6F06
C7F9 ADD HL,DE
C7FA CALL $C82E Initialize the supertile
C7FD LD DE,$0003 Point IX to the next supertile location in the room graphic buffer
C800 ADD IX,DE
C802 INC IY Point IY to the next supertile
C804 POP BC Restore BC
C805 DJNZ $C7EA Jump back until all supertiles in a row are drawn
C807 POP IX Restore IX
C809 LD DE,$0300 Point IX to the first supertile of the next row in the room graphics buffer
C80C ADD IX,DE
C80E POP BC Restore BC
C80F DJNZ $C7E5 Jump back until all the seven rows of supertiles are drawn
C811 LD HL,$5860 Fill the attribute file with color attribute $47 if the current color attribute is $00
C814 LD BC,$02A0
C817 LD A,(HL)
C818 OR A
C819 JP NZ,$C81E
C81C LD (HL),$47
C81E DEC BC
C81F INC HL
C820 LD A,B
C821 OR C
C822 JP NZ,$C817
C825 LD A,($A1F8) Return if Rex atoms are flushing on Rex teleporting
C828 OR A
C829 RET NZ
C82A CALL $D346 Reset sound data buffer
C82D RET
Initialize a supertile
C82E PUSH IX Save IX
C830 LD B,$03 Set B to the number of rows per supertile (3x3)
C832 PUSH BC Save BC
C833 LD B,$03 Set B to the number of columns per supertile (3x3)
C835 PUSH BC Save BC
C836 LD A,(HL) Set A to the value of the tile
C837 CALL $C84B Copy color attribute, type and graphic data of the tile into corresponding buffers and drawn tile
C83A INC HL Point HL to the next tile in the supertile layout
C83B INC IX Point IX to the next address into room graphic buffer
C83D POP BC Restore BC
C83E DJNZ $C835 Jump back until all the tiles in a row are drawn
C840 LD DE,$00FD Point IX to the addres into room graphics buffer for the next row of tiles
C843 ADD IX,DE
C845 POP BC Restore BC
C846 DJNZ $C832 Jump back until all three rows of tiles are drawn
C848 POP IX Restore IX
C84A 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
C84B PUSH HL Save HL and AF
C84C PUSH AF
C84D LD ($A22E),A Save the tile value into temporal variable A22E
C850 LD E,A Computes the address into the tile attributes table for the corresponent tile
C851 LD D,$00
C853 LD HL,$6E06
C856 ADD HL,DE
C857 LD A,(HL) Set A to the color attribute for the tile
C858 PUSH IX Copy IX into HL
C85A POP HL
C85B CALL $C906 Computes into HL the position of the tile in the attribute buffer
C85E LD (HL),A Save the color attribute for the tile into attribute buffer
C85F LD DE,$E55F Computes into HL the offset of the tile into the attribute buffer
C862 AND A
C863 SBC HL,DE
C865 LD DE,$E1FF And add this offset to the base address of the tile type buffer
C868 ADD HL,DE
C869 PUSH HL Save HL
C86A LD ($A1B7),HL Save the address into tile type buffer of the tile at A1B7
C86D LD A,($A22E) Pick up the tile value from A22E
C870 LD E,A Set HL to the address of the tile type table for the tile
C871 LD D,$00
C873 LD HL,$6506
C876 ADD HL,DE
C877 LD A,(HL) Set A to the tile type value of the tile
C878 POP HL Restore into HL the address of the tile type buffer
C879 LD (HL),A Copy the value of the tile type into the tile type buffer
C87A POP AF Restore AF
C87B LD L,A Computes address for the graphics data of the tile into HL
C87C LD H,$00
C87E ADD HL,HL
C87F ADD HL,HL
C880 ADD HL,HL
C881 LD DE,$6606
C884 ADD HL,DE
C885 EX DE,HL Exchange DE and HL
C886 LD B,$08 Set B to the number of bytes to copy into graphics buffer
C888 PUSH IX Copy IX into HL
C88A POP HL
Check if the tile is visible
C88B LD A,($A22E) Set A to the tile value
C88E OR A is a background (shadow) tile?
C88F JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C892 CP $01 is a background (blue) tile?
C894 JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C897 CP $95 unknown R tile meaning?
C899 JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C89C CP $96 unknown B tile meaning?
C89E JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C8A1 CP $C6 is a J (always jump - blue) tile?
C8A3 JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C8A6 CP $D6 is a RJ (random jump - blue) tile?
C8A8 JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C8AB CP $10 is a RD (random crouch - blue) tile?
C8AD JP Z,$C8F2 Jump forward (this will not be drawn in display file)
C8B0 CP $81 is a J (always jump - shadow) tile?
C8B2 JP Z,$C8F2 Jump forward (this will not be drawn in display file)
Establish mapping between tile graphic data and room graphics buffer
C8B5 PUSH IY Save IY
C8B7 LD IY,($A252) Set IY to the address pointer into the mapping table of tile graphics and room graphics buffer
C8BB LD (IY+$00),L Save into the first word the address of the room graphics buffer where tile will be draw
C8BE LD (IY+$01),H
C8C1 LD (IY+$02),E Save into the second word the address of the tile graphics data for the tile drawn
C8C4 LD (IY+$03),D
C8C7 LD (IY+$04),$FF Set in the fifth byte the end marker
C8CB PUSH HL Save HL and DE
C8CC PUSH DE
C8CD LD HL,($A1B7) Set HL to the address pointer into the tile type buffer
C8D0 LD DE,$E19F Computes the offset of the current tile into the tile type buffer
C8D3 AND A
C8D4 SBC HL,DE
C8D6 LD DE,$DE9F Add the offset to the base address of the tile count buffer to obtain the address for the current tile
C8D9 ADD HL,DE
C8DA LD A,($A1B6) Save the current count tile into this address
C8DD LD (HL),A
C8DE INC A Increment the tile count number
C8DF LD ($A1B6),A
C8E2 POP DE Restore DE and HL
C8E3 POP HL
C8E4 INC IY Point to the next address into the mapping table of tile graphics and room graphics buffer
C8E6 INC IY
C8E8 INC IY
C8EA INC IY
C8EC LD ($A252),IY Point A252 to the new address
C8F0 POP IY Restore IY
Copy tile graphics into room graphics buffer
C8F2 LD A,(DE) Copy the tile graphic data into room graphic buffer
C8F3 LD (HL),A
C8F4 INC DE
C8F5 PUSH DE
C8F6 LD DE,$0020
C8F9 ADD HL,DE
C8FA POP DE
C8FB DJNZ $C8F2
C8FD LD HL,($A1B7) Increment the tile type address at A01E
C900 INC HL
C901 LD ($A1B7),HL
C904 POP HL Restore HL
C905 RET
Computes into HL the position of the tile in the attribute buffer
C906 PUSH AF Save AF and DE
C907 PUSH DE
C908 LD DE,$EAFF Set DE to the address of the room graphics buffer
C90B AND A Reset carry bit
C90C SBC HL,DE Set HL to the offset of the current tile into graphic buffer
C90E LD A,L Computes into A the horizontal position of the tile
C90F AND $1F
C911 LD ($A22C),A Save this into A093
C914 LD A,L Computes into HL the offset for the vertical position of the tile
C915 AND $E0
C917 LD L,A
C918 SRL H
C91A RR L
C91C SRL H
C91E RR L
C920 SRL H
C922 RR L
C924 LD A,($A22C) Restore horizontal position into A
C927 LD E,A And add the horizontal position to the computed offset for the vertical position
C928 LD D,$00
C92A ADD HL,DE
C92B LD DE,$E55F Set HL to the address of the tile into the attribute buffer
C92E ADD HL,DE
C92F POP DE Restore DE and AF
C930 POP AF
C931 RET
Prev: C794 Up: Map Next: C932