diff --git a/cli/emulator.c b/cli/emulator.c index 095e5e8..1974456 100644 --- a/cli/emulator.c +++ b/cli/emulator.c @@ -26,9 +26,6 @@ int emulator_main(int argc, char *argv[]) lcd_new(&lcd); - // this might be too much abstraction but it'll let me - // test the cpu, rom, and dmg independently and use the cpu - // for other non-GB stuff dmg_new(&dmg, &cpu, &rom, &lcd); cpu.dmg = &dmg; // cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write); diff --git a/cli/imgui_example.cpp b/cli/imgui_example.cpp index 55d6fe4..a25a2ad 100644 --- a/cli/imgui_example.cpp +++ b/cli/imgui_example.cpp @@ -152,9 +152,6 @@ int main(int argc, char *argv[]) lcd_new(&lcd); - // this might be too much abstraction but it'll let me - // test the cpu, rom, and dmg independently and use the cpu - // for other non-GB stuff dmg_new(&dmg, &cpu, &rom, &lcd); cpu.dmg = &dmg; // cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write); diff --git a/src/dmg.c b/src/dmg.c index 8dfffe0..833d6cf 100644 --- a/src/dmg.c +++ b/src/dmg.c @@ -262,22 +262,22 @@ void dmg_step(void *_dmg) dmg_request_interrupt(dmg, INT_LCDSTAT); } - // int lcdc = lcd_read(dmg->lcd, REG_LCDC); - // if (lcdc & LCDC_ENABLE_BG) { - // render_background(dmg, lcdc); - // } + int lcdc = lcd_read(dmg->lcd, REG_LCDC); + if (lcdc & LCDC_ENABLE_BG) { + render_background(dmg, lcdc); + } - // if (lcdc & LCDC_ENABLE_WINDOW) { - // // printf("window\n"); - // } + if (lcdc & LCDC_ENABLE_WINDOW) { + // printf("window\n"); + } - // lcd_apply_scroll(dmg->lcd); + lcd_apply_scroll(dmg->lcd); - // if (lcdc & LCDC_ENABLE_OBJ) { - // render_objs(dmg); - // } + if (lcdc & LCDC_ENABLE_OBJ) { + render_objs(dmg); + } - // lcd_draw(dmg->lcd); + lcd_draw(dmg->lcd); } } else { int scan = lcd_read(dmg->lcd, REG_LY); diff --git a/system6/CMakeLists.txt b/system6/CMakeLists.txt index 90698e8..53d87bf 100644 --- a/system6/CMakeLists.txt +++ b/system6/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.9) include_directories(../src) -set(CMAKE_CXX_FLAGS "-O3") +set(CMAKE_C_FLAGS "-O3") add_application(Emulator ../src/bootstrap.c diff --git a/system6/emulator.c b/system6/emulator.c index 3bd404f..ea1646b 100644 --- a/system6/emulator.c +++ b/system6/emulator.c @@ -89,7 +89,7 @@ void Render(void) MoveTo(10, 180); char debug[128]; double ms = execTime / 600.0; - sprintf(debug, "10000 insn %d ticks, %f ms per instruction", execTime, ms); + sprintf(debug, "10000 in %d ticks, %.2f ms per instruction", execTime, ms); C2PStr(debug); DrawString(debug); } @@ -102,6 +102,13 @@ void Render(void) // 0.000695 second per instruction // 0.695 ms per instruction +// REAL GB: +// 4194304 Hz +// 1048576 NOPs per second +// 174763 CALL 16s per second +// 0.001 ms per NOP +// 0.006 ms per CALL 16 + void StartEmulation(void) { g_wp = NewWindow(0, &windowBounds, WINDOW_TITLE, true,