.include "macros.inc"
.section .text, "ax"
.global GXSetFog
GXSetFog:
mflr r0
fcmpu cr0, f4, f3
stw r0, 4(r1)
stwu r1, -0x48(r1)
stw r31, 0x44(r1)
addi r31, r3, 0
stw r30, 0x40(r1)
stw r29, 0x3c(r1)
addi r29, r4, 0
beq lbl_800AC470
fcmpu cr0, f2, f1
bne lbl_800AC480
lbl_800AC470:
lfs f3, "@125"@sda21(r2)
lfs f4, "@126"@sda21(r2)
fmr f5, f3
b lbl_800AC49C
lbl_800AC480:
fsubs f0, f4, f3
fsubs f5, f2, f1
fmuls f2, f4, f3
fdivs f4, f4, f0
fmuls f0, f0, f5
fdivs f5, f1, f5
fdivs f3, f2, f0
lbl_800AC49C:
lfs f1, "@126"@sda21(r2)
li r3, 0
lfd f0, "@127"@sda21(r2)
b lbl_800AC4B4
lbl_800AC4AC:
fmuls f4, f4, f1
addi r3, r3, 1
lbl_800AC4B4:
fcmpo cr0, f4, f0
bgt lbl_800AC4AC
lfd f0, "@129"@sda21(r2)
lfs f2, "@128"@sda21(r2)
lfs f1, "@125"@sda21(r2)
b lbl_800AC4D4
lbl_800AC4CC:
fmuls f4, f4, f2
addi r3, r3, -1
lbl_800AC4D4:
fcmpo cr0, f4, f1
ble lbl_800AC4E4
fcmpo cr0, f4, f0
blt lbl_800AC4CC
lbl_800AC4E4:
addi r30, r3, 1
lfs f0, "@130"@sda21(r2)
li r0, 1
lfd f2, "@132"@sda21(r2)
slw r0, r0, r30
fmuls f1, f0, f4
xoris r3, r0, 0x8000
stfs f5, 0x28(r1)
lis r0, 0x4330
stw r3, 0x34(r1)
stw r0, 0x30(r1)
lfd f0, 0x30(r1)
fsubs f0, f0, f2
fdivs f0, f3, f0
stfs f0, 0x2c(r1)
bl __cvt_fp2unsigned
lwz r0, 0x2c(r1)
clrlwi r9, r3, 8
lbz r6, 1(r29)
clrlwi r8, r30, 8
rlwinm r4, r0, 0x14, 0xd, 0x14
rlwimi r4, r0, 0x14, 0x15, 0x1f
lbz r11, 2(r29)
rlwinm r0, r0, 0x14, 0xc, 0xc
lbz r5, 0(r29)
rlwimi r0, r4, 0, 0xd, 0x1f
lwz r12, 0x28(r1)
clrlwi r7, r0, 8
lwz r3, gx@sda21(r13)
oris r10, r7, 0xee00
li r0, 0x61
lis r4, 0xCC008000@ha
stb r0, 0xCC008000@l(r4)
oris r7, r9, 0xef00
slwi r6, r6, 8
stw r10, -0x8000(r4)
rlwinm r10, r12, 0x14, 0xd, 0x14
rlwimi r10, r12, 0x14, 0x15, 0x1f
stb r0, -0x8000(r4)
rlwinm r9, r12, 0x14, 0xc, 0xc
rlwimi r9, r10, 0, 0xd, 0x1f
stw r7, -0x8000(r4)
oris r7, r8, 0xf000
rlwimi r6, r11, 0, 0x18, 0x1f
stb r0, -0x8000(r4)
stw r7, -0x8000(r4)
slwi r7, r31, 0x15
rlwimi r7, r9, 0, 0xc, 0x1f
clrlwi r7, r7, 8
stb r0, -0x8000(r4)
oris r7, r7, 0xf100
stw r7, -0x8000(r4)
stb r0, -0x8000(r4)
slwi r0, r5, 0x10
rlwimi r0, r6, 0, 0x10, 0x1f
clrlwi r0, r0, 8
oris r0, r0, 0xf200
stw r0, -0x8000(r4)
li r0, 0
sth r0, 2(r3)
lwz r0, 0x4c(r1)
lwz r31, 0x44(r1)
lwz r30, 0x40(r1)
lwz r29, 0x3c(r1)
addi r1, r1, 0x48
mtlr r0
blr
.global GXSetFogRangeAdj
GXSetFogRangeAdj:
clrlwi. r0, r3, 0x18
beq lbl_800AC6B4
lhz r8, 2(r5)
li r0, 0x61
lhz r10, 0(r5)
lis r6, 0xCC008000@ha
slwi r8, r8, 0xc
rlwimi r8, r10, 0, 0x14, 0x1f
stb r0, 0xCC008000@l(r6)
li r7, 0xe9
clrlwi r9, r8, 8
rlwimi r9, r7, 0x18, 0, 7
stw r9, -0x8000(r6)
li r7, 0xea
slwi r9, r7, 0x18
lhzu r10, 4(r5)
li r7, 0xeb
lhz r8, 2(r5)
slwi r8, r8, 0xc
stb r0, -0x8000(r6)
rlwimi r8, r10, 0, 0x14, 0x1f
rlwimi r9, r8, 0, 8, 0x1f
stw r9, -0x8000(r6)
slwi r9, r7, 0x18
li r7, 0xec
lhz r8, 6(r5)
lhz r10, 4(r5)
slwi r8, r8, 0xc
rlwimi r8, r10, 0, 0x14, 0x1f
stb r0, -0x8000(r6)
rlwimi r9, r8, 0, 8, 0x1f
stw r9, -0x8000(r6)
slwi r9, r7, 0x18
li r7, 0xed
lhz r8, 0xa(r5)
lhz r10, 8(r5)
slwi r8, r8, 0xc
rlwimi r8, r10, 0, 0x14, 0x1f
stb r0, -0x8000(r6)
rlwimi r9, r8, 0, 8, 0x1f
stw r9, -0x8000(r6)
lhz r8, 0xe(r5)
lhz r10, 0xc(r5)
slwi r8, r8, 0xc
rlwimi r8, r10, 0, 0x14, 0x1f
stb r0, -0x8000(r6)
clrlwi r9, r8, 8
rlwimi r9, r7, 0x18, 0, 7
stw r9, -0x8000(r6)
lbl_800AC6B4:
clrlwi r5, r4, 0x10
lwz r4, gx@sda21(r13)
addi r0, r5, 0x156
rlwinm r5, r0, 0, 0x16, 0x14
rlwinm r0, r3, 0xa, 0xe, 0x15
or r0, r5, r0
clrlwi r5, r0, 8
li r0, 0x61
lis r3, 0xCC008000@ha
stb r0, 0xCC008000@l(r3)
oris r5, r5, 0xe800
li r0, 0
stw r5, -0x8000(r3)
sth r0, 2(r4)
blr
.global GXSetBlendMode
GXSetBlendMode:
cmpwi r3, 1
li r9, 1
beq lbl_800AC708
cmpwi r3, 3
beq lbl_800AC708
li r9, 0
lbl_800AC708:
lwz r8, gx@sda21(r13)
subfic r0, r3, 3
cntlzw r7, r0
addi r10, r8, 0x1d0
lwz r8, 0x1d0(r8)
subfic r0, r3, 2
rlwinm r3, r8, 0, 0, 0x1e
or r3, r3, r9
stw r3, 0(r10)
cntlzw r0, r0
rlwinm r3, r7, 6, 0, 0x14
lwz r9, gx@sda21(r13)
rlwinm r8, r0, 0x1c, 4, 0x1e
lwzu r0, 0x1d0(r9)
slwi r7, r6, 0xc
slwi r6, r4, 8
rlwinm r0, r0, 0, 0x15, 0x13
or r0, r0, r3
stw r0, 0(r9)
slwi r4, r5, 5
li r3, 0x61
lwz r9, gx@sda21(r13)
lis r5, 0xCC008000@ha
li r0, 0
addi r10, r9, 0x1d0
lwz r9, 0x1d0(r9)
rlwinm r9, r9, 0, 0x1f, 0x1d
or r8, r9, r8
stw r8, 0(r10)
lwz r8, gx@sda21(r13)
addi r9, r8, 0x1d0
lwz r8, 0x1d0(r8)
rlwinm r8, r8, 0, 0x14, 0xf
or r7, r8, r7
stw r7, 0(r9)
lwz r7, gx@sda21(r13)
addi r8, r7, 0x1d0
lwz r7, 0x1d0(r7)
rlwinm r7, r7, 0, 0x18, 0x14
or r6, r7, r6
stw r6, 0(r8)
lwz r6, gx@sda21(r13)
addi r7, r6, 0x1d0
lwz r6, 0x1d0(r6)
rlwinm r6, r6, 0, 0x1b, 0x17
or r4, r6, r4
stw r4, 0(r7)
lwz r4, gx@sda21(r13)
addi r6, r4, 0x1d0
lwz r4, 0x1d0(r4)
clrlwi r4, r4, 8
oris r4, r4, 0x4100
stw r4, 0(r6)
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1d0(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetColorUpdate
GXSetColorUpdate:
lwz r4, gx@sda21(r13)
rlwinm r0, r3, 3, 0x15, 0x1c
li r3, 0x61
addi r6, r4, 0x1d0
lwz r4, 0x1d0(r4)
lis r5, 0xCC008000@ha
rlwinm r4, r4, 0, 0x1d, 0x1b
or r0, r4, r0
stw r0, 0(r6)
li r0, 0
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1d0(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetAlphaUpdate
GXSetAlphaUpdate:
lwz r4, gx@sda21(r13)
rlwinm r0, r3, 4, 0x14, 0x1b
li r3, 0x61
addi r6, r4, 0x1d0
lwz r4, 0x1d0(r4)
lis r5, 0xCC008000@ha
rlwinm r4, r4, 0, 0x1c, 0x1a
or r0, r4, r0
stw r0, 0(r6)
li r0, 0
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1d0(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetZMode
GXSetZMode:
lwz r6, gx@sda21(r13)
clrlwi r0, r3, 0x18
lwz r3, 0x1d8(r6)
addi r7, r6, 0x1d8
slwi r6, r4, 1
rlwinm r3, r3, 0, 0, 0x1e
or r0, r3, r0
stw r0, 0(r7)
rlwinm r4, r5, 4, 0x14, 0x1b
li r3, 0x61
lwz r7, gx@sda21(r13)
lis r5, 0xCC008000@ha
li r0, 0
addi r8, r7, 0x1d8
lwz r7, 0x1d8(r7)
rlwinm r7, r7, 0, 0x1f, 0x1b
or r6, r7, r6
stw r6, 0(r8)
lwz r6, gx@sda21(r13)
addi r7, r6, 0x1d8
lwz r6, 0x1d8(r6)
rlwinm r6, r6, 0, 0x1c, 0x1a
or r4, r6, r4
stw r4, 0(r7)
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1d8(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetZCompLoc
GXSetZCompLoc:
lwz r4, gx@sda21(r13)
rlwinm r0, r3, 6, 0x12, 0x19
li r3, 0x61
addi r6, r4, 0x1dc
lwz r4, 0x1dc(r4)
lis r5, 0xCC008000@ha
rlwinm r4, r4, 0, 0x1a, 0x18
or r0, r4, r0
stw r0, 0(r6)
li r0, 0
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1dc(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetPixelFmt
GXSetPixelFmt:
lwz r7, gx@sda21(r13)
lis r5, p2f$194@ha
slwi r6, r3, 2
addi r8, r7, 0x1dc
addi r0, r5, p2f$194@l
lwz r7, 0x1dc(r7)
add r9, r0, r6
lwz r5, 0(r9)
rlwinm r6, r7, 0, 0, 0x1c
slwi r0, r4, 3
or r4, r6, r5
stw r4, 0(r8)
lwz r4, gx@sda21(r13)
addi r5, r4, 0x1dc
lwz r4, 0x1dc(r4)
rlwinm r4, r4, 0, 0x1d, 0x19
or r0, r4, r0
stw r0, 0(r5)
lwz r4, gx@sda21(r13)
lwz r5, 0x1dc(r4)
cmplw r7, r5
beq lbl_800AC9D4
li r0, 0x61
lis r4, 0xCC008000@ha
stb r0, 0xCC008000@l(r4)
cmpwi r3, 2
stw r5, -0x8000(r4)
bne lbl_800AC9A4
li r0, 1
b lbl_800AC9A8
lbl_800AC9A4:
li r0, 0
lbl_800AC9A8:
lwz r4, gx@sda21(r13)
rlwinm r0, r0, 9, 0xf, 0x16
addi r5, r4, 0x204
lwz r4, 0x204(r4)
rlwinm r4, r4, 0, 0x17, 0x15
or r0, r4, r0
stw r0, 0(r5)
lwz r4, gx@sda21(r13)
lwz r0, 0x4f4(r4)
ori r0, r0, 4
stw r0, 0x4f4(r4)
lbl_800AC9D4:
lwz r0, 0(r9)
cmplwi r0, 4
bne lbl_800ACA2C
lwz r4, gx@sda21(r13)
addi r3, r3, -4
li r0, 0x61
addi r5, r4, 0x1d4
lwz r4, 0x1d4(r4)
rlwinm r4, r4, 0, 0x17, 0x14
rlwimi r4, r3, 9, 0x15, 0x16
stw r4, 0(r5)
lis r4, 0xCC008000@ha
lwz r3, gx@sda21(r13)
addi r5, r3, 0x1d4
lwz r3, 0x1d4(r3)
clrlwi r3, r3, 8
oris r3, r3, 0x4200
stw r3, 0(r5)
stb r0, 0xCC008000@l(r4)
lwz r3, gx@sda21(r13)
lwz r0, 0x1d4(r3)
stw r0, -0x8000(r4)
lbl_800ACA2C:
lwz r3, gx@sda21(r13)
li r0, 0
sth r0, 2(r3)
blr
.global GXSetDither
GXSetDither:
lwz r4, gx@sda21(r13)
rlwinm r0, r3, 2, 0x16, 0x1d
li r3, 0x61
addi r6, r4, 0x1d0
lwz r4, 0x1d0(r4)
lis r5, 0xCC008000@ha
rlwinm r4, r4, 0, 0x1e, 0x1c
or r0, r4, r0
stw r0, 0(r6)
li r0, 0
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1d0(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetDstAlpha
GXSetDstAlpha:
lwz r5, gx@sda21(r13)
rlwinm r6, r3, 8, 0x10, 0x17
lwzu r0, 0x1d4(r5)
li r3, 0x61
rlwinm r0, r0, 0, 0, 0x17
rlwimi r0, r4, 0, 0x18, 0x1f
stw r0, 0(r5)
lis r5, 0xCC008000@ha
li r0, 0
lwz r4, gx@sda21(r13)
addi r7, r4, 0x1d4
lwz r4, 0x1d4(r4)
rlwinm r4, r4, 0, 0x18, 0x16
or r4, r4, r6
stw r4, 0(r7)
stb r3, 0xCC008000@l(r5)
lwz r4, gx@sda21(r13)
lwz r3, 0x1d4(r4)
stw r3, -0x8000(r5)
sth r0, 2(r4)
blr
.global GXSetFieldMask
GXSetFieldMask:
clrlwi r0, r4, 0x18
lwz r4, gx@sda21(r13)
rlwinm r5, r0, 0, 0x1f, 0x1d
rlwinm r0, r3, 1, 0x17, 0x1e
or r0, r5, r0
clrlwi r5, r0, 8
li r0, 0x61
lis r3, 0xCC008000@ha
stb r0, 0xCC008000@l(r3)
oris r5, r5, 0x4400
li r0, 0
stw r5, -0x8000(r3)
sth r0, 2(r4)
blr
.global GXSetFieldMode
GXSetFieldMode:
mflr r0
stw r0, 4(r1)
rlwinm r0, r4, 0x16, 2, 9
stwu r1, -0x20(r1)
stw r31, 0x1c(r1)
lis r31, 0xCC008000@ha
stw r30, 0x18(r1)
li r30, 0x61
stw r29, 0x14(r1)
mr r29, r3
lwz r5, gx@sda21(r13)
lwzu r4, 0x7c(r5)
rlwinm r4, r4, 0, 0xa, 8
or r0, r4, r0
stw r0, 0(r5)
stb r30, 0xCC008000@l(r31)
lwz r3, gx@sda21(r13)
lwz r0, 0x7c(r3)
stw r0, -0x8000(r31)
bl __GXFlushTextureState
clrlwi r0, r29, 0x18
stb r30, -0x8000(r31)
oris r0, r0, 0x6800
stw r0, -0x8000(r31)
bl __GXFlushTextureState
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
addi r1, r1, 0x20
mtlr r0
blr
.section .data, "wa"
p2f$194:
.4byte 0
.4byte 0x00000001
.4byte 0x00000002
.4byte 0x00000003
.4byte 0x00000004
.4byte 0x00000004
.4byte 0x00000004
.4byte 0x00000005
.section .sdata2, "a"
.balign 8
"@125":
.4byte 0
"@126":
.4byte 0x3F000000
"@127":
.4byte 0x3FF00000
.4byte 0
"@128":
.4byte 0x40000000
.4byte 0
"@129":
.4byte 0x3FE00000
.4byte 0
"@130":
.4byte 0x4B00001E
.4byte 0
"@132":
.4byte 0x43300000
.4byte 0x80000000