mirror of
https://github.com/zeldaret/ss
synced 2026-08-19 13:53:25 -04:00
Merge branch 'main' into eggXfb
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#include <egg/core/eggAllocator.h>
|
||||
#include <egg/core/eggHeap.h>
|
||||
|
||||
/* 804952d0 */ static void *MEM_AllocFor_Heap(MEMAllocator* alloc, u32 size) {
|
||||
return static_cast<EGG::Heap*>(static_cast<EGG::Allocator*>(alloc)->heap)->alloc(size, alloc->heapParam1);
|
||||
}
|
||||
/* 804952f0 */ static void MEM_FreeFor_Heap(MEMAllocator* alloc, void* block) {
|
||||
return static_cast<EGG::Heap*>(static_cast<EGG::Allocator*>(alloc)->heap)->free(block);
|
||||
}
|
||||
|
||||
const MEMAllocatorFuncs eggAllocatorFuncs = {
|
||||
&MEM_AllocFor_Heap,
|
||||
&MEM_FreeFor_Heap,
|
||||
};
|
||||
|
||||
// TODO this is used from eggHeap for some reason. Figure out
|
||||
// the correct privacy boundary later.
|
||||
/* 80495310 */ void MEMInitAllocatorFor_Heap(MEMAllocator* alloc, s32 align, void* heap) {
|
||||
alloc->funcs = &eggAllocatorFuncs;
|
||||
alloc->heap = heap;
|
||||
alloc->heapParam1 = align;
|
||||
alloc->heapParam2 = 0;
|
||||
}
|
||||
|
||||
|
||||
namespace EGG {
|
||||
|
||||
/* 80495330 */ Allocator::Allocator(Heap *heap, s32 align) : mHeap(heap), align(align) {
|
||||
MEMInitAllocatorFor_Heap(this, align, heap);
|
||||
}
|
||||
|
||||
/* 80495380 */ Allocator::~Allocator() {}
|
||||
|
||||
/* 804953c0 */ void *Allocator::alloc(u32 size) {
|
||||
return Heap::alloc(size, align, mHeap);
|
||||
}
|
||||
|
||||
/* 804953e0 */ void Allocator::free(void *block) {
|
||||
Heap::free(block, mHeap);
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -6,7 +6,7 @@
|
||||
/* 80497930 */
|
||||
EGG::ColorFader::ColorFader(float startX, float startY, float lengthX, float lengthY, nw4r::ut::Color color,
|
||||
Fader::EStatus initialStatus)
|
||||
: mStartX(startX), mStartY(startY), mEndX(startX + lengthX), mEndY(startY + lengthY), mFrame(0x14), mFadeTimer(0) {
|
||||
: mStartX(startX), mStartY(startY), mEndX(startX + lengthX), mEndY(startY + lengthY), mFrame(0x14), mFadeTimer(0), mFlags(0) {
|
||||
setColor(color);
|
||||
setStatus(initialStatus);
|
||||
mFlags.setBit(1);
|
||||
|
||||
@@ -16,13 +16,13 @@ u32 Display::sTickPeriod = ((OS_BUS_CLOCK_SPEED >> 2)/125000)*300 >> 3;
|
||||
/* 80497570 */
|
||||
Display::Display(u8 maxRetrace) :
|
||||
mMaxRetraces(maxRetrace),
|
||||
mScreenStateFlag(),
|
||||
mScreenStateFlag(0),
|
||||
mRetraceCount(0),
|
||||
mFrameCount(0),
|
||||
mClearColor(0x808080ff),
|
||||
mClearZ(0xFFFFFF),
|
||||
mBeginTick(0),
|
||||
mFlag()
|
||||
mFlag(0)
|
||||
{
|
||||
mFlag.setBit(mFlag_SetClear);
|
||||
mFlag.setBit(mFlag_WaitForRetrace);
|
||||
@@ -99,4 +99,4 @@ void Display::calcFrequency() {
|
||||
mBeginTick = endTick;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
} // namespace EGG
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
#include <egg/core/eggAllocator.h>
|
||||
#include <egg/core/eggHeap.h>
|
||||
#include <nw4r/ut/ut_list.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
/* 80673ae8 */ nw4r::ut::List Heap::sHeapList;
|
||||
/* 80673af8 */ OSMutex Heap::sRootMutex;
|
||||
/* 80576740 */ Heap *Heap::sCurrentHeap;
|
||||
/* 80576744 */ int Heap::sIsHeapListInitialized;
|
||||
/* 80576748 */ Heap *Heap::sAllocatableHeap;
|
||||
/* 8057674c */ ErrorCallback Heap::sErrorCallback;
|
||||
/* 80576750 */ HeapAllocCallback Heap::sAllocCallback;
|
||||
/* 80576754 */ HeapFreeCallback Heap::sFreeCallback;
|
||||
/* 80576758 */ void *Heap::sErrorCallbackArg;
|
||||
/* 8057675c */ void *Heap::sAllocCallbackArg;
|
||||
/* 80576760 */ void *Heap::sFreeCallbackArg;
|
||||
/* 80576764 */ HeapCreateCallback Heap::sCreateCallback;
|
||||
/* 80576764 */ HeapDestroyCallback Heap::sDestroyCallback;
|
||||
|
||||
/* 804953f0 */ void Heap::initialize() {
|
||||
nw4r::ut::List_Init(&sHeapList, 0x1c /* todo offsetof() */);
|
||||
OSInitMutex(&sRootMutex);
|
||||
sIsHeapListInitialized = true;
|
||||
}
|
||||
|
||||
/* 80495430 */ Heap::Heap(MEMiHeapHead *head) : mHeapHandle(head), mParentBlock(nullptr), mName("NoName"), mFlag() {
|
||||
mFlag.value = 0;
|
||||
nw4r::ut::List_Init(&mChildren, 0x8 /* todo offsetof() */);
|
||||
OSLockMutex(&sRootMutex);
|
||||
nw4r::ut::List_Append(&sHeapList, this);
|
||||
OSUnlockMutex(&sRootMutex);
|
||||
}
|
||||
|
||||
/* 804954c0 */ Heap::~Heap() {
|
||||
OSLockMutex(&sRootMutex);
|
||||
nw4r::ut::List_Remove(&sHeapList, this);
|
||||
OSUnlockMutex(&sRootMutex);
|
||||
}
|
||||
|
||||
/* 80495560 */ void *Heap::alloc(size_t size, s32 align, Heap *heap) {
|
||||
Heap *currentHeap = sCurrentHeap;
|
||||
Thread *thread = Thread::findThread(OSGetCurrentThread());
|
||||
Heap *threadHeap = nullptr;
|
||||
|
||||
if (thread != nullptr && (threadHeap = thread->mAllocatableHeap, threadHeap != nullptr)) {
|
||||
heap = threadHeap;
|
||||
}
|
||||
if (sAllocatableHeap != nullptr) {
|
||||
if (heap == nullptr) {
|
||||
heap = currentHeap;
|
||||
}
|
||||
if (heap != sAllocatableHeap) {
|
||||
// TODO small instshuffle here, related to regshuffle problems
|
||||
OSReport("cannot allocate from heap %x(%s) : allocatable heap is %x(%s)\n", heap, heap->getName(),
|
||||
sAllocatableHeap, sAllocatableHeap->getName());
|
||||
OSReport("\tthread heap=%x(%s)\n", threadHeap, threadHeap != nullptr ? threadHeap->getName() : "none");
|
||||
if (sErrorCallback != nullptr) {
|
||||
HeapErrorArg arg;
|
||||
arg.msg = "disable_but";
|
||||
arg.userdata = sErrorCallbackArg;
|
||||
sErrorCallback(&arg);
|
||||
}
|
||||
dumpAll();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (heap == nullptr) {
|
||||
heap = currentHeap;
|
||||
}
|
||||
void *ptr = nullptr;
|
||||
if (heap) {
|
||||
ptr = heap->alloc(size, align);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* 80495690 */ Heap *Heap::findHeap(MEMiHeapHead *head) {
|
||||
Heap *heap = nullptr;
|
||||
OSLockMutex(&sRootMutex);
|
||||
if (sIsHeapListInitialized) {
|
||||
Heap *heap2 = nullptr;
|
||||
while ((heap2 = (Heap *)nw4r::ut::List_GetNext(&sHeapList, heap2))) {
|
||||
if (heap2->mHeapHandle == head) {
|
||||
heap = heap2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
OSUnlockMutex(&sRootMutex);
|
||||
return heap;
|
||||
}
|
||||
|
||||
/* 80495730 */ Heap *Heap::findParentHeap() {
|
||||
Heap *retHeap = nullptr;
|
||||
MEMiHeapHead *heap = MEMFindContainHeap(mHeapHandle);
|
||||
if (heap) {
|
||||
retHeap = findHeap(heap);
|
||||
}
|
||||
|
||||
return retHeap;
|
||||
}
|
||||
|
||||
extern "C" MEMiHeapHead *fn_803CC670(const void *memBlock);
|
||||
|
||||
/* 80495780 */ Heap *Heap::findContainHeap(const void *memBlock) {
|
||||
Heap *retHeap = nullptr;
|
||||
MEMiHeapHead *heap = fn_803CC670(memBlock);
|
||||
if (heap) {
|
||||
retHeap = findHeap(heap);
|
||||
}
|
||||
|
||||
return retHeap;
|
||||
}
|
||||
|
||||
/* 804957c0 */ void Heap::free(void *ptr, Heap *heap) {
|
||||
if (heap == nullptr) {
|
||||
MEMiHeapHead *iheap = fn_803CC670(ptr);
|
||||
if (iheap == nullptr) {
|
||||
return;
|
||||
}
|
||||
heap = findHeap(iheap);
|
||||
if (heap == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
heap->free(ptr);
|
||||
}
|
||||
|
||||
/* 80495830 */ void Heap::dispose() {
|
||||
mFlag.setBit(1);
|
||||
Heap *heap;
|
||||
while ((heap = (Heap *)nw4r::ut::List_GetFirst(&mChildren)) != nullptr) {
|
||||
heap->~Heap();
|
||||
}
|
||||
mFlag.resetBit(1);
|
||||
}
|
||||
|
||||
/* 804958a0 */ void Heap::dump() {}
|
||||
|
||||
// TODO: This debugging function with stripped out error reports doesn't match yet
|
||||
/* 804958b0 */ void Heap::dumpAll() {
|
||||
u32 mem[2] = {0, 0};
|
||||
|
||||
OSLockMutex(&sRootMutex);
|
||||
for (Heap *heap = nullptr; heap != nullptr; heap = (Heap *)nw4r::ut::List_GetNext(&sHeapList, &heap)) {
|
||||
Heap *childHeap = nullptr;
|
||||
Heap *parentHeap = heap->findParentHeap();
|
||||
if ((u32)heap < 0x90000000) {
|
||||
mem[0] += heap->getAllocatableSize(4);
|
||||
} else {
|
||||
mem[1] += heap->getAllocatableSize(4);
|
||||
}
|
||||
|
||||
while ((childHeap = (Heap *)nw4r::ut::List_GetNext(&sHeapList, childHeap)) != nullptr) {
|
||||
if (parentHeap == childHeap) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
OSUnlockMutex(&sRootMutex);
|
||||
}
|
||||
|
||||
/* 804959a0 */ Heap *Heap::becomeCurrentHeap() {
|
||||
OSLockMutex(&sRootMutex);
|
||||
Heap *h = sCurrentHeap;
|
||||
sCurrentHeap = this;
|
||||
OSUnlockMutex(&sRootMutex);
|
||||
return h;
|
||||
}
|
||||
|
||||
/* 80495a00 */ Heap *Heap::_becomeCurrentHeapWithoutLock() {
|
||||
Heap *h = sCurrentHeap;
|
||||
sCurrentHeap = this;
|
||||
DCStoreRange(&sCurrentHeap, sizeof(sCurrentHeap));
|
||||
return h;
|
||||
}
|
||||
|
||||
// TODO
|
||||
extern "C" void MEMInitAllocatorForHeap(Allocator *alloc, s32 align, Heap *heap);
|
||||
|
||||
// TODO this could be an inline virtual function
|
||||
/* 80495a40 */ void Heap::initAllocator(Allocator *alloc, s32 align) {
|
||||
MEMInitAllocatorForHeap(alloc, align, this);
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
/* 80495a60 */ void *operator new(size_t, void *p) {
|
||||
return p;
|
||||
}
|
||||
/* 80495a70 */ void *operator new(size_t size, EGG::Heap *heap, int align) {
|
||||
return EGG::Heap::alloc(size, align, heap);
|
||||
}
|
||||
|
||||
/* 80495a80 */ void *operator new(size_t size, EGG::Allocator *alloc) {
|
||||
return MEMAllocFromAllocator(alloc->getHandle(), size);
|
||||
}
|
||||
/* 80495a90 */ void *operator new[](size_t size, int align) {
|
||||
return EGG::Heap::alloc(size, align, nullptr);
|
||||
}
|
||||
/* 80495aa0 */ void *operator new[](size_t size, EGG::Heap *heap, int align) {
|
||||
return EGG::Heap::alloc(size, align, heap);
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
#include <egg/core/eggVideo.h>
|
||||
#include <rvl/OS/OSHardware.h>
|
||||
#include <rvl/OS/OSTime.h>
|
||||
#include <rvl/SC/scapi.h>
|
||||
|
||||
namespace {
|
||||
|
||||
const GXRenderModeObj gRMO_Pal60_640x456Prog_16x9 = {
|
||||
0, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
25, // viXOrigin
|
||||
12, // viYOrigin
|
||||
670, // viWidth
|
||||
456, // viHeight
|
||||
1, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{7, 7, 12, 12, 12, 7, 7} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Pal60_640x456IntDf_16x9 = {
|
||||
2, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
25, // viXOrigin
|
||||
12, // viYOrigin
|
||||
670, // viWidth
|
||||
456, // viHeight
|
||||
0, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{0, 0, 21, 22, 21, 0, 0} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Pal50_640x456IntDf_16x9 = {
|
||||
4, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
542, // xfbHeight
|
||||
27, // viXOrigin
|
||||
16, // viYOrigin
|
||||
666, // viWidth
|
||||
542, // viHeight
|
||||
1, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{7, 7, 12, 12, 12, 7, 7} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Ntsc_640x456Prog_16x9 = {
|
||||
20, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
25, // viXOrigin
|
||||
12, // viYOrigin
|
||||
670, // viWidth
|
||||
456, // viHeight
|
||||
1, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{7, 7, 12, 12, 12, 7, 7} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Ntsc_640x456IntDf_16x9 = {
|
||||
22, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
25, // viXOrigin
|
||||
12, // viYOrigin
|
||||
670, // viWidth
|
||||
456, // viHeight
|
||||
0, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{0, 0, 21, 22, 21, 0, 0} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Pal60_640x456Prog_4x3 = {
|
||||
0, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
17, // viXOrigin
|
||||
12, // viYOrigin
|
||||
686, // viWidth
|
||||
456, // viHeight
|
||||
1, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{7, 7, 12, 12, 12, 7, 7} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Pal60_640x456IntDf_4x3 = {
|
||||
2, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
17, // viXOrigin
|
||||
12, // viYOrigin
|
||||
686, // viWidth
|
||||
456, // viHeight
|
||||
0, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{0, 0, 21, 22, 21, 0, 0} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Pal50_640x456IntDf_4x3 = {
|
||||
4, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
542, // xfbHeight
|
||||
19, // viXOrigin
|
||||
16, // viYOrigin
|
||||
682, // viWidth
|
||||
542, // viHeight
|
||||
1, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{7, 7, 12, 12, 12, 7, 7} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Ntsc_640x456Prog_4x3 = {
|
||||
20, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
17, // viXOrigin
|
||||
12, // viYOrigin
|
||||
686, // viWidth
|
||||
456, // viHeight
|
||||
1, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{7, 7, 12, 12, 12, 7, 7} // vFilter
|
||||
};
|
||||
|
||||
const GXRenderModeObj gRMO_Ntsc_640x456IntDf_4x3 = {
|
||||
22, // tvInfo
|
||||
640, // fbWidth
|
||||
456, // efbHeight
|
||||
456, // xfbHeight
|
||||
17, // viXOrigin
|
||||
12, // viYOrigin
|
||||
686, // viWidth
|
||||
456, // viHeight
|
||||
0, // xfbMode
|
||||
0, // field_rendering
|
||||
0, // aa
|
||||
{
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
{6, 6},
|
||||
}, // sample_pattern
|
||||
{0, 0, 21, 22, 21, 0, 0} // vFilter
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace EGG {
|
||||
|
||||
const EGG::Video::RenderModeObjSet renderModes = {{&gRMO_Pal60_640x456Prog_16x9, &gRMO_Pal60_640x456IntDf_16x9,
|
||||
&gRMO_Pal50_640x456IntDf_16x9, &gRMO_Ntsc_640x456Prog_16x9, &gRMO_Ntsc_640x456IntDf_16x9,
|
||||
&gRMO_Pal60_640x456Prog_4x3, &gRMO_Pal60_640x456IntDf_4x3, &gRMO_Pal50_640x456IntDf_4x3,
|
||||
&gRMO_Ntsc_640x456Prog_4x3, &gRMO_Ntsc_640x456IntDf_4x3}};
|
||||
|
||||
/* 80498690 */ void Video::initialize(GXRenderModeObj *obj, const RenderModeObjSet *set) {
|
||||
VIInit();
|
||||
configure(obj, set);
|
||||
}
|
||||
|
||||
/* 804986f0 */ GXRenderModeObj *Video::configure(GXRenderModeObj *obj, const RenderModeObjSet *set) {
|
||||
GXRenderModeObj *oldMode = pRenderMode;
|
||||
if (set == nullptr) {
|
||||
set = &renderModes;
|
||||
}
|
||||
if (obj == nullptr) {
|
||||
// Cast away constness. In an incredibly cursed way, adding proper
|
||||
// const correctness to this class changes regalloc
|
||||
obj = (GXRenderModeObj *)getStandardRenderModeObj(set);
|
||||
}
|
||||
if (pRenderMode != obj) {
|
||||
pRenderMode = obj;
|
||||
VISetBlack(true);
|
||||
VIConfigure(obj);
|
||||
VIFlush();
|
||||
mConfiguredTime = OSGetTick();
|
||||
mFlag.setBit(0);
|
||||
u16 efbWidth = obj->fbWidth;
|
||||
u16 efbHeight = obj->efbHeight;
|
||||
f32 factor = GXGetYScaleFactor(efbHeight, obj->xfbHeight);
|
||||
u16 lines = GXGetNumXfbLines(efbHeight, factor);
|
||||
GXSetDispCopySrc(0, 0, efbWidth, efbHeight);
|
||||
GXSetDispCopyDst(efbWidth, lines);
|
||||
GXSetDispCopyYScale(factor);
|
||||
VIWaitForRetrace();
|
||||
VIWaitForRetrace();
|
||||
}
|
||||
|
||||
return oldMode;
|
||||
}
|
||||
|
||||
// Random function that pretends to do an int to float
|
||||
// cast here, for float ordering issues
|
||||
f32 itof(u32 n) {
|
||||
return n;
|
||||
}
|
||||
// TODO VITvFormat
|
||||
/* 80498800 */ u32 Video::getTickPerVRetrace(u32 tvFormat) {
|
||||
f32 val = tvFormat - 1 <= VI_TV_FMT_PAL ? 50.0f : 59.94f;
|
||||
return (u32)((OS_BUS_CLOCK_SPEED >> 2) / val);
|
||||
}
|
||||
/* 80498860 */ u32 Video::getTickPerVRetrace() {
|
||||
return getTickPerVRetrace(VIGetTvFormat());
|
||||
}
|
||||
/* 80498890 */ const GXRenderModeObj *Video::getStandardRenderModeObj(const RenderModeObjSet *set) {
|
||||
bool pmode = SCGetProgressiveMode() == 1;
|
||||
bool rbg60mode = SCGetEuRgb60Mode() == 1;
|
||||
bool aspect = SCGetAspectRatio() == 0;
|
||||
bool dtvstatus = VIGetDTVStatus() == 1;
|
||||
u32 tvFormat = VIGetTvFormat();
|
||||
|
||||
bool isNtscLike;
|
||||
switch (tvFormat) {
|
||||
case VI_TV_FMT_NTSC:
|
||||
isNtscLike = true;
|
||||
break;
|
||||
case VI_TV_FMT_PAL:
|
||||
case VI_TV_FMT_EURGB60:
|
||||
isNtscLike = false;
|
||||
break;
|
||||
default:
|
||||
isNtscLike = true;
|
||||
}
|
||||
|
||||
if (dtvstatus && pmode) {
|
||||
if (isNtscLike) {
|
||||
if (aspect) {
|
||||
return set->table[1];
|
||||
} else {
|
||||
return set->table[6];
|
||||
}
|
||||
} else if (aspect) {
|
||||
return set->table[4];
|
||||
} else {
|
||||
return set->table[9];
|
||||
}
|
||||
} else if (isNtscLike) {
|
||||
if (aspect) {
|
||||
return set->table[0];
|
||||
} else {
|
||||
return set->table[5];
|
||||
}
|
||||
} else if (rbg60mode) {
|
||||
if (aspect) {
|
||||
return set->table[3];
|
||||
} else {
|
||||
return set->table[8];
|
||||
}
|
||||
} else if (aspect) {
|
||||
return set->table[2];
|
||||
}
|
||||
return set->table[7];
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
Reference in New Issue
Block a user