From 05e4614af434934ba66e2eeba17e70e7bd9a2f82 Mon Sep 17 00:00:00 2001 From: condret Date: Fri, 15 Nov 2024 04:44:29 +0100 Subject: [PATCH] Start working on esil stop and halt custom ops --- Makefile | 7 +++++-- gb/esil.c | 25 +++++++++++++++++++++++++ include/gb.h | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gb/esil.c diff --git a/Makefile b/Makefile index 637145f..d80313b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ LDFLAGS = $(shell pkg-config --libs sdl2 r_util r_io) CFLAGS = -Wall -I include/ $(shell pkg-config --cflags sdl2 r_util r_io r_arch r_esil r_anal r_reg) -all: sdl/pixbuf.o io/timers.o io/mbc1.o io/mbc2.o io/joypad.o io/dma.o io/ppu.o io/interrupts.o +all: sdl/pixbuf.o io/timers.o io/mbc1.o io/mbc2.o io/joypad.o io/dma.o io/ppu.o io/interrupts.o gb/esil.o sdl/pixbuf.o: gcc -c sdl/pixbuf.c -o sdl/pixbuf.o $(CFLAGS) @@ -27,5 +27,8 @@ io/ppu.o: io/interrupts.o: gcc -c io/interrupts.c -o io/interrupts.o $(CFLAGS) +gb/esil.o: + gcc -c gb/esil.c -o gb/esil.o $(CFLAGS) + clean: - rm sdl/*.o && rm io/*.o + rm sdl/*.o && rm io/*.o && rm gb/*.o diff --git a/gb/esil.c b/gb/esil.c new file mode 100644 index 0000000..a9488fc --- /dev/null +++ b/gb/esil.c @@ -0,0 +1,25 @@ +#include +#include + +bool gb_custom_op_halt (REsil *esil) { + return true; +} + +bool gb_custom_op_stop (REsil *esil) { + return true; +} + +bool gb_esil_setup (GB *gb) { + if (!gb) { + return false; + } + gb->esil = r_esil_new (4096, 0, 1); + if (!gb->esil) { + return false; + } + r_esil_setup (gb->esil, gb->anal, false, false, false); + gb->esil->user = gb; + r_esil_set_op (gb->esil, "halt", gb_custom_op_halt, 0, 0, R_ESIL_OP_TYPE_CUSTOM); + r_esil_set_op (gb->esil, "stop", gb_custom_op_stop, 0, 0, R_ESIL_OP_TYPE_CUSTOM); + return true; +} diff --git a/include/gb.h b/include/gb.h index b4522cc..b934450 100644 --- a/include/gb.h +++ b/include/gb.h @@ -251,4 +251,6 @@ extern RIOPlugin r_io_plugin_gb_mbc1; extern RIOPlugin r_io_plugin_gb_mbc2; extern RIOPlugin r_io_plugin_gb_joypad; +bool gb_esil_setup (GB *gb); + #endif