From 6604b3dd06429b5562b9f3ca9fe90f12ef3b9908 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 21 Oct 2021 18:44:31 +0200 Subject: [PATCH] Add support for -t / -title. --- src/main.c | 22 +++++++++++++++++----- src/sdl.c | 4 ++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 5556382..4d23107 100644 --- a/src/main.c +++ b/src/main.c @@ -239,7 +239,7 @@ int flushing = FALSE; /* see dbprint.h if set, all debug/trace printing will cal extern DspInterface currentdsp; #endif /* DOS || XWINDOW */ #ifdef SDL -extern int init_SDL(int, int, int); +extern int init_SDL(char*, int, int, int); #endif extern const time_t MDate; extern int nokbdflag; @@ -284,7 +284,9 @@ const char *helpstring = -info Print general info about the system\n\ -help Print this message\n\ -pixelscale The amount of pixels to show for one Medley screen pixel.\n\ - -sc[reen] x] The Medley screen geometry\n"; + -sc[reen] x] The Medley screen geometry\n\ + -t The window title\n\ + -title <title> The window title\n"; #else /* not DOS, not XWINDOW, not SDL */ const char *helpstring = "\n\ @@ -326,6 +328,7 @@ int main(int argc, char *argv[]) long tmpint; int width = 1024, height = 768; int pixelscale = 1; + char *windowtitle = "Medley"; #ifdef MAIKO_ENABLE_FOREIGN_FUNCTION_INTERFACE if (dld_find_executable(argv[0]) == 0) { @@ -463,7 +466,7 @@ int main(int argc, char *argv[]) exit(1); } } else { - fprintf(stderr, "Missing argument after -m\n"); + fprintf(stderr, "Missing argument after -sc\n"); exit(1); } } else if ((strcmp(argv[i], "-pixelscale") == 0) || (strcmp(argv[i], "-PIXELSCALE") == 0)) { @@ -474,10 +477,19 @@ int main(int argc, char *argv[]) exit(1); } } else { - fprintf(stderr, "Missing argument after -m\n"); + fprintf(stderr, "Missing argument after -pixelscale\n"); + exit(1); + } + } else if ((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "-T") == 0) + || (strcmp(argv[i], "-title") == 0) || (strcmp(argv[i], "-TITLE") == 0)) { + if (argc > ++i) { + windowtitle = argv[i]; + } else { + fprintf(stderr, "Missing argument after -title\n"); exit(1); } } + #endif /* SDL */ /* Can only do this under SUNOs, for now */ else if (!strcmp(argv[i], "-E")) { /**** ethernet info ****/ @@ -637,7 +649,7 @@ int main(int argc, char *argv[]) make_dsp_instance(currentdsp, 0, 0, 0, 1); /* All defaults the first time */ #endif /* DOS || XWINDOW */ #if defined(SDL) - init_SDL(width, height, pixelscale); + init_SDL(windowtitle, width, height, pixelscale); #endif /* SDL */ /* Load sysout to VM space and returns real sysout_size(not 0) */ sysout_size = sysout_loader(sysout_name, sysout_size); diff --git a/src/sdl.c b/src/sdl.c index 90e513e..bbff60b 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -445,7 +445,7 @@ void process_SDLevents() { // printf("rendering took %dms\n", after - before); } } -int init_SDL(int w, int h, int s) { +int init_SDL(char *windowtitle, int w, int h, int s) { sdl_pixelscale = s; // must be multiples of 32 w = w / 32 * 32; @@ -462,7 +462,7 @@ int init_SDL(int w, int h, int s) { return 1; } printf("initialised\n"); - sdl_window = SDL_CreateWindow("Maiko", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, sdl_windowwidth, sdl_windowheight, 0); + sdl_window = SDL_CreateWindow(windowtitle, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, sdl_windowwidth, sdl_windowheight, 0); printf("Window created\n"); if(sdl_window == NULL) { printf("Window could not be created. SDL_Error: %s\n", SDL_GetError());