Even more DolphinCGraphics

This commit is contained in:
Luke Street 2022-12-01 00:58:57 -05:00
parent 9fcf74b45b
commit dd8dd94f36
26 changed files with 413 additions and 65 deletions

View File

@ -345,8 +345,8 @@ lbl_803766F0:
/* 80376718 00373678 7C 08 03 A6 */ mtlr r0
/* 8037671C 0037367C 4E 80 00 20 */ blr
.global __GXSaveCPUFifoAux
__GXSaveCPUFifoAux:
.global GXGetFifoPtrs
GXGetFifoPtrs:
/* 80376720 00373680 80 0D AC 88 */ lwz r0, lbl_805A9848@sda21(r13)
/* 80376724 00373684 7C 03 00 40 */ cmplw r3, r0
/* 80376728 00373688 40 82 00 18 */ bne lbl_80376740
@ -829,4 +829,3 @@ lbl_80376DA0:
/* 80376DB4 00373D14 38 21 00 18 */ addi r1, r1, 0x18
/* 80376DB8 00373D18 7C 08 03 A6 */ mtlr r0
/* 80376DBC 00373D1C 4E 80 00 20 */ blr

View File

@ -125,8 +125,8 @@ sub_8036cb78:
/* 8036CB88 00369AE8 90 03 00 08 */ stw r0, 8(r3)
/* 8036CB8C 00369AEC 4E 80 00 20 */ blr
.global sub_8036cb90
sub_8036cb90:
.global sub_8036cb90__19CFrameDelayedKillerFv
sub_8036cb90__19CFrameDelayedKillerFv:
/* 8036CB90 00369AF0 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8036CB94 00369AF4 7C 08 02 A6 */ mflr r0
/* 8036CB98 00369AF8 3C 60 80 54 */ lis r3, lbl_80540A4C@ha
@ -250,7 +250,7 @@ sub_8036cd20:
/* 8036CD2C 00369C8C 93 E1 00 0C */ stw r31, 0xc(r1)
/* 8036CD30 00369C90 3B E0 00 00 */ li r31, 0
lbl_8036CD34:
/* 8036CD34 00369C94 4B FF FE 5D */ bl sub_8036cb90
/* 8036CD34 00369C94 4B FF FE 5D */ bl sub_8036cb90__19CFrameDelayedKillerFv
/* 8036CD38 00369C98 3B FF 00 01 */ addi r31, r31, 1
/* 8036CD3C 00369C9C 2C 1F 00 02 */ cmpwi r31, 2
/* 8036CD40 00369CA0 41 80 FF F4 */ blt lbl_8036CD34

View File

@ -2456,7 +2456,7 @@ MyTHPGXYuv2RgbSetup__Fb:
/* 8035D2EC 0035A24C 90 E1 00 68 */ stw r7, 0x68(r1)
/* 8035D2F0 0035A250 90 C1 00 6C */ stw r6, 0x6c(r1)
/* 8035D2F4 0035A254 90 01 00 70 */ stw r0, 0x70(r1)
/* 8035D2F8 0035A258 4B FA B5 85 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8035D2F8 0035A258 4B FA B5 85 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8035D2FC 0035A25C 38 60 00 00 */ li r3, 0
/* 8035D300 0035A260 38 80 00 01 */ li r4, 1
/* 8035D304 0035A264 38 A0 00 00 */ li r5, 0
@ -2771,7 +2771,7 @@ MyTHPGXRestore__Fv:
/* 8035D7BC 0035A71C 38 80 00 07 */ li r4, 7
/* 8035D7C0 0035A720 90 01 00 14 */ stw r0, 0x14(r1)
/* 8035D7C4 0035A724 38 A0 00 00 */ li r5, 0
/* 8035D7C8 0035A728 4B FA B0 B5 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8035D7C8 0035A728 4B FA B0 B5 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8035D7CC 0035A72C 38 60 00 00 */ li r3, 0
/* 8035D7D0 0035A730 38 80 00 01 */ li r4, 1
/* 8035D7D4 0035A734 38 A0 00 00 */ li r5, 0

View File

@ -951,8 +951,8 @@ lbl_80308868:
/* 80308874 003057D4 38 21 00 10 */ addi r1, r1, 0x10
/* 80308878 003057D8 4E 80 00 20 */ blr
.global SetZMode__3CGXFb10_GXCompareb
SetZMode__3CGXFb10_GXCompareb:
.global SetZMode__3CGXFUi10_GXCompareUi
SetZMode__3CGXFUi10_GXCompareUi:
/* 8030887C 003057DC 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80308880 003057E0 7C 08 02 A6 */ mflr r0
/* 80308884 003057E4 3C C0 80 5A */ lis r6, sGXState__3CGX@ha
@ -1465,4 +1465,3 @@ lbl_803D73B8:
.4byte 0x00000003
.4byte 0x000000FF
.4byte 0

View File

@ -3159,7 +3159,7 @@ SetDepthWriteMode__9CGraphicsFb8ERglEnumb:
/* 8030BAA0 00308A00 54 A5 06 3E */ clrlwi r5, r5, 0x18
/* 8030BAA4 00308A04 90 01 00 14 */ stw r0, 0x14(r1)
/* 8030BAA8 00308A08 90 8D 9C 70 */ stw r4, mDepthFunc__9CGraphics@sda21(r13)
/* 8030BAAC 00308A0C 4B FF CD D1 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8030BAAC 00308A0C 4B FF CD D1 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8030BAB0 00308A10 80 01 00 14 */ lwz r0, 0x14(r1)
/* 8030BAB4 00308A14 7C 08 03 A6 */ mtlr r0
/* 8030BAB8 00308A18 38 21 00 10 */ addi r1, r1, 0x10
@ -3176,7 +3176,7 @@ EndScene__9CGraphicsFv:
/* 8030BAD8 00308A38 93 E1 00 9C */ stw r31, 0x9c(r1)
/* 8030BADC 00308A3C 93 C1 00 98 */ stw r30, 0x98(r1)
/* 8030BAE0 00308A40 93 A1 00 94 */ stw r29, 0x94(r1)
/* 8030BAE4 00308A44 4B FF CD 99 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8030BAE4 00308A44 4B FF CD 99 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8030BAE8 00308A48 3B AD A8 0C */ addi r29, r13, mNumBreakpointsWaiting__9CGraphics@sda21
/* 8030BAEC 00308A4C 48 00 00 08 */ b lbl_8030BAF4
lbl_8030BAF0:
@ -3311,7 +3311,7 @@ lbl_8030BB40:
/* 8030BCE8 00308C48 48 06 AE 45 */ bl GXGetGPFifo
/* 8030BCEC 00308C4C 38 81 00 0C */ addi r4, r1, 0xc
/* 8030BCF0 00308C50 38 A1 00 08 */ addi r5, r1, 8
/* 8030BCF4 00308C54 48 06 AA 2D */ bl __GXSaveCPUFifoAux
/* 8030BCF4 00308C54 48 06 AA 2D */ bl GXGetFifoPtrs
/* 8030BCF8 00308C58 80 61 00 08 */ lwz r3, 8(r1)
/* 8030BCFC 00308C5C 48 06 AB 01 */ bl GXEnableBreakPt
/* 8030BD00 00308C60 80 6D A8 00 */ lwz r3, mFrameCounter__9CGraphics@sda21(r13)
@ -3319,7 +3319,7 @@ lbl_8030BB40:
/* 8030BD08 00308C68 38 03 00 01 */ addi r0, r3, 1
/* 8030BD0C 00308C6C 98 8D A8 14 */ stb r4, mLastFrameUsedAbove__9CGraphics@sda21(r13)
/* 8030BD10 00308C70 90 0D A8 00 */ stw r0, mFrameCounter__9CGraphics@sda21(r13)
/* 8030BD14 00308C74 48 06 0E 7D */ bl sub_8036cb90
/* 8030BD14 00308C74 48 06 0E 7D */ bl sub_8036cb90__19CFrameDelayedKillerFv
/* 8030BD18 00308C78 80 01 00 A4 */ lwz r0, 0xa4(r1)
/* 8030BD1C 00308C7C 83 E1 00 9C */ lwz r31, 0x9c(r1)
/* 8030BD20 00308C80 83 C1 00 98 */ lwz r30, 0x98(r1)

