Removed ugly manual bit-packing; other cleanups
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2383 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -19,13 +19,6 @@
|
||||
#ifndef _DISPLAY_H
|
||||
#define _DISPLAY_H
|
||||
|
||||
/*
|
||||
#define WANT_MASK (CREATE_FLAGS)(1 << 0)
|
||||
#define WANT_PIXMAP (CREATE_FLAGS)(1 << 1)
|
||||
*/
|
||||
#define WANT_COMPRESSED (CREATE_FLAGS)(1 << 2)
|
||||
#define DOUBLE_RES (CREATE_FLAGS)(1 << 3)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CREATE_FLAGS DisplayFlags;
|
||||
|
||||
@@ -56,12 +56,9 @@ CreateDisplay (CREATE_FLAGS CreateFlags, PSIZE pwidth, PSIZE pheight)
|
||||
if (!DisplayActive ())
|
||||
return (0);
|
||||
|
||||
Drawable = _request_drawable (
|
||||
(COUNT)1, (DRAWABLE_TYPE)SCREEN_DRAWABLE,
|
||||
(CREATE_FLAGS)(CreateFlags & (WANT_PIXMAP | (GetDisplayFlags () & WANT_MASK))),
|
||||
(SIZE)GetDisplayWidth (),
|
||||
(SIZE)GetDisplayHeight ()
|
||||
);
|
||||
Drawable = _request_drawable (1, SCREEN_DRAWABLE,
|
||||
(CreateFlags & (WANT_PIXMAP | (GetDisplayFlags () & WANT_MASK))),
|
||||
GetDisplayWidth (), GetDisplayHeight ());
|
||||
if (Drawable)
|
||||
{
|
||||
FRAMEPTR F;
|
||||
@@ -101,9 +98,10 @@ AllocDrawable (COUNT n)
|
||||
FRAMEPTR F;
|
||||
F = &DrawablePtr->Frame[i];
|
||||
F->parent = DrawablePtr;
|
||||
F->TypeIndexAndFlags = 0;
|
||||
F->Type = 0;
|
||||
F->Index = 0;
|
||||
F->image = 0;
|
||||
F->Bounds = 0;
|
||||
F->Bounds.width = F->Bounds.height = 0;
|
||||
F->HotSpot.x = F->HotSpot.y = 0;
|
||||
}
|
||||
|
||||
@@ -121,12 +119,10 @@ CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width, SIZE height, COUNT
|
||||
if (!DisplayActive ())
|
||||
return (0);
|
||||
|
||||
Drawable = _request_drawable (
|
||||
(COUNT)num_frames, (DRAWABLE_TYPE)RAM_DRAWABLE,
|
||||
(CREATE_FLAGS)(CreateFlags & (WANT_MASK | WANT_PIXMAP
|
||||
Drawable = _request_drawable (num_frames, RAM_DRAWABLE,
|
||||
(CreateFlags & (WANT_MASK | WANT_PIXMAP
|
||||
| WANT_ALPHA | MAPPED_TO_DISPLAY)),
|
||||
(SIZE)width, (SIZE)height
|
||||
);
|
||||
width, height);
|
||||
if (Drawable)
|
||||
{
|
||||
FRAMEPTR F;
|
||||
|
||||
@@ -48,46 +48,42 @@ typedef BRESENHAM_LINE *PBRESENHAM_LINE;
|
||||
#define PAD_WIDTH(w) (w)
|
||||
#endif /* MSDOS */
|
||||
|
||||
#define FTYPE_SHIFT 12
|
||||
#define FINDEX_MASK ((1 << FTYPE_SHIFT) - 1)
|
||||
#define FTYPE_MASK (0xFFFF & ~FINDEX_MASK)
|
||||
|
||||
#define ROM_DRAWABLE (0 << FTYPE_SHIFT)
|
||||
#define RAM_DRAWABLE (1 << FTYPE_SHIFT)
|
||||
#define SCREEN_DRAWABLE (2 << FTYPE_SHIFT)
|
||||
|
||||
typedef UWORD DRAWABLE_TYPE;
|
||||
#define ROM_DRAWABLE 0
|
||||
#define RAM_DRAWABLE 1
|
||||
#define SCREEN_DRAWABLE 2
|
||||
|
||||
#define DATA_HARDWARE (1 << 12)
|
||||
#define DATA_COPY (1 << 13)
|
||||
#define DATA_PACKED (1 << 14)
|
||||
#define X_FLIP (1 << 15)
|
||||
|
||||
typedef struct
|
||||
typedef struct frame_desc
|
||||
{
|
||||
DWORD TypeIndexAndFlags;
|
||||
DRAWABLE_TYPE Type;
|
||||
UWORD Index;
|
||||
HOT_SPOT HotSpot;
|
||||
DWORD Bounds;
|
||||
EXTENT Bounds;
|
||||
TFB_Image *image;
|
||||
struct _drawable_desc *parent;
|
||||
struct drawable_desc *parent;
|
||||
} FRAME_DESC;
|
||||
typedef FRAME_DESC *PFRAME_DESC;
|
||||
|
||||
typedef struct _drawable_desc
|
||||
typedef struct drawable_desc
|
||||
{
|
||||
MEM_HANDLE hDrawable;
|
||||
|
||||
UWORD FlagsAndIndex;
|
||||
CREATE_FLAGS Flags;
|
||||
UWORD MaxIndex;
|
||||
FRAME_DESC *Frame;
|
||||
} DRAWABLE_DESC;
|
||||
typedef DRAWABLE_DESC *PDRAWABLE_DESC;
|
||||
|
||||
#define GetFrameWidth(f) LOWORD (((FRAMEPTR)(f))->Bounds)
|
||||
#define GetFrameHeight(f) HIWORD (((FRAMEPTR)(f))->Bounds)
|
||||
#define SetFrameBounds(f,w,h) (((FRAMEPTR)(f))->Bounds=MAKE_DWORD(w,h))
|
||||
#define GetFrameFlags(f) HIWORD(((FRAMEPTR)(f))->TypeIndexAndFlags)
|
||||
#define AddFrameFlags(f,v) (((FRAMEPTR)(f))->TypeIndexAndFlags|=((DWORD)(v)<<16))
|
||||
#define SubFrameFlags(f,v) (((FRAMEPTR)(f))->TypeIndexAndFlags&=~((DWORD)(v)<<16))
|
||||
#define GetFrameWidth(f) (((PFRAME_DESC)(f))->Bounds.width)
|
||||
#define GetFrameHeight(f) (((PFRAME_DESC)(f))->Bounds.height)
|
||||
#define SetFrameBounds(f,w,h) \
|
||||
(((PFRAME_DESC)(f))->Bounds.width=(w), \
|
||||
((PFRAME_DESC)(f))->Bounds.height=(h))
|
||||
|
||||
#define DRAWABLE_PRIORITY DEFAULT_MEM_PRIORITY
|
||||
|
||||
|
||||
@@ -44,9 +44,7 @@ ReleaseDrawable (FRAMEPTR FramePtr)
|
||||
DRAWABLEPTR DrawablePtr;
|
||||
|
||||
DrawablePtr = GetFrameParentDrawable (FramePtr);
|
||||
Drawable = BUILD_DRAWABLE (
|
||||
DrawablePtr->hDrawable, INDEX_GET (FramePtr->TypeIndexAndFlags)
|
||||
);
|
||||
Drawable = BUILD_DRAWABLE (DrawablePtr->hDrawable, FramePtr->Index);
|
||||
UnlockDrawable (Drawable);
|
||||
|
||||
return (Drawable);
|
||||
@@ -76,7 +74,7 @@ GetFrameCount (FRAMEPTR FramePtr)
|
||||
return (0);
|
||||
|
||||
DrawablePtr = GetFrameParentDrawable (FramePtr);
|
||||
return (INDEX_GET (DrawablePtr->FlagsAndIndex) + 1);
|
||||
return DrawablePtr->MaxIndex + 1;
|
||||
}
|
||||
|
||||
COUNT
|
||||
@@ -85,7 +83,7 @@ GetFrameIndex (FRAMEPTR FramePtr)
|
||||
if (FramePtr == 0)
|
||||
return (0);
|
||||
|
||||
return ((UWORD)INDEX_GET (FramePtr->TypeIndexAndFlags));
|
||||
return FramePtr->Index;
|
||||
}
|
||||
|
||||
FRAME
|
||||
@@ -97,8 +95,7 @@ SetAbsFrameIndex (FRAMEPTR FramePtr, COUNT FrameIndex)
|
||||
|
||||
DrawablePtr = GetFrameParentDrawable (FramePtr);
|
||||
|
||||
FrameIndex = FrameIndex
|
||||
% (INDEX_GET (DrawablePtr->FlagsAndIndex) + 1);
|
||||
FrameIndex = FrameIndex % (DrawablePtr->MaxIndex + 1);
|
||||
FramePtr = (FRAMEPTR)&DrawablePtr->Frame[FrameIndex];
|
||||
}
|
||||
|
||||
@@ -114,14 +111,14 @@ SetRelFrameIndex (FRAMEPTR FramePtr, SIZE FrameOffs)
|
||||
DRAWABLEPTR DrawablePtr;
|
||||
|
||||
DrawablePtr = GetFrameParentDrawable (FramePtr);
|
||||
num_frames = INDEX_GET (DrawablePtr->FlagsAndIndex) + 1;
|
||||
num_frames = DrawablePtr->MaxIndex + 1;
|
||||
if (FrameOffs < 0)
|
||||
{
|
||||
while ((FrameOffs += num_frames) < 0)
|
||||
;
|
||||
}
|
||||
|
||||
FrameOffs = ((SWORD)INDEX_GET (FramePtr->TypeIndexAndFlags) + FrameOffs) % num_frames;
|
||||
FrameOffs = ((SWORD)FramePtr->Index + FrameOffs) % num_frames;
|
||||
FramePtr = (FRAMEPTR)&DrawablePtr->Frame[FrameOffs];
|
||||
}
|
||||
|
||||
@@ -150,7 +147,7 @@ IncFrameIndex (FRAMEPTR FramePtr)
|
||||
return (0);
|
||||
|
||||
DrawablePtr = GetFrameParentDrawable (FramePtr);
|
||||
if (INDEX_GET (FramePtr->TypeIndexAndFlags) < (DWORD)INDEX_GET (DrawablePtr->FlagsAndIndex))
|
||||
if (FramePtr->Index < DrawablePtr->MaxIndex)
|
||||
return ((FRAME)++FramePtr);
|
||||
else
|
||||
return ((FRAME)DrawablePtr->Frame);
|
||||
@@ -162,13 +159,13 @@ DecFrameIndex (FRAMEPTR FramePtr)
|
||||
if (FramePtr == 0)
|
||||
return (0);
|
||||
|
||||
if (INDEX_GET (FramePtr->TypeIndexAndFlags))
|
||||
if (FramePtr->Index > 0)
|
||||
return ((FRAME)--FramePtr);
|
||||
else
|
||||
{
|
||||
DRAWABLEPTR DrawablePtr;
|
||||
|
||||
DrawablePtr = GetFrameParentDrawable (FramePtr);
|
||||
return ((FRAME)&DrawablePtr->Frame[INDEX_GET (DrawablePtr->FlagsAndIndex)]);
|
||||
return ((FRAME)&DrawablePtr->Frame[DrawablePtr->MaxIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,10 @@ GetGraphicScale ()
|
||||
static void
|
||||
read_screen (PRECT lpRect, FRAMEPTR DstFramePtr)
|
||||
{
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) != SCREEN_DRAWABLE
|
||||
|| TYPE_GET (DstFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE
|
||||
|| !(TYPE_GET (GetFrameParentDrawable (DstFramePtr)
|
||||
->FlagsAndIndex)
|
||||
& ((DWORD) MAPPED_TO_DISPLAY << FTYPE_SHIFT)))
|
||||
if (_CurFramePtr->Type != SCREEN_DRAWABLE
|
||||
|| DstFramePtr->Type == SCREEN_DRAWABLE
|
||||
|| !(GetFrameParentDrawable (DstFramePtr)->Flags
|
||||
& MAPPED_TO_DISPLAY))
|
||||
{
|
||||
log_add (log_Warning, "Unimplemented function activated: read_screen()");
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ process_image (FRAMEPTR FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct)
|
||||
TFB_Image *tfbimg;
|
||||
int hx, hy;
|
||||
|
||||
TYPE_SET (FramePtr->TypeIndexAndFlags, ROM_DRAWABLE);
|
||||
INDEX_SET (FramePtr->TypeIndexAndFlags, cel_ct);
|
||||
FramePtr->Type = ROM_DRAWABLE;
|
||||
FramePtr->Index = cel_ct;
|
||||
|
||||
// handle transparency cases
|
||||
if (img[cel_ct]->format->palette)
|
||||
@@ -193,8 +193,7 @@ FRAMEPTR stretch_frame (FRAMEPTR FramePtr, int neww, int newh, int destroy)
|
||||
TFB_Canvas src, dst;
|
||||
EXTENT ext;
|
||||
|
||||
flags = TYPE_GET (GetFrameParentDrawable (FramePtr)
|
||||
->FlagsAndIndex) >> FTYPE_SHIFT;
|
||||
flags = GetFrameParentDrawable (FramePtr)->Flags;
|
||||
NewFrame = CaptureDrawable (
|
||||
CreateDrawable (flags, (SIZE)neww, (SIZE)newh, 1));
|
||||
tfbImg = FramePtr->image;
|
||||
@@ -454,9 +453,8 @@ _GetCelData (uio_Stream *fp, DWORD length)
|
||||
FRAMEPTR FramePtr;
|
||||
|
||||
DrawablePtr->hDrawable = GetDrawableHandle (Drawable);
|
||||
TYPE_SET (DrawablePtr->FlagsAndIndex,
|
||||
(DRAWABLE_TYPE)WANT_PIXMAP << FTYPE_SHIFT);
|
||||
INDEX_SET (DrawablePtr->FlagsAndIndex, cel_ct - 1);
|
||||
DrawablePtr->Flags = WANT_PIXMAP;
|
||||
DrawablePtr->MaxIndex = cel_ct - 1;
|
||||
|
||||
FramePtr = &DrawablePtr->Frame[cel_ct];
|
||||
while (--FramePtr, cel_ct--)
|
||||
@@ -482,12 +480,12 @@ _ReleaseCelData (MEM_HANDLE handle)
|
||||
if ((DrawablePtr = LockDrawable (handle)) == 0)
|
||||
return (FALSE);
|
||||
|
||||
cel_ct = INDEX_GET (DrawablePtr->FlagsAndIndex)+1;
|
||||
cel_ct = DrawablePtr->MaxIndex + 1;
|
||||
|
||||
if (DrawablePtr->Frame)
|
||||
{
|
||||
FramePtr = DrawablePtr->Frame;
|
||||
if (TYPE_GET (FramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (FramePtr->Type == SCREEN_DRAWABLE)
|
||||
{
|
||||
FramePtr = NULL;
|
||||
}
|
||||
@@ -753,8 +751,8 @@ _request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType,
|
||||
FRAMEPTR FramePtr;
|
||||
|
||||
DrawablePtr->hDrawable = GetDrawableHandle (Drawable);
|
||||
TYPE_SET (DrawablePtr->FlagsAndIndex, flags << FTYPE_SHIFT);
|
||||
INDEX_SET (DrawablePtr->FlagsAndIndex, NumFrames - 1);
|
||||
DrawablePtr->Flags = flags;
|
||||
DrawablePtr->MaxIndex = NumFrames - 1;
|
||||
|
||||
imgw = width;
|
||||
imgh = height;
|
||||
@@ -771,8 +769,8 @@ _request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType,
|
||||
FramePtr->image = Image;
|
||||
}
|
||||
|
||||
TYPE_SET (FramePtr->TypeIndexAndFlags, DrawableType);
|
||||
INDEX_SET (FramePtr->TypeIndexAndFlags, NumFrames);
|
||||
FramePtr->Type = DrawableType;
|
||||
FramePtr->Index = NumFrames;
|
||||
SetFrameBounds (FramePtr, width, height);
|
||||
--FramePtr;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand)
|
||||
}
|
||||
|
||||
if (DrawCommand->Type <= TFB_DRAWCOMMANDTYPE_COPYTOIMAGE
|
||||
&& TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
&& _CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
{
|
||||
static RECT scissor_rect;
|
||||
|
||||
|
||||
@@ -534,16 +534,15 @@ void random16xZoomSurfaceRGBA (SDL_Surface *src, SDL_Surface *dst)
|
||||
FRAMEPTR scale16xRandomizeFrame (FRAMEPTR NewFrame, FRAMEPTR FramePtr)
|
||||
{
|
||||
TFB_Image *origImg, *newImg;
|
||||
UBYTE type;
|
||||
CREATE_FLAGS flags;
|
||||
|
||||
if (NewFrame == NULL)
|
||||
{
|
||||
type = (UBYTE)TYPE_GET (GetFrameParentDrawable (FramePtr)
|
||||
->FlagsAndIndex) >> FTYPE_SHIFT;
|
||||
flags = GetFrameParentDrawable (FramePtr)->Flags;
|
||||
NewFrame = CaptureDrawable (
|
||||
CreateDrawable (type,
|
||||
(SIZE)((GetFrameWidth (FramePtr)) << 2),
|
||||
(SIZE)((GetFrameHeight (FramePtr)) << 2), 1));
|
||||
CreateDrawable (flags,
|
||||
GetFrameWidth (FramePtr) << 2,
|
||||
GetFrameHeight (FramePtr) << 2, 1));
|
||||
}
|
||||
|
||||
newImg = NewFrame->image;
|
||||
|
||||
@@ -37,7 +37,7 @@ TFB_Prim_Point (PPOINT p, TFB_Palette *color)
|
||||
r.corner.y = p->y - _CurFramePtr->HotSpot.y;
|
||||
r.extent.width = r.extent.height = 1;
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
TFB_DrawScreen_Rect (&r, color->r, color->g, color->b, TFB_SCREEN_MAIN);
|
||||
else
|
||||
TFB_DrawImage_Rect (&r, color->r, color->g, color->b, _CurFramePtr->image);
|
||||
@@ -92,7 +92,7 @@ TFB_Prim_FillRect (PRECT r, TFB_Palette *color)
|
||||
rect.extent.height) >> 1;
|
||||
}
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
TFB_DrawScreen_Rect (&rect, color->r, color->g, color->b, TFB_SCREEN_MAIN);
|
||||
else
|
||||
TFB_DrawImage_Rect (&rect, color->r, color->g, color->b, _CurFramePtr->image);
|
||||
@@ -108,7 +108,7 @@ TFB_Prim_Line (PLINE line, TFB_Palette *color)
|
||||
x2=line->second.x - _CurFramePtr->HotSpot.x;
|
||||
y2=line->second.y - _CurFramePtr->HotSpot.y;
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
TFB_DrawScreen_Line (x1, y1, x2, y2, color->r, color->g, color->b, TFB_SCREEN_MAIN);
|
||||
else
|
||||
TFB_DrawImage_Line (x1, y1, x2, y2, color->r, color->g, color->b, _CurFramePtr->image);
|
||||
@@ -153,7 +153,7 @@ TFB_Prim_Stamp (PSTAMP stmp)
|
||||
|
||||
UnlockMutex (img->mutex);
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
{
|
||||
TFB_DrawScreen_Image (img, x, y, gscale, cmap, TFB_SCREEN_MAIN);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
|
||||
|
||||
UnlockMutex (img->mutex);
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
{
|
||||
TFB_DrawScreen_FilledImage (img, x, y, gscale, r, g, b,
|
||||
TFB_SCREEN_MAIN);
|
||||
@@ -220,7 +220,7 @@ TFB_Prim_FontChar (PPOINT origin, TFB_Char *fontChar, TFB_Image *backing)
|
||||
x = origin->x - _CurFramePtr->HotSpot.x;
|
||||
y = origin->y - _CurFramePtr->HotSpot.y;
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
{
|
||||
TFB_DrawScreen_FontChar (fontChar, backing, x, y,
|
||||
TFB_SCREEN_MAIN);
|
||||
|
||||
Reference in New Issue
Block a user