-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynarecContext.cpp
52 lines (46 loc) · 1.19 KB
/
DynarecContext.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
#include "DynarecContext.hpp"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <malloc.h>
#include <memory.h>
dynarec_state * esCreate( )
{
dynarec_state *state = (dynarec_state*)malloc( sizeof(dynarec_state) );
if( state ) {
size_t tablesize = ( PSP_MEM_SIZE<< 2 );
state->transtable = (void**)_aligned_malloc( tablesize, ATOMIC_ALIGN );
memset( state->transtable, 0, tablesize );
}
return state;
}
void esDestroy( dynarec_state *&state )
{
if( state ) {
_aligned_free( state->transtable );
free( state );
state = nullptr;
}
}
dynarec_context * ecCreate( dynarec_state *state, unsigned int stacksize )
{
dynarec_context *context = (dynarec_context*)malloc( sizeof(dynarec_context) );
if( context ) {
context->state = state;
context->stack = pmHeapAlloc( stacksize );
for( int i = 0; i < 35; ++i ) {
context->regs[i] = 0xBAADF00D;
}
context->regs[PREG_ZR] = 0x00000000;
context->regs[PREG_SP] = context->stack->start;
context->asmblr = new AsmJit::Assembler( );
context->labels = nullptr;
context->delayslotlabel = nullptr;
}
return context;
}
void ecDestroy( dynarec_context *&context )
{
pmHeapFree( context->stack );
free( context );
context = nullptr;
}