Check for the new *FX 163,242,0-66 commands - 160 bytes (0.9%)
- §1. Get either the GXR status or size of the current sprite
- §2. getGXRStatusOrSpriteSizeInternal
- §3. getCurrentSpriteSize
- §4. notHandled
- §5. Handle an OSBYTE (*FX) call that the OS doesn't know
- §6. setDotPatternAndRepeat
- §7. setDotPatternToA
§1. Get either the GXR status or size of the current sprite.
.getGXRStatusOrSpriteSize = $82a9 LDA .romWorkspaceBytes,X BNE .getGXRStatusOrSpriteSizeInternal if (GXR is active) then branch .resetXY = $82ae Set OSBYTE X and Y to zero (always called with A=0) STA .osbyteX STA .osbyteY Set X and Y to 0 TAX TAY RTS
§2. getGXRStatusOrSpriteSizeInternal.
.getGXRStatusOrSpriteSizeInternal = $82b5 JSR .getPrivateWorkspaceAddress LDA .osbyteY CMP #$41 BNE .getCurrentSpriteSize if (not *FX 163,242,66) then branch (get size of selected sprite) Get GXR status First get dot-dash pattern in bits 0-5 LDY #.workspaceOffsetDotDashRepeatLength LDA (.privateWorkspaceLow),Y AND #$3F dot-dash length MOD 64 STA .osbyteX temp store Add the current memory options in bits 6-7 LDY #.workspaceOffsetOptions } LDA (.privateWorkspaceLow),Y } AND #$80 } Set X to status: SEC } bit 7: 1 (GXR active) ROR } bit 6: flood enabled ORA .osbyteX } bits 0-5: dot-dash length MOD 64 TAX } Y = number of sprite pages INY Y=#.workspaceOffsetSpritePages LDA (.privateWorkspaceLow),Y get sprite pages TAY Y = sprite pages .exitStoringXY = $82d5 STX .osbyteX OSBYTE X = status STY .osbyteY OSBYTE Y = sprite pages LDA #0 RTS
.getCurrentSpriteSize = $82dc tempStoreDA/DB = sprite address LDY #.workspaceOffsetCurrentSpriteAddressLow } LDA (.privateWorkspaceLow),Y } STA .vduTempStoreDA } get address of current sprite into } tempStoreDA/DB INY } LDA (.privateWorkspaceLow),Y } STA .vduTempStoreDB } ORA .vduTempStoreDA } BEQ .resetXY } if (sprite address is zero) then } branch X,Y = sprite width, height LDY #.spriteHeaderOffsetWidth LDA (.vduTempStoreDA),Y TAX X = width of sprite - 1 INY LDA (.vduTempStoreDA),Y TAY Y = height of sprite - 1 INX X = width of sprite INY Y = height of sprite BNE .exitStoringXY ALWAYS branch
.notHandled = $82f8 LDA #7 unrecognised OSBYTE call reason code RTS pass on to next ROM
§5. Handle an OSBYTE (*FX) call that the OS doesn't know.
.handleOSBYTECall = $82fb Check for *FX 163 LDA .osbyteA CMP #163 BNE .notHandled if (not *FX 163) then branch Check for *FX 163,242 LDA .osbyteX CMP #242 BNE .notHandled if (not *FX 163,242) then branch Check for *FX 163,242,65 LDA .osbyteY CMP #65 BEQ .getGXRStatusOrSpriteSize if (*FX 163,242,65) then branch (get GXR status) Check for *FX 163,242,66 CMP #66 BEQ .getGXRStatusOrSpriteSize if (*FX 163,242,66) then branch (get size of selected sprite) BCS .notHandled if (.osbyteY > 66) then branch (not handled) Check GXR is active LDA .romWorkspaceBytes,X BEQ .notHandled if (GXR not active) then branch (not handled) Handle *FX 163,242,.osbyteY (where 0<=.osbyteY<=64) LDA .osbyteY JSR .setDotPatternAndRepeat LDX .osbyteX } LDY .osbyteY } Restore OSBYTE X and Y, LDA #0 } and return with A=0 to indicate RTS } 'handled'
.setDotPatternAndRepeat = $8324 JSR .getPrivateWorkspaceAddress BNE .setDotPatternToA Reset to default dot pattern (*FX 163,242,0) LDY #.workspaceOffsetDotDashPattern LDX #7 loop counter LDA #%10101010 value to store (default dot pattern) - STA (.privateWorkspaceLow),Y INY DEX BPL - Reset to default pattern length LDA #8 default dot-dash pattern length fall through...
.setDotPatternToA = $8337 LDY #.workspaceOffsetDotDashRepeatLength STA (.privateWorkspaceLow),Y workspace[DotDashRepeatLength] = dot-dash pattern length INY STA (.privateWorkspaceLow),Y workspace[DotDashBitsRemaining] = bits remaining of dot-dash pattern length INY LDA #$80 STA (.privateWorkspaceLow),Y workspace[DotDashBit] = one bit set. This is the mask to extract the next dot-dash pattern bit INY LDA #0 STA (.privateWorkspaceLow),Y workspace[DotDashPatternByte] = current dot-dash pattern byte RTS