Initial NESemu

Former-commit-id: 454723c7de88d8848a29ac914d3ca43916eeadeb
This commit is contained in:
Phillip Stephens 2023-12-19 01:44:37 -08:00
parent 3cf745eee5
commit d885ed5a4b
5 changed files with 96 additions and 3 deletions

View File

@ -233,9 +233,17 @@ cflags_musyx_debug = [
# REL flags
cflags_rel = [
*cflags_base,
"-proc gecko",
"-fp hard",
"-nodefaults",
"-nosyspath",
"-i include",
"-i libc",
"-O0",
"-sdata 0",
"-sdata2 0",
"-str noreuse",
"-Cpp_exceptions off"
]
config.linker_version = "GC/1.3.2"
@ -283,7 +291,7 @@ def MusyX(objects, mw_version="GC/1.3.2", debug=False, major=2, minor=0, patch=0
def Rel(lib_name, objects):
return {
"lib": lib_name,
"mw_version": "Wii/1.3",
"mw_version": "GC/1.3.2",
"cflags": cflags_rel,
"host": True,
"objects": objects,
@ -1294,6 +1302,15 @@ config.libs = [
Object(Matching, "Dolphin/GBA/GBAKey.c"),
],
),
Rel(
"NESemuP",
[
Object(
Matching,
"NESemu/modwrapper.c",
),
],
),
]
if args.mode == "configure":

2
extern/musyx vendored

@ -1 +1 @@
Subproject commit 28424c828c8c462e26953ded3b08e6f3a0c8e489
Subproject commit ddfad60c3e4fede55479c744a1c70081e0d6cd12

View File

@ -0,0 +1,27 @@
#ifndef _MODWRAPPER_H_
#define _MODWRAPPER_H_
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
void _prolog();
void _epilog();
void _unresolved();
// User functions
void ksNesInitModule(void);
#ifdef __MWERKS__
#define REL_EXPORT __declspec(export)
#else
#define REL_EXPORT
#endif
#ifdef __cplusplus
}
#endif
#endif // _MODWRAPPER_H_

View File

@ -162,6 +162,7 @@ u32 OSSaveContext(OSContext* context);
void OSClearContext(OSContext* context);
OSContext* OSGetCurrentContext();
void OSSetCurrentContext(OSContext* context);
u32 OSGetStackPointer();
#ifdef __cplusplus
}

48
src/NESemu/modwrapper.c Normal file
View File

@ -0,0 +1,48 @@
#include "NESemu/modwrapper.h"
#include "dolphin/os.h"
typedef void (*voidfunctionptr)(void); // pointer to function returning void
__declspec(section ".init") extern voidfunctionptr _ctors[];
__declspec(section ".init") extern voidfunctionptr _dtors[];
REL_EXPORT asm void _prolog(void) {
fralloc
lis r3, _ctors@ha
addi r0, r3, _ctors@l
mr r31, r0
b @2
@1:
mtctr r12
bctrl
addi r31, r31, 0x4
@2:
lwz r12, 0x0(r31)
cmplwi r12, 0x0
bne+ @1
bl ksNesInitModule
frfree
blr
}
REL_EXPORT asm void _epilog(void) {
fralloc
lis r3, _dtors@ha
addi r0, r3, _dtors@l
mr r31, r0
b @2
@1:
mtctr r12
bctrl
addi r31, r31, sizeof(voidfunctionptr)
@2:
lwz r12, 0x0(r31)
cmplwi r12, 0x0
bne+ @1
frfree
blr
}
REL_EXPORT void _unresolved(void) { OSPanic("modwrapper.c\0\0\0", 0x3d, "ksNesEmulator unresolved"); }