Only list resolutions that can actually be used, using new gr_check_mode

This commit is contained in:
kreatordxx 2009-11-17 14:27:39 +00:00
parent 00347f0bcb
commit 57c71476fc
6 changed files with 67 additions and 60 deletions

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20091117
--------
arch/ogl/gr.c, arch/sdl/gr.c, include/gr.h, main/menu.c, main/piggy.c: Only list resolutions that can actually be used, using new gr_check_mode
20091115
--------
main/gamecntl.c, main/gameseq.c, main/gameseq.h, main/menu.c, main/newdemo.c, main/newdemo.h, main/newmenu.c, main/text.c: Add endian converter for demos, read shareware demos, various bugfixes to demo system

View file

@ -9,7 +9,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#ifdef _MSC_VER
#include <windows.h>
#endif
@ -56,7 +55,7 @@
int gr_installed = 0;
int gl_initialized=0;
int ogl_fullscreen;
int ogl_fullscreen=0;
static int curx=-1,cury=-1,curfull=0;
int linedotscale=1; // scalar of glLinewidth and glPointSize - only calculated once when resolution changes
@ -194,7 +193,19 @@ void ogl_get_verinfo(void)
GameArg.DbgGlGetTexLevelParamOk=0; // Always returns 0
#endif
con_printf(CON_VERBOSE, "gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i\n", GameArg.DbgGlIntensity4Ok, GameArg.DbgGlLuminance4Alpha4Ok, GameArg.DbgGlRGBA2Ok, GameArg.DbgGlReadPixelsOk, GameArg.DbgGlGetTexLevelParamOk);
#ifndef NDEBUG
con_printf(CON_VERBOSE,"gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i\n",GameArg.DbgGlIntensity4Ok,GameArg.DbgGlLuminance4Alpha4Ok,GameArg.DbgGlRGBA2Ok,GameArg.DbgGlReadPixelsOk,GameArg.DbgGlGetTexLevelParamOk);
#endif
}
int gr_check_mode(u_int32_t mode)
{
unsigned int w, h;
w=SM_W(mode);
h=SM_H(mode);
return SDL_VideoModeOK(w, h, GameArg.DbgGlBpp, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0));
}
int gr_set_mode(u_int32_t mode)
@ -230,7 +241,7 @@ int gr_set_mode(u_int32_t mode)
grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_OGL;
grd_curscreen->sc_canvas.cv_bitmap.bm_data = d_realloc(gr_bm_data,w*h);
gr_set_current_canvas(NULL);
ogl_init_window(w,h);//platform specific code
ogl_get_verinfo();
OGL_VIEWPORT(0,0,w,h);
@ -347,7 +358,7 @@ int gr_init(int mode)
{
int retcode;
// Only do this function once!
// Only do this function once!
if (gr_installed==1)
return -1;
@ -376,8 +387,8 @@ int gr_init(int mode)
grd_curscreen->sc_canvas.cv_font_fg_color = 0;
grd_curscreen->sc_canvas.cv_font_bg_color = 0;
gr_set_current_canvas( &grd_curscreen->sc_canvas );
ogl_init_pixel_buffers(256, 128); // for gamefont_init
ogl_init_pixel_buffers(256, 128); // for gamefont_init
gr_installed = 1;
@ -458,7 +469,6 @@ void ogl_ulinec(int left,int top,int right,int bot,int c)
glVertex2f(xf,yf);
glEnd();
}
GLfloat last_r=0, last_g=0, last_b=0;
int do_pal_step=0;
@ -482,7 +492,6 @@ void ogl_do_palfx(void)
glVertex2f(1,1);
glVertex2f(1,0);
glEnd();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
@ -560,7 +569,7 @@ void write_bmp(char *savename,int w,int h,unsigned char *buf)
TGA_header TGA;
GLbyte HeightH,HeightL,WidthH,WidthL;
buf = (unsigned char*)calloc(w*h*3,sizeof(unsigned char));
buf = (unsigned char*)d_calloc(w*h*3,sizeof(unsigned char));
glReadPixels(0,0,w,h,GL_BGR_EXT,GL_UNSIGNED_BYTE,buf);
@ -597,7 +606,7 @@ void write_bmp(char *savename,int w,int h,unsigned char *buf)
PHYSFS_write(TGAFile,&TGA,sizeof(TGA_header),1);
PHYSFS_write(TGAFile,buf,w*h*3*sizeof(unsigned char),1);
PHYSFS_close(TGAFile);
free(buf);
d_free(buf);
}
void save_screen_shot(int automap_flag)

