.include "macros.inc"
.section .text, "ax"
.global GXProject
GXProject:
lfs f4, 0(r3)
lfs f0, 4(r3)
lfs f6, 0x10(r3)
fmuls f10, f4, f1
lfs f5, 0x14(r3)
fmuls f9, f0, f2
lfs f4, 0x20(r3)
lfs f0, 0x24(r3)
lfs f11, 8(r3)
fmuls f7, f6, f1
fmuls f6, f5, f2
lfs f8, 0x18(r3)
lfs f5, 0x28(r3)
fmuls f4, f4, f1
fmuls f2, f0, f2
fmuls f11, f11, f3
lfs f1, "@14"@sda21(r2)
fadds f9, f10, f9
lfs f0, 0(r4)
fmuls f8, f8, f3
fadds f6, f7, f6
lfs f10, 0xc(r3)
fadds f9, f11, f9
lfs f7, 0x1c(r3)
fadds f6, f8, f6
fmuls f3, f5, f3
lfs f5, 0x2c(r3)
fadds f2, f4, f2
fcmpu cr0, f1, f0
fadds f8, f10, f9
fadds f0, f3, f2
fadds f7, f7, f6
fadds f9, f5, f0
bne lbl_800AD4B0
fneg f0, f9
lfs f1, "@15"@sda21(r2)
lfs f6, 4(r4)
lfs f5, 8(r4)
fdivs f0, f1, f0
lfs f4, 0xc(r4)
lfs f3, 0x10(r4)
lfs f1, 0x14(r4)
lfs f2, 0x18(r4)
fmuls f1, f9, f1
fmuls f6, f8, f6
fmuls f5, f9, f5
fmuls f4, f7, f4
fmuls f3, f9, f3
fadds f6, f6, f5
fadds f7, f2, f1
fadds f3, f4, f3
b lbl_800AD4E4
lbl_800AD4B0:
lfs f2, 4(r4)
lfs f1, 0xc(r4)
lfs f0, 0x14(r4)
fmuls f5, f8, f2
lfs f6, 8(r4)
fmuls f3, f7, f1
lfs f4, 0x10(r4)
fmuls f1, f9, f0
lfs f2, 0x18(r4)
fadds f6, f6, f5
fadds f3, f4, f3
lfs f0, "@15"@sda21(r2)
fadds f7, f2, f1
lbl_800AD4E4:
lfs f4, 8(r5)
fneg f1, f3
lfs f5, "@16"@sda21(r2)
fmuls f2, f6, f4
lfs f3, 0(r5)
fmuls f4, f4, f5
fmuls f2, f2, f5
fmuls f2, f0, f2
fadds f2, f3, f2
fadds f2, f4, f2
stfs f2, 0(r6)
lfs f3, 0xc(r5)
lfs f2, 4(r5)
fmuls f1, f1, f3
fmuls f3, f3, f5
fmuls f1, f1, f5
fmuls f1, f0, f1
fadds f1, f2, f1
fadds f1, f3, f1
stfs f1, 0(r7)
lfs f2, 0x14(r5)
lfs f1, 0x10(r5)
fsubs f1, f2, f1
fmuls f1, f7, f1
fmuls f0, f0, f1
fadds f0, f2, f0
stfs f0, 0(r8)
blr
.global GXSetProjection
GXSetProjection:
lwz r5, gx@sda21(r13)
cmpwi r4, 1
stw r4, 0x420(r5)
lfs f0, 0(r3)
lwz r4, gx@sda21(r13)
stfs f0, 0x424(r4)
lfs f0, 0x14(r3)
lwz r4, gx@sda21(r13)
stfs f0, 0x42c(r4)
lfs f0, 0x28(r3)
lwz r4, gx@sda21(r13)
stfs f0, 0x434(r4)
lfs f0, 0x2c(r3)
lwz r4, gx@sda21(r13)
stfs f0, 0x438(r4)
bne lbl_800AD5B0
lfs f0, 0xc(r3)
lwz r4, gx@sda21(r13)
stfs f0, 0x428(r4)
lfs f0, 0x1c(r3)
lwz r3, gx@sda21(r13)
stfs f0, 0x430(r3)
b lbl_800AD5C8
lbl_800AD5B0:
lfs f0, 8(r3)
lwz r4, gx@sda21(r13)
stfs f0, 0x428(r4)
lfs f0, 0x18(r3)
lwz r3, gx@sda21(r13)
stfs f0, 0x430(r3)
lbl_800AD5C8:
li r0, 0x10
lwz r4, gx@sda21(r13)
lis r5, 0xCC008000@ha
lis r3, 0x00061020@ha
stb r0, 0xCC008000@l(r5)
addi r0, r3, 0x00061020@l
stw r0, -0x8000(r5)
li r0, 1
lfs f0, 0x424(r4)
stfs f0, -0x8000(r5)
lfs f0, 0x428(r4)
stfs f0, -0x8000(r5)
lfs f0, 0x42c(r4)
stfs f0, -0x8000(r5)
lfs f0, 0x430(r4)
stfs f0, -0x8000(r5)
lfs f0, 0x434(r4)
stfs f0, -0x8000(r5)
lfs f0, 0x438(r4)
stfs f0, -0x8000(r5)
lwz r3, 0x420(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXGetProjectionv
GXGetProjectionv:
stwu r1, -0x18(r1)
lis r0, 0x4330
lwz r4, gx@sda21(r13)
lfd f1, "@24"@sda21(r2)
lwz r4, 0x420(r4)
stw r4, 0x14(r1)
stw r0, 0x10(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f1
stfs f0, 0(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x424(r4)
stfs f0, 4(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x428(r4)
stfs f0, 8(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x42c(r4)
stfs f0, 0xc(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x430(r4)
stfs f0, 0x10(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x434(r4)
stfs f0, 0x14(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x438(r4)
stfs f0, 0x18(r3)
addi r1, r1, 0x18
blr
.global WriteMTXPS4x3
WriteMTXPS4x3:
psq_l f0, 0(r3), 0, qr0
psq_l f1, 8(r3), 0, qr0
psq_l f2, 16(r3), 0, qr0
psq_l f3, 24(r3), 0, qr0
psq_l f4, 32(r3), 0, qr0
psq_l f5, 40(r3), 0, qr0
psq_st f0, 0(r4), 0, qr0
psq_st f1, 0(r4), 0, qr0
psq_st f2, 0(r4), 0, qr0
psq_st f3, 0(r4), 0, qr0
psq_st f4, 0(r4), 0, qr0
psq_st f5, 0(r4), 0, qr0
blr
.global WriteMTXPS3x3from3x4
WriteMTXPS3x3from3x4:
psq_l f0, 0(r3), 0, qr0
lfs f1, 8(r3)
psq_l f2, 16(r3), 0, qr0
lfs f3, 0x18(r3)
psq_l f4, 32(r3), 0, qr0
lfs f5, 0x28(r3)
psq_st f0, 0(r4), 0, qr0
stfs f1, 0(r4)
psq_st f2, 0(r4), 0, qr0
stfs f3, 0(r4)
psq_st f4, 0(r4), 0, qr0
stfs f5, 0(r4)
blr
.global WriteMTXPS4x2
WriteMTXPS4x2:
psq_l f0, 0(r3), 0, qr0
psq_l f1, 8(r3), 0, qr0
psq_l f2, 16(r3), 0, qr0
psq_l f3, 24(r3), 0, qr0
psq_st f0, 0(r4), 0, qr0
psq_st f1, 0(r4), 0, qr0
psq_st f2, 0(r4), 0, qr0
psq_st f3, 0(r4), 0, qr0
blr
.global GXLoadPosMtxImm
GXLoadPosMtxImm:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
li r6, 0x10
lis r5, 0xCC008000@ha
slwi r0, r4, 2
stb r6, 0xCC008000@l(r5)
oris r0, r0, 0xb
stw r0, -0x8000(r5)
addi r4, r5, -32768
bl WriteMTXPS4x3
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global GXLoadPosMtxIndx
GXLoadPosMtxIndx:
slwi r0, r4, 2
rlwinm r0, r0, 0, 0x14, 0xf
ori r5, r0, 0xb000
clrlwi r4, r3, 0x10
li r0, 0x20
lis r3, 0xCC008000@ha
stb r0, 0xCC008000@l(r3)
clrlwi r5, r5, 0x10
slwi r0, r4, 0x10
or r0, r5, r0
stw r0, -0x8000(r3)
blr
.global GXLoadNrmMtxImm
GXLoadNrmMtxImm:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
mulli r4, r4, 3
addi r0, r4, 0x400
lis r5, 0xCC008000@ha
li r6, 0x10
stb r6, 0xCC008000@l(r5)
oris r0, r0, 8
addi r4, r5, -32768
stw r0, -0x8000(r5)
bl WriteMTXPS3x3from3x4
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global GXLoadNrmMtxIndx3x3
GXLoadNrmMtxIndx3x3:
mulli r4, r4, 3
addi r0, r4, 0x400
rlwinm r0, r0, 0, 0x14, 0xf
ori r5, r0, 0x8000
clrlwi r4, r3, 0x10
li r0, 0x28
lis r3, 0xCC008000@ha
stb r0, 0xCC008000@l(r3)
clrlwi r5, r5, 0x10
slwi r0, r4, 0x10
or r0, r5, r0
stw r0, -0x8000(r3)
blr
.global GXSetCurrentMtx
GXSetCurrentMtx:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lwz r4, gx@sda21(r13)
addi r4, r4, 0x80
lwz r0, 0(r4)
rlwinm r0, r0, 0, 0, 0x19
or r0, r0, r3
stw r0, 0(r4)
li r3, 0
bl __GXSetMatrixIndex
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global GXLoadTexMtxImm
GXLoadTexMtxImm:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
cmplwi r4, 0x40
blt lbl_800AD86C
addi r0, r4, -64
slwi r4, r0, 2
addi r7, r4, 0x500
b lbl_800AD870
lbl_800AD86C:
slwi r7, r4, 2
lbl_800AD870:
cmpwi r5, 1
bne lbl_800AD880
li r4, 8
b lbl_800AD884
lbl_800AD880:
li r4, 0xc
lbl_800AD884:
addi r0, r4, -1
slwi r0, r0, 0x10
li r6, 0x10
lis r4, 0xCC008000@ha
stb r6, 0xCC008000@l(r4)
or r0, r7, r0
cmpwi r5, 0
stw r0, -0x8000(r4)
bne lbl_800AD8B4
addi r4, r4, -32768
bl WriteMTXPS4x3
b lbl_800AD8BC
lbl_800AD8B4:
addi r4, r4, -32768
bl WriteMTXPS4x2
lbl_800AD8BC:
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global GXSetViewportJitter
GXSetViewportJitter:
mflr r0
stw r0, 4(r1)
stwu r1, -0x60(r1)
stfd f31, 0x58(r1)
stfd f30, 0x50(r1)
stfd f29, 0x48(r1)
stfd f28, 0x40(r1)
stfd f27, 0x38(r1)
stfd f26, 0x30(r1)
cmplwi r3, 0
bne lbl_800AD900
lfs f0, "@16"@sda21(r2)
fsubs f2, f2, f0
lbl_800AD900:
lfs f11, "@16"@sda21(r2)
fneg f10, f4
lfs f0, "@64"@sda21(r2)
lfs f9, "@63"@sda21(r2)
fmuls f31, f3, f11
lwz r3, gx@sda21(r13)
fmuls f7, f4, f11
stfs f1, 0x43c(r3)
fadds f8, f1, f31
fmuls f30, f0, f6
lwz r3, gx@sda21(r13)
fadds f1, f2, f7
stfs f2, 0x440(r3)
fmuls f0, f0, f5
fmuls f29, f10, f11
lwz r3, gx@sda21(r13)
fadds f27, f9, f8
stfs f3, 0x444(r3)
fadds f26, f9, f1
fsubs f28, f30, f0
lwz r3, gx@sda21(r13)
stfs f4, 0x448(r3)
lwz r3, gx@sda21(r13)
stfs f5, 0x44c(r3)
lwz r3, gx@sda21(r13)
stfs f6, 0x450(r3)
lwz r3, gx@sda21(r13)
lbz r0, 0x454(r3)
cmplwi r0, 0
beq lbl_800AD984
fmr f1, f5
lfs f2, 0x458(r3)
bl __GXSetRange
lbl_800AD984:
li r0, 0x10
lwz r3, gx@sda21(r13)
lis r5, 0xCC008000@ha
lis r4, 0x0005101A@ha
stb r0, 0xCC008000@l(r5)
addi r0, r4, 0x0005101A@l
stw r0, -0x8000(r5)
li r0, 1
stfs f31, -0x8000(r5)
stfs f29, -0x8000(r5)
stfs f28, -0x8000(r5)
stfs f27, -0x8000(r5)
stfs f26, -0x8000(r5)
stfs f30, -0x8000(r5)
sth r0, 2(r3)
lwz r0, 0x64(r1)
lfd f31, 0x58(r1)
lfd f30, 0x50(r1)
lfd f29, 0x48(r1)
lfd f28, 0x40(r1)
lfd f27, 0x38(r1)
lfd f26, 0x30(r1)
addi r1, r1, 0x60
mtlr r0
blr
.global GXSetViewport
GXSetViewport:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
li r3, 1
bl GXSetViewportJitter
lwz r0, 0xc(r1)
addi r1, r1, 8
mtlr r0
blr
.global GXGetViewportv
GXGetViewportv:
lwz r4, gx@sda21(r13)
lfs f0, 0x43c(r4)
stfs f0, 0(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x440(r4)
stfs f0, 4(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x444(r4)
stfs f0, 8(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x448(r4)
stfs f0, 0xc(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x44c(r4)
stfs f0, 0x10(r3)
lwz r4, gx@sda21(r13)
lfs f0, 0x450(r4)
stfs f0, 0x14(r3)
blr
.global GXSetScissor
GXSetScissor:
lwz r7, gx@sda21(r13)
addi r8, r3, 0x156
addi r0, r5, -1
addi r5, r7, 0xf8
lwz r3, 0(r5)
add r0, r8, r0
addi r4, r4, 0x156
rlwinm r3, r3, 0, 0, 0x14
or r3, r3, r4
stw r3, 0(r5)
addi r3, r6, -1
slwi r7, r8, 0xc
lwz r5, gx@sda21(r13)
add r4, r4, r3
slwi r3, r0, 0xc
addi r8, r5, 0xf8
lwz r0, 0(r8)
li r6, 0x61
lis r5, 0xCC008000@ha
rlwinm r0, r0, 0, 0x14, 8
or r0, r0, r7
stw r0, 0(r8)
li r0, 0
lwz r7, gx@sda21(r13)
addi r8, r7, 0xfc
lwz r7, 0(r8)
rlwinm r7, r7, 0, 0, 0x14
or r4, r7, r4
stw r4, 0(r8)
lwz r4, gx@sda21(r13)
addi r7, r4, 0xfc
lwz r4, 0(r7)
rlwinm r4, r4, 0, 0x14, 8
or r3, r4, r3
stw r3, 0(r7)
stb r6, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0xf8(r4)
stw r3, -0x8000(r5)
stb r6, -0x8000(r5)
lwz r3, 0xfc(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetScissorBoxOffset
GXSetScissorBoxOffset:
addi r5, r3, 0x156
lwz r3, gx@sda21(r13)
addi r0, r4, 0x156
srwi r4, r5, 1
srwi r0, r0, 1
rlwinm r4, r4, 0, 0x16, 0xb
slwi r0, r0, 0xa
or r0, r4, r0
clrlwi r5, r0, 8
li r0, 0x61
lis r4, 0xCC008000@ha
stb r0, 0xCC008000@l(r4)
oris r5, r5, 0x5900
li r0, 0
stw r5, -0x8000(r4)
sth r0, 2(r3)
blr
.global GXSetClipMode
GXSetClipMode:
li r0, 0x10
lwz r4, gx@sda21(r13)
lis r6, 0xCC008000@ha
stb r0, 0xCC008000@l(r6)
li r5, 0x1005
li r0, 1
stw r5, -0x8000(r6)
stw r3, -0x8000(r6)
sth r0, 2(r4)
blr
.global __GXSetMatrixIndex
__GXSetMatrixIndex:
cmpwi r3, 5
bge lbl_800ADBB4
li r0, 8
lwz r4, gx@sda21(r13)
lis r5, 0xCC008000@ha
stb r0, 0xCC008000@l(r5)
li r0, 0x30
li r3, 0x10
stb r0, -0x8000(r5)
li r0, 0x1018
lwz r4, 0x80(r4)
stw r4, -0x8000(r5)
stb r3, -0x8000(r5)
stw r0, -0x8000(r5)
stw r4, -0x8000(r5)
b lbl_800ADBE8
lbl_800ADBB4:
li r0, 8
lwz r4, gx@sda21(r13)
lis r5, 0xCC008000@ha
stb r0, 0xCC008000@l(r5)
li r0, 0x40
li r3, 0x10
stb r0, -0x8000(r5)
li r0, 0x1019
lwz r4, 0x84(r4)
stw r4, -0x8000(r5)
stb r3, -0x8000(r5)
stw r0, -0x8000(r5)
stw r4, -0x8000(r5)
lbl_800ADBE8:
lwz r3, gx@sda21(r13)
li r0, 1
sth r0, 2(r3)
blr
.section .sdata2, "a"
.balign 8
"@14":
.4byte 0
"@15":
.4byte 0x3F800000
"@16":
.4byte 0x3F000000
.4byte 0
"@24":
.4byte 0x43300000
.4byte 0
"@63":
.4byte 0x43AB0000
"@64":
.4byte 0x4B7FFFFF