.include "macros.inc"
.section .text, "ax"
.global GXInitLightAttn
GXInitLightAttn:
stfs f1, 0x10(r3)
stfs f2, 0x14(r3)
stfs f3, 0x18(r3)
stfs f4, 0x1c(r3)
stfs f5, 0x20(r3)
stfs f6, 0x24(r3)
blr
.global GXInitLightAttnA
GXInitLightAttnA:
stfs f1, 0x10(r3)
stfs f2, 0x14(r3)
stfs f3, 0x18(r3)
blr
.global GXInitLightAttnK
GXInitLightAttnK:
stfs f1, 0x1c(r3)
stfs f2, 0x20(r3)
stfs f3, 0x24(r3)
blr
.global GXInitLightDistAttn
GXInitLightDistAttn:
lfs f0, "@121"@sda21(r2)
fcmpo cr0, f1, f0
bge lbl_800A9990
li r4, 0
lbl_800A9990:
lfs f0, "@121"@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 0, 2
beq lbl_800A99B0
lfs f0, "@127"@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_800A99B4
lbl_800A99B0:
li r4, 0
lbl_800A99B4:
cmpwi r4, 2
beq lbl_800A99F4
bge lbl_800A99D0
cmpwi r4, 0
beq lbl_800A9A34
bge lbl_800A99DC
b lbl_800A9A34
lbl_800A99D0:
cmpwi r4, 4
bge lbl_800A9A34
b lbl_800A9A18
lbl_800A99DC:
lfs f5, "@127"@sda21(r2)
fmuls f0, f2, f1
lfs f4, "@121"@sda21(r2)
fsubs f1, f5, f2
fdivs f3, f1, f0
b lbl_800A9A40
lbl_800A99F4:
lfs f5, "@127"@sda21(r2)
fmuls f4, f2, f1
lfs f3, "@148"@sda21(r2)
fsubs f2, f5, f2
fmuls f0, f1, f4
fmuls f1, f3, f2
fdivs f3, f1, f4
fdivs f4, f1, f0
b lbl_800A9A40
lbl_800A9A18:
fmuls f0, f2, f1
lfs f5, "@127"@sda21(r2)
lfs f3, "@121"@sda21(r2)
fsubs f2, f5, f2
fmuls f0, f1, f0
fdivs f4, f2, f0
b lbl_800A9A40
lbl_800A9A34:
lfs f3, "@121"@sda21(r2)
lfs f5, "@127"@sda21(r2)
fmr f4, f3
lbl_800A9A40:
stfs f5, 0x1c(r3)
stfs f3, 0x20(r3)
stfs f4, 0x24(r3)
blr
.global GXInitLightPos
GXInitLightPos:
stfs f1, 0x28(r3)
stfs f2, 0x2c(r3)
stfs f3, 0x30(r3)
blr
.global GXInitSpecularDir
GXInitSpecularDir:
stwu r1, -0x20(r1)
fneg f0, f1
fneg f1, f2
lfs f5, "@127"@sda21(r2)
fmuls f6, f0, f0
lfs f4, "@121"@sda21(r2)
fsubs f2, f5, f3
fmuls f5, f1, f1
fmuls f7, f2, f2
fadds f5, f6, f5
fadds f8, f7, f5
fcmpo cr0, f8, f4
ble lbl_800A9AEC
frsqrte f5, f8
lfd f7, "@165"@sda21(r2)
lfd f6, "@166"@sda21(r2)
fmul f4, f5, f5
fmul f5, f7, f5
fmul f4, f8, f4
fsub f4, f6, f4
fmul f5, f5, f4
fmul f4, f5, f5
fmul f5, f7, f5
fmul f4, f8, f4
fsub f4, f6, f4
fmul f5, f5, f4
fmul f4, f5, f5
fmul f5, f7, f5
fmul f4, f8, f4
fsub f4, f6, f4
fmul f4, f5, f4
fmul f4, f8, f4
frsp f4, f4
stfs f4, 0x18(r1)
lfs f8, 0x18(r1)
lbl_800A9AEC:
lfs f4, "@127"@sda21(r2)
fneg f3, f3
fdivs f6, f4, f8
fmuls f5, f0, f6
fmuls f4, f1, f6
fmuls f2, f2, f6
stfs f5, 0x34(r3)
stfs f4, 0x38(r3)
stfs f2, 0x3c(r3)
lfs f4, "@167"@sda21(r2)
fmuls f2, f4, f0
fmuls f1, f4, f1
fmuls f0, f4, f3
stfs f2, 0x28(r3)
stfs f1, 0x2c(r3)
stfs f0, 0x30(r3)
addi r1, r1, 0x20
blr
.global GXInitLightColor
GXInitLightColor:
lbz r0, 1(r4)
lbz r5, 0(r4)
lbz r6, 2(r4)
slwi r0, r0, 0x10
rlwimi r0, r5, 0x18, 0, 7
lbz r4, 3(r4)
rlwimi r0, r6, 8, 0x10, 0x17
or r0, r4, r0
stw r0, 0xc(r3)
blr
.global GXGetLightColor
GXGetLightColor:
lwz r0, 0xc(r3)
srwi r0, r0, 0x18
stb r0, 0(r4)
lwz r0, 0xc(r3)
rlwinm r0, r0, 0x10, 0x18, 0x1f
stb r0, 1(r4)
lwz r0, 0xc(r3)
rlwinm r0, r0, 0x18, 0x18, 0x1f
stb r0, 2(r4)
lwz r0, 0xc(r3)
stb r0, 3(r4)
blr
.global GXLoadLightObjImm
GXLoadLightObjImm:
cmpwi r4, 0x10
beq lbl_800A9C0C
bge lbl_800A9BC8
cmpwi r4, 4
beq lbl_800A9BFC
bge lbl_800A9BBC
cmpwi r4, 2
beq lbl_800A9BF4
bge lbl_800A9C2C
cmpwi r4, 1
bge lbl_800A9BEC
b lbl_800A9C2C
lbl_800A9BBC:
cmpwi r4, 8
beq lbl_800A9C04
b lbl_800A9C2C
lbl_800A9BC8:
cmpwi r4, 0x40
beq lbl_800A9C1C
bge lbl_800A9BE0
cmpwi r4, 0x20
beq lbl_800A9C14
b lbl_800A9C2C
lbl_800A9BE0:
cmpwi r4, 0x80
beq lbl_800A9C24
b lbl_800A9C2C
lbl_800A9BEC:
li r0, 0
b lbl_800A9C30
lbl_800A9BF4:
li r0, 1
b lbl_800A9C30
lbl_800A9BFC:
li r0, 2
b lbl_800A9C30
lbl_800A9C04:
li r0, 3
b lbl_800A9C30
lbl_800A9C0C:
li r0, 4
b lbl_800A9C30
lbl_800A9C14:
li r0, 5
b lbl_800A9C30
lbl_800A9C1C:
li r0, 6
b lbl_800A9C30
lbl_800A9C24:
li r0, 7
b lbl_800A9C30
lbl_800A9C2C:
li r0, 0
lbl_800A9C30:
slwi r5, r0, 4
lwz r4, gx@sda21(r13)
addi r0, r5, 0x600
li r5, 0x10
lis r6, 0xCC008000@ha
stb r5, 0xCC008000@l(r6)
oris r0, r0, 0xf
li r5, 0
stw r0, -0x8000(r6)
li r0, 1
stw r5, -0x8000(r6)
stw r5, -0x8000(r6)
stw r5, -0x8000(r6)
lwz r5, 0xc(r3)
stw r5, -0x8000(r6)
lfs f0, 0x10(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x14(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x18(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x1c(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x20(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x24(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x28(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x2c(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x30(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x34(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x38(r3)
stfs f0, -0x8000(r6)
lfs f0, 0x3c(r3)
stfs f0, -0x8000(r6)
sth r0, 2(r4)
blr
.global GXSetChanAmbColor
GXSetChanAmbColor:
cmpwi r3, 3
beq lbl_800A9D88
bge lbl_800A9CF8
cmpwi r3, 1
beq lbl_800A9D3C
bge lbl_800A9D70
cmpwi r3, 0
bge lbl_800A9D08
blr
lbl_800A9CF8:
cmpwi r3, 5
beq lbl_800A9DD0
bgelr
b lbl_800A9DA0
lbl_800A9D08:
lwz r5, gx@sda21(r13)
li r3, 0
lbz r6, 2(r4)
lwz r7, 0xa8(r5)
lbz r5, 1(r4)
lbz r0, 0(r4)
clrlwi r7, r7, 0x18
rlwimi r7, r6, 8, 0x10, 0x17
slwi r4, r5, 0x10
rlwimi r4, r7, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9E04
lbl_800A9D3C:
lwz r5, gx@sda21(r13)
li r3, 1
lbz r6, 2(r4)
lwz r7, 0xac(r5)
lbz r5, 1(r4)
lbz r0, 0(r4)
clrlwi r7, r7, 0x18
rlwimi r7, r6, 8, 0x10, 0x17
slwi r4, r5, 0x10
rlwimi r4, r7, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9E04
lbl_800A9D70:
lwz r5, gx@sda21(r13)
li r3, 0
lbz r7, 3(r4)
lwz r0, 0xa8(r5)
rlwimi r7, r0, 0, 0, 0x17
b lbl_800A9E04
lbl_800A9D88:
lwz r5, gx@sda21(r13)
li r3, 1
lbz r7, 3(r4)
lwz r0, 0xac(r5)
rlwimi r7, r0, 0, 0, 0x17
b lbl_800A9E04
lbl_800A9DA0:
lbz r0, 2(r4)
li r3, 0
lbz r7, 3(r4)
slwi r6, r0, 8
lbz r5, 1(r4)
lbz r0, 0(r4)
rlwimi r6, r7, 0, 0x18, 0x1f
slwi r4, r5, 0x10
rlwimi r4, r6, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9E04
lbl_800A9DD0:
lbz r0, 2(r4)
li r3, 1
lbz r7, 3(r4)
slwi r6, r0, 8
lbz r5, 1(r4)
lbz r0, 0(r4)
rlwimi r6, r7, 0, 0x18, 0x1f
slwi r4, r5, 0x10
rlwimi r4, r6, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9E04
blr
lbl_800A9E04:
li r0, 0x10
lwz r4, gx@sda21(r13)
lis r6, 0xCC008000@ha
stb r0, 0xCC008000@l(r6)
addi r0, r3, 0x100a
li r5, 1
stw r0, -0x8000(r6)
slwi r0, r3, 2
stw r7, -0x8000(r6)
sth r5, 2(r4)
lwz r3, gx@sda21(r13)
add r3, r3, r0
stw r7, 0xa8(r3)
blr
.global GXSetChanMatColor
GXSetChanMatColor:
cmpwi r3, 3
beq lbl_800A9EF0
bge lbl_800A9E60
cmpwi r3, 1
beq lbl_800A9EA4
bge lbl_800A9ED8
cmpwi r3, 0
bge lbl_800A9E70
blr
lbl_800A9E60:
cmpwi r3, 5
beq lbl_800A9F38
bgelr
b lbl_800A9F08
lbl_800A9E70:
lwz r5, gx@sda21(r13)
li r3, 0
lbz r6, 2(r4)
lwz r7, 0xb0(r5)
lbz r5, 1(r4)
lbz r0, 0(r4)
clrlwi r7, r7, 0x18
rlwimi r7, r6, 8, 0x10, 0x17
slwi r4, r5, 0x10
rlwimi r4, r7, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9F6C
lbl_800A9EA4:
lwz r5, gx@sda21(r13)
li r3, 1
lbz r6, 2(r4)
lwz r7, 0xb4(r5)
lbz r5, 1(r4)
lbz r0, 0(r4)
clrlwi r7, r7, 0x18
rlwimi r7, r6, 8, 0x10, 0x17
slwi r4, r5, 0x10
rlwimi r4, r7, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9F6C
lbl_800A9ED8:
lwz r5, gx@sda21(r13)
li r3, 0
lbz r7, 3(r4)
lwz r0, 0xb0(r5)
rlwimi r7, r0, 0, 0, 0x17
b lbl_800A9F6C
lbl_800A9EF0:
lwz r5, gx@sda21(r13)
li r3, 1
lbz r7, 3(r4)
lwz r0, 0xb4(r5)
rlwimi r7, r0, 0, 0, 0x17
b lbl_800A9F6C
lbl_800A9F08:
lbz r0, 2(r4)
li r3, 0
lbz r7, 3(r4)
slwi r6, r0, 8
lbz r5, 1(r4)
lbz r0, 0(r4)
rlwimi r6, r7, 0, 0x18, 0x1f
slwi r4, r5, 0x10
rlwimi r4, r6, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9F6C
lbl_800A9F38:
lbz r0, 2(r4)
li r3, 1
lbz r7, 3(r4)
slwi r6, r0, 8
lbz r5, 1(r4)
lbz r0, 0(r4)
rlwimi r6, r7, 0, 0x18, 0x1f
slwi r4, r5, 0x10
rlwimi r4, r6, 0, 0x10, 0x1f
slwi r7, r0, 0x18
rlwimi r7, r4, 0, 8, 0x1f
b lbl_800A9F6C
blr
lbl_800A9F6C:
li r0, 0x10
lwz r4, gx@sda21(r13)
lis r6, 0xCC008000@ha
stb r0, 0xCC008000@l(r6)
addi r0, r3, 0x100c
li r5, 1
stw r0, -0x8000(r6)
slwi r0, r3, 2
stw r7, -0x8000(r6)
sth r5, 2(r4)
lwz r3, gx@sda21(r13)
add r3, r3, r0
stw r7, 0xb0(r3)
blr
.global GXSetNumChans
GXSetNumChans:
lwz r4, gx@sda21(r13)
clrlwi r7, r3, 0x18
rlwinm r0, r3, 4, 0x14, 0x1b
addi r6, r4, 0x204
lwz r5, 0x204(r4)
li r3, 0x10
lis r4, 0xCC008000@ha
rlwinm r5, r5, 0, 0x1c, 0x18
or r0, r5, r0
stw r0, 0(r6)
li r0, 0x1009
stb r3, 0xCC008000@l(r4)
lwz r3, gx@sda21(r13)
stw r0, -0x8000(r4)
stw r7, -0x8000(r4)
lwz r0, 0x4f4(r3)
ori r0, r0, 4
stw r0, 0x4f4(r3)
blr
.global GXSetChanCtrl
GXSetChanCtrl:
stwu r1, -0x38(r1)
cmpwi r3, 4
stw r31, 0x34(r1)
stw r30, 0x30(r1)
stw r29, 0x2c(r1)
stw r28, 0x28(r1)
bne lbl_800AA014
li r11, 0
b lbl_800AA028
lbl_800AA014:
cmpwi r3, 5
bne lbl_800AA024
li r11, 1
b lbl_800AA028
lbl_800AA024:
mr r11, r3
lbl_800AA028:
rlwinm r4, r4, 1, 0x17, 0x1e
or r10, r4, r6
clrlwi r0, r7, 0x1f
neg r6, r0
addic r4, r6, -1
rlwinm r0, r7, 0, 0x1e, 0x1e
neg r12, r0
subfe r6, r4, r6
addic r4, r12, -1
subfe r4, r4, r12
rlwinm r0, r7, 0, 0x1d, 0x1d
neg r28, r0
addic r0, r28, -1
rlwinm r12, r7, 0, 0x1c, 0x1c
subfe r0, r0, r28
neg r29, r12
addic r28, r29, -1
rlwinm r12, r7, 0, 0x1b, 0x1b
neg r30, r12
subfe r28, r28, r29
addic r29, r30, -1
rlwinm r12, r7, 0, 0x1a, 0x1a
neg r31, r12
subfe r29, r29, r30
addic r30, r31, -1
rlwinm r12, r7, 0, 0x19, 0x19
subfe r30, r30, r31
neg r31, r12
addic r12, r31, -1
rlwinm r10, r10, 0, 0x1a, 0x18
slwi r5, r5, 6
or r5, r10, r5
rlwinm r10, r5, 0, 0x1e, 0x1c
slwi r5, r6, 2
or r5, r10, r5
rlwinm r5, r5, 0, 0x1d, 0x1b
slwi r4, r4, 3
or r4, r5, r4
rlwinm r4, r4, 0, 0x1c, 0x1a
slwi r0, r0, 4
or r0, r4, r0
rlwinm r4, r0, 0, 0x1b, 0x19
slwi r0, r28, 5
or r0, r4, r0
rlwinm r4, r0, 0, 0x15, 0x13
slwi r0, r29, 0xb
or r0, r4, r0
rlwinm r4, r0, 0, 0x14, 0x12
slwi r0, r30, 0xc
or r0, r4, r0
rlwinm r7, r7, 0, 0x18, 0x18
subfe r31, r12, r31
neg r12, r7
addic r7, r12, -1
rlwinm r4, r0, 0, 0x13, 0x11
slwi r0, r31, 0xd
or r0, r4, r0
subfe r7, r7, r12
rlwinm r4, r0, 0, 0x12, 0x10
slwi r0, r7, 0xe
cmpwi r9, 0
or r6, r4, r0
bne lbl_800AA128
li r8, 0
lbl_800AA128:
subfic r5, r9, 2
lwz r4, gx@sda21(r13)
addic r0, r5, -1
subfe r10, r0, r5
neg r5, r9
addic r0, r5, -1
subfe r7, r0, r5
rlwinm r5, r6, 0, 0x19, 0x16
slwi r0, r8, 7
or r8, r5, r0
li r6, 0x10
lis r5, 0xCC008000@ha
stb r6, 0xCC008000@l(r5)
addi r0, r11, 0x100e
rlwinm r9, r8, 0, 0x17, 0x15
slwi r8, r10, 9
stw r0, -0x8000(r5)
or r0, r9, r8
rlwinm r8, r0, 0, 0x16, 0x14
slwi r0, r7, 0xa
or r7, r8, r0
stw r7, -0x8000(r5)
li r0, 1
cmpwi r3, 4
sth r0, 2(r4)
bne lbl_800AA1A4
stb r6, -0x8000(r5)
li r0, 0x1010
stw r0, -0x8000(r5)
stw r7, -0x8000(r5)
b lbl_800AA1BC
lbl_800AA1A4:
cmpwi r3, 5
bne lbl_800AA1BC
stb r6, -0x8000(r5)
li r0, 0x1011
stw r0, -0x8000(r5)
stw r7, -0x8000(r5)
lbl_800AA1BC:
lwz r31, 0x34(r1)
lwz r30, 0x30(r1)
lwz r29, 0x2c(r1)
lwz r28, 0x28(r1)
addi r1, r1, 0x38
blr
.section .sdata2, "a"
.balign 8
"@121":
.4byte 0
"@127":
.4byte 0x3F800000
"@148":
.4byte 0x3F000000
.4byte 0
"@165":
.4byte 0x3FE00000
.4byte 0
"@166":
.4byte 0x40080000
.4byte 0
"@167":
.4byte 0x49800000
.4byte 0