commit bd8b7bb

zzo38  ·  2024-06-24 19:46:19 +0000 UTC
parent 67da655
Make the -F switch to automatically determine the screen size (if not overridden by the user).
2 files changed,  +14, -3
M main.c
+3, -1
 1@@ -5,7 +5,9 @@
 2   Use double buffering for the display.
 3 
 4 -F
 5-  Start in full screen mode.
 6+  Start in full screen mode. It will decide the appropriate screen size
 7+  automatically if you do not specify the -w and -h switches. This does
 8+  not imply -S but you may specify both switches.
 9 
10 -I
11   Use a separate thread to read from stdin.
M main.c
+11, -2
 1@@ -1671,6 +1671,14 @@ static void do_script(Uint8 stage) {
 2   use_extension=u;
 3 }
 4 
 5+static void set_full_screen_size(void) {
 6+  SDL_Rect**m=SDL_ListModes(0,scrflags);
 7+  int i;
 8+  if(!m || m==(SDL_Rect**)(-1) || !*m) errx(1,"Cannot determine size to use for full screen mode");
 9+  default_width=m[0]->w/zoom;
10+  default_height=m[0]->h/zoom;
11+}
12+
13 int main(int argc,char**argv) {
14   int i,j;
15   for(i=0;i<16;i++) {
16@@ -1687,7 +1695,7 @@ int main(int argc,char**argv) {
17   inf=stdin; outf=stdout;
18   while((i=getopt(argc,argv,"+ADFIJ:NOQST:YZa:de:h:ijm:np:qs:t:w:xyz:"))>0) switch(i) {
19     case 'D': scrflags|=SDL_DOUBLEBUF; break;
20-    case 'F': scrflags|=SDL_FULLSCREEN; break;
21+    case 'F': scrflags|=SDL_FULLSCREEN; default_width=default_height=0; break;
22     case 'I': use_thread=1; break;
23     case 'J': set_joystick(optarg); break;
24     case 'N': scrflags|=SDL_NOFRAME; break;
25@@ -1726,10 +1734,11 @@ int main(int argc,char**argv) {
26   load_rom();
27   if(use_screen) {
28     if(zoom<1) errx(1,"Zoom out of range");
29-    if(default_height<1 || default_width<1) errx(1,"Screen size out of range");
30+    if((default_height<1 || default_width<1) && !(scrflags&SDL_FULLSCREEN)) errx(1,"Screen size out of range");
31     if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|(audio_option?SDL_INIT_AUDIO:0)|(joy_mask?SDL_INIT_JOYSTICK:0))) errx(1,"Cannot initialize SDL: %s",SDL_GetError());
32     atexit(SDL_Quit);
33     device[2].out=screen_out;
34+    if(!default_width && !default_height && (scrflags&SDL_FULLSCREEN)) set_full_screen_size();
35     scr_w=default_width;
36     scr_h=default_height;
37     PUT16(device[2].d+2,scr_w);