Prev: 8148 Up: Map Next: 81B5
8151: Drawing: Plot The Selected Pixel
Used by the routine at DrawingSetup.
Plots one line. Bit 0 of the direction chooses which coordinate steps first, and L is how many pixels are drawn.
Drawing_PlotTheSelectedPixel 8151 BIT 0,C Jump to Drawing_PlotTheSelectedPixel_OtherDirection when bit 0 of the direction is set.
8153 JR NZ,Drawing_PlotTheSelectedPixel_OtherDirection
8155 PUSH HL
8156 PUSH BC
Drawing_PlotTheSelectedPixel_AddressThePixel 8157 CALL Drawing_AddressThePixel Call Drawing_AddressThePixel to address the pixel.
815A BIT 2,C Jump to Drawing_PlotTheSelectedPixel_StepHigh if bit 2 of the direction is clear.
815C JR Z,Drawing_PlotTheSelectedPixel_StepHigh
815E CALL Drawing_RetreatTheHighCoordinate Call Drawing_RetreatTheHighCoordinate to retreat the high coordinate.
8161 JR Z,Drawing_PlotTheSelectedPixel_FinishTheFirstPass Jump to Drawing_PlotTheSelectedPixel_FinishTheFirstPass if Drawing_RetreatTheHighCoordinate wrapped the high coordinate.
8163 JR Drawing_PlotTheSelectedPixel_CountTheLength Jump to Drawing_PlotTheSelectedPixel_CountTheLength to count this pixel.
Drawing_PlotTheSelectedPixel_StepHigh 8165 CALL Drawing_AdvanceTheHighCoordinate Call Drawing_AdvanceTheHighCoordinate to advance the high coordinate.
8168 JR Z,Drawing_PlotTheSelectedPixel_FinishTheFirstPass Jump to Drawing_PlotTheSelectedPixel_FinishTheFirstPass if Drawing_AdvanceTheHighCoordinate wrapped the high coordinate.
Drawing_PlotTheSelectedPixel_CountTheLength 816A DEC B Drop one from the remaining length.
816B JR NZ,Drawing_PlotTheSelectedPixel_CountDownThePixels Jump to Drawing_PlotTheSelectedPixel_CountDownThePixels if it is not zero.
816D BIT 1,C Jump to Drawing_PlotTheSelectedPixel_StepLow if bit 1 of the direction is clear.
816F JR Z,Drawing_PlotTheSelectedPixel_StepLow
8171 CALL Drawing_RetreatTheLowCoordinate Call Drawing_RetreatTheLowCoordinate to retreat the low coordinate.
8174 JR Z,Drawing_PlotTheSelectedPixel_FinishTheFirstPass Jump to Drawing_PlotTheSelectedPixel_FinishTheFirstPass if Drawing_RetreatTheLowCoordinate wrapped the low coordinate.
8176 JR Drawing_PlotTheSelectedPixel_HoldThePixelCount Jump to Drawing_PlotTheSelectedPixel_HoldThePixelCount to bring the count back.
Drawing_PlotTheSelectedPixel_StepLow 8178 CALL Drawing_AdvanceTheLowCoordinate Call Drawing_AdvanceTheLowCoordinate to advance the low coordinate.
817B JR Z,Drawing_PlotTheSelectedPixel_FinishTheFirstPass Jump to Drawing_PlotTheSelectedPixel_FinishTheFirstPass if Drawing_AdvanceTheLowCoordinate wrapped the low coordinate.
Drawing_PlotTheSelectedPixel_HoldThePixelCount 817D POP BC Copy the count, leaving it on the stack.
817E PUSH BC
Drawing_PlotTheSelectedPixel_CountDownThePixels 817F DEC L Loop back to Drawing_PlotTheSelectedPixel_AddressThePixel until the pixel count reaches zero.
8180 JR NZ,Drawing_PlotTheSelectedPixel_AddressThePixel
Drawing_PlotTheSelectedPixel_FinishTheFirstPass 8182 POP BC Restore BC and HL from the stack.
8183 POP HL
8184 RET Return.
Drawing_PlotTheSelectedPixel_OtherDirection 8185 PUSH HL The other direction steps the low coordinate first.
8186 PUSH BC
Drawing_PlotTheSelectedPixel_StepTheLowCoordinate 8187 CALL Drawing_AddressThePixel
818A BIT 1,C Jump to Drawing_PlotTheSelectedPixel_StepLowOtherWay if bit 1 of the direction is clear.
818C JR Z,Drawing_PlotTheSelectedPixel_StepLowOtherWay
818E CALL Drawing_RetreatTheLowCoordinate Call Drawing_RetreatTheLowCoordinate to retreat the low coordinate.
8191 JR Z,Drawing_PlotTheSelectedPixel_FinishTheOtherPass Jump to Drawing_PlotTheSelectedPixel_FinishTheOtherPass if Drawing_RetreatTheLowCoordinate wrapped the low coordinate.
8193 JR Drawing_PlotTheSelectedPixel_CountDownTheLength Jump to Drawing_PlotTheSelectedPixel_CountDownTheLength to skip that picture step.
Drawing_PlotTheSelectedPixel_StepLowOtherWay 8195 CALL Drawing_AdvanceTheLowCoordinate Call Drawing_AdvanceTheLowCoordinate to advance the low coordinate.
8198 JR Z,Drawing_PlotTheSelectedPixel_FinishTheOtherPass Jump to Drawing_PlotTheSelectedPixel_FinishTheOtherPass if Drawing_AdvanceTheLowCoordinate wrapped the low coordinate.
Drawing_PlotTheSelectedPixel_CountDownTheLength 819A DEC B Drop one from the remaining length, and jump to Drawing_PlotTheSelectedPixel_RepeatForEachPixel to skip the high-coordinate step unless it is zero.
819B JR NZ,Drawing_PlotTheSelectedPixel_RepeatForEachPixel
819D BIT 2,C Jump to Drawing_PlotTheSelectedPixel_StepHighOtherWay if bit 2 of the direction is clear.
819F JR Z,Drawing_PlotTheSelectedPixel_StepHighOtherWay
81A1 CALL Drawing_RetreatTheHighCoordinate Call Drawing_RetreatTheHighCoordinate to retreat the high coordinate.
81A4 JR Z,Drawing_PlotTheSelectedPixel_FinishTheOtherPass Jump to Drawing_PlotTheSelectedPixel_FinishTheOtherPass if Drawing_RetreatTheHighCoordinate wrapped the high coordinate.
81A6 JR Drawing_PlotTheSelectedPixel_RefreshThePixelCount Jump to Drawing_PlotTheSelectedPixel_RefreshThePixelCount to bring the count back.
Drawing_PlotTheSelectedPixel_StepHighOtherWay 81A8 CALL Drawing_AdvanceTheHighCoordinate Call Drawing_AdvanceTheHighCoordinate to advance the high coordinate.
81AB JR Z,Drawing_PlotTheSelectedPixel_FinishTheOtherPass Jump to Drawing_PlotTheSelectedPixel_FinishTheOtherPass if Drawing_AdvanceTheHighCoordinate wrapped the high coordinate.
Drawing_PlotTheSelectedPixel_RefreshThePixelCount 81AD POP BC Copy the count, leaving it on the stack.
81AE PUSH BC
Drawing_PlotTheSelectedPixel_RepeatForEachPixel 81AF DEC L Loop back to Drawing_PlotTheSelectedPixel_StepTheLowCoordinate until the pixel count reaches zero.
81B0 JR NZ,Drawing_PlotTheSelectedPixel_StepTheLowCoordinate
Drawing_PlotTheSelectedPixel_FinishTheOtherPass 81B2 POP BC Restore BC and HL from the stack.
81B3 POP HL
81B4 RET Return.
View the equivalent code in;
Prev: 8148 Up: Map Next: 81B5