Prev: 5F80 Up: Map Next: 602B
6010: Unpack Background Attribute Data
Used by the routine at Create_Background.
Unpacks the attribute data into the buffer. On entry HL will contain one of the following background reference memory locations;
Background reference Background data
01 6061
02 6B83
03 7766
The idea here is to use bit 7 (flash) as a flag to signify to copy the attrbute byte a specified number of times. For example;
Address Value Binary Value After Reset
6061 E8 11101000 68
6062 9E
So, in 6061 bit 7 is set - after a reset we take 6062 as a counter and hence copy 68 into the following 158 memory locations.
Background_Attributes 6010 LD DE,$5800 Begin at the start of the 5800.
Background_Attributes_Loop 6013 LD A,(HL) Pick up the attribute data from HL.
6014 INC HL Increase HL by one.
6015 CP (HL) If the following byte is different to the current attribute byte jump to Background_Attributes_Repeat_Copy.
6016 JR NZ,Background_Attributes_Repeat_Copy
6018 AND A The data terminates with double zeroes, so if this occurs then return.
6019 RET Z
Copy and loop back round to Background_Attributes_Loop until bit 7 in the current attribute data is set.
Background_Attributes_Repeat_Copy 601A BIT 7,A Test if d7 is set in current attribute data. Reset bit to zero.
601C RES 7,A
601E LD (DE),A Write the attribute data to DE.
601F INC DE Increment DE by one.
6020 JR Z,Background_Attributes_Loop Jump back to Background_Attributes_Loop unless the bit was set.
Using the following attribute data byte as a counter, copy the current byte this number of times.
6022 LD B,(HL) Pick up the attribute data from HL into B to use as a counter.
6023 INC HL Increase HL by one.
6024 DEC B Decrease the counter by one.
Background_Copy_Attribute_Repeat 6025 LD (DE),A Write the same attribute data to DE.
6026 INC DE Increment DE by one.
6027 DJNZ Background_Copy_Attribute_Repeat Decrease counter by one and loop back to Background_Copy_Attribute_Repeat until counter is zero.
6029 JR Background_Attributes_Loop Jump back to Background_Attributes_Loop.
Prev: 5F80 Up: Map Next: 602B