From 1bd3dc8e28bee97bae894bdb2a36a2a7a0032924 Mon Sep 17 00:00:00 2001 From: Matt Laux Date: Wed, 17 Apr 2019 02:36:49 -0500 Subject: [PATCH] got the old GUI compiling with Retro68 can't load a ROM because Standard File isn't loaded? --- .gitignore | 1 + CMakeLists.txt | 6 ++++++ src/old/emulator.c | 13 +++++++++---- src/old/z80.c | 18 +++++++++--------- 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index fafd190..6ad4ea6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ emu *.img vMac* .vscode +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..08bdef3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +add_application(Emulator + src/old/emulator.c + src/old/mem_model.c + src/old/z80.c + resources.r +) diff --git a/src/old/emulator.c b/src/old/emulator.c index 3584dd3..bee8b99 100644 --- a/src/old/emulator.c +++ b/src/old/emulator.c @@ -8,6 +8,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "gb_types.h" #include "z80.h" @@ -66,7 +71,7 @@ bool LoadRom(FSSpec *fp) if(theState.rom != NULL) { // unload existing ROM - DisposPtr((char *) theState.rom); + free((char *) theState.rom); theState.romLength = 0; } @@ -77,7 +82,7 @@ bool LoadRom(FSSpec *fp) } GetEOF(fileNo, (long *) &theState.romLength); - theState.rom = (unsigned char *) NewPtr(theState.romLength); + theState.rom = (unsigned char *) malloc(theState.romLength); if(theState.rom == NULL) { Alert(ALRT_NOT_ENOUGH_RAM, NULL); return false; @@ -117,7 +122,7 @@ void ShowAboutBox(void) while(!GetNextEvent(mDownMask, &e)); while(WaitMouseUp()); - DisposDialog(dp); + DisposeDialog(dp); } // -- EVENT FUNCTIONS -- @@ -202,4 +207,4 @@ int main(int argc, char *argv[]) } return 0; -} \ No newline at end of file +} diff --git a/src/old/z80.c b/src/old/z80.c index e9a83fe..b8841b0 100644 --- a/src/old/z80.c +++ b/src/old/z80.c @@ -69,10 +69,10 @@ z80_state *z80_create(void) { z80_state *state; - state = (z80_state *) NewPtr(sizeof(z80_state)); + state = (z80_state *) malloc(sizeof(z80_state)); - state->regs = (z80_regs *) NewPtr(sizeof(z80_regs)); - state->ram = (u8 *) NewPtr(GB_RAM_SIZE); + state->regs = (z80_regs *) malloc(sizeof(z80_regs)); + state->ram = (u8 *) malloc(GB_RAM_SIZE); state->regs->pc = 0; return state; @@ -80,9 +80,9 @@ z80_state *z80_create(void) void z80_destroy(z80_state *state) { - DisposPtr((char *) state->regs); - DisposPtr((char *) state->ram); - DisposPtr((char *) state); + free((char *) state->regs); + free((char *) state->ram); + free((char *) state); } void z80_dump_regs(z80_state *state) @@ -100,8 +100,8 @@ void z80_dump_regs(z80_state *state) line3[0] = strlen(line3); line4[0] = strlen(line4); - ParamText((void *) line1, (void *) line2, (void *) line3, (void *) line4); - Alert(129, NULL); + //ParamText((void *) line1, (void *) line2, (void *) line3, (void *) line4); + //Alert(129, NULL); } #define load(dst, src) ((dst) = (src)) @@ -300,4 +300,4 @@ void z80_run(z80_state *state) } } -} \ No newline at end of file +}