Re: Conversion of VIC-SSS-MMX to CBM prg Studio
Posted: Mon Mar 20, 2023 2:32 am
here is the picture . . .
The Commodore Vic 20 Forum
http://www.sleepingelephant.com/ipw-web/bulletin/bb/
http://www.sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?t=10597
Code: Select all
SSSXYPRINTS
PLA
STA VECTORFG
PLA
STA VECTORFG+1
LDY #$01
byte $B3, $F7 ; opcode LAX 5 (+1) cylces
;LDA (VECTORFG),Y ; 5 (+1) cycles
;PHA ; 3 cycles
INY
LDA (VECTORFG),Y
TAY
;PLA ; 4 cycles
;TAX ; 2 cycles
JSR SSSPLOT
LDY #3
JMP DOSSSPRINTS
Code: Select all
SSSUPDATE
LDX #0
STX sssIDX ;mod: sssnum in original
@do
CPX SPRITES
BCC @cc
RTS
@cc
; Mod draw sprites in Z_ORDER
LDA SSSZORDR,X
byte $8F, sssNUM ; opcode SAX
;STA sssNUM
;TAX
Code: Select all
;and #$7e
;lsr
byte $4B,$7E ; opcode ALR (ASR)
Unless absolutely necessary you should really avoid such "optimizations" with illegal opcodes. Some people are now using newer 65C02 as replacements for a defect 6502 and the new ones do not support illegal opcodes at all. Then for marginal speed increases you just cut your user-base unnecessarily. It is better to do optimizations with normal opcodes.MrSterlingBS wrote: ↑Tue Apr 11, 2023 11:44 am There are some "illegal"-opcodes describet in "no more secrets" and i found some interesting optimazion for the sprite stack.
The SSSXYPrintS can be done by the LAX opcode instead of LDA/LDX and saves 9 cycles. The check with the newest SpriteStack version runs normal.
With your code you actually change what is in the Accumulator at the end. Since with the PLA the result of the first LDA will be restored in the Accumulator, but just keep the value of the second LDA (VECTORFG),y in it. Using LAX would only save 2 cycles (the TAX).There are some other optimizations possible and i have added this in the code "VIC-SSS-MMX.asm". No huge speed increase, but ...Code: Select all
SSSXYPRINTS PLA STA VECTORFG PLA STA VECTORFG+1 LDY #$01 byte $B3, $F7 ; opcode LAX 5 (+1) cylces ;LDA (VECTORFG),Y ; 5 (+1) cycles ;PHA ; 3 cycles INY LDA (VECTORFG),Y TAY ;PLA ; 4 cycles ;TAX ; 2 cycles JSR SSSPLOT LDY #3 JMP DOSSSPRINTS
SAX does something different than you think obviously. It does NOT store the value to the X-register, but just applies an AND-operation to the Accumulator and X-register and stores that (ANDed) value.Code: Select all
SSSUPDATE LDX #0 STX sssIDX ;mod: sssnum in original @do CPX SPRITES BCC @cc RTS @cc ; Mod draw sprites in Z_ORDER LDA SSSZORDR,X byte $8F, sssNUM ; opcode SAX ;STA sssNUM ;TAX