Replaced GetGraphicScaleIdentity() with a define; moved melee scale step

reducing to process.c instead


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@872 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2003-03-08 15:50:45 +00:00
parent 3c39c2269c
commit 627997f3b5
6 changed files with 27 additions and 39 deletions
+2 -1
View File
@@ -48,12 +48,13 @@ void TFB_ProcessEvents (void);
// 3DO Graphics Stuff // 3DO Graphics Stuff
#define GSCALE_IDENTITY 256
void LoadIntoExtraScreen (PRECT r); 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); int GetGraphicScale (void);
int GetGraphicScaleIdentity (void);
void SetGraphicUseOtherExtra (int other); void SetGraphicUseOtherExtra (int other);
void ScreenTransition (int transition, PRECT pRect); void ScreenTransition (int transition, PRECT pRect);
+1 -12
View File
@@ -21,17 +21,12 @@
#include "sdl_common.h" #include "sdl_common.h"
#include "graphics/tfb_draw.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; static int gscale = GSCALE_IDENTITY;
void void
SetGraphicScale (int scale) SetGraphicScale (int scale)
{ {
gscale = scale >> GSCALE_SHIFT; gscale = (scale ? scale : GSCALE_IDENTITY);
if (gscale == 0)
gscale = GSCALE_IDENTITY;
} }
int int
@@ -40,12 +35,6 @@ GetGraphicScale ()
return gscale; return gscale;
} }
int
GetGraphicScaleIdentity (void)
{
return GSCALE_IDENTITY;
}
static void static void
read_screen (PRECT lpRect, FRAMEPTR DstFramePtr) read_screen (PRECT lpRect, FRAMEPTR DstFramePtr)
{ {
+4 -4
View File
@@ -48,7 +48,7 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale
targetRect.x = x; targetRect.x = x;
targetRect.y = y; targetRect.y = y;
if (scale != 0 && scale != GetGraphicScaleIdentity ()) if (scale != 0 && scale != GSCALE_IDENTITY)
{ {
TFB_DrawImage_FixScaling (img, scale); TFB_DrawImage_FixScaling (img, scale);
surf = img->ScaledImg; 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.x = x;
targetRect.y = y; targetRect.y = y;
if (scale != 0 && scale != GetGraphicScaleIdentity ()) if (scale != 0 && scale != GSCALE_IDENTITY)
{ {
TFB_DrawImage_FixScaling (img, scale); TFB_DrawImage_FixScaling (img, scale);
surf = img->ScaledImg; surf = img->ScaledImg;
@@ -273,8 +273,8 @@ void
TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, int scale, PEXTENT size) TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, int scale, PEXTENT size)
{ {
SDL_Surface *src = (SDL_Surface *)src_canvas; SDL_Surface *src = (SDL_Surface *)src_canvas;
size->width = (int) (src->w * scale / (float)GetGraphicScaleIdentity ()); size->width = (int) (src->w * scale / (float)GSCALE_IDENTITY);
size->height = (int) (src->h * scale / (float)GetGraphicScaleIdentity ()); size->height = (int) (src->h * scale / (float)GSCALE_IDENTITY);
} }
void void
+2 -2
View File
@@ -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.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.scale = (scale == GetGraphicScaleIdentity ()) ? 0 : scale; DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale;
if (palette != NULL) 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.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.scale = (scale == GetGraphicScaleIdentity ()) ? 0 : scale; DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 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;
+15 -19
View File
@@ -46,9 +46,8 @@ void
TFB_Prim_Rect (PRECT r, TFB_Palette *color) TFB_Prim_Rect (PRECT r, TFB_Palette *color)
{ {
RECT arm; RECT arm;
int gscale, gscale_identity; int gscale;
gscale = GetGraphicScale (); gscale = GetGraphicScale ();
gscale_identity = GetGraphicScaleIdentity ();
arm = *r; arm = *r;
arm.extent.width = r->extent.width; arm.extent.width = r->extent.width;
arm.extent.height = 1; arm.extent.height = 1;
@@ -56,10 +55,10 @@ TFB_Prim_Rect (PRECT r, TFB_Palette *color)
arm.extent.height = r->extent.height; arm.extent.height = r->extent.height;
arm.extent.width = 1; arm.extent.width = 1;
TFB_Prim_FillRect (&arm, color); 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); TFB_Prim_FillRect (&arm, color);
arm.corner.x = r->corner.x; 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.width = r->extent.width;
arm.extent.height = 1; arm.extent.height = 1;
TFB_Prim_FillRect (&arm, color); TFB_Prim_FillRect (&arm, color);
@@ -69,7 +68,7 @@ void
TFB_Prim_FillRect (PRECT r, TFB_Palette *color) TFB_Prim_FillRect (PRECT r, TFB_Palette *color)
{ {
RECT rect; RECT rect;
int gscale, gscale_identity; int gscale;
rect.corner.x = r->corner.x - _CurFramePtr->HotSpot.x; rect.corner.x = r->corner.x - _CurFramePtr->HotSpot.x;
rect.corner.y = r->corner.y - _CurFramePtr->HotSpot.y; 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; rect.extent.height = r->extent.height;
gscale = GetGraphicScale (); gscale = GetGraphicScale ();
gscale_identity = GetGraphicScaleIdentity (); if (gscale != GSCALE_IDENTITY)
if (gscale != gscale_identity)
{ {
rect.extent.width = (rect.extent.width * gscale) / gscale_identity; rect.extent.width = (rect.extent.width * gscale) / GSCALE_IDENTITY;
rect.extent.height = (rect.extent.height * gscale) / gscale_identity; rect.extent.height = (rect.extent.height * gscale) / GSCALE_IDENTITY;
rect.corner.x += (r->extent.width - rect.corner.x += (r->extent.width -
rect.extent.width) >> 1; rect.extent.width) >> 1;
rect.corner.y += (r->extent.height - rect.corner.y += (r->extent.height -
@@ -118,7 +116,7 @@ TFB_Prim_Stamp (PSTAMP stmp)
TFB_Image *img; TFB_Image *img;
BOOLEAN paletted; BOOLEAN paletted;
TFB_Palette palette[256]; TFB_Palette palette[256];
int gscale, gscale_identity; int gscale;
SrcFramePtr = (PFRAME_DESC)stmp->frame; SrcFramePtr = (PFRAME_DESC)stmp->frame;
if (!SrcFramePtr) if (!SrcFramePtr)
@@ -128,7 +126,6 @@ TFB_Prim_Stamp (PSTAMP stmp)
} }
img = SrcFramePtr->image; img = SrcFramePtr->image;
gscale = GetGraphicScale (); gscale = GetGraphicScale ();
gscale_identity = GetGraphicScaleIdentity ();
if (!img) if (!img)
{ {
@@ -142,12 +139,12 @@ TFB_Prim_Stamp (PSTAMP stmp)
y = stmp->origin.y - _CurFramePtr->HotSpot.y - SrcFramePtr->HotSpot.y; y = stmp->origin.y - _CurFramePtr->HotSpot.y - SrcFramePtr->HotSpot.y;
paletted = FALSE; paletted = FALSE;
if (gscale != GetGraphicScaleIdentity ()) if (gscale != GSCALE_IDENTITY)
{ {
x += (SrcFramePtr->HotSpot.x * x += (SrcFramePtr->HotSpot.x *
(gscale_identity - gscale)) / gscale_identity; (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY;
y += (SrcFramePtr->HotSpot.y * y += (SrcFramePtr->HotSpot.y *
(gscale_identity - gscale)) / gscale_identity; (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY;
} }
if (TFB_DrawCanvas_IsPaletted(img->NormalImg) && img->colormap_index != -1) 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; PFRAME_DESC SrcFramePtr;
TFB_Image *img; TFB_Image *img;
int r, g, b; int r, g, b;
int gscale, gscale_identity; int gscale;
SrcFramePtr = (PFRAME_DESC)stmp->frame; SrcFramePtr = (PFRAME_DESC)stmp->frame;
if (!SrcFramePtr) if (!SrcFramePtr)
@@ -187,7 +184,6 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
} }
img = SrcFramePtr->image; img = SrcFramePtr->image;
gscale = GetGraphicScale (); gscale = GetGraphicScale ();
gscale_identity = GetGraphicScaleIdentity ();
if (!img) if (!img)
{ {
@@ -203,12 +199,12 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
g = color->g; g = color->g;
b = color->b; b = color->b;
if (gscale != gscale_identity) if (gscale != GSCALE_IDENTITY)
{ {
x += (SrcFramePtr->HotSpot.x * x += (SrcFramePtr->HotSpot.x *
(gscale_identity - gscale)) / gscale_identity; (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY;
y += (SrcFramePtr->HotSpot.y * y += (SrcFramePtr->HotSpot.y *
(gscale_identity - gscale)) / gscale_identity; (GSCALE_IDENTITY - gscale)) / GSCALE_IDENTITY;
} }
UnlockMutex (img->mutex); UnlockMutex (img->mutex);
+3 -1
View File
@@ -19,6 +19,8 @@
#include "starcon.h" #include "starcon.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#define GSCALE_SHIFT 2 // controls the number of discrete scaling steps
COUNT DisplayFreeList; COUNT DisplayFreeList;
PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS];
extern POINT SpaceOrg; extern POINT SpaceOrg;
@@ -1104,7 +1106,7 @@ if (clear)
COUNT index, scale; COUNT index, scale;
CALC_ZOOM_STUFF (&index, &scale); CALC_ZOOM_STUFF (&index, &scale);
SetGraphicScale (scale); SetGraphicScale ((scale >> GSCALE_SHIFT) << GSCALE_SHIFT);
} }
DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE); DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE);
SetGraphicScale (0); SetGraphicScale (0);