From 931a3998b096b27d881f4e4576759ef0e0bff4e1 Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Wed, 10 Jul 2013 23:47:48 -0700 Subject: Read joystick bindings from config file --- render_sdl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'render_sdl.c') diff --git a/render_sdl.c b/render_sdl.c index 5fbf518..6148c96 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -73,6 +73,11 @@ void render_close_audio() SDL_Joystick * joysticks[MAX_JOYSTICKS]; int num_joysticks; +int render_num_joysticks() +{ + return num_joysticks; +} + uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b) { return SDL_MapRGB(screen->format, r, g, b); -- cgit v1.2.3 From b94c9fd1cd3731c9a0bdcabcb15e7bead85021dc Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Wed, 17 Jul 2013 22:26:11 -0700 Subject: Add fullscreen support and add a keybinding for exiting the emulator --- render_sdl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'render_sdl.c') diff --git a/render_sdl.c b/render_sdl.c index 6148c96..bde6825 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -88,7 +88,7 @@ uint8_t render_depth() return screen->format->BytesPerPixel * 8; } -void render_init(int width, int height, char * title, uint32_t fps) +void render_init(int width, int height, char * title, uint32_t fps, uint8_t fullscreen) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); @@ -97,7 +97,13 @@ void render_init(int width, int height, char * title, uint32_t fps) atexit(SDL_Quit); atexit(render_close_audio); printf("width: %d, height: %d\n", width, height); - screen = SDL_SetVideoMode(width, height, 32, SDL_SWSURFACE | SDL_ANYFORMAT); + uint32_t flags = SDL_ANYFORMAT; + if (fullscreen) { + flags |= SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF; + } else { + flags |= SDL_SWSURFACE; + } + screen = SDL_SetVideoMode(width, height, 32, flags); if (!screen) { fprintf(stderr, "Unable to get SDL surface: %s\n", SDL_GetError()); exit(1); @@ -216,7 +222,8 @@ void render_context(vdp_context * context) if ( SDL_MUSTLOCK(screen) ) { SDL_UnlockSurface(screen); } - SDL_UpdateRect(screen, 0, 0, screen->clip_rect.w, screen->clip_rect.h); + //SDL_UpdateRect(screen, 0, 0, screen->clip_rect.w, screen->clip_rect.h); + SDL_Flip(screen); if (context->regs[REG_MODE_4] & BIT_INTERLACE) { context->framebuf = context->framebuf == context->oddbuf ? context->evenbuf : context->oddbuf; -- cgit v1.2.3 From ac8549baa9e68eae2ecf8551f8dc6e1a0ba99ce4 Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Thu, 18 Jul 2013 09:59:39 -0700 Subject: Add config values for audio sample rate and buffer size --- render_sdl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'render_sdl.c') diff --git a/render_sdl.c b/render_sdl.c index bde6825..408c821 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -135,10 +135,21 @@ void render_init(int width, int height, char * title, uint32_t fps, uint8_t full audio_ready = SDL_CreateCond(); SDL_AudioSpec desired, actual; - desired.freq = 48000; + char * rate_str = tern_find_ptr(config, "audiorate"); + int rate = rate_str ? atoi(rate_str) : 0; + if (!rate) { + rate = 48000; + } + desired.freq = rate; desired.format = AUDIO_S16SYS; desired.channels = 2; - desired.samples = 2048;//1024; + char * samples_str = tern_find_ptr(config, "audiobuffer"); + int samples = samples_str ? atoi(samples_str) : 0; + if (!samples) { + samples = 512; + } + printf("config says: %d\n", samples); + desired.samples = samples*2; desired.callback = audio_callback; desired.userdata = NULL; -- cgit v1.2.3 From 2c302a78d201d9b594774cec505d14c22e03662c Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Tue, 10 Sep 2013 23:31:08 -0700 Subject: Added copyright notice to source files and added GPL license text in COPYING --- render_sdl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'render_sdl.c') diff --git a/render_sdl.c b/render_sdl.c index 408c821..8954deb 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -1,3 +1,8 @@ +/* + Copyright 2013 Michael Pavone + This file is part of BlastEm. + BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. +*/ #include #include #include "render.h" -- cgit v1.2.3 From b8dc9d69563379341f127af571b4bec1312f4ca0 Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Thu, 3 Oct 2013 21:22:05 -0700 Subject: Add an FPS counter to the title bar --- render_sdl.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'render_sdl.c') diff --git a/render_sdl.c b/render_sdl.c index 8954deb..3cbc604 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -93,6 +93,8 @@ uint8_t render_depth() return screen->format->BytesPerPixel * 8; } +char * caption = NULL; + void render_init(int width, int height, char * title, uint32_t fps, uint8_t fullscreen) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) { @@ -118,6 +120,7 @@ void render_init(int width, int height, char * title, uint32_t fps, uint8_t full exit(1); } SDL_WM_SetCaption(title, title); + caption = title; min_delay = 0; for (int i = 0; i < 100; i++) { uint32_t start = SDL_GetTicks(); @@ -326,6 +329,8 @@ int32_t handle_event(SDL_Event *event) return 0; } +char * fps_caption = NULL; + uint32_t frame_counter = 0; uint32_t start = 0; int wait_render_frame(vdp_context * context, int frame_limit) @@ -349,18 +354,22 @@ int wait_render_frame(vdp_context * context, int frame_limit) } } render_context(context); - - + + //TODO: Figure out why this causes segfaults - /*frame_counter++; + frame_counter++; if ((last_frame - start) > 1000) { if (start && (last_frame-start)) { - printf("\r%f fps", ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0)); + if (!fps_caption) { + fps_caption = malloc(strlen(caption) + strlen(" - 1000.1 fps") + 1); + } + sprintf(fps_caption, "%s - %.1f fps", caption, ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0)); + SDL_WM_SetCaption(fps_caption, caption); fflush(stdout); } start = last_frame; frame_counter = 0; - }*/ + } return ret; } -- cgit v1.2.3