Prev: 28484 Up: Map Next: 28918
28503: Address Picture Byte
Used by the routines at PlotShape and ScaleShape_Screen.
Turns a character row into a pointer inside the attribute buffer, using the same row table as the text printer. It then reads each shape byte and expands the tiles.
Input
A Character row
HL Shape pointer
Output
HL Shape pointer
PictureAddress 28503 PUSH HL Stash HL on the stack.
28504 CALL RowWord Call RowWord.
28507 EX DE,HL Add the picture origin.
28508 ADD HL,BC
28509 LD (23482),HL Store the buffer address in Picture_Destination.
28512 POP HL Restore the shape pointer from the stack.
28513 INC HL Store the next shape pointer in Shape_Pointer.
28514 LD (23484),HL
Start this shape with overwrite and no run count.
28517 XOR A Write 0 to Combine_Mode and Run_Count.
28518 LD (23496),A
28521 LD (23488),A
Fetch the next shape byte and remember it for the shift that follows.
ReadShapeByte 28524 XOR A Write 0 to Shift_Flags.
28525 LD (23486),A
28528 LD A,(HL) Fetch the next shape byte.
Marker 251 replaces this byte from the parameter block.
28529 CP 251 Call FetchParameterByte if it is 251, which replaces this byte.
28531 CALL Z,FetchParameterByte
Marker 239 paints a run of 1 blank tiles.
28534 CP 239 Jump to ReadShapeByte_Marker if it is not 239, a blank run of 1.
28536 JR NZ,ReadShapeByte_Marker
28538 LD A,1 Jump to ReadShapeByte_Store with a blank run of 1.
28540 JR ReadShapeByte_Store
Marker 238 paints a run of 2 blank tiles.
ReadShapeByte_Marker 28542 CP 238 Jump to ReadShapeByte_Wide if it is not 238, a blank run of 2.
28544 JR NZ,ReadShapeByte_Wide
28546 LD A,2 Jump to ReadShapeByte_Store with a blank run of 2.
28548 JR ReadShapeByte_Store
Marker 235 paints a run of 3 blank tiles.
ReadShapeByte_Wide 28550 CP 235 Jump to ReadShapeByte_Literal if it is not 235, a blank run of 3.
28552 JR NZ,ReadShapeByte_Literal
28554 LD A,3 Jump to ReadShapeByte_Store with a blank run of 3.
28556 JR ReadShapeByte_Store
Marker 243 paints a run of blank tiles; the next byte is the count.
ReadShapeByte_Literal 28558 CP 243 Jump to SpecialShape if it is not 243, a counted blank run.
28560 JR NZ,SpecialShape
28562 INC HL Fetch the run count.
28563 LD A,(HL)
Store the run count and the default shift flags.
ReadShapeByte_Store 28564 LD (23488),A Store it in Run_Count.
28567 LD A,130 Write default flags 130 (no shift, page 0, overwrite) to Shift_Flags and Shift_Flag.
28569 LD (23486),A
28572 LD (23487),A
28575 LD (23484),HL Store HL in Shape_Pointer.
28578 XOR A The tile number is 0.
28579 JR ScaleShape Jump to ScaleShape.
Marker 250 copies a parameter block. Other markers adjust the coordinate that follows.
SpecialShape 28581 CP 250 Jump to SpecialShape_Other if it is not 250, which copies a parameter block.
28583 JR NZ,SpecialShape_Other
Copy the parameter block.
28585 CALL CopyParameterBlock Call CopyParameterBlock.
28588 JR ReadShapeByte Jump to ReadShapeByte.
Adjust the coordinate that follows.
SpecialShape_Other 28590 LD (23484),HL Store HL in Shape_Pointer.
28593 BIT 7,A Jump to ScaleShape if bit 7 is reset.
28595 JR Z,ScaleShape
28597 LD (23486),A Copy the marker into Shift_Flags and Shift_Flag.
28600 LD (23487),A
28603 AND %00000010 Keep only bit 1.
28605 JR Z,SpecialShape_Advance Jump to SpecialShape_Advance if bit 1 is reset.
28607 INC HL Advance to the run count.
28608 LD A,(HL)
28609 LD (23488),A Store it in Run_Count.
Step on to the coordinate.
SpecialShape_Advance 28612 INC HL Advance Shape_Pointer.
28613 LD (23484),HL
28616 LD A,(HL) Fetch the coordinate.
Multiply the coordinate by eight and add the picture origin.
ScaleShape 28617 LD L,A Copy the coordinate into HL.
28618 LD H,0
28620 LD BC,50000 Point BC at PictureTiles.
28623 LD A,(23487) Jump to ScaleShape_Offset if bit 0 of Shift_Flag is reset.
28626 BIT 0,A
28628 JR Z,ScaleShape_Offset
28630 INC B Add 1024 to the tile base.
28631 INC B
28632 INC B
28633 INC B
Point at the tile bytes and choose a shift.
ScaleShape_Offset 28634 ADD HL,HL Multiply the coordinate by eight.
28635 ADD HL,HL
28636 ADD HL,HL
28637 ADD HL,BC Add the tile base.
28638 PUSH HL Point IX at those bytes (using the stack).
28639 POP IX
28641 LD HL,23474 Point HL at Tile_Workspace.
28644 LD B,8 Count the 8 pixel rows of this tile.
28646 LD A,(23486) Fetch Shift_Flags.
28649 AND %00110000 Keep only bits 4-5.
28651 JR NZ,ScaleShape_Left Jump to ScaleShape_Left if a shift is needed.
Copy eight unshifted bytes.
ScaleShape_Copy 28653 LD A,(IX+0) Copy one tile byte.
28656 LD (HL),A
28657 INC IX Step both pointers.
28659 INC HL
28660 DJNZ ScaleShape_Copy Jump to ScaleShape_Copy until eight bytes are copied.
28662 JR ScaleShape_Rotate Jump to ScaleShape_Rotate.
Shift left when bits 4-5 are 16.
ScaleShape_Left 28664 CP 16 Jump to ScaleShape_Right if the shift is not 16.
28666 JR NZ,ScaleShape_Right
28668 LD C,8 Count the 8 tile bytes to shift left.
One left-shift pass.
ScaleShape_LeftPass 28670 LD B,8 Count the 8 bits of this tile byte.
28672 LD A,(IX+0) Fetch this tile byte.
Rotate one tile byte left into the workspace.
ScaleShape_LeftBit 28675 SLA A Rotate this bit into the workspace.
28677 RR (HL)
28679 INC HL Advance the workspace pointer.
28680 DJNZ ScaleShape_LeftBit Jump to ScaleShape_LeftBit until eight bits are done.
28682 LD HL,23474 Point HL at Tile_Workspace.
28685 INC IX Advance the tile pointer.
28687 DEC C Jump to ScaleShape_LeftPass until eight bytes have been shifted.
28688 JR NZ,ScaleShape_LeftPass
28690 JR ScaleShape_Rotate Jump to ScaleShape_Rotate.
Shift right when bits 4-5 are 32.
ScaleShape_Right 28692 CP 32 Jump to ScaleShape_Srl if the shift is not 32.
28694 JR NZ,ScaleShape_Srl
28696 LD C,8 Count the 8 tile bytes to shift right.
28698 LD HL,23481 Point HL at 23481.
One right-shift pass.
ScaleShape_RightPass 28701 LD B,8 Count the 8 bits of this tile byte.
28703 LD A,(IX+0) Fetch this tile byte.
Rotate one tile byte left into the workspace, backwards.
ScaleShape_RightBit 28706 SLA A Rotate this bit into the workspace.
28708 RR (HL)
28710 DJNZ ScaleShape_RightBit
28712 INC IX Step both pointers.
28714 DEC HL
28715 DEC C Jump to ScaleShape_RightPass until eight bytes have been shifted.
28716 JR NZ,ScaleShape_RightPass
28718 JR ScaleShape_Rotate Jump to ScaleShape_Rotate.
Shift right when bits 4-5 are 48.
ScaleShape_Srl 28720 CP 48 Jump to ScaleShape_Rotate if the shift is not 48.
28722 JR NZ,ScaleShape_Rotate
28724 LD C,8 Count the 8 tile bytes to shift right.
One logical-right pass.
ScaleShape_SrlPass 28726 LD B,8 Count the 8 bits of this tile byte.
28728 LD A,(IX+0) Fetch this tile byte.
Rotate one tile byte right into the workspace.
ScaleShape_SrlBit 28731 SRL A Rotate this bit into the workspace.
28733 RL (HL)
28735 INC HL Advance the workspace pointer.
28736 DJNZ ScaleShape_SrlBit Jump to ScaleShape_SrlBit until eight bits are done.
28738 LD HL,23474 Point HL at Tile_Workspace.
28741 INC IX Advance the tile pointer.
28743 DEC C Jump to ScaleShape_SrlPass until eight bytes have been shifted.
28744 JR NZ,ScaleShape_SrlPass
Optionally rotate the workspace once more.
ScaleShape_Rotate 28746 LD A,(23486) Fetch Shift_Flags.
28749 AND %01000000 Keep only bit 6.
28751 OR A Jump to ScaleShape_Combine if bit 6 is reset.
28752 JR Z,ScaleShape_Combine
28754 LD C,8 Count the 8 workspace bytes to rotate left.
28756 LD HL,23474 Point HL at Tile_Workspace.
One extra left-shift pass.
ScaleShape_RotatePass 28759 LD B,8 Fetch eight bits of this workspace byte.
28761 LD A,(HL)
Rotate this workspace byte left.
ScaleShape_RotateBit 28762 SLA A Rotate this bit in place.
28764 RR (HL)
28766 DJNZ ScaleShape_RotateBit
28768 INC HL Advance the workspace pointer.
28769 DEC C Jump to ScaleShape_RotatePass until eight bytes have been shifted.
28770 JR NZ,ScaleShape_RotatePass
Combine the workspace with the destination.
ScaleShape_Combine 28772 LD DE,(23482) Point DE at Picture_Destination.
28776 LD HL,23474 Point HL at Tile_Workspace.
28779 LD B,8 Count the 8 pixel rows to merge.
Choose how this byte is merged.
ScaleShape_Merge 28781 LD A,(23496) Jump to ScaleShape_And if Combine_Mode is not 4.
28784 CP 4
28786 JR NZ,ScaleShape_And
28788 LD A,(DE) OR the workspace byte into the destination.
28789 OR (HL)
28790 JR ScaleShape_Write
AND when the combine mode is 8.
ScaleShape_And 28792 CP 8 Jump to ScaleShape_Xor if Combine_Mode is not 8.
28794 JR NZ,ScaleShape_Xor
28796 LD A,(DE) AND the workspace byte into the destination.
28797 AND (HL)
28798 JR ScaleShape_Write
XOR when the combine mode is 12.
ScaleShape_Xor 28800 CP 12 Jump to ScaleShape_Plain if Combine_Mode is not 12.
28802 JR NZ,ScaleShape_Plain
28804 LD A,(DE) XOR the workspace byte into the destination.
28805 XOR (HL)
28806 JR ScaleShape_Write
Write the merged byte.
ScaleShape_Plain 28808 LD A,(HL) Use the workspace byte as-is.
Store this byte and step to the next pixel row.
ScaleShape_Write 28809 LD (DE),A Write the byte to the destination and the workspace.
28810 LD (HL),A
28811 INC HL Step both pointers.
28812 INC D
28813 DJNZ ScaleShape_Merge Jump to ScaleShape_Merge until eight rows are done.
28815 LD A,(23486) Fetch Shift_Flags.
28818 AND %00001100 Keep only bits 2-3.
28820 LD (23496),A Store that in Combine_Mode.
28823 JR NZ,ScaleShape_Next Jump to ScaleShape_Next if it is set.
Repeat the copy for the remaining run count.
ScaleShape_Repeat 28825 LD A,(23488) Jump to ScaleShape_Step if Run_Count has reached 0.
28828 OR A
28829 JR Z,ScaleShape_Step
28831 CALL ScaleShape_Column Call ScaleShape_Column.
28834 LD B,8 Count the 8 pixel rows to copy.
28836 LD HL,23474 Point HL at Tile_Workspace.
28839 LD DE,(23482) Point DE at Picture_Destination.
Copy eight bytes to the destination.
ScaleShape_RepeatCopy 28843 LD A,(HL) Copy this byte.
28844 LD (DE),A
28845 INC HL Step both pointers.
28846 INC D
28847 DJNZ ScaleShape_RepeatCopy Jump to ScaleShape_RepeatCopy until eight rows are done.
28849 LD A,(23488) Count down Run_Count.
28852 DEC A
28853 LD (23488),A
28856 JR NZ,ScaleShape_Repeat Jump to ScaleShape_Repeat until the run is done.
Step the destination on after the run.
ScaleShape_Step 28858 CALL ScaleShape_Column Call ScaleShape_Column.
Fetch the next shape byte.
ScaleShape_Next 28861 LD HL,(23484) Advance Shape_Pointer.
28864 INC HL
28865 LD (23484),HL
28868 JP ReadShapeByte Jump to ReadShapeByte.
Step the destination to the next column, wrapping at the row width.
ScaleShape_Column 28871 LD DE,(23482) Advance Picture_Destination.
28875 INC DE
28876 LD (23482),DE
28880 LD HL,23494 Point HL at Column_Counter.
28883 DEC (HL) Return if this row still has columns left.
28884 RET NZ
28885 LD HL,23495 Point HL at Rows_Remaining.
28888 DEC (HL) Jump to AbandonShape if the remaining rows have run out.
28889 JR Z,AbandonShape
28891 LD A,(23492) Copy Row_Width into Column_Counter.
28894 LD (23494),A
28897 LD A,(23491) Step Drawing_Y.
28900 INC A
28901 LD (23491),A
Look up the new row.
28904 CALL RowWord Call RowWord.
28907 LD A,(23489) Copy Picture_X into HL.
28910 LD L,A
28911 LD H,0
28913 ADD HL,DE Add the destination.
28914 LD (23482),HL Store it in Picture_Destination.
28917 RET Return.
Prev: 28484 Up: Map Next: 28918