--- uae/src/od-dos/video/video.c 2018/04/24 16:40:30 1.1.1.1 +++ uae/src/od-dos/video/video.c 2018/04/24 16:44:03 1.1.1.3 @@ -125,10 +125,114 @@ void InitColors(void) { } } +struct gfxstring *gfxmenu; +int numgfxitems = 0; + +struct gfxstring{ + char data[32]; + int val; +}; + +int gfxmenusort(const void *a, const void *b) { + struct gfxstring *ga, *gb; + + ga = (struct gfxstring *) a; + gb = (struct gfxstring *) b; + if (ModeList[ga->val].ModeWidth < ModeList[gb->val].ModeWidth) + return(-1); + else if (ModeList[ga->val].ModeWidth > ModeList[gb->val].ModeWidth) + return(1); + else if (ModeList[ga->val].ModeHeight < ModeList[gb->val].ModeHeight) + return(-1); + else if (ModeList[ga->val].ModeHeight > ModeList[gb->val].ModeHeight) + return(1); + else if (ModeList[ga->val].ModeType < ModeList[gb->val].ModeType) + return(-1); + else if (ModeList[ga->val].ModeType > ModeList[gb->val].ModeType) + return(1); + return(0); +} + int graphics_setup(void) { + int i, j, hasres; + struct gfxstring gfxmenuitem; + + gfxmenu = (struct gfxstring *)calloc(NumberOfModes, sizeof(struct gfxstring)); + + for (i = 0; i < NumberOfModes; i++) { + hasres = 0; + for (j = 0; j < numgfxitems; j++) + if ((ModeList[gfxmenu[j].val].ModeType == ModeList[i].ModeType) && + (ModeList[gfxmenu[j].val].ModeWidth == ModeList[i].ModeWidth) && + (ModeList[gfxmenu[j].val].ModeHeight == ModeList[i].ModeHeight)) + hasres = 1; + if (!hasres) { + sprintf(gfxmenu[numgfxitems].data, "%dx%d ", ModeList[i].ModeWidth, ModeList[i].ModeHeight); + switch (ModeList[i].ModeType) { + case T16: + strcat(gfxmenu[numgfxitems].data, "16 colors"); + break; + case T256: + strcat(gfxmenu[numgfxitems].data, "256 colors"); + break; + case T32K: + strcat(gfxmenu[numgfxitems].data, "32k colors"); + break; + case T64K: + strcat(gfxmenu[numgfxitems].data, "64k colors"); + break; + case T16M: + strcat(gfxmenu[numgfxitems].data, "16M colors"); + break; + } + gfxmenu[numgfxitems].val = i; + numgfxitems++; + } + } + qsort((void *)gfxmenu, numgfxitems, sizeof(struct gfxstring), gfxmenusort); + + video_mode_menu = (struct bstring *)malloc(sizeof (struct bstring)*(numgfxitems+1)); + for (i = 0; i < numgfxitems; i++) { + video_mode_menu[i].val = -1; + video_mode_menu[i].data = strdup(gfxmenu[i].data); + } + video_mode_menu[numgfxitems].val = -3; + video_mode_menu[numgfxitems].data = NULL; + return 1; } +void vidmode_menu_selected(int a) { + currprefs.gfx_width = ModeList[gfxmenu[a].val].ModeWidth; + currprefs.gfx_height = ModeList[gfxmenu[a].val].ModeHeight; + switch (ModeList[gfxmenu[a].val].ModeType) { + case T16: + currprefs.color_mode = 4; + break; + case T256: + currprefs.color_mode = 0; + break; + case T32K: + currprefs.color_mode = 1; + break; + case T64K: + currprefs.color_mode = 2; + break; + case T16M: + currprefs.color_mode = 5; + break; + } + currprefs.gfx_lores=currprefs.gfx_width<640; + currprefs.gfx_xcenter=2; + currprefs.gfx_ycenter=2; + currprefs.gfx_linedbl=0; + if (currprefs.gfx_height > 285) + currprefs.gfx_linedbl = 1; + currprefs.gfx_correct_aspect = 1; + if (currprefs.gfx_height > 570) + currprefs.gfx_correct_aspect = 0; +} + int graphics_init(void) { T_ModeType WantedType; int i; @@ -181,7 +285,7 @@ int graphics_init(void) { return 0; } - if (!SetMode(ModeNumber, UseLinear)) { + if (!SetMode(ModeNumber, UseLinear, 1)) { printf("Can't start graphics mode.\n"); return 0; } @@ -325,7 +429,7 @@ int DX_FillResolutions (uae_u16 *ppixel_ } void SetWindowForPicasso(void) { - if (!SetMode(PicassoModeNumber, PicassoUseLinear)) { + if (!SetMode(PicassoModeNumber, PicassoUseLinear, 0)) { printf("Can't start graphics mode.\n"); abort(); } @@ -338,7 +442,7 @@ void SetWindowForPicasso(void) { } void SetWindowForAmiga(void) { - if (!SetMode(ModeNumber, UseLinear)) { + if (!SetMode(ModeNumber, UseLinear, 0)) { printf("Can't start graphics mode.\n"); abort(); }