Planet code cleanups, from PhracturedBlue

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@358 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-12-06 19:50:57 +00:00
parent 91566e4dbd
commit a449e7e461
4 changed files with 388 additions and 1119 deletions
@@ -198,9 +198,9 @@ Uint32 **getpixelarray(FRAMEPTR FramePtr,int width, int height)
img = ((TFB_Image *)((BYTE *)(FramePtr) + FramePtr->DataOffs))->NormalImg;
SDL_LockSurface (img);
getpix = getpixel_for (img);
map=(Uint32 **)malloc(sizeof(Uint32 *)*(height+1));
map=(Uint32 **)HMalloc(sizeof(Uint32 *)*(height+1));
for (y=0;y<height;y++) {
map[y]=(Uint32 *)calloc(width,sizeof(Uint32));
map[y]=(Uint32 *)HCalloc(width*sizeof(Uint32));
if(y>=img->h) {
continue;
}
+25 -756
View File
@@ -16,501 +16,28 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//#include "Portfolio.h" //A 3DO library we don't care about
//#include "Init3DO.h"
//#include "Parse3DO.h"
//#include "Utils3DO.h"
//#include "filefunctions.h"
//#include "BlockFile.h"
#include "starcon.h"
#include "libs/graphics/gfx_common.h"
#include "libs/graphics/drawable.h"
#define PLANET_SPIN 0
#define PLANET_SPIN_DEBUG 1
//Added by Chris
//End Added by Chris
//#define KDEBUG
//#define SCALE_ROTATE
//#define SCREEN_WIDTH 320
#define WIDTH 210
#define HEIGHT 67
#define XBANDS 6
#define SPHERE_HEIGHT (HEIGHT + 10)
#define SPHERE_WIDTH SPHERE_HEIGHT
#define WRAP_EXTRA 20
#define LINE_PIXELS ((WIDTH + WRAP_EXTRA + 3) & ~3)
#define SURFACE_WIDTH 210
#define SURFACE_HEIGHT 124
#define SURFACE_SHIFT 2
#define SURFACE_UNIT (1 << SURFACE_SHIFT)
#define SURFACE_ADD (SURFACE_UNIT - 1)
#define NUM_TINTS 4
#define PIXC_DUP(v) (((unsigned int)(v) << PPMP_0_SHIFT) | ((unsigned int)(v) << PPMP_1_SHIFT))
#define PIXC_UNCODED16 (PIXC_DUP (PPMPC_MF_8 | PPMPC_SF_8))
#define PIXC_UNCODED8 (PIXC_DUP (PPMPC_MF_8 | PPMPC_SF_8))
#define PIXC_CODED (PIXC_DUP (PPMPC_MS_PIN | PPMPC_SF_8))
#define SET_CEL_FLAGS(c,f) ((c)->ccb_Flags |= (f))
#define CLR_CEL_FLAGS(c,f) ((c)->ccb_Flags &= ~(f))
#define CEL_FLAGS \
(CCB_SPABS | CCB_PPABS | CCB_YOXY | CCB_ACW | CCB_ACCW | CCB_LDSIZE | CCB_CCBPRE \
| CCB_LDPRS | CCB_LDPPMP | CCB_ACE | CCB_LCE | CCB_PLUTPOS | CCB_BGND | CCB_NPABS \
/*| CCB_NOBLK*/)
#define MAP_CEL myMapCel
#define NUM_ROTATE_CELS (138) // derived empirically!
#define NUM_CELS (NUM_ROTATE_CELS * 2) // must be at least 257 for oscilloscope
#define MIN_Y (-(SURFACE_HEIGHT >> 1))
#define MAX_Y ((HEIGHT << SURFACE_SHIFT) - (SURFACE_HEIGHT >> 1))
#define PULSE_SCALE (2)
#define SCALE_PULSE_RED(r) ((r)<<PULSE_SCALE)
#define MIN_PULSE_RED (SCALE_PULSE_RED(2))
#define MAX_PULSE_RED (SCALE_PULSE_RED(7))
#define PULSE_NEG_BIT (1 << 7)
#define SOL 82
#define EARTH 2
#define LUNA 2
typedef struct
{
int x0[15], x1[15], y0[15], y1[15];
int ystep[15];
int src_ws[XBANDS];
CCB planet_ccb, surface_ccb, tint_ccb[NUM_TINTS];
CCB black_rect_ccb, black_circ_ccb, *pblack_circ_ccb, *pshield_ccb, *pshadow_ccb;
CCB repair_ccb[2];
int black_circ_plut[16];
UBYTE rmap[HEIGHT][LINE_PIXELS];
CCB *cur_ccb;
int old_sx, old_sy;
CCB plCCB[NUM_CELS];
CCB *last_zoom_ccb;
UBYTE zoom_batch;
#ifdef SCALE_ROTATE
int scale;
#endif
CCB *pcirc_ccb, *pblur_ccb;
} PLANET_STUFF;
static PLANET_STUFF *planet_stuff=NULL;
#define x0 (planet_stuff->x0)
#define x1 (planet_stuff->x1)
#define y0 (planet_stuff->y0)
#define y1 (planet_stuff->y1)
#define ystep (planet_stuff->ystep)
#define src_ws (planet_stuff->src_ws)
#define planet_ccb (planet_stuff->planet_ccb)
#define surface_ccb (planet_stuff->surface_ccb)
#define tint_ccb (planet_stuff->tint_ccb)
#define black_rect_ccb (planet_stuff->black_rect_ccb)
#define black_circ_ccb (planet_stuff->black_circ_ccb)
#define pshadow_ccb (planet_stuff->pshadow_ccb)
#define pshield_ccb (planet_stuff->pshield_ccb)
#define pblack_circ_ccb (planet_stuff->pblack_circ_ccb)
#define black_circ_plut (planet_stuff->black_circ_plut)
#define repair_ccb (planet_stuff->repair_ccb)
#define rmap (planet_stuff->rmap)
#define cur_ccb (planet_stuff->cur_ccb)
#define old_sx (planet_stuff->old_sx)
#define old_sy (planet_stuff->old_sy)
#define plCCB (planet_stuff->plCCB)
#define last_zoom_ccb (planet_stuff->last_zoom_ccb)
#define zoom_batch (planet_stuff->zoom_batch)
#define shield_pulse (zoom_batch)
#ifdef SCALE_ROTATE
#define scale (planet_stuff->scale)
#define SCALE_AMT_SHIFT 7
#define SCALE_AMT_MASK ((1<<(SCALE_AMT_SHIFT+1))-1)
#define SCALE_X_SHIFT 9
#define SCALE_X_MASK (3<<SCALE_X_SHIFT)
#define SCALE_Y_SHIFT 12
#define SCALE_Y_MASK (3<<SCALE_Y_SHIFT)
#define SCALE_MAX (1<<SCALE_AMT_SHIFT)
#define SCALE_STEP ((scale & SCALE_AMT_MASK) < (SCALE_MAX / 2) ? \
4 : ((scale & SCALE_AMT_MASK) < (SCALE_MAX * 3 / 4) ? \
3 : ((scale & SCALE_AMT_MASK) < (SCALE_MAX * 7 / 8) ? \
2 : 1)))
#define SCALE_CEL(ccb,cx,cy) \
do \
{ \
int s, _dx, _dy; \
\
s = scale & SCALE_AMT_MASK; \
_dx = (int)((scale & SCALE_X_MASK) >> SCALE_X_SHIFT) - 1; \
_dy = (int)((scale & SCALE_Y_MASK) >> SCALE_Y_SHIFT) - 1; \
(ccb)->ccb_XPos = (((ccb)->ccb_XPos - (cx)) * s) >> SCALE_AMT_SHIFT; \
(ccb)->ccb_YPos = (((ccb)->ccb_YPos - (cy)) * s) >> SCALE_AMT_SHIFT; \
if (_dx < 0) \
(ccb)->ccb_XPos += ((cx) * s) >> SCALE_AMT_SHIFT; \
else if (_dx > 0) \
(ccb)->ccb_XPos += ((cx) << 1) - (((cx) * s) >> SCALE_AMT_SHIFT); \
else \
(ccb)->ccb_XPos += (cx); \
if (_dy < 0) \
(ccb)->ccb_YPos += ((cy) * s) >> SCALE_AMT_SHIFT; \
else if (_dy > 0) \
(ccb)->ccb_YPos += ((cy) << 1) - (((cy) * s) >> SCALE_AMT_SHIFT); \
else \
(ccb)->ccb_YPos += (cy); \
(ccb)->ccb_HDX = ((ccb)->ccb_HDX * s) >> SCALE_AMT_SHIFT; \
(ccb)->ccb_VDY = ((ccb)->ccb_VDY * s) >> SCALE_AMT_SHIFT; \
(ccb)->ccb_VDX = ((ccb)->ccb_VDX * s) >> SCALE_AMT_SHIFT; \
(ccb)->ccb_HDY = ((ccb)->ccb_HDY * s) >> SCALE_AMT_SHIFT; \
(ccb)->ccb_HDDX = ((ccb)->ccb_HDDX * s) >> SCALE_AMT_SHIFT; \
(ccb)->ccb_HDDY = ((ccb)->ccb_HDDY * s) >> SCALE_AMT_SHIFT; \
} while (0)
#endif
#define pcirc_ccb (planet_stuff->pcirc_ccb)
#define pblur_ccb (planet_stuff->pblur_ccb)
#if PLANET_SPIN
void add_cel(CCB* cel) {}
void add_cels(CCB* first, CCB* last) {}
void myMapCel(CCB* myCCB, POINT Points[4]) {}
void OpenMathFolio(void) {}
static void
build_steps ()
{
int y, i, c, inc;
c = 1;
inc = 1;
y = 0;
for (i = 0; y < (HEIGHT >> 1); ++i)
{
ystep[i] = c;
y += c;
if (y > (HEIGHT >> 2) && inc == 1)
{
y -= c;
ystep[i] = ((HEIGHT >> 1) - (y << 1));
if (ystep[i] == 0)
--i;
else
y += ystep[i];
inc = -1;
}
c += inc;
}
ystep[i] = 1;
#if PLANET_SPIN_DEBUG
y = 0;
for (i = 0; y < (HEIGHT >> 1); i++)
{
fprintf (stderr, "ystep[%ld] = %ld\n", i, ystep[i]);
y += ystep[i];
}
#endif
}
static void
build_tables (int da)
{
int y, i;
build_steps ();
OpenMathFolio (); // calling this multiply is not a problem, right?
for (y = 0, i = 0; y <= (HEIGHT >> 1); i++)
{
int dx, dy, a, h;
h = ystep[i];
if (y + h > (HEIGHT >> 1)
&& (h = (HEIGHT >> 1) - y + 1) == 0)
return;
dy = (HEIGHT >> 1) - y;
dx = (int)SqrtF16 (((HEIGHT >> 1) * (HEIGHT >> 1) - dy * dy) << 16);
dy <<= 16;
a = (int)Atan2F16 (-dx, -dy);
a += da << 16;
x0[i] = (int)(HEIGHT * CosF16 (a));
y0[i] = (int)(HEIGHT * SinF16 (a));
a = (int)Atan2F16 (dx, -dy);
a += da << 16;
x1[i] = (int)(HEIGHT * CosF16 (a));
y1[i] = (int)(HEIGHT * SinF16 (a));
x0[i] >>= 1;
y0[i] >>= 1;
x1[i] >>= 1;
y1[i] >>= 1;
y += h;
#if PLANET_SPIN_DEBUG
fprintf (stderr, "%ld: %ld ", i, y);
fprintf (stderr, "%ld,%ld -- ", x0[i] >> 16, y0[i] >> 16);
fprintf (stderr, "%ld,%ld\n", x1[i] >> 16, y1[i] >> 16);
#endif
}
x0[i] = x0[i - 1];
y0[i] = y0[i - 1];
x1[i] = x1[i - 1];
y1[i] = y1[i - 1];
}
static void
draw_band (int src_x, int src_y, int dst_cx, int dst_cy)
{
//I_CANNOT_FIGURE_OUT_HOW_TO_FIX_THIS_FILE___STREAM???();
int *sp;
int i;
sp = (int *)planet_ccb.ccb_SourcePtr + src_y * (LINE_PIXELS >> 1);
for (i = 0; i < XBANDS; i++)
{
#define src_w src_ws[i]
cur_ccb->ccb_SourcePtr = (CelData *)(sp + (src_x >> 1));
cur_ccb->ccb_XPos = dst_cx + cur_ccb->ccb_Width;
cur_ccb->ccb_YPos = dst_cy + cur_ccb->ccb_Height;
#ifdef SCALE_ROTATE
if (scale)
SCALE_CEL (cur_ccb, dst_cx, dst_cy);
#endif
cur_ccb++;
src_x += src_w;
if (src_x >= WIDTH)
src_x -= WIDTH;
else if (src_x < 0)
src_x += WIDTH;
}
}
static void
set_band_cels (int src_y, int src_h, int band)
{
int i, dst_x0, dst_y0, dst_x1, dst_y1, dx0, dy0, dx1, dy1;
if (src_y > (HEIGHT >> 1))
{
if (src_y + src_h > HEIGHT
&& (src_h = HEIGHT - src_y + 1) == 0)
return;
dx0 = x1[band + 1];
dy0 = y1[band + 1];
dx1 = x1[band];
dy1 = y1[band];
dst_x0 = -dx0;
dst_y0 = -dy0;
dst_x1 = -dx1;
dst_y1 = -dy1;
dx0 -= x0[band + 1];
dy0 -= y0[band + 1];
dx1 -= x0[band];
dy1 -= y0[band];
}
else
{
if (src_y + src_h > (HEIGHT >> 1)
&& (src_h = (HEIGHT >> 1) - src_y + 1) == 0)
return;
dx0 = x0[band];
dy0 = y0[band];
dx1 = x0[band + 1];
dy1 = y0[band + 1];
dst_x0 = dx0;
dst_y0 = dy0;
dst_x1 = dx1;
dst_y1 = dy1;
dx0 = x1[band] - dx0;
dy0 = y1[band] - dy0;
dx1 = x1[band + 1] - dx1;
dy1 = y1[band + 1] - dy1;
}
for (i = 0; i < XBANDS; i++)
{
#define dd d[i]
#define src_w src_ws[i]
POINT quadpts[4];
int d[XBANDS] = { 17, 47, 64, 64, 47, 17 };
quadpts[0].x = dst_x0;
quadpts[0].y = dst_y0;
quadpts[3].x = dst_x1;
quadpts[3].y = dst_y1;
dst_x0 += (dx0 * dd) >> 8;
dst_y0 += (dy0 * dd) >> 8;
dst_x1 += (dx1 * dd) >> 8;
dst_y1 += (dy1 * dd) >> 8;
quadpts[1].x = dst_x0;
quadpts[1].y = dst_y0;
quadpts[2].x = dst_x1;
quadpts[2].y = dst_y1;
cur_ccb->ccb_PRE0 &= ~PRE0_VCNT_MASK;
cur_ccb->ccb_PRE1 &= ~PRE1_TLHPCNT_MASK;
cur_ccb->ccb_PRE0 |= (src_h - PRE0_VCNT_PREFETCH) << PRE0_VCNT_SHIFT;
cur_ccb->ccb_PRE1 |= (src_w - PRE1_TLHPCNT_PREFETCH) << PRE1_TLHPCNT_SHIFT;
cur_ccb->ccb_Width = src_w;
cur_ccb->ccb_Height = src_h;
MAP_CEL (cur_ccb, quadpts);
cur_ccb->ccb_Width = cur_ccb->ccb_XPos;
cur_ccb->ccb_Height = cur_ccb->ccb_YPos;
cur_ccb++;
}
}
static void
init_rotate_cels ()
{
int i, incr, y;
incr = 1;
cur_ccb = plCCB;
for (y = 0, i = 0; y < HEIGHT;)
{
#define src_h ystep[i]
set_band_cels (y, src_h, i);
y += src_h;
i += incr;
if (src_h == 0)
{
--i;
incr = -1;
if (HEIGHT & 1)
--i;
}
}
#if PLANET_SPIN_DEBUG
fprintf (stderr, "using %d cels for rotate\n", cur_ccb - plCCB);
#endif
}
#endif
//SetPlantTilt has moved to plangen.c
#if PLANET_SPIN
void
SetPlanetTilt (int da)
{
int w, i;
int j;
j=MAX_PULSE_RED;
if(planet_stuff==NULL) {
planet_stuff=(PLANET_STUFF *)calloc(sizeof(PLANET_STUFF),1);
}
shield_pulse = MAX_PULSE_RED;
for (i = 0, cur_ccb = plCCB; i < NUM_ROTATE_CELS; i++, cur_ccb++)
{
*cur_ccb = planet_ccb;
cur_ccb->ccb_NextPtr = cur_ccb + 1;
}
if (!src_ws[0])
{
int err;
w = (WIDTH / 2) / XBANDS;
err = XBANDS;
i = XBANDS - 1;
do
{
src_ws[i] = w;
if ((err -= ((WIDTH / 2) % XBANDS)) <= 0)
{
src_ws[i]++;
err += XBANDS;
}
} while (i--);
build_tables (da);
}
init_rotate_cels ();
{
CCB *ccb;
ccb = plCCB;
cur_ccb = plCCB + NUM_ROTATE_CELS;
for (i = 0; i < NUM_ROTATE_CELS; i++, cur_ccb++, ccb++)
{
*cur_ccb = *ccb;
cur_ccb->ccb_NextPtr = cur_ccb + 1;
}
}
}
#endif
DWORD frame_mapRGBA (FRAME FramePtr,UBYTE r, UBYTE g, UBYTE b, UBYTE a);
void process_rgb_bmp (FRAME FramePtr, DWORD **rgba, int maxx, int maxy);
extern FRAME stretch_frame (FRAME FramePtr, int neww, int newh,int destroy);
extern void RenderLevelMasks (int, int);
// RotatePlanet
// This will take care of zooming into a planet on orbit, generating the planet frames
// And applying the shield.
// The initial size of the planet when zooming. MUST BE ODD
#define PLANET_INIT_ZOOM_SIZE 9
// The speed to zoom in.
#define PLANET_ZOOM_SPEED 2
int
RotatePlanet (int x, int da, int dx, int dy, int zoom)
{
#if !PLANET_SPIN
STAMP s;
FRAME pFrame[2];
COUNT i, num_frames;
@@ -523,233 +50,57 @@ RotatePlanet (int x, int da, int dx, int dy, int zoom)
}
num_frames = (pSolarSysState->ShieldFrame == 0) ? 1 : 2;
pFrame[0] = pSolarSysState->PlanetFrameArray[x];
if(num_frames==2) {
if (num_frames == 2)
pFrame[1] = pSolarSysState->ShieldFrame;
}
if (zoom) {
if (zoom)
{
// we're zooming in, take care of scalinng the frames
for(i=0;i<num_frames;i++) {
for (i=0; i < num_frames; i++)
{
COUNT frameh, this_scale;
if(pSolarSysState->ScaleFrame[i]) {
if (pSolarSysState->ScaleFrame[i])
{
DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i]));
pSolarSysState->ScaleFrame[i] = 0;
}
frameh = GetFrameHeight (pFrame[i]);
this_scale = frameh * scale_amt / MAP_HEIGHT;
if(! (this_scale & 0x01)) {
if (! (this_scale & 0x01))
this_scale++;
}
pSolarSysState->ScaleFrame[i] = stretch_frame(pFrame[i],this_scale,this_scale,0);
SetFrameHot (pSolarSysState->ScaleFrame[i], MAKE_HOT_SPOT ((this_scale>>1)+1,(this_scale>>1)+1));
pSolarSysState->ScaleFrame[i] = stretch_frame (
pFrame[i], this_scale, this_scale, 0
);
SetFrameHot (
pSolarSysState->ScaleFrame[i],
MAKE_HOT_SPOT ((this_scale >> 1) + 1, (this_scale >> 1) + 1)
);
pFrame[i] = pSolarSysState->ScaleFrame[i];
}
scale_amt += PLANET_ZOOM_SPEED;
//Translate the planet so it comes from the bottom right corner
if (scale_amt > MAP_HEIGHT)
{
scale_amt=MAP_HEIGHT;
}
dx += dx * (MAP_HEIGHT - scale_amt) / MAP_HEIGHT;
dy += dy * (MAP_HEIGHT - scale_amt) / MAP_HEIGHT;
if(scale_amt==MAP_HEIGHT) {
if (scale_amt == MAP_HEIGHT)
{
scale_amt = PLANET_INIT_ZOOM_SIZE;
zoom = 0;
}
}
s.origin.x = dx;
s.origin.y = dy;
for(i=0;i<num_frames;i++) {
for (i = 0; i < num_frames; i++)
{
s.frame = pFrame[i];
DrawStamp (&s);
}
return (zoom);
// }
#else
int i, y;
int incr;
CCB *first;
dx <<= 16;
dy <<= 16;
if (pblack_circ_ccb && !pshield_ccb->ccb_HDY)
{
pblack_circ_ccb->ccb_XPos = dx - (pblack_circ_ccb->ccb_Width << 15);
pblack_circ_ccb->ccb_YPos = dy - (pblack_circ_ccb->ccb_Height << 15);
pblack_circ_ccb->ccb_HDX = 1 << 20;
pblack_circ_ccb->ccb_VDY = 1 << 16;
#ifdef SCALE_ROTATE
if ((scale & SCALE_AMT_MASK) > SCALE_STEP)
{
scale -= SCALE_STEP;
SCALE_CEL (pblack_circ_ccb, dx, dy);
scale += SCALE_STEP;
}
else if (!scale)
#endif
add_cel (pblack_circ_ccb);
#ifdef KDEBUG
fprintf (stderr, "CLEAR...\n");
while (AnyButtonPress (FALSE))
;
while (!AnyButtonPress (FALSE))
;
#endif /* KDEBUG */
}
incr = 1;
#ifdef SCALE_ROTATE
if (scale)
{
CCB *ccb;
ccb = plCCB;
cur_ccb = plCCB + NUM_ROTATE_CELS;
for (i = 0; i < NUM_ROTATE_CELS; i++, cur_ccb++, ccb++)
{
*cur_ccb = *ccb;
cur_ccb->ccb_NextPtr = cur_ccb + 1;
}
first = plCCB + NUM_ROTATE_CELS;
}
else
#endif
first = plCCB;
cur_ccb = first;
for (y = 0, i = 0; y < HEIGHT;)
{
#define src_h ystep[i]
draw_band (x, y, dx, dy);
y += src_h;
i += incr;
if (src_h == 0)
{
--i;
incr = -1;
if (HEIGHT & 1)
--i;
}
}
add_cels (first, cur_ccb - 1);
#ifdef KDEBUG
fprintf (stderr, "PLANET...\n");
while (AnyButtonPress (FALSE))
;
while (!AnyButtonPress (FALSE))
;
#endif /* KDEBUG */
if (pcirc_ccb)
{
pcirc_ccb->ccb_XPos = dx - (pcirc_ccb->ccb_Width << 15);
pcirc_ccb->ccb_YPos = dy - (pcirc_ccb->ccb_Height << 15);
pcirc_ccb->ccb_HDX = 1 << 20;
pcirc_ccb->ccb_VDY = 1 << 16;
#ifdef SCALE_ROTATE
if (scale)
SCALE_CEL (pcirc_ccb, dx, dy);
#endif
add_cel (pcirc_ccb);
#ifdef KDEBUG
fprintf (stderr, "CLIP...\n");
while (AnyButtonPress (FALSE))
;
while (!AnyButtonPress (FALSE))
;
#endif /* KDEBUG */
}
if (pblur_ccb)
{
pblur_ccb->ccb_XPos = dx - (pblur_ccb->ccb_Width << 15);
pblur_ccb->ccb_YPos = dy - (pblur_ccb->ccb_Height << 15);
pblur_ccb->ccb_HDX = 1 << 20;
pblur_ccb->ccb_VDY = 1 << 16;
#ifdef SCALE_ROTATE
if (scale)
SCALE_CEL (pblur_ccb, dx, dy);
#endif
add_cel (pblur_ccb);
#ifdef KDEBUG
fprintf (stderr, "BLUR...\n");
while (AnyButtonPress (FALSE))
;
while (!AnyButtonPress (FALSE))
;
#endif /* KDEBUG */
}
if (pshadow_ccb)
{
pshadow_ccb->ccb_XPos = dx - (pshadow_ccb->ccb_Width << 15);
pshadow_ccb->ccb_YPos = dy - (pshadow_ccb->ccb_Height << 15);
pshadow_ccb->ccb_HDX = 1 << 20;
pshadow_ccb->ccb_VDY = 1 << 16;
#ifdef SCALE_ROTATE
if (scale)
SCALE_CEL (pshadow_ccb, dx, dy);
#endif
add_cel (pshadow_ccb);
#ifdef KDEBUG
fprintf (stderr, "SHADOW...\n");
while (AnyButtonPress (FALSE))
;
while (!AnyButtonPress (FALSE))
;
#endif /* KDEBUG */
}
if (!pshield_ccb->ccb_HDY)
{
pshield_ccb->ccb_XPos = dx - (pshield_ccb->ccb_Width << 15);
pshield_ccb->ccb_YPos = dy - (pshield_ccb->ccb_Height << 15);
pshield_ccb->ccb_HDX = 1 << 20;
pshield_ccb->ccb_VDY = 1 << 16;
#ifdef SCALE_ROTATE
if (scale)
SCALE_CEL (pshield_ccb, dx, dy);
#endif
if (shield_pulse & PULSE_NEG_BIT)
{
if (((--shield_pulse) & ~PULSE_NEG_BIT) < MIN_PULSE_RED)
shield_pulse = (MIN_PULSE_RED + 1);
}
else if (((++shield_pulse) & ~PULSE_NEG_BIT) > MAX_PULSE_RED)
shield_pulse = (MAX_PULSE_RED - 1) | PULSE_NEG_BIT;
pshield_ccb->ccb_PIXC =
PIXC_DUP (PPMPC_1S_PDC | PPMPC_MS_CCB
| (((shield_pulse & ~PULSE_NEG_BIT) >> PULSE_SCALE) << PPMPC_MF_SHIFT)
| PPMPC_SF_8 | PPMPC_2S_CFBD | PPMPC_2D_1);
add_cel (pshield_ccb);
#ifdef KDEBUG
fprintf (stderr, "SHIELD...\n");
while (AnyButtonPress (FALSE))
;
while (!AnyButtonPress (FALSE))
;
while (AnyButtonPress (FALSE))
;
#endif /* KDEBUG */
}
#ifdef SCALE_ROTATE
if (scale && ((scale += SCALE_STEP) & SCALE_AMT_MASK) > SCALE_MAX)
scale = 0;
return (scale != 0);
#else
return (0);
#endif
#endif
}
void
DrawPlanet (int x, int y, int dy, unsigned int rgb)
{
#if 1
STAMP s;
UBYTE a = 128;
s.origin.x = x;
@@ -778,7 +129,7 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb)
CreateDrawable (WANT_PIXMAP, framew, (UWORD)dy, 1)
);
pSolarSysState->TintFrame = tintFrame;
rgba=(DWORD **)HMalloc(sizeof(DWORD *)*(dy));
rgba = (DWORD **)HMalloc (sizeof(DWORD *) * dy);
r = (rgb & (0x1f << 10)) >> 8;
g = (rgb & (0x1f << 5)) >> 3;
b = (rgb & 0x1f) << 2;
@@ -797,87 +148,5 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb)
s.frame = tintFrame;
DrawStamp (&s);
}
#else
if (rgb || !pshield_ccb->ccb_HDY)
{
int i, nt, my;
if (!pshield_ccb->ccb_HDY)
{
dy = HEIGHT + NUM_TINTS;
rgb = 0x1f << 10;
}
my = dy - NUM_TINTS;
if (my < 0)
{
nt = NUM_TINTS + my + 1;
my = 0;
}
else if (my >= HEIGHT)
{
nt = NUM_TINTS;
my = HEIGHT - 1;
}
else
nt = NUM_TINTS;
my += y;
surface_ccb.ccb_XPos = x << 16;
surface_ccb.ccb_YPos = y << 16;
surface_ccb.ccb_SourcePtr = planet_ccb.ccb_SourcePtr;
surface_ccb.ccb_PRE0 =
PRE0_BGND
| (((dy + 1) - PRE0_VCNT_PREFETCH) << PRE0_VCNT_SHIFT)
| PRE0_LINEAR
| PRE0_BPP_16;
surface_ccb.ccb_PIXC =
PIXC_DUP (PPMPC_1S_PDC | PPMPC_MS_CCB | PPMPC_MF_6
| PPMPC_SF_8 | PPMPC_2S_0);
add_cel (&surface_ccb);
nt = NUM_TINTS - nt;
for (i = nt; i < NUM_TINTS; i++, my++)
{
if (my >= y && my < y + HEIGHT)
{
if (i == 0)
{
tint_ccb[i].ccb_YPos = y << 16;
tint_ccb[i].ccb_VDY = (my - y + 1) << 16;
}
else
tint_ccb[i].ccb_YPos = my << 16;
tint_ccb[i].ccb_XPos = x << 16;
*((DWORD *)tint_ccb[i].ccb_SourcePtr) = rgb | (rgb << 16) | 0x80008000;
add_cel (&tint_ccb[i]);
}
}
}
else
{
surface_ccb.ccb_XPos = x << 16;
surface_ccb.ccb_YPos = y << 16;
surface_ccb.ccb_SourcePtr = planet_ccb.ccb_SourcePtr;
surface_ccb.ccb_PRE0 =
PRE0_BGND
| ((HEIGHT - PRE0_VCNT_PREFETCH) << PRE0_VCNT_SHIFT)
| PRE0_LINEAR
| PRE0_BPP_16;
surface_ccb.ccb_PIXC = PIXC_UNCODED16;
add_cel (&surface_ccb);
}
#endif
}
CCB *
GetCelArray ()
{
return (plCCB);
}
+16 -13
View File
@@ -213,18 +213,21 @@ FreePlanet (void)
pSolarSysState->TopoFrame = 0;
DestroyColorMap (ReleaseColorMap (pSolarSysState->OrbitalCMap));
pSolarSysState->OrbitalCMap = 0;
for(i=0;i<255;i++) {
for (i=0; i<255; i++)
DestroyDrawable (ReleaseDrawable (pSolarSysState->PlanetFrameArray[i]));
}
free(pSolarSysState->PlanetFrameArray);
free(pSolarSysState->isPFADefined);
for(i=0;i<2;i++) {
if(pSolarSysState->ScaleFrame[i]) {
HFree (pSolarSysState->PlanetFrameArray);
pSolarSysState->PlanetFrameArray = 0;
HFree (pSolarSysState->isPFADefined);
pSolarSysState->isPFADefined = 0;
for (i = 0; i < 2; i++)
if (pSolarSysState->ScaleFrame[i])
{
DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i]));
pSolarSysState->ScaleFrame[i]=0;
}
}
if(pSolarSysState->ShieldFrame != 0) {
if(pSolarSysState->ShieldFrame != 0)
{
DestroyDrawable (ReleaseDrawable (pSolarSysState->ShieldFrame));
pSolarSysState->ShieldFrame = 0;
}
@@ -233,11 +236,11 @@ FreePlanet (void)
DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame));
pSolarSysState->TintFrame = 0;
}
if(pSolarSysState->lpTopoMap!=0) {
for(i=0;pSolarSysState->lpTopoMap[i]!=NULL;i++) {
free(pSolarSysState->lpTopoMap[i]);
}
free(pSolarSysState->lpTopoMap);
if (pSolarSysState->lpTopoMap!=0)
{
for (i=0; pSolarSysState->lpTopoMap[i] != NULL; i++)
HFree (pSolarSysState->lpTopoMap[i]);
HFree (pSolarSysState->lpTopoMap);
pSolarSysState->lpTopoMap = 0;
}
+117 -120
View File
@@ -17,6 +17,7 @@
*/
#include "starcon.h"
#include "libs/graphics/gfx_common.h"
#include <math.h>
#include <time.h>
@@ -204,38 +205,45 @@ RenderPhongMask (POINT loc)
int lmag;
DWORD step;
double lmag2;
int y, x;
#define LIGHT_MULT 0.8
#define AMBIENT_LIGHT 0.05
#define LIGHT_RADIUS 1.6
light.x=(int)(LIGHT_MULT*RADIUS*cos(atan2(-(double)loc.y,-(double)loc.x)));
light.y=(int)(LIGHT_MULT*RADIUS*sin(atan2(-(double)loc.y,-(double)loc.x)));
light.x = (int)(LIGHT_MULT * RADIUS *
cos (atan2 (-(double)loc.y, -(double)loc.x)));
light.y = (int)(LIGHT_MULT * RADIUS *
sin (atan2 (-(double)loc.y, -(double)loc.x)));
// light.x=(int)(RADIUS*0.8);
// light.y=(int)(-RADIUS*0.6);
// fprintf(stderr,"light: (%d,%d)->(%d,%d)\n",loc.x,loc.y,light.x,light.y);
lmag = (int)(LIGHT_RADIUS * RADIUS);
lmag2=pow(lmag,2);
lmag2 = lmag * lmag;
step = 1 << PHONG_BITS;
for (pt.y = 0; pt.y <= TWORADIUS; ++pt.y)
for (pt.y = 0, y = -RADIUS; pt.y <= TWORADIUS; ++pt.y, y++)
{
for (pt.x = 0; pt.x <= TWORADIUS; ++pt.x)
int y_2, deltay_2;
y_2 = y * y;
deltay_2 = (y - light.y) * (y - light.y);
for (pt.x = 0, x = -RADIUS; pt.x <= TWORADIUS; ++pt.x, x++)
{
int x,y,rad;
int rad;
DWORD stepint;
double lrad2;
double intens;
x=pt.x-RADIUS;
y=pt.y-RADIUS;
rad=x*x+y*y;
rad = x * x + y_2;
if (rad <= RADIUS_2)
{
lrad=((x-light.x)*(x-light.x)+(y-light.y)*(y-light.y));
lrad2=pow(lrad,1);
if (lrad2 >= lmag2) {
lrad = ((x - light.x) * (x - light.x) + deltay_2);
lrad2 = lrad;
//lrad2=pow(lrad,1);
if (lrad2 >= lmag2)
intens = AMBIENT_LIGHT;
else
{
intens = 1 * cos ((M_PI / 2) * (double)lrad2 / (double)lmag2);
if (intens < AMBIENT_LIGHT)
intens = AMBIENT_LIGHT;
} else {
intens=1*cos((3.1416/2)*(double)lrad2/(double)lmag2);
if(intens<AMBIENT_LIGHT) {intens=AMBIENT_LIGHT;}
}
stepint = step - (DWORD)(intens * step + 0.5);
if(rad > (RADIUS - 1) * (RADIUS - 1))
@@ -246,9 +254,8 @@ RenderPhongMask (POINT loc)
if (stepint > step)
stepint = step;
}
} else {
} else
stepint = step;
}
phong[pt.y][pt.x] = (int)stepint;
}
}
@@ -258,7 +265,8 @@ RenderPhongMask (POINT loc)
// 4 points around the 'ideal' point at x,y
// the concept is to compute the weight based on the
// distance from the integer location poinnts to the ideal point
void create_aa_points(MAP3D_POINT *ppt, double x, double y)
static void
create_aa_points (MAP3D_POINT *ppt, double x, double y)
{
double deltax = 0, deltay = 0, inv_deltax, inv_deltay;
COORD nextx, nexty;
@@ -267,31 +275,28 @@ void create_aa_points(MAP3D_POINT *ppt, double x, double y)
// get the integer value of this point
ppt->p[0].x = (COORD)(0.5 + x);
ppt->p[0].y = (COORD)(0.5 + y);
if(ppt->p[0].x >= TWORADIUS) {
if (ppt->p[0].x >= TWORADIUS)
ppt->p[0].x = TWORADIUS;
} else if(ppt->p[0].x != 0) {
else if (ppt->p[0].x != 0)
deltax = x - ppt->p[0].x;
}
if(ppt->p[0].y >= TWORADIUS) {
if (ppt->p[0].y >= TWORADIUS)
ppt->p[0].y = TWORADIUS;
} else if(ppt->p[0].y != 0) {
else if (ppt->p[0].y != 0)
deltay = y - ppt->p[0].y;
}
//if this point doesn't need modificaton, set m[0]=0
if(deltax==0 && deltay==0) {
if (deltax == 0 && deltay == 0)
ppt->m[0] = 0;
} else {
else
{
//get the neighbboring points surrounding the 'ideal' poinnt
if(deltax!=0) {
if (deltax != 0)
nextx = ppt->p[0].x + ((deltax > 0) ? 1 : -1);
} else {
else
nextx = ppt->p[0].x;
}
if(deltay!=0) {
if (deltay != 0)
nexty = ppt->p[0].y + ((deltay > 0) ? 1 : -1);
} else {
else
nexty = ppt->p[0].y;
}
//(x1,y)
ppt->p[1].x = nextx;
ppt->p[1].y = ppt->p[0].y;
@@ -325,13 +330,13 @@ void create_aa_points(MAP3D_POINT *ppt, double x, double y)
//get_avg_rgb creates either a red, green, or blue value by
//computing the weightd averages of the 4 points in p1
UBYTE get_avg_rgb(DWORD p1[4],DWORD mult[4],COUNT offset) {
static UBYTE
get_avg_rgb (DWORD p1[4], DWORD mult[4], COUNT offset) {
COUNT i, j;
UBYTE c;
DWORD ci;
DWORD ci = 0;
i = offset << 3;
ci=0;
//sum(mult[])==65536
//c is the red/green/blue value of this pixel
for (j = 0; j < 4; j++)
@@ -339,7 +344,7 @@ UBYTE get_avg_rgb(DWORD p1[4],DWORD mult[4],COUNT offset) {
c = (UBYTE)(p1[j] >> i);
ci += c * mult[j];
}
ci=ci>>16;
ci >>= 16;
//check for overflow
if ( ci > 255)
ci = 255;
@@ -352,9 +357,8 @@ void
SetPlanetTilt (int angle)
{
int x, y, y_2;
double multx,multy;
multx=(MAP_HEIGHT/M_PI)/RADIUS;
multy=(MAP_HEIGHT/M_PI)/RADIUS;
double multx = (MAP_HEIGHT / M_PI) / RADIUS;
double multy = (MAP_HEIGHT / M_PI) / RADIUS;
for (y = -RADIUS; y <= RADIUS; y++)
{
y_2 = y * y;
@@ -398,8 +402,8 @@ SetPlanetTilt (int angle)
//Outer diameter of HALO
#define SHIELD_RADIUS (RADIUS + 5)
#define SHIELD_DIAM ((SHIELD_RADIUS << 1) + 1)
#define SHIELD_RADIUS_2 SHIELD_RADIUS*SHIELD_RADIUS
void CreateShieldMask()
#define SHIELD_RADIUS_2 (SHIELD_RADIUS * SHIELD_RADIUS)
static void CreateShieldMask ()
{
DWORD rad2, clear, **rgba, p;
UBYTE red_nt;
@@ -410,26 +414,30 @@ void CreateShieldMask()
ShieldFrame = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, SHIELD_DIAM, SHIELD_DIAM, 1)
);
rgba=(DWORD **)malloc(sizeof(DWORD *)*(SHIELD_DIAM));
rgba = (DWORD **)HMalloc (sizeof (DWORD *) * (SHIELD_DIAM));
// This is a non-transparent red for the halo
red_nt = 180;
// This is 100% transparent.
clear = frame_mapRGBA (ShieldFrame, 0, 0, 0, 0);
aa_delta = SHIELD_RADIUS_2 - (SHIELD_RADIUS - 1) * (SHIELD_RADIUS - 1);
aa_delta2 = (RADIUS + 3) * (RADIUS + 3) - (RADIUS + 2)*(RADIUS + 2);
for(y=-SHIELD_RADIUS;y<=SHIELD_RADIUS;y++) {
rgba[y+SHIELD_RADIUS]=(DWORD *)calloc((SHIELD_DIAM),sizeof(DWORD));
for(x=-SHIELD_RADIUS;x<=SHIELD_RADIUS;x++) {
for (y = -SHIELD_RADIUS; y <= SHIELD_RADIUS; y++)
{
rgba[y+SHIELD_RADIUS] = (DWORD *)HCalloc (sizeof (DWORD) * (SHIELD_DIAM));
for (x = -SHIELD_RADIUS; x <= SHIELD_RADIUS; x++)
{
rad2 = x * x + y * y;
if(rad2<=SHIELD_RADIUS_2) {
if (rad2 <= SHIELD_RADIUS_2)
{
//Inside the halo
if(rad2<=RADIUS_2) {
if (rad2 <= RADIUS_2)
// The mask for the planet
p=clear;
} else if (rad2<=(RADIUS+2)*(RADIUS+2)) {
else if (rad2 <= (RADIUS + 2) * (RADIUS + 2))
// The space between the halo and the planet
p = frame_mapRGBA (ShieldFrame, 0, 0, 0, 255);
} else {
else
{
// The halo itself
UBYTE red = red_nt;
if (rad2 > (SHIELD_RADIUS - 1) * (SHIELD_RADIUS - 1))
@@ -437,7 +445,9 @@ void CreateShieldMask()
DWORD r;
r = rad2 - (SHIELD_RADIUS - 1) * (SHIELD_RADIUS - 1);
red = red_nt - (UBYTE)(red_nt * r / aa_delta);
} else if (rad2 < (RADIUS+3)*(RADIUS+3)) {
}
else if (rad2 < (RADIUS + 3) * (RADIUS + 3))
{
DWORD r;
r = rad2 - (RADIUS + 2) * (RADIUS + 2);
red = (UBYTE)(red_nt * r / aa_delta2);
@@ -445,9 +455,9 @@ void CreateShieldMask()
p = frame_mapRGBA (ShieldFrame, red, 0, 0, 255);
}
} else {
p=clear;
}
else
p = clear;
rgba[y + SHIELD_RADIUS][x + SHIELD_RADIUS] = p;
}
@@ -456,9 +466,9 @@ void CreateShieldMask()
SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS + 1,SHIELD_RADIUS + 1));
for (y=-SHIELD_RADIUS; y <= SHIELD_RADIUS; ++y)
{
free(rgba[y+SHIELD_RADIUS]);
HFree (rgba[y + SHIELD_RADIUS]);
}
free(rgba);
HFree(rgba);
pSolarSysState->ShieldFrame = ShieldFrame;
}
@@ -481,13 +491,13 @@ RenderLevelMasks (int offset)
t1 = clock ();
#endif
rgba=malloc(sizeof(DWORD *)*(DIAMETER));
rgba = HMalloc (sizeof (DWORD *) * (DIAMETER));
// Choose the correct Frame to wrte to
MaskFrame = pSolarSysState->PlanetFrameArray[offset];
pixels = pSolarSysState->lpTopoMap;
for (pt.y = 0, y = -RADIUS; pt.y <= TWORADIUS; ++pt.y, ++y)
{
rgba[pt.y]=malloc(sizeof(DWORD)*(DIAMETER));
rgba[pt.y] = HCalloc (sizeof (DWORD) * (DIAMETER));
for (pt.x = 0, x = -RADIUS; pt.x <= TWORADIUS; ++pt.x, ++x)
{
UBYTE c[3];
@@ -495,58 +505,60 @@ RenderLevelMasks (int offset)
COUNT i;
DWORD p1[4];
MAP3D_POINT *ppt = &map_rotate[pt.y][pt.x];
rgba[pt.y][pt.x]=0;
ph = phong[pt.y][pt.x];
if(ph < 1<<PHONG_BITS) {
if(ppt->m[0]==0) {
if (ph < 1 << PHONG_BITS)
{
if (ppt->m[0] == 0)
{
p = pixels[ppt->p[0].y][ppt->p[0].x + offset];
c[0] = (UBYTE)(p >> 8);
c[1] = (UBYTE)(p >> 16);
c[2] = (UBYTE)(p >> 24);
} else {
for(i=0;i<4;i++) {
p1[i]=pixels[ppt->p[i].y][ppt->p[i].x+offset];
}
for(i=1;i<4;i++) {
else
{
for (i = 0; i < 4; i++)
p1[i]=pixels[ppt->p[i].y][ppt->p[i].x + offset];
for (i = 1; i < 4; i++)
c[i-1] = get_avg_rgb (p1, ppt->m, i);
}
}
// fixed planet surfaces being too dark
// ctab shifts were previously >> 3 .. -Mika
// Apply the lightinng model. This also bounds the sphere to make it circular
if(pSolarSysState->ShieldFrame) {
if (pSolarSysState->ShieldFrame)
{
c[2] = GET_PHONG (255, ph);
c[1] = GET_PHONG (c[1] >> 1, ph);
c[0] = GET_PHONG (c[0] >> 1, ph);
} else {
}
else
{
c[2] = GET_PHONG (c[2], ph);
c[1] = GET_PHONG (c[1], ph);
c[0] = GET_PHONG (c[0], ph);
}
rgba[pt.y][pt.x]=frame_mapRGBA (MaskFrame,c[2],c[1],c[0],(UBYTE)255);
} else {
rgba[pt.y][pt.x]=frame_mapRGBA (MaskFrame,0,0,0,0);
rgba[pt.y][pt.x] = frame_mapRGBA (
MaskFrame, c[2], c[1], c[0], (UBYTE)255);
}
else
rgba[pt.y][pt.x] = frame_mapRGBA (MaskFrame, 0, 0, 0, 0);
}
}
// Map the rgb bitmap onto the SDL_Surface
process_rgb_bmp (pSolarSysState->PlanetFrameArray[offset], rgba, DIAMETER, DIAMETER);
SetFrameHot (MaskFrame, MAKE_HOT_SPOT (RADIUS + 1, RADIUS + 1));
for (pt.y = 0, y=-RADIUS; pt.y <= TWORADIUS; ++pt.y,++y)
{
free(rgba[pt.y]);
}
free(rgba);
for (pt.y = 0; pt.y <= TWORADIUS; ++pt.y)
HFree (rgba[pt.y]);
HFree(rgba);
#if PROFILE
if(frames_done==MAP_WIDTH) {
t += clock() - t1;
fprintf(stderr,"frames/sec: %d/%d(msec)=%f\n",frames_done,t,frames_done/((double)t/CLOCKS_PER_SEC));
if (frames_done == MAP_WIDTH)
{
fprintf (stderr, "frames/sec: %d/%d(msec)=%f\n", frames_done, t,
frames_done / ((double)t / CLOCKS_PER_SEC));
frames_done = 1;
t = clock () - t1;
} else {
t+=clock()-t1;
frames_done++;
}
else
frames_done++;
#endif
}
@@ -1071,23 +1083,31 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
RECT r;
DWORD old_seed;
PLANDATAPTR PlanDataPtr;
COUNT i;
COUNT i, x, y;
POINT loc;
CONTEXT OldContext;
old_seed = SeedRandom (pPlanetDesc->rand_seed);
if(pSolarSysState->hTopoData!=0) {
fprintf(stderr,"hTopoData wasn't reset!!!\n");
}
OldContext = SetContext (TaskContext);
pSolarSysState->isPFADefined = (BYTE *)HCalloc (sizeof(BYTE) * 255);
pSolarSysState->PlanetFrameArray = HMalloc (sizeof(FRAME) * 255);
for (i = 0; i < 255; i++)
pSolarSysState->PlanetFrameArray[i] = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, DIAMETER, DIAMETER, 1)
);
if (IsEarth)
{
//Earth uses a pixmap for the topography
pSolarSysState->TopoFrame = CaptureDrawable (
LoadGraphic (EARTH_MASK_ANIM)
);
pSolarSysState->TopoFrame = stretch_frame(pSolarSysState->TopoFrame,MAP_WIDTH,MAP_HEIGHT,1);
pSolarSysState->TopoFrame = stretch_frame (
pSolarSysState->TopoFrame, MAP_WIDTH, MAP_HEIGHT, 1
);
} else {
pSolarSysState->lpTopoMap=NULL;
PlanDataPtr = &PlanData[
pPlanetDesc->data_index & ~PLANET_SHIELDED
];
@@ -1162,22 +1182,6 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
} else {
return;
}
}
{
CONTEXT OldContext;
OldContext = SetContext (TaskContext);
pSolarSysState->isPFADefined=(BYTE *)calloc(255,sizeof(BYTE));
pSolarSysState->PlanetFrameArray=malloc(255*sizeof(FRAME));
for(i=0;i<255;i++) {
pSolarSysState->PlanetFrameArray[i] = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, DIAMETER, DIAMETER, 1)
);
}
pSolarSysState->ScaleFrame[0]=0;
pSolarSysState->ScaleFrame[1]=0;
if(! IsEarth) {
pSolarSysState->TopoFrame = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, (SIZE)MAP_WIDTH, (SIZE)MAP_HEIGHT, 1)
);
@@ -1204,26 +1208,20 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
}
pSolarSysState->XlatPtr = GetStringAddress (pSolarSysState->XlatRef);
RenderTopography (FALSE);
}
{
// Generate a pixel array fromthe Topography map.
// We use this instead of lpTopoData because it needs to be WAP_WIDTH+MAP_HEIGHT wide
// and we need this method for Earth anyway. It may be more efficient to build it
// from lpTopoData instead of the FRAMPTR though
COUNT x,y;
x = MAP_WIDTH + MAP_HEIGHT;
y = MAP_HEIGHT;
pSolarSysState->lpTopoMap=getpixelarray(pSolarSysState->TopoFrame,x,y);
pSolarSysState->lpTopoMap = getpixelarray (
pSolarSysState->TopoFrame, x, y
);
// Extend the width from MAP_WIDTH to MAP_WIDTH+MAP_HEIGHT
for(y=0;y<MAP_HEIGHT;y++) {
for(x=0;x<MAP_HEIGHT;x++) {
for (y = 0; y < MAP_HEIGHT; y++)
for (x = 0; x < MAP_HEIGHT; x++)
pSolarSysState->lpTopoMap[y][x + MAP_WIDTH] = pSolarSysState->lpTopoMap[y][x];
}
}
}
{
POINT loc;
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0])
{
// This is a planet. Get its location
@@ -1233,14 +1231,11 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
loc = pSolarSysState->pOrbitalDesc->pPrevDesc->location;
}
RenderPhongMask (loc);
}
if (pPlanetDesc->data_index & PLANET_SHIELDED) {
fprintf(stderr,"Found shield\n");
if (pPlanetDesc->data_index & PLANET_SHIELDED)
CreateShieldMask();
}
SetContext (OldContext);
}
SeedRandom (old_seed);
@@ -1301,7 +1296,9 @@ rotate_planet_task(void *data)
r.extent.height = SIS_SCREEN_HEIGHT - MAP_HEIGHT;
RepairBackRect (&r);
}
repair = RotatePlanet (x, angle, SIS_SCREEN_WIDTH >> 1, (148 - SIS_ORG_Y) >> 1,zooming);
repair = RotatePlanet (x, angle, SIS_SCREEN_WIDTH >> 1,
(148 - SIS_ORG_Y) >> 1, zooming
);
UnbatchGraphics ();
SetContext (OldContext);