Prev: 28920 Up: Map Next: 29064
28942: Paint Shape Bytes
Used by the routine at PlotShape.
Copies the expanded shape into the attribute buffer, honouring the 254 and 251 markers that end or repeat a run.
PaintShape 28942 LD HL,(23484) Fetch Shape_Pointer.
28945 INC HL Step to the first shape byte.
28946 PUSH HL Stash that pointer on the stack.
28947 LD A,(23492) Copy Row_Width into Column_Counter.
28950 LD (23494),A
28953 LD HL,(23490) Fetch Picture_Y.
28956 LD H,0 Keep only the low byte.
28958 CALL 3731 Call CL_LINE.
28961 LD A,(23489) Copy Picture_X into DE.
28964 LD E,A
28965 LD D,0
28967 ADD HL,DE Add the X coordinate.
28968 LD DE,(23497) Fetch Destination_Base.
28972 ADD HL,DE Add it.
28973 EX DE,HL Swap the destination into DE.
28974 POP HL Restore the shape pointer from the stack.
Paint the next shape byte.
PaintShape_Byte 28975 PUSH HL Stash the shape pointer on the stack.
28976 LD A,(HL) Fetch this shape byte.
28977 CP 251 Jump to PaintShape_Markers if it is not 251.
28979 JR NZ,PaintShape_Markers
28981 PUSH DE Stash the destination on the stack.
Fetch the parameter byte.
28982 CALL FetchParameterByte Call FetchParameterByte.
28985 POP DE Restore the destination from the stack.
28986 POP BC Replace the shape pointer (using the stack).
28987 PUSH HL
The terminator 254 ends the shape, and 250 copies a parameter block.
PaintShape_Markers 28988 CP 254 Jump to AbandonShape if it is the terminator 254.
28990 JR Z,AbandonShape
28992 CP 250 Jump to PaintShape_Run if it is not 250.
28994 JR NZ,PaintShape_Run
Copy the parameter block.
28996 PUSH DE Call CopyParameterBlock.
28997 CALL CopyParameterBlock
29000 POP DE
29001 POP AF Drop the old pointer.
29002 JR PaintShape_Byte Jump to PaintShape_Byte.
A run-length byte has bit 7 set.
PaintShape_Run 29004 BIT 7,A Jump to PaintShape_Write if bit 7 is reset.
29006 JR Z,PaintShape_Write
29008 AND %01111111 Keep only bits 0-6.
29010 DEC A Store that in Run_Count.
29011 LD (23488),A
29014 LD A,(23499) Fetch Last_Painted_Byte.
Write this attribute byte.
PaintShape_Write 29017 LD (DE),A Write the byte.
29018 LD (23499),A Store it in Last_Painted_Byte.
29021 INC DE Advance the destination.
29022 LD HL,23494 Point HL at Column_Counter.
29025 DEC (HL) Jump to PaintShape_Repeat if this row still has columns left.
29026 JR NZ,PaintShape_Repeat
29028 PUSH HL Stash the column counter on the stack.
29029 LD A,(23492) Copy Row_Width into Column_Counter.
29032 LD (23494),A
29035 LD L,A 32 minus the columns used.
29036 LD A,32
29038 SUB L
29039 LD L,A
29040 LD H,0 Add that gap to the destination.
29042 ADD HL,DE
29043 EX DE,HL
29044 POP HL Restore the column counter from the stack.
Repeat the last byte for the remaining run count.
PaintShape_Repeat 29045 LD A,(23488) Jump to PaintShape_Next if Run_Count has reached 0.
29048 OR A
29049 JR Z,PaintShape_Next
29051 DEC A Decrement Run_Count.
29052 LD (23488),A
29055 LD A,(23499) Fetch Last_Painted_Byte.
29058 JR PaintShape_Write Jump to PaintShape_Write.
Step on to the next shape byte.
PaintShape_Next 29060 POP HL Restore the shape pointer from the stack.
29061 INC HL Advance it.
29062 JR PaintShape_Byte Jump to PaintShape_Byte.
Prev: 28920 Up: Map Next: 29064