Start DolphinCGraphics, 10/11 functions matching

This commit is contained in:
Luke Street 2022-11-29 20:56:37 -05:00
parent c598ab7439
commit 609873426e
17 changed files with 802 additions and 66 deletions

View File

@ -297,7 +297,7 @@ __sinit_CTevCombiners_cpp:
/* 80309234 00306194 91 21 00 3C */ stw r9, 0x3c(r1)
/* 80309238 00306198 91 01 00 40 */ stw r8, 0x40(r1)
/* 8030923C 0030619C 90 01 00 44 */ stw r0, 0x44(r1)
/* 80309240 003061A0 48 00 00 15 */ bl sub_80309254
/* 80309240 003061A0 48 00 00 15 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 80309244 003061A4 80 01 00 74 */ lwz r0, 0x74(r1)
/* 80309248 003061A8 7C 08 03 A6 */ mtlr r0
/* 8030924C 003061AC 38 21 00 70 */ addi r1, r1, 0x70

View File

@ -130,10 +130,7 @@ mGraphicsInitialized__12CGraphicsSys:
.skip 0x8
.global sFPSTimer
sFPSTimer:
.skip 0x4
.global lbl_805A9374
lbl_805A9374:
.skip 0x4
.skip 0x8
.global sRenderState__9CGraphics
sRenderState__9CGraphics:
.skip 0x8
@ -257,23 +254,23 @@ lbl_805A940C:
.global lbl_805A9410
lbl_805A9410:
.skip 0x4
.global lbl_805A9414
lbl_805A9414:
.global "nextTexRgn$2336"
"nextTexRgn$2336":
.skip 0x4
.global lbl_805A9418
lbl_805A9418:
.global "init$2337"
"init$2337":
.skip 0x4
.global lbl_805A941C
lbl_805A941C:
.global "nextTexRgnCI$2339"
"nextTexRgnCI$2339":
.skip 0x4
.global lbl_805A9420
lbl_805A9420:
.global "init$2340"
"init$2340":
.skip 0x8
.section .text, "ax"
.global sub_80309254
sub_80309254:
.global __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
__ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp:
/* 80309254 003061B4 81 0D A7 98 */ lwz r8, lbl_805A9358@sda21(r13)
/* 80309258 003061B8 38 08 00 01 */ addi r0, r8, 1
/* 8030925C 003061BC 90 0D A7 98 */ stw r0, lbl_805A9358@sda21(r13)
@ -3349,7 +3346,7 @@ VideoPostCallback__9CGraphicsFUl:
/* 8030BD68 00308CC8 3B ED A7 B0 */ addi r31, r13, sFPSTimer@sda21
/* 8030BD6C 00308CCC 90 0D A8 10 */ stw r0, mFlippingState__9CGraphics@sda21(r13)
/* 8030BD70 00308CD0 48 07 96 39 */ bl OSGetTime
/* 8030BD74 00308CD4 80 0D A7 B4 */ lwz r0, lbl_805A9374@sda21(r13)
/* 8030BD74 00308CD4 80 0D A7 B4 */ lwz r0, sFPSTimer+4@sda21(r13)
/* 8030BD78 00308CD8 C0 0D A8 04 */ lfs f0, mFramesPerSecond__9CGraphics@sda21(r13)
/* 8030BD7C 00308CDC 7C 80 20 10 */ subfc r4, r0, r4
/* 8030BD80 00308CE0 80 0D A7 B0 */ lwz r0, sFPSTimer@sda21(r13)
@ -4756,26 +4753,26 @@ InitGraphicsVariables__9CGraphicsFv:
/* 8030D1B0 0030A110 38 21 00 30 */ addi r1, r1, 0x30
/* 8030D1B4 0030A114 4E 80 00 20 */ blr
.global TexRegionCallback__9CGraphicsFP9_GXTexObj11_GXTexMapID
TexRegionCallback__9CGraphicsFP9_GXTexObj11_GXTexMapID:
.global TexRegionCallback__9CGraphicsFPC9_GXTexObj11_GXTexMapID
TexRegionCallback__9CGraphicsFPC9_GXTexObj11_GXTexMapID:
/* 8030D1B8 0030A118 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8030D1BC 0030A11C 7C 08 02 A6 */ mflr r0
/* 8030D1C0 0030A120 90 01 00 14 */ stw r0, 0x14(r1)
/* 8030D1C4 0030A124 88 0D A8 58 */ lbz r0, lbl_805A9418@sda21(r13)
/* 8030D1C4 0030A124 88 0D A8 58 */ lbz r0, "init$2337"@sda21(r13)
/* 8030D1C8 0030A128 7C 00 07 75 */ extsb. r0, r0
/* 8030D1CC 0030A12C 40 82 00 14 */ bne lbl_8030D1E0
/* 8030D1D0 0030A130 38 A0 00 00 */ li r5, 0
/* 8030D1D4 0030A134 38 00 00 01 */ li r0, 1
/* 8030D1D8 0030A138 90 AD A8 54 */ stw r5, lbl_805A9414@sda21(r13)
/* 8030D1DC 0030A13C 98 0D A8 58 */ stb r0, lbl_805A9418@sda21(r13)
/* 8030D1D8 0030A138 90 AD A8 54 */ stw r5, "nextTexRgn$2336"@sda21(r13)
/* 8030D1DC 0030A13C 98 0D A8 58 */ stb r0, "init$2337"@sda21(r13)
lbl_8030D1E0:
/* 8030D1E0 0030A140 88 0D A8 60 */ lbz r0, lbl_805A9420@sda21(r13)
/* 8030D1E0 0030A140 88 0D A8 60 */ lbz r0, "init$2340"@sda21(r13)
/* 8030D1E4 0030A144 7C 00 07 75 */ extsb. r0, r0
/* 8030D1E8 0030A148 40 82 00 14 */ bne lbl_8030D1FC
/* 8030D1EC 0030A14C 38 A0 00 00 */ li r5, 0
/* 8030D1F0 0030A150 38 00 00 01 */ li r0, 1
/* 8030D1F4 0030A154 90 AD A8 5C */ stw r5, lbl_805A941C@sda21(r13)
/* 8030D1F8 0030A158 98 0D A8 60 */ stb r0, lbl_805A9420@sda21(r13)
/* 8030D1F4 0030A154 90 AD A8 5C */ stw r5, "nextTexRgnCI$2339"@sda21(r13)
/* 8030D1F8 0030A158 98 0D A8 60 */ stb r0, "init$2340"@sda21(r13)
lbl_8030D1FC:
/* 8030D1FC 0030A15C 2C 04 00 07 */ cmpwi r4, 7
/* 8030D200 0030A160 40 82 00 10 */ bne lbl_8030D210
@ -4790,27 +4787,27 @@ lbl_8030D210:
/* 8030D220 0030A180 41 82 00 40 */ beq lbl_8030D260
/* 8030D224 0030A184 2C 03 00 0A */ cmpwi r3, 0xa
/* 8030D228 0030A188 41 82 00 38 */ beq lbl_8030D260
/* 8030D22C 0030A18C 80 6D A8 54 */ lwz r3, lbl_805A9414@sda21(r13)
/* 8030D22C 0030A18C 80 6D A8 54 */ lwz r3, "nextTexRgn$2336"@sda21(r13)
/* 8030D230 0030A190 2C 03 00 00 */ cmpwi r3, 0
/* 8030D234 0030A194 40 82 00 0C */ bne lbl_8030D240
/* 8030D238 0030A198 38 03 00 01 */ addi r0, r3, 1
/* 8030D23C 0030A19C 90 0D A8 54 */ stw r0, lbl_805A9414@sda21(r13)
/* 8030D23C 0030A19C 90 0D A8 54 */ stw r0, "nextTexRgn$2336"@sda21(r13)
lbl_8030D240:
/* 8030D240 0030A1A0 80 AD A8 54 */ lwz r5, lbl_805A9414@sda21(r13)
/* 8030D240 0030A1A0 80 AD A8 54 */ lwz r5, "nextTexRgn$2336"@sda21(r13)
/* 8030D244 0030A1A4 3C 60 80 5A */ lis r3, mTexRegions__9CGraphics@ha
/* 8030D248 0030A1A8 38 03 64 40 */ addi r0, r3, mTexRegions__9CGraphics@l
/* 8030D24C 0030A1AC 38 85 00 01 */ addi r4, r5, 1
/* 8030D250 0030A1B0 54 A3 26 76 */ rlwinm r3, r5, 4, 0x19, 0x1b
/* 8030D254 0030A1B4 90 8D A8 54 */ stw r4, lbl_805A9414@sda21(r13)
/* 8030D254 0030A1B4 90 8D A8 54 */ stw r4, "nextTexRgn$2336"@sda21(r13)
/* 8030D258 0030A1B8 7C 60 1A 14 */ add r3, r0, r3
/* 8030D25C 0030A1BC 48 00 00 20 */ b lbl_8030D27C
lbl_8030D260:
/* 8030D260 0030A1C0 80 AD A8 5C */ lwz r5, lbl_805A941C@sda21(r13)
/* 8030D260 0030A1C0 80 AD A8 5C */ lwz r5, "nextTexRgnCI$2339"@sda21(r13)
/* 8030D264 0030A1C4 3C 60 80 5A */ lis r3, mTexRegionsCI__9CGraphics@ha
/* 8030D268 0030A1C8 38 03 64 C0 */ addi r0, r3, mTexRegionsCI__9CGraphics@l
/* 8030D26C 0030A1CC 38 85 00 01 */ addi r4, r5, 1
/* 8030D270 0030A1D0 54 A3 26 B6 */ rlwinm r3, r5, 4, 0x1a, 0x1b
/* 8030D274 0030A1D4 90 8D A8 5C */ stw r4, lbl_805A941C@sda21(r13)
/* 8030D274 0030A1D4 90 8D A8 5C */ stw r4, "nextTexRgnCI$2339"@sda21(r13)
/* 8030D278 0030A1D8 7C 60 1A 14 */ add r3, r0, r3
lbl_8030D27C:
/* 8030D27C 0030A1DC 80 01 00 14 */ lwz r0, 0x14(r1)
@ -4899,8 +4896,8 @@ lbl_8030D38C:
/* 8030D3B4 0030A314 3B FF 00 10 */ addi r31, r31, 0x10
/* 8030D3B8 0030A318 3B BD 00 02 */ addi r29, r29, 2
/* 8030D3BC 0030A31C 41 80 FF D0 */ blt lbl_8030D38C
/* 8030D3C0 0030A320 3C 60 80 31 */ lis r3, TexRegionCallback__9CGraphicsFP9_GXTexObj11_GXTexMapID@ha
/* 8030D3C4 0030A324 38 63 D1 B8 */ addi r3, r3, TexRegionCallback__9CGraphicsFP9_GXTexObj11_GXTexMapID@l
/* 8030D3C0 0030A320 3C 60 80 31 */ lis r3, TexRegionCallback__9CGraphicsFPC9_GXTexObj11_GXTexMapID@ha
/* 8030D3C4 0030A324 38 63 D1 B8 */ addi r3, r3, TexRegionCallback__9CGraphicsFPC9_GXTexObj11_GXTexMapID@l
/* 8030D3C8 0030A328 48 06 D4 C1 */ bl GXSetTexRegionCallback
/* 8030D3CC 0030A32C 3C A0 00 04 */ lis r5, 0x00046000@ha
/* 8030D3D0 0030A330 3C 80 80 48 */ lis r4, sSpareFrameBuffer@ha
@ -4929,7 +4926,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D420 0030A380 48 07 7F 89 */ bl OSGetTime
/* 8030D424 0030A384 38 00 00 00 */ li r0, 0
/* 8030D428 0030A388 38 A0 00 01 */ li r5, 1
/* 8030D42C 0030A38C 90 8D A7 B4 */ stw r4, lbl_805A9374@sda21(r13)
/* 8030D42C 0030A38C 90 8D A7 B4 */ stw r4, sFPSTimer+4@sda21(r13)
/* 8030D430 0030A390 38 80 00 07 */ li r4, 7
/* 8030D434 0030A394 90 6D A7 B0 */ stw r3, sFPSTimer@sda21(r13)
/* 8030D438 0030A398 38 61 01 28 */ addi r3, r1, 0x128
@ -4987,7 +4984,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D508 0030A468 91 21 02 7C */ stw r9, 0x27c(r1)
/* 8030D50C 0030A46C 91 01 02 80 */ stw r8, 0x280(r1)
/* 8030D510 0030A470 90 01 02 84 */ stw r0, 0x284(r1)
/* 8030D514 0030A474 4B FF BD 41 */ bl sub_80309254
/* 8030D514 0030A474 4B FF BD 41 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030D518 0030A478 38 00 00 00 */ li r0, 0
/* 8030D51C 0030A47C 38 A0 00 01 */ li r5, 1
/* 8030D520 0030A480 98 A1 03 C8 */ stb r5, 0x3c8(r1)
@ -5046,7 +5043,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D5F4 0030A554 91 21 02 5C */ stw r9, 0x25c(r1)
/* 8030D5F8 0030A558 91 01 02 60 */ stw r8, 0x260(r1)
/* 8030D5FC 0030A55C 90 01 02 64 */ stw r0, 0x264(r1)
/* 8030D600 0030A560 4B FF BC 55 */ bl sub_80309254
/* 8030D600 0030A560 4B FF BC 55 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030D604 0030A564 38 00 00 00 */ li r0, 0
/* 8030D608 0030A568 38 A0 00 01 */ li r5, 1
/* 8030D60C 0030A56C 98 A1 03 A0 */ stb r5, 0x3a0(r1)
@ -5105,7 +5102,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D6E0 0030A640 91 21 02 3C */ stw r9, 0x23c(r1)
/* 8030D6E4 0030A644 91 01 02 40 */ stw r8, 0x240(r1)
/* 8030D6E8 0030A648 90 01 02 44 */ stw r0, 0x244(r1)
/* 8030D6EC 0030A64C 4B FF BB 69 */ bl sub_80309254
/* 8030D6EC 0030A64C 4B FF BB 69 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030D6F0 0030A650 38 00 00 00 */ li r0, 0
/* 8030D6F4 0030A654 38 A0 00 01 */ li r5, 1
/* 8030D6F8 0030A658 98 A1 03 78 */ stb r5, 0x378(r1)
@ -5164,7 +5161,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D7CC 0030A72C 91 21 02 1C */ stw r9, 0x21c(r1)
/* 8030D7D0 0030A730 91 01 02 20 */ stw r8, 0x220(r1)
/* 8030D7D4 0030A734 90 01 02 24 */ stw r0, 0x224(r1)
/* 8030D7D8 0030A738 4B FF BA 7D */ bl sub_80309254
/* 8030D7D8 0030A738 4B FF BA 7D */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030D7DC 0030A73C 38 00 00 00 */ li r0, 0
/* 8030D7E0 0030A740 38 A0 00 01 */ li r5, 1
/* 8030D7E4 0030A744 98 A1 03 50 */ stb r5, 0x350(r1)
@ -5223,7 +5220,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D8B8 0030A818 91 21 01 FC */ stw r9, 0x1fc(r1)
/* 8030D8BC 0030A81C 91 01 02 00 */ stw r8, 0x200(r1)
/* 8030D8C0 0030A820 90 01 02 04 */ stw r0, 0x204(r1)
/* 8030D8C4 0030A824 4B FF B9 91 */ bl sub_80309254
/* 8030D8C4 0030A824 4B FF B9 91 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030D8C8 0030A828 38 00 00 00 */ li r0, 0
/* 8030D8CC 0030A82C 38 A0 00 01 */ li r5, 1
/* 8030D8D0 0030A830 98 A1 03 28 */ stb r5, 0x328(r1)
@ -5282,7 +5279,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030D9A4 0030A904 91 21 01 DC */ stw r9, 0x1dc(r1)
/* 8030D9A8 0030A908 91 01 01 E0 */ stw r8, 0x1e0(r1)
/* 8030D9AC 0030A90C 90 01 01 E4 */ stw r0, 0x1e4(r1)
/* 8030D9B0 0030A910 4B FF B8 A5 */ bl sub_80309254
/* 8030D9B0 0030A910 4B FF B8 A5 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030D9B4 0030A914 38 00 00 00 */ li r0, 0
/* 8030D9B8 0030A918 38 A0 00 01 */ li r5, 1
/* 8030D9BC 0030A91C 98 A1 03 00 */ stb r5, 0x300(r1)
@ -5341,7 +5338,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030DA90 0030A9F0 91 21 01 BC */ stw r9, 0x1bc(r1)
/* 8030DA94 0030A9F4 91 01 01 C0 */ stw r8, 0x1c0(r1)
/* 8030DA98 0030A9F8 90 01 01 C4 */ stw r0, 0x1c4(r1)
/* 8030DA9C 0030A9FC 4B FF B7 B9 */ bl sub_80309254
/* 8030DA9C 0030A9FC 4B FF B7 B9 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030DAA0 0030AA00 38 00 00 00 */ li r0, 0
/* 8030DAA4 0030AA04 38 A0 00 01 */ li r5, 1
/* 8030DAA8 0030AA08 98 A1 02 D8 */ stb r5, 0x2d8(r1)
@ -5400,7 +5397,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030DB7C 0030AADC 91 21 01 9C */ stw r9, 0x19c(r1)
/* 8030DB80 0030AAE0 91 01 01 A0 */ stw r8, 0x1a0(r1)
/* 8030DB84 0030AAE4 90 01 01 A4 */ stw r0, 0x1a4(r1)
/* 8030DB88 0030AAE8 4B FF B6 CD */ bl sub_80309254
/* 8030DB88 0030AAE8 4B FF B6 CD */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030DB8C 0030AAEC 38 00 00 00 */ li r0, 0
/* 8030DB90 0030AAF0 38 A0 00 01 */ li r5, 1
/* 8030DB94 0030AAF4 98 A1 02 B0 */ stb r5, 0x2b0(r1)
@ -5459,7 +5456,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030DC68 0030ABC8 91 21 01 7C */ stw r9, 0x17c(r1)
/* 8030DC6C 0030ABCC 91 01 01 80 */ stw r8, 0x180(r1)
/* 8030DC70 0030ABD0 90 01 01 84 */ stw r0, 0x184(r1)
/* 8030DC74 0030ABD4 4B FF B5 E1 */ bl sub_80309254
/* 8030DC74 0030ABD4 4B FF B5 E1 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030DC78 0030ABD8 38 00 00 00 */ li r0, 0
/* 8030DC7C 0030ABDC 38 A0 00 01 */ li r5, 1
/* 8030DC80 0030ABE0 98 A1 02 88 */ stb r5, 0x288(r1)
@ -5518,7 +5515,7 @@ __sinit_DolphinCGraphics_cpp:
/* 8030DD54 0030ACB4 91 21 01 5C */ stw r9, 0x15c(r1)
/* 8030DD58 0030ACB8 91 01 01 60 */ stw r8, 0x160(r1)
/* 8030DD5C 0030ACBC 90 01 01 64 */ stw r0, 0x164(r1)
/* 8030DD60 0030ACC0 4B FF B4 F5 */ bl sub_80309254
/* 8030DD60 0030ACC0 4B FF B4 F5 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8030DD64 0030ACC4 38 6D A7 B8 */ addi r3, r13, sRenderState__9CGraphics@sda21
/* 8030DD68 0030ACC8 4B FF B6 81 */ bl __ct__Q29CGraphics12CRenderStateFv
/* 8030DD6C 0030ACCC 3C 60 80 5A */ lis r3, mLightParams@ha

