static int load_cursor; ///< 0 < load_cursor < MAX_SAVEGAMES
-#define MAX_SAVEGAMES 12
static char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
static int loadable[MAX_SAVEGAMES];
//=============================================================================
/* VIDEO MENU */
-static video_resolution_t video_resolutions_hardcoded[] =
+video_resolution_t video_resolutions_hardcoded[] =
{
{"Standard 4x3" , 320, 240, 320, 240, 1 },
{"Standard 4x3" , 400, 300, 400, 300, 1 },
{NULL, 0, 0, 0, 0, 0}
};
// this is the number of the default mode (640x480) in the list above
+int video_resolutions_hardcoded_count = sizeof(video_resolutions_hardcoded) / sizeof(*video_resolutions_hardcoded) - 1;
#define VIDEO_ITEMS 11
static int video_cursor = 0;
static int video_cursor_table[VIDEO_ITEMS] = {68, 88, 96, 104, 112, 120, 128, 136, 144, 152, 168};
-static int video_resolution;
+static int menu_video_resolution;
video_resolution_t *video_resolutions;
int video_resolutions_count;
-void M_Menu_Video_f (void)
+static video_resolution_t *menu_video_resolutions;
+static int menu_video_resolutions_count;
+static qboolean menu_video_resolutions_forfullscreen;
+
+static void M_Menu_Video_FindResolution(int w, int h, float a)
{
int i;
- key_dest = key_menu;
- m_state = m_video;
- m_entersound = true;
+ if(menu_video_resolutions_forfullscreen)
+ {
+ menu_video_resolutions = video_resolutions;
+ menu_video_resolutions_count = video_resolutions_count;
+ }
+ else
+ {
+ menu_video_resolutions = video_resolutions_hardcoded;
+ menu_video_resolutions_count = video_resolutions_hardcoded_count;
+ }
// Look for the closest match to the current resolution
- video_resolution = 0;
- for (i = 1;i < video_resolutions_count;i++)
+ menu_video_resolution = 0;
+ for (i = 1;i < menu_video_resolutions_count;i++)
{
// if the new mode would be a worse match in width, skip it
- if (fabs(video_resolutions[i].width - vid.width) > fabs(video_resolutions[video_resolution].width - vid.width))
+ if (abs(menu_video_resolutions[i].width - w) > abs(menu_video_resolutions[menu_video_resolution].width - w))
continue;
// if it is equal in width, check height
- if (video_resolutions[i].width == vid.width && video_resolutions[video_resolution].width == vid.width)
+ if (menu_video_resolutions[i].width == w && menu_video_resolutions[menu_video_resolution].width == w)
{
// if the new mode would be a worse match in height, skip it
- if (fabs(video_resolutions[i].height - vid.height) > fabs(video_resolutions[video_resolution].height - vid.height))
+ if (abs(menu_video_resolutions[i].height - h) > abs(menu_video_resolutions[menu_video_resolution].height - h))
continue;
// if it is equal in width and height, check pixel aspect
- if (video_resolutions[i].height == vid.height && video_resolutions[video_resolution].height == vid.height)
+ if (menu_video_resolutions[i].height == h && menu_video_resolutions[menu_video_resolution].height == h)
{
// if the new mode would be a worse match in pixel aspect, skip it
- if (fabs(video_resolutions[i].pixelheight - vid_pixelheight.value) > fabs(video_resolutions[video_resolution].pixelheight - vid_pixelheight.value))
+ if (abs(menu_video_resolutions[i].pixelheight - a) > abs(menu_video_resolutions[menu_video_resolution].pixelheight - a))
continue;
// if it is equal in everything, skip it (prefer earlier modes)
- if (video_resolutions[i].pixelheight == vid_pixelheight.value && video_resolutions[video_resolution].pixelheight == vid_pixelheight.value)
+ if (menu_video_resolutions[i].pixelheight == a && menu_video_resolutions[menu_video_resolution].pixelheight == a)
continue;
// better match for width, height, and pixel aspect
- video_resolution = i;
+ menu_video_resolution = i;
}
else // better match for width and height
- video_resolution = i;
+ menu_video_resolution = i;
}
else // better match for width
- video_resolution = i;
+ menu_video_resolution = i;
}
}
+void M_Menu_Video_f (void)
+{
+ key_dest = key_menu;
+ m_state = m_video;
+ m_entersound = true;
+
+ M_Menu_Video_FindResolution(vid.width, vid.height, vid_pixelheight.value);
+}
+
static void M_Video_Draw (void)
{
int t;
cachepic_t *p;
+ if(!!vid_fullscreen.integer != menu_video_resolutions_forfullscreen)
+ {
+ video_resolution_t *res = &menu_video_resolutions[menu_video_resolution];
+ menu_video_resolutions_forfullscreen = !!vid_fullscreen.integer;
+ M_Menu_Video_FindResolution(res->width, res->height, res->pixelheight);
+ }
+
M_Background(320, 200);
M_DrawPic(16, 4, "gfx/qplaque");
// Current and Proposed Resolution
M_Print(16, video_cursor_table[t] - 12, " Current Resolution");
if (vid_supportrefreshrate && vid.userefreshrate && vid.fullscreen)
- M_Print(220, video_cursor_table[t] - 12, va("%dx%d %dhz", vid.width, vid.height, vid.refreshrate));
+ M_Print(220, video_cursor_table[t] - 12, va("%dx%d %.2fhz", vid.width, vid.height, vid.refreshrate));
else
M_Print(220, video_cursor_table[t] - 12, va("%dx%d", vid.width, vid.height));
M_Print(16, video_cursor_table[t], " New Resolution");
- M_Print(220, video_cursor_table[t], va("%dx%d", video_resolutions[video_resolution].width, video_resolutions[video_resolution].height));
- M_Print(96, video_cursor_table[t] + 8, va("Type: %s", video_resolutions[video_resolution].type));
+ M_Print(220, video_cursor_table[t], va("%dx%d", menu_video_resolutions[menu_video_resolution].width, menu_video_resolutions[menu_video_resolution].height));
+ M_Print(96, video_cursor_table[t] + 8, va("Type: %s", menu_video_resolutions[menu_video_resolution].type));
t++;
// Bits per pixel
// Refresh Rate
M_ItemPrint(16, video_cursor_table[t], " Refresh Rate", vid_supportrefreshrate && vid_userefreshrate.integer);
- M_DrawSlider(220, video_cursor_table[t], vid_refreshrate.integer, 60, 150);
+ M_DrawSlider(220, video_cursor_table[t], vid_refreshrate.value, 50, 150);
t++;
// Fullscreen
t++;
// Vertical Sync
- M_ItemPrint(16, video_cursor_table[t], " Vertical Sync", gl_videosyncavailable);
+ M_ItemPrint(16, video_cursor_table[t], " Vertical Sync", true);
M_DrawCheckbox(220, video_cursor_table[t], vid_vsync.integer);
t++;
- M_ItemPrint(16, video_cursor_table[t], " Anisotropic Filter", gl_support_anisotropy);
- M_DrawSlider(220, video_cursor_table[t], gl_texture_anisotropy.integer, 1, gl_max_anisotropy);
+ M_ItemPrint(16, video_cursor_table[t], " Anisotropic Filter", vid.support.ext_texture_filter_anisotropic);
+ M_DrawSlider(220, video_cursor_table[t], gl_texture_anisotropy.integer, 1, vid.max_anisotropy);
t++;
M_ItemPrint(16, video_cursor_table[t], " Texture Quality", true);
M_DrawSlider(220, video_cursor_table[t], gl_picmip.value, 3, 0);
t++;
- M_ItemPrint(16, video_cursor_table[t], " Texture Compression", gl_support_texture_compression);
+ M_ItemPrint(16, video_cursor_table[t], " Texture Compression", vid.support.arb_texture_compression);
M_DrawCheckbox(220, video_cursor_table[t], gl_texturecompression.integer);
t++;
{
// Resolution
int r;
- for(r = 0;r < video_resolutions_count;r++)
+ for(r = 0;r < menu_video_resolutions_count;r++)
{
- video_resolution += dir;
- if (video_resolution >= video_resolutions_count)
- video_resolution = 0;
- if (video_resolution < 0)
- video_resolution = video_resolutions_count - 1;
- if (video_resolutions[video_resolution].width >= vid_minwidth.integer && video_resolutions[video_resolution].height >= vid_minheight.integer)
+ menu_video_resolution += dir;
+ if (menu_video_resolution >= menu_video_resolutions_count)
+ menu_video_resolution = 0;
+ if (menu_video_resolution < 0)
+ menu_video_resolution = menu_video_resolutions_count - 1;
+ if (menu_video_resolutions[menu_video_resolution].width >= vid_minwidth.integer && menu_video_resolutions[menu_video_resolution].height >= vid_minheight.integer)
break;
}
}
else if (video_cursor == t++)
Cvar_SetValueQuick (&vid_userefreshrate, !vid_userefreshrate.integer);
else if (video_cursor == t++)
- Cvar_SetValueQuick (&vid_refreshrate, bound(60, vid_refreshrate.integer + dir, 150));
+ Cvar_SetValueQuick (&vid_refreshrate, bound(50, vid_refreshrate.value + dir, 150));
else if (video_cursor == t++)
Cvar_SetValueQuick (&vid_fullscreen, !vid_fullscreen.integer);
else if (video_cursor == t++)
Cvar_SetValueQuick (&vid_vsync, !vid_vsync.integer);
else if (video_cursor == t++)
- Cvar_SetValueQuick (&gl_texture_anisotropy, bound(1, gl_texture_anisotropy.value * (dir < 0 ? 0.5 : 2.0), gl_max_anisotropy));
+ Cvar_SetValueQuick (&gl_texture_anisotropy, bound(1, gl_texture_anisotropy.value * (dir < 0 ? 0.5 : 2.0), vid.max_anisotropy));
else if (video_cursor == t++)
Cvar_SetValueQuick (&gl_picmip, bound(0, gl_picmip.value - dir, 3));
else if (video_cursor == t++)
switch (video_cursor)
{
case (VIDEO_ITEMS - 1):
- Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution].width);
- Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution].height);
- Cvar_SetValueQuick (&vid_conwidth, video_resolutions[video_resolution].conwidth);
- Cvar_SetValueQuick (&vid_conheight, video_resolutions[video_resolution].conheight);
- Cvar_SetValueQuick (&vid_pixelheight, video_resolutions[video_resolution].pixelheight);
+ Cvar_SetValueQuick (&vid_width, menu_video_resolutions[menu_video_resolution].width);
+ Cvar_SetValueQuick (&vid_height, menu_video_resolutions[menu_video_resolution].height);
+ Cvar_SetValueQuick (&vid_conwidth, menu_video_resolutions[menu_video_resolution].conwidth);
+ Cvar_SetValueQuick (&vid_conheight, menu_video_resolutions[menu_video_resolution].conheight);
+ Cvar_SetValueQuick (&vid_pixelheight, menu_video_resolutions[menu_video_resolution].pixelheight);
Cbuf_AddText ("vid_restart\n");
M_Menu_Options_f ();
break;
void M_Init (void)
{
- vid_mode_t res[1024];
- size_t res_count, i;
-
- res_count = VID_ListModes(res, sizeof(res) / sizeof(*res));
- res_count = VID_SortModes(res, res_count, false, false, true);
- if(res_count)
- {
- video_resolutions_count = res_count;
- video_resolutions = (video_resolution_t *) Mem_Alloc(cls.permanentmempool, sizeof(*video_resolutions) * (video_resolutions_count + 1));
- memset(&video_resolutions[video_resolutions_count], 0, sizeof(video_resolutions[video_resolutions_count]));
- for(i = 0; i < res_count; ++i)
- {
- int n, d, t;
- video_resolutions[i].type = "Detected mode"; // FIXME make this more dynamic
- video_resolutions[i].width = res[i].width;
- video_resolutions[i].height = res[i].height;
- video_resolutions[i].pixelheight = res[i].pixelheight_num / (double) res[i].pixelheight_denom;
- n = res[i].pixelheight_denom * video_resolutions[i].width;
- d = res[i].pixelheight_num * video_resolutions[i].height;
- while(d)
- {
- t = n;
- n = d;
- d = t % d;
- }
- d = (res[i].pixelheight_num * video_resolutions[i].height) / n;
- n = (res[i].pixelheight_denom * video_resolutions[i].width) / n;
- switch(n * 0x10000 | d)
- {
- case 0x00040003:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 480;
- video_resolutions[i].type = "Standard 4x3";
- break;
- case 0x00050004:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 512;
- if(res[i].pixelheight_denom == res[i].pixelheight_num)
- video_resolutions[i].type = "Square Pixel (LCD) 5x4";
- else
- video_resolutions[i].type = "Short Pixel (CRT) 5x4";
- break;
- case 0x00080005:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 400;
- if(res[i].pixelheight_denom == res[i].pixelheight_num)
- video_resolutions[i].type = "Widescreen 8x5";
- else
- video_resolutions[i].type = "Tall Pixel (CRT) 8x5";
-
- break;
- case 0x00050003:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 384;
- video_resolutions[i].type = "Widescreen 5x3";
- break;
- case 0x000D0009:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 400;
- video_resolutions[i].type = "Widescreen 14x9";
- break;
- case 0x00100009:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 480;
- video_resolutions[i].type = "Widescreen 16x9";
- break;
- case 0x00030002:
- video_resolutions[i].conwidth = 720;
- video_resolutions[i].conheight = 480;
- video_resolutions[i].type = "NTSC 3x2";
- break;
- case 0x000D000B:
- video_resolutions[i].conwidth = 720;
- video_resolutions[i].conheight = 566;
- video_resolutions[i].type = "PAL 14x11";
- break;
- case 0x00080007:
- if(video_resolutions[i].width >= 512)
- {
- video_resolutions[i].conwidth = 512;
- video_resolutions[i].conheight = 448;
- video_resolutions[i].type = "SNES 8x7";
- }
- else
- {
- video_resolutions[i].conwidth = 256;
- video_resolutions[i].conheight = 224;
- video_resolutions[i].type = "NES 8x7";
- }
- break;
- default:
- video_resolutions[i].conwidth = 640;
- video_resolutions[i].conheight = 640 * d / n;
- video_resolutions[i].type = "Detected mode";
- break;
- }
- if(video_resolutions[i].conwidth > video_resolutions[i].width || video_resolutions[i].conheight > video_resolutions[i].height)
- {
- double f1, f2;
- f1 = video_resolutions[i].conwidth > video_resolutions[i].width;
- f2 = video_resolutions[i].conheight > video_resolutions[i].height;
- if(f1 > f2)
- {
- video_resolutions[i].conwidth = video_resolutions[i].width;
- video_resolutions[i].conheight = video_resolutions[i].conheight / f1;
- }
- else
- {
- video_resolutions[i].conwidth = video_resolutions[i].conwidth / f2;
- video_resolutions[i].conheight = video_resolutions[i].height;
- }
- }
- }
- }
-
menuplyr_load = true;
menuplyr_pixels = NULL;
prog->init_cmd = VM_M_Cmd_Init;
prog->reset_cmd = VM_M_Cmd_Reset;
prog->error_cmd = MP_Error;
+ prog->ExecuteProgram = MVM_ExecuteProgram;
// allocate the mempools
prog->progs_mempool = Mem_AllocPool(M_PROG_FILENAME, 0, NULL);
void MR_Init(void)
{
+ vid_mode_t res[1024];
+ size_t res_count, i;
+
+ res_count = VID_ListModes(res, sizeof(res) / sizeof(*res));
+ res_count = VID_SortModes(res, res_count, false, false, true);
+ if(res_count)
+ {
+ video_resolutions_count = res_count;
+ video_resolutions = (video_resolution_t *) Mem_Alloc(cls.permanentmempool, sizeof(*video_resolutions) * (video_resolutions_count + 1));
+ memset(&video_resolutions[video_resolutions_count], 0, sizeof(video_resolutions[video_resolutions_count]));
+ for(i = 0; i < res_count; ++i)
+ {
+ int n, d, t;
+ video_resolutions[i].type = "Detected mode"; // FIXME make this more dynamic
+ video_resolutions[i].width = res[i].width;
+ video_resolutions[i].height = res[i].height;
+ video_resolutions[i].pixelheight = res[i].pixelheight_num / (double) res[i].pixelheight_denom;
+ n = res[i].pixelheight_denom * video_resolutions[i].width;
+ d = res[i].pixelheight_num * video_resolutions[i].height;
+ while(d)
+ {
+ t = n;
+ n = d;
+ d = t % d;
+ }
+ d = (res[i].pixelheight_num * video_resolutions[i].height) / n;
+ n = (res[i].pixelheight_denom * video_resolutions[i].width) / n;
+ switch(n * 0x10000 | d)
+ {
+ case 0x00040003:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 480;
+ video_resolutions[i].type = "Standard 4x3";
+ break;
+ case 0x00050004:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 512;
+ if(res[i].pixelheight_denom == res[i].pixelheight_num)
+ video_resolutions[i].type = "Square Pixel (LCD) 5x4";
+ else
+ video_resolutions[i].type = "Short Pixel (CRT) 5x4";
+ break;
+ case 0x00080005:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 400;
+ if(res[i].pixelheight_denom == res[i].pixelheight_num)
+ video_resolutions[i].type = "Widescreen 8x5";
+ else
+ video_resolutions[i].type = "Tall Pixel (CRT) 8x5";
+
+ break;
+ case 0x00050003:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 384;
+ video_resolutions[i].type = "Widescreen 5x3";
+ break;
+ case 0x000D0009:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 400;
+ video_resolutions[i].type = "Widescreen 14x9";
+ break;
+ case 0x00100009:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 480;
+ video_resolutions[i].type = "Widescreen 16x9";
+ break;
+ case 0x00030002:
+ video_resolutions[i].conwidth = 720;
+ video_resolutions[i].conheight = 480;
+ video_resolutions[i].type = "NTSC 3x2";
+ break;
+ case 0x000D000B:
+ video_resolutions[i].conwidth = 720;
+ video_resolutions[i].conheight = 566;
+ video_resolutions[i].type = "PAL 14x11";
+ break;
+ case 0x00080007:
+ if(video_resolutions[i].width >= 512)
+ {
+ video_resolutions[i].conwidth = 512;
+ video_resolutions[i].conheight = 448;
+ video_resolutions[i].type = "SNES 8x7";
+ }
+ else
+ {
+ video_resolutions[i].conwidth = 256;
+ video_resolutions[i].conheight = 224;
+ video_resolutions[i].type = "NES 8x7";
+ }
+ break;
+ default:
+ video_resolutions[i].conwidth = 640;
+ video_resolutions[i].conheight = 640 * d / n;
+ video_resolutions[i].type = "Detected mode";
+ break;
+ }
+ if(video_resolutions[i].conwidth > video_resolutions[i].width || video_resolutions[i].conheight > video_resolutions[i].height)
+ {
+ int f1, f2;
+ f1 = video_resolutions[i].conwidth > video_resolutions[i].width;
+ f2 = video_resolutions[i].conheight > video_resolutions[i].height;
+ if(f1 > f2)
+ {
+ video_resolutions[i].conwidth = video_resolutions[i].width;
+ video_resolutions[i].conheight = video_resolutions[i].conheight / f1;
+ }
+ else
+ {
+ video_resolutions[i].conwidth = video_resolutions[i].conwidth / f2;
+ video_resolutions[i].conheight = video_resolutions[i].height;
+ }
+ }
+ }
+ }
+ else
+ {
+ video_resolutions = video_resolutions_hardcoded;
+ video_resolutions_count = sizeof(video_resolutions_hardcoded) / sizeof(*video_resolutions_hardcoded) - 1;
+ }
+
+ menu_video_resolutions_forfullscreen = !!vid_fullscreen.integer;
+ M_Menu_Video_FindResolution(vid.width, vid.height, vid_pixelheight.value);
+
// use -forceqmenu to use always the normal quake menu (it sets forceqmenu to 1)
// COMMANDLINEOPTION: Client: -forceqmenu disables menu.dat (same as +forceqmenu 1)
if(COM_CheckParm("-forceqmenu"))