Skip to content

Commit 532731b

Browse files
committed
Cleanup options variables, spelling errors, declarations
Options for requested width, height, and pixel scaling and window title can be shared between display subsystems. Include correct header for local sdl function definitions rather than manually duplicating a reference for init_SDL(). Correct a typo in comments on build_lisp_map().
1 parent 29e5b37 commit 532731b

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/main.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ int flushing = FALSE; /* see dbprint.h if set, all debug/trace printing will cal
243243
extern DspInterface currentdsp;
244244
#endif /* DOS || XWINDOW */
245245
#ifdef SDL
246-
extern int init_SDL(char*, int, int, int);
246+
#include "sdldefs.h" /* for init_SDL */
247247
#endif
248248
extern const time_t MDate;
249249
extern int nokbdflag;
@@ -324,6 +324,15 @@ extern char foregroundColorName[64];
324324
char backgroundColorName[64] = {0};
325325
extern char backgroundColorName[64];
326326
#endif
327+
char windowTitle[255] = "Medley";
328+
extern char windowTitle[255];
329+
int lispDisplayRequestedWidth = 1024;
330+
extern int lispDisplayRequestedWidth;
331+
int lispDisplayRequestedHeight = 768;
332+
extern int lispDisplayRequestedHeight;
333+
int pixelScale = 1;
334+
extern int pixelScale;
335+
327336
/************************************************************************/
328337
/* */
329338
/* M A I N E N T R Y P O I N T */
@@ -338,9 +347,6 @@ int main(int argc, char *argv[])
338347
extern int TIMER_INTERVAL;
339348
extern fd_set LispReadFds;
340349
long tmpint;
341-
int width = 1024, height = 768;
342-
int pixelscale = 1;
343-
char *windowtitle = "Medley";
344350

345351
#ifdef MAIKO_ENABLE_FOREIGN_FUNCTION_INTERFACE
346352
if (dld_find_executable(argv[0]) == 0) {
@@ -365,7 +371,6 @@ int main(int argc, char *argv[])
365371
// arg processing changes argc/argv
366372
if (argc > 1 && argv[1][0] != '-') {
367373
strncpy(sysout_name_first_arg, argv[1], MAXPATHLEN);
368-
i++;
369374
}
370375

371376

@@ -468,7 +473,7 @@ int main(int argc, char *argv[])
468473
#ifdef SDL
469474
else if ((strcmp(argv[i], "-sc") == 0) || (strcmp(argv[i], "-SC") == 0)) {
470475
if (argc > ++i) {
471-
int read = sscanf(argv[i], "%dx%d", &width, &height);
476+
int read = sscanf(argv[i], "%dx%d", &lispDisplayRequestedWidth, &lispDisplayRequestedHeight);
472477
if(read != 2) {
473478
(void)fprintf(stderr, "Could not parse -sc argument %s\n", argv[i]);
474479
exit(1);
@@ -479,7 +484,7 @@ int main(int argc, char *argv[])
479484
}
480485
} else if ((strcmp(argv[i], "-pixelscale") == 0) || (strcmp(argv[i], "-PIXELSCALE") == 0)) {
481486
if (argc > ++i) {
482-
int read = sscanf(argv[i], "%d", &pixelscale);
487+
int read = sscanf(argv[i], "%d", &pixelScale);
483488
if(read != 1) {
484489
(void)fprintf(stderr, "Could not parse -pixelscale argument %s\n", argv[i]);
485490
exit(1);
@@ -491,7 +496,7 @@ int main(int argc, char *argv[])
491496
} else if ((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "-T") == 0)
492497
|| (strcmp(argv[i], "-title") == 0) || (strcmp(argv[i], "-TITLE") == 0)) {
493498
if (argc > ++i) {
494-
windowtitle = argv[i];
499+
strncpy(windowTitle, argv[i], sizeof(windowTitle) - 1);
495500
} else {
496501
(void)fprintf(stderr, "Missing argument after -title\n");
497502
exit(1);
@@ -711,13 +716,12 @@ int main(int argc, char *argv[])
711716
make_dsp_instance(currentdsp, 0, 0, 0, 1); /* All defaults the first time */
712717
#endif /* DOS || XWINDOW */
713718
#if defined(SDL)
714-
init_SDL(windowtitle, width, height, pixelscale);
719+
init_SDL(windowTitle, lispDisplayRequestedWidth, lispDisplayRequestedHeight, pixelScale);
715720
#endif /* SDL */
716721
/* Load sysout to VM space and returns real sysout_size(not 0) */
717722
sysout_size = sysout_loader(sysout_name, sysout_size);
718723

719-
build_lisp_map(); /* built up map */
720-
724+
build_lisp_map(); /* build up map */
721725
init_ifpage(sysout_size); /* init interface page */
722726
init_iopage();
723727
init_miscstats();

src/sdl.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,7 @@ int init_SDL(char *windowtitle, int w, int h, int s) {
15651565
sdl_displayheight = h;
15661566
sdl_windowwidth = w * s;
15671567
sdl_windowheight = h * s;
1568-
int width = sdl_displaywidth;
1569-
int height = sdl_displayheight;
1570-
printf("requested width: %d, height: %d\n", width, height);
1568+
printf("requested width: %d, height: %d\n", sdl_displaywidth, sdl_displayheight);
15711569
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
15721570
printf("SDL could not be initialized. SDL_Error: %s\n", SDL_GetError());
15731571
return 1;
@@ -1608,7 +1606,8 @@ int init_SDL(char *windowtitle, int w, int h, int s) {
16081606
#endif
16091607
printf("Creating texture...\n");
16101608
sdl_texture = SDL_CreateTexture(sdl_renderer, sdl_pixelformat->format,
1611-
SDL_TEXTUREACCESS_STREAMING, width, height);
1609+
SDL_TEXTUREACCESS_STREAMING,
1610+
sdl_displaywidth, sdl_displayheight);
16121611
sdl_foreground_color = sdl_MapColorName(sdl_pixelformat,
16131612
foregroundColorName[0] ? foregroundColorName : "black");
16141613
sdl_background_color = sdl_MapColorName(sdl_pixelformat,

0 commit comments

Comments
 (0)