View File

@ -1797,7 +1797,7 @@ lbl_80318CBC:
/* 80318E20 00315D80 91 21 00 7C */ stw r9, 0x7c(r1)
/* 80318E24 00315D84 91 01 00 80 */ stw r8, 0x80(r1)
/* 80318E28 00315D88 90 01 00 84 */ stw r0, 0x84(r1)
/* 80318E2C 00315D8C 4B FF 04 29 */ bl sub_80309254
/* 80318E2C 00315D8C 4B FF 04 29 */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 80318E30 00315D90 38 00 00 01 */ li r0, 1
/* 80318E34 00315D94 98 0D A8 C5 */ stb r0, lbl_805A9485@sda21(r13)
lbl_80318E38:
@ -3632,7 +3632,7 @@ lbl_8031A858:
/* 8031A9BC 0031791C 91 3F 01 10 */ stw r9, 0x110(r31)
/* 8031A9C0 00317920 91 1F 01 14 */ stw r8, 0x114(r31)
/* 8031A9C4 00317924 90 1F 01 18 */ stw r0, 0x118(r31)
/* 8031A9C8 00317928 4B FE E8 8D */ bl sub_80309254
/* 8031A9C8 00317928 4B FE E8 8D */ bl __ct__Q213CTevCombiners8CTevPassFRCQ213CTevCombiners9ColorPassRCQ213CTevCombiners9AlphaPassRCQ213CTevCombiners6CTevOpRCQ213CTevCombiners6CTevOp
/* 8031A9CC 0031792C 38 00 00 01 */ li r0, 1
/* 8031A9D0 00317930 98 0D A8 BB */ stb r0, lbl_805A947B@sda21(r13)
lbl_8031A9D4:

