Mercurial > repos > blastem
diff blastem.c @ 340:58a085cfc6bd
Set window title based on ROM header name
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 15 May 2013 23:32:21 -0700 |
parents | 5c34a9c39394 |
children | 6ad8e36de685 |
line wrap: on
line diff
--- a/blastem.c Wed May 15 22:39:36 2013 -0700 +++ b/blastem.c Wed May 15 23:32:21 2013 -0700 @@ -1023,6 +1023,39 @@ 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 @@ 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;