summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-05-15 23:32:21 -0700
committerMike Pavone <pavone@retrodev.com>2013-05-15 23:32:21 -0700
commit4ac4182037dad9f6fd1693b1e75cefa9cc60aa7f (patch)
treed497a751f7720edaec0de17001f17dbc28c93d88
parentba79e12a288587fe4be9d562d2552250e089f585 (diff)
Set window title based on ROM header name
-rw-r--r--blastem.c36
-rw-r--r--render.h2
-rw-r--r--render_sdl.c3
3 files changed, 38 insertions, 3 deletions
diff --git a/blastem.c b/blastem.c
index 8366883..240dcda 100644
--- a/blastem.c
+++ b/blastem.c
@@ -1023,6 +1023,39 @@ void init_run_cpu(genesis_context * gen, int debug, FILE * address_log)
m68k_reset(&context);
}
+char title[64];
+
+#define TITLE_START 0x150
+#define TITLE_END (TITLE_START+48)
+
+void update_title()
+{
+ uint16_t *last = cart + TITLE_END/2 - 1;
+ while(last > cart + TITLE_START/2 && *last == 0x2020)
+ {
+ last--;
+ }
+ uint16_t *start = cart + TITLE_START/2;
+ char *cur = title;
+ char last_char = ' ';
+ for (; start != last; start++)
+ {
+ if ((last_char != ' ' || (*start >> 8) != ' ') && (*start >> 8) < 0x80) {
+ *(cur++) = *start >> 8;
+ last_char = *start >> 8;
+ }
+ if (last_char != ' ' || (*start & 0xFF) != ' ' && (*start & 0xFF) < 0x80) {
+ *(cur++) = *start;
+ last_char = *start & 0xFF;
+ }
+ }
+ *(cur++) = *start >> 8;
+ if ((*start & 0xFF) != ' ') {
+ *(cur++) = *start;
+ }
+ strcpy(cur, " - BlastEm");
+}
+
int main(int argc, char ** argv)
{
if (argc < 2) {
@@ -1065,10 +1098,11 @@ int main(int argc, char ** argv)
height = atoi(argv[i]);
}
}
+ update_title();
width = width < 320 ? 320 : width;
height = height < 240 ? (width/320) * 240 : height;
if (!headless) {
- render_init(width, height);
+ render_init(width, height, title);
}
vdp_context v_context;
diff --git a/render.h b/render.h
index 82a5cb6..d73ecb3 100644
--- a/render.h
+++ b/render.h
@@ -2,7 +2,7 @@
#define RENDER_SDL_H_
#include "vdp.h"
-void render_init(int width, int height);
+void render_init(int width, int height, char * title);
void render_context(vdp_context * context);
void render_wait_quit(vdp_context * context);
int wait_render_frame(vdp_context * context, int frame_limit);
diff --git a/render_sdl.c b/render_sdl.c
index 5cad352..502cae4 100644
--- a/render_sdl.c
+++ b/render_sdl.c
@@ -15,7 +15,7 @@ uint8_t levels[] = {0, 27, 49, 71, 87, 103, 119, 130, 146, 157, 174, 190, 206, 2
uint32_t min_delay;
-void render_init(int width, int height)
+void render_init(int width, int height, char * title)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
@@ -32,6 +32,7 @@ void render_init(int width, int height)
fprintf(stderr, "BlastEm requires at least a 16-bit surface, SDL returned a %d-bit surface\n", screen->format->BytesPerPixel * 8);
exit(1);
}
+ SDL_WM_SetCaption(title, title);
uint8_t b,g,r;
for (uint16_t color = 0; color < (1 << 12); color++) {
if (color & FBUF_SHADOW) {