Support for PC-style melee zooming; -b=pc|step option (bug #694)
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1606 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+106
-164
@@ -22,11 +22,16 @@
|
||||
#include "globdata.h"
|
||||
#include "init.h"
|
||||
#include "units.h"
|
||||
#include "options.h"
|
||||
#include "libs/compiler.h"
|
||||
#include "libs/gfxlib.h"
|
||||
#include "libs/graphics/gfx_common.h"
|
||||
#include "libs/mathlib.h"
|
||||
|
||||
|
||||
extern COUNT zoom_out;
|
||||
extern PRIM_LINKS DisplayLinks;
|
||||
|
||||
//Added by Chris
|
||||
|
||||
void InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI);
|
||||
@@ -283,101 +288,108 @@ InitGalaxy (void)
|
||||
SortStarBlock (&StarBlock[2]);
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
CmpMovePoints (const PPOINT pt1, const PPOINT pt2, SIZE dx, SIZE dy,
|
||||
SIZE reduction)
|
||||
{
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{
|
||||
return (int)pt1->x != (int)((pt2->x - dx) >> reduction)
|
||||
|| (int)pt1->y != (int)((pt2->y - dy) >> reduction);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (int)pt1->x != (int)(((pt2->x - dx) << ZOOM_SHIFT) / reduction)
|
||||
|| (int)pt1->y != (int)(((pt2->y - dy) << ZOOM_SHIFT) / reduction);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
|
||||
{
|
||||
PPRIMITIVE pprim;
|
||||
static const COUNT star_counts[] =
|
||||
{
|
||||
BIG_STAR_COUNT,
|
||||
MED_STAR_COUNT,
|
||||
SML_STAR_COUNT
|
||||
};
|
||||
static const COUNT star_frame_ofs[] = { 32 + 26, 26, 0 };
|
||||
|
||||
if (view_state != VIEW_STABLE)
|
||||
{
|
||||
#ifdef OLD_ZOOM
|
||||
BYTE reduction;
|
||||
#else
|
||||
COUNT reduction;
|
||||
#endif
|
||||
COUNT i;
|
||||
COUNT iss;
|
||||
PPOINT ppt;
|
||||
int wrap_around;
|
||||
|
||||
reduction = zoom_out;
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
reduction = GLOBAL (cur_state);
|
||||
#else
|
||||
{
|
||||
extern COUNT zoom_out;
|
||||
|
||||
reduction = zoom_out;
|
||||
}
|
||||
#endif
|
||||
if (view_state == VIEW_CHANGE)
|
||||
{
|
||||
pprim = DisplayArray;
|
||||
i = BIG_STAR_COUNT;
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
|
||||
{
|
||||
do
|
||||
for (iss = 0, pprim = DisplayArray; iss < 2; ++iss)
|
||||
{
|
||||
pprim->Object.Stamp.frame =
|
||||
SetAbsFrameIndex (stars_in_space,
|
||||
((COUNT)TFB_Random () & 31) + (32 + 26));
|
||||
++pprim;
|
||||
} while (--i);
|
||||
|
||||
i = MED_STAR_COUNT;
|
||||
do
|
||||
{
|
||||
pprim->Object.Stamp.frame =
|
||||
SetAbsFrameIndex (stars_in_space,
|
||||
((COUNT)TFB_Random () & 31) + 26);
|
||||
++pprim;
|
||||
} while (--i);
|
||||
for (i = star_counts[iss]; i > 0; --i, ++pprim)
|
||||
{
|
||||
pprim->Object.Stamp.frame = SetAbsFrameIndex (
|
||||
stars_in_space,
|
||||
(COUNT)(TFB_Random () & 31)
|
||||
+ star_frame_ofs[iss]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GRAPHICS_PRIM star_object, big_star_obj;
|
||||
FRAME star_frame;
|
||||
GRAPHICS_PRIM star_object[2];
|
||||
FRAME star_frame[2];
|
||||
|
||||
star_frame = stars_in_space;
|
||||
#ifdef OLD_ZOOM
|
||||
big_star_obj = STAMP_PRIM;
|
||||
if (reduction > 0)
|
||||
star_object = POINT_PRIM;
|
||||
else
|
||||
{
|
||||
star_frame = IncFrameIndex (star_frame);
|
||||
star_object = STAMP_PRIM;
|
||||
star_frame[0] = IncFrameIndex (stars_in_space);
|
||||
star_frame[1] = stars_in_space;
|
||||
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{ /* on PC, the closest stars are images when zoomed out */
|
||||
star_object[0] = STAMP_PRIM;
|
||||
if (reduction > 0)
|
||||
{
|
||||
star_object[1] = POINT_PRIM;
|
||||
star_frame[0] = star_frame[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
star_object[1] = STAMP_PRIM;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (reduction > (1 << ZOOM_SHIFT))
|
||||
big_star_obj = star_object = POINT_PRIM;
|
||||
else
|
||||
{
|
||||
big_star_obj = star_object = STAMP_PRIM;
|
||||
star_frame = IncFrameIndex (star_frame);
|
||||
star_object = POINT_PRIM;
|
||||
{ /* on 3DO, the closest stars are pixels when zoomed out */
|
||||
star_object[1] = POINT_PRIM;
|
||||
if (reduction > (1 << ZOOM_SHIFT))
|
||||
{
|
||||
star_object[0] = POINT_PRIM;
|
||||
}
|
||||
else
|
||||
{
|
||||
star_object[0] = STAMP_PRIM;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
do
|
||||
for (iss = 0, pprim = DisplayArray; iss < 2; ++iss)
|
||||
{
|
||||
SetPrimType (pprim, big_star_obj);
|
||||
pprim->Object.Stamp.frame = star_frame;
|
||||
++pprim;
|
||||
} while (--i);
|
||||
|
||||
pprim = &DisplayArray[BIG_STAR_COUNT];
|
||||
i = MED_STAR_COUNT;
|
||||
do
|
||||
{
|
||||
SetPrimType (pprim, star_object);
|
||||
++pprim;
|
||||
} while (--i);
|
||||
for (i = star_counts[iss]; i > 0; --i, ++pprim)
|
||||
{
|
||||
SetPrimType (pprim, star_object[iss]);
|
||||
pprim->Object.Stamp.frame = star_frame[iss];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
|
||||
{
|
||||
pprim = DisplayArray;
|
||||
i = BIG_STAR_COUNT + MED_STAR_COUNT;
|
||||
do
|
||||
for (i = BIG_STAR_COUNT + MED_STAR_COUNT, pprim = DisplayArray;
|
||||
i > 0; --i, ++pprim)
|
||||
{
|
||||
COUNT base_index;
|
||||
|
||||
@@ -385,8 +397,7 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
|
||||
pprim->Object.Stamp.frame =
|
||||
SetAbsFrameIndex (pprim->Object.Stamp.frame,
|
||||
((base_index & ~31) + ((base_index + 1) & 31)) + 26);
|
||||
++pprim;
|
||||
} while (--i);
|
||||
}
|
||||
|
||||
dx <<= 3;
|
||||
dy <<= 3;
|
||||
@@ -400,11 +411,10 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
|
||||
{
|
||||
dx = SpaceOrg.x;
|
||||
dy = SpaceOrg.y;
|
||||
#ifdef OLD_ZOOM
|
||||
reduction += ONE_SHIFT;
|
||||
#else
|
||||
reduction <<= ONE_SHIFT;
|
||||
#endif
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
reduction += ONE_SHIFT;
|
||||
else
|
||||
reduction <<= ONE_SHIFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -414,110 +424,42 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
|
||||
dy = (COORD)(LOG_SPACE_HEIGHT >> 1)
|
||||
- (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1)
|
||||
- MAX_VIS_REDUCTION));
|
||||
#ifdef OLD_ZOOM
|
||||
reduction = (COUNT)(MAX_VIS_REDUCTION + ONE_SHIFT);
|
||||
#else
|
||||
reduction = MAX_ZOOM_OUT << ONE_SHIFT;
|
||||
#endif
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
reduction = MAX_VIS_REDUCTION + ONE_SHIFT;
|
||||
else
|
||||
reduction = MAX_ZOOM_OUT << ONE_SHIFT;
|
||||
}
|
||||
|
||||
ppt = log_star_array;
|
||||
pprim = DisplayArray;
|
||||
|
||||
if (view_state == VIEW_CHANGE
|
||||
#ifdef OLD_ZOOM
|
||||
|| (int)pprim->Object.Point.x != (int)((ppt->x - dx) >> reduction)
|
||||
|| (int)pprim->Object.Point.y != (int)((ppt->y - dy) >> reduction))
|
||||
#else
|
||||
|| (int)pprim->Object.Point.x != (int)(((ppt->x - dx) << ZOOM_SHIFT) / reduction)
|
||||
|| (int)pprim->Object.Point.y != (int)(((ppt->y - dy) << ZOOM_SHIFT) / reduction))
|
||||
#endif
|
||||
for (iss = 0, pprim = DisplayArray, wrap_around = LOG_SPACE_WIDTH;
|
||||
iss < 3 &&
|
||||
(view_state == VIEW_CHANGE || CmpMovePoints (
|
||||
&pprim->Object.Point, ppt, dx, dy, reduction));
|
||||
++iss, wrap_around <<= 1, dx <<= 1, dy <<= 1)
|
||||
{
|
||||
i = BIG_STAR_COUNT;
|
||||
do
|
||||
for (i = star_counts[iss]; i > 0; --i, ++pprim, ++ppt)
|
||||
{
|
||||
// ppt->x &= (LOG_SPACE_WIDTH - 1);
|
||||
ppt->x = WRAP_VAL (ppt->x, LOG_SPACE_WIDTH);
|
||||
#ifdef OLD_ZOOM
|
||||
pprim->Object.Point.x = (ppt->x - dx) >> reduction;
|
||||
pprim->Object.Point.y = (ppt->y - dy) >> reduction;
|
||||
#else
|
||||
pprim->Object.Point.x = ((ppt->x - dx) << ZOOM_SHIFT) / reduction;
|
||||
pprim->Object.Point.y = ((ppt->y - dy) << ZOOM_SHIFT) / reduction;
|
||||
#endif
|
||||
++pprim, ++ppt;
|
||||
} while (--i);
|
||||
dx <<= 1;
|
||||
dy <<= 1;
|
||||
#ifdef OLD_ZOOM
|
||||
++reduction;
|
||||
#else
|
||||
reduction <<= 1;
|
||||
#endif
|
||||
|
||||
if (view_state == VIEW_CHANGE
|
||||
#ifdef OLD_ZOOM
|
||||
|| pprim->Object.Point.x != (ppt->x - dx) >> reduction
|
||||
|| pprim->Object.Point.y != (ppt->y - dy) >> reduction)
|
||||
#else
|
||||
|| (int)(pprim->Object.Point.x) != (int)(((ppt->x - dx) << ZOOM_SHIFT) / reduction)
|
||||
|| (int)(pprim->Object.Point.y) != (int)(((ppt->y - dy) << ZOOM_SHIFT) / reduction))
|
||||
#endif
|
||||
{
|
||||
i = MED_STAR_COUNT;
|
||||
do
|
||||
// ppt->x &= (LOG_SPACE_WIDTH - 1);
|
||||
ppt->x = WRAP_VAL (ppt->x, wrap_around);
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{
|
||||
// ppt->x &= ((LOG_SPACE_WIDTH << 1) - 1);
|
||||
ppt->x = WRAP_VAL (ppt->x, LOG_SPACE_WIDTH << 1);
|
||||
#ifdef OLD_ZOOM
|
||||
pprim->Object.Point.x = (ppt->x - dx) >> reduction;
|
||||
pprim->Object.Point.y = (ppt->y - dy) >> reduction;
|
||||
#else
|
||||
pprim->Object.Point.x = ((ppt->x - dx) << ZOOM_SHIFT) / reduction;
|
||||
pprim->Object.Point.y = ((ppt->y - dy) << ZOOM_SHIFT) / reduction;
|
||||
#endif
|
||||
++pprim, ++ppt;
|
||||
} while (--i);
|
||||
dx <<= 1;
|
||||
dy <<= 1;
|
||||
#ifdef OLD_ZOOM
|
||||
++reduction;
|
||||
#else
|
||||
reduction <<= 1;
|
||||
#endif
|
||||
|
||||
if (view_state == VIEW_CHANGE
|
||||
#ifdef OLD_ZOOM
|
||||
|| pprim->Object.Point.x != (ppt->x - dx) >> reduction
|
||||
|| pprim->Object.Point.y != (ppt->y - dy) >> reduction)
|
||||
#else
|
||||
|| (int)(pprim->Object.Point.x) != (int)(((ppt->x - dx) << ZOOM_SHIFT) / reduction)
|
||||
|| (int)(pprim->Object.Point.y) != (int)(((ppt->y - dy) << ZOOM_SHIFT) / reduction))
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
i = SML_STAR_COUNT;
|
||||
do
|
||||
{
|
||||
// ppt->x &= ((LOG_SPACE_WIDTH << 2) - 1);
|
||||
ppt->x = WRAP_VAL (ppt->x, LOG_SPACE_WIDTH << 2);
|
||||
#ifdef OLD_ZOOM
|
||||
pprim->Object.Point.x = (ppt->x - dx) >> reduction;
|
||||
pprim->Object.Point.y = (ppt->y - dy) >> reduction;
|
||||
#else
|
||||
pprim->Object.Point.x = ((ppt->x - dx) << ZOOM_SHIFT) / reduction;
|
||||
pprim->Object.Point.y = ((ppt->y - dy) << ZOOM_SHIFT) / reduction;
|
||||
#endif
|
||||
++pprim, ++ppt;
|
||||
} while (--i);
|
||||
pprim->Object.Point.x = ((ppt->x - dx) << ZOOM_SHIFT)
|
||||
/ reduction;
|
||||
pprim->Object.Point.y = ((ppt->y - dy) << ZOOM_SHIFT)
|
||||
/ reduction;
|
||||
}
|
||||
}
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
++reduction;
|
||||
else
|
||||
reduction <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
extern PRIM_LINKS DisplayLinks;
|
||||
|
||||
DisplayLinks = MakeLinks (NUM_STARS - 1, 0);
|
||||
}
|
||||
DisplayLinks = MakeLinks (NUM_STARS - 1, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -877,6 +877,7 @@ typedef UWORD ACTIVITY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// XXX: cur_state is obsolete now and was replaced by process.c:zoom_out
|
||||
BYTE cur_state, glob_flags;
|
||||
|
||||
BYTE CrewCost, FuelCost;
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef enum {
|
||||
} SCREEN;
|
||||
|
||||
typedef enum {
|
||||
TFB_SCALE_STEP, /* not really a scaler */
|
||||
TFB_SCALE_NEAREST,
|
||||
TFB_SCALE_TRILINEAR
|
||||
} SCALE;
|
||||
|
||||
+153
-205
@@ -36,37 +36,36 @@ COUNT DisplayFreeList;
|
||||
PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS];
|
||||
extern POINT SpaceOrg;
|
||||
|
||||
#ifndef OLD_ZOOM
|
||||
SIZE zoom_out = 1 << ZOOM_SHIFT;
|
||||
#endif
|
||||
static SIZE opt_max_zoom_out;
|
||||
|
||||
#if 0
|
||||
#define CALC_ZOOM_STUFF(idx,sc) \
|
||||
do \
|
||||
{ \
|
||||
int i, z; \
|
||||
\
|
||||
z = 1 << ZOOM_SHIFT; \
|
||||
for (i = 0; (z <<= 1) <= zoom_out; i++) \
|
||||
; \
|
||||
*(idx) = i; \
|
||||
*(sc) = ((1 << i) << (ZOOM_SHIFT + 8)) / zoom_out; \
|
||||
} while (0)
|
||||
static void inline
|
||||
CALC_ZOOM_STUFF (COUNT* idx, COUNT* sc)
|
||||
{
|
||||
int i, z;
|
||||
|
||||
z = 1 << ZOOM_SHIFT;
|
||||
for (i = 0; (z <<= 1) <= zoom_out; i++)
|
||||
;
|
||||
*idx = i;
|
||||
*sc = ((1 << i) << (ZOOM_SHIFT + 8)) / zoom_out;
|
||||
}
|
||||
#else
|
||||
#define CALC_ZOOM_STUFF(idx,sc) \
|
||||
do \
|
||||
{ \
|
||||
int i; \
|
||||
\
|
||||
if (zoom_out < 2 << ZOOM_SHIFT) \
|
||||
i = 0; \
|
||||
else if (zoom_out < 4 << ZOOM_SHIFT) \
|
||||
i = 1; \
|
||||
else \
|
||||
i = 2; \
|
||||
*(idx) = i; \
|
||||
*(sc) = (1 << (i + ZOOM_SHIFT + 8)) / zoom_out; \
|
||||
} while (0)
|
||||
static void inline
|
||||
CALC_ZOOM_STUFF (COUNT* idx, COUNT* sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (zoom_out < 2 << ZOOM_SHIFT)
|
||||
i = 0;
|
||||
else if (zoom_out < 4 << ZOOM_SHIFT)
|
||||
i = 1;
|
||||
else
|
||||
i = 2;
|
||||
*idx = i;
|
||||
*sc = (1 << (i + ZOOM_SHIFT + 8)) / zoom_out;
|
||||
}
|
||||
#endif
|
||||
|
||||
HELEMENT
|
||||
@@ -195,34 +194,35 @@ PostProcess (ELEMENTPTR ElementPtr)
|
||||
| POST_PROCESS;
|
||||
}
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
static BYTE
|
||||
CalcReduction (SIZE dx, SIZE dy)
|
||||
#else
|
||||
static COUNT
|
||||
CalcReduction (SIZE dx, SIZE dy)
|
||||
#endif
|
||||
{
|
||||
#ifdef OLD_ZOOM
|
||||
BYTE next_reduction;
|
||||
SIZE sdx, sdy;
|
||||
COUNT next_reduction;
|
||||
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER)
|
||||
return (0);
|
||||
#ifdef KDEBUG
|
||||
fprintf (stderr, "CalcReduction:\n");
|
||||
#endif
|
||||
|
||||
sdx = dx;
|
||||
sdy = dy;
|
||||
for (next_reduction = MAX_VIS_REDUCTION;
|
||||
(dx <<= REDUCTION_SHIFT) <= TRANSITION_WIDTH
|
||||
&& (dy <<= REDUCTION_SHIFT) <= TRANSITION_HEIGHT
|
||||
&& next_reduction > 0;
|
||||
next_reduction -= REDUCTION_SHIFT)
|
||||
;
|
||||
|
||||
/* check for "real" zoom in */
|
||||
if (next_reduction < GLOBAL (cur_state)
|
||||
&& GLOBAL (cur_state) <= MAX_VIS_REDUCTION)
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{
|
||||
SIZE sdx, sdy;
|
||||
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER)
|
||||
return (0);
|
||||
|
||||
sdx = dx;
|
||||
sdy = dy;
|
||||
for (next_reduction = MAX_VIS_REDUCTION;
|
||||
(dx <<= REDUCTION_SHIFT) <= TRANSITION_WIDTH
|
||||
&& (dy <<= REDUCTION_SHIFT) <= TRANSITION_HEIGHT
|
||||
&& next_reduction > 0;
|
||||
next_reduction -= REDUCTION_SHIFT)
|
||||
;
|
||||
|
||||
/* check for "real" zoom in */
|
||||
if (next_reduction < zoom_out
|
||||
&& zoom_out <= MAX_VIS_REDUCTION)
|
||||
{
|
||||
#define HYSTERESIS_X DISPLAY_TO_WORLD(24)
|
||||
#define HYSTERESIS_Y DISPLAY_TO_WORLD(20)
|
||||
if (((sdx + HYSTERESIS_X)
|
||||
@@ -231,56 +231,49 @@ CalcReduction (SIZE dx, SIZE dy)
|
||||
<< (MAX_VIS_REDUCTION - next_reduction)) > TRANSITION_HEIGHT)
|
||||
/* if we don't zoom in, we want to stay at next+1 */
|
||||
next_reduction += REDUCTION_SHIFT;
|
||||
}
|
||||
|
||||
if (next_reduction == 0
|
||||
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
|
||||
next_reduction += REDUCTION_SHIFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER)
|
||||
return (1 << ZOOM_SHIFT);
|
||||
|
||||
dx = (dx * MAX_ZOOM_OUT) / (LOG_SPACE_WIDTH >> 2);
|
||||
if (dx < (1 << ZOOM_SHIFT))
|
||||
dx = 1 << ZOOM_SHIFT;
|
||||
else if (dx > MAX_ZOOM_OUT)
|
||||
dx = MAX_ZOOM_OUT;
|
||||
|
||||
dy = (dy * MAX_ZOOM_OUT) / (LOG_SPACE_HEIGHT >> 2);
|
||||
if (dy < (1 << ZOOM_SHIFT))
|
||||
dy = 1 << ZOOM_SHIFT;
|
||||
else if (dy > MAX_ZOOM_OUT)
|
||||
dy = MAX_ZOOM_OUT;
|
||||
|
||||
if (dy > dx)
|
||||
next_reduction = dy;
|
||||
else
|
||||
next_reduction = dx;
|
||||
|
||||
if (next_reduction < (2 << ZOOM_SHIFT)
|
||||
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
|
||||
next_reduction = (2 << ZOOM_SHIFT);
|
||||
}
|
||||
|
||||
if (next_reduction == 0
|
||||
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
|
||||
next_reduction += REDUCTION_SHIFT;
|
||||
#else
|
||||
COUNT next_reduction;
|
||||
#ifdef KDEBUG
|
||||
fprintf (stderr, "CalcReduction:\n");
|
||||
#endif
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER)
|
||||
return (1 << ZOOM_SHIFT);
|
||||
|
||||
dx = (dx * MAX_ZOOM_OUT) / (LOG_SPACE_WIDTH >> 2);
|
||||
if (dx < (1 << ZOOM_SHIFT))
|
||||
dx = 1 << ZOOM_SHIFT;
|
||||
else if (dx > MAX_ZOOM_OUT)
|
||||
dx = MAX_ZOOM_OUT;
|
||||
|
||||
dy = (dy * MAX_ZOOM_OUT) / (LOG_SPACE_HEIGHT >> 2);
|
||||
if (dy < (1 << ZOOM_SHIFT))
|
||||
dy = 1 << ZOOM_SHIFT;
|
||||
else if (dy > MAX_ZOOM_OUT)
|
||||
dy = MAX_ZOOM_OUT;
|
||||
|
||||
if (dy > dx)
|
||||
next_reduction = dy;
|
||||
else
|
||||
next_reduction = dx;
|
||||
|
||||
if (next_reduction < (2 << ZOOM_SHIFT)
|
||||
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
|
||||
next_reduction = (2 << ZOOM_SHIFT);
|
||||
#ifdef KDEBUG
|
||||
fprintf (stderr, "CalcReduction: exit\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return (next_reduction);
|
||||
}
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
static VIEW_STATE
|
||||
CalcView (PPOINT pNewScrollPt, BYTE next_reduction,
|
||||
PSIZE pdx, PSIZE pdy, COUNT ships_alive)
|
||||
#else
|
||||
static VIEW_STATE
|
||||
CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
|
||||
PSIZE pdx, PSIZE pdy, COUNT ships_alive)
|
||||
#endif
|
||||
{
|
||||
SIZE dx, dy;
|
||||
VIEW_STATE view_state;
|
||||
@@ -309,39 +302,36 @@ CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
|
||||
if ((dx || dy) && LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
|
||||
MoveSIS (&dx, &dy);
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
if (GLOBAL (cur_state) == next_reduction)
|
||||
#else
|
||||
if (zoom_out == next_reduction)
|
||||
#endif
|
||||
view_state = dx == 0 && dy == 0
|
||||
&& LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE
|
||||
? VIEW_STABLE : VIEW_SCROLL;
|
||||
else
|
||||
{
|
||||
#ifdef OLD_ZOOM
|
||||
GLOBAL (cur_state) = next_reduction;
|
||||
|
||||
SpaceOrg.x = (COORD)(LOG_SPACE_WIDTH >> 1)
|
||||
- (LOG_SPACE_WIDTH >> ((MAX_REDUCTION + 1) - next_reduction));
|
||||
SpaceOrg.y = (COORD)(LOG_SPACE_HEIGHT >> 1)
|
||||
- (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1) - next_reduction));
|
||||
#else
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{
|
||||
SpaceOrg.x = (COORD)(LOG_SPACE_WIDTH >> 1)
|
||||
- (LOG_SPACE_WIDTH >> ((MAX_REDUCTION + 1)
|
||||
- next_reduction));
|
||||
SpaceOrg.y = (COORD)(LOG_SPACE_HEIGHT >> 1)
|
||||
- (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1)
|
||||
- next_reduction));
|
||||
}
|
||||
else
|
||||
{
|
||||
#define ZOOM_JUMP ((1 << ZOOM_SHIFT) >> 3)
|
||||
if (ships_alive == 1
|
||||
&& zoom_out > next_reduction
|
||||
&& zoom_out <= MAX_ZOOM_OUT
|
||||
&& zoom_out - next_reduction > ZOOM_JUMP)
|
||||
next_reduction = zoom_out - ZOOM_JUMP;
|
||||
|
||||
if (ships_alive == 1
|
||||
&& zoom_out > next_reduction
|
||||
&& zoom_out <= MAX_ZOOM_OUT
|
||||
&& zoom_out - next_reduction > ZOOM_JUMP)
|
||||
next_reduction = zoom_out - ZOOM_JUMP;
|
||||
|
||||
SpaceOrg.x = (int)(LOG_SPACE_WIDTH >> 1)
|
||||
- (LOG_SPACE_WIDTH * next_reduction / (MAX_ZOOM_OUT << 2));
|
||||
SpaceOrg.y = (int)(LOG_SPACE_HEIGHT >> 1)
|
||||
- (LOG_SPACE_HEIGHT * next_reduction / (MAX_ZOOM_OUT << 2));
|
||||
}
|
||||
zoom_out = next_reduction;
|
||||
|
||||
SpaceOrg.x = (int)(LOG_SPACE_WIDTH >> 1)
|
||||
- (LOG_SPACE_WIDTH * next_reduction / (MAX_ZOOM_OUT << 2));
|
||||
SpaceOrg.y = (int)(LOG_SPACE_HEIGHT >> 1)
|
||||
- (LOG_SPACE_HEIGHT * next_reduction / (MAX_ZOOM_OUT << 2));
|
||||
#endif
|
||||
|
||||
view_state = VIEW_CHANGE;
|
||||
}
|
||||
|
||||
@@ -630,11 +620,7 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr,
|
||||
static VIEW_STATE
|
||||
PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
{
|
||||
#ifdef OLD_ZOOM
|
||||
BYTE min_reduction, max_reduction;
|
||||
#else
|
||||
SIZE min_reduction, max_reduction;
|
||||
#endif
|
||||
COUNT num_ships;
|
||||
POINT Origin;
|
||||
HELEMENT hElement;
|
||||
@@ -646,11 +632,11 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
num_ships = (LOBYTE (battle_counter) ? 1 : 0)
|
||||
+ (HIBYTE (battle_counter) ? 1 : 0);
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
min_reduction = max_reduction = MAX_VIS_REDUCTION + 1;
|
||||
#else
|
||||
min_reduction = max_reduction = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT);
|
||||
#endif
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
min_reduction = max_reduction = MAX_VIS_REDUCTION + 1;
|
||||
else
|
||||
min_reduction = max_reduction = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT);
|
||||
|
||||
Origin.x = (COORD)(LOG_SPACE_WIDTH >> 1);
|
||||
Origin.y = (COORD)(LOG_SPACE_HEIGHT >> 1);
|
||||
|
||||
@@ -677,13 +663,8 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
SIZE dx, dy;
|
||||
|
||||
ships_alive++;
|
||||
#ifdef OLD_ZOOM
|
||||
if (max_reduction > MAX_VIS_REDUCTION
|
||||
&& min_reduction > MAX_VIS_REDUCTION)
|
||||
#else
|
||||
if (max_reduction > MAX_ZOOM_OUT
|
||||
&& min_reduction > MAX_ZOOM_OUT)
|
||||
#endif
|
||||
if (max_reduction > opt_max_zoom_out
|
||||
&& min_reduction > opt_max_zoom_out)
|
||||
{
|
||||
Origin.x = DISPLAY_ALIGN (ElementPtr->next.location.x);
|
||||
Origin.y = DISPLAY_ALIGN (ElementPtr->next.location.y);
|
||||
@@ -705,13 +686,8 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
dy = -dy;
|
||||
max_reduction = CalcReduction (dx, dy);
|
||||
}
|
||||
#ifdef OLD_ZOOM
|
||||
else if (max_reduction > MAX_VIS_REDUCTION
|
||||
&& min_reduction <= MAX_VIS_REDUCTION)
|
||||
#else
|
||||
else if (max_reduction > MAX_ZOOM_OUT
|
||||
&& min_reduction <= MAX_ZOOM_OUT)
|
||||
#endif
|
||||
else if (max_reduction > opt_max_zoom_out
|
||||
&& min_reduction <= opt_max_zoom_out)
|
||||
{
|
||||
Origin.x = DISPLAY_ALIGN (Origin.x + (dx >> 1));
|
||||
Origin.y = DISPLAY_ALIGN (Origin.y + (dy >> 1));
|
||||
@@ -724,11 +700,7 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef OLD_ZOOM
|
||||
BYTE reduction;
|
||||
#else
|
||||
SIZE reduction;
|
||||
#endif
|
||||
|
||||
if (dx < 0)
|
||||
dx = -dx;
|
||||
@@ -736,13 +708,8 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
dy = -dy;
|
||||
reduction = CalcReduction (dx << 1, dy << 1);
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
if (min_reduction > MAX_VIS_REDUCTION
|
||||
if (min_reduction > opt_max_zoom_out
|
||||
|| reduction < min_reduction)
|
||||
#else
|
||||
if (min_reduction > MAX_ZOOM_OUT
|
||||
|| reduction < min_reduction)
|
||||
#endif
|
||||
min_reduction = reduction;
|
||||
}
|
||||
// fprintf (stderr, "dx = %d dy = %d min_red = %d max_red = %d\n",
|
||||
@@ -753,17 +720,13 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
|
||||
hElement = hNextElement;
|
||||
}
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
if ((min_reduction > MAX_VIS_REDUCTION || min_reduction <= max_reduction)
|
||||
&& (min_reduction = max_reduction) > MAX_VIS_REDUCTION
|
||||
&& (min_reduction = GLOBAL (cur_state)) > MAX_VIS_REDUCTION)
|
||||
min_reduction = 0;
|
||||
#else
|
||||
if ((min_reduction > MAX_ZOOM_OUT || min_reduction <= max_reduction)
|
||||
&& (min_reduction = max_reduction) > MAX_ZOOM_OUT
|
||||
&& (min_reduction = zoom_out) > MAX_ZOOM_OUT)
|
||||
min_reduction = 1 << ZOOM_SHIFT;
|
||||
#endif
|
||||
if ((min_reduction > opt_max_zoom_out || min_reduction <= max_reduction)
|
||||
&& (min_reduction = max_reduction) > opt_max_zoom_out
|
||||
&& (min_reduction = zoom_out) > opt_max_zoom_out)
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
min_reduction = 0;
|
||||
else
|
||||
min_reduction = 1 << ZOOM_SHIFT;
|
||||
|
||||
#ifdef KDEBUG
|
||||
fprintf (stderr, "PreProcess: exit\n");
|
||||
@@ -808,44 +771,34 @@ InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI)
|
||||
|
||||
PRIM_LINKS DisplayLinks;
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
/* old fixed-step zoom style */
|
||||
static inline COORD
|
||||
CalcDisplayCoord (COORD c, COORD orgc, BYTE reduction)
|
||||
{
|
||||
return (c - orgc) >> reduction;
|
||||
}
|
||||
|
||||
#else /* OLD_ZOOM */
|
||||
|
||||
/* new continuous zoom style */
|
||||
static inline COORD
|
||||
CalcDisplayCoord (COORD c, COORD orgc, SIZE reduction)
|
||||
{
|
||||
return ((c - orgc) << ZOOM_SHIFT) / reduction;
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{ /* old fixed-step zoom style */
|
||||
return (c - orgc) >> reduction;
|
||||
}
|
||||
else
|
||||
{ /* new continuous zoom style */
|
||||
return ((c - orgc) << ZOOM_SHIFT) / reduction;
|
||||
}
|
||||
}
|
||||
#endif /* OLD_ZOOM */
|
||||
|
||||
static void
|
||||
PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
||||
SIZE scroll_y)
|
||||
{
|
||||
POINT delta;
|
||||
#ifdef OLD_ZOOM
|
||||
BYTE reduction;
|
||||
#else
|
||||
SIZE reduction;
|
||||
#endif
|
||||
HELEMENT hElement;
|
||||
|
||||
#ifdef KDEBUG
|
||||
fprintf (stderr, "PostProcess:\n");
|
||||
#endif
|
||||
#ifdef OLD_ZOOM
|
||||
reduction = (BYTE)(GLOBAL (cur_state) + ONE_SHIFT);
|
||||
#else
|
||||
reduction = zoom_out << ONE_SHIFT;
|
||||
#endif
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
reduction = zoom_out + ONE_SHIFT;
|
||||
else
|
||||
reduction = zoom_out << ONE_SHIFT;
|
||||
|
||||
hElement = GetHeadElement ();
|
||||
while (hElement != 0)
|
||||
@@ -951,29 +904,18 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
||||
DisplayArray[ElementPtr->PrimIndex].Object.Point.y =
|
||||
CalcDisplayCoord (next.y, SpaceOrg.y, reduction);
|
||||
|
||||
if (ObjType == STAMP_PRIM
|
||||
|| ObjType == STAMPFILL_PRIM)
|
||||
if (ObjType == STAMP_PRIM || ObjType == STAMPFILL_PRIM)
|
||||
{
|
||||
if (view_state == VIEW_CHANGE
|
||||
|| (state_flags & (APPEARING | CHANGING)))
|
||||
{
|
||||
#ifdef OLD_ZOOM
|
||||
ElementPtr->next.image.frame =
|
||||
#ifdef SAFE
|
||||
SetAbsFrameIndex (
|
||||
ElementPtr->next.image.farray
|
||||
[GLOBAL (cur_state)],
|
||||
GetFrameIndex (ElementPtr->next.image.frame));
|
||||
#else /* SAFE */
|
||||
SetEquFrameIndex (
|
||||
ElementPtr->next.image.farray
|
||||
[GLOBAL (cur_state)],
|
||||
ElementPtr->next.image.frame);
|
||||
#endif /* SAFE */
|
||||
#else
|
||||
COUNT index, scale;
|
||||
|
||||
CALC_ZOOM_STUFF (&index, &scale);
|
||||
COUNT index, scale = GSCALE_IDENTITY;
|
||||
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
index = zoom_out;
|
||||
else
|
||||
CALC_ZOOM_STUFF (&index, &scale);
|
||||
|
||||
ElementPtr->next.image.frame =
|
||||
#ifdef SAFE
|
||||
SetAbsFrameIndex (
|
||||
@@ -986,6 +928,7 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
||||
[index],
|
||||
ElementPtr->next.image.frame);
|
||||
#endif /* SAFE */
|
||||
|
||||
if (optMeleeScale == TFB_SCALE_TRILINEAR && index < 2 && scale != 256)
|
||||
{
|
||||
// enqueues drawcommand to assign next (smaller) zoom
|
||||
@@ -1009,7 +952,6 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
||||
TFB_EnqueueDrawCommand (&DC);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
DisplayArray[ElementPtr->PrimIndex].Object.Stamp.frame =
|
||||
ElementPtr->next.image.frame;
|
||||
@@ -1040,11 +982,16 @@ InitDisplayList (void)
|
||||
{
|
||||
COUNT i;
|
||||
|
||||
#ifdef OLD_ZOOM
|
||||
GLOBAL (cur_state) = MAX_VIS_REDUCTION + 1;
|
||||
#else
|
||||
zoom_out = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT);
|
||||
#endif
|
||||
if (optMeleeScale == TFB_SCALE_STEP)
|
||||
{
|
||||
zoom_out = MAX_VIS_REDUCTION + 1;
|
||||
opt_max_zoom_out = MAX_VIS_REDUCTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
zoom_out = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT);
|
||||
opt_max_zoom_out = MAX_ZOOM_OUT;
|
||||
}
|
||||
|
||||
ReinitQueue (&disp_q);
|
||||
|
||||
@@ -1083,14 +1030,15 @@ RedrawQueue (BOOLEAN clear)
|
||||
nth_frame += skip_frames;
|
||||
if (clear)
|
||||
ClearDrawable (); // this is for BATCH_BUILD_PAGE effect, but not scaled by SetGraphicScale
|
||||
#ifndef OLD_ZOOM
|
||||
|
||||
if (optMeleeScale != TFB_SCALE_STEP)
|
||||
{
|
||||
COUNT index, scale;
|
||||
|
||||
CALC_ZOOM_STUFF (&index, &scale);
|
||||
SetGraphicScale (scale);
|
||||
}
|
||||
#endif
|
||||
|
||||
DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE);
|
||||
SetGraphicScale (0);
|
||||
}
|
||||
|
||||
@@ -414,6 +414,8 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
|
||||
options->meleeScale = TFB_SCALE_NEAREST;
|
||||
else if (!strcmp (optarg, "trilinear"))
|
||||
options->meleeScale = TFB_SCALE_TRILINEAR;
|
||||
else if (!strcmp (optarg, "step") || !strcmp (optarg, "pc"))
|
||||
options->meleeScale = TFB_SCALE_STEP;
|
||||
else
|
||||
{
|
||||
InvalidArgument(optarg, "--meleescale or -b");
|
||||
|
||||
Reference in New Issue
Block a user