View file

@ -35,6 +35,16 @@ void gr_set_draw_buffer(int buf)
buf = buf;
}
int gr_check_mode(u_int32_t mode)
{
unsigned int w, h;
w=SM_W(mode);
h=SM_H(mode);
return SDL_VideoModeOK(w,h,8,sdl_video_flags);
}
int gr_set_mode(u_int32_t mode)
{
unsigned int w, h;
@ -67,7 +77,7 @@ int gr_set_mode(u_int32_t mode)
exit(1);
}
memset( grd_curscreen, 0, sizeof(grs_screen));
memset(grd_curscreen, 0, sizeof(grs_screen));
grd_curscreen->sc_mode = mode;
grd_curscreen->sc_w = w;
grd_curscreen->sc_h = h;
@ -113,7 +123,7 @@ int gr_init(int mode)
{
int retcode;
// Only do this function once!
// Only do this function once!
if (gr_installed==1)
return -1;
@ -233,18 +243,18 @@ void gr_palette_load( ubyte *pal )
if (gr_current_pal[i] > 63)
gr_current_pal[i] = 63;
}
if (screen == NULL)
return;
palette = screen->format->palette;
if (palette == NULL)
return; // Display is not palettised
for (i=0;i<64;i++)
gamma[i] = (int)((pow(((double)(14)/(double)(32)), 1.0)*i) + 0.5);
for (i = 0, j = 0; j < 256; j++)
{
int c;
@ -254,7 +264,7 @@ void gr_palette_load( ubyte *pal )
colors[j].g = (min(gr_current_pal[i++] + gr_palette_gamma, 63)) * 4;
colors[j].b = (min(gr_current_pal[i++] + gr_palette_gamma, 63)) * 4;
}
SDL_SetColors(screen, colors, 0, 256);
init_computed_colors();
gr_remap_color_fonts();
@ -265,9 +275,9 @@ void gr_palette_read(ubyte * pal)
{
SDL_Palette *palette;
int i, j;
palette = screen->format->palette;
if (palette == NULL)
return; // Display is not palettised

View file

@ -24,16 +24,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "pstypes.h"
#include "fix.h"
#if defined(MACDATA)
#error native mac data currently not supported
#define SWAP_0_255 // swap black and white
#define TRANSPARENCY_COLOR 0 // palette entry of transparency color -- 0 on the mac
#define TRANSPARENCY_COLOR_STR "0"
#else /* defined(MACDATA) */
/* #undef SWAP_0_255 */ // no swapping for PC people
#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC
#define TRANSPARENCY_COLOR_STR "255"
#endif /* defined(MACDATA) */
// #define SWAP_0_255 0 // swap black and white
#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC
#define GR_FADE_LEVELS 34
#define GR_ACTUAL_FADE_LEVELS 32
@ -42,10 +34,11 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define GHEIGHT grd_curcanv->cv_bitmap.bm_h
#define SWIDTH (grd_curscreen->sc_w)
#define SHEIGHT (grd_curscreen->sc_h)
#define HIRESMODE (SWIDTH >= 640 && SHEIGHT >= 480 && GameArg.GfxHiresGFXAvailable)
#define HIRESMODE (SWIDTH >= 640 && SHEIGHT >= 480 && GameArg.GfxHiresGFXAvailable)
#define MAX_BMP_SIZE(width, height) (4 + ((width) + 2) * (height))
#define BM_FLAG_TGA 128
#define SCRNS_DIR "screenshots/"
extern int Gr_scanline_darkening_level;
@ -77,7 +70,7 @@ typedef struct _grs_point {
#define SM(w,h) ((((u_int32_t)w)<<16)+(((u_int32_t)h)&0xFFFF))
#define SM_W(m) (m>>16)
#define SM_H(m) (m&0xFFFF)
#define SM_ORIGINAL 0
#define BM_FLAG_TRANSPARENT 1
#define BM_FLAG_SUPER_TRANSPARENT 2
@ -107,8 +100,6 @@ typedef struct _grs_bitmap {
#endif /* def OGL */
} grs_bitmap;
#define SCRNS_DIR "screenshots/"
//font structure
typedef struct _grs_font {
short ft_w; // Width in pixels
@ -156,20 +147,13 @@ typedef struct _grs_screen { // This is a video screen
int gr_init(int mode);
// This function sets up the main screen. It should be called whenever
// the video mode changes.
int gr_init_screen(int mode, int w, int h, int x, int y, int rowsize, ubyte *data);
int gr_check_mode(u_int32_t mode);
int gr_set_mode(u_int32_t mode);
void gr_set_attributes(void);
extern void gr_pal_setblock( int start, int number, unsigned char * pal );
extern void gr_pal_getblock( int start, int number, unsigned char * pal );
extern unsigned char *gr_video_memory;
// All graphic modules will define this value.
//shut down the 2d. Restore the screen mode.
void gr_close(void);
@ -244,7 +228,10 @@ void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * s
void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
void gr_set_bitmap_flags(grs_bitmap *pbm, int flags);
void gr_set_transparent(grs_bitmap *pbm, int bTransparent);
void gr_set_super_transparent(grs_bitmap *pbm, int bTransparent);
void gr_set_bitmap_data(grs_bitmap *bm, unsigned char *data);
//=========================================================================
// Color functions:
@ -271,8 +258,8 @@ void gr_setcolor(int color);
// but not necessarily shaded as a concave polygon. It shouldn't hang.
// probably good solution is to shade from minx to maxx on each scan line.
// int should really be fix
int gr_poly(int nverts,int *verts);
int gr_upoly(int nverts,int *verts);
void gr_poly(int nverts,int *verts);
void gr_upoly(int nverts,int *verts);
// Draws a point into the current canvas in the current color and drawmode.
@ -294,6 +281,7 @@ int gr_uaaline(fix x0,fix y0,fix x1,fix y1);
// Draw the bitmap into the current canvas at the specified location.
void gr_bitmap(int x,int y,grs_bitmap *bm);
void gr_ubitmap(int x,int y,grs_bitmap *bm);
inline void scale_line(unsigned char *in, unsigned char *out, int ilen, int olen);
void gr_bitmap_scale_to(grs_bitmap *src, grs_bitmap *dst);
void show_fullscr(grs_bitmap *bm);
@ -363,8 +351,6 @@ extern void gr_set_current_canvas( grs_canvas *canv );
#define FT_PROPORTIONAL 2
#define FT_KERNED 4
extern void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 );
// Special effects
extern void gr_snow_out(int num_dots);
@ -401,6 +387,7 @@ extern void gr_palette_step_up( int r, int g, int b );
extern void gr_bitmap_check_transparency( grs_bitmap * bmp );
#ifdef BITMAP_SELECTOR
// Allocates a selector that has a base address at 'address' and length 'size'.
// Returns 0 if successful... BE SURE TO CHECK the return value since there
// is a limited number of selectors available!!!
@ -409,6 +396,7 @@ extern int get_selector( void * address, int size, unsigned int * selector );
// Assigns a selector to a bitmap. Returns 0 if successful. BE SURE TO CHECK
// this return value since there is a limited number of selectors!!!!!!!
extern int gr_bitmap_assign_selector( grs_bitmap * bmp );
#endif
#define BM_RGB(r,g,b) ( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )
#define BM_XRGB(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )

View file

@ -489,16 +489,15 @@ void change_res()
u_int32_t screen_mode = 0, aspect_mode = 0;
// the list of pre-defined resolutions
// TODO: You know, since we currently have SDL, we could use it to build a list of supported resolutions
m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200 (16x10)"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480 (4x3)"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600 (4x3)"; m[mc].value = (Game_screen_mode == SM(800,600)); m[mc].group = 0; modes[mc] = SM(800,600); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768 (4x3)"; m[mc].value = (Game_screen_mode == SM(1024,768)); m[mc].group = 0; modes[mc] = SM(1024,768); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x800 (16x10)"; m[mc].value = (Game_screen_mode == SM(1280,800)); m[mc].group = 0; modes[mc] = SM(1280,800); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x1024 (5x4)"; m[mc].value = (Game_screen_mode == SM(1280,1024)); m[mc].group = 0; modes[mc] = SM(1280,1024); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "1440x900 (16x10)"; m[mc].value = (Game_screen_mode == SM(1440,900)); m[mc].group = 0; modes[mc] = SM(1440,900); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "1600x1200 (4x3)"; m[mc].value = (Game_screen_mode == SM(1600,1200)); m[mc].group = 0; modes[mc] = SM(1600,1200); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "1920x1200 (16x10)"; m[mc].value = (Game_screen_mode == SM(1920,1200)); m[mc].group = 0; modes[mc] = SM(1920,1200); mc++;
if (gr_check_mode(SM(320,200))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200 (16x10)"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++; }
if (gr_check_mode(SM(640,480))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480 (4x3)"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++; }
if (gr_check_mode(SM(800,600))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600 (4x3)"; m[mc].value = (Game_screen_mode == SM(800,600)); m[mc].group = 0; modes[mc] = SM(800,600); mc++; }
if (gr_check_mode(SM(1024,768))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768 (4x3)"; m[mc].value = (Game_screen_mode == SM(1024,768)); m[mc].group = 0; modes[mc] = SM(1024,768); mc++; }
if (gr_check_mode(SM(1280,800))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x800 (16x10)"; m[mc].value = (Game_screen_mode == SM(1280,800)); m[mc].group = 0; modes[mc] = SM(1280,800); mc++; }
if (gr_check_mode(SM(1280,1024))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x1024 (5x4)"; m[mc].value = (Game_screen_mode == SM(1280,1024)); m[mc].group = 0; modes[mc] = SM(1280,1024); mc++; }
if (gr_check_mode(SM(1440,900))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "1440x900 (16x10)"; m[mc].value = (Game_screen_mode == SM(1440,900)); m[mc].group = 0; modes[mc] = SM(1440,900); mc++; }
if (gr_check_mode(SM(1600,1200))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "1600x1200 (4x3)"; m[mc].value = (Game_screen_mode == SM(1600,1200)); m[mc].group = 0; modes[mc] = SM(1600,1200); mc++; }
if (gr_check_mode(SM(1920,1200))) { m[mc].type = NM_TYPE_RADIO; m[mc].text = "1920x1200 (16x10)"; m[mc].value = (Game_screen_mode == SM(1920,1200)); m[mc].group = 0; modes[mc] = SM(1920,1200); mc++; }
num_presets = mc;
// now see which field is true and break there

View file

@ -488,7 +488,6 @@ void piggy_init_pigfile(char *filename)
#define MAX_BITMAPS_PER_BRUSH 30
extern int compute_average_pixel(grs_bitmap *new);
extern void gr_set_bitmap_data(grs_bitmap *bm, unsigned char *data);
ubyte *Bitmap_replacement_data = NULL;
@ -1029,8 +1028,6 @@ void piggy_critical_error()
grd_curcanv->cv_font = save_font;
}
extern void gr_set_bitmap_flags(grs_bitmap *pbm, int flags);
void piggy_bitmap_page_in( bitmap_index bitmap )
{
grs_bitmap * bmp;