mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-07 01:35:29 -04:00
some J3D/misc cleanup (#2628)
* some j3d cleanup * begin using uintptr_t * j3dgraphbase cleanup * j3dgraphanimator cleanup
This commit is contained in:
@@ -47,7 +47,7 @@ OSMessageQueue JKRAram::sMessageQueue = {0};
|
||||
/* 802D2040-802D214C 2CC980 010C+00 1/1 0/0 0/0 .text __ct__7JKRAramFUlUll */
|
||||
JKRAram::JKRAram(u32 audio_buffer_size, u32 audio_graph_size, s32 priority)
|
||||
: JKRThread(0xC00, 0x10, priority) {
|
||||
u32 aramBase = ARInit(mStackArray, ARRAY_SIZE(mStackArray));
|
||||
u32 aramBase = ARInit(mStackArray, ARRAY_SIZEU(mStackArray));
|
||||
ARQInit();
|
||||
|
||||
u32 aramSize = ARGetSize();
|
||||
@@ -103,11 +103,11 @@ void* JKRAram::run(void) {
|
||||
/* 802D2248-802D22DC 2CCB88 0094+00 2/2 0/0 0/0 .text
|
||||
* checkOkAddress__7JKRAramFPUcUlP12JKRAramBlockUl */
|
||||
void JKRAram::checkOkAddress(u8* addr, u32 size, JKRAramBlock* block, u32 param_4) {
|
||||
if (!IS_ALIGNED((u32)addr, 0x20) && !IS_ALIGNED(size, 0x20)) {
|
||||
if (!IS_ALIGNED((uintptr_t)addr, 0x20) && !IS_ALIGNED(size, 0x20)) {
|
||||
JUTException::panic(__FILE__, 219, ":::address not 32Byte aligned.");
|
||||
}
|
||||
|
||||
if (block && !IS_ALIGNED((u32)block->getAddress() + param_4, 0x20)) {
|
||||
if (block && !IS_ALIGNED((uintptr_t)block->getAddress() + param_4, 0x20)) {
|
||||
JUTException::panic(__FILE__, 227, ":::address not 32Byte aligned.");
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ JKRAramBlock* JKRAram::mainRamToAram(u8* buf, u32 bufSize, u32 alignedSize,
|
||||
block = NULL;
|
||||
} else {
|
||||
JKRDecompress(buf, (u8*)allocatedMem, fileSize, 0);
|
||||
JKRAramPcs(0, (u32)allocatedMem, bufSize, alignedSize, block);
|
||||
JKRAramPcs(0, (uintptr_t)allocatedMem, bufSize, alignedSize, block);
|
||||
JKRFreeToHeap(heap, allocatedMem);
|
||||
block = block == NULL ? (JKRAramBlock*)-1 : block;
|
||||
if (pSize != NULL) {
|
||||
@@ -184,7 +184,7 @@ JKRAramBlock* JKRAram::mainRamToAram(u8* buf, u32 bufSize, u32 alignedSize,
|
||||
bufSize = allocatedBlock->getAddress();
|
||||
}
|
||||
|
||||
JKRAramPcs(0, (u32)buf, bufSize, alignedSize, block);
|
||||
JKRAramPcs(0, (uintptr_t)buf, bufSize, alignedSize, block);
|
||||
block = block == NULL ? (JKRAramBlock*)-1 : block;
|
||||
if (pSize != NULL)
|
||||
*pSize = alignedSize;
|
||||
@@ -205,8 +205,8 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS
|
||||
u32 expandSize;
|
||||
if (expandSwitch == EXPAND_SWITCH_UNKNOWN1) {
|
||||
u8 buffer[64];
|
||||
u8* bufPtr = (u8*)ALIGN_NEXT((u32)buffer, 32);
|
||||
JKRAramPcs(1, address, (u32)bufPtr, sizeof(buffer) / 2,
|
||||
u8* bufPtr = (u8*)ALIGN_NEXT((uintptr_t)buffer, 32);
|
||||
JKRAramPcs(1, address, (uintptr_t)bufPtr, sizeof(buffer) / 2,
|
||||
NULL); // probably change sizeof(buffer) / 2 to 32
|
||||
compression = JKRCheckCompressed_noASR(bufPtr);
|
||||
expandSize = JKRDecompExpandSize(bufPtr);
|
||||
@@ -230,7 +230,7 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS
|
||||
if (szpSpace == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
JKRAramPcs(1, address, (u32)szpSpace, p3, NULL);
|
||||
JKRAramPcs(1, address, (uintptr_t)szpSpace, p3, NULL);
|
||||
if (p5 != 0 && p5 < expandSize)
|
||||
expandSize = p5;
|
||||
|
||||
@@ -261,7 +261,7 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS
|
||||
return NULL;
|
||||
} else {
|
||||
changeGroupIdIfNeed(buf, id);
|
||||
JKRAramPcs(1, address, (u32)buf, p3, NULL);
|
||||
JKRAramPcs(1, address, (uintptr_t)buf, p3, NULL);
|
||||
if (pSize != NULL) {
|
||||
*pSize = p3;
|
||||
}
|
||||
@@ -494,8 +494,8 @@ static u8* firstSrcData() {
|
||||
length = size;
|
||||
}
|
||||
|
||||
u32 src = (u32)(srcAddress + srcOffset);
|
||||
u32 dst = (u32)buffer;
|
||||
u32 src = (uintptr_t)(srcAddress + srcOffset);
|
||||
u32 dst = (uintptr_t)buffer;
|
||||
u32 alignedLength = ALIGN_NEXT(length, 0x20);
|
||||
JKRAramPcs(1, src, dst, alignedLength, NULL);
|
||||
|
||||
@@ -511,18 +511,18 @@ static u8* firstSrcData() {
|
||||
/* 802D2CE4-802D2DAC 2CD624 00C8+00 1/1 0/0 0/0 .text nextSrcData__FPUc */
|
||||
static u8* nextSrcData(u8* current) {
|
||||
u8* dest;
|
||||
u32 left = (u32)(szpEnd - current);
|
||||
u32 left = (uintptr_t)(szpEnd - current);
|
||||
if (IS_NOT_ALIGNED(left, 0x20))
|
||||
dest = szpBuf + 0x20 - (left & (0x20 - 1));
|
||||
else
|
||||
dest = szpBuf;
|
||||
|
||||
memcpy(dest, current, left);
|
||||
u32 transSize = (u32)(szpEnd - (dest + left));
|
||||
u32 transSize = (uintptr_t)(szpEnd - (dest + left));
|
||||
if (transSize > transLeft)
|
||||
transSize = transLeft;
|
||||
|
||||
JKRAramPcs(1, (u32)(srcAddress + srcOffset), ((u32)dest + left), ALIGN_NEXT(transSize, 0x20),
|
||||
JKRAramPcs(1, (uintptr_t)(srcAddress + srcOffset), ((uintptr_t)dest + left), ALIGN_NEXT(transSize, 0x20),
|
||||
NULL);
|
||||
srcOffset += transSize;
|
||||
transLeft -= transSize;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "JSystem/JKernel/JKRAramPiece.h"
|
||||
#include "JSystem/JSupport/JSUFileStream.h"
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 80451408-8045140C 000908 0004+00 1/1 0/0 0/0 .sbss sAramStreamObject__13JKRAramStream
|
||||
@@ -40,7 +41,7 @@ JKRAramStream::~JKRAramStream() {}
|
||||
|
||||
/* 802D3C68-802D3CD8 2CE5A8 0070+00 1/0 0/0 0/0 .text run__13JKRAramStreamFv */
|
||||
void* JKRAramStream::run() {
|
||||
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, ARRAY_SIZE(sMessageBuffer));
|
||||
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, ARRAY_SIZEU(sMessageBuffer));
|
||||
|
||||
for (;;) {
|
||||
OSMessage message;
|
||||
@@ -115,7 +116,7 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
|
||||
break;
|
||||
}
|
||||
|
||||
JKRAramPcs(0, (u32)buffer, destination, length, NULL);
|
||||
JKRAramPcs(0, (uintptr_t)buffer, destination, length, NULL);
|
||||
dstSize -= length;
|
||||
writtenLength += length;
|
||||
destination += length;
|
||||
@@ -205,7 +206,7 @@ void JKRAramStream::setTransBuffer(u8* buffer, u32 bufferSize, JKRHeap* heap) {
|
||||
transHeap = NULL;
|
||||
|
||||
if (buffer) {
|
||||
transBuffer = (u8*)ALIGN_NEXT((u32)buffer, 0x20);
|
||||
transBuffer = (u8*)ALIGN_NEXT((uintptr_t)buffer, 0x20);
|
||||
}
|
||||
|
||||
if (bufferSize) {
|
||||
@@ -227,4 +228,4 @@ JKRAramStreamCommand::JKRAramStreamCommand() {
|
||||
// should be an inline function
|
||||
extern "C" s32 getAvailable__20JSURandomInputStreamCFv(JSURandomInputStream* self) {
|
||||
return self->getLength() - self->getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ void JKRArchive::CArcName::store(const char* name) {
|
||||
while (*name) {
|
||||
s32 ch = tolower(*name);
|
||||
mHash = ch + mHash * 3;
|
||||
if (length < (s32)ARRAY_SIZE(mData)) {
|
||||
if (length < ARRAY_SIZE(mData)) {
|
||||
mData[length++] = ch;
|
||||
}
|
||||
name++;
|
||||
@@ -208,7 +208,7 @@ const char* JKRArchive::CArcName::store(const char* name, char endChar) {
|
||||
while (*name && *name != endChar) {
|
||||
s32 lch = tolower((int)*name);
|
||||
mHash = lch + mHash * 3;
|
||||
if (length < (s32)ARRAY_SIZE(mData)) {
|
||||
if (length < ARRAY_SIZE(mData)) {
|
||||
mData[length++] = lch;
|
||||
}
|
||||
name++;
|
||||
@@ -240,4 +240,4 @@ u32 JKRArchive::getExpandSize(SDIFileEntry* fileEntry) const {
|
||||
return 0;
|
||||
|
||||
return mExpandedSize[index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include "math.h"
|
||||
#include "string.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 802D87D4-802D887C 2D3114 00A8+00 0/0 1/1 0/0 .text
|
||||
* __ct__14JKRCompArchiveFlQ210JKRArchive15EMountDirection */
|
||||
@@ -104,10 +105,10 @@ bool JKRCompArchive::open(s32 entryNum) {
|
||||
}
|
||||
else
|
||||
{
|
||||
JKRDvdToMainRam(entryNum, (u8 *)mArcInfoBlock, EXPAND_SWITCH_UNKNOWN1, (u32)arcHeader->file_data_offset + mSizeOfMemPart,
|
||||
JKRDvdToMainRam(entryNum, (u8 *)mArcInfoBlock, EXPAND_SWITCH_UNKNOWN1, (uintptr_t)arcHeader->file_data_offset + mSizeOfMemPart,
|
||||
NULL, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, 0x20, NULL, NULL);
|
||||
DCInvalidateRange(mArcInfoBlock, (u32)arcHeader->file_data_offset + mSizeOfMemPart);
|
||||
field_0x64 = (u32)mArcInfoBlock + arcHeader->file_data_offset;
|
||||
DCInvalidateRange(mArcInfoBlock, (uintptr_t)arcHeader->file_data_offset + mSizeOfMemPart);
|
||||
field_0x64 = (uintptr_t)mArcInfoBlock + arcHeader->file_data_offset;
|
||||
|
||||
if (mSizeOfAramPart != 0) {
|
||||
mAramPart = (JKRAramBlock*)JKRAllocFromAram(mSizeOfAramPart, JKRAramHeap::HEAD);
|
||||
@@ -119,9 +120,9 @@ bool JKRCompArchive::open(s32 entryNum) {
|
||||
JKRDvdToAram(entryNum, mAramPart->getAddress(), EXPAND_SWITCH_UNKNOWN1, arcHeader->header_length + arcHeader->file_data_offset + mSizeOfMemPart, 0, NULL);
|
||||
}
|
||||
|
||||
mNodes = (SDIDirEntry*)((u32)mArcInfoBlock + mArcInfoBlock->node_offset);
|
||||
mFiles = (SDIFileEntry *)((u32)mArcInfoBlock + mArcInfoBlock->file_entry_offset);
|
||||
mStringTable = (char*)((u32)mArcInfoBlock + mArcInfoBlock->string_table_offset);
|
||||
mNodes = (SDIDirEntry*)((uintptr_t)mArcInfoBlock + mArcInfoBlock->node_offset);
|
||||
mFiles = (SDIFileEntry *)((uintptr_t)mArcInfoBlock + mArcInfoBlock->file_entry_offset);
|
||||
mStringTable = (char*)((uintptr_t)mArcInfoBlock + mArcInfoBlock->string_table_offset);
|
||||
field_0x6c = arcHeader->header_length + arcHeader->file_data_offset;
|
||||
}
|
||||
break;
|
||||
@@ -155,7 +156,7 @@ bool JKRCompArchive::open(s32 entryNum) {
|
||||
else {
|
||||
// arcHeader + 1 should lead to 0x20, which is the data after the header
|
||||
JKRHeap::copyMemory((u8 *)mArcInfoBlock, arcHeader + 1, (arcHeader->file_data_offset + mSizeOfMemPart));
|
||||
field_0x64 = (u32)mArcInfoBlock + arcHeader->file_data_offset;
|
||||
field_0x64 = (uintptr_t)mArcInfoBlock + arcHeader->file_data_offset;
|
||||
if (mSizeOfAramPart != 0) {
|
||||
mAramPart = (JKRAramBlock*)JKRAllocFromAram(mSizeOfAramPart, JKRAramHeap::HEAD);
|
||||
if(mAramPart == NULL) {
|
||||
@@ -169,9 +170,9 @@ bool JKRCompArchive::open(s32 entryNum) {
|
||||
}
|
||||
}
|
||||
}
|
||||
mNodes = (SDIDirEntry *)((u32)mArcInfoBlock + mArcInfoBlock->node_offset);
|
||||
mFiles = (SDIFileEntry *)((u32)mArcInfoBlock + mArcInfoBlock->file_entry_offset);
|
||||
mStringTable = (char *)((u32)mArcInfoBlock + mArcInfoBlock->string_table_offset);
|
||||
mNodes = (SDIDirEntry *)((uintptr_t)mArcInfoBlock + mArcInfoBlock->node_offset);
|
||||
mFiles = (SDIFileEntry *)((uintptr_t)mArcInfoBlock + mArcInfoBlock->file_entry_offset);
|
||||
mStringTable = (char *)((uintptr_t)mArcInfoBlock + mArcInfoBlock->string_table_offset);
|
||||
field_0x6c = arcHeader->header_length + arcHeader->file_data_offset;
|
||||
break;
|
||||
}
|
||||
@@ -374,7 +375,7 @@ u32 JKRCompArchive::getExpandedResSize(const void *resource) const
|
||||
}
|
||||
|
||||
u8 buf[64];
|
||||
u8 *bufPtr = (u8 *)ALIGN_NEXT((u32)buf, 32);
|
||||
u8 *bufPtr = (u8 *)ALIGN_NEXT((uintptr_t)buf, 32);
|
||||
if ((flags & 0x20) != 0) {
|
||||
u32 addr = mAramPart->mAddress;
|
||||
addr = fileEntry->data_offset + addr;
|
||||
@@ -391,4 +392,4 @@ u32 JKRCompArchive::getExpandedResSize(const void *resource) const
|
||||
u32 expandSize = JKRDecompExpandSize(bufPtr);
|
||||
const_cast<JKRCompArchive *>(this)->setExpandSize(fileEntry, expandSize);
|
||||
return expandSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "math.h"
|
||||
#include "string.h"
|
||||
#include "global.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 802D7BF0-802D7C98 2D2530 00A8+00 0/0 1/1 0/0 .text
|
||||
* __ct__13JKRDvdArchiveFlQ210JKRArchive15EMountDirection */
|
||||
@@ -233,7 +234,7 @@ u32 JKRDvdArchive::fetchResource_subroutine(s32 entryNum, u32 offset, u32 size,
|
||||
// The dst pointer to JKRDvdToMainRam should be aligned to 32 bytes. This will align
|
||||
// arcHeader to 32 bytes on the stack.
|
||||
char arcHeaderBuffer[64];
|
||||
u8* arcHeader = (u8*)ALIGN_NEXT((u32)arcHeaderBuffer, 0x20);
|
||||
u8* arcHeader = (u8*)ALIGN_NEXT((uintptr_t)arcHeaderBuffer, 0x20);
|
||||
JKRDvdToMainRam(entryNum, arcHeader, EXPAND_SWITCH_UNKNOWN2, sizeof(SArcHeader),
|
||||
NULL, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, offset, NULL, NULL);
|
||||
DCInvalidateRange(arcHeader, sizeof(SArcHeader));
|
||||
@@ -300,7 +301,7 @@ u32 JKRDvdArchive::fetchResource_subroutine(s32 entryNum, u32 offset, u32 size,
|
||||
// The dst pointer to JKRDvdToMainRam should be aligned to 32 bytes. This will align
|
||||
// arcHeader to 32 bytes on the stack.
|
||||
char arcHeaderBuffer[64];
|
||||
u8* arcHeader = (u8*)ALIGN_NEXT((u32)arcHeaderBuffer, 0x20);
|
||||
u8* arcHeader = (u8*)ALIGN_NEXT((uintptr_t)arcHeaderBuffer, 0x20);
|
||||
JKRDvdToMainRam(entryNum, arcHeader, EXPAND_SWITCH_UNKNOWN2, sizeof(SArcHeader),
|
||||
NULL, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, offset, NULL, NULL);
|
||||
DCInvalidateRange(arcHeader, sizeof(SArcHeader));
|
||||
@@ -364,7 +365,7 @@ u32 JKRDvdArchive::getExpandedResSize(const void* resource) const {
|
||||
// The dst pointer to JKRDvdToMainRam should be aligned to 32 bytes. This will align arcHeader
|
||||
// to 32 bytes on the stack.
|
||||
char buffer[64];
|
||||
u8* arcHeader = (u8*)ALIGN_NEXT((u32)buffer, 0x20);
|
||||
u8* arcHeader = (u8*)ALIGN_NEXT((uintptr_t)buffer, 0x20);
|
||||
JKRDvdToMainRam(mEntryNum, arcHeader, EXPAND_SWITCH_UNKNOWN2, sizeof(SArcHeader), NULL,
|
||||
JKRDvdRipper::ALLOC_DIRECTION_FORWARD,
|
||||
mDataOffset + fileEntry->data_offset, NULL, NULL);
|
||||
@@ -375,4 +376,4 @@ u32 JKRDvdArchive::getExpandedResSize(const void* resource) const {
|
||||
((JKRDvdArchive*)this)->setExpandSize(fileEntry, resourceSize);
|
||||
|
||||
return resourceSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <dolphin/os.h>
|
||||
#include <dolphin/os.h>
|
||||
#include "dolphin/vi.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static int JKRDecompressFromDVD(JKRDvdFile*, void*, u32, u32, u32, u32, u32*);
|
||||
static int decompSZS_subroutine(u8*, u8*);
|
||||
@@ -66,7 +67,7 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
|
||||
if (expandSwitch == EXPAND_SWITCH_UNKNOWN1)
|
||||
{
|
||||
u8 buffer[0x40];
|
||||
u8 *bufPtr = (u8 *)ALIGN_NEXT((u32)buffer, 32);
|
||||
u8 *bufPtr = (u8 *)ALIGN_NEXT((uintptr_t)buffer, 32);
|
||||
while (true)
|
||||
{
|
||||
int readBytes = DVDReadPrio(dvdFile->getFileInfo(), bufPtr, 0x20, 0, 2);
|
||||
@@ -134,7 +135,7 @@ void* JKRDvdRipper::loadToMainRAM(JKRDvdFile* dvdFile, u8* dst, JKRExpandSwitch
|
||||
if (offset != 0)
|
||||
{
|
||||
u8 buffer[0x40];
|
||||
u8 *bufPtr = (u8 *)ALIGN_NEXT((u32)buffer, 32);
|
||||
u8 *bufPtr = (u8 *)ALIGN_NEXT((uintptr_t)buffer, 32);
|
||||
while (true)
|
||||
{
|
||||
int readBytes = DVDReadPrio(dvdFile->getFileInfo(), bufPtr, 32, (s32)offset, 2);
|
||||
@@ -534,7 +535,7 @@ static u8* nextSrcData(u8* src) {
|
||||
buf = szpBuf;
|
||||
|
||||
memcpy(buf, src, limit);
|
||||
u32 transSize = (u32)(szpEnd - (buf + limit));
|
||||
u32 transSize = (uintptr_t)(szpEnd - (buf + limit));
|
||||
if (transSize > transLeft)
|
||||
transSize = transLeft;
|
||||
while (true)
|
||||
|
||||
@@ -75,7 +75,7 @@ JKRExpHeap* JKRExpHeap::create(void* ptr, u32 size, JKRHeap* parent, bool errorF
|
||||
return NULL;
|
||||
|
||||
void* dataPtr = (u8*)ptr + expHeapSize;
|
||||
u32 alignedSize = ALIGN_PREV((u32)ptr + size - (u32)dataPtr, 0x10);
|
||||
u32 alignedSize = ALIGN_PREV((uintptr_t)ptr + size - (uintptr_t)dataPtr, 0x10);
|
||||
if (ptr) {
|
||||
newHeap = new (ptr) JKRExpHeap(dataPtr, alignedSize, parent2, errorFlag);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void* JKRExpHeap::allocFromHead(u32 size, int align) {
|
||||
|
||||
for (CMemBlock* block = mHeadFreeList; block; block = block->mNext) {
|
||||
u32 offset =
|
||||
ALIGN_PREV(align - 1 + (u32)block->getContent(), align) - (u32)block->getContent();
|
||||
ALIGN_PREV(align - 1 + (uintptr_t)block->getContent(), align) - (uintptr_t)block->getContent();
|
||||
if (block->size < size + offset) {
|
||||
continue;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ void* JKRExpHeap::allocFromHead(u32 size, int align) {
|
||||
CMemBlock* prev = foundBlock->mPrev;
|
||||
CMemBlock* next = foundBlock->mNext;
|
||||
removeFreeBlock(foundBlock);
|
||||
newUsedBlock = (CMemBlock*)((u32)foundBlock + foundOffset);
|
||||
newUsedBlock = (CMemBlock*)((uintptr_t)foundBlock + foundOffset);
|
||||
newUsedBlock->size = foundBlock->size - foundOffset;
|
||||
newFreeBlock =
|
||||
newUsedBlock->allocFore(size, mCurrentGroupId, (u8)foundOffset, 0, 0);
|
||||
@@ -252,7 +252,7 @@ void* JKRExpHeap::allocFromHead(u32 size, int align) {
|
||||
CMemBlock* prev = foundBlock->mPrev;
|
||||
CMemBlock* next = foundBlock->mNext;
|
||||
// Works but very fake match
|
||||
size = (u32)foundBlock->allocFore(size, mCurrentGroupId, 0, 0, 0);
|
||||
size = (uintptr_t)foundBlock->allocFore(size, mCurrentGroupId, 0, 0, 0);
|
||||
removeFreeBlock(foundBlock);
|
||||
if (size) {
|
||||
setFreeBlock((CMemBlock*)size, prev, next);
|
||||
@@ -318,8 +318,8 @@ void* JKRExpHeap::allocFromTail(u32 size, int align) {
|
||||
u32 start;
|
||||
|
||||
for (CMemBlock* block = mTailFreeList; block; block = block->mPrev) {
|
||||
start = ALIGN_PREV((u32)block->getContent() + block->size - size, align);
|
||||
usedSize = (u32)block->getContent() + block->size - start;
|
||||
start = ALIGN_PREV((uintptr_t)block->getContent() + block->size - size, align);
|
||||
usedSize = (uintptr_t)block->getContent() + block->size - start;
|
||||
if (block->size >= usedSize) {
|
||||
foundBlock = block;
|
||||
offset = block->size - usedSize;
|
||||
@@ -454,7 +454,7 @@ s32 JKRExpHeap::do_resize(void* ptr, u32 size) {
|
||||
if (size > block->size) {
|
||||
CMemBlock* foundBlock = NULL;
|
||||
for (CMemBlock* freeBlock = mHeadFreeList; freeBlock; freeBlock = freeBlock->mNext) {
|
||||
if (freeBlock == (CMemBlock*)((u32)(block + 1) + block->size)) {
|
||||
if (freeBlock == (CMemBlock*)((uintptr_t)(block + 1) + block->size)) {
|
||||
foundBlock = freeBlock;
|
||||
break;
|
||||
}
|
||||
@@ -718,9 +718,9 @@ void JKRExpHeap::recycleFreeBlock(JKRExpHeap::CMemBlock* block) {
|
||||
/* 802D00B4-802D0190 2CA9F4 00DC+00 1/1 0/0 0/0 .text
|
||||
* joinTwoBlocks__10JKRExpHeapFPQ210JKRExpHeap9CMemBlock */
|
||||
void JKRExpHeap::joinTwoBlocks(CMemBlock* block) {
|
||||
u32 endAddr = (u32)(block + 1) + block->size;
|
||||
u32 endAddr = (uintptr_t)(block + 1) + block->size;
|
||||
CMemBlock* next = block->mNext;
|
||||
u32 nextAddr = (u32)next - (next->mFlags & 0x7f);
|
||||
u32 nextAddr = (uintptr_t)next - (next->mFlags & 0x7f);
|
||||
if (endAddr > nextAddr) {
|
||||
JUTWarningConsole_f(":::Heap may be broken. (block = %x)", block);
|
||||
JKRGetCurrentHeap()->dump();
|
||||
@@ -776,7 +776,7 @@ bool JKRExpHeap::check() {
|
||||
block->mNext->mPrev);
|
||||
}
|
||||
|
||||
if ((u32)block + block->size + sizeof(CMemBlock) > (u32)block->mNext) {
|
||||
if ((uintptr_t)block + block->size + sizeof(CMemBlock) > (uintptr_t)block->mNext) {
|
||||
ok = false;
|
||||
JUTWarningConsole_f(":::addr %08x: bad block size (%08x)\n", block, block->size);
|
||||
}
|
||||
@@ -932,7 +932,7 @@ JKRExpHeap::CMemBlock* JKRExpHeap::CMemBlock::allocFore(u32 size, u8 groupId1, u
|
||||
mGroupId = groupId1;
|
||||
mFlags = alignment1;
|
||||
if (getSize() >= size + sizeof(CMemBlock)) {
|
||||
block = (CMemBlock*)(size + (u32)this);
|
||||
block = (CMemBlock*)(size + (uintptr_t)this);
|
||||
block[1].mGroupId = groupId2;
|
||||
block[1].mFlags = alignment2;
|
||||
block[1].size = this->size - (size + sizeof(CMemBlock));
|
||||
@@ -948,7 +948,7 @@ JKRExpHeap::CMemBlock* JKRExpHeap::CMemBlock::allocBack(u32 size, u8 groupId1, u
|
||||
u8 groupId2, u8 alignment2) {
|
||||
CMemBlock* newblock = NULL;
|
||||
if (getSize() >= size + sizeof(CMemBlock)) {
|
||||
newblock = (CMemBlock*)((u32)this + getSize() - size);
|
||||
newblock = (CMemBlock*)((uintptr_t)this + getSize() - size);
|
||||
newblock->mGroupId = groupId2;
|
||||
newblock->mFlags = alignment2 | 0x80;
|
||||
newblock->size = size;
|
||||
@@ -997,10 +997,10 @@ void JKRExpHeap::state_register(JKRHeap::TState* p, u32 param_1) const {
|
||||
if (param_1 <= 0xff) {
|
||||
u8 groupId = block->getGroupId();
|
||||
if (groupId == param_1) {
|
||||
checkCode += (u32)block * 3;
|
||||
checkCode += (uintptr_t)block * 3;
|
||||
}
|
||||
} else {
|
||||
checkCode += (u32)block * 3;
|
||||
checkCode += (uintptr_t)block * 3;
|
||||
}
|
||||
}
|
||||
p->mCheckCode = checkCode;
|
||||
|
||||
@@ -110,7 +110,7 @@ JKRFileLoader* JKRFileLoader::findVolume(const char** volumeName) {
|
||||
}
|
||||
|
||||
char volumeNameBuffer[0x101];
|
||||
*volumeName = fetchVolumeName(volumeNameBuffer, ARRAY_SIZE(volumeNameBuffer), *volumeName);
|
||||
*volumeName = fetchVolumeName(volumeNameBuffer, ARRAY_SIZEU(volumeNameBuffer), *volumeName);
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
@@ -159,4 +159,4 @@ const char* JKRFileLoader::fetchVolumeName(char* buffer, s32 bufferSize, const c
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include <stdint.h>
|
||||
|
||||
bool data_804508B0 = 1;
|
||||
|
||||
@@ -109,8 +110,8 @@ bool JKRHeap::initArena(char** memory, u32* size, int maxHeaps) {
|
||||
return false;
|
||||
|
||||
arenaStart = OSInitAlloc(arenaLo, arenaHi, maxHeaps);
|
||||
ram_start = (void*)ALIGN_NEXT((u32)arenaStart, 0x20);
|
||||
ram_end = (void*)ALIGN_PREV((u32)arenaHi, 0x20);
|
||||
ram_start = (void*)ALIGN_NEXT((uintptr_t)arenaStart, 0x20);
|
||||
ram_end = (void*)ALIGN_PREV((uintptr_t)arenaHi, 0x20);
|
||||
|
||||
OSBootInfo* codeStart = (OSBootInfo*)OSPhysicalToCached(0);
|
||||
mCodeStart = codeStart;
|
||||
@@ -124,7 +125,7 @@ bool JKRHeap::initArena(char** memory, u32* size, int maxHeaps) {
|
||||
OSSetArenaHi(ram_end);
|
||||
|
||||
*memory = (char*)ram_start;
|
||||
*size = (u32)ram_end - (u32)ram_start;
|
||||
*size = (uintptr_t)ram_end - (uintptr_t)ram_start;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -273,7 +274,7 @@ s32 JKRHeap::changeGroupID(u8 groupID) {
|
||||
/* 802CE7DC-802CE83C 2C911C 0060+00 0/0 2/2 0/0 .text getMaxAllocatableSize__7JKRHeapFi
|
||||
*/
|
||||
u32 JKRHeap::getMaxAllocatableSize(int alignment) {
|
||||
u32 maxFreeBlock = (u32)getMaxFreeBlock();
|
||||
u32 maxFreeBlock = (uintptr_t)getMaxFreeBlock();
|
||||
u32 ptrOffset = (alignment - 1) & alignment - (maxFreeBlock & 0xf);
|
||||
return ~(alignment - 1) & (getFreeSize() - ptrOffset);
|
||||
}
|
||||
@@ -363,13 +364,13 @@ void JKRHeap::dispose_subroutine(u32 begin, u32 end) {
|
||||
|
||||
/* 802CEA78-802CEAA0 2C93B8 0028+00 0/0 1/1 0/0 .text dispose__7JKRHeapFPvUl */
|
||||
bool JKRHeap::dispose(void* ptr, u32 size) {
|
||||
dispose_subroutine((u32)ptr, (u32)ptr + size);
|
||||
dispose_subroutine((uintptr_t)ptr, (uintptr_t)ptr + size);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 802CEAA0-802CEAC0 2C93E0 0020+00 0/0 1/1 0/0 .text dispose__7JKRHeapFPvPv */
|
||||
void JKRHeap::dispose(void* begin, void* end) {
|
||||
dispose_subroutine((u32)begin, (u32)end);
|
||||
dispose_subroutine((uintptr_t)begin, (uintptr_t)end);
|
||||
}
|
||||
|
||||
/* 802CEAC0-802CEB18 2C9400 0058+00 0/0 3/3 0/0 .text dispose__7JKRHeapFv */
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include "string.h"
|
||||
#include "global.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 802D69B8-802D6A6C 2D12F8 00B4+00 0/0 2/2 0/0 .text
|
||||
* __ct__13JKRMemArchiveFlQ210JKRArchive15EMountDirection */
|
||||
@@ -94,7 +95,7 @@ bool JKRMemArchive::open(s32 entryNum, JKRArchive::EMountDirection mountDirectio
|
||||
mStringTable = (char *)((u8 *)&mArcInfoBlock->num_nodes + mArcInfoBlock->string_table_offset);
|
||||
|
||||
mArchiveData =
|
||||
(u8 *)((u32)mArcHeader + mArcHeader->header_length + mArcHeader->file_data_offset);
|
||||
(u8 *)((uintptr_t)mArcHeader + mArcHeader->header_length + mArcHeader->file_data_offset);
|
||||
mIsOpen = true;
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ bool JKRMemArchive::open(void* buffer, u32 bufferSize, JKRMemBreakFlag flag) {
|
||||
mNodes = (SDIDirEntry *)((u8 *)&mArcInfoBlock->num_nodes + mArcInfoBlock->node_offset);
|
||||
mFiles = (SDIFileEntry *)((u8 *)&mArcInfoBlock->num_nodes + mArcInfoBlock->file_entry_offset);
|
||||
mStringTable = (char *)((u8 *)&mArcInfoBlock->num_nodes + mArcInfoBlock->string_table_offset);
|
||||
mArchiveData = (u8 *)(((u32)mArcHeader + mArcHeader->header_length) + mArcHeader->file_data_offset);
|
||||
mArchiveData = (u8 *)(((uintptr_t)mArcHeader + mArcHeader->header_length) + mArcHeader->file_data_offset);
|
||||
mIsOpen = (flag == JKRMEMBREAK_FLAG_UNKNOWN1) ? true : false; // mIsOpen might be u8
|
||||
mHeap = JKRHeap::findFromRoot(buffer);
|
||||
mCompression = COMPRESSION_NONE;
|
||||
@@ -239,4 +240,4 @@ u32 JKRMemArchive::getExpandedResSize(const void* resource) const {
|
||||
} else {
|
||||
return JKRDecompExpandSize((u8*)resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "JSystem/JUtility/JUTConsole.h"
|
||||
#include "global.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 802D0A24-802D0AD0 2CB364 00AC+00 0/0 4/4 1/1 .text create__12JKRSolidHeapFUlP7JKRHeapb
|
||||
*/
|
||||
@@ -58,7 +59,7 @@ s32 JKRSolidHeap::adjustSize(void) {
|
||||
JKRHeap* parent = getParent();
|
||||
if (parent) {
|
||||
lock();
|
||||
u32 thisSize = (u32)mStart - (u32)this;
|
||||
u32 thisSize = (uintptr_t)mStart - (uintptr_t)this;
|
||||
u32 newSize = ALIGN_NEXT(mSolidHead - mStart, 0x20);
|
||||
if (parent->resize(this, thisSize + newSize) != -1) {
|
||||
mFreeSize = 0;
|
||||
@@ -115,8 +116,8 @@ void* JKRSolidHeap::do_alloc(u32 size, int alignment) {
|
||||
void* JKRSolidHeap::allocFromHead(u32 size, int alignment) {
|
||||
size = ALIGN_NEXT(size, 0x4);
|
||||
void* ptr = NULL;
|
||||
u32 alignedStart = (alignment - 1 + (u32)mSolidHead) & ~(alignment - 1);
|
||||
u32 offset = alignedStart - (u32)mSolidHead;
|
||||
u32 alignedStart = (alignment - 1 + (uintptr_t)mSolidHead) & ~(alignment - 1);
|
||||
u32 offset = alignedStart - (uintptr_t)mSolidHead;
|
||||
u32 totalSize = size + offset;
|
||||
if (totalSize <= mFreeSize) {
|
||||
ptr = (void*)alignedStart;
|
||||
@@ -137,8 +138,8 @@ void* JKRSolidHeap::allocFromHead(u32 size, int alignment) {
|
||||
void* JKRSolidHeap::allocFromTail(u32 size, int alignment) {
|
||||
size = ALIGN_NEXT(size, 4);
|
||||
void* ptr = NULL;
|
||||
u32 alignedStart = ALIGN_PREV((u32)mSolidTail - size, alignment);
|
||||
u32 totalSize = (u32)mSolidTail - (u32)alignedStart;
|
||||
u32 alignedStart = ALIGN_PREV((uintptr_t)mSolidTail - size, alignment);
|
||||
u32 totalSize = (uintptr_t)mSolidTail - (uintptr_t)alignedStart;
|
||||
if (totalSize <= mFreeSize) {
|
||||
ptr = (void*)alignedStart;
|
||||
mSolidTail -= totalSize;
|
||||
@@ -178,7 +179,7 @@ void JKRSolidHeap::do_freeTail(void) {
|
||||
dispose(mSolidTail, mEnd);
|
||||
}
|
||||
|
||||
this->mFreeSize = ((u32)mEnd - (u32)mSolidTail + mFreeSize);
|
||||
this->mFreeSize = ((uintptr_t)mEnd - (uintptr_t)mSolidTail + mFreeSize);
|
||||
this->mSolidTail = mEnd;
|
||||
|
||||
JKRSolidHeap::Unknown* unknown = field_0x78;
|
||||
@@ -216,7 +217,7 @@ bool JKRSolidHeap::check(void) {
|
||||
|
||||
bool result = true;
|
||||
u32 calculatedSize =
|
||||
((u32)mSolidHead - (u32)mStart) + mFreeSize + ((u32)mEnd - (u32)mSolidTail);
|
||||
((uintptr_t)mSolidHead - (uintptr_t)mStart) + mFreeSize + ((uintptr_t)mEnd - (uintptr_t)mSolidTail);
|
||||
u32 availableSize = mSize;
|
||||
if (calculatedSize != availableSize) {
|
||||
result = false;
|
||||
@@ -233,11 +234,11 @@ bool JKRSolidHeap::dump(void) {
|
||||
bool result = check();
|
||||
|
||||
lock();
|
||||
u32 headSize = ((u32)mSolidHead - (u32)mStart);
|
||||
u32 tailSize = ((u32)mEnd - (u32)mSolidTail);
|
||||
u32 headSize = ((uintptr_t)mSolidHead - (uintptr_t)mStart);
|
||||
u32 tailSize = ((uintptr_t)mEnd - (uintptr_t)mSolidTail);
|
||||
s32 htSize = headSize + tailSize;
|
||||
JUTReportConsole_f("head %08x: %08x\n", mStart, headSize);
|
||||
JUTReportConsole_f("tail %08x: %08x\n", mSolidTail, ((u32)mEnd - (u32)mSolidTail));
|
||||
JUTReportConsole_f("tail %08x: %08x\n", mSolidTail, ((uintptr_t)mEnd - (uintptr_t)mSolidTail));
|
||||
|
||||
u32 totalSize = mSize;
|
||||
float percentage = (float)htSize / (float)totalSize * 100.0f;
|
||||
@@ -255,8 +256,8 @@ void JKRSolidHeap::state_register(JKRHeap::TState* p, u32 id) const {
|
||||
getState_(p);
|
||||
setState_u32ID_(p, id);
|
||||
setState_uUsedSize_(p, getUsedSize((JKRSolidHeap*)this));
|
||||
u32 r29 = (u32)mSolidHead;
|
||||
r29 += (u32)mSolidTail * 3;
|
||||
u32 r29 = (uintptr_t)mSolidHead;
|
||||
r29 += (uintptr_t)mSolidTail * 3;
|
||||
setState_u32CheckCode_(p, r29);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "stdio.h"
|
||||
#include "dol2asm.h"
|
||||
#include "global.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 8043428C-80434298 060FAC 000C+00 5/6 0/0 0/0 .bss sThreadList__9JKRThread */
|
||||
JSUList<JKRThread> JKRThread::sThreadList(0);
|
||||
@@ -53,7 +54,7 @@ JKRThread::JKRThread(JKRHeap* heap, u32 stack_size, int message_count, int param
|
||||
JKRThread::JKRThread(OSThread* thread, int message_count) : mThreadListLink(this) {
|
||||
mHeap = NULL;
|
||||
mThreadRecord = thread;
|
||||
mStackSize = (u32)thread->stackEnd - (u32)thread->stackBase;
|
||||
mStackSize = (uintptr_t)thread->stackEnd - (uintptr_t)thread->stackBase;
|
||||
mStackMemory = thread->stackBase;
|
||||
|
||||
setCommon_mesgQueue(JKRHeap::getSystemHeap(), message_count);
|
||||
|
||||
Reference in New Issue
Block a user