View File

@ -2197,7 +2197,7 @@ RenderParticlesIndirectTexture__11CElementGenFv:
/* 80319408 00316368 38 60 00 01 */ li r3, 1
/* 8031940C 0031636C 38 80 00 03 */ li r4, 3
/* 80319410 00316370 38 A0 00 00 */ li r5, 0
/* 80319414 00316374 4B FE F4 69 */ bl SetZMode__3CGXFb10_GXCompareb
/* 80319414 00316374 4B FE F4 69 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80319418 00316378 38 60 00 01 */ li r3, 1
/* 8031941C 0031637C 38 80 00 04 */ li r4, 4
/* 80319420 00316380 38 A0 00 01 */ li r5, 1
@ -2208,7 +2208,7 @@ lbl_80319430:
/* 80319430 00316390 54 65 E7 FE */ rlwinm r5, r3, 0x1c, 0x1f, 0x1f
/* 80319434 00316394 38 60 00 01 */ li r3, 1
/* 80319438 00316398 38 80 00 03 */ li r4, 3
/* 8031943C 0031639C 4B FE F4 41 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8031943C 0031639C 4B FE F4 41 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80319440 003163A0 38 60 00 01 */ li r3, 1
/* 80319444 003163A4 38 80 00 04 */ li r4, 4
/* 80319448 003163A8 38 A0 00 05 */ li r5, 5

View File

