- to get it running on other compilers, I removed all references to

iostream, vector, and the use of templates.  Now the vector of bitmaps
  is an array of pointers to bitmaps and a count.
This commit is contained in:
Bryce Denney 2002-03-06 20:36:35 +00:00
parent efd408f386
commit 55b12f615c

View File

@ -1,8 +1,5 @@
#define _MULTI_THREAD
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_endian.h>
@ -26,6 +23,7 @@ void we_are_here(void)
static unsigned prev_cursor_x=0;
static unsigned prev_cursor_y=0;
#define MAX_SDL_BITMAPS 10
struct bitmaps {
SDL_Surface *surface;
SDL_Rect src,dst;
@ -50,7 +48,8 @@ Uint32 headerbar_fg, headerbar_bg;
Bit8u old_mousebuttons=0, new_mousebuttons=0;
int old_mousex=0, new_mousex=0;
int old_mousey=0, new_mousey=0;
vector<bitmaps> sdl_bitmaps;
bitmaps *sdl_bitmaps[MAX_SDL_BITMAPS];
int n_sdl_bitmaps = 0;
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SWAP16(X) (X)
@ -609,6 +608,11 @@ unsigned bx_gui_c::create_bitmap(
Uint32 disp;
unsigned char pixels;
if (n_sdl_bitmaps >= MAX_SDL_BITMAPS) {
BX_PANIC (("too many SDL bitmaps. To fix, increase MAX_SDL_BITMAPS"));
return 0;
}
tmp->surface = SDL_CreateRGBSurface(
SDL_SWSURFACE,
xdim,
@ -667,8 +671,8 @@ unsigned bx_gui_c::create_bitmap(
0, 0,
tmp->src.w,
tmp->src.h );
sdl_bitmaps.push_back(*tmp);
return sdl_bitmaps.size()-1;
sdl_bitmaps[n_sdl_bitmaps] = tmp;
return n_sdl_bitmaps++;
}
@ -677,24 +681,24 @@ unsigned bx_gui_c::headerbar_bitmap(
unsigned alignment,
void (*f)(void))
{
if( bmap_id >= sdl_bitmaps.size() ) return 0;
if( bmap_id >= n_sdl_bitmaps ) return 0;
sdl_bitmaps[bmap_id].dst.x = headerbar_offset;
headerbar_offset + sdl_bitmaps[bmap_id].src.w;
sdl_bitmaps[bmap_id].cb = f;
sdl_bitmaps[bmap_id]->dst.x = headerbar_offset;
headerbar_offset += sdl_bitmaps[bmap_id]->src.w;
sdl_bitmaps[bmap_id]->cb = f;
if( sdl_screen )
{
SDL_BlitSurface(
sdl_bitmaps[bmap_id].surface,
&sdl_bitmaps[bmap_id].src,
sdl_bitmaps[bmap_id]->surface,
&sdl_bitmaps[bmap_id]->src,
sdl_screen,
&sdl_bitmaps[bmap_id].dst);
&sdl_bitmaps[bmap_id]->dst);
SDL_UpdateRect(
sdl_screen,
sdl_bitmaps[bmap_id].dst.x,
sdl_bitmaps[bmap_id].dst.y,
sdl_bitmaps[bmap_id].src.w,
sdl_bitmaps[bmap_id].src.h);
sdl_bitmaps[bmap_id]->dst.x,
sdl_bitmaps[bmap_id]->dst.y,
sdl_bitmaps[bmap_id]->src.w,
sdl_bitmaps[bmap_id]->src.h);
}
return bmap_id;
}
@ -704,10 +708,10 @@ void bx_gui_c::replace_bitmap(
unsigned hbar_id,
unsigned bmap_id)
{
sdl_bitmaps[bmap_id].dst.x = sdl_bitmaps[hbar_id].dst.x;
sdl_bitmaps[bmap_id].cb = sdl_bitmaps[hbar_id].cb;
sdl_bitmaps[hbar_id].dst.x = -1;
sdl_bitmaps[hbar_id].cb = NULL;
sdl_bitmaps[bmap_id]->dst.x = sdl_bitmaps[hbar_id]->dst.x;
sdl_bitmaps[bmap_id]->cb = sdl_bitmaps[hbar_id]->cb;
sdl_bitmaps[hbar_id]->dst.x = -1;
sdl_bitmaps[hbar_id]->cb = NULL;
}
@ -718,7 +722,7 @@ void bx_gui_c::show_headerbar(void)
Uint32 disp;
int rowsleft = headerbar_height;
int colsleft;
int bitmapscount = sdl_bitmaps.size();
int bitmapscount = n_sdl_bitmaps;
if( !sdl_screen ) return;
disp = sdl_screen->pitch/4;
@ -741,19 +745,19 @@ void bx_gui_c::show_headerbar(void)
// go thru the bitmaps and display the active ones
while( bitmapscount-- )
{
if( sdl_bitmaps[bitmapscount].dst.x != -1 )
if( sdl_bitmaps[bitmapscount]->dst.x != -1 )
{
SDL_BlitSurface(
sdl_bitmaps[bitmapscount].surface,
&sdl_bitmaps[bitmapscount].src,
sdl_bitmaps[bitmapscount]->surface,
&sdl_bitmaps[bitmapscount]->src,
sdl_screen,
&sdl_bitmaps[bitmapscount].dst);
&sdl_bitmaps[bitmapscount]->dst);
SDL_UpdateRect(
sdl_screen,
sdl_bitmaps[bitmapscount].dst.x,
sdl_bitmaps[bitmapscount].dst.y,
sdl_bitmaps[bitmapscount].src.w,
sdl_bitmaps[bitmapscount].src.h );
sdl_bitmaps[bitmapscount]->dst.x,
sdl_bitmaps[bitmapscount]->dst.y,
sdl_bitmaps[bitmapscount]->src.w,
sdl_bitmaps[bitmapscount]->src.h );
}
}
}
@ -761,7 +765,7 @@ void bx_gui_c::show_headerbar(void)
void bx_gui_c::mouse_enabled_changed_specific (Boolean val)
{
cout << "sdl: mouse enabled changed specific" <<endl;
BX_INFO (("mouse enabled changed specific"));
}
@ -771,10 +775,10 @@ void bx_gui_c::exit(void)
SDL_FreeSurface(sdl_screen);
if( sdl_fullscreen )
SDL_FreeSurface(sdl_fullscreen);
while( sdl_bitmaps.size() )
while( n_sdl_bitmaps )
{
SDL_FreeSurface( sdl_bitmaps[sdl_bitmaps.size()-1].surface );
sdl_bitmaps.pop_back();
SDL_FreeSurface( sdl_bitmaps[n_sdl_bitmaps-1]->surface );
n_sdl_bitmaps--;
}
}