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:
avolkov
2005-04-01 07:34:44 +00:00
parent e186d6eb30
commit 52d87d5b5c
5 changed files with 263 additions and 369 deletions
+95 -153
View File
@@ -22,11 +22,16 @@
#include "globdata.h" #include "globdata.h"
#include "init.h" #include "init.h"
#include "units.h" #include "units.h"
#include "options.h"
#include "libs/compiler.h" #include "libs/compiler.h"
#include "libs/gfxlib.h" #include "libs/gfxlib.h"
#include "libs/graphics/gfx_common.h"
#include "libs/mathlib.h" #include "libs/mathlib.h"
extern COUNT zoom_out;
extern PRIM_LINKS DisplayLinks;
//Added by Chris //Added by Chris
void InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI); void InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI);
@@ -283,101 +288,108 @@ InitGalaxy (void)
SortStarBlock (&StarBlock[2]); 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 void
MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy) MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
{ {
PPRIMITIVE pprim; 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) if (view_state != VIEW_STABLE)
{ {
#ifdef OLD_ZOOM
BYTE reduction;
#else
COUNT reduction; COUNT reduction;
#endif
COUNT i; COUNT i;
COUNT iss;
PPOINT ppt; PPOINT ppt;
int wrap_around;
#ifdef OLD_ZOOM
reduction = GLOBAL (cur_state);
#else
{
extern COUNT zoom_out;
reduction = zoom_out; reduction = zoom_out;
}
#endif
if (view_state == VIEW_CHANGE) if (view_state == VIEW_CHANGE)
{ {
pprim = DisplayArray;
i = BIG_STAR_COUNT;
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
{ {
do for (iss = 0, pprim = DisplayArray; iss < 2; ++iss)
{ {
pprim->Object.Stamp.frame = for (i = star_counts[iss]; i > 0; --i, ++pprim)
SetAbsFrameIndex (stars_in_space,
((COUNT)TFB_Random () & 31) + (32 + 26));
++pprim;
} while (--i);
i = MED_STAR_COUNT;
do
{ {
pprim->Object.Stamp.frame = pprim->Object.Stamp.frame = SetAbsFrameIndex (
SetAbsFrameIndex (stars_in_space, stars_in_space,
((COUNT)TFB_Random () & 31) + 26); (COUNT)(TFB_Random () & 31)
++pprim; + star_frame_ofs[iss]);
} while (--i); }
}
} }
else else
{ {
GRAPHICS_PRIM star_object, big_star_obj; GRAPHICS_PRIM star_object[2];
FRAME star_frame; FRAME star_frame[2];
star_frame = stars_in_space; star_frame[0] = IncFrameIndex (stars_in_space);
#ifdef OLD_ZOOM star_frame[1] = stars_in_space;
big_star_obj = STAMP_PRIM;
if (optMeleeScale == TFB_SCALE_STEP)
{ /* on PC, the closest stars are images when zoomed out */
star_object[0] = STAMP_PRIM;
if (reduction > 0) if (reduction > 0)
star_object = POINT_PRIM; {
star_object[1] = POINT_PRIM;
star_frame[0] = star_frame[1];
}
else else
{ {
star_frame = IncFrameIndex (star_frame); star_object[1] = STAMP_PRIM;
star_object = STAMP_PRIM;
} }
#else }
else
{ /* on 3DO, the closest stars are pixels when zoomed out */
star_object[1] = POINT_PRIM;
if (reduction > (1 << ZOOM_SHIFT)) if (reduction > (1 << ZOOM_SHIFT))
big_star_obj = star_object = POINT_PRIM; {
star_object[0] = POINT_PRIM;
}
else else
{ {
big_star_obj = star_object = STAMP_PRIM; star_object[0] = STAMP_PRIM;
star_frame = IncFrameIndex (star_frame); }
star_object = POINT_PRIM;
} }
#endif
do for (iss = 0, pprim = DisplayArray; iss < 2; ++iss)
{ {
SetPrimType (pprim, big_star_obj); for (i = star_counts[iss]; i > 0; --i, ++pprim)
pprim->Object.Stamp.frame = star_frame;
++pprim;
} while (--i);
pprim = &DisplayArray[BIG_STAR_COUNT];
i = MED_STAR_COUNT;
do
{ {
SetPrimType (pprim, star_object); SetPrimType (pprim, star_object[iss]);
++pprim; pprim->Object.Stamp.frame = star_frame[iss];
} while (--i); }
}
} }
} }
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
{ {
pprim = DisplayArray; for (i = BIG_STAR_COUNT + MED_STAR_COUNT, pprim = DisplayArray;
i = BIG_STAR_COUNT + MED_STAR_COUNT; i > 0; --i, ++pprim)
do
{ {
COUNT base_index; COUNT base_index;
@@ -385,8 +397,7 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
pprim->Object.Stamp.frame = pprim->Object.Stamp.frame =
SetAbsFrameIndex (pprim->Object.Stamp.frame, SetAbsFrameIndex (pprim->Object.Stamp.frame,
((base_index & ~31) + ((base_index + 1) & 31)) + 26); ((base_index & ~31) + ((base_index + 1) & 31)) + 26);
++pprim; }
} while (--i);
dx <<= 3; dx <<= 3;
dy <<= 3; dy <<= 3;
@@ -400,11 +411,10 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
{ {
dx = SpaceOrg.x; dx = SpaceOrg.x;
dy = SpaceOrg.y; dy = SpaceOrg.y;
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
reduction += ONE_SHIFT; reduction += ONE_SHIFT;
#else else
reduction <<= ONE_SHIFT; reduction <<= ONE_SHIFT;
#endif
} }
else else
{ {
@@ -414,110 +424,42 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
dy = (COORD)(LOG_SPACE_HEIGHT >> 1) dy = (COORD)(LOG_SPACE_HEIGHT >> 1)
- (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1) - (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1)
- MAX_VIS_REDUCTION)); - MAX_VIS_REDUCTION));
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
reduction = (COUNT)(MAX_VIS_REDUCTION + ONE_SHIFT); reduction = MAX_VIS_REDUCTION + ONE_SHIFT;
#else else
reduction = MAX_ZOOM_OUT << ONE_SHIFT; reduction = MAX_ZOOM_OUT << ONE_SHIFT;
#endif
} }
ppt = log_star_array; ppt = log_star_array;
pprim = DisplayArray; for (iss = 0, pprim = DisplayArray, wrap_around = LOG_SPACE_WIDTH;
iss < 3 &&
if (view_state == VIEW_CHANGE (view_state == VIEW_CHANGE || CmpMovePoints (
#ifdef OLD_ZOOM &pprim->Object.Point, ppt, dx, dy, reduction));
|| (int)pprim->Object.Point.x != (int)((ppt->x - dx) >> reduction) ++iss, wrap_around <<= 1, dx <<= 1, dy <<= 1)
|| (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
{ {
i = BIG_STAR_COUNT; for (i = star_counts[iss]; i > 0; --i, ++pprim, ++ppt)
do
{ {
// ppt->x &= (LOG_SPACE_WIDTH - 1); // ppt->x &= (LOG_SPACE_WIDTH - 1);
ppt->x = WRAP_VAL (ppt->x, LOG_SPACE_WIDTH); ppt->x = WRAP_VAL (ppt->x, wrap_around);
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
{
pprim->Object.Point.x = (ppt->x - dx) >> reduction; pprim->Object.Point.x = (ppt->x - dx) >> reduction;
pprim->Object.Point.y = (ppt->y - dy) >> reduction; pprim->Object.Point.y = (ppt->y - dy) >> reduction;
#else }
pprim->Object.Point.x = ((ppt->x - dx) << ZOOM_SHIFT) / reduction; else
pprim->Object.Point.y = ((ppt->y - dy) << ZOOM_SHIFT) / reduction; {
#endif pprim->Object.Point.x = ((ppt->x - dx) << ZOOM_SHIFT)
++pprim, ++ppt; / reduction;
} while (--i); pprim->Object.Point.y = ((ppt->y - dy) << ZOOM_SHIFT)
dx <<= 1; / reduction;
dy <<= 1; }
#ifdef OLD_ZOOM }
if (optMeleeScale == TFB_SCALE_STEP)
++reduction; ++reduction;
#else else
reduction <<= 1; 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) - 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
{
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);
} }
} }
}
}
{
extern PRIM_LINKS DisplayLinks;
DisplayLinks = MakeLinks (NUM_STARS - 1, 0); DisplayLinks = MakeLinks (NUM_STARS - 1, 0);
} }
}
+1
View File
@@ -877,6 +877,7 @@ typedef UWORD ACTIVITY;
typedef struct typedef struct
{ {
// XXX: cur_state is obsolete now and was replaced by process.c:zoom_out
BYTE cur_state, glob_flags; BYTE cur_state, glob_flags;
BYTE CrewCost, FuelCost; BYTE CrewCost, FuelCost;
+1
View File
@@ -33,6 +33,7 @@ typedef enum {
} SCREEN; } SCREEN;
typedef enum { typedef enum {
TFB_SCALE_STEP, /* not really a scaler */
TFB_SCALE_NEAREST, TFB_SCALE_NEAREST,
TFB_SCALE_TRILINEAR TFB_SCALE_TRILINEAR
} SCALE; } SCALE;
+94 -146
View File
@@ -36,37 +36,36 @@ COUNT DisplayFreeList;
PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS];
extern POINT SpaceOrg; extern POINT SpaceOrg;
#ifndef OLD_ZOOM
SIZE zoom_out = 1 << ZOOM_SHIFT; SIZE zoom_out = 1 << ZOOM_SHIFT;
#endif static SIZE opt_max_zoom_out;
#if 0 #if 0
#define CALC_ZOOM_STUFF(idx,sc) \ static void inline
do \ CALC_ZOOM_STUFF (COUNT* idx, COUNT* sc)
{ \ {
int i, z; \ int i, z;
\
z = 1 << ZOOM_SHIFT; \ z = 1 << ZOOM_SHIFT;
for (i = 0; (z <<= 1) <= zoom_out; i++) \ for (i = 0; (z <<= 1) <= zoom_out; i++)
; \ ;
*(idx) = i; \ *idx = i;
*(sc) = ((1 << i) << (ZOOM_SHIFT + 8)) / zoom_out; \ *sc = ((1 << i) << (ZOOM_SHIFT + 8)) / zoom_out;
} while (0) }
#else #else
#define CALC_ZOOM_STUFF(idx,sc) \ static void inline
do \ CALC_ZOOM_STUFF (COUNT* idx, COUNT* sc)
{ \ {
int i; \ int i;
\
if (zoom_out < 2 << ZOOM_SHIFT) \ if (zoom_out < 2 << ZOOM_SHIFT)
i = 0; \ i = 0;
else if (zoom_out < 4 << ZOOM_SHIFT) \ else if (zoom_out < 4 << ZOOM_SHIFT)
i = 1; \ i = 1;
else \ else
i = 2; \ i = 2;
*(idx) = i; \ *idx = i;
*(sc) = (1 << (i + ZOOM_SHIFT + 8)) / zoom_out; \ *sc = (1 << (i + ZOOM_SHIFT + 8)) / zoom_out;
} while (0) }
#endif #endif
HELEMENT HELEMENT
@@ -195,16 +194,17 @@ PostProcess (ELEMENTPTR ElementPtr)
| POST_PROCESS; | POST_PROCESS;
} }
#ifdef OLD_ZOOM
static BYTE
CalcReduction (SIZE dx, SIZE dy)
#else
static COUNT static COUNT
CalcReduction (SIZE dx, SIZE dy) CalcReduction (SIZE dx, SIZE dy)
#endif
{ {
#ifdef OLD_ZOOM COUNT next_reduction;
BYTE next_reduction;
#ifdef KDEBUG
fprintf (stderr, "CalcReduction:\n");
#endif
if (optMeleeScale == TFB_SCALE_STEP)
{
SIZE sdx, sdy; SIZE sdx, sdy;
if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER) if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER)
@@ -220,8 +220,8 @@ CalcReduction (SIZE dx, SIZE dy)
; ;
/* check for "real" zoom in */ /* check for "real" zoom in */
if (next_reduction < GLOBAL (cur_state) if (next_reduction < zoom_out
&& GLOBAL (cur_state) <= MAX_VIS_REDUCTION) && zoom_out <= MAX_VIS_REDUCTION)
{ {
#define HYSTERESIS_X DISPLAY_TO_WORLD(24) #define HYSTERESIS_X DISPLAY_TO_WORLD(24)
#define HYSTERESIS_Y DISPLAY_TO_WORLD(20) #define HYSTERESIS_Y DISPLAY_TO_WORLD(20)
@@ -236,11 +236,9 @@ CalcReduction (SIZE dx, SIZE dy)
if (next_reduction == 0 if (next_reduction == 0
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE) && LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
next_reduction += REDUCTION_SHIFT; next_reduction += REDUCTION_SHIFT;
#else }
COUNT next_reduction; else
#ifdef KDEBUG {
fprintf (stderr, "CalcReduction:\n");
#endif
if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER) if (LOBYTE (GLOBAL (CurrentActivity)) > IN_ENCOUNTER)
return (1 << ZOOM_SHIFT); return (1 << ZOOM_SHIFT);
@@ -264,23 +262,18 @@ CalcReduction (SIZE dx, SIZE dy)
if (next_reduction < (2 << ZOOM_SHIFT) if (next_reduction < (2 << ZOOM_SHIFT)
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE) && LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
next_reduction = (2 << ZOOM_SHIFT); next_reduction = (2 << ZOOM_SHIFT);
}
#ifdef KDEBUG #ifdef KDEBUG
fprintf (stderr, "CalcReduction: exit\n"); fprintf (stderr, "CalcReduction: exit\n");
#endif
#endif #endif
return (next_reduction); 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 static VIEW_STATE
CalcView (PPOINT pNewScrollPt, SIZE next_reduction, CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
PSIZE pdx, PSIZE pdy, COUNT ships_alive) PSIZE pdx, PSIZE pdy, COUNT ships_alive)
#endif
{ {
SIZE dx, dy; SIZE dx, dy;
VIEW_STATE view_state; VIEW_STATE view_state;
@@ -309,24 +302,23 @@ CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
if ((dx || dy) && LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) if ((dx || dy) && LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
MoveSIS (&dx, &dy); MoveSIS (&dx, &dy);
#ifdef OLD_ZOOM
if (GLOBAL (cur_state) == next_reduction)
#else
if (zoom_out == next_reduction) if (zoom_out == next_reduction)
#endif
view_state = dx == 0 && dy == 0 view_state = dx == 0 && dy == 0
&& LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE && LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE
? VIEW_STABLE : VIEW_SCROLL; ? VIEW_STABLE : VIEW_SCROLL;
else else
{ {
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
GLOBAL (cur_state) = next_reduction; {
SpaceOrg.x = (COORD)(LOG_SPACE_WIDTH >> 1) SpaceOrg.x = (COORD)(LOG_SPACE_WIDTH >> 1)
- (LOG_SPACE_WIDTH >> ((MAX_REDUCTION + 1) - next_reduction)); - (LOG_SPACE_WIDTH >> ((MAX_REDUCTION + 1)
- next_reduction));
SpaceOrg.y = (COORD)(LOG_SPACE_HEIGHT >> 1) SpaceOrg.y = (COORD)(LOG_SPACE_HEIGHT >> 1)
- (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1) - next_reduction)); - (LOG_SPACE_HEIGHT >> ((MAX_REDUCTION + 1)
#else - next_reduction));
}
else
{
#define ZOOM_JUMP ((1 << ZOOM_SHIFT) >> 3) #define ZOOM_JUMP ((1 << ZOOM_SHIFT) >> 3)
if (ships_alive == 1 if (ships_alive == 1
&& zoom_out > next_reduction && zoom_out > next_reduction
@@ -334,14 +326,12 @@ CalcView (PPOINT pNewScrollPt, SIZE next_reduction,
&& zoom_out - next_reduction > ZOOM_JUMP) && zoom_out - next_reduction > ZOOM_JUMP)
next_reduction = zoom_out - ZOOM_JUMP; next_reduction = zoom_out - ZOOM_JUMP;
zoom_out = next_reduction;
SpaceOrg.x = (int)(LOG_SPACE_WIDTH >> 1) SpaceOrg.x = (int)(LOG_SPACE_WIDTH >> 1)
- (LOG_SPACE_WIDTH * next_reduction / (MAX_ZOOM_OUT << 2)); - (LOG_SPACE_WIDTH * next_reduction / (MAX_ZOOM_OUT << 2));
SpaceOrg.y = (int)(LOG_SPACE_HEIGHT >> 1) SpaceOrg.y = (int)(LOG_SPACE_HEIGHT >> 1)
- (LOG_SPACE_HEIGHT * next_reduction / (MAX_ZOOM_OUT << 2)); - (LOG_SPACE_HEIGHT * next_reduction / (MAX_ZOOM_OUT << 2));
#endif }
zoom_out = next_reduction;
view_state = VIEW_CHANGE; view_state = VIEW_CHANGE;
} }
@@ -630,11 +620,7 @@ ProcessCollisions (HELEMENT hSuccElement, ELEMENTPTR ElementPtr,
static VIEW_STATE static VIEW_STATE
PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y) PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
{ {
#ifdef OLD_ZOOM
BYTE min_reduction, max_reduction;
#else
SIZE min_reduction, max_reduction; SIZE min_reduction, max_reduction;
#endif
COUNT num_ships; COUNT num_ships;
POINT Origin; POINT Origin;
HELEMENT hElement; HELEMENT hElement;
@@ -646,11 +632,11 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
num_ships = (LOBYTE (battle_counter) ? 1 : 0) num_ships = (LOBYTE (battle_counter) ? 1 : 0)
+ (HIBYTE (battle_counter) ? 1 : 0); + (HIBYTE (battle_counter) ? 1 : 0);
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
min_reduction = max_reduction = MAX_VIS_REDUCTION + 1; min_reduction = max_reduction = MAX_VIS_REDUCTION + 1;
#else else
min_reduction = max_reduction = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT); min_reduction = max_reduction = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT);
#endif
Origin.x = (COORD)(LOG_SPACE_WIDTH >> 1); Origin.x = (COORD)(LOG_SPACE_WIDTH >> 1);
Origin.y = (COORD)(LOG_SPACE_HEIGHT >> 1); Origin.y = (COORD)(LOG_SPACE_HEIGHT >> 1);
@@ -677,13 +663,8 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
SIZE dx, dy; SIZE dx, dy;
ships_alive++; ships_alive++;
#ifdef OLD_ZOOM if (max_reduction > opt_max_zoom_out
if (max_reduction > MAX_VIS_REDUCTION && min_reduction > opt_max_zoom_out)
&& min_reduction > MAX_VIS_REDUCTION)
#else
if (max_reduction > MAX_ZOOM_OUT
&& min_reduction > MAX_ZOOM_OUT)
#endif
{ {
Origin.x = DISPLAY_ALIGN (ElementPtr->next.location.x); Origin.x = DISPLAY_ALIGN (ElementPtr->next.location.x);
Origin.y = DISPLAY_ALIGN (ElementPtr->next.location.y); Origin.y = DISPLAY_ALIGN (ElementPtr->next.location.y);
@@ -705,13 +686,8 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
dy = -dy; dy = -dy;
max_reduction = CalcReduction (dx, dy); max_reduction = CalcReduction (dx, dy);
} }
#ifdef OLD_ZOOM else if (max_reduction > opt_max_zoom_out
else if (max_reduction > MAX_VIS_REDUCTION && min_reduction <= opt_max_zoom_out)
&& min_reduction <= MAX_VIS_REDUCTION)
#else
else if (max_reduction > MAX_ZOOM_OUT
&& min_reduction <= MAX_ZOOM_OUT)
#endif
{ {
Origin.x = DISPLAY_ALIGN (Origin.x + (dx >> 1)); Origin.x = DISPLAY_ALIGN (Origin.x + (dx >> 1));
Origin.y = DISPLAY_ALIGN (Origin.y + (dy >> 1)); Origin.y = DISPLAY_ALIGN (Origin.y + (dy >> 1));
@@ -724,11 +700,7 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
} }
else else
{ {
#ifdef OLD_ZOOM
BYTE reduction;
#else
SIZE reduction; SIZE reduction;
#endif
if (dx < 0) if (dx < 0)
dx = -dx; dx = -dx;
@@ -736,13 +708,8 @@ PreProcessQueue (PSIZE pscroll_x, PSIZE pscroll_y)
dy = -dy; dy = -dy;
reduction = CalcReduction (dx << 1, dy << 1); reduction = CalcReduction (dx << 1, dy << 1);
#ifdef OLD_ZOOM if (min_reduction > opt_max_zoom_out
if (min_reduction > MAX_VIS_REDUCTION
|| reduction < min_reduction) || reduction < min_reduction)
#else
if (min_reduction > MAX_ZOOM_OUT
|| reduction < min_reduction)
#endif
min_reduction = reduction; min_reduction = reduction;
} }
// fprintf (stderr, "dx = %d dy = %d min_red = %d max_red = %d\n", // 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; hElement = hNextElement;
} }
#ifdef OLD_ZOOM if ((min_reduction > opt_max_zoom_out || min_reduction <= max_reduction)
if ((min_reduction > MAX_VIS_REDUCTION || min_reduction <= max_reduction) && (min_reduction = max_reduction) > opt_max_zoom_out
&& (min_reduction = max_reduction) > MAX_VIS_REDUCTION && (min_reduction = zoom_out) > opt_max_zoom_out)
&& (min_reduction = GLOBAL (cur_state)) > MAX_VIS_REDUCTION) if (optMeleeScale == TFB_SCALE_STEP)
min_reduction = 0; min_reduction = 0;
#else 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; min_reduction = 1 << ZOOM_SHIFT;
#endif
#ifdef KDEBUG #ifdef KDEBUG
fprintf (stderr, "PreProcess: exit\n"); fprintf (stderr, "PreProcess: exit\n");
@@ -808,44 +771,34 @@ InsertPrim (PRIM_LINKS *pLinks, COUNT primIndex, COUNT iPI)
PRIM_LINKS DisplayLinks; 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 static inline COORD
CalcDisplayCoord (COORD c, COORD orgc, SIZE reduction) CalcDisplayCoord (COORD c, COORD orgc, SIZE 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; return ((c - orgc) << ZOOM_SHIFT) / reduction;
} }
#endif /* OLD_ZOOM */ }
static void static void
PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x, PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
SIZE scroll_y) SIZE scroll_y)
{ {
POINT delta; POINT delta;
#ifdef OLD_ZOOM
BYTE reduction;
#else
SIZE reduction; SIZE reduction;
#endif
HELEMENT hElement; HELEMENT hElement;
#ifdef KDEBUG #ifdef KDEBUG
fprintf (stderr, "PostProcess:\n"); fprintf (stderr, "PostProcess:\n");
#endif #endif
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
reduction = (BYTE)(GLOBAL (cur_state) + ONE_SHIFT); reduction = zoom_out + ONE_SHIFT;
#else else
reduction = zoom_out << ONE_SHIFT; reduction = zoom_out << ONE_SHIFT;
#endif
hElement = GetHeadElement (); hElement = GetHeadElement ();
while (hElement != 0) while (hElement != 0)
@@ -951,29 +904,18 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
DisplayArray[ElementPtr->PrimIndex].Object.Point.y = DisplayArray[ElementPtr->PrimIndex].Object.Point.y =
CalcDisplayCoord (next.y, SpaceOrg.y, reduction); CalcDisplayCoord (next.y, SpaceOrg.y, reduction);
if (ObjType == STAMP_PRIM if (ObjType == STAMP_PRIM || ObjType == STAMPFILL_PRIM)
|| ObjType == STAMPFILL_PRIM)
{ {
if (view_state == VIEW_CHANGE if (view_state == VIEW_CHANGE
|| (state_flags & (APPEARING | CHANGING))) || (state_flags & (APPEARING | CHANGING)))
{ {
#ifdef OLD_ZOOM COUNT index, scale = GSCALE_IDENTITY;
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;
if (optMeleeScale == TFB_SCALE_STEP)
index = zoom_out;
else
CALC_ZOOM_STUFF (&index, &scale); CALC_ZOOM_STUFF (&index, &scale);
ElementPtr->next.image.frame = ElementPtr->next.image.frame =
#ifdef SAFE #ifdef SAFE
SetAbsFrameIndex ( SetAbsFrameIndex (
@@ -986,6 +928,7 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
[index], [index],
ElementPtr->next.image.frame); ElementPtr->next.image.frame);
#endif /* SAFE */ #endif /* SAFE */
if (optMeleeScale == TFB_SCALE_TRILINEAR && index < 2 && scale != 256) if (optMeleeScale == TFB_SCALE_TRILINEAR && index < 2 && scale != 256)
{ {
// enqueues drawcommand to assign next (smaller) zoom // enqueues drawcommand to assign next (smaller) zoom
@@ -1009,7 +952,6 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
TFB_EnqueueDrawCommand (&DC); TFB_EnqueueDrawCommand (&DC);
} }
} }
#endif
} }
DisplayArray[ElementPtr->PrimIndex].Object.Stamp.frame = DisplayArray[ElementPtr->PrimIndex].Object.Stamp.frame =
ElementPtr->next.image.frame; ElementPtr->next.image.frame;
@@ -1040,11 +982,16 @@ InitDisplayList (void)
{ {
COUNT i; COUNT i;
#ifdef OLD_ZOOM if (optMeleeScale == TFB_SCALE_STEP)
GLOBAL (cur_state) = MAX_VIS_REDUCTION + 1; {
#else zoom_out = MAX_VIS_REDUCTION + 1;
opt_max_zoom_out = MAX_VIS_REDUCTION;
}
else
{
zoom_out = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT); zoom_out = MAX_ZOOM_OUT + (1 << ZOOM_SHIFT);
#endif opt_max_zoom_out = MAX_ZOOM_OUT;
}
ReinitQueue (&disp_q); ReinitQueue (&disp_q);
@@ -1083,14 +1030,15 @@ RedrawQueue (BOOLEAN clear)
nth_frame += skip_frames; nth_frame += skip_frames;
if (clear) if (clear)
ClearDrawable (); // this is for BATCH_BUILD_PAGE effect, but not scaled by SetGraphicScale ClearDrawable (); // this is for BATCH_BUILD_PAGE effect, but not scaled by SetGraphicScale
#ifndef OLD_ZOOM
if (optMeleeScale != TFB_SCALE_STEP)
{ {
COUNT index, scale; COUNT index, scale;
CALC_ZOOM_STUFF (&index, &scale); CALC_ZOOM_STUFF (&index, &scale);
SetGraphicScale (scale); SetGraphicScale (scale);
} }
#endif
DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE); DrawBatch (DisplayArray, DisplayLinks, 0);//BATCH_BUILD_PAGE);
SetGraphicScale (0); SetGraphicScale (0);
} }
+2
View File
@@ -414,6 +414,8 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
options->meleeScale = TFB_SCALE_NEAREST; options->meleeScale = TFB_SCALE_NEAREST;
else if (!strcmp (optarg, "trilinear")) else if (!strcmp (optarg, "trilinear"))
options->meleeScale = TFB_SCALE_TRILINEAR; options->meleeScale = TFB_SCALE_TRILINEAR;
else if (!strcmp (optarg, "step") || !strcmp (optarg, "pc"))
options->meleeScale = TFB_SCALE_STEP;
else else
{ {
InvalidArgument(optarg, "--meleescale or -b"); InvalidArgument(optarg, "--meleescale or -b");