@ -939,7 +939,7 @@ lbl_802B6568:
/* 802B6700 002B3660 38 60 00 00 */ li r3, 0
/* 802B6704 002B3664 38 80 00 07 */ li r4, 7
/* 802B6708 002B3668 38 A0 00 00 */ li r5, 0
/* 802B670C 002B366C 48 05 21 71 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B670C 002B366C 48 05 21 71 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B6710 002B3670 38 60 00 00 */ li r3, 0
/* 802B6714 002B3674 48 0C 24 45 */ bl GXSetCullMode
/* 802B6718 002B3678 38 60 00 01 */ li r3, 1
@ -2684,7 +2684,7 @@ lbl_802B801C:
/* 802B8030 002B4F90 38 80 00 03 */ li r4, 3
lbl_802B8034:
/* 802B8034 002B4F94 54 A5 FF FE */ rlwinm r5, r5, 0x1f, 0x1f, 0x1f
/* 802B8038 002B4F98 48 05 08 45 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B8038 002B4F98 48 05 08 45 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B803C 002B4F9C 38 60 00 01 */ li r3, 1
/* 802B8040 002B4FA0 48 05 0C 51 */ bl SetNumTevStages__3CGXFUc
/* 802B8044 002B4FA4 38 60 00 01 */ li r3, 1
@ -2992,7 +2992,7 @@ DrawModelDisintegrate__13CCubeRendererFRC6CModelRC8CTextureRC6CColorPCfPCf:
/* 802B84EC 002B544C 38 60 00 01 */ li r3, 1
/* 802B84F0 002B5450 38 80 00 03 */ li r4, 3
/* 802B84F4 002B5454 38 A0 00 01 */ li r5, 1
/* 802B84F8 002B5458 48 05 03 85 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B84F8 002B5458 48 05 03 85 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B84FC 002B545C 7F A3 EB 78 */ mr r3, r29
/* 802B8500 002B5460 48 09 CC 21 */ bl UpdateLastFrame__6CModelFv
/* 802B8504 002B5464 80 7D 00 28 */ lwz r3, 0x28(r29)
@ -3162,7 +3162,7 @@ sub_802b85cc:
/* 802B877C 002B56DC 7C 00 00 34 */ cntlzw r0, r0
/* 802B8780 002B56E0 54 63 D9 7E */ srwi r3, r3, 5
/* 802B8784 002B56E4 54 05 D9 7E */ srwi r5, r0, 5
/* 802B8788 002B56E8 48 05 00 F5 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B8788 002B56E8 48 05 00 F5 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B878C 002B56EC A0 1F 00 02 */ lhz r0, 2(r31)
/* 802B8790 002B56F0 7F 83 E3 78 */ mr r3, r28
/* 802B8794 002B56F4 7F A4 EB 78 */ mr r4, r29
@ -4515,7 +4515,7 @@ lbl_802B9A98:
/* 802B9AC8 002B6A28 38 60 00 01 */ li r3, 1
/* 802B9ACC 002B6A2C 38 80 00 03 */ li r4, 3
/* 802B9AD0 002B6A30 38 A0 00 01 */ li r5, 1
/* 802B9AD4 002B6A34 48 04 ED A9 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B9AD4 002B6A34 48 04 ED A9 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B9AD8 002B6A38 38 60 00 01 */ li r3, 1
/* 802B9ADC 002B6A3C 48 04 F1 B5 */ bl SetNumTevStages__3CGXFUc
/* 802B9AE0 002B6A40 38 60 00 01 */ li r3, 1
@ -4548,7 +4548,7 @@ lbl_802B9A98:
/* 802B9B4C 002B6AAC 38 60 00 00 */ li r3, 0
/* 802B9B50 002B6AB0 38 80 00 07 */ li r4, 7
/* 802B9B54 002B6AB4 38 A0 00 00 */ li r5, 0
/* 802B9B58 002B6AB8 48 04 ED 25 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B9B58 002B6AB8 48 04 ED 25 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B9B5C 002B6ABC 7F 43 D3 78 */ mr r3, r26
/* 802B9B60 002B6AC0 7F 64 DB 78 */ mr r4, r27
/* 802B9B64 002B6AC4 7F E6 FB 78 */ mr r6, r31
@ -4558,7 +4558,7 @@ lbl_802B9A98:
/* 802B9B74 002B6AD4 38 60 00 01 */ li r3, 1
/* 802B9B78 002B6AD8 38 80 00 03 */ li r4, 3
/* 802B9B7C 002B6ADC 38 A0 00 01 */ li r5, 1
/* 802B9B80 002B6AE0 48 04 EC FD */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B9B80 002B6AE0 48 04 EC FD */ bl SetZMode__3CGXFUi10_GXCompareUi
lbl_802B9B84:
/* 802B9B84 002B6AE4 38 60 00 01 */ li r3, 1
/* 802B9B88 002B6AE8 38 80 00 00 */ li r4, 0
@ -4586,7 +4586,7 @@ lbl_802B9B84:
/* 802B9BE0 002B6B40 38 60 00 01 */ li r3, 1
/* 802B9BE4 002B6B44 38 80 00 04 */ li r4, 4
/* 802B9BE8 002B6B48 38 A0 00 00 */ li r5, 0
/* 802B9BEC 002B6B4C 48 04 EC 91 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B9BEC 002B6B4C 48 04 EC 91 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B9BF0 002B6B50 7F 43 D3 78 */ mr r3, r26
/* 802B9BF4 002B6B54 7F 64 DB 78 */ mr r4, r27
/* 802B9BF8 002B6B58 7F E6 FB 78 */ mr r6, r31
@ -4596,7 +4596,7 @@ lbl_802B9B84:
/* 802B9C08 002B6B68 38 60 00 01 */ li r3, 1
/* 802B9C0C 002B6B6C 38 80 00 03 */ li r4, 3
/* 802B9C10 002B6B70 38 A0 00 01 */ li r5, 1
/* 802B9C14 002B6B74 48 04 EC 69 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B9C14 002B6B74 48 04 EC 69 */ bl SetZMode__3CGXFUi10_GXCompareUi
lbl_802B9C18:
/* 802B9C18 002B6B78 80 61 03 28 */ lwz r3, 0x328(r1)
/* 802B9C1C 002B6B7C 38 80 00 00 */ li r4, 0
@ -4691,7 +4691,7 @@ lbl_802B9C18:
/* 802B9D80 002B6CE0 38 60 00 00 */ li r3, 0
/* 802B9D84 002B6CE4 38 80 00 07 */ li r4, 7
/* 802B9D88 002B6CE8 38 A0 00 00 */ li r5, 0
/* 802B9D8C 002B6CEC 48 04 EA F1 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802B9D8C 002B6CEC 48 04 EA F1 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802B9D90 002B6CF0 38 60 00 00 */ li r3, 0
/* 802B9D94 002B6CF4 48 0B ED C5 */ bl GXSetCullMode
/* 802B9D98 002B6CF8 38 60 00 00 */ li r3, 0
@ -5205,7 +5205,7 @@ DoThermalBlendHot__13CCubeRendererFv:
/* 802BA4F8 002B7458 38 A0 00 01 */ li r5, 1
/* 802BA4FC 002B745C 83 E6 00 08 */ lwz r31, 8(r6)
/* 802BA500 002B7460 83 C6 00 0C */ lwz r30, 0xc(r6)
/* 802BA504 002B7464 48 04 E3 79 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BA504 002B7464 48 04 E3 79 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BA508 002B7468 57 A3 04 3E */ clrlwi r3, r29, 0x10
/* 802BA50C 002B746C 57 84 04 3E */ clrlwi r4, r28, 0x10
/* 802BA510 002B7470 57 E5 04 3E */ clrlwi r5, r31, 0x10
@ -5269,7 +5269,7 @@ DoThermalBlendHot__13CCubeRendererFv:
/* 802BA5F8 002B7558 38 60 00 00 */ li r3, 0
/* 802BA5FC 002B755C 38 80 00 03 */ li r4, 3
/* 802BA600 002B7560 38 A0 00 00 */ li r5, 0
/* 802BA604 002B7564 48 04 E2 79 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BA604 002B7564 48 04 E2 79 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BA608 002B7568 3C 60 80 3D */ lis r3, lbl_803D6654@ha
/* 802BA60C 002B756C 38 63 66 54 */ addi r3, r3, lbl_803D6654@l
/* 802BA610 002B7570 48 04 D8 19 */ bl SetVtxDescv__3CGXFPC14_GXVtxDescList
@ -5426,7 +5426,7 @@ DoThermalBlendCold__13CCubeRendererFv:
/* 802BA860 002B77C0 38 A0 00 00 */ li r5, 0
/* 802BA864 002B77C4 83 C6 00 08 */ lwz r30, 8(r6)
/* 802BA868 002B77C8 83 A6 00 0C */ lwz r29, 0xc(r6)
/* 802BA86C 002B77CC 48 04 E0 11 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BA86C 002B77CC 48 04 E0 11 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BA870 002B77D0 57 E3 04 3E */ clrlwi r3, r31, 0x10
/* 802BA874 002B77D4 57 64 04 3E */ clrlwi r4, r27, 0x10
/* 802BA878 002B77D8 57 C5 04 3E */ clrlwi r5, r30, 0x10
@ -5664,7 +5664,7 @@ lbl_802BAA1C:
/* 802BAC08 002B7B68 38 60 00 00 */ li r3, 0
/* 802BAC0C 002B7B6C 38 80 00 07 */ li r4, 7
/* 802BAC10 002B7B70 38 A0 00 00 */ li r5, 0
/* 802BAC14 002B7B74 48 04 DC 69 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BAC14 002B7B74 48 04 DC 69 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BAC18 002B7B78 3C 60 80 3D */ lis r3, lbl_803D6624@ha
/* 802BAC1C 002B7B7C 38 63 66 24 */ addi r3, r3, lbl_803D6624@l
/* 802BAC20 002B7B80 48 04 D2 09 */ bl SetVtxDescv__3CGXFPC14_GXVtxDescList
@ -7128,7 +7128,7 @@ lbl_802BBEB8:
/* 802BC198 002B90F8 38 60 00 00 */ li r3, 0
/* 802BC19C 002B90FC 38 80 00 07 */ li r4, 7
/* 802BC1A0 002B9100 38 A0 00 00 */ li r5, 0
/* 802BC1A4 002B9104 48 04 C6 D9 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BC1A4 002B9104 48 04 C6 D9 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BC1A8 002B9108 38 60 00 00 */ li r3, 0
/* 802BC1AC 002B910C 48 0B C9 AD */ bl GXSetCullMode
/* 802BC1B0 002B9110 38 60 00 A0 */ li r3, 0xa0
@ -7332,7 +7332,7 @@ lbl_802BC424:
/* 802BC4A0 002B9400 38 60 00 01 */ li r3, 1
/* 802BC4A4 002B9404 38 80 00 03 */ li r4, 3
/* 802BC4A8 002B9408 38 A0 00 01 */ li r5, 1
/* 802BC4AC 002B940C 48 04 C3 D1 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BC4AC 002B940C 48 04 C3 D1 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BC4B0 002B9410 7F 63 DB 78 */ mr r3, r27
/* 802BC4B4 002B9414 38 80 00 01 */ li r4, 1
/* 802BC4B8 002B9418 48 0B D0 7D */ bl GXCopyTex
@ -7350,7 +7350,7 @@ lbl_802BC424:
/* 802BC4E8 002B9448 7C 1B 03 78 */ mr r27, r0
/* 802BC4EC 002B944C 38 80 00 03 */ li r4, 3
/* 802BC4F0 002B9450 38 A0 00 01 */ li r5, 1
/* 802BC4F4 002B9454 48 04 C3 89 */ bl SetZMode__3CGXFb10_GXCompareb
/* 802BC4F4 002B9454 48 04 C3 89 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 802BC4F8 002B9458 7F 63 DB 78 */ mr r3, r27
/* 802BC4FC 002B945C 57 E4 06 3E */ clrlwi r4, r31, 0x18
/* 802BC500 002B9460 48 0B D0 35 */ bl GXCopyTex

