From d33ccb0f010bff7afb2e7c4dec95edeea4dd2cb7 Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Thu, 22 Mar 2007 11:32:22 +0000 Subject: [PATCH] Use Doublebuffer in OGL for all parts of the game and properly redraw elements, fixed Profiler build --- SConstruct | 1 + arch/ogl/gr.c | 14 +- arch/ogl/include/ogl_init.h | 2 - arch/ogl/ogl.c | 28 --- dxx-changelog.txt | 4 + main/credits.c | 6 +- main/game.c | 14 +- main/kconfig.c | 279 ++++++++++++++------------- main/kmatrix.c | 25 ++- main/menu.c | 11 -- main/netlist.c | 48 +++-- main/newmenu.c | 365 +++++++++++++++++++----------------- main/polyobj.c | 6 +- main/scores.c | 87 +++++---- main/state.c | 125 +++++++----- main/titles.c | 145 +++++++++++--- 16 files changed, 648 insertions(+), 512 deletions(-) diff --git a/SConstruct b/SConstruct index 8e26e0eeb..4d2161ffd 100755 --- a/SConstruct +++ b/SConstruct @@ -417,6 +417,7 @@ else: # profiler? if (profiler == 1): env.Append(CPPFLAGS = ['-pg']) + lflags += ' -pg' # assembler code? if (no_asm == 0) and (sdl_only == 1): diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index 85a33f4e4..b8a899d00 100755 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -92,11 +92,9 @@ void ogl_set_screen_mode(void){ OGL_VIEWPORT(0,0,grd_curscreen->sc_w,grd_curscreen->sc_h); - if (Screen_mode==SCREEN_GAME){ - glDrawBuffer(GL_BACK); - }else{ + if (Screen_mode!=SCREEN_GAME) + { glClearColor(0.0, 0.0, 0.0, 0.0); - glDrawBuffer(GL_FRONT); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity();//clear matrix @@ -111,12 +109,6 @@ void ogl_set_screen_mode(void){ } void gr_update() { - if (gl_initialized){ - - if(Screen_mode != SCREEN_GAME){ - glFlush(); - } - } } const char *gl_vendor,*gl_renderer,*gl_version,*gl_extensions; @@ -198,7 +190,7 @@ void ogl_get_verinfo(void){ #ifndef NDEBUG printf("gl_arb_multitexture:%i gl_sgis_multitexture:%i\n",ogl_arb_multitexture_ok,ogl_sgis_multitexture_ok); - printf("gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i gl_setgammaramp:%i gl_scissor_ok:%i\n",ogl_intensity4_ok,ogl_luminance4_alpha4_ok,ogl_rgba2_ok,ogl_readpixels_ok,ogl_gettexlevelparam_ok,ogl_setgammaramp_ok,ogl_scissor_ok); + printf("gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i gl_setgammaramp:%i gl_scissor:%i\n",ogl_intensity4_ok,ogl_luminance4_alpha4_ok,ogl_rgba2_ok,ogl_readpixels_ok,ogl_gettexlevelparam_ok,ogl_setgammaramp_ok,ogl_scissor_ok); #endif } diff --git a/arch/ogl/include/ogl_init.h b/arch/ogl/include/ogl_init.h index 2d26b7e6a..aee70e193 100755 --- a/arch/ogl/include/ogl_init.h +++ b/arch/ogl/include/ogl_init.h @@ -140,8 +140,6 @@ int ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex, int void ogl_freetexture(ogl_texture *gltexture); void ogl_freebmtexture(grs_bitmap *bm); void ogl_do_palfx(void); -void ogl_start_offscreen_render(int x, int y, int w, int h); -void ogl_end_offscreen_render(void); void ogl_start_frame(void); void ogl_end_frame(void); void ogl_swap_buffers(void); diff --git a/arch/ogl/ogl.c b/arch/ogl/ogl.c index 75d694d99..18238895b 100755 --- a/arch/ogl/ogl.c +++ b/arch/ogl/ogl.c @@ -1118,36 +1118,8 @@ bool ogl_ubitblt_copy(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * sr return 0; } -grs_canvas *offscreen_save_canv = NULL, *offscreen_canv = NULL; -// float pixels [OGLTEXBUFSIZE]; GLubyte *pixels = NULL; -void ogl_start_offscreen_render(int x, int y, int w, int h) { - int y2; - - if (offscreen_canv) Error("ogl_start_offscreen_render: offscreen_canv!=NULL"); - offscreen_save_canv = grd_curcanv; - glDrawBuffer(GL_BACK); - offscreen_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h); - gr_set_current_canvas(offscreen_canv); - y2 = last_height - offscreen_canv->cv_bitmap.bm_y - offscreen_canv->cv_bitmap.bm_h; - glReadPixels(offscreen_canv->cv_bitmap.bm_x,y2,w,h,GL_RGBA,GL_UNSIGNED_BYTE,pixels); -} -void ogl_end_offscreen_render(void) { - int y; - - if (!offscreen_canv) Error("ogl_end_offscreen_render: no offscreen_canv"); - glDrawBuffer(GL_FRONT); - glReadBuffer(GL_BACK); - OGL_DISABLE(TEXTURE_2D); - y = last_height - offscreen_canv->cv_bitmap.bm_y - offscreen_canv->cv_bitmap.bm_h; - glRasterPos2f(offscreen_canv->cv_bitmap.bm_x/(float)last_width, y/(float)last_height); - glDrawPixels(offscreen_canv->cv_bitmap.bm_w, offscreen_canv->cv_bitmap.bm_h,GL_RGBA,GL_UNSIGNED_BYTE,pixels); - gr_free_sub_canvas(offscreen_canv); - gr_set_current_canvas(offscreen_save_canv); - offscreen_canv=NULL; -} - void ogl_start_frame(void){ r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitmapc=0;r_ubitbltc=0;r_upixelc=0; diff --git a/dxx-changelog.txt b/dxx-changelog.txt index af8df8603..af40aaf01 100755 --- a/dxx-changelog.txt +++ b/dxx-changelog.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20070322 +-------- +SConstruct, arch/ogl/gr.c, arch/ogl/ogl.c, arch/ogl/include/ogl_init.h, main/credits.c, main/game.c, main/kconfig.c, main/kmatrix.c, main/menu.c, main/netlist.c, main/newmenu.c, main.polyobj.c, main/scores.c, main/state.c, main/titles.c: Use Doublebuffer in OGL for all parts of the game and properly redraw elements, fixed Profiler build + 20070318 -------- SConstruct, main/game.c: fixed compiling without jukebox code if no SDL_mixer available diff --git a/main/credits.c b/main/credits.c index 14e9bfb64..a91c26db5 100755 --- a/main/credits.c +++ b/main/credits.c @@ -211,7 +211,7 @@ void credits_show(char *credits_filename) y = first_line_offset - i; #ifdef OGL - ogl_start_offscreen_render(0,-2,GWIDTH,GHEIGHT); + ogl_swap_buffers(); ogl_ubitmapm_cs(0,0,-1,-1,&backdrop,-1,F1_0); #endif gr_set_current_canvas(CreditsOffscreenBuf); @@ -321,15 +321,11 @@ void credits_show(char *credits_filename) gr_palette_load( gr_palette ); #ifdef OGL gr_free_sub_canvas(CreditsOffscreenBuf); - ogl_end_offscreen_render(); #else gr_free_canvas(CreditsOffscreenBuf); #endif return; } -#ifdef OGL - ogl_end_offscreen_render(); -#endif } } } diff --git a/main/game.c b/main/game.c index 517f8312f..895bd736c 100755 --- a/main/game.c +++ b/main/game.c @@ -1723,6 +1723,10 @@ void show_boxed_message(char *msg) int w,h,aw; int x,y; +#ifdef OGL + gr_clear_canvas(0); +#endif + gr_set_current_canvas(&VR_screen_pages[VR_current_page]); gr_set_curfont( HELP_FONT ); @@ -1747,6 +1751,9 @@ void show_boxed_message(char *msg) gr_set_fontcolor( gr_getcolor(31, 31, 31), -1 ); gr_ustring( (grd_curscreen->sc_w-w)/2, y, msg ); gr_update(); +#ifdef OGL + ogl_swap_buffers(); +#endif } void clear_boxed_message() @@ -1789,8 +1796,11 @@ int do_game_pause(int allow_menu) SDL_WM_GrabInput(SDL_GRAB_OFF); while (paused) { - - key = key_getch(); + d_delay(1); +#ifdef OGL + show_boxed_message(TXT_PAUSE); +#endif + key = key_inkey(); switch (key) { case 0: diff --git a/main/kconfig.c b/main/kconfig.c index 330c5888b..4f4f56cbb 100755 --- a/main/kconfig.c +++ b/main/kconfig.c @@ -65,6 +65,11 @@ static char rcsid[] = "$Id: kconfig.c,v 1.1.1.1 2006/03/17 19:44:27 zicodxx Exp #include "d_delay.h" #include "physics.h" #include "vlcnfire.h" +#include "d_delay.h" + +#ifdef OGL +#include "ogl_init.h" +#endif #ifdef GP2X #include "gp2x.h" @@ -86,6 +91,7 @@ ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, //extern void GameLoop(int, int ); extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); +extern void nm_draw_background1(char * filename); control_info Controls; @@ -103,8 +109,8 @@ int Allow_secondary_cycle=1; int mouselook=0; extern int Automap_flag; -#define LHX(x) ((x)*(hiresfont?FONTSCALE_X(2):FONTSCALE_X(1))) -#define LHY(y) ((y)*(hiresfont?FONTSCALE_Y(2.4):FONTSCALE_Y(1))) +#define LHX(x) ((x)*(hiresfont && SWIDTH>=640 && SHEIGHT>=480?FONTSCALE_X(2):FONTSCALE_X(1))) +#define LHY(y) ((y)*(hiresfont && SWIDTH>=640 && SHEIGHT>=480?FONTSCALE_Y(2.4):FONTSCALE_Y(1))) #define BT_KEY 0 #define BT_MOUSE_BUTTON 1 @@ -591,13 +597,16 @@ void kconfig_sub(kc_item * items,int nitems, char * title) grs_canvas * save_canvas, canvas; grs_font * save_font; int old_keyd_repeat; -#ifdef NEWMENU_MOUSE - int mouse_state, omouse_state, mx, my, x1, x2, y1, y2; - int close_x, close_y, close_size; -#endif int i,k,ocitem,citem; int time_stopped = 0; char * p; + int w = LHX(290), h = LHY(170); +#ifdef NEWMENU_MOUSE + int mouse_state, omouse_state, mx, my, x1, x2, y1, y2; + int close_x = (SWIDTH/2)-(w/2)-8*(SWIDTH/320); + int close_y = (SHEIGHT/2)-(h/2)-8*(SHEIGHT/200); + int close_size = FONTSCALE_X(hiresfont && SWIDTH>=640 && SHEIGHT>=480?10:5); +#endif All_items = items; Num_items = nitems; @@ -614,114 +623,18 @@ void kconfig_sub(kc_item * items,int nitems, char * title) save_canvas = grd_curcanv; - if (hiresfont) + if (hiresfont && SWIDTH>=640 && SHEIGHT>=480) { gr_init_sub_canvas(&canvas, &grd_curscreen->sc_canvas, (SWIDTH - FONTSCALE_X(640))/2, (SHEIGHT - FONTSCALE_Y(480))/2, FONTSCALE_X(640), FONTSCALE_Y(480)); - else + } else { gr_init_sub_canvas(&canvas, &grd_curscreen->sc_canvas, (SWIDTH - FONTSCALE_X(320))/2, (SHEIGHT - FONTSCALE_Y(200))/2, FONTSCALE_X(320), FONTSCALE_Y(200)); - gr_set_current_canvas(&canvas); + } save_font = grd_curcanv->cv_font; game_flush_inputs(); old_keyd_repeat = keyd_repeat; keyd_repeat = 1; - nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w-1, grd_curcanv->cv_bitmap.bm_h-1 );//args are x,y,x2,y2 NOT x,y,w,h - - grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3]; - - - p = strchr( title, '\n' ); - if ( p ) *p = 32; - gr_string( 0x8000, LHY(8), title ); - if ( p ) *p = '\n'; - -#ifdef NEWMENU_MOUSE - close_x = FONTSCALE_X(hiresfont?15:7); - close_y = FONTSCALE_Y(hiresfont?15:7); - close_size = FONTSCALE_X(hiresfont?10:5); - gr_setcolor( BM_XRGB(0, 0, 0) ); - gr_rect(close_x, close_y, close_x + close_size, close_y + close_size); - gr_setcolor( BM_XRGB(21, 21, 21) ); - gr_rect(close_x + 1, close_y + 1, close_x + close_size - 1, close_y + close_size - 1); -#endif - - grd_curcanv->cv_font = GAME_FONT; - gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - gr_string( 0x8000, LHY(28), TXT_KCONFIG_STRING_1 ); - gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - - if ( items == kc_keyboard ) - { - gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); - gr_setcolor( BM_XRGB(31,27,6) ); - - gr_rect( LHX( 98), LHY(42), LHX(106), LHY(42) ); // horiz/left - gr_rect( LHX(120), LHY(42), LHX(128), LHY(42) ); // horiz/right - gr_rect( LHX( 98), LHY(42), LHX( 98), LHY(44) ); // vert/left - gr_rect( LHX(128), LHY(42), LHX(128), LHY(44) ); // vert/right - - gr_string( LHX(109), LHY(40), "OR" ); - - gr_rect( LHX(253), LHY(42), LHX(261), LHY(42) ); // horiz/left - gr_rect( LHX(275), LHY(42), LHX(283), LHY(42) ); // horiz/right - gr_rect( LHX(253), LHY(42), LHX(253), LHY(44) ); // vert/left - gr_rect( LHX(283), LHY(42), LHX(283), LHY(44) ); // vert/right - - gr_string( LHX(264), LHY(40), "OR" ); - } - else if ( items == kc_joystick ) - { - gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); - gr_setcolor( BM_XRGB(31,27,6) ); - gr_string( 0x8000, LHY(36), TXT_BUTTONS ); - gr_string( 0x8000,LHY(127), TXT_AXES ); - gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - gr_string( LHX(81), LHY(137), TXT_AXIS ); - gr_string( LHX(111), LHY(137), TXT_INVERT ); - gr_string( LHX(230), LHY(137), TXT_AXIS ); - gr_string( LHX(260), LHY(137), TXT_INVERT ); - gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); - gr_setcolor( BM_XRGB(31,27,6) ); - - gr_rect( LHX(115), LHY(45), LHX(123), LHY(45) ); // horiz/left - gr_rect( LHX(137), LHY(45), LHX(145), LHY(45) ); // horiz/right - gr_rect( LHX(115), LHY(45), LHX(115), LHY(47) ); // vert/left - gr_rect( LHX(145), LHY(45), LHX(145), LHY(47) ); // vert/right - - gr_string( LHX(126), LHY(43), "OR" ); - - gr_rect( LHX(250), LHY(45), LHX(258), LHY(45) ); // horiz/left - gr_rect( LHX(272), LHY(45), LHX(280), LHY(45) ); // horiz/right - gr_rect( LHX(250), LHY(45), LHX(250), LHY(47) ); // vert/left - gr_rect( LHX(280), LHY(45), LHX(280), LHY(47) ); // vert/right - - gr_string( LHX(261), LHY(43), "OR" ); - } - else if ( items == kc_mouse ) - { - gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); - gr_setcolor( BM_XRGB(31,27,6) ); - gr_string( 0x8000, LHY(35), TXT_BUTTONS ); - gr_string( 0x8000,LHY(122), TXT_AXES ); - gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - gr_string( LHX(169), LHY(129), TXT_AXIS ); - gr_string( LHX(199), LHY(129), TXT_INVERT ); - } - else if ( items == kc_d1x ) - { - gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); - gr_setcolor( BM_XRGB(31,27,6) ); - - gr_string(LHX( 94), LHY(40), "KB"); - gr_string(LHX(121), LHY(40), "JOY"); - } - - for (i=0; icv_font = Gamefonts[GFONT_MEDIUM_3]; + + + p = strchr( title, '\n' ); + if ( p ) *p = 32; + gr_string( 0x8000, LHY(8), title ); + if ( p ) *p = '\n'; + + grd_curcanv->cv_font = GAME_FONT; + gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); + gr_string( 0x8000, LHY(28), TXT_KCONFIG_STRING_1 ); + gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); + + if ( items == kc_keyboard ) + { + gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); + gr_setcolor( BM_XRGB(31,27,6) ); + + gr_rect( LHX( 98), LHY(42), LHX(106), LHY(42) ); // horiz/left + gr_rect( LHX(120), LHY(42), LHX(128), LHY(42) ); // horiz/right + gr_rect( LHX( 98), LHY(42), LHX( 98), LHY(44) ); // vert/left + gr_rect( LHX(128), LHY(42), LHX(128), LHY(44) ); // vert/right + + gr_string( LHX(109), LHY(40), "OR" ); + + gr_rect( LHX(253), LHY(42), LHX(261), LHY(42) ); // horiz/left + gr_rect( LHX(275), LHY(42), LHX(283), LHY(42) ); // horiz/right + gr_rect( LHX(253), LHY(42), LHX(253), LHY(44) ); // vert/left + gr_rect( LHX(283), LHY(42), LHX(283), LHY(44) ); // vert/right + + gr_string( LHX(264), LHY(40), "OR" ); + } + else if ( items == kc_joystick ) + { + gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); + gr_setcolor( BM_XRGB(31,27,6) ); + gr_string( 0x8000, LHY(36), TXT_BUTTONS ); + gr_string( 0x8000,LHY(127), TXT_AXES ); + gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); + gr_string( LHX(81), LHY(137), TXT_AXIS ); + gr_string( LHX(111), LHY(137), TXT_INVERT ); + gr_string( LHX(230), LHY(137), TXT_AXIS ); + gr_string( LHX(260), LHY(137), TXT_INVERT ); + gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); + gr_setcolor( BM_XRGB(31,27,6) ); + + gr_rect( LHX(115), LHY(45), LHX(123), LHY(45) ); // horiz/left + gr_rect( LHX(137), LHY(45), LHX(145), LHY(45) ); // horiz/right + gr_rect( LHX(115), LHY(45), LHX(115), LHY(47) ); // vert/left + gr_rect( LHX(145), LHY(45), LHX(145), LHY(47) ); // vert/right + + gr_string( LHX(126), LHY(43), "OR" ); + + gr_rect( LHX(250), LHY(45), LHX(258), LHY(45) ); // horiz/left + gr_rect( LHX(272), LHY(45), LHX(280), LHY(45) ); // horiz/right + gr_rect( LHX(250), LHY(45), LHX(250), LHY(47) ); // vert/left + gr_rect( LHX(280), LHY(45), LHX(280), LHY(47) ); // vert/right + + gr_string( LHX(261), LHY(43), "OR" ); + } + else if ( items == kc_mouse ) + { + gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); + gr_setcolor( BM_XRGB(31,27,6) ); + gr_string( 0x8000, LHY(35), TXT_BUTTONS ); + gr_string( 0x8000,LHY(122), TXT_AXES ); + gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); + gr_string( LHX(169), LHY(129), TXT_AXIS ); + gr_string( LHX(199), LHY(129), TXT_INVERT ); + } + else if ( items == kc_d1x ) + { + gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); + gr_setcolor( BM_XRGB(31,27,6) ); + + gr_string(LHX( 94), LHY(40), "KB"); + gr_string(LHX(121), LHY(40), "JOY"); + } + + for (i=0; icv_font->ft_h) ); - game_flush_inputs(); } @@ -1147,13 +1163,14 @@ void kc_change_joybutton( kc_item * item ) ubyte code; gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - - gr_string( 0x8000, INFO_Y, TXT_PRESS_NEW_JBUTTON ); - + game_flush_inputs(); code=255; k=255; while( (k!=KEY_ESC) && (code==255)) { + + gr_string( 0x8000, INFO_Y, TXT_PRESS_NEW_JBUTTON ); + #ifdef NETWORK if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) multi_menu_poll(); @@ -1198,6 +1215,9 @@ void kc_change_joybutton( kc_item * item ) code = i; } } +#ifdef OGL + ogl_swap_buffers_internal(); +#endif } if (code!=255) { for (i=0; ivalue = code; } kc_drawitem( item, 1 ); - nm_restore_background( 0, INFO_Y, GWIDTH-10, FONTSCALE_Y(grd_curcanv->cv_font->ft_h) ); game_flush_inputs(); } @@ -1220,13 +1239,14 @@ void kc_change_mousebutton( kc_item * item ) ubyte code; gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - - gr_string( 0x8000, INFO_Y, TXT_PRESS_NEW_MBUTTON ); - + game_flush_inputs(); code=255; k=255; - while( (k!=KEY_ESC) && (code==255)) { + while( (k!=KEY_ESC) && (code==255)) { + + gr_string( 0x8000, INFO_Y, TXT_PRESS_NEW_MBUTTON ); + #ifdef NETWORK if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) multi_menu_poll(); @@ -1248,6 +1268,9 @@ void kc_change_mousebutton( kc_item * item ) if ( b & (1<value = code; } kc_drawitem( item, 1 ); - nm_restore_background( 0, INFO_Y, GWIDTH-10, FONTSCALE_Y(grd_curcanv->cv_font->ft_h) ); game_flush_inputs(); } @@ -1299,7 +1321,6 @@ void kc_next_joyaxis(kc_item *item) }//end if kc_drawitem(item, 1); - nm_restore_background( 0, INFO_Y, GWIDTH-10, FONTSCALE_Y(grd_curcanv->cv_font->ft_h) ); game_flush_inputs(); }//method kc_next_joyaxis @@ -1314,8 +1335,6 @@ void kc_change_joyaxis( kc_item * item ) ubyte code; gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - - gr_string( 0x8000, INFO_Y, TXT_MOVE_NEW_JOY_AXIS ); game_flush_inputs(); code=255; @@ -1325,6 +1344,9 @@ void kc_change_joyaxis( kc_item * item ) while( (k!=KEY_ESC) && (code==255)) { + + gr_string( 0x8000, INFO_Y, TXT_MOVE_NEW_JOY_AXIS ); + #ifdef NETWORK if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) multi_menu_poll(); @@ -1358,6 +1380,9 @@ void kc_change_joyaxis( kc_item * item ) code = 255; } */ +#ifdef OGL + ogl_swap_buffers_internal(); +#endif } if (code!=255) { for (i=0; icv_font->ft_h) ); game_flush_inputs(); } @@ -1388,8 +1412,6 @@ void kc_change_mouseaxis( kc_item * item ) gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - gr_string( 0x8000, INFO_Y, TXT_MOVE_NEW_MSE_AXIS ); - game_flush_inputs(); code=255; k=255; @@ -1397,6 +1419,8 @@ void kc_change_mouseaxis( kc_item * item ) mouse_get_delta( &dx, &dy ); while( (k!=KEY_ESC) && (code==255)) { + + gr_string( 0x8000, INFO_Y, TXT_MOVE_NEW_MSE_AXIS ); #ifdef NETWORK if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) multi_menu_poll(); @@ -1422,6 +1446,9 @@ void kc_change_mouseaxis( kc_item * item ) if ( abs(dy)>20 ) code = 1; #ifdef SDL_INPUT if ( abs(dz)>20 ) code = 2; +#endif +#ifdef OGL + ogl_swap_buffers_internal(); #endif } if (code!=255) { @@ -1435,9 +1462,7 @@ void kc_change_mouseaxis( kc_item * item ) item->value = code; } kc_drawitem( item, 1 ); - nm_restore_background( 0, INFO_Y, GWIDTH-10, FONTSCALE_Y(grd_curcanv->cv_font->ft_h) ); game_flush_inputs(); - } diff --git a/main/kmatrix.c b/main/kmatrix.c index 91d98952d..1dd515fc2 100755 --- a/main/kmatrix.c +++ b/main/kmatrix.c @@ -140,10 +140,12 @@ static char rcsid[] = "$Id: kmatrix.c,v 1.1.1.1 2006/03/17 19:44:38 zicodxx Exp #include "gauges.h" #include "pcx.h" #include "network.h" - -//added 11/01/98 Matt Mueller #include "hudlog.h" -//end addition -MM +#include "d_delay.h" + +#ifdef OGL +#include "ogl_init.h" +#endif static int rescale_x(int x) { @@ -290,14 +292,6 @@ void kmatrix_redraw() kmatrix_draw_deaths(sorted); gr_update(); - -//added 11/01/98 Matthew Mueller - loggable score grid - kmatrix_log(0); -//end addition -MM - -//added 03/07/99 Matt Mueller - fix black screen instead of endlevel scores. - gr_update(); -//end addition -MM } #define MAX_VIEW_TIME F1_0*60 @@ -313,14 +307,14 @@ void kmatrix_view(int network) set_screen_mode( SCREEN_MENU ); - kmatrix_redraw(); - gr_palette_fade_in( gr_palette,32, 0); game_flush_inputs(); done = 0; while(!done) { + d_delay(5); + kmatrix_redraw(); for (i=0; i<4; i++ ) if (joy_get_button_down_cnt(i)>0) done=1; @@ -356,11 +350,16 @@ void kmatrix_view(int network) if (key < -1) done = 1; } +#ifdef OGL + ogl_swap_buffers(); +#endif } // Restore background and exit gr_palette_fade_out( gr_palette, 32, 0 ); game_flush_inputs(); + + kmatrix_log(0); } #endif diff --git a/main/menu.c b/main/menu.c index f1a6a628c..820929e11 100755 --- a/main/menu.c +++ b/main/menu.c @@ -174,15 +174,6 @@ void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int ci items=items; citem = citem; - //draw copyright message - if ( Menu_draw_copyright ) { - Menu_draw_copyright = 0; - gr_set_current_canvas(NULL); - gr_set_curfont(GAME_FONT); - gr_set_fontcolor(BM_XRGB(6,6,6),-1); - gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-FONTSCALE_Y(GAME_FONT->ft_h)-2,TXT_COPYRIGHT); - } - // Don't allow them to hit ESC in the main menu. if (*last_key==KEY_ESC) *last_key = 0; @@ -305,8 +296,6 @@ int DoMenu() else { //end this section addition - VR - extern int Menu_Special; - Menu_Special = 1; main_menu_choice = newmenu_do2(NULL, NULL, num_options, m, autodemo_menu_check, main_menu_choice, Menu_pcx_name); if ( main_menu_choice > -1 ) do_option(menu_choice[main_menu_choice]); } diff --git a/main/netlist.c b/main/netlist.c index 67794d1e7..e91f55031 100755 --- a/main/netlist.c +++ b/main/netlist.c @@ -22,23 +22,16 @@ #include "game.h" #include "multi.h" #include "text.h" -//added 4/18/99 Matt Mueller - show radar in game info #include "multipow.h" -//end addition -MM - #include "gamefont.h" #include "u_mem.h" - #include "string.h" - -//added on 1/5/99 by Victor Rachels for missiondir #include "cfile.h" -//end this section addition - -//added on 11/20/99 by Victor Rachels for observer mode #include "observer.h" -//end this section addition +#ifdef OGL +#include "ogl_init.h" +#endif #define LINE_ITEMS 8 #define MAX_TEXT_LEN 25 @@ -143,7 +136,9 @@ char *network_menu_title[LINE_ITEMS] = { "", "", "Game", "Mode", "#Plrs", "Missi static int selected_game; static void draw_back(bkg *b, int x, int y, int w, int h) { +#ifndef OGL gr_bm_bitblt(b->background->bm_w-15, h, 5, y, 5, y, b->background, &(grd_curcanv->cv_bitmap) ); +#endif } static void draw_item(bkg *b, struct line_item *li, int is_current) { @@ -186,12 +181,15 @@ static void init_background(bkg *bg, int x, int y, int w, int h) { bg->menu_canvas = gr_create_sub_canvas( &grd_curscreen->sc_canvas, x, y, w, h ); gr_set_current_canvas( bg->menu_canvas ); +#ifndef OGL // Save the background under the menu... bg->saved = gr_create_bitmap( w, h ); Assert( bg->saved != NULL ); gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg->saved ); +#endif gr_set_current_canvas( NULL ); nm_draw_background(x,y,x+w-1,y+h-1); +#ifndef OGL if (w > nm_background.bm_w || h > nm_background.bm_h){ bg->background=gr_create_bitmap(w,h); gr_bitmap_scale_to(&nm_background,bg->background); @@ -200,17 +198,20 @@ static void init_background(bkg *bg, int x, int y, int w, int h) { bg->background = gr_create_sub_bitmap(&nm_background,0,0,w,h); bg->background_is_sub=1; } +#endif gr_set_current_canvas( bg->menu_canvas ); } static void done_background(bkg *bg) { gr_set_current_canvas(bg->menu_canvas); +#ifndef OGL gr_bitmap(0, 0, bg->saved); gr_free_bitmap(bg->saved); if (bg->background_is_sub) gr_free_sub_bitmap( bg->background ); else gr_free_bitmap( bg->background ); +#endif gr_free_sub_canvas( bg->menu_canvas ); } @@ -495,14 +496,14 @@ void netlist_redraw(bkg bg, init_background(&bg, 0, 7, grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h - 14); - yp=22; + yp=10*(SHEIGHT/200); gr_set_curfont(Gamefonts[GFONT_BIG_1]); gr_string(0x8000, yp, "Netgames");//yp was 22 yp+=grd_curcanv->cv_font->ft_h+network_menu_hskip*3+Gamefonts[GFONT_SMALL]->ft_h;//need to account for size of current socket, drawn elsewhere // draw titles gr_set_curfont(Gamefonts[GFONT_SMALL]); gr_set_fontcolor(BM_XRGB(27, 27, 27), -1); - k = 15; + k = 15*(SWIDTH/320); for (j = 0; j < LINE_ITEMS; j++) { gr_ustring(k, yp, network_menu_title[j]);//yp was 61 k += network_menu_width[j]; @@ -511,7 +512,7 @@ void netlist_redraw(bkg bg, for (i = 0; i < MAX_ACTIVE_NETGAMES; i++) { struct line_item *li = lis[i]; - k=15; + k=15*(SWIDTH/320); yp+=grd_curcanv->cv_font->ft_h+network_menu_hskip; for (j = 0; j < LINE_ITEMS; j++) { @@ -546,16 +547,14 @@ int network_join_game_menu() { for (k=0;kcv_bitmap.bm_w/320; - network_menu_hskip=(grd_curcanv->cv_bitmap.bm_h-Gamefonts[GFONT_BIG_1]->ft_h-22-Gamefonts[GFONT_SMALL]->ft_h*17)/17; + network_menu_hskip=(grd_curcanv->cv_bitmap.bm_h-Gamefonts[GFONT_BIG_1]->ft_h-10-Gamefonts[GFONT_SMALL]->ft_h*17)/17; init_background(&bg, 0, 7, grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h - 14); game_flush_inputs(); -//added/changed on 9/17/98 by Victor Rachels for netgame info screen redraw netlist_redraw(bg,menu_text,lis); -//end this section addition - Victor Rachels Network_games_changed = 1; old_socket = -32768; @@ -568,10 +567,14 @@ int network_join_game_menu() { done = 0; while (!done) { +#ifdef OGL + ogl_swap_buffers(); + netlist_redraw(bg,menu_text,lis); +#endif if (Network_socket != old_socket) { gr_set_fontcolor(BM_XRGB(27, 27, 27), -1); - draw_back(&bg, 30, 22+Gamefonts[GFONT_BIG_1]->ft_h+network_menu_hskip*2, 250, Gamefonts[GFONT_SMALL]->ft_h+4);//was 52,250,9 - gr_printf(30, 22+Gamefonts[GFONT_BIG_1]->ft_h+network_menu_hskip*2, "Current IPX socket is %+d " + draw_back(&bg, 30*(SWIDTH/320), (10*SHEIGHT/200)+Gamefonts[GFONT_BIG_1]->ft_h+network_menu_hskip*2, 250, Gamefonts[GFONT_SMALL]->ft_h+4);//was 52,250,9 + gr_printf(30*(SWIDTH/320), (10*SHEIGHT/200)+Gamefonts[GFONT_BIG_1]->ft_h+network_menu_hskip*2, "Current IPX socket is %+d " "(PgUp/PgDn to change)", Network_socket); if (old_socket != -32768) { /* changed by user? */ network_listen(); @@ -581,6 +584,15 @@ int network_join_game_menu() { req_timer -= F1_0 * 5; /* force send request */ Network_games_changed = 1; } +#ifdef OGL + else { + gr_set_fontcolor(BM_XRGB(27, 27, 27), -1); + gr_printf(30*(SWIDTH/320), (10*SHEIGHT/200)+Gamefonts[GFONT_BIG_1]->ft_h+network_menu_hskip*2, "Current IPX socket is %+d " + "(PgUp/PgDn to change)", Network_socket); + draw_list(&bg, lis); + } +#endif + if (Network_games_changed) { if (num_active_games > last_num_games) /* new game? */ digi_play_sample(SOUND_HUD_MESSAGE, F1_0); diff --git a/main/newmenu.c b/main/newmenu.c index 431247b83..4418a4bc3 100755 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -29,7 +29,6 @@ static char rcsid[] = "$Id: newmenu.c,v 1.1.1.1 2006/03/17 19:44:42 zicodxx Exp #include #include "clipboard.h" - #include "error.h" #include "types.h" #include "gr.h" @@ -57,21 +56,22 @@ static char rcsid[] = "$Id: newmenu.c,v 1.1.1.1 2006/03/17 19:44:42 zicodxx Exp #include "d_io.h" #include "timer.h" #include "vers_id.h" +#include "d_delay.h" + +#ifdef OGL +#include "ogl_init.h" +#endif #ifdef GP2X #include "gp2x.h" #endif #define TITLE_FONT (Gamefonts[GFONT_BIG_1]) - #define SUBTITLE_FONT (Gamefonts[GFONT_MEDIUM_3]) #define CURRENT_FONT (Gamefonts[GFONT_MEDIUM_2]) #define NORMAL_FONT (Gamefonts[GFONT_MEDIUM_1]) #define TEXT_FONT (Gamefonts[GFONT_MEDIUM_3]) -int Newmenu_first_time = 1; -//--unused-- int Newmenu_fade_in = 1; - typedef struct bkg { grs_canvas * menu_canvas; grs_bitmap * saved; // The background under the menu. @@ -80,9 +80,10 @@ typedef struct bkg { } bkg; grs_bitmap nm_background; +grs_bitmap nm_background1; #define MESSAGEBOX_TEXT_SIZE 2176 // How many characters in messagebox (changed form 300 (fixes crash from show_game_score and friends) - 2000/01/18 Matt Mueller) -#define MAX_TEXT_WIDTH FONTSCALE_X(200) // How many pixels wide a input box can be +#define MAX_TEXT_WIDTH FONTSCALE_X(200) // How many pixels wide a input box can be // ZICO - since the background is rescaled the bevels do the same. because of this we need bigger borders or the fonts would be printed inside the bevels... #define MENSCALE_X ((double)(SWIDTH/320)) @@ -92,34 +93,61 @@ extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitma void newmenu_close() { gr_free_bitmap_data ( &nm_background ); - Newmenu_first_time = 1; + gr_free_bitmap_data ( &nm_background1 ); } +// Draw Copyright and Version strings +void nm_draw_copyright() +{ + grd_curcanv->cv_font = GAME_FONT; + gr_set_fontcolor(BM_XRGB(6,6,6),-1); + gr_printf(0x8000,grd_curcanv->cv_bitmap.bm_h-FONTSCALE_Y(GAME_FONT->ft_h)-2,TXT_COPYRIGHT); + gr_set_fontcolor( GR_GETCOLOR(25,0,0), -1); + gr_printf(0x8000,GHEIGHT-FONTSCALE_Y(grd_curcanv->cv_font->ft_h*3),DESCENT_VERSION); +} + +// Draws the background of menus (i.e. Descent Logo screen) void nm_draw_background1(char * filename) { int pcx_error; - gr_clear_canvas( BM_XRGB(0,0,0) ); - pcx_error = pcx_read_fullscr(filename, NULL); - Assert(pcx_error == PCX_ERROR_NONE); + #ifdef OGL - gr_palette_load(gr_palette); + if (filename == NULL && Function_mode == FMODE_MENU) + filename = Menu_pcx_name; + if (filename != NULL) #endif + { + if (nm_background1.bm_data == NULL) { + ubyte newpal[768]; + atexit( newmenu_close ); + gr_init_bitmap_data (&nm_background1); + pcx_error = pcx_read_bitmap( filename, &nm_background1, BM_LINEAR, newpal ); + Assert(pcx_error == PCX_ERROR_NONE); + gr_remap_bitmap_good( &nm_background, newpal, -1, -1 ); + } +#ifndef OGL + show_fullscr(&nm_background1); +#else + ogl_ubitmapm_cs(0,0,-1,-1,&nm_background1,-1,F1_0); +#endif + + if (!strcmp(filename,Menu_pcx_name) && Function_mode != FMODE_GAME) + nm_draw_copyright(); + } } +// Draws the frame background for menus void nm_draw_background(int x1, int y1, int x2, int y2 ) { int w,h; - if (Newmenu_first_time) { + if (nm_background.bm_data == NULL) { int pcx_error; ubyte newpal[768]; atexit( newmenu_close ); - Newmenu_first_time = 0; - gr_init_bitmap_data (&nm_background); pcx_error = pcx_read_bitmap("SCORES.PCX",&nm_background,BM_LINEAR,newpal); Assert(pcx_error == PCX_ERROR_NONE); - gr_remap_bitmap_good( &nm_background, newpal, -1, -1 ); } @@ -129,79 +157,37 @@ void nm_draw_background(int x1, int y1, int x2, int y2 ) w = x2-x1+1; h = y2-y1+1; - if ( GWIDTH >= nm_background.bm_w || GHEIGHT >= nm_background.bm_h ){//Resize background to fit. Resize so that the original aspect is preserved. -MPM - grs_canvas *tmp,*old; - grs_bitmap bg; - old=grd_curcanv; - tmp=gr_create_sub_canvas(old,x1,y1,w,h); - gr_init_sub_bitmap(&bg,&nm_background,0,0,w*(320.0/GWIDTH),h*(200.0/GHEIGHT));//note that we haven't replaced current_canvas yet, so these macros are still ok. - gr_set_current_canvas(tmp); + grs_canvas *tmp,*old; + grs_bitmap bg; + old=grd_curcanv; + tmp=gr_create_sub_canvas(old,x1,y1,w,h); + gr_init_sub_bitmap(&bg,&nm_background,0,0,w*(320.0/SWIDTH),h*(200.0/SHEIGHT));//note that we haven't replaced current_canvas yet, so these macros are still ok. + gr_set_current_canvas(tmp); +#ifdef OGL + if (ogl_scissor_ok) { + glEnable(GL_SCISSOR_TEST); + glScissor(0,y1,x2,SHEIGHT); + ogl_ubitmapm_cs(0,0,SWIDTH,SHEIGHT,&nm_background,-1,F1_0); + glDisable(GL_SCISSOR_TEST); + } else +#endif show_fullscr( &bg ); - gr_set_current_canvas(old); - gr_free_sub_canvas(tmp); - } - else - { - gr_bm_bitblt(w, h, x1, y1, 0, 0, &nm_background, &(grd_curcanv->cv_bitmap) ); - } + gr_set_current_canvas(old); + gr_free_sub_canvas(tmp); Gr_scanline_darkening_level = 2*7; - //scale the bevels to the res too. All the gwidth/height stuff is needed so that the corners have the correct angles at odd resolutions like 320x400 where the ratios are different for x and y - -// #ifdef OGL -// gr_setcolor( BM_XRGB(1,1,1) ); -// -// for (w=5*(GWIDTH/320.0);w>=0;w--) -// gr_urect( x2-w+1, y1+w*((GHEIGHT/200.0)/(GWIDTH/320.0)), x2+1, y2-(GHEIGHT/200.0) );//right edge -// for (h=5*(GHEIGHT/200.0);h>=0;h--) -// gr_urect( x1+h*((GWIDTH/320.0)/(GHEIGHT/200.0)), y2+1, x2+1, y2-h+1 );//bottom edge -// #else + //scale the bevels to the res. gr_setcolor( BM_XRGB(0,0,0) ); - for (w=5*(GWIDTH/320.0);w>=0;w--) - gr_urect( x2-w, y1+w*((GHEIGHT/200.0)/(GWIDTH/320.0)), x2-w, y2-(GHEIGHT/200.0) );//right edge - for (h=5*(GHEIGHT/200.0);h>=0;h--) - gr_urect( x1+h*((GWIDTH/320.0)/(GHEIGHT/200.0)), y2-h, x2, y2-h );//bottom edge -// #endif - + for (w=5*(SWIDTH/320.0);w>=0;w--) + gr_urect( x2-w, y1+w*((SHEIGHT/200.0)/(SWIDTH/320.0)), x2-w, y2 );//right edge + for (h=5*(SHEIGHT/200.0);h>=0;h--) + gr_urect( x1+h*((SWIDTH/320.0)/(SHEIGHT/200.0)), y2-h, x2, y2-h );//bottom edge Gr_scanline_darkening_level = GR_FADE_LEVELS; } -void nm_restore_background( int x, int y, int w, int h ) -{ - int x1, x2, y1, y2; - - x1 = x; x2 = x+w-1; - y1 = y; y2 = y+h-1; - - if ( x1 < 0 ) x1 = 0; - if ( y1 < 0 ) y1 = 0; - - if ( x2 >= GWIDTH ) x2=GWIDTH-1; - if ( y2 >= GHEIGHT ) y2=GHEIGHT-1; - - w = x2 - x1 + 1; - h = y2 - y1 + 1; - - if ( GWIDTH > nm_background.bm_w || GHEIGHT > nm_background.bm_h ) { - grs_bitmap sbg; - grs_canvas *tmp,*old; - old=grd_curcanv; - tmp=gr_create_sub_canvas(old,x1,y1,w,h); - gr_init_sub_bitmap(&sbg,&nm_background,x1*(320.0/GWIDTH),y1*(200.0/GHEIGHT),w*(320.0/GWIDTH),h*(200.0/GHEIGHT));//use the correctly resized portion of the background. -MPM - gr_set_current_canvas(tmp); - show_fullscr( &sbg ); - gr_set_current_canvas(old); - gr_free_sub_canvas(tmp); - } - else - { - gr_bm_bitblt(w, h, x1, y1, x1, y1, &nm_background, &(grd_curcanv->cv_bitmap) ); - } -} - // Draw a left justfied string void nm_string( bkg * b, int w1,int x, int y, char * _s ) { @@ -222,11 +208,9 @@ void nm_string( bkg * b, int w1,int x, int y, char * _s ) if (w1 > 0) w = w1; - - // CHANGED +#ifndef OGL gr_bm_bitblt(b->background->bm_w-(15*MENSCALE_X), h, 5, y, 5, y, b->background, &(grd_curcanv->cv_bitmap) ); - //gr_bm_bitblt(w, h, x, y, x, y, b->background, &(grd_curcanv->cv_bitmap) ); - +#endif gr_string( x, y, s ); if (s1) { @@ -251,18 +235,17 @@ void nm_string_slider( bkg * b, int w1,int x, int y, char * s ) } gr_get_string_size(s, &w, &h, &aw ); - // CHANGED +#ifndef OGL gr_bm_bitblt(b->background->bm_w-(15*MENSCALE_X), h, 5, y, 5, y, b->background, &(grd_curcanv->cv_bitmap) ); - //gr_bm_bitblt(w, h, x, y, x, y, b->background, &(grd_curcanv->cv_bitmap) ); - +#endif gr_string( x, y, s ); if (p) { gr_get_string_size(s1, &w, &h, &aw ); - // CHANGED +#ifndef OGL gr_bm_bitblt(w, 1, x+w1-w, y, x+w1-w, y, b->background, &(grd_curcanv->cv_bitmap) ); - // CHANGED gr_bm_bitblt(w, 1, x+w1-w, y+h-1, x+w1-w, y, b->background, &(grd_curcanv->cv_bitmap) ); +#endif gr_string( x+w1-w, y, s1 ); *p = '\t'; } @@ -290,11 +273,9 @@ void nm_rstring( bkg * b,int w1,int x, int y, char * s ) x -= 3; if (w1 == 0) w1 = w; - - //mprintf( 0, "Width = %d, string='%s'\n", w, s ); - - // CHANGED +#ifndef OGL gr_bm_bitblt(w1, h, x-w1, y, x-w1, y, b->background, &(grd_curcanv->cv_bitmap) ); +#endif gr_string( x-w, y, s ); } @@ -469,7 +450,7 @@ int check_button_press() if (mouse_button_down_count(i)>0) return 1; break; #endif - case CONTROL_NONE: //keyboard only + case CONTROL_NONE: //keyboard only break; default: Error("Bad control type (Config_control_type):%i",Config_control_type); @@ -478,10 +459,6 @@ int check_button_press() return 0; } -//added on 11/31/98 by Victor Rachels for different way to do ver -int Menu_Special = 0; -//end this section addition - VR - #ifdef NEWMENU_MOUSE ubyte Hack_DblClick_MenuMode=0; #endif @@ -525,7 +502,7 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * int string_width, string_height, average_width; int ty; bkg bg; - int all_text=0; //set true if all text items + int all_text=0; //set true if all text items int sound_stopped=0, time_stopped=0; #ifdef NEWMENU_MOUSE int mouse_state, omouse_state, dblclick_flag=0; @@ -536,8 +513,6 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * if (nitems < 1 ) return -1; -// set_screen_mode(SCREEN_MENU);// caller is responsible for setting screen mode first, else fonts can get screwed up. Not a big deal since (at the moment) only the 2 funcs below call this one directly. - if ( Function_mode == FMODE_GAME ) { digi_pause_all(); sound_stopped = 1; @@ -570,7 +545,7 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * } - th += 8*MENSCALE_Y; //put some space between titles & body + th += 8*MENSCALE_Y; //put some space between titles & body grd_curcanv->cv_font = normal_font; @@ -681,10 +656,6 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * if (right_offset > 0 ) right_offset += 3; - //mprintf( 0, "Right offset = %d\n", right_offset ); - - //gr_get_string_size("",&string_width,&string_height,&average_width ); - w += right_offset; twidth = 0; @@ -697,8 +668,6 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * w += 30*MENSCALE_X; h += 30*MENSCALE_Y; -// if ( w > SWIDTH ) w = SWIDTH; -// if ( h > SHEIGHT ) h = SHEIGHT; /* If window is as or almost as big as screen define hard size so it fits (with borders and stuff). Also make use of MENSCALE_* so we are sure it does scale correct if font does scale or not */ if (w >= 320*MENSCALE_X-3) @@ -713,15 +682,20 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * if ( x < 0 ) x = 0; if ( y < 0 ) y = 0; +#ifndef OGL if ( filename != NULL ) { nm_draw_background1( filename ); gr_palette_load(gr_palette); } +#endif // Save the background of the display bg.menu_canvas = gr_create_sub_canvas( &grd_curscreen->sc_canvas, x, y, w+MENSCALE_X, h+MENSCALE_Y ); gr_set_current_canvas( bg.menu_canvas ); + ty = (15*MENSCALE_Y); + +#ifndef OGL if ( filename == NULL ) { // Save the background under the menu... bg.saved = gr_create_bitmap( w+MENSCALE_X+10, h+MENSCALE_Y ); @@ -750,26 +724,6 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * gr_bm_bitblt(w, h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.background ); } -// ty = 15 + (yborder/4); - ty = (15*MENSCALE_Y); - - //added on 11/20/98 by Victor Rachels for d1x ver -//added/changed on 11/31/98 by Victor Rachels for different way to do ver - if(Menu_Special==1) -//-killed- title && !strcmp(title,"MAIN MENU")) -//end this section change - VR - { - grs_canvas *saved_canvas = grd_curcanv; - grd_curcanv = &grd_curscreen->sc_canvas; - grd_curcanv->cv_font = GAME_FONT; - gr_set_fontcolor( GR_GETCOLOR(25,0,0), -1); - gr_printf(0x8000,GHEIGHT-FONTSCALE_Y(grd_curcanv->cv_font->ft_h*3),DESCENT_VERSION); - grd_curcanv = saved_canvas; - Menu_Special = 0; - } - //end this section addition - VR - - if ( title ) { grd_curcanv->cv_font = title_font; gr_set_fontcolor( GR_GETCOLOR(31,31,31), -1 ); @@ -777,19 +731,17 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * tw = string_width; th = string_height; gr_printf( 0x8000, ty, title ); - ty += th; } - + if ( subtitle ) { grd_curcanv->cv_font = subtitle_font; gr_set_fontcolor( GR_GETCOLOR(21,21,21), -1 ); gr_get_string_size(subtitle,&string_width,&string_height,&average_width ); tw = string_width; - th = string_height; - gr_printf( 0x8000, ty, subtitle ); - ty += th; + th = (title?th:0); + gr_printf( 0x8000, ty+th, subtitle ); } - +#endif grd_curcanv->cv_font = normal_font; // Update all item's x & y values. @@ -837,7 +789,7 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * break; } } - } + } done = 0; gr_update(); // Clear mouse, joystick to clear button presses. @@ -845,17 +797,45 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * #ifdef NEWMENU_MOUSE mouse_state = omouse_state = 0; - if (filename == NULL) { - draw_close_box(0,0); - close_box = 1; - } - newmenu_show_cursor(); #endif while(!done) { - //network_listen(); + d_delay(5); +#ifdef OGL + ogl_swap_buffers(); + + gr_set_current_canvas( NULL ); + nm_draw_background1(filename); + if (filename == NULL) + nm_draw_background(x,y,x+w,y+h); + + gr_set_current_canvas( bg.menu_canvas ); + + if ( title ) { + grd_curcanv->cv_font = title_font; + gr_set_fontcolor( GR_GETCOLOR(31,31,31), -1 ); + gr_get_string_size(title,&string_width,&string_height,&average_width ); + tw = string_width; + th = string_height; + gr_printf( 0x8000, ty, title ); + } + if ( subtitle ) { + grd_curcanv->cv_font = subtitle_font; + gr_set_fontcolor( GR_GETCOLOR(21,21,21), -1 ); + gr_get_string_size(subtitle,&string_width,&string_height,&average_width ); + tw = string_width; + th = (title?th:0); + gr_printf( 0x8000, ty+th, subtitle ); + } + +#endif + if (filename == NULL) { + draw_close_box(0,0); + close_box = 1; + } + #ifdef NEWMENU_MOUSE newmenu_show_cursor(); // possibly hidden omouse_state = mouse_state; @@ -1297,6 +1277,8 @@ int newmenu_do3_real( char * title, char * subtitle, int nitems, newmenu_item * } gr_set_current_canvas(bg.menu_canvas); + +#ifndef OGL // Redraw everything... for (i=0; icv_font = save_font; - gr_set_current_canvas( save_canvas ); + gr_set_current_canvas( save_canvas ); keyd_repeat = old_keyd_repeat; game_flush_inputs(); @@ -1425,11 +1418,11 @@ void newmenu_file_sort( int n, char *list ) char t[14]; incr = n / 2; - while( incr > 0 ) { - for (i=incr; i 0 ) { + for (i=incr; i=0 ) { - if (strncmp(&list[j*14], &list[(j+incr)*14], 12) > 0) { + while (j>=0 ) { + if (strncmp(&list[j*14], &list[(j+incr)*14], 12) > 0) { memcpy( t, &list[j*14], 13 ); memcpy( &list[j*14], &list[(j+incr)*14], 13 ); memcpy( &list[(j+incr)*14], t, 13 ); @@ -1474,7 +1467,9 @@ int newmenu_get_filename( char * title, char * filespec, char * filename, int al int exit_value = 0; int w_x, w_y, w_w, w_h, title_height; int box_x, box_y, box_w, box_h; - bkg bg; // background under listbox +#ifndef OGL + bkg bg; // background under listbox +#endif #ifdef NEWMENU_MOUSE int mx, my, x1, x2, y1, y2, mouse_state, omouse_state; int mouse2_state, omouse2_state; @@ -1571,7 +1566,9 @@ ReadFileNames: gr_get_string_size( title, &w, &h, &aw ); if ( w > w_w ) w_w = w; +#ifdef OGL if (fixedfont) +#endif h += 10*MENSCALE_Y; title_height = h + FONTSCALE_Y(grd_curcanv->cv_font->ft_h*2); // add a little space at the bottom of the title } @@ -1601,8 +1598,8 @@ ReadFileNames: box_y = w_y + title_height; -// save the screen behind the menu. - +#ifndef OGL + // save the screen behind the menu. bg.saved = NULL; if ( (GWIDTH >= w_w) && (GHEIGHT >= w_h) ) @@ -1612,17 +1609,12 @@ ReadFileNames: Assert( bg.background != NULL ); - -// gr_bm_bitblt(w_w, w_h, 0, 0, w_x, w_y, &grd_curcanv->cv_bitmap, bg.background ); - -// #if 0 gr_bm_bitblt(GWIDTH, GHEIGHT, 0, 0, 0, 0, &(grd_curcanv->cv_bitmap), &(VR_offscreen_buffer->cv_bitmap) ); -// #endif - nm_draw_background( w_x,w_y,w_x+w_w-1,w_y+w_h-1 ); + nm_draw_background( w_x,w_y,w_x+w_w-1,w_y+w_h ); gr_string( 0x8000, w_y+(10*MENSCALE_Y), title ); - +#endif initialized = 1; } @@ -1643,16 +1635,25 @@ ReadFileNames: #ifdef NEWMENU_MOUSE mouse_state = omouse_state = 0; mouse2_state = omouse2_state = 0; - draw_close_box(w_x,w_y); newmenu_show_cursor(); #endif while(!done) { + d_delay(5); ocitem = citem; ofirst_item = first_item; gr_update(); +#ifdef OGL + ogl_swap_buffers(); + nm_draw_background1(NULL); + nm_draw_background( w_x,w_y,w_x+w_w-1,w_y+w_h ); + grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3]; + gr_string( 0x8000, w_y+(10*MENSCALE_Y), title ); +#endif + #ifdef NEWMENU_MOUSE + draw_close_box(w_x,w_y); omouse_state = mouse_state; omouse2_state = mouse2_state; mouse_state = mouse_button_state(0); @@ -1842,10 +1843,12 @@ ReadFileNames: #endif +#ifndef OGL gr_setcolor( BM_XRGB( 0,0,0) ); if (ofirst_item != first_item) { newmenu_hide_cursor(); +#endif gr_setcolor( BM_XRGB( 0,0,0) ); for (i=first_item; icv_font->ft_h + 2)); - //gr_rect( box_x, y + grd_curcanv->cv_font->ft_h + 2, box_x + box_w, y + grd_curcanv->cv_font->ft_h + 2); gr_setcolor( BM_XRGB(2,2,2)); gr_rect( box_x - 1, y - 1, box_x - 1, y + FONTSCALE_Y(grd_curcanv->cv_font->ft_h + 2) ); @@ -1871,7 +1873,6 @@ ReadFileNames: gr_get_string_size(&filenames[i*14], &w, &h, &aw ); gr_setcolor( BM_XRGB(5,5,5)); - // gr_rect( box_x, y + h + 2, box_x + box_w, y + h + 2); gr_rect( box_x + box_w, y - 1, box_x + box_w, y + h + FONTSCALE_Y(2)); gr_setcolor( BM_XRGB(2,2,2)); @@ -1882,6 +1883,7 @@ ReadFileNames: gr_string( box_x + 5, y, (&filenames[i*14])+((player_mode && filenames[i*14]=='$')?1:0) ); } } +#ifndef OGL newmenu_show_cursor(); } else if ( citem != ocitem ) { int w, h, aw, y; @@ -1906,12 +1908,11 @@ ReadFileNames: else grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_1]; gr_get_string_size(&filenames[i*14], &w, &h, &aw ); -// gr_rect( box_x, y-1, box_x + box_x - 1, y + h + FONTSCALE_Y(2) ); gr_string( box_x + 5, y, (&filenames[i*14])+((player_mode && filenames[i*14]=='$')?1:0) ); } newmenu_show_cursor(); } - +#endif if ( gr_palette_faded_out ) { gr_palette_fade_in( gr_palette, 32, 0 ); } @@ -1923,7 +1924,7 @@ ExitFileMenuEarly: exit_value = 1; } else { exit_value = 0; - } + } ExitFileMenu: keyd_repeat = old_keyd_repeat; @@ -1989,7 +1990,7 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ width = 0; for (i=0; i width ) width = w; } @@ -1999,7 +2000,7 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ { int w, h, aw; - gr_get_string_size( title, &w, &h, &aw ); + gr_get_string_size( title, &w, &h, &aw ); if ( w > width ) width = w; title_height = h + 5; @@ -2016,10 +2017,12 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ bg.saved = NULL; bg.background = gr_create_bitmap(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h); +#ifndef OGL gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, 0, 0, 0, 0, &grd_curcanv->cv_bitmap, bg.background ); nm_draw_background( wx-(15*MENSCALE_X),wy-title_height-(15*MENSCALE_Y),wx+width+(15*MENSCALE_X),wy+height+(15*MENSCALE_Y) ); gr_string( 0x8000, wy - title_height, title ); +#endif done = 0; citem = default_item; @@ -2029,18 +2032,27 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ first_item = -1; #ifdef NEWMENU_MOUSE - mouse_state = omouse_state = 0; //dblclick_flag = 0; + mouse_state = omouse_state = 0; close_x = wx-(15*MENSCALE_X); close_y = wy-title_height-(15*MENSCALE_Y); - draw_close_box(close_x,close_y); newmenu_show_cursor(); #endif while(!done) { + d_delay(5); +#ifdef OGL + ogl_swap_buffers(); + nm_draw_background1(NULL); + nm_draw_background( wx-(15*MENSCALE_X),wy-title_height-(15*MENSCALE_Y),wx+width+(15*MENSCALE_X),wy+height+(15*MENSCALE_Y) ); + grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3]; + gr_string( 0x8000, wy - title_height, title ); +#endif + ocitem = citem; ofirst_item = first_item; #ifdef NEWMENU_MOUSE + draw_close_box(close_x,close_y); omouse_state = mouse_state; mouse_state = mouse_button_state(0); #endif @@ -2157,10 +2169,6 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ y1 = (i-first_item)*FONTSCALE_Y(grd_curcanv->cv_font->ft_h+2)+wy; y2 = y1+h+1; if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) { - //if (i == citem) { - // break; - //} - //dblclick_flag= 0; citem = i; done = 1; break; @@ -2182,8 +2190,11 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ } #endif - if ( (ofirst_item != first_item) || redraw) { +#ifndef OGL + if ((ofirst_item != first_item) || redraw) + { newmenu_hide_cursor(); +#endif gr_setcolor( BM_XRGB( 0,0,0) ); for (i=first_item; i=0) && (icv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, 0, 0, 0, 0, bg.background, &grd_curcanv->cv_bitmap ); - +#endif if ( bg.background != &VR_offscreen_buffer->cv_bitmap ) gr_free_bitmap(bg.background); diff --git a/main/polyobj.c b/main/polyobj.c index 940d98011..bea0f5a20 100755 --- a/main/polyobj.c +++ b/main/polyobj.c @@ -863,7 +863,7 @@ void draw_model_picture(int mn,vms_angvec *orient_angles) Assert(mn>=0 && mncv_bitmap.bm_w,grd_curcanv->cv_bitmap.bm_h); + gr_use_palette_table( "palette.256" ); #else temp_canv = gr_create_canvas(save_canv->cv_bitmap.bm_w,save_canv->cv_bitmap.bm_h); gr_set_current_canvas(temp_canv); @@ -881,9 +881,7 @@ void draw_model_picture(int mn,vms_angvec *orient_angles) draw_polygon_model(&temp_pos,&temp_orient,NULL,mn,0,f1_0,NULL,NULL); g3_end_frame(); -#ifdef OGL - ogl_end_offscreen_render(); -#else +#ifndef OGL gr_set_current_canvas(save_canv); gr_bitmap(0,0,&temp_canv->cv_bitmap); gr_free_canvas(temp_canv); diff --git a/main/scores.c b/main/scores.c index 769dbee17..570b31ce8 100755 --- a/main/scores.c +++ b/main/scores.c @@ -272,8 +272,14 @@ static char rcsid[] = "$Id: scores.c,v 1.1.1.1 2006/03/17 19:42:39 zicodxx Exp $ #include "timer.h" #include "text.h" #include "d_io.h" +#include "d_delay.h" + +#ifdef OGL +#include "ogl_init.h" +#endif void scores_view(int citem); +extern void nm_draw_background1(char * filename); #define VERSION_NUMBER 1 #define SCORES_FILENAME "descent.hi"//"DESCENT.HI" @@ -307,8 +313,8 @@ char scores_filename[128]; #define XX (7) #define YY (-3) -#define LHX(x) ((x)*(hiresfont?FONTSCALE_X(2):FONTSCALE_X(1))) -#define LHY(y) ((y)*(hiresfont?FONTSCALE_Y(2.4):FONTSCALE_Y(1))) +#define LHX(x) ((x)*(hiresfont && SWIDTH>=640 && SHEIGHT>=480?FONTSCALE_X(2):FONTSCALE_X(1))) +#define LHY(y) ((y)*(hiresfont && SWIDTH>=640 && SHEIGHT>=480?FONTSCALE_Y(2.4):FONTSCALE_Y(1))) char * get_scores_filename() { @@ -576,6 +582,7 @@ void scores_view(int citem) int k; sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 }; grs_canvas canvas; + int w = LHX(290), h = LHY(170); #ifdef OGL gr_palette_load( gr_palette ); // ZICO - added to be sure right palette is loaded after endgame @@ -586,45 +593,10 @@ ReshowScores: set_screen_mode(SCREEN_MENU); - if (hiresfont) + if (hiresfont && SWIDTH>=640 && SHEIGHT>=480) gr_init_sub_canvas(&canvas, &grd_curscreen->sc_canvas, (SWIDTH - FONTSCALE_X(640))/2, (SHEIGHT - FONTSCALE_Y(480))/2, FONTSCALE_X(640), FONTSCALE_Y(480)); else gr_init_sub_canvas(&canvas, &grd_curscreen->sc_canvas, (SWIDTH - FONTSCALE_X(320))/2, (SHEIGHT - FONTSCALE_Y(200))/2, FONTSCALE_X(320), FONTSCALE_Y(200)); - gr_set_current_canvas(&canvas); - - nm_draw_background(0, 0, GWIDTH-1, GHEIGHT-1); - //nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h ); - - grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3]; - - gr_string( 0x8000, LHY(15), TXT_HIGH_SCORES ); - - grd_curcanv->cv_font = Gamefonts[GFONT_SMALL]; - - gr_set_fontcolor( BM_XRGB(31,26,5), -1 ); - gr_string( LHX(31+33+XX), LHY(46+7+YY), TXT_NAME ); - gr_string( LHX(82+33+XX), LHY(46+7+YY), TXT_SCORE ); - gr_string( LHX(127+33+XX), LHY(46+7+YY), TXT_SKILL ); - gr_string( LHX(170+33+XX), LHY(46+7+YY), TXT_LEVELS ); -// gr_string( 202, 46, "Kills" ); -// gr_string( 234, 46, "Rescues" ); - gr_string( LHX(288-42+XX), LHY(46+7+YY), TXT_TIME ); - - if ( citem < 0 ) - gr_string( 0x8000, LHY(175), TXT_PRESS_CTRL_R ); - - gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); - - gr_printf( 0x8000, LHY(31), "%c%s%c - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name ); - - for (i=0; icv_font = Gamefonts[GFONT_MEDIUM_3]; + + gr_string( 0x8000, LHY(15), TXT_HIGH_SCORES ); + + grd_curcanv->cv_font = Gamefonts[GFONT_SMALL]; + + gr_set_fontcolor( BM_XRGB(31,26,5), -1 ); + gr_string( LHX(31+33+XX), LHY(46+7+YY), TXT_NAME ); + gr_string( LHX(82+33+XX), LHY(46+7+YY), TXT_SCORE ); + gr_string( LHX(127+33+XX), LHY(46+7+YY), TXT_SKILL ); + gr_string( LHX(170+33+XX), LHY(46+7+YY), TXT_LEVELS ); + gr_string( LHX(288-42+XX), LHY(46+7+YY), TXT_TIME ); + + if ( citem < 0 ) + gr_string( 0x8000, LHY(175), TXT_PRESS_CTRL_R ); + + gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); + + gr_printf( 0x8000, LHY(31), "%c%s%c - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name ); + + for (i=0; i -1 ) { t1 = timer_get_fixed_seconds(); @@ -660,8 +669,8 @@ ReshowScores: if ( nm_messagebox( NULL, 2, TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 ) { remove( get_scores_filename() ); gr_palette_fade_out( gr_palette, 32, 0 ); - goto ReshowScores; } + goto ReshowScores; } break; case KEY_BACKSP: Int3(); k = 0; break; diff --git a/main/state.c b/main/state.c index 4d1469299..47547ca4a 100755 --- a/main/state.c +++ b/main/state.c @@ -258,13 +258,17 @@ int state_save_old_game(int slotnum, char * sg_name, player * sg_player, int sg_difficulty_level, int sg_primary_weapon, int sg_secondary_weapon, int sg_next_level_num ) { - int i; + int i,j; int temp_int; ubyte temp_byte; char desc[DESC_LENGTH+1]; char filename[128]; grs_canvas * cnv; FILE * fp; + ubyte *pal; +#ifdef OGL + GLint gl_draw_buffer; +#endif sprintf( filename, "%s.sg%d", sg_player->callsign, slotnum ); //added on 9/30/98 by Matt Mueller to fix savegames in linux @@ -286,34 +290,45 @@ int state_save_old_game(int slotnum, char * sg_name, player * sg_player, // Save the current screen shot... cnv = gr_create_canvas( THUMBNAIL_W, THUMBNAIL_H ); - if ( cnv ) { - char * pcx_file; - ubyte pcx_palette[768]; + if ( cnv ) + { +#ifdef OGL + ubyte *buf; + int k; +#endif + grs_canvas * cnv_save; + cnv_save = grd_curcanv; gr_set_current_canvas( cnv ); - gr_clear_canvas( BM_XRGB(0,0,0) ); - pcx_file = get_briefing_screen( sg_next_level_num ); - if ( pcx_file != NULL ) { - grs_bitmap bmp; - gr_init_bitmap_data (&bmp); - if (pcx_read_bitmap( pcx_file, &bmp, BM_LINEAR, pcx_palette )==PCX_ERROR_NONE) { - grs_point vertbuf[3]; - gr_clear_canvas( 255 ); - vertbuf[0].x = vertbuf[0].y = -F1_0*6; // -6 pixel rows for ascpect - vertbuf[1].x = vertbuf[1].y = 0; - vertbuf[2].x = i2f(THUMBNAIL_W); vertbuf[2].y = i2f(THUMBNAIL_H+7); // + 7 pixel rows for ascpect - scale_bitmap(&bmp, vertbuf ); - gr_remap_bitmap_good( &cnv->cv_bitmap, pcx_palette, -1, -1 ); - } - gr_free_bitmap_data( &bmp ); + render_frame(0); + +#ifdef OGL + buf = malloc(THUMBNAIL_W * THUMBNAIL_H * 3); + glGetIntegerv(GL_DRAW_BUFFER, &gl_draw_buffer); + glReadBuffer(gl_draw_buffer); + glReadPixels(0, SHEIGHT - THUMBNAIL_H, THUMBNAIL_W, THUMBNAIL_H, GL_RGB, GL_UNSIGNED_BYTE, buf); + k = THUMBNAIL_H; + for (i = 0; i < THUMBNAIL_W * THUMBNAIL_H; i++) { + if (!(j = i % THUMBNAIL_W)) + k--; + cnv->cv_bitmap.bm_data[THUMBNAIL_W * k + j] = + gr_find_closest_color(buf[3*i]/4, buf[3*i+1]/4, buf[3*i+2]/4); } - fwrite( cnv->cv_bitmap.bm_data, THUMBNAIL_W*THUMBNAIL_H, 1, fp ); + free(buf); +#endif + pal = gr_palette; + + fwrite(cnv->cv_bitmap.bm_data, THUMBNAIL_W * THUMBNAIL_H, 1, fp); + + gr_set_current_canvas(cnv_save); gr_free_canvas( cnv ); - } else { + } + else + { ubyte color = 0; for ( i=0; icv_bitmap, pcx_palette, -1, -1 ); - } - gr_free_bitmap_data (&bmp); - free(pcx_file); - } - } else { - render_frame(0); + if ( cnv ) + { #ifdef OGL - ogl_ubitblt_tolinear(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, 0, 0, 0, 0, &grd_curscreen->sc_canvas.cv_bitmap, &grd_curcanv->cv_bitmap); + ubyte *buf; + int k; #endif + grs_canvas * cnv_save; + cnv_save = grd_curcanv; + + gr_set_current_canvas( cnv ); + + render_frame(0); + +#ifdef OGL + buf = malloc(THUMBNAIL_W * THUMBNAIL_H * 3); + glGetIntegerv(GL_DRAW_BUFFER, &gl_draw_buffer); + glReadBuffer(gl_draw_buffer); + glReadPixels(0, SHEIGHT - THUMBNAIL_H, THUMBNAIL_W, THUMBNAIL_H, GL_RGB, GL_UNSIGNED_BYTE, buf); + k = THUMBNAIL_H; + for (i = 0; i < THUMBNAIL_W * THUMBNAIL_H; i++) { + if (!(j = i % THUMBNAIL_W)) + k--; + cnv->cv_bitmap.bm_data[THUMBNAIL_W * k + j] = + gr_find_closest_color(buf[3*i]/4, buf[3*i+1]/4, buf[3*i+2]/4); } - fwrite( cnv->cv_bitmap.bm_data, THUMBNAIL_W*THUMBNAIL_H, 1, fp ); + free(buf); +#endif + pal = gr_palette; + + fwrite(cnv->cv_bitmap.bm_data, THUMBNAIL_W * THUMBNAIL_H, 1, fp); + + gr_set_current_canvas(cnv_save); gr_free_canvas( cnv ); - } else { + } + else + { ubyte color = 0; for ( i=0; i 2 || gr_palette_fade_in( New_pal, 32, allow_keys ) || allow_keys > 1) { @@ -331,6 +334,15 @@ void show_bitmap_frame(void) // Only plot every nth frame. if (Door_div_count) { +#ifdef OGL + if (Bitmap_name[0] != 0) { + bitmap_index bi; + bi = piggy_find_bitmap(Bitmap_name); + bitmap_ptr = &GameBitmaps[bi.index]; + PIGGY_PAGE_IN( bi ); + ogl_ubitmapm_cs(rescale_x(220), rescale_y(45),(bitmap_ptr->bm_w*(SWIDTH/320)),(bitmap_ptr->bm_h*(SHEIGHT/200)),bitmap_ptr,255,F1_0); + } +#endif Door_div_count--; return; } @@ -349,10 +361,10 @@ void show_bitmap_frame(void) New_pal[254*3+2] = 0; } - switch (Animating_bitmap_type) { - case 0: bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 64, 64); break; - case 1: bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 94, 94); break; // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size. - default: Int3(); // Impossible, illegal value for Animating_bitmap_type + switch (Animating_bitmap_type) { + case 0: bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 64, 64); break; + case 1: bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_y(45), 94, 94); break; // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size. + default: Int3(); // Impossible, illegal value for Animating_bitmap_type } curcanv_save = grd_curcanv; @@ -429,14 +441,12 @@ void show_bitmap_frame(void) void show_briefing_bitmap(grs_bitmap *bmp) { grs_canvas *curcanv_save, *bitmap_canv; - if (!(Briefing_screens_LH == Briefing_screens_h)) { - bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220*((double)SWIDTH/320), 45*((double)SHEIGHT/200), 166, 138); - curcanv_save = grd_curcanv; - grd_curcanv = bitmap_canv; - gr_bitmapm(0, 0, bmp); - grd_curcanv = curcanv_save; - free(bitmap_canv); - } + bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220*((double)SWIDTH/320), 45*((double)SHEIGHT/200), 166, 138); + curcanv_save = grd_curcanv; + grd_curcanv = bitmap_canv; + gr_bitmapm(0, 0, bmp); + grd_curcanv = curcanv_save; + free(bitmap_canv); } // ----------------------------------------------------------------------------- @@ -633,6 +643,31 @@ void flash_cursor(int cursor_flag) } +#ifdef OGL +typedef struct msgstream { + int x; + int y; + int color; + int ch; +} __pack__ msgstream; + +msgstream messagestream[2048]; + +void redraw_messagestream(int count) +{ + char msgbuf[2]; + int i; + + for (i=0; itext_ulx); int text_uly = rescale_y(bsp->text_uly); + grs_bitmap guy_bitmap; +#ifdef OGL + int streamcount=0, guy_bitmap_show=0; + grs_bitmap briefing_bm; + + gr_init_bitmap_data (&briefing_bm); + pcx_read_bitmap( Briefing_screens_LH[screen_num].bs_name, &briefing_bm, BM_LINEAR, gr_palette ); +#endif Bitmap_name[0] = 0; @@ -699,21 +742,25 @@ int show_briefing_message(int screen_num, char *message) prev_ch = 10; } else if (ch == 'B') { char bitmap_name[32]; - grs_bitmap guy_bitmap; ubyte temp_palette[768]; int iff_error; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} - get_message_name(&message, bitmap_name); - strcat(bitmap_name, ".bbm"); - gr_init_bitmap_data (&guy_bitmap); - iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette); - Assert(iff_error == IFF_NO_ERROR); - - show_briefing_bitmap(&guy_bitmap); - gr_free_bitmap_data (&guy_bitmap); + get_message_name(&message, bitmap_name); + strcat(bitmap_name, ".bbm"); + if (Briefing_screens_LH != Briefing_screens_h) { + gr_init_bitmap_data (&guy_bitmap); + iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette); + Assert(iff_error == IFF_NO_ERROR); + show_briefing_bitmap(&guy_bitmap); +#ifndef OGL + gr_free_bitmap_data (&guy_bitmap); +#else + guy_bitmap_show=1; +#endif + } prev_ch = 10; } else if (ch == 'S') { int keypress; @@ -735,6 +782,15 @@ int show_briefing_message(int screen_num, char *message) } while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; + d_delay(5); +#ifdef OGL + ogl_swap_buffers(); + gr_clear_canvas(255); + ogl_ubitmapm_cs(0,0,-1,-1,&briefing_bm,-1,F1_0); + redraw_messagestream(streamcount); + if (guy_bitmap_show) + show_briefing_bitmap(&guy_bitmap); +#endif flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); @@ -756,6 +812,7 @@ int show_briefing_message(int screen_num, char *message) flashing_cursor = 0; done = 1; } else if (ch == 'P') { // New page. + new_page = 1; while (*message != 10) { message++; // drop carriage return after special escape sequence @@ -783,7 +840,9 @@ int show_briefing_message(int screen_num, char *message) Briefing_text_y += FONTSCALE_Y(GAME_FONT->ft_h)+FONTSCALE_Y(GAME_FONT->ft_h)*3/5; Briefing_text_x = text_ulx; if (Briefing_text_y > text_uly + rescale_y(bsp->text_height)) { +#ifndef OGL load_briefing_screen(screen_num); +#endif Briefing_text_x = text_ulx; Briefing_text_y = text_uly; } @@ -793,8 +852,26 @@ int show_briefing_message(int screen_num, char *message) prev_ch = ch; } } else { +#ifdef OGL + messagestream[streamcount].x = Briefing_text_x; + messagestream[streamcount].y = Briefing_text_y; + messagestream[streamcount].color = Briefing_foreground_colors[Current_color]; + messagestream[streamcount].ch = ch; + if (delay_count) { + ogl_swap_buffers(); + gr_clear_canvas(255); + ogl_ubitmapm_cs(0,0,-1,-1,&briefing_bm,-1,F1_0); + redraw_messagestream(streamcount); + if (flashing_cursor) + gr_printf(Briefing_text_x + FONTSCALE_X(GAME_FONT->ft_w),Briefing_text_y,"_"); + } + if (guy_bitmap_show) + show_briefing_bitmap(&guy_bitmap); + streamcount++; +#endif prev_ch = ch; Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor); + } // added/changed on 9/13/98 by adb to speed up briefings after pressing a key with SDL @@ -840,6 +917,15 @@ int show_briefing_message(int screen_num, char *message) } while (timer_get_approx_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; + d_delay(15); +#ifdef OGL + ogl_swap_buffers(); + gr_clear_canvas(255); + ogl_ubitmapm_cs(0,0,-1,-1,&briefing_bm,-1,F1_0); + redraw_messagestream(streamcount); + if (guy_bitmap_show) + show_briefing_bitmap(&guy_bitmap); +#endif flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); @@ -865,10 +951,23 @@ int show_briefing_message(int screen_num, char *message) load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; +#ifdef OGL + streamcount=0; + if (guy_bitmap_show) { + gr_free_bitmap_data (&guy_bitmap); + guy_bitmap_show=0; + } +#endif delay_count = KEY_DELAY_DEFAULT; } } + +#ifdef OGL + gr_free_bitmap_data (&briefing_bm); + gr_use_palette_table( "palette.256" ); +#endif + if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} @@ -1008,9 +1107,7 @@ int show_briefing_screen( int screen_num, int allow_keys) gr_palette_clear(); #endif - show_fullscr(&briefing_bm ); - //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb