Prev: 8D33 Up: Map Next: 8DC0
8D6B: Fill the buffer at 5E00 with attribute bytes for the current room
Used by the routine at 8D33. Fills the buffer at 5E00 with attribute bytes for the background, floor, wall, nasty, conveyor and ramp tiles in the current room.
8D6B LD HL,$8000 Point HL at the first room layout byte at 8000
8D6E LD IX,$5E00 Point IX at the first byte of the attribute buffer at 5E00
The following loop copies the attribute bytes for the background, floor, wall and nasty tiles into the buffer at 5E00.
8D72 LD A,(HL) Pick up a room layout byte
8D73 RLCA Move bits 6 and 7 into bits 0 and 1
8D74 RLCA
8D75 CALL $8DC0 Copy the attribute byte for this tile into the buffer at 5E00
8D78 LD A,(HL) Pick up the room layout byte again
8D79 RRCA Move bits 4 and 5 into bits 0 and 1
8D7A RRCA
8D7B RRCA
8D7C RRCA
8D7D CALL $8DC0 Copy the attribute byte for this tile into the buffer at 5E00
8D80 LD A,(HL) Pick up the room layout byte again
8D81 RRCA Move bits 2 and 3 into bits 0 and 1
8D82 RRCA
8D83 CALL $8DC0 Copy the attribute byte for this tile into the buffer at 5E00
8D86 LD A,(HL) Pick up the room layout byte again; this time the required bit-pair is already in bits 0 and 1
8D87 CALL $8DC0 Copy the attribute byte for this tile into the buffer at 5E00
8D8A INC HL Point HL at the next room layout byte
8D8B LD A,L Have we processed all 128 room layout bytes yet?
8D8C AND $80
8D8E JR Z,$8D72 If not, jump back to process the next one
Next consider the conveyor tiles (if any).
8D90 LD A,($80D9) Pick up the length of the conveyor from 80D9
8D93 OR A Is there a conveyor in the room?
8D94 JR Z,$8DA1 Jump if not
8D96 LD HL,($80D7) Pick up the address of the conveyor's location in the attribute buffer at 5E00 from 80D7
8D99 LD B,A B will count the conveyor tiles
8D9A LD A,($80CD) Pick up the attribute byte for the conveyor tile from 80CD
8D9D LD (HL),A Copy the attribute bytes for the conveyor tiles into the buffer at 5E00
8D9E INC HL
8D9F DJNZ $8D9D
And finally consider the ramp tiles (if any).
8DA1 LD A,($80DD) Pick up the length of the ramp from 80DD
8DA4 OR A Is there a ramp in the room?
8DA5 RET Z Return if not
8DA6 LD HL,($80DB) Pick up the address of the ramp's location in the attribute buffer at 5E00 from 80DB
8DA9 LD A,($80DA) Pick up the ramp direction from 80DA; A=0 (ramp goes up to the left) or 1 (ramp goes up to the right)
8DAC AND $01
8DAE RLCA Now DE=-33 (ramp goes up to the left) or -31 (ramp goes up to the right)
8DAF ADD A,$DF
8DB1 LD E,A
8DB2 LD D,$FF
8DB4 LD A,($80DD) Pick up the length of the ramp from 80DD
8DB7 LD B,A B will count the ramp tiles
8DB8 LD A,($80C4) Pick up the attribute byte for the ramp tile from 80C4
8DBB LD (HL),A Copy the attribute bytes for the ramp tiles into the buffer at 5E00
8DBC ADD HL,DE
8DBD DJNZ $8DBB
8DBF RET
Prev: 8D33 Up: Map Next: 8DC0