Skip to content

Commit 4a0615c

Browse files
Brendan Robertclaude
andcommitted
perf: Apply decompression speedup from PR #42
Cherry-picked optimization improvements from Peter Ferrie's PR #42: - Move sec out of hot path (set once instead of repeatedly) - Replace jmp with bne (2 cycles vs 3) - Eliminate redundant branching in .src3A - Reorder instructions to avoid pipeline stalls This provides measurable speedup in the decompression loop which runs frequently during game loading. Original commit: b258ed4 by Peter Ferrie Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e2d6af7 commit 4a0615c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Platform/Apple/virtual/src/core/decomp.s

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ DEBUG = 0
3333
decomp !zone {
3434
jsr .chkdst
3535
ldy #0 ; In lit loop Y must be zero
36+
sec
3637
.fill1A jsr .getbt2
37-
jmp .fill1B
38+
bne .fill1B ; always taken
3839

3940
.incdst inc pDst+1
4041
.chkdst ldx pDst+1
@@ -174,19 +175,19 @@ decomp !zone {
174175
bne .gshift ; always taken
175176

176177
; Get another 8 bits into our bit buffer. Destroys X. Preserves A. Requires Y=0.
178+
; Carry is always set on entry, Z always clear on exit
177179
; Alternately, use .getbt2 to preserve X and destroy A
178180
.getbts tax
179181
.getbt2 lda (pSrc),y
180-
inc pSrc
181-
beq .src3A
182-
.src3B sec
183182
rol
184183
sta bits
185184
txa
185+
inc pSrc
186+
beq .src3A
186187
rts
187188

188189
.src3A inc pSrc+1
189-
bne .src3B ; always taken
190+
rts
190191

191192
} ; end of zone
192193

0 commit comments

Comments
 (0)