diff --git a/sc2/build/msvc6/UrQuanMasters.dsp b/sc2/build/msvc6/UrQuanMasters.dsp index 068f28174..1f8a7641c 100644 --- a/sc2/build/msvc6/UrQuanMasters.dsp +++ b/sc2/build/msvc6/UrQuanMasters.dsp @@ -290,10 +290,6 @@ SOURCE=..\..\src\libs\graphics\sdl\2xscalers_sse.c # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\sdl\3do_blt.c -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\sdl\3do_funcs.c # End Source File # Begin Source File @@ -439,10 +435,6 @@ SOURCE=..\..\src\libs\graphics\dcqueue.h # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\display.h -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\drawable.c # End Source File # Begin Source File diff --git a/sc2/src/libs/gfxlib.h b/sc2/src/libs/gfxlib.h index 651648b4c..c6ceab9b5 100644 --- a/sc2/src/libs/gfxlib.h +++ b/sc2/src/libs/gfxlib.h @@ -133,8 +133,14 @@ buildColorRgba (BYTE r, BYTE g, BYTE b, BYTE a) typedef BYTE CREATE_FLAGS; +// WANT_MASK is deprecated (and non-functional). It used to generate a bitmap +// of changed pixels for a target DRAWABLE, so that DRAW_SUBTRACTIVE could +// paint background pixels over them, i.e. a revert draw. The backgrounds +// are fully erased now instead. #define WANT_MASK (CREATE_FLAGS)(1 << 0) #define WANT_PIXMAP (CREATE_FLAGS)(1 << 1) +// MAPPED_TO_DISPLAY is deprecated but still checked by LoadDisplayPixmap(). +// Its former use was to indicate a pre-scaled graphic for the display. #define MAPPED_TO_DISPLAY (CREATE_FLAGS)(1 << 2) #define WANT_ALPHA (CREATE_FLAGS)(1 << 3) @@ -334,7 +340,7 @@ extern BOOLEAN InstallGraphicResTypes (void); extern DRAWABLE LoadGraphicFile (const char *pStr); extern FONT LoadFontFile (const char *pStr); extern void *LoadGraphicInstance (RESOURCE res); -extern DRAWABLE LoadDisplayPixmap (RECT *area, FRAME frame); +extern DRAWABLE LoadDisplayPixmap (const RECT *area, FRAME frame); extern FRAME SetContextFontEffect (FRAME EffectFrame); extern FONT SetContextFont (FONT Font); extern BOOLEAN DestroyFont (FONT FontRef); diff --git a/sc2/src/libs/graphics/context.h b/sc2/src/libs/graphics/context.h index 6a61777bb..43f6f014d 100644 --- a/sc2/src/libs/graphics/context.h +++ b/sc2/src/libs/graphics/context.h @@ -117,15 +117,11 @@ extern GRAPHICS_STATUS _GraphicsStatusFlags; #define GRAPHICS_VISIBLE (GRAPHICS_STATUS)(1 << 1) #define CONTEXT_ACTIVE (GRAPHICS_STATUS)(1 << 2) #define DRAWABLE_ACTIVE (GRAPHICS_STATUS)(1 << 3) -#define DISPLAY_ACTIVE (GRAPHICS_STATUS)(1 << 5) #define DeactivateGraphics() (_GraphicsStatusFlags &= ~GRAPHICS_ACTIVE) #define ActivateGraphics() (_GraphicsStatusFlags |= GRAPHICS_ACTIVE) #define GraphicsActive() (_GraphicsStatusFlags & GRAPHICS_ACTIVE) #define DeactivateVisible() (_GraphicsStatusFlags &= ~GRAPHICS_VISIBLE) #define ActivateVisible() (_GraphicsStatusFlags |= GRAPHICS_VISIBLE) -#define DeactivateDisplay() (_GraphicsStatusFlags &= ~DISPLAY_ACTIVE) -#define ActivateDisplay() (_GraphicsStatusFlags |= DISPLAY_ACTIVE) -#define DisplayActive() (_GraphicsStatusFlags & DISPLAY_ACTIVE) #define DeactivateContext() (_GraphicsStatusFlags &= ~CONTEXT_ACTIVE) #define ActivateContext() (_GraphicsStatusFlags |= CONTEXT_ACTIVE) #define ContextActive() (_GraphicsStatusFlags & CONTEXT_ACTIVE) @@ -133,10 +129,8 @@ extern GRAPHICS_STATUS _GraphicsStatusFlags; #define ActivateDrawable() (_GraphicsStatusFlags |= DRAWABLE_ACTIVE) #define DrawableActive() (_GraphicsStatusFlags & DRAWABLE_ACTIVE) -#define SYSTEM_ACTIVE (GRAPHICS_STATUS)( \ - DISPLAY_ACTIVE | CONTEXT_ACTIVE | \ - DRAWABLE_ACTIVE \ - ) +#define SYSTEM_ACTIVE (GRAPHICS_STATUS)(CONTEXT_ACTIVE | DRAWABLE_ACTIVE) + #define GraphicsSystemActive() \ ((_GraphicsStatusFlags & SYSTEM_ACTIVE) == SYSTEM_ACTIVE) #define GraphicsStatus() \ diff --git a/sc2/src/libs/graphics/display.h b/sc2/src/libs/graphics/display.h deleted file mode 100644 index c5ea7beef..000000000 --- a/sc2/src/libs/graphics/display.h +++ /dev/null @@ -1,50 +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. - */ - -#ifndef _DISPLAY_H -#define _DISPLAY_H - -typedef struct -{ - CREATE_FLAGS DisplayFlags; - - BYTE DisplayDepth; - COUNT DisplayWidth; - COUNT DisplayHeight; - - DRAWABLE (*alloc_image) (COUNT NumFrames, DRAWABLE_TYPE DrawableType, - CREATE_FLAGS flags, SIZE width, SIZE height); - - void (*read_display) (RECT *pRect, FRAME DstFramePtr); - -} DISPLAY_INTERFACE; - -extern DISPLAY_INTERFACE *_pCurDisplay; - -extern void (* mask_func_array[]) (RECT *pClipRect, PRIMITIVE *PrimPtr); - -#define AllocDrawableImage (*_pCurDisplay->alloc_image) -#define ReadDisplay (*_pCurDisplay->read_display) - -#define GetDisplayFlags() (_pCurDisplay->DisplayFlags) -#define GetDisplayDepth() (_pCurDisplay->DisplayDepth) -#define GetDisplayWidth() (_pCurDisplay->DisplayWidth) -#define GetDisplayHeight() (_pCurDisplay->DisplayHeight) - -#endif /* _DISPLAY_H */ - diff --git a/sc2/src/libs/graphics/drawable.c b/sc2/src/libs/graphics/drawable.c index e50648787..d3282686f 100644 --- a/sc2/src/libs/graphics/drawable.c +++ b/sc2/src/libs/graphics/drawable.c @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gfxintrn.h" +#include "libs/gfxlib.h" +#include "libs/graphics/context.h" +#include "libs/graphics/drawable.h" #include "libs/memlib.h" #include "tfb_draw.h" #include @@ -61,17 +63,17 @@ CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth, SIZE *pheight) { DRAWABLE Drawable; - if (!DisplayActive ()) - return (0); - + // TODO: ScreenWidth and ScreenHeight should be passed in + // instead of returned. Drawable = _request_drawable (1, SCREEN_DRAWABLE, - (CreateFlags & (WANT_PIXMAP | (GetDisplayFlags () & WANT_MASK))), - GetDisplayWidth (), GetDisplayHeight ()); + (CreateFlags & (WANT_PIXMAP | WANT_MASK)), + ScreenWidth, ScreenHeight); if (Drawable) { FRAME F; - if ((F = CaptureDrawable (Drawable)) == 0) + F = CaptureDrawable (Drawable); + if (F == 0) DestroyDrawable (Drawable); else { @@ -126,9 +128,6 @@ CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width, SIZE height, COUNT { DRAWABLE Drawable; - if (!DisplayActive ()) - return (0); - Drawable = _request_drawable (num_frames, RAM_DRAWABLE, (CreateFlags & (WANT_MASK | WANT_PIXMAP | WANT_ALPHA | MAPPED_TO_DISPLAY)), diff --git a/sc2/src/libs/graphics/gfx_common.c b/sc2/src/libs/graphics/gfx_common.c index ceee09df3..e357d18c6 100644 --- a/sc2/src/libs/graphics/gfx_common.c +++ b/sc2/src/libs/graphics/gfx_common.c @@ -23,10 +23,6 @@ #include "libs/misc.h" // for TFB_DEBUG_HALT -DISPLAY_INTERFACE *_pCurDisplay; //Not a function. Probably has to be initialized... - -void (*mask_func_array[]) (RECT *pClipRect, PRIMITIVE *PrimPtr) - = { 0 }; int ScreenWidth; int ScreenHeight; diff --git a/sc2/src/libs/graphics/gfxintrn.h b/sc2/src/libs/graphics/gfxintrn.h index 84351dc80..c34f6142c 100644 --- a/sc2/src/libs/graphics/gfxintrn.h +++ b/sc2/src/libs/graphics/gfxintrn.h @@ -27,7 +27,6 @@ #include "context.h" #include "drawable.h" #include "font.h" -#include "display.h" #endif /* _GFXINTRN_H */ diff --git a/sc2/src/libs/graphics/loaddisp.c b/sc2/src/libs/graphics/loaddisp.c index c1e88e34f..ccc7919d5 100644 --- a/sc2/src/libs/graphics/loaddisp.c +++ b/sc2/src/libs/graphics/loaddisp.c @@ -16,42 +16,50 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "gfxintrn.h" - - -/* - LoadDisplay---Drawable - - Allocate a chunk of memory and read from the display into that - chunk of memory. - - - LoadDisplayPixmapDrawable() - LoadDisplayMaskDrawable() - LoadDisplayPixmapMaskDrawable() - -*/ +#include "libs/gfxlib.h" +#include "libs/graphics/drawable.h" +#include "libs/log.h" +// Reads a piece of screen into a passed FRAME or a newly created one DRAWABLE -LoadDisplayPixmap (RECT *area, FRAME frame) +LoadDisplayPixmap (const RECT *area, FRAME frame) { + // TODO: This should just return a FRAME instead of DRAWABLE DRAWABLE buffer = GetFrameParentDrawable (frame); - COUNT index = GetFrameIndex (frame); + COUNT index; - if (buffer || (buffer = CreateDrawable ( - WANT_PIXMAP | MAPPED_TO_DISPLAY, - area->extent.width, - area->extent.height, - 1)) - ) + if (!buffer) + { // asked to create a new DRAWABLE instead + buffer = CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY, + area->extent.width, area->extent.height, 1); + if (!buffer) + return NULL; + + index = 0; + } + else { - frame = SetAbsFrameIndex (CaptureDrawable (buffer), index); - ReadDisplay (area, frame); - ReleaseDrawable (frame); + index = GetFrameIndex (frame); } - return (buffer); + frame = SetAbsFrameIndex (CaptureDrawable (buffer), index); + + if (_CurFramePtr->Type != SCREEN_DRAWABLE + || frame->Type == SCREEN_DRAWABLE + || !(GetFrameParentDrawable (frame)->Flags & MAPPED_TO_DISPLAY)) + { + log_add (log_Warning, "Unimplemented function activated: " + "LoadDisplayPixmap()"); + } + else + { + TFB_Image *img = frame->image; + TFB_DrawScreen_CopyToImage (img, area, TFB_SCREEN_MAIN); + } + + ReleaseDrawable (frame); + + return buffer; } - diff --git a/sc2/src/libs/graphics/sdl/3do_blt.c b/sc2/src/libs/graphics/sdl/3do_blt.c deleted file mode 100644 index a12a74d99..000000000 --- a/sc2/src/libs/graphics/sdl/3do_blt.c +++ /dev/null @@ -1,74 +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. - */ - -#ifdef GFXMODULE_SDL - -#include "sdl_common.h" -#include "libs/graphics/tfb_draw.h" -#include "libs/log.h" - -static void -read_screen (RECT *lpRect, FRAME DstFramePtr) -{ - if (_CurFramePtr->Type != SCREEN_DRAWABLE - || DstFramePtr->Type == SCREEN_DRAWABLE - || !(GetFrameParentDrawable (DstFramePtr)->Flags - & MAPPED_TO_DISPLAY)) - { - log_add (log_Warning, "Unimplemented function activated: " - "read_screen()"); - } - else - { - TFB_Image *img = DstFramePtr->image; - TFB_DrawScreen_CopyToImage (img, lpRect, TFB_SCREEN_MAIN); - } -} - -static DRAWABLE -alloc_image (COUNT NumFrames, DRAWABLE_TYPE DrawableType, CREATE_FLAGS - flags, SIZE width, SIZE height) -{ - /* dodge compiler warnings */ - (void)DrawableType; - (void)flags; - (void)width; - (void)height; - return AllocDrawable (NumFrames); -} - -static DISPLAY_INTERFACE DisplayInterface = -{ - /* .DisplayFlags = */ WANT_MASK, - - /* .DisplayDepth = */ 16, - /* .DisplayWidth = */ 320, - /* .DisplayHeight = */ 240, - - /* .alloc_iamge = */ alloc_image, - /* .read_display = */ read_screen, -}; - -void -LoadDisplay (DISPLAY_INTERFACE **pDisplay) -{ - *pDisplay = &DisplayInterface; -} - -#endif - diff --git a/sc2/src/libs/graphics/sdl/3do_funcs.c b/sc2/src/libs/graphics/sdl/3do_funcs.c index fc91623a9..fd61d0dea 100644 --- a/sc2/src/libs/graphics/sdl/3do_funcs.c +++ b/sc2/src/libs/graphics/sdl/3do_funcs.c @@ -26,23 +26,17 @@ #include "libs/graphics/tfb_draw.h" -//Status: Not entirely unimplemented! +// Status: Ignored BOOLEAN InitGraphics (int argc, char* argv[], COUNT KbytesRequired) // Kbytes should only matter if we wanted to port Starcon2 to the // hand-helds... { - BOOLEAN ret; - - LoadDisplay (&_pCurDisplay); - ActivateDisplay (); - (void) argc; /* lint */ (void) argv; /* lint */ (void) KbytesRequired; /* lint */ - ret = TRUE; - return (ret); + return TRUE; } // Status: Unimplemented diff --git a/sc2/src/libs/graphics/sdl/3do_getbody.c b/sc2/src/libs/graphics/sdl/3do_getbody.c index a4f50a796..7ed1c02f1 100644 --- a/sc2/src/libs/graphics/sdl/3do_getbody.c +++ b/sc2/src/libs/graphics/sdl/3do_getbody.c @@ -835,9 +835,7 @@ _request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType, { DRAWABLE Drawable; - Drawable = AllocDrawableImage ( - NumFrames, DrawableType, flags, width, height - ); + Drawable = AllocDrawable (NumFrames); if (Drawable) { int imgw, imgh; diff --git a/sc2/src/libs/graphics/sdl/Makeinfo b/sc2/src/libs/graphics/sdl/Makeinfo index c785db8ca..56b806f8a 100644 --- a/sc2/src/libs/graphics/sdl/Makeinfo +++ b/sc2/src/libs/graphics/sdl/Makeinfo @@ -1,4 +1,4 @@ -uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c opengl.c +uqm_CFILES="3do_funcs.c 3do_getbody.c opengl.c palette.c primitives.c pure.c sdl_common.c scalers.c 2xscalers.c diff --git a/sc2/src/libs/graphics/sdl/sdl_common.h b/sc2/src/libs/graphics/sdl/sdl_common.h index 9e89d4094..296901b2b 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.h +++ b/sc2/src/libs/graphics/sdl/sdl_common.h @@ -46,9 +46,6 @@ extern SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS]; extern SDL_Surface *format_conv_surf; -void ScreenOrigin (FRAME Display, COORD sx, COORD sy); -void LoadDisplay (DISPLAY_INTERFACE **pDisplay); - SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface); void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, int blend_numer, int blend_denom);