View File

@ -2294,7 +2294,7 @@ lbl_8019B99C:
/* 8019B99C 001988FC 38 60 00 01 */ li r3, 1
/* 8019B9A0 00198900 38 80 00 03 */ li r4, 3
/* 8019B9A4 00198904 38 A0 00 00 */ li r5, 0
/* 8019B9A8 00198908 48 16 CE D5 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8019B9A8 00198908 48 16 CE D5 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8019B9AC 0019890C 38 60 00 07 */ li r3, 7
/* 8019B9B0 00198910 38 80 00 00 */ li r4, 0
/* 8019B9B4 00198914 38 A0 00 00 */ li r5, 0

View File

@ -576,7 +576,7 @@ lbl_8019DBA4:
/* 8019DBB4 0019AB14 38 60 00 01 */ li r3, 1
/* 8019DBB8 0019AB18 38 80 00 03 */ li r4, 3
/* 8019DBBC 0019AB1C 38 A0 00 00 */ li r5, 0
/* 8019DBC0 0019AB20 48 16 AC BD */ bl SetZMode__3CGXFb10_GXCompareb
/* 8019DBC0 0019AB20 48 16 AC BD */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8019DBC4 0019AB24 38 60 00 07 */ li r3, 7
/* 8019DBC8 0019AB28 38 80 00 00 */ li r4, 0
/* 8019DBCC 0019AB2C 38 A0 00 00 */ li r5, 0
@ -718,4 +718,3 @@ lbl_803D1300:
.4byte 0
.4byte 0
.4byte 0

View File

@ -387,7 +387,7 @@ sub_80293e2c:
/* 80294044 00290FA4 38 60 00 01 */ li r3, 1
/* 80294048 00290FA8 38 80 00 07 */ li r4, 7
/* 8029404C 00290FAC 38 A0 00 00 */ li r5, 0
/* 80294050 00290FB0 48 07 48 2D */ bl SetZMode__3CGXFb10_GXCompareb
/* 80294050 00290FB0 48 07 48 2D */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80294054 00290FB4 7F A4 EB 78 */ mr r4, r29
/* 80294058 00290FB8 38 60 00 00 */ li r3, 0
/* 8029405C 00290FBC 48 07 4B E9 */ bl SetTevKColor__3CGXF14_GXTevKColorIDRC8_GXColor

View File

@ -186,7 +186,7 @@ lbl_8029D928:
/* 8029D930 0029A890 38 60 00 01 */ li r3, 1
/* 8029D934 0029A894 38 80 00 02 */ li r4, 2
/* 8029D938 0029A898 38 A0 00 00 */ li r5, 0
/* 8029D93C 0029A89C 48 06 AF 41 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8029D93C 0029A89C 48 06 AF 41 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8029D940 0029A8A0 38 60 00 01 */ li r3, 1
/* 8029D944 0029A8A4 38 80 00 04 */ li r4, 4
/* 8029D948 0029A8A8 38 A0 00 05 */ li r5, 5
@ -354,7 +354,7 @@ lbl_8029DB80:
/* 8029DBC4 0029AB24 38 60 00 01 */ li r3, 1
/* 8029DBC8 0029AB28 38 80 00 03 */ li r4, 3
/* 8029DBCC 0029AB2C 38 A0 00 01 */ li r5, 1
/* 8029DBD0 0029AB30 48 06 AC AD */ bl SetZMode__3CGXFb10_GXCompareb
/* 8029DBD0 0029AB30 48 06 AC AD */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8029DBD4 0029AB34 38 60 00 07 */ li r3, 7
/* 8029DBD8 0029AB38 38 80 00 00 */ li r4, 0
/* 8029DBDC 0029AB3C 38 A0 00 00 */ li r5, 0
@ -716,7 +716,7 @@ RenderShadowBuffer__16CProjectedShadowFR13CStateManagerRC10CModelDataRC12CTransf
/* 8029E13C 0029B09C 38 60 00 01 */ li r3, 1
/* 8029E140 0029B0A0 38 80 00 03 */ li r4, 3
/* 8029E144 0029B0A4 38 A0 00 01 */ li r5, 1
/* 8029E148 0029B0A8 48 06 A7 35 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8029E148 0029B0A8 48 06 A7 35 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8029E14C 0029B0AC 57 A5 04 3E */ clrlwi r5, r29, 0x10
/* 8029E150 0029B0B0 57 86 04 3E */ clrlwi r6, r28, 0x10
/* 8029E154 0029B0B4 38 60 00 00 */ li r3, 0

View File

@ -442,7 +442,7 @@ DoDraw__20CRainSplashGeneratorCFRC12CTransform4f:
/* 8026A2A0 00267200 38 60 00 01 */ li r3, 1
/* 8026A2A4 00267204 38 80 00 03 */ li r4, 3
/* 8026A2A8 00267208 38 A0 00 00 */ li r5, 0
/* 8026A2AC 0026720C 48 09 E5 D1 */ bl SetZMode__3CGXFb10_GXCompareb
/* 8026A2AC 0026720C 48 09 E5 D1 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8026A2B0 00267210 80 8D 9C 68 */ lwz r4, kEnvPassthru__9CGraphics@sda21(r13)
/* 8026A2B4 00267214 38 60 00 00 */ li r3, 0
/* 8026A2B8 00267218 48 0A 00 01 */ bl SetTevOp__9CGraphicsF12ERglTevStageRCQ213CTevCombiners8CTevPass
@ -1328,4 +1328,3 @@ lbl_803D5410:
# ROM: 0x3D2410
.asciz "??(??)"
.balign 4

