Prev: 24448 Up: Map Next: 24619
24592: 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
1 24673
2 27523
3 30566
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
24673 232 11101000 104
24674 158
So, in 24673 bit 7 is set - after a reset we take 24674 as a counter and hence copy 104 into the following 158 memory locations.
Background_Attributes 24592 LD DE,22528 Begin at the start of the 22528.
Background_Attributes_Loop 24595 LD A,(HL) Pick up the attribute data from HL.
24596 INC HL Increase HL by one.
24597 CP (HL) If the following byte is different to the current attribute byte jump to Background_Attributes_Repeat_Copy.
24598 JR NZ,Background_Attributes_Repeat_Copy
24600 AND A The data terminates with double zeroes, so if this occurs then return.
24601 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 24602 BIT 7,A Test if d7 is set in current attribute data. Reset bit to zero.
24604 RES 7,A
24606 LD (DE),A Write the attribute data to DE.
24607 INC DE Increment DE by one.
24608 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.
24610 LD B,(HL) Pick up the attribute data from HL into B to use as a counter.
24611 INC HL Increase HL by one.
24612 DEC B Decrease the counter by one.
Background_Copy_Attribute_Repeat 24613 LD (DE),A Write the same attribute data to DE.
24614 INC DE Increment DE by one.
24615 DJNZ Background_Copy_Attribute_Repeat Decrease counter by one and loop back to Background_Copy_Attribute_Repeat until counter is zero.
24617 JR Background_Attributes_Loop Jump back to Background_Attributes_Loop.
Prev: 24448 Up: Map Next: 24619