Prev: 5EC8 Up: Map Next: 5F35
5EDB: Command 03: Fill Attribute Buffer With Single Colour
Used by the routine at PopulateRoomBuffer.
Command 03: fill the attribute buffer with a single colour, then parse an overlay map to apply per-cell colour changes. The overlay uses a simple encoding:
  • 12 + count: skip N attribute cells
  • 1B + count + colour: repeat a colour N times
  • 24: end of attribute data
  • Any other value: set a single attribute cell directly
Input
DE Tile counter
HL Pointer to the room data
Command03_FillAttributes 5EDB INC HL Increment the room data pointer by one.
5EDC LD C,(HL) Fetch the base fill colour into C.
Fill 02C0 attribute cells at RoomAttributeBuffer with the base colour.
5EDD LD IX,$D800 IX=RoomAttributeBuffer.
5EE1 LD DE,$02C0 DE=02C0.
FillAttributes_Loop 5EE4 LD (IX+$00),C Write C to *IX+00.
5EE7 INC IX Increment IX by one.
5EE9 DEC DE Decrease DE by one.
5EEA LD A,E Jump back to FillAttributes_Loop until DE is zero.
5EEB OR D
5EEC JR NZ,FillAttributes_Loop
Now parse the attribute overlay data to apply per-cell changes on top of the base fill colour.
FillAttributes_Overlay 5EEE INC HL Increment HL by one.
5EEF LD DE,$02C1 DE=02C1.
5EF2 LD IX,$D800 IX=RoomAttributeBuffer.
FillAttributes_Overlay_Loop 5EF6 LD A,(HL) A=*HL.
5EF7 CP $12 Jump to FillAttributes_Skip if A is 12 (skip command).
5EF9 JR Z,FillAttributes_Skip
5EFB CP $1B Jump to FillAttributes_Repeat if A is 1B (repeat command).
5EFD JR Z,FillAttributes_Repeat
5EFF CP $24 Jump to Room_Attributes_End if A is 24 (end of attribute data).
5F01 JR Z,Room_Attributes_End
Otherwise, write this byte directly as a single attribute value.
5F03 LD C,(HL) C=*HL.
5F04 LD (IX+$00),C Write C to *IX+00.
5F07 DEC DE Decrease DE by one.
5F08 INC IX Increment IX by one.
5F0A LD A,E Jump to PopulateRoomBuffer_Error if DE is zero.
5F0B OR D
5F0C JP Z,PopulateRoomBuffer_Error
5F0F INC HL Increment HL by one.
5F10 JR FillAttributes_Overlay_Loop Jump to FillAttributes_Overlay_Loop.
Attribute overlay command 12: skip over a number of attribute cells.
The following byte gives the skip count.
FillAttributes_Skip 5F12 INC HL Increment HL by one.
5F13 LD B,(HL) Fetch the skip count into B.
FillAttributes_Skip_Loop 5F14 INC IX Increment IX by one.
5F16 DEC DE Decrease DE by one.
5F17 LD A,E Jump to PopulateRoomBuffer_Error if DE is zero.
5F18 OR D
5F19 JP Z,PopulateRoomBuffer_Error
5F1C DJNZ FillAttributes_Skip_Loop Decrease the skip counter by one and loop back to FillAttributes_Skip_Loop until done.
5F1E INC HL Increment HL by one.
5F1F JR FillAttributes_Overlay_Loop Jump to FillAttributes_Overlay_Loop.
Attribute overlay command 1B: repeat a colour value a number of times. The following two bytes give the repeat count and colour value.
FillAttributes_Repeat 5F21 INC HL Increment HL by one.
5F22 LD B,(HL) Fetch the repeat count into B.
5F23 INC HL Increment HL by one.
5F24 LD C,(HL) Fetch the colour value into C.
5F25 INC HL Increment HL past the colour value byte.
FillAttributes_Repeat_Loop 5F26 LD (IX+$00),C Write C to *IX+00.
5F29 INC IX Increment IX by one.
5F2B DEC DE Decrease DE by one.
5F2C LD A,E Jump to PopulateRoomBuffer_Error if DE is zero.
5F2D OR D
5F2E JP Z,PopulateRoomBuffer_Error
5F31 DJNZ FillAttributes_Repeat_Loop Decrease the repeat counter by one and loop back to FillAttributes_Repeat_Loop until done.
5F33 JR FillAttributes_Overlay_Loop Jump to FillAttributes_Overlay_Loop.
Prev: 5EC8 Up: Map Next: 5F35