View File

@ -1052,7 +1052,7 @@ lbl_80209B80:
/* 80209BD8 00206B38 38 60 00 01 */ li r3, 1
/* 80209BDC 00206B3C 38 80 00 03 */ li r4, 3
/* 80209BE0 00206B40 38 A0 00 01 */ li r5, 1
/* 80209BE4 00206B44 48 0F EC 99 */ bl SetZMode__3CGXFb10_GXCompareb
/* 80209BE4 00206B44 48 0F EC 99 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80209BE8 00206B48 57 E3 04 3E */ clrlwi r3, r31, 0x10
/* 80209BEC 00206B4C 57 C4 04 3E */ clrlwi r4, r30, 0x10
/* 80209BF0 00206B50 38 A0 00 04 */ li r5, 4
@ -1158,7 +1158,7 @@ lbl_80209B80:
/* 80209D80 00206CE0 38 60 00 00 */ li r3, 0
/* 80209D84 00206CE4 38 80 00 07 */ li r4, 7
/* 80209D88 00206CE8 38 A0 00 00 */ li r5, 0
/* 80209D8C 00206CEC 48 0F EA F1 */ bl SetZMode__3CGXFb10_GXCompareb
/* 80209D8C 00206CEC 48 0F EA F1 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80209D90 00206CF0 38 60 00 A0 */ li r3, 0xa0
/* 80209D94 00206CF4 38 80 00 00 */ li r4, 0
/* 80209D98 00206CF8 38 A0 00 04 */ li r5, 4

View File

@ -320,7 +320,7 @@ lbl_80295F84:
/* 80295F90 00292EF0 38 80 00 02 */ li r4, 2
/* 80295F94 00292EF4 90 01 00 14 */ stw r0, 0x14(r1)
/* 80295F98 00292EF8 38 A0 00 00 */ li r5, 0
/* 80295F9C 00292EFC 48 07 28 E1 */ bl SetZMode__3CGXFb10_GXCompareb
/* 80295F9C 00292EFC 48 07 28 E1 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80295FA0 00292F00 38 60 00 01 */ li r3, 1
/* 80295FA4 00292F04 38 80 00 04 */ li r4, 4
/* 80295FA8 00292F08 38 A0 00 05 */ li r5, 5
@ -718,7 +718,7 @@ lbl_802963B0:
/* 8029658C 002934EC 38 60 00 01 */ li r3, 1
/* 80296590 002934F0 38 80 00 07 */ li r4, 7
/* 80296594 002934F4 38 A0 00 01 */ li r5, 1
/* 80296598 002934F8 48 07 22 E5 */ bl SetZMode__3CGXFb10_GXCompareb
/* 80296598 002934F8 48 07 22 E5 */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 8029659C 002934FC 38 60 00 00 */ li r3, 0
/* 802965A0 00293500 48 07 54 D1 */ bl SetCullMode__9CGraphicsF12ERglCullMode
/* 802965A4 00293504 3C 60 80 5A */ lis r3, sIdentity__12CTransform4f@ha
@ -808,7 +808,7 @@ lbl_802963B0:
/* 802966F4 00293654 38 60 00 01 */ li r3, 1
/* 802966F8 00293658 38 80 00 03 */ li r4, 3
/* 802966FC 0029365C 38 A0 00 01 */ li r5, 1
/* 80296700 00293660 48 07 21 7D */ bl SetZMode__3CGXFb10_GXCompareb
/* 80296700 00293660 48 07 21 7D */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80296704 00293664 48 07 62 79 */ bl DisableAllLights__9CGraphicsFv
/* 80296708 00293668 38 60 00 01 */ li r3, 1
/* 8029670C 0029366C 48 0A F0 DD */ bl SetRenderModelBlack__10CCubeModelFb
@ -975,7 +975,7 @@ lbl_80296888:
/* 80296974 002938D4 38 60 00 01 */ li r3, 1
/* 80296978 002938D8 38 80 00 03 */ li r4, 3
/* 8029697C 002938DC 38 A0 00 01 */ li r5, 1
/* 80296980 002938E0 48 07 1E FD */ bl SetZMode__3CGXFb10_GXCompareb
/* 80296980 002938E0 48 07 1E FD */ bl SetZMode__3CGXFUi10_GXCompareUi
/* 80296984 002938E4 38 61 01 A0 */ addi r3, r1, 0x1a0
/* 80296988 002938E8 48 07 5D C5 */ bl SetViewPointMatrix__9CGraphicsFRC12CTransform4f
/* 8029698C 002938EC 38 61 00 94 */ addi r3, r1, 0x94

View File

@ -1190,4 +1190,3 @@ lbl_803D6550:
.4byte 0x00000001
.4byte 0x000000FF
.4byte 0

View File

@ -7,6 +7,8 @@ class CFrameDelayedKiller {
public:
static void Initialize();
static void ShutDown();
static void sub_8036cb90();
};
#endif // _CFRAMEDELAYEDKILLER

View File

