diff --git a/sc2/src/sc2code/libs/graphics/gfx_common.h b/sc2/src/sc2code/libs/graphics/gfx_common.h index 262089537..b8c7c0faf 100644 --- a/sc2/src/sc2code/libs/graphics/gfx_common.h +++ b/sc2/src/sc2code/libs/graphics/gfx_common.h @@ -48,12 +48,13 @@ void TFB_ProcessEvents (void); // 3DO Graphics Stuff +#define GSCALE_IDENTITY 256 + void LoadIntoExtraScreen (PRECT r); void DrawFromExtraScreen (PRECT r); void SetGraphicGrabOther (int grab_other); void SetGraphicScale (int scale); int GetGraphicScale (void); -int GetGraphicScaleIdentity (void); void SetGraphicUseOtherExtra (int other); void ScreenTransition (int transition, PRECT pRect); diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_blt.c b/sc2/src/sc2code/libs/graphics/sdl/3do_blt.c index 5ffd8b9b0..31f3f8265 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_blt.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_blt.c @@ -21,17 +21,12 @@ #include "sdl_common.h" #include "graphics/tfb_draw.h" -#define GSCALE_SHIFT 2 // controls the number of scale steps -#define GSCALE_IDENTITY (256 >> GSCALE_SHIFT) // 'identity scale' - static int gscale = GSCALE_IDENTITY; void SetGraphicScale (int scale) { - gscale = scale >> GSCALE_SHIFT; - if (gscale == 0) - gscale = GSCALE_IDENTITY; + gscale = (scale ? scale : GSCALE_IDENTITY); } int @@ -40,12 +35,6 @@ GetGraphicScale () return gscale; } -int -GetGraphicScaleIdentity (void) -{ - return GSCALE_IDENTITY; -} - static void read_screen (PRECT lpRect, FRAMEPTR DstFramePtr) { diff --git a/sc2/src/sc2code/libs/graphics/sdl/canvas.c b/sc2/src/sc2code/libs/graphics/sdl/canvas.c index f20b2142a..3e7d4cae3 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/canvas.c +++ b/sc2/src/sc2code/libs/graphics/sdl/canvas.c @@ -48,7 +48,7 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale targetRect.x = x; targetRect.y = y; - if (scale != 0 && scale != GetGraphicScaleIdentity ()) + if (scale != 0 && scale != GSCALE_IDENTITY) { TFB_DrawImage_FixScaling (img, scale); surf = img->ScaledImg; @@ -99,7 +99,7 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int targetRect.x = x; targetRect.y = y; - if (scale != 0 && scale != GetGraphicScaleIdentity ()) + if (scale != 0 && scale != GSCALE_IDENTITY) { TFB_DrawImage_FixScaling (img, scale); surf = img->ScaledImg; @@ -273,8 +273,8 @@ void TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, int scale, PEXTENT size) { SDL_Surface *src = (SDL_Surface *)src_canvas; - size->width = (int) (src->w * scale / (float)GetGraphicScaleIdentity ()); - size->height = (int) (src->h * scale / (float)GetGraphicScaleIdentity ()); + size->width = (int) (src->w * scale / (float)GSCALE_IDENTITY); + size->height = (int) (src->h * scale / (float)GSCALE_IDENTITY); } void diff --git a/sc2/src/sc2code/libs/graphics/tfb_draw.c b/sc2/src/sc2code/libs/graphics/tfb_draw.c index 61685e053..9d872c6a5 100644 --- a/sc2/src/sc2code/libs/graphics/tfb_draw.c +++ b/sc2/src/sc2code/libs/graphics/tfb_draw.c @@ -84,7 +84,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale DC.data.image.image = img; DC.data.image.x = x; DC.data.image.y = y; - DC.data.image.scale = (scale == GetGraphicScaleIdentity ()) ? 0 : scale; + DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; if (palette != NULL) @@ -130,7 +130,7 @@ TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int DC.data.filledimage.image = img; DC.data.filledimage.x = x; DC.data.filledimage.y = y; - DC.data.filledimage.scale = (scale == GetGraphicScaleIdentity ()) ? 0 : scale; + DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; DC.data.filledimage.r = r; DC.data.filledimage.g = g; DC.data.filledimage.b = b; diff --git a/sc2/src/sc2code/libs/graphics/tfb_prim.c b/sc2/src/sc2code/libs/graphics/tfb_prim.c index 8722046cc..6165b6185 100644 --- a/sc2/src/sc2code/libs/graphics/tfb_prim.c +++ b/sc2/src/sc2code/libs/graphics/tfb_prim.c @@ -46,9 +46,8 @@ void TFB_Prim_Rect (PRECT r, TFB_Palette *color) { RECT arm; - int gscale, gscale_identity; + int gscale; gscale = GetGraphicScale (); - gscale_identity = GetGraphicScaleIdentity (); arm = *r; arm.extent.width = r->extent.width; arm.extent.height = 1; @@ -56,10 +55,10 @@ TFB_Prim_Rect (PRECT r, TFB_Palette *color) arm.extent.height = r->extent.height; arm.extent.width = 1; TFB_Prim_FillRect (&arm, color); - arm.corner.x += ((r->extent.width * gscale) / gscale_identity) - 1; + arm.corner.x += ((r->extent.width * gscale) / GSCALE_IDENTITY) - 1; TFB_Prim_FillRect (&arm, color); arm.corner.x = r->corner.x; - arm.corner.y += ((r->extent.height * gscale) / gscale_identity) - 1; + arm.corner.y += ((r->extent.height * gscale) / GSCALE_IDENTITY) - 1; arm.extent.width = r->extent.width; arm.extent.height = 1; TFB_Prim_FillRect (&arm, color); @@ -69,7 +68,7 @@ void TFB_Prim_FillRect (PRECT r, TFB_Palette *color) { RECT rect; - int gscale, gscale_identity; + int gscale; rect.corner.x = r->corner.x - _CurFramePtr->HotSpot.x; rect.corner.y = r->corner.y - _CurFramePtr->HotSpot.y; @@ -77,11 +76,10 @@ TFB_Prim_FillRect (PRECT r, TFB_Palette *color) rect.extent.height = r->extent.height; gscale = GetGraphicScale (); - gscale_identity = GetGraphicScaleIdentity (); - if (gscale != gscale_identity) + if (gscale != GSCALE_IDENTITY) { - rect.extent.width = (rect.extent.width * gscale) / gscale_identity; - rect.extent.height = (rect.extent.height * gscale) / gscale_identity; + rect.extent.width = (rect.extent.width * gscale) / GSCALE_IDENTITY; + rect.extent.height = (rect.extent.height * gscale) / GSCALE_IDENTITY; rect.corner.x += (r->extent.width - rect.extent.width) >> 1; rect.corner.y += (r->extent.height - @@ -118,7 +116,7 @@ TFB_Prim_Stamp (PSTAMP stmp) TFB_Image *img; BOOLEAN paletted; TFB_Palette palette[256]; - int gscale, gscale_identity; + int gscale; SrcFramePtr = (PFRAME_DESC)stmp->frame; if (!SrcFramePtr) @@ -128,7 +126,6 @@ TFB_Prim_Stamp (PSTAMP stmp) } img = SrcFramePtr->image; gscale = GetGraphicScale (); - gscale_identity = GetGraphicScaleIdentity (); if (!img) { @@ -142,12 +139,12 @@ TFB_Prim_Stamp (PSTAMP stmp) y = stmp->origin.y - _CurFramePtr->HotSpot.y - SrcFramePtr->HotSpot.y; paletted = FALSE; - if (gscale != GetGraphicScaleIdentity ()) + if (gscale != GSCALE_IDENTITY) { x += (SrcFramePtr->HotSpot.x * - (gscale_identity - gscale)) / gscale_identity; + (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY; y += (SrcFramePtr->HotSpot.y * - (gscale_identity - gscale)) / gscale_identity; + (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY; } if (TFB_DrawCanvas_IsPaletted(img->NormalImg) && img->colormap_index != -1) @@ -177,7 +174,7 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color) PFRAME_DESC SrcFramePtr; TFB_Image *img; int r, g, b; - int gscale, gscale_identity; + int gscale; SrcFramePtr = (PFRAME_DESC)stmp->frame; if (!SrcFramePtr) @@ -187,7 +184,6 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color) } img = SrcFramePtr->image; gscale = GetGraphicScale (); - gscale_identity = GetGraphicScaleIdentity (); if (!img) { @@ -203,12 +199,12 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color) g = color->g; b = color->b; - if (gscale != gscale_identity) + if (gscale != GSCALE_IDENTITY) { x += (SrcFramePtr->HotSpot.x * - (gscale_identity - gscale)) / gscale_identity; + (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY; y += (SrcFramePtr->HotSpot.y * - (gscale_identity - gscale)) / gscale_identity; + (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY; } UnlockMutex (img->mutex); diff --git a/sc2/src/sc2code/process.c b/sc2/src/sc2code/process.c index 2eaf0a3f6..03c2c005c 100644 --- a/sc2/src/sc2code/process.c +++ b/sc2/src/sc2code/process.c @@ -19,6 +19,8 @@ #include "starcon.h" #include "libs/graphics/gfx_common.h" +#define GSCALE_SHIFT 2 // controls the number of discrete scaling steps + COUNT DisplayFreeList; PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; extern POINT SpaceOrg; @@ -1104,7 +1106,7 @@ if (clear) COUNT index, scale; CALC_ZOOM_STUFF (&index, &scale); - SetGraphicScale (scale); + SetGraphicScale ((scale >> GSCALE_SHIFT) << GSCALE_SHIFT); } DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE); SetGraphicScale (0);