View File

@ -50,6 +50,10 @@ public:
return ((hiAddr & ~31) - ((loAddr + 31) & ~31));
}
void* GetFramebuf1() const { return x24_frameBuffer1; }
void* GetFramebuf2() const { return x28_frameBuffer2; }
const GXRenderModeObj& GetRenderModeObj() const { return x30_renderMode; }
static void SetProgressiveMode(bool progressive) { mProgressiveMode = progressive; }
static bool GetProgressiveMode() { return mProgressiveMode; }

View File

@ -3,11 +3,15 @@
#include "types.h"
#include "Kyoto/CTimeProvider.hpp"
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Graphics/CLight.hpp"
#include "Kyoto/Graphics/CTevCombiners.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
#include "Kyoto/Math/CVector3f.hpp"
#include "Kyoto/Graphics/CTevCombiners.hpp"
#include "dolphin/gx.h"
#include "dolphin/mtx.h"
enum ERglFogMode {
kRFM_None = GX_FOG_NONE,
@ -132,6 +136,17 @@ enum ERglCullMode {
kCM_All = GX_CULL_ALL,
};
enum ERglLight {
kLight0,
kLight1,
kLight2,
kLight3,
kLight4,
kLight5,
kLight6,
kLight7,
kLightMax,
};
struct CViewport {
int mLeft;
@ -142,10 +157,69 @@ struct CViewport {
float mHalfHeight;
};
class COsContext;
class CTimeProvider;
typedef struct {
float x;
float y;
} Vec2, *Vec2Ptr;
class CGraphics {
public:
class CRenderState {
public:
CRenderState();
void ResetFlushAll();
private:
int x0_;
int x4_;
};
class CProjectionState {
public:
CProjectionState(bool persp, float left, float right, float top, float bottom, float near,
float far)
: x0_persp(persp)
, x4_left(left)
, x8_right(right)
, xc_top(top)
, x10_bottom(bottom)
, x14_near(near)
, x18_far(far) {}
float GetNear() const { return x14_near; }
float GetFar() const { return x18_far; }
private:
bool x0_persp;
float x4_left;
float x8_right;
float xc_top;
float x10_bottom;
float x14_near;
float x18_far;
};
static bool Startup(const COsContext& osContext, uint fifoSize, void* fifoBase);
static GXTexRegion* TexRegionCallback(const GXTexObj* obj, GXTexMapID id);
static void InitGraphicsVariables();
static void Shutdown();
static void InitGraphicsDefaults();
static void ConfigureFrameBuffer(const COsContext& osContext);
static void EnableLight(ERglLight light);
static void LoadLight(ERglLight light, const CLight& info);
static void SetIdentityViewPointMatrix();
static void SetIdentityModelMatrix();
static void SetViewport(int left, int bottom, int width, int height);
static void SetPerspective(float fovy, float aspect, float znear, float zfar);
static void SetCopyClear(const CColor& color, float depth);
static void SetDepthRange(float near, float far);
static void FlushProjection();
static void SetDefaultVtxAttrFmt();
static bool IsBeginSceneClearFb();
static void SetIsBeginSceneClearFb(bool);
static void BeginScene();
@ -161,7 +235,7 @@ public:
static void StreamEnd();
static const CViewport& GetViewport() { return mViewport; }
static const CVector3f& GetViewpoint() { return mViewpoint; }
static const CVector3f& GetViewPoint() { return mViewPoint; }
static const CTransform4f& GetViewMatrix() { return mViewMatrix; }
static const CTransform4f& GetModelMatrix() { return mModelMatrix; }
static void SetViewPointMatrix(const CTransform4f&);
@ -195,14 +269,85 @@ public:
static CTevCombiners::CTevPass kEnvReplace;
static CTevCombiners::CTevPass kEnvModulateAlpha;
static CTevCombiners::CTevPass kEnvModulateColor;
static CTevCombiners::CTevPass kEnvModulateColorByalpha;
static CTevCombiners::CTevPass kEnvModulateColorByAlpha;
private:
static CRenderState sRenderState;
static VecPtr vtxBuffer;
static VecPtr nrmBuffer;
static Vec2Ptr txtBuffer0;
static Vec2Ptr txtBuffer1;
static GXColor* clrBuffer;
static bool mJustReset;
static ERglCullMode mCullMode;
static int mNumLightsActive;
static float mDepthNear;
static VecPtr mpVtxBuffer;
static VecPtr mpNrmBuffer;
static Vec2Ptr mpTxtBuffer0;
static Vec2Ptr mpTxtBuffer1;
static GXColor* mpClrBuffer;
static int mNumPrimitives;
static int mFrameCounter;
static float mFramesPerSecond;
static float mLastFramesPerSecond;
static int mNumBreakpointsWaiting;
static int mFlippingState;
static bool mLastFrameUsedAbove;
static bool mInterruptLastFrameUsedAbove;
static uchar mLightActive;
static uchar mLightsWereOn;
static void* mpFrameBuf1;
static void* mpFrameBuf2;
static void* mpCurrenFrameBuf;
static int mSpareBufferSize;
static void* mpSpareBuffer;
static int mSpareBufferTexCacheSize;
static GXTexRegionCallback mGXDefaultTexRegionCallback;
static void* mpFifo;
static GXFifoObj* mpFifoObj;
static int mRenderTimings;
static float mSecondsMod900;
static CTimeProvider* mpExternalTimeProvider;
// lbl_805A9408
// lbl_805A940C
// lbl_805A9410
// "nextTexRgn$2336"
// "init$2337"
// "nextTexRgnCI$2339"
// "init$2340"
static CVector3f kDefaultPositionVector;
static CVector3f kDefaultDirectionVector;
static CProjectionState mProj;
static CTransform4f mViewMatrix;
static CTransform4f mModelMatrix;
static CColor mClearColor;
static CVector3f mViewPoint;
static CViewport mViewport;
static CVector3f mViewpoint;
static ELightType mLightTypes[8];
static GXLightObj mLightObj[8];
static GXTexRegion mTexRegions[GX_MAX_TEXMAP];
static GXTexRegion mTexRegionsCI[GX_MAX_TEXMAP / 2];
static GXRenderModeObj mRenderModeObj;
static Mtx mGXViewPointMatrix;
static Mtx mGXModelMatrix;
static Mtx mGxModelView;
static Mtx mCameraMtx;
// .sdata
static bool mIsBeginSceneClearFb;
static ERglEnum mDepthFunc;
static ERglPrimitive mCurrentPrimitive;
static float mDepthFar;
static u32 mClearDepthValue; // = GX_MAX_Z24
static bool mIsGXModelMatrixIdentity;
static bool mFirstFrame;
static bool mUseVideoFilter;
static float mBrightness;
// static const float mBrightnessMin;
// static const float mBrightnessMax;
static Vec2 mBrightnessRange;
};
#endif // _CGRAPHICS

View File

@ -3,6 +3,9 @@
#include "types.h"
class COsContext;
class CMemorySys;
class CGraphicsSys {
public:
CGraphicsSys(const COsContext& osContext, const CMemorySys& memorySys, uint, void*);
@ -10,6 +13,8 @@ public:
private:
uint pad;
static bool mGraphicsInitialized;
};
#endif // _CGRAPHICSSYS

View File

@ -25,10 +25,19 @@ public:
kCS_Konst,
kCS_Zero,
};
struct ColorVar {
class ColorVar {
public:
ColorVar(EColorSrc src);
private:
EColorSrc x0_src;
};
struct ColorPass {
class ColorPass {
public:
ColorPass(const ColorVar& a, const ColorVar& b, const ColorVar& c, const ColorVar& d)
: x0_a(a), x4_b(b), x8_c(c), xc_d(d) {}
private:
ColorVar x0_a;
ColorVar x4_b;
ColorVar x8_c;
@ -42,14 +51,22 @@ public:
kAS_RegisterA2,
kAS_TextureAlpha,
kAS_RasterAlpha,
kAS_One,
kAS_Zero,
kAS_Konst,
kAS_Zero,
};
struct AlphaVar {
class AlphaVar {
public:
AlphaVar(EAlphaSrc src);
private:
EAlphaSrc x0_src;
};
struct AlphaPass {
class AlphaPass {
public:
AlphaPass(const AlphaVar& a, const AlphaVar& b, const AlphaVar& c, const AlphaVar& d)
: x0_a(a), x4_b(b), x8_c(c), xc_d(d) {}
private:
AlphaVar x0_a;
AlphaVar x4_b;
AlphaVar x8_c;
@ -77,7 +94,13 @@ public:
kTO_Register1,
kTO_Register2,
};
struct CTevOp {
class CTevOp {
public:
CTevOp(ETevOp op = kTO_Add, ETevBias bias = kTB_Zero, ETevScale scale = kTS_Scale1,
bool clamp = true, ETevOutput output = kTO_Previous)
: x0_clamp(clamp), x4_op(op), x8_bias(bias), xc_scale(scale), x10_output(output) {}
private:
bool x0_clamp;
ETevOp x4_op;
ETevBias x8_bias;
@ -87,12 +110,20 @@ public:
class CTevPass {
public:
CTevPass(const ColorPass& colorPass, const AlphaPass& alphaPass,
const CTevOp& colorOp = CTevOp(), const CTevOp& alphaOp = CTevOp());
private:
uint x0_id;
ColorPass x4_colorPass;
AlphaPass x14_alphaPass;
CTevOp x24_colorOp;
CTevOp x38_alphaOp;
};
static void Init();
static CTevPass kEnvPassthru;
};
extern CTevCombiners::CTevPass CTevPass_805a5ebc;

View File

@ -780,6 +780,20 @@ typedef enum _GXTlutFmt {
GX_MAX_TLUTFMT,
} GXTlutFmt;
typedef enum _GXMiscToken {
GX_MT_NULL = 0,
GX_MT_XF_FLUSH = 1,
GX_MT_DL_SAVE_CONTEXT = 2,
GX_MT_ABORT_WAIT_COPYOUT = 3,
} GXMiscToken;
typedef enum _GXTexCacheSize {
GX_TEXCACHE_32K,
GX_TEXCACHE_128K,
GX_TEXCACHE_512K,
GX_TEXCACHE_NONE
} GXTexCacheSize;
#ifdef __cplusplus
}
#endif

View File

@ -8,13 +8,13 @@
extern "C" {
#endif
GXBool GXGetTexObjMipMap(GXTexObj* tex_obj);
GXTexFmt GXGetTexObjFmt(GXTexObj* tex_obj);
u16 GXGetTexObjHeight(GXTexObj* tex_obj);
u16 GXGetTexObjWidth(GXTexObj* tex_obj);
GXTexWrapMode GXGetTexObjWrapS(GXTexObj* tex_obj);
GXTexWrapMode GXGetTexObjWrapT(GXTexObj* tex_obj);
void* GXGetTexObjData(GXTexObj* tex_obj);
GXBool GXGetTexObjMipMap(const GXTexObj* obj);
GXTexFmt GXGetTexObjFmt(const GXTexObj* obj);
u16 GXGetTexObjHeight(const GXTexObj* obj);
u16 GXGetTexObjWidth(const GXTexObj* obj);
GXTexWrapMode GXGetTexObjWrapS(const GXTexObj* obj);
GXTexWrapMode GXGetTexObjWrapT(const GXTexObj* obj);
void* GXGetTexObjData(const GXTexObj* obj);
void GXGetProjectionv(f32* p);
void GXGetLightPos(GXLightObj* lt_obj, f32* x, f32* y, f32* z);
void GXGetLightColor(GXLightObj* lt_obj, GXColor* color);

View File

@ -15,6 +15,7 @@ void GXDrawDone(void);
void GXSetDrawDone(void);
void GXFlush(void);
void GXPixModeSync(void);
void GXSetMisc(GXMiscToken token, u32 val);
#ifdef __cplusplus
}

View File

@ -93,6 +93,10 @@ typedef struct _GXColorS10 {
s16 a;
} GXColorS10;
typedef struct _GXTexRegion {
u32 dummy[4];
} GXTexRegion;
#ifdef __cplusplus
}
#endif

View File

@ -8,6 +8,8 @@
extern "C" {
#endif
typedef GXTexRegion* (*GXTexRegionCallback)(const GXTexObj* obj, GXTexMapID id);
void GXInitTexObj(GXTexObj* obj, const void* data, u16 width, u16 height, u32 format,
GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXBool mipmap);
void GXInitTexObjCI(GXTexObj* obj, const void* data, u16 width, u16 height, GXCITexFmt format,
@ -23,6 +25,9 @@ void GXInitTexObjWrapMode(GXTexObj* obj, GXTexWrapMode s, GXTexWrapMode t);
void GXInitTlutObj(GXTlutObj* obj, const void* data, GXTlutFmt format, u16 entries);
void GXLoadTlut(const GXTlutObj* obj, GXTlut idx);
void GXSetTexCoordScaleManually(GXTexCoordID coord, GXBool enable, u16 ss, u16 ts);
void GXInitTexCacheRegion(GXTexRegion* region, GXBool is_32b_mipmap, u32 tmem_even,
GXTexCacheSize size_even, u32 tmem_odd, GXTexCacheSize size_odd);
GXTexRegionCallback GXSetTexRegionCallback(GXTexRegionCallback callback);
#ifdef __cplusplus
}

View File

@ -3,7 +3,73 @@
#include <dolphin/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef f32 Mtx[3][4];
typedef f32 (*MtxPtr)[4];
typedef struct {
f32 x;
f32 y;
f32 z;
} Vec, *VecPtr;
void C_MTXIdentity(Mtx m);
void C_MTXCopy(const Mtx src, Mtx dst);
void C_MTXConcat(const Mtx a, const Mtx b, Mtx ab);
void C_MTXConcatArray(const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count);
void C_MTXTranspose(const Mtx src, Mtx xPose);
u32 C_MTXInverse(const Mtx src, Mtx inv);
u32 C_MTXInvXpose(const Mtx src, Mtx invX);
void C_MTXMultVec(const Mtx m, const Vec* src, Vec* dst);
void C_MTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count);
void C_MTXMultVecSR(const Mtx m, const Vec* src, Vec* dst);
void C_MTXMultVecArraySR(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count);
#ifdef __MWERKS__
void PSMTXIdentity(Mtx m);
void PSMTXCopy(const Mtx src, Mtx dst);
void PSMTXConcat(const Mtx a, const Mtx b, Mtx ab);
void PSMTXConcatArray(const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count);
void PSMTXTranspose(const Mtx src, Mtx xPose);
u32 PSMTXInverse(const Mtx src, Mtx inv);
u32 PSMTXInvXpose(const Mtx src, Mtx invX);
void PSMTXMultVec(const Mtx m, const Vec* src, Vec* dst);
void PSMTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count);
void PSMTXMultVecSR(const Mtx m, const Vec* src, Vec* dst);
void PSMTXMultVecArraySR(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count);
#endif
#ifdef __MWERKS__
#define MTXIdentity PSMTXIdentity
#define MTXCopy PSMTXCopy
#define MTXConcat PSMTXConcat
#define MTXConcatArray PSMTXConcatArray
#define MTXTranspose PSMTXTranspose
#define MTXInverse PSMTXInverse
#define MTXInvXpose PSMTXInvXpose
#define MTXMultVec PSMTXMultVec
#define MTXMultVecArray PSMTXMultVecArray
#define MTXMultVecSR PSMTXMultVecSR
#define MTXMultVecArraySR PSMTXMultVecArraySR
#else
#define MTXIdentity C_MTXIdentity
#define MTXCopy C_MTXCopy
#define MTXConcat C_MTXConcat
#define MTXConcatArray C_MTXConcatArray
#define MTXTranspose C_MTXTranspose
#define MTXInverse C_MTXInverse
#define MTXInvXpose C_MTXInvXpose
#define MTXMultVec C_MTXMultVec
#define MTXMultVecArray C_MTXMultVecArray
#define MTXMultVecSR C_MTXMultVecSR
#define MTXMultVecArraySR C_MTXMultVecArraySR
#endif
#ifdef __cplusplus
}
#endif
#endif // _DOLPHIN_MTX

View File

@ -19,6 +19,8 @@ typedef void* unkptr;
#define SBig(x) x
#define ARRAY_SIZE(arr) static_cast< int >(sizeof(arr) / sizeof(arr[0]))
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,464 @@
#include "Kyoto/Graphics/CGraphics.hpp"
#include "Kyoto/Basics/COsContext.hpp"
#include "Kyoto/Basics/CStopwatch.hpp"
#include "Kyoto/Graphics/CGX.hpp"
#include "Kyoto/Graphics/CGraphicsSys.hpp"
#include "dolphin/vi.h"
bool CGraphicsSys::mGraphicsInitialized;
static CStopwatch sFPSTimer;
static uchar sSpareFrameBuffer[640 * 448];
// clang-format off
CTevCombiners::CTevPass CGraphics::kEnvModulateConstColor(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_RasterColor,
CTevCombiners::kCS_RegisterC0,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_RasterAlpha,
CTevCombiners::kAS_RegisterA0,
CTevCombiners::kAS_Zero
)
);
CTevCombiners::CTevPass CGraphics::kEnvConstColor(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_RegisterC0
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_RegisterA0
)
);
CTevCombiners::CTevPass CGraphics::kEnvModulate(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_RasterColor,
CTevCombiners::kCS_TextureColor,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_RasterAlpha,
CTevCombiners::kAS_TextureAlpha,
CTevCombiners::kAS_Zero
)
);
CTevCombiners::CTevPass CGraphics::kEnvDecal(
CTevCombiners::ColorPass(
CTevCombiners::kCS_RasterColor,
CTevCombiners::kCS_TextureColor,
CTevCombiners::kCS_TextureAlpha,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_RasterAlpha
)
);
CTevCombiners::CTevPass CGraphics::kEnvBlend(
CTevCombiners::ColorPass(
CTevCombiners::kCS_RasterColor,
CTevCombiners::kCS_One,
CTevCombiners::kCS_TextureColor,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_TextureAlpha,
CTevCombiners::kAS_RasterAlpha,
CTevCombiners::kAS_Zero
)
);
CTevCombiners::CTevPass CGraphics::kEnvReplace(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_TextureColor
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_TextureAlpha
)
);
static CTevCombiners::CTevPass kEnvBlendCTandCConCF(
CTevCombiners::ColorPass(
CTevCombiners::kCS_RegisterC0,
CTevCombiners::kCS_TextureColor,
CTevCombiners::kCS_RasterColor,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_RasterAlpha
)
);
CTevCombiners::CTevPass CGraphics::kEnvModulateAlpha(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_RasterColor
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_TextureAlpha,
CTevCombiners::kAS_RasterAlpha,
CTevCombiners::kAS_Zero
)
);
CTevCombiners::CTevPass CGraphics::kEnvModulateColor(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_TextureColor,
CTevCombiners::kCS_RasterColor,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Konst,
CTevCombiners::kAS_RasterAlpha,
CTevCombiners::kAS_Zero
)
);
CTevCombiners::CTevPass CGraphics::kEnvModulateColorByAlpha(
CTevCombiners::ColorPass(
CTevCombiners::kCS_Zero,
CTevCombiners::kCS_PreviousColor,
CTevCombiners::kCS_PreviousAlpha,
CTevCombiners::kCS_Zero
),
CTevCombiners::AlphaPass(
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_Zero,
CTevCombiners::kAS_PreviousAlpha
)
);
// clang-format on
CGraphics::CRenderState CGraphics::sRenderState;
VecPtr CGraphics::vtxBuffer;
VecPtr CGraphics::nrmBuffer;
Vec2Ptr CGraphics::txtBuffer0;
Vec2Ptr CGraphics::txtBuffer1;
GXColor* CGraphics::clrBuffer;
bool CGraphics::mJustReset;
ERglCullMode CGraphics::mCullMode;
int CGraphics::mNumLightsActive;
float CGraphics::mDepthNear;
VecPtr CGraphics::mpVtxBuffer;
VecPtr CGraphics::mpNrmBuffer;
Vec2Ptr CGraphics::mpTxtBuffer0;
Vec2Ptr CGraphics::mpTxtBuffer1;
GXColor* CGraphics::mpClrBuffer;
struct CGXLightParams {
int x0_;
int x4_;
int x8_;
int xc_;
int x10_;
CGXLightParams() : x0_(4), x4_(0), x8_(0), xc_(2), x10_(2) {}
};
CGXLightParams mLightParams[8];
struct {
Vec vtx;
Vec nrm;
float uvU, uvV;
int unk0;
int unk1;
GXColor color;
short textureUsed;
uchar streamFlags;
} vtxDescr;
CVector3f CGraphics::kDefaultPositionVector(0.f, 0.f, 0.f);
CVector3f CGraphics::kDefaultDirectionVector(0.f, 0.f, 0.f);
CGraphics::CProjectionState CGraphics::mProj(true, -1.f, 1.f, 1.f, -1.f, 1.f, 100.f);
CTransform4f CGraphics::mViewMatrix = CTransform4f::Identity();
CTransform4f CGraphics::mModelMatrix = CTransform4f::Identity();
CColor CGraphics::mClearColor = CColor::Black();
CVector3f CGraphics::mViewPoint(0.f, 0.f, 0.f);
GXLightObj CGraphics::mLightObj[8];
GXTexRegion CGraphics::mTexRegions[GX_MAX_TEXMAP];
GXTexRegion CGraphics::mTexRegionsCI[GX_MAX_TEXMAP / 2];
GXRenderModeObj CGraphics::mRenderModeObj;
Mtx CGraphics::mGXViewPointMatrix;
Mtx CGraphics::mGXModelMatrix;
Mtx CGraphics::mGxModelView;
Mtx CGraphics::mCameraMtx;
int CGraphics::mNumPrimitives;
int CGraphics::mFrameCounter;
float CGraphics::mFramesPerSecond;
float CGraphics::mLastFramesPerSecond;
int CGraphics::mNumBreakpointsWaiting;
int CGraphics::mFlippingState;
bool CGraphics::mLastFrameUsedAbove;
bool CGraphics::mInterruptLastFrameUsedAbove;
uchar CGraphics::mLightActive;
uchar CGraphics::mLightsWereOn;
void* CGraphics::mpFrameBuf1;
void* CGraphics::mpFrameBuf2;
void* CGraphics::mpCurrenFrameBuf;
int CGraphics::mSpareBufferSize;
void* CGraphics::mpSpareBuffer;
int CGraphics::mSpareBufferTexCacheSize;
GXTexRegionCallback CGraphics::mGXDefaultTexRegionCallback;
void* CGraphics::mpFifo;
GXFifoObj* CGraphics::mpFifoObj;
int CGraphics::mRenderTimings;
float CGraphics::mSecondsMod900;
CTimeProvider* CGraphics::mpExternalTimeProvider;
int lbl_805A9408;
int lbl_805A940C;
int lbl_805A9410;
CViewport CGraphics::mViewport = {0, 0, 640, 448, 320.f, 240.f};
ELightType CGraphics::mLightTypes[8] = {
kLT_Directional, kLT_Directional, kLT_Directional, kLT_Directional,
kLT_Directional, kLT_Directional, kLT_Directional, kLT_Directional,
};
CTevCombiners::CTevPass& CGraphics::kEnvPassthru = CTevCombiners::kEnvPassthru;
bool CGraphics::mIsBeginSceneClearFb = true;
ERglEnum CGraphics::mDepthFunc = kE_LEqual;
ERglPrimitive CGraphics::mCurrentPrimitive = kP_Points;
float CGraphics::mDepthFar = 1.f;
u32 CGraphics::mClearDepthValue = GX_MAX_Z24;
bool CGraphics::mIsGXModelMatrixIdentity = true;
bool CGraphics::mFirstFrame = true;
bool CGraphics::mUseVideoFilter = true;
float CGraphics::mBrightness = 1.f;
Vec2 CGraphics::mBrightnessRange = {0.f, 2.f};
bool CGraphics::Startup(const COsContext& osContext, uint fifoSize, void* fifoBase) {
mpFifo = fifoBase;
mpFifoObj = GXInit(fifoBase, fifoSize);
GXFifoObj fifoObj;
GXInitFifoBase(&fifoObj, mpFifo, fifoSize);
GXSetCPUFifo(&fifoObj);
GXSetGPFifo(&fifoObj);
GXInitFifoLimits(mpFifoObj, fifoSize - 0x4000, fifoSize - 0x10000);
GXSetCPUFifo(mpFifoObj);
GXSetGPFifo(mpFifoObj);
GXSetMisc(GX_MT_XF_FLUSH, 8);
GXSetDither(GX_FALSE);
CGX::ResetGXStates();
InitGraphicsVariables();
ConfigureFrameBuffer(osContext);
for (int i = 0; i < ARRAY_SIZE(mTexRegions); i++) {
GXInitTexCacheRegion(&mTexRegions[i], false, 0x8000 * i, GX_TEXCACHE_32K,
0x80000 + (0x8000 * i), GX_TEXCACHE_32K);
}
for (int i = 0; i < ARRAY_SIZE(mTexRegionsCI); i++) {
GXInitTexCacheRegion(&mTexRegionsCI[i], false, (8 + (2 * i)) << 0xF, GX_TEXCACHE_32K,
(9 + (2 * i)) << 0xF, GX_TEXCACHE_32K);
}
mGXDefaultTexRegionCallback = GXSetTexRegionCallback(TexRegionCallback);
mSpareBufferSize = ARRAY_SIZE(sSpareFrameBuffer);
mpSpareBuffer = sSpareFrameBuffer;
mSpareBufferTexCacheSize = 0x10000;
return true;
}
GXTexRegion* CGraphics::TexRegionCallback(const GXTexObj* obj, GXTexMapID id) {
static int nextTexRgn = 0;
static int nextTexRgnCI = 0;
if (id == GX_TEXMAP7) {
return &mTexRegions[0];
} else {
GXTexFmt fmt = GXGetTexObjFmt(obj);
if (fmt != GX_TF_C4 && fmt != GX_TF_C8 && fmt != GX_TF_C14X2) {
if (nextTexRgn == 0) {
++nextTexRgn;
}
return &mTexRegions[nextTexRgn++ & 7];
} else {
return &mTexRegionsCI[nextTexRgnCI++ & 3];
}
}
}
void CGraphics::InitGraphicsVariables() {
for (int i = 0; i < ARRAY_SIZE(mLightTypes); ++i) {
mLightTypes[i] = kLT_Directional;
}
mLightActive = 0;
SetDepthWriteMode(false, mDepthFunc, false);
SetCullMode(kCM_None);
SetAmbientColor(CColor(0.2f, 0.2f, 0.2f, 1.f));
mIsGXModelMatrixIdentity = false;
SetIdentityViewPointMatrix();
SetIdentityModelMatrix();
SetViewport(0, 0, mViewport.mWidth, mViewport.mHeight);
SetPerspective(60.f,
static_cast< float >(mViewport.mWidth) / static_cast< float >(mViewport.mHeight),
mProj.GetNear(), mProj.GetFar());
SetCopyClear(mClearColor, 1.f);
const GXColor white = {0xFF, 0xFF, 0xFF, 0xFF};
CGX::SetChanMatColor(CGX::Channel0, white);
sRenderState.ResetFlushAll();
}
void CGraphics::Shutdown() { GXSetTexRegionCallback(mGXDefaultTexRegionCallback); }
void CGraphics::InitGraphicsDefaults() {
SetDepthRange(0.f, 1.f);
mIsGXModelMatrixIdentity = false;
SetModelMatrix(mModelMatrix);
SetViewPointMatrix(mViewMatrix);
SetDepthWriteMode(false, mDepthFunc, false);
SetCullMode(mCullMode);
SetViewport(mViewport.mLeft, mViewport.mTop, mViewport.mWidth, mViewport.mHeight);
FlushProjection();
CTevCombiners::Init();
DisableAllLights();
SetDefaultVtxAttrFmt();
}
void CGraphics::ConfigureFrameBuffer(const COsContext& osContext) {
mRenderModeObj = osContext.GetRenderModeObj();
mpFrameBuf1 = osContext.GetFramebuf1();
mpFrameBuf2 = osContext.GetFramebuf2();
VIConfigure(&mRenderModeObj);
VISetNextFrameBuffer(mpFrameBuf1);
mpCurrenFrameBuf = mpFrameBuf2;
GXSetViewport(0.f, 0.f, static_cast< float >(mRenderModeObj.fbWidth),
static_cast< float >(mRenderModeObj.efbHeight), 0.f, 1.f);
GXSetScissor(0, 0, mRenderModeObj.fbWidth, mRenderModeObj.efbHeight);
GXSetDispCopySrc(0, 0, mRenderModeObj.fbWidth, mRenderModeObj.efbHeight);
GXSetDispCopyDst(mRenderModeObj.fbWidth, mRenderModeObj.efbHeight);
GXSetDispCopyYScale(static_cast< float >(mRenderModeObj.xfbHeight) /
static_cast< float >(mRenderModeObj.efbHeight));
GXSetCopyFilter(mRenderModeObj.aa, mRenderModeObj.sample_pattern, GX_TRUE,
mRenderModeObj.vfilter);
if (mRenderModeObj.aa) {
GXSetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
} else {
GXSetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
}
GXSetDispCopyGamma(GX_GM_1_0);
GXCopyDisp(mpCurrenFrameBuf, true);
VIFlush();
VIWaitForRetrace();
VIWaitForRetrace();
mViewport.mWidth = mRenderModeObj.fbWidth;
mViewport.mHeight = mRenderModeObj.efbHeight;
InitGraphicsDefaults();
}
void CGraphics::EnableLight(ERglLight light) {
CGX::SetNumChans(1);
int lightsWereOn = mLightActive;
GXLightID lightId = static_cast< GXLightID >(1 << light);
if ((lightsWereOn & lightId) == GX_LIGHT_NULL) {
mLightActive |= lightId;
CGX::SetChanCtrl(CGX::Channel0, true, GX_SRC_REG, GX_SRC_REG,
static_cast< GXLightID >((lightsWereOn | lightId) & (GX_MAX_LIGHT - 1)),
GX_DF_CLAMP, GX_AF_SPOT);
++mNumLightsActive;
}
mLightsWereOn = mLightActive;
}
static inline GXLightID get_hw_light_index(ERglLight light) {
if (light == kLight0) {
return GX_LIGHT0;
} else if (light == kLight1) {
return GX_LIGHT1;
} else if (light == kLight2) {
return GX_LIGHT2;
} else if (light == kLight3) {
return GX_LIGHT3;
} else if (light == kLight4) {
return GX_LIGHT4;
} else if (light == kLight5) {
return GX_LIGHT5;
} else if (light == kLight6) {
return GX_LIGHT6;
}
// wtf?
return static_cast< GXLightID >(light == kLight7 ? GX_LIGHT7 : 0);
}
void CGraphics::LoadLight(ERglLight light, const CLight& info) {
GXLightID lightId = get_hw_light_index(light);
ELightType type = info.GetType();
CVector3f pos = info.GetPosition();
CVector3f dir = info.GetDirection();
switch (type) {
case kLT_Spot: {
MTXMultVec(mCameraMtx, reinterpret_cast< VecPtr >(&pos), reinterpret_cast< VecPtr >(&pos));
GXLightObj* obj = &mLightObj[light];
GXInitLightPos(obj, pos.GetX(), pos.GetY(), pos.GetZ());
MTXMultVecSR(mCameraMtx, reinterpret_cast< VecPtr >(&dir), reinterpret_cast< VecPtr >(&dir));
GXInitLightDir(obj, dir.GetX(), dir.GetY(), dir.GetZ());
GXInitLightAttn(obj, 1.f, 0.f, 0.f, info.GetAttenuationConstant(), info.GetAttenuationLinear(),
info.GetAttenuationQuadratic());
GXInitLightSpot(obj, info.GetSpotCutoff(), GX_SP_COS2);
break;
}
case kLT_Point:
case kLT_LocalAmbient: {
MTXMultVec(mCameraMtx, reinterpret_cast< VecPtr >(&pos), reinterpret_cast< VecPtr >(&pos));
GXInitLightPos(&mLightObj[light], pos.GetX(), pos.GetY(), pos.GetZ());
GXInitLightAttn(&mLightObj[light], 1.f, 0.f, 0.f, info.GetAttenuationConstant(),
info.GetAttenuationLinear(), info.GetAttenuationQuadratic());
break;
}
case kLT_Directional: {
MTXMultVecSR(mCameraMtx, reinterpret_cast< VecPtr >(&dir), reinterpret_cast< VecPtr >(&dir));
dir = -dir;
GXInitLightPos(&mLightObj[light], dir.GetX() * 1048576.f, dir.GetY() * 1048576.f,
dir.GetZ() * 1048576.f);
GXInitLightAttn(&mLightObj[light], 1.f, 0.f, 0.f, 1.f, 0.f, 0.f);
break;
}
case kLT_Custom: {
MTXMultVec(mCameraMtx, reinterpret_cast< VecPtr >(&pos), reinterpret_cast< VecPtr >(&pos));
GXLightObj* obj = &mLightObj[light];
GXInitLightPos(obj, pos.GetX(), pos.GetY(), pos.GetZ());
MTXMultVecSR(mCameraMtx, reinterpret_cast< VecPtr >(&dir), reinterpret_cast< VecPtr >(&dir));
GXInitLightDir(obj, dir.GetX(), dir.GetY(), dir.GetZ());
GXInitLightAttn(obj, info.GetAngleAttenuationConstant(), info.GetAngleAttenuationLinear(),
info.GetAngleAttenuationQuadratic(), info.GetAttenuationConstant(),
info.GetAttenuationLinear(), info.GetAttenuationQuadratic());
break;
}
default:
break;
}
GXInitLightColor(&mLightObj[light], info.GetColor().GetGXColor());
GXLoadLightObjImm(&mLightObj[light], lightId);
mLightTypes[light] = info.GetType();
}
void CGraphics::DisableAllLights() {
mNumLightsActive = 0;
mLightActive = 0;
CGX::SetChanCtrl(CGX::Channel0, false, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE,
GX_AF_NONE);
}

View File

@ -419,7 +419,7 @@ void CStateManager::DrawWorld() const {
}
}
rstl::sort(&areaArr[0], &areaArr[areaCount], area_sorter(CGraphics::GetViewpoint(), visAreaId));
rstl::sort(&areaArr[0], &areaArr[areaCount], area_sorter(CGraphics::GetViewPoint(), visAreaId));
}
void CStateManager::BuildDynamicLightListForWorld() {

View File

@ -120,8 +120,6 @@ void CPuffer::Think(float dt, CStateManager& mgr) {
}
}
#define ARRAY_SIZE(arr) static_cast< int >(sizeof(arr) / sizeof(arr[0]))
void CPuffer::sub8025bfa4(CStateManager& mgr) {
CVector3f moveVector = GetBodyCtrl()->GetCommandMgr().GetMoveVector();