Streamlined the 'legacy' graphics code implementation.

The vtable-style code that was implementing the drawing of primitives
turned out to be entirely unnecessary; every virtual call was inside a
switch or if on the type of the primitive.  Code has been restructured to
be more consistent and simpler.  Never-used primitives (composites and
polygons) have been removed entirely.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@838 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2003-03-01 07:14:15 +00:00
parent 0f487716ad
commit 954a333685
45 changed files with 552 additions and 1938 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.3: Changes towards version 0.3:
- Removed aspects of the legacy graphics code that are never used or that
are redundant. More 'C-like' use of the PRIMITIVE datatype.
- Fix various graphics glitches during dialog. Especially Spathi Eye,and ZFP - Fix various graphics glitches during dialog. Especially Spathi Eye,and ZFP
Closes #23, #156 - PhracturedBlue Closes #23, #156 - PhracturedBlue
- Fix Syreen, KohrAh and Slylandro ship effects to not be screen - Fix Syreen, KohrAh and Slylandro ship effects to not be screen
-3
View File
@@ -24,11 +24,9 @@ InitSISContexts (void)
RECT r; RECT r;
SetContext (StatusContext); SetContext (StatusContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextFGFrame (Screen); SetContextFGFrame (Screen);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
r.corner.x = SIS_ORG_X; r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y; r.corner.y = SIS_ORG_Y;
@@ -44,7 +42,6 @@ DrawSISFrame (void)
SetSemaphore (GraphicsSem); SetSemaphore (GraphicsSem);
SetContext (ScreenContext); SetContext (ScreenContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
BatchGraphics (); BatchGraphics ();
{ {
-1
View File
@@ -1683,7 +1683,6 @@ HailAlien (void)
ES.phrase_buf[0] = '\0'; ES.phrase_buf[0] = '\0';
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
OldFont = SetContextFont (PlayerFont); OldFont = SetContextFont (PlayerFont);
{ {
-3
View File
@@ -45,10 +45,8 @@ ConfirmExit (void)
STAMP s; STAMP s;
FRAME F; FRAME F;
CONTEXT oldContext; CONTEXT oldContext;
DRAW_STATE oldDrawState;
oldContext = SetContext (ScreenContext); oldContext = SetContext (ScreenContext);
oldDrawState = SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
s.frame = SetAbsFrameIndex (ActivityFrame, 1); s.frame = SetAbsFrameIndex (ActivityFrame, 1);
GetFrameRect (s.frame, &r); GetFrameRect (s.frame, &r);
@@ -97,7 +95,6 @@ ConfirmExit (void)
FlushInput (); FlushInput ();
} }
SetContextDrawState (oldDrawState);
SetContext (oldContext); SetContext (oldContext);
} }
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
-1
View File
@@ -176,7 +176,6 @@ MUSIC_REF MR;
hOldIndex = SetResourceIndex (hResIndex); hOldIndex = SetResourceIndex (hResIndex);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContextFont (TinyFont); SetContextFont (TinyFont);
MR = LoadMusicInstance (REDALERT_MUSIC); MR = LoadMusicInstance (REDALERT_MUSIC);
-6
View File
@@ -1103,8 +1103,6 @@ PickGame (PMENU_STATE
{ {
BOOLEAN retval; BOOLEAN retval;
CONTEXT OldContext; CONTEXT OldContext;
FRAME OldFrame;
DRAW_STATE OldDrawState;
SUMMARY_DESC desc_array[MAX_SAVED_GAMES]; SUMMARY_DESC desc_array[MAX_SAVED_GAMES];
RECT DlgRect; RECT DlgRect;
STAMP DlgStamp; STAMP DlgStamp;
@@ -1118,8 +1116,6 @@ PickGame (PMENU_STATE
SetSemaphore (GraphicsSem); SetSemaphore (GraphicsSem);
OldContext = SetContext (SpaceContext); OldContext = SetContext (SpaceContext);
OldFrame = SetContextBGFrame (NULL_PTR);
OldDrawState = SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
DlgStamp.origin.x = 0; DlgStamp.origin.x = 0;
DlgStamp.origin.y = 0; DlgStamp.origin.y = 0;
@@ -1188,8 +1184,6 @@ PickGame (PMENU_STATE
DestroyDrawable (ReleaseDrawable (DlgStamp.frame)); DestroyDrawable (ReleaseDrawable (DlgStamp.frame));
SetContextDrawState (OldDrawState);
SetContextBGFrame (OldFrame);
SetContext (OldContext); SetContext (OldContext);
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
-5
View File
@@ -350,7 +350,6 @@ LoadHyperspace (void)
SET_GAME_STATE (USED_BROADCASTER, 0); SET_GAME_STATE (USED_BROADCASTER, 0);
SET_GAME_STATE (BROADCASTER_RESPONSE, 0); SET_GAME_STATE (BROADCASTER_RESPONSE, 0);
} }
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
// ClearDrawable (); // ClearDrawable ();
ClearSISRect (CLEAR_SIS_RADAR); ClearSISRect (CLEAR_SIS_RADAR);
@@ -1542,13 +1541,11 @@ DoMenuOptions (void)
{ {
COLOR OldColor; COLOR OldColor;
CONTEXT OldContext; CONTEXT OldContext;
DRAW_STATE OldDrawState;
MENU_STATE MenuState; MENU_STATE MenuState;
UnbatchGraphics (); UnbatchGraphics ();
OldContext = SetContext (SpaceContext); OldContext = SetContext (SpaceContext);
OldDrawState = SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
OldColor = SetContextBackGroundColor (BLACK_COLOR); OldColor = SetContextBackGroundColor (BLACK_COLOR);
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
@@ -1570,7 +1567,6 @@ UnbatchGraphics ();
SetFlashRect (NULL_PTR, (FRAME)0); SetFlashRect (NULL_PTR, (FRAME)0);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextBGFrame (0);
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))) if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{ {
@@ -1582,7 +1578,6 @@ UnbatchGraphics ();
} }
SetContextBackGroundColor (OldColor); SetContextBackGroundColor (OldColor);
SetContextDrawState (OldDrawState);
SetContext (OldContext); SetContext (OldContext);
if (!(GLOBAL (CurrentActivity) & IN_BATTLE)) if (!(GLOBAL (CurrentActivity) & IN_BATTLE))
cleanup_hyperspace (); cleanup_hyperspace ();
-2
View File
@@ -121,7 +121,6 @@ InitShips (void)
InitSpace (); InitSpace ();
SetContext (StatusContext); SetContext (StatusContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContext (SpaceContext); SetContext (SpaceContext);
InitDisplayList (); InitDisplayList ();
@@ -157,7 +156,6 @@ InitShips (void)
OldContext = SetContext (ScreenContext); OldContext = SetContext (ScreenContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContextBackGroundColor (BLACK_COLOR); SetContextBackGroundColor (BLACK_COLOR);
ClearDrawable (); ClearDrawable ();
+1 -94
View File
@@ -24,7 +24,6 @@
#define CONTEXT PVOID #define CONTEXT PVOID
#define FRAME PVOID #define FRAME PVOID
#define FONT PVOID #define FONT PVOID
#define CYCLE_REF DWORD
typedef CONTEXT *PCONTEXT; typedef CONTEXT *PCONTEXT;
typedef FRAME *PFRAME; typedef FRAME *PFRAME;
@@ -54,28 +53,6 @@ typedef BYTE CREATE_FLAGS;
#define WANT_PIXMAP (CREATE_FLAGS)(1 << 1) #define WANT_PIXMAP (CREATE_FLAGS)(1 << 1)
#define MAPPED_TO_DISPLAY (CREATE_FLAGS)(1 << 2) #define MAPPED_TO_DISPLAY (CREATE_FLAGS)(1 << 2)
typedef enum
{
MAP_ISOTROPIC, /* == X/Y scale is the same */
MAP_ANISOTROPIC, /* == X/Y scale different (e.g. aspect ratio) */
MAP_NOXFORM /* == X/Y scale is ignored */
} MAP_TYPE;
typedef enum
{
DEST_MASK = MAKE_WORD (0, 0),
DEST_PIXMAP = MAKE_WORD (0, 1)
} DRAW_DESTINATION;
typedef enum
{
DRAW_SUBTRACTIVE = 0, /* implied only to active page */
DRAW_ADDITIVE, /* implied only to active page */
DRAW_REPLACE
} DRAW_MODE;
typedef UWORD DRAW_STATE;
typedef struct extent typedef struct extent
{ {
COORD width, height; COORD width, height;
@@ -132,33 +109,12 @@ typedef struct text
} TEXT; } TEXT;
typedef TEXT *PTEXT; typedef TEXT *PTEXT;
typedef MEM_HANDLE POLYREF;
typedef PVOID POLYGON;
typedef POLYGON *PPOLYGON;
#include "strlib.h" #include "strlib.h"
typedef STRING_TABLE COLORMAP_REF; typedef STRING_TABLE COLORMAP_REF;
typedef STRING COLORMAP; typedef STRING COLORMAP;
typedef STRINGPTR COLORMAPPTR; typedef STRINGPTR COLORMAPPTR;
typedef struct stamp_cmap
{
POINT origin;
FRAME frame;
COLORMAPPTR CMap;
} STAMP_CMAP;
typedef STAMP_CMAP *PSTAMP_CMAP;
typedef struct composite
{
POINT origin;
PFRAME FrameList;
COUNT NumFrames;
} COMPOSITE;
typedef COMPOSITE *PCOMPOSITE;
enum gfx_object enum gfx_object
{ {
POINT_PRIM = 0, POINT_PRIM = 0,
@@ -166,13 +122,8 @@ enum gfx_object
STAMPFILL_PRIM, STAMPFILL_PRIM,
LINE_PRIM, LINE_PRIM,
TEXT_PRIM, TEXT_PRIM,
STAMPCMAP_PRIM,
RECT_PRIM, RECT_PRIM,
RECTFILL_PRIM, RECTFILL_PRIM,
POLY_PRIM,
POLYFILL_PRIM,
COMPOSITE_PRIM,
COMPOSITEFILL_PRIM,
NUM_PRIMS NUM_PRIMS
}; };
@@ -184,10 +135,7 @@ typedef union
STAMP Stamp; STAMP Stamp;
LINE Line; LINE Line;
TEXT Text; TEXT Text;
STAMP_CMAP StampCMap;
RECT Rect; RECT Rect;
POLYGON Polygon;
COMPOSITE Composite;
} PRIM_DESC; } PRIM_DESC;
typedef PRIM_DESC *PPRIM_DESC; typedef PRIM_DESC *PPRIM_DESC;
@@ -268,8 +216,6 @@ extern INTERSECT_CODE BoxIntersect (PRECT pr1, PRECT pr2, PRECT
printer); printer);
extern void BoxUnion (PRECT pr1, PRECT pr2, PRECT punion); extern void BoxUnion (PRECT pr1, PRECT pr2, PRECT punion);
typedef void (*BG_FUNC) (PRECT pClipRect);
#endif /* _GFXLIB_H */ #endif /* _GFXLIB_H */
@@ -283,22 +229,9 @@ extern void UninitGraphics (void);
extern CONTEXT SetContext (CONTEXT Context); extern CONTEXT SetContext (CONTEXT Context);
extern CONTEXT CaptureContext (CONTEXT_REF ContextRef); extern CONTEXT CaptureContext (CONTEXT_REF ContextRef);
extern CONTEXT_REF ReleaseContext (CONTEXT Context); extern CONTEXT_REF ReleaseContext (CONTEXT Context);
extern MAP_TYPE SetContextMapType (MAP_TYPE MapType);
extern BOOLEAN SetContextWinOrigin (PPOINT pOrg);
extern BOOLEAN SetContextViewExtents (PEXTENT pExtent);
extern BOOLEAN SetContextWinExtents (PEXTENT pExtent);
extern BOOLEAN GetContextWinOrigin (PPOINT pOrg);
extern BOOLEAN GetContextViewExtents (PEXTENT pExtent);
extern BOOLEAN GetContextWinExtents (PEXTENT pExtent);
extern BOOLEAN LOGtoDEV (PPOINT pSrcPt, PPOINT pDstPt, COUNT NumPoints);
extern BOOLEAN DEVtoLOG (PPOINT pSrcPt, PPOINT pDstPt, COUNT NumPoints);
extern DRAW_STATE GetContextDrawState (void);
extern DRAW_STATE SetContextDrawState (DRAW_STATE DrawState);
extern COLOR SetContextForeGroundColor (COLOR Color); extern COLOR SetContextForeGroundColor (COLOR Color);
extern COLOR SetContextBackGroundColor (COLOR Color); extern COLOR SetContextBackGroundColor (COLOR Color);
extern FRAME SetContextFGFrame (FRAME Frame); extern FRAME SetContextFGFrame (FRAME Frame);
extern FRAME SetContextBGFrame (FRAME Frame);
extern BG_FUNC SetContextBGFunc (BG_FUNC BGFunc);
extern BOOLEAN SetContextClipping (BOOLEAN ClipStatus); extern BOOLEAN SetContextClipping (BOOLEAN ClipStatus);
extern BOOLEAN SetContextClipRect (PRECT pRect); extern BOOLEAN SetContextClipRect (PRECT pRect);
extern BOOLEAN GetContextClipRect (PRECT pRect); extern BOOLEAN GetContextClipRect (PRECT pRect);
@@ -306,14 +239,11 @@ extern TIME_VALUE DrawablesIntersect (PINTERSECT_CONTROL pControl0,
PINTERSECT_CONTROL pControl1, TIME_VALUE max_time_val); PINTERSECT_CONTROL pControl1, TIME_VALUE max_time_val);
extern void DrawStamp (PSTAMP pStamp); extern void DrawStamp (PSTAMP pStamp);
extern void DrawFilledStamp (PSTAMP pStamp); extern void DrawFilledStamp (PSTAMP pStamp);
extern void DrawStampCMap (PSTAMP_CMAP pStampCmap);
extern void DrawPoint (PPOINT pPoint); extern void DrawPoint (PPOINT pPoint);
extern void DrawRectangle (PRECT pRect); extern void DrawRectangle (PRECT pRect);
extern void DrawFilledRectangle (PRECT pRect); extern void DrawFilledRectangle (PRECT pRect);
extern void DrawLine (PLINE pLine); extern void DrawLine (PLINE pLine);
extern void font_DrawText (PTEXT pText); extern void font_DrawText (PTEXT pText);
extern void DrawPolygon (POLYGON Polygon);
extern void DrawFilledPolygon (POLYGON Polygon);
extern void DrawBatch (PPRIMITIVE pBasePrim, PRIM_LINKS PrimLinks, extern void DrawBatch (PPRIMITIVE pBasePrim, PRIM_LINKS PrimLinks,
BATCH_FLAGS BatchFlags); BATCH_FLAGS BatchFlags);
extern void BatchGraphics (void); extern void BatchGraphics (void);
@@ -335,7 +265,6 @@ extern HOT_SPOT SetFrameHot (FRAME Frame, HOT_SPOT HotSpot);
extern HOT_SPOT GetFrameHot (FRAME Frame); extern HOT_SPOT GetFrameHot (FRAME Frame);
extern BOOLEAN InstallGraphicResTypes (COUNT cel_type, COUNT font_type); extern BOOLEAN InstallGraphicResTypes (COUNT cel_type, COUNT font_type);
extern DWORD LoadCelFile (PVOID pStr); extern DWORD LoadCelFile (PVOID pStr);
extern DWORD LoadFontFile (PVOID pStr);
extern DWORD LoadGraphicInstance (DWORD res); extern DWORD LoadGraphicInstance (DWORD res);
extern DWORD LoadGraphic (DWORD res); extern DWORD LoadGraphic (DWORD res);
extern DRAWABLE LoadDisplayPixmap (PRECT area, FRAME frame); extern DRAWABLE LoadDisplayPixmap (PRECT area, FRAME frame);
@@ -354,34 +283,12 @@ extern FRAME SetEquFrameIndex (FRAME DstFrame, FRAME SrcFrame);
extern FRAME IncFrameIndex (FRAME Frame); extern FRAME IncFrameIndex (FRAME Frame);
extern FRAME DecFrameIndex (FRAME Frame); extern FRAME DecFrameIndex (FRAME Frame);
extern void XFlipFrame (FRAME Frame);
extern FRAME CaptureDrawable (DRAWABLE Drawable); extern FRAME CaptureDrawable (DRAWABLE Drawable);
extern DRAWABLE ReleaseDrawable (FRAME Frame); extern DRAWABLE ReleaseDrawable (FRAME Frame);
extern MEM_HANDLE GetFrameHandle (FRAME Frame); extern MEM_HANDLE GetFrameHandle (FRAME Frame);
extern POLYREF CreatePolygon (COUNT PtCount);
extern POLYGON CapturePolygon (POLYREF PolyRef);
extern BOOLEAN SetPolygonPoint (POLYGON Polygon, COUNT PtIndex, COORD x,
COORD y);
extern BOOLEAN GetPolygonPoint (POLYGON Polygon, COUNT PtIndex, PCOORD
px, PCOORD py);
extern POLYREF ReleasePolygon (POLYGON Polygon);
extern BOOLEAN DestroyPolygon (POLYREF PolyRef);
extern DRAWABLE CreateOverlayWindow (CREATE_FLAGS CreateFlags, FRAME
Display, SIZE height);
extern void ShowOverlayWin (FRAME WinFrame, COUNT TimeInterval);
extern void HideOverlayWin (FRAME WinFrame, COUNT TimeInterval);
extern BOOLEAN DestroyOverlayWindow (FRAME Display, DRAWABLE Drawable);
extern void ScrollDisplay (FRAME Display, COORD x, COORD y);
extern BOOLEAN ReadColorMap (COLORMAPPTR ColorMapPtr);
extern BOOLEAN SetColorMap (COLORMAPPTR ColorMapPtr); extern BOOLEAN SetColorMap (COLORMAPPTR ColorMapPtr);
extern BOOLEAN BatchColorMap (COLORMAPPTR ColorMapPtr);
extern CYCLE_REF CycleColorMap (COLORMAPPTR ColorMapPtr, COUNT Cycles,
SIZE TimeInterval);
extern void StopCycleColorMap (CYCLE_REF CycleRef);
extern DWORD XFormColorMap (COLORMAPPTR ColorMapPtr, SIZE TimeInterval); extern DWORD XFormColorMap (COLORMAPPTR ColorMapPtr, SIZE TimeInterval);
extern void FlushColorXForms (void); extern void FlushColorXForms (void);
#define InitColorMapResources InitStringTableResources #define InitColorMapResources InitStringTableResources
+2 -2
View File
@@ -1,4 +1,4 @@
uqm_SUBDIRS="sdl" uqm_SUBDIRS="sdl"
uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c uqm_CFILES="boxint.c clipline.c cmap.c context.c drawable.c filegfx.c
font.c frame.c gfx_common.c intersec.c line.c loaddisp.c makepoly.c font.c frame.c gfx_common.c intersec.c loaddisp.c
map.c pixmap.c poly.c rect.c resgfx.c stamp.c tfb_draw.c" pixmap.c resgfx.c tfb_draw.c tfb_prim.c"
-6
View File
@@ -68,12 +68,6 @@ void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index)
} }
} }
BOOLEAN
BatchColorMap (COLORMAPPTR ColorMapPtr)
{
return (SetColorMap (ColorMapPtr));
}
BOOLEAN BOOLEAN
SetColorMap (COLORMAPPTR map) SetColorMap (COLORMAPPTR map)
{ {
-45
View File
@@ -56,7 +56,6 @@ SetContext (CONTEXT Context)
SetPrimColor (&_locPrim, _get_context_fg_color ()); SetPrimColor (&_locPrim, _get_context_fg_color ());
_CurFramePtr = (FRAMEPTR)_get_context_fg_frame (); _CurFramePtr = (FRAMEPTR)_get_context_fg_frame ();
BGFrame = _get_context_bg_frame ();
_CurFontPtr = (FONTPTR)_get_context_font (); _CurFontPtr = (FONTPTR)_get_context_font ();
} }
} }
@@ -76,8 +75,6 @@ CreateContext (void)
/* initialize context */ /* initialize context */
OldContext = SetContext (CaptureContext (ContextRef)); OldContext = SetContext (CaptureContext (ContextRef));
SetContextMapType (MAP_NOXFORM);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContextForeGroundColor ( SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F) BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)
); );
@@ -134,32 +131,6 @@ ReleaseContext (CONTEXT Context)
return (0); return (0);
} }
DRAW_STATE
GetContextDrawState (void)
{
if (!ContextActive ())
return (DEST_PIXMAP | DRAW_REPLACE);
return (_get_context_draw_state ());
}
DRAW_STATE
SetContextDrawState (DRAW_STATE DrawState)
{
DRAW_STATE oldState;
if (!ContextActive ())
return (DEST_PIXMAP | DRAW_REPLACE);
if ((oldState = _get_context_draw_state ()) != DrawState)
{
SwitchContextDrawState (DrawState);
SetContextGraphicsFunctions ();
}
return (oldState);
}
COLOR COLOR
SetContextForeGroundColor (COLOR Color) SetContextForeGroundColor (COLOR Color)
{ {
@@ -193,22 +164,6 @@ SetContextBackGroundColor (COLOR Color)
return (oldColor); return (oldColor);
} }
BG_FUNC
SetContextBGFunc (BG_FUNC BGFunc)
{
BG_FUNC oldBGFunc;
if (!ContextActive ())
return (0);
if ((oldBGFunc = _get_context_bg_func ()) != BGFunc)
{
SwitchContextBGFunc (BGFunc);
}
return (oldBGFunc);
}
BOOLEAN BOOLEAN
SetContextClipping (BOOLEAN ClipStatus) SetContextClipping (BOOLEAN ClipStatus)
{ {
+8 -64
View File
@@ -19,38 +19,16 @@
#ifndef _CONTEXT_H #ifndef _CONTEXT_H
#define _CONTEXT_H #define _CONTEXT_H
#ifdef MAPPING
typedef struct
{
MAP_TYPE MapType;
EXTENT ViewExt; /* Device units per inch */
EXTENT WinExt; /* Logical units per inch */
POINT WinOrg;
/* Translation to device units relative to
* (0, 0) is as follows:
* x_du = (x_lu - WinOrg.x) * ViewExt.x / WinExt.x;
* y_du = (y_lu - WinOrg.y) * ViewExt.y / WinExt.y;
*/
} MAP_INFO;
typedef MAP_INFO *PMAP_INFO;
#endif /* MAPPING */
typedef struct typedef struct
{ {
CONTEXT_REF ContextRef; CONTEXT_REF ContextRef;
UWORD Flags; UWORD Flags;
DRAW_STATE DrawState;
COLOR ForeGroundColor, BackGroundColor; COLOR ForeGroundColor, BackGroundColor;
FRAME ForeGroundFrame, BackGroundFrame; FRAME ForeGroundFrame;
void (**func_array) (PRECT pClipRect, PPRIMITIVE PrimPtr);
FONT Font; FONT Font;
BG_FUNC BackGroundFunc;
RECT ClipRect; RECT ClipRect;
#ifdef MAPPING
MAP_INFO Map;
#endif /* MAPPING */
} CONTEXT_DESC; } CONTEXT_DESC;
typedef CONTEXT_DESC *PCONTEXT_DESC; typedef CONTEXT_DESC *PCONTEXT_DESC;
@@ -70,41 +48,9 @@ extern PRIMITIVE _locPrim;
#define _get_context_fg_color() (_pCurContext->ForeGroundColor) #define _get_context_fg_color() (_pCurContext->ForeGroundColor)
#define _get_context_bg_color() (_pCurContext->BackGroundColor) #define _get_context_bg_color() (_pCurContext->BackGroundColor)
#define _get_context_draw_state() (_pCurContext->DrawState)
#define _get_context_draw_dest() ((DRAW_DESTINATION)(_pCurContext->DrawState & 0xFF00))
#define _get_context_draw_mode() ((DRAW_MODE)LOBYTE (_pCurContext->DrawState))
#define _get_context_flags() (_pCurContext->Flags) #define _get_context_flags() (_pCurContext->Flags)
#define _get_context_fg_frame() (_pCurContext->ForeGroundFrame) #define _get_context_fg_frame() (_pCurContext->ForeGroundFrame)
#define _get_context_bg_frame() (_pCurContext->BackGroundFrame)
#define _get_context_font() (_pCurContext->Font) #define _get_context_font() (_pCurContext->Font)
#define _get_context_bg_func() (_pCurContext->BackGroundFunc)
#ifdef MAPPING
#define _get_context_map_type() (_pCurContext->Map.MapType)
#define _init_context_map(pmt) \
COORD worg_x, worg_y; \
SIZE vext_w, vext_h, wext_w, wext_h; \
\
if ((*(pmt) = _get_context_map_type ()) != MAP_NOXFORM) \
worg_x = _pCurContext->Map.WinOrg.x, \
worg_y = _pCurContext->Map.WinOrg.y, \
vext_w = _pCurContext->Map.ViewExt.width, \
vext_h = _pCurContext->Map.ViewExt.height, \
wext_w = _pCurContext->Map.WinExt.width, \
wext_h = _pCurContext->Map.WinExt.height
#define _uninit_context_map()
#define LXtoDX(x) ((((x) - worg_x) * vext_w) / wext_w)
#define LYtoDY(y) ((((y) - worg_y) * vext_h) / wext_h)
#define DXtoLX(x) ((((x) * wext_w) / vext_w) + worg_x)
#define DYtoLY(y) ((((y) * wext_h) / vext_h) + worg_y)
#define SwitchContextMapType(t) \
{ \
_pCurContext->Map.MapType = (t); \
}
#define SwitchContextWinOrigin(org) (_pCurContext->Map.WinOrg = *(org))
#define SwitchContextViewExtents(ext) (_pCurContext->Map.ViewExt = *(ext))
#define SwitchContextWinExtents(ext) (_pCurContext->Map.WinExt = *(ext))
#endif /* MAPPING */
#define SwitchContextDrawState(s) \ #define SwitchContextDrawState(s) \
{ \ { \
@@ -130,10 +76,6 @@ extern PRIMITIVE _locPrim;
{ \ { \
_pCurContext->ForeGroundFrame = (f); \ _pCurContext->ForeGroundFrame = (f); \
} }
#define SwitchContextBGFrame(f) \
{ \
_pCurContext->BackGroundFrame = (f); \
}
#define SwitchContextFont(f) \ #define SwitchContextFont(f) \
{ \ { \
_pCurContext->Font = (f); \ _pCurContext->Font = (f); \
@@ -144,13 +86,15 @@ extern PRIMITIVE _locPrim;
} }
/* /*
These seem to have been moved to gfxlib.h, but not in their
entirety. That's rather unpleasant. -- Michael
#define BATCH_BUILD_PAGE (BATCH_FLAGS)(1 << 0) #define BATCH_BUILD_PAGE (BATCH_FLAGS)(1 << 0)
#define BATCH_SINGLE (BATCH_FLAGS)(1 << 1) #define BATCH_SINGLE (BATCH_FLAGS)(1 << 1)
#define BATCH_UPDATE_DRAWABLE (BATCH_FLAGS)(1 << 2) #define BATCH_UPDATE_DRAWABLE (BATCH_FLAGS)(1 << 2)
*/ */
#define BATCH_CLIP_GRAPHICS (BATCH_FLAGS)(1 << 3) #define BATCH_CLIP_GRAPHICS (BATCH_FLAGS)(1 << 3)
#define BATCH_XFORM (BATCH_FLAGS)(1 << 4) #define BATCH_XFORM (BATCH_FLAGS)(1 << 4)
#define BATCH_DIRTY_TILES (BATCH_FLAGS)(1 << 7)
typedef BYTE GRAPHICS_STATUS; typedef BYTE GRAPHICS_STATUS;
@@ -176,14 +120,14 @@ extern GRAPHICS_STATUS _GraphicsStatusFlags;
#define DrawableActive() (_GraphicsStatusFlags & DRAWABLE_ACTIVE) #define DrawableActive() (_GraphicsStatusFlags & DRAWABLE_ACTIVE)
#define SYSTEM_ACTIVE (GRAPHICS_STATUS)( \ #define SYSTEM_ACTIVE (GRAPHICS_STATUS)( \
DISPLAY_ACTIVE | CONTEXT_ACTIVE | \ DISPLAY_ACTIVE | CONTEXT_ACTIVE | \
DRAWABLE_ACTIVE \ DRAWABLE_ACTIVE \
) )
#define GraphicsSystemActive() \ #define GraphicsSystemActive() \
((_GraphicsStatusFlags & SYSTEM_ACTIVE) == SYSTEM_ACTIVE) ((_GraphicsStatusFlags & SYSTEM_ACTIVE) == SYSTEM_ACTIVE)
#define GraphicsStatus() \ #define GraphicsStatus() \
(_GraphicsStatusFlags & (GRAPHICS_STATUS)(GRAPHICS_ACTIVE \ (_GraphicsStatusFlags & (GRAPHICS_STATUS)(GRAPHICS_ACTIVE \
| GRAPHICS_VISIBLE)) | GRAPHICS_VISIBLE))
#endif /* _CONTEXT_H */ #endif /* _CONTEXT_H */
-16
View File
@@ -38,8 +38,6 @@ typedef struct
void (*read_display) (PRECT pRect, FRAMEPTR DstFramePtr); void (*read_display) (PRECT pRect, FRAMEPTR DstFramePtr);
void (**graphics_func_array) (PRECT pClipRect, PRIMITIVEPTR
PrimPtr);
} DISPLAY_INTERFACE; } DISPLAY_INTERFACE;
typedef DISPLAY_INTERFACE *PDISPLAY_INTERFACE; typedef DISPLAY_INTERFACE *PDISPLAY_INTERFACE;
@@ -49,26 +47,12 @@ extern void (* mask_func_array[]) (PRECT pClipRect,
PRIMITIVEPTR PrimPtr); PRIMITIVEPTR PrimPtr);
#define AllocDrawableImage (*_pCurDisplay->alloc_image) #define AllocDrawableImage (*_pCurDisplay->alloc_image)
#define DrawGraphicsFunc(pRect,pPtr) \
(*_pCurContext->func_array[GetPrimType(pPtr)]) (pRect, (PRIMITIVEPTR)(pPtr))
#define ReadDisplay (*_pCurDisplay->read_display) #define ReadDisplay (*_pCurDisplay->read_display)
extern void _bitplane_blt (PRECT pClipRect, FRAMEPTR
DstFramePtr, COORD src_x, COORD src_y, FRAMEPTR
SrcFramePtr, DRAW_MODE DrawMode);
#define GetDisplayFlags() (_pCurDisplay->DisplayFlags) #define GetDisplayFlags() (_pCurDisplay->DisplayFlags)
#define GetDisplayDepth() (_pCurDisplay->DisplayDepth) #define GetDisplayDepth() (_pCurDisplay->DisplayDepth)
#define GetDisplayWidth() (_pCurDisplay->DisplayWidth) #define GetDisplayWidth() (_pCurDisplay->DisplayWidth)
#define GetDisplayHeight() (_pCurDisplay->DisplayHeight) #define GetDisplayHeight() (_pCurDisplay->DisplayHeight)
#define SetContextGraphicsFunctions() \
do \
{ \
if (_get_context_draw_dest () == DEST_MASK) \
_pCurContext->func_array = mask_func_array; \
else \
_pCurContext->func_array = _pCurDisplay->graphics_func_array; \
} while (0)
#endif /* _DISPLAY_H */ #endif /* _DISPLAY_H */
-16
View File
@@ -37,26 +37,12 @@ SetContextFGFrame (FRAME Frame)
if (ContextActive ()) if (ContextActive ())
{ {
SwitchContextFGFrame (Frame); SwitchContextFGFrame (Frame);
SetContextGraphicsFunctions ();
} }
} }
return (LastFrame); return (LastFrame);
} }
FRAME
SetContextBGFrame (FRAME Frame)
{
FRAME LastFrame;
LastFrame = BGFrame;
BGFrame = Frame;
if (ContextActive ())
SwitchContextBGFrame (Frame);
return (LastFrame);
}
DRAWABLE DRAWABLE
CreateDisplay (CREATE_FLAGS CreateFlags, PSIZE pwidth, PSIZE pheight) CreateDisplay (CREATE_FLAGS CreateFlags, PSIZE pwidth, PSIZE pheight)
{ {
@@ -180,8 +166,6 @@ DestroyDrawable (DRAWABLE Drawable)
if (LOWORD (Drawable) == GetFrameHandle (_CurFramePtr)) if (LOWORD (Drawable) == GetFrameHandle (_CurFramePtr))
SetContextFGFrame ((FRAME)0); SetContextFGFrame ((FRAME)0);
if (LOWORD (Drawable) == GetFrameHandle (BGFrame))
SetContextBGFrame ((FRAME)0);
DrawablePtr = LockDrawable (Drawable); DrawablePtr = LockDrawable (Drawable);
if (DrawablePtr) if (DrawablePtr)
-23
View File
@@ -119,27 +119,6 @@ typedef DRAWABLE_DESC *PDRAWABLE_DESC;
#define TYPE_SET(f,t) ((f)|=t) #define TYPE_SET(f,t) ((f)|=t)
#define INDEX_SET(f,i) ((f)|=i) #define INDEX_SET(f,i) ((f)|=i)
typedef struct polygon_desc
{
RECT BoundRect;
POLYREF hPoly;
COUNT PtCount;
PPOINT PtList;
} POLYGON_DESC;
typedef POLYGON_DESC *PPOLYGON_DESC;
#define POLYGON_PRIORITY DEFAULT_MEM_PRIORITY
#define AllocPolygon(n) \
mem_allocate ((MEM_SIZE)(sizeof (POLYGON_DESC) + \
(sizeof (POINT) * (n))), MEM_ZEROINIT, \
POLYGON_PRIORITY, MEM_SIMPLE)
#define LockPolygon(Polygon) (PPOLYGON_DESC)mem_lock (Polygon)
#define UnlockPolygon(Polygon) mem_unlock (Polygon)
#define FreePolygon(Polygon) mem_release (Polygon)
typedef struct typedef struct
{ {
RECT Box; RECT Box;
@@ -162,12 +141,10 @@ typedef PSTAMP STAMPPTR;
typedef PTEXT TEXTPTR; typedef PTEXT TEXTPTR;
extern STAMP _save_stamp; extern STAMP _save_stamp;
#define BGFrame _save_stamp.frame
extern FRAMEPTR _CurFramePtr; extern FRAMEPTR _CurFramePtr;
extern void _rect_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr); extern void _rect_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr);
extern void _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr); extern void _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr);
extern void _fillpoly_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr);
#endif /* _DRAWABLE_H */ #endif /* _DRAWABLE_H */
+2 -2
View File
@@ -59,7 +59,7 @@ typedef struct tfb_dc_img
int x, y; int x, y;
SCREEN destBuffer; SCREEN destBuffer;
BOOLEAN UsePalette; BOOLEAN UsePalette;
BOOLEAN UseScaling; int scale;
} TFB_DrawCommand_Image; } TFB_DrawCommand_Image;
typedef struct tfb_dc_filledimg typedef struct tfb_dc_filledimg
@@ -68,7 +68,7 @@ typedef struct tfb_dc_filledimg
int x, y; int x, y;
int r, g, b; int r, g, b;
SCREEN destBuffer; SCREEN destBuffer;
BOOLEAN UseScaling; int scale;
} TFB_DrawCommand_FilledImage; } TFB_DrawCommand_FilledImage;
typedef struct tfb_dc_copy typedef struct tfb_dc_copy
-25
View File
@@ -43,28 +43,3 @@ LoadCelFile (PVOID pStr)
return (0); return (0);
} }
DWORD
LoadFontFile (PVOID pStr)
{
FILE *fp;
// FIXME: this theoretically needs a mechanism to prevent races
if (_cur_resfile_name)
// something else is loading resources atm
return 0;
if ((fp = res_OpenResFile (pStr, "rb")) != NULL)
{
MEM_HANDLE hData;
_cur_resfile_name = pStr;
hData = _GetFontData (fp, LengthResFile (fp));
_cur_resfile_name = 0;
res_CloseResFile (fp);
return ((DWORD)hData);
}
return (0);
}
+8 -3
View File
@@ -221,12 +221,17 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
UNICODE next_ch, *pStr; UNICODE next_ch, *pStr;
TEXTPTR TextPtr; TEXTPTR TextPtr;
PRIMITIVE locPrim; PRIMITIVE locPrim;
TFB_Palette color;
DWORD c32k;
if (FontEffect.Use) if (FontEffect.Use)
SetPrimType (&locPrim, STAMP_PRIM); SetPrimType (&locPrim, STAMP_PRIM);
else else
SetPrimType (&locPrim, STAMPFILL_PRIM); SetPrimType (&locPrim, STAMPFILL_PRIM);
SetPrimColor (&locPrim, _get_context_fg_color ()); c32k = _get_context_fg_color () >> 8;
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TextPtr = &PrimPtr->Object.Text; TextPtr = &PrimPtr->Object.Text;
locPrim.Object.Stamp.origin.x = _save_stamp.origin.x; locPrim.Object.Stamp.origin.x = _save_stamp.origin.x;
@@ -265,12 +270,12 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
locPrim.Object.Stamp.frame = Build_Font_Effect( locPrim.Object.Stamp.frame = Build_Font_Effect(
locPrim.Object.Stamp.frame, locPrim.Object.Stamp.frame,
FontEffect.from, FontEffect.to, FontEffect.type); FontEffect.from, FontEffect.to, FontEffect.type);
DrawGraphicsFunc (&r, &locPrim); TFB_Prim_Stamp (&locPrim.Object.Stamp);
DestroyDrawable (ReleaseDrawable (locPrim.Object.Stamp.frame)); DestroyDrawable (ReleaseDrawable (locPrim.Object.Stamp.frame));
locPrim.Object.Stamp.frame = origFrame; locPrim.Object.Stamp.frame = origFrame;
} }
else else
DrawGraphicsFunc (&r, &locPrim); TFB_Prim_StampFill (&locPrim.Object.Stamp, &color);
} }
locPrim.Object.Stamp.origin.x += GetFrameWidth (locPrim.Object.Stamp.frame); locPrim.Object.Stamp.origin.x += GetFrameWidth (locPrim.Object.Stamp.frame);
+170 -215
View File
@@ -18,6 +18,9 @@
#include "gfxintrn.h" #include "gfxintrn.h"
#include "declib.h" #include "declib.h"
#include "gfx_common.h"
#include "tfb_draw.h"
#include "tfb_prim.h"
typedef union typedef union
{ {
@@ -25,16 +28,7 @@ typedef union
STAMP Stamp; STAMP Stamp;
BRESENHAM_LINE Line; BRESENHAM_LINE Line;
TEXT Text; TEXT Text;
STAMP_CMAP StampCMap;
RECT Rect; RECT Rect;
POLYGON_DESC Polygon;
struct
{
POINT origin;
FRAME frame;
COUNT NumFrames;
PFRAME FrameList;
} Composite;
} INTERNAL_PRIM_DESC; } INTERNAL_PRIM_DESC;
typedef INTERNAL_PRIM_DESC *PINTERNAL_PRIM_DESC; typedef INTERNAL_PRIM_DESC *PINTERNAL_PRIM_DESC;
@@ -83,40 +77,14 @@ GetFrameValidRect (PRECT pValidRect, HOT_SPOT *pOldHot)
void void
ClearBackGround (PRECT pClipRect) ClearBackGround (PRECT pClipRect)
{ {
if (_get_context_bg_func ()) TFB_Palette color;
{ DWORD c32k;
(*_get_context_bg_func ()) (pClipRect);
}
else
{
RECT locRect;
PRIMITIVE locPrim;
locPrim.Object.Rect = *pClipRect; c32k = _get_context_bg_color () >> 8; //shift out color index
if (BGFrame == 0) color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
{ color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
SetPrimColor (&locPrim, _get_context_bg_color ()); color.b = (c32k << (8 - 5)) & 0xF8;
SetPrimType (&locPrim, RECTFILL_PRIM); TFB_Prim_FillRect (pClipRect, &color);
}
else
{
locRect.corner.x = -GetFrameHotX (BGFrame);
locRect.corner.y = -GetFrameHotY (BGFrame);
locRect.extent.width = GetFrameWidth (BGFrame);
locRect.extent.height = GetFrameHeight (BGFrame);
_save_stamp.origin = locRect.corner;
if (!BoxIntersect (&locRect, &locPrim.Object.Rect, &locRect))
return;
pClipRect = &locRect;
SetPrimType (&locPrim, STAMP_PRIM);
SetPrimColor (&locPrim, _get_context_bg_color ());
locPrim.Object.Stamp = _save_stamp;
}
DrawGraphicsFunc (pClipRect, &locPrim);
}
} }
void void
@@ -128,17 +96,9 @@ DrawBatch (PPRIMITIVE lpBasePrim, PRIM_LINKS PrimLinks, register
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{ {
int frame_dir;
COUNT CurIndex; COUNT CurIndex;
PRIM_LINKS OldLinks; PRIM_LINKS OldLinks;
register PPRIMITIVE lpPrim; register PPRIMITIVE lpPrim;
#ifdef MAPPING
MAP_TYPE MapType;
_init_context_map (&MapType);
if (MapType != MAP_NOXFORM)
BatchFlags |= BATCH_XFORM;
#endif /* MAPPING */
BatchFlags &= BATCH_SINGLE BatchFlags &= BATCH_SINGLE
| BATCH_BUILD_PAGE | BATCH_BUILD_PAGE
@@ -148,20 +108,12 @@ DrawBatch (PPRIMITIVE lpBasePrim, PRIM_LINKS PrimLinks, register
BatchGraphics (); BatchGraphics ();
frame_dir = ((GetDisplayFlags () & WANT_MASK)
&& _get_context_draw_mode () == DRAW_SUBTRACTIVE) ? -1 : 1;
if (BatchFlags & BATCH_BUILD_PAGE) if (BatchFlags & BATCH_BUILD_PAGE)
{ {
if (frame_dir == 1) ClearBackGround (&ValidRect);
ClearBackGround (&ValidRect);
} }
else if (_get_context_draw_mode () == DRAW_ADDITIVE
&& _get_context_bg_func ())
BatchFlags |= BATCH_DIRTY_TILES;
CurIndex = frame_dir < 0 CurIndex = GetPredLink (PrimLinks);
? GetSuccLink (PrimLinks)
: GetPredLink (PrimLinks);
if (BatchFlags & BATCH_SINGLE) if (BatchFlags & BATCH_SINGLE)
{ {
@@ -176,16 +128,14 @@ DrawBatch (PPRIMITIVE lpBasePrim, PRIM_LINKS PrimLinks, register
} }
} }
for (; CurIndex != END_OF_LIST; for (; CurIndex != END_OF_LIST; CurIndex = GetSuccLink (GetPrimLinks (lpPrim)))
CurIndex = frame_dir < 0
? GetPredLink (GetPrimLinks (lpPrim))
: GetSuccLink (GetPrimLinks (lpPrim)))
{ {
register GRAPHICS_PRIM PrimType; register GRAPHICS_PRIM PrimType;
PPRIMITIVE lpWorkPrim; PPRIMITIVE lpWorkPrim;
RECT ClipRect; RECT ClipRect;
INTERNAL_PRIMITIVE Prim;
FRAMEPTR SrcFramePtr; FRAMEPTR SrcFramePtr;
TFB_Palette color;
DWORD c32k;
lpPrim = &lpBasePrim[CurIndex]; lpPrim = &lpBasePrim[CurIndex];
PrimType = GetPrimType (lpPrim); PrimType = GetPrimType (lpPrim);
@@ -193,134 +143,45 @@ DrawBatch (PPRIMITIVE lpBasePrim, PRIM_LINKS PrimLinks, register
continue; continue;
lpWorkPrim = lpPrim; lpWorkPrim = lpPrim;
#ifdef MAPPING
if (BatchFlags & BATCH_XFORM)
{
COORD x, y;
Prim = *(PINTERNAL_PRIMITIVE)lpWorkPrim;
lpWorkPrim = (PPRIMITIVE)&Prim;
x = LXtoDX (Prim.Object.Point.x);
y = LYtoDY (Prim.Object.Point.y);
if (PrimType == RECT_PRIM
|| PrimType == RECTFILL_PRIM)
{
Prim.Object.Line.second.x =
LXtoDX (Prim.Object.Rect.corner.x +
Prim.Object.Rect.extent.width - 1);
Prim.Object.Line.second.y =
LYtoDY (Prim.Object.Rect.corner.y +
Prim.Object.Rect.extent.height - 1);
Prim.Object.Rect.extent.width = Prim.Object.Line.second.x - x + 1;
Prim.Object.Rect.extent.height = Prim.Object.Line.second.y - y + 1;
}
Prim.Object.Point.x = x;
Prim.Object.Point.y = y;
}
#endif /* MAPPING */
switch (PrimType) switch (PrimType)
{ {
case POINT_PRIM: case POINT_PRIM:
ClipRect.corner = lpWorkPrim->Object.Point; c32k = GetPrimColor (lpWorkPrim) >> 8; //shift out color index
if ((BatchFlags & BATCH_CLIP_GRAPHICS) color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
&& (ClipRect.corner.x < ValidRect.corner.x color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
|| ClipRect.corner.y < ValidRect.corner.y color.b = (c32k << (8 - 5)) & 0xF8;
|| ClipRect.corner.x >= ValidRect.corner.x
+ ValidRect.extent.width TFB_Prim_Point (&lpWorkPrim->Object.Point, &color);
|| ClipRect.corner.y >= ValidRect.corner.y break;
+ ValidRect.extent.height))
continue;
ClipRect.extent.width = ClipRect.extent.height = 1;
goto DoGraphics;
case STAMPCMAP_PRIM:
BatchColorMap (lpWorkPrim->Object.StampCMap.CMap);
goto ProcessStamp;
case COMPOSITE_PRIM:
case COMPOSITEFILL_PRIM:
Prim = *(PINTERNAL_PRIMITIVE)lpWorkPrim;
if ((Prim.Object.Composite.FrameList =
(PFRAME)Prim.Object.Composite.frame) == 0
|| Prim.Object.Composite.NumFrames == 0)
continue;
if (frame_dir < 0)
Prim.Object.Composite.FrameList +=
Prim.Object.Composite.NumFrames - 1;
lpWorkPrim = (PPRIMITIVE)&Prim;
SetPrimType (lpWorkPrim,
STAMP_PRIM + (PrimType - COMPOSITE_PRIM));
ProcessComposite:
Prim.Object.Composite.frame =
*Prim.Object.Composite.FrameList;
Prim.Object.Composite.FrameList += frame_dir;
if (--Prim.Object.Composite.NumFrames == 0)
PrimType = GetPrimType (&Prim);
case STAMP_PRIM: case STAMP_PRIM:
case STAMPFILL_PRIM: SrcFramePtr = (FRAMEPTR)(lpWorkPrim->Object.Stamp.frame);
ProcessStamp:
SrcFramePtr = (FRAMEPTR)(
lpWorkPrim->Object.Stamp.frame
);
if (SrcFramePtr == 0) if (SrcFramePtr == 0)
{ {
if (PrimType >= COMPOSITE_PRIM) continue;
goto ProcessComposite; }
else TFB_Prim_Stamp (&lpWorkPrim->Object.Stamp);
continue; break;
case STAMPFILL_PRIM:
SrcFramePtr = (FRAMEPTR)(lpWorkPrim->Object.Stamp.frame);
if (SrcFramePtr == 0)
{
continue;
} }
ClipRect.corner = lpWorkPrim->Object.Stamp.origin; c32k = GetPrimColor (lpWorkPrim) >> 8; //shift out color index
ClipRect.corner.x -= GetFrameHotX (SrcFramePtr); color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
ClipRect.corner.y -= GetFrameHotY (SrcFramePtr); color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
ClipRect.extent.width = GetFrameWidth (SrcFramePtr); color.b = (c32k << (8 - 5)) & 0xF8;
ClipRect.extent.height = GetFrameHeight (SrcFramePtr); TFB_Prim_StampFill (&lpWorkPrim->Object.Stamp, &color);
_save_stamp.origin = ClipRect.corner;
break; break;
case LINE_PRIM: case LINE_PRIM:
#ifdef MAPPING c32k = GetPrimColor (lpWorkPrim) >> 8; //shift out color index
if (BatchFlags & BATCH_XFORM) color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
{ color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
Prim.Object.Line.second.x = LXtoDX (Prim.Object.Line.second.x); color.b = (c32k << (8 - 5)) & 0xF8;
Prim.Object.Line.second.y = LYtoDY (Prim.Object.Line.second.y);
}
else
#endif /* MAPPING */
{
Prim = *(PINTERNAL_PRIMITIVE)lpWorkPrim;
lpWorkPrim = (PPRIMITIVE)&Prim;
}
if (Prim.Object.Line.second.x >= Prim.Object.Line.first.x) TFB_Prim_Line (&lpWorkPrim->Object.Line, &color);
{
ClipRect.corner.x = Prim.Object.Line.first.x;
ClipRect.extent.width =
Prim.Object.Line.second.x
- Prim.Object.Line.first.x + 1;
}
else
{
ClipRect.corner.x = Prim.Object.Line.second.x;
ClipRect.extent.width =
Prim.Object.Line.first.x
- Prim.Object.Line.second.x + 1;
}
if (Prim.Object.Line.second.y >= Prim.Object.Line.first.y)
{
ClipRect.corner.y = Prim.Object.Line.first.y;
ClipRect.extent.height =
Prim.Object.Line.second.y
- Prim.Object.Line.first.y + 1;
}
else
{
ClipRect.corner.y = Prim.Object.Line.second.y;
ClipRect.extent.height =
Prim.Object.Line.first.y
- Prim.Object.Line.second.y + 1;
}
break; break;
case TEXT_PRIM: case TEXT_PRIM:
if (!TextRect (&lpWorkPrim->Object.Text, if (!TextRect (&lpWorkPrim->Object.Text,
@@ -328,42 +189,23 @@ ProcessStamp:
continue; continue;
_save_stamp.origin = ClipRect.corner; _save_stamp.origin = ClipRect.corner;
_text_blt (&ClipRect, lpWorkPrim);
break; break;
case RECT_PRIM: case RECT_PRIM:
c32k = GetPrimColor (lpWorkPrim) >> 8; //shift out color index
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TFB_Prim_Rect (&lpWorkPrim->Object.Rect, &color);
case RECTFILL_PRIM: case RECTFILL_PRIM:
ClipRect = lpWorkPrim->Object.Rect; c32k = GetPrimColor (lpWorkPrim) >> 8; //shift out color index
break; color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
case POLY_PRIM: color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
case POLYFILL_PRIM: color.b = (c32k << (8 - 5)) & 0xF8;
ClipRect = ((PPOLYGON_DESC)lpWorkPrim->Object.Polygon)->BoundRect; TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, &color);
break; break;
} }
#if 0
if ((BatchFlags & BATCH_CLIP_GRAPHICS)
&& BoxIntersect (&ClipRect,
&ValidRect, &ClipRect) == 0)
{
if (PrimType >= COMPOSITE_PRIM)
goto ProcessComposite;
else
continue;
}
#endif
DoGraphics:
if (BatchFlags & BATCH_DIRTY_TILES)
(*_get_context_bg_func ()) (&ClipRect);
DrawGraphicsFunc (&ClipRect, lpWorkPrim);
if (PrimType >= COMPOSITE_PRIM)
goto ProcessComposite;
}
if (BatchFlags & BATCH_BUILD_PAGE)
{
if (frame_dir < 0)
ClearBackGround (&ValidRect);
} }
UnbatchGraphics (); UnbatchGraphics ();
@@ -375,9 +217,6 @@ DoGraphics:
GetPredLink (OldLinks), GetPredLink (OldLinks),
GetSuccLink (OldLinks)); GetSuccLink (OldLinks));
#ifdef MAPPING
_uninit_context_map ();
#endif /* MAPPING */
} }
} }
@@ -397,3 +236,119 @@ ClearDrawable (void)
} }
} }
void
DrawPoint (PPOINT lpPoint)
{
RECT ValidRect;
HOT_SPOT OldHot;
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{
TFB_Palette color;
DWORD c32k;
c32k = GetPrimColor (&_locPrim) >> 8; //shift out color index
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TFB_Prim_Point (lpPoint, &color);
SetFrameHotSpot (_CurFramePtr, OldHot);
}
}
void
DrawRectangle (PRECT lpRect)
{
RECT ValidRect;
HOT_SPOT OldHot;
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{
TFB_Palette color;
DWORD c32k;
c32k = GetPrimColor (&_locPrim) >> 8; //shift out color index
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TFB_Prim_Rect (lpRect, &color);
SetFrameHotSpot (_CurFramePtr, OldHot);
}
}
void
DrawFilledRectangle (PRECT lpRect)
{
RECT ValidRect;
HOT_SPOT OldHot;
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{
TFB_Palette color;
DWORD c32k;
c32k = GetPrimColor (&_locPrim) >> 8; //shift out color index
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TFB_Prim_FillRect (lpRect, &color);
SetFrameHotSpot (_CurFramePtr, OldHot);
}
}
void
DrawLine (PLINE lpLine)
{
RECT ValidRect;
HOT_SPOT OldHot;
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{
TFB_Palette color;
DWORD c32k;
c32k = GetPrimColor (&_locPrim) >> 8; //shift out color index
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TFB_Prim_Line (lpLine, &color);
SetFrameHotSpot (_CurFramePtr, OldHot);
}
}
void
DrawStamp (PSTAMP stmp)
{
RECT ValidRect;
HOT_SPOT OldHot;
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{
TFB_Prim_Stamp (stmp);
SetFrameHotSpot (_CurFramePtr, OldHot);
}
}
void
DrawFilledStamp (PSTAMP stmp)
{
RECT ValidRect;
HOT_SPOT OldHot;
if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot))
{
TFB_Palette color;
DWORD c32k;
c32k = GetPrimColor (&_locPrim) >> 8; //shift out color index
color.r = (c32k >> (10 - (8 - 5))) & 0xF8;
color.g = (c32k >> (5 - (8 - 5))) & 0xF8;
color.b = (c32k << (8 - 5)) & 0xF8;
TFB_Prim_StampFill (stmp, &color);
SetFrameHotSpot (_CurFramePtr, OldHot);
}
}
@@ -52,6 +52,7 @@ void LoadIntoExtraScreen (PRECT r);
void DrawFromExtraScreen (PRECT r); void DrawFromExtraScreen (PRECT r);
void SetGraphicGrabOther (int grab_other); void SetGraphicGrabOther (int grab_other);
void SetGraphicScale (int scale); void SetGraphicScale (int scale);
int GetGraphicScale ();
void SetGraphicUseOtherExtra (int other); void SetGraphicUseOtherExtra (int other);
void ScreenTransition (int transition, PRECT pRect); void ScreenTransition (int transition, PRECT pRect);
-557
View File
@@ -1,557 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
/* I don't know yet what the deal is with the __WATCOMC__ delimited
* code, but this will at least make it compile, which is stage 1. - SvdB
*/
#define __WATCOMC__
#define AllocGraphicData(size) \
mem_allocate ((MEM_SIZE)(size), MEM_ZEROINIT | MEM_GRAPHICS, \
DEFAULT_MEM_PRIORITY, MEM_SIMPLE)
#define LockData (PBYTE)mem_lock
#define UnlockData mem_unlock
#define FreeData mem_release
typedef enum
{
UP,
DOWN
} DIRECTION;
#define POLY_XMIN 1
#define POLY_YMIN 0
static void
xor_dot (FRAMEPTR FramePtr, COORD x, COORD y)
{
PBYTE lpMaskAddr;
lpMaskAddr =
#ifndef __WATCOMC__
GetImageData (&FramePtr->MaskImage)
+ (y * GetImageLineBytes (&FramePtr->MaskImage))
+ BYTE_POS (x);
#else /* __WATCOMC__ */
0;
#endif /* __WATCOMC__ */
*lpMaskAddr ^= (BYTE)0x80 >> BYTE_OFFS (x);
}
static void
xor_line (FRAMEPTR FramePtr, PBRESENHAM_LINE pLine)
{
COORD dst_x, dst_y;
COORD dst_mask_x;
SIZE dst_mask_incr;
SIZE count;
BYTE dst_bit, bit_shift;
SIZE delta_x, delta_y, error_term;
PBYTE lpMaskAddr;
dst_x = pLine->first.x;
dst_y = pLine->first.y;
delta_x = pLine->abs_delta_x;
delta_y = pLine->abs_delta_y;
error_term = pLine->error_term;
dst_mask_x = dst_x;
bit_shift = 1;
#ifndef __WATCOMC__
lpMaskAddr = GetImageData (&FramePtr->MaskImage);
dst_mask_incr = GetImageLineBytes (&FramePtr->MaskImage);
lpMaskAddr += (dst_y * dst_mask_incr) + BYTE_POS (dst_mask_x);
#endif /* __WATCOMC__ */
if (delta_y < 0)
{
delta_y = -delta_y;
dst_mask_incr = -dst_mask_incr;
}
dst_bit = (BYTE)((BYTE)0x80 >> (BYTE)BYTE_OFFS (dst_mask_x));
if (delta_x > delta_y)
{
count = pLine->second.x - pLine->first.x;
if (!pLine->end_points_exchanged)
{
do
{
if ((error_term += delta_y) >= 0)
{
*lpMaskAddr ^= dst_bit;
if (count == 0)
break;
lpMaskAddr += dst_mask_incr;
error_term -= delta_x;
}
if ((dst_bit >>= bit_shift) == 0)
{
dst_bit = (BYTE)0x80;
++lpMaskAddr;
}
} while (count--);
if (error_term < 0)
{
if ((dst_bit <<= bit_shift) == 0)
{
dst_bit = (BYTE)0x01;
--lpMaskAddr;
}
*lpMaskAddr ^= dst_bit;
}
}
else
{
*lpMaskAddr ^= dst_bit;
do
{
if ((dst_bit >>= bit_shift) == 0)
{
dst_bit = (BYTE)0x80;
++lpMaskAddr;
}
if ((error_term += delta_y) >= 0)
{
if (count == 0)
break;
lpMaskAddr += dst_mask_incr;
*lpMaskAddr ^= dst_bit;
error_term -= delta_x;
}
} while (count--);
}
}
else
{
if ((count = pLine->second.y - pLine->first.y) < 0)
count = -count;
do
{
*lpMaskAddr ^= dst_bit;
lpMaskAddr += dst_mask_incr;
if ((error_term += delta_x) >= 0)
{
if ((dst_bit >>= bit_shift) == 0)
{
dst_bit = (BYTE)0x80;
++lpMaskAddr;
}
error_term -= delta_y;
}
} while (count--);
}
}
static void
or_line (FRAMEPTR FramePtr, PBRESENHAM_LINE pLine)
{
COORD dst_x, dst_y;
COORD dst_mask_x;
SIZE dst_mask_incr;
SIZE delta_x, delta_y, error_term, count;
BYTE dst_bit, dst_byte, bit_mask, bit_shift;
PBYTE lpMaskAddr;
dst_x = pLine->first.x;
dst_y = pLine->first.y;
delta_x = pLine->abs_delta_x;
delta_y = pLine->abs_delta_y;
error_term = pLine->error_term;
dst_mask_x = dst_x;
bit_mask = (BYTE)0x80;
bit_shift = 1;
#ifndef __WATCOMC__
lpMaskAddr = GetImageData (&FramePtr->MaskImage);
dst_mask_incr = GetImageLineBytes (&FramePtr->MaskImage);
lpMaskAddr += (dst_y * dst_mask_incr) + BYTE_POS (dst_mask_x);
#endif /* __WATCOMC__ */
if (delta_y < 0)
{
delta_y = -delta_y;
dst_mask_incr = -dst_mask_incr;
}
dst_bit = (BYTE)(bit_mask >> BYTE_OFFS (dst_mask_x));
if (delta_x > delta_y)
{
count = pLine->second.x - pLine->first.x;
dst_byte = 0;
do
{
dst_byte |= dst_bit;
if ((dst_bit >>= bit_shift) == 0)
{
dst_bit = bit_mask;
*lpMaskAddr++ |= dst_byte;
dst_byte = 0;
}
if ((error_term += delta_y) >= 0)
{
if (dst_byte)
{
*lpMaskAddr |= dst_byte;
dst_byte = 0;
}
lpMaskAddr += dst_mask_incr;
error_term -= delta_x;
}
} while (count--);
if (dst_byte)
*lpMaskAddr |= dst_byte;
}
else
{
if ((count = pLine->second.y - pLine->first.y) < 0)
count = -count;
do
{
*lpMaskAddr |= dst_bit;
lpMaskAddr += dst_mask_incr;
if ((error_term += delta_x) >= 0)
{
if ((dst_bit >>= bit_shift) == 0)
{
dst_bit = bit_mask;
++lpMaskAddr;
}
error_term -= delta_y;
}
} while (count--);
}
}
static void
on_off (FRAMEPTR FramePtr)
{
register SIZE width, height;
register SIZE dst_mask_incr;
register PBYTE lpScan;
width = GetFrameWidth (FramePtr);
height = GetFrameHeight (FramePtr);
#ifndef __WATCOMC__
lpScan = GetImageData (&FramePtr->MaskImage);
dst_mask_incr = GetImageLineBytes (&FramePtr->MaskImage);
#endif /* __WATCOMC__ */
width = BYTE_WIDTH (width);
do
{
register SIZE byte_width;
register BYTE mask_byte, bit;
register PBYTE lpMask;
byte_width = width;
lpMask = lpScan;
start_scan:
while (!(mask_byte = *lpMask))
{
if (--byte_width == 0)
goto done_scan;
++lpMask;
}
for (bit = (BYTE)0x80; !(bit & mask_byte); bit >>= 1)
;
fill_scan:
while (bit >>= 1)
{
fill_byte:
if (!(bit & mask_byte))
mask_byte |= bit;
else
{
while (bit >>= 1)
{
if (bit & mask_byte)
goto fill_scan;
}
*lpMask++ = mask_byte;
if (--byte_width == 0)
goto done_scan;
else
goto start_scan;
}
}
*lpMask++ = mask_byte;
if (--byte_width > 0)
{
while (!(mask_byte = *lpMask))
{
*lpMask++ = 0xFF;
if (--byte_width == 0)
goto done_scan;
}
bit = (BYTE)0x80;
goto fill_byte;
}
done_scan:
lpScan += dst_mask_incr;
} while (--height);
}
static void
create_poly (PRECT pClipRect, PPOLYGON_DESC lpPolygon, FRAMEPTR
FramePtr)
{
COUNT i;
COORD xoffs, yoffs;
BRESENHAM_LINE Line;
PPOINT pt1;
xoffs = pClipRect->corner.x - POLY_XMIN;
yoffs = pClipRect->corner.y - POLY_YMIN;
if (lpPolygon->PtCount > 2)
{
COORD xmax, ymax;
COORD ox, oy;
COORD ystart;
PPOINT pt2;
DIRECTION last_ydir;
BRESENHAM_LINE ShadowLine;
xmax = POLY_XMIN + pClipRect->extent.width - 1;
ymax = POLY_YMIN + pClipRect->extent.height - 1;
ShadowLine.first.x = ShadowLine.second.x = POLY_XMIN - 1;
ShadowLine.error_term = -1;
ShadowLine.abs_delta_x = 0;
ShadowLine.end_points_exchanged = FALSE;
pt1 = lpPolygon->PtList;
ystart = pt1->y;
while ((oy = (++pt1)->y) == ystart)
;
ox = pt1->x;
last_ydir = oy > ystart ? UP : DOWN;
i = lpPolygon->PtCount;
pt2 = &lpPolygon->PtList[i - 1];
do
{
COORD x1, y1;
if (pt1 != pt2)
++pt1;
else
pt1 = lpPolygon->PtList;
x1 = ox;
y1 = oy;
ox = pt1->x;
oy = pt1->y;
if (oy != y1)
{
COORD y2;
INTERSECT_CODE intersect_code;
Line.first.x = x1;
Line.first.y = y1;
Line.second.x = ox;
Line.second.y = oy;
LOGtoDEV ((PPOINT)&Line, (PPOINT)&Line, 2);
y1 = Line.first.y - yoffs;
y2 = Line.second.y - yoffs;
{
DIRECTION ydir;
ydir = y2 > y1 ? UP : DOWN;
if (ydir != last_ydir)
last_ydir = ydir;
else if (y1 >= POLY_YMIN && y1 <= ymax)
{
x1 = Line.first.x - xoffs;
if (x1 < POLY_XMIN)
xor_dot (FramePtr, POLY_XMIN - 1, y1);
else if (x1 <= xmax)
xor_dot (FramePtr, x1, y1);
}
}
intersect_code = _clip_line (pClipRect, &Line);
Line.first.x -= xoffs;
Line.first.y -= yoffs;
Line.second.x -= xoffs;
Line.second.y -= yoffs;
if (intersect_code)
{
xor_line (FramePtr, &Line);
if (intersect_code & INTERSECT_LEFT)
{
if (Line.end_points_exchanged)
y1 = y2;
y2 = Line.first.y;
if (y2 > POLY_YMIN && y1 < y2)
{
--y2;
if (y1 < POLY_YMIN)
y1 = POLY_YMIN;
ShadowLine.first.y = y1;
ShadowLine.second.y = y2;
ShadowLine.abs_delta_y = y2 - y1;
xor_line (FramePtr, &ShadowLine);
}
else if (y2 < ymax && y1 > y2)
{
++y2;
if (y1 > ymax)
y1 = ymax;
ShadowLine.first.y = y2;
ShadowLine.second.y = y1;
ShadowLine.abs_delta_y = y1 - y2;
xor_line (FramePtr, &ShadowLine);
}
}
}
else if (Line.first.x < POLY_XMIN
&& (Line.first.y >= POLY_YMIN
|| Line.second.y >= POLY_YMIN)
&& (Line.first.y <= ymax
|| Line.second.y <= ymax))
{
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
if (Line.first.y > Line.second.y)
{
y1 = MAX (Line.second.y, POLY_YMIN);
y2 = MIN (Line.first.y, ymax);
}
else
{
y1 = MAX (Line.first.y, POLY_YMIN);
y2 = MIN (Line.second.y, ymax);
}
if (Line.first.x == Line.second.x) /* vertical line */
{
ShadowLine.first.y = y1;
ShadowLine.second.y = y2;
ShadowLine.abs_delta_y = y2 - y1;
xor_line (FramePtr, &ShadowLine);
}
else /* sloped line */
{
SIZE line_delta_x, line_delta_y;
long yinter; /* y intercept with xmin */
line_delta_x = Line.second.x - Line.first.x;
line_delta_y = Line.second.y - Line.first.y;
yinter = ((long)Line.first.y * line_delta_x)
+ ((long)(POLY_XMIN - Line.first.x)
* line_delta_y);
if ((Line.first.y < Line.second.y
&& yinter >= (long)(POLY_YMIN * line_delta_x))
|| (Line.first.y > Line.second.y
&& yinter <= (long)ymax * line_delta_x))
{
ShadowLine.first.y = y1;
ShadowLine.second.y = y2;
ShadowLine.abs_delta_y = y2 - y1;
xor_line (FramePtr, &ShadowLine);
}
}
}
}
} while (--i);
on_off (FramePtr);
}
/* now outline the polygon */
pt1 = lpPolygon->PtList;
for (i = lpPolygon->PtCount - 1; i > 0; --i)
{
LOGtoDEV (pt1++, (PPOINT)&Line, 2);
if (_clip_line (pClipRect, &Line))
{
Line.first.x -= xoffs;
Line.first.y -= yoffs;
Line.second.x -= xoffs;
Line.second.y -= yoffs;
or_line (FramePtr, &Line);
}
}
Line.first = *pt1;
Line.second = lpPolygon->PtList[0];
LOGtoDEV ((PPOINT)&Line, (PPOINT)&Line, 2);
if (_clip_line (pClipRect, &Line))
{
Line.first.x -= xoffs;
Line.first.y -= yoffs;
Line.second.x -= xoffs;
Line.second.y -= yoffs;
or_line (FramePtr, &Line);
}
}
void
_fillpoly_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
{
#ifndef __WATCOMC__
MEM_HANDLE h;
FRAME_DESC PolyFrame;
PRIMITIVE locPrim;
SetFrameX (&PolyFrame, 0);
SetFrameY (&PolyFrame, 0);
SetFrameWidth (&PolyFrame, pClipRect->extent.width + POLY_XMIN);
SetFrameHeight (&PolyFrame, pClipRect->extent.height + POLY_YMIN);
SetImageShift (&PolyFrame.MaskImage, 0);
AllocMaskImage (&PolyFrame, RAM_DRAWABLE, 0);
SubImageFlags (&PolyFrame.PixmapImage, ~0);
SetImageData (&PolyFrame.PixmapImage, NULL_PTR);
AllocPixmapImage (&PolyFrame, RAM_DRAWABLE, 0);
h = AllocGraphicData (GetImageByteCount (&PolyFrame.MaskImage));
SetImageData (&PolyFrame.MaskImage, LockData (h));
create_poly (pClipRect,
(PPOLYGON_DESC)PrimPtr->Object.Polygon, &PolyFrame);
_save_stamp.origin.x = pClipRect->corner.x - POLY_XMIN;
_save_stamp.origin.y = pClipRect->corner.y - POLY_YMIN;
locPrim.Object.Stamp.frame = &PolyFrame;
SetPrimType (&locPrim, STAMPFILL_PRIM);
SetPrimColor (&locPrim, GetPrimColor (PrimPtr));
DrawGraphicsFunc (pClipRect, &locPrim);
UnlockData (h);
FreeMaskImage (h);
#endif /* __WATCOMC__ */
}
-201
View File
@@ -1,201 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
MAP_TYPE
SetContextMapType (MAP_TYPE MapType)
{
#ifndef MAPPING
return (MAP_NOXFORM);
#else /* MAPPING */
MAP_TYPE oldMapType;
if (!ContextActive ())
oldMapType = MAP_NOXFORM;
else if ((oldMapType = _get_context_map_type ()) != MapType)
{
SwitchContextMapType (MapType);
}
return (oldMapType);
#endif /* MAPPING */
}
BOOLEAN
SetContextWinOrigin (PPOINT lpOrg)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive ())
return (FALSE);
SwitchContextWinOrigin (lpOrg);
return (TRUE);
#endif /* MAPPING */
}
BOOLEAN
SetContextViewExtents (PEXTENT lpExtent)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive ())
return (FALSE);
SwitchContextViewExtents (lpExtent);
return (TRUE);
#endif /* MAPPING */
}
BOOLEAN
SetContextWinExtents (PEXTENT lpExtent)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive ())
return (FALSE);
SwitchContextWinExtents (lpExtent);
return (TRUE);
#endif /* MAPPING */
}
BOOLEAN
GetContextWinOrigin (PPOINT lpOrg)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive ())
return (FALSE);
*lpOrg = _pCurContext->Map.WinOrg;
return (TRUE);
#endif /* MAPPING */
}
BOOLEAN
GetContextViewExtents (PEXTENT lpExtent)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive ())
return (FALSE);
*lpExtent = _pCurContext->Map.ViewExt;
return (TRUE);
#endif /* MAPPING */
}
BOOLEAN
GetContextWinExtents (PEXTENT lpExtent)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive ())
return (FALSE);
*lpExtent = _pCurContext->Map.WinExt;
return (TRUE);
#endif /* MAPPING */
}
BOOLEAN
LOGtoDEV (PPOINT lpSrcPt, PPOINT lpDstPt, COUNT NumPoints)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive () || NumPoints == 0)
return (FALSE);
{
MAP_TYPE MapType;
_init_context_map (&MapType);
if (MapType == MAP_NOXFORM)
{
do
*lpDstPt++ = *lpSrcPt++;
while (--NumPoints);
}
else
{
do
{
lpDstPt->x = LXtoDX (lpSrcPt->x);
lpDstPt->y = LYtoDY (lpSrcPt->y);
++lpSrcPt;
++lpDstPt;
} while (--NumPoints);
}
_uninit_context_map ();
return (TRUE);
}
#endif /* MAPPING */
}
BOOLEAN
DEVtoLOG (PPOINT lpSrcPt, PPOINT lpDstPt, COUNT NumPoints)
{
#ifndef MAPPING
return (FALSE);
#else /* MAPPING */
if (!ContextActive () || NumPoints == 0)
return (FALSE);
{
MAP_TYPE MapType;
_init_context_map (&MapType);
if (MapType == MAP_NOXFORM)
{
do
*lpDstPt++ = *lpSrcPt++;
while (--NumPoints);
}
else
{
do
{
lpDstPt->x = DXtoLX (lpSrcPt->x);
lpDstPt->y = DYtoLY (lpSrcPt->y);
++lpSrcPt;
++lpDstPt;
} while (--NumPoints);
}
_uninit_context_map ();
return (TRUE);
}
#endif /* MAPPING */
}
-17
View File
@@ -172,20 +172,3 @@ DecFrameIndex (FRAMEPTR FramePtr)
return ((FRAME)&DrawablePtr->Frame[INDEX_GET (DrawablePtr->FlagsAndIndex)]); return ((FRAME)&DrawablePtr->Frame[INDEX_GET (DrawablePtr->FlagsAndIndex)]);
} }
} }
void
XFlipFrame (FRAMEPTR FramePtr)
{
if (FramePtr)
{
if (GetFrameFlags (FramePtr) & X_FLIP)
{
SubFrameFlags (FramePtr, X_FLIP);
}
else
{
AddFrameFlags (FramePtr, X_FLIP);
}
}
}
-178
View File
@@ -1,178 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
void
DrawPolygon (POLYGON Polygon)
{
SetPrimType (&_locPrim, POLY_PRIM);
_locPrim.Object.Polygon = Polygon;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void
DrawFilledPolygon (POLYGON Polygon)
{
SetPrimType (&_locPrim, POLYFILL_PRIM);
_locPrim.Object.Polygon = Polygon;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
POLYREF
CreatePolygon (COUNT PtCount)
{
POLYREF hPoly;
hPoly = (POLYREF)NULL_PTR;
if (PtCount > 0)
{
PPOLYGON_DESC lpPoly;
if ((hPoly = AllocPolygon (PtCount)) != (POLYREF)NULL_PTR)
{
if ((lpPoly = LockPolygon (hPoly)) == (PPOLYGON_DESC)NULL_PTR)
{
FreePolygon (hPoly);
hPoly = (POLYREF)NULL_PTR;
}
else
{
lpPoly->hPoly = hPoly;
lpPoly->PtCount = PtCount;
UnlockPolygon (hPoly);
}
}
}
return (hPoly);
}
BOOLEAN
DestroyPolygon (POLYREF PolyRef)
{
return (FreePolygon (PolyRef));
}
POLYGON
CapturePolygon (POLYREF PolyRef)
{
PPOLYGON_DESC lpPoly;
if (PolyRef == (POLYREF)NULL_PTR)
lpPoly = (PPOLYGON_DESC)NULL_PTR;
else
{
lpPoly = LockPolygon (PolyRef);
lpPoly->PtList = (PPOINT)&lpPoly[1];
}
return ((POLYGON)lpPoly);
}
POLYREF
ReleasePolygon (POLYGON Polygon)
{
POLYREF PolyRef;
PolyRef = (POLYREF)NULL_PTR;
if (Polygon != (POLYGON)NULL_PTR)
{
PolyRef = ((PPOLYGON_DESC)Polygon)->hPoly;
UnlockPolygon (PolyRef);
}
return (PolyRef);
}
BOOLEAN
SetPolygonPoint (POLYGON Polygon, COUNT PtIndex, COORD x, COORD y)
{
BOOLEAN retval;
retval = FALSE;
if (Polygon != (POLYGON)NULL_PTR)
{
PPOLYGON_DESC lpPoly;
PPOINT lpPt;
lpPoly = (PPOLYGON_DESC)Polygon;
if (lpPoly->BoundRect.extent.width == 0)
{
lpPoly->BoundRect.corner.x = x;
lpPoly->BoundRect.corner.y = y;
lpPoly->BoundRect.extent.width =
lpPoly->BoundRect.extent.height = 1;
}
else
{
SIZE delta, width, height;
width = height = 1;
if ((delta = x - lpPoly->BoundRect.corner.x) >= 0)
width += delta;
else
{
lpPoly->BoundRect.extent.width -= delta;
lpPoly->BoundRect.corner.x = x;
}
if ((delta = y - lpPoly->BoundRect.corner.y) >= 0)
height += delta;
else
{
lpPoly->BoundRect.extent.height -= delta;
lpPoly->BoundRect.corner.y = y;
}
if ((delta = width - lpPoly->BoundRect.extent.width) > 0)
lpPoly->BoundRect.extent.width += delta;
if ((delta = height - lpPoly->BoundRect.extent.height) > 0)
lpPoly->BoundRect.extent.height += delta;
}
lpPt = &lpPoly->PtList[PtIndex];
lpPt->x = x;
lpPt->y = y;
retval = TRUE;
}
return (retval);
}
BOOLEAN
GetPolygonPoint (POLYGON Polygon, COUNT PtIndex, PCOORD px, PCOORD py)
{
BOOLEAN retval;
retval = FALSE;
if (Polygon != (POLYGON)NULL_PTR)
{
PPOINT lpPt;
lpPt = &((PPOLYGON_DESC)Polygon)->PtList[PtIndex];
*px = lpPt->x;
*py = lpPt->y;
retval = TRUE;
}
return (retval);
}
-91
View File
@@ -1,91 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
void
DrawPoint (PPOINT lpPoint)
{
SetPrimType (&_locPrim, POINT_PRIM);
_locPrim.Object.Point = *lpPoint;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void
DrawRectangle (PRECT lpRect)
{
SetPrimType (&_locPrim, RECT_PRIM);
_locPrim.Object.Rect = *lpRect;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void
DrawFilledRectangle (PRECT lpRect)
{
SetPrimType (&_locPrim, RECTFILL_PRIM);
_locPrim.Object.Rect = *lpRect;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void
_rect_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
{
COORD x, y;
RECTPTR RectPtr;
PRIMITIVE locPrim;
locPrim = *PrimPtr;
SetPrimType (&locPrim, RECTFILL_PRIM);
RectPtr = &PrimPtr->Object.Rect;
locPrim.Object.Rect = *pClipRect;
if (locPrim.Object.Rect.corner.x == RectPtr->corner.x)
{
locPrim.Object.Rect.extent.width = 1;
DrawGraphicsFunc (&locPrim.Object.Rect, &locPrim);
locPrim.Object.Rect.extent.width = pClipRect->extent.width;
}
if (locPrim.Object.Rect.corner.y == RectPtr->corner.y)
{
locPrim.Object.Rect.extent.height = 1;
DrawGraphicsFunc (&locPrim.Object.Rect, &locPrim);
locPrim.Object.Rect.extent.height = pClipRect->extent.height;
}
if ((x = locPrim.Object.Rect.corner.x
+ locPrim.Object.Rect.extent.width) ==
RectPtr->corner.x + RectPtr->extent.width)
{
locPrim.Object.Rect.corner.x = x - 1;
locPrim.Object.Rect.extent.width = 1;
DrawGraphicsFunc (&locPrim.Object.Rect, &locPrim);
locPrim.Object.Rect.corner.x = pClipRect->corner.x;
locPrim.Object.Rect.extent.width = pClipRect->extent.width;
}
if ((y = locPrim.Object.Rect.corner.y
+ locPrim.Object.Rect.extent.height) ==
RectPtr->corner.y + RectPtr->extent.height)
{
locPrim.Object.Rect.corner.y = y - 1;
locPrim.Object.Rect.extent.height = 1;
DrawGraphicsFunc (&locPrim.Object.Rect, &locPrim);
}
}
+3 -249
View File
@@ -30,240 +30,10 @@ SetGraphicScale (int scale)
gscale = scale; gscale = scale;
} }
static void int
blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) GetGraphicScale ()
{ {
TFB_Image *img; return gscale;
PFRAME_DESC SrcFramePtr;
SrcFramePtr = (PFRAME_DESC)PrimPtr->Object.Stamp.frame;
if (!SrcFramePtr->image)
{
fprintf (stderr, "Non-existent image to blt()\n");
return;
}
img = SrcFramePtr->image;
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
int x, y;
BOOLEAN scaled, paletted, filled;
TFB_Palette palette[256];
LockMutex (img->mutex);
x = pClipRect->corner.x - GetFrameHotX (_CurFramePtr);
y = pClipRect->corner.y - GetFrameHotY (_CurFramePtr);
scaled = filled = FALSE;
if (gscale != 0 && gscale != 256)
{
x += (GetFrameHotX (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
y += (GetFrameHotY (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
scaled = TRUE;
if (img->ScaledImg)
{
if (img->scale != gscale)
{
SDL_FreeSurface(img->ScaledImg);
img->ScaledImg = NULL;
}
}
if (!img->ScaledImg)
{
// atleast melee zooming uses this
SDL_Surface *new_surf;
img->scale = gscale;
img->dirty = FALSE;
new_surf = zoomSurface (img->NormalImg, gscale / 256.0f,
gscale / 256.0f, SMOOTHING_OFF);
if (new_surf)
{
if (!new_surf->format->palette)
{
img->ScaledImg = TFB_DrawCanvas_ToScreenFormat (new_surf);
}
else
{
img->ScaledImg = new_surf;
SDL_SetColors (img->ScaledImg, (SDL_Color *)img->Palette, 0, 256);
if (((SDL_Surface *)img->NormalImg)->flags & SDL_SRCCOLORKEY)
{
SDL_SetColorKey (img->ScaledImg, SDL_SRCCOLORKEY,
((SDL_Surface *)img->NormalImg)->format->colorkey);
}
}
}
else
{
fprintf (stderr, "blt(): zoomSurface failed\n");
}
}
}
paletted = FALSE;
if (GetPrimType (PrimPtr) == STAMPFILL_PRIM)
{
int r, g, b;
DWORD c32k;
c32k = GetPrimColor (PrimPtr) >> 8; // shift out color index
r = (c32k >> (10 - (8 - 5))) & 0xF8;
g = (c32k >> (5 - (8 - 5))) & 0xF8;
b = (c32k << (8 - 5)) & 0xF8;
palette[0].r = r;
palette[0].g = g;
palette[0].b = b;
filled = TRUE;
}
else
{
if (((SDL_Surface *)img->NormalImg)->format->palette && img->colormap_index != -1)
{
TFB_ColorMapToRGB (palette, img->colormap_index);
paletted = TRUE;
}
}
UnlockMutex (img->mutex);
if (filled)
{
TFB_DrawScreen_FilledImage (img, x, y,
scaled, palette[0].r,
palette[0].g, palette[0].b,
TFB_SCREEN_MAIN);
}
else
{
TFB_DrawScreen_Image (img, x, y, scaled,
(paletted ? palette : NULL),
TFB_SCREEN_MAIN);
}
}
else
{
TFB_Image *dst_img;
dst_img = _CurFramePtr->image;
if (GetPrimType (PrimPtr) == STAMPFILL_PRIM)
{
int r, g, b;
DWORD c32k;
c32k = GetPrimColor (PrimPtr) >> 8; // shift out color index
r = (c32k >> (10 - (8 - 5))) & 0xF8;
g = (c32k >> (5 - (8 - 5))) & 0xF8;
b = (c32k << (8 - 5)) & 0xF8;
TFB_DrawImage_FilledImage(img,
pClipRect->corner.x - GetFrameHotX (_CurFramePtr),
pClipRect->corner.y - GetFrameHotY (_CurFramePtr),
FALSE, r, g, b, dst_img);
} else {
TFB_DrawImage_Image(img,
pClipRect->corner.x - GetFrameHotX (_CurFramePtr),
pClipRect->corner.y - GetFrameHotY (_CurFramePtr),
FALSE, img->Palette, dst_img);
}
}
}
static void
fillrect_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
{
int r, g, b;
DWORD c32k;
c32k = GetPrimColor (PrimPtr) >> 8; //shift out color index
r = (c32k >> (10 - (8 - 5))) & 0xF8;
g = (c32k >> (5 - (8 - 5))) & 0xF8;
b = (c32k << (8 - 5)) & 0xF8;
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
RECT rect;
rect.corner.x = pClipRect->corner.x - GetFrameHotX (_CurFramePtr);
rect.corner.y = pClipRect->corner.y - GetFrameHotY (_CurFramePtr);
rect.extent.width = pClipRect->extent.width;
rect.extent.height = pClipRect->extent.height;
if (gscale && GetPrimType (PrimPtr) != POINT_PRIM)
{
rect.extent.width = (rect.extent.width * gscale) >> 8;
rect.extent.height = (rect.extent.height * gscale) >> 8;
rect.corner.x += (pClipRect->extent.width -
rect.extent.width) >> 1;
rect.corner.y += (pClipRect->extent.height -
rect.extent.height) >> 1;
}
TFB_DrawScreen_Rect (&rect, r, g, b, TFB_SCREEN_MAIN);
}
else
{
SDL_Rect SDLRect;
TFB_Image *img;
img = _CurFramePtr->image;
LockMutex (img->mutex);
SDLRect.x = (short) (pClipRect->corner.x -
GetFrameHotX (_CurFramePtr));
SDLRect.y = (short) (pClipRect->corner.y -
GetFrameHotY (_CurFramePtr));
SDLRect.w = (short) pClipRect->extent.width;
SDLRect.h = (short) pClipRect->extent.height;
SDL_FillRect (img->NormalImg, &SDLRect, SDL_MapRGB (((SDL_Surface *)img->NormalImg)->format, r, g, b));
UnlockMutex (img->mutex);
}
}
static void
cmap_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
{
fprintf (stderr, "Unimplemented function activated: cmap_blt()\n");
}
static void
line_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
{
int x1,y1,x2,y2;
int r, g, b;
DWORD c32k;
c32k = GetPrimColor (PrimPtr) >> 8; // shift out color index
r = (c32k >> (10 - (8 - 5))) & 0xF8;
g = (c32k >> (5 - (8 - 5))) & 0xF8;
b = (c32k << (8 - 5)) & 0xF8;
x1=PrimPtr->Object.Line.first.x - GetFrameHotX (_CurFramePtr);
y1=PrimPtr->Object.Line.first.y - GetFrameHotY (_CurFramePtr);
x2=PrimPtr->Object.Line.second.x - GetFrameHotX (_CurFramePtr);
y2=PrimPtr->Object.Line.second.y - GetFrameHotY (_CurFramePtr);
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawScreen_Line (x1, y1, x2, y2, r, g, b, TFB_SCREEN_MAIN);
}
else
{
// Maybe we should do something about this?
}
} }
static void static void
@@ -291,20 +61,6 @@ alloc_image (COUNT NumFrames, DRAWABLE_TYPE DrawableType, CREATE_FLAGS
return AllocDrawable (NumFrames, 0); return AllocDrawable (NumFrames, 0);
} }
void (*func_array[]) (PRECT pClipRect, PRIMITIVEPTR PrimPtr) =
{
fillrect_blt,
blt,
blt,
line_blt,
_text_blt,
cmap_blt,
_rect_blt,
fillrect_blt,
_fillpoly_blt,
_fillpoly_blt,
};
static DISPLAY_INTERFACE DisplayInterface = static DISPLAY_INTERFACE DisplayInterface =
{ {
WANT_MASK, WANT_MASK,
@@ -315,8 +71,6 @@ static DISPLAY_INTERFACE DisplayInterface =
alloc_image, alloc_image,
read_screen, read_screen,
func_array,
}; };
void void
+71 -7
View File
@@ -2,6 +2,8 @@
#include "sdl_common.h" #include "sdl_common.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/graphics/sdl/primitives.h" #include "libs/graphics/sdl/primitives.h"
#include "libs/graphics/tfb_draw.h"
#include "rotozoom.h"
typedef SDL_Surface *NativeCanvas; typedef SDL_Surface *NativeCanvas;
@@ -32,7 +34,7 @@ TFB_DrawCanvas_Rect (PRECT rect, int r, int g, int b, TFB_Canvas target)
} }
void void
TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, TFB_Canvas target) TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Canvas target)
{ {
SDL_Rect targetRect; SDL_Rect targetRect;
SDL_Surface *surf; SDL_Surface *surf;
@@ -47,8 +49,11 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette
targetRect.x = x; targetRect.x = x;
targetRect.y = y; targetRect.y = y;
if (scaled) if (scale != 0 && scale != 256)
{
// TFB_DrawImage_FixScaling (img, scale);
surf = img->ScaledImg; surf = img->ScaledImg;
}
else else
surf = img->NormalImg; surf = img->NormalImg;
@@ -69,7 +74,7 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette
} }
void void
TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r, int g, int b, TFB_Canvas target) TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Canvas target)
{ {
SDL_Rect targetRect; SDL_Rect targetRect;
SDL_Surface *surf; SDL_Surface *surf;
@@ -87,8 +92,11 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r,
targetRect.x = x; targetRect.x = x;
targetRect.y = y; targetRect.y = y;
if (scaled) if (scale != 0 && scale != 256)
{
// TFB_DrawImage_FixScaling (img, scale);
surf = img->ScaledImg; surf = img->ScaledImg;
}
else else
surf = img->NormalImg; surf = img->NormalImg;
@@ -178,15 +186,71 @@ TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas)
TFB_Canvas TFB_Canvas
TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas) TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas)
{ {
SDL_Surface *result = TFB_DisplayFormatAlpha (canvas); SDL_Surface *result = TFB_DisplayFormatAlpha ((SDL_Surface *)canvas);
if (result == NULL) if (result == NULL)
{ {
fprintf (stderr, "WARNING: Could not convert sprite-canvas to display format. Expect performance penalties.\n"); fprintf (stderr, "WARNING: Could not convert sprite-canvas to display format.\n");
return canvas; return canvas;
} }
else else
{ {
TFB_DrawCanvas_Delete(canvas); TFB_DrawCanvas_Delete (canvas);
return result; return result;
} }
return canvas;
}
TFB_Canvas
TFB_DrawCanvas_New_Scaled (TFB_Canvas src, int scale)
{
SDL_Surface *new_surf;
new_surf = zoomSurface ((SDL_Surface *)src, scale / 256.0f,
scale / 256.0f, SMOOTHING_OFF);
if (new_surf)
{
if (!TFB_DrawCanvas_IsPaletted (new_surf))
{
new_surf = TFB_DrawCanvas_ToScreenFormat (new_surf);
}
return new_surf;
}
fprintf (stderr, "TFB_DrawCanvas_New_Scaled failed\n");
return NULL;
}
BOOLEAN
TFB_DrawCanvas_IsPaletted (TFB_Canvas canvas)
{
return ((SDL_Surface *)canvas)->format->palette != NULL;
}
void
TFB_DrawCanvas_SetPalette (TFB_Canvas target, TFB_Palette *palette)
{
SDL_SetColors ((SDL_Surface *)target, (SDL_Color *)palette, 0, 256);
}
int
TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas)
{
if (((SDL_Surface *)canvas)->flags & SDL_SRCCOLORKEY)
return ((SDL_Surface *)canvas)->format->colorkey;
return -1;
}
void
TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int index)
{
if (index >= 0)
{
SDL_SetColorKey ((SDL_Surface *)canvas, SDL_SRCCOLORKEY, index);
}
else
{
SDL_SetColorKey ((SDL_Surface *)canvas, 0, 0);
}
} }
+1 -1
View File
@@ -918,7 +918,7 @@ SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smoo
* Call the 8bit transformation routine to do the zooming * Call the 8bit transformation routine to do the zooming
*/ */
zoomSurfaceY(rz_src, rz_dst); zoomSurfaceY(rz_src, rz_dst);
SDL_SetColorKey(rz_dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, rz_src->format->colorkey); SDL_SetColorKey(rz_dst, SDL_SRCCOLORKEY, rz_src->format->colorkey);
} }
/* /*
* Unlock source surface * Unlock source surface
@@ -509,7 +509,7 @@ TFB_FlushGraphics () // Only call from main thread!!
int x = DC.data.image.x; int x = DC.data.image.x;
int y = DC.data.image.y; int y = DC.data.image.y;
if (DC.data.image.UseScaling) if (DC.data.image.scale)
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y); TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
else else
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y); TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
@@ -524,7 +524,7 @@ TFB_FlushGraphics () // Only call from main thread!!
} }
TFB_DrawCanvas_Image (DC_image, x, y, TFB_DrawCanvas_Image (DC_image, x, y,
DC.data.image.UseScaling, pal, DC.data.image.scale, pal,
SDL_Screens[DC.data.image.destBuffer]); SDL_Screens[DC.data.image.destBuffer]);
break; break;
@@ -535,13 +535,13 @@ TFB_FlushGraphics () // Only call from main thread!!
int x = DC.data.filledimage.x; int x = DC.data.filledimage.x;
int y = DC.data.filledimage.y; int y = DC.data.filledimage.y;
if (DC.data.filledimage.UseScaling) if (DC.data.filledimage.scale)
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y); TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
else else
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y); TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, DC.data.filledimage.x, DC.data.filledimage.y, TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, DC.data.filledimage.x, DC.data.filledimage.y,
DC.data.filledimage.UseScaling, DC.data.filledimage.r, DC.data.filledimage.g, DC.data.filledimage.scale, DC.data.filledimage.r, DC.data.filledimage.g,
DC.data.filledimage.b, SDL_Screens[DC.data.filledimage.destBuffer]); DC.data.filledimage.b, SDL_Screens[DC.data.filledimage.destBuffer]);
break; break;
} }
-47
View File
@@ -1,47 +0,0 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
void
DrawStamp (PSTAMP lpStamp)
{
SetPrimType (&_locPrim, STAMP_PRIM);
_locPrim.Object.Stamp = *lpStamp;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void
DrawFilledStamp (PSTAMP lpStamp)
{
SetPrimType (&_locPrim, STAMPFILL_PRIM);
_locPrim.Object.Stamp = *lpStamp;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void
DrawStampCMap (PSTAMP_CMAP lpStampCMap)
{
SetPrimType (&_locPrim, STAMPCMAP_PRIM);
_locPrim.Object.StampCMap = *lpStampCMap;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
+38 -8
View File
@@ -76,7 +76,7 @@ TFB_FlushPaletteCache ()
} }
void void
TFB_DrawScreen_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, SCREEN dest) TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, SCREEN dest)
{ {
TFB_DrawCommand DC; TFB_DrawCommand DC;
@@ -84,7 +84,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette
DC.data.image.image = img; DC.data.image.image = img;
DC.data.image.x = x; DC.data.image.x = x;
DC.data.image.y = y; DC.data.image.y = y;
DC.data.image.UseScaling = scaled; DC.data.image.scale = (scale == 256) ? 0 : scale;
if (palette != NULL) if (palette != NULL)
{ {
@@ -121,7 +121,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette
} }
void void
TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r, int g, int b, SCREEN dest) TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, SCREEN dest)
{ {
TFB_DrawCommand DC; TFB_DrawCommand DC;
@@ -129,7 +129,7 @@ TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r,
DC.data.filledimage.image = img; DC.data.filledimage.image = img;
DC.data.filledimage.x = x; DC.data.filledimage.x = x;
DC.data.filledimage.y = y; DC.data.filledimage.y = y;
DC.data.filledimage.UseScaling = scaled; DC.data.filledimage.scale = (scale == 256) ? 0 : scale;
DC.data.filledimage.r = r; DC.data.filledimage.r = r;
DC.data.filledimage.g = g; DC.data.filledimage.g = g;
DC.data.filledimage.b = b; DC.data.filledimage.b = b;
@@ -226,19 +226,19 @@ TFB_DrawImage_Rect (PRECT rect, int r, int g, int b, TFB_Image *image)
} }
void void
TFB_DrawImage_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, TFB_Image *target) TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Image *target)
{ {
LockMutex (target->mutex); LockMutex (target->mutex);
TFB_DrawCanvas_Image (img, x, y, scaled, palette, target->NormalImg); TFB_DrawCanvas_Image (img, x, y, scale, palette, target->NormalImg);
target->dirty = TRUE; target->dirty = TRUE;
UnlockMutex (target->mutex); UnlockMutex (target->mutex);
} }
void void
TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r, int g, int b, TFB_Image *target) TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Image *target)
{ {
LockMutex (target->mutex); LockMutex (target->mutex);
TFB_DrawCanvas_FilledImage (img, x, y, scaled, r, g, b, target->NormalImg); TFB_DrawCanvas_FilledImage (img, x, y, scale, r, g, b, target->NormalImg);
target->dirty = TRUE; target->dirty = TRUE;
UnlockMutex (target->mutex); UnlockMutex (target->mutex);
} }
@@ -290,3 +290,33 @@ TFB_DrawImage_Delete (TFB_Image *image)
HFree (image); HFree (image);
} }
void
TFB_DrawImage_FixScaling (TFB_Image *image, int target)
{
if (image->ScaledImg)
{
if (image->scale != target)
{
TFB_DrawCanvas_Delete(image->ScaledImg);
image->ScaledImg = NULL;
}
}
if (!image->ScaledImg)
{
image->scale = target;
image->dirty = FALSE;
image->ScaledImg = TFB_DrawCanvas_New_Scaled (image->NormalImg, target);
if (TFB_DrawCanvas_IsPaletted (image->ScaledImg))
{
int colorkey = TFB_DrawCanvas_GetTransparentIndex (image->NormalImg);
TFB_DrawCanvas_SetPalette (image->ScaledImg, image->Palette);
if (colorkey != -1)
{
TFB_DrawCanvas_SetTransparentIndex (image->ScaledImg, colorkey);
}
}
}
}
+13 -6
View File
@@ -55,9 +55,9 @@ typedef struct tfb_image
void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest); void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest);
void TFB_DrawScreen_Rect (PRECT rect, int r, int g, int b, SCREEN dest); void TFB_DrawScreen_Rect (PRECT rect, int r, int g, int b, SCREEN dest);
void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, SCREEN dest); void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, SCREEN dest);
void TFB_DrawScreen_Copy (PRECT r, SCREEN src, SCREEN dest); void TFB_DrawScreen_Copy (PRECT r, SCREEN src, SCREEN dest);
void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r, int g, int b, SCREEN dest); void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, SCREEN dest);
void TFB_DrawScreen_CopyToImage (TFB_Image *img, PRECT lpRect, SCREEN src); void TFB_DrawScreen_CopyToImage (TFB_Image *img, PRECT lpRect, SCREEN src);
void TFB_DrawScreen_DeleteImage (TFB_Image *img); void TFB_DrawScreen_DeleteImage (TFB_Image *img);
void TFB_DrawScreen_WaitForSignal (void); void TFB_DrawScreen_WaitForSignal (void);
@@ -66,21 +66,28 @@ void TFB_FlushPaletteCache (void);
TFB_Image *TFB_DrawImage_New (TFB_Canvas canvas); TFB_Image *TFB_DrawImage_New (TFB_Canvas canvas);
void TFB_DrawImage_Delete (TFB_Image *image); void TFB_DrawImage_Delete (TFB_Image *image);
void TFB_DrawImage_FixScaling (TFB_Image *image, int target);
void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Image *dest); void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Image *dest);
void TFB_DrawImage_Rect (PRECT rect, int r, int g, int b, TFB_Image *image); void TFB_DrawImage_Rect (PRECT rect, int r, int g, int b, TFB_Image *image);
void TFB_DrawImage_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, TFB_Image *target); void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Image *target);
void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r, int g, int b, TFB_Image *target); void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Image *target);
TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha); TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha);
TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index); TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index);
TFB_Canvas TFB_DrawCanvas_New_Scaled (TFB_Canvas src, int scale);
TFB_Canvas TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas); TFB_Canvas TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas);
BOOLEAN TFB_DrawCanvas_IsPaletted (TFB_Canvas canvas);
void TFB_DrawCanvas_Delete (TFB_Canvas canvas); void TFB_DrawCanvas_Delete (TFB_Canvas canvas);
void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Canvas dest); void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Canvas dest);
void TFB_DrawCanvas_Rect (PRECT rect, int r, int g, int b, TFB_Canvas image); void TFB_DrawCanvas_Rect (PRECT rect, int r, int g, int b, TFB_Canvas image);
void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, TFB_Canvas target); void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Canvas target);
void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, BOOLEAN scaled, int r, int g, int b, TFB_Canvas target); void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Canvas target);
TFB_Palette *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas); TFB_Palette *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas);
void TFB_DrawCanvas_SetPalette (TFB_Canvas target, TFB_Palette *palette);
int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas);
void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int index);
#endif #endif
+216
View File
@@ -0,0 +1,216 @@
// Copyright Michael Martin, 2003
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* The original Primitive routines do various elaborate checks to
* ensure we're within bounds for the clipping. Since clipping is
* handled by the underlying TFB_Canvas implementation, we need not
* worry about this. */
#include "gfxintrn.h"
#include "tfb_draw.h"
#include "tfb_prim.h"
void
TFB_Prim_Point (PPOINT p, TFB_Palette *color)
{
RECT r;
r.corner.x = p->x - GetFrameHotX (_CurFramePtr);
r.corner.y = p->y - GetFrameHotY (_CurFramePtr);
r.extent.width = r.extent.height = 1;
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == 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);
}
void
TFB_Prim_Rect (PRECT r, TFB_Palette *color)
{
RECT arm;
int gscale;
gscale = GetGraphicScale ();
if (!gscale)
gscale = 256;
arm = *r;
arm.extent.width = r->extent.width;
arm.extent.height = 1;
TFB_Prim_FillRect (&arm, color);
arm.extent.height = r->extent.height;
arm.extent.width = 1;
TFB_Prim_FillRect (&arm, color);
arm.corner.x += ((r->extent.width * gscale) >> 8) - 1;
TFB_Prim_FillRect (&arm, color);
arm.corner.x = r->corner.x;
arm.corner.y += ((r->extent.height * gscale) >> 8) - 1;
arm.extent.width = r->extent.width;
arm.extent.height = 1;
TFB_Prim_FillRect (&arm, color);
}
void
TFB_Prim_FillRect (PRECT r, TFB_Palette *color)
{
RECT rect;
int gscale;
rect.corner.x = r->corner.x - GetFrameHotX (_CurFramePtr);
rect.corner.y = r->corner.y - GetFrameHotY (_CurFramePtr);
rect.extent.width = r->extent.width;
rect.extent.height = r->extent.height;
gscale = GetGraphicScale ();
if (gscale)
{
rect.extent.width = (rect.extent.width * gscale) >> 8;
rect.extent.height = (rect.extent.height * gscale) >> 8;
rect.corner.x += (r->extent.width -
rect.extent.width) >> 1;
rect.corner.y += (r->extent.height -
rect.extent.height) >> 1;
}
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == 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);
}
void
TFB_Prim_Line (PLINE line, TFB_Palette *color)
{
int x1, y1, x2, y2;
x1=line->first.x - GetFrameHotX (_CurFramePtr);
y1=line->first.y - GetFrameHotY (_CurFramePtr);
x2=line->second.x - GetFrameHotX (_CurFramePtr);
y2=line->second.y - GetFrameHotY (_CurFramePtr);
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == 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);
}
void
TFB_Prim_Stamp (PSTAMP stmp)
{
int x, y;
PFRAME_DESC SrcFramePtr;
TFB_Image *img;
BOOLEAN paletted;
TFB_Palette palette[256];
int gscale;
SrcFramePtr = (PFRAME_DESC)stmp->frame;
img = SrcFramePtr->image;
gscale = GetGraphicScale ();
if (!img)
{
fprintf (stderr, "Non-existent image to TFB_Prim_Stamp()\n");
return;
}
LockMutex (img->mutex);
x = stmp->origin.x - GetFrameHotX (_CurFramePtr) - GetFrameHotX (SrcFramePtr);
y = stmp->origin.y - GetFrameHotY (_CurFramePtr) - GetFrameHotY (SrcFramePtr);
paletted = FALSE;
if (gscale != 0 && gscale != 256)
{
TFB_DrawImage_FixScaling (img, gscale);
x += (GetFrameHotX (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
y += (GetFrameHotY (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
}
if (TFB_DrawCanvas_IsPaletted(img->NormalImg) && img->colormap_index != -1)
{
TFB_ColorMapToRGB (palette, img->colormap_index);
paletted = TRUE;
}
UnlockMutex (img->mutex);
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawScreen_Image (img, x, y, gscale, (paletted ? palette : NULL),
TFB_SCREEN_MAIN);
}
else
{
TFB_DrawImage_Image (img, x, y, gscale, (paletted ? palette : NULL),
_CurFramePtr->image);
}
}
void
TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
{
int x, y;
PFRAME_DESC SrcFramePtr;
TFB_Image *img;
int r, g, b;
int gscale;
SrcFramePtr = (PFRAME_DESC)stmp->frame;
img = SrcFramePtr->image;
gscale = GetGraphicScale ();
if (!img)
{
fprintf (stderr, "Non-existent image to TFB_Prim_StampFill()\n");
return;
}
LockMutex (img->mutex);
x = stmp->origin.x - GetFrameHotX (_CurFramePtr) - GetFrameHotX (SrcFramePtr);
y = stmp->origin.y - GetFrameHotY (_CurFramePtr) - GetFrameHotY (SrcFramePtr);
r = color->r;
g = color->g;
b = color->b;
if (gscale != 0 && gscale != 256)
{
TFB_DrawImage_FixScaling (img, gscale);
x += (GetFrameHotX (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
y += (GetFrameHotY (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
}
UnlockMutex (img->mutex);
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawScreen_FilledImage (img, x, y, gscale, r, g, b,
TFB_SCREEN_MAIN);
}
else
{
TFB_DrawImage_FilledImage (img, x, y, gscale, r, g, b,
_CurFramePtr->image);
}
}
// Text rendering is in font.c, under the name _text_blt
@@ -1,4 +1,4 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002 // Copyright Michael Martin, 2003
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -16,14 +16,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "gfxintrn.h" #include "gfxlib.h"
#include "tfb_draw.h"
void
DrawLine (PLINE lpLine)
{
SetPrimType (&_locPrim, LINE_PRIM);
_locPrim.Object.Line = *lpLine;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
}
void TFB_Prim_Line (PLINE line, TFB_Palette *color);
void TFB_Prim_Point (PPOINT p, TFB_Palette *color);
void TFB_Prim_Rect (PRECT r, TFB_Palette *color);
void TFB_Prim_FillRect (PRECT r, TFB_Palette *color);
void TFB_Prim_Stamp (PSTAMP stamp);
void TFB_Prim_StampFill (PSTAMP stamp, TFB_Palette *color);
+3 -3
View File
@@ -37,7 +37,7 @@ InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME_DESC *f)
scope_bg = TFB_DrawImage_New (scope_bg_canvas); scope_bg = TFB_DrawImage_New (scope_bg_canvas);
scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, f->image->Palette, -1); scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, f->image->Palette, -1);
scope_surf = TFB_DrawImage_New (scope_surf_canvas); scope_surf = TFB_DrawImage_New (scope_surf_canvas);
TFB_DrawImage_Image (f->image, 0, 0, FALSE, NULL, scope_bg); TFB_DrawImage_Image (f->image, 0, 0, 0, NULL, scope_bg);
scope_init = 1; scope_init = 1;
} }
} }
@@ -67,7 +67,7 @@ Oscilloscope (DWORD grab_data)
if (!grab_data) if (!grab_data)
return; return;
TFB_DrawImage_Image (scope_bg, 0, 0, FALSE, NULL, scope_surf); TFB_DrawImage_Image (scope_bg, 0, 0, 0, NULL, scope_surf);
if (GetSoundData (scope_data)) if (GetSoundData (scope_data))
{ {
int i, r, g, b; int i, r, g, b;
@@ -77,7 +77,7 @@ Oscilloscope (DWORD grab_data)
for (i = 0; i < RADAR_WIDTH - 1; ++i) for (i = 0; i < RADAR_WIDTH - 1; ++i)
TFB_DrawImage_Line (i, scope_data[i], i + 1, scope_data[i + 1], r, g, b, scope_surf); TFB_DrawImage_Line (i, scope_data[i], i + 1, scope_data[i + 1], r, g, b, scope_surf);
} }
TFB_DrawImage_Image (scope_surf, 0, 0, FALSE, NULL, scope_frame->image); TFB_DrawImage_Image (scope_surf, 0, 0, 0, NULL, scope_frame->image);
s.frame = scope_frame; s.frame = scope_frame;
s.origin.x = s.origin.y = 0; s.origin.x = s.origin.y = 0;
-3
View File
@@ -221,7 +221,6 @@ DoInstallModule (INPUT_STATE InputState, PMENU_STATE pMS)
SetSemaphore (GraphicsSem); SetSemaphore (GraphicsSem);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
ClearSISRect (CLEAR_SIS_RADAR); ClearSISRect (CLEAR_SIS_RADAR);
SetFlashRect (NULL_PTR, (FRAME)0); SetFlashRect (NULL_PTR, (FRAME)0);
goto InitFlash; goto InitFlash;
@@ -608,7 +607,6 @@ DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS)
DrawSISTitle (GAME_STRING (STARBASE_STRING_BASE)); DrawSISTitle (GAME_STRING (STARBASE_STRING_BASE));
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
DrawStamp (&s); DrawStamp (&s);
DestroyDrawable (ReleaseDrawable (s.frame)); DestroyDrawable (ReleaseDrawable (s.frame));
@@ -691,7 +689,6 @@ DoOutfit (INPUT_STATE InputState, PMENU_STATE pMS)
} }
SetContext (StatusContext); SetContext (StatusContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
} }
else if ((InputState & DEVICE_BUTTON2) else if ((InputState & DEVICE_BUTTON2)
|| ((InputState & DEVICE_BUTTON1) || ((InputState & DEVICE_BUTTON1)
-2
View File
@@ -116,8 +116,6 @@ LoadPlanet (BOOLEAN IsDefined)
} }
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
s.frame = pSolarSysState->PlanetSideFrame[2]; s.frame = pSolarSysState->PlanetSideFrame[2];
if (s.frame) if (s.frame)
-1
View File
@@ -111,7 +111,6 @@ RenderTopography (BOOLEAN Reconstruct)
OldContext = SetContext (TaskContext); OldContext = SetContext (TaskContext);
OldFrame = SetContextFGFrame (pSolarSysState->TopoFrame); OldFrame = SetContextFGFrame (pSolarSysState->TopoFrame);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
if (pSolarSysState->XlatRef == 0) if (pSolarSysState->XlatRef == 0)
{ {
-7
View File
@@ -243,7 +243,6 @@ DrawStarMap (COUNT race_update, PRECT pClipRect)
STAMP s; STAMP s;
FRAME star_frame; FRAME star_frame;
STAR_DESCPTR SDPtr; STAR_DESCPTR SDPtr;
FRAME OldFrame;
BOOLEAN draw_cursor; BOOLEAN draw_cursor;
if (pClipRect == (PRECT)-1) if (pClipRect == (PRECT)-1)
@@ -269,11 +268,8 @@ DrawStarMap (COUNT race_update, PRECT pClipRect)
SetFrameHot (Screen, SetFrameHot (Screen,
MAKE_HOT_SPOT (pClipRect->corner.x, pClipRect->corner.y)); MAKE_HOT_SPOT (pClipRect->corner.x, pClipRect->corner.y));
} }
OldFrame = SetContextBGFrame ((FRAME)0);
BatchGraphics (); BatchGraphics ();
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
which_space = GET_GAME_STATE (ARILOU_SPACE_SIDE); which_space = GET_GAME_STATE (ARILOU_SPACE_SIDE);
if (which_space <= 1) if (which_space <= 1)
@@ -511,8 +507,6 @@ wprintf ("%s\n", buf);
SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0)); SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
} }
SetContextBGFrame (OldFrame);
if (race_update == 0) if (race_update == 0)
{ {
if (draw_cursor) if (draw_cursor)
@@ -1237,7 +1231,6 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS)
DrawSISTitle(GLOBAL_SIS(PlanetName)); DrawSISTitle(GLOBAL_SIS(PlanetName));
DrawStarBackGround(TRUE); DrawStarBackGround(TRUE);
OldContext = SetContext(SpaceContext); OldContext = SetContext(SpaceContext);
SetContextDrawState(DEST_PIXMAP | DRAW_REPLACE);
BatchGraphics(); BatchGraphics();
DrawPlanet(SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); DrawPlanet(SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0);
UnbatchGraphics(); UnbatchGraphics();
-3
View File
@@ -218,7 +218,6 @@ DoDiscoveryReport (SOUND ReadOutSounds)
{ {
POINT old_curs; POINT old_curs;
CONTEXT OldContext; CONTEXT OldContext;
FRAME OldFrame;
extern void DrawScannedObjects (BOOLEAN Reversed); extern void DrawScannedObjects (BOOLEAN Reversed);
if (pMenuState) if (pMenuState)
@@ -229,7 +228,6 @@ DoDiscoveryReport (SOUND ReadOutSounds)
} }
OldContext = SetContext (ScanContext); OldContext = SetContext (ScanContext);
OldFrame = SetContextBGFrame ((FRAME)0);
{ {
FONT OldFont; FONT OldFont;
@@ -250,7 +248,6 @@ DoDiscoveryReport (SOUND ReadOutSounds)
GetStringLength (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString)); GetStringLength (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString));
SetContextFont (OldFont); SetContextFont (OldFont);
} }
SetContextBGFrame (OldFrame);
#ifdef OLD #ifdef OLD
ClearDrawable (); ClearDrawable ();
if (pSolarSysState->MenuState.Initialized >= 3) if (pSolarSysState->MenuState.Initialized >= 3)
-6
View File
@@ -352,7 +352,6 @@ FreeSolarSys (void)
SetSemaphore (GraphicsSem); SetSemaphore (GraphicsSem);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextBGFrame ((FRAME)0);
StopMusic (); StopMusic ();
@@ -936,7 +935,6 @@ ScaleSystem (void)
GetContextClipRect (&r); GetContextClipRect (&r);
SetGraphicGrabOther (1); // to grab from hidden screen (since we haven't flipped yet) SetGraphicGrabOther (1); // to grab from hidden screen (since we haven't flipped yet)
LoadIntoExtraScreen (&r); LoadIntoExtraScreen (&r);
SetContextBGFrame ((FRAME)0);
SetGraphicGrabOther (0); SetGraphicGrabOther (0);
SetContextFGFrame (Screen); SetContextFGFrame (Screen);
@@ -1437,8 +1435,6 @@ LoadLanderData ();
DrawSISMessage (NULL_PTR); DrawSISMessage (NULL_PTR);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextFGFrame (Screen); SetContextFGFrame (Screen);
SetContextBGFrame ((FRAME)0);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContextBackGroundColor (BLACK_COLOR); SetContextBackGroundColor (BLACK_COLOR);
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);
@@ -1760,8 +1756,6 @@ DrawStarBackGround (BOOLEAN ForPlanet)
DWORD old_seed; DWORD old_seed;
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextBGFrame ((FRAME)0);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
SetContextBackGroundColor (BLACK_COLOR); SetContextBackGroundColor (BLACK_COLOR);
ClearDrawable (); ClearDrawable ();
-2
View File
@@ -183,8 +183,6 @@ TryAgain:
black_buf[0] = FadeAllToBlack; black_buf[0] = FadeAllToBlack;
SetContext (ScreenContext); SetContext (ScreenContext);
SetContextBGFrame ((FRAME)0);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
GLOBAL (CurrentActivity) |= CHECK_ABORT; GLOBAL (CurrentActivity) |= CHECK_ABORT;
if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0 if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
-2
View File
@@ -1216,8 +1216,6 @@ DoShipyard (INPUT_STATE InputState, PMENU_STATE pMS)
SetSemaphore (GraphicsSem); SetSemaphore (GraphicsSem);
SetContext (SpaceContext); SetContext (SpaceContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
s.origin.x = s.origin.y = 0; s.origin.x = s.origin.y = 0;
#ifdef USE_3DO_HANGAR #ifdef USE_3DO_HANGAR
DrawStamp (&s); DrawStamp (&s);
-1
View File
@@ -304,7 +304,6 @@ DoStarBase (INPUT_STATE InputState, PMENU_STATE pMS)
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
SetContext (ScreenContext); SetContext (ScreenContext);
SetContextDrawState (DEST_PIXMAP | DRAW_REPLACE);
ClearSemaphore (GraphicsSem); ClearSemaphore (GraphicsSem);