Prev: 7F78 Up: Map Next: 80EE
7FA7: Drawing: Start A Picture Command
Used by the routine at Drawing.
Reads picture commands. 00 ends the picture, 08 moves the pen, bit 7 draws a line, and the other bytes fill or paint.
Drawing routines.
DrawingSetup 7FA7 PUSH IY Save the picture registers and clear the window when the place is dark.
7FA9 PUSH HL
7FAA PUSH HL
7FAB POP IY
7FAD PUSH DE
7FAE PUSH BC
7FAF CALL DrawingClear
7FB2 LD D,$7F Start the high coordinate at 7F.
7FB4 LD E,$3F Start the low coordinate at 3F.
7FB6 LD B,$01 Start the step count at 01.
7FB8 LD C,$01 Start the direction at 01.
7FBA LD L,$01 Start the length at 01.
Drawing_Loop 7FBC LD A,(IY+$00) Fetch the next drawing instruction.
7FBF AND A If the drawing instruction is zero, jump to Drawing_End.
7FC0 JP Z,Drawing_End
7FC3 INC IY Increment the graphics data pointer by one.
7FC5 CP $08 If the graphics data value which was fetched is not 08 (move to X/Y) jump to DrawingSetup_TestForALine.
7FC7 JR NZ,DrawingSetup_TestForALine
Moves the "pen" held in DE to a screen location.
7FC9 LD D,(IY+$00) Populate DE with two values from the graphics data and increment the pointer by two.
7FCC INC IY
7FCE LD E,(IY+$00)
7FD1 INC IY
7FD3 JR Drawing_Loop Jump back to Drawing_Loop for the next drawing instruction.
DrawingSetup_TestForALine 7FD5 BIT 7,A If bit 7 is clear, jump to DrawingSetup_TestForAFill. A set bit 7 is a line.
7FD7 JR Z,DrawingSetup_TestForAFill
7FD9 LD B,A Keep the line command.
7FDA AND %00000111 The low three bits are the direction.
7FDC LD C,A Store the direction in C.
7FDD LD A,B Bring the line command back.
7FDE RRCA
7FDF AND $3C
7FE1 LD B,A Store this in B.
7FE2 LD A,(IY+$00) Read the length byte of the line.
7FE5 AND %00111111 The low six bits are the length.
7FE7 LD L,A Store that length.
7FE8 INC L A stored length of zero draws one pixel.
7FE9 LD A,(IY+$00) Read the length byte again for the step spacing.
7FEC INC IY Increment the graphics data pointer by one.
7FEE RLCA Move bits 6-7 down to bits 0-1.
7FEF RLCA
7FF0 AND $03
7FF2 OR B Combine the step spacing from both command bytes.
7FF3 LD B,A Store the step spacing.
7FF4 INC B A stored spacing of zero steps every pixel.
7FF5 CALL Drawing_PlotTheSelectedPixel Call Drawing_PlotTheSelectedPixel to plot the line.
7FF8 JR Drawing_Loop Jump back to Drawing_Loop for the next drawing instruction.
A set bit 6 is a fill.
DrawingSetup_TestForAFill 7FFA BIT 6,A Jump to DrawingSetup_RepeatWhileBitFiveIsClear if bit 6 is clear.
7FFC JR Z,DrawingSetup_RepeatWhileBitFiveIsClear
7FFE AND %00000111 The low three bits are the fill ink.
8000 PUSH DE Read the fill's X coordinate.
8001 LD D,(IY+$00)
8004 INC IY Advance the graphics pointer.
8006 LD E,(IY+$00) Read the fill's other coordinate.
8009 INC IY Advance the graphics pointer.
Flood-fill from the point in DE.
800B CALL DrawingSetup_0 Call DrawingSetup_0 to flood-fill from that point.
800E POP DE Jump back to Drawing_Loop to fetch the next drawing instruction.
800F JP Drawing_Loop
DrawingSetup_RepeatWhileBitFiveIsClear 8012 BIT 5,A Jump back to Drawing_Loop if bit 5 of this picture command is clear.
8014 JP Z,Drawing_Loop
8017 AND %00000111 The low three bits are the ink to paint.
8019 RLCA Shift the ink towards the paper bits.
801A RLCA Shift the ink towards the paper bits.
801B RLCA Shift the ink into the paper bits.
801C PUSH HL Save HL, DE and BC, and keep the scaled bits in C.
801D PUSH DE
801E PUSH BC
801F LD C,A
8020 LD H,(IY+$00) Read the attribute address high byte into H.
8023 INC IY Advance the graphics pointer.
8025 LD L,(IY+$00) Read the attribute address low byte into L.
8028 INC IY Advance the graphics pointer.
DrawingSetup_ReadTheNextAttributeByte 802A LD A,(IY+$00) Read the next attribute byte.
802D INC IY Advance the graphics pointer.
802F CP $FF Jump to DrawingSetup_FetchTheNextDrawingInstruction at the FF terminator.
8031 JR Z,DrawingSetup_FetchTheNextDrawingInstruction
8033 LD B,A Copy the result into B.
8034 AND %00000011 The low two bits choose which way this attribute run steps.
8036 LD E,A Store that step.
8037 LD A,B Shift the length down two bits.
8038 RRCA
8039 RRCA
803A AND $3F
803C INC A A stored length of zero paints one cell.
803D LD B,A Copy the result into B.
DrawingSetup_Loop 803E LD A,(HL) Read the next byte.
803F AND %00000111 Jump to DrawingSetup_StoreTheAttribute when this cell's ink is not the ink being replaced.
8041 RLCA
8042 RLCA
8043 RLCA
8044 CP C
8045 JR NZ,DrawingSetup_StoreTheAttribute
8047 XOR $38 Flip the bits selected by 38.
DrawingSetup_StoreTheAttribute 8049 RRCA Shift the ink back into bits 0-2, merge it with C and store the attribute; then call Drawing_StepUpOneRow if the direction in E is 00.
804A RRCA
804B RRCA
804C OR C
804D LD (HL),A
804E LD A,E
804F AND A
8050 CALL Z,Drawing_StepUpOneRow
8053 DEC A Call Drawing_StepRightOnePixel if the direction is 01.
8054 CALL Z,Drawing_StepRightOnePixel
8057 DEC A Call Drawing_StepDownOneRow if the direction is 02.
8058 CALL Z,Drawing_StepDownOneRow
805B DEC A Call Drawing_StepLeftOnePixel if the direction is 03.
805C CALL Z,Drawing_StepLeftOnePixel
805F DJNZ DrawingSetup_Loop Loop back to DrawingSetup_Loop until the count runs out.
8061 JR DrawingSetup_ReadTheNextAttributeByte Jump back to DrawingSetup_ReadTheNextAttributeByte for the next attribute byte.
Restore the registers saved for this shape.
DrawingSetup_FetchTheNextDrawingInstruction 8063 POP BC Restore BC, DE and HL from the stack, then jump to Drawing_Loop for the next drawing instruction.
8064 POP DE
8065 POP HL
8066 JP Drawing_Loop
This entry point is used by the routine at DrawingClear.
Drawing_End 8069 POP BC Restore BC, DE, HL and IY from the stack.
806A POP DE
806B POP HL
806C POP IY
806E RET Return.
806F DEFB $00,$00
DrawingSetup_0 8071 LD ($824E),A Store the result at 824E.
8074 PUSH DE Allow 80 steps of this flood fill.
8075 PUSH HL
8076 LD HL,$0080
8079 PUSH HL
DrawingSetup_MaskOneScreenByte 807A CALL Drawing_MaskOneScreenByte Call Drawing_MaskOneScreenByte to mask one screen byte.
807D JR NZ,DrawingSetup_AddressThePixel Jump to DrawingSetup_AddressThePixel if Drawing_MaskOneScreenByte found the masked screen byte set.
807F CALL Drawing_RetreatTheHighCoordinate Call Drawing_RetreatTheHighCoordinate to retreat the high coordinate.
8082 JR NZ,DrawingSetup_MaskOneScreenByte Jump back to DrawingSetup_MaskOneScreenByte if Drawing_RetreatTheHighCoordinate did not wrap the high coordinate.
8084 JR DrawingSetup_ClearTheFloodFillCount Jump to DrawingSetup_ClearTheFloodFillCount to clear the saved coordinate, because the high coordinate wrapped.
DrawingSetup_AddressThePixel 8086 CALL Drawing_AddressThePixel Call Drawing_AddressThePixel to address the pixel.
8089 CALL Drawing_AdvanceTheHighCoordinate Call Drawing_AdvanceTheHighCoordinate to advance the high coordinate.
DrawingSetup_ClearTheFloodFillCount 808C LD HL,$0000 Store 0000 in *806F.
808F LD ($806F),HL
DrawingSetup_AdvanceTheLowCoordinate 8092 CALL Drawing_AdvanceTheLowCoordinate Call Drawing_AdvanceTheLowCoordinate to advance the low coordinate.
8095 LD A,$00 Take zero and jump to DrawingSetup_StoreTheResultAtFloodFillCount if Drawing_AdvanceTheLowCoordinate wrapped the low coordinate.
8097 JR Z,DrawingSetup_StoreTheResultAtFloodFillCount
8099 CALL Drawing_MaskOneScreenByte Call Drawing_MaskOneScreenByte to mask one screen byte.
809C LD A,$00 Take zero and jump to DrawingSetup_RetreatTheLowCoordinate if Drawing_MaskOneScreenByte found the masked screen byte set.
809E JR NZ,DrawingSetup_RetreatTheLowCoordinate
Test this flag.
80A0 LD A,($806F) Jump to DrawingSetup_RetreatTheLowCoordinate if *806F is not zero.
80A3 AND A
80A4 JR NZ,DrawingSetup_RetreatTheLowCoordinate
80A6 PUSH DE Use 01 when the coordinate was zero.
80A7 LD A,$01
DrawingSetup_RetreatTheLowCoordinate 80A9 PUSH AF Call Drawing_RetreatTheLowCoordinate to retreat the low coordinate, then restore AF from the stack.
80AA CALL Drawing_RetreatTheLowCoordinate
80AD POP AF
DrawingSetup_StoreTheResultAtFloodFillCount 80AE LD ($806F),A Store the result at 806F.
80B1 CALL Drawing_RetreatTheLowCoordinate Call Drawing_RetreatTheLowCoordinate to retreat the low coordinate.
80B4 LD A,$00 Take zero, and jump to DrawingSetup_StoreTheHighCoordinate if Drawing_RetreatTheLowCoordinate returned with the zero flag set.
80B6 JR Z,DrawingSetup_StoreTheHighCoordinate
80B8 CALL Drawing_MaskOneScreenByte Call Drawing_MaskOneScreenByte to mask one screen byte.
80BB LD A,$00 Take zero, and jump to DrawingSetup_AdvanceAndRestore if Drawing_MaskOneScreenByte found the masked screen byte set.
80BD JR NZ,DrawingSetup_AdvanceAndRestore
Test this flag.
80BF LD A,($8070) Jump to DrawingSetup_AdvanceAndRestore if the drawing scratch is not zero.
80C2 AND A
80C3 JR NZ,DrawingSetup_AdvanceAndRestore
80C5 PUSH DE Use 01 when the coordinate was zero.
80C6 LD A,$01
DrawingSetup_AdvanceAndRestore 80C8 PUSH AF Call Drawing_AdvanceTheLowCoordinate to advance the low coordinate, then restore AF from the stack.
80C9 CALL Drawing_AdvanceTheLowCoordinate
80CC POP AF
DrawingSetup_StoreTheHighCoordinate 80CD LD ($8070),A Store the result at 8070.
80D0 CALL Drawing_AddressThePixel Call Drawing_AddressThePixel to address the pixel.
80D3 CALL Drawing_AdvanceTheHighCoordinate Call Drawing_AdvanceTheHighCoordinate to advance the high coordinate.
80D6 JR Z,DrawingSetup_TestTheFloodFillCount Jump to DrawingSetup_TestTheFloodFillCount if Drawing_AdvanceTheHighCoordinate wrapped the high coordinate.
80D8 CALL Drawing_MaskOneScreenByte Call Drawing_MaskOneScreenByte to mask one screen byte.
80DB JR Z,DrawingSetup_AdvanceTheLowCoordinate Jump back to DrawingSetup_AdvanceTheLowCoordinate if Drawing_MaskOneScreenByte found the masked screen byte clear.
80DD CALL Drawing_AddressThePixel Call Drawing_AddressThePixel to address the pixel.
DrawingSetup_TestTheFloodFillCount 80E0 POP DE Jump back to DrawingSetup_MaskOneScreenByte unless the flood-fill count is 80.
80E1 LD A,E
80E2 CP $80
80E4 JR NZ,DrawingSetup_MaskOneScreenByte
80E6 LD A,$00 Write 00 to *824E.
80E8 LD ($824E),A
80EB POP HL Restore HL and DE from the stack.
80EC POP DE
80ED RET Return.
View the equivalent code in;
Prev: 7F78 Up: Map Next: 80EE