diff --git a/sc2/src/sc2code/libs/gfxlib.h b/sc2/src/sc2code/libs/gfxlib.h index e307b3590..32f606e0d 100644 --- a/sc2/src/sc2code/libs/gfxlib.h +++ b/sc2/src/sc2code/libs/gfxlib.h @@ -131,8 +131,7 @@ typedef struct STAMP IntersectStamp; } INTERSECT_CONTROL; -typedef DWORD DRAWABLE; -#define BUILD_DRAWABLE(h,i) ((DRAWABLE)MAKE_DWORD(h,i)) +typedef MEM_HANDLE DRAWABLE; typedef MEM_HANDLE FONT_REF; diff --git a/sc2/src/sc2code/libs/graphics/drawable.h b/sc2/src/sc2code/libs/graphics/drawable.h index f985ea5d6..e1afac149 100644 --- a/sc2/src/sc2code/libs/graphics/drawable.h +++ b/sc2/src/sc2code/libs/graphics/drawable.h @@ -66,11 +66,9 @@ typedef struct drawable_desc #define DRAWABLE_PRIORITY DEFAULT_MEM_PRIORITY extern DRAWABLE AllocDrawable (COUNT num_frames); -#define LockDrawable(D) ((DRAWABLE_DESC*)mem_lock (GetDrawableHandle (D))) -#define UnlockDrawable(D) mem_unlock (GetDrawableHandle (D)) -#define FreeDrawable(D) _ReleaseCelData (GetDrawableHandle (D)) -#define GetDrawableHandle(D) ((MEM_HANDLE)LOWORD (D)) -#define GetDrawableIndex(D) ((COUNT)HIWORD (D)) +#define LockDrawable(D) ((DRAWABLE_DESC*)mem_lock (D)) +#define UnlockDrawable(D) mem_unlock (D) +#define FreeDrawable(D) _ReleaseCelData (D) #define GetFrameParentDrawable(F) (F)->parent #define TYPE_GET(f) ((f) & FTYPE_MASK) diff --git a/sc2/src/sc2code/libs/graphics/loaddisp.c b/sc2/src/sc2code/libs/graphics/loaddisp.c index ca07646a2..d45de86a5 100644 --- a/sc2/src/sc2code/libs/graphics/loaddisp.c +++ b/sc2/src/sc2code/libs/graphics/loaddisp.c @@ -36,12 +36,9 @@ DRAWABLE LoadDisplayPixmap (RECT *area, FRAME frame) { - DRAWABLE buffer; + MEM_HANDLE buffer = GetFrameHandle (frame); + COUNT index = GetFrameIndex (frame); - buffer = BUILD_DRAWABLE ( - GetFrameHandle (frame), - GetFrameIndex (frame) - ); if (buffer || (buffer = CreateDrawable ( WANT_PIXMAP | MAPPED_TO_DISPLAY, area->extent.width, @@ -49,7 +46,7 @@ LoadDisplayPixmap (RECT *area, FRAME frame) 1)) ) { - frame = CaptureDrawable (buffer); + frame = SetAbsFrameIndex (CaptureDrawable (buffer), index); ReadDisplay (area, frame); ReleaseDrawable (frame); } diff --git a/sc2/src/sc2code/libs/graphics/pixmap.c b/sc2/src/sc2code/libs/graphics/pixmap.c index e1e05adf8..7844fefe7 100644 --- a/sc2/src/sc2code/libs/graphics/pixmap.c +++ b/sc2/src/sc2code/libs/graphics/pixmap.c @@ -27,10 +27,7 @@ CaptureDrawable (DRAWABLE Drawable) DrawablePtr = LockDrawable (Drawable); if (DrawablePtr) { - COUNT FrameIndex; - - FrameIndex = GetDrawableIndex (Drawable); - return &DrawablePtr->Frame[FrameIndex]; + return &DrawablePtr->Frame[0]; } return (0); @@ -45,13 +42,13 @@ ReleaseDrawable (FRAME FramePtr) DRAWABLE_DESC *DrawablePtr; DrawablePtr = GetFrameParentDrawable (FramePtr); - Drawable = BUILD_DRAWABLE (DrawablePtr->hDrawable, FramePtr->Index); + Drawable = DrawablePtr->hDrawable; UnlockDrawable (Drawable); return (Drawable); } - return (0); + return NULL_HANDLE; } MEM_HANDLE diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c b/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c index b8d33f1ac..28479ee59 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c @@ -409,10 +409,7 @@ _GetCelData (uio_Stream *fp, DWORD length) { log_add (log_Warning, "Couldn't allocate space for '%s' images", _cur_resfile_name); - /* This isn't a very good way to return failure, but - * it seems to be how it is normally done in this - * routine. */ - return (GetDrawableHandle (0)); + return NULL_HANDLE; } ani = HMalloc (sizeof (AniData) * cel_total); @@ -421,10 +418,7 @@ _GetCelData (uio_Stream *fp, DWORD length) HFree (img); log_add (log_Warning, "Couldn't allocate space for '%s' anidata", _cur_resfile_name); - /* This isn't a very good way to return failure, but - * it seems to be how it is normally done in this - * routine. */ - return (GetDrawableHandle (0)); + return NULL_HANDLE; } cel_index = 0; @@ -461,7 +455,7 @@ _GetCelData (uio_Stream *fp, DWORD length) break; } - Drawable = 0; + Drawable = NULL_HANDLE; if (cel_index && (Drawable = AllocDrawable (cel_index))) { DRAWABLE_DESC *DrawablePtr; @@ -472,13 +466,13 @@ _GetCelData (uio_Stream *fp, DWORD length) SDL_FreeSurface (img[cel_index]); mem_release ((MEM_HANDLE)Drawable); - Drawable = 0; + Drawable = NULL_HANDLE; } else { FRAME FramePtr; - DrawablePtr->hDrawable = GetDrawableHandle (Drawable); + DrawablePtr->hDrawable = Drawable; DrawablePtr->Flags = WANT_PIXMAP; DrawablePtr->MaxIndex = cel_index - 1; @@ -496,7 +490,7 @@ _GetCelData (uio_Stream *fp, DWORD length) HFree (img); HFree (ani); - return (GetDrawableHandle (Drawable)); + return Drawable; } BOOLEAN @@ -773,14 +767,14 @@ _request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType, if ((DrawablePtr = LockDrawable (Drawable)) == 0) { FreeDrawable (Drawable); - Drawable = 0; + Drawable = NULL_HANDLE; } else { int imgw, imgh; FRAME FramePtr; - DrawablePtr->hDrawable = GetDrawableHandle (Drawable); + DrawablePtr->hDrawable = Drawable; DrawablePtr->Flags = flags; DrawablePtr->MaxIndex = NumFrames - 1; diff --git a/sc2/src/sc2code/libs/strings/sfileins.c b/sc2/src/sc2code/libs/strings/sfileins.c index a6a0c6585..a95d0bed3 100644 --- a/sc2/src/sc2code/libs/strings/sfileins.c +++ b/sc2/src/sc2code/libs/strings/sfileins.c @@ -42,7 +42,7 @@ LoadStringTableFile (uio_DirHandle *dir, const char *fileName) _cur_resfile_name = 0; res_CloseResFile (fp); - return (BUILD_STRING_TABLE (hData)); + return hData; } return (0); diff --git a/sc2/src/sc2code/libs/strings/sresins.c b/sc2/src/sc2code/libs/strings/sresins.c index ccb83c09e..71d413163 100644 --- a/sc2/src/sc2code/libs/strings/sresins.c +++ b/sc2/src/sc2code/libs/strings/sresins.c @@ -36,6 +36,6 @@ LoadStringTableInstance (DWORD res) res_DetachResource (res); } - return (BUILD_STRING_TABLE (hData)); + return hData; } diff --git a/sc2/src/sc2code/libs/strings/strintrn.h b/sc2/src/sc2code/libs/strings/strintrn.h index c9d02eaf7..116aa336c 100644 --- a/sc2/src/sc2code/libs/strings/strintrn.h +++ b/sc2/src/sc2code/libs/strings/strintrn.h @@ -37,14 +37,13 @@ typedef STRING_TABLE_DESC *PSTRING_TABLE_DESC; #define HAS_TIMESTAMP (1 << 1) #define STRING_TABLEPTR PSTRING_TABLE_DESC -#define AllocStringTable(s) AllocResourceData((s),MEM_SOUND) -#define LockStringTable(h,ps) LockResourceData((MEM_HANDLE)LOWORD(h),ps) -#define UnlockStringTable(h) UnlockResourceData ((MEM_HANDLE)LOWORD(h)) -#define FreeStringTable(h) FreeResourceData ((MEM_HANDLE)LOWORD(h)) +#define AllocStringTable(s) AllocResourceData((s),MEM_SOUND) +#define LockStringTable LockResourceData +#define UnlockStringTable UnlockResourceData +#define FreeStringTable FreeResourceData #define STRING_INDEX(S) ((COUNT)HIWORD (S)) -#define BUILD_STRING(h,i) ((STRING_TABLE)MAKE_DWORD(h,i)) -#define BUILD_STRING_TABLE(h) (STRING_TABLE)(h) +#define BUILD_STRING(h,i) ((STRING)MAKE_DWORD(h,i)) extern MEM_HANDLE _GetStringData (uio_Stream *fp, DWORD length); diff --git a/sc2/src/sc2code/libs/strlib.h b/sc2/src/sc2code/libs/strlib.h index 672642208..c05fd3d21 100644 --- a/sc2/src/sc2code/libs/strlib.h +++ b/sc2/src/sc2code/libs/strlib.h @@ -21,11 +21,12 @@ #include "compiler.h" #include "port.h" +#include "libs/memlib.h" #include "libs/uio.h" #include -typedef DWORD STRING_TABLE; +typedef MEM_HANDLE STRING_TABLE; typedef DWORD STRING; typedef BYTE* STRINGPTR;