Skip to content

Commit

Permalink
make startup 'detecting video modes' output debug-level chatter
Browse files Browse the repository at this point in the history
Use the new 'listvidmodes' osd command to see them in a game
  • Loading branch information
jonof committed Dec 2, 2023
1 parent 4034aa2 commit 2cc9638
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
29 changes: 29 additions & 0 deletions src/baselayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,34 @@ static int osdcmd_vars(const osdfuncparm_t *parm)
return OSDCMD_SHOWHELP;
}

static int osdcmd_listvidmodes(const osdfuncparm_t *parm)
{
int filterbpp = -1, filterfs = -1, found = 0;

for (int i = 0; i < parm->numparms; i++) {
if (strcasecmp(parm->parms[i], "win") == 0) {
filterfs = 0;
} else if (strcasecmp(parm->parms[i], "fs") == 0) {
filterfs = 1;
} else {
char *e = NULL;
long l = strtol(parm->parms[i], &e, 10);
if (!e || *e != 0) return OSDCMD_SHOWHELP;
filterbpp = (int)l;
}
}

for (int i = 0; i < validmodecnt; i++) {
if (filterbpp >= 0 && validmode[i].bpp != filterbpp) continue;
if (filterfs >= 0 && (validmode[i].fs & 1) != filterfs) continue;
buildprintf(" %4dx%-4d %d-bit %s\n", validmode[i].xdim, validmode[i].ydim,
validmode[i].bpp, (validmode[i].fs & 1) ? "fullscreen" : "windowed");
found++;
}
buildprintf("%d modes identified\n", found);
return OSDCMD_OK;
}

int baselayer_init(void)
{
OSD_Init();
Expand All @@ -234,6 +262,7 @@ int baselayer_init(void)

OSD_RegisterFunction("novoxmips","novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars);
OSD_RegisterFunction("usevoxels","usevoxels: enable/disable automatic sprite->voxel rendering",osdcmd_vars);
OSD_RegisterFunction("listvidmodes","listvidmodes [bpp|win|fs]: show all available video mode combinations",osdcmd_listvidmodes);

#if USE_POLYMOST
OSD_RegisterFunction("setrendermode","setrendermode <number>: sets the engine's rendering mode.\n"
Expand Down
4 changes: 2 additions & 2 deletions src/sdlayer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ void getvalidmodes(void)
return;
}

buildputs("Detecting video modes:\n");
debugprintf("Detecting video modes:\n");

#define ADDMODE(x,y,c,f) if (validmodecnt<MAXVALIDMODES) { \
int mn; \
Expand All @@ -717,7 +717,7 @@ void getvalidmodes(void)
validmode[validmodecnt].bpp=c; \
validmode[validmodecnt].fs=f; \
validmodecnt++; \
buildprintf(" - %dx%d %d-bit %s\n", x, y, c, (f&1)?"fullscreen":"windowed"); \
debugprintf(" - %dx%d %d-bit %s\n", x, y, c, (f&1)?"fullscreen":"windowed"); \
} \
}

Expand Down
4 changes: 2 additions & 2 deletions src/winlayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ int setvideomode(int x, int y, int c, int fs)
validmode[validmodecnt].fs=f; \
validmode[validmodecnt].extra=n; \
validmodecnt++; \
buildprintf(" - %dx%d %d-bit %s\n", x, y, c, (f&1)?"fullscreen":"windowed"); \
debugprintf(" - %dx%d %d-bit %s\n", x, y, c, (f&1)?"fullscreen":"windowed"); \
}

#define CHECKL(w,h) if ((w < maxx) && (h < maxy))
Expand Down Expand Up @@ -1228,7 +1228,7 @@ void getvalidmodes(void)
if (modeschecked) return;

validmodecnt=0;
buildputs("Detecting video modes:\n");
debugprintf("Detecting video modes:\n");

// Fullscreen 8-bit modes: upsamples to the desktop mode.
maxx = desktopxdim;
Expand Down

0 comments on commit 2cc9638

Please sign in to comment.