Skip to content

Commit

Permalink
MGTK: Shave 15 bytes by optimizing InflateRect
Browse files Browse the repository at this point in the history
No functional changes.
  • Loading branch information
inexorabletash committed Oct 11, 2024
1 parent 635dcec commit 3fa6229
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions mgtk/mgtk.s
Original file line number Diff line number Diff line change
Expand Up @@ -10621,13 +10621,34 @@ ydelta .word
END_PARAM_BLOCK

ldy #0
sub16in (params::rect),y, params::xdelta, (params::rect),y

;; Subtract from x1 and y1; Y is 0...3
ldx #2
: sec
lda (params::rect),y
sbc params::xdelta,y
sta (params::rect),y
iny
sub16in (params::rect),y, params::ydelta, (params::rect),y
lda (params::rect),y
sbc params::xdelta,y
sta (params::rect),y
iny
add16in (params::rect),y, params::xdelta, (params::rect),y
dex
bne :-

;; Add to x1 and y1; Y is 4...7
ldx #2
: clc
lda (params::rect),y
adc params::xdelta - 4,y
sta (params::rect),y
iny
lda (params::rect),y
adc params::xdelta - 4,y
sta (params::rect),y
iny
add16in (params::rect),y, params::ydelta, (params::rect),y
dex
bne :-

rts
.endproc ; InflateRectImpl
Expand Down

0 comments on commit 3fa6229

Please sign in to comment.