Start work on memory.c
This commit is contained in:
parent
33cc13b687
commit
f6d4f74c25
5 changed files with 62 additions and 13 deletions
|
|
@ -116,7 +116,7 @@ HuMemHeapPtrGet = .text:0x8000A920; // type:function size:0x18
|
|||
HuMemHeapInit = .text:0x8000A938; // type:function size:0x4C
|
||||
HuMemMemoryAllocNum = .text:0x8000A984; // type:function size:0x40
|
||||
HuMemMemoryAlloc = .text:0x8000A9C4; // type:function size:0x3C
|
||||
HuMemMemoryAlloc2 = .text:0x8000AA00; // type:function size:0x108
|
||||
HuMemMemoryAlloc2 = .text:0x8000AA00; // type:function size:0x108 scope:local
|
||||
HuMemMemoryFreeNum = .text:0x8000AB08; // type:function size:0x7C
|
||||
HuMemMemoryFree = .text:0x8000AB84; // type:function size:0x12C
|
||||
HuMemUsedMemorySizeGet = .text:0x8000ACB0; // type:function size:0x48
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ config.libs = [
|
|||
"host": False,
|
||||
"objects": [
|
||||
Object(Matching, "game/malloc.c"),
|
||||
Object(NonMatching, "game/memory.c"),
|
||||
Object(Matching, "game/memory.c"),
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,13 +24,22 @@ void fn_1_26C(void);
|
|||
|
||||
void HuMemInitAll(void);
|
||||
void *HuMemInit(void *ptr, u32 size);
|
||||
void HuMemDCFlushAll();
|
||||
void HuMemDCFlush(int heap);
|
||||
void *HuMemDirectMalloc(int heap, u32 size);
|
||||
void *HuMemDirectMallocNum(int heap, u32 size, int num);
|
||||
void HuMemDirectFree(void *ptr);
|
||||
void HuMemDirectFreeNum(int heap, int num);
|
||||
u32 HuMemUsedMallocSizeGet(int heap);
|
||||
u32 HuMemUsedMallocBlockGet(int heap);
|
||||
u32 HuMemHeapSizeGet(int heap);
|
||||
void *HuMemHeapPtrGet(int heap);
|
||||
|
||||
void *HuMemHeapInit(void *ptr, u32 size);
|
||||
void *HuMemMemoryAlloc(void *heap_ptr, u32 size, void *retaddr);
|
||||
void *HuMemMemoryAllocNum(void *heap_ptr, u32 size, u32 num, void *retaddr);
|
||||
void HuMemMemoryFree(void *ptr, void *retaddr);
|
||||
void HuMemMemoryFreeNum(void *heap_ptr, u32 num, void *retaddr);
|
||||
void *HuMemMemoryAlloc(void *heap_ptr, u32 size, u32 retaddr);
|
||||
void *HuMemMemoryAllocNum(void *heap_ptr, u32 size, int num, u32 retaddr);
|
||||
void HuMemMemoryFree(void *ptr, u32 retaddr);
|
||||
void HuMemMemoryFreeNum(void *heap_ptr, int num, u32 retaddr);
|
||||
u32 HuMemUsedMemorySizeGet(void *heap_ptr);
|
||||
u32 HuMemUsedMemoryBlockGet(void *heap_ptr);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ void *HuMemInit(void *ptr, u32 size)
|
|||
return HuMemHeapInit(ptr, size);
|
||||
}
|
||||
|
||||
|
||||
void HuMemDCFlushAll()
|
||||
{
|
||||
HuMemDCFlush(2);
|
||||
|
|
@ -49,7 +48,7 @@ void HuMemDCFlush(int heap)
|
|||
|
||||
void *HuMemDirectMalloc(int heap, u32 size)
|
||||
{
|
||||
register void *retaddr;
|
||||
register u32 retaddr;
|
||||
asm {
|
||||
mflr retaddr
|
||||
}
|
||||
|
|
@ -57,9 +56,9 @@ void *HuMemDirectMalloc(int heap, u32 size)
|
|||
return HuMemMemoryAlloc(HeapTbl[heap], size, retaddr);
|
||||
}
|
||||
|
||||
void *HuMemDirectMallocNum(int heap, u32 size, u32 num)
|
||||
void *HuMemDirectMallocNum(int heap, u32 size, int num)
|
||||
{
|
||||
register void *retaddr;
|
||||
register u32 retaddr;
|
||||
asm {
|
||||
mflr retaddr
|
||||
}
|
||||
|
|
@ -69,16 +68,16 @@ void *HuMemDirectMallocNum(int heap, u32 size, u32 num)
|
|||
|
||||
void HuMemDirectFree(void *ptr)
|
||||
{
|
||||
register void *retaddr;
|
||||
register u32 retaddr;
|
||||
asm {
|
||||
mflr retaddr
|
||||
}
|
||||
HuMemMemoryFree(ptr, retaddr);
|
||||
}
|
||||
|
||||
void HuMemDirectFreeNum(int heap, u32 num)
|
||||
void HuMemDirectFreeNum(int heap, int num)
|
||||
{
|
||||
register void *retaddr;
|
||||
register u32 retaddr;
|
||||
asm {
|
||||
mflr retaddr
|
||||
}
|
||||
|
|
|
|||
41
src/game/memory.c
Normal file
41
src/game/memory.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include "common.h"
|
||||
|
||||
struct memory_block {
|
||||
u32 size;
|
||||
u8 magic;
|
||||
u8 flag;
|
||||
struct memory_block *prev;
|
||||
struct memory_block *next;
|
||||
int num;
|
||||
u32 retaddr;
|
||||
};
|
||||
|
||||
static void *HuMemMemoryAlloc2(void *heap_ptr, u32 size, int num, u32 retaddr);
|
||||
|
||||
void *HuMemHeapInit(void *ptr, u32 size)
|
||||
{
|
||||
struct memory_block *block = ptr;
|
||||
block->size = size;
|
||||
block->magic = 205;
|
||||
block->flag = 0;
|
||||
block->prev = block;
|
||||
block->next = block;
|
||||
block->num = -256;
|
||||
block->retaddr = 0xCDCDCDCD;
|
||||
return block;
|
||||
}
|
||||
|
||||
void *HuMemMemoryAllocNum(void *heap_ptr, u32 size, int num, u32 retaddr)
|
||||
{
|
||||
return HuMemMemoryAlloc2(heap_ptr, size, num, retaddr);
|
||||
}
|
||||
|
||||
void *HuMemMemoryAlloc(void *heap_ptr, u32 size, u32 retaddr)
|
||||
{
|
||||
return HuMemMemoryAlloc2(heap_ptr, size, -256, retaddr);
|
||||
}
|
||||
|
||||
static void *HuMemMemoryAlloc2(void *heap_ptr, u32 size, int num, u32 retaddr)
|
||||
{
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue