[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video cursor.c font.c graphic.c l...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src/video cursor.c font.c graphic.c l... |
Date: |
Thu, 15 Jan 2004 02:45:29 -0000 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/15 13:14:09
Modified files:
src/video : cursor.c font.c graphic.c linedraw.c png.c
sdl.c sprite.c video.c
Log message:
USE_SDL_SURFACE is default
Patches:
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.92 stratagus/src/video/cursor.c:1.93
--- stratagus/src/video/cursor.c:1.92 Thu Jan 15 10:48:44 2004
+++ stratagus/src/video/cursor.c Thu Jan 15 13:14:07 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: cursor.c,v 1.92 2004/01/14 23:48:44 jsalmon3 Exp $
+// $Id: cursor.c,v 1.93 2004/01/15 02:14:07 jsalmon3 Exp $
//@{
@@ -127,11 +127,7 @@
/// Memory re-use, so can be defined although no save present!
local int OldCursorSize; /// size of saved cursor image
-#ifdef USE_SDL_SURFACE
local SDL_Surface* OldCursorImage; /// background
saved behind cursor
-#else
-local void* OldCursorImage; /// background saved
behind cursor
-#endif
/**
** Function pointer: Save 2D image behind sprite cursor
@@ -145,7 +141,6 @@
** non-empty
** (x >= 0, y >= 0, w > 0, h > 0, (x + w - 1) <= VideoWidth, (y +
h - 1) <= VideoHeight)
*/
-#ifdef USE_SDL_SURFACE
#ifndef USE_OPENGL
local void SaveCursorBackground(int x, int y, int w, int h);
/// Function pointer: Load background behind cursor
@@ -155,12 +150,6 @@
#define SaveCursorBackground(x, y, w, h) // nothing
#endif
-#else
-local void (*SaveCursorBackground)(int x, int y, int w, int h);
- /// Function pointer: Load background behind cursor
-local void (*LoadCursorBackground)(int x, int y, int w, int h);
-#endif
-
/*--- DRAW RECTANGLE CURSOR ------------------------------------------------*/
// Saved area after draw rectangle, needed later to hide it
again
// (OldCursorRectangleW != 0 denotes it's defined)
@@ -192,11 +181,7 @@
** (x >= 0, y >= 0, w > 0, h > 0, (x + w - 1) <= VideoWidth, (y + h - 1)
<= VideoHeight)
*/
#ifndef USE_OPENGL
-#ifdef USE_SDL_SURFACE
global void SaveCursorRectangle(void* buffer, int x, int y, int w, int h);
-#else
-global void (*SaveCursorRectangle)(void* buffer, int x, int y, int w, int h);
-#endif
#endif
/**
@@ -211,11 +196,7 @@
** @note rectangle previously saved with
SaveCursorRectangle(x,y,w,h)
*/
#ifndef USE_OPENGL
-#ifdef USE_SDL_SURFACE
global void LoadCursorRectangle(void* buffer, int x, int y, int w, int h);
-#else
-global void (*LoadCursorRectangle)(void* buffer, int x, int y, int w, int h);
-#endif
#endif
/*----------------------------------------------------------------------------
@@ -293,7 +274,6 @@
-- DRAW RECTANGLE CURSOR
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
#ifndef USE_OPENGL
global void LoadCursorRectangle(void* buffer, int x, int y, int w, int h)
{
@@ -356,139 +336,6 @@
VideoUnlockScreen();
}
#endif
-#else
-/**
-** Puts stored 'image' from SAVECURSORRECTANGLE back on the screen.
-** Note w and h are both > 0
-**
-** FIXME: this kind of macros are hard to single step with gdb.
-** FIXME: inline functions should have the same speed and are
debugable.
-*/
-#define LOADCURSORRECTANGLE(buffer, video, memtype, x, y, w, h) { \
- const memtype* sp; \
- memtype* dp; \
- sp = (memtype*)buffer; \
- dp = video + y * VideoWidth + x; \
- memcpy(dp, sp, w * sizeof(memtype)); \
- if (--h) { \
- sp += w; \
- dp += VideoWidth; \
- while (--h) { \
- *dp = *sp++; \
- dp[w - 1] = *sp++; \
- dp += VideoWidth; \
- } \
- memcpy(dp, sp, w * sizeof(memtype)); \
- } \
-}
-
-/**
-** Saves 'image' of screen overlapped by rectangle cursor, to be
able to
-** restore it later using LOADCURSORRECTANGLE.
-** Note w and h > 0
-**
-** FIXME: this kind of macros are hard to single step with gdb.
-** FIXME: inline functions should have the same speed and are
debugable.
-*/
-#define SAVECURSORRECTANGLE(buffer, video, memtype, x, y, w, h) { \
- const memtype* sp; \
- memtype* dp; \
- sp = video + y * VideoWidth + x; \
- dp = (memtype*)buffer; \
- memcpy(dp, sp, w * sizeof(memtype)); \
- if (--h) { \
- dp += w; \
- sp += VideoWidth; \
- while (--h) { \
- *dp++ = *sp; \
- *dp++ = sp[w - 1]; \
- sp += VideoWidth; \
- } \
- memcpy(dp, sp, w * sizeof(memtype)); \
- } \
-}
-
-
-/**
-** Restore cursor rectangle for 8bpp frame buffer.
-** (See description function pointer LoadCursorRectangle)
-** @see LoadCursorRectangle
-*/
-global void LoadCursorRectangle8(void* buffer, int x, int y, int w, int h)
-{
- LOADCURSORRECTANGLE(buffer, VideoMemory8, VMemType8, x, y, w, h);
-}
-
-/**
-** Restore cursor rectangle for 16bpp frame buffer.
-** (See description function pointer LoadCursorRectangle)
-** @see LoadCursorRectangle
-*/
-global void LoadCursorRectangle16(void* buffer, int x, int y, int w, int h)
-{
- LOADCURSORRECTANGLE(buffer, VideoMemory16, VMemType16, x, y, w, h);
-}
-
-/**
-** Restore cursor rectangle for 24bpp frame buffer.
-** (See description function pointer LoadCursorRectangle)
-** @see LoadCursorRectangle
-*/
-global void LoadCursorRectangle24(void* buffer, int x, int y, int w, int h)
-{
- LOADCURSORRECTANGLE(buffer,VideoMemory24, VMemType24, x, y, w, h);
-}
-
-/**
-** Restore cursor rectangle for 32bpp frame buffer.
-** (See description function pointer LoadCursorRectangle)
-** @see LoadCursorRectangle
-*/
-global void LoadCursorRectangle32(void* buffer, int x, int y, int w, int h)
-{
- LOADCURSORRECTANGLE(buffer, VideoMemory32, VMemType32, x, y, w, h);
-}
-
-/**
-** Save cursor rectangle for 8bpp frame buffer.
-** (See description function pointer SaveCursorRectangle)
-** @see SaveCursorRectangle
-*/
-global void SaveCursorRectangle8(void* buffer, int x, int y, int w, int h)
-{
- SAVECURSORRECTANGLE(buffer, VideoMemory8, VMemType8, x, y, w, h);
-}
-
-/**
-** Save cursor rectangle for 16bpp frame buffer.
-** (See description function pointer SaveCursorRectangle)
-** @see SaveCursorRectangle
-*/
-global void SaveCursorRectangle16(void* buffer, int x, int y, int w, int h)
-{
- SAVECURSORRECTANGLE(buffer, VideoMemory16, VMemType16, x, y, w, h);
-}
-
-/**
-** Save cursor rectangle for 24bpp frame buffer.
-** (See description function pointer SaveCursorRectangle)
-** @see SaveCursorRectangle
-*/
-global void SaveCursorRectangle24(void* buffer, int x, int y, int w, int h)
-{
- SAVECURSORRECTANGLE(buffer, VideoMemory24, VMemType24, x, y, w, h);
-}
-
-/**
-** Save cursor rectangle for 32bpp frame buffer.
-** (See description function pointer SaveCursorRectangle)
-** @see SaveCursorRectangle
-*/
-global void SaveCursorRectangle32(void* buffer, int x, int y, int w, int h)
-{
- SAVECURSORRECTANGLE(buffer, VideoMemory32, VMemType32, x, y, w, h);
-}
-#endif
/**
** Draw rectangle cursor when visible, defined by
@@ -547,7 +394,6 @@
/*----------------------------------------------------------------------------
-- DRAW SPRITE CURSOR
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
#ifndef USE_OPENGL
local void LoadCursorBackground(int x, int y, int w, int h)
{
@@ -577,183 +423,6 @@
SDL_BlitSurface(TheScreen, &srect, OldCursorImage, NULL);
}
#endif
-#else
-/**
-** Restore cursor background for 8bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void LoadCursorBackground8(int x, int y, int w, int h)
-{
- const VMemType8* sp;
- VMemType8* dp;
-
- sp = OldCursorImage;
- dp = VideoMemory8 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType8));
- sp += w;
- dp += VideoWidth;
- }
-}
-
-/**
-** Restore cursor background for 16bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void LoadCursorBackground16(int x, int y, int w, int h)
-{
- const VMemType16* sp;
- VMemType16* dp;
-
- sp = OldCursorImage;
- dp = VideoMemory16 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType16));
- sp += w;
- dp += VideoWidth;
- }
-}
-
-/**
-** Restore cursor background for 24bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void LoadCursorBackground24(int x, int y, int w, int h)
-{
- const VMemType24* sp;
- VMemType24* dp;
-
- sp = OldCursorImage;
- dp = VideoMemory24 + y * VideoWidth+x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType24));
- sp += w;
- dp += VideoWidth;
- }
-}
-
-/**
-** Restore cursor background for 32bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void LoadCursorBackground32(int x, int y, int w, int h)
-{
- const VMemType32* sp;
- VMemType32* dp;
-
- sp = OldCursorImage;
- dp = VideoMemory32 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType32));
- sp += w;
- dp += VideoWidth;
- }
-}
-
-/**
-** Save cursor background for 8bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void SaveCursorBackground8(int x, int y, int w, int h)
-{
- VMemType8* dp;
- VMemType8* sp;
-
- dp = OldCursorImage;
- sp = VideoMemory8 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType8));
- dp += w;
- sp += VideoWidth;
- }
-}
-
-/**
-** Save cursor background for 16bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void SaveCursorBackground16(int x, int y, int w, int h)
-{
- VMemType16* dp;
- const VMemType16* sp;
-
- dp = OldCursorImage;
- sp = VideoMemory16 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType16));
- dp += w;
- sp += VideoWidth;
- }
-}
-
-/**
-** Save cursor background for 24bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void SaveCursorBackground24(int x, int y, int w, int h)
-{
- VMemType24* dp;
- const VMemType24* sp;
-
- dp = OldCursorImage;
- sp = VideoMemory24 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType24));
- dp += w;
- sp += VideoWidth;
- }
-}
-
-/**
-** Save cursor background for 32bpp frame buffer.
-**
-** @param x Screen X pixels coordinate.
-** @param y Screen Y pixels coordinate.
-** @param w Width in pixels.
-** @param h Height in pixels.
-*/
-local void SaveCursorBackground32(int x, int y, int w, int h)
-{
- VMemType32* dp;
- const VMemType32* sp;
-
- dp = OldCursorImage;
- sp = VideoMemory32 + y * VideoWidth + x;
- while (h--) {
- memcpy(dp, sp, w * sizeof(VMemType32));
- dp += w;
- sp += VideoWidth;
- }
-}
-#endif
/**
** Destroy image behind cursor.
@@ -761,11 +430,7 @@
global void DestroyCursorBackground(void)
{
if (OldCursorImage) {
-#ifdef USE_SDL_SURFACE
SDL_FreeSurface(OldCursorImage);
-#else
- free(OldCursorImage);
-#endif
OldCursorImage = NULL;
}
OldCursorSize = 0;
@@ -799,23 +464,11 @@
h = VideoGraphicHeight(type->Sprite);
//Reserve enough memory for background of sprite (also for future calls)
-#ifdef USE_SDL_SURFACE
size = w * h;
if (OldCursorSize < size) {
OldCursorImage = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
BMASK, GMASK, RMASK, AMASK);
OldCursorSize = size;
}
-#else
- size = w * h * MemSize;
- if (OldCursorSize < size) {
- if (OldCursorImage) {
- OldCursorImage = realloc(OldCursorImage, size);
- } else {
- OldCursorImage = malloc(size);
- }
- OldCursorSize = size;
- }
-#endif
//Save (seen) area behind sprite
CLIP_RECTANGLE(x, y, w, h);
SaveCursorBackground(OldCursorX = x, OldCursorY = y,
@@ -838,13 +491,7 @@
int y;
int mx;
int my;
-#ifdef USE_SDL_SURFACE
Uint32 color;
-#else
- int x1;
- int y1;
- VMemType color;
-#endif
int f;
int w;
int w0;
@@ -891,12 +538,6 @@
while (h--) {
w = w0;
while (w--) {
-#ifndef USE_SDL_SURFACE
- int basex;
- int basey;
- int i;
- int j;
-#endif
// FIXME: The field is covered by fog of war!
if (f && (CursorBuilding->MustBuildOnTop ||
@@ -909,29 +550,8 @@
} else {
color = ColorRed;
}
-#ifdef USE_SDL_SURFACE
VideoFillTransRectangle(color, x + w * TileSizeX, y + h
*
TileSizeY, TileSizeX, TileSizeY, 95);
-#else
- // FIXME: I could do this faster+better
- /* latimerius: I'm not sure what you have in mind but I
can
- * at least move invariants out of the loops. */
- basex = x + w * TileSizeX;
- basey = y + h * TileSizeY;
- for (y1 = 0; y1 < TileSizeY; ++y1) {
- j = basey + y1;
- for (x1 = y1 & 1; x1 < TileSizeX; x1 += 2) {
- i = basex + x1;
- if (i > vp->EndX) {
- break;
- }
- VideoDrawPixel(color, i, j);
- }
- if (j > vp->EndY) {
- break;
- }
- }
-#endif
}
}
}
@@ -1191,46 +811,8 @@
free(OldCursorRectangle);
OldCursorRectangle = 0;
}
-#ifdef USE_SDL_SURFACE
OldCursorRectangle = malloc((2 * VideoWidth + 2 *
(VideoHeight - 2)) * TheScreen->format->BytesPerPixel);
-#else
- switch (VideoBpp) {
- case 8:
- SaveCursorBackground = SaveCursorBackground8;
- LoadCursorBackground = LoadCursorBackground8;
- MemSize = sizeof(VMemType8);
- SaveCursorRectangle = SaveCursorRectangle8;
- LoadCursorRectangle = LoadCursorRectangle8;
- break;
- case 15:
- case 16:
- SaveCursorBackground = SaveCursorBackground16;
- LoadCursorBackground = LoadCursorBackground16;
- MemSize = sizeof(VMemType16);
- SaveCursorRectangle = SaveCursorRectangle16;
- LoadCursorRectangle = LoadCursorRectangle16;
- break;
- case 24:
- SaveCursorBackground = SaveCursorBackground24;
- LoadCursorBackground = LoadCursorBackground24;
- MemSize = sizeof(VMemType24);
- SaveCursorRectangle = SaveCursorRectangle24;
- LoadCursorRectangle = LoadCursorRectangle24;
- break;
- case 32:
- SaveCursorBackground = SaveCursorBackground32;
- LoadCursorBackground = LoadCursorBackground32;
- MemSize = sizeof(VMemType32);
- SaveCursorRectangle = SaveCursorRectangle32;
- LoadCursorRectangle = LoadCursorRectangle32;
- break;
- default:
- DebugLevel0Fn("unsupported %d bpp\n" _C_ VideoBpp);
- abort();
- }
- OldCursorRectangle = malloc((2 * VideoWidth + 2 * (VideoHeight - 2)) *
MemSize);
-#endif // ifdef USE_SDL_SURFACE
#endif
CursorX = VideoWidth / 2;
@@ -1246,7 +828,7 @@
int i;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.92 2004/01/14
23:48:44 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.93 2004/01/15
02:14:07 jsalmon3 Exp $\n\n");
for (i = 0; Cursors[i].OType; ++i) {
CLprintf(file, "(define-cursor '%s '%s\n",
Index: stratagus/src/video/font.c
diff -u stratagus/src/video/font.c:1.76 stratagus/src/video/font.c:1.77
--- stratagus/src/video/font.c:1.76 Thu Jan 15 10:48:44 2004
+++ stratagus/src/video/font.c Thu Jan 15 13:14:07 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: font.c,v 1.76 2004/01/14 23:48:44 jsalmon3 Exp $
+// $Id: font.c,v 1.77 2004/01/15 02:14:07 jsalmon3 Exp $
//@{
@@ -51,7 +51,6 @@
#define NumFontColors 7
-#ifdef USE_SDL_SURFACE
/// Font color mapping
typedef struct _font_color_mapping_ {
char* ColorName; /// Font color name
@@ -60,26 +59,6 @@
} FontColorMapping;
local FontColorMapping* FontColor;
-#else
- /// Font color mapping
-typedef struct _font_color_mapping_ {
- char* Color; /// Font color
- struct {
- int R;
- int G;
- int B;
- } RGB[NumFontColors];
- VMemType Pixels[NumFontColors]; /// Array of hardware dependent
pixels
- struct _font_color_mapping_* Next; /// Next pointer
-} FontColorMapping;
-
-local const VMemType* FontPixels; /// Font pixels
-#define FontPixels8 (&FontPixels->D8) /// font pixels 8bpp
-#define FontPixels16 (&FontPixels->D16) /// font pixels 16bpp
-#define FontPixels24 (&FontPixels->D24) /// font pixels 24bpp
-#define FontPixels32 (&FontPixels->D32) /// font pixels 32bpp
-
-#endif
/// Font color mappings
local FontColorMapping* FontColorMappings;
@@ -91,32 +70,19 @@
*/
local ColorFont Fonts[MaxFonts];
-#ifdef USE_SDL_SURFACE
/// Last text color
local FontColorMapping* LastTextColor;
/// Default text color
local FontColorMapping* DefaultTextColor;
/// Reverse text color
local FontColorMapping* ReverseTextColor;
-#else
- /// Last text color
-local const VMemType* LastTextColor;
- /// Default text color
-local const VMemType* DefaultTextColor;
- /// Reverse text color
-local const VMemType* ReverseTextColor;
-#endif
/// Default normal color index
local char* DefaultNormalColorIndex;
/// Default reverse color index
local char* DefaultReverseColorIndex;
/// Draw character with current video depth.
-#ifdef USE_SDL_SURFACE
local void VideoDrawChar(const Graphic*, int, int, int, int, int, int);
-#else
-local void (*VideoDrawChar)(const Graphic*, int, int, int, int, int, int);
-#endif
#ifdef USE_OPENGL
/// Font bitmaps
@@ -149,7 +115,6 @@
// FIXME: should use RLE encoded fonts, not color key fonts.
-#ifdef USE_SDL_SURFACE
/**
** Draw character with current color.
**
@@ -202,230 +167,8 @@
glEnable(GL_TEXTURE_2D);
}
#endif
-#else
-/**
-** Draw character with current color into 8bit 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 VideoDrawChar8(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;
- VMemType8* dp;
- int da;
-
- sp = (const unsigned char*)sprite->Frames + gx + gy * sprite->Width - 1;
- gp = sp + sprite->Width * h;
- sa = sprite->Width - w;
- dp = VideoMemory8 + x + y * VideoWidth - 1;
- da = VideoWidth - w;
- --w;
-
-#define UNROLL \
- ++dp; \
- p = *++sp; \
- if (p != 255) { \
- if (p < NumFontColors) { \
- *dp = FontPixels8[p]; \
- } else { \
- *dp = ((VMemType8*)sprite->Pixels)[p]; \
- } \
- }
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) { // loop with unroll
- UNROLL;
- UNROLL;
- }
- if (sp <= lp) {
- UNROLL;
- }
- sp += sa;
- dp += da;
- }
-#undef UNROLL
-}
/**
-** Draw character with current color into 16bit 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 VideoDrawChar16(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;
- VMemType16* dp;
- int da;
-
- sp = (const unsigned char*)sprite->Frames + gx + gy * sprite->Width - 1;
- gp = sp + sprite->Width * h;
- sa = sprite->Width - w;
- dp = VideoMemory16 + x + y * VideoWidth - 1;
- da = VideoWidth - w;
- --w;
-
-#define UNROLL \
- ++dp; \
- p = *++sp; \
- if (p != 255) { \
- if (p < NumFontColors) { \
- *dp = FontPixels16[p]; \
- } else { \
- *dp = ((VMemType16*)sprite->Pixels)[p]; \
- } \
- }
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) { // loop with unroll
- UNROLL;
- UNROLL;
- }
- if (sp <= lp) {
- UNROLL;
- }
- sp += sa;
- dp += da;
- }
-#undef UNROLL
-}
-
-/**
-** 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 = (const unsigned char*)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;
-
-#define UNROLL \
- ++dp; \
- p = *++sp; \
- if (p != 255) { \
- if (p < NumFontColors) { \
- *dp = FontPixels24[p]; \
- } else { \
- *dp = ((VMemType24*)sprite->Pixels)[p]; \
- } \
- }
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) { // loop with unroll
- UNROLL;
- UNROLL;
- }
- if (sp <= lp) {
- UNROLL;
- }
- sp += sa;
- dp += da;
- }
-#undef UNROLL
-}
-
-/**
-** Draw character with current color into 32bit 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 VideoDrawChar32(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;
- VMemType32* dp;
- int da;
-
- sp = (const unsigned char*)sprite->Frames + gx + gy * sprite->Width - 1;
- gp = sp + sprite->Width * h;
- sa = sprite->Width - w;
- dp = VideoMemory32 + x + y * VideoWidth - 1;
- da = VideoWidth - w;
- --w;
-
-#define UNROLL \
- ++dp; \
- p = *++sp; \
- if (p != 255) { \
- if (p < NumFontColors) { \
- *dp = FontPixels32[p]; \
- } else { \
- *dp = ((VMemType32*)sprite->Pixels)[p]; \
- } \
- }
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) { // loop with unroll
- UNROLL;
- UNROLL;
- }
- if (sp <= lp) {
- UNROLL;
- }
- sp += sa;
- dp += da;
- }
-#undef UNROLL
-}
-#endif
-
-#ifdef USE_SDL_SURFACE
-/**
** FIXME: docu
*/
local FontColorMapping* GetFontColorMapping(char* color)
@@ -443,26 +186,6 @@
ExitFatal(1);
return NULL;
}
-#else
-/**
-** FIXME: docu
-*/
-local const VMemType* GetFontColorMapping(char* color)
-{
- FontColorMapping* fcm;
-
- fcm = FontColorMappings;
- while (fcm) {
- if (!strcmp(fcm->Color, color)) {
- return fcm->Pixels;
- }
- fcm = fcm->Next;
- }
- fprintf(stderr, "Font mapping not found: '%s'\n", color);
- ExitFatal(1);
- return NULL;
-}
-#endif
/**
** Set the default text colors.
@@ -474,11 +197,7 @@
{
DefaultNormalColorIndex = normal;
DefaultReverseColorIndex = reverse;
-#ifdef USE_SDL_SURFACE
LastTextColor = DefaultTextColor = FontColor =
GetFontColorMapping(normal);
-#else
- LastTextColor = DefaultTextColor = FontPixels =
GetFontColorMapping(normal);
-#endif
ReverseTextColor = GetFontColorMapping(reverse);
}
@@ -588,11 +307,7 @@
int height;
int widths;
const ColorFont* fp;
-#ifdef USE_SDL_SURFACE
FontColorMapping* rev;
-#else
- const VMemType* rev;
-#endif
char* color;
const unsigned char* p;
void (*DrawChar)(const Graphic*, int, int, int, int, int, int);
@@ -618,34 +333,19 @@
case '~':
break;
case '!':
-#ifdef USE_SDL_SURFACE
rev = FontColor;
FontColor = ReverseTextColor;
-#else
- rev = FontPixels;
- FontPixels = ReverseTextColor;
-#endif
++text;
break;
case '<':
-#ifdef USE_SDL_SURFACE
LastTextColor = FontColor;
FontColor = ReverseTextColor;
-#else
- LastTextColor = FontPixels;
- FontPixels = ReverseTextColor;
-#endif
continue;
case '>':
rev = LastTextColor; // swap last and
current color
-#ifdef USE_SDL_SURFACE
LastTextColor = FontColor;
FontColor = rev;
-#else
- LastTextColor = FontPixels;
- FontPixels = rev;
-#endif
continue;
default:
@@ -661,13 +361,8 @@
memcpy(color, text, p - text);
color[p - text] = '\0';
text = p;
-#ifdef USE_SDL_SURFACE
LastTextColor = FontColor;
FontColor = GetFontColorMapping(color);
-#else
- LastTextColor = FontPixels;
- FontPixels = GetFontColorMapping(color);
-#endif
free(color);
continue;
}
@@ -684,11 +379,7 @@
}
widths += w + 1;
if (rev) {
-#ifdef USE_SDL_SURFACE
FontColor = rev;
-#else
- FontPixels = rev;
-#endif
rev = NULL;
}
}
@@ -754,15 +445,9 @@
{
int w;
-#ifdef USE_SDL_SURFACE
FontColor = ReverseTextColor;
w = VideoDrawText(x, y, font, text);
FontColor = DefaultTextColor;
-#else
- FontPixels = ReverseTextColor;
- w = VideoDrawText(x, y, font, text);
- FontPixels = DefaultTextColor;
-#endif
return w;
}
@@ -856,7 +541,6 @@
return VideoDrawReverseText(x, y, font, buf);
}
-#ifdef USE_SDL_SURFACE
local void FontMeasureWidths(ColorFont* fp)
{
// FIXME: todo.. can this be optimized?
@@ -896,48 +580,6 @@
}
SDL_UnlockSurface(fp->Graphic->Surface);
}
-#else
-/**
-** Calculate widths table for a font.
-**
-// FIXME: ARI: This is runtime and fairly slow!
-// FIXME: ARI: Maybe integrate into wartool and load from file!
-*/
-local void FontMeasureWidths(ColorFont* fp)
-{
- int y;
- const unsigned char* sp;
- const unsigned char* lp;
- const unsigned char* gp;
-
- for (y = 1; y < 207; ++y) {
- fp->CharWidth[y] = 0;
- }
-
- for (y = 1; y < 207; ++y) {
- sp = (const unsigned char *)fp->Graphic->Frames +
- y * fp->Height * fp->Graphic->Width - 1;
- gp = sp + fp->Graphic->Width * fp->Height;
- // Bail out cause there are no letters left
- if (gp >= ((const unsigned char *)fp->Graphic->Frames +
- fp->Graphic->Width * fp->Graphic->Height)) {
- break;
- }
- while (sp < gp) {
- lp = sp + fp->Graphic->Width - 1;
- for (; sp < lp; --lp) {
- if (*lp != 255) {
- if (lp - sp > fp->CharWidth[y]) { //
max width
- fp->CharWidth[y] = lp - sp;
- }
- }
- }
- sp += fp->Graphic->Width;
- }
- }
- fp->CharWidth[0] = fp->Width / 2; // a reasonable value for SPACE
-}
-#endif
/**
** Make font bitmap.
@@ -999,38 +641,6 @@
global void LoadFonts(void)
{
unsigned i;
-#ifndef USE_SDL_SURFACE
- FontColorMapping* fcm;
- void* pixels;
-#endif
-
- //
- // First select the font drawing procedure.
- //
-#ifndef USE_SDL_SURFACE
- switch (VideoBpp) {
- case 8:
- VideoDrawChar = VideoDrawChar8;
- break;
-
- case 15:
- case 16:
- VideoDrawChar = VideoDrawChar16;
- break;
-
- case 24:
- VideoDrawChar = VideoDrawChar24;
- break;
-
- case 32:
- VideoDrawChar = VideoDrawChar32;
- break;
-
- default:
- DebugLevel0Fn("unsupported %d bpp\n" _C_ VideoBpp);
- abort();
- }
-#endif
for (i = 0; i < sizeof(Fonts) / sizeof(*Fonts); ++i) {
if (Fonts[i].File && !Fonts[i].Graphic) {
@@ -1042,35 +652,6 @@
#endif
}
}
-
-#ifndef USE_SDL_SURFACE
- fcm = FontColorMappings;
- while (fcm) {
- pixels = fcm->Pixels;
- for (i = 0; i < NumFontColors; ++i) {
- VMemType c;
-
- c = VideoMapRGB(fcm->RGB[i].R, fcm->RGB[i].G,
fcm->RGB[i].B);
-
- switch (VideoBpp) {
- case 8:
- ((VMemType8*)pixels)[i] = c.D8;
- break;
- case 15:
- case 16:
- ((VMemType16*)pixels)[i] = c.D16;
- break;
- case 24:
- ((VMemType24*)pixels)[i] = c.D24;
- break;
- case 32:
- ((VMemType32*)pixels)[i] = c.D32;
- break;
- }
- }
- fcm = fcm->Next;
- }
-#endif
}
/*----------------------------------------------------------------------------
@@ -1193,17 +774,9 @@
} else {
fcmp = &FontColorMappings;
while (*fcmp) {
-#ifdef USE_SDL_SURFACE
if (!strcmp((*fcmp)->ColorName, color)) {
-#else
- if (!strcmp((*fcmp)->Color, color)) {
-#endif
fprintf(stderr, "Warning: Redefining color
'%s'\n", color);
-#ifdef USE_SDL_SURFACE
free((*fcmp)->ColorName);
-#else
- free((*fcmp)->Color);
-#endif
fcm = *fcmp;
break;
}
@@ -1212,11 +785,7 @@
*fcmp = calloc(sizeof(*FontColorMappings), 1);
fcm = *fcmp;
}
-#ifdef USE_SDL_SURFACE
fcm->ColorName = color;
-#else
- fcm->Color = color;
-#endif
fcm->Next = NULL;
if (luaL_getn(l, 2) != NumFontColors * 3) {
@@ -1224,25 +793,13 @@
}
for (i = 0; i < NumFontColors; ++i) {
lua_rawgeti(l, 2, i * 3 + 1);
-#ifdef USE_SDL_SURFACE
fcm->Color[i].r = LuaToNumber(l, -1);
-#else
- fcm->RGB[i].R = LuaToNumber(l, -1);
-#endif
lua_pop(l, 1);
lua_rawgeti(l, 2, i * 3 + 2);
-#ifdef USE_SDL_SURFACE
fcm->Color[i].g = LuaToNumber(l, -1);
-#else
- fcm->RGB[i].G = LuaToNumber(l, -1);
-#endif
lua_pop(l, 1);
lua_rawgeti(l, 2, i * 3 + 3);
-#ifdef USE_SDL_SURFACE
fcm->Color[i].b = LuaToNumber(l, -1);
-#else
- fcm->RGB[i].B = LuaToNumber(l, -1);
-#endif
lua_pop(l, 1);
}
@@ -1275,10 +832,6 @@
global void CleanFonts(void)
{
unsigned i;
-#ifndef USE_SDL_SURFACE
- FontColorMapping* fcm;
- FontColorMapping* temp;
-#endif
for (i = 0; i < sizeof(Fonts) / sizeof(*Fonts); ++i) {
free(Fonts[i].File);
@@ -1287,15 +840,6 @@
Fonts[i].Graphic = NULL;
}
-#ifndef USE_SDL_SURFACE
- fcm = FontColorMappings;
- while (fcm) {
- temp = fcm->Next;
- free(fcm->Color);
- free(fcm);
- fcm = temp;
- }
-#endif
FontColorMappings = NULL;
}
Index: stratagus/src/video/graphic.c
diff -u stratagus/src/video/graphic.c:1.62 stratagus/src/video/graphic.c:1.63
--- stratagus/src/video/graphic.c:1.62 Thu Jan 15 10:48:44 2004
+++ stratagus/src/video/graphic.c Thu Jan 15 13:14:07 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: graphic.c,v 1.62 2004/01/14 23:48:44 jsalmon3 Exp $
+// $Id: graphic.c,v 1.63 2004/01/15 02:14:07 jsalmon3 Exp $
//@{
@@ -54,16 +54,10 @@
-- Variables
----------------------------------------------------------------------------*/
-#ifndef USE_SDL_SURFACE
-local GraphicType GraphicImage8Type; /// image type 8bit palette
-local GraphicType GraphicImage16Type; /// image type 16bit palette
-#endif
-
/*----------------------------------------------------------------------------
-- Local functions
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
/**
** Video draw part of graphic.
**
@@ -185,260 +179,9 @@
VideoDrawSubFaded(graphic, gx, gy, w, h, x, y, fade);
}
-#else
-/**
-** Video draw part of 8bit graphic into 8 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to8(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* lp;
- const unsigned char* gp;
- VMemType8* dp;
- const VMemType8* pixels;
- int sa;
- int da;
-
- pixels = graphic->Pixels;
- sp = (const unsigned char*)graphic->Frames + gx + gy * graphic->Width;
- gp = sp + graphic->Width * h;
- sa = graphic->Width - w;
- dp = VideoMemory8 + x + y * VideoWidth;
- da = VideoWidth - w--;
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) {
- *dp++ = pixels[*sp++]; // unroll
- *dp++ = pixels[*sp++];
- }
- if (sp <= lp) {
- *dp++ = pixels[*sp++];
- }
- sp += sa;
- dp += da;
- }
-}
-
-/**
-** Video draw part of 8bit graphic into 16 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to16(const Graphic* graphic, int gx, int gy,
- int w, int h, int x,int y)
-{
- const unsigned char* sp;
- const unsigned char* lp;
- const unsigned char* gp;
- int sa;
- const VMemType16* pixels;
- VMemType16* dp;
- int da;
-
- pixels = (VMemType16*)graphic->Pixels;
- sp = (const unsigned char*)graphic->Frames + gx + gy * graphic->Width;
- gp = sp + graphic->Width * h;
- sa = graphic->Width - w;
- dp = VideoMemory16 + x + y * VideoWidth;
- da = VideoWidth - w--;
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) {
- *dp++ = pixels[*sp++]; // unroll
- *dp++ = pixels[*sp++];
- }
- if (sp <= lp) {
- *dp++ = pixels[*sp++];
- }
- sp += sa;
- dp += da;
- }
-}
-
-/**
-** Video draw part of 8bit graphic into 24 bit framebuffer.
-**
-** FIXME: 24 bit blitting could be optimized.
-**
-** @param graphic 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 VideoDrawSub8to24(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* lp;
- const unsigned char* gp;
- int sa;
- const VMemType24* pixels;
- VMemType24* dp;
- int da;
-
- pixels = (VMemType24*)graphic->Pixels;
- sp = (const unsigned char*)graphic->Frames + gx + gy * graphic->Width;
- gp = sp + graphic->Width * h;
- sa = graphic->Width - w;
- dp = VideoMemory24 + x + y * VideoWidth;
- da = VideoWidth - w--;
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) {
- *dp++ = pixels[*sp++]; // unroll
- *dp++ = pixels[*sp++];
- }
- if (sp <= lp) {
- *dp++ = pixels[*sp++];
- }
- sp += sa;
- dp += da;
- }
-}
-
-/**
-** Video draw part of 8bit graphic into 32 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to32(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* lp;
- const unsigned char* gp;
- int sa;
- const VMemType32* pixels;
- VMemType32* dp;
- int da;
-
- pixels = (VMemType32*)graphic->Pixels;
- sp = (const unsigned char*)graphic->Frames + gx + gy * graphic->Width;
- gp = sp + graphic->Width * h;
- sa = graphic->Width - w;
- dp = VideoMemory32 + x + y * VideoWidth;
- da = VideoWidth - w--;
-
- while (sp < gp) {
- lp = sp + w;
- while (sp < lp) {
- *dp++ = pixels[*sp++]; // unroll
- *dp++ = pixels[*sp++];
- }
- if (sp <= lp) {
- *dp++ = pixels[*sp++];
- }
- sp += sa;
- dp += da;
- }
-}
-#endif
-
-#ifndef USE_SDL_SURFACE
-/**
-** Video draw part of 8bit graphic clipped into 8 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to8Clip(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- CLIP_RECTANGLE(x, y, w, h);
- VideoDrawSub8to8(graphic, gx, gy, w, h, x, y);
-}
-
-/**
-** Video draw part of 8bit graphic clipped into 16 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to16Clip(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- CLIP_RECTANGLE(x, y, w, h);
- VideoDrawSub8to16(graphic, gx, gy, w, h, x, y);
-}
-
-/**
-** Video draw part of 8bit graphic clipped into 24 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to24Clip(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- CLIP_RECTANGLE(x, y, w, h);
- VideoDrawSub8to24(graphic, gx, gy, w, h, x, y);
-}
-
-/**
-** Video draw part of 8bit graphic clipped into 32 bit framebuffer.
-**
-** @param graphic 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 VideoDrawSub8to32Clip(const Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y)
-{
- CLIP_RECTANGLE(x, y, w, h);
- VideoDrawSub8to32(graphic, gx, gy, w, h, x, y);
-}
-#endif
-
/**
** Free graphic object.
*/
-#ifdef USE_SDL_SURFACE
global void VideoFree(Graphic* graphic)
{
#ifdef DEBUG
@@ -466,7 +209,8 @@
}
free(graphic);
}
-#else
+
+#if 0
local void FreeGraphic8(Graphic* graphic)
{
#ifdef DEBUG
@@ -490,32 +234,10 @@
}
#endif
-
/*----------------------------------------------------------------------------
-- Global functions
----------------------------------------------------------------------------*/
-#ifndef USE_SDL_SURFACE
-/**
-** Video draw part of a graphic clipped and faded.
-**
-** @param graphic 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
-** @param fade Amount faded, from 0 (black) to 255 (no
fading)
-*/
-global void VideoDrawSubClipFaded(Graphic* graphic, int gx, int gy,
- int w, int h, int x, int y, unsigned char fade)
-{
- VideoDrawSubClip(graphic, gx, gy, w, h, x, y);
- VideoFillTransRectangle(ColorBlack, x, y, w, h, fade);
-}
-#endif
-
/**
** Make a graphic object.
**
@@ -541,34 +263,15 @@
fprintf(stderr, "Out of memory\n");
ExitFatal(-1);
}
-#ifndef USE_SDL_SURFACE
- if (depth == 8) {
- graphic->Type = &GraphicImage8Type;
- } else if (depth == 16) {
- graphic->Type = &GraphicImage16Type;
- } else {
- fprintf(stderr, "Unsported image depth\n");
- ExitFatal(-1);
- }
-#endif
graphic->Width = width;
graphic->Height = height;
-#ifdef USE_SDL_SURFACE
// FIXME: endian
graphic->Surface = SDL_CreateRGBSurfaceFrom(data, width, height, depth,
width * depth / 8,
0, 0, 0, 0);
graphic->SurfaceFlip = NULL;
graphic->NumFrames = 0;
-#else
- graphic->Pixels = NULL;
- graphic->Palette = NULL;
-
- graphic->NumFrames = 0;
- graphic->Frames = data;
- graphic->Size = size;
-#endif
#ifdef USE_OPENGL
graphic->NumTextureNames = 0;
@@ -577,7 +280,6 @@
return graphic;
}
-#ifdef USE_SDL_SURFACE
/**
** Flip graphic and store in graphic->SurfaceFlip
**
@@ -606,7 +308,6 @@
}
SDL_UnlockSurface(s);
}
-#endif
/**
** Make a new graphic object.
@@ -812,7 +513,6 @@
unsigned char* data;
int x;
-#ifdef USE_SDL_SURFACE
SDL_Color pal[256];
DebugCheck(g->Surface->format->BytesPerPixel != 1);
@@ -821,12 +521,6 @@
}
SDL_LockSurface(g->Surface);
-#else
- DebugCheck(g->Type != &GraphicImage8Type);
- if (g->Width == w && g->Height == h) {
- return;
- }
-#endif
data = (unsigned char*)malloc(w * h);
#ifdef DEBUG
@@ -836,18 +530,12 @@
for (i = 0; i < h; ++i) {
for (j = 0; j < w; ++j) {
-#ifdef USE_SDL_SURFACE
data[x] = ((unsigned char*)g->Surface->pixels)[
(i * g->Height / h) * g->Surface->pitch + j *
g->Width / w];
-#else
- data[x] = ((unsigned char*)g->Frames)[
- (i * g->Height / h) * g->Width + j * g->Width /
w];
-#endif
++x;
}
}
-#ifdef USE_SDL_SURFACE
SDL_UnlockSurface(g->Surface);
memcpy(pal, g->Surface->format->palette->colors, sizeof(SDL_Color) *
256);
VideoPaletteListRemove(g->Surface);
@@ -860,15 +548,6 @@
g->Width = w;
g->Height = h;
-#else
- free(g->Frames);
-#ifdef DEBUG
- AllocatedGraphicMemory -= g->Width * g->Height;
-#endif
- g->Frames = data;
- g->Width = w;
- g->Height = h;
-#endif
}
/**
@@ -892,12 +571,8 @@
ExitFatal(-1);
}
-#ifdef USE_SDL_SURFACE
graphic->NumFrames = 1;
VideoPaletteListAdd(graphic->Surface);
-#else
- graphic->Pixels = VideoCreateSharedPalette(graphic->Palette);
-#endif
return graphic;
}
@@ -907,40 +582,6 @@
*/
global void InitGraphic(void)
{
-#ifndef USE_SDL_SURFACE
-#ifdef USE_OPENGL
- GraphicImage8Type.DrawSub = VideoDrawSubOpenGL;
- GraphicImage8Type.DrawSubClip = VideoDrawSubOpenGLClip;
-#else
- switch (VideoBpp) {
- case 8:
- GraphicImage8Type.DrawSub = VideoDrawSub8to8;
- GraphicImage8Type.DrawSubClip = VideoDrawSub8to8Clip;
- break;
-
- case 15:
- case 16:
- GraphicImage8Type.DrawSub = VideoDrawSub8to16;
- GraphicImage8Type.DrawSubClip = VideoDrawSub8to16Clip;
- break;
-
- case 24:
- GraphicImage8Type.DrawSub = VideoDrawSub8to24;
- GraphicImage8Type.DrawSubClip = VideoDrawSub8to24Clip;
- break;
-
- case 32:
- GraphicImage8Type.DrawSub = VideoDrawSub8to32;
- GraphicImage8Type.DrawSubClip = VideoDrawSub8to32Clip;
- break;
-
- default:
- DebugLevel0Fn("unsupported %d bpp\n" _C_ VideoBpp);
- abort();
- }
-#endif
- GraphicImage8Type.Free = FreeGraphic8;
-#endif
}
//@}
Index: stratagus/src/video/linedraw.c
diff -u stratagus/src/video/linedraw.c:1.66 stratagus/src/video/linedraw.c:1.67
--- stratagus/src/video/linedraw.c:1.66 Thu Jan 15 06:48:20 2004
+++ stratagus/src/video/linedraw.c Thu Jan 15 13:14:07 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: linedraw.c,v 1.66 2004/01/14 19:48:20 nobody_ Exp $
+// $Id: linedraw.c,v 1.67 2004/01/15 02:14:07 jsalmon3 Exp $
//@{
@@ -65,8 +65,6 @@
-- Variables
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
-// FIXME: comments
global void (*VideoDrawPixel)(Uint32 color, int x, int y);
local void (*VideoDoDrawPixel)(Uint32 color, int x, int y);
global void (*VideoDrawTransPixel)(Uint32 color, int x, int y, unsigned char
alpha);
@@ -94,362 +92,11 @@
int w, int h);
global void VideoFillTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha);
-#else
-/**
-** Draw pixel unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void (*VideoDrawPixel)(VMemType color, int x, int y);
-
-/**
-** Draw 25% translucent pixel (Alpha = 64) unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void (*VideoDraw25TransPixel)(VMemType color, int x, int y);
-
-/**
-** Draw 50% translucent pixel (Alpha = 128) unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void (*VideoDraw50TransPixel)(VMemType color, int x, int y);
-
-/**
-** Draw 75% translucent pixel (Alpha = 192) unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void (*VideoDraw75TransPixel)(VMemType color, int x, int y);
-
-/**
-** Draw translucent pixel unclipped.
-**
-** All upfollowing translucent routines follow:
-** newcolor = ((oldcolor-color) * alpha)/255+color
-**
-** FIXME: the following delivers better rounding, but is slower and can
-** not be calculate in an unsigned char (can deliver overflow):
-** newcolor = (oldcolor*alpha+color*(255 - alpha)+127)/255
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-*/
-global void (*VideoDrawTransPixel)(VMemType color, int x, int y,
- unsigned char alpha);
-
-/**
-** Draw pixel clipped to current clip setting.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void (*VideoDrawPixelClip)(VMemType color, int x, int y);
-
-/**
-** Draw vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line.
-*/
-global void (*VideoDrawVLine)(VMemType color, int x, int y, int height);
-
-/**
-** Draw 25% translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line.
-*/
-global void (*VideoDraw25TransVLine)(VMemType color, int x, int y, int height);
-
-/**
-** Draw 50% translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line.
-*/
-global void (*VideoDraw50TransVLine)(VMemType color, int x, int y, int height);
-
-/**
-** Draw 75% translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line.
-*/
-global void (*VideoDraw75TransVLine)(VMemType color, int x, int y, int height);
-
-/**
-** Draw translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line.
-** @param alpha alpha value of pixel.
-*/
-global void (*VideoDrawTransVLine)(VMemType color, int x, int y,
- int height, unsigned char alpha);
-
-/**
-** Draw horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line.
-*/
-global void (*VideoDrawHLine)(VMemType color, int x, int y, int width);
-
-/**
-** Draw 25% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line.
-*/
-global void (*VideoDraw25TransHLine)(VMemType color, int x, int y, int width);
-
-/**
-** Draw 50% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line.
-*/
-global void (*VideoDraw50TransHLine)(VMemType color, int x, int y, int width);
-
-/**
-** Draw 75% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line.
-*/
-global void (*VideoDraw75TransHLine)(VMemType color, int x, int y, int width);
-
-/**
-** Draw translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line.
-** @param alpha alpha value of pixel.
-*/
-global void (*VideoDrawTransHLine)(VMemType color, int x, int y,
- int width, unsigned char alpha);
-
-/**
-** Draw line unclipped.
-**
-** @param color color
-** @param sx Source x coordinate on the screen
-** @param sy Source y coordinate on the screen
-** @param dx Destination x coordinate on the screen
-** @param dy Destination y coordinate on the screen
-*/
-global void (*VideoDrawLine)(VMemType color, int sx, int sy, int dx, int dy);
-
-/**
-** Draw 25% translucent line unclipped.
-**
-** @param color color
-** @param sx Source x coordinate on the screen
-** @param sy Source y coordinate on the screen
-** @param dx Destination x coordinate on the screen
-** @param dy Destination y coordinate on the screen
-*/
-global void (*VideoDraw25TransLine)(VMemType color, int sx, int sy,
- int dx, int dy);
-
-/**
-** Draw 50% translucent line unclipped.
-**
-** @param color color
-** @param sx Source x coordinate on the screen
-** @param sy Source y coordinate on the screen
-** @param dx Destination x coordinate on the screen
-** @param dy Destination y coordinate on the screen
-*/
-global void (*VideoDraw50TransLine)(VMemType color, int sx, int sy,
- int dx, int dy);
-
-/**
-** Draw 75% translucent line unclipped.
-**
-** @param color color
-** @param sx Source x coordinate on the screen
-** @param sy Source y coordinate on the screen
-** @param dx Destination x coordinate on the screen
-** @param dy Destination y coordinate on the screen
-*/
-global void (*VideoDraw75TransLine)(VMemType color, int sx, int sy,
- int dx, int dy);
-
-/**
-** Draw translucent line unclipped.
-**
-** @param color color
-** @param sx Source x coordinate on the screen
-** @param sy Source y coordinate on the screen
-** @param dx Destination x coordinate on the screen
-** @param dy Destination y coordinate on the screen
-** @param alpha alpha value of pixel.
-*/
-global void (*VideoDrawTransLine)(VMemType color, int sx, int sy,
- int dx, int dy, unsigned char alpha);
-
-/**
-** Draw rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoDrawRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw 25% translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoDraw25TransRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw 50% translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoDraw50TransRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw 75% translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoDraw75TransRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-** @param alpha alpha value of pixel.
-*/
-global void (*VideoDrawTransRectangle)(VMemType color, int x, int y,
- int w, int h, unsigned char alpha);
-
-/**
-** Fill rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoFillRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw 25% translucent filled rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoFill25TransRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw 50% translucent filled rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoFill50TransRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw 75% translucent filled rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-*/
-global void (*VideoFill75TransRectangle)(VMemType color, int x, int y,
- int w, int h);
-
-/**
-** Draw translucent filled rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle.
-** @param w width of rectangle.
-** @param alpha alpha value of pixel.
-*/
-global void (*VideoFillTransRectangle)(VMemType color, int x, int y,
- int w, int h, unsigned char alpha);
-#endif
// ===========================================================================
// Pixel
// ===========================================================================
-#ifdef USE_SDL_SURFACE
/**
** FIXME: docu
*/
@@ -1377,64 +1024,45 @@
}
}
-#else
-/**
-** Draw pixel unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixel8(VMemType color, int x, int y)
-{
- VideoMemory8[x + y * VideoWidth] = color.D8;
-}
+#if 0
/**
-** Draw pixel unclipped into 16bit framebuffer.
+** Draw pixel unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
*/
-local void DrawPixel16(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void DrawPixelOpenGL(VMemType color, int x, int y)
{
- VideoMemory16[x + y * VideoWidth] = color.D16;
-}
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
-/**
-** Draw pixel unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixel24(VMemType color, int x, int y)
-{
- VideoMemory24[x + y * VideoWidth] = color.D24;
-}
-
-/**
-** Draw pixel unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixel32(VMemType color, int x, int y)
-{
- VideoMemory32[x + y * VideoWidth] = color.D32;
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor3ub(r, g, b);
+ glBegin(GL_POINTS);
+ glVertex2i(x, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw pixel unclipped.
+** Draw 25% translucent pixel unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
*/
#ifdef USE_OPENGL
-local void DrawPixelOpenGL(VMemType color, int x, int y)
+local void Draw25TransPixelOpenGL(VMemType color, int x, int y)
{
VMemType32 c;
GLubyte r;
@@ -1446,7 +1074,7 @@
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
+ glColor4ub(r, g, b, 192);
glBegin(GL_POINTS);
glVertex2i(x, VideoHeight - y);
glEnd();
@@ -1454,131 +1082,119 @@
}
#endif
-/**
-** Draw 25% translucent pixel unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw25TransPixel8(VMemType color, int x, int y)
-{
- VMemType8* p;
-
- p = VideoMemory8 + x + y * VideoWidth;
- *p = lookup25trans8[(color.D8 << 8) | *p];
-}
/**
-** Draw 25% translucent pixel unclipped into 15bit framebuffer.
+** Draw 50% translucent pixel unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
*/
-local void Draw25TransPixel15(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void Draw50TransPixelOpenGL(VMemType color, int x, int y)
{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x03E07C1F) * 3;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 128);
+ glBegin(GL_POINTS);
+ glVertex2i(x, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 25% translucent pixel unclipped into 16bit framebuffer.
+** Draw 75% translucent pixel unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
*/
-local void Draw25TransPixel16(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void Draw75TransPixelOpenGL(VMemType color, int x, int y)
{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
-
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x07E0F81F) * 3;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
-}
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
-/**
-** Draw 25% translucent pixel unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw25TransPixel24(VMemType color, int x, int y)
-{
-//FIXME: does 24bpp represents R|G|B?
- VideoMemory24[x + y * VideoWidth] = color.D24;
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 64);
+ glBegin(GL_POINTS);
+ glVertex2i(x, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 25% translucent pixel unclipped into 32bit framebuffer.
+** Draw translucent pixel unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param alpha alpha value of pixel.
*/
-local void Draw25TransPixel32(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void DrawTransPixelOpenGL(VMemType color, int x, int y,
+ unsigned char alpha)
{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
-
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = ((sp1 & 0xFF00FF00) >> 8) * 3;
- sp1 = (sp1 & 0x00FF00FF) * 3;
-
- p = VideoMemory32 + y * VideoWidth + x;
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 255 - alpha);
+ glBegin(GL_POINTS);
+ glVertex2i(x, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 25% translucent pixel unclipped.
+** Draw pixel clipped to current clip setting.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
*/
#ifdef USE_OPENGL
-local void Draw25TransPixelOpenGL(VMemType color, int x, int y)
+local void DrawPixelClipOpenGL(VMemType color, int x, int y)
{
VMemType32 c;
GLubyte r;
GLubyte g;
GLubyte b;
+ // Clipping:
+ if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
+ return;
+ }
+
c = color.D32;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
+ glColor3ub(r, g, b);
glBegin(GL_POINTS);
glVertex2i(x, VideoHeight - y);
glEnd();
@@ -1586,116 +1202,139 @@
}
#endif
-/**
-** Draw 50% translucent pixel unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw50TransPixel8(VMemType color, int x, int y)
-{
- VMemType8* p;
-
- p = VideoMemory8 + x + y * VideoWidth;
- *p = lookup50trans8[(color.D8 << 8) | *p];
-}
/**
-** Draw 50% translucent pixel unclipped into 15bit framebuffer.
+** Draw horizontal line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
*/
-local void Draw50TransPixel15(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void DrawHLineOpenGL(VMemType color, int x, int y, int width)
{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor3ub(r, g, b);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + width, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 50% translucent pixel unclipped into 16bit framebuffer.
+** Draw 25% translucent horizontal line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
*/
-local void Draw50TransPixel16(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void Draw25TransHLineOpenGL(VMemType color, int x, int y, int width)
{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 192);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + width, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 50% translucent pixel unclipped into 24bit framebuffer.
+** Draw 50% translucent horizontal line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
*/
-local void Draw50TransPixel24(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void Draw50TransHLineOpenGL(VMemType color, int x, int y, int width)
{
-//FIXME: does 24bpp represents R|G|B?
- VideoMemory24[x + y * VideoWidth] = color.D24;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
+
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 128);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + width, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 50% translucent pixel unclipped into 32bit framebuffer.
+** Draw 75% translucent horizontal line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
*/
-local void Draw50TransPixel32(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void Draw75TransHLineOpenGL(VMemType color, int x, int y, int width)
{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
-
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- p = VideoMemory32 + y * VideoWidth + x;
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 64);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + width, VideoHeight - y);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw 50% translucent pixel unclipped.
+** Draw translucent horizontal line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param width width of line (0=don't draw).
+** @param alpha alpha value of pixels.
*/
#ifdef USE_OPENGL
-local void Draw50TransPixelOpenGL(VMemType color, int x, int y)
+local void DrawTransHLineOpenGL(VMemType color, int x, int y, int width,
+ unsigned char alpha)
{
VMemType32 c;
GLubyte r;
@@ -1707,5248 +1346,83 @@
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_POINTS);
+ glColor4ub(r, g, b, 255 - alpha);
+ glBegin(GL_LINES);
glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + width, VideoHeight - y);
glEnd();
glEnable(GL_TEXTURE_2D);
}
#endif
/**
-** Draw 75% translucent pixel unclipped into 8bit framebuffer.
+** Draw vertical line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
+** @param height height of line (0=don't draw).
*/
-local void Draw75TransPixel8(VMemType color, int x, int y)
+#ifdef USE_OPENGL
+local void DrawVLineOpenGL(VMemType color, int x, int y, int height)
{
- VMemType8* p;
-
- p = VideoMemory8 + x + y * VideoWidth;
- *p = lookup25trans8[(*p << 8) | color.D8];
-}
-
-/**
-** Draw 75% translucent pixel unclipped into 15bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw75TransPixel15(VMemType color, int x, int y)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
-
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
-}
-
-/**
-** Draw 75% translucent pixel unclipped into 16bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw75TransPixel16(VMemType color, int x, int y)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
-
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
-}
-
-/**
-** Draw 75% translucent pixel unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw75TransPixel24(VMemType color, int x, int y)
-{
-//FIXME: does 24bpp represents R|G|B?
- VideoMemory24[x + y * VideoWidth] = color.D24;
-}
-
-/**
-** Draw 75% translucent pixel unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void Draw75TransPixel32(VMemType color, int x, int y)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
-
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- p = VideoMemory32 + y * VideoWidth + x;
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-}
-
-/**
-** Draw 75% translucent pixel unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void Draw75TransPixelOpenGL(VMemType color, int x, int y)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-#endif // ifdef USE_SDL_SURFACE
-
-#ifndef USE_SDL_SURFACE
-/**
-** Draw translucent pixel unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransPixel8(VMemType color, int x, int y,
- unsigned char alpha)
-{
- VMemType8* p;
-
- p = VideoMemory8 + x + y * VideoWidth;
- switch (((unsigned int)alpha * 4) / 255) {
- case 0:
- *p = color.D8;
- break;
- case 1:
- *p = lookup25trans8[(color.D8 << 8) | *p];
- break;
- case 2:
- *p = lookup50trans8[(*p << 8) | color.D8];
- break;
- case 3:
- *p = lookup25trans8[(*p << 8) | color.D8];
- break;
- default:
- break;
- }
-}
-
-/**
-** Draw pixel unclipped into 8bit framebuffer (ignoring alpha).
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-*/
-local void DrawNoTransPixel8(VMemType color, int x, int y,
- unsigned char alpha __attribute__((unused)))
-{
- DrawPixel8(color, x, y);
-}
-
-/**
-** Draw translucent pixel unclipped into 15bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-**
-** For 15bit |-RRRRRGGGGGBBBBB|, we need for each 5bit offically:
-** (5bit - 5bit) * 8bit alpha = 14bit signed int
-**
-** But Lutz has a smarter way, all in one unsigned 32bit:
-** color = |------GGGGG-----RRRRR------BBBBB|
-** c1 - c2 = |-SSSSSGGGGGSSSSSRRRRR-SSSSSBBBBB|
-** * alpha = |-GGGGGGGGGGSRRRRRRRRR-SBBBBBBBBB|
-** newcolor = |------GGGGG-----RRRRR------BBBBB|
-*/
-local void DrawTransPixel15(VMemType color, int x, int y,
- unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
-
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- alpha >>= 3; //FIXME: only 5bits available between colors
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x03E07C1F; //FIXME:
alpha==256 unreached
- *p = (dp >> 16) | dp;
-}
-
-/**
-** Draw translucent pixel unclipped into 16bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-**
-** For 16bit |RRRRRGGGGGGBBBBB|, we need offically:
-** (5bit - 5bit) * 8bit alpha = 14bit signed int
-** (6bit - 6bit) * 8bit alpha = 15bit signed int
-**
-** But Lutz has a smarter way, all in one unsigned 32bit:
-** color = |-----GGGGGG-----RRRRR------BBBBB|
-** c1 - c2 = |SSSSSGGGGGGSSSSSRRRRRSSSSSSBBBBB|
-** * alpha = |SGGGGGGGGGGSRRRRRRRRRSBBBBBBBBBB|
-** newcolor = |-----GGGGGG-----RRRRR------BBBBB|
-*/
-local void DrawTransPixel16(VMemType color, int x, int y,
- unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
-
- p = VideoMemory16 + x + y * VideoWidth;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- alpha >>= 3; //FIXME: only 5bits available between colors
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x07E0F81F; //FIXME:
alpha==256 unreached
- *p = (dp >> 16) | dp;
-}
-
-/**
-** Draw translucent pixel unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransPixel24(VMemType color, int x, int y,
- unsigned char alpha __attribute__((unused)))
-{
-//FIXME: does 24bpp represents R|G|B?
- VideoMemory24[x + y * VideoWidth] = color.D24;
-}
-
-/**
-** Draw translucent pixel unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-**
-** For 32bit |AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB|, we need offically:
-** (8bit - 8bit) * 8bit alpha = 17bit signed int
-**
-** a smarter way, all in two unsigned 32bit:
-** color(1) = |--------RRRRRRRR--------BBBBBBBB|
-** c1(1)-c2(1) = |SSSSSSSSRRRRRRRRSSSSSSSSBBBBBBBB|
-** * alpha = |SRRRRRRRRRRRRRRRSBBBBBBBBBBBBBBB|
-** newcolor(1) = |--------RRRRRRRR--------BBBBBBBB|
-**
-** color(2) = |--------AAAAAAAA--------GGGGGGGG|
-** c1(2)-c2(2) = |SSSSSSSSAAAAAAAASSSSSSSSGGGGGGGG|
-** * alpha = |SAAAAAAAAAAAAAAASGGGGGGGGGGGGGGG|
-** newcolor(2) = |--------AAAAAAAA--------GGGGGGGG|
-**
-** FIXME: alpha blending the A-value of 32bit may not be needed.. always 0
-*/
-local void DrawTransPixel32(VMemType color, int x, int y,
- unsigned char alpha)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
-
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- p = VideoMemory32 + y * VideoWidth + x;
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- //FIXME: alpha==256 unreached
- dp1 = ((((dp1-sp1) * alpha) >> 8) + sp1) & 0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) + sp2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-}
-
-/**
-** Draw translucent pixel unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixel.
-*/
-#ifdef USE_OPENGL
-local void DrawTransPixelOpenGL(VMemType color, int x, int y,
- unsigned char alpha)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw pixel clipped to current clip setting into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixelClip8(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoMemory8[x + y * VideoWidth] = color.D8;
-}
-
-/**
-** Draw pixel clipped to current clip setting into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixelClip16(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoMemory16[x + y * VideoWidth] = color.D16;
-}
-
-/**
-** Draw pixel clipped to current clip setting into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixelClip24(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoMemory24[x + y * VideoWidth] = color.D24;
-}
-
-/**
-** Draw pixel clipped to current clip setting into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void DrawPixelClip32(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoMemory32[x + y * VideoWidth] = color.D32;
-}
-
-/**
-** Draw pixel clipped to current clip setting.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void DrawPixelClipOpenGL(VMemType color, int x, int y)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_POINTS);
- glVertex2i(x, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 25% translucent pixel clipped to current clip setting.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void VideoDraw25TransPixelClip(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoDraw25TransPixel(color, x, y);
-}
-
-/**
-** Draw 50% translucent pixel clipped to current clip setting.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void VideoDraw50TransPixelClip(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoDraw50TransPixel(color, x, y);
-}
-
-/**
-** Draw 75% translucent pixel clipped to current clip setting.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-global void VideoDraw75TransPixelClip(VMemType color, int x, int y)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoDraw75TransPixel(color, x, y);
-}
-
-/**
-** Draw translucent pixel clipped to current clip setting.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param alpha alpha value of pixels.
-*/
-global void VideoDrawTransPixelClip(VMemType color, int x, int y,
- unsigned char alpha)
-{
- // Clipping:
- if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
- return;
- }
- VideoDrawTransPixel(color, x, y, alpha);
-}
-
-// ===========================================================================
-// Horizontal Line
-// ===========================================================================
-
-/**
-** Draw horizontal line unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line.
-*/
-local void DrawHLine8(VMemType color, int x, int y, int width)
-{
- VMemType8* p;
- VMemType8* e;
- int w;
- unsigned f;
-
- w = VideoWidth;
- p = VideoMemory8 + y * w + x;
- e = p + width;
- f = color.D8;
-
- while (p < e) { // FIXME:
better!
- *p++ = f;
- }
-}
-
-/**
-** Draw horizontal line unclipped into 16bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void DrawHLine16(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long f;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width-1;
- f = ((unsigned long)color.D16 << 16) | color.D16;
-
- while (p < e) { // draw 2 pixels
- *((unsigned long*)p)++ = f;
- }
-
- if (p <= e) {
- *p = f;
- }
-}
-
-/**
-** Draw horizontal line unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void DrawHLine24(VMemType color, int x, int y, int width)
-{
- VMemType24* p;
- VMemType24* e;
- int w;
- VMemType24 f;
-
- w = VideoWidth;
- p = VideoMemory24 + y * w + x;
- e = p + width;
- f = color.D24;
-
- while (p < e) {
- *p++ = f;
- }
-}
-
-/**
-** Draw horizontal line unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void DrawHLine32(VMemType color, int x, int y, int width)
-{
- VMemType32* p;
- VMemType32* e;
- int w;
- unsigned long f;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- e = p + width;
- f = color.D32;
-
- while (p < e) {
- *p++ = f;
- }
-}
-
-/**
-** Draw horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void DrawHLineOpenGL(VMemType color, int x, int y, int width)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 25% translucent horizontal line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw25TransHLine8(VMemType color, int x, int y, int width)
-{
- VMemType8* p;
- VMemType8* e;
- unsigned int c;
-
- p = VideoMemory8 + x + y * VideoWidth;
- e = p + width;
- c = color.D8 << 8;
-
- while (p < e) {
- *p = lookup25trans8[c | *p];
- ++p;
- }
-}
-
-/**
-** Draw 25% translucent horizontal line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw25TransHLine15(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long sp;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x03E07C1F) * 3;
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw 25% translucent horizontal line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw25TransHLine16(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long sp;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x07E0F81F) * 3;
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw 25% translucent horizontal line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw25TransHLine24(VMemType color, int x, int y, int width)
-{
-// FIXME: does 24bpp holds R|G|B ?
- DrawHLine24(color, x, y, width); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 25% translucent horizontal line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw25TransHLine32(VMemType color, int x, int y, int width)
-{
- VMemType32* p;
- VMemType32* e;
- unsigned long sp1;
- unsigned long sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- e = p + width;
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = ((sp1 & 0xFF00FF00) >> 8) * 3;
- sp1 = (sp1 & 0x00FF00FF) * 3;
-
- while (p < e) {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- }
-}
-
-/**
-** Draw 25% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw25TransHLineOpenGL(VMemType color, int x, int y, int width)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 50% translucent horizontal line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw50TransHLine8(VMemType color, int x, int y, int width)
-{
- VMemType8* p;
- VMemType8* e;
- unsigned int c;
-
- p = VideoMemory8 + x + y * VideoWidth;
- e = p + width;
- c = color.D8 << 8;
-
- while (p < e) {
- *p = lookup50trans8[c | *p];
- ++p;
- }
-}
-
-/**
-** Draw 50% translucent horizontal line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw50TransHLine15(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long sp;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw 50% translucent horizontal line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw50TransHLine16(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long sp;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw 50% translucent horizontal line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw50TransHLine24(VMemType color, int x, int y, int width)
-{
-// FIXME: does 24bpp holds R|G|B ?
- DrawHLine24(color, x, y, width); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 50% translucent horizontal line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw50TransHLine32(VMemType color, int x, int y, int width)
-{
- VMemType32* p, *e;
- unsigned long sp1, sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- e = p + width;
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- while (p < e) {
- unsigned long dp1, dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- }
-}
-
-/**
-** Draw 50% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw50TransHLineOpenGL(VMemType color, int x, int y, int width)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 75% translucent horizontal line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw75TransHLine8(VMemType color, int x, int y, int width)
-{
- VMemType8* p;
- VMemType8* e;
- unsigned int c;
-
- p = VideoMemory8 + x + y * VideoWidth;
- e = p + width;
- c = color.D8;
-
- while (p < e) {
- *p = lookup25trans8[(*p << 8) | c];
- ++p;
- }
-}
-
-/**
-** Draw 75% translucent horizontal line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw75TransHLine15(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long sp;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw 75% translucent horizontal line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw75TransHLine16(VMemType color, int x, int y, int width)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- unsigned long sp;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + width;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw 75% translucent horizontal line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw75TransHLine24(VMemType color, int x, int y, int width)
-{
-// FIXME: does 24bpp holds R|G|B ?
- DrawHLine24(color, x, y, width); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 75% translucent horizontal line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-local void Draw75TransHLine32(VMemType color, int x, int y, int width)
-{
- VMemType32* p;
- VMemType32* e;
- unsigned long sp1;
- unsigned long sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- e = p + width;
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- while (p < e) {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- }
-}
-
-/**
-** Draw 75% translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw75TransHLineOpenGL(VMemType color, int x, int y, int width)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw translucent horizontal line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransHLine8(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- VMemType8* p;
- VMemType8* e;
- unsigned c;
-
- p = VideoMemory8 + x + y * VideoWidth;
- e = p + width;
- c = color.D8;
-
- switch (((unsigned int)alpha * 4) / 255) {
- case 0:
- while (p < e) {
- *p++ = c;
- }
- break;
- case 1:
- while (p < e) {
- *p = lookup25trans8[(*p << 8) | c];
- ++p;
- }
- break;
- case 2:
- c <<= 8;
- while (p < e) {
- *p = lookup50trans8[c | *p];
- ++p;
- }
- break;
- case 3:
- c <<= 8;
- while (p < e) {
- *p = lookup25trans8[c | *p];
- ++p;
- }
- break;
- default:
- break;
- }
-}
-
-/**
-** Draw horizontal line unclipped into 8bit framebuffer (ignoring
alpha).
-**
-** @param color Color index
-** @param x x pixel coordinate on the screen
-** @param y y pixel coordinate on the screen
-** @param width Line width in pixel
-** @param alpha alpha value of pixel
-*/
-local void DrawNoTransHLine8(VMemType color, int x, int y, int width,
- unsigned char alpha __attribute__((unused)))
-{
- DrawHLine8(color, x, y, width);
-}
-
-/**
-** Draw translucent horizontal line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransHLine15(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- VMemType16* p;
- VMemType16* e;
- unsigned long sp;
-
- p = VideoMemory16 + y * VideoWidth + x;
- e = p + width;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- alpha >>= 3;
// FIXME: only 5bits
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x03E07C1F; //FIXME:
alpha==256 unreached
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw translucent horizontal line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransHLine16(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- VMemType16* p;
- VMemType16* e;
- unsigned long sp;
-
- p = VideoMemory16 + y * VideoWidth + x;
- e = p + width;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- alpha >>= 3;
// FIXME: only 5bits
-
- while (p < e) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x07E0F81F; //FIXME:
alpha==256 unreached
- *p++ = (dp >> 16) | dp;
- }
-}
-
-/**
-** Draw translucent horizontal line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransHLine24(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- VMemType24 c;
- VMemType24* p;
- VMemType24* e;
- unsigned spR;
- unsigned spG;
- unsigned spB;
-
- p = VideoMemory24 + y * VideoWidth + x;
- e = p + width;
- c = color.D24;
- spR = c.a;
- spG = c.b;
- spB = c.c;
- // FIXME: untested; does 24bpp holds R|G|B ?
- //FIXME: alpha==256 unreached
-
- while (p < e) {
- unsigned int i;
-
- c = *p;
-
- i = c.a;
- i = (((i - spR) * alpha) >> 8) + spR;
- c.a = i & 0xFF;
-
- i = c.b;
- i = (((i - spG) * alpha) >> 8) + spG;
- c.b = i & 0xFF;
-
- i = c.c;
- i = (((i - spB) * alpha) >> 8) + spB;
- c.c = i & 0xFF;
-
- *p++ = c;
- }
-}
-
-/**
-** Draw translucent horizontal line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransHLine32(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- VMemType32* p;
- VMemType32* e;
- unsigned long sp1;
- unsigned long sp2;
-
- p = VideoMemory32 + y * VideoWidth + x;
- e = p + width;
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- alpha >>= 1;
-
- while (p < e) {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- //FIXME: alpha==256 unreached
- dp1 = ((((dp1 - sp1) * alpha) >> 7) + sp1) & 0x00FF00FF;
- dp2 = ((((dp2 - sp2) * alpha) >> 7) + sp2) & 0x00FF00FF;
-
- *p++ = (dp1 | (dp2 << 8));
- }
-}
-
-#define CLIP_HLINE(x, y, width) { \
- if (y < ClipY1 || y > ClipY2) { \
- return; \
- } \
- if (x < ClipX1) { \
- int f = ClipX1 - x; \
- if (width <= f) { \
- return; \
- } \
- width -= f; \
- x = ClipX1; \
- } \
- if ((x + width) > ClipX2 + 1) { \
- if (x > ClipX2) { \
- return; \
- } \
- width = ClipX2 - x + 1; \
- } \
-}
-
-/**
-** Draw translucent horizontal line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-#ifdef USE_OPENGL
-local void DrawTransHLineOpenGL(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + width, VideoHeight - y);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-/**
-** Draw horizontal line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-global void VideoDrawHLineClip(VMemType color, int x, int y, int width)
-{
- CLIP_HLINE(x, y, width);
- VideoDrawHLine(color, x, y, width);
-}
-
-/**
-** Draw 25% translucent horizontal line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-global void VideoDraw25TransHLineClip(VMemType color, int x, int y, int width)
-{
- CLIP_HLINE(x, y, width);
- VideoDraw25TransHLine(color, x, y, width);
-}
-
-/**
-** Draw 50% translucent horizontal line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-global void VideoDraw50TransHLineClip(VMemType color, int x, int y, int width)
-{
- CLIP_HLINE(x, y, width);
- VideoDraw50TransHLine(color, x, y, width);
-}
-
-/**
-** Draw 75% translucent horizontal line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param width width of line (0=don't draw).
-*/
-global void VideoDraw75TransHLineClip(VMemType color, int x, int y, int width)
-{
- CLIP_HLINE(x, y, width);
- VideoDraw75TransHLine(color, x, y, width);
-}
-
-/**
-** Draw translucent horizontal line clipped.
-**
-** @param color Color index
-** @param x X pixel coordinate on the screen
-** @param y Y c pixeloordinate on the screen
-** @param width Width of line (0=don't draw)
-** @param alpha Alpha value of pixels
-*/
-global void VideoDrawTransHLineClip(VMemType color, int x, int y, int width,
- unsigned char alpha)
-{
- CLIP_HLINE(x, y, width);
- VideoDrawTransHLine(color, x, y, width,alpha);
-}
-
-// ===========================================================================
-// Vertical Line
-// ===========================================================================
-
-/**
-** Draw vertical line unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void DrawVLine8(VMemType color, int x, int y, int height)
-{
- VMemType8* p;
- VMemType8* e;
- int w;
- int f;
-
- w = VideoWidth;
- p = VideoMemory8 + y * w + x;
- e = p + height * w;
- f = color.D8;
- while (p < e) { // FIXME: better
- *p = f;
- p += w;
- }
-}
-
-/**
-** Draw vertical line unclipped into 16bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void DrawVLine16(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- VMemType16* e;
- int w;
- int f;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- e = p + height * w;
- f = color.D16;
- while (p < e) { // FIXME: better
- *p = f;
- p += w;
- }
-}
-
-/**
-** Draw vertical line unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void DrawVLine24(VMemType color, int x, int y, int height)
-{
- VMemType24* p;
- VMemType24* e;
- int w;
- VMemType24 f;
-
- w = VideoWidth;
- p = VideoMemory24 + y * w + x;
- e = p + height * w;
- f = color.D24;
- while (p < e) { // FIXME: better
- *p = f;
- p += w;
- }
-}
-
-/**
-** Draw vertical line unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void DrawVLine32(VMemType color, int x, int y, int height)
-{
- VMemType32* p;
- VMemType32* e;
- int w;
- int f;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- e = p + height * w;
- f = color.D32;
- while (p < e) { // FIXME: better
- *p = f;
- p += w;
- }
-}
-
-/**
-** Draw vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void DrawVLineOpenGL(VMemType color, int x, int y, int height)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 25% translucent vertical line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw25TransVLine8(VMemType color, int x, int y, int height)
-{
- VMemType8* p;
- unsigned int c;
- int w;
-
- w = VideoWidth;
- p = VideoMemory8 + x + y * w;
- c = color.D8 << 8;
- while (height--) {
- *p = lookup25trans8[c | *p];
- p += w;
- }
-}
-
-/**
-** Draw 25% translucent vertical line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw25TransVLine15(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x03E07C1F) * 3;
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw 25% translucent vertical line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw25TransVLine16(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x07E0F81F) * 3;
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw 25% translucent vertical line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw25TransVLine24(VMemType color, int x, int y, int height)
-{
- // FIXME: does 24bpp holds R|G|B ?
- DrawVLine24(color, x, y, height); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 25% translucent vertical line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw25TransVLine32(VMemType color, int x, int y, int height)
-{
- VMemType32* p;
- unsigned long sp1,sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = ((sp1 & 0xFF00FF00) >> 8) * 3;
- sp1 = (sp1 & 0x00FF00FF) * 3;
-
- while (height--) {
- unsigned long dp1, dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += w;
- }
-}
-
-/**
-** Draw 25% translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw25TransVLineOpenGL(VMemType color, int x, int y, int height)
-{
- VMemType32 c;
- GLubyte r,g,b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 50% translucent vertical line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw50TransVLine8(VMemType color, int x, int y, int height)
-{
- VMemType8* p;
- unsigned int c;
- int w;
-
- w = VideoWidth;
- p = VideoMemory8 + x + y * w;
- c = color.D8 << 8;
- while (height--) {
- *p = lookup50trans8[c | *p];
- p += w;
- }
-}
-
-/**
-** Draw 50% translucent vertical line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw50TransVLine15(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw 50% translucent vertical line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw50TransVLine16(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x07E0F81F;
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw 50% translucent vertical line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw50TransVLine24(VMemType color, int x, int y, int height)
-{
- // FIXME: does 24bpp holds R|G|B ?
- DrawVLine24(color, x, y, height); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 50% translucent vertical line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw50TransVLine32(VMemType color, int x, int y, int height)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- while (height--) {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += w;
- }
-}
-
-/**
-** Draw 50% translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw50TransVLineOpenGL(VMemType color, int x, int y, int height)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 75% translucent vertical line unclipped into 8bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw75TransVLine8(VMemType color, int x, int y, int height)
-{
- VMemType8* p;
- unsigned int c;
- int w;
-
- w = VideoWidth;
- p = VideoMemory8 + x + y * w;
- c = color.D8;
- while (height--) {
- *p = lookup25trans8[(*p << 8) | c];
- p += w;
- }
-}
-
-/**
-** Draw 75% translucent vertical line unclipped into 15bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw75TransVLine15(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x03E07C1F;
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw 75% translucent vertical line unclipped into 16bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw75TransVLine16(VMemType color, int x, int y, int height)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x07E0F81F;
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw 75% translucent vertical line unclipped into 24bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw75TransVLine24(VMemType color, int x, int y, int height)
-{
- // FIXME: does 24bpp holds R|G|B ?
- DrawVLine24(color, x, y, height); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 75% translucent vertical line unclipped into 32bit
framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-local void Draw75TransVLine32(VMemType color, int x, int y, int height)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- while (height--) {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += w;
- }
-}
-
-/**
-** Draw 75% translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw75TransVLineOpenGL(VMemType color, int x, int y, int height)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw translucent vertical line unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransVLine8(VMemType color, int x, int y, int height,
- unsigned char alpha)
-{
- VMemType8* p;
- unsigned int c;
- int w;
-
- w = VideoWidth;
- p = VideoMemory8 + x + y * w;
- c = color.D8;
-
- switch (((unsigned int)alpha * 4) / 255) {
- case 0:
- while (height--) {
- *p = c;
- p += w;
- }
- break;
- case 1:
- while (height--) {
- *p = lookup25trans8[(*p << 8) | c];
- p += w;
- }
- break;
- case 2:
- c <<= 8;
- while (height--) {
- *p = lookup50trans8[c | *p];
- p += w;
- }
- break;
- case 3:
- c <<= 8;
- while (height--) {
- *p = lookup25trans8[c | *p];
- p += w;
- }
- break;
- default:
- break;
- }
-}
-
-/**
-** Draw vertical line unclipped into 8bit framebuffer (ignoring
alpha).
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height Height = length of the line.
-** @param alpha alpha value of pixel.
-*/
-local void DrawNoTransVLine8(VMemType color, int x, int y, int height,
- unsigned char alpha __attribute__((unused)))
-{
- DrawVLine8(color, x, y, height);
-}
-
-/**
-** Draw translucent vertical line unclipped into 15bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransVLine15(VMemType color, int x, int y, int height,
- unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- alpha >>= 3;
// FIXME: only 5bits
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x03E07C1F; //FIXME:
alpha==256 unreached
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw translucent vertical line unclipped into 16bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransVLine16(VMemType color, int x, int y, int height,
- unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- int w;
-
- w = VideoWidth;
- p = VideoMemory16 + y * w + x;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- alpha >>= 3;
// FIXME: only 5bits
-
- while (height--) {
- unsigned long dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x07E0F81F; //FIXME:
alpha==256 unreached
- *p = (dp >> 16) | dp;
- p += w;
- }
-}
-
-/**
-** Draw translucent vertical line unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransVLine24(VMemType color, int x, int y, int height,
- unsigned char alpha __attribute__((unused)))
-{
- // FIXME: does 24bpp holds R|G|B ?
- DrawVLine24(color, x, y, height); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw translucent vertical line unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-local void DrawTransVLine32(VMemType color, int x, int y, int height,
- unsigned char alpha)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int w;
-
- w = VideoWidth;
- p = VideoMemory32 + y * w + x;
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- while (height--) {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- //FIXME: alpha==256 unreached
- dp1 = ((((dp1-sp1) * alpha) >> 8) + sp1) & 0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) + sp2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += w;
- }
-}
-
-#define CLIP_VLINE(x, y, width) { \
- if (x < ClipX1 || x > ClipX2) { \
- return; \
- } \
- if (y < ClipY1) { \
- int f = ClipY1 - y; \
- if (height <= f) { \
- return; \
- } \
- height -= f; \
- y = ClipY1; \
- } \
- if ((y + height) > ClipY2 + 1) { \
- if (y > ClipY2) { \
- return; \
- } \
- height = ClipY2 - y + 1; \
- } \
-}
-
-/**
-** Draw translucent vertical line unclipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-#ifdef USE_OPENGL
-local void DrawTransVLineOpenGL(VMemType color, int x, int y, int height,
- unsigned char alpha)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_LINES);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + height));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw vertical line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-global void VideoDrawVLineClip(VMemType color, int x, int y, int height)
-{
- CLIP_VLINE(x, y, height);
- VideoDrawVLine(color, x, y, height);
-}
-
-/**
-** Draw 25% translucent vertical line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-global void VideoDraw25TransVLineClip(VMemType color, int x, int y,
- int height)
-{
- CLIP_VLINE(x, y, height);
- VideoDraw25TransVLine(color, x, y, height);
-}
-
-/**
-** Draw 50% translucent vertical line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-global void VideoDraw50TransVLineClip(VMemType color, int x, int y,
- int height)
-{
- CLIP_VLINE(x, y, height);
- VideoDraw50TransVLine(color, x, y, height);
-}
-
-/**
-** Draw 75% translucent vertical line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-*/
-global void VideoDraw75TransVLineClip(VMemType color, int x, int y,
- int height)
-{
- CLIP_VLINE(x, y, height);
- VideoDraw75TransVLine(color, x, y, height);
-}
-
-/**
-** Draw translucent vertical line clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param height height of line (0=don't draw).
-** @param alpha alpha value of pixels.
-*/
-global void VideoDrawTransVLineClip(VMemType color, int x, int y,
- int height, unsigned char alpha)
-{
- CLIP_VLINE(x, y, height);
- VideoDrawTransVLine(color, x, y, height, alpha);
-}
-
-// ===========================================================================
-// General Line
-// ===========================================================================
-
-/**
-** Draw line unclipped into 8bit framebuffer.
-**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
-*/
-local void DrawLine8(VMemType color, int x1, int y1, int x2, int y2)
-{
- int d;
- int dx;
- int dy;
- int xstep;
- VMemType8* p;
- int w;
- unsigned f;
-
- if (x1 == x2) {
- if (y1<y2) {
- DrawVLine8(color, x1, y1, y2 - y1 + 1);
- } else {
- DrawVLine8(color, x2, y2, y1 - y2 + 1);
- }
- return;
- }
- if (y1 == y2) {
- if (x1 < x2) {
- DrawHLine8(color, x1, y1, x2 - x1 + 1);
- } else {
- DrawHLine8(color, x2, y2, x1 - x2 + 1);
- }
- return;
- }
-
- // initialize
-
- w = VideoWidth;
- f = color.D8;
-
- if (y1 > y2) { // exchange coordinates
- x1 ^= x2; x2 ^= x1; x1 ^= x2;
- y1 ^= y2; y2 ^= y1; y1 ^= y2;
- }
- dy = y2 - y1;
- xstep = 1;
- dx = x2 - x1;
- if (dx < 0) {
- dx = -dx;
- xstep = -1;
- }
-
- p = VideoMemory8 + w * y1 + x1;
- *p = f;
-
- if (dx < dy) { // step in vertical direction
- d = dy - 1;
- dx += dx;
- dy += dy;
- while (y1 != y2) {
- y1++;
- p += w;
- d -= dx;
- if (d < 0) {
- d += dy;
- p += xstep;
- }
- *p = f;
- }
- return;
- }
-
- if (dx > dy) { // step in horizontal direction
- d = dx - 1;
- dx += dx;
- dy += dy;
-
- while (x1 != x2) {
- x1 += xstep;
- p += xstep;
- d -= dy;
- if (d < 0) {
- d += dx;
- p += w;
- }
- *p = f;
- }
- return;
- }
-
- while (y1 != y2) { //
diagonal line
- //x1 += xstep;
- p += xstep;
- y1++;
- p += w;
- *p = f;
- }
-}
-
-/**
-** Draw line unclipped into 16bit framebuffer.
-**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
-*/
-local void DrawLine16(VMemType color, int x1, int y1, int x2, int y2)
-{
- int d;
- int dx;
- int dy;
- int xstep;
- VMemType16* p;
- int w;
- unsigned f;
-
- if (x1 == x2) {
- if (y1 < y2) {
- DrawVLine16(color, x1, y1, y2 - y1 + 1);
- } else {
- DrawVLine16(color, x2, y2, y1 - y2 + 1);
- }
- return;
- }
- if (y1 == y2) {
- if (x1 < x2) {
- DrawHLine16(color, x1, y1, x2 - x1 + 1);
- } else {
- DrawHLine16(color, x2, y2, x1 - x2 + 1);
- }
- return;
- }
-
- // initialize
-
- w = VideoWidth;
- f = color.D16;
-
- if (y1 > y2) { // exchange coordinates
- x1 ^= x2; x2 ^= x1; x1 ^= x2;
- y1 ^= y2; y2 ^= y1; y1 ^= y2;
- }
- dy = y2 - y1;
- xstep = 1;
- dx = x2 - x1;
- if (dx < 0) {
- dx = -dx;
- xstep = -1;
- }
-
- p = VideoMemory16 + w * y1 + x1;
- *p = f;
-
- if (dx < dy) { // step in vertical direction
- d = dy - 1;
- dx += dx;
- dy += dy;
- while (y1 != y2) {
- y1++;
- p += w;
- d -= dx;
- if (d < 0) {
- d += dy;
- p += xstep;
- }
- *p = f;
- }
- return;
- }
-
- if (dx > dy) { // step in horizontal direction
- d = dx - 1;
- dx += dx;
- dy += dy;
-
- while (x1 != x2) {
- x1 += xstep;
- p += xstep;
- d -= dy;
- if (d < 0) {
- d += dx;
- p += w;
- }
- *p = f;
- }
- return;
- }
-
- while (y1 != y2) { //
diagonal line
- //x1 += xstep;
- p += xstep;
- y1++;
- p += w;
- *p = f;
- }
-}
-
-/**
-** Draw line unclipped into 24bit framebuffer.
-**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
-*/
-local void DrawLine24(VMemType color, int x1, int y1, int x2, int y2)
-{
- int d;
- int dx;
- int dy;
- int xstep;
- VMemType24* p;
- int w;
- VMemType24 f;
-
- if (x1 == x2) {
- if (y1<y2) {
- DrawVLine24(color, x1, y1, y2 - y1 + 1);
- } else {
- DrawVLine24(color, x2, y2, y1 - y2 + 1);
- }
- return;
- }
- if (y1 == y2) {
- if (x1 < x2) {
- DrawHLine24(color, x1, y1, x2 - x1 + 1);
- } else {
- DrawHLine24(color, x2, y2, x1 - x2 + 1);
- }
- return;
- }
-
- // initialize
-
- w = VideoWidth;
- f = color.D24;
-
- if (y1 > y2) { // exchange coordinates
- x1 ^= x2; x2 ^= x1; x1 ^= x2;
- y1 ^= y2; y2 ^= y1; y1 ^= y2;
- }
- dy = y2 - y1;
- xstep = 1;
- dx = x2 - x1;
- if (dx < 0) {
- dx = -dx;
- xstep = -1;
- }
-
- p = VideoMemory24 + w * y1 + x1;
- *p = f;
-
- if (dx < dy) { // step in vertical direction
- d = dy - 1;
- dx += dx;
- dy += dy;
- while (y1 != y2) {
- y1++;
- p += w;
- d -= dx;
- if (d < 0) {
- d += dy;
- p += xstep;
- }
- *p = f;
- }
- return;
- }
-
- if (dx > dy) { // step in horizontal direction
- d = dx - 1;
- dx += dx;
- dy += dy;
-
- while (x1 != x2) {
- x1 += xstep;
- p += xstep;
- d -= dy;
- if (d < 0) {
- d += dx;
- p += w;
- }
- *p = f;
- }
- return;
- }
-
- while (y1 != y2) { //
diagonal line
- //x1 += xstep;
- p += xstep;
- y1++;
- p += w;
- *p = f;
- }
-}
-
-/**
-** Draw line unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
-*/
-local void DrawLine32(VMemType color, int x1, int y1, int x2, int y2)
-{
- int d;
- int dx;
- int dy;
- int xstep;
- VMemType32* p;
- int w;
- unsigned f;
-
- if (x1 == x2) {
- if (y1 < y2) {
- DrawVLine32(color, x1, y1, y2 - y1 + 1);
- } else {
- DrawVLine32(color, x2, y2, y1 - y2 + 1);
- }
- return;
- }
- if (y1 == y2) {
- if (x1 < x2) {
- DrawHLine32(color, x1, y1, x2 - x1 + 1);
- } else {
- DrawHLine32(color, x2, y2, x1 - x2 + 1);
- }
- return;
- }
-
- // initialize
-
- w = VideoWidth;
- f = color.D32;
-
- if (y1 > y2) { // exchange coordinates
- x1 ^= x2; x2 ^= x1; x1 ^= x2;
- y1 ^= y2; y2 ^= y1; y1 ^= y2;
- }
- dy = y2 - y1;
- xstep = 1;
- dx = x2 - x1;
- if (dx < 0) {
- dx = -dx;
- xstep = -1;
- }
-
- p = VideoMemory32 + w * y1 + x1;
- *p = f;
-
- if (dx < dy) { // step in vertical direction
- d = dy - 1;
- dx += dx;
- dy += dy;
- while (y1 != y2) {
- y1++;
- p += w;
- d -= dx;
- if (d < 0) {
- d += dy;
- p += xstep;
- }
- *p = f;
- }
- return;
- }
-
- if (dx > dy) { // step in horizontal direction
- d = dx - 1;
- dx += dx;
- dy += dy;
-
- while (x1 != x2) {
- x1 += xstep;
- p += xstep;
- d -= dy;
- if (d < 0) {
- d += dx;
- p += w;
- }
- *p = f;
- }
- return;
- }
-
- while (y1 != y2) { //
diagonal line
- //x1 += xstep;
- p += xstep;
- y1++;
- p += w;
- *p = f;
- }
-}
-
-/**
-** Draw line unclipped into 32bit framebuffer.
-**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void DrawLineOpenGL(VMemType color, int x1, int y1, int x2, int y2)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_LINES);
- glVertex2i(x1, VideoHeight - y1);
- glVertex2i(x2, VideoHeight - y2);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Delivers bitmask denoting given point is left/right/above/below
-** clip rectangle, used for faster determinination of clipped position.
-**
-** @param x pixel's x position (not restricted to
screen width)
-** @param y pixel's y position (not restricted to
screen height)
-*/
-static ClipCode ClipCodeLine(int x, int y)
-{
- ClipCode result;
-
- if (y < ClipY1) {
- result = ClipCodeAbove;
- } else if (y > ClipY2) {
- result = ClipCodeBelow;
- } else {
- result = ClipCodeInside;
- }
-
- if (x < ClipX1) {
- result |= ClipCodeLeft;
- } else if (x > ClipX2) {
- result |= ClipCodeRight;
- }
-
- return result;
-}
-
-/**
-** Denotes entire line located at the same side outside clip
rectangle
-** (point 1 and 2 are both as left/right/above/below the clip rectangle)
-**
-** @param code1 ClipCode of one point of line
-** @param code2 ClipCode of second point of line
-*/
-static ClipCode LineIsUnclippedOnSameSide(int code1, int code2)
-{
- return code1 & code2;
-}
-
-/**
-** Denotes part of (or entire) line located outside clip rectangle
-** (point 1 and/or 2 is outside clip rectangle)
-**
-** @param code1 ClipCode of one point of line
-** @param code2 ClipCode of second point of line
-*/
-static ClipCode LineIsUnclipped(int code1, int code2)
-{
- return code1 | code2;
-}
-
-/**
-** Draw line clipped.
-** Based on Sutherland-Cohen clipping technique
-** (Replaces Liang/Barksy clipping algorithm in CVS version 1.18, which
-** might be faster, but that one contained some BUGs)
-**
-** @param color color
-** @param x1 Source x coordinate on the screen
-** @param y1 Source y coordinate on the screen
-** @param x2 Destination x coordinate on the screen
-** @param y2 Destination y coordinate on the screen
-*/
-global void VideoDrawLineClip(VMemType color, int x1, int y1, int x2, int y2)
-/* Based on Sutherland-Cohen clipping technique */
-{
- ClipCode code1;
- ClipCode code2;
- int temp;
-
-// Make sure coordinates or on/in clipped rectangle
- while (code1 = ClipCodeLine(x1, y1), code2 = ClipCodeLine(x2, y2),
- LineIsUnclipped(code1, code2)) {
- if (LineIsUnclippedOnSameSide(code1, code2)) {
- return;
- }
-
- if (!code1) {
- temp = x1; x1 = x2; x2 = temp;
- temp = y1; y1 = y2; y2 = temp;
- code1 = code2;
- }
-
- if (code1 & ClipCodeAbove) {
- temp = ClipY1;
- x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 -
y1));
- y1 = temp;
- } else if (code1 & ClipCodeBelow) {
- temp = ClipY2;
- x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 -
y1));
- y1 = temp;
- } else if (code1 & ClipCodeLeft) {
- temp = ClipX1;
- y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 -
x1));
- x1 = temp;
- } else { /* code1 & ClipCodeRight */
- temp = ClipX2;
- y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 -
x1));
- x1 = temp;
- }
- }
-
-//Draw line based on clipped coordinates
-//FIXME: As the clipped coordinates are rounded to integers, the line's
-// direction vector might be slightly off. Somehow, the sub-pixel
-// position(s) on the clipped retangle should be denoted to the line
-// drawing routine..
- DebugCheck(x1 < ClipX1 || x2 < ClipX1 || x1 > ClipX2 || x2 > ClipX2 ||
- y1 < ClipY1 || y2 < ClipY1 || y1 > ClipY2 || y2 > ClipY2);
- VideoDrawLine(color, x1, y1, x2, y2);
-}
-
-// ===========================================================================
-// Rectangle
-// ===========================================================================
-
-/**
-** Draw rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawRectangle8(VMemType color, int x, int y, int w, int h)
-{
- VMemType8* p;
- VMemType8 f;
- int swidth;
- int ofs;
-
- f = color.D8;
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- if (h && (ofs = w)) {
- do {
- *p++ = f; // Draw top horizontal line, FIXME: 4 bytes
in one go
- } while (--ofs);
- if (--h) {
- p += (swidth - w);
- ofs = w - 1;
- while (--h) { // Draw vertical line(s)
- p[ofs] = *p = f; //FIXME: draws pixel twice for
w == 1 :(
- p += swidth;
- }
- do {
- *p++ = f; // Draw bottom horizontal line,
FIXME: 4 bytes in one go
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw rectangle into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawRectangle16(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- VMemType16 f;
- int swidth;
- int ofs;
-
- f = color.D16;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do {
- *p++ = f; // Draw top horizontal line
- } while (--ofs);
- if (--h) {
- p += (swidth - w);
- ofs = w - 1;
- while (--h) { // Draw vertical line(s)
- p[ofs] = *p = f; //FIXME: draws pixel twice for
w == 1 :(
- p += swidth;
- }
- do {
- *p++ = f; // Draw bottom horizontal line
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw rectangle into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawRectangle24(VMemType color, int x, int y
- , int w, int h)
-{
- VMemType24* p;
- VMemType24 f;
- int swidth;
- int ofs;
-
- f = color.D24;
- swidth = VideoWidth;
- p = VideoMemory24 + y * swidth + x;
- if (h && (ofs = w)) {
- do {
- *p++ = f; // Draw top horizontal line
- } while (--ofs);
- if (--h) {
- p += (swidth - w);
- ofs = w - 1;
- while (--h) { // Draw vertical line(s)
- p[ofs] = *p = f; //FIXME: draws pixel twice for
w == 1 :(
- p += swidth;
- }
- do {
- *p++ = f; // Draw bottom horizontal line
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawRectangle32(VMemType color, int x, int y
- , int w, int h)
-{
- VMemType32* p;
- VMemType32 f;
- int swidth;
- int ofs;
-
- f = color.D32;
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- if (h && (ofs = w)) {
- do {
- *p++ = f; // Draw top horizontal line
- } while (--ofs);
- if (--h) {
- p += (swidth - w);
- ofs = w - 1;
- while (--h) { // Draw vertical line(s)
- p[ofs] = *p = f; //FIXME: draws pixel twice for
w == 1 :(
- p += swidth;
- }
- do {
- *p++ = f; // Draw bottom horizontal line
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void DrawRectangleOpenGL(VMemType color, int x, int y, int w, int h)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 25% translucent rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw25TransRectangle8(VMemType color, int x, int y, int w, int h)
-{
- VMemType8* p;
- int swidth;
- int ofs;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- c = color.D8 << 8;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- *p = lookup25trans8[c | *p];
- ++p;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- p[ofs] = lookup25trans8[c | p[ofs]];
- *p = lookup25trans8[c | *p];
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- *p = lookup25trans8[c | *p];
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- *p = lookup25trans8[c | *p];
- ++p;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 25% translucent rectangle into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw25TransRectangle15(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x03E07C1F) * 3;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- p[ofs]=(dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 25% translucent rectangle into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw25TransRectangle16(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x07E0F81F) * 3;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- p[ofs]=(dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 25% translucent rectangle into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw25TransRectangle24(VMemType color, int x, int y, int w, int h)
-{
-//FIXME: does 24bpp represents R|G|B?
- DrawRectangle24(color, x, y, w, h); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 25% translucent rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw25TransRectangle32(VMemType color, int x, int y, int w, int h)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
- int swidth;
- int ofs;
-
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = ((sp1 & 0xFF00FF00) >> 8) * 3;
- sp1 = (sp1 & 0x00FF00FF) * 3;
-
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp1 = p[ofs];
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- p[ofs] = (dp1 | (dp2 << 8));
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 25% translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw25TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 50% translucent rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw50TransRectangle8(VMemType color, int x, int y, int w, int h)
-{
- VMemType8* p;
- int swidth;
- int ofs;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- c = color.D8 << 8;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- *p = lookup50trans8[c | *p];
- ++p;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- p[ofs] = lookup50trans8[c | p[ofs]];
- *p = lookup50trans8[c | *p];
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- *p = lookup50trans8[c | *p];
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- *p = lookup50trans8[c | *p];
- ++p;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 50% translucent rectangle into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw50TransRectangle15(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- p[ofs] = (dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 50% translucent rectangle into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw50TransRectangle16(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- p[ofs] = (dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 50% translucent rectangle into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw50TransRectangle24(VMemType color, int x, int y, int w, int h)
-{
-//FIXME: does 24bpp represents R|G|B?
- DrawRectangle24(color, x, y, w, h); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 50% translucent rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw50TransRectangle32(VMemType color, int x, int y, int w, int h)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
- int swidth;
- int ofs;
-
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp1 = p[ofs];
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- p[ofs] = (dp1 | (dp2 << 8));
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 50% translucent rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw50TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 128);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw 75% translucent rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw75TransRectangle8(VMemType color, int x, int y, int w, int h)
-{
- VMemType8* p;
- int swidth;
- int ofs;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- c = color.D8;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- *p = lookup25trans8[(*p << 8) | c];
- ++p;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- p[ofs] = lookup25trans8[(p[ofs] << 8) |
c];
- *p = lookup25trans8[(*p << 8) | c];
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- *p = lookup25trans8[(*p << 8) | c];
- p += swidth;
- }
-
- do { // Draw bottom horizontal line
- *p = lookup25trans8[(*p << 8) | c];
- ++p;
- } while (ofs--);
- }
- }
- }
-}
-
-/**
-** Draw 75% translucent rectangle into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw75TransRectangle15(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) &
0x03E07C1F;
- p[ofs] = (dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) &
0x03E07C1F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) &
0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 75% translucent rectangle into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw75TransRectangle16(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) &
0x07E0F81F;
- p[ofs] = (dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) &
0x07E0F81F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) &
0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 75% translucent rectangle into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw75TransRectangle24(VMemType color, int x, int y, int w, int h)
-{
-//FIXME: does 24bpp represents R|G|B?
- DrawRectangle24(color, x, y, w, h); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw 75% translucent rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void Draw75TransRectangle32(VMemType color, int x, int y, int w, int h)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
- int swidth;
- int ofs;
-
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp1 = p[ofs];
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) &
0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) &
0x00FF00FF;
- p[ofs] = (dp1 | (dp2 << 8));
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) &
0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) &
0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) &
0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) &
0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) &
0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) &
0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw 75% translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void Draw75TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw translucent rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransRectangle8(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- switch (((unsigned int)alpha * 4) / 255) {
- case 0:
- DrawRectangle8(color, x, y, w, h);
- break;
- case 1:
- Draw25TransRectangle8(color, x, y, w, h);
- break;
- case 2:
- Draw50TransRectangle8(color, x, y, w, h);
- break;
- case 3:
- Draw75TransRectangle8(color, x, y, w, h);
- break;
- default:
- break;
- }
-}
-
-/**
-** Draw rectangle into 8bpp frame buffer (ignoring alpha).
-**
-** @param color Color index
-** @param x X pixel coordinate on the screen
-** @param y Y pixel coordinate on the screen
-** @param w Width in pixel of the rectangle
-** @param h Height in pixel of the rectangle
-** @param alpha Alpha value of pixel
-*/
-local void DrawNoTransRectangle8(VMemType color, int x, int y,
- int w, int h, unsigned char alpha __attribute__((unused)))
-{
- DrawRectangle8(color, x, y, w, h);
-}
-
-/**
-** Draw translucent rectangle into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransRectangle15(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- //FIXME: alpha==256 unreached
- alpha >>= 3; //FIXME: only
5bits
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp)
& 0x03E07C1F;
- p[ofs] = (dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp)
& 0x03E07C1F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp)
& 0x03E07C1F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) &
0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw translucent rectangle into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransRectangle16(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- unsigned long dp;
- int swidth;
- int ofs;
-
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- //FIXME: alpha==256 unreached
- alpha >>= 3; //FIXME: only
5bits
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--ofs);
-
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp = p[ofs];
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp)
& 0x07E0F81F;
- p[ofs] = (dp >> 16) | dp;
-
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp)
& 0x07E0F81F;
- *p = (dp >> 16) | dp;
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp)
& 0x07E0F81F;
- *p = (dp >> 16) | dp;
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) &
0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw translucent rectangle into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransRectangle24(VMemType color, int x, int y,
- int w, int h, unsigned char alpha __attribute__((unused)))
-{
-//FIXME: does 24bpp represents R|G|B?
- DrawRectangle24(color, x, y, w, h); // no trans functionaility for the
moment :(
-}
-
-/**
-** Draw translucent rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawTransRectangle32(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
- int swidth;
- int ofs;
-
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- //FIXME: alpha==256 unreached
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- if (h && (ofs = w)) {
- do { // Draw top horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((((dp1-sp1) * alpha) >> 8) + sp1) & 0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) + sp2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--ofs);
- if (--h) {
- p += (swidth - w);
- if ((ofs = w - 1)) {
- while (--h) { // Draw two vertical lines
- dp1 = p[ofs];
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((((dp1-sp1) * alpha) >> 8) +
sp1) & 0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) +
sp2) & 0x00FF00FF;
- p[ofs] = (dp1 | (dp2 << 8));
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((((dp1-sp1) * alpha) >> 8) +
sp1) & 0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) +
sp2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
-
- p += swidth;
- }
- } else {
- while (--h) { // Draw one vertical line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((((dp1-sp1) * alpha) >> 8) +
sp1) & 0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) +
sp2) & 0x00FF00FF;
- *p = (dp1 | (dp2 << 8));
- p += swidth;
- }
- }
-
- do { // Draw bottom horizontal line
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = ((((dp1-sp1) * alpha) >> 8) + sp1) &
0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) + sp2) &
0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (ofs--);
- }
- }
-}
-
-/**
-** Draw translucent rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-#ifdef USE_OPENGL
-local void DrawTransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - (y + h));
- glVertex2i(x, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Draw rectangle clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-global void VideoDrawRectangleClip(VMemType color, int x, int y,
- int w, int h)
-{
- #define _x x
- #define _y y
- #define _w w
- #define _h h
- #define _hline(x, y,w) VideoDrawHLine(color, x, y,w)
- #define _vline(x, y,h) VideoDrawVLine(color, x, y,h)
-
- #include "_clip_rectangle"
-
- #undef _x
- #undef _y
- #undef _w
- #undef _h
- #undef _hline
- #undef _vline
-}
-
-/**
-** Draw 25% translucent rectangle clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-global void VideoDraw25TransRectangleClip(VMemType color, int x, int y,
- int w, int h)
-{
- #define _x x
- #define _y y
- #define _w w
- #define _h h
- #define _hline(x, y,w) VideoDraw25TransHLine(color, x, y,w)
- #define _vline(x, y,h) VideoDraw25TransVLine(color, x, y,h)
-
- #include "_clip_rectangle"
-
- #undef _x
- #undef _y
- #undef _w
- #undef _h
- #undef _hline
- #undef _vline
-}
-
-/**
-** Draw 50% translucent rectangle clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-global void VideoDraw50TransRectangleClip(VMemType color, int x, int y,
- int w, int h)
-{
- #define _x x
- #define _y y
- #define _w w
- #define _h h
- #define _hline(x, y,w) VideoDraw50TransHLine(color, x, y,w)
- #define _vline(x, y,h) VideoDraw50TransVLine(color, x, y,h)
-
- #include "_clip_rectangle"
-
- #undef _x
- #undef _y
- #undef _w
- #undef _h
- #undef _hline
- #undef _vline
-}
-
-/**
-** Draw 75% translucent rectangle clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-global void VideoDraw75TransRectangleClip(VMemType color, int x, int y,
- int w, int h)
-{
- #define _x x
- #define _y y
- #define _w w
- #define _h h
- #define _hline(x, y,w) VideoDraw75TransHLine(color, x, y,w)
- #define _vline(x, y,h) VideoDraw75TransVLine(color, x, y,h)
-
- #include "_clip_rectangle"
-
- #undef _x
- #undef _y
- #undef _w
- #undef _h
- #undef _hline
- #undef _vline
-}
-
-/**
-** Draw translucent rectangle clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-global void VideoDrawTransRectangleClip(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- #define _x x
- #define _y y
- #define _w w
- #define _h h
- #define _hline(x, y,w) VideoDrawTransHLine(color, x, y,w,alpha)
- #define _vline(x, y,h) VideoDrawTransVLine(color, x, y,h,alpha)
-
- #include "_clip_rectangle"
-
- #undef _x
- #undef _y
- #undef _w
- #undef _h
- #undef _hline
- #undef _vline
-}
-
-// ===========================================================================
-// Circle
-// ===========================================================================
-
-// FIXME: could write a general circle function?
-
-/**
-** Draw circle.
-**
-** @param color color
-** @param x Center x coordinate on the screen
-** @param y Center y coordinate on the screen
-** @param r radius of circle
-*/
-global void VideoDrawCircle(VMemType color, int x, int y, int r)
-{
- int cx;
- int cy;
- int df;
- int d_e;
- int d_se;
-
- cx = 0;
- cy = r;
- df = 1 - r;
- d_e = 3;
- d_se = -2 * r + 5;
-
- // FIXME: could much improved :)
- do {
- if (cx == 0) {
- VideoDrawPixel(color, x, y + cy);
- VideoDrawPixel(color, x, y - cy);
- VideoDrawPixel(color, x + cy, y);
- VideoDrawPixel(color, x - cy, y);
- } else if (cx == cy) {
- DebugCheck(cx == 0 || cy == 0);
- VideoDrawPixel(color,x + cx, y + cy);
- VideoDrawPixel(color,x - cx, y + cy);
- VideoDrawPixel(color,x + cx, y - cy);
- VideoDrawPixel(color,x - cx, y - cy);
- } else if (cx < cy) {
- DebugCheck(cx == 0 || cy == 0);
- VideoDrawPixel(color, x + cx, y + cy);
- VideoDrawPixel(color, x + cx, y - cy);
- VideoDrawPixel(color, x + cy, y + cx);
- VideoDrawPixel(color, x + cy, y - cx);
- VideoDrawPixel(color, x - cx, y + cy);
- VideoDrawPixel(color, x - cx, y - cy);
- VideoDrawPixel(color, x - cy, y + cx);
- VideoDrawPixel(color, x - cy, y - cx);
- }
- if (df < 0) {
- df += d_e;
- d_se += 2;
- } else {
- df += d_se;
- d_se += 4;
- cy--;
- }
- d_e += 2;
- cx++;
- } while (cx <= cy);
-}
-
-/**
-** Draw circle clipped.
-**
-** @param color color
-** @param x Center x coordinate on the screen
-** @param y Center y coordinate on the screen
-** @param r radius of circle
-*/
-global void VideoDrawCircleClip(VMemType color, int x, int y, int r)
-{
- int cx;
- int cy;
- int df;
- int d_e;
- int d_se;
-
- cx = 0;
- cy = r;
- df = 1 - r;
- d_e = 3;
- d_se = -2 * r + 5;
-
- // FIXME: could much improved :)
- do {
- if (cx == 0) {
- VideoDrawPixelClip(color, x, y + cy);
- VideoDrawPixelClip(color, x, y - cy);
- VideoDrawPixelClip(color, x + cy, y);
- VideoDrawPixelClip(color, x - cy, y);
- } else if (cx == cy) {
- DebugCheck(cx == 0 || cy == 0);
- VideoDrawPixelClip(color, x + cx, y + cy);
- VideoDrawPixelClip(color, x - cx, y + cy);
- VideoDrawPixelClip(color, x + cx, y - cy);
- VideoDrawPixelClip(color, x - cx, y - cy);
- } else if (cx < cy) {
- DebugCheck(cx == 0 || cy == 0);
- VideoDrawPixelClip(color, x + cx, y + cy);
- VideoDrawPixelClip(color, x + cx, y - cy);
- VideoDrawPixelClip(color, x + cy, y + cx);
- VideoDrawPixelClip(color, x + cy, y - cx);
- VideoDrawPixelClip(color, x - cx, y + cy);
- VideoDrawPixelClip(color, x - cx, y - cy);
- VideoDrawPixelClip(color, x - cy, y + cx);
- VideoDrawPixelClip(color, x - cy, y - cx);
- }
- if (df < 0) {
- df += d_e;
- d_se += 2;
- } else {
- df += d_se;
- d_se += 4;
- cy--;
- }
- d_e += 2;
- cx++;
- } while (cx <= cy);
-}
-
-// ===========================================================================
-// Filled rectangle
-// ===========================================================================
-
-/**
-** Fill rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFillRectangle8(VMemType color, int x, int y, int w, int h)
-{
- VMemType8* p;
- VMemType8 f;
- int swidth;
- int i;
-
- f = color.D8;
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- swidth -= w;
- if (w) {
- while (h--) {
- i = w;
- do {
- *p++ = f;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFillRectangle16(VMemType color, int x, int y, int w, int h)
-{
- VMemType16* p;
- VMemType16 f;
- int swidth;
- int i;
-
- f = color.D16;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- if (w) {
- while (h--) {
- i = w;
- do {
- *p++ = f;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFillRectangle24(VMemType color, int x, int y, int w, int h)
-{
- VMemType24* p;
- VMemType24 f;
- int swidth;
- int i;
-
- f = color.D24;
- swidth = VideoWidth;
- p = VideoMemory24 + y * swidth + x;
- swidth -= w;
- if (w) {
- while (h--) {
- i = w;
- do {
- *p++ = f;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFillRectangle32(VMemType color, int x, int y, int w, int h)
-{
- VMemType32* p;
- VMemType32 f;
- int swidth;
- int i;
-
- f = color.D32;
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- swidth -= w;
- if (w) {
- while (h--) {
- i = w;
- do {
- *p++ = f;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void DrawFillRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor3ub(r, g, b);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Fill rectangle 25% translucent clipped into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill25TransRectangle8(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType8* p;
- int i;
- int swidth;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- swidth -= w;
- c = color.D8 << 8;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- *p = lookup25trans8[c | *p];
- ++p;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 25% translucent clipped into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill25TransRectangle15(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x03E07C1F) * 3;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 25% translucent clipped into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill25TransRectangle16(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- // FIXME: pre multiply?
- sp = (((sp << 16) | sp) & 0x07E0F81F) * 3;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 25% translucent clipped into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill25TransRectangle24(VMemType color, int x, int y,
- int w, int h)
-{
-// FIXME: does 24bpp holds R|G|B ?
- DrawFillRectangle24(color, x, y, w, h); // no trans functionaility :(
-}
-
-/**
-** Fill rectangle 25% translucent clipped into 32bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill25TransRectangle32(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- swidth -= w;
-
- sp1 = color.D32;
- // FIXME: pre multiply?
- sp2 = ((sp1 & 0xFF00FF00) >> 8) * 3;
- sp1 = (sp1 & 0x00FF00FF) * 3;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((dp1 + sp1) >> 2) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 2) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 25% translucent clipped.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-#ifdef USE_OPENGL
-local void DrawFill25TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType32 c;
- GLubyte r;
- GLubyte g;
- GLubyte b;
-
- c = color.D32;
- r = (c >> 16) & 0xff;
- g = (c >> 8) & 0xff;
- b = (c >> 0) & 0xff;
- glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 192);
- glBegin(GL_TRIANGLE_STRIP);
- glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
- glEnd();
- glEnable(GL_TEXTURE_2D);
-}
-#endif
-
-/**
-** Fill rectangle 50% translucent clipped into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill50TransRectangle8(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType8* p;
- int i;
- int swidth;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- swidth -= w;
- c = color.D8 << 8;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- *p = lookup50trans8[c | *p];
- ++p;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 50% translucent clipped into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill50TransRectangle15(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = ((dp + sp) >> 1) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 50% translucent clipped into 16bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill50TransRectangle16(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((dp + sp) >> 1) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
-}
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
-/**
-** Fill rectangle 50% translucent clipped into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill50TransRectangle24(VMemType color, int x, int y,
- int w, int h)
-{
-// FIXME: how does 24bpp represents RGB ?
- DrawFillRectangle24(color, x, y, w, h); // no trans functionaility :(
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor3ub(r, g, b);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + height));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Fill rectangle 50% translucent clipped into 32bpp frame buffer.
+** Draw 25% translucent vertical line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param height height of line (0=don't draw).
*/
-local void DrawFill50TransRectangle32(VMemType color, int x, int y,
- int w, int h)
+#ifdef USE_OPENGL
+local void Draw25TransVLineOpenGL(VMemType color, int x, int y, int height)
{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int i;
- int swidth;
+ VMemType32 c;
+ GLubyte r,g,b;
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- swidth -= w;
-
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((dp1 + sp1) >> 1) & 0x00FF00FF;
- dp2 = ((dp2 + sp2) >> 1) & 0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--i);
- p += swidth;
- }
- }
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 192);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + height));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Fill rectangle 50% translucent clipped.
+** Draw 50% translucent vertical line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param height height of line (0=don't draw).
*/
#ifdef USE_OPENGL
-local void DrawFill50TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+local void Draw50TransVLineOpenGL(VMemType color, int x, int y, int height)
{
VMemType32 c;
GLubyte r;
@@ -6961,190 +1435,109 @@
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
glColor4ub(r, g, b, 128);
- glBegin(GL_TRIANGLE_STRIP);
+ glBegin(GL_LINES);
glVertex2i(x, VideoHeight - y);
- glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
- glVertex2i(x + w, VideoHeight - (y + h));
+ glVertex2i(x, VideoHeight - (y + height));
glEnd();
glEnable(GL_TEXTURE_2D);
}
#endif
/**
-** Fill rectangle 75% translucent clipped into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill75TransRectangle8(VMemType color, int x, int y,
- int w, int h)
-{
- VMemType8* p;
- int i;
- int swidth;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- swidth -= w;
- c = color.D8;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- *p = lookup25trans8[(*p << 8) | c];
- ++p;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Fill rectangle 75% translucent clipped into 15bpp frame buffer.
+** Draw 75% translucent vertical line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param height height of line (0=don't draw).
*/
-local void DrawFill75TransRectangle15(VMemType color, int x, int y,
- int w, int h)
+#ifdef USE_OPENGL
+local void Draw75TransVLineOpenGL(VMemType color, int x, int y, int height)
{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x03E07C1F;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x03E07C1F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x03E07C1F;
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 64);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + height));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Fill rectangle 75% translucent clipped into 16bpp frame buffer.
+** Draw translucent vertical line unclipped.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param height height of line (0=don't draw).
+** @param alpha alpha value of pixels.
*/
-local void DrawFill75TransRectangle16(VMemType color, int x, int y,
- int w, int h)
+#ifdef USE_OPENGL
+local void DrawTransVLineOpenGL(VMemType color, int x, int y, int height,
+ unsigned char alpha)
{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = (((dp << 1) + dp + sp) >> 2) & 0x07E0F81F;
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
-}
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
-/**
-** Fill rectangle 75% translucent clipped into 24bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-*/
-local void DrawFill75TransRectangle24(VMemType color, int x, int y,
- int w, int h)
-{
-// FIXME: does 24bpp holds R|G|B ?
- DrawFillRectangle24(color, x, y, w, h); // no trans functionaility :(
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 255 - alpha);
+ glBegin(GL_LINES);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + height));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Fill rectangle 75% translucent clipped into 32bpp frame buffer.
+** Draw line unclipped into 32bit framebuffer.
**
** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
+** @param x1 Source x coordinate on the screen
+** @param y1 Source y coordinate on the screen
+** @param x2 Destination x coordinate on the screen
+** @param y2 Destination y coordinate on the screen
*/
-local void DrawFill75TransRectangle32(VMemType color, int x, int y,
- int w, int h)
+#ifdef USE_OPENGL
+local void DrawLineOpenGL(VMemType color, int x1, int y1, int x2, int y2)
{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int i;
- int swidth;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- swidth -= w;
-
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = (((dp1 << 1) + dp1 + sp1) >> 2) &
0x00FF00FF;
- dp2 = (((dp2 << 1) + dp2 + sp2) >> 2) &
0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--i);
- p += swidth;
- }
- }
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor3ub(r, g, b);
+ glBegin(GL_LINES);
+ glVertex2i(x1, VideoHeight - y1);
+ glVertex2i(x2, VideoHeight - y2);
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Fill rectangle 75% translucent clipped.
+** Draw rectangle.
**
** @param color color
** @param x x coordinate on the screen
@@ -7153,263 +1546,130 @@
** @param w width of rectangle (0=don't draw).
*/
#ifdef USE_OPENGL
-local void DrawFill75TransRectangleOpenGL(VMemType color, int x, int y,
- int w, int h)
+local void DrawRectangleOpenGL(VMemType color, int x, int y, int w, int h)
{
VMemType32 c;
GLubyte r;
GLubyte g;
- Glubyte b;
+ GLubyte b;
c = color.D32;
r = (c >> 16) & 0xff;
g = (c >> 8) & 0xff;
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
- glColor4ub(r, g, b, 64);
- glBegin(GL_TRIANGLE_STRIP);
+ glColor3ub(r, g, b);
+ glBegin(GL_LINE_LOOP);
glVertex2i(x, VideoHeight - y);
glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
glVertex2i(x + w, VideoHeight - (y + h));
+ glVertex2i(x, VideoHeight - (y + h));
glEnd();
glEnable(GL_TEXTURE_2D);
}
#endif
/**
-** Draw translucent rectangle into 8bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawFillTransRectangle8(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- VMemType8* p;
- int i;
- int swidth;
- unsigned c;
-
- swidth = VideoWidth;
- p = VideoMemory8 + y * swidth + x;
- swidth -= w;
- c = color.D8;
-
- if (w) {
- switch (((unsigned int)alpha * 4) / 255) {
- case 0:
- while (h--) {
- i = w;
- do {
- *p = c;
- ++p;
- } while (--i);
- p += swidth;
- }
- break;
- case 1:
- c <<= 8;
- while (h--) {
- i = w;
- do {
- *p = lookup25trans8[*p | c];
- ++p;
- } while (--i);
- p += swidth;
- }
- break;
- case 2:
- c <<= 8;
- while (h--) {
- i = w;
- do {
- *p = lookup50trans8[*p | c];
- ++p;
- } while (--i);
- p += swidth;
- }
- break;
- case 3:
- while (h--) {
- i = w;
- do {
- *p = lookup25trans8[(*p << 8) |
c];
- ++p;
- } while (--i);
- p += swidth;
- }
- break;
- default:
- break;
- }
- }
-}
-
-/**
-** Draw rectangle into 8bpp frame buffer (ignoring alpha).
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawFillNoTransRectangle8(VMemType color, int x, int y,
- int w, int h, unsigned char alpha __attribute__((unused)))
-{
- DrawFillRectangle8(color, x, y, w, h);
-}
-
-/**
-** Draw translucent rectangle into 15bpp frame buffer.
-**
-** @param color color
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-** @param h height of rectangle (0=don't draw).
-** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
-*/
-local void DrawFillTransRectangle15(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
-{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
-
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- alpha >>= 3; //FIXME: only
5bits
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) &
0x03E07C1F; //FIXME: alpha==256 unreached
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
-}
-
-/**
-** Draw translucent rectangle into 16bpp frame buffer.
+** Draw 25% translucent rectangle.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
*/
-local void DrawFillTransRectangle16(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
+#ifdef USE_OPENGL
+local void Draw25TransRectangleOpenGL(VMemType color, int x, int y,
+ int w, int h)
{
- VMemType16* p;
- unsigned long sp;
- int i;
- int swidth;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- swidth = VideoWidth;
- p = VideoMemory16 + y * swidth + x;
- swidth -= w;
- sp = color.D16;
- sp = ((sp << 16) | sp) & 0x07E0F81F;
- alpha >>= 3; //FIXME: only
5bits
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp;
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - sp) * alpha) >> 5) + sp) &
0x07E0F81F; //FIXME: alpha==256 unreached
- *p++ = (dp >> 16) | dp;
- } while (--i);
- p += swidth;
- }
- }
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 192);
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glVertex2i(x, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw translucent rectangle into 24bpp frame buffer.
+** Draw 50% translucent rectangle into 32bpp frame buffer.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
*/
-local void DrawFillTransRectangle24(VMemType color, int x, int y,
- int w, int h, unsigned char alpha __attribute__((unused)))
+#ifdef USE_OPENGL
+local void Draw50TransRectangleOpenGL(VMemType color, int x, int y,
+ int w, int h)
{
-//FIXME: does 24bpp represents R|G|B?
- DrawFillRectangle24(color, x, y, w, h); // no trans functionaility :(
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
+
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 128);
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glVertex2i(x, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Draw translucent rectangle into 32bpp frame buffer.
+** Draw 75% translucent rectangle.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixel.
*/
-local void DrawFillTransRectangle32(VMemType color, int x, int y,
- int w, int h, unsigned char alpha)
+#ifdef USE_OPENGL
+local void Draw75TransRectangleOpenGL(VMemType color, int x, int y,
+ int w, int h)
{
- VMemType32* p;
- unsigned long sp1;
- unsigned long sp2;
- int i;
- int swidth;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- swidth = VideoWidth;
- p = VideoMemory32 + y * swidth + x;
- swidth -= w;
-
- sp1 = color.D32;
- sp2 = (sp1 & 0xFF00FF00) >> 8;
- sp1 &= 0x00FF00FF;
-
- if (w) {
- while (h--) {
- i = w;
- do {
- unsigned long dp1;
- unsigned long dp2;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- //FIXME: alpha==256 unreached
- dp1 = ((((dp1-sp1) * alpha) >> 8) + sp1) &
0x00FF00FF;
- dp2 = ((((dp2-sp2) * alpha) >> 8) + sp2) &
0x00FF00FF;
- *p++ = (dp1 | (dp2 << 8));
- } while (--i);
- p += swidth;
- }
- }
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 64);
+ glBegin(GL_LINE_LOOP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glVertex2i(x, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
** Draw translucent rectangle.
@@ -7422,7 +1682,7 @@
** @param alpha alpha value of pixel.
*/
#ifdef USE_OPENGL
-local void DrawFillTransRectangleOpenGL(VMemType color, int x, int y,
+local void DrawTransRectangleOpenGL(VMemType color, int x, int y,
int w, int h, unsigned char alpha)
{
VMemType32 c;
@@ -7436,18 +1696,18 @@
b = (c >> 0) & 0xff;
glDisable(GL_TEXTURE_2D);
glColor4ub(r, g, b, 255 - alpha);
- glBegin(GL_TRIANGLE_STRIP);
+ glBegin(GL_LINE_LOOP);
glVertex2i(x, VideoHeight - y);
glVertex2i(x + w, VideoHeight - y);
- glVertex2i(x, VideoHeight - (y + h));
glVertex2i(x + w, VideoHeight - (y + h));
+ glVertex2i(x, VideoHeight - (y + h));
glEnd();
glEnable(GL_TEXTURE_2D);
}
#endif
/**
-** Fill rectangle clipped.
+** Fill rectangle.
**
** @param color color
** @param x x coordinate on the screen
@@ -7455,12 +1715,30 @@
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
*/
-global void VideoFillRectangleClip(VMemType color, int x, int y,
+#ifdef USE_OPENGL
+local void DrawFillRectangleOpenGL(VMemType color, int x, int y,
int w, int h)
{
- CLIP_RECTANGLE(x, y, w, h);
- VideoFillRectangle(color, x, y, w, h);
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
+
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor3ub(r, g, b);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + h));
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
** Fill rectangle 25% translucent clipped.
@@ -7471,12 +1749,30 @@
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
*/
-global void VideoFill25TransRectangleClip(VMemType color, int x, int y,
+#ifdef USE_OPENGL
+local void DrawFill25TransRectangleOpenGL(VMemType color, int x, int y,
int w, int h)
{
- CLIP_RECTANGLE(x, y, w, h);
- VideoFill25TransRectangle(color, x, y, w, h);
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
+
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 192);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + h));
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
** Fill rectangle 50% translucent clipped.
@@ -7487,12 +1783,30 @@
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
*/
-global void VideoFill50TransRectangleClip(VMemType color, int x, int y,
+#ifdef USE_OPENGL
+local void DrawFill50TransRectangleOpenGL(VMemType color, int x, int y,
int w, int h)
{
- CLIP_RECTANGLE(x, y, w, h);
- VideoFill50TransRectangle(color, x, y, w, h);
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
+
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 128);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + h));
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
** Fill rectangle 75% translucent clipped.
@@ -7503,445 +1817,66 @@
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
*/
-global void VideoFill75TransRectangleClip(VMemType color, int x, int y,
+#ifdef USE_OPENGL
+local void DrawFill75TransRectangleOpenGL(VMemType color, int x, int y,
int w, int h)
{
- CLIP_RECTANGLE(x, y, w, h);
- VideoFill75TransRectangle(color, x, y, w, h);
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ Glubyte b;
+
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 64);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + h));
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
+#endif
/**
-** Fill rectangle translucent clipped.
+** Draw translucent rectangle.
**
** @param color color
** @param x x coordinate on the screen
** @param y y coordinate on the screen
** @param h height of rectangle (0=don't draw).
** @param w width of rectangle (0=don't draw).
-** @param alpha alpha value of pixels.
+** @param alpha alpha value of pixel.
*/
-global void VideoFillTransRectangleClip(VMemType color, int x, int y,
+#ifdef USE_OPENGL
+local void DrawFillTransRectangleOpenGL(VMemType color, int x, int y,
int w, int h, unsigned char alpha)
{
- CLIP_RECTANGLE(x, y, w, h);
- VideoFillTransRectangle(color, x, y, w, h,alpha);
-}
-
-// ===========================================================================
-// Filled circle
-// ===========================================================================
-
-/**
-** Fill circle clipped.
-**
-** @param color color
-** @param x Center x coordinate on the screen
-** @param y Center y coordinate on the screen
-** @param r radius of circle
-*/
-global void VideoFillCircleClip(VMemType color, int x, int y, int r)
-{
- int cx;
- int cy;
- int df;
- int d_e;
- int d_se;
-
- cx = 0;
- cy = r;
- df = 1 - r;
- d_e = 3;
- d_se = -2 * r + 5;
-
- // FIXME: could much improved :)
- do {
- VideoDrawHLineClip(color, x - cy, y - cx, 1 + cy * 2);
- if (cx) {
- VideoDrawHLineClip(color, x - cy, y + cx, 1 + cy * 2);
- }
- if (df < 0) {
- df += d_e;
- d_se += 2;
- } else {
- if (cx != cy) {
- VideoDrawHLineClip(color, x - cx, y - cy, 1 +
cx * 2);
- VideoDrawHLineClip(color, x - cx, y + cy, 1 +
cx * 2);
- }
- df += d_se;
- d_se += 4;
- cy--;
- }
- d_e += 2;
- cx++;
-
- } while (cx <= cy);
-}
-
-/**
-** Fill circle 25% translucent clipped.
-**
-** @param color color
-** @param x Center x coordinate on the screen
-** @param y Center y coordinate on the screen
-** @param r radius of circle
-*/
-global void VideoFill25TransCircleClip(VMemType color, int x, int y, int r)
-{
- int cx;
- int cy;
- int df;
- int d_e;
- int d_se;
-
- cx = 0;
- cy = r;
- df = 1 - r;
- d_e = 3;
- d_se = -2 * r + 5;
-
- // FIXME: could much improved :)
- do {
- VideoDraw25TransHLineClip(color, x - cy, y - cx, 1 + cy * 2);
- if (cx) {
- VideoDraw25TransHLineClip(color, x - cy, y + cx, 1 + cy
* 2);
- }
- if (df < 0) {
- df += d_e;
- d_se += 2;
- } else {
- if (cx!=cy) {
- VideoDraw25TransHLineClip(color, x - cx, y -
cy, 1 + cx * 2);
- VideoDraw25TransHLineClip(color, x - cx, y +
cy, 1 + cx * 2);
- }
- df += d_se;
- d_se += 4;
- cy--;
- }
- d_e += 2;
- cx++;
-
- } while (cx <= cy);
-}
-
-/**
-** Fill circle 50% translucent clipped.
-**
-** @param color color
-** @param x Center x coordinate on the screen
-** @param y Center y coordinate on the screen
-** @param r radius of circle
-*/
-global void VideoFill50TransCircleClip(VMemType color, int x, int y, int r)
-{
- int cx;
- int cy;
- int df;
- int d_e;
- int d_se;
-
- cx = 0;
- cy = r;
- df = 1 - r;
- d_e = 3;
- d_se = -2 * r + 5;
-
- // FIXME: could much improved :)
- do {
- VideoDraw50TransHLineClip(color, x - cy, y - cx, 1 + cy * 2);
- if (cx) {
- VideoDraw50TransHLineClip(color, x - cy, y + cx, 1 + cy
* 2);
- }
- if (df < 0) {
- df += d_e;
- d_se += 2;
- } else {
- if (cx != cy) {
- VideoDraw50TransHLineClip(color, x - cx, y -
cy, 1 + cx * 2);
- VideoDraw50TransHLineClip(color, x - cx, y +
cy, 1 + cx * 2);
- }
- df += d_se;
- d_se += 4;
- cy--;
- }
- d_e += 2;
- cx++;
-
- } while (cx <= cy);
-}
-
-/**
-** Fill circle 75% translucent clipped.
-**
-** @param color color
-** @param x Center x coordinate on the screen
-** @param y Center y coordinate on the screen
-** @param r radius of circle
-*/
-global void VideoFill75TransCircleClip(VMemType color, int x, int y, int r)
-{
- int cx;
- int cy;
- int df;
- int d_e;
- int d_se;
-
- cx = 0;
- cy = r;
- df = 1 - r;
- d_e = 3;
- d_se = -2 * r + 5;
-
- // FIXME: could much improved :)
- do {
- VideoDraw75TransHLineClip(color, x - cy, y - cx, 1 + cy * 2);
- if (cx) {
- VideoDraw75TransHLineClip(color, x - cy, y + cx, 1 + cy
* 2);
- }
- if (df < 0) {
- df += d_e;
- d_se += 2;
- } else {
- if (cx != cy) {
- VideoDraw75TransHLineClip(color, x - cx, y -
cy, 1 + cx * 2);
- VideoDraw75TransHLineClip(color, x - cx, y +
cy, 1 + cx * 2);
- }
- df += d_se;
- d_se += 4;
- cy--;
- }
- d_e += 2;
- cx++;
+ VMemType32 c;
+ GLubyte r;
+ GLubyte g;
+ GLubyte b;
- } while (cx <= cy);
+ c = color.D32;
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = (c >> 0) & 0xff;
+ glDisable(GL_TEXTURE_2D);
+ glColor4ub(r, g, b, 255 - alpha);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2i(x, VideoHeight - y);
+ glVertex2i(x + w, VideoHeight - y);
+ glVertex2i(x, VideoHeight - (y + h));
+ glVertex2i(x + w, VideoHeight - (y + h));
+ glEnd();
+ glEnable(GL_TEXTURE_2D);
}
-
-/*----------------------------------------------------------------------------
--- Global functions
-----------------------------------------------------------------------------*/
-
-/**
-** Init linedraw
-*/
-global void InitLineDraw(void)
-{
-#ifdef USE_OPENGL
- VideoDrawPixel = DrawPixelOpenGL;
- VideoDraw25TransPixel = Draw25TransPixelOpenGL;
- VideoDraw50TransPixel = Draw50TransPixelOpenGL;
- VideoDraw75TransPixel = Draw75TransPixelOpenGL;
- VideoDrawTransPixel = DrawTransPixelOpenGL;
- VideoDrawPixelClip = DrawPixelClipOpenGL;
- VideoDrawHLine = DrawHLineOpenGL;
- VideoDraw25TransHLine = Draw25TransHLineOpenGL;
- VideoDraw50TransHLine = Draw50TransHLineOpenGL;
- VideoDraw75TransHLine = Draw75TransHLineOpenGL;
- VideoDrawTransHLine = DrawTransHLineOpenGL;
- VideoDrawVLine = DrawVLineOpenGL;
- VideoDraw25TransVLine = Draw25TransVLineOpenGL;
- VideoDraw50TransVLine = Draw50TransVLineOpenGL;
- VideoDraw75TransVLine = Draw75TransVLineOpenGL;
- VideoDrawTransVLine = DrawTransVLineOpenGL;
- VideoDrawLine = DrawLineOpenGL;
- VideoDrawRectangle = DrawRectangleOpenGL;
- VideoDraw25TransRectangle = Draw25TransRectangleOpenGL;
- VideoDraw50TransRectangle = Draw50TransRectangleOpenGL;
- VideoDraw75TransRectangle = Draw75TransRectangleOpenGL;
- VideoDrawTransRectangle = DrawTransRectangleOpenGL;
- VideoFillRectangle = DrawFillRectangleOpenGL;
- VideoFill25TransRectangle = DrawFill25TransRectangleOpenGL;
- VideoFill50TransRectangle = DrawFill50TransRectangleOpenGL;
- VideoFill75TransRectangle = DrawFill75TransRectangleOpenGL;
- VideoFillTransRectangle = DrawFillTransRectangleOpenGL;
-#else
- switch (VideoBpp) {
- case 8:
- if (lookup25trans8 && lookup50trans8) {
- VideoDrawPixel = DrawPixel8;
- VideoDraw25TransPixel = Draw25TransPixel8;
- VideoDraw50TransPixel = Draw50TransPixel8;
- VideoDraw75TransPixel = Draw75TransPixel8;
- VideoDrawTransPixel = DrawTransPixel8;
- VideoDrawPixelClip =
DrawPixelClip8;
- VideoDrawHLine = DrawHLine8;
- VideoDraw25TransHLine = Draw25TransHLine8;
- VideoDraw50TransHLine = Draw50TransHLine8;
- VideoDraw75TransHLine = Draw75TransHLine8;
- VideoDrawTransHLine = DrawTransHLine8;
- VideoDrawVLine = DrawVLine8;
- VideoDraw25TransVLine = Draw25TransVLine8;
- VideoDraw50TransVLine = Draw50TransVLine8;
- VideoDraw75TransVLine = Draw75TransVLine8;
- VideoDrawTransVLine = DrawTransVLine8;
- VideoDrawLine = DrawLine8;
- VideoDrawRectangle =
DrawRectangle8;
- VideoDraw25TransRectangle =
Draw25TransRectangle8;
- VideoDraw50TransRectangle =
Draw50TransRectangle8;
- VideoDraw75TransRectangle =
Draw75TransRectangle8;
- VideoDrawTransRectangle = DrawTransRectangle8;
- VideoFillRectangle =
DrawFillRectangle8;
- VideoFill25TransRectangle =
DrawFill25TransRectangle8;
- VideoFill50TransRectangle =
DrawFill50TransRectangle8;
- VideoFill75TransRectangle =
DrawFill75TransRectangle8;
- VideoFillTransRectangle =
DrawFillTransRectangle8;
- } else {
- printf("(transparency support disabled)\n");
- VideoDrawPixel =
- VideoDraw25TransPixel =
- VideoDraw50TransPixel =
- VideoDraw75TransPixel = DrawPixel8;
- VideoDrawTransPixel = DrawNoTransPixel8;
- VideoDrawPixelClip =
DrawPixelClip8;
- VideoDrawHLine =
- VideoDraw25TransHLine =
- VideoDraw50TransHLine =
- VideoDraw75TransHLine = DrawHLine8;
- VideoDrawTransHLine = DrawNoTransHLine8;
- VideoDrawVLine =
- VideoDraw25TransVLine =
- VideoDraw50TransVLine =
- VideoDraw75TransVLine = DrawVLine8;
- VideoDrawTransVLine = DrawNoTransVLine8;
- VideoDrawLine = DrawLine8;
- VideoDrawRectangle =
- VideoDraw25TransRectangle =
- VideoDraw50TransRectangle =
- VideoDraw75TransRectangle = DrawRectangle8;
- VideoDrawTransRectangle =
DrawNoTransRectangle8;
- VideoFillRectangle =
- VideoFill25TransRectangle =
- VideoFill50TransRectangle =
- VideoFill75TransRectangle = DrawFillRectangle8;
- VideoFillTransRectangle =
DrawFillNoTransRectangle8;
- }
- break;
-
- case 15:
- VideoDrawPixel = DrawPixel16;
- VideoDraw25TransPixel = Draw25TransPixel15;
- VideoDraw50TransPixel = Draw50TransPixel15;
- VideoDraw75TransPixel = Draw75TransPixel15;
- VideoDrawTransPixel = DrawTransPixel15;
- VideoDrawPixelClip = DrawPixelClip16;
- VideoDrawHLine = DrawHLine16;
- VideoDraw25TransHLine = Draw25TransHLine15;
- VideoDraw50TransHLine = Draw50TransHLine15;
- VideoDraw75TransHLine = Draw75TransHLine15;
- VideoDrawTransHLine = DrawTransHLine15;
- VideoDrawVLine = DrawVLine16;
- VideoDraw25TransVLine = Draw25TransVLine15;
- VideoDraw50TransVLine = Draw50TransVLine15;
- VideoDraw75TransVLine = Draw75TransVLine15;
- VideoDrawTransVLine = DrawTransVLine15;
- VideoDrawLine = DrawLine16;
- VideoDrawRectangle = DrawRectangle16;
- VideoDraw25TransRectangle = Draw25TransRectangle15;
- VideoDraw50TransRectangle = Draw50TransRectangle15;
- VideoDraw75TransRectangle = Draw75TransRectangle15;
- VideoDrawTransRectangle = DrawTransRectangle15;
- VideoFillRectangle = DrawFillRectangle16;
- VideoFill25TransRectangle = DrawFill25TransRectangle15;
- VideoFill50TransRectangle = DrawFill50TransRectangle15;
- VideoFill75TransRectangle = DrawFill75TransRectangle15;
- VideoFillTransRectangle = DrawFillTransRectangle15;
- break;
-
- case 16:
- VideoDrawPixel = DrawPixel16;
- VideoDraw25TransPixel = Draw25TransPixel16;
- VideoDraw50TransPixel = Draw50TransPixel16;
- VideoDraw75TransPixel = Draw75TransPixel16;
- VideoDrawTransPixel = DrawTransPixel16;
- VideoDrawPixelClip = DrawPixelClip16;
- VideoDrawHLine = DrawHLine16;
- VideoDraw25TransHLine = Draw25TransHLine16;
- VideoDraw50TransHLine = Draw50TransHLine16;
- VideoDraw75TransHLine = Draw75TransHLine16;
- VideoDrawTransHLine = DrawTransHLine16;
- VideoDrawVLine = DrawVLine16;
- VideoDraw25TransVLine = Draw25TransVLine16;
- VideoDraw50TransVLine = Draw50TransVLine16;
- VideoDraw75TransVLine = Draw75TransVLine16;
- VideoDrawTransVLine = DrawTransVLine16;
- VideoDrawLine = DrawLine16;
- VideoDrawRectangle = DrawRectangle16;
- VideoDraw25TransRectangle = Draw25TransRectangle16;
- VideoDraw50TransRectangle = Draw50TransRectangle16;
- VideoDraw75TransRectangle = Draw75TransRectangle16;
- VideoDrawTransRectangle = DrawTransRectangle16;
- VideoFillRectangle = DrawFillRectangle16;
- VideoFill25TransRectangle = DrawFill25TransRectangle16;
- VideoFill50TransRectangle = DrawFill50TransRectangle16;
- VideoFill75TransRectangle = DrawFill75TransRectangle16;
- VideoFillTransRectangle = DrawFillTransRectangle16;
- break;
-
- case 24:
- VideoDrawPixel = DrawPixel24;
- VideoDraw25TransPixel = Draw25TransPixel24;
- VideoDraw50TransPixel = Draw50TransPixel24;
- VideoDraw75TransPixel = Draw75TransPixel24;
- VideoDrawTransPixel = DrawTransPixel24;
- VideoDrawPixelClip = DrawPixelClip24;
- VideoDrawHLine = DrawHLine24;
- VideoDraw25TransHLine = Draw25TransHLine24;
- VideoDraw50TransHLine = Draw50TransHLine24;
- VideoDraw75TransHLine = Draw75TransHLine24;
- VideoDrawTransHLine = DrawTransHLine24;
- VideoDrawVLine = DrawVLine24;
- VideoDraw25TransVLine = Draw25TransVLine24;
- VideoDraw50TransVLine = Draw50TransVLine24;
- VideoDraw75TransVLine = Draw75TransVLine24;
- VideoDrawTransVLine = DrawTransVLine24;
- VideoDrawLine = DrawLine24;
- VideoDrawRectangle = DrawRectangle24;
- VideoDraw25TransRectangle = Draw25TransRectangle24;
- VideoDraw50TransRectangle = Draw50TransRectangle24;
- VideoDraw75TransRectangle = Draw75TransRectangle24;
- VideoDrawTransRectangle = DrawTransRectangle24;
- VideoFillRectangle = DrawFillRectangle24;
- VideoFill25TransRectangle = DrawFill25TransRectangle24;
- VideoFill50TransRectangle = DrawFill50TransRectangle24;
- VideoFill75TransRectangle = DrawFill75TransRectangle24;
- VideoFillTransRectangle = DrawFillTransRectangle24;
- break;
-
- case 32:
- VideoDrawPixel = DrawPixel32;
- VideoDraw25TransPixel = Draw25TransPixel32;
- VideoDraw50TransPixel = Draw50TransPixel32;
- VideoDraw75TransPixel = Draw75TransPixel32;
- VideoDrawTransPixel = DrawTransPixel32;
- VideoDrawPixelClip = DrawPixelClip32;
- VideoDrawHLine = DrawHLine32;
- VideoDraw25TransHLine = Draw25TransHLine32;
- VideoDraw50TransHLine = Draw50TransHLine32;
- VideoDraw75TransHLine = Draw75TransHLine32;
- VideoDrawTransHLine = DrawTransHLine32;
- VideoDrawVLine = DrawVLine32;
- VideoDraw25TransVLine = Draw25TransVLine32;
- VideoDraw50TransVLine = Draw50TransVLine32;
- VideoDraw75TransVLine = Draw75TransVLine32;
- VideoDrawTransVLine = DrawTransVLine32;
- VideoDrawLine = DrawLine32;
- VideoDrawRectangle = DrawRectangle32;
- VideoDraw25TransRectangle = Draw25TransRectangle32;
- VideoDraw50TransRectangle = Draw50TransRectangle32;
- VideoDraw75TransRectangle = Draw75TransRectangle32;
- VideoDrawTransRectangle = DrawTransRectangle32;
- VideoFillRectangle = DrawFillRectangle32;
- VideoFill25TransRectangle = DrawFill25TransRectangle32;
- VideoFill50TransRectangle = DrawFill50TransRectangle32;
- VideoFill75TransRectangle = DrawFill75TransRectangle32;
- VideoFillTransRectangle = DrawFillTransRectangle32;
- break;
-
- default:
- DebugLevel0Fn("unsupported %d bpp\n" _C_ VideoBpp);
- abort();
- }
#endif
-}
-#endif // !USE_SDL_SURFACE
+#endif
//@}
Index: stratagus/src/video/png.c
diff -u stratagus/src/video/png.c:1.30 stratagus/src/video/png.c:1.31
--- stratagus/src/video/png.c:1.30 Sat Dec 20 16:33:49 2003
+++ stratagus/src/video/png.c Thu Jan 15 13:14:08 2004
@@ -5,12 +5,12 @@
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
-// T H E W A R B E G I N S
-// Stratagus - A free fantasy real time strategy game engine
+// T H E W A R B E G I N S
+// Stratagus - A free fantasy real time strategy game engine
//
-/address@hidden png.c - The png graphic file loader. */
+/address@hidden png.c - The png graphic file loader. */
//
-// (c) Copyright 1998-2002 by Lutz Sammer
+// (c) Copyright 1998-2004 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: png.c,v 1.30 2003/12/20 05:33:49 jsalmon3 Exp $
+// $Id: png.c,v 1.31 2004/01/15 02:14:08 jsalmon3 Exp $
//@{
@@ -80,12 +80,7 @@
global Graphic* LoadGraphicPNG(const char* name)
{
Graphic* graphic;
-#ifdef USE_SDL_SURFACE
-// SDL_Palette* palette;
SDL_Color* palettecolors;
-#else
- Palette* palette;
-#endif
CLFile* fp;
png_structp png_ptr;
png_infop info_ptr;
@@ -137,11 +132,7 @@
// Setup translators:
-#ifdef USE_SDL_SURFACE
palettecolors = (SDL_Color*)calloc(256, sizeof(SDL_Color));
-#else
- palette = (Palette*)calloc(256, sizeof(Palette));
-#endif
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
DebugLevel3("Color palette\n");
@@ -151,22 +142,12 @@
abort();
}
for (i = 0; i < info_ptr->num_palette; ++i) {
-#ifdef USE_SDL_SURFACE
palettecolors[i].r = info_ptr->palette[i].red;
palettecolors[i].g = info_ptr->palette[i].green;
palettecolors[i].b = info_ptr->palette[i].blue;
-#else
- palette[i].r = info_ptr->palette[i].red;
- palette[i].g = info_ptr->palette[i].green;
- palette[i].b = info_ptr->palette[i].blue;
-#endif
}
- for(; i < 256; ++i) {
-#ifdef USE_SDL_SURFACE
+ for (; i < 256; ++i) {
palettecolors[i].r = palettecolors[i].g =
palettecolors[i].b = 0;
-#else
- palette[i].r = palette[i].g = palette[i].b = 0;
-#endif
}
}
}
@@ -230,12 +211,8 @@
CLclose(fp);
graphic = MakeGraphic(8, w, h, data, w * h); // data freed
by make graphic
-#ifdef USE_SDL_SURFACE
- SDL_SetPalette(graphic->Surface, SDL_LOGPAL|SDL_PHYSPAL, palettecolors,
0, 256);
- SDL_SetColorKey(graphic->Surface, SDL_SRCCOLORKEY|SDL_RLEACCEL, 255);
-#else
- graphic->Palette = palette; //FIXME: should this be part of MakeGraphic
-#endif
+ SDL_SetPalette(graphic->Surface, SDL_LOGPAL | SDL_PHYSPAL,
palettecolors, 0, 256);
+ SDL_SetColorKey(graphic->Surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, 255);
return graphic;
}
@@ -253,13 +230,9 @@
unsigned char* row;
int i;
int j;
-#ifdef USE_SDL_SURFACE
-// Uint32 c;
int bpp;
bpp = TheScreen->format->BytesPerPixel;
-#else
-#endif
fp = fopen(name, "wb");
if (fp == NULL) {
@@ -302,7 +275,6 @@
png_write_info(png_ptr, info_ptr);
for (i = 0; i < VideoHeight; ++i) {
-#ifdef USE_SDL_SURFACE
switch (VideoDepth) {
case 15: {
Uint16 c;
@@ -343,46 +315,6 @@
break;
}
}
-#else
- switch (VideoDepth) {
- case 8:
- // FIXME: Finish
- break;
- case 15:
- for (j = 0; j < VideoWidth; ++j) {
- VMemType16 c;
- c = VideoMemory16[i * VideoWidth + j];
- row[j * 3 + 0] = (((c >> 0) & 0x1f) * 0xff) /
0x1f;
- row[j * 3 + 1] = (((c >> 5) & 0x1f) * 0xff) /
0x1f;
- row[j * 3 + 2] = (((c >> 10) & 0x1f) * 0xff) /
0x1f;
- }
- break;
- case 16:
- for (j = 0; j < VideoWidth; ++j) {
- VMemType16 c;
- c = VideoMemory16[i*VideoWidth+j];
- row[j * 3 + 0] = (((c >> 0) & 0x1f) * 0xff) /
0x1f;
- row[j * 3 + 1] = (((c >> 5) & 0x3f) * 0xff) /
0x3f;
- row[j * 3 + 2] = (((c >> 11) & 0x1f) * 0xff) /
0x1f;
- }
- break;
- case 24:
- if (VideoBpp == 24) {
- memcpy(row, VideoMemory24 + i * VideoWidth,
VideoWidth * 3);
- break;
- }
- // FALL THROUGH
- case 32:
- for (j = 0; j < VideoWidth; ++j) {
- VMemType32 c;
- c = VideoMemory32[i * VideoWidth + j];
- row[j * 3 + 0] = ((c >> 0) & 0xff);
- row[j * 3 + 1] = ((c >> 8) & 0xff);
- row[j * 3 + 2] = ((c >> 16) & 0xff);
- }
- break;
- }
-#endif
png_write_row(png_ptr, row);
}
Index: stratagus/src/video/sdl.c
diff -u stratagus/src/video/sdl.c:1.113 stratagus/src/video/sdl.c:1.114
--- stratagus/src/video/sdl.c:1.113 Thu Jan 15 10:48:45 2004
+++ stratagus/src/video/sdl.c Thu Jan 15 13:14:08 2004
@@ -5,12 +5,12 @@
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
-// T H E W A R B E G I N S
-// Stratagus - A free fantasy real time strategy game engine
+// T H E W A R B E G I N S
+// Stratagus - A free fantasy real time strategy game engine
//
-/address@hidden sdl.c - SDL video support. */
+/address@hidden sdl.c - SDL video support. */
//
-// (c) Copyright 1999-2003 by Lutz Sammer, Jimmy Salmon, Nehal Mistry
+// (c) Copyright 1999-2004 by Lutz Sammer, Jimmy Salmon, Nehal Mistry
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sdl.c,v 1.113 2004/01/14 23:48:45 jsalmon3 Exp $
+// $Id: sdl.c,v 1.114 2004/01/15 02:14:08 jsalmon3 Exp $
//@{
@@ -233,12 +233,6 @@
exit(1);
}
-#ifdef USE_SDL_SURFACE
-// if (VideoDepth == 8) {
-// TheScreen->format->palette = &GlobalPalette;
-// }
-#endif
-
#ifdef DEBUG
if (SDL_MUSTLOCK(TheScreen)) {
DebugLevel0Fn("Must locksurface!\n");
@@ -256,30 +250,7 @@
// You see it's better making all self, than using wired
libaries :)
// And with the win32 version this also doesn't work
//
-#ifdef USE_SDL_SURFACE
VideoDepth = TheScreen->format->BitsPerPixel;
-#else
- if (!VideoDepth) {
- int i;
- int j;
-
- DebugLevel3Fn("Mask R%x G%x B%x\n" _C_
- TheScreen->format->Rmask _C_
- TheScreen->format->Gmask _C_
- TheScreen->format->Bmask);
-
- if (TheScreen->format->BitsPerPixel > 8) {
- j = TheScreen->format->Rmask | TheScreen->format->Gmask
|
- TheScreen->format->Bmask;
-
- for (i = 0; j & (1 << i); ++i) {
- }
- VideoDepth = i;
- } else {
- VideoDepth = TheScreen->format->BitsPerPixel;
- }
- }
-#endif
// Make default character translation easier
SDL_EnableUNICODE(1);
@@ -288,7 +259,6 @@
InitOpenGL();
#endif
-#ifdef USE_SDL_SURFACE
ColorBlack = SDL_MapRGB(TheScreen->format, 0, 0, 0);
ColorDarkGreen = SDL_MapRGB(TheScreen->format, 48, 100, 4);
ColorBlue = SDL_MapRGB(TheScreen->format, 0, 0, 252);
@@ -298,17 +268,6 @@
ColorRed = SDL_MapRGB(TheScreen->format, 252, 0, 0);
ColorGreen = SDL_MapRGB(TheScreen->format, 0, 252, 0);
ColorYellow = SDL_MapRGB(TheScreen->format, 252, 252, 0);
-#else
- ColorBlack = VideoMapRGB(0, 0, 0);
- ColorDarkGreen = VideoMapRGB(48, 100, 4);
- ColorBlue = VideoMapRGB(0, 0, 252);
- ColorOrange = VideoMapRGB(248, 140, 20);
- ColorWhite = VideoMapRGB(252, 248, 240);
- ColorGray = VideoMapRGB(128, 128, 128);
- ColorRed = VideoMapRGB(252, 0, 0);
- ColorGreen = VideoMapRGB(0, 252, 0);
- ColorYellow = VideoMapRGB(252, 252, 0);
-#endif
DebugLevel3Fn("Video init ready %d %d\n" _C_ VideoDepth _C_ VideoBpp);
@@ -817,123 +776,6 @@
#endif
}
-#ifndef USE_SDL_SURFACE
-/**
-** Maps RGB to a hardware dependent pixel.
-**
-** @param r Red color.
-** @param g Green color.
-** @param b Blue color.
-**
-** @return A hardware dependent pixel.
-*/
-global VMemType VideoMapRGB(int r, int g, int b)
-{
- VMemType c;
- unsigned long map;
-
- DebugCheck(!TheScreen);
- map = SDL_MapRGB(TheScreen->format, r, g, b);
-
- memcpy(&c, &map, sizeof(c));
- return c;
-}
-#endif
-
-#ifdef USE_SDL_SURFACE
-// FIXME: todo
-/*
-global SDL_Palette* VideoCreateNewPalette(const SDL_Palette* palette)
-{
- SDL_Palette *s;
- return s;
-}
-*/
-#else
-/**
-** Create a new hardware dependent palette palette.
-**
-** @param palette Hardware independent palette.
-**
-** @return A hardware dependent pixel
table.
-*/
-global VMemType* VideoCreateNewPalette(const Palette* palette)
-{
- int i;
- void* pixels;
-
- if (!TheScreen) { // no
init
- return NULL;
- }
-
- switch (VideoBpp) {
- case 8:
- pixels = malloc(256 * sizeof(VMemType8));
- break;
- case 15:
- case 16:
- pixels = malloc(256 * sizeof(VMemType16));
- break;
- case 24:
- pixels = malloc(256 * sizeof(VMemType24));
- break;
- case 32:
- pixels = malloc(256 * sizeof(VMemType32));
- break;
- default:
- DebugLevel0Fn("Unknown depth\n");
- return NULL;
- }
-
- //
- // Convert each palette entry into hardware format.
- //
- for (i = 0; i < 256; ++i) {
- int r;
- int g;
- int b;
- int v;
- char* vp;
-
- r = (palette[i].r) & 0xFF;
- g = (palette[i].g) & 0xFF;
- b = (palette[i].b) & 0xFF;
- v = r + g + b;
-
- // Boundings
- r = r < 0 ? 0 : r > 255 ? 255 : r;
- g = g < 0 ? 0 : g > 255 ? 255 : g;
- b = b < 0 ? 0 : b > 255 ? 255 : b;
-
- // -> Video
- switch (VideoBpp) {
- case 8:
- ((VMemType8*)pixels)[i] =
- SDL_MapRGB(TheScreen->format, r, g, b);
- break;
- case 15:
- case 16:
- ((VMemType16*)pixels)[i] =
- SDL_MapRGB(TheScreen->format, r, g, b);
- break;
- case 24:
- v = SDL_MapRGB(TheScreen->format, r, g, b);
- vp = (char *)(&v);
- ((VMemType24*)pixels)[i].a = vp[0];
// endian safe ?
- ((VMemType24*)pixels)[i].b = vp[1];
- ((VMemType24*)pixels)[i].c = vp[2];
- break;
- case 32:
- ((VMemType32*)pixels)[i] =
- SDL_MapRGB(TheScreen->format, r, g, b);
- break;
- }
- }
-
- return pixels;
-}
-#endif
-
/**
** Check video interrupt.
**
@@ -964,9 +806,6 @@
if (SDL_MUSTLOCK(TheScreen)) {
SDL_LockSurface(TheScreen);
}
-#ifndef USE_SDL_SURFACE
- VideoMemory = TheScreen->pixels;
-#endif
#endif
}
@@ -979,13 +818,6 @@
if (SDL_MUSTLOCK(TheScreen)) {
SDL_UnlockSurface(TheScreen);
}
-#ifndef USE_SDL_SURFACE
-#ifdef DEBUG
- VideoMemory = NULL; //
Catch errors!
-#else
- VideoMemory = TheScreen->pixels; // Be kind
-#endif
-#endif
#endif
}
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.61 stratagus/src/video/sprite.c:1.62
--- stratagus/src/video/sprite.c:1.61 Wed Jan 14 16:42:11 2004
+++ stratagus/src/video/sprite.c Thu Jan 15 13:14:08 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sprite.c,v 1.61 2004/01/14 05:42:11 jsalmon3 Exp $
+// $Id: sprite.c,v 1.62 2004/01/15 02:14:08 jsalmon3 Exp $
//@{
@@ -52,18 +52,8 @@
-- Variables
----------------------------------------------------------------------------*/
-#ifndef USE_SDL_SURFACE
-local GraphicType GraphicSprite8Type; /// sprite type 8bit palette
-local GraphicType GraphicSprite16Type; /// sprite type 16bit palette
-#endif
-
-#ifdef USE_SDL_SURFACE
global void VideoDrawRawClip(SDL_Surface *surface,
int x, int y, int w, int h);
-#else
-global void (*VideoDrawRawClip)(VMemType *pixels, const unsigned char *data,
- int x, int y, int w, int h);
-#endif
/*----------------------------------------------------------------------------
-- Local functions
@@ -73,7 +63,6 @@
-- RLE Sprites
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
global void VideoDraw(const Graphic* sprite, unsigned frame, int x, int y)
{
SDL_Rect srect;
@@ -312,126 +301,6 @@
SDL_BlitSurface(sprite->SurfaceFlip, &srect, TheScreen, &drect);
SDL_SetAlpha(sprite->Surface, SDL_SRCALPHA, oldalpha);
}
-#else
-//
-// The current implementation uses RLE encoded sprites.
-// If you know something better, write it.
-//
-// The encoding translates the sprite data to a stream of segments
-// of the form:
-//
-// <skip> <run> <data>
-//
-// where <skip> is the number of transparent pixels to
skip,
-// <run> is the number of opaque pixels to blit,
-// and <data> are the pixels themselves.
-//
-// <skip> and <run> are unsigned 8 bit integers.
-// If more than 255 transparent pixels are needed 255 0 <n> <run>
is
-// used. <run> is always stored, even 0 at the end of line.
-// This makes the pixel data aligned at all times.
-// Segments never wrap around from one scan line to the next.
-//
-
-/**
-** Draw a RLE encoded graphic object unclipped into framebuffer.
-**
-** @note This macro looks nice, but is absolutly no
debugable.
-** @todo Make this an inline function.
-**
-** @param bpp Bit depth of target framebuffer
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#define RLE_BLIT(bpp, sprite, frame, x, y) \
- do {
\
- const unsigned char* sp;
\
- unsigned w;
\
- VMemType##bpp* dp;
\
- const VMemType##bpp* lp;
\
- const VMemType##bpp* ep;
\
- const VMemType##bpp* pixels;
\
- const VMemType##bpp* pp;
\
- unsigned da;
\
-
\
- pixels = (VMemType##bpp*)sprite->Pixels;
\
- sp = ((unsigned char**)sprite->Frames)[frame];
\
- w = sprite->Width;
\
- da = VideoWidth-w;
\
- dp = VideoMemory##bpp + x + y * VideoWidth;
\
- ep = dp + VideoWidth * sprite->Height;
\
-
\
- do {
\
- lp = dp + w;
\
- do { /* 1
line */ \
- dp += *sp++; /*
transparent # */ \
- pp = dp - 1 + *sp++;
/* opaque # */ \
- while (dp < pp) { /* unrolled */
\
- *dp++ = pixels[*sp++];
\
- *dp++ = pixels[*sp++];
\
- }
\
- if (dp <= pp) {
\
- *dp++ = pixels[*sp++];
\
- }
\
- } while (dp < lp);
\
- dp += da;
\
- } while (dp < ep); /* all lines */
\
- } while (0)
-
-/**
-** Draw 8bit graphic object unclipped into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8(const Graphic* sprite, unsigned frame, int x, int y)
-{
- RLE_BLIT(8, sprite, frame, x, y);
-}
-
-/**
-** Draw 8bit graphic object unclipped into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16(const Graphic* sprite, unsigned frame, int x, int y)
-{
- RLE_BLIT(16, sprite, frame, x, y);
-}
-
-/**
-** Draw 8bit graphic object unclipped into 24 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24(const Graphic* sprite, unsigned frame, int x, int y)
-{
- RLE_BLIT(24, sprite, frame, x, y);
-}
-
-/**
-** Draw 8bit graphic object unclipped into 32 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32(const Graphic* sprite, unsigned frame, int x, int y)
-{
- RLE_BLIT(32, sprite, frame, x, y);
-}
-#endif
/**
** Draw graphic object unclipped.
@@ -468,183 +337,6 @@
}
#endif
-#ifndef USE_SDL_SURFACE
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8X(const Graphic* sprite, unsigned frame, int x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- const VMemType8* pp;
- const VMemType8* pixels;
- unsigned da;
-
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory8 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16X(const Graphic* sprite, unsigned frame, int x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- const VMemType16* pp;
- const VMemType16* pixels;
- unsigned da;
-
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory16 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
-
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 24 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24X(const Graphic* sprite, unsigned frame, int x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- const VMemType24* pp;
- const VMemType24* pixels;
- unsigned da;
-
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory24 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
-
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 32 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32X(const Graphic* sprite, unsigned frame, int x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- const VMemType32* pp;
- const VMemType32* pixels;
- unsigned da;
-
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory32 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
-
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-#endif
-
/**
** Draw graphic object unclipped and flipped in X direction.
**
@@ -680,553 +372,6 @@
}
#endif
-#ifndef USE_SDL_SURFACE
-/**
-** Draw 8bit graphic object clipped into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8Clip(const Graphic* sprite, unsigned frame, int x, int
y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- VMemType8* pp;
- const VMemType8* pixels;
- int da;
-
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory8 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16Clip(const Graphic* sprite, unsigned frame, int x,
int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- VMemType16* pp;
- const VMemType16* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory16 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped into 24 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24Clip(const Graphic* sprite, unsigned frame, int x,
int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- VMemType24* pp;
- const VMemType24* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory24 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped into 32 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32Clip(const Graphic* sprite, unsigned frame, int x,
int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- VMemType32* pp;
- const VMemType32* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory32 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-#endif
-
/**
** Draw graphic object clipped.
**
@@ -1280,3313 +425,84 @@
}
#endif
-#ifdef USE_SDL_SURFACE
-
-#else
/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 8 bit framebuffer.
+** Draw graphic object clipped and flipped in X direction.
**
** @param sprite pointer to object
** @param frame number of frame (object index)
** @param x x coordinate on the screen
** @param y y coordinate on the screen
*/
-local void VideoDraw8to8ClipX(const Graphic* sprite, unsigned frame, int x,
int y)
+#ifdef USE_OPENGL
+local void VideoDrawClipXOpenGL(const Graphic* sprite, unsigned frame,
+ int x, int y)
{
+ GLint svx;
+ GLint evx;
+ GLint svy;
+ GLint evy;
+ GLfloat stx;
+ GLfloat etx;
+ GLfloat sty;
+ GLfloat ety;
int ox;
- int ex;
int oy;
+ int ex;
int w;
int h;
- const unsigned char* sp;
- int sw;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- VMemType8* pp;
- const VMemType8* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
+
+ w = sprite->Width;
h = sprite->Height;
CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory8 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
+ svx = x;
+ evx = svx + w;
+ evy = VideoHeight - y;
+ svy = evy - h;
+ if (w < sprite->Width) {
+ if (ox == 0) {
+ ox += sprite->Width - w;
+ } else {
+ ox = 0;
}
}
+ stx = (GLfloat)ox / sprite->Width * sprite->TextureWidth;
+ etx = (GLfloat)(ox + w) / sprite->Width * sprite->TextureWidth;
+ ety = 1.0f - (GLfloat)oy / sprite->Height * sprite->TextureHeight;
+ sty = 1.0f - (GLfloat)(oy + h) / sprite->Height * sprite->TextureHeight;
+
+ glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(stx, sty);
+ glVertex2i(evx, svy);
+ glTexCoord2f(stx, ety);
+ glVertex2i(evx, evy);
+ glTexCoord2f(etx, ety);
+ glVertex2i(svx, evy);
+ glTexCoord2f(etx, sty);
+ glVertex2i(svx, svy);
+ glEnd();
}
+#endif
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16ClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- VMemType16* pp;
- const VMemType16* pixels;
- int da;
-
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory16 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 24bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24ClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- VMemType24* pp;
- const VMemType24* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory24 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 32bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32ClipX(const Graphic* sprite, unsigned frame
- , int x, int y)
-{
- int ex;
- int ox;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- VMemType32* pp;
- const VMemType32* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory32 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= ex;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + ex;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-///
*******************************************************************************************
-/// Begining of 50% Transparent functions
-///
*******************************************************************************************
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8XTrans50(const Graphic* sprite, unsigned frame, int x,
int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- const VMemType8* pp;
- const VMemType8* pixels;
- unsigned da;
-
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory8 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16XTrans50(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- const VMemType16* pp;
- const VMemType16* pixels;
- unsigned da;
-
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory16 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
-
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 24 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24XTrans50(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- const VMemType24* pp;
- const VMemType24* pixels;
- unsigned da;
-
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory24 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
-
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-/**
-** Draw 8bit graphic object unclipped and flipped in X direction
-** into 32 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32XTrans50(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- const unsigned char* sp;
- unsigned w;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- const VMemType32* pp;
- const VMemType32* pixels;
- unsigned da;
-
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
- w = sprite->Width;
- dp = VideoMemory32 + x + y * VideoWidth + w - 1;
- da = VideoWidth + w;
- ep = dp + VideoWidth * sprite->Height;
-
- do {
- lp = dp - w;
- do {
// 1 line
- dp -= *sp++;
// transparent
- pp = dp + 1 - *sp++; //
opaque
- while (dp > pp) { //
unrolled
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- } while (dp < ep); // all
lines
-}
-
-
-/**
-** Draw 8bit graphic object clipped into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8ClipTrans50(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- VMemType8* pp;
- const VMemType8* pixels;
- int da;
-
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory8 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16ClipTrans50(const Graphic* sprite, unsigned frame,
int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- VMemType16* pp;
- const VMemType16* pixels;
- int da;
-
-//Added by Mohydine
-
-// VMemType16* p;
-// p = VideoMemory16 + y * VideoWidth + x;
-
-//Added by Mohydine
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory16 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp = ((*dp >> 1) & 0x7BEF)
+((pixels[*sp++] >> 1) & 0x7BEF);
- ++dp;
- *dp = ((*dp >> 1) & 0x7BEF)
+((pixels[*sp++] >> 1) & 0x7BEF);
- ++dp;
-#if 0
- *dp++ = ((*dp >> 2) & 0x79E7) +
((pixels[*sp] >> 2) & 0x79E7) +((pixels[*sp++] >> 1) & 0x7BEF);
- *dp++ = ((*dp >> 2) & 0x79E7) +
((pixels[*sp] >> 2) & 0x79E7) +((pixels[*sp++] >> 1) & 0x7BEF);
-#endif
- }
- if (dp <= pp) {
- *dp = ((*dp >> 1) & 0x7BEF) +
((pixels[*sp++] >> 1) & 0x7BEF);
- ++dp;
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp = ((*dp >> 1) & 0x7BEF) +
((pixels[*sp++] >> 1) & 0x7BEF);
- ++dp;
- }
- continue;
- }
- while (dp < lp) {
- *dp = ((*dp >> 1) & 0x7BEF) +
((pixels[*sp++] >> 1) & 0x7BEF);
- ++dp;
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped into 24 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24ClipTrans50(const Graphic* sprite, unsigned frame,
int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- VMemType24* pp;
- const VMemType24* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory24 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped into 32 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32ClipTrans50(const Graphic* sprite, unsigned frame,
int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- VMemType32* pp;
- const VMemType32* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory32 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- ++dp;
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- ++dp;
- }
- if (dp <= pp) {
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- ++dp;
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp = ((*dp >> 1) & 0x7F7F7F7F)
+ ((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- ++dp;
- }
- continue;
- }
- while (dp < lp) {
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- ++dp;
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8ClipXTrans50(const Graphic* sprite, unsigned frame,
int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- VMemType8* pp;
- const VMemType8* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory8 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16ClipXTrans50(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- VMemType16* pp;
- const VMemType16* pixels;
- int da;
-
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory16 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp = ((*dp >> 1) & 0x7BEF) +
((pixels[*sp++] >> 1) & 0x7BEF);
- --dp;
- *dp = ((*dp >> 1) & 0x7BEF) +
((pixels[*sp++] >> 1) & 0x7BEF);
- --dp;
- }
- if (dp >= pp) {
- *dp = ((*dp >> 1) & 0x7BEF) +
((pixels[*sp++] >> 1) & 0x7BEF);
- --dp;
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 24bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24ClipXTrans50(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- VMemType24* pp;
- const VMemType24* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory24 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit graphic object clipped and flipped in X direction
-** into 32bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32ClipXTrans50(const Graphic* sprite, unsigned frame
- , int x, int y)
-{
- int ex;
- int ox;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- VMemType32* pp;
- const VMemType32* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory32 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- --dp;
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- --dp;
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= ex;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + ex;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp = ((*dp >> 1) & 0x7F7F7F7F)
+ ((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- --dp;
- }
- continue;
- }
- while (dp > lp) {
- *dp = ((*dp >> 1) & 0x7F7F7F7F) +
((pixels[*sp++] >> 1) & 0x7F7F7F7F);
- --dp;
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-// End Of 50% Transparent functions
-#endif
-
-/**
-** Draw graphic object clipped and flipped in X direction.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-#ifdef USE_OPENGL
-local void VideoDrawClipXOpenGL(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- GLint svx;
- GLint evx;
- GLint svy;
- GLint evy;
- GLfloat stx;
- GLfloat etx;
- GLfloat sty;
- GLfloat ety;
- int ox;
- int oy;
- int ex;
- int w;
- int h;
-
- w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- svx = x;
- evx = svx + w;
- evy = VideoHeight - y;
- svy = evy - h;
-
- if (w < sprite->Width) {
- if (ox == 0) {
- ox += sprite->Width - w;
- } else {
- ox = 0;
- }
- }
- stx = (GLfloat)ox / sprite->Width * sprite->TextureWidth;
- etx = (GLfloat)(ox + w) / sprite->Width * sprite->TextureWidth;
- ety = 1.0f - (GLfloat)oy / sprite->Height * sprite->TextureHeight;
- sty = 1.0f - (GLfloat)(oy + h) / sprite->Height * sprite->TextureHeight;
-
- glBindTexture(GL_TEXTURE_2D, sprite->TextureNames[frame]);
- glBegin(GL_QUADS);
- glTexCoord2f(stx, sty);
- glVertex2i(evx, svy);
- glTexCoord2f(stx, ety);
- glVertex2i(evx, evy);
- glTexCoord2f(etx, ety);
- glVertex2i(svx, evy);
- glTexCoord2f(etx, sty);
- glVertex2i(svx, svy);
- glEnd();
-}
-#endif
-
-#ifdef USE_SDL_SURFACE
-
-#else
-/**
-** Draw 8bit shadow graphic object clipped into 8 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8ShadowClip(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- VMemType8* pp;
- const VMemType8* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory8 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp = lookup50trans8[(ColorBlack.D8 >>
8) | *dp];
- ++dp;
- ++sp;
- *dp = lookup50trans8[(ColorBlack.D8 >>
8) | *dp];
- ++dp;
- ++sp;
- }
- if (dp <= pp) {
- *dp = lookup50trans8[(ColorBlack.D8 >>
8) | *dp];
- ++dp;
- ++sp;
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp =
lookup50trans8[(ColorBlack.D8 >> 8) | *dp];
- ++dp;
- ++sp;
- }
- continue;
- }
- while (dp < lp) {
- *dp = lookup50trans8[(ColorBlack.D8 >>
8) | *dp];
- ++dp;
- ++sp;
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit shadow graphic object clipped into 16 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16ShadowClip(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- VMemType16* pp;
- const VMemType16* pixels;
- int da;
- unsigned long dp1;
- unsigned long mask;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory16 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (VideoBpp == 15) {
- mask = 0x03E07C1F;
- } else {
- mask = 0x07E0F81F;
- }
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp++ = (dp1 >> 16) | dp1;
- ++sp;
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp++ = (dp1 >> 16) | dp1;
- ++sp;
- }
- if (dp <= pp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp++ = (dp1 >> 16) | dp1;
- ++sp;
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) &
mask) >> 1) & mask;
- *dp++ = (dp1 >> 16) | dp1;
- ++sp;
- }
- continue;
- }
- while (dp < lp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp++ = (dp1 >> 16) | dp1;
- ++sp;
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit shadow graphic object clipped into 24 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24ShadowClip(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- VMemType24* pp;
- const VMemType24* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory24 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- *dp++ = pixels[*sp++];
- *dp++ = pixels[*sp++];
- }
- if (dp <= pp) {
- *dp++ = pixels[*sp++];
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- *dp++ = pixels[*sp++];
- }
- continue;
- }
- while (dp < lp) {
- *dp++ = pixels[*sp++];
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-
-/**
-** Draw 8bit shadow graphic object clipped into 32 bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32ShadowClip(const Graphic* sprite, unsigned frame, int
x, int y)
-{
- int ox;
- int ex;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- VMemType32* pp;
- const VMemType32* pixels;
- int da;
- unsigned long dp1;
- unsigned long dp2;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines, if needed.
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth - sw;
- dp = VideoMemory32 + x + y * VideoWidth;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- do {
- lp = dp + sw;
- do { // 1
line
- dp += *sp++; //
transparent
- pp = dp - 1 + *sp++;
// opaque
- while (dp < pp) { // unroll
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp++ = (dp1 | (dp2 << 8));
- ++sp;
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp++ = (dp1 | (dp2 << 8));
- ++sp;
- }
- if (dp <= pp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp++ = (dp1 | (dp2 << 8));
- ++sp;
- }
- } while (dp < lp);
- dp += da;
- } while (dp < ep); // all lines
-
- } else {
// Clip horizontal
-
- da += ox;
- do {
- lp = dp + w;
- //
- // Clip left
- //
- pp = dp - ox;
- for (;;) {
- pp += *sp++; //
transparent
- if (pp >= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp += *sp; //
opaque
- if (pp >= dp) {
- sp += *sp - (pp - dp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp += *sp++; //
transparent
-middle_trans:
- if (dp >= lp) {
- lp += sw - w - ox;
- goto right_trans;
- }
- pp = dp + *sp++;
// opaque
-middle_pixel:
- if (pp < lp) {
- while (dp < pp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp++ = (dp1 | (dp2 << 8));
- ++sp;
- }
- continue;
- }
- while (dp < lp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp++ = (dp1 | (dp2 << 8));
- ++sp;
- }
- sp += pp - dp;
- dp = pp;
- break;
- }
-
- //
- // Clip right
- //
- lp += sw - w - ox;
- while (dp < lp) {
- dp += *sp++; //
transparent
-right_trans:
- dp += *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
- } while (dp < ep); // all lines
-
- }
-}
-#endif
-
-#ifdef USE_SDL_SURFACE
- // FIXME: todo
-#else
-/**
-** Draw 8bit shadow graphic object clipped and flipped in X
direction
-** into 8bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to8ShadowClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ex;
- int ox;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType8* dp;
- const VMemType8* lp;
- const VMemType8* ep;
- VMemType8* pp;
- const VMemType8* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType8*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory8 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp = lookup50trans8[(ColorBlack.D8 <<
8) | *dp];
- --dp;
- ++sp;
- *dp = lookup50trans8[(ColorBlack.D8 <<
8) | *dp];
- --dp;
- ++sp;
- }
- if (dp >= pp) {
- *dp = lookup50trans8[(ColorBlack.D8 <<
8) | *dp];
- --dp;
- ++sp;
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp =
lookup50trans8[(ColorBlack.D8 << 8) | *dp];
- --dp;
- ++sp;
- }
- continue;
- }
- while (dp > lp) {
- *dp = lookup50trans8[(ColorBlack.D8 <<
8) | *dp];
- --dp;
- ++sp;
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit shadow graphic object clipped and flipped in X
direction
-** into 16bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to16ShadowClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ex;
- int ox;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType16* dp;
- const VMemType16* lp;
- const VMemType16* ep;
- VMemType16* pp;
- const VMemType16* pixels;
- int da;
- unsigned long dp1;
- unsigned long mask;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType16*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory16 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (VideoBpp == 15) {
- mask = 0x03E07C1F;
- } else {
- mask = 0x07E0F81F;
- }
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp-- = (dp1 >> 16) | dp1;
- ++sp;
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp-- = (dp1 >> 16) | dp1;
- ++sp;
- }
- if (dp >= pp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp-- = (dp1 >> 16) | dp1;
- ++sp;
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) &
mask) >> 1) & mask;
- *dp-- = (dp1 >> 16) | dp1;
- ++sp;
- }
- continue;
- }
- while (dp > lp) {
- dp1 = *dp;
- dp1 = ((((dp1 << 16) | dp1) & mask) >>
1) & mask;
- *dp-- = (dp1 >> 16) | dp1;
- ++sp;
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit shadow graphic object clipped and flipped in X
direction
-** into 24bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to24ShadowClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ex;
- int ox;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType24* dp;
- const VMemType24* lp;
- const VMemType24* ep;
- VMemType24* pp;
- const VMemType24* pixels;
- int da;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType24*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory24 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- *dp-- = pixels[*sp++];
- }
- if (dp >= pp) {
- *dp-- = pixels[*sp++];
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= sw - w - ox;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + sw - w - ox;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- *dp-- = pixels[*sp++];
- }
- continue;
- }
- while (dp > lp) {
- *dp-- = pixels[*sp++];
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit shadow graphic object clipped and flipped in X
direction
-** into 32bit framebuffer.
-**
-** @param sprite pointer to object
-** @param frame number of frame (object index)
-** @param x x coordinate on the screen
-** @param y y coordinate on the screen
-*/
-local void VideoDraw8to32ShadowClipX(const Graphic* sprite, unsigned frame,
- int x, int y)
-{
- int ex;
- int ox;
- int oy;
- int w;
- int h;
- const unsigned char* sp;
- int sw;
- VMemType32* dp;
- const VMemType32* lp;
- const VMemType32* ep;
- VMemType32* pp;
- const VMemType32* pixels;
- int da;
- unsigned long dp1;
- unsigned long dp2;
-
- //
- // reduce to visible range
- //
- sw = w = sprite->Width;
- h = sprite->Height;
- CLIP_RECTANGLE_OFS(x, y, w, h, ox, oy, ex);
-
- //
- // Draw the clipped sprite
- //
- pixels = (VMemType32*)sprite->Pixels;
- sp = ((unsigned char**)sprite->Frames)[frame];
-
- //
- // Skip top lines
- //
- while (oy--) {
- da = 0;
- do {
- da += *sp++;
// transparent
- da += *sp;
// opaque
- sp += *sp + 1;
- } while (da < sw);
- }
-
- da = VideoWidth + sw;
- dp = VideoMemory32 + x + y * VideoWidth + w - 1;
- ep = dp + VideoWidth * h;
-
- if (w == sw) { // Unclipped
horizontal
-
- while (dp < ep) { // all lines
- lp = dp - w;
- do { // 1
line
- dp -= *sp++; //
transparent
- pp = dp + 1 - *sp++;
// opaque
- while (dp > pp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp-- = (dp1 | (dp2 << 8));
- ++sp;
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp-- = (dp1 | (dp2 << 8));
- ++sp;
- }
- if (dp >= pp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp-- = (dp1 | (dp2 << 8));
- ++sp;
- }
- } while (dp > lp);
- dp += da;
- }
-
- } else {
// Clip horizontal
-
- da -= ex;
- while (dp < ep) { // all lines
- lp = dp - w;
- //
- // Clip right side
- //
- pp = dp + ex;
- for (;;) {
- pp -= *sp++; //
transparent
- if (pp <= dp) {
- dp = pp;
- goto middle_trans;
- }
- pp -= *sp; //
opaque
- if (pp <= dp) {
- sp += *sp - (dp - pp) + 1;
- goto middle_pixel;
- }
- sp += *sp + 1;
- }
-
- //
- // Draw middle
- //
- for (;;) {
- dp -= *sp++; //
transparent
-middle_trans:
- if (dp <= lp) {
- lp -= ox;
- goto right_trans;
- }
- pp = dp - *sp++;
// opaque
-middle_pixel:
- if (pp > lp) {
- while (dp > pp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp-- = (dp1 | (dp2 << 8));
- ++sp;
- }
- continue;
- }
- while (dp > lp) {
- dp1 = *dp;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
- dp1 = (dp1 >> 1) & 0x00FF00FF;
- dp2 = (dp2 >> 1) & 0x00FF00FF;
- *dp-- = (dp1 | (dp2 << 8));
- ++sp;
- }
- sp += dp - pp;
- dp = pp;
- break;
- }
-
- //
- // Clip left side
- //
- lp -= ox;
- while (dp > lp) {
- dp -= *sp++; //
transparent
-right_trans:
- dp -= *sp; //
opaque
- sp += *sp + 1;
- }
- dp += da;
-
- }
- }
-}
-
-/**
-** Draw 8bit raw graphic data clipped, using given pixel pallette
-** of a given color-depth in bytes: 8=1, 16=2, 24=3, 32=4
-**
-** @param pixels VMemType 256 color palette to translate
given data
-** @param data raw graphic data in 8bit color indexes
of above palette
-** @param x left-top corner x coordinate in pixels
on the screen
-** @param y left-top corner y coordinate in pixels
on the screen
-** @param w width of above graphic data in pixels
-** @param h height of above graphic data in pixels
-** @param bytes color-depth of given palette
-**
-** FIXME: make this faster..
-*/
-global void VideoDrawRawXXClip(char *pixels, const unsigned char *data,
- int x, int y, int w, int h, char bytes)
-{
- char *dest;
- int ofsx;
- int ofsy;
- int skipx;
- int nextline;
-
- // Clip given rectangle area, keeping track of start- and end-offsets
- nextline = w;
- CLIP_RECTANGLE_OFS(x, y, w, h, ofsx, ofsy, skipx);
- data += (ofsy * nextline) + ofsx;
- skipx += ofsx;
-
- // Draw the raw data, through the given palette
- dest = (char*)VideoMemory + (y * VideoWidth + x) * bytes;
- nextline = (VideoWidth - w) * bytes;
-
- do {
- int w2;
- w2 = w;
-
- do {
- memcpy(dest, pixels + *data++ * bytes, bytes);
- dest += bytes;
- } while (--w2 > 0);
-
- data += skipx;
- dest += nextline;
- } while (--h > 0);
-}
-#endif
-
-#ifdef USE_SDL_SURFACE
- // FIXME: todo
-#else
-/**
-** Draw 8bit raw graphic data clipped, using given pixel pallette
-** into 8bit framebuffer.
-**
-** @param pixels VMemType8 256 color palette to
translate given data
-** @param data raw graphic data in 8bit color indexes
of above palette
-** @param x left-top corner x coordinate in pixels
on the screen
-** @param y left-top corner y coordinate in pixels
on the screen
-** @param w width of above graphic data in pixels
-** @param h height of above graphic data in pixels
-*/
-local void VideoDrawRaw8Clip(VMemType *pixels, const unsigned char *data,
- int x, int y, int w, int h)
-{
- VideoDrawRawXXClip((char*)pixels, data, x, y, w, h, sizeof(VMemType8));
-}
-
-/**
-** Draw 8bit raw graphic data clipped, using given pixel pallette
-** into 16bit framebuffer.
-**
-** @param pixels VMemType16 256 color palette to
translate given data
-** @param data raw graphic data in 8bit color indexes
of above palette
-** @param x left-top corner x coordinate in pixels
on the screen
-** @param y left-top corner y coordinate in pixels
on the screen
-** @param w width of above graphic data in pixels
-** @param h height of above graphic data in pixels
-*/
-local void VideoDrawRaw16Clip(VMemType *pixels, const unsigned char *data,
- int x, int y, int w, int h)
-{
- VideoDrawRawXXClip((char*)pixels, data, x, y, w, h, sizeof(VMemType16));
-}
-
-/**
-** Draw 8bit raw graphic data clipped, using given pixel pallette
-** into 24bit framebuffer.
-**
-** @param pixels VMemType24 256 color palette to
translate given data
-** @param data raw graphic data in 8bit color indexes
of above palette
-** @param x left-top corner x coordinate in pixels
on the screen
-** @param y left-top corner y coordinate in pixels
on the screen
-** @param w width of above graphic data in pixels
-** @param h height of above graphic data in pixels
-*/
-local void VideoDrawRaw24Clip(VMemType *pixels, const unsigned char *data,
- int x, int y, int w, int h)
-{
- VideoDrawRawXXClip((char*)pixels, data, x, y, w, h, sizeof(VMemType24));
-}
-
-/**
-** Draw 8bit raw graphic data clipped, using given pixel pallette
-** into 32bit framebuffer.
-**
-** @param pixels VMemType32 256 color palette to
translate given data
-** @param data raw graphic data in 8bit color indexes
of above palette
-** @param x left-top corner x coordinate in pixels
on the screen
-** @param y left-top corner y coordinate in pixels
on the screen
-** @param w width of above graphic data in pixels
-** @param h height of above graphic data in pixels
-*/
-local void VideoDrawRaw32Clip(VMemType *pixels, const unsigned char *data,
- int x, int y, int w, int h)
-{
- VideoDrawRawXXClip((char*)pixels, data, x, y, w, h, sizeof(VMemType32));
-}
-#endif
-
-#ifdef USE_SDL_SURFACE
-local void FreeSprite(Graphic* graphic)
+local void FreeSprite(Graphic* graphic)
{
int i;
#ifdef DEBUG_TODO
AllocatedGraphicMemory -= graphic->Size;
AllocatedGraphicMemory -= sizeof(Graphic);
#endif
- for (i = 0; i < graphic->NumFrames; ++i) {
- SDL_FreeSurface(&graphic->Surface[i]);
- }
-}
-#else
-/**
-** Free graphic object.
-*/
-local void FreeSprite8(Graphic* graphic)
-{
-#ifdef DEBUG
- AllocatedGraphicMemory -= graphic->Size;
- AllocatedGraphicMemory -= sizeof(Graphic);
-#endif
-
#ifdef USE_OPENGL
if (graphic->NumTextureNames) {
glDeleteTextures(graphic->NumTextureNames,
graphic->TextureNames);
free(graphic->TextureNames);
}
#endif
- VideoFreeSharedPalette(graphic->Pixels);
- free(graphic->Frames);
- free(graphic);
+ for (i = 0; i < graphic->NumFrames; ++i) {
+ SDL_FreeSurface(&graphic->Surface[i]);
+ }
}
-#endif
// FIXME: need 16 bit palette version
// FIXME: need alpha blending version
@@ -4611,7 +527,7 @@
*/
global Graphic* LoadSprite(const char* name, int width, int height)
{
-#ifdef USE_SDL_SURFACE
+#ifndef USE_OPENGL
Graphic * g;
int nframes;
@@ -4626,19 +542,6 @@
return g;
#else
Graphic* graphic;
-#ifndef USE_OPENGL
- Graphic* sprite;
- unsigned char* data;
- const unsigned char* sp;
- unsigned char* dp;
- unsigned char* cp;
- int fl;
- int n;
- int counter;
- int i;
- int h;
- int w;
-#endif
int depth;
graphic = LoadGraphic(name);
@@ -4664,7 +567,6 @@
DebugCheck(((graphic->Width / width) * width != graphic->Width) ||
((graphic->Height / height) * height != graphic->Height));
-#ifdef USE_OPENGL
MakeTexture(graphic, width, height);
graphic->NumFrames = (graphic->Width / width) * (graphic->Height /
height);
graphic->GraphicWidth = graphic->Width;
@@ -4672,132 +574,7 @@
graphic->Width = width;
graphic->Height = height;
- if (depth == 8) {
- graphic->Type = &GraphicSprite8Type;
- } else if (depth == 16) {
- graphic->Type = &GraphicSprite16Type;
- } else {
- fprintf(stderr, "Unsported image depth\n");
- ExitFatal(-1);
- }
-
return graphic;
-#else
- n = (graphic->Width / width) * (graphic->Height / height);
- DebugLevel3Fn("%dx%d in %dx%d = %d frames.\n" _C_ width _C_ height _C_
- graphic->Width _C_ graphic->Height _C_ n);
-
- //
- // Allocate structure
- //
- sprite = malloc(sizeof(Graphic));
-#ifdef DEBUG
- AllocatedGraphicMemory += sizeof(Graphic);
-#endif
-
- if (!sprite) {
- fprintf(stderr, "Out of memory\n");
- ExitFatal(-1);
- }
- if (depth == 8) {
- sprite->Type = &GraphicSprite8Type;
- } else if (depth == 16) {
- sprite->Type = &GraphicSprite16Type;
- } else {
- fprintf(stderr, "Unsported image depth\n");
- ExitFatal(-1);
- }
-
- sprite->Width = width;
- sprite->Height = height;
-
- sprite->NumFrames = n;
-
- sprite->Palette = graphic->Palette;
- sprite->Pixels = graphic->Pixels; // WARNING: if not
shared freed below!
-
- sprite->Size = 0;
- sprite->Frames = NULL;
-
- // Worst case is alternating opaque and transparent pixels
- data = malloc(n * sizeof(unsigned char*) +
- (graphic->Width / 2 + 1) * 3 * graphic->Height);
- // Pixel area
- dp = (unsigned char*)data + n * sizeof(unsigned char*);
-
- //
- // Compress all frames of the sprite.
- //
- fl = graphic->Width / width;
- for (i = 0; i < n; ++i) { // each frame
- ((unsigned char**)data)[i] = dp;
- for (h = 0; h < height; ++h) { // each line
- sp = (const unsigned char*)graphic->Frames + (i % fl) *
width +
- ((i / fl) * height + h) * graphic->Width;
-
- for (counter = w = 0; w < width; ++w) {
- if (*sp == 255 || *sp == 0) {
// start transparency
- ++sp;
- if (++counter == 256) {
- *dp++ = 255;
- *dp++ = 0;
- counter = 1;
- }
- continue;
- }
- *dp++ = counter;
-
- cp = dp++;
- counter = 0;
- for(; w < width; ++w) {
// opaque
- *dp++ = *sp++;
- if (++counter == 255) {
- *cp = 255;
- *dp++ = 0;
- cp = dp++;
- counter = 0;
- }
- // ARI: FIXME: wrong position
- if (w + 1 != width && (*sp == 255 ||
*sp == 0)) { // end transparency
- break;
- }
- }
- *cp = counter;
- counter = 0;
- }
- if (counter) {
- *dp++ = counter;
- *dp++ = 0; // 1
byte more, 1 check less! (phantom end transparency)
- }
- }
- }
-
- DebugLevel3Fn("\t%d => %d RLE compressed\n" _C_
- graphic->Width * graphic->Height _C_ dp - data);
-
- //
- // Update to real length
- //
- sprite->Frames = data;
- i = n * sizeof(unsigned char*) + dp - data;
- sprite->Size = i;
- dp = realloc(data, i);
- if (dp != data) { //
shrink only - happens rarely
- for (h = 0; h < n; ++h) { // convert address
- ((unsigned char**)dp)[h] += dp - data;
- }
- sprite->Frames = dp;
- }
-
-#ifdef DEBUG
- CompressedGraphicMemory += i;
-#endif
-
- graphic->Pixels = NULL; // We own now the
shared pixels
- VideoFree(graphic);
-
- return sprite;
-#endif
#endif
}
@@ -4806,82 +583,6 @@
*/
global void InitSprite(void)
{
-#ifdef USE_SDL_SURFACE
-
-#else
-
-#ifdef USE_OPENGL
- GraphicSprite8Type.Draw = VideoDrawOpenGL;
- GraphicSprite8Type.DrawClip = VideoDrawClipOpenGL;
- GraphicSprite8Type.DrawShadowClip = VideoDraw8to32ShadowClip;
- GraphicSprite8Type.DrawX = VideoDrawXOpenGL;
- GraphicSprite8Type.DrawClipX = VideoDrawClipXOpenGL;
- GraphicSprite8Type.DrawShadowClipX = VideoDraw8to32ShadowClipX;
- VideoDrawRawClip = VideoDrawRaw32Clip;
-#else
-
- switch (VideoBpp) {
- case 8:
- GraphicSprite8Type.Draw = VideoDraw8to8;
- GraphicSprite8Type.DrawClip = VideoDraw8to8Clip;
- GraphicSprite8Type.DrawShadowClip =
VideoDraw8to8ShadowClip;
- GraphicSprite8Type.DrawX = VideoDraw8to8X;
- GraphicSprite8Type.DrawClipX = VideoDraw8to8ClipX;
- GraphicSprite8Type.DrawShadowClipX =
VideoDraw8to8ShadowClipX;
- GraphicSprite8Type.DrawClipTrans50 =
VideoDraw8to8ClipTrans50;
- GraphicSprite8Type.DrawXTrans50 = VideoDraw8to8XTrans50;
- GraphicSprite8Type.DrawClipXTrans50 =
VideoDraw8to8ClipXTrans50;
- VideoDrawRawClip = VideoDrawRaw8Clip;
- break;
-
- case 15:
- case 16:
- GraphicSprite8Type.Draw = VideoDraw8to16;
- GraphicSprite8Type.DrawClip = VideoDraw8to16Clip;
- GraphicSprite8Type.DrawShadowClip =
VideoDraw8to16ShadowClip;
- GraphicSprite8Type.DrawX = VideoDraw8to16X;
- GraphicSprite8Type.DrawClipX = VideoDraw8to16ClipX;
- GraphicSprite8Type.DrawShadowClipX =
VideoDraw8to16ShadowClipX;
- GraphicSprite8Type.DrawClipTrans50 =
VideoDraw8to16ClipTrans50;
- GraphicSprite8Type.DrawXTrans50 =
VideoDraw8to16XTrans50;
- GraphicSprite8Type.DrawClipXTrans50 =
VideoDraw8to16ClipXTrans50;
- VideoDrawRawClip = VideoDrawRaw16Clip;
- break;
-
- case 24:
- GraphicSprite8Type.Draw = VideoDraw8to24;
- GraphicSprite8Type.DrawClip = VideoDraw8to24Clip;
- GraphicSprite8Type.DrawShadowClip =
VideoDraw8to24ShadowClip;
- GraphicSprite8Type.DrawX = VideoDraw8to24X;
- GraphicSprite8Type.DrawClipX = VideoDraw8to24ClipX;
- GraphicSprite8Type.DrawShadowClipX =
VideoDraw8to24ShadowClipX;
- GraphicSprite8Type.DrawClipTrans50 =
VideoDraw8to24ClipTrans50;
- GraphicSprite8Type.DrawXTrans50 =
VideoDraw8to24XTrans50;
- GraphicSprite8Type.DrawClipXTrans50 =
VideoDraw8to24ClipXTrans50;
- VideoDrawRawClip = VideoDrawRaw24Clip;
- break;
-
- case 32:
- GraphicSprite8Type.Draw = VideoDraw8to32;
- GraphicSprite8Type.DrawClip = VideoDraw8to32Clip;
- GraphicSprite8Type.DrawShadowClip =
VideoDraw8to32ShadowClip;
- GraphicSprite8Type.DrawX = VideoDraw8to32X;
- GraphicSprite8Type.DrawClipX = VideoDraw8to32ClipX;
- GraphicSprite8Type.DrawShadowClipX =
VideoDraw8to32ShadowClipX;
- GraphicSprite8Type.DrawClipTrans50 =
VideoDraw8to32ClipTrans50;
- GraphicSprite8Type.DrawXTrans50 =
VideoDraw8to32XTrans50;
- GraphicSprite8Type.DrawClipXTrans50 =
VideoDraw8to32ClipXTrans50;
- VideoDrawRawClip = VideoDrawRaw32Clip;
- break;
-
- default:
- DebugLevel0Fn("Unsupported %d bpp\n" _C_ VideoBpp);
- abort();
- }
-#endif
-
- GraphicSprite8Type.Free = FreeSprite8;
-#endif
}
//@}
Index: stratagus/src/video/video.c
diff -u stratagus/src/video/video.c:1.87 stratagus/src/video/video.c:1.88
--- stratagus/src/video/video.c:1.87 Thu Jan 15 10:48:45 2004
+++ stratagus/src/video/video.c Thu Jan 15 13:14:08 2004
@@ -4,13 +4,13 @@
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
-// ______________________ ______________________
-// T H E W A R B E G I N S
-// Stratagus - A free fantasy real time strategy game engine
+// ______________________ ______________________
+// T H E W A R B E G I N S
+// Stratagus - A free fantasy real time strategy game engine
//
-/address@hidden video.c - The universal video functions. */
+/address@hidden video.c - The universal video functions. */
//
-// (c) Copyright 1999-2002 by Lutz Sammer and Nehal Mistry
+// (c) Copyright 1999-2004 by Lutz Sammer and Nehal Mistry
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.c,v 1.87 2004/01/14 23:48:45 jsalmon3 Exp $
+// $Id: video.c,v 1.88 2004/01/15 02:14:08 jsalmon3 Exp $
//@{
@@ -184,11 +184,7 @@
** @see InitVideo @see InitVideoSdl
** @see VMemType
*/
-#ifdef USE_SDL_SURFACE
global SDL_Surface* TheScreen;
-#else
-global VMemType* VideoMemory;
-#endif
global int VideoSyncSpeed = 100; /// 0 disable interrupts
global volatile int VideoInterrupts; /// be happy, were are quicker
@@ -207,17 +203,10 @@
** lookup50trans8:
** The same for 50% color1 and 50% color2.
*/
-#ifdef USE_SDL_SURFACE
// FIXME: docu
global SDL_Color* lookup25trans8;
// FIXME: docu
global SDL_Color* lookup50trans8;
-#else
- // FIXME: docu
-global VMemType8* lookup25trans8;
- // FIXME: docu
-global VMemType8* lookup50trans8;
-#endif
global int ColorWaterCycleStart;
global int ColorWaterCycleEnd;
@@ -227,7 +216,6 @@
global int ColorBuildingCycleEnd;
/// Does ColorCycling..
-#ifdef USE_SDL_SURFACE
global void ColorCycle(void);
Uint32 ColorBlack;
@@ -239,20 +227,6 @@
Uint32 ColorRed;
Uint32 ColorGreen;
Uint32 ColorYellow;
-#else
-global void (*ColorCycle)(void);
-
-VMemType ColorBlack;
-VMemType ColorDarkGreen;
-VMemType ColorBlue;
-VMemType ColorOrange;
-VMemType ColorWhite;
-VMemType ColorNPC;
-VMemType ColorGray;
-VMemType ColorRed;
-VMemType ColorGreen;
-VMemType ColorYellow;
-#endif
/*----------------------------------------------------------------------------
@@ -402,33 +376,8 @@
}
/**
-** Creates a checksum used to compare palettes.
-**
-** @param palette Palette source.
-**
-** @return Calculated hash/checksum.
-*/
-#ifndef USE_SDL_SURFACE
-local long GetPaletteChecksum(const Palette* palette)
-{
- long retVal;
- int i;
-
- for (retVal = i = 0; i < 256; ++i){
- //This is designed to return different values if
- // the pixels are in a different order.
- retVal = ((palette[i].r + i) & 0xff) + retVal;
- retVal = ((palette[i].g + i) & 0xff) + retVal;
- retVal = ((palette[i].b + i) & 0xff) + retVal;
- }
- return retVal;
-}
-#endif
-
-/**
** FIXME: docu
*/
-#ifdef USE_SDL_SURFACE
global void VideoPaletteListAdd(SDL_Surface* surface)
{
PaletteLink* curlink;
@@ -467,78 +416,6 @@
free(tmp);
}
}
-#else
-global VMemType* VideoCreateSharedPalette(const Palette* palette)
-{
- PaletteLink* current_link;
- PaletteLink** prev_link;
- VMemType* pixels;
- long checksum;
-
- pixels = VideoCreateNewPalette(palette);
- checksum = GetPaletteChecksum(palette);
- prev_link = &PaletteList;
- while ((current_link = *prev_link)) {
- if (current_link->Checksum == checksum &&
- !memcmp(current_link->Palette, pixels,
- 256 * ((VideoDepth + 7) / 8))) {
- break;
- }
- prev_link = ¤t_link->Next;
- }
-
- if (current_link) { //
Palette found (reuse)
- free(pixels);
- pixels = current_link->Palette;
- ++current_link->RefCount;
- DebugLevel3("uses palette %p %d\n" _C_ pixels _C_
current_link->RefCount);
- } else {
// Palette NOT found
- DebugLevel3("loading new palette %p\n" _C_ pixels);
-
- current_link = *prev_link = malloc(sizeof(PaletteLink));
- current_link->Checksum = checksum;
- current_link->Next = NULL;
- current_link->Palette = pixels;
- current_link->RefCount = 1;
- }
-
- return pixels;
-}
-
-/**
-** Free a shared hardware palette.
-**
-** @param pixels palette in hardware dependend format
-*/
-global void VideoFreeSharedPalette(VMemType* pixels)
-{
- PaletteLink* current_link;
- PaletteLink** prev_link;
-
-// if (pixels == Pixels) {
-// DebugLevel3Fn("Freeing global palette\n");
-// }
-
- //
- // Find and free palette.
- //
- prev_link = &PaletteList;
- while ((current_link = *prev_link)) {
- if (current_link->Palette == pixels) {
- break;
- }
- prev_link = ¤t_link->Next;
- }
- if (current_link) {
- if (!--current_link->RefCount) {
- DebugLevel3Fn("Free palette %p\n" _C_ pixels);
- free(current_link->Palette);
- *prev_link = current_link->Next;
- free(current_link);
- }
- }
-}
-#endif
/**
** Load a picture and display it on the screen (full screen),
@@ -556,7 +433,6 @@
MakeTexture(picture, picture->Width, picture->Height);
#endif
-#ifdef USE_SDL_SURFACE
#ifndef USE_OPENGL
// Unset the alpha color key, not needed
SDL_SetColorKey(picture->Surface, 0, 0);
@@ -565,12 +441,6 @@
VideoDrawSubClip(picture, 0, 0, picture->Width, picture->Height,
(VideoWidth - picture->Width) / 2, (VideoHeight -
picture->Height) / 2);
#endif
-#else
- VideoLockScreen();
- VideoDrawSubClip(picture, 0, 0, picture->Width, picture->Height,
- (VideoWidth - picture->Width) / 2, (VideoHeight -
picture->Height) / 2);
- VideoUnlockScreen();
-#endif
VideoFree(picture);
}
@@ -603,11 +473,8 @@
// 205-207 cycle (lights on christmas
tree)
// 240-244 cycle (water around ships,
Runestone, Dark Portal)
-#ifdef USE_SDL_SURFACE
/**
** Color cycle.
-**
-** FIXME: Also icons and some units use color cycling.
*/
// FIXME: cpu intensive to go through the whole PaletteList
global void ColorCycle(void)
@@ -673,229 +540,6 @@
MustRedraw |= RedrawColorCycle;
}
-#else
-local void ColorCycle8(void)
-{
- int i;
- int x;
- VMemType8* pixels;
-
- if (ColorCycleAll) {
- PaletteLink* current_link;
-
- current_link = PaletteList;
- while (current_link != NULL) {
- x =
((VMemType8*)(current_link->Palette))[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd;
++i) { // tileset color cycle
- ((VMemType8*)(current_link->Palette))[i] =
- ((VMemType8*)(current_link->Palette))[i
+ 1];
- }
-
((VMemType8*)(current_link->Palette))[ColorWaterCycleEnd] = x;
-
- x =
((VMemType8*)(current_link->Palette))[ColorIconCycleStart];
- for (i = ColorIconCycleStart; i < ColorIconCycleEnd;
++i) { // units/icons color cycle
- ((VMemType8*)(current_link->Palette))[i] =
- ((VMemType8*)(current_link->Palette))[i
+ 1];
- }
- ((VMemType8*)
(current_link->Palette))[ColorIconCycleEnd] = x;
-
- x =
((VMemType8*)(current_link->Palette))[ColorBuildingCycleStart];
- for (i = ColorBuildingCycleStart; i <
ColorBuildingCycleEnd; ++i) { // buildings color cycle
- ((VMemType8*)(current_link->Palette))[i] =
- ((VMemType8*)(current_link->Palette))[i
+ 1];
- }
-
((VMemType8*)(current_link->Palette))[ColorBuildingCycleEnd] = x;
-
- current_link = current_link->Next;
- }
- } else {
-
- //
- // Color cycle tileset palette
- //
- pixels = TheMap.TileData->Pixels;
- x = pixels[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd; ++i) {
- pixels[i] = pixels[i + 1];
- }
- pixels[ColorWaterCycleEnd] = x;
- }
-
- MapColorCycle(); // FIXME: could be
little more informative
- MustRedraw |= RedrawColorCycle;
-}
-
-/**
-** Color cycle for 16 bpp video mode.
-**
-** FIXME: Also icons and some units use color cycling.
-** FIXME: must be configured by the tileset or global.
-*/
-local void ColorCycle16(void)
-{
- int i;
- int x;
- VMemType16* pixels;
-
- if (ColorCycleAll) {
- PaletteLink* current_link;
-
- current_link = PaletteList;
- while (current_link != NULL) {
- x =
((VMemType16*)(current_link->Palette))[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd;
++i) { // tileset color cycle
- ((VMemType16*)(current_link->Palette))[i] =
-
((VMemType16*)(current_link->Palette))[i + 1];
- }
-
((VMemType16*)(current_link->Palette))[ColorWaterCycleEnd] = x;
-
- x =
((VMemType16*)(current_link->Palette))[ColorIconCycleStart];
- for (i = ColorIconCycleStart; i < ColorIconCycleEnd;
++i) { // units/icons color cycle
- ((VMemType16*)(current_link->Palette))[i] =
-
((VMemType16*)(current_link->Palette))[i + 1];
- }
-
((VMemType16*)(current_link->Palette))[ColorIconCycleEnd] = x;
-
- x =
((VMemType16*)(current_link->Palette))[ColorBuildingCycleStart];
- for (i = ColorBuildingCycleStart; i <
ColorBuildingCycleEnd; ++i) { // Buildings color cycle
- ((VMemType16*)(current_link->Palette))[i] =
-
((VMemType16*)(current_link->Palette))[i + 1];
- }
-
((VMemType16*)(current_link->Palette))[ColorBuildingCycleEnd] = x;
-
- current_link = current_link->Next;
- }
- } else {
-
- //
- // Color cycle tileset palette
- //
- pixels = TheMap.TileData->Pixels;
- x = pixels[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd; ++i) {
- pixels[i] = pixels[i + 1];
- }
- pixels[ColorWaterCycleEnd] = x;
- }
-
- MapColorCycle(); // FIXME: could be
little more informative
- MustRedraw |= RedrawColorCycle;
-}
-
-/**
-** Color cycle for 24 bpp video mode.
-**
-** FIXME: Also icons and some units use color cycling.
-** FIXME: must be configured by the tileset or global.
-*/
-local void ColorCycle24(void)
-{
- int i;
- VMemType24 x;
- VMemType24* pixels;
-
- if (ColorCycleAll) {
- PaletteLink* current_link;
-
- current_link = PaletteList;
- while (current_link != NULL) {
- x =
((VMemType24*)(current_link->Palette))[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd;
++i) { // tileset color cycle
- ((VMemType24*)(current_link->Palette))[i] =
-
((VMemType24*)(current_link->Palette))[i + 1];
- }
-
((VMemType24*)(current_link->Palette))[ColorWaterCycleEnd] = x;
-
- x =
((VMemType24*)(current_link->Palette))[ColorIconCycleStart];
- for (i = ColorIconCycleStart; i < ColorIconCycleEnd;
++i) { // units/icons color cycle
- ((VMemType24*)(current_link->Palette))[i] =
-
((VMemType24*)(current_link->Palette))[i + 1];
- }
-
((VMemType24*)(current_link->Palette))[ColorIconCycleEnd] = x;
-
- x =
((VMemType24*)(current_link->Palette))[ColorBuildingCycleStart];
- for (i = ColorBuildingCycleStart; i <
ColorBuildingCycleEnd; ++i) { // Buildings color cycle
- ((VMemType24*)(current_link->Palette))[i] =
-
((VMemType24*)(current_link->Palette))[i + 1];
- }
-
((VMemType24*)(current_link->Palette))[ColorBuildingCycleEnd] = x;
-
- current_link = current_link->Next;
- }
- } else {
-
- //
- // Color cycle tileset palette
- //
- pixels = TheMap.TileData->Pixels;
- x = pixels[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd; ++i) {
- pixels[i] = pixels[i + 1];
- }
- pixels[ColorWaterCycleEnd] = x;
- }
-
- MapColorCycle(); // FIXME: could be
little more informative
- MustRedraw |= RedrawColorCycle;
-}
-
-/**
-** Color cycle for 32 bpp video mode.
-**
-** FIXME: Also icons and some units use color cycling.
-** FIXME: must be configured by the tileset or global.
-*/
-local void ColorCycle32(void)
-{
- int i;
- int x;
- VMemType32* pixels;
-
- if (ColorCycleAll) {
- PaletteLink* current_link;
-
- current_link = PaletteList;
- while (current_link != NULL) {
- x =
((VMemType32*)(current_link->Palette))[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd;
++i) { // tileset color cycle
- ((VMemType32*)(current_link->Palette))[i] =
-
((VMemType32*)(current_link->Palette))[i + 1];
- }
-
((VMemType32*)(current_link->Palette))[ColorWaterCycleEnd] = x;
-
- x =
((VMemType32*)(current_link->Palette))[ColorIconCycleStart];
- for (i = ColorIconCycleStart; i < ColorIconCycleEnd;
++i) { // units/icons color cycle
- ((VMemType32*)(current_link->Palette))[i] =
-
((VMemType32*)(current_link->Palette))[i + 1];
- }
-
((VMemType32*)(current_link->Palette))[ColorIconCycleEnd] = x;
-
- x =
((VMemType32*)(current_link->Palette))[ColorBuildingCycleStart];
- for (i = ColorBuildingCycleStart; i <
ColorBuildingCycleEnd; ++i) { // Buildings color cycle
- ((VMemType32*)(current_link->Palette))[i] =
-
((VMemType32*)(current_link->Palette))[i + 1];
- }
-
((VMemType32*)(current_link->Palette))[ColorBuildingCycleEnd] = x;
-
- current_link = current_link->Next;
- }
- } else {
-
- //
- // Color cycle tileset palette
- //
- pixels = TheMap.TileData->Pixels;
- x = pixels[ColorWaterCycleStart];
- for (i = ColorWaterCycleStart; i < ColorWaterCycleEnd; ++i) {
- pixels[i] = pixels[i + 1];
- }
- pixels[ColorWaterCycleEnd] = x;
- }
-
- MapColorCycle(); // FIXME: could be
little more informative
- MustRedraw |= RedrawColorCycle;
-}
-#endif
/*----------------------------------------------------------------------------
-- Functions
@@ -946,22 +590,6 @@
{
#ifdef USE_SDL
InitVideoSdl();
-#endif
-
- //
- // General (video) modules and settings
- //
-#ifdef USE_SDL_SURFACE
-#else
- switch (VideoBpp) {
- case 8: ColorCycle = ColorCycle8; break;
- case 15:
- case 16: ColorCycle = ColorCycle16; break;
- case 24: ColorCycle = ColorCycle24; break;
- case 32: ColorCycle = ColorCycle32; break;
- default: DebugLevel0Fn("Video %d bpp unsupported\n" _C_
VideoBpp);
- }
- VideoTypeSize = VideoBpp / 8;
#endif
//
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/video cursor.c font.c graphic.c l...,
address@hidden <=