From 2fc24406a56f2d8f27f0695ba5e3097f2cf95db1 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 2 Oct 2001 02:46:00 -0400 Subject: [PATCH] Update to support 32bpp display version 2.9.14a --- svmwgraph/sdl_svmwgraph.c | 102 +++++++++++++++++++++++++++++++++++++- svmwgraph/sdl_svmwgraph.h | 2 + svmwgraph/vmw_setup.c | 18 ++++++- 3 files changed, 120 insertions(+), 2 deletions(-) diff --git a/svmwgraph/sdl_svmwgraph.c b/svmwgraph/sdl_svmwgraph.c index 6613a03..2f10908 100644 --- a/svmwgraph/sdl_svmwgraph.c +++ b/svmwgraph/sdl_svmwgraph.c @@ -82,6 +82,106 @@ void SDL_flushPalette(vmwSVMWGraphState *state) { } } +void SDL_NoScale32bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) { + + int x,y,color; + + unsigned char *s_pointer,*t_pointer; + + SDL_Surface *target; + + target=(SDL_Surface *)target_p->output_screen; + + if ( SDL_MUSTLOCK(target) ) { + if ( SDL_LockSurface(target) < 0 ) + return; + } + + s_pointer=source->memory; + t_pointer=((Uint8 *)target->pixels); + +// printf("%i %i\n",source->xsize,source->ysize); + + for (x=0;xxsize;x++) + for (y=0;yysize;y++) { + + color=( (target_p->actual_pal[*(s_pointer)].r<<24)+ + (target_p->actual_pal[*(s_pointer)].g<<16)+ + (target_p->actual_pal[*(s_pointer)].b<<8)+ + 255); + + *((Uint32 *)(t_pointer))=color; + s_pointer++; t_pointer+=4; + } + + + /* Update the display */ + if ( SDL_MUSTLOCK(target) ) { + SDL_UnlockSurface(target); + } + + /* Write this out to the screen */ + SDL_UpdateRect(target, 0, 0, source->xsize, source->ysize); + +} + + /* I should make this generic, but it makes it really slow */ +void SDL_Double32bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) { + + int x,y,scale,color; + + unsigned char *s_pointer,*t_pointer; + + SDL_Surface *target; + + target=(SDL_Surface *)target_p->output_screen; + + scale=target_p->scale; + + if ( SDL_MUSTLOCK(target) ) { + if ( SDL_LockSurface(target) < 0 ) + return; + } + + s_pointer=source->memory; + t_pointer=((Uint8 *)target->pixels); + + for (y=0;yysize;y++) { + for (x=0;xxsize;x++) { + + color=( (target_p->actual_pal[*(s_pointer)].r<<24)+ + (target_p->actual_pal[*(s_pointer)].g<<16)+ + (target_p->actual_pal[*(s_pointer)].b<<8)+ + 255); + + /* i=0, j=0 */ + *((Uint16 *) ( (t_pointer)))=color; + + /* i=1, j=0 */ + *((Uint16 *) ( (t_pointer+(2*target_p->xsize) )))=color; + + /* i=0, j=1 */ + *((Uint16 *) ( (t_pointer+2) ))=color; + + /* i=1 j=1 */ + *((Uint16 *) ( (t_pointer+2+(2*target_p->xsize) )))=color; + + + s_pointer++; t_pointer+=4; + } + t_pointer+=2*target_p->xsize; + } + + + /* Update the display */ + if ( SDL_MUSTLOCK(target) ) { + SDL_UnlockSurface(target); + } + + /* Write this out to the screen */ + SDL_UpdateRect(target, 0, 0, target_p->xsize, target_p->ysize); + +} void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) { @@ -162,7 +262,7 @@ void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source) { s_pointer++; t_pointer+=4; } - t_pointer+=2*target_p->xsize; + t_pointer+=4*target_p->xsize; } diff --git a/svmwgraph/sdl_svmwgraph.h b/svmwgraph/sdl_svmwgraph.h index 1e45cb4..fe664e9 100644 --- a/svmwgraph/sdl_svmwgraph.h +++ b/svmwgraph/sdl_svmwgraph.h @@ -3,6 +3,8 @@ void *SDL_setupGraphics(int *xsize,int *ysize,int *bpp,int fullscreen, int verbose); void SDL_flushPalette(vmwSVMWGraphState *state); +void SDL_NoScale32bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source); +void SDL_Double32bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source); void SDL_NoScale16bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source); void SDL_Double16bpp_BlitMem(vmwSVMWGraphState *target_p, vmwVisual *source); void SDL_NoScale8bpp_BlitMem(vmwSVMWGraphState *target, vmwVisual *source); diff --git a/svmwgraph/vmw_setup.c b/svmwgraph/vmw_setup.c index d2d630c..b3d1ec6 100644 --- a/svmwgraph/vmw_setup.c +++ b/svmwgraph/vmw_setup.c @@ -112,13 +112,29 @@ vmwSVMWGraphState *vmwSetupSVMWGraph(int display_type,int xsize,int ysize, vmwBlitMemToDisplay=SDL_Double8bpp_BlitMem; } } - if (temp_state->bpp>=16) { + if (temp_state->bpp==16) { if (scale==1) { vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem; } else { vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem; } } + if (temp_state->bpp==24) { + printf("ERROR! 24bpp not supported!\n"); + if (scale==1) { + vmwBlitMemToDisplay=SDL_NoScale16bpp_BlitMem; + } else { + vmwBlitMemToDisplay=SDL_Double16bpp_BlitMem; + } + } + + if (temp_state->bpp>=32) { + if (scale==1) { + vmwBlitMemToDisplay=SDL_NoScale32bpp_BlitMem; + } else { + vmwBlitMemToDisplay=SDL_Double32bpp_BlitMem; + } + } vmwFlushPalette=SDL_flushPalette; vmwClearKeyboardBuffer=SDL_clearKeyboardBuffer; vmwGetInput=SDL_getInput;