From 4b6a5d2e013c5e6d5efb320620c783be2064e733 Mon Sep 17 00:00:00 2001 From: Elijah Thomas Date: Thu, 17 Aug 2023 20:25:20 -0400 Subject: [PATCH] added egg/core headers seen in SS --- config/SOUE01/splits.txt | 106 ++++++++++++++ config/SOUE01/symbols.txt | 36 +++-- configure.py | 56 +++++--- include/d/a/d_a_base.h | 4 +- include/lib/egg/core/eggAllocator.h | 21 ++- include/lib/egg/core/eggArchive.h | 60 ++++++++ include/lib/egg/core/eggAssertHeap.h | 27 ++++ include/lib/egg/core/eggAsyncDisplay.h | 48 +++++++ include/lib/egg/core/eggColorFader.h | 40 ++++++ include/lib/egg/core/eggController.h | 170 +++++++++++++++++++++++ include/lib/egg/core/eggDecomp.h | 76 ++++++++++ include/lib/egg/core/eggDisplay.h | 50 +++++++ include/lib/egg/core/eggDisposer.h | 47 ++++--- include/lib/egg/core/eggDvdFile.h | 47 +++++++ include/lib/egg/core/eggDvdRipper.h | 41 ++++++ include/lib/egg/core/eggExpHeap.h | 29 ++++ include/lib/egg/core/eggFader.h | 26 ++++ include/lib/egg/core/eggFile.h | 24 ++++ include/lib/egg/core/eggFrmHeap.h | 27 +++- include/lib/egg/core/eggGraphicsFifo.h | 25 ++++ include/lib/egg/core/eggHeap.h | 136 +++++++++--------- include/lib/egg/core/eggSystem.h | 53 +++++++ include/lib/egg/core/eggThread.h | 40 +++++- include/lib/egg/core/eggUnk.h | 22 +++ include/lib/egg/core/eggVideo.h | 34 +++++ include/lib/egg/core/eggXfb.h | 30 ++++ include/lib/egg/core/eggXfbManager.h | 23 +++ include/lib/egg/egg_types.h | 2 +- include/lib/egg/math/eggMatrix.h | 12 ++ include/lib/egg/math/eggVector.h | 16 +++ include/lib/egg/prim/eggBitFlag.h | 63 +++++++++ include/lib/egg/prim/eggBuffer.h | 55 ++++++++ include/lib/nw4r/db/db_directPrint.h | 14 ++ include/lib/nw4r/ut/Color.h | 25 ++++ include/lib/nw4r/ut/{utList.h => List.h} | 0 include/lib/rvl/ARC/arc.h | 12 +- include/lib/rvl/DVD/dvdfs.h | 27 ++++ include/lib/rvl/GX/GXAttr.h | 9 +- include/lib/rvl/GX/GXBump.h | 1 - include/lib/rvl/GX/GXDraw.h | 2 +- include/lib/rvl/GX/GXFrameBuf.h | 4 + include/lib/rvl/GX/GXGeometry.h | 2 +- include/lib/rvl/MEM.h | 2 +- include/lib/rvl/macros.h | 6 +- include/m/m_frustum.h | 7 + include/m/m_heap.h | 44 +++--- include/m/m_thread.h | 3 + src/d/a/d_a_base.cpp | 36 ++--- src/lib/egg/core/eggController.cpp | 14 ++ src/lib/egg/core/eggDisplay.cpp | 102 ++++++++++++++ 50 files changed, 1539 insertions(+), 217 deletions(-) create mode 100644 include/lib/egg/core/eggArchive.h create mode 100644 include/lib/egg/core/eggAssertHeap.h create mode 100644 include/lib/egg/core/eggAsyncDisplay.h create mode 100644 include/lib/egg/core/eggColorFader.h create mode 100644 include/lib/egg/core/eggController.h create mode 100644 include/lib/egg/core/eggDecomp.h create mode 100644 include/lib/egg/core/eggDisplay.h create mode 100644 include/lib/egg/core/eggDvdFile.h create mode 100644 include/lib/egg/core/eggDvdRipper.h create mode 100644 include/lib/egg/core/eggExpHeap.h create mode 100644 include/lib/egg/core/eggFader.h create mode 100644 include/lib/egg/core/eggFile.h create mode 100644 include/lib/egg/core/eggGraphicsFifo.h create mode 100644 include/lib/egg/core/eggSystem.h create mode 100644 include/lib/egg/core/eggUnk.h create mode 100644 include/lib/egg/core/eggVideo.h create mode 100644 include/lib/egg/core/eggXfb.h create mode 100644 include/lib/egg/core/eggXfbManager.h create mode 100644 include/lib/egg/math/eggMatrix.h create mode 100644 include/lib/egg/math/eggVector.h create mode 100644 include/lib/egg/prim/eggBitFlag.h create mode 100644 include/lib/egg/prim/eggBuffer.h create mode 100644 include/lib/nw4r/db/db_directPrint.h create mode 100644 include/lib/nw4r/ut/Color.h rename include/lib/nw4r/ut/{utList.h => List.h} (100%) create mode 100644 include/m/m_thread.h create mode 100644 src/lib/egg/core/eggController.cpp create mode 100644 src/lib/egg/core/eggDisplay.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index e1feef66..e1db8c70 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -39,6 +39,112 @@ toBeSorted/unk_flag_stuff.cpp: toBeSorted/bitwise_flag_helper.cpp: .text start:0x800BF200 end:0x800BF264 +lib/rvl/CX/cx.c: + .text start:0x803CEE90 end:0x803D0B20 + +lib/egg/core/eggArchive.cpp: + .text start:0x80493510 end:0x80494254 + .data start:0x8056E820 end:0x8056E82C + .sbss start:0x80576728 end:0x80576730 + .bss start:0x80673AC8 end:0x80673AD8 + +lib/egg/core/eggDvdFile.cpp: + .text start:0x80494260 end:0x80494678 + .data start:0x8056E830 end:0x8056E858 + .sbss start:0x80576730 end:0x80576738 + .bss start:0x80673AD8 end:0x80673AE8 + +lib/egg/core/eggDvdRipper.cpp: + .text start:0x80494680 end:0x80494C80 + .sdata start:0x80574ED0 end:0x80574ED8 + .sbss start:0x80576738 end:0x80576740 + +lib/egg/core/eggStream.cpp: + .text start:0x80494C80 end:0x804952B8 + .data start:0x8056E858 end:0x8056E8D0 + +lib/egg/core/eggAllocator.cpp: + .text start:0x804952D0 end:0x804953F0 + .data start:0x8056E8D0 end:0x8056E8E4 + +lib/egg/core/eggHeap.cpp: + .text start:0x804953F0 end:0x80495AB0 + .data start:0x8056E8E8 end:0x8056E980 + .sbss start:0x80576740 end:0x80576770 + .bss start:0x80673AE8 end:0x80673B10 + +lib/egg/core/eggExpHeap.cpp: + .text start:0x80495AB0 end:0x80495F98 + .data start:0x8056E980 end:0x8056E9D0 + +lib/egg/core/eggFrmHeap.cpp: + .text start:0x80495FA0 end:0x80496398 + .data start:0x8056E9D0 end:0x8056EA00 + +lib/egg/core/eggAssertHeap.cpp: + .text start:0x804963A0 end:0x80496828 + .data start:0x8056EA00 end:0x8056EA30 + +lib/egg/core/eggDisposer.cpp: + .text start:0x80496830 end:0x80496904 + .data start:0x8056EA30 end:0x8056EA3C + +lib/egg/core/eggThread.cpp: + .text start:0x80496910 end:0x80496DD8 + .data start:0x8056EA40 end:0x8056EA58 + .sbss start:0x80576770 end:0x80576778 + .bss start:0x80673B10 end:0x80673B20 + +lib/egg/core/eggUnk.cpp: + .text start:0x80496DE0 end:0x8049716C + .sbss start:0x80576778 end:0x80576780 + +lib/egg/core/eggSystem.cpp: + .text start:0x80497170 end:0x8049752C + .data start:0x8056EA58 end:0x8056EAC8 + .sbss start:0x80576780 end:0x80576788 + +lib/egg/core/eggDisplay.cpp: + .text start:0x80497530 end:0x8049792C + .ctors start:0x804DB988 end:0x804DB98C + .data start:0x8056EAC8 end:0x8056EAE8 + .sbss start:0x80576788 end:0x8057678C + .sdata2 start:0x8057F2F8 end:0x8057F308 + +lib/egg/core/eggColorFader.cpp: + .text start:0x80497930 end:0x80497E3C + .data start:0x8056EAE8 end:0x8056EB0C + .sdata2 start:0x8057F308 end:0x8057F310 rename:.sdata + +lib/egg/core/eggAsyncDisplay.cpp: + .text start:0x80497E40 end:0x80498688 + .data start:0x8056EB60 end:0x8056EB80 + .sbss start:0x80576790 end:0x80576798 + .sdata2 start:0x8057F310 end:0x8057F328 rename:.sdata + +lib/egg/core/eggVideo.cpp: + .text start:0x80498690 end:0x804989D8 + .rodata start:0x804FB7A0 end:0x804FBA20 + .sdata2 start:0x8057F328 end:0x8057F338 rename:.sdata + +lib/egg/core/eggXfb.cpp: + .text start:0x804989E0 end:0x80498AE4 + +lib/egg/core/eggXfbManager.cpp: + .text start:0x80498AF0 end:0x80498E20 + +lib/egg/core/eggGraphicsFifo.cpp: + .text start:0x80498E20 end:0x80498F90 + .sbss start:0x80576798 end:0x805767A8 + +lib/egg/core/eggController.cpp: + .text start:0x80498F90 end:0x8049AB58 + .ctors start:0x804DB98C end:0x804DB990 + .rodata start:0x804FBA20 end:0x804FBA30 + .data start:0x8056EB90 end:0x8056EC88 + .sdata2 start:0x8057F338 end:0x8057F360 rename:.sdata + .bss start:0x80673B40 end:0x80674C00 + Runtime/__init_cpp_exceptions.cpp: .text start:0x804C71A8 end:0x804C7218 .ctors start:0x804DB640 end:0x804DB644 rename:.ctors$10 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c1b30d7b..8b6c1a21 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -136,7 +136,7 @@ _bss_init_info = .init:0x800066FC; // type:object size:0x20 scope:global data:4b @eti_80006BE4 = extabindex:0x80006BE4; // type:object size:0xC scope:local hidden _eti_init_info = extabindex:0x80006BF0; // type:object size:0x20 scope:global fn_80006C20 = .text:0x80006C20; // type:function size:0x4 -fn_80006C30 = .text:0x80006C30; // type:function size:0x90 +strequals = .text:0x80006C30; // type:function size:0x90 fn_80006CC0 = .text:0x80006CC0; // type:function size:0x10 fn_80006CD0 = .text:0x80006CD0; // type:function size:0x10 fn_80006CE0 = .text:0x80006CE0; // type:function size:0x80 @@ -22142,12 +22142,12 @@ SISetSamplingRate = .text:0x803B33B0; // type:function size:0xD4 scope:global fn_803B3490 = .text:0x803B3490; // type:function size:0x8 fn_803B34A0 = .text:0x803B34A0; // type:function size:0x198 fn_803B3640 = .text:0x803B3640; // type:function size:0x80C -fn_803B3E50 = .text:0x803B3E50; // type:function size:0x44 +VISetPreRetraceCallback = .text:0x803B3E50; // type:function size:0x44 fn_803B3EA0 = .text:0x803B3EA0; // type:function size:0x44 fn_803B3EF0 = .text:0x803B3EF0; // type:function size:0x118 fn_803B4010 = .text:0x803B4010; // type:function size:0x200 fn_803B4210 = .text:0x803B4210; // type:function size:0x548 -fn_803B4760 = .text:0x803B4760; // type:function size:0x54 +VIWaitForRetrace = .text:0x803B4760; // type:function size:0x54 fn_803B47C0 = .text:0x803B47C0; // type:function size:0x2A8 fn_803B4A70 = .text:0x803B4A70; // type:function size:0xE0 fn_803B4B50 = .text:0x803B4B50; // type:function size:0x194 @@ -22156,8 +22156,8 @@ fn_803B53C0 = .text:0x803B53C0; // type:function size:0x354 fn_803B5720 = .text:0x803B5720; // type:function size:0x114 fn_803B5840 = .text:0x803B5840; // type:function size:0x6C fn_803B58B0 = .text:0x803B58B0; // type:function size:0x8 -fn_803B58C0 = .text:0x803B58C0; // type:function size:0x78 -fn_803B5940 = .text:0x803B5940; // type:function size:0x8 +VISetBlack = .text:0x803B58C0; // type:function size:0x78 +VIGetRetraceCount = .text:0x803B5940; // type:function size:0x8 fn_803B5950 = .text:0x803B5950; // type:function size:0x9C fn_803B59F0 = .text:0x803B59F0; // type:function size:0x90 VIGetTvFormat = .text:0x803B5A80; // type:function size:0x60 scope:global @@ -24138,7 +24138,7 @@ fn_804334E0 = .text:0x804334E0; // type:function size:0x828 fn_80433D10 = .text:0x80433D10; // type:function size:0x4D8 fn_804341F0 = .text:0x804341F0; // type:function size:0x18 fn_80434210 = .text:0x80434210; // type:function size:0x84 -fn_804342A0 = .text:0x804342A0; // type:function size:0xB4 +DirectPrint_Init__Q24nw4r2dbFv = .text:0x804342A0; // type:function size:0xB4 fn_80434360 = .text:0x80434360; // type:function size:0x28 fn_80434390 = .text:0x80434390; // type:function size:0x190 fn_80434520 = .text:0x80434520; // type:function size:0x34 @@ -26272,14 +26272,14 @@ run__Q23EGG17ConfigurationDataFv = .text:0x804972F0; // type:function size:0x23C PreRetraceCallback = .text:0x80497530; // type:function size:0x40 __ct__Q23EGG7DisplayFUc = .text:0x80497570; // type:function size:0x80 getTickPerFrame__Q23EGG7DisplayFv = .text:0x804975F0; // type:function size:0x4 -beginFrame__Q23EGG7DisplayFb = .text:0x80497600; // type:function size:0xB8 +beginFrame__Q23EGG7DisplayFv = .text:0x80497600; // type:function size:0xB8 beginRender__Q23EGG7DisplayFv = .text:0x804976C0; // type:function size:0x4 endRender__Q23EGG7DisplayFv = .text:0x804976D0; // type:function size:0x4 endFrame__Q23EGG7DisplayFv = .text:0x804976E0; // type:function size:0x4 preVRetrace__Q23EGG7DisplayFv = .text:0x804976F0; // type:function size:0xDC copyEFBtoXFB__Q23EGG7DisplayFv = .text:0x804977D0; // type:function size:0x9C calcFrequency__Q23EGG7DisplayFv = .text:0x80497870; // type:function size:0x84 -__sinit_eggDisplay_cpp = .text:0x80497900; // type:function size:0x2C +__sinit_\eggDisplay_cpp = .text:0x80497900; // type:function size:0x2C scope:global __ct__Q23EGG10ColorFaderFffffQ34nw4r2ut5ColorQ33EGG5Fader7EStatus = .text:0x80497930; // type:function size:0xAC setFrame__Q23EGG10ColorFaderFUs = .text:0x804979E0; // type:function size:0x8 setColor__Q23EGG10ColorFaderFQ34nw4r2ut5Color = .text:0x804979F0; // type:function size:0x1C @@ -37100,7 +37100,7 @@ lbl_8056EA00 = .data:0x8056EA00; // type:object size:0x30 lbl_8056EA30 = .data:0x8056EA30; // type:object size:0x10 lbl_8056EA40 = .data:0x8056EA40; // type:object size:0x18 lbl_8056EA58 = .data:0x8056EA58; // type:object size:0x70 -lbl_8056EAC8 = .data:0x8056EAC8; // type:object size:0x20 +__vt__Q23EGG7Display = .data:0x8056EAC8; // type:object size:0x20 lbl_8056EAE8 = .data:0x8056EAE8; // type:object size:0x38 lbl_8056EB20 = .data:0x8056EB20; // type:object size:0x40 lbl_8056EB60 = .data:0x8056EB60; // type:object size:0x20 @@ -40886,8 +40886,8 @@ lbl_80576764 = .sbss:0x80576764; // type:object size:0x4 data:4byte lbl_80576768 = .sbss:0x80576768; // type:object size:0x8 data:4byte lbl_80576770 = .sbss:0x80576770; // type:object size:0x8 data:4byte lbl_80576778 = .sbss:0x80576778; // type:object size:0x8 data:4byte -lbl_80576780 = .sbss:0x80576780; // type:object size:0x8 data:4byte -lbl_80576788 = .sbss:0x80576788; // type:object size:0x8 data:4byte +mConfigData__Q23EGG10BaseSystem = .sbss:0x80576780; // type:object size:0x4 data:4byte +sTickPeriod__Q23EGG7Display = .sbss:0x80576788; // type:object size:0x4 data:4byte lbl_80576790 = .sbss:0x80576790; // type:object size:0x8 data:4byte lbl_80576798 = .sbss:0x80576798; // type:object size:0x4 data:4byte lbl_8057679C = .sbss:0x8057679C; // type:object size:0xC @@ -41148,7 +41148,7 @@ lbl_80576C74 = .sdata2:0x80576C74; // type:object size:0x4 data:float lbl_80576C78 = .sdata2:0x80576C78; // type:object size:0x4 data:float lbl_80576C7C = .sdata2:0x80576C7C; // type:object size:0x4 data:float lbl_80576C80 = .sdata2:0x80576C80; // type:object size:0x8 data:double -lbl_80576C88 = .sdata2:0x80576C88; // type:object size:0x4 scope:local data:float +lbl_80576C88 = .sdata2:0x80576C88; // type:object size:0x4 data:float lbl_80576C8C = .sdata2:0x80576C8C; // type:object size:0x4 data:float lbl_80576C90 = .sdata2:0x80576C90; // type:object size:0x4 data:float lbl_80576C94 = .sdata2:0x80576C94; // type:object size:0x4 data:float @@ -47125,7 +47125,8 @@ lbl_8057E9B0 = .sdata2:0x8057E9B0; // type:object size:0x4 data:4byte lbl_8057E9B4 = .sdata2:0x8057E9B4; // type:object size:0x2 data:2byte lbl_8057E9B6 = .sdata2:0x8057E9B6; // type:object size:0x1 data:byte lbl_8057E9B8 = .sdata2:0x8057E9B8; // type:object size:0x4 data:float -lbl_8057E9BC = .sdata2:0x8057E9BC; // type:object size:0x8 data:float +lbl_8057E9BC = .sdata2:0x8057E9BC; // type:object size:0x4 data:float +lbl_8057E9C0 = .sdata2:0x8057E9C0; // type:object size:0x4 data:float lbl_8057E9C4 = .sdata2:0x8057E9C4; // type:object size:0x4 data:float lbl_8057E9C8 = .sdata2:0x8057E9C8; // type:object size:0x4 data:float lbl_8057E9CC = .sdata2:0x8057E9CC; // type:object size:0x4 data:float @@ -48210,8 +48211,8 @@ lbl_805A7730 = .bss:0x805A7730; // type:object size:0xC4 data:byte lbl_805A77F4 = .bss:0x805A77F4; // type:object size:0xC4 data:byte lbl_805A78B8 = .bss:0x805A78B8; // type:object size:0xC lbl_805A78C4 = .bss:0x805A78C4; // type:object size:0xC data:4byte -sSceneFlags__16SceneflagManager = .bss:0x805A78D0; // type:object size:0x10 -sZoneFlags__16SceneflagManager = .bss:0x805A78E0; // type:object size:0x1F8 +lbl_805A78D0 = .bss:0x805A78D0; // type:object size:0x10 +lbl_805A78E0 = .bss:0x805A78E0; // type:object size:0x1F8 lbl_805A7AD8 = .bss:0x805A7AD8; // type:object size:0x2000 lbl_805A9AD8 = .bss:0x805A9AD8; // type:object size:0x100 lbl_805A9BD8 = .bss:0x805A9BD8; // type:object size:0x80 @@ -49025,10 +49026,7 @@ lbl_805B83A0 = .bss:0x805B83A0; // type:object size:0x100 lbl_805B84A0 = .bss:0x805B84A0; // type:object size:0x10 data:4byte lbl_805B84B0 = .bss:0x805B84B0; // type:object size:0xC lbl_805B84BC = .bss:0x805B84BC; // type:object size:0xC -m_tmpCtProfName__7fBase_c = .bss:0x805B84C8; // type:object size:0x4 data:2byte -m_tmpCtConnectParent__7fBase_c = .bss:0x805B84CC; // type:object size:0x4 data:4byte -m_tmpCtParam__7fBase_c = .bss:0x805B84D0; // type:object size:0x4 data:4byte -m_tmpCtGroupType__7fBase_c = .bss:0x805B84D4; // type:object size:0x4 data:byte +lbl_805B84C8 = .bss:0x805B84C8; // type:object size:0x10 data:2byte lbl_805B84D8 = .bss:0x805B84D8; // type:object size:0x10 data:4byte lbl_805B84E8 = .bss:0x805B84E8; // type:object size:0x14 data:4byte lbl_805B84FC = .bss:0x805B84FC; // type:object size:0x14 data:4byte diff --git a/configure.py b/configure.py index 278cb6b4..e481b3aa 100644 --- a/configure.py +++ b/configure.py @@ -19,30 +19,50 @@ LIBS = [ ["toBeSorted/save_manager.cpp", False], ], }, + # { + # "lib": "RVL", + # "mw_version": "Wii/1.7", # FIXME: Change Compiler+flags Probably + # "cflags": "-proc gekko -Cpp_exceptions off -RTTI off -O4,p -fp hard, -inline noauto, -enum int, -str reuse -I- -i include -i include/lib", + # "host": False, + # "objects": [ + # ["lib/rvl/CX/cx.c", False], + # ], + # }, + # { + # "lib": "NW4R", + # "mw_version": "Wii/1.7", # FIXME: Change Compiler+flags Probably + # "cflags": "-proc gekko -Cpp_exceptions off -RTTI off -O4,p -fp hard, -inline noauto, -enum int, -str reuse -I- -i include -i include/lib", + # "host": False, + # "objects": [ + # ], + # }, { - "lib": "RVL", - "mw_version": "Wii/1.7", # FIXME: Change Compiler+flags Probably - "cflags": "-proc gekko -Cpp_exceptions off -RTTI off -O4,p -fp hard, -inline noauto, -enum int, -str reuse -I- -i include -i include/lib", - "host": False, - "objects": [ - ["lib/rvl/CX/cx.c", False], - ], - }, - { - "lib": "nw4r", - "mw_version": "Wii/1.7", # FIXME: Change Compiler+flags Probably - "cflags": "-proc gekko -Cpp_exceptions off -RTTI off -O4,p -fp hard, -inline noauto, -enum int, -str reuse -I- -i include -i include/lib", - "host": False, - "objects": [ - ], - }, - { - "lib": "egg", + "lib": "EGG", "mw_version": "Wii/1.7", # FIXME: Change Compiler+flags Probably "cflags": "-proc gekko -Cpp_exceptions off -RTTI off -O4,p -fp hard, -inline noauto, -enum int, -str reuse -I- -i include -i include/lib", "host": False, "objects": [ + ["lib/egg/core/eggArchive.cpp", False], + ["lib/egg/core/eggDvdFile.cpp", False], + ["lib/egg/core/eggDvdRipper.cpp", False], ["lib/egg/core/eggStream.cpp", False], + ["lib/egg/core/eggAllocator.cpp", False], + ["lib/egg/core/eggHeap.cpp", False], + ["lib/egg/core/eggExpHeap.cpp", False], + ["lib/egg/core/eggFrmHeap.cpp", False], + ["lib/egg/core/eggAssertHeap.cpp", False], + ["lib/egg/core/eggDisposer.cpp", False], + ["lib/egg/core/eggThread.cpp", False], + ["lib/egg/core/eggUnk.cpp", False], + ["lib/egg/core/eggSystem.cpp", False], + ["lib/egg/core/eggDisplay.cpp", True], + ["lib/egg/core/eggColorFader.cpp", False], + ["lib/egg/core/eggAsyncDisplay.cpp", False], + ["lib/egg/core/eggVideo.cpp", False], + ["lib/egg/core/eggXfb.cpp", False], + ["lib/egg/core/eggXfbManager.cpp", False], + ["lib/egg/core/eggGraphicsFifo.cpp", False], + ["lib/egg/core/eggController.cpp", False], ], } ] diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index 229fbdba..471ffb11 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -26,7 +26,7 @@ public: /* 0x68 */ mHeapAllocator_c heap_allocator; /* 0x84 */ ObjInfo* obj_info; /* 0x88 */ void* sound_info_tail; - /* 0x8c */ SoundInfo* sound_info_next; + /* 0x8c */ void* sound_info_next; /* 0x90 */ int count; /* 0x94 */ void* obj_sound; /* 0x9C */ mVec3_c* obj_pos; @@ -45,7 +45,7 @@ public: /* 0xE8 */ u32 field_0xe8; /* 0xEC */ u8 roomid; /* 0xED */ u8 actor_subtype; - /* 0xF0 */ u32 field_0xF0; + /* 0xF0 */ u32 JStudio_actor; /* 0xF4 */ char someStr[4]; /* 0xF8 */ char field_0xf8[0xfc - 0xf8]; protected: diff --git a/include/lib/egg/core/eggAllocator.h b/include/lib/egg/core/eggAllocator.h index 9c1134af..3db4db8b 100644 --- a/include/lib/egg/core/eggAllocator.h +++ b/include/lib/egg/core/eggAllocator.h @@ -1,26 +1,23 @@ #pragma once +#include #include #include -// Ghidra: Allocator -// size: 0x1C -// .text: [0x804952d0, 0x804953f0] -// .data: [0x8056e8d0, 0x8056e8e8] # Allocator vtable -// sdata2: [0x8057f2f0, 0x8057f2f8] # MEMAllocator func table - +// /* 80495310 */ MEMInitAllocatorFor_Heap(MEMAllocator* alloc, s32 align, void* heap); +// /* 804952f0 */ MEM_AllocFor_Heap(MEMAllocator* alloc, void* block); +// /* 804952d0 */ MEM_AllocFor_Heap(MEMAllocator* alloc, u32 size, s32 align); namespace EGG { class Heap; class Allocator : public MEMAllocator { public: - Allocator(Heap* heap, s32 align); - // vtable at 0x10 - /* 0x08 */ virtual ~Allocator(); - /* 0x0C */ virtual void* alloc(u32 size); - /* 0x10 */ virtual void free(void* block); + /* 80495330 */ Allocator(Heap* heap, s32 align); + public: + /* vt 0x08 | 80495380 */ virtual ~Allocator(); + /* vt 0x0C | 804953c0 */ virtual void* alloc(u32 size); + /* vt 0x10 | 804953e0 */ virtual void free(void* block); inline MEMAllocator* getHandle() { return static_cast(this); } - private: /* 0x14 */ Heap* mHeap; /* 0x18 */ s32 align; }; diff --git a/include/lib/egg/core/eggArchive.h b/include/lib/egg/core/eggArchive.h new file mode 100644 index 00000000..0e5d87c5 --- /dev/null +++ b/include/lib/egg/core/eggArchive.h @@ -0,0 +1,60 @@ +#pragma once + +#include +#include +#include +#include + +typedef void (*FileCallbackFunc)(void*, void*, const ARCDirEntry*, const char*); + +namespace EGG +{ +// Functions that need a proper home: +/* 80493510 */ void readNANDFile(NANDFileInfo* info, void* buf, u32 len, s32 offs); + +class Archive : public Disposer { +public: + struct FileInfo { + u32 mArcStartOffset; + u32 mArcLength; + }; + enum MountType { // enum name is correct, values arent official + NOT_LOADED, LOADED_CAN_FAST_READ, NAND_File, + }; + /* 0x10 */ MountType mMountType; + /* 0x14 */ u32 mRefCount; + /* 0x18 */ ARCHandle mHandle; + /* 0x34 */ s32 mDvdEntryNum; // gets put into first param of DVDFastOpen + /* 0x38 */ s32 mNandFile; // pointer to NANDFileInfo (was allocated) + /* 0x3C */ nw4r::ut::Node mLink; +public: + /* 804935f0 */ virtual ~Archive(); +public: + /* 80493580 */ Archive(); + /* 80493660 */ void initHandle(void* data, MountType mountType); + /* 804936d0 */ static Archive* findArchive(void* data); + /* 80493760 */ static Archive* findArchive(NANDFileInfo* file); + /* 804937f0 */ static void appendList(Archive*); // prob private + /* 80493850 */ static void removeList(Archive*); + /* 80493860 */ static Archive* mount(void* data, Heap* heap, s32 align); + /* 80493950 */ static Archive* mountFST(void* data, Heap* heap, s32 align); + /* 80493a40 */ static Archive* mountNandFile(NANDFileInfo* , Heap* heap, s32 align); + /* 80493ac0 */ static Archive* loadFST(const char* fileName, Heap* heap, s32 align); + /* 80493b80 */ void unmount(); + /* 80493c20 */ u32 getFile(const char* name, FileInfo* out); + /* 80493cf0 */ long convertPathToEntryID(const char* path); + /* 80493d00 */ void* getFileFast(long entryId, FileInfo* fileinfo); + /* 80493dc0 */ void* getFileFast(long entryId, Heap* heap, s32 align); + /* 80493f30 */ s32 countFile(); + /* 804940c0 */ void searchInside(FileCallbackFunc, void*); + /* 80494140 */ static void* loadFromNAND(NANDFileInfo* fileInfo, Heap* heap, s32 align); + +public: + /* 80576728 */ static bool sIsArchiveListInitialized; + /* 80673ac8 */ static nw4r::ut::List sArchiveList; +}; +/* 80493f10 */ void countFileCallbackFunc(void*, void*, const ARCDirEntry*, const char*); +/* 80493f70 */ void searchInsideWithPath( + Archive* arc, ARCHandle* handle, FileCallbackFunc, void*, char* outPath, u32 +); +} // namespace EGG diff --git a/include/lib/egg/core/eggAssertHeap.h b/include/lib/egg/core/eggAssertHeap.h new file mode 100644 index 00000000..0ef9ebb2 --- /dev/null +++ b/include/lib/egg/core/eggAssertHeap.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +namespace EGG { + +class AssertHeap : public Heap { +public: + // vtable at 0x0 | 8056ea00 + /* vt 0x08 | 804963e0 */ virtual ~AssertHeap(); + /* vt 0x0C | 80496820 */ virtual eHeapKind getHeapKind() const; + /* vt 0x14 | 804966b0 */ virtual void* alloc(u32 size, s32 align); + /* vt 0x18 | 80496710 */ virtual void free(void* block); + /* vt 0x1C | 80496620 */ virtual void destroy(); + /* vt 0x20 | 80496760 */ virtual u32 resizeForMBlock(void* block, u32 size); + /* vt 0x24 | 80496770 */ virtual u32 getTotalFreeSize(); + /* vt 0x28 | 80496780 */ virtual u32 getAllocatableSize(s32 align); + /* vt 0x2C | 80496790 */ virtual u32 adjust(); +public: + /* 804963a0 */ AssertHeap(MEMiHeapHead* heapHead); + /* 80496460 */ static AssertHeap* create(void* block, u32 size, u16 attr); + /* 80496530 */ static AssertHeap* create(u32 size, Heap* heap); + /* 80496810 */ static u32 getSize(); // returns 0x7C +}; + +} // namespace EGG \ No newline at end of file diff --git a/include/lib/egg/core/eggAsyncDisplay.h b/include/lib/egg/core/eggAsyncDisplay.h new file mode 100644 index 00000000..593092af --- /dev/null +++ b/include/lib/egg/core/eggAsyncDisplay.h @@ -0,0 +1,48 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +class AsyncDisplay : public Display { +public: + // vtable at 0x04 | 8056eb60 + /* vt 0x08 | 80497f20 */ virtual void beginFrame(); + /* vt 0x10 | 804980e0 */ virtual void endRender(); + /* vt 0x14 | 804980c0 */ virtual void endFrame(); + /* vt 0x18 | 804982d0 */ virtual u32 getTickPerFrame(); + /* vt 0x1C | 80498100 */ virtual void preVRetrace(); +public: + /* 0x2C */ char field_0x2C[0x60-0x2C]; + /* 0x60 */ OSThreadQueue mThreadQueue; + /* 0x68 */ OSMessageQueue mMesgQueue; + /* 0x88 */ OSMessage mMesg; + /* 0x8C */ char field_0x8C[0x98-0x8C]; + /* 0x98 */ s32 field_0x98; + /* 0x9C */ f32 field_0x9C; + /* 0xA0 */ f32 field_0xA0; + /* 0xA4 */ s32 field_0xA4; + /* 0xA8 */ s32 field_0xA8; + /* 0xAC */ s32 field_0xAC; + /* 0xB0 */ u32 field_0xB0; + /* 0xB4 */ s32 field_0xB4; + /* 0xB8 */ u32 field_0xB8; + /* 0xBC */ u32 field_0xBC; +public: + /* 80497e40 */ AsyncDisplay(u8 maxRetrace); + /* 80497ec0 */ void calcS(); + /* 80498260 */ void clearEFB(); + /* 804982f0 */ void clearEFB(u16, u16, u16, u16, u16, u16, nw4r::ut::Color); +}; + +} // namespace EGG + +#ifdef __cplusplus +extern "C" { +#endif + /* 80576790 */ static EGG::AsyncDisplay* spSelector; +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/include/lib/egg/core/eggColorFader.h b/include/lib/egg/core/eggColorFader.h new file mode 100644 index 00000000..12abf94a --- /dev/null +++ b/include/lib/egg/core/eggColorFader.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include +#include + +namespace EGG +{ + +class ColorFader : public Fader { +public: + // vtable at 0x00 | 8056eae8 + /* vt 0x08 | 80497a10 */ virtual void setStatus(EStatus); + /* vt 0x0C | 00000000 */ virtual EStatus getStatus() const; + /* vt 0x10 | 80497a50 */ virtual bool fadeIn(); + /* vt 0x14 | 80497a80 */ virtual bool fadeOut(); + /* vt 0x18 | 80497ab0 */ virtual bool calc(); + /* vt 0x1C | 80497ba0 */ virtual bool draw(); + /* vt 0x1C | 80131b70 */ virtual ~ColorFader(); +public: + /* 0x04 */ EStatus mStatus; + /* 0x08 */ TBitFlag mFlags; + /* 0x0A */ u16 mFrame; + /* 0x0C */ u16 mFadeTimer; + /* 0x0E */ u16 field_0x0E; + /* 0x10 */ nw4r::ut::Color mColor; + /* 0x14 */ f32 mStartX; + /* 0x18 */ f32 mStartY; + /* 0x1C */ f32 mEndX; + /* 0x20 */ f32 mEndY; +public: + /* 80497930 */ ColorFader( + f32 startX, f32 startY, f32 lengthX, f32 lengthY, + nw4r::ut::Color color,EStatus status); + /* 804979e0 */ void setFrame(u16 frame); + /* 804979f0 */ void setColor(nw4r::ut::Color); +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggController.h b/include/lib/egg/core/eggController.h new file mode 100644 index 00000000..a6b00c14 --- /dev/null +++ b/include/lib/egg/core/eggController.h @@ -0,0 +1,170 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include + +namespace EGG +{ + +class ControllerRumbleMgr; + + +// To Be Filled out +enum eCoreDevType { +}; + +class CoreStatus { +public: + /* 0x00 */ u8 field_0x00[0xF0]; +public: + /* 80498f90 */ void init(); + /* 80498fa0 */ u32 getFSStickButton() const; +}; + +class CoreController { +public: + // vtable 0x000 | 8056ec50 + /* vt 0x08 | 80064920 */ virtual void setPosParam(f32, f32); + /* vt 0x0C | 8049a940 */ virtual void setHoriParam(f32, f32); + /* vt 0x10 | 8049a930 */ virtual void setDistParam(f32, f32); + /* vt 0x14 | 8049a920 */ virtual void setAccParam(f32, f32); + /* vt 0x18 | 80059820 */ virtual bool isPressed(u32 mask); + /* vt 0x1C | 80059a60 */ virtual bool isAnyPressed(u32 mask); + /* vt 0x20 | 80014e30 */ virtual bool isTriggered(u32 mask); + /* vt 0x24 | 800599e0 */ virtual bool isReleased(); + /* vt 0x28 | 80059840 */ virtual bool isAllPressed(); + /* vt 0x2C | 80059a80 */ virtual bool isNotPressed(); + /* vt 0x30 | 80499660 */ virtual void beginFrame(void* padStatus); // Really needs to be PADStatus + /* vt 0x34 | 80499a60 */ virtual void endFrame(); +public: + /* 0x004 */ s32 mChannelID; + /* 0x008 */ u32 mButtonHeld; // these fields may need a slight amount of work + /* 0x00C */ u32 mButtonTriggered; + /* 0x010 */ u32 mButtonReleased; + /* 0x014 */ u32 field_0x14; + /* 0x018 */ CoreStatus coreStatus[16]; + /* 0xf18 */ int mKPADResult; + /* 0xf1c */ TBitFlag mFlag; + /* 0xf20 */ Vector3f mAccel; + /* 0xf2c */ Vector2f mDpdPos; + /* 0xf34 */ u32 field_0xf28; + /* 0xf38 */ u32 mMotorPattern; + /* 0xf3c */ bool mEnableMotor; + /* 0xf40 */ s32 mMotorFrameDuration; + /* 0xf44 */ u8 mMotorPatternLength; + /* 0xf45 */ u8 mMotorPatternPos; + /* 0xf48 */ ControllerRumbleMgr* mRumbleMgr; + /* 0xf4c */ Matrix34f mPostureMatrix; + /* 0xf7c */ Matrix34f mPostureMatrixPrev; + /* 0xfac */ TBitFlag mAccelFlags; + /* 0xfb0 */ s32 mMaxAccelFrameTime; + /* 0xfb4 */ s32 mAccelFrameTimeX; + /* 0xfb8 */ s32 mAccelFrameTimeY; + /* 0xfbc */ s32 mAccelFrameTimeZ; + /* 0xfc0 */ f32 mMaxAccelDiff; + /* 0xfc4 */ Vector3f mPrevAccel; +public: + /* 80499050 */ CoreController(); + /* 804990b0 */ void sceneReset(); + /* 80499170 */ Vector2f getDpdRawPos(); + /* 80499190 */ s32 getDpdDistance(); + /* 804991a0 */ void startMotor(); + /* 804991b0 */ void stopMotor(); + /* 804991c0 */ void createRumberMgr(u8); + /* 80499220 */ void startPatternRumble(const char*, int, bool); + /* 80499240 */ void stopRumbleMgr(); + /* 80499260 */ CoreStatus* getCoreStatus(s32 idx); + /* 8056ebf8 */ void calc_posture_matrix(Matrix34f& mat, bool); + /* 80499ac0 */ f32 getFreeStickX(); + /* 80499ae0 */ f32 getFreeStickY(); +}; + +class NullController : public CoreController { +public: + // idk this has NO effect on anything + u8 unk[0x80674c00-0x80674b10]; +}; + +class ControllerRumbleUnit { +public: + // 0x00 vtable | 8056ebb4 + /* vt 0x08 | 8049a8e0 */ virtual ~ControllerRumbleUnit(); +public: + /* 0x04 */ char* mPattern; + /* 0x08 */ char* mPatternPos; + /* 0x0C */ s32 mTimer; // guess + /* 0x10 */ f32 mRampUp; // guess + /* 0x14 */ f32 mIntesity; // guess + /* 0x18 */ TBitFlag mFlag; + /* 0x1C */ nw4r::ut::Node mNode; + /* 0x24 */ u32 field_0x24; // could just be part of the node (List) +public: + /* 8049a3b0 */ void init(); + /* 8049a3e0 */ void startPattern(const char* patter, int); + /* 8049a440 */ f32 calc(); +}; + +class ControllerRumbleMgr { +public: + // 0x00 vtable | 8056eba8 + /* vt 0x08 | 8049a8a0 */ virtual ~ControllerRumbleMgr(); +public: + /* 0x04 */ nw4r::ut::List mActiveUnitList; + /* 0x10 */ nw4r::ut::List mInactiveUnitList; + /* 0x1C */ CoreController* mController; +public: + /* 8049a530 */ ControllerRumbleMgr(); + /* 8049a590 */ void createUnit(u8 numUnits, CoreController* controller); + /* 8049a620 */ void stop(); + /* 8049a690 */ void calc(); + /* 8049a7a0 */ void startPattern(const char* pattern, int, bool); + /* 8049a7f0 */ ControllerRumbleUnit* getUnitFromList(bool bGrabActive); +}; +class CoreControllerMgr { +public: + struct T__Disposer { + Disposer mDisposer; + /* vt 0x08 | 80499b00 */ virtual ~T__Disposer(); + /* 805767ac */ static T__Disposer* sStaticDisposer; + }; + // Disposer Vtable: 8056ec40 + /* 0x0000 */ T__Disposer mDisposer; // for the static T__Disposer +public: + // 0x0010 vtable | 8056ebf8 + /* vt 0x08 | 8049a130 */ void beginFrame(); + /* vt 0x0C | 8049a1e0 */ void endFrame(); +public: + /* 0x0014 */ TBuffer mControllers; + /* 0x0020 */ u8 field_0x20[0x10a4 - 0x0020]; + /* 0x10A4 */ TBuffer mDevTypes; + /* 0x10b0 */ u8 field_0x10B0[0x10e0 - 0x10b0]; +public: + /* 80499b80 */ static void createInstance(); + /* 80499bd0 */ static void deleteInstance(); + /* 80499cd0 */ void connectCallback(s32, s32); + /* 80499d10 */ CoreControllerMgr(); +public: + /* 805767a8 */ static CoreControllerMgr* sInstance; + /* 805767b0 */ static CoreController* (*sCoreControllerFactory)(); + /* 805767b4 */ static void (*sConnectCallback)(s32, s32); + /* 805767b8 */ static bool sUnk; + // /* 805767bc */ static sAllocator; // defined in cpp file + + +// Other Stuff thats autogen (buffers/sinit/etc) +// /* 8049a950 */ void TBuffer::allocate(int, int); +// /* 8049a9a0 */ void TBuffer::allocate(int, Heap*, int); +// /* 8049aa20 */ void TBuffer::onAllocate(Heap*); +// /* 8049aa30 */ void TBuffer::allocate(int, int); +// /* 8049aa80 */ void TBuffer::allocate(int, Heap*, int); +// /* 8049ab00 */ void TBuffer::onAllocate(Heap*); +// /* 8049ab10 */ void sinit(); // NULL CONTROLLER + +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggDecomp.h b/include/lib/egg/core/eggDecomp.h new file mode 100644 index 00000000..1bca30c4 --- /dev/null +++ b/include/lib/egg/core/eggDecomp.h @@ -0,0 +1,76 @@ +#pragma once + +#include +#include + +// NOTE: I put StreamDecomp stuff here. im unsure of the correct place + +namespace EGG +{ +class StreamDecomp { +public: + /* vt 0x08 */ virtual bool init(void* dest, u32 maxCompressedSize); + /* vt 0x0C */ virtual bool decomp(const void* src, u32 len); + /* vt 0x10 */ virtual u32 getHeaderSize(); + /* vt 0x14 */ virtual u32 getUncompressedSize(const void* src); +public: + /* 0x04 */ void* dest; + /* 0x08 */ u32 maxCompressedSize; +}; + +class StreamDecompLZ : public StreamDecomp { +public: + /* vt 0x08 | 80494c80 */ virtual bool init(void* dest, u32 maxCompressedSize); + /* vt 0x0C | 80494cb0 */ virtual bool decomp(const void* src, u32 len); + /* vt 0x10 | 804952c0 */ virtual u32 getHeaderSize(); + /* vt 0x14 | 804952b0 */ virtual u32 getUncompressedSize(const void* src); +public: + /* 0x0C */ CXUncompContextLZ context; +}; +class StreamDecompRL : public StreamDecomp { +public: + /* vt 0x08 | 80494ce0 */ virtual bool init(void* dest, u32 maxCompressedSize); + /* vt 0x0C | 80494d10 */ virtual bool decomp(const void* src, u32 len); + /* vt 0x10 | 804952a0 */ virtual u32 getHeaderSize(); + /* vt 0x14 | 80495290 */ virtual u32 getUncompressedSize(const void* src); +public: + /* 0x0C */ CXUncompContextRL context; +}; + +class StreamDecompLH : public StreamDecomp { +public: + /* vt 0x08 | 80494d40 */ virtual bool init(void* dest, u32 maxCompressedSize); + /* vt 0x0C | 80494d70 */ virtual bool decomp(const void* src, u32 len); + /* vt 0x10 | 80495280 */ virtual u32 getHeaderSize(); + /* vt 0x14 | 80495270 */ virtual u32 getUncompressedSize(const void* src); +public: + /* 0x0C */ CXUncompContextLH context; +}; +class StreamDecompLRC : public StreamDecomp { +public: + /* vt 0x08 | 80494da0 */ virtual bool init(void* dest, u32 maxCompressedSize); + /* vt 0x0C | 80494dd0 */ virtual bool decomp(const void* src, u32 len); + /* vt 0x10 | 80495260 */ virtual u32 getHeaderSize(); + /* vt 0x14 | 80495250 */ virtual u32 getUncompressedSize(const void* src); +public: + /* 0x0C */ CXUncompContextLRC context; +}; +class StreamDecompSZS : public StreamDecomp { +public: + /* vt 0x08 | 804951d0 */ virtual bool init(void* dest, u32 maxCompressedSize); + /* vt 0x0C | 80495200 */ virtual bool decomp(const void* src, u32 len); + /* vt 0x10 | 80495240 */ virtual u32 getHeaderSize(); + /* vt 0x14 | 80495230 */ virtual u32 getUncompressedSize(const void* src); +private: + // NON-OFFICIAL + struct SZSCompContext { + u8 _[0x18]; + /* 80494e00 */ static u32 getUncompressedSize(const void* src); + /* 80494e30 */ void init(u32 maxCompSize); + /* 80494e60 */ static int readSzsHeader(/* unk params*/); + /* 80494f60 */ void* decomp(const void* src, u32 len); + }; +public: + /* 0x0C */ SZSCompContext context; +}; +} // namespace EGG diff --git a/include/lib/egg/core/eggDisplay.h b/include/lib/egg/core/eggDisplay.h new file mode 100644 index 00000000..c6ac4a23 --- /dev/null +++ b/include/lib/egg/core/eggDisplay.h @@ -0,0 +1,50 @@ +#pragma once + + +#include +#include +#include +#include +#include // for BaseSystem config +#include + + +/* 80497530 */ // void PreRetraceCallback(void); + +namespace EGG +{ + +class Display { +public: + enum EFlagBits { mFlag_SetClear, mFlag_WaitForRetrace }; + /* 0x00*/ TBitFlag mFlag; +public: + // vtable at 0x04 | 8056eac8 + /* vt 0x08 | 80497600 */ virtual void beginFrame(); + /* vt 0x0C | 804976c0 */ virtual void beginRender(); + /* vt 0x10 | 804976d0 */ virtual void endRender(); + /* vt 0x14 | 804976e0 */ virtual void endFrame(); + /* vt 0x18 | 804975f0 */ virtual u32 getTickPerFrame(); + /* vt 0x1C | 804976f0 */ virtual void preVRetrace(); +public: + /* 0x08 */ u8 mMaxRetraces; + enum EScreenStateBits { mScreenStateFlag_SetBlack }; + /* 0x09 */ TBitFlag mScreenStateFlag; + /* 0x0C */ u32 mRetraceCount; + /* 0x10 */ u32 mFrameCount; + /* 0x14 */ nw4r::ut::Color mClearColor; + /* 0x18 */ u32 mClearZ; + /* 0x1C */ s32 mBeginTick; + /* 0x20 */ s32 mLastTick; // new + /* 0x24 */ s32 mDeltaTick; + /* 0x28 */ f32 mFrequency; +public: + /* 80497570 */ Display(u8 maxRetrace); + /* 804977d0 */ void copyEFBtoXFB(); + /* 80497870 */ void calcFrequency(); + /* inline */ void setBlack(bool b) {} +public: + /* 80497900 */ static u32 sTickPeriod; +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggDisposer.h b/include/lib/egg/core/eggDisposer.h index f33e2609..1c9409dd 100644 --- a/include/lib/egg/core/eggDisposer.h +++ b/include/lib/egg/core/eggDisposer.h @@ -2,32 +2,33 @@ // This file was adapted from https://github.com/riidefi/mkw/blob/master/source/egg/core/eggDisposer.hpp -#include +#include #include namespace EGG { - class Heap; - - // Ghidra: EggBase - // size: 0x8 - // .text: [0x80496830, 0x80496910] - class Disposer : private NonCopyable { - friend class Heap; - protected: - virtual ~Disposer(); - Disposer(); - public: - enum eLifetime { - LIFETIME_UNMANAGED, - LIFETIME_HEAP_GC - }; - inline eLifetime getLifetime() const { - return mContainHeap != nullptr ? LIFETIME_HEAP_GC : LIFETIME_UNMANAGED; - } - - private: - Heap* mContainHeap; - nw4r::ut::Node mList; +class Heap; +class Disposer : private NonCopyable { + friend class Heap; +protected: + /* vt 0x08 | 80496890 */ virtual ~Disposer(); + /* 80496830 */ Disposer(); +public: + enum eLifetime { + LIFETIME_UNMANAGED, + LIFETIME_HEAP_GC }; + inline eLifetime getLifetime() const { + return mContainHeap != nullptr ? LIFETIME_HEAP_GC : LIFETIME_UNMANAGED; + } + +private: + /* 0x04 */ Heap* mContainHeap; + /* 0x08 */ nw4r::ut::Node mList; +}; + +// TODO: Add singleton define for the T__Disposer stuff. +// see https://github.com/open-ead/sead/blob/master/include/heap/seadDisposer.h +// for reference + }; \ No newline at end of file diff --git a/include/lib/egg/core/eggDvdFile.h b/include/lib/egg/core/eggDvdFile.h new file mode 100644 index 00000000..12c80e46 --- /dev/null +++ b/include/lib/egg/core/eggDvdFile.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace EGG +{ + +class DvdFile : public File { +public: + struct FileInfo : public DVDFileInfo { + DvdFile* dvdFile; + }; +public: + /* 0x08 */ OSMutex mMutex; + /* 0x20 */ OSMutex mMutexUnused; + /* 0x38 */ u32 field_0x38; + /* 0x3c */ FileInfo mFileInfo; + /* 0x7c */ OSMessageQueue mMsgQueueUnsued; + /* 0x9c */ OSMessage mMsgUnused; + /* 0xa0 */ OSMessageQueue mMsgQueue; + /* 0xc0 */ OSMessage mMsg; + /* 0xc4 */ OSThread* mThread; + /* 0xc8 */ nw4r::ut::Node mNode; +public: + /* vt 0x08 | 804942f0 */ virtual ~DvdFile(); + /* vt 0x0C | 80494450 */ virtual bool open(const char* path); + /* vt 0x10 | 804944b0 */ virtual void close(); + /* vt 0x14 | 80494510 */ virtual s32 readData(void* buffer, s32 length, s32 offset); + /* vt 0x18 | 804945e0 */ virtual s32 writeData(void* buffer, s32 length, s32 offset); + /* vt 0x1C | 80494670 */ virtual u32 getFileSize(); + /* vt 0x20 | 804943d0 */ virtual bool open(s32 entryNum); + /* vt 0x24 | 804944a0 */ virtual bool open(const char* path, void*); +public: + /* 804942a0 */ DvdFile(); + /* 80494360 */ void initiate(); + /* 804945f0 */ s32 sync(); + /* 80494650 */ static void doneProcess(s32 result, DVDFileInfo* fileInfo); +public: + /* 80576730 */ static bool sIsInitialized; + /* 80673ad8 */ static nw4r::ut::List sDvdList; +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggDvdRipper.h b/include/lib/egg/core/eggDvdRipper.h new file mode 100644 index 00000000..93395041 --- /dev/null +++ b/include/lib/egg/core/eggDvdRipper.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include +#include + +namespace EGG +{ + +class DvdRipper { +public: + enum EAllocDirection { + ALLOC_CIR_PAD, + ALLOC_DIR_TOP, + ALLOC_DIR_BOTTOM + }; +public: + /* 80494680 */ static u8* loadToMainRAM( s32 entryNum, + u8* dst, Heap* heap, EAllocDirection allocDir, + u32 offset, u32* amountRead, u32* fileSize + ); + /* 80494730 */ static u8* loadToMainRAM( const char* path, + u8* dst, Heap* heap, EAllocDirection allocDir, + u32 offset, u32* amountRead, u32* fileSize + ); + /* 804947e0 */ static u8* loadToMainRAM( DvdFile* file, + u8* dst, Heap* heap, EAllocDirection allocDir, + u32 offset, u32* amountRead, u32* fileSize + ); + /* 804949b0 */ static void* loadToMainRAMDecomp( DvdFile* file, + StreamDecomp* decompressor, u8* dst, Heap* heap, + EAllocDirection allocDir, u32 offset, s32 size, + u32 maxChunkSize, u32* amountRead, u32* fileSize + ); +public: + /* 80574ed0 */ static bool sErrorRetry; + /* */ // static sCallback; +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggExpHeap.h b/include/lib/egg/core/eggExpHeap.h new file mode 100644 index 00000000..06411d13 --- /dev/null +++ b/include/lib/egg/core/eggExpHeap.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +class ExpHeap : public Heap { +public: + // vtable at 0x0 | 8056e980 + /* vt 0x08 | 80495af0 */ virtual ~ExpHeap(); + /* vt 0x0C | 80495f90 */ virtual eHeapKind getHeapKind() const; + /* vt 0x14 | 80495d90 */ virtual void* alloc(u32 size, s32 align); + /* vt 0x18 | 80495e50 */ virtual void free(void* block); + /* vt 0x1C | 80495d00 */ virtual void destroy(); + /* vt 0x20 | 80495ec0 */ virtual u32 resizeForMBlock(void* block, u32 size); + /* vt 0x24 | 80495ed0 */ virtual u32 getTotalFreeSize(); + /* vt 0x28 | 80495ee0 */ virtual u32 getAllocatableSize(s32 align); + /* vt 0x2C | 80495f00 */ virtual u32 adjust(); +public: + /* 80495ab0 */ ExpHeap(MEMiHeapHead* heapHead); + /* 80495b70 */ static ExpHeap* create(void* block, u32 size, u16 attr); + /* 80495c30 */ static ExpHeap* create(u32 size, Heap* heap, u16 attr); + /* 80495d00 */ void setGroupID(u16 groupId); + /* 80495f80 */ u32 getSizeForMBlock(const void* block); +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggFader.h b/include/lib/egg/core/eggFader.h new file mode 100644 index 00000000..f8c2d1c9 --- /dev/null +++ b/include/lib/egg/core/eggFader.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace EGG +{ + +class Fader { +public: + enum EStatus { + STATUS_PREPARE_IN, + STATUS_PREPARE_OUT, + STATUS_FADE_IN, + STATUS_FADE_OUT, + }; +public: + // vtable at 0x00 + /* vt 0x08 | 00000000 */ virtual void setStatus(EStatus) = 0; + /* vt 0x0C | 00000000 */ virtual EStatus getStatus() const = 0; + /* vt 0x10 | 00000000 */ virtual bool fadeIn() = 0; + /* vt 0x14 | 00000000 */ virtual bool fadeOut() = 0; + /* vt 0x18 | 00000000 */ virtual bool calc() = 0; + /* vt 0x1C | 00000000 */ virtual bool draw() = 0; +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggFile.h b/include/lib/egg/core/eggFile.h new file mode 100644 index 00000000..9d6f4a15 --- /dev/null +++ b/include/lib/egg/core/eggFile.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace EGG +{ + +class File { +public: + File() : mIsOpen(false) {} +public: + /* vt 0x08 */ virtual ~File() {} + /* vt 0x0C */ virtual bool open(const char* path) = 0; + /* vt 0x10 */ virtual void close() = 0; + /* vt 0x14 */ virtual s32 readData(void* buffer, s32 length, s32 offset) = 0; + /* vt 0x18 */ virtual s32 writeData(const void* buffer, s32 length, s32 offset) = 0; + /* vt 0x1C */ virtual u32 getFileSize() const = 0; + + /* 0x4 */ bool mIsOpen; + + private: u8 pad[3]; +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggFrmHeap.h b/include/lib/egg/core/eggFrmHeap.h index bfa06ba8..33c7325f 100644 --- a/include/lib/egg/core/eggFrmHeap.h +++ b/include/lib/egg/core/eggFrmHeap.h @@ -1,11 +1,28 @@ #pragma once +#include #include -// [TODO: extend this] - namespace EGG { - class FrmHeap : public Heap { - }; -} \ No newline at end of file +class FrmHeap : public Heap { +public: + // vtable at 0x0 | 8056e9d0 + /* vt 0x08 | 80495fe0 */ virtual ~FrmHeap(); + /* vt 0x0C | 80496390 */ virtual eHeapKind getHeapKind() const; + /* vt 0x14 | 804961c0 */ virtual void* alloc(u32 size, s32 align); + /* vt 0x18 | 80496250 */ virtual void free(void* block); + /* vt 0x1C | 80496130 */ virtual void destroy(); + /* vt 0x20 | 804962b0 */ virtual u32 resizeForMBlock(void* block, u32 size); + /* vt 0x24 | 804962c0 */ virtual u32 getTotalFreeSize(); + /* vt 0x28 | 804962e0 */ virtual u32 getAllocatableSize(s32 align); + /* vt 0x2C | 804962f0 */ virtual u32 adjust(); +public: + /* 80495fa0 */ FrmHeap(MEMiHeapHead* heapHead); + /* 80496060 */ static FrmHeap* create(void* block, u32 size, u16 attr); + /* 804962a0 */ void free(u32 flags); + /* 80496370 */ void recordState(u32 id); // non official for now + /* 80496380 */ void freeState(u32 id); // non official for now +}; + +} // namespace EGG \ No newline at end of file diff --git a/include/lib/egg/core/eggGraphicsFifo.h b/include/lib/egg/core/eggGraphicsFifo.h new file mode 100644 index 00000000..ba5d60c1 --- /dev/null +++ b/include/lib/egg/core/eggGraphicsFifo.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +class GraphicsFifo { +public: + // vtable 0x00 | 8056eb80 + /* vt 0x08 | 80498e90*/ virtual ~GraphicsFifo(); +public: + /* 0x04 */ void* mGxInitData; + /* 0x08 */ void* mBuffBase; + /* 0x0C */ u32 mBufSize; +public: + /* 80498e20 */ static void create(u32 size, Heap* heap); + /* 80498f30 */ GraphicsFifo(u32 size, Heap* heap); +public: + /* 80576798 */ static GraphicsFifo* sGraphicsFifo; + /* 8057679c */ static bool sGpStatus[4]; +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggHeap.h b/include/lib/egg/core/eggHeap.h index 34768369..76261120 100644 --- a/include/lib/egg/core/eggHeap.h +++ b/include/lib/egg/core/eggHeap.h @@ -7,16 +7,13 @@ #include #include #include -#include #include - -#ifndef HEAP_PRIVATE -#define HEAP_PRIVATE protected -#endif +#include +#include namespace EGG { -class ExpHeap; +// class ExpHeap; class Allocator; struct HeapAllocArg { @@ -35,14 +32,19 @@ struct HeapErrorArg { inline HeapErrorArg() {} }; - typedef void (*ErrorCallback)(void*); -// Ghidra: Heap -// size: 0x34 -// .text: [0x804953f0, 0x80495ab0] +struct HeapFreeArg { + u32 arg1; // Idk the args + u32 arg2; +}; +typedef void (*HeapFreeCallback)(void*); + +typedef void (*HeapCreateCallback)(void*); +typedef void (*HeapDestroyCallback)(void*); + class Heap : public Disposer { -public: +public: enum eHeapKind { HEAP_KIND_NONE = 0, HEAP_KIND_EXPANDED, @@ -50,73 +52,60 @@ public: HEAP_KIND_UNIT, HEAP_KIND_ASSERT, }; + // vtable at 0x0 | 8056e950 + /* vt 0x08 | 804954c0 */ virtual ~Heap(); + /* vt 0x0C | 00000000 */ virtual eHeapKind getHeapKind() const = 0; + /* vt 0x10 | 80495a40 */ virtual void initAllocator(Allocator* allocator, s32 align) = 0; + /* vt 0x14 | 00000000 */ virtual void* alloc(u32 size, s32 align) = 0; + /* vt 0x18 | 00000000 */ virtual void free(void* block) = 0; + /* vt 0x1C | 00000000 */ virtual void destroy() = 0; + /* vt 0x20 | 00000000 */ virtual u32 resizeForMBlock(void* block, u32 size) = 0; + /* vt 0x24 | 00000000 */ virtual u32 getTotalFreeSize() = 0; + /* vt 0x24 | 00000000 */ virtual u32 getAllocatableSize(s32 align) = 0; + /* vt 0x28 | 00000000 */ virtual u32 adjust() = 0; +public: inline bool isExpHeap() { return getHeapKind() == HEAP_KIND_EXPANDED; } // inline Heap* getParentHeap() { return mParentHeap; } // not part of ss inline void* getStartAddress() { return this; } - - // vtable at 0x0 - /* 0x08 */ virtual ~Heap(); - /* 0x0C */ virtual eHeapKind getHeapKind() const = 0; - /* 0x10 */ virtual void initAllocator(Allocator* allocator, s32 align) = 0; - /* 0x14 */ virtual void* alloc(u32 size, s32 align) = 0; - /* 0x18 */ virtual void free(void* block) = 0; - /* 0x1C */ virtual void destroy() = 0; - /* 0x20 */ virtual u32 resizeForMBlock(void* block, u32 size) = 0; - /* 0x24 */ virtual u32 getAllocatableSize(s32 align) = 0; - /* 0x28 */ virtual u32 adjust() = 0; - - HEAP_PRIVATE : - static nw4r::ut::List sHeapList; - static OSMutex sRootMutex; - static Heap* sCurrentHeap; - static int sIsHeapListInitialized; - - static Heap* sAllocatableHeap; - static ErrorCallback sErrorCallback; - static HeapAllocCallback sAllocCallback; - static void* sErrorCallbackArg; - static void* sAllocCallbackArg; - static class Thread* sAllocatableThread; + public: // members /* 0x10 */ MEMiHeapHead* mHeapHandle; /* 0x14 */ void* mParentBlock; -// Heap* mParentHeap; // does not exist in ss + /* 0x18 */ TBitFlag mFlag; + /* 0x1C */ nw4r::ut::Node mNode; + /* 0x24 */ nw4r::ut::List mChildren; + /* 0x30 */ const char* mName; // set to "NoName" in ctor + enum HeapFlag { // tstDisableAllocation, enableAllocation, disableAllocation // setBit__Q23EGG12TBitFlagFUc HEAP_FLAG_LOCKED = (1 << 0) }; - /* 0x18 */ u16 mFlag; - /* 0x1C */ nw4r::ut::Node mNode; - /* 0x24 */ nw4r::ut::List mChildren; - /* 0x30 */ const char* mName; // set to "NoName" in ctor public: - static void initialize(); - Heap(MEMiHeapHead* heapHandle); - -private: - inline Heap(const Heap&) {} - + /* 804953f0 */ static void initialize(); + /* 80495430 */ Heap(MEMiHeapHead* heapHandle); + /* 80495690 */ static Heap* findHeap(MEMiHeapHead* heapHandle); + /* 80495730 */ Heap* findParentHeap(); + /* 80495780 */ static Heap* findContainHeap(const void* memBlock); + /* 80495560 */ static void* alloc(u32 size, int align, Heap* heap); + /* 804957c0 */ static void free(void* memBlock, Heap* heap); + /* 80495830 */ void dispose(); + /* 804958a0 */ void dump(); + /* 804958b0 */ void dumpAll(); + /* 804959a0 */ Heap* becomeCurrentHeap(); + /* 80495a00 */ Heap* _becomeCurrentHeapWithoutLock(); + public: - static void* alloc(u32 size, int align, Heap* heap); - template static T* alloc(u32 count, Heap* heap, int align = 4) { return reinterpret_cast(alloc(count * sizeof(T), align, heap)); } template static T* alloc(Heap* heap, int align = 4) { return reinterpret_cast(alloc(sizeof(T), align, heap)); } - - Heap* findParentHeap(); - static Heap* findContainHeap(const void* memBlock); - static void free(void* memBlock, Heap* heap); - void dispose(); - static void dumpAll(); - Heap* becomeCurrentHeap(); - + public: static void* addOffset(void* begin, u32 size) { return reinterpret_cast(begin) + size; @@ -136,24 +125,25 @@ public: inline int getArenaEnd() { return (int)mHeapHandle->end; } + /* 80673ae8 */ static nw4r::ut::List sHeapList; + /* 80673af8 */ static OSMutex sRootMutex; + /* 80576740 */ static Heap* sCurrentHeap; + /* 80576744 */ static int sIsHeapListInitialized; + /* 80576748 */ static Heap* sAllocatableHeap; + /* 8057674c */ static ErrorCallback sErrorCallback; + /* 80576750 */ static HeapAllocCallback sAllocCallback; + /* 80576754 */ static HeapFreeCallback sFreeCallback; + /* 80576758 */ static void* sErrorCallbackArg; + /* 8057675c */ static void* sAllocCallbackArg; + /* 80576760 */ static void* sFreeCallbackArg; + /* 80576764 */ static HeapCreateCallback sCreateCallback; + /* 80576764 */ static HeapDestroyCallback sDestroyCallback; }; } // namespace EGG -void* operator new(size_t size); -// __nwa(ulong, ulong) -void* operator new[](size_t size, u32 align); -// __nw(ulong, EGG::Heap *, int) -void* operator new(size_t size, EGG::Heap* heap, int align); -// __nwa(ulong) -void* operator new[](size_t size); -// __nwa(ulong, int) -void* operator new[](size_t size, int align); -// __nwa(ulong, EGG::Heap *, int) -void* operator new[](size_t size, EGG::Heap* heap, int align); -// __dl(void *) -void operator delete(void* p); -// __dla(void *) -void operator delete[](void*); - -#undef HEAP_PRIVATE \ No newline at end of file +/* 80495a60 */ void* operator new(size_t, void* p); +/* 80495a70 */ void* operator new(size_t size, EGG::Heap* heap, u32 align); +/* 80495a80 */ void* operator new(size_t size, EGG::Allocator* alloc); +/* 80495a90 */ void* operator new[](size_t size, u32 align); +/* 80495aa0 */ void* operator new[](size_t size, EGG::Heap* heap, int align); diff --git a/include/lib/egg/core/eggSystem.h b/include/lib/egg/core/eggSystem.h new file mode 100644 index 00000000..5f1313d6 --- /dev/null +++ b/include/lib/egg/core/eggSystem.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +class Display; +class XfbManager; +class Video; + +class ConfigurationData { +public: + // vtable at 0x0 | 8056ea8c + /* vt 0x08 | 00000000 */ virtual Video* getVideo() = 0; + /* vt 0x0C | 00000000 */ virtual Heap* getSystemHeap() = 0; + /* vt 0x10 | 00000000 */ virtual Display* getDisplay() = 0; + /* vt 0x14 | 00000000 */ virtual XfbManager* getXfbMgr() = 0; + /* vt 0x18 | 00000000 */ virtual void getPerfView() = 0; + /* vt 0x1C | 00000000 */ virtual void getScnMgr() = 0; + /* vt 0x20 | 00000000 */ virtual void getAudioMgr() = 0; + /* vt 0x24 | 800643d0 */ virtual void onBeginFrame(); + /* vt 0x28 | 80064430 */ virtual void onEndFrame(); + /* vt 0x2C | 80064ea0 */ virtual void initRenderMode(); + /* vt 0x30 | 80497170 */ virtual void initMemory(); + /* vt 0x34 | 804972f0 */ virtual void run(); +public: + /* 0x04 */ u32 mRoot1HeapStart; + /* 0x08 */ u32 mRoot1HeapEnd; + /* 0x0C */ u32 mRoot2HeapStart; + /* 0x10 */ u32 mRoot2HeapEnd; + /* 0x14 */ u32 mMemSize; + /* 0x18 */ Heap* mRootHeapMem1; + /* 0x1C */ Heap* mRootHeapMem2; + /* 0x20 */ Heap* mRootHeapDebug; + /* 0x24 */ Heap* mSystemHeap; + /* 0x28 */ Thread* mSystemThread; + /* 0x2C */ u32 field_0x2C; + /* 0x30 */ u32 mSystemHeapStart; + /* 0x34 */ u32 mSystemHeapSize; + /* 0x38 */ u32 mGraphicsFifoSize; + /* 0x3C */ u32 field_0x3C; +}; +class BaseSystem { +public: + /* 80576780 */ static ConfigurationData* mConfigData; + static XfbManager* getXfbMgr() { return mConfigData->getXfbMgr(); } + static Display* getDisplay() { return mConfigData->getDisplay(); } + static Video* getVideo() { return mConfigData->getVideo(); } +}; + +} // namespace EGG \ No newline at end of file diff --git a/include/lib/egg/core/eggThread.h b/include/lib/egg/core/eggThread.h index af9ba130..1284378c 100644 --- a/include/lib/egg/core/eggThread.h +++ b/include/lib/egg/core/eggThread.h @@ -1,6 +1,42 @@ #pragma once +#include +#include +#include +#include + namespace EGG { - class Thread; -} \ No newline at end of file +class Thread { +public: // vtable: 0x00 | 8056ea40 + /* 0x08 | 80496a60 */ virtual ~Thread(); + /* 0x0C | 80496dd0 */ virtual void* run(); + /* 0x10 | 800bd600 */ virtual void onEnter(); + /* 0x14 | 800bd5f0 */ virtual void onExit(); +public: + /* 0x04 */ Heap* mContainingHeap; + /* 0x08 */ OSThread* mOSThread; + /* 0x0C */ OSMessageQueue mMesgQueue; + /* 0x2C */ OSMessage* mMesgBuffer; + /* 0x30 */ int mMesgCount; + /* 0x34 */ void* mStackMemory; + /* 0x38 */ u32 mStackSize; + /* 0x3C */ Heap* mAllocatableHeap; + /* 0x40 */ Heap* mCurrentHeap; + /* 0x44 */ nw4r::ut::Node mLink; +public: + /* 80496910 */ Thread(u32 stackSize, int msgCount, int priority, Heap* heap); + /* 804969e0 */ Thread(OSThread* osThread, int msgCount); + /* 80496b20 */ static Thread* findThread(OSThread* thread); + /* 80496b90 */ static void initialize(); + /* 80496bd0 */ void setThreadCurrentHeap(Heap* heap); + /* 80496c70 */ static void switchThreadCallback(OSThread* from, OSThread* to); + /* 80496d60 */ void setCommonMesgQueue(int mesgCount, Heap* heap); + /* 80496dc0 */ static void* start(void* thread); + +public: + /* 80673b10 */ static nw4r::ut::List sThreadList; + /* 80576770 */ static void (*sOldSwitchThreadCallback)(OSThread*, OSThread*); +}; + +} // namespace EGG \ No newline at end of file diff --git a/include/lib/egg/core/eggUnk.h b/include/lib/egg/core/eggUnk.h new file mode 100644 index 00000000..8ee9304a --- /dev/null +++ b/include/lib/egg/core/eggUnk.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +// This is seen in Animal Crossing: City Folk also. Idk where it belongs + +// Seen between EGG::Thread and EGG::ConfigurationData (eggThread and eggSystem) +// dSysNandThread (or NandRequestThread ) inherits from eggThread, +// with part of that thread referencing tsome of these funcs + +namespace EGG +{ + class Unknown { + public: + u8 _[0xfC-0x00]; // size unsure, but this is the limit seen + /* 80496de0 */ void fn_80496de0(OSThread*); + /* 80496e30 */ void fn_80496e30(OSThread*); + /* 80496f10 */ void fn_80496f10(); + /* 804970e0 */ void fn_804970e0(OSThread*, u8*); + }; +} // namespace EGG diff --git a/include/lib/egg/core/eggVideo.h b/include/lib/egg/core/eggVideo.h new file mode 100644 index 00000000..da1909db --- /dev/null +++ b/include/lib/egg/core/eggVideo.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include +#include + +namespace EGG +{ + +class Video { +public: + struct RenderModeObjSet { + GXRenderModeObj* table[10]; + }; +public: + /* 0x00 */ GXRenderModeObj const* pRenderMode; + /* 0x04 */ TBitFlag mFlag; + /* 0x08 */ u32 mConfiguredTime; +public: + /* inline */ Video() : pRenderMode(0), mFlag(), mConfiguredTime() {}; + /* 80498690 */ void initialize(GXRenderModeObj*, const RenderModeObjSet*); + /* 804986f0 */ void configure(GXRenderModeObj*, const RenderModeObjSet*); + /* 80498800 */ static u32 getTickPerVRetrace(u32 tvFormat); + /* 80498860 */ static u32 getTickPerVRetrace(); + /* 80498890 */ static GXRenderModeObj* getStandardRenderModeObj(RenderModeObjSet*); +public: + /* inline */ void setBlack(bool b) { + VISetBlack(!mFlag.onBit(0)); + mFlag.toggleBit(0); + } +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggXfb.h b/include/lib/egg/core/eggXfb.h new file mode 100644 index 00000000..0392e9f8 --- /dev/null +++ b/include/lib/egg/core/eggXfb.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +class Xfb { +public: + // Non-Official assumed based on actions + enum XFBState{ + XFB_UNPROCESSED, + XFB_COPIED, + XFB_SHOWN, + }; +public: + /* 0x00 */ u16 mWidth; + /* 0x02 */ u16 mHeight; + /* 0x04 */ u8* mBuffer; + /* 0x08 */ XFBState mState; + /* 0x0C */ Xfb* mNext; // idk the actual order, but they always link to each other + /* 0x10 */ Xfb* mPrev; // idk the actual order, but they always link to each other +public: + /* 804989e0 */ void init(u16 width, u16 height, Heap* heap); + /* 80498a60 */ Xfb(Heap* heap); + /* 80498ad0 */ static u32 calcBufferSize(u16 width, u16 height); +}; + +} // namespace EGG diff --git a/include/lib/egg/core/eggXfbManager.h b/include/lib/egg/core/eggXfbManager.h new file mode 100644 index 00000000..55f1f372 --- /dev/null +++ b/include/lib/egg/core/eggXfbManager.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +class XfbManager { +public: + /* 0x0 */ Xfb* mNextXfb; // next xfb to process? + /* 0x4 */ Xfb* mToCopyXfb; // current xfb to use in copyEFB + /* 0x8 */ Xfb* mToShowXfb; // current xfb to use in setNextFrameBuffer + /* 0xC */ u8 mNumXfbs; // Total number of Xfbs ever attached + /* 0xD */ u8 mNumXfbs_Copy; // Unsure of purpose yet, but showing wont proceed until its under 3 +public: + /* 80498af0 */ bool isRegisterd(Xfb* xfb) const; // yes. this is correct spelling + /* 80498b30 */ bool attach(Xfb* xfb); + /* 80498c10 */ void copyEFB(bool); + /* 80498d00 */ void setNextFrameBuffer(); +}; + +} // namespace EGG diff --git a/include/lib/egg/egg_types.h b/include/lib/egg/egg_types.h index 68ec4f10..e48fc8d6 100644 --- a/include/lib/egg/egg_types.h +++ b/include/lib/egg/egg_types.h @@ -72,8 +72,8 @@ namespace EGG class DvdRipper; class ExpHeap; class Fader; - class FrmHeap; class Heap; + class FrmHeap; class Scene; class SceneManager; class Thread; diff --git a/include/lib/egg/math/eggMatrix.h b/include/lib/egg/math/eggMatrix.h new file mode 100644 index 00000000..9831cbb4 --- /dev/null +++ b/include/lib/egg/math/eggMatrix.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace EGG +{ + +struct Matrix34f{ + f32 mData[3][4]; +}; + +} // namespace EGG diff --git a/include/lib/egg/math/eggVector.h b/include/lib/egg/math/eggVector.h new file mode 100644 index 00000000..a8348a3a --- /dev/null +++ b/include/lib/egg/math/eggVector.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace EGG +{ + +struct Vector3f { + f32 x,y,z; +}; + +struct Vector2f { + f32 x,y; +}; + +} // namespace EGG diff --git a/include/lib/egg/prim/eggBitFlag.h b/include/lib/egg/prim/eggBitFlag.h new file mode 100644 index 00000000..dea7972b --- /dev/null +++ b/include/lib/egg/prim/eggBitFlag.h @@ -0,0 +1,63 @@ +#pragma once + +// Pulled from ogws + +#include + +namespace EGG +{ + +template class TBitFlag { +public: + T value; + inline void makeAllZero() { + value = T(); + } + inline TBitFlag() { + makeAllZero(); + } + inline T makeMask(u8 bit) const { + return 1 << bit; + } + inline bool on(T mask) const { + return value & mask; + } + inline bool off(T mask) const { + return !(value & mask); + } + inline void set(T mask) { + value |= mask; + } + inline void reset(T mask) { + value &= ~mask; + } + inline bool onBit(u8 bit) const { + return on(makeMask(bit)); + } + inline bool offBit(u8 bit) const { + return off(makeMask(bit)); + } + inline void setBit(u8 bit) { + set(makeMask(bit)); + } + inline void resetBit(u8 bit) { + reset(makeMask(bit)); + } + inline void toggleBit(u8 bit) { + if (!onBit(bit)) + setBit(bit); + else + resetBit(bit); + } + inline void changeBit(u8 bit, bool b) { + if (b) + setBit(bit); + else + resetBit(bit); + } + inline T getDirect() { + return value; + } +}; + +} // namespace EGG diff --git a/include/lib/egg/prim/eggBuffer.h b/include/lib/egg/prim/eggBuffer.h new file mode 100644 index 00000000..8a6e9246 --- /dev/null +++ b/include/lib/egg/prim/eggBuffer.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +namespace EGG +{ + +template +class TBuffer { +public: + // vtable 0x00 + /* vt 0x08 */ virtual ~TBuffer(){ + delete[] mBuffer; + mBuffer = nullptr; + } + /* vt 0x0C */ virtual void allocate(int n, int){ + mSize = n; + mBuffer = new T[n]; + onAllocate(nullptr); + } + /* vt 0x10 */ virtual void allocate(int n, Heap* heap, int){ + mSize = n; + if (heap == nullptr) heap = Heap::sCurrentHeap; + mBuffer = new(heap, 4) T[n]; + onAllocate(heap); + } + /* vt 0x14 */ virtual void onAllocate(Heap*){ + return; + } + /* vt 0x18 */ virtual void errRangeOver(){ + return; + } +public: + /* 0x08 */ s32 mSize; + /* 0x0C */ T* mBuffer; +public: + inline TBuffer() : mSize(0), mBuffer(nullptr) {} + + inline bool isRangeValid(int i) { + return (i >= 0 && i < mSize); + } + inline void checkRange(int i) { + if (!isRangeValid(i)) { + errRangeOver(); + } + } + inline T& operator()(int i) { + checkRange(i); + return mBuffer[i]; + } + inline s32 getSize() { return mSize; } +}; + +} // namespace EGG diff --git a/include/lib/nw4r/db/db_directPrint.h b/include/lib/nw4r/db/db_directPrint.h new file mode 100644 index 00000000..b0f56a37 --- /dev/null +++ b/include/lib/nw4r/db/db_directPrint.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +namespace nw4r +{ + +namespace db { + +void DirectPrint_Init(); + +} + +} // namespace nw4r diff --git a/include/lib/nw4r/ut/Color.h b/include/lib/nw4r/ut/Color.h new file mode 100644 index 00000000..b542e26b --- /dev/null +++ b/include/lib/nw4r/ut/Color.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace nw4r +{ +namespace ut +{ + +struct Color : public _GXColor { + Color() {} + /* 80007bc0 */ ~Color(); + Color(u32 color) { + *(u32*)this = color; + } + + Color& operator=(u32 color) { + *(u32*)this = color; + return *this; + } +}; + +} // namespace ut +} // namespace nw4r diff --git a/include/lib/nw4r/ut/utList.h b/include/lib/nw4r/ut/List.h similarity index 100% rename from include/lib/nw4r/ut/utList.h rename to include/lib/nw4r/ut/List.h diff --git a/include/lib/rvl/ARC/arc.h b/include/lib/rvl/ARC/arc.h index 594e656f..4b3faf91 100644 --- a/include/lib/rvl/ARC/arc.h +++ b/include/lib/rvl/ARC/arc.h @@ -1,3 +1,4 @@ +#pragma once #ifndef RVL_SDK_ARC_H #define RVL_SDK_ARC_H #include @@ -72,12 +73,13 @@ typedef struct ARCEntry { const char* name; // at 0xC } ARCEntry; -typedef struct ARCDir { +typedef struct ARCDirEntry { ARCHandle* handle; // at 0x0 u32 path_begin; // at 0x4 u32 path_it; // at 0x8 u32 path_end; // at 0xC -} ARCDir; +} ARCDirEntry; + BOOL ARCGetCurrentDir(ARCHandle* handle, char* string, u32 maxlen); BOOL ARCInitHandle(void* bin, ARCHandle* handle); @@ -89,9 +91,9 @@ s32 ARCGetStartOffset(ARCFileInfo* info); u32 ARCGetLength(ARCFileInfo* info); BOOL ARCClose(ARCFileInfo* info); BOOL ARCChangeDir(ARCHandle* info, const char* path); -BOOL ARCOpenDir(ARCHandle* info, const char* path, ARCDir* dir); -BOOL ARCReadDir(ARCDir* dir, ARCEntry* entry); -BOOL ARCCloseDir(ARCDir* dir); +BOOL ARCOpenDir(ARCHandle* info, const char* path, ARCDirEntry* dir); +BOOL ARCReadDir(ARCDirEntry* dir, ARCEntry* entry); +BOOL ARCCloseDir(ARCDirEntry* dir); #ifdef __cplusplus } diff --git a/include/lib/rvl/DVD/dvdfs.h b/include/lib/rvl/DVD/dvdfs.h index 12fea7ed..a66e6ae6 100644 --- a/include/lib/rvl/DVD/dvdfs.h +++ b/include/lib/rvl/DVD/dvdfs.h @@ -7,6 +7,33 @@ extern "C" { extern BOOL __DVDLongFileNameFlag; +typedef void (*DVDCommandCallback)(s32, struct DVDCommandBlock*); +typedef void (*DVDFileCallback)(s32, struct DVDFileInfo*); + +typedef struct DVDCommandBlock { + /* 0x00 */ struct DVDCommandBlock* next; + /* 0x04 */ struct DVDCommandBlock* prev; + /* 0x08 */ u32 command; + /* 0x0c */ s32 state; + /* 0x10 */ u32 offset; + /* 0x14 */ u32 length; + /* 0x18 */ void* addr; + /* 0x1c */ u32 currTransferSize; + /* 0x20 */ u32 transferredSize; + /* 0x24 */ DVDDiskID* id; + /* 0x28 */ DVDCommandCallback callback; + /* 0x2c */ void* userData; +} DVDCommandBlock; + +typedef struct DVDFileInfo +{ + /* 0x00 */ DVDCommandBlock cb; + /* 0x30 */ u32 startAddr; + /* 0x34 */ u32 length; + /* 0x38 */ DVDFileCallback* callback; +} DVDFileInfo; + + #ifdef __cplusplus } #endif diff --git a/include/lib/rvl/GX/GXAttr.h b/include/lib/rvl/GX/GXAttr.h index df715585..24dd1eef 100644 --- a/include/lib/rvl/GX/GXAttr.h +++ b/include/lib/rvl/GX/GXAttr.h @@ -47,10 +47,11 @@ void __GXCalculateVLim(void); void __GXSetVAT(void); static void GXSetTexCoordGen(GXTexCoordID id, GXTexGenType type, - GXTexGenSrc src, u32 texMtxIdx) { - // TODO: What matrix index is this??? - GXSetTexCoordGen2(id, type, src, texMtxIdx, FALSE, 125); -} + GXTexGenSrc src, u32 texMtxIdx) ; +// // TODO: What matrix index is this??? +// GXSetTexCoordGen2(id, type, src, texMtxIdx, FALSE, 125); +// } + #ifdef __cplusplus } diff --git a/include/lib/rvl/GX/GXBump.h b/include/lib/rvl/GX/GXBump.h index 25f67c18..5c3d8e82 100644 --- a/include/lib/rvl/GX/GXBump.h +++ b/include/lib/rvl/GX/GXBump.h @@ -18,7 +18,6 @@ void GXSetIndTexOrder(GXIndTexStageID stage, GXTexCoordID coord, GXTexMapID map); void GXSetNumIndStages(u8 num); void GXSetTevDirect(GXTevStageID stage); - void __GXUpdateBPMask(void); void __GXSetIndirectMask(u32 mask); void __GXFlushTextureState(void); diff --git a/include/lib/rvl/GX/GXDraw.h b/include/lib/rvl/GX/GXDraw.h index e92a2149..1e9ea343 100644 --- a/include/lib/rvl/GX/GXDraw.h +++ b/include/lib/rvl/GX/GXDraw.h @@ -7,7 +7,7 @@ extern "C" { void GXDrawCylinder(u8 sides); void GXDrawSphere(u32 stacks, u32 sectors); - +/* 803bcdb0 */ void GXDrawDone(); #ifdef __cplusplus } #endif diff --git a/include/lib/rvl/GX/GXFrameBuf.h b/include/lib/rvl/GX/GXFrameBuf.h index 29352dde..764a2a90 100644 --- a/include/lib/rvl/GX/GXFrameBuf.h +++ b/include/lib/rvl/GX/GXFrameBuf.h @@ -21,6 +21,10 @@ typedef struct _GXRenderModeObj { u8 vfilter[7]; // at 0x32 } GXRenderModeObj; +void GXSetCopyFilter(u8, const u8[12][2], u8, const u8[7]); +void GXSetCopyClear(GXColor, u32 zClear); +void GXSetDispCopySrc(u16 left, u16 top, u16 width, u16 height); + #ifdef __cplusplus } #endif diff --git a/include/lib/rvl/GX/GXGeometry.h b/include/lib/rvl/GX/GXGeometry.h index 615784cf..88b75df2 100644 --- a/include/lib/rvl/GX/GXGeometry.h +++ b/include/lib/rvl/GX/GXGeometry.h @@ -7,7 +7,7 @@ extern "C" { #endif void GXBegin(GXPrimitive prim, GXVtxFmt fmt, u16 verts); -static void GXEnd(void) {} +static void GXEnd(void); void GXSetLineWidth(u8 width, u32 offset); void GXSetPointSize(u8 size, u32 offset); diff --git a/include/lib/rvl/MEM.h b/include/lib/rvl/MEM.h index 18321f49..d9aea4ac 100644 --- a/include/lib/rvl/MEM.h +++ b/include/lib/rvl/MEM.h @@ -4,10 +4,10 @@ extern "C" { #endif +#include #include #include #include -#include #include #ifdef __cplusplus diff --git a/include/lib/rvl/macros.h b/include/lib/rvl/macros.h index af601101..ea564007 100644 --- a/include/lib/rvl/macros.h +++ b/include/lib/rvl/macros.h @@ -1,6 +1,4 @@ -#ifndef MACROS_H -#define MACROS_H - +#pragma once #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) @@ -47,5 +45,3 @@ #define __attribute__(x) #define __declspec(x) #endif - -#endif diff --git a/include/m/m_frustum.h b/include/m/m_frustum.h index e69de29b..3e7ad504 100644 --- a/include/m/m_frustum.h +++ b/include/m/m_frustum.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +class mFrustum_c { + +}; \ No newline at end of file diff --git a/include/m/m_heap.h b/include/m/m_heap.h index 56f802c8..dadb4700 100644 --- a/include/m/m_heap.h +++ b/include/m/m_heap.h @@ -11,25 +11,27 @@ namespace EGG { } // TODO: Doc symbols and func locations namespace mHeap { - EGG::ExpHeap* createExpHeap(s32 size, EGG::Heap* parentHeap, char* name, s32 align, u32 unk); - void adjustExpHeap(EGG::Heap* heap); - s32 expHeapCost(s32 start, s32 size); - EGG::FrmHeap* createFrmHeap(s32 size, EGG::Heap* parentHeap, char* name, s32 align, u32 unk); - void destroyFrmHeap(EGG::Heap* heap); - void adjustFrmHeap(EGG::Heap* heap); - s32 frmHeapCost(s32 start, s32 size); - void setTempHeap(EGG::Heap** prevHeap, EGG::Heap* tempNewHeap); - void restoreTempHeap(EGG::Heap** prevHeap); - void createHeap(s32 size, EGG::Heap*, char* name); - void saveCurrentHeap(); - void restoreCurrentHeap(); - EGG::Heap* makeFrmHeapAndSet(s32 size, EGG::Heap* parentHeap, char* name, s32 align, u32 unk); - int getGameHeapNum(); - EGG::Heap* createGameHeap(s32 heapNum, s32 size, EGG::Heap* parentHeap); - EGG::Heap* createGameHeap1(s32 size, EGG::Heap* parentHeap); - void createArchiveHeap(s32 size, EGG::Heap* parentHeap); - void createCommandHeap(s32 size, EGG::Heap* parentHeap); - void createDylinkHeap(s32 size, EGG::Heap* parentHeap); - void createAssertHeap(EGG::Heap* parentHeap); - EGG::Heap* makeHeapOnCurrentGameHeap(s32 size, char* name, s32 align, u32 unk); + /* 802f0f00 */ u8 copyAttribute(u32); + /* 802f0f40 */ EGG::Heap* setCurrentHeap(EGG::Heap*); + /* 802f0f50 */ EGG::ExpHeap* createExpHeap(s32 size, EGG::Heap* parentHeap, char* name, s32 align, u32 unk); + /* 802f1060 */ void adjustExpHeap(EGG::Heap* heap); + /* 802f10d0 */ s32 expHeapCost(s32 start, s32 size); + /* 802f10f0 */ EGG::FrmHeap* createFrmHeap(s32 size, EGG::Heap* parentHeap, char* name, s32 align, u32 unk); + /* 802f1200 */ void destroyFrmHeap(EGG::Heap* heap); + /* 802f1220 */ void adjustFrmHeap(EGG::Heap* heap); + /* 802f1290 */ s32 frmHeapCost(s32 start, s32 size); + /* 802f12b0 */ void setTempHeap(EGG::Heap** prevHeap, EGG::Heap* tempNewHeap); + /* 802f12f0 */ void restoreTempHeap(EGG::Heap** prevHeap); + /* 802f1350 */ void createHeap(s32 size, EGG::Heap*, char* name); + /* 802f13d0 */ void saveCurrentHeap(); + /* 802f13e0 */ void restoreCurrentHeap(); + /* 802f1410 */ EGG::Heap* makeFrmHeapAndSet(s32 size, EGG::Heap* parentHeap, char* name, s32 align, u32 unk); + /* 802f1450 */ int getGameHeapNum(); + /* 802f1460 */ EGG::Heap* createGameHeap(s32 heapNum, s32 size, EGG::Heap* parentHeap); + /* 802f1510 */ EGG::Heap* createGameHeap1(s32 size, EGG::Heap* parentHeap); + /* 802f1560 */ void createArchiveHeap(s32 size, EGG::Heap* parentHeap); + /* 802f1590 */ void createCommandHeap(s32 size, EGG::Heap* parentHeap); + /* 802f15c0 */ void createDylinkHeap(s32 size, EGG::Heap* parentHeap); + /* 802f15f0 */ void createAssertHeap(EGG::Heap* parentHeap); + /* 802f1640 */ EGG::Heap* makeHeapOnCurrentGameHeap(s32 size, char* name, s32 align, u32 unk); }; \ No newline at end of file diff --git a/include/m/m_thread.h b/include/m/m_thread.h new file mode 100644 index 00000000..8bd58044 --- /dev/null +++ b/include/m/m_thread.h @@ -0,0 +1,3 @@ +#pragma once + +// This file is a complete guess \ No newline at end of file diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index ecb6ae92..8cc26cd4 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -27,30 +27,20 @@ bool dAcBase_c::createHeap() { // Doesnt Match Yet dAcBase_c::dAcBase_c() : heap_allocator() , - obj_info(s_Create_ObjInfo) - // sound_list(&heap_allocator.mHeap, &heap_allocator.mHeap) - // obj_sound(0), - // obj_pos(&position), - // params2(s_Create_Params2), - // obj_id(s_Create_UnkFlags), - // viewclip_index(s_Create_ViewClipIdx), - // actor_node(0), - // roomid(s_Create_RoomId) + obj_info(s_Create_ObjInfo), + sound_info_tail(&heap_allocator.mHeap), + sound_info_next(&heap_allocator.mHeap), + count(0), + obj_sound(nullptr), + obj_pos(&position), + params2(s_Create_Params2), + obj_id(s_Create_UnkFlags), + viewclip_index(s_Create_ViewClipIdx), + actor_node(), + roomid(s_Create_RoomId), + actor_subtype(s_Create_Subtype) { - - // obj_info = s_Create_ObjInfo; - sound_info_tail = nullptr; - sound_info_next = nullptr; - obj_sound = nullptr; - obj_pos = &position; - params2 = (s_Create_Params2); - obj_id = (s_Create_UnkFlags); - viewclip_index = (s_Create_ViewClipIdx); - actor_node = (0); - roomid =(s_Create_RoomId); - - actor_subtype = s_Create_Subtype; - field_0xF0 = 0; + JStudio_actor = 0; someStr[0] = 0; if (s_Create_Position != nullptr) { // void set(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; } diff --git a/src/lib/egg/core/eggController.cpp b/src/lib/egg/core/eggController.cpp new file mode 100644 index 00000000..a936f1fa --- /dev/null +++ b/src/lib/egg/core/eggController.cpp @@ -0,0 +1,14 @@ +#include + + +namespace EGG +{ + +void CoreControllerMgr::beginFrame() { + for (int i = 0; i < mControllers.getSize(); ++i) { + mControllers(i)->beginFrame(NULL); + } +} + + +} // namespace EGG diff --git a/src/lib/egg/core/eggDisplay.cpp b/src/lib/egg/core/eggDisplay.cpp new file mode 100644 index 00000000..e31ae8da --- /dev/null +++ b/src/lib/egg/core/eggDisplay.cpp @@ -0,0 +1,102 @@ +#include +#include +#include +#include +#include + +extern "C" { + void PreRetraceCallback(u32 retraceCount) { + EGG::BaseSystem::getDisplay()->preVRetrace(); + } +} +namespace EGG { + +u32 Display::sTickPeriod = ((OS_BUS_CLOCK_SPEED >> 2)/125000)*300 >> 3; + +/* 80497570 */ +Display::Display(u8 maxRetrace) : + mMaxRetraces(maxRetrace), + mScreenStateFlag(), + mRetraceCount(0), + mFrameCount(0), + mClearColor(0x808080ff), + mClearZ(0xFFFFFF), + mBeginTick(0), + mFlag() +{ + mFlag.setBit(mFlag_SetClear); + mFlag.setBit(mFlag_WaitForRetrace); + nw4r::db::DirectPrint_Init(); + VISetPreRetraceCallback(PreRetraceCallback); +} + +/* vt 0x18 | 804975f0 */ +u32 Display::getTickPerFrame() { + return Video::getTickPerVRetrace(); +} +/* vt 0x08 | 80497600 */ +void Display::beginFrame() { + + GXDrawDone(); + if ( + mFlag.onBit(mFlag_WaitForRetrace) + || (BaseSystem::getXfbMgr()->mNumXfbs == 1 + && OSGetTick()-mLastTick > sTickPeriod)) { + VIWaitForRetrace(); + } + // Holds while the next XFB gets to its copy state + while (BaseSystem::getXfbMgr()->mToCopyXfb == 0 ) { + VIWaitForRetrace(); + } + copyEFBtoXFB(); + calcFrequency(); + mFrameCount++; +} + +/* vt 0x0C | 804976c0 */ +void Display::beginRender() { + return; +} + +/* vt 0x10 | 804976d0 */ +void Display::endRender() { + return; +} + +/* vt 0x14 | 804976e0 */ +void Display::endFrame() { + return; +} + + +/* vt 0x1C | 804976f0 */ +void Display::preVRetrace() { + mLastTick = OSGetTick(); + if (VIGetRetraceCount() - mRetraceCount < mMaxRetraces) return; + if (mScreenStateFlag.onBit(mScreenStateFlag_SetBlack)) { + BaseSystem::getVideo()->setBlack(1); + mScreenStateFlag.resetBit(mScreenStateFlag_SetBlack); + } + BaseSystem::getXfbMgr()->setNextFrameBuffer(); + mRetraceCount = VIGetRetraceCount(); +} + +/* 804977d0 */ +void Display::copyEFBtoXFB() { + if (mFlag.onBit(mFlag_SetClear)) { + GXSetCopyClear(mClearColor, mClearZ); + } + GXRenderModeObj const* renderObj = BaseSystem::getVideo()->pRenderMode; + GXSetCopyFilter(renderObj->aa, renderObj->sample_pattern, renderObj->aa == 0, renderObj->vfilter); + BaseSystem::getXfbMgr()->copyEFB(mFlag.onBit(mFlag_SetClear)); +} + +/* 80497870 */ +void Display::calcFrequency() { + s32 endTick = OSGetTick(); + mDeltaTick = endTick-mBeginTick; + mFrequency = 1000000.0f / ((mDeltaTick * 8) / ((OS_BUS_CLOCK_SPEED >> 2) / 125000)); + mBeginTick = endTick; +} + +} // namespace EGG \ No newline at end of file