diff options
author | Mike Pavone <pavone@retrodev.com> | 2012-12-19 20:53:59 -0800 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2012-12-19 20:53:59 -0800 |
commit | 5061934613fc7cd633ef0ab1551f3bec0491227a (patch) | |
tree | 8fc1a3a248d28511bc0ab3fc444452bb7a014b59 | |
parent | f8f558ca4493901200f718208b3a57d59e742563 (diff) |
Add FPS counter to console output
-rw-r--r-- | render_sdl.c | 13 | ||||
-rw-r--r-- | vdp.c | 9 |
2 files changed, 20 insertions, 2 deletions
diff --git a/render_sdl.c b/render_sdl.c index f91ca29..2c82cd1 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -162,7 +162,8 @@ void render_wait_quit(vdp_context * context) #define FRAME_DELAY 16 #define MIN_DELAY 10 - +uint32_t frame_counter = 0; +uint32_t start = 0; void wait_render_frame(vdp_context * context) { SDL_Event event; @@ -184,6 +185,7 @@ void wait_render_frame(vdp_context * context) } break; case SDL_QUIT: + puts(""); exit(0); } } @@ -200,6 +202,15 @@ void wait_render_frame(vdp_context * context) } } render_context(context); + frame_counter++; + if ((last_frame - start) > 1000) { + if (start) { + printf("\r%f fps", ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0)); + fflush(stdout); + } + start = last_frame; + frame_counter = 0; + } } @@ -892,14 +892,21 @@ void vdp_control_port_write(vdp_context * context, uint16_t value) if (context->flags & FLAG_PENDING) { context->address = (context->address & 0x3FFF) | (value << 14); context->cd = (context->cd & 0x3) | ((value >> 2) & 0x3C); + if (context->cd & 0x30) { + puts("attempt to use DMA detected!"); + } + //printf("New Address: %X, New CD: %X\n", context->address, context->cd); context->flags &= ~FLAG_PENDING; } else { if ((value & 0xC000) == 0x8000) { //Register write uint8_t reg = (value >> 8) & 0x1F; if (reg < VDP_REGS) { - //printf("register %d set to %X\n", reg, value); + //printf("register %d set to %X\n", reg, value & 0xFF); context->regs[reg] = value; + /*if (reg == REG_MODE_2) { + printf("Display is now %s\n", (context->regs[REG_MODE_2] & DISPLAY_ENABLE) ? "enabled" : "disabled"); + }*/ } } else { context->flags |= FLAG_PENDING; |