@ -107,7 +107,8 @@ public:
GXChannelID color);
static void SetBlendMode(GXBlendMode mode, GXBlendFactor srcFac, GXBlendFactor dstFac,
GXLogicOp op);
static void SetZMode(bool compareEnable, GXCompare func, bool updateEnable);
// TODO: GXBool doesn't work, why?
static void SetZMode(uint compareEnable, GXCompare func, uint updateEnable);
static void SetAlphaCompare(GXCompare comp0, uchar ref0, GXAlphaOp op, GXCompare comp1,
uchar ref1);
static void SetTevIndirect(GXTevStageID stageId, GXIndTexStageID indStage, GXIndTexFormat fmt,

View File

@ -7,6 +7,7 @@
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Graphics/CLight.hpp"
#include "Kyoto/Graphics/CTevCombiners.hpp"
#include "Kyoto/Math/CMatrix4f.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
#include "Kyoto/Math/CVector3f.hpp"
@ -158,8 +159,10 @@ struct CViewport {
};
class COsContext;
class CTexture;
class CTimeProvider;
// TODO
typedef struct {
float x;
float y;
@ -189,6 +192,11 @@ public:
, x14_near(near)
, x18_far(far) {}
bool IsPerspective() const { return x0_persp; }
float GetLeft() const { return x4_left; }
float GetRight() const { return x8_right; }
float GetTop() const { return xc_top; }
float GetBottom() const { return x10_bottom; }
float GetNear() const { return x14_near; }
float GetFar() const { return x18_far; }
@ -212,20 +220,26 @@ public:
static void LoadLight(ERglLight light, const CLight& info);
static void SetLightState(uchar lights);
static void SetViewMatrix();
static void SetScissor(int left, int bottom, int width, int height);
static void ClearBackAndDepthBuffers();
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 SetClearColor(const CColor& color);
static void SetDepthRange(float near, float far);
static void FlushProjection();
static void SetDefaultVtxAttrFmt();
static CMatrix4f GetPerspectiveProjectionMatrix();
static CMatrix4f CalculatePerspectiveMatrix(float fovy, float aspect, float znear, float zfar);
static bool IsBeginSceneClearFb();
static void SetIsBeginSceneClearFb(bool);
static void BeginScene();
static void EndScene();
static void SwapBuffers();
static void SetTevOp(ERglTevStage stage, const CTevCombiners::CTevPass& pass);
static void StreamBegin(ERglPrimitive primitive);
static void StreamColor(uint color);
@ -234,7 +248,13 @@ public:
static void StreamVertex(float, float, float);
static void StreamVertex(const CVector3f& vtx);
static void StreamVertex(const float*);
static void StreamNormal(const float*);
static void StreamEnd();
static void Render2D(const CTexture& tex, int x, int y, int w, int h, const CColor& col);
static void DrawPrimitive(ERglPrimitive primitive, const float* pos, const CVector3f& normal, const CColor& col, int numVerts);
static void VideoPreCallback(u32 retraceCount);
static void VideoPostCallback(u32 retraceCount);
static const CViewport& GetViewport() { return mViewport; }
static const CVector3f& GetViewPoint() { return mViewPoint; }
@ -252,11 +272,13 @@ public:
static void SetFog(ERglFogMode mode, float startz, float endz, const CColor& color);
static void SetModelMatrix(const CTransform4f& xf);
static void SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1,
u8 ref1);
static void SetAlphaCompare(ERglAlphaFunc comp0, uchar ref0, ERglAlphaOp op, ERglAlphaFunc comp1,
uchar ref1);
static void SetDepthWriteMode(bool test, ERglEnum comp, bool write);
static void SetBlendMode(ERglBlendMode, ERglBlendFactor, ERglBlendFactor, ERglLogicOp);
static void SetCullMode(ERglCullMode);
static void SetBlendMode(ERglBlendMode mode, ERglBlendFactor src, ERglBlendFactor dst,
ERglLogicOp op);
static void SetCullMode(ERglCullMode cullMode);
static void SetTevStates(uchar);
// Screen Position
static void sub_80309564(uint* stretch, uint* xOffset, uint* yOffset);

View File

@ -4,6 +4,10 @@
#include "types.h"
class CMatrix4f {
public:
CMatrix4f(float, float, float, float, float, float, float, float, float, float, float, float,
float, float, float, float);
private:
float m00;
float m01;

View File

@ -43,6 +43,9 @@ CHECK_SIZEOF(CRelAngle, 0x4)
// __mi__FRC9CRelAngleRC9CRelAngle
// __pl__FRC9CRelAngleRC9CRelAngle
// __dv__FRC9CRelAnglef
// static inline CRelAngle operator/(const CRelAngle& ang, float f) {
// return CRelAngle::FromRadians(ang.AsRadians() / f);
// }
static inline float sine(const CRelAngle& angle) { return sin(angle.AsRadians()); }
static inline float cosine(const CRelAngle& angle) { return cos(angle.AsRadians()); }

View File

@ -11,6 +11,8 @@ typedef struct {
u8 pad[128];
} GXFifoObj;
typedef void (*GXBreakPtCallback)(void);
void GXInitFifoBase(GXFifoObj* fifo, void* base, u32 size);
void GXInitFifoPtrs(GXFifoObj* fifo, void* readPtr, void* writePtr);
void GXGetFifoPtrs(GXFifoObj* fifo, void** readPtr, void** writePtr);
@ -24,6 +26,9 @@ void GXGetFifoStatus(GXFifoObj* fifo, GXBool* overhi, GXBool* underlow, u32* fif
void GXGetGPStatus(GXBool* overhi, GXBool* underlow, GXBool* readIdle, GXBool* cmdIdle,
GXBool* brkpt);
void GXInitFifoLimits(GXFifoObj* fifo, u32 hiWaterMark, u32 loWaterMark);
GXBreakPtCallback GXSetBreakPtCallback(GXBreakPtCallback cb);
void GXEnableBreakPt(void* breakPt);
void GXDisableBreakPt(void);
#ifdef __cplusplus
}

View File

@ -3,11 +3,15 @@
#include <dolphin/types.h>
#include <dolphin/vitypes.h>
#ifdef __cplusplus
extern "C" {
#endif
u32 VIGetNextField(void);
VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback callback);
VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback callback);
#ifdef __cplusplus
}

16
include/dolphin/vitypes.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef _DOLPHIN_VITYPES
#define _DOLPHIN_VITYPES
#include <dolphin/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*VIRetraceCallback)(u32 retraceCount);
#ifdef __cplusplus
}
#endif
#endif // _DOLPHIN_VITYPES

View File

@ -72,6 +72,7 @@ double sin(double x);
double cos(double x);
double atan(double x);
double atan2(double y, double x);
double tan(double x);
_MATH_INLINE float fabsf(float x) { return (float)fabs((double)x); }
_MATH_INLINE float sinf(float x) { return (float)sin((double)x); }

View File

