Added some missing 24bpp functions.
This commit is contained in:
parent
831b76ed1d
commit
57fb0e23c9
4 changed files with 233 additions and 1 deletions
src/video
|
@ -837,6 +837,8 @@ global VMemType* VideoCreateNewPalette(const Palette *palette)
|
|||
pixels=malloc(256*sizeof(VMemType16));
|
||||
break;
|
||||
case 24:
|
||||
// pixels=malloc(256*sizeof(VMemType24));
|
||||
// break;
|
||||
case 32:
|
||||
pixels=malloc(256*sizeof(VMemType32));
|
||||
break;
|
||||
|
@ -896,7 +898,7 @@ global VMemType* VideoCreateNewPalette(const Palette *palette)
|
|||
((VMemType16*)pixels)[i]=color.pixel;
|
||||
break;
|
||||
case 24:
|
||||
//((VMemType32*)pixels)[i]=color.pixel;
|
||||
//((VMemType24*)pixels)[i]=color.pixel;
|
||||
//break;
|
||||
// FIXME: real 24bpp mode.
|
||||
case 32:
|
||||
|
|
|
@ -220,6 +220,61 @@ local void VideoDrawChar16(const Graphic* sprite,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw character with current color into 24bit video memory.
|
||||
**
|
||||
** @param sprite Pointer to object
|
||||
** @param gx X offset into object
|
||||
** @param gy Y offset into object
|
||||
** @param w width to display
|
||||
** @param h height to display
|
||||
** @param x X screen position
|
||||
** @param y Y screen position
|
||||
*/
|
||||
local void VideoDrawChar24(const Graphic* sprite,
|
||||
int gx,int gy,int w,int h,int x,int y)
|
||||
{
|
||||
int p;
|
||||
const unsigned char* sp;
|
||||
const unsigned char* lp;
|
||||
const unsigned char* gp;
|
||||
int sa;
|
||||
VMemType24* dp;
|
||||
int da;
|
||||
|
||||
sp=sprite->Frames+gx+gy*sprite->Width-1;
|
||||
gp=sp+sprite->Width*h;
|
||||
sa=sprite->Width-w;
|
||||
dp=VideoMemory24+x+y*VideoWidth-1;
|
||||
da=VideoWidth-w;
|
||||
--w;
|
||||
|
||||
while( sp<gp ) {
|
||||
lp=sp+w;
|
||||
while( sp<lp ) { // loop with unroll
|
||||
++dp;
|
||||
p=*++sp;
|
||||
if( p!=255 ) {
|
||||
*dp=Pixels24[TextColor[p]];
|
||||
}
|
||||
++dp;
|
||||
p=*++sp;
|
||||
if( p!=255 ) {
|
||||
*dp=Pixels24[TextColor[p]];
|
||||
}
|
||||
}
|
||||
if( sp<=lp ) {
|
||||
++dp;
|
||||
p=*++sp;
|
||||
if( p!=255 ) {
|
||||
*dp=Pixels24[TextColor[p]];
|
||||
}
|
||||
}
|
||||
sp+=sa;
|
||||
dp+=da;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw character with current color into 32bit video memory.
|
||||
**
|
||||
|
@ -553,6 +608,9 @@ global void LoadFonts(void)
|
|||
break;
|
||||
|
||||
case 24:
|
||||
VideoDrawChar=VideoDrawChar24;
|
||||
// FIXME: real 24bpp break;
|
||||
|
||||
case 32:
|
||||
VideoDrawChar=VideoDrawChar32;
|
||||
break;
|
||||
|
|
|
@ -136,6 +136,18 @@ local void DrawPixel16(SysColors color,int x,int y)
|
|||
VideoMemory16[x+y*VideoWidth]=Pixels16[color];
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw pixel unclipped into 24bit framebuffer.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
local void DrawPixel24(SysColors color,int x,int y)
|
||||
{
|
||||
VideoMemory24[x+y*VideoWidth]=Pixels24[color];
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw pixel unclipped into 32bit framebuffer.
|
||||
**
|
||||
|
@ -180,6 +192,22 @@ local void DrawPixelClip16(SysColors color,int x,int y)
|
|||
VideoMemory16[x+y*VideoWidth]=Pixels16[color];
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw pixel clipped to current clip setting into 24bit framebuffer.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
*/
|
||||
local void DrawPixelClip24(SysColors color,int x,int y)
|
||||
{
|
||||
// Clipping:
|
||||
if( x<ClipX1 || x>=ClipX2 || y<ClipY1 || y>=ClipY2 ) {
|
||||
return;
|
||||
}
|
||||
VideoMemory24[x+y*VideoWidth]=Pixels24[color];
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw pixel clipped to current clip setting into 32bit framebuffer.
|
||||
**
|
||||
|
@ -250,6 +278,31 @@ local void DrawHLine16(SysColors color,int x,int y,unsigned width)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw horizontal line unclipped into 24bit framebuffer.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param width width of line.
|
||||
*/
|
||||
local void DrawHLine24(SysColors color,int x,int y,unsigned width)
|
||||
{
|
||||
VMemType24* p;
|
||||
VMemType24* e;
|
||||
int w;
|
||||
VMemType24 f;
|
||||
|
||||
w=VideoWidth;
|
||||
p=VideoMemory24+y*w+x;
|
||||
e=p+width;
|
||||
f=Pixels24[color];
|
||||
|
||||
while( p<e ) {
|
||||
*p++=f;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw horizontal line unclipped into 32bit framebuffer.
|
||||
**
|
||||
|
@ -341,6 +394,38 @@ local void DrawHLineClip16(SysColors color,int x,int y,unsigned width)
|
|||
DrawHLine16(color,x,y,width);
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw horizontal line clipped into 24bit framebuffer.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param width width of line.
|
||||
*/
|
||||
local void DrawHLineClip24(SysColors color,int x,int y,unsigned width)
|
||||
{
|
||||
int f;
|
||||
|
||||
if( y<ClipY1 || y>=ClipY2 ) { // Clipping:
|
||||
return;
|
||||
}
|
||||
if( x<ClipX1 ) {
|
||||
f=ClipX1-x;
|
||||
x=ClipX1;
|
||||
if( width<f ) {
|
||||
return;
|
||||
}
|
||||
width-=f;
|
||||
}
|
||||
if( (x+width)>ClipX2 ) {
|
||||
if( width<ClipX2-x ) {
|
||||
return;
|
||||
}
|
||||
width=ClipX2-x;
|
||||
}
|
||||
|
||||
DrawHLine24(color,x,y,width);
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw horizontal line clipped into 32bit framebuffer.
|
||||
|
@ -425,6 +510,31 @@ local void DrawVLine16(SysColors color,int x,int y,unsigned height)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw vertical line unclipped into 24bit framebuffer.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param height height of line.
|
||||
*/
|
||||
local void DrawVLine24(SysColors color,int x,int y,unsigned height)
|
||||
{
|
||||
VMemType24* p;
|
||||
VMemType24* e;
|
||||
int w;
|
||||
VMemType24 f;
|
||||
|
||||
w=VideoWidth;
|
||||
p=VideoMemory24+y*w+x;
|
||||
e=p+height*w;
|
||||
f=Pixels24[color];
|
||||
while( p<e ) { // FIXME: better
|
||||
*p=f;
|
||||
p+=w;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw vertical line unclipped into 32bit framebuffer.
|
||||
**
|
||||
|
@ -540,6 +650,53 @@ local void DrawVLineClip16(SysColors color,int x,int y,unsigned height)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw vertical line clipped into 24bit framebuffer.
|
||||
**
|
||||
** @param color Color index.
|
||||
** @param x x coordinate on the screen
|
||||
** @param y y coordinate on the screen
|
||||
** @param height height of line.
|
||||
*/
|
||||
local void DrawVLineClip24(SysColors color,int x,int y,unsigned height)
|
||||
{
|
||||
VMemType24* p;
|
||||
VMemType24* e;
|
||||
int w;
|
||||
int t;
|
||||
VMemType24 f;
|
||||
|
||||
// Clipping:
|
||||
if( x<ClipX1 || x>=ClipX2 ) {
|
||||
return;
|
||||
}
|
||||
if( y<ClipY1 ) {
|
||||
t=ClipY1-y;
|
||||
y=ClipY1;
|
||||
if( height<t ) {
|
||||
return;
|
||||
}
|
||||
height-=t;
|
||||
}
|
||||
if( (y+height)>ClipY2 ) {
|
||||
if( height<ClipY2-y ) {
|
||||
return;
|
||||
}
|
||||
height=ClipY2-y;
|
||||
}
|
||||
if( height>640 )
|
||||
abort();
|
||||
|
||||
w=VideoWidth;
|
||||
p=VideoMemory24+y*w+x;
|
||||
e=p+height*w;
|
||||
f=Pixels24[color];
|
||||
while( p<e ) {
|
||||
*p=f;
|
||||
p+=w;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw vertical line clipped into 32bit framebuffer.
|
||||
**
|
||||
|
@ -651,6 +808,14 @@ global void InitLineDraw(void)
|
|||
break;
|
||||
|
||||
case 24:
|
||||
VideoDrawPixel=DrawPixel24;
|
||||
VideoDrawPixelClip=DrawPixelClip24;
|
||||
VideoDrawHLine=DrawHLine24;
|
||||
VideoDrawHLineClip=DrawHLineClip24;
|
||||
VideoDrawVLine=DrawVLine24;
|
||||
VideoDrawVLineClip=DrawVLineClip24;
|
||||
// FIXME: real 24bpp break;
|
||||
|
||||
case 32:
|
||||
VideoDrawPixel=DrawPixel32;
|
||||
VideoDrawPixelClip=DrawPixelClip32;
|
||||
|
|
|
@ -591,6 +591,8 @@ global VMemType* VideoCreateNewPalette(const Palette *palette)
|
|||
pixels=malloc(256*sizeof(VMemType16));
|
||||
break;
|
||||
case 24:
|
||||
//pixels=malloc(256*sizeof(VMemType24));
|
||||
//break;
|
||||
case 32:
|
||||
pixels=malloc(256*sizeof(VMemType32));
|
||||
break;
|
||||
|
@ -639,6 +641,11 @@ global VMemType* VideoCreateNewPalette(const Palette *palette)
|
|||
((VMemType16*)pixels)[i]=SDL_MapRGB(Screen->format,r,g,b);
|
||||
break;
|
||||
case 24:
|
||||
v=SDL_MapRGB(Screen->format,r,g,b);
|
||||
((VMemType24*)pixels)[i].a=v>>16;
|
||||
((VMemType24*)pixels)[i].b=v>> 8;
|
||||
((VMemType24*)pixels)[i].c=v>> 0;
|
||||
//break;
|
||||
case 32:
|
||||
((VMemType32*)pixels)[i]=SDL_MapRGB(Screen->format,r,g,b);
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue