reenable rendering for now

This commit is contained in:
Matthew Laux 2022-08-02 15:11:51 -05:00
parent 2b6a315b0e
commit a9ecd14598
5 changed files with 21 additions and 20 deletions

View File

@ -26,9 +26,6 @@ int emulator_main(int argc, char *argv[])
lcd_new(&lcd); 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); dmg_new(&dmg, &cpu, &rom, &lcd);
cpu.dmg = &dmg; cpu.dmg = &dmg;
// cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write); // cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write);

View File

@ -152,9 +152,6 @@ int main(int argc, char *argv[])
lcd_new(&lcd); 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); dmg_new(&dmg, &cpu, &rom, &lcd);
cpu.dmg = &dmg; cpu.dmg = &dmg;
// cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write); // cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write);

View File

@ -262,22 +262,22 @@ void dmg_step(void *_dmg)
dmg_request_interrupt(dmg, INT_LCDSTAT); dmg_request_interrupt(dmg, INT_LCDSTAT);
} }
// int lcdc = lcd_read(dmg->lcd, REG_LCDC); int lcdc = lcd_read(dmg->lcd, REG_LCDC);
// if (lcdc & LCDC_ENABLE_BG) { if (lcdc & LCDC_ENABLE_BG) {
// render_background(dmg, lcdc); render_background(dmg, lcdc);
// } }
// if (lcdc & LCDC_ENABLE_WINDOW) { if (lcdc & LCDC_ENABLE_WINDOW) {
// // printf("window\n"); // printf("window\n");
// } }
// lcd_apply_scroll(dmg->lcd); lcd_apply_scroll(dmg->lcd);
// if (lcdc & LCDC_ENABLE_OBJ) { if (lcdc & LCDC_ENABLE_OBJ) {
// render_objs(dmg); render_objs(dmg);
// } }
// lcd_draw(dmg->lcd); lcd_draw(dmg->lcd);
} }
} else { } else {
int scan = lcd_read(dmg->lcd, REG_LY); int scan = lcd_read(dmg->lcd, REG_LY);

View File

@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.9)
include_directories(../src) include_directories(../src)
set(CMAKE_CXX_FLAGS "-O3") set(CMAKE_C_FLAGS "-O3")
add_application(Emulator add_application(Emulator
../src/bootstrap.c ../src/bootstrap.c

View File

@ -89,7 +89,7 @@ void Render(void)
MoveTo(10, 180); MoveTo(10, 180);
char debug[128]; char debug[128];
double ms = execTime / 600.0; 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); C2PStr(debug);
DrawString(debug); DrawString(debug);
} }
@ -102,6 +102,13 @@ void Render(void)
// 0.000695 second per instruction // 0.000695 second per instruction
// 0.695 ms 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) void StartEmulation(void)
{ {
g_wp = NewWindow(0, &windowBounds, WINDOW_TITLE, true, g_wp = NewWindow(0, &windowBounds, WINDOW_TITLE, true,