Prev: 6F44 Up: Map Next: 70F6
6F57: 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 6F57 PUSH HL Stash HL on the stack.
6F58 CALL RowWord Call RowWord.
6F5B EX DE,HL Add the picture origin.
6F5C ADD HL,BC
6F5D LD ($5BBA),HL Store the buffer address in Picture_Destination.
6F60 POP HL Restore the shape pointer from the stack.
6F61 INC HL Store the next shape pointer in Shape_Pointer.
6F62 LD ($5BBC),HL
Start this shape with overwrite and no run count.
6F65 XOR A Write 00 to Combine_Mode and Run_Count.
6F66 LD ($5BC8),A
6F69 LD ($5BC0),A
Fetch the next shape byte and remember it for the shift that follows.
ReadShapeByte 6F6C XOR A Write 00 to Shift_Flags.
6F6D LD ($5BBE),A
6F70 LD A,(HL) Fetch the next shape byte.
Marker FB replaces this byte from the parameter block.
6F71 CP $FB Call FetchParameterByte if it is FB, which replaces this byte.
6F73 CALL Z,FetchParameterByte
Marker EF paints a run of 01 blank tiles.
6F76 CP $EF Jump to ReadShapeByte_Marker if it is not EF, a blank run of 01.
6F78 JR NZ,ReadShapeByte_Marker
6F7A LD A,$01 Jump to ReadShapeByte_Store with a blank run of 01.
6F7C JR ReadShapeByte_Store
Marker EE paints a run of 02 blank tiles.
ReadShapeByte_Marker 6F7E CP $EE Jump to ReadShapeByte_Wide if it is not EE, a blank run of 02.
6F80 JR NZ,ReadShapeByte_Wide
6F82 LD A,$02 Jump to ReadShapeByte_Store with a blank run of 02.
6F84 JR ReadShapeByte_Store
Marker EB paints a run of 03 blank tiles.
ReadShapeByte_Wide 6F86 CP $EB Jump to ReadShapeByte_Literal if it is not EB, a blank run of 03.
6F88 JR NZ,ReadShapeByte_Literal
6F8A LD A,$03 Jump to ReadShapeByte_Store with a blank run of 03.
6F8C JR ReadShapeByte_Store
Marker F3 paints a run of blank tiles; the next byte is the count.
ReadShapeByte_Literal 6F8E CP $F3 Jump to SpecialShape if it is not F3, a counted blank run.
6F90 JR NZ,SpecialShape
6F92 INC HL Fetch the run count.
6F93 LD A,(HL)
Store the run count and the default shift flags.
ReadShapeByte_Store 6F94 LD ($5BC0),A Store it in Run_Count.
6F97 LD A,$82 Write default flags 82 (no shift, page 0, overwrite) to Shift_Flags and Shift_Flag.
6F99 LD ($5BBE),A
6F9C LD ($5BBF),A
6F9F LD ($5BBC),HL Store HL in Shape_Pointer.
6FA2 XOR A The tile number is 00.
6FA3 JR ScaleShape Jump to ScaleShape.
Marker FA copies a parameter block. Other markers adjust the coordinate that follows.
SpecialShape 6FA5 CP $FA Jump to SpecialShape_Other if it is not FA, which copies a parameter block.
6FA7 JR NZ,SpecialShape_Other
Copy the parameter block.
6FA9 CALL CopyParameterBlock Call CopyParameterBlock.
6FAC JR ReadShapeByte Jump to ReadShapeByte.
Adjust the coordinate that follows.
SpecialShape_Other 6FAE LD ($5BBC),HL Store HL in Shape_Pointer.
6FB1 BIT 7,A Jump to ScaleShape if bit 7 is reset.
6FB3 JR Z,ScaleShape
6FB5 LD ($5BBE),A Copy the marker into Shift_Flags and Shift_Flag.
6FB8 LD ($5BBF),A
6FBB AND %00000010 Keep only bit 1.
6FBD JR Z,SpecialShape_Advance Jump to SpecialShape_Advance if bit 1 is reset.
6FBF INC HL Advance to the run count.
6FC0 LD A,(HL)
6FC1 LD ($5BC0),A Store it in Run_Count.
Step on to the coordinate.
SpecialShape_Advance 6FC4 INC HL Advance Shape_Pointer.
6FC5 LD ($5BBC),HL
6FC8 LD A,(HL) Fetch the coordinate.
Multiply the coordinate by eight and add the picture origin.
ScaleShape 6FC9 LD L,A Copy the coordinate into HL.
6FCA LD H,$00
6FCC LD BC,$C350 Point BC at PictureTiles.
6FCF LD A,($5BBF) Jump to ScaleShape_Offset if bit 0 of Shift_Flag is reset.
6FD2 BIT 0,A
6FD4 JR Z,ScaleShape_Offset
6FD6 INC B Add 0400 to the tile base.
6FD7 INC B
6FD8 INC B
6FD9 INC B
Point at the tile bytes and choose a shift.
ScaleShape_Offset 6FDA ADD HL,HL Multiply the coordinate by eight.
6FDB ADD HL,HL
6FDC ADD HL,HL
6FDD ADD HL,BC Add the tile base.
6FDE PUSH HL Point IX at those bytes (using the stack).
6FDF POP IX
6FE1 LD HL,$5BB2 Point HL at Tile_Workspace.
6FE4 LD B,$08 Count the 08 pixel rows of this tile.
6FE6 LD A,($5BBE) Fetch Shift_Flags.
6FE9 AND %00110000 Keep only bits 4-5.
6FEB JR NZ,ScaleShape_Left Jump to ScaleShape_Left if a shift is needed.
Copy eight unshifted bytes.
ScaleShape_Copy 6FED LD A,(IX+$00) Copy one tile byte.
6FF0 LD (HL),A
6FF1 INC IX Step both pointers.
6FF3 INC HL
6FF4 DJNZ ScaleShape_Copy Jump to ScaleShape_Copy until eight bytes are copied.
6FF6 JR ScaleShape_Rotate Jump to ScaleShape_Rotate.
Shift left when bits 4-5 are 10.
ScaleShape_Left 6FF8 CP $10 Jump to ScaleShape_Right if the shift is not 10.
6FFA JR NZ,ScaleShape_Right
6FFC LD C,$08 Count the 08 tile bytes to shift left.
One left-shift pass.
ScaleShape_LeftPass 6FFE LD B,$08 Count the 08 bits of this tile byte.
7000 LD A,(IX+$00) Fetch this tile byte.
Rotate one tile byte left into the workspace.
ScaleShape_LeftBit 7003 SLA A Rotate this bit into the workspace.
7005 RR (HL)
7007 INC HL Advance the workspace pointer.
7008 DJNZ ScaleShape_LeftBit Jump to ScaleShape_LeftBit until eight bits are done.
700A LD HL,$5BB2 Point HL at Tile_Workspace.
700D INC IX Advance the tile pointer.
700F DEC C Jump to ScaleShape_LeftPass until eight bytes have been shifted.
7010 JR NZ,ScaleShape_LeftPass
7012 JR ScaleShape_Rotate Jump to ScaleShape_Rotate.
Shift right when bits 4-5 are 20.
ScaleShape_Right 7014 CP $20 Jump to ScaleShape_Srl if the shift is not 20.
7016 JR NZ,ScaleShape_Srl
7018 LD C,$08 Count the 08 tile bytes to shift right.
701A LD HL,$5BB9 Point HL at 5BB9.
One right-shift pass.
ScaleShape_RightPass 701D LD B,$08 Count the 08 bits of this tile byte.
701F LD A,(IX+$00) Fetch this tile byte.
Rotate one tile byte left into the workspace, backwards.
ScaleShape_RightBit 7022 SLA A Rotate this bit into the workspace.
7024 RR (HL)
7026 DJNZ ScaleShape_RightBit
7028 INC IX Step both pointers.
702A DEC HL
702B DEC C Jump to ScaleShape_RightPass until eight bytes have been shifted.
702C JR NZ,ScaleShape_RightPass
702E JR ScaleShape_Rotate Jump to ScaleShape_Rotate.
Shift right when bits 4-5 are 30.
ScaleShape_Srl 7030 CP $30 Jump to ScaleShape_Rotate if the shift is not 30.
7032 JR NZ,ScaleShape_Rotate
7034 LD C,$08 Count the 08 tile bytes to shift right.
One logical-right pass.
ScaleShape_SrlPass 7036 LD B,$08 Count the 08 bits of this tile byte.
7038 LD A,(IX+$00) Fetch this tile byte.
Rotate one tile byte right into the workspace.
ScaleShape_SrlBit 703B SRL A Rotate this bit into the workspace.
703D RL (HL)
703F INC HL Advance the workspace pointer.
7040 DJNZ ScaleShape_SrlBit Jump to ScaleShape_SrlBit until eight bits are done.
7042 LD HL,$5BB2 Point HL at Tile_Workspace.
7045 INC IX Advance the tile pointer.
7047 DEC C Jump to ScaleShape_SrlPass until eight bytes have been shifted.
7048 JR NZ,ScaleShape_SrlPass
Optionally rotate the workspace once more.
ScaleShape_Rotate 704A LD A,($5BBE) Fetch Shift_Flags.
704D AND %01000000 Keep only bit 6.
704F OR A Jump to ScaleShape_Combine if bit 6 is reset.
7050 JR Z,ScaleShape_Combine
7052 LD C,$08 Count the 08 workspace bytes to rotate left.
7054 LD HL,$5BB2 Point HL at Tile_Workspace.
One extra left-shift pass.
ScaleShape_RotatePass 7057 LD B,$08 Fetch eight bits of this workspace byte.
7059 LD A,(HL)
Rotate this workspace byte left.
ScaleShape_RotateBit 705A SLA A Rotate this bit in place.
705C RR (HL)
705E DJNZ ScaleShape_RotateBit
7060 INC HL Advance the workspace pointer.
7061 DEC C Jump to ScaleShape_RotatePass until eight bytes have been shifted.
7062 JR NZ,ScaleShape_RotatePass
Combine the workspace with the destination.
ScaleShape_Combine 7064 LD DE,($5BBA) Point DE at Picture_Destination.
7068 LD HL,$5BB2 Point HL at Tile_Workspace.
706B LD B,$08 Count the 08 pixel rows to merge.
Choose how this byte is merged.
ScaleShape_Merge 706D LD A,($5BC8) Jump to ScaleShape_And if Combine_Mode is not 04.
7070 CP $04
7072 JR NZ,ScaleShape_And
7074 LD A,(DE) OR the workspace byte into the destination.
7075 OR (HL)
7076 JR ScaleShape_Write
AND when the combine mode is 08.
ScaleShape_And 7078 CP $08 Jump to ScaleShape_Xor if Combine_Mode is not 08.
707A JR NZ,ScaleShape_Xor
707C LD A,(DE) AND the workspace byte into the destination.
707D AND (HL)
707E JR ScaleShape_Write
XOR when the combine mode is 0C.
ScaleShape_Xor 7080 CP $0C Jump to ScaleShape_Plain if Combine_Mode is not 0C.
7082 JR NZ,ScaleShape_Plain
7084 LD A,(DE) XOR the workspace byte into the destination.
7085 XOR (HL)
7086 JR ScaleShape_Write
Write the merged byte.
ScaleShape_Plain 7088 LD A,(HL) Use the workspace byte as-is.
Store this byte and step to the next pixel row.
ScaleShape_Write 7089 LD (DE),A Write the byte to the destination and the workspace.
708A LD (HL),A
708B INC HL Step both pointers.
708C INC D
708D DJNZ ScaleShape_Merge Jump to ScaleShape_Merge until eight rows are done.
708F LD A,($5BBE) Fetch Shift_Flags.
7092 AND %00001100 Keep only bits 2-3.
7094 LD ($5BC8),A Store that in Combine_Mode.
7097 JR NZ,ScaleShape_Next Jump to ScaleShape_Next if it is set.
Repeat the copy for the remaining run count.
ScaleShape_Repeat 7099 LD A,($5BC0) Jump to ScaleShape_Step if Run_Count has reached 00.
709C OR A
709D JR Z,ScaleShape_Step
709F CALL ScaleShape_Column Call ScaleShape_Column.
70A2 LD B,$08 Count the 08 pixel rows to copy.
70A4 LD HL,$5BB2 Point HL at Tile_Workspace.
70A7 LD DE,($5BBA) Point DE at Picture_Destination.
Copy eight bytes to the destination.
ScaleShape_RepeatCopy 70AB LD A,(HL) Copy this byte.
70AC LD (DE),A
70AD INC HL Step both pointers.
70AE INC D
70AF DJNZ ScaleShape_RepeatCopy Jump to ScaleShape_RepeatCopy until eight rows are done.
70B1 LD A,($5BC0) Count down Run_Count.
70B4 DEC A
70B5 LD ($5BC0),A
70B8 JR NZ,ScaleShape_Repeat Jump to ScaleShape_Repeat until the run is done.
Step the destination on after the run.
ScaleShape_Step 70BA CALL ScaleShape_Column Call ScaleShape_Column.
Fetch the next shape byte.
ScaleShape_Next 70BD LD HL,($5BBC) Advance Shape_Pointer.
70C0 INC HL
70C1 LD ($5BBC),HL
70C4 JP ReadShapeByte Jump to ReadShapeByte.
Step the destination to the next column, wrapping at the row width.
ScaleShape_Column 70C7 LD DE,($5BBA) Advance Picture_Destination.
70CB INC DE
70CC LD ($5BBA),DE
70D0 LD HL,$5BC6 Point HL at Column_Counter.
70D3 DEC (HL) Return if this row still has columns left.
70D4 RET NZ
70D5 LD HL,$5BC7 Point HL at Rows_Remaining.
70D8 DEC (HL) Jump to AbandonShape if the remaining rows have run out.
70D9 JR Z,AbandonShape
70DB LD A,($5BC4) Copy Row_Width into Column_Counter.
70DE LD ($5BC6),A
70E1 LD A,($5BC3) Step Drawing_Y.
70E4 INC A
70E5 LD ($5BC3),A
Look up the new row.
70E8 CALL RowWord Call RowWord.
70EB LD A,($5BC1) Copy Picture_X into HL.
70EE LD L,A
70EF LD H,$00
70F1 ADD HL,DE Add the destination.
70F2 LD ($5BBA),HL Store it in Picture_Destination.
70F5 RET Return.
Prev: 6F44 Up: Map Next: 70F6