Skip to content

Commit d5817c0

Browse files
committed
extras
1 parent 6ba95bb commit d5817c0

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/graphx/graphx.asm

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5174,7 +5174,7 @@ gfx_RotateScaleSprite:
51745174
; sinf = _SineTable[angle] * 128 / scale;
51755175
ld a, (ix + 12) ; angle
51765176
call calcSinCosSMC
5177-
push hl ; ld (ix - 3), _smc_dsrs_sinf_1_plus_offset_ix
5177+
push hl ; ld (ix - 3), _smc_dsrs_sinf_1_plus_offset_ix
51785178
; ld (_smc_dsrs_sinf_1_plus_offset_ix),hl ; write smc
51795179

51805180
; The previous code does ~HL instead of -HL. Unsure if intentional.
@@ -5210,12 +5210,12 @@ gfx_RotateScaleSprite:
52105210

52115211
; carry is cleared here
52125212
ld de, (ix - 6) ; dsrs_dys_0
5213-
sbc.s hl, de ; make sure UHL is zero
5214-
ld (iy + (_smc_dsrs_size128_1_minus_dys_0 - _smc_dsrs_base_address)), hl ; write smc
5213+
sbc hl, de
5214+
push hl ; ld (ix - 12), _smc_dsrs_size128_1_minus_dys_0
52155215
add hl, de ; restore HL
52165216
ld de, (ix - 9) ; dsrs_dyc_0
52175217
add hl, de
5218-
ld (iy + (_smc_dsrs_size128_0_plus_dyc_0 - _smc_dsrs_base_address)), hl ; write smc
5218+
push hl ; ld (ix - 15), _smc_dsrs_size128_0_plus_dyc_0
52195219
; carry might be set, but that shouldn't matter for rl c
52205220

52215221
ld a, b
@@ -5240,7 +5240,7 @@ gfx_RotateScaleSprite:
52405240
ld a, d
52415241
add a, l
52425242
ld d, a
5243-
ld hl, (ix - 3)
5243+
ld hl, (ix - 3) ; _smc_dsrs_sinf_1_plus_offset_ix
52445244
or a, a
52455245
sbc.s hl, de ; make sure UHL is zero
52465246
ld (iy + (_smc_dsrs_sinf_1_plus_offset_ix - _smc_dsrs_base_address)), hl
@@ -5268,29 +5268,34 @@ gfx_RotateScaleSprite:
52685268
ld iy, (ix + 9) ; sprite storing to
52695269
ld b, c
52705270
ld (iy + 0), bc
5271-
lea de, iy + 2
52725271

5272+
; by popping these off the stack in a werid way, we can reduce SMC useage
5273+
5274+
pop ix ; _smc_dsrs_size128_0_plus_dyc_0
5275+
pop de ; _smc_dsrs_size128_1_minus_dys_0
52735276
pop hl ; smc = dxc start
5274-
pop ix ; smc = dxs start
52755277

5276-
ex (sp), iy ; pop reg24 \ push iy
5278+
; ys = (dxc - dys) + (size * 128)
5279+
add hl, de ; HL = (dxc - dys) + (size * 128)
52775280

5278-
ld iyh, c ; size * scale / 64
5281+
pop de ; smc = dxs start
52795282

5280-
ld bc, $000000 ; xs = (dxs + dyc) + (size * 128)
5281-
_smc_dsrs_size128_0_plus_dyc_0 := $-3
5282-
_smc_dsrs_base_address := _smc_dsrs_size128_0_plus_dyc_0
5283-
add ix, bc ; de = (dxs + dyc) + (size * 128)
5283+
; xs = (dxs + dyc) + (size * 128)
5284+
add ix, de ; IX = (dxs + dyc) + (size * 128)
52845285

5285-
ld bc, $000000 ; ys = (dxc - dys) + (size * 128)
5286-
_smc_dsrs_size128_1_minus_dys_0 := $-3
5287-
add hl, bc ; hl = (dxc - dys) + (size * 128)
5286+
lea de, iy + 2
5287+
5288+
ex (sp), iy ; pop reg24 \ push iy
5289+
5290+
ld iyh, c ; size * scale / 64
52885291

5292+
; UBC was set to zero from mlt bc awhile back
52895293
jr drawSpriteRotateScale_Begin
52905294
;-------------------------------------------------------------------------------
52915295
_yloop:
52925296
ld bc, $000000 ; smc = cosf
52935297
_smc_dsrs_cosf_1_plus_offset_hl := $-3
5298+
_smc_dsrs_base_address := _smc_dsrs_cosf_1_plus_offset_hl
52945299
add hl, bc ; dxc += cosf
52955300

52965301
ld bc, $000000 ; smc = sinf

0 commit comments

Comments
 (0)