Skip to content

Commit

Permalink
#368 GBA more conditional muls, matrixSetIdentity_asm optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Dec 4, 2022
1 parent 5c13524 commit 17d13c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/platform/gba/asm/common_asm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@
ldrsh vx2, [vp2, #VERTEX_X]
ldrsh vy1, [vp1, #VERTEX_Y]
rsb vx2, vx2, vx0, asr #16 // reverse order for mla
sub vy1, vy1, vy0, asr #16
mul vy1, vx2, vy1
subs vy1, vy1, vy0, asr #16
mulne vy1, vx2, vy1
ldrsh vx1, [vp1, #VERTEX_X]
sub vx0, vx1, vx0, asr #16
ldrsh vy2, [vp2, #VERTEX_Y]
sub vy0, vy2, vy0, asr #16
mlas vy1, vx0, vy0, vy1
subs vy0, vy2, vy0, asr #16
mulne vy0, vx0, vy0
adds vy1, vy0
ble \skip
.endm

Expand Down
22 changes: 13 additions & 9 deletions src/platform/gba/asm/matrixSetIdentity.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@ e0 .req r0
e1 .req r1
e2 .req r2
e3 .req r3
e4 .req r12
m .req lr
// FIQ regs
e4 .req r8
e5 .req r9
e6 .req r10
m .req r11

.global matrixSetIdentity_asm
matrixSetIdentity_asm:
stmfd sp!, {lr}
fiq_on
ldr m, =gMatrixPtr
ldr m, [m]
mov e0, #0x4000
mov e1, #0
mov e2, #0
mov e3, #0
mov e4, #0
mov e5, #0x4000
mov e6, #0

// row-major
// e0 e1 e2 e3
// e4 e0 e1 e2
// e3 e4 e0 e1
// e4 e5 e6 e2
// e3 e4 e5 e6

stmia m!, {e0, e1, e2, e3, e4}
stmia m!, {e0, e1, e2, e3, e4}
stmia m!, {e0, e1}
stmia m!, {e0, e1, e2, e3, e4, e5, e6}
stmia m!, {e2, e3, e4, e5, e6}

ldmfd sp!, {lr}
fiq_off
bx lr
4 changes: 2 additions & 2 deletions src/platform/gba/asm/sndPCM.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ out .req size
.macro pcm_sample_fetch
ldrb out, [data, pos, lsr #SND_FIXED_SHIFT]
add pos, inc
sub out, #128
mul out, volume
subs out, #128
mulne out, volume
.endm

.macro pcm_sample_fill
Expand Down

0 comments on commit 17d13c4

Please sign in to comment.