-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpspMemory.cpp
67 lines (51 loc) · 1.32 KB
/
pspMemory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "pspMemory.hpp"
#include <memory.h>
unsigned char* g_pMemory[4] = { nullptr };
unsigned char* g_pMemLookup[ 0x3F ] = { nullptr };
unsigned int g_pHeapTop = 0;
psp_heap_block *g_pHeapFreedList = nullptr;
void pmInit( )
{
// Scratch RAM
g_pMemory[0] = new unsigned char[ 0x00004000 ];
g_pMemLookup[0x00] = g_pMemory[0];
// V RAM
g_pMemory[1] = new unsigned char[ 0x00200000 ];
g_pMemLookup[0x01] = g_pMemory[1];
// Main RAM
g_pMemory[2] = new unsigned char[ 0x02000000 ];
g_pMemLookup[0x02] = g_pMemory[2];
// UV RAM
g_pMemory[3] = new unsigned char[ 0x00200000 ];
g_pMemLookup[0x11] = g_pMemory[3];
g_pHeapTop = 0x0a000000;
// Test to match JPSCP
g_pHeapTop -= 0x200;
}
void pmDestroy( ) {
for( int i = 0; i < 4; ++i ) {
delete[] g_pMemory[i];
g_pMemory[i] = nullptr;
}
for( int i = 0x00; i < 0x3F; ++i ) {
g_pMemLookup[i] = nullptr;
}
}
psp_heap_block *pmHeapAlloc( unsigned int size )
{
psp_heap_block *block = new psp_heap_block( );
block->start = g_pHeapTop;
block->size = size;
block->next = nullptr;
g_pHeapTop -= size;
// Fill the stack with garbage to help with debugging
memset( pmPtr(block->start-size), 0xBD, size );
return block;
}
void pmHeapFree( psp_heap_block *block )
{
}
void* __stdcall pmPtr( unsigned int addr )
{
return g_pMemLookup[ addr >> 26 ] + ( addr & 0x01FFFFFF );
}