Common code and data used while plotting - 298 bytes (1.8%)
- §1. Byte mask table
- §2. Default patterns
- §3. Pixel shape
- §4. Fill row
- §5. Set graphics colour masks and fill row
- §6. Check the given point is within the graphics window, and if so plot it
- §7. Prepare to read or write a pixel
- §8. Table of routines that handle PLOT commands
This table stores masks for setting the rightmost pixels of a byte in each MODE.
.plotByteMaskTable = $8a8a !byte %11111111 2 pixels per byte (MODE 2) !byte %01010101 !byte %11111111 4 pixels per byte (MODE 1 or 5) !byte %01110111 !byte %00110011 !byte %00010001 !byte %11111111 8 pixels per byte (MODE 0 or 4) !byte %01111111 !byte %00111111 !byte %00011111 !byte %00001111 !byte %00000111 !byte %00000011 !byte %00000001
Each MODE has four patterns, each pattern is eight bytes. These are the default patterns for each MODE.
.defaultPatterns = $8a98 MODE 4 patterns !byte %10101010 one dot in four !byte %00000000 !byte %10101010 !byte %00000000 !byte %10101010 !byte %00000000 !byte %10101010 !byte %00000000 !byte %10101010 checkerboard !byte %01010101 !byte %10101010 !byte %01010101 !byte %10101010 !byte %01010101 !byte %10101010 !byte %01010101 !byte %11111111 three dots in four !byte %01010101 !byte %11111111 !byte %01010101 !byte %11111111 !byte %01010101 !byte %11111111 !byte %01010101 !byte %00010001 diagonal stripes !byte %00100010 !byte %01000100 !byte %10001000 !byte %00010001 !byte %00100010 !byte %01000100 !byte %10001000 MODE 1 and 5 patterns !byte $A5,$0F,$A5,$0F,$A5,$0F,$A5,$0F one dot in four is colour 2, the rest are colour 1 !byte $A5,$5A,$A5,$5A,$A5,$5A,$A5,$5A checkerboard colour 1 and 2 !byte $F0,$5A,$F0,$5A,$F0,$5A,$F0,$5A three dots in four are colour 2, the other is colour 1 !byte $F5,$FA,$F5,$FA,$F5,$FA,$F5,$FA checkerboard colour 2 and 3 MODE 2 patterns !byte $0B,$07,$0B,$07,$0B,$07,$0B,$07 checkerboard colour 1 and 2 !byte $23,$13,$23,$13,$23,$13,$23,$13 checkerboard colour 1 and 5 !byte $0E,$0D,$0E,$0D,$0E,$0D,$0E,$0D checkerboard colour 3 and 2 !byte $1F,$2F,$1F,$2F,$1F,$2F,$1F,$2F checkerboard colour 3 and 7 MODE 0 Patterns !byte $CC,$00,$CC,$00,$CC,$00,$CC,$00 one dot in four !byte $CC,$33,$CC,$33,$CC,$33,$CC,$33 checkerboard !byte $FF,$33,$FF,$33,$FF,$33,$FF,$33 three dots in four !byte $03,$0C,$30,$C0,$03,$0C,$30,$C0 diagonal stripes
Pixel shape is based on the current MODE, and defines the relative width and height of a pixel. Used when drawing a circle to make sure we increment appropriately for the screen resolution: MODE 0 has half width pixels, since there is twice as much X resolution than MODE 1 MODE 1 and 4 are regular square pixels MODE 2 and 5 are double width (wide pixels)
.pixelShapeForMODE = $8b18 MODE 0, 1, 2, 3, 4, 5, 6, 7 !byte $02,$00,$01,$FF,$00,$01,$FF,$FF indexed by screen MODE pixel shape compared to the square pixels of MODE 1: bit 0 set = double width bit 1 set = half width $FF = non-graphics mode [NOTE: bytes 6,7 could be removed]
Copies the left and right X coordinates and a Y coordinate, then set graphics colour masks and fills the row. On Entry: X = offset into VDU variables for one extreme graphics pixel X coordinate and Y coordinate Y = offset into VDU variables for the other extreme graphics pixel X coordinate
.copyCoordinatesSetMasksAndFillRow = $8b20 Copy two bytes at vdu[Y,Y+1] to .vduOldGraphicsCursorPixelsX LDA .vduVariablesStart + 0,Y STA .vduOldGraphicsCursorPixelsXLow LDA .vduVariablesStart + 1,Y STA .vduOldGraphicsCursorPixelsXHigh Copy two bytes at vdu[X+2,X+3] to .vduOldGraphicsCursorPixelsY LDA .vduVariablesStart + 2,X STA .vduOldGraphicsCursorPixelsYLow LDA .vduVariablesStart + 3,X STA .vduOldGraphicsCursorPixelsYHigh vdu[Y] is one extreme X coordinate LDY #.vduOldGraphicsCursorPixelsXLow - .vduVariablesStart fall through...
§5. Set graphics colour masks and fill row.
On Entry: X: offset into VDU variables for one extreme graphics pixel X coordinate Y: offset into VDU variables for the other extreme graphics pixel X coordinate
.setMasksAndFillRow = $8b3a STY .vduTempStoreDE remember Y LDA .vduVariablesStart + 2,X } get Y coordinate EOR #7 } AND #7 } Y = offset within cell TAY } JSR .gxrSetGraphicsColourMasks LDY .vduTempStoreDE recall Y JMP .fillRow calls OS routine to fill the row
§6. Check the given point is within the graphics window, and if so plot it.
On Entry: X: offset into VDU variables for a point
.plotPointXInternal = $8b4c JSR .gxrCheckInBoundsThenSetScreenAddressAndSetGraphicsColourMask BNE .return3 if (out of bounds) then return JMP .plotPointWithinBoundsAtY plot point .return3 = $8b54 RTS
§7. Prepare to read or write a pixel.
Check the point is in the graphics window, if so get the screen address and set the colour masks. On Entry: X: offset into VDU variables for a point On Exit: Z set if inside graphics window Z clear otherwise
.gxrCheckInBoundsThenSetScreenAddressAndSetGraphicsColourMask = $8b55 JSR .checkPointXIsWithinGraphicsWindow BNE .return3 failure, return with Z flag clear .gxrSetScreenAddressAndSetGraphicsColourMask = $8b5a JSR .setScreenAddress .gxrSetGraphicsColourMasks = $8b5d LDA .fillPattern,Y fill pattern byte (Y is the vertical offset 0-7 within cell) PHA ORA .gcolModeMask0 EOR .gcolModeMask1 STA .vduGraphicsColourByteOR PLA ORA .gcolModeMask2 EOR .gcolModeMask3 STA .vduGraphicsColourByteEOR LDA #0 success, return with Z flag set RTS
§8. Table of routines that handle PLOT commands.
.plotTypeRoutineTable = $8b71 !word .plotLine 0 | Line: Both ends, no pattern !word .plotLine 2 | Line: End omitted, no pattern !word .plotLine 4 | Line: Both ends, pattern restarts !word .plotLine 6 | Line: End omitted, pattern restarts !word .plotLine 8 | Line: Start omitted, no pattern !word .plotLine 10 | Line: Neither end, no pattern !word .plotLine 12 | Line: Start omitted, pattern continues !word .plotLine 14 | Line: Neither end, pattern continues !word .plotPoint 16 | Plot single point !word .plotHorizontalFillLRToNonBg 18 | Horizontal fill left and right to non-background colour !word .plotTriangleFilled 20 | Fill a triangle !word .plotHorizontalFillRToBg 22 | Horizontal fill right to background colour !word .plotRectangleFilled 24 | Rectangle fill !word .plotHorizontalFillLRToFg 26 | Horizontal fill left and right to foreground colour !word .plotParallelogramFilled 28 | Parallelogram fill !word .plotHorizontalFillRToNonFg 30 | Horizontal fill right to non-foreground colour !word .floodFillToNonBg 32 | Flood fill to non-background colour !word .floodFillToFg 34 | Flood fill to foreground colour !word .plotCircleOutline 36 | Circle outline !word .plotCircleFilled 38 | Circle fill !word .plotCircleArc 40 | Circle arc !word .plotCircleSegment 42 | Circle segment !word .plotCircleSector 44 | Circle sector !word .blockCopyOrMoveScreenRectangle 46 | On screen rectangle copy or move !word .plotEllipseOutline 48 | Ellipse outline !word .plotEllipseFilled 50 | Ellipse fill !word .unknownPlot 52 | [unused] !word .unknownPlot 54 | [unused] !word .unknownPlot 56 | [unused] !word .plotSprite 58 | Sprite !word .unknownPlot 60 | [unused] !word .unknownPlot 62 | [unused]