mirror of
https://github.com/zeldaret/ss
synced 2026-08-19 13:53:25 -04:00
Misc Egg (#37)
* EGG: Archive, DvdFile, DvdRipper * start eggStream * FrmHeap and AssertHeap OK * progress on EggController * port in WPAD stuff * update WPAD/WUD/KPAD/SC symbols * eggController OK * bytematch more CoreController virtual funcs * eggDecomp/eggStreamDecomp Ok * eggDvdRipper OK * EGG gfx splits * Finished Splitting EGG * create egg Files * eggDecomp.h -> eggStreamDecomp.h * Revert some format changes
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
#include <egg/audio/eggAudioArcPlayerMgr.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/audio/eggAudioHeapMgr.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/audio/eggAudioMgr.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/audio/eggAudioRmtSpeakerMgr.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/audio/eggAudioSystem.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/audio/eggAudioUtility.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -1,11 +1,11 @@
|
||||
#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);
|
||||
/* 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);
|
||||
/* 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 = {
|
||||
@@ -15,14 +15,13 @@ const MEMAllocatorFuncs eggAllocatorFuncs = {
|
||||
|
||||
// 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) {
|
||||
/* 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) {
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
#include <egg/core/eggArchive.h>
|
||||
#include <egg/core/eggHeap.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
bool Archive::sIsArchiveListInitialized;
|
||||
nw4r::ut::List Archive::sArchiveList;
|
||||
|
||||
s32 readNANDFile(NANDFileInfo *info, void *buf, u32 len, s32 offs) {
|
||||
s32 seek = NANDSeek(info, offs, NAND_SEEK_BEG);
|
||||
if (seek == offs) {
|
||||
return NANDRead(info, buf, len);
|
||||
}
|
||||
return seek;
|
||||
}
|
||||
|
||||
Archive::Archive() {
|
||||
mDvdEntryNum = -1;
|
||||
mNandFile = nullptr;
|
||||
mRefCount = 1;
|
||||
mMountType = MOUNT_NONE;
|
||||
memset(&mHandle, 0, sizeof(ARCHandle));
|
||||
appendList(this);
|
||||
}
|
||||
|
||||
Archive::~Archive() {
|
||||
removeList(this);
|
||||
}
|
||||
|
||||
bool Archive::initHandle(void *data, MountType mount) {
|
||||
bool success = false;
|
||||
|
||||
if (data) {
|
||||
success = ARCInitHandle(data, &mHandle);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
mMountType = mount;
|
||||
} else {
|
||||
mMountType = MOUNT_NONE;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Archive *Archive::findArchive(void *data) {
|
||||
Archive *arc = nullptr;
|
||||
|
||||
if (sIsArchiveListInitialized && data) {
|
||||
Archive *node = nullptr;
|
||||
while (node = (Archive *)nw4r::ut::List_GetNext(&sArchiveList, node)) {
|
||||
if (node->mHandle.header == data) {
|
||||
arc = node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arc;
|
||||
}
|
||||
|
||||
Archive *Archive::findArchive(NANDFileInfo *data) {
|
||||
Archive *arc = nullptr;
|
||||
|
||||
if (sIsArchiveListInitialized && data) {
|
||||
Archive *node = nullptr;
|
||||
while (node = (Archive *)nw4r::ut::List_GetNext(&sArchiveList, node)) {
|
||||
if (node->mNandFile == data) {
|
||||
arc = node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arc;
|
||||
}
|
||||
|
||||
void Archive::appendList(Archive *arc) {
|
||||
if (!sIsArchiveListInitialized) {
|
||||
nw4r::ut::List_Init(&sArchiveList, offsetof(Archive, mLink));
|
||||
sIsArchiveListInitialized = true;
|
||||
}
|
||||
|
||||
nw4r::ut::List_Append(&sArchiveList, arc);
|
||||
}
|
||||
|
||||
void Archive::removeList(Archive *arc) {
|
||||
nw4r::ut::List_Remove(&sArchiveList, arc);
|
||||
}
|
||||
|
||||
Archive *Archive::mount(void *data, Heap *pHeap, int align) {
|
||||
if (data == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Archive *arc = findArchive(data);
|
||||
if (!arc) {
|
||||
arc = new (pHeap, align) Archive();
|
||||
|
||||
if (!arc || !arc->initHandle(data, MOUNT_MEM)) {
|
||||
delete arc;
|
||||
arc = nullptr;
|
||||
}
|
||||
} else {
|
||||
arc->mRefCount++;
|
||||
}
|
||||
|
||||
return arc;
|
||||
}
|
||||
|
||||
Archive *Archive::mountFST(void *data, Heap *pHeap, int align) {
|
||||
if (data == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Archive *arc = findArchive(data);
|
||||
if (!arc) {
|
||||
arc = new (pHeap, align) Archive();
|
||||
|
||||
if (!arc || !arc->initHandle(data, MOUNT_NAND)) {
|
||||
delete arc;
|
||||
arc = nullptr;
|
||||
}
|
||||
} else {
|
||||
arc->mRefCount++;
|
||||
}
|
||||
|
||||
return arc;
|
||||
}
|
||||
|
||||
Archive *Archive::mountNAND(NANDFileInfo *nandFile, Heap *pHeap, int align) {
|
||||
Archive *arc = findArchive(nandFile);
|
||||
if (!arc) {
|
||||
void *arc_bin = loadNAND(nandFile, pHeap, align);
|
||||
arc = mountFST(arc_bin, pHeap, align);
|
||||
arc->mNandFile = nandFile;
|
||||
} else {
|
||||
arc->mRefCount++;
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
Archive *Archive::loadFST(const char *fileName, Heap *pHeap, int align) {
|
||||
NANDFileInfo *nandFile = (NANDFileInfo *)pHeap->alloc(sizeof(NANDFileInfo), align > 0 ? -0x20 : 0x20);
|
||||
|
||||
if (NANDOpen(fileName, nandFile, NAND_ACCESS_READ) != NAND_RESULT_OK) {
|
||||
pHeap->free(nandFile);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mountNAND(nandFile, pHeap, align);
|
||||
}
|
||||
|
||||
void Archive::unmount() {
|
||||
if (mRefCount == 0) {
|
||||
return;
|
||||
}
|
||||
if (--mRefCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mNandFile) {
|
||||
NANDClose(mNandFile);
|
||||
Heap::free(mNandFile, nullptr);
|
||||
mNandFile = nullptr;
|
||||
}
|
||||
mDvdEntryNum = -1;
|
||||
mMountType = MOUNT_NONE;
|
||||
delete this;
|
||||
}
|
||||
|
||||
void *Archive::getFile(const char *path, FileInfo *fileInfo) {
|
||||
ARCFileInfo arcFileInfo;
|
||||
void *file = nullptr;
|
||||
bool opened = false;
|
||||
int entryNum = ARCConvertPathToEntrynum(&mHandle, path);
|
||||
|
||||
if (entryNum != -1) {
|
||||
opened = ARCFastOpen(&mHandle, entryNum, &arcFileInfo);
|
||||
}
|
||||
|
||||
if (opened) {
|
||||
if (mMountType == MOUNT_MEM) {
|
||||
file = ARCGetStartAddrInMem(&arcFileInfo);
|
||||
}
|
||||
if (fileInfo) {
|
||||
fileInfo->mArcStartOffset = ARCGetStartOffset(&arcFileInfo);
|
||||
fileInfo->mArcLength = ARCGetLength(&arcFileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
ARCClose(&arcFileInfo);
|
||||
return file;
|
||||
}
|
||||
|
||||
s32 Archive::convertPathToEntryID(const char *path) {
|
||||
return ARCConvertPathToEntrynum(&mHandle, path);
|
||||
}
|
||||
|
||||
void *Archive::getFileFast(s32 entryId, FileInfo *fileInfo) {
|
||||
if (entryId == -1) {
|
||||
if (fileInfo) {
|
||||
fileInfo->mArcStartOffset = 0;
|
||||
fileInfo->mArcLength = 0;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *file = nullptr;
|
||||
if (mMountType == MOUNT_MEM) {
|
||||
ARCFileInfo arcFileInfo;
|
||||
bool opened = ARCFastOpen(&mHandle, entryId, &arcFileInfo);
|
||||
if (opened) {
|
||||
file = ARCGetStartAddrInMem(&arcFileInfo);
|
||||
if (fileInfo) {
|
||||
fileInfo->mArcStartOffset = ARCGetStartOffset(&arcFileInfo);
|
||||
fileInfo->mArcLength = ARCGetLength(&arcFileInfo);
|
||||
}
|
||||
}
|
||||
ARCClose(&arcFileInfo);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
void *Archive::getFileFast(s32 entryId, Heap *pHeap, int align) {
|
||||
if (entryId == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
u32 file_len;
|
||||
void *file = nullptr;
|
||||
ARCFileInfo arcFileInfo;
|
||||
bool opened = ARCFastOpen(&mHandle, entryId, &arcFileInfo);
|
||||
|
||||
if (opened) {
|
||||
file_len = ROUND_UP(ARCGetLength(&arcFileInfo), 0x20);
|
||||
file = pHeap->alloc(file_len, align);
|
||||
if (file) {
|
||||
if (mMountType == MOUNT_MEM) {
|
||||
void *startAddr = ARCGetStartAddrInMem(&arcFileInfo);
|
||||
memcpy(file, startAddr, file_len);
|
||||
} else {
|
||||
u32 offs = ARCGetStartOffset(&arcFileInfo);
|
||||
if (mNandFile) {
|
||||
readNANDFile(mNandFile, file, file_len, offs);
|
||||
} else {
|
||||
if (mDvdEntryNum != -1) {
|
||||
DVDFileInfo dvdFileInfo;
|
||||
DVDFastOpen(mDvdEntryNum, &dvdFileInfo);
|
||||
DVDReadPrio(&dvdFileInfo, file, file_len, offs, DVD_PRIO_MEDIUM);
|
||||
DVDClose(&dvdFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ARCClose(&arcFileInfo);
|
||||
return file;
|
||||
}
|
||||
|
||||
void countFileCallbackFunc(void *arg1, void *arg2, const ARCDirEntry *, const char *) {
|
||||
if (!arg2) {
|
||||
return;
|
||||
}
|
||||
(*(u32 *)arg1)++;
|
||||
return;
|
||||
}
|
||||
|
||||
s32 Archive::countFile() {
|
||||
u32 count = 0;
|
||||
searchInside(countFileCallbackFunc, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
void searchInsideWithPath(
|
||||
Archive *arc, ARCHandle *handle, FileCallbackFunc cb, void *cbArg, char *outPath, u32 max_len
|
||||
) {
|
||||
ARCDir dir;
|
||||
if (ARCOpenDir(handle, outPath, &dir)) {
|
||||
ARCDirEntry dirEntry;
|
||||
while (ARCReadDir(&dir, &dirEntry)) {
|
||||
size_t path_len = strlen(outPath);
|
||||
if (dirEntry.isDir) {
|
||||
size_t dir_len = strlen(dirEntry.name) + 1;
|
||||
strcat(outPath, dirEntry.name);
|
||||
cb(cbArg, nullptr, &dirEntry, outPath);
|
||||
strcat(outPath, "/");
|
||||
searchInsideWithPath(arc, handle, cb, cbArg, outPath, max_len - dir_len);
|
||||
} else {
|
||||
size_t _unused = strlen(dirEntry.name);
|
||||
strcat(outPath, dirEntry.name);
|
||||
cb(cbArg, arc->getFile(outPath, nullptr), &dirEntry, outPath);
|
||||
}
|
||||
outPath[path_len] = '\0';
|
||||
}
|
||||
ARCCloseDir(&dir);
|
||||
}
|
||||
}
|
||||
|
||||
void Archive::searchInside(FileCallbackFunc cb, void *cbArg) {
|
||||
char buffer[256];
|
||||
strcpy(buffer, "/");
|
||||
size_t bufSize = sizeof(buffer);
|
||||
bufSize -= 1 + strlen(buffer);
|
||||
searchInsideWithPath(this, &mHandle, cb, cbArg, buffer, bufSize);
|
||||
}
|
||||
|
||||
void *Archive::loadNAND(NANDFileInfo *fileInfo, Heap *pHeap, int align) {
|
||||
int file_align = align >= 0 ? 0x20 : -0x20;
|
||||
void *arc_file = nullptr;
|
||||
ARCHeader *header = (ARCHeader *)pHeap->alloc(sizeof(ARCHeader), -file_align);
|
||||
if (header) {
|
||||
s32 readres = readNANDFile(fileInfo, header, sizeof(ARCHeader), 0);
|
||||
if (readres >= sizeof(ARCHeader)) {
|
||||
u32 file_len = ROUND_UP(header->nodes.size + sizeof(ARCHeader), 0x20);
|
||||
arc_file = pHeap->alloc(file_len, file_align);
|
||||
if (arc_file) {
|
||||
readres = readNANDFile(fileInfo, arc_file, file_len, 0);
|
||||
if (readres != file_len) {
|
||||
pHeap->free(arc_file);
|
||||
arc_file = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
pHeap->free(header);
|
||||
}
|
||||
return arc_file;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -0,0 +1,126 @@
|
||||
#include <egg/core/eggAssertHeap.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
AssertHeap::AssertHeap(MEMiHeapHead *pHead) : Heap(pHead) {}
|
||||
|
||||
AssertHeap::~AssertHeap() {
|
||||
dispose();
|
||||
MEMDestroyFrmHeap(mHeapHandle);
|
||||
}
|
||||
|
||||
AssertHeap *AssertHeap::create(void *pBlock, u32 size) {
|
||||
AssertHeap *heap = nullptr;
|
||||
void *startAddr = pBlock;
|
||||
void *heapEnd = ROUND_DOWN_PTR((u8 *)pBlock + size, 0x04);
|
||||
pBlock = ROUND_UP_PTR(pBlock, 0x04);
|
||||
|
||||
if (pBlock > heapEnd || ((u8 *)heapEnd - (u8 *)pBlock) < 0x38u) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MEMiHeapHead *head =
|
||||
MEMCreateFrmHeapEx((u8 *)pBlock + sizeof(AssertHeap), ((u8 *)heapEnd - (u8 *)pBlock) - sizeof(AssertHeap), 0);
|
||||
if (head != nullptr) {
|
||||
heap = new (pBlock) AssertHeap(head);
|
||||
heap->mParentBlock = startAddr;
|
||||
if (sCreateCallback != nullptr) {
|
||||
(sCreateCallback)(heap);
|
||||
}
|
||||
}
|
||||
|
||||
return heap;
|
||||
}
|
||||
|
||||
AssertHeap *AssertHeap::create(u32 size, Heap *pHeap) {
|
||||
AssertHeap *assertHeap = nullptr;
|
||||
|
||||
if (!pHeap) {
|
||||
pHeap = sCurrentHeap;
|
||||
}
|
||||
if (size == -1) {
|
||||
size = pHeap->getAllocatableSize(4);
|
||||
} else if (size == 0) {
|
||||
size = getSize();
|
||||
}
|
||||
|
||||
void *pBlock = pHeap->alloc(size, 4);
|
||||
if (pBlock) {
|
||||
assertHeap = create(pBlock, size);
|
||||
if (!assertHeap) {
|
||||
pHeap->free(pBlock);
|
||||
}
|
||||
}
|
||||
|
||||
return assertHeap;
|
||||
}
|
||||
|
||||
void AssertHeap::destroy() {
|
||||
if (sDestroyCallback) {
|
||||
sDestroyCallback(this);
|
||||
}
|
||||
|
||||
Heap *parent = findParentHeap();
|
||||
this->~AssertHeap();
|
||||
if (parent) {
|
||||
parent->free(this);
|
||||
}
|
||||
}
|
||||
|
||||
void *AssertHeap::alloc(u32 size, s32 align) {
|
||||
if (sAllocCallback) {
|
||||
HeapAllocArg arg;
|
||||
arg.userArg = sAllocCallbackArg;
|
||||
arg.size = size;
|
||||
arg.align = align;
|
||||
arg.heap = this;
|
||||
arg.ptr = nullptr;
|
||||
sAllocCallback(&arg);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AssertHeap::free(void *pBlock) {
|
||||
if (sFreeCallback != nullptr) {
|
||||
HeapFreeArg arg;
|
||||
arg.userArg = sFreeCallbackArg;
|
||||
arg.ptr = pBlock;
|
||||
arg.heap = this;
|
||||
(sFreeCallback)(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
u32 AssertHeap::resizeForMBlock(void *pBlock, u32 size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 AssertHeap::getTotalFreeSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 AssertHeap::getAllocatableSize(s32 align) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 AssertHeap::adjust() {
|
||||
u32 adjustedSize = MEMAdjustFrmHeap(mHeapHandle);
|
||||
u32 totalSize = adjustedSize + sizeof(AssertHeap);
|
||||
if (totalSize > sizeof(AssertHeap)) {
|
||||
Heap *parent = findParentHeap();
|
||||
if (parent != nullptr) {
|
||||
parent->resizeForMBlock(mParentBlock, totalSize);
|
||||
return totalSize;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t AssertHeap::getSize() {
|
||||
return 0x7C;
|
||||
}
|
||||
|
||||
Heap::eHeapKind AssertHeap::getHeapKind() const {
|
||||
return HEAP_KIND_ASSERT;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -58,8 +58,10 @@ inline void AsyncDisplay::waitForMsg(bool b) {
|
||||
// This is really ugly but I couldn't find a different way
|
||||
// to make the compiler use the registers
|
||||
XfbManager *xfb;
|
||||
while (!((xfb = BaseSystem::mConfigData->getXfbMgr(), 1 < xfb->mNumXfbs - this->field_0xAC) &&
|
||||
(BaseSystem::mConfigData->getXfbMgr()->mToCopyXfb != nullptr || b))) {
|
||||
while (
|
||||
!((xfb = BaseSystem::mConfigData->getXfbMgr(), 1 < xfb->mNumXfbs - this->field_0xAC) &&
|
||||
(BaseSystem::mConfigData->getXfbMgr()->mToCopyXfb != nullptr || b))
|
||||
) {
|
||||
OSReceiveMessage(&this->mMesgQueue, this->mMesgBuf, 1);
|
||||
|
||||
while (OSReceiveMessage(&this->mMesgQueue, this->mMesgBuf, 0)) {}
|
||||
@@ -159,8 +161,9 @@ void AsyncDisplay::preVRetrace() {
|
||||
void AsyncDisplay::clearEFB() {
|
||||
Video *video = BaseSystem::mConfigData->getVideo();
|
||||
GXRenderModeObj const *renderMode = video->pRenderMode;
|
||||
this->clearEFB(renderMode->fbWidth, renderMode->efbHeight, 0, 0, renderMode->fbWidth, renderMode->efbHeight,
|
||||
this->mClearColor);
|
||||
this->clearEFB(
|
||||
renderMode->fbWidth, renderMode->efbHeight, 0, 0, renderMode->fbWidth, renderMode->efbHeight, this->mClearColor
|
||||
);
|
||||
}
|
||||
|
||||
u32 AsyncDisplay::getTickPerFrame() {
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
#include <rvl/GX/GXHardware.h>
|
||||
#include <rvl/GX/GXTexture.h>
|
||||
|
||||
|
||||
/* 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), mFlags(0) {
|
||||
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),
|
||||
mFlags(0) {
|
||||
setColor(color);
|
||||
setStatus(initialStatus);
|
||||
mFlags.setBit(1);
|
||||
|
||||
+358
-174
@@ -1,11 +1,13 @@
|
||||
|
||||
#include "egg/core/eggController.h"
|
||||
|
||||
#include "MSL_C/string.h"
|
||||
#include "egg/core/eggAllocator.h"
|
||||
#include "egg/core/eggExpHeap.h"
|
||||
#include "egg/core/eggSystem.h"
|
||||
#include "egg/math/eggMath.h"
|
||||
#include "rvl/VI.h"
|
||||
|
||||
|
||||
EGG::NullController null_controller;
|
||||
namespace EGG {
|
||||
|
||||
@@ -15,33 +17,32 @@ ControllerFactory CoreControllerMgr::sCoreControllerFactory;
|
||||
ConnectCallback CoreControllerMgr::sConnectCallback;
|
||||
// This controls whether EggController registers an allocator within the WPAD driver
|
||||
bool CoreControllerMgr::sUseBuiltinWpadAllocator;
|
||||
static Allocator *sWPADAllocator;
|
||||
s32 CoreControllerMgr::sWPADWorkSize = 0x32000;
|
||||
|
||||
/* 0x80498F90 */ void CoreStatus::init() {
|
||||
void CoreStatus::init() {
|
||||
memset(this, 0, sizeof(CoreStatus));
|
||||
}
|
||||
|
||||
/* 0x80498FA0 */ u32 CoreStatus::getFSStickButton() const {
|
||||
f32 button = this->fsStickButton;
|
||||
u32 CoreStatus::getFSStickButton() const {
|
||||
f32 stick = getFSStickX();
|
||||
u32 result = 0;
|
||||
// TODO what are these flags and why is this code so weird?
|
||||
|
||||
if (!(-0.25f < button) || !(button < 0.25f)) {
|
||||
if (button <= -0.5f) {
|
||||
if (!(-0.25f < stick) || !(stick < 0.25f)) {
|
||||
if (stick <= -0.5f) {
|
||||
result = 0;
|
||||
result |= 0x40000;
|
||||
} else if (button >= 0.5f) {
|
||||
} else if (stick >= 0.5f) {
|
||||
result = 0;
|
||||
result |= 0x80000;
|
||||
}
|
||||
}
|
||||
|
||||
button = this->fsStickButton2;
|
||||
if (!(-0.25f < button) || !(button < 0.25f)) {
|
||||
if (button <= -0.5f) {
|
||||
stick = getFSStickY();
|
||||
if (!(-0.25f < stick) || !(stick < 0.25f)) {
|
||||
if (stick <= -0.5f) {
|
||||
result &= ~0x10000;
|
||||
result |= 0x20000;
|
||||
} else if (button >= 0.5f) {
|
||||
} else if (stick >= 0.5f) {
|
||||
result &= ~0x20000;
|
||||
result |= 0x10000;
|
||||
}
|
||||
@@ -50,116 +51,262 @@ static Allocator *sWPADAllocator;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* 0x80499050 */ CoreController::CoreController() : mDpdPos(), mAccel(), mAccelFlags(), mFlag(0) {
|
||||
this->mRumbleMgr = nullptr;
|
||||
this->mButtonHeld = 0;
|
||||
this->mButtonTriggered = 0;
|
||||
this->mButtonReleased = 0;
|
||||
this->sceneReset();
|
||||
this->mFlag.makeAllZero();
|
||||
CoreController::CoreController() : mDpdPos(), mAccel(), mAccelFlags(), mFlag(0) {
|
||||
mRumbleMgr = nullptr;
|
||||
mButtonHeld = 0;
|
||||
mButtonTriggered = 0;
|
||||
mButtonReleased = 0;
|
||||
sceneReset();
|
||||
mFlag.makeAllZero();
|
||||
}
|
||||
|
||||
/* 0x804990B0 */ void CoreController::sceneReset() {
|
||||
this->mAccel.set(0.0, 0.0, 0.0);
|
||||
this->mDpdPos.x = 0.0;
|
||||
this->mDpdPos.y = 0.0;
|
||||
this->field_0xf28 = 0;
|
||||
this->mPostureMatrixPrev.makeIdentity();
|
||||
this->mPostureMatrix.makeIdentity();
|
||||
this->mMaxAccelFrameTime = 10;
|
||||
this->mMaxAccelDiff = 0.13;
|
||||
this->mPrevAccel.set(0.0, 0.0, 0.0);
|
||||
this->mAccelFlags.makeAllZero();
|
||||
this->mAccelFrameTimeZ = 0;
|
||||
this->mAccelFrameTimeY = 0;
|
||||
this->mAccelFrameTimeX = 0;
|
||||
this->mMotorPattern = 0;
|
||||
this->mMotorFrameDuration = 0;
|
||||
this->mEnableMotor = false;
|
||||
this->mMotorPatternLength = 0x20;
|
||||
this->mMotorPatternPos = 0x1f;
|
||||
this->stopRumbleMgr();
|
||||
void CoreController::sceneReset() {
|
||||
mAccel.set(0.0, 0.0, 0.0);
|
||||
mDpdPos.x = 0.0;
|
||||
mDpdPos.y = 0.0;
|
||||
mIdleTime = 0;
|
||||
mPostureMatrixPrev.makeIdentity();
|
||||
mPostureMatrix.makeIdentity();
|
||||
mMaxAccelFrameTime = 10;
|
||||
mMaxAccelDiff = 0.13;
|
||||
mPrevAccel.set(0.0, 0.0, 0.0);
|
||||
mAccelFlags.makeAllZero();
|
||||
mAccelFrameTime[2] = 0;
|
||||
mAccelFrameTime[1] = 0;
|
||||
mAccelFrameTime[0] = 0;
|
||||
mMotorPattern = 0;
|
||||
mMotorFrameDuration = 0;
|
||||
mEnableMotor = false;
|
||||
mMotorPatternLength = 0x20;
|
||||
mMotorPatternPos = 0x1f;
|
||||
stopRumbleMgr();
|
||||
}
|
||||
|
||||
/* 0x80499170 */ Vector2f CoreController::getDpdRawPos() const {
|
||||
return Vector2f(this->coreStatus[0].dpdRawX, this->coreStatus[0].dpdRawY);
|
||||
Vector2f CoreController::getDpdRawPos() {
|
||||
return Vector2f(mCoreStatus[0].mDpdRawX, mCoreStatus[0].mDpdRawY);
|
||||
}
|
||||
|
||||
/* 0x80499190 */ s32 CoreController::getDpdDistance() const {
|
||||
return this->coreStatus[0].dpdDistance;
|
||||
f32 CoreController::getDpdDistance() {
|
||||
return mCoreStatus[0].mDpdDistance;
|
||||
}
|
||||
|
||||
// TODO
|
||||
extern "C" void fn_803DB1E0(s32 channel, bool arg);
|
||||
|
||||
/* 0x804991A0 */ void CoreController::startMotor() {
|
||||
fn_803DB1E0(mChannelID, true);
|
||||
s32 CoreController::getDpdValidFlag() {
|
||||
return mCoreStatus[0].getDpdValidFlag();
|
||||
}
|
||||
|
||||
/* 0x804991B0 */ void CoreController::stopMotor() {
|
||||
fn_803DB1E0(mChannelID, false);
|
||||
void CoreController::startMotor() {
|
||||
WPADControlMotor(mChannelID, WPAD_MOTOR_RUMBLE);
|
||||
}
|
||||
|
||||
/* 0x804991C0 */ void CoreController::createRumbleMgr(u8 numUnits) {
|
||||
this->mRumbleMgr = new ControllerRumbleMgr();
|
||||
this->mRumbleMgr->createUnit(numUnits, this);
|
||||
void CoreController::stopMotor() {
|
||||
WPADControlMotor(mChannelID, WPAD_MOTOR_STOP);
|
||||
}
|
||||
|
||||
/* 0x80499220 */ void CoreController::startPatternRumble(const char *pattern, int duration, bool bGrabActive) {
|
||||
if (this->mRumbleMgr) {
|
||||
this->mRumbleMgr->startPattern(pattern, duration, bGrabActive);
|
||||
void CoreController::createRumbleMgr(u8 numUnits) {
|
||||
mRumbleMgr = new ControllerRumbleMgr();
|
||||
mRumbleMgr->createUnit(numUnits, this);
|
||||
}
|
||||
|
||||
void CoreController::startPatternRumble(const char *pattern, int duration, bool bGrabActive) {
|
||||
if (mRumbleMgr) {
|
||||
mRumbleMgr->startPattern(pattern, duration, bGrabActive);
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x80499240 */ void CoreController::stopRumbleMgr() {
|
||||
if (this->mRumbleMgr) {
|
||||
this->mRumbleMgr->stop();
|
||||
void CoreController::stopRumbleMgr() {
|
||||
if (mRumbleMgr) {
|
||||
mRumbleMgr->stop();
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x80499260 */ CoreStatus *CoreController::getCoreStatus(s32 idx) {
|
||||
return &this->coreStatus[idx];
|
||||
CoreStatus *CoreController::getCoreStatus(int idx) {
|
||||
return &mCoreStatus[idx];
|
||||
}
|
||||
|
||||
/* 0x80499270 */ void CoreController::calc_posture_matrix(Matrix34f &mat, bool someBool) {
|
||||
if (!someBool || this->mAccelFlags.onBit(7)) {
|
||||
Vector3f vec = Vector3f(-mat(2, 3), -mat(2, 2), -mat(2, 1));
|
||||
Vector3f vec3 = vec;
|
||||
vec.normalise();
|
||||
// TODO lots of inlined math
|
||||
void CoreController::calc_posture_matrix(Matrix34f &posture, bool checkStable) {
|
||||
if (checkStable && !isStable(7)) {
|
||||
return;
|
||||
}
|
||||
Vector3f acc = -getAccel();
|
||||
Vector3f vy = acc;
|
||||
vy.normalise();
|
||||
|
||||
Vector3f vz(0.0f, 0.0f, 1.0f);
|
||||
Vector3f vx(1.0f, 0.0f, 0.0f);
|
||||
|
||||
Vector3f bx, by, bz;
|
||||
mPostureMatrixPrev.getBase(0, bx);
|
||||
mPostureMatrixPrev.getBase(1, by);
|
||||
mPostureMatrixPrev.getBase(2, bz);
|
||||
|
||||
Vector3f vz_n(0.0f, 0.0f, -1.0f);
|
||||
Vector3f vx_n(-1.0f, 0.0f, 0.0f);
|
||||
|
||||
if (vz.dot(bz) < vz_n.dot(bz)) {
|
||||
vz = vz_n;
|
||||
}
|
||||
|
||||
if (vx.dot(bx) < vx_n.dot(bx)) {
|
||||
vx = vx_n;
|
||||
}
|
||||
|
||||
if (Math<f32>::abs(vy.dot(vz)) < Math<f32>::abs(vy.dot(vx))) {
|
||||
vx = vy.cross(vz);
|
||||
vx.normalise();
|
||||
vz = vx.cross(vy);
|
||||
vz.normalise();
|
||||
} else {
|
||||
vz = vx.cross(vy);
|
||||
vz.normalise();
|
||||
vx = vy.cross(vz);
|
||||
vx.normalise();
|
||||
}
|
||||
|
||||
posture.setBase(0, vx);
|
||||
posture.setBase(1, vy);
|
||||
posture.setBase(2, vz);
|
||||
}
|
||||
|
||||
void CoreController::beginFrame(PADStatus *padStatus) {
|
||||
s32 kpad_result;
|
||||
mReadStatusIdx = KPADReadEx(mChannelID, mCoreStatus, 0x10, &kpad_result);
|
||||
if (mReadStatusIdx == 0 && kpad_result == -1 /* Rvl usually uses negative nums for results */) {
|
||||
mReadStatusIdx = 1;
|
||||
}
|
||||
|
||||
WPADDeviceType dev_type;
|
||||
switch (WPADProbe(mChannelID, &dev_type)) {
|
||||
case WPAD_ERR_OK: {
|
||||
if ((u32)dev_type == WPAD_DEV_NONE) {
|
||||
mFlag.resetBit(0);
|
||||
} else {
|
||||
mFlag.setBit(0);
|
||||
}
|
||||
} break;
|
||||
case WPAD_ERR_NO_CONTROLLER: {
|
||||
mFlag.resetBit(0);
|
||||
} break;
|
||||
}
|
||||
|
||||
if (mReadStatusIdx > 0) {
|
||||
CoreStatus *pStatus = mCoreStatus;
|
||||
u32 prev_held = mButtonHeld;
|
||||
if (pStatus->isFreestyle()) {
|
||||
mButtonHeld = pStatus->getFSStickButton();
|
||||
} else {
|
||||
mButtonHeld = 0;
|
||||
}
|
||||
|
||||
mButtonTriggered = mButtonHeld & ~prev_held;
|
||||
mButtonReleased = prev_held & ~mButtonHeld;
|
||||
pStatus->mHold &= ~0xF0000;
|
||||
pStatus->mTrig &= ~0xF0000;
|
||||
pStatus->mRelease &= ~0xF0000;
|
||||
pStatus->mHold |= (mButtonHeld & 0xF0000);
|
||||
pStatus->mTrig |= (mButtonTriggered & 0xF0000);
|
||||
pStatus->mRelease |= (mButtonReleased & 0xF0000);
|
||||
}
|
||||
|
||||
mPostureMatrixPrev.copyFrom(mPostureMatrix);
|
||||
mAccelFlags.makeAllZero();
|
||||
Vector3f acc = mCoreStatus->getAccel();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (acc(i) - mAccel(i) < mMaxAccelDiff) {
|
||||
if (mMaxAccelFrameTime <= ++mAccelFrameTime[i]) {
|
||||
mAccelFrameTime[i] = mMaxAccelFrameTime;
|
||||
mAccelFlags.set(1 << i);
|
||||
mPrevAccel(i) = acc(i);
|
||||
}
|
||||
} else {
|
||||
mAccelFlags.value &= ~(1 << i); // ?
|
||||
mAccelFrameTime[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
calc_posture_matrix(mPostureMatrix, true);
|
||||
|
||||
if (mEnableMotor) {
|
||||
if (mMotorPattern & (1 << mMotorPatternPos)) {
|
||||
startMotor();
|
||||
} else {
|
||||
stopMotor();
|
||||
}
|
||||
if (mMotorPatternPos == 0) {
|
||||
mMotorPatternPos = mMotorPatternLength - 1;
|
||||
} else {
|
||||
mMotorPatternPos = mMotorPatternPos - 1;
|
||||
}
|
||||
|
||||
if (--mMotorFrameDuration == 0) {
|
||||
stopMotor();
|
||||
mEnableMotor = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mRumbleMgr) {
|
||||
mRumbleMgr->calc();
|
||||
}
|
||||
bool increment = true;
|
||||
|
||||
if (mCoreStatus->getHold() != 0) {
|
||||
increment = false;
|
||||
}
|
||||
|
||||
if (increment) {
|
||||
Vector3f diff = (mAccel - mCoreStatus->getAccel());
|
||||
if (diff.squaredLength() > 0.01f) {
|
||||
increment = false;
|
||||
}
|
||||
}
|
||||
if (increment) {
|
||||
Vector2f diff = (mDpdPos - getDpdRawPos());
|
||||
if (diff.squaredLength() > 0.05f) {
|
||||
increment = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (increment) {
|
||||
// I dont know what this is for...
|
||||
// if no interaction, this increments? (30fps -> 2hrs)
|
||||
if (mIdleTime < 216000) {
|
||||
mIdleTime++;
|
||||
}
|
||||
} else {
|
||||
mIdleTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x80499660 */ void CoreController::beginFrame(void *padStatus) {}
|
||||
|
||||
/* 0x80499A60 */ void CoreController::endFrame() {
|
||||
this->mAccel(0) = this->coreStatus[0].accel[0];
|
||||
this->mAccel(1) = this->coreStatus[0].accel[1];
|
||||
this->mAccel(2) = this->coreStatus[0].accel[2];
|
||||
this->mDpdPos = this->getDpdRawPos();
|
||||
void CoreController::endFrame() {
|
||||
mAccel = getAccel();
|
||||
mDpdPos = getDpdRawPos();
|
||||
}
|
||||
|
||||
/* 0x80499AC0 */ f32 CoreController::getFreeStickX() const {
|
||||
if (this->coreStatus[0].field_0x00[0x5C] == 0) {
|
||||
/* 0x80499AC0 */
|
||||
f32 CoreController::getFreeStickX() const {
|
||||
if (mCoreStatus->getDevType() == WPAD_DEV_CORE) {
|
||||
return 0.0;
|
||||
}
|
||||
return ((f32 *)(&this->coreStatus[0].field_0x00))[0x18];
|
||||
return mCoreStatus[0].getFSStickX();
|
||||
}
|
||||
|
||||
/* 0x80499AE0 */ f32 CoreController::getFreeStickY() const {
|
||||
if (this->coreStatus[0].field_0x00[0x5C] == 0) {
|
||||
/* 0x80499AE0 */
|
||||
f32 CoreController::getFreeStickY() const {
|
||||
if (mCoreStatus->getDevType() == WPAD_DEV_CORE) {
|
||||
return 0.0;
|
||||
}
|
||||
return ((f32 *)(&this->coreStatus[0].field_0x00))[0x19];
|
||||
return mCoreStatus[0].getFSStickY();
|
||||
}
|
||||
|
||||
/* 0x80499B00 */ CoreControllerMgr::T__Disposer::~T__Disposer() {
|
||||
/* 0x80499B00 */
|
||||
CoreControllerMgr::T__Disposer::~T__Disposer() {
|
||||
if (this == CoreControllerMgr::T__Disposer::sStaticDisposer) {
|
||||
deleteInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x80499B80 */ CoreControllerMgr *CoreControllerMgr::createInstance() {
|
||||
/* 0x80499B80 */
|
||||
CoreControllerMgr *CoreControllerMgr::createInstance() {
|
||||
if (CoreControllerMgr::sInstance == nullptr) {
|
||||
CoreControllerMgr *mgr = new CoreControllerMgr();
|
||||
CoreControllerMgr::sInstance = mgr;
|
||||
@@ -168,56 +315,58 @@ extern "C" void fn_803DB1E0(s32 channel, bool arg);
|
||||
return CoreControllerMgr::sInstance;
|
||||
}
|
||||
|
||||
/* 0x80499BD0 */ void CoreControllerMgr::deleteInstance() {
|
||||
/* 0x80499BD0 */
|
||||
void CoreControllerMgr::deleteInstance() {
|
||||
CoreControllerMgr::sInstance = nullptr;
|
||||
CoreControllerMgr::T__Disposer::sStaticDisposer = nullptr;
|
||||
}
|
||||
|
||||
/* 0x80499BE0 */ EGG::CoreController *CoreControllerMgr::getNthController(int n) {
|
||||
return this->mControllers(n);
|
||||
/* 0x80499BE0 */
|
||||
EGG::CoreController *CoreControllerMgr::getNthController(int n) {
|
||||
return mControllers(n);
|
||||
}
|
||||
|
||||
/* 0x80499C70 */ void *CoreControllerMgr::allocThunk(size_t size) {
|
||||
return sWPADAllocator->alloc(size);
|
||||
namespace {
|
||||
|
||||
static Allocator *sAllocator;
|
||||
|
||||
void *alloc(size_t size) {
|
||||
return sAllocator->alloc(size);
|
||||
}
|
||||
|
||||
/* 0x80499C90 */ int CoreControllerMgr::deleteThunk(void *ptr) {
|
||||
sWPADAllocator->free(ptr);
|
||||
int free(void *ptr) {
|
||||
sAllocator->free(ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 0x80499CD0 */ void CoreControllerMgr::connectCallback(s32 a1, s32 a2) {
|
||||
} // namespace
|
||||
|
||||
/* 0x80499CD0 */
|
||||
void CoreControllerMgr::connectCallback(s32 a1, s32 a2) {
|
||||
int args[] = {a1, a2};
|
||||
if (sConnectCallback != nullptr) {
|
||||
(sConnectCallback)(args);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" s32 lbl_80574EE8;
|
||||
// TODO headers
|
||||
extern "C" void fn_803D9400(void *a, void *b);
|
||||
extern "C" void fn_803F2040(void *a, int b);
|
||||
extern "C" void fn_803F26B0(int a, void *b);
|
||||
|
||||
/* 0x80499D10 */ CoreControllerMgr::CoreControllerMgr() {
|
||||
/* 0x80499D10 */
|
||||
CoreControllerMgr::CoreControllerMgr() {
|
||||
const int idxes[] = {0, 1, 2, 3};
|
||||
if (sUseBuiltinWpadAllocator == false) {
|
||||
Heap *heap = ExpHeap::create(lbl_80574EE8, BaseSystem::mConfigData->mRootHeapMem2, 0);
|
||||
Heap *heap = ExpHeap::create(sWPADWorkSize, BaseSystem::mConfigData->mRootHeapMem2, 0);
|
||||
heap->mName = "EGG::CoreControllerMgr";
|
||||
sWPADAllocator = new Allocator(heap, 0x20);
|
||||
fn_803D9400(allocThunk, deleteThunk);
|
||||
sAllocator = new Allocator(heap, 0x20);
|
||||
WPADRegisterAllocator(alloc, free);
|
||||
}
|
||||
fn_803F2040(field_0x20, 0x40);
|
||||
KPADInitEx(field_0x20, 0x40);
|
||||
beginFrame();
|
||||
endFrame();
|
||||
VIWaitForRetrace();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
fn_803F26B0(idxes[i], connectCallback);
|
||||
KPADSetConnectCallback(idxes[i], connectCallback);
|
||||
}
|
||||
|
||||
// TODO these allocate calls cause the relevant inline buffer functions to be moved
|
||||
// from the bottom of the TU to after this ctor. How to fix?
|
||||
mControllers.allocate(4, 0);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (sCoreControllerFactory != nullptr) {
|
||||
@@ -232,133 +381,166 @@ extern "C" void fn_803F26B0(int a, void *b);
|
||||
mControllers(i)->mChannelID = idxes[i];
|
||||
mDevTypes(i) = (eCoreDevType)0xfd;
|
||||
}
|
||||
field_0x10A0 = 0;
|
||||
field_0x10A0 = nullptr;
|
||||
}
|
||||
|
||||
/* 0x8049A130 */ void CoreControllerMgr::beginFrame() {
|
||||
/* 0x8049A130 */
|
||||
void CoreControllerMgr::beginFrame() {
|
||||
for (int i = 0; i < mControllers.getSize(); ++i) {
|
||||
mControllers(i)->beginFrame(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x8049A1E0 */ void CoreControllerMgr::endFrame() {
|
||||
/* 0x8049A1E0 */
|
||||
void CoreControllerMgr::endFrame() {
|
||||
for (int i = 0; i < mControllers.mSize; i++) {
|
||||
mControllers(i)->endFrame();
|
||||
// TODO WPADprobe
|
||||
// Update device type after probe?
|
||||
|
||||
WPADDeviceType dev_type;
|
||||
s32 result = WPADProbe(i, &dev_type);
|
||||
|
||||
WPADDeviceType res_dev_type;
|
||||
if (result == WPAD_ERR_OK) {
|
||||
res_dev_type = dev_type;
|
||||
} else if (result == WPAD_ERR_NO_CONTROLLER) {
|
||||
res_dev_type = WPAD_DEV_NONE;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (field_0x10A0) {
|
||||
if (res_dev_type != mDevTypes(i)) {
|
||||
s32 sp0C[3];
|
||||
sp0C[0] = res_dev_type;
|
||||
sp0C[1] = mDevTypes(i);
|
||||
sp0C[2] = i;
|
||||
|
||||
field_0x10A0->v_08(sp0C);
|
||||
}
|
||||
}
|
||||
|
||||
mDevTypes(i) = (eCoreDevType)res_dev_type;
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x8049A3B0 */ void ControllerRumbleUnit::init() {
|
||||
this->mPattern = nullptr;
|
||||
this->mPatternPos = nullptr;
|
||||
this->mTimer = 0;
|
||||
this->mIntensity = 0.0;
|
||||
this->mRampUp = 0.0;
|
||||
this->mFlag.makeAllZero();
|
||||
/* 0x8049A3B0 */
|
||||
void ControllerRumbleUnit::init() {
|
||||
mPattern = nullptr;
|
||||
mPatternPos = nullptr;
|
||||
mTimer = 0;
|
||||
mIntensity = 0.0;
|
||||
mRampUp = 0.0;
|
||||
mFlag.makeAllZero();
|
||||
}
|
||||
|
||||
/* 0x8049A3E0 */ void ControllerRumbleUnit::startPattern(const char *pattern, int duration) {
|
||||
this->mPattern = pattern;
|
||||
this->mPatternPos = pattern;
|
||||
/* 0x8049A3E0 */
|
||||
void ControllerRumbleUnit::startPattern(const char *pattern, int duration) {
|
||||
mPattern = pattern;
|
||||
mPatternPos = pattern;
|
||||
|
||||
this->mFlag.value &= 0xef;
|
||||
this->mFlag.value &= 0xdf;
|
||||
mFlag.value &= 0xef;
|
||||
mFlag.value &= 0xdf;
|
||||
|
||||
if (duration < 0) {
|
||||
this->mFlag.set(0x10);
|
||||
mFlag.set(0x10);
|
||||
} else if (duration > 0) {
|
||||
this->mFlag.set(0x30);
|
||||
mFlag.set(0x30);
|
||||
}
|
||||
|
||||
this->mTimer = duration;
|
||||
this->mFlag.value = ((this->mFlag.value | 0x01) & 0xfd) | 0x8;
|
||||
mTimer = duration;
|
||||
|
||||
mFlag.setBit(0);
|
||||
mFlag.resetBit(1);
|
||||
mFlag.setBit(3);
|
||||
}
|
||||
|
||||
/* 0x8049A440 */ f32 ControllerRumbleUnit::calc() {
|
||||
/* 0x8049A440 */
|
||||
f32 ControllerRumbleUnit::calc() {
|
||||
f32 result = 0.0f;
|
||||
if (this->mFlag.onBit(3)) {
|
||||
if (this->mFlag.onBit(0)) {
|
||||
char x = *++this->mPatternPos;
|
||||
if (mFlag.onBit(3)) {
|
||||
if (mFlag.onBit(0)) {
|
||||
char x = *++mPatternPos;
|
||||
if (x == '\0') {
|
||||
if (this->mFlag.onBit(4)) {
|
||||
this->mPatternPos = this->mPattern;
|
||||
if (mFlag.onBit(4)) {
|
||||
mPatternPos = mPattern;
|
||||
} else {
|
||||
this->mFlag.reset(~0xf7);
|
||||
mFlag.resetBit(3);
|
||||
}
|
||||
} else if (x == '*') {
|
||||
result = 1.0f;
|
||||
}
|
||||
|
||||
if (this->mFlag.offBit(5)) {
|
||||
if (mFlag.offBit(5)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (--this->mTimer > 0) {
|
||||
if (--mTimer > 0) {
|
||||
return result;
|
||||
}
|
||||
this->mFlag.reset(~0xf7);
|
||||
mFlag.resetBit(3);
|
||||
return result;
|
||||
} else {
|
||||
f32 intensity = this->mIntensity + this->mRampUp;
|
||||
this->mIntensity = intensity;
|
||||
f32 intensity = mIntensity + mRampUp;
|
||||
mIntensity = intensity;
|
||||
if (intensity >= 1.0f) {
|
||||
result = 1.0f;
|
||||
this->mIntensity = 0.0f;
|
||||
mIntensity = 0.0f;
|
||||
}
|
||||
|
||||
// infinite flag?
|
||||
if (this->mFlag.onBit(2)) {
|
||||
if (mFlag.onBit(2)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (--this->mTimer > 0) {
|
||||
if (--mTimer > 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
this->mFlag.reset(~0xf7);
|
||||
mFlag.resetBit(3);
|
||||
return result;
|
||||
} else {
|
||||
return -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x8049A530 */ ControllerRumbleMgr::ControllerRumbleMgr() {
|
||||
this->mController = nullptr;
|
||||
// TODO offsetof macro
|
||||
List_Init(&this->mActiveUnitList, 0x1c);
|
||||
List_Init(&this->mInactiveUnitList, 0x1c);
|
||||
/* 0x8049A530 */
|
||||
ControllerRumbleMgr::ControllerRumbleMgr() {
|
||||
mController = nullptr;
|
||||
List_Init(&mActiveUnitList, offsetof(ControllerRumbleUnit, mNode));
|
||||
List_Init(&mInactiveUnitList, offsetof(ControllerRumbleUnit, mNode));
|
||||
}
|
||||
|
||||
/* 0x8049A590 */ void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) {
|
||||
/* 0x8049A590 */
|
||||
void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) {
|
||||
for (u8 created = 0; created < numUnits; created++) {
|
||||
ControllerRumbleUnit *unit = new ControllerRumbleUnit();
|
||||
List_Append(&this->mInactiveUnitList, unit);
|
||||
List_Append(&mInactiveUnitList, unit);
|
||||
}
|
||||
this->mController = ctrl;
|
||||
mController = ctrl;
|
||||
}
|
||||
|
||||
/* 0x8049A620 */ void ControllerRumbleMgr::stop() {
|
||||
this->mController->stopMotor();
|
||||
while (List_GetSize(&this->mActiveUnitList) != 0) {
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit *>(List_GetNext(&this->mActiveUnitList, nullptr));
|
||||
List_Remove(&this->mActiveUnitList, unit);
|
||||
List_Append(&this->mInactiveUnitList, unit);
|
||||
/* 0x8049A620 */
|
||||
void ControllerRumbleMgr::stop() {
|
||||
mController->stopMotor();
|
||||
while (List_GetSize(&mActiveUnitList) != 0) {
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit *>(List_GetNext(&mActiveUnitList, nullptr));
|
||||
List_Remove(&mActiveUnitList, unit);
|
||||
List_Append(&mInactiveUnitList, unit);
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x8049A690 */ void ControllerRumbleMgr::calc() {
|
||||
if (List_GetSize(&this->mActiveUnitList) != 0) {
|
||||
void *object = List_GetFirst(&this->mActiveUnitList);
|
||||
/* 0x8049A690 */
|
||||
void ControllerRumbleMgr::calc() {
|
||||
if (List_GetSize(&mActiveUnitList) != 0) {
|
||||
void *object = List_GetFirst(&mActiveUnitList);
|
||||
f32 acc = 0.0f;
|
||||
|
||||
while (object != nullptr) {
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit *>(object);
|
||||
f32 x = unit->calc();
|
||||
void *nextObject = List_GetNext(&this->mActiveUnitList, object);
|
||||
void *nextObject = List_GetNext(&mActiveUnitList, object);
|
||||
if (x < 0.0f) {
|
||||
List_Remove(&this->mActiveUnitList, object);
|
||||
List_Append(&this->mInactiveUnitList, object);
|
||||
List_Remove(&mActiveUnitList, object);
|
||||
List_Append(&mInactiveUnitList, object);
|
||||
} else {
|
||||
acc += x;
|
||||
}
|
||||
@@ -366,28 +548,30 @@ extern "C" void fn_803F26B0(int a, void *b);
|
||||
}
|
||||
|
||||
if (acc >= 1.0f) {
|
||||
this->mController->startMotor();
|
||||
mController->startMotor();
|
||||
} else {
|
||||
this->mController->stopMotor();
|
||||
mController->stopMotor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x8049A7A0 */ void ControllerRumbleMgr::startPattern(const char *pattern, int duration, bool bGrabActive) {
|
||||
/* 0x8049A7A0 */
|
||||
void ControllerRumbleMgr::startPattern(const char *pattern, int duration, bool bGrabActive) {
|
||||
EGG::ControllerRumbleUnit *unit = getUnitFromList(bGrabActive);
|
||||
if (unit != nullptr) {
|
||||
if (unit) {
|
||||
unit->startPattern(pattern, duration);
|
||||
}
|
||||
}
|
||||
|
||||
/* 0x8049A7F0 */ ControllerRumbleUnit *ControllerRumbleMgr::getUnitFromList(bool bGrabActive) {
|
||||
/* 0x8049A7F0 */
|
||||
ControllerRumbleUnit *ControllerRumbleMgr::getUnitFromList(bool bGrabActive) {
|
||||
void *first = List_GetFirst(&this->mInactiveUnitList);
|
||||
if (first != nullptr) {
|
||||
List_Remove(&this->mInactiveUnitList, first);
|
||||
List_Append(&this->mActiveUnitList, first);
|
||||
} else if (bGrabActive && (first = List_GetFirst(&this->mActiveUnitList), first != nullptr)) {
|
||||
List_Remove(&this->mActiveUnitList, first);
|
||||
List_Append(&this->mActiveUnitList, first);
|
||||
if (first) {
|
||||
List_Remove(&mInactiveUnitList, first);
|
||||
List_Append(&mActiveUnitList, first);
|
||||
} else if (bGrabActive && (first = List_GetFirst(&mActiveUnitList), first != nullptr)) {
|
||||
List_Remove(&mActiveUnitList, first);
|
||||
List_Append(&mActiveUnitList, first);
|
||||
}
|
||||
|
||||
return static_cast<ControllerRumbleUnit *>(first);
|
||||
|
||||
+31
-38
@@ -1,51 +1,43 @@
|
||||
#include "egg/core/eggDisplay.h"
|
||||
#include "nw4r/db/db_directPrint.h"
|
||||
|
||||
#include "egg/core/eggXfbManager.h"
|
||||
#include "nw4r/db/db_directPrint.h"
|
||||
#include "rvl/GX.h"
|
||||
#include "rvl/OS/OSHardware.h"
|
||||
|
||||
|
||||
extern "C" {
|
||||
void PreRetraceCallback(u32 retraceCount) {
|
||||
EGG::BaseSystem::getDisplay()->preVRetrace();
|
||||
}
|
||||
void PreRetraceCallback(u32 retraceCount) {
|
||||
EGG::BaseSystem::getDisplay()->preVRetrace();
|
||||
}
|
||||
namespace EGG {
|
||||
}
|
||||
namespace EGG {
|
||||
|
||||
u32 Display::sTickPeriod = ((OS_BUS_CLOCK_SPEED >> 2)/125000)*300 >> 3;
|
||||
u32 Display::sTickPeriod = ((OS_BUS_CLOCK_SPEED >> 2) / 125000) * 300 >> 3;
|
||||
|
||||
/* 80497570 */
|
||||
Display::Display(u8 maxRetrace) :
|
||||
mMaxRetraces(maxRetrace),
|
||||
mScreenStateFlag(0),
|
||||
mRetraceCount(0),
|
||||
mFrameCount(0),
|
||||
mClearColor(0x808080ff),
|
||||
mClearZ(0xFFFFFF),
|
||||
mBeginTick(0),
|
||||
mFlag(0)
|
||||
{
|
||||
/* 80497570 */
|
||||
Display::Display(u8 maxRetrace)
|
||||
: mMaxRetraces(maxRetrace), mScreenStateFlag(0), mRetraceCount(0), mFrameCount(0), mClearColor(0x808080ff),
|
||||
mClearZ(0xFFFFFF), mBeginTick(0), mFlag(0) {
|
||||
mFlag.setBit(mFlag_SetClear);
|
||||
mFlag.setBit(mFlag_WaitForRetrace);
|
||||
nw4r::db::DirectPrint_Init();
|
||||
VISetPreRetraceCallback(PreRetraceCallback);
|
||||
}
|
||||
|
||||
/* vt 0x18 | 804975f0 */
|
||||
/* vt 0x18 | 804975f0 */
|
||||
u32 Display::getTickPerFrame() {
|
||||
return Video::getTickPerVRetrace();
|
||||
}
|
||||
/* vt 0x08 | 80497600 */
|
||||
/* vt 0x08 | 80497600 */
|
||||
void Display::beginFrame() {
|
||||
|
||||
GXDrawDone();
|
||||
if (
|
||||
mFlag.onBit(mFlag_WaitForRetrace)
|
||||
|| (BaseSystem::getXfbMgr()->mNumXfbs == 1
|
||||
&& OSGetTick()-mLastTick > sTickPeriod)) {
|
||||
VIWaitForRetrace();
|
||||
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 ) {
|
||||
while (BaseSystem::getXfbMgr()->mToCopyXfb == 0) {
|
||||
VIWaitForRetrace();
|
||||
}
|
||||
copyEFBtoXFB();
|
||||
@@ -53,26 +45,27 @@ void Display::beginFrame() {
|
||||
mFrameCount++;
|
||||
}
|
||||
|
||||
/* vt 0x0C | 804976c0 */
|
||||
/* vt 0x0C | 804976c0 */
|
||||
void Display::beginRender() {
|
||||
return;
|
||||
}
|
||||
|
||||
/* vt 0x10 | 804976d0 */
|
||||
/* vt 0x10 | 804976d0 */
|
||||
void Display::endRender() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* vt 0x14 | 804976e0 */
|
||||
/* vt 0x14 | 804976e0 */
|
||||
void Display::endFrame() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* vt 0x1C | 804976f0 */
|
||||
/* vt 0x1C | 804976f0 */
|
||||
void Display::preVRetrace() {
|
||||
mLastTick = OSGetTick();
|
||||
if (VIGetRetraceCount() - mRetraceCount < mMaxRetraces) return;
|
||||
if (VIGetRetraceCount() - mRetraceCount < mMaxRetraces) {
|
||||
return;
|
||||
}
|
||||
if (mScreenStateFlag.onBit(mScreenStateFlag_SetBlack)) {
|
||||
BaseSystem::getVideo()->setBlack(1);
|
||||
mScreenStateFlag.resetBit(mScreenStateFlag_SetBlack);
|
||||
@@ -81,20 +74,20 @@ void Display::preVRetrace() {
|
||||
mRetraceCount = VIGetRetraceCount();
|
||||
}
|
||||
|
||||
/* 804977d0 */
|
||||
/* 804977d0 */
|
||||
void Display::copyEFBtoXFB() {
|
||||
if (mFlag.onBit(mFlag_SetClear)) {
|
||||
if (mFlag.onBit(mFlag_SetClear)) {
|
||||
GXSetCopyClear(mClearColor, mClearZ);
|
||||
}
|
||||
GXRenderModeObj const* renderObj = BaseSystem::getVideo()->pRenderMode;
|
||||
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 */
|
||||
/* 80497870 */
|
||||
void Display::calcFrequency() {
|
||||
s32 endTick = OSGetTick();
|
||||
mDeltaTick = endTick-mBeginTick;
|
||||
mDeltaTick = endTick - mBeginTick;
|
||||
mFrequency = 1000000.0f / ((mDeltaTick * 8) / ((OS_BUS_CLOCK_SPEED >> 2) / 125000));
|
||||
mBeginTick = endTick;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#include <egg/core/eggDvdFile.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
bool DvdFile::sIsInitialized;
|
||||
nw4r::ut::List DvdFile::sDvdList;
|
||||
|
||||
void DvdFile::initialize() {
|
||||
if (!sIsInitialized) {
|
||||
nw4r::ut::List_Init(&sDvdList, offsetof(DvdFile, mNode));
|
||||
sIsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
DvdFile::DvdFile() {
|
||||
initiate();
|
||||
}
|
||||
|
||||
DvdFile::~DvdFile() {
|
||||
close();
|
||||
}
|
||||
|
||||
void DvdFile::initiate() {
|
||||
mFileInfo.dvdFile = this;
|
||||
OSInitMutex(&mMutex);
|
||||
OSInitMutex(&mMutexUnused);
|
||||
OSInitMessageQueue(&mMsgQueue, &mMsg, 1);
|
||||
OSInitMessageQueue(&mMsgQueueUnsued, &mMsgUnused, 1);
|
||||
mThread = nullptr;
|
||||
field_0x38 = 0;
|
||||
}
|
||||
|
||||
bool DvdFile::open(s32 entryId) {
|
||||
if (!mIsOpen && entryId != -1) {
|
||||
s32 res = DVDFastOpen(entryId, &mFileInfo);
|
||||
mIsOpen = res;
|
||||
if (mIsOpen) {
|
||||
nw4r::ut::List_Append(&sDvdList, this);
|
||||
s32 _status = DVDGetCommandBlockStatus(&mFileInfo.block);
|
||||
}
|
||||
}
|
||||
return mIsOpen;
|
||||
}
|
||||
|
||||
bool DvdFile::open(const char *path) {
|
||||
return open(DVDConvertPathToEntrynum(path));
|
||||
}
|
||||
|
||||
bool DvdFile::open(const char *path, void *) {
|
||||
return open(path);
|
||||
}
|
||||
|
||||
void DvdFile::close() {
|
||||
if (mIsOpen && DVDClose(&mFileInfo)) {
|
||||
mIsOpen = false;
|
||||
nw4r::ut::List_Remove(&sDvdList, this);
|
||||
}
|
||||
}
|
||||
|
||||
s32 DvdFile::readData(void *buffer, s32 length, s32 offset) {
|
||||
OSLockMutex(&mMutex);
|
||||
if (mThread) {
|
||||
OSUnlockMutex(&mMutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mThread = OSGetCurrentThread();
|
||||
s32 res = -1;
|
||||
|
||||
if (DVDReadAsyncPrio(&mFileInfo, buffer, length, offset, doneProcess, DVD_PRIO_MEDIUM)) {
|
||||
res = sync();
|
||||
}
|
||||
|
||||
mThread = nullptr;
|
||||
OSUnlockMutex(&mMutex);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
s32 DvdFile::writeData(const void *buffer, s32 length, s32 offset) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 DvdFile::sync() {
|
||||
OSMessage msg;
|
||||
OSLockMutex(&mMutex);
|
||||
OSReceiveMessage(&mMsgQueue, &msg, OS_MSG_PERSISTENT);
|
||||
mThread = nullptr;
|
||||
OSUnlockMutex(&mMutex);
|
||||
return (s32)(msg);
|
||||
}
|
||||
|
||||
void DvdFile::doneProcess(s32 result, DVDFileInfo *pFileInfo) {
|
||||
OSSendMessage(&((FileInfo *)pFileInfo)->dvdFile->mMsgQueue, (OSMessage)result, 0);
|
||||
}
|
||||
|
||||
u32 DvdFile::getFileSize() const {
|
||||
return mFileInfo.size;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -0,0 +1,188 @@
|
||||
#include <egg/core/eggDvdRipper.h>
|
||||
#include <rvl/VI.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
bool DvdRipper::sErrorRetry = true;
|
||||
DvdRipper::UnkCallback DvdRipper::sCallback;
|
||||
|
||||
/* 80494680 */
|
||||
u8 *DvdRipper::loadToMainRAM(
|
||||
s32 entryNum, u8 *dst, Heap *heap, EAllocDirection allocDir, u32 offset, u32 *amountRead, u32 *fileSize
|
||||
) {
|
||||
DvdFile file = DvdFile();
|
||||
if (!file.open(entryNum)) {
|
||||
return nullptr;
|
||||
}
|
||||
return loadToMainRAM(&file, dst, heap, allocDir, offset, amountRead, fileSize);
|
||||
}
|
||||
|
||||
/* 80494730 */
|
||||
u8 *DvdRipper::loadToMainRAM(
|
||||
const char *path, u8 *dst, Heap *heap, EAllocDirection allocDir, u32 offset, u32 *amountRead, u32 *fileSize
|
||||
) {
|
||||
DvdFile file = DvdFile();
|
||||
if (!file.open(path)) {
|
||||
return nullptr;
|
||||
}
|
||||
return loadToMainRAM(&file, dst, heap, allocDir, offset, amountRead, fileSize);
|
||||
}
|
||||
|
||||
/* 804947e0 */
|
||||
u8 *DvdRipper::loadToMainRAM(
|
||||
DvdFile *pFile, u8 *pOut, Heap *pHeap, EAllocDirection allocDir, u32 offset, u32 *pRead, u32 *pSize
|
||||
) {
|
||||
u32 size;
|
||||
bool memAllocated = false;
|
||||
u32 alignedSize;
|
||||
s32 result;
|
||||
u8 buf[0x40];
|
||||
|
||||
// msg could be a buffer, it could be a completely different structure,
|
||||
// there is no good way to know. (callback is never set D: )
|
||||
// Issue with the callback argument not being placed on the stack properly
|
||||
if (sCallback) {
|
||||
UnkCallback_Arg cb_arg;
|
||||
cb_arg.UNK_0x04 = 0;
|
||||
cb_arg.UNK_0x08 = 0;
|
||||
cb_arg.UNK_0x0C = 1;
|
||||
cb_arg.UNK_0x10 = 0;
|
||||
cb_arg.buf = &buf;
|
||||
sCallback(&cb_arg);
|
||||
}
|
||||
|
||||
size = pFile->getFileSize();
|
||||
if (pSize) {
|
||||
*pSize = size;
|
||||
}
|
||||
alignedSize = nw4r::ut::RoundUp(size, 0x20);
|
||||
|
||||
if (!pOut) {
|
||||
u32 size = alignedSize - offset;
|
||||
pOut = (u8 *)Heap::alloc(size, allocDir == ALLOC_DIR_TOP ? 0x20 : -0x20, pHeap);
|
||||
memAllocated = true;
|
||||
}
|
||||
if (pOut == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (offset != 0) {
|
||||
// Fakematch???? This just feels weird
|
||||
void *ptr = ROUND_UP_PTR(&buf[8], 0x20);
|
||||
while (true) {
|
||||
result = DVDReadPrio(&pFile->mFileInfo, ptr, 0x20, offset, DVD_PRIO_MEDIUM);
|
||||
if (result >= DVD_RESULT_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == DVD_RESULT_CANCELED || !sErrorRetry) {
|
||||
if (memAllocated) {
|
||||
Heap::free(pOut, nullptr);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VIWaitForRetrace();
|
||||
}
|
||||
DCInvalidateRange(ptr, 0x20);
|
||||
}
|
||||
while (true) {
|
||||
result = DVDReadPrio(&pFile->mFileInfo, pOut, alignedSize - offset, offset, DVD_PRIO_MEDIUM);
|
||||
if (result >= DVD_RESULT_OK) {
|
||||
break;
|
||||
}
|
||||
if (result == DVD_RESULT_CANCELED || !sErrorRetry) {
|
||||
if (memAllocated) {
|
||||
Heap::free(pOut, nullptr);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
VIWaitForRetrace();
|
||||
}
|
||||
if (pRead) {
|
||||
*pRead = alignedSize - offset;
|
||||
}
|
||||
|
||||
return pOut;
|
||||
}
|
||||
|
||||
/* 804949b0 */
|
||||
void *DvdRipper::loadToMainRAMDecomp(
|
||||
DvdFile *file, StreamDecomp *decompressor, u8 *pOut, Heap *heap, EAllocDirection allocDir, s32 offset, u32 size,
|
||||
u32 chunkSize, u32 *pRead, u32 *pSize
|
||||
) {
|
||||
s32 uncomp_align = allocDir == ALLOC_DIR_TOP ? 0x20 : -0x20;
|
||||
s32 align = allocDir == ALLOC_DIR_TOP ? -0x20 : 0x20;
|
||||
|
||||
// Ouput size of file
|
||||
s32 file_size = file->getFileSize();
|
||||
if (pSize) {
|
||||
*pSize = file_size;
|
||||
}
|
||||
|
||||
// Setup amount to read
|
||||
s32 max_read = ROUND_UP(file->getFileSize(), 0x20) - offset;
|
||||
if (size != 0) {
|
||||
max_read = size;
|
||||
}
|
||||
|
||||
void *read_buffer = heap->alloc(decompressor->getHeaderSize(), align);
|
||||
|
||||
if (!read_buffer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s32 result = DVDReadPrio(&file->mFileInfo, read_buffer, decompressor->getHeaderSize(), offset, DVD_PRIO_MEDIUM);
|
||||
file_size = decompressor->getHeaderSize();
|
||||
|
||||
if (result == file_size) {
|
||||
file_size = decompressor->getUncompressedSize(read_buffer);
|
||||
} else {
|
||||
// BUG? - Read buffer never freed
|
||||
return nullptr;
|
||||
}
|
||||
heap->free(read_buffer);
|
||||
read_buffer = nullptr;
|
||||
|
||||
// Already Read header to get size
|
||||
if (pRead) {
|
||||
*pRead = decompressor->getHeaderSize();
|
||||
}
|
||||
|
||||
// Ensure decompression space
|
||||
if (!pOut) {
|
||||
pOut = (u8 *)heap->alloc(file_size, uncomp_align);
|
||||
}
|
||||
|
||||
if (!pOut) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Read and decompress the chunks
|
||||
void *chunk_buffer = heap->alloc(chunkSize, align);
|
||||
if (chunk_buffer) {
|
||||
s32 file_size = 0;
|
||||
decompressor->init(pOut, max_read);
|
||||
|
||||
while (true) {
|
||||
u32 chunk_size = MIN(max_read - file_size, chunkSize);
|
||||
u32 chunk_offset = offset + file_size;
|
||||
|
||||
s32 result =
|
||||
DVDReadPrio(&file->mFileInfo, chunk_buffer, ROUND_UP(chunk_size, 0x20), chunk_offset, DVD_PRIO_MEDIUM);
|
||||
|
||||
if (result < DVD_RESULT_OK || decompressor->decomp(chunk_buffer, result)) {
|
||||
break;
|
||||
}
|
||||
file_size += result;
|
||||
}
|
||||
heap->free(chunk_buffer);
|
||||
if (pRead) {
|
||||
*pRead = file_size + decompressor->getHeaderSize();
|
||||
}
|
||||
}
|
||||
|
||||
return pOut;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
+16
-16
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace EGG {
|
||||
|
||||
/* 80495ab0 */ ExpHeap::ExpHeap(MEMiHeapHead *heapHandle) : Heap(heapHandle) {}
|
||||
ExpHeap::ExpHeap(MEMiHeapHead *heapHandle) : Heap(heapHandle) {}
|
||||
|
||||
/* 80495af0 */ ExpHeap::~ExpHeap() {
|
||||
ExpHeap::~ExpHeap() {
|
||||
dispose();
|
||||
MEMDestroyExpHeap(mHeapHandle);
|
||||
}
|
||||
|
||||
/* 80495b70 */ ExpHeap *ExpHeap::create(void *heapStart, size_t size, u16 attr) {
|
||||
ExpHeap *ExpHeap::create(void *heapStart, size_t size, u16 attr) {
|
||||
ExpHeap *heap = nullptr;
|
||||
void *startAddr = heapStart;
|
||||
void *heapEnd = ROUND_DOWN_PTR((u8 *)heapStart + size, 0x04);
|
||||
@@ -31,7 +31,7 @@ namespace EGG {
|
||||
return heap;
|
||||
}
|
||||
|
||||
/* 80495c30 */ ExpHeap *ExpHeap::create(size_t size, Heap *heap, u16 attr) {
|
||||
ExpHeap *ExpHeap::create(size_t size, Heap *heap, u16 attr) {
|
||||
ExpHeap *newHeap = nullptr;
|
||||
if (heap == nullptr) {
|
||||
heap = sCurrentHeap;
|
||||
@@ -52,7 +52,7 @@ namespace EGG {
|
||||
return newHeap;
|
||||
}
|
||||
|
||||
/* 80495d00 */ void ExpHeap::destroy() {
|
||||
void ExpHeap::destroy() {
|
||||
if (sDestroyCallback != nullptr) {
|
||||
sDestroyCallback(this);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace EGG {
|
||||
}
|
||||
}
|
||||
|
||||
/* 80495d90 */ void *ExpHeap::alloc(u32 size, s32 align) {
|
||||
void *ExpHeap::alloc(u32 size, s32 align) {
|
||||
if (mFlag.onBit(0)) {
|
||||
#line 182
|
||||
OSError("DAME DAME\n");
|
||||
@@ -84,7 +84,7 @@ namespace EGG {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* 80495e50 */ void ExpHeap::free(void *ptr) {
|
||||
void ExpHeap::free(void *ptr) {
|
||||
if (sFreeCallback != nullptr) {
|
||||
HeapFreeArg arg;
|
||||
arg.userArg = sFreeCallbackArg;
|
||||
@@ -95,26 +95,26 @@ namespace EGG {
|
||||
MEMFreeToExpHeap(mHeapHandle, ptr);
|
||||
}
|
||||
|
||||
/* 80495ec0 */ u32 ExpHeap::resizeForMBlock(void *block, u32 size) {
|
||||
u32 ExpHeap::resizeForMBlock(void *block, u32 size) {
|
||||
return MEMResizeForMBlockExpHeap(mHeapHandle, block, size);
|
||||
}
|
||||
|
||||
/* 80495ed0 */ u32 ExpHeap::getTotalFreeSize() {
|
||||
u32 ExpHeap::getTotalFreeSize() {
|
||||
return MEMGetAllocatableSizeForExpHeap(mHeapHandle);
|
||||
}
|
||||
|
||||
/* 80495ee0 */ u32 ExpHeap::getAllocatableSize(s32 align) {
|
||||
u32 ExpHeap::getAllocatableSize(s32 align) {
|
||||
return MEMGetAllocatableSizeForExpHeapEx(mHeapHandle, align);
|
||||
}
|
||||
|
||||
/* 80495d00 */ void ExpHeap::setGroupID(u16 groupId) {
|
||||
void ExpHeap::setGroupID(u16 groupId) {
|
||||
MEMSetGroupIdForExpHeap(mHeapHandle, groupId);
|
||||
}
|
||||
|
||||
/* 80495f00 */ u32 ExpHeap::adjust() {
|
||||
u32 ExpHeap::adjust() {
|
||||
u32 adjustedSize = MEMAdjustExpHeap(mHeapHandle);
|
||||
u32 totalSize = adjustedSize + 0x34;
|
||||
if (totalSize > 0x34) {
|
||||
u32 totalSize = adjustedSize + sizeof(ExpHeap);
|
||||
if (totalSize > sizeof(ExpHeap)) {
|
||||
Heap *parent = findParentHeap();
|
||||
if (parent != nullptr) {
|
||||
parent->resizeForMBlock(mParentBlock, totalSize);
|
||||
@@ -124,11 +124,11 @@ namespace EGG {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 80495f80 */ u32 ExpHeap::getSizeForMBlock(const void *block) {
|
||||
u32 ExpHeap::getSizeForMBlock(const void *block) {
|
||||
return MEMGetSizeForMBlockExpHeap(block);
|
||||
}
|
||||
|
||||
/* 80495f90 */ Heap::eHeapKind ExpHeap::getHeapKind() const {
|
||||
Heap::eHeapKind ExpHeap::getHeapKind() const {
|
||||
return HEAP_KIND_EXPANDED;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#include <egg/core/eggFrmHeap.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
FrmHeap::FrmHeap(MEMiHeapHead *pHead) : Heap(pHead) {}
|
||||
|
||||
FrmHeap::~FrmHeap() {
|
||||
dispose();
|
||||
MEMDestroyFrmHeap(mHeapHandle);
|
||||
}
|
||||
|
||||
FrmHeap *FrmHeap::create(void *pBlock, u32 size, u16 attr) {
|
||||
FrmHeap *heap = nullptr;
|
||||
void *startAddr = pBlock;
|
||||
void *heapEnd = ROUND_DOWN_PTR((u8 *)pBlock + size, 0x04);
|
||||
pBlock = ROUND_UP_PTR(pBlock, 0x04);
|
||||
|
||||
if (pBlock > heapEnd || ((u8 *)heapEnd - (u8 *)pBlock) < 0x38u) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MEMiHeapHead *head =
|
||||
MEMCreateFrmHeapEx((u8 *)pBlock + sizeof(FrmHeap), ((u8 *)heapEnd - (u8 *)pBlock) - sizeof(FrmHeap), attr);
|
||||
if (head != nullptr) {
|
||||
heap = new (pBlock) FrmHeap(head);
|
||||
heap->mParentBlock = startAddr;
|
||||
if (sCreateCallback != nullptr) {
|
||||
(sCreateCallback)(heap);
|
||||
}
|
||||
}
|
||||
|
||||
return heap;
|
||||
}
|
||||
|
||||
void FrmHeap::destroy() {
|
||||
if (sDestroyCallback) {
|
||||
sDestroyCallback(this);
|
||||
}
|
||||
|
||||
Heap *parent = findParentHeap();
|
||||
this->~FrmHeap();
|
||||
if (parent) {
|
||||
parent->free(this);
|
||||
}
|
||||
}
|
||||
|
||||
void *FrmHeap::alloc(u32 size, s32 align) {
|
||||
void *pBlock = MEMAllocFromFrmHeapEx(mHeapHandle, size, align);
|
||||
if (sAllocCallback) {
|
||||
HeapAllocArg arg;
|
||||
arg.userArg = sAllocCallbackArg;
|
||||
arg.ptr = pBlock;
|
||||
arg.size = size;
|
||||
arg.align = align;
|
||||
arg.heap = this;
|
||||
sAllocCallback(&arg);
|
||||
}
|
||||
return pBlock;
|
||||
}
|
||||
|
||||
void FrmHeap::free(void *pBlock) {
|
||||
if (sFreeCallback != nullptr) {
|
||||
HeapFreeArg arg;
|
||||
arg.userArg = sFreeCallbackArg;
|
||||
arg.ptr = pBlock;
|
||||
arg.heap = this;
|
||||
(sFreeCallback)(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
void FrmHeap::free(s32 flags) {
|
||||
MEMFreeToFrmHeap(mHeapHandle, flags);
|
||||
}
|
||||
|
||||
u32 FrmHeap::resizeForMBlock(void *pBlock, u32 size) {
|
||||
return MEMResizeForMBlockFrmHeap(mHeapHandle, pBlock, size);
|
||||
}
|
||||
|
||||
u32 FrmHeap::getTotalFreeSize() {
|
||||
return getAllocatableSize(4);
|
||||
}
|
||||
|
||||
u32 FrmHeap::getAllocatableSize(s32 align) {
|
||||
return MEMGetAllocatableSizeForFrmHeapEx(mHeapHandle, align);
|
||||
}
|
||||
|
||||
u32 FrmHeap::adjust() {
|
||||
u32 adjustedSize = MEMAdjustFrmHeap(mHeapHandle);
|
||||
u32 totalSize = adjustedSize + sizeof(FrmHeap);
|
||||
if (totalSize > sizeof(FrmHeap)) {
|
||||
Heap *parent = findParentHeap();
|
||||
if (parent != nullptr) {
|
||||
parent->resizeForMBlock(mParentBlock, totalSize);
|
||||
return totalSize;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FrmHeap::recordState(u32 id) {
|
||||
MEMRecordStateForFrmHeap(mHeapHandle, id);
|
||||
}
|
||||
|
||||
void FrmHeap::freeByState(u32 id) {
|
||||
MEMFreeByStateToFrmHeap(mHeapHandle, id);
|
||||
}
|
||||
|
||||
Heap::eHeapKind FrmHeap::getHeapKind() const {
|
||||
return HEAP_KIND_FRAME;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -58,8 +58,10 @@ void *Heap::alloc(size_t size, int align, Heap *heap) {
|
||||
heap = currentHeap;
|
||||
}
|
||||
if (heap != sAllocatableHeap) {
|
||||
OSReport("cannot allocate from heap %x(%s) : allocatable heap is %x(%s)\n", heap, heap->getName(),
|
||||
sAllocatableHeap, sAllocatableHeap->getName());
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
#include <egg/core/eggStreamDecomp.h>
|
||||
|
||||
namespace EGG {
|
||||
|
||||
// *********************************** LZ ********************************** //
|
||||
|
||||
bool StreamDecompLZ::init(void *pDest, u32 maxCompressedSize) {
|
||||
mpDest = pDest;
|
||||
mMaxCompressedSize = maxCompressedSize;
|
||||
CXInitUncompContextLZ(&mContext);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamDecompLZ::decomp(const void *pSrc, u32 len) {
|
||||
return CXReadUncompLZ(&mContext, pSrc, len) == CX_READ_OK;
|
||||
}
|
||||
|
||||
// *********************************** RL ********************************** //
|
||||
|
||||
bool StreamDecompRL::init(void *pDest, u32 maxCompressedSize) {
|
||||
mpDest = pDest;
|
||||
mMaxCompressedSize = maxCompressedSize;
|
||||
CXInitUncompContextRL(&mContext);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamDecompRL::decomp(const void *pSrc, u32 len) {
|
||||
return CXReadUncompRL(&mContext, pSrc, len) == CX_READ_OK;
|
||||
}
|
||||
|
||||
// *********************************** LH ********************************** //
|
||||
|
||||
bool StreamDecompLH::init(void *pDest, u32 maxCompressedSize) {
|
||||
mpDest = pDest;
|
||||
mMaxCompressedSize = maxCompressedSize;
|
||||
CXInitUncompContextLH(&mContext);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamDecompLH::decomp(const void *pSrc, u32 len) {
|
||||
return CXReadUncompLH(&mContext, pSrc, len) == CX_READ_OK;
|
||||
}
|
||||
|
||||
// ********************************** LRC ********************************** //
|
||||
|
||||
bool StreamDecompLRC::init(void *pDest, u32 maxCompressedSize) {
|
||||
mpDest = pDest;
|
||||
mMaxCompressedSize = maxCompressedSize;
|
||||
CXInitUncompContextLRC(&mContext);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamDecompLRC::decomp(const void *pSrc, u32 len) {
|
||||
return CXReadUncompLRC(&mContext, pSrc, len) == CX_READ_OK;
|
||||
}
|
||||
|
||||
// ********************************** SZS ********************************** //
|
||||
|
||||
u32 UncompContextSZS::getUncompressedSize(const void *pSrc) {
|
||||
const u8 *pData = (u8 *)pSrc;
|
||||
return (pData[4] << 24) | (pData[5] << 16) | (pData[6] << 8) | (pData[7] << 0);
|
||||
}
|
||||
|
||||
void UncompContextSZS::initUncompContext(void *pDest) {
|
||||
mpDest = (u8 *)pDest;
|
||||
mUncompSize = 0;
|
||||
mHeaderLen = 0x10;
|
||||
mMaxUncompSize = 0;
|
||||
mGroupHead = 0;
|
||||
mSecondByte = 0;
|
||||
mFirstByte = 0;
|
||||
mState = 0;
|
||||
mCopySrc = 0;
|
||||
}
|
||||
|
||||
s32 UncompContextSZS::readHeader(u8 *pHeaderLen, s32 *pUncompSize, const u8 *src, u32 maxCompLen, s32 maxUncompSize) {
|
||||
s32 read_amount = 0;
|
||||
while (*pHeaderLen != 0) {
|
||||
(*pHeaderLen)--;
|
||||
if (*pHeaderLen == 0xF) {
|
||||
if (*src != (u8)'Y') {
|
||||
return -1;
|
||||
}
|
||||
} else if (*pHeaderLen == 0xE) {
|
||||
if (*src != (u8)'a') {
|
||||
return -1;
|
||||
}
|
||||
} else if (*pHeaderLen == 0xD) {
|
||||
if (*src != (u8)'z') {
|
||||
return -1;
|
||||
}
|
||||
} else if (*pHeaderLen == 0xC) {
|
||||
if (*src != (u8)'0') {
|
||||
return -1;
|
||||
}
|
||||
} else if (*pHeaderLen >= 0x8) {
|
||||
*pUncompSize |= *src << ((*pHeaderLen - 8) << 3);
|
||||
}
|
||||
|
||||
maxCompLen--;
|
||||
src++;
|
||||
read_amount++;
|
||||
|
||||
if (maxCompLen == 0 && *pHeaderLen != 0) {
|
||||
return read_amount;
|
||||
}
|
||||
}
|
||||
if (maxUncompSize > 0 && maxUncompSize < *pUncompSize) {
|
||||
*pUncompSize = maxUncompSize;
|
||||
}
|
||||
return read_amount;
|
||||
}
|
||||
|
||||
s32 UncompContextSZS::readUncomp(const void *pSrca, u32 len) {
|
||||
const u8 *pSrc = static_cast<const u8 *>(pSrca);
|
||||
if (mHeaderLen != 0) {
|
||||
s32 read_len = readHeader(&mHeaderLen, &mUncompSize, pSrc, len, mMaxUncompSize);
|
||||
pSrc += read_len;
|
||||
len -= read_len;
|
||||
|
||||
if (len == 0) {
|
||||
if (mHeaderLen == 0) {
|
||||
return mUncompSize;
|
||||
}
|
||||
return CX_READ_ERR_1;
|
||||
}
|
||||
}
|
||||
|
||||
while (mUncompSize > 0) {
|
||||
if (mState == 2) {
|
||||
u32 num_bytes = *pSrc++ + 0x12;
|
||||
len--;
|
||||
if (num_bytes > mUncompSize) {
|
||||
if (mMaxUncompSize == 0) {
|
||||
return CX_READ_ERR_4;
|
||||
}
|
||||
num_bytes = (u16)mUncompSize;
|
||||
}
|
||||
mUncompSize -= num_bytes;
|
||||
do {
|
||||
*mpDest = *(mpDest - mCopySrc);
|
||||
mpDest++;
|
||||
} while (--num_bytes);
|
||||
mState = 0;
|
||||
} else if (mState == 1) {
|
||||
len--;
|
||||
u32 b1 = (mFirstByte << 8) | *pSrc++;
|
||||
u32 num_bytes = b1 >> 12;
|
||||
mCopySrc = (b1 & 0xFFF) + 1;
|
||||
|
||||
if (num_bytes == 0) {
|
||||
mState = 2;
|
||||
} else {
|
||||
num_bytes += 2;
|
||||
if (num_bytes > mUncompSize) {
|
||||
if (mMaxUncompSize == 0) {
|
||||
return CX_READ_ERR_4;
|
||||
}
|
||||
num_bytes = (u16)mUncompSize;
|
||||
}
|
||||
mUncompSize -= num_bytes;
|
||||
do {
|
||||
*mpDest = *(mpDest - mCopySrc);
|
||||
mpDest++;
|
||||
} while (--num_bytes);
|
||||
mState = 0;
|
||||
}
|
||||
} else {
|
||||
if (mGroupHead == 0) {
|
||||
len--;
|
||||
mSecondByte = *pSrc++;
|
||||
mGroupHead = 0x80;
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mSecondByte & mGroupHead) {
|
||||
*mpDest++ = *pSrc++;
|
||||
mUncompSize--;
|
||||
} else {
|
||||
mFirstByte = *pSrc++;
|
||||
mState = 1;
|
||||
}
|
||||
len--;
|
||||
mGroupHead >>= 1;
|
||||
}
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mUncompSize == 0 && mMaxUncompSize == 0 && len > 0x20) {
|
||||
return CX_READ_ERR_3;
|
||||
}
|
||||
return mUncompSize;
|
||||
}
|
||||
|
||||
bool StreamDecompSZS::init(void *pDest, u32 maxCompressedSize) {
|
||||
mpDest = pDest;
|
||||
mMaxCompressedSize = maxCompressedSize;
|
||||
mContext.initUncompContext(pDest);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamDecompSZS::decomp(const void *pSrc, u32 len) {
|
||||
return mContext.readUncomp((const u8 *)pSrc, len) == CX_READ_OK;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -5,7 +5,6 @@ namespace EGG {
|
||||
/* 80673b10 */ nw4r::ut::List Thread::sThreadList;
|
||||
/* 80576770 */ void (*Thread::sOldSwitchThreadCallback)(OSThread *, OSThread *);
|
||||
|
||||
|
||||
/* 80496910 */ Thread::Thread(u32 stackSize, int msgCount, int priority, Heap *heap) {
|
||||
if (heap == nullptr) {
|
||||
heap = Heap::sCurrentHeap;
|
||||
@@ -86,7 +85,7 @@ namespace EGG {
|
||||
/* 80496c70 */ void Thread::switchThreadCallback(OSThread *from, OSThread *to) {
|
||||
Thread *fromThread = from != nullptr ? findThread(from) : nullptr;
|
||||
Thread *toThread = to != nullptr ? findThread(to) : nullptr;
|
||||
|
||||
|
||||
if (fromThread != nullptr) {
|
||||
fromThread->onExit();
|
||||
if (fromThread->mCurrentHeap != nullptr) {
|
||||
@@ -95,7 +94,7 @@ namespace EGG {
|
||||
fromThread->mCurrentHeap = curr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (toThread != nullptr) {
|
||||
if (toThread->mCurrentHeap != nullptr) {
|
||||
Heap *curr = Heap::sCurrentHeap;
|
||||
@@ -118,7 +117,7 @@ namespace EGG {
|
||||
}
|
||||
|
||||
/* 80496dc0 */ void *Thread::start(void *arg) {
|
||||
Thread *thread = static_cast<Thread*>(arg);
|
||||
Thread *thread = static_cast<Thread *>(arg);
|
||||
return thread->run();
|
||||
}
|
||||
|
||||
|
||||
+270
-273
@@ -6,303 +6,305 @@
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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}};
|
||||
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();
|
||||
@@ -362,15 +364,10 @@ f32 itof(u32 n) {
|
||||
|
||||
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;
|
||||
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) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <egg/core/eggVideo.h>
|
||||
#include <egg/core/eggXfb.h>
|
||||
|
||||
|
||||
namespace EGG {
|
||||
|
||||
/* 804989e0 */ void Xfb::init(u16 width, u16 height, Heap *heap) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggCamera.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggCapTexture.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggCpuTexture.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggDrawGX.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggDrawPathBase.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggDrawPathDOF.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggDrawPathUnk1.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggDrawPathUnk2.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggFog.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggFrustum.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggG3DUtility.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggGXUtility.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggGfxEngine.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggGlobalDrawState.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggIScnProc.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggLight.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggLightTexture.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggLightTextureMgr.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggModelEx.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPalette.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectBase.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectBlur.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectMask.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectMaskDOF.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectSimple.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectUnk1.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggPostEffectUnk2.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggScreen.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggScreenEffectBase.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggScreenEffectBlur.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggStateEfb.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggStateGX.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggTexture.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggTextureBuffer.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <egg/gfx/eggUnk1.h>
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
@@ -57,4 +57,4 @@ f32 Vector3f::setLength(f32 len) {
|
||||
return mag;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
} // namespace EGG
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include <egg/util/eggException.h>
|
||||
+15
-16
@@ -38,7 +38,7 @@ void mShadow_c::drawOpa() {
|
||||
}
|
||||
|
||||
void mShadow_c::create(int count, u8 unk1, int unk2, u16 texSize, u32 drawOpaPriority, nw4r::g3d::ResMdl mdl,
|
||||
u32 heapSize) {
|
||||
u32 heapSize) {
|
||||
// Regswaps
|
||||
mAllocator.attach(mpHeap, 0x20);
|
||||
proc_c::create(&mAllocator, nullptr);
|
||||
@@ -180,7 +180,7 @@ bool mShadow_c::addCircle(mShadowCircle_c *circle, u32 priority, u32 isMdl) {
|
||||
}
|
||||
|
||||
bool mShadow_c::drawMdl(mShadowCircle_c *circle, u32 priority, scnLeaf_c &mdl, const mQuat_c &quat, mVec3_c &pos,
|
||||
mColor color, u32 param9, f32 dist) {
|
||||
mColor color, u32 param9, f32 dist) {
|
||||
if (!addCircle(circle, priority, 1)) {
|
||||
return false;
|
||||
}
|
||||
@@ -213,14 +213,14 @@ static f32 sTexMtx[2][4] = {{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}};
|
||||
static u32 STEP = 0x2492;
|
||||
|
||||
static GXColor sColors[] = {
|
||||
{0xFF, 0x00, 0x00, 0x00},
|
||||
{0x00, 0xFF, 0x00, 0x00},
|
||||
{0x00, 0x00, 0xFF, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00},
|
||||
{0xFF, 0x00, 0x00, 0x00},
|
||||
{0x00, 0xFF, 0x00, 0x00},
|
||||
{0x00, 0x00, 0xFF, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00},
|
||||
};
|
||||
|
||||
bool mShadow_c::drawTexObj(mShadowCircle_c *circle, u32 priority, const GXTexObj *texObj, const mMtx_c &mtx,
|
||||
const mQuat_c &quat, mVec3_c &pos, mColor color, u32 param9, f32 dist) {
|
||||
const mQuat_c &quat, mVec3_c &pos, mColor color, u32 param9, f32 dist) {
|
||||
if (!addCircle(circle, priority, 0)) {
|
||||
return false;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ static void drawSub2(void *data, u8 i) {
|
||||
GXSetTevColor(GX_TEVREG1, nw4r::ut::Color(0, 0, 0, 0x20));
|
||||
ang = 0;
|
||||
for (int id = GX_TEXCOORD0, idx = GX_TEXMTX0; id < GX_MAX_TEXCOORD;
|
||||
id += 1, idx += (GX_TEXMTX1 - GX_TEXMTX0), ang += STEP) {
|
||||
id += 1, idx += (GX_TEXMTX1 - GX_TEXMTX0), ang += STEP) {
|
||||
GXSetTexCoordGen2((GXTexCoordID)id, GX_TG_MTX2x4, GX_TG_TEX0, idx, FALSE, GX_DUALMTX_IDENT);
|
||||
sTexMtx[0][3] = 0.01f * nw4r::math::CosIdx(ang);
|
||||
sTexMtx[1][3] = 0.01f * nw4r::math::SinIdx(ang);
|
||||
@@ -402,7 +402,7 @@ void mShadow_c::drawAllShadows() {
|
||||
void mShadow_c::create(const mShadowCircleConfig *config, nw4r::g3d::ResMdl mdl, EGG::Heap *heap) {
|
||||
mShadow_c::sInstance = new (heap, 0x04) mShadow_c(heap);
|
||||
mShadow_c::sInstance->create(config->count, config->unk1, config->unk2, config->texBufferSize,
|
||||
config->drawOpaPriority, mdl, config->heapSize);
|
||||
config->drawOpaPriority, mdl, config->heapSize);
|
||||
}
|
||||
|
||||
void mShadow_c::beforeDraw() {
|
||||
@@ -425,7 +425,7 @@ void mShadow_c::afterDraw() {
|
||||
|
||||
void mShadow_c::swapHeaps() {
|
||||
changeHeap(mCurrentHeapIdx + 1);
|
||||
mpCurrentHeap->freeState(FRM_HEAP_STATE);
|
||||
mpCurrentHeap->freeByState(FRM_HEAP_STATE);
|
||||
mpCurrentHeap->recordState(FRM_HEAP_STATE);
|
||||
}
|
||||
|
||||
@@ -506,9 +506,8 @@ void mShadowChild_c::updateMtx() {
|
||||
mVec3_c b = *(mVec3_c *)(&mQuat) - mPositionMaybe * field_0x13C;
|
||||
mMtx_c mtx;
|
||||
C_MTXLookAt(mtx.m, b,
|
||||
*(fabsf((a.x - b.x) * (a.x - b.x) + (a.z - b.z) * (a.z - b.z)) <= FLT_EPSILON ? &mVec3_c::Ez :
|
||||
&mVec3_c::Ey),
|
||||
a);
|
||||
*(fabsf((a.x - b.x) * (a.x - b.x) + (a.z - b.z) * (a.z - b.z)) <= FLT_EPSILON ? &mVec3_c::Ez : &mVec3_c::Ey),
|
||||
a);
|
||||
f32 f = field_0x13C;
|
||||
mFrustum.set(f, -f, -f, f, f, f + mOffsetMaybe, mtx, true);
|
||||
}
|
||||
@@ -531,7 +530,7 @@ void mShadowChild_c::drawMdl() {
|
||||
math::MTX34 *viewPosArray = static_cast<math::MTX34 *>(mShadow_c::sInstance->mpHeap->alloc(bufSize, 0x20));
|
||||
|
||||
g3d::CalcView(viewPosArray, nullptr, mdl->GetWldMtxArray(), mdl->GetWldMtxAttribArray(),
|
||||
mdl->GetNumViewMtx(), mFrustum.mView, mdl->GetResMdl(), nullptr);
|
||||
mdl->GetNumViewMtx(), mFrustum.mView, mdl->GetResMdl(), nullptr);
|
||||
DCStoreRange(viewPosArray, bufSize);
|
||||
|
||||
g3d::ScnMdl *mdl2 = g3d::G3dObj::DynamicCast<g3d::ScnMdl>(lf->getG3dObject());
|
||||
@@ -539,8 +538,8 @@ void mShadowChild_c::drawMdl() {
|
||||
g3d::DrawResMdlReplacement *pRep = mdl2 ? mdl2->GetDrawResMdlReplacement() : nullptr;
|
||||
|
||||
g3d::DrawResMdlDirectly(mdl->GetResMdl(), viewPosArray, nullptr, nullptr,
|
||||
mdl2->GetByteCode(g3d::ScnMdlSimple::BYTE_CODE_DRAW_OPA), nullptr, pRep,
|
||||
g3d::RESMDL_DRAWMODE_FORCE_LIGHTOFF | g3d::RESMDL_DRAWMODE_IGNORE_MATERIAL);
|
||||
mdl2->GetByteCode(g3d::ScnMdlSimple::BYTE_CODE_DRAW_OPA), nullptr, pRep,
|
||||
g3d::RESMDL_DRAWMODE_FORCE_LIGHTOFF | g3d::RESMDL_DRAWMODE_IGNORE_MATERIAL);
|
||||
GXInvalidateVtxCache();
|
||||
} else {
|
||||
// this happens with bomb bag, and goes to 0x802EDC90 (mCustomShadow_c::draw)
|
||||
|
||||
+26
-22
@@ -1,15 +1,12 @@
|
||||
#include <MSL_C/string.h>
|
||||
#include <egg/core/eggArchive.h>
|
||||
#include <egg/core/eggDecomp.h>
|
||||
#include <egg/core/eggDvdFile.h>
|
||||
#include <egg/core/eggDvdRipper.h>
|
||||
#include <egg/core/eggHeap.h>
|
||||
#include <egg/core/eggStreamDecomp.h>
|
||||
#include <m/m_dvd.h>
|
||||
#include <m/m_heap.h>
|
||||
#include <rvl/DVD.h>
|
||||
// clang-format off
|
||||
// TODO a define in here stomps another header
|
||||
#include <MSL_C/string.h>
|
||||
// clang-format on
|
||||
|
||||
static int ConvertPathToEntrynum(const char *path, u8 *outType);
|
||||
|
||||
@@ -31,7 +28,7 @@ mDvd_param_c l_param;
|
||||
|
||||
// unofficial
|
||||
TUncompressInfo_Base_c *decompressorPtrs[1] = {
|
||||
&s_UncompressInfoLZ,
|
||||
&s_UncompressInfoLZ,
|
||||
};
|
||||
|
||||
u8 g_mountDirection = 1;
|
||||
@@ -127,8 +124,10 @@ void create(int priority, EGG::Heap *commandHeap, EGG::Heap *archiveHeap, EGG::H
|
||||
}
|
||||
|
||||
/** 802eef30 */
|
||||
static void *loadToMainRAM(int entryNum, char *dst, EGG::Heap *heap, EGG::DvdRipper::EAllocDirection allocDir,
|
||||
s32 offset, u32 *outAmountRead, u32 *outFileSize, u32 decompressorType) {
|
||||
static void *loadToMainRAM(
|
||||
int entryNum, char *dst, EGG::Heap *heap, EGG::DvdRipper::EAllocDirection allocDir, s32 offset, u32 *outAmountRead,
|
||||
u32 *outFileSize, u32 decompressorType
|
||||
) {
|
||||
void *result;
|
||||
u32 amountRead = 0;
|
||||
u32 fileSize = 0;
|
||||
@@ -138,8 +137,9 @@ static void *loadToMainRAM(int entryNum, char *dst, EGG::Heap *heap, EGG::DvdRip
|
||||
static EGG::DvdFile DvdFile;
|
||||
DvdFile.open(entryNum);
|
||||
|
||||
result = EGG::DvdRipper::loadToMainRAMDecomp(&DvdFile, decomp, (u8 *)dst, heap, allocDir, offset, 0,
|
||||
maxChunkSize, nullptr, nullptr);
|
||||
result = EGG::DvdRipper::loadToMainRAMDecomp(
|
||||
&DvdFile, decomp, (u8 *)dst, heap, allocDir, offset, 0, maxChunkSize, nullptr, nullptr
|
||||
);
|
||||
|
||||
deleteUncompressObj(decompressorType);
|
||||
u32 size = DvdFile.mFileInfo.size;
|
||||
@@ -345,7 +345,8 @@ mDvd_callback_c *mDvd_callback_c::create(dvdReadCallback cb, void *cbData) {
|
||||
/** 802ef650 */
|
||||
mDvd_callback_c *mDvd_callback_c::createOrFail(dvdReadCallback cb, void *cbData) {
|
||||
mDvd_callback_c *cmd = mDvd_callback_c::create(cb, cbData);
|
||||
while (!cmd) {}
|
||||
while (!cmd) {
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -548,8 +549,8 @@ mDvd_toMainRam_arc_c::mDvd_toMainRam_arc_c(EGG::Archive *arc, int entryNum, int
|
||||
}
|
||||
|
||||
/** 802efda0 */
|
||||
mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::makeRequest(EGG::Archive *arc, int entryNum, int mountDirection,
|
||||
EGG::Heap *heap) {
|
||||
mDvd_toMainRam_arc_c *
|
||||
mDvd_toMainRam_arc_c::makeRequest(EGG::Archive *arc, int entryNum, int mountDirection, EGG::Heap *heap) {
|
||||
mDvd_toMainRam_arc_c *cmd = new mDvd_toMainRam_arc_c(arc, entryNum, mountDirection);
|
||||
if (cmd != nullptr) {
|
||||
cmd->mHeap = heap;
|
||||
@@ -559,8 +560,8 @@ mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::makeRequest(EGG::Archive *arc, int e
|
||||
}
|
||||
|
||||
/** 802efe20 */
|
||||
mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::create(EGG::Archive *arc, const char *path, int mountDirection,
|
||||
EGG::Heap *heap) {
|
||||
mDvd_toMainRam_arc_c *
|
||||
mDvd_toMainRam_arc_c::create(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap) {
|
||||
int entryNum = arc->convertPathToEntryID(path);
|
||||
mDvd_toMainRam_arc_c *cmd = nullptr;
|
||||
if (entryNum != -1) {
|
||||
@@ -570,10 +571,11 @@ mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::create(EGG::Archive *arc, const char
|
||||
}
|
||||
|
||||
/** 802efe90 */
|
||||
mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::createOrFail(EGG::Archive *arc, const char *path, int mountDirection,
|
||||
EGG::Heap *heap) {
|
||||
mDvd_toMainRam_arc_c *
|
||||
mDvd_toMainRam_arc_c::createOrFail(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap) {
|
||||
mDvd_toMainRam_arc_c *cmd = mDvd_toMainRam_arc_c::create(arc, path, mountDirection, heap);
|
||||
while (!cmd) {}
|
||||
while (!cmd) {
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -613,13 +615,15 @@ mDvd_toMainRam_normal_c *mDvd_toMainRam_normal_c::create(const char *path, int m
|
||||
/** 802f0030 */
|
||||
mDvd_toMainRam_normal_c *mDvd_toMainRam_normal_c::createOrFail(const char *path, int mountDirection, EGG::Heap *heap) {
|
||||
mDvd_toMainRam_normal_c *cmd = mDvd_toMainRam_normal_c::create(path, mountDirection, heap);
|
||||
while (!cmd) {}
|
||||
while (!cmd) {
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
/** 802f0060 */
|
||||
void mDvd_toMainRam_normal_c::create2(mDvd_toMainRam_normal_c **cmd, const char *path, int mountDirection,
|
||||
EGG::Heap *heap) {
|
||||
void mDvd_toMainRam_normal_c::create2(
|
||||
mDvd_toMainRam_normal_c **cmd, const char *path, int mountDirection, EGG::Heap *heap
|
||||
) {
|
||||
if (*cmd == nullptr) {
|
||||
*cmd = mDvd_toMainRam_normal_c::create(path, mountDirection, heap);
|
||||
}
|
||||
@@ -634,7 +638,7 @@ u32 mDvd_toMainRam_normal_c::execute() {
|
||||
u32 fileSize;
|
||||
EGG::Heap *heap = mHeap != nullptr ? mHeap : mDvd::l_ArchiveHeap;
|
||||
EGG::DvdRipper::EAllocDirection allocDirection =
|
||||
mMountDirection == 1 ? EGG::DvdRipper::ALLOC_DIR_TOP : EGG::DvdRipper::ALLOC_DIR_BOTTOM;
|
||||
mMountDirection == 1 ? EGG::DvdRipper::ALLOC_DIR_TOP : EGG::DvdRipper::ALLOC_DIR_BOTTOM;
|
||||
mDataPtr = mDvd::loadToMainRAM(mEntryNum, 0, heap, allocDirection, 0, &amountRead, &fileSize, mCompressionType2);
|
||||
if (mDataPtr != nullptr) {
|
||||
mAmountRead = amountRead;
|
||||
|
||||
+14
-15
@@ -18,7 +18,6 @@ static bool s_WPADInfoAvailable[4];
|
||||
static u32 s_GetWPADInfoInterval = 0;
|
||||
static u32 s_GetWPADInfoCount = 0;
|
||||
|
||||
|
||||
struct PadAdditionalData_t {
|
||||
PadAdditionalData_t() {}
|
||||
~PadAdditionalData_t() {}
|
||||
@@ -48,7 +47,6 @@ void create() {
|
||||
// (just indexing the arrays normally)
|
||||
// but has an annoying regshuffle
|
||||
void beginPad() {
|
||||
|
||||
g_PadFrame++;
|
||||
g_padMg->beginFrame();
|
||||
|
||||
@@ -65,7 +63,7 @@ void beginPad() {
|
||||
if (ctl->mFlag.onBit(0)) {
|
||||
// These sort of look like value, first order derivative, and second order derivative
|
||||
// So perhaps value, velocity, acceleration?
|
||||
EGG::Vector2f pos = ctl->coreStatus[0].getUnk();
|
||||
EGG::Vector2f pos = ctl->mCoreStatus[0].getUnk();
|
||||
EGG::Vector2f v = pos - dat->v1;
|
||||
dat->v1 = pos;
|
||||
dat->v3 = v - dat->v2;
|
||||
@@ -77,12 +75,13 @@ void beginPad() {
|
||||
|
||||
// Not sure why this checks the controller index against the tick count
|
||||
if (s_GetWPADInfoInterval != 0 &&
|
||||
((s_GetWPADInfoInterval == 1 || s_GetWPADInfoCount == i) ||
|
||||
(s_GetWPADInfoInterval <= 3 && (s_GetWPADInfoCount & 1) == (i & 1)))) {
|
||||
((s_GetWPADInfoInterval == 1 || s_GetWPADInfoCount == i) ||
|
||||
(s_GetWPADInfoInterval <= 3 && (s_GetWPADInfoCount & 1) == (i & 1))))
|
||||
{
|
||||
getWPADInfoCB(i);
|
||||
}
|
||||
} else if (*connected) {
|
||||
ctl->coreStatus->init();
|
||||
ctl->mCoreStatus->init();
|
||||
ctl->sceneReset();
|
||||
dat->v1.x = 0.0f;
|
||||
dat->v1.y = 0.0f;
|
||||
@@ -113,15 +112,15 @@ void endPad() {
|
||||
}
|
||||
|
||||
static inline void clear(WPADInfo *info) {
|
||||
info->field_0x00 = 0;
|
||||
info->field_0x04 = 0;
|
||||
info->field_0x08 = 0;
|
||||
info->field_0x0C = 0;
|
||||
info->field_0x10 = 0;
|
||||
info->field_0x14 = false;
|
||||
info->field_0x15 = false;
|
||||
info->field_0x16 = false;
|
||||
info->field_0x17 = false;
|
||||
info->dpd = FALSE;
|
||||
info->speaker = FALSE;
|
||||
info->attach = FALSE;
|
||||
info->lowBat = FALSE;
|
||||
info->nearempty = FALSE;
|
||||
info->battery = 0;
|
||||
info->led = 0;
|
||||
info->protocol = 0;
|
||||
info->firmware = 0;
|
||||
}
|
||||
|
||||
static void clearWPADInfo(int controller) {
|
||||
|
||||
Reference in New Issue
Block a user