@ -177,9 +177,10 @@ void CGX::SetBlendMode(GXBlendMode mode, GXBlendFactor srcFac, GXBlendFactor dst
}
}
void CGX::SetZMode(bool compareEnable, GXCompare func, bool updateEnable) {
// ??
uchar flags = compareEnable | MaskAndShiftLeft(updateEnable, 0xFF, 1) | (func & 0xFF) << 2;
// TODO: GXBool doesn't work, why?
void CGX::SetZMode(uint compareEnable, GXCompare func, uint updateEnable) {
uchar flags = MaskAndShiftLeft(compareEnable, 0xFF, 0) | MaskAndShiftLeft(updateEnable, 0xFF, 1) |
MaskAndShiftLeft(func, 0xFF, 2);
if (flags != sGXState.x52_zmode) {
sGXState.x52_zmode = flags;
GXSetZMode(compareEnable, func, updateEnable);

View File

@ -2,8 +2,11 @@
#include "Kyoto/Basics/COsContext.hpp"
#include "Kyoto/Basics/CStopwatch.hpp"
#include "Kyoto/CFrameDelayedKiller.hpp"
#include "Kyoto/Graphics/CGX.hpp"
#include "Kyoto/Graphics/CGraphicsSys.hpp"
#include "Kyoto/Graphics/CTexture.hpp"
#include "Kyoto/Math/CRelAngle.hpp"
#include "dolphin/vi.h"
@ -250,7 +253,7 @@ bool CGraphics::mIsGXModelMatrixIdentity = true;
bool CGraphics::mFirstFrame = true;
bool CGraphics::mUseVideoFilter = true;
float CGraphics::mBrightness = 1.f;
Vec2 CGraphics::mBrightnessRange = {0.f, 2.f};
// Vec2 CGraphics::mBrightnessRange = {0.f, 2.f};
bool CGraphics::Startup(const COsContext& osContext, uint fifoSize, void* fifoBase) {
mpFifo = fifoBase;
@ -384,6 +387,7 @@ void CGraphics::EnableLight(ERglLight light) {
static inline GXLightID get_hw_light_index(ERglLight light) {
#if NONMATCHING
// one instruction, no branches
return static_cast< GXLightID >((light << 1) & (GX_MAX_LIGHT - 1));
#else
if (light == kLight0) {
@ -527,19 +531,18 @@ void CGraphics::SetViewPointMatrix(const CTransform4f& xf) {
void CGraphics::SetIdentityViewPointMatrix() {
mViewMatrix = CTransform4f::Identity();
MTXIdentity(mGXViewPointMatrix);
mGXViewPointMatrix[2][2] = 0.0;
mGXViewPointMatrix[1][1] = 0.0;
mGXViewPointMatrix[1][2] = 1.0;
mGXViewPointMatrix[2][1] = -1.0;
mGXViewPointMatrix[2][2] = 0.f;
mGXViewPointMatrix[1][1] = 0.f;
mGXViewPointMatrix[1][2] = 1.f;
mGXViewPointMatrix[2][1] = -1.f;
mViewPoint = CVector3f::Zero();
SetViewMatrix();
}
// TODO: non-matching
void CGraphics::SetModelMatrix(const CTransform4f& xf) {
if (&xf == &CTransform4f::Identity()) {
if (!mIsGXModelMatrixIdentity) {
mModelMatrix = CTransform4f::Identity();
mModelMatrix = xf;
mIsGXModelMatrixIdentity = true;
SetViewMatrix();
}
@ -570,3 +573,294 @@ void CGraphics::SetIdentityModelMatrix() {
SetViewMatrix();
}
}
void CGraphics::SetOrtho(float left, float right, float top, float bottom, float znear,
float zfar) {
mProj = CProjectionState(false, left, right, top, bottom, znear, zfar);
FlushProjection();
}
// TODO non-matching (regswaps)
void CGraphics::SetPerspective(float fovy, float aspect, float znear, float zfar) {
float t = tan(CRelAngle::FromDegrees(fovy).AsRadians() / 2.f);
float top = znear * 2.f * t * 0.5f;
float right = aspect * 2.f * znear * t * 0.5f;
mProj = CProjectionState(true, -right, right, top, -top, znear, zfar);
FlushProjection();
}
CMatrix4f CGraphics::GetPerspectiveProjectionMatrix() {
#if NONMATCHING
// construct in place
return CMatrix4f(
#else
CMatrix4f mtx(
#endif
// clang-format off
(mProj.GetNear() * 2.f) / (mProj.GetRight() - mProj.GetLeft()),
-(mProj.GetRight() + mProj.GetLeft()) / (mProj.GetRight() - mProj.GetLeft()),
0.f,
0.f,
0.f,
-(mProj.GetTop() + mProj.GetBottom()) / (mProj.GetTop() - mProj.GetBottom()),
(mProj.GetNear() * 2.f) / (mProj.GetTop() - mProj.GetBottom()),
0.f,
0.f,
(mProj.GetFar() + mProj.GetNear()) / (mProj.GetFar() - mProj.GetNear()),
0.f,
-(mProj.GetFar() * 2.f * mProj.GetNear()) / (mProj.GetFar() - mProj.GetNear()),
0.f,
1.f,
0.f,
0.f
// clang-format on
);
#if !NONMATCHING
return mtx;
#endif
}
CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect, float znear, float zfar) {
float t = tan(CRelAngle::FromDegrees(fovy).AsRadians() / 2.f);
float right = aspect * 2.f * znear * t * 0.5f;
float left = -right;
float top = znear * 2.f * t * 0.5f;
float bottom = -top;
#if NONMATCHING
// construct in place
return CMatrix4f(
#else
CMatrix4f mtx(
#endif
// clang-format off
(2.f * znear) / (right - left),
-(right + left) / (right - left),
0.f,
0.f,
0.f,
-(top + bottom) / (top - bottom),
(2.f * znear) / (top - bottom),
0.f,
0.f,
(zfar + znear) / (zfar - znear),
0.f,
-(2.f * zfar * znear) / (zfar - znear),
0.f,
1.f,
0.f,
0.f
// clang-format on
);
#if !NONMATCHING
return mtx;
#endif
}
void CGraphics::SetViewport(int left, int bottom, int width, int height) {
mViewport.mLeft = left;
mViewport.mTop = mRenderModeObj.efbHeight - (bottom + height);
mViewport.mWidth = width;
mViewport.mHeight = height;
mViewport.mHalfWidth = static_cast< float >(width / 2);
mViewport.mHalfHeight = static_cast< float >(height / 2);
GXSetViewport(static_cast< float >(mViewport.mLeft), static_cast< float >(mViewport.mTop),
static_cast< float >(mViewport.mWidth), static_cast< float >(mViewport.mHeight),
mDepthNear, mDepthFar);
}
void CGraphics::SetScissor(int left, int bottom, int width, int height) {
GXSetScissor(left, mRenderModeObj.efbHeight - (bottom + height), width, height);
}
void CGraphics::SetAmbientColor(const CColor& color) {
CGX::SetChanAmbColor(CGX::Channel0, color.GetGXColor());
CGX::SetChanAmbColor(CGX::Channel1, color.GetGXColor());
}
void CGraphics::SetCopyClear(const CColor& color, float depth) {
mClearColor = color;
mClearDepthValue = static_cast< u32 >(depth * GX_MAX_Z24);
GXSetCopyClear(color.GetGXColor(), mClearDepthValue);
}
void CGraphics::SetClearColor(const CColor& color) {
mClearColor = color;
GXSetCopyClear(color.GetGXColor(), mClearDepthValue);
}
void CGraphics::ClearBackAndDepthBuffers() {
GXInvalidateTexAll();
if (mRenderModeObj.field_rendering) {
GXSetViewportJitter(0.f, 0.f, static_cast< float >(mRenderModeObj.fbWidth),
static_cast< float >(mRenderModeObj.xfbHeight), 0.f, 1.f, VIGetNextField());
} else {
GXSetViewport(0.f, 0.f, static_cast< float >(mRenderModeObj.fbWidth),
static_cast< float >(mRenderModeObj.xfbHeight), 0.f, 1.f);
}
GXInvalidateVtxCache();
}
void CGraphics::BeginScene() { ClearBackAndDepthBuffers(); }
void CGraphics::SwapBuffers() {
GXDisableBreakPt();
mFlippingState = 1;
}
void CGraphics::VideoPreCallback(u32 retraceCount) {
if (mNumBreakpointsWaiting != 0 && mFlippingState == 1) {
if (mFirstFrame) {
VISetBlack(GX_FALSE);
mFirstFrame = false;
}
VISetNextFrameBuffer(mpCurrenFrameBuf);
VIFlush();
void* frameBuf = mpCurrenFrameBuf == mpFrameBuf1 ? mpFrameBuf2 : mpFrameBuf1;
mFlippingState = 2;
mpCurrenFrameBuf = frameBuf;
}
}
void CGraphics::VideoPostCallback(u32 retraceCount) {
if (mNumBreakpointsWaiting != 0) {
if (mFlippingState == 2) {
--mNumBreakpointsWaiting;
mFlippingState = 0;
CStopwatch& timer = sFPSTimer;
float elapsed = timer.GetElapsedTime();
mLastFramesPerSecond = mFramesPerSecond;
mFramesPerSecond = 1.f / elapsed;
timer.Reset();
mInterruptLastFrameUsedAbove = VIGetNextField() == 1;
}
}
}
void CGraphics::EndScene() {
CGX::SetZMode(true, GX_LEQUAL, true);
volatile int& numBreakPt = const_cast< volatile int& >(mNumBreakpointsWaiting);
while (numBreakPt > 0) {
OSYieldThread();
}
++mNumBreakpointsWaiting;
void*& frameBuf = mpCurrenFrameBuf;
float brightness = CMath::Clamp(0.f, mBrightness, 2.f);
static const u8 copyFilter[7] = {0x00, 0x00, 0x15, 0x16, 0x15, 0x00, 0x00};
const u8* inFilter = mUseVideoFilter ? mRenderModeObj.vfilter : copyFilter;
u8 vfilter[7];
for (int i = 0; i < 7; i++) {
vfilter[i] = static_cast< u8 >(static_cast< float >(inFilter[i]) * brightness);
}
GXSetCopyFilter(mRenderModeObj.aa, mRenderModeObj.sample_pattern, true, vfilter);
GXCopyDisp(frameBuf, mIsBeginSceneClearFb ? GX_TRUE : GX_FALSE);
GXSetCopyFilter(mRenderModeObj.aa, mRenderModeObj.sample_pattern,
mUseVideoFilter ? GX_TRUE : GX_FALSE, mRenderModeObj.vfilter);
GXSetBreakPtCallback(SwapBuffers);
VISetPreRetraceCallback(VideoPreCallback);
VISetPostRetraceCallback(VideoPostCallback);
GXFlush();
GXFifoObj* fifo = GXGetGPFifo();
void* readPtr;
void* writePtr;
GXGetFifoPtrs(fifo, &readPtr, &writePtr);
GXEnableBreakPt(writePtr);
mLastFrameUsedAbove = mInterruptLastFrameUsedAbove;
++mFrameCounter;
CFrameDelayedKiller::sub_8036cb90();
}
void CGraphics::SetDepthWriteMode(bool test, ERglEnum comp, bool write) {
mDepthFunc = comp;
CGX::SetZMode(static_cast< uchar >(test), static_cast< GXCompare >(comp),
static_cast< uchar >(write));
}
void CGraphics::SetCullMode(ERglCullMode cullMode) {
mCullMode = cullMode;
GXSetCullMode(static_cast< GXCullMode >(cullMode));
}
void CGraphics::SetBlendMode(ERglBlendMode mode, ERglBlendFactor src, ERglBlendFactor dst,
ERglLogicOp op) {
CGX::SetBlendMode(static_cast< GXBlendMode >(mode), static_cast< GXBlendFactor >(src),
static_cast< GXBlendFactor >(dst), static_cast< GXLogicOp >(op));
}
void CGraphics::SetAlphaCompare(ERglAlphaFunc comp0, uchar ref0, ERglAlphaOp op,
ERglAlphaFunc comp1, uchar ref1) {
CGX::SetAlphaCompare(static_cast< GXCompare >(comp0), static_cast< uchar >(ref0),
static_cast< GXAlphaOp >(op), static_cast< GXCompare >(comp1),
static_cast< uchar >(ref1));
}
static const GXVtxDescList skPosColorTexDirect[] = {
{GX_VA_POS, GX_DIRECT},
{GX_VA_CLR0, GX_DIRECT},
{GX_VA_TEX0, GX_DIRECT},
{GX_VA_NULL, GX_DIRECT},
};
// TODO non-matching (regswaps)
void CGraphics::Render2D(const CTexture& tex, int x, int y, int w, int h, const CColor& col) {
Mtx44 proj;
MTXOrtho(proj, mViewport.mHeight / 2, -mViewport.mHeight / 2, -mViewport.mWidth / 2,
mViewport.mWidth / 2, -1.f, -10.f);
GXSetProjection(proj, GX_ORTHOGRAPHIC);
uint c = col.GetColor_u32();
Mtx mtx;
MTXIdentity(mtx);
GXLoadPosMtxImm(mtx, GX_PNMTX0);
float x1 = x - mViewport.mWidth / 2;
float y1 = y - mViewport.mHeight / 2;
float x2 = x1 + w;
float y2 = y1 + h;
// Save state + setup
CGX::SetVtxDescv(skPosColorTexDirect);
SetTevStates(6);
mLightsWereOn = mLightActive;
if (mLightActive != 0) {
DisableAllLights();
}
ERglCullMode cullMode = mCullMode;
SetCullMode(kCM_None);
tex.Load(GX_TEXMAP0, CTexture::kCM_Repeat);
// Draw
CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
GXPosition3f32(x1, y1, 1.f);
GXColor1u32(c);
GXTexCoord2f32(0.f, 0.f);
GXPosition3f32(x2, y1, 1.f);
GXColor1u32(c);
GXTexCoord2f32(1.f, 0.f);
GXPosition3f32(x1, y2, 1.f);
GXColor1u32(c);
GXTexCoord2f32(0.f, 1.f);
GXPosition3f32(x2, y2, 1.f);
GXColor1u32(c);
GXTexCoord2f32(1.f, 1.f);
CGX::End();
// Restore state
if (mLightsWereOn != 0) {
SetLightState(mLightsWereOn);
}
FlushProjection();
mIsGXModelMatrixIdentity = false;
SetModelMatrix(mModelMatrix);
SetCullMode(cullMode);
}
void CGraphics::DrawPrimitive(ERglPrimitive primitive, const float* pos, const CVector3f& normal,
const CColor& col, int numVerts) {
StreamBegin(primitive);
StreamNormal(reinterpret_cast< const float* >(&normal));
StreamColor(col);
for (int i = 0; i < numVerts; ++i) {
StreamVertex(pos + i * 3);
}
StreamEnd();
}