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:
@@ -198,9 +198,9 @@ Uint32 **getpixelarray(FRAMEPTR FramePtr,int width, int height)
|
|||||||
img = ((TFB_Image *)((BYTE *)(FramePtr) + FramePtr->DataOffs))->NormalImg;
|
img = ((TFB_Image *)((BYTE *)(FramePtr) + FramePtr->DataOffs))->NormalImg;
|
||||||
SDL_LockSurface (img);
|
SDL_LockSurface (img);
|
||||||
getpix = getpixel_for (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++) {
|
for (y=0;y<height;y++) {
|
||||||
map[y]=(Uint32 *)calloc(width,sizeof(Uint32));
|
map[y]=(Uint32 *)HCalloc(width*sizeof(Uint32));
|
||||||
if(y>=img->h) {
|
if(y>=img->h) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,868 +16,137 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* 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 "starcon.h"
|
||||||
#include "libs/graphics/gfx_common.h"
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include "libs/graphics/drawable.h"
|
#include "libs/graphics/drawable.h"
|
||||||
#define PLANET_SPIN 0
|
|
||||||
#define PLANET_SPIN_DEBUG 1
|
|
||||||
//Added by Chris
|
|
||||||
|
|
||||||
//End Added by Chris
|
DWORD frame_mapRGBA (FRAME FramePtr,UBYTE r, UBYTE g, UBYTE b, UBYTE a);
|
||||||
|
|
||||||
//#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
|
|
||||||
|
|
||||||
|
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 FRAME stretch_frame (FRAME FramePtr, int neww, int newh,int destroy);
|
||||||
extern void RenderLevelMasks(int,int);
|
extern void RenderLevelMasks (int, int);
|
||||||
|
|
||||||
// RotatePlanet
|
// RotatePlanet
|
||||||
// This will take care of zooming into a planet on orbit, generating the planet frames
|
// This will take care of zooming into a planet on orbit, generating the planet frames
|
||||||
// And applying the shield.
|
// And applying the shield.
|
||||||
//The initial size of the planet when zooming. MUST BE ODD
|
|
||||||
|
// The initial size of the planet when zooming. MUST BE ODD
|
||||||
#define PLANET_INIT_ZOOM_SIZE 9
|
#define PLANET_INIT_ZOOM_SIZE 9
|
||||||
// The speed to zoom in.
|
// The speed to zoom in.
|
||||||
#define PLANET_ZOOM_SPEED 2
|
#define PLANET_ZOOM_SPEED 2
|
||||||
|
|
||||||
int
|
int
|
||||||
RotatePlanet (int x, int da, int dx, int dy, int zoom)
|
RotatePlanet (int x, int da, int dx, int dy, int zoom)
|
||||||
{
|
{
|
||||||
#if !PLANET_SPIN
|
|
||||||
STAMP s;
|
STAMP s;
|
||||||
FRAME pFrame[2];
|
FRAME pFrame[2];
|
||||||
COUNT i,num_frames;
|
COUNT i, num_frames;
|
||||||
static COUNT scale_amt=PLANET_INIT_ZOOM_SIZE;
|
static COUNT scale_amt = PLANET_INIT_ZOOM_SIZE;
|
||||||
|
|
||||||
// If thiis frame hasn' been generted, generate it
|
// If thiis frame hasn' been generted, generate it
|
||||||
if(!pSolarSysState->isPFADefined[x]) {
|
if (! pSolarSysState->isPFADefined[x]) {
|
||||||
RenderLevelMasks(x,da);
|
RenderLevelMasks (x, da);
|
||||||
pSolarSysState->isPFADefined[x]=1;
|
pSolarSysState->isPFADefined[x] = 1;
|
||||||
}
|
}
|
||||||
num_frames=(pSolarSysState->ShieldFrame==0) ? 1 : 2;
|
num_frames = (pSolarSysState->ShieldFrame == 0) ? 1 : 2;
|
||||||
pFrame[0]=pSolarSysState->PlanetFrameArray[x];
|
pFrame[0] = pSolarSysState->PlanetFrameArray[x];
|
||||||
if(num_frames==2) {
|
if (num_frames == 2)
|
||||||
pFrame[1]=pSolarSysState->ShieldFrame;
|
pFrame[1] = pSolarSysState->ShieldFrame;
|
||||||
}
|
if (zoom)
|
||||||
if (zoom) {
|
{
|
||||||
// we're zooming in, take care of scalinng the frames
|
// 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]) {
|
|
||||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i]));
|
|
||||||
pSolarSysState->ScaleFrame[i]=0;
|
|
||||||
}
|
|
||||||
frameh=GetFrameHeight(pFrame[i]);
|
|
||||||
this_scale=frameh*scale_amt/MAP_HEIGHT;
|
|
||||||
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));
|
|
||||||
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;
|
COUNT frameh, this_scale;
|
||||||
|
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))
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
pFrame[i] = pSolarSysState->ScaleFrame[i];
|
||||||
}
|
}
|
||||||
dx+=dx*(MAP_HEIGHT-scale_amt)/MAP_HEIGHT;
|
scale_amt += PLANET_ZOOM_SPEED;
|
||||||
dy+=dy*(MAP_HEIGHT-scale_amt)/MAP_HEIGHT;
|
//Translate the planet so it comes from the bottom right corner
|
||||||
if(scale_amt==MAP_HEIGHT) {
|
if (scale_amt > MAP_HEIGHT)
|
||||||
scale_amt=PLANET_INIT_ZOOM_SIZE;
|
scale_amt=MAP_HEIGHT;
|
||||||
zoom=0;
|
dx += dx * (MAP_HEIGHT - scale_amt) / MAP_HEIGHT;
|
||||||
|
dy += dy * (MAP_HEIGHT - scale_amt) / MAP_HEIGHT;
|
||||||
|
if (scale_amt == MAP_HEIGHT)
|
||||||
|
{
|
||||||
|
scale_amt = PLANET_INIT_ZOOM_SIZE;
|
||||||
|
zoom = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.origin.x = dx;
|
s.origin.x = dx;
|
||||||
s.origin.y = dy;
|
s.origin.y = dy;
|
||||||
for(i=0;i<num_frames;i++) {
|
for (i = 0; i < num_frames; i++)
|
||||||
s.frame=pFrame[i];
|
{
|
||||||
|
s.frame = pFrame[i];
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
}
|
}
|
||||||
return(zoom);
|
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
|
void
|
||||||
DrawPlanet (int x, int y, int dy, unsigned int rgb)
|
DrawPlanet (int x, int y, int dy, unsigned int rgb)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
STAMP s;
|
STAMP s;
|
||||||
UBYTE a=128;
|
UBYTE a = 128;
|
||||||
s.origin.x = x;
|
s.origin.x = x;
|
||||||
s.origin.y = y;
|
s.origin.y = y;
|
||||||
s.frame = pSolarSysState->TopoFrame;
|
s.frame = pSolarSysState->TopoFrame;
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
if (pSolarSysState->ShieldFrame!=0)
|
if (pSolarSysState->ShieldFrame != 0)
|
||||||
{
|
{
|
||||||
rgb=0x1f<<10;
|
rgb = 0x1f << 10;
|
||||||
dy=GetFrameHeight(s.frame);
|
dy = GetFrameHeight (s.frame);
|
||||||
a=200;
|
a = 200;
|
||||||
}
|
}
|
||||||
if (rgb)
|
if (rgb)
|
||||||
{
|
{
|
||||||
UBYTE r,g,b;
|
UBYTE r, g, b;
|
||||||
DWORD **rgba,p;
|
DWORD **rgba, p;
|
||||||
COUNT i,j,framew;
|
COUNT i, j, framew;
|
||||||
FRAME tintFrame;
|
FRAME tintFrame;
|
||||||
if(pSolarSysState->TintFrame !=0)
|
if (pSolarSysState->TintFrame != 0)
|
||||||
{
|
{
|
||||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame));
|
DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame));
|
||||||
pSolarSysState->TintFrame=0;
|
pSolarSysState->TintFrame = 0;
|
||||||
}
|
}
|
||||||
framew=GetFrameWidth(s.frame);
|
framew = GetFrameWidth (s.frame);
|
||||||
tintFrame = CaptureDrawable (
|
tintFrame = CaptureDrawable (
|
||||||
CreateDrawable (WANT_PIXMAP, framew, (UWORD)dy, 1)
|
CreateDrawable (WANT_PIXMAP, framew, (UWORD)dy, 1)
|
||||||
);
|
);
|
||||||
pSolarSysState->TintFrame=tintFrame;
|
pSolarSysState->TintFrame = tintFrame;
|
||||||
rgba=(DWORD **)HMalloc(sizeof(DWORD *)*(dy));
|
rgba = (DWORD **)HMalloc (sizeof(DWORD *) * dy);
|
||||||
r=(rgb&(0x1f<<10))>>8;
|
r = (rgb & (0x1f << 10)) >> 8;
|
||||||
g=(rgb&(0x1f<<5))>>3;
|
g = (rgb & (0x1f << 5)) >> 3;
|
||||||
b=(rgb&0x1f)<<2;
|
b = (rgb & 0x1f) << 2;
|
||||||
p=frame_mapRGBA(tintFrame,r,g,b,a);
|
p = frame_mapRGBA (tintFrame, r, g, b, a);
|
||||||
for(i=0;i<dy;i++)
|
for (i = 0; i < dy; i++)
|
||||||
{
|
{
|
||||||
rgba[i]=(DWORD *)HMalloc(sizeof(DWORD)*framew);
|
rgba[i] = (DWORD *)HMalloc (sizeof(DWORD)*framew);
|
||||||
for(j=0;j<framew;j++)
|
for(j=0; j<framew; j++)
|
||||||
rgba[i][j]=p;
|
rgba[i][j] = p;
|
||||||
}
|
}
|
||||||
process_rgb_bmp(tintFrame,rgba,framew,dy);
|
process_rgb_bmp (tintFrame, rgba, framew, dy);
|
||||||
SetFrameHot (tintFrame, MAKE_HOT_SPOT (0, 0));
|
SetFrameHot (tintFrame, MAKE_HOT_SPOT (0, 0));
|
||||||
for (i=0;i<dy;i++)
|
for (i = 0;i < dy; i++)
|
||||||
HFree(rgba[i]);
|
HFree (rgba[i]);
|
||||||
HFree(rgba);
|
HFree (rgba);
|
||||||
s.frame = tintFrame;
|
s.frame = tintFrame;
|
||||||
DrawStamp (&s);
|
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);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -213,32 +213,35 @@ FreePlanet (void)
|
|||||||
pSolarSysState->TopoFrame = 0;
|
pSolarSysState->TopoFrame = 0;
|
||||||
DestroyColorMap (ReleaseColorMap (pSolarSysState->OrbitalCMap));
|
DestroyColorMap (ReleaseColorMap (pSolarSysState->OrbitalCMap));
|
||||||
pSolarSysState->OrbitalCMap = 0;
|
pSolarSysState->OrbitalCMap = 0;
|
||||||
for(i=0;i<255;i++) {
|
for (i=0; i<255; i++)
|
||||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->PlanetFrameArray[i]));
|
DestroyDrawable (ReleaseDrawable (pSolarSysState->PlanetFrameArray[i]));
|
||||||
}
|
HFree (pSolarSysState->PlanetFrameArray);
|
||||||
free(pSolarSysState->PlanetFrameArray);
|
pSolarSysState->PlanetFrameArray = 0;
|
||||||
free(pSolarSysState->isPFADefined);
|
|
||||||
for(i=0;i<2;i++) {
|
HFree (pSolarSysState->isPFADefined);
|
||||||
if(pSolarSysState->ScaleFrame[i]) {
|
pSolarSysState->isPFADefined = 0;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
if (pSolarSysState->ScaleFrame[i])
|
||||||
|
{
|
||||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i]));
|
DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i]));
|
||||||
pSolarSysState->ScaleFrame[i]=0;
|
pSolarSysState->ScaleFrame[i]=0;
|
||||||
}
|
}
|
||||||
}
|
if(pSolarSysState->ShieldFrame != 0)
|
||||||
if(pSolarSysState->ShieldFrame != 0) {
|
{
|
||||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->ShieldFrame));
|
DestroyDrawable (ReleaseDrawable (pSolarSysState->ShieldFrame));
|
||||||
pSolarSysState->ShieldFrame=0;
|
pSolarSysState->ShieldFrame = 0;
|
||||||
}
|
}
|
||||||
if(pSolarSysState->TintFrame != 0)
|
if (pSolarSysState->TintFrame != 0)
|
||||||
{
|
{
|
||||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame));
|
DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame));
|
||||||
pSolarSysState->TintFrame=0;
|
pSolarSysState->TintFrame = 0;
|
||||||
}
|
}
|
||||||
if(pSolarSysState->lpTopoMap!=0) {
|
if (pSolarSysState->lpTopoMap!=0)
|
||||||
for(i=0;pSolarSysState->lpTopoMap[i]!=NULL;i++) {
|
{
|
||||||
free(pSolarSysState->lpTopoMap[i]);
|
for (i=0; pSolarSysState->lpTopoMap[i] != NULL; i++)
|
||||||
}
|
HFree (pSolarSysState->lpTopoMap[i]);
|
||||||
free(pSolarSysState->lpTopoMap);
|
HFree (pSolarSysState->lpTopoMap);
|
||||||
pSolarSysState->lpTopoMap=0;
|
pSolarSysState->lpTopoMap = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyContext (ReleaseContext (TaskContext));
|
DestroyContext (ReleaseContext (TaskContext));
|
||||||
|
|||||||
+290
-293
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "starcon.h"
|
#include "starcon.h"
|
||||||
|
#include "libs/graphics/gfx_common.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -199,57 +200,63 @@ RenderTopography (BOOLEAN Reconstruct)
|
|||||||
static void
|
static void
|
||||||
RenderPhongMask (POINT loc)
|
RenderPhongMask (POINT loc)
|
||||||
{
|
{
|
||||||
POINT pt,light;
|
POINT pt, light;
|
||||||
double lrad;
|
double lrad;
|
||||||
int lmag;
|
int lmag;
|
||||||
DWORD step;
|
DWORD step;
|
||||||
double lmag2;
|
double lmag2;
|
||||||
|
int y, x;
|
||||||
|
|
||||||
#define LIGHT_MULT 0.8
|
#define LIGHT_MULT 0.8
|
||||||
#define AMBIENT_LIGHT 0.05
|
#define AMBIENT_LIGHT 0.05
|
||||||
#define LIGHT_RADIUS 1.6
|
#define LIGHT_RADIUS 1.6
|
||||||
light.x=(int)(LIGHT_MULT*RADIUS*cos(atan2(-(double)loc.y,-(double)loc.x)));
|
light.x = (int)(LIGHT_MULT * RADIUS *
|
||||||
light.y=(int)(LIGHT_MULT*RADIUS*sin(atan2(-(double)loc.y,-(double)loc.x)));
|
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.x=(int)(RADIUS*0.8);
|
||||||
// light.y=(int)(-RADIUS*0.6);
|
// light.y=(int)(-RADIUS*0.6);
|
||||||
// fprintf(stderr,"light: (%d,%d)->(%d,%d)\n",loc.x,loc.y,light.x,light.y);
|
// fprintf(stderr,"light: (%d,%d)->(%d,%d)\n",loc.x,loc.y,light.x,light.y);
|
||||||
lmag=(int)(LIGHT_RADIUS*RADIUS);
|
lmag = (int)(LIGHT_RADIUS * RADIUS);
|
||||||
lmag2=pow(lmag,2);
|
lmag2 = lmag * lmag;
|
||||||
step=1<<PHONG_BITS;
|
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;
|
DWORD stepint;
|
||||||
double lrad2;
|
double lrad2;
|
||||||
double intens;
|
double intens;
|
||||||
x=pt.x-RADIUS;
|
rad = x * x + y_2;
|
||||||
y=pt.y-RADIUS;
|
if (rad <= RADIUS_2)
|
||||||
rad=x*x+y*y;
|
|
||||||
if(rad<=RADIUS_2)
|
|
||||||
{
|
{
|
||||||
lrad=((x-light.x)*(x-light.x)+(y-light.y)*(y-light.y));
|
lrad = ((x - light.x) * (x - light.x) + deltay_2);
|
||||||
lrad2=pow(lrad,1);
|
lrad2 = lrad;
|
||||||
if (lrad2 >= lmag2) {
|
//lrad2=pow(lrad,1);
|
||||||
intens=AMBIENT_LIGHT;
|
if (lrad2 >= lmag2)
|
||||||
} else {
|
intens = AMBIENT_LIGHT;
|
||||||
intens=1*cos((3.1416/2)*(double)lrad2/(double)lmag2);
|
else
|
||||||
if(intens<AMBIENT_LIGHT) {intens=AMBIENT_LIGHT;}
|
{
|
||||||
|
intens = 1 * cos ((M_PI / 2) * (double)lrad2 / (double)lmag2);
|
||||||
|
if (intens < AMBIENT_LIGHT)
|
||||||
|
intens = AMBIENT_LIGHT;
|
||||||
}
|
}
|
||||||
stepint=step- (DWORD)(intens*step+0.5);
|
stepint = step - (DWORD)(intens * step + 0.5);
|
||||||
if(rad >(RADIUS-1)*(RADIUS-1))
|
if(rad > (RADIUS - 1) * (RADIUS - 1))
|
||||||
{
|
{
|
||||||
DWORD r;
|
DWORD r;
|
||||||
r=rad-(RADIUS-1)*(RADIUS-1);
|
r = rad - (RADIUS - 1) * (RADIUS - 1);
|
||||||
stepint+=(step>>7)*(r+1);
|
stepint += (step >> 7) * (r + 1);
|
||||||
if(stepint > step)
|
if (stepint > step)
|
||||||
stepint=step;
|
stepint = step;
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
stepint=step;
|
stepint = step;
|
||||||
}
|
phong[pt.y][pt.x] = (int)stepint;
|
||||||
phong[pt.y][pt.x]=(int)stepint;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,92 +265,90 @@ RenderPhongMask (POINT loc)
|
|||||||
// 4 points around the 'ideal' point at x,y
|
// 4 points around the 'ideal' point at x,y
|
||||||
// the concept is to compute the weight based on the
|
// the concept is to compute the weight based on the
|
||||||
// distance from the integer location poinnts to the ideal point
|
// 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;
|
double deltax = 0, deltay = 0, inv_deltax, inv_deltay;
|
||||||
COORD nextx,nexty;
|
COORD nextx, nexty;
|
||||||
COUNT i;
|
COUNT i;
|
||||||
double d1,d2,d3,d4,m[4];
|
double d1, d2, d3, d4, m[4];
|
||||||
// get the integer value of this point
|
// get the integer value of this point
|
||||||
ppt->p[0].x=(COORD)(0.5+x);
|
ppt->p[0].x = (COORD)(0.5 + x);
|
||||||
ppt->p[0].y=(COORD)(0.5+y);
|
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;
|
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;
|
deltax = x - ppt->p[0].x;
|
||||||
}
|
if (ppt->p[0].y >= TWORADIUS)
|
||||||
if(ppt->p[0].y >= TWORADIUS) {
|
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;
|
||||||
deltay=y-ppt->p[0].y;
|
|
||||||
}
|
|
||||||
//if this point doesn't need modificaton, set m[0]=0
|
//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;
|
ppt->m[0] = 0;
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
//get the neighbboring points surrounding the 'ideal' poinnt
|
//get the neighbboring points surrounding the 'ideal' poinnt
|
||||||
if(deltax!=0) {
|
if (deltax != 0)
|
||||||
nextx=ppt->p[0].x+((deltax >0) ?1 : -1);
|
nextx = ppt->p[0].x + ((deltax > 0) ? 1 : -1);
|
||||||
} else {
|
else
|
||||||
nextx=ppt->p[0].x;
|
nextx = ppt->p[0].x;
|
||||||
}
|
if (deltay != 0)
|
||||||
if(deltay!=0) {
|
nexty = ppt->p[0].y + ((deltay > 0) ? 1 : -1);
|
||||||
nexty=ppt->p[0].y+((deltay >0) ?1 : -1);
|
else
|
||||||
} else {
|
nexty = ppt->p[0].y;
|
||||||
nexty=ppt->p[0].y;
|
|
||||||
}
|
|
||||||
//(x1,y)
|
//(x1,y)
|
||||||
ppt->p[1].x=nextx;
|
ppt->p[1].x = nextx;
|
||||||
ppt->p[1].y=ppt->p[0].y;
|
ppt->p[1].y = ppt->p[0].y;
|
||||||
//(x,y1)
|
//(x,y1)
|
||||||
ppt->p[2].x=ppt->p[0].x;
|
ppt->p[2].x = ppt->p[0].x;
|
||||||
ppt->p[2].y=nexty;
|
ppt->p[2].y = nexty;
|
||||||
//(x1y1)
|
//(x1y1)
|
||||||
ppt->p[3].x=nextx;
|
ppt->p[3].x = nextx;
|
||||||
ppt->p[3].y=nexty;
|
ppt->p[3].y = nexty;
|
||||||
//the square 1x1, so opposite poinnts are at 1-delta
|
//the square 1x1, so opposite poinnts are at 1-delta
|
||||||
inv_deltax=1.0-fabs(deltax);
|
inv_deltax = 1.0 - fabs (deltax);
|
||||||
inv_deltax*=inv_deltax;
|
inv_deltax *= inv_deltax;
|
||||||
inv_deltay=1.0-fabs(deltay);
|
inv_deltay = 1.0 - fabs (deltay);
|
||||||
inv_deltay*=inv_deltay;
|
inv_deltay *= inv_deltay;
|
||||||
deltax*=deltax;
|
deltax *= deltax;
|
||||||
deltay*=deltay;
|
deltay *= deltay;
|
||||||
//d1-d4 contain the distances from the poinnts to the ideal point
|
//d1-d4 contain the distances from the poinnts to the ideal point
|
||||||
d1=sqrt(deltax+deltay);
|
d1 = sqrt (deltax + deltay);
|
||||||
d2=sqrt(inv_deltax+deltay);
|
d2 = sqrt (inv_deltax + deltay);
|
||||||
d3=sqrt(deltax+inv_deltay);
|
d3 = sqrt (deltax + inv_deltay);
|
||||||
d4=sqrt(inv_deltax+inv_deltay);
|
d4 = sqrt (inv_deltax + inv_deltay);
|
||||||
//compute the weights. the sum(ppt->m[])=65536
|
//compute the weights. the sum(ppt->m[])=65536
|
||||||
m[0]=1/(1+d1*(1/d2+1/d3+1/d4));
|
m[0] = 1 / (1 + d1 * (1 / d2 + 1 / d3 + 1 / d4));
|
||||||
m[1]=m[0]*d1/d2;
|
m[1] = m[0] * d1 / d2;
|
||||||
m[2]=m[0]*d1/d3;
|
m[2] = m[0] * d1 / d3;
|
||||||
m[3]=m[0]*d1/d4;
|
m[3] = m[0] * d1 / d4;
|
||||||
for(i=0;i<4;i++)
|
for (i=0; i<4; i++)
|
||||||
ppt->m[i]=(DWORD)((1<<16)*m[i]+0.5);
|
ppt->m[i] = (DWORD)((1 << 16) * m[i] + 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get_avg_rgb creates either a red, green, or blue value by
|
//get_avg_rgb creates either a red, green, or blue value by
|
||||||
//computing the weightd averages of the 4 points in p1
|
//computing the weightd averages of the 4 points in p1
|
||||||
UBYTE get_avg_rgb(DWORD p1[4],DWORD mult[4],COUNT offset) {
|
static UBYTE
|
||||||
COUNT i,j;
|
get_avg_rgb (DWORD p1[4], DWORD mult[4], COUNT offset) {
|
||||||
|
COUNT i, j;
|
||||||
UBYTE c;
|
UBYTE c;
|
||||||
DWORD ci;
|
DWORD ci = 0;
|
||||||
|
|
||||||
i=offset<<3;
|
i = offset << 3;
|
||||||
ci=0;
|
|
||||||
//sum(mult[])==65536
|
//sum(mult[])==65536
|
||||||
//c is the red/green/blue value of this pixel
|
//c is the red/green/blue value of this pixel
|
||||||
for(j=0;j<4;j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
c=(UBYTE)(p1[j] >> i);
|
c = (UBYTE)(p1[j] >> i);
|
||||||
ci+=c*mult[j];
|
ci += c * mult[j];
|
||||||
}
|
}
|
||||||
ci=ci>>16;
|
ci >>= 16;
|
||||||
//check for overflow
|
//check for overflow
|
||||||
if (ci> 255)
|
if ( ci > 255)
|
||||||
ci=255;
|
ci = 255;
|
||||||
return((UBYTE)ci);
|
return ((UBYTE)ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPlanetTilt creates 'map_rotate' to map the topo data
|
// SetPlanetTilt creates 'map_rotate' to map the topo data
|
||||||
@@ -351,38 +356,37 @@ UBYTE get_avg_rgb(DWORD p1[4],DWORD mult[4],COUNT offset) {
|
|||||||
void
|
void
|
||||||
SetPlanetTilt (int angle)
|
SetPlanetTilt (int angle)
|
||||||
{
|
{
|
||||||
int x,y,y_2;
|
int x, y, y_2;
|
||||||
double multx,multy;
|
double multx = (MAP_HEIGHT / M_PI) / RADIUS;
|
||||||
multx=(MAP_HEIGHT/M_PI)/RADIUS;
|
double multy = (MAP_HEIGHT / M_PI) / RADIUS;
|
||||||
multy=(MAP_HEIGHT/M_PI)/RADIUS;
|
for (y = -RADIUS; y <= RADIUS; y++)
|
||||||
for(y=-RADIUS;y<=RADIUS;y++)
|
|
||||||
{
|
{
|
||||||
y_2=y*y;
|
y_2 = y * y;
|
||||||
for(x=-RADIUS;x<=RADIUS;x++)
|
for (x = -RADIUS; x <= RADIUS; x++)
|
||||||
{
|
{
|
||||||
double dx, dy, newx, newy;
|
double dx, dy, newx, newy;
|
||||||
double da,rad,rad2;
|
double da, rad, rad2;
|
||||||
MAP3D_POINT *ppt=&map_rotate[y+RADIUS][x+RADIUS];
|
MAP3D_POINT *ppt = &map_rotate[y + RADIUS][x + RADIUS];
|
||||||
rad2=x*x+y_2;
|
rad2 = x * x + y_2;
|
||||||
if(rad2<=RADIUS_2) {
|
if (rad2 <= RADIUS_2) {
|
||||||
rad=sqrt(rad2);
|
rad = sqrt (rad2);
|
||||||
da=atan2((double)y,(double)x);
|
da = atan2 ((double)y, (double)x);
|
||||||
// compute the planet-tilt
|
// compute the planet-tilt
|
||||||
if(angle != 0) {
|
if (angle != 0) {
|
||||||
dx=rad*cos(da+M_DEG2RAD*angle);
|
dx = rad * cos (da + M_DEG2RAD * angle);
|
||||||
dy=rad*sin(da+M_DEG2RAD*angle);
|
dy = rad * sin (da + M_DEG2RAD * angle);
|
||||||
} else {
|
} else {
|
||||||
dx=x;
|
dx = x;
|
||||||
dy=y;
|
dy = y;
|
||||||
}
|
}
|
||||||
//Map the sphere onto a plane
|
//Map the sphere onto a plane
|
||||||
newx=RADIUS*(multx*acos(-dx/RADIUS));
|
newx = RADIUS * (multx * acos (-dx / RADIUS));
|
||||||
newy=RADIUS*(multy*acos(-dy/RADIUS));
|
newy = RADIUS * (multy * acos (-dy / RADIUS));
|
||||||
create_aa_points(ppt,newx,newy);
|
create_aa_points (ppt, newx, newy);
|
||||||
} else {
|
} else {
|
||||||
ppt->p[0].x=x+RADIUS;
|
ppt->p[0].x = x + RADIUS;
|
||||||
ppt->p[0].y=y+RADIUS;
|
ppt->p[0].y = y + RADIUS;
|
||||||
ppt->m[0]=0;
|
ppt->m[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,70 +400,76 @@ SetPlanetTilt (int angle)
|
|||||||
// this routine, but a filter can be applied if desired too.
|
// this routine, but a filter can be applied if desired too.
|
||||||
|
|
||||||
//Outer diameter of HALO
|
//Outer diameter of HALO
|
||||||
#define SHIELD_RADIUS (RADIUS+5)
|
#define SHIELD_RADIUS (RADIUS + 5)
|
||||||
#define SHIELD_DIAM ((SHIELD_RADIUS<<1)+1)
|
#define SHIELD_DIAM ((SHIELD_RADIUS << 1) + 1)
|
||||||
#define SHIELD_RADIUS_2 SHIELD_RADIUS*SHIELD_RADIUS
|
#define SHIELD_RADIUS_2 (SHIELD_RADIUS * SHIELD_RADIUS)
|
||||||
void CreateShieldMask()
|
static void CreateShieldMask ()
|
||||||
{
|
{
|
||||||
DWORD rad2,clear,**rgba,p;
|
DWORD rad2, clear, **rgba, p;
|
||||||
UBYTE red_nt;
|
UBYTE red_nt;
|
||||||
int x,y;
|
int x, y;
|
||||||
FRAME ShieldFrame;
|
FRAME ShieldFrame;
|
||||||
DWORD aa_delta,aa_delta2;
|
DWORD aa_delta, aa_delta2;
|
||||||
|
|
||||||
ShieldFrame = CaptureDrawable (
|
ShieldFrame = CaptureDrawable (
|
||||||
CreateDrawable (WANT_PIXMAP, SHIELD_DIAM, SHIELD_DIAM, 1)
|
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
|
// This is a non-transparent red for the halo
|
||||||
red_nt=180;
|
red_nt = 180;
|
||||||
// This is 100% transparent.
|
// This is 100% transparent.
|
||||||
clear=frame_mapRGBA (ShieldFrame,0,0,0,0);
|
clear = frame_mapRGBA (ShieldFrame, 0, 0, 0, 0);
|
||||||
aa_delta=SHIELD_RADIUS_2-(SHIELD_RADIUS-1)*(SHIELD_RADIUS-1);
|
aa_delta = SHIELD_RADIUS_2 - (SHIELD_RADIUS - 1) * (SHIELD_RADIUS - 1);
|
||||||
aa_delta2=(RADIUS+3)*(RADIUS+3)-(RADIUS+2)*(RADIUS+2);
|
aa_delta2 = (RADIUS + 3) * (RADIUS + 3) - (RADIUS + 2)*(RADIUS + 2);
|
||||||
for(y=-SHIELD_RADIUS;y<=SHIELD_RADIUS;y++) {
|
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++) {
|
rgba[y+SHIELD_RADIUS] = (DWORD *)HCalloc (sizeof (DWORD) * (SHIELD_DIAM));
|
||||||
rad2=x*x+y*y;
|
for (x = -SHIELD_RADIUS; x <= SHIELD_RADIUS; x++)
|
||||||
if(rad2<=SHIELD_RADIUS_2) {
|
{
|
||||||
|
rad2 = x * x + y * y;
|
||||||
|
if (rad2 <= SHIELD_RADIUS_2)
|
||||||
|
{
|
||||||
//Inside the halo
|
//Inside the halo
|
||||||
if(rad2<=RADIUS_2) {
|
if (rad2 <= RADIUS_2)
|
||||||
// The mask for the planet
|
// The mask for the planet
|
||||||
p=clear;
|
p=clear;
|
||||||
} else if (rad2<=(RADIUS+2)*(RADIUS+2)) {
|
else if (rad2 <= (RADIUS + 2) * (RADIUS + 2))
|
||||||
// The space between the halo and the planet
|
// The space between the halo and the planet
|
||||||
p=frame_mapRGBA(ShieldFrame,0,0,0,255);
|
p = frame_mapRGBA (ShieldFrame, 0, 0, 0, 255);
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
// The halo itself
|
// The halo itself
|
||||||
UBYTE red=red_nt;
|
UBYTE red = red_nt;
|
||||||
if(rad2>(SHIELD_RADIUS-1)*(SHIELD_RADIUS-1))
|
if (rad2 > (SHIELD_RADIUS - 1) * (SHIELD_RADIUS - 1))
|
||||||
{
|
{
|
||||||
DWORD r;
|
DWORD r;
|
||||||
r=rad2-(SHIELD_RADIUS-1)*(SHIELD_RADIUS-1);
|
r = rad2 - (SHIELD_RADIUS - 1) * (SHIELD_RADIUS - 1);
|
||||||
red=red_nt-(UBYTE)(red_nt*r/aa_delta);
|
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;
|
DWORD r;
|
||||||
r = rad2 - (RADIUS+2)*(RADIUS+2);
|
r = rad2 - (RADIUS + 2) * (RADIUS + 2);
|
||||||
red = (UBYTE)(red_nt*r/aa_delta2);
|
red = (UBYTE)(red_nt * r / aa_delta2);
|
||||||
}
|
}
|
||||||
p=frame_mapRGBA (ShieldFrame,red,0,0,255);
|
p = frame_mapRGBA (ShieldFrame, red, 0, 0, 255);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
p=clear;
|
else
|
||||||
}
|
p = clear;
|
||||||
|
|
||||||
rgba[y+SHIELD_RADIUS][x+SHIELD_RADIUS]=p;
|
rgba[y + SHIELD_RADIUS][x + SHIELD_RADIUS] = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process_rgb_bmp(ShieldFrame,rgba,SHIELD_DIAM,SHIELD_DIAM);
|
process_rgb_bmp (ShieldFrame, rgba, SHIELD_DIAM, SHIELD_DIAM);
|
||||||
SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS+1,SHIELD_RADIUS+1));
|
SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS + 1,SHIELD_RADIUS + 1));
|
||||||
for (y=-SHIELD_RADIUS; y <= SHIELD_RADIUS; ++y)
|
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;
|
pSolarSysState->ShieldFrame = ShieldFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderLevelMasks builds a frame for the rotating planet view
|
// RenderLevelMasks builds a frame for the rotating planet view
|
||||||
@@ -470,83 +480,85 @@ RenderLevelMasks (int offset)
|
|||||||
{
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
DWORD **rgba;
|
DWORD **rgba;
|
||||||
int x,y;
|
int x, y;
|
||||||
DWORD p,**pixels;
|
DWORD p, **pixels;
|
||||||
FRAME MaskFrame;
|
FRAME MaskFrame;
|
||||||
|
|
||||||
#if PROFILE
|
#if PROFILE
|
||||||
static clock_t t=0;
|
static clock_t t = 0;
|
||||||
static int frames_done=1;
|
static int frames_done = 1;
|
||||||
clock_t t1;
|
clock_t t1;
|
||||||
t1=clock();
|
t1 = clock ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rgba=malloc(sizeof(DWORD *)*(DIAMETER));
|
rgba = HMalloc (sizeof (DWORD *) * (DIAMETER));
|
||||||
// Choose the correct Frame to wrte to
|
// Choose the correct Frame to wrte to
|
||||||
MaskFrame = pSolarSysState->PlanetFrameArray[offset];
|
MaskFrame = pSolarSysState->PlanetFrameArray[offset];
|
||||||
pixels=pSolarSysState->lpTopoMap;
|
pixels = pSolarSysState->lpTopoMap;
|
||||||
for (pt.y = 0, y=-RADIUS; pt.y <= TWORADIUS; ++pt.y,++y)
|
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)
|
for (pt.x = 0, x = -RADIUS; pt.x <= TWORADIUS; ++pt.x, ++x)
|
||||||
{
|
{
|
||||||
UBYTE c[3];
|
UBYTE c[3];
|
||||||
int ph;
|
int ph;
|
||||||
COUNT i;
|
COUNT i;
|
||||||
DWORD p1[4];
|
DWORD p1[4];
|
||||||
MAP3D_POINT *ppt=&map_rotate[pt.y][pt.x];
|
MAP3D_POINT *ppt = &map_rotate[pt.y][pt.x];
|
||||||
rgba[pt.y][pt.x]=0;
|
ph = phong[pt.y][pt.x];
|
||||||
ph=phong[pt.y][pt.x];
|
if (ph < 1 << PHONG_BITS)
|
||||||
if(ph < 1<<PHONG_BITS) {
|
{
|
||||||
if(ppt->m[0]==0) {
|
if (ppt->m[0] == 0)
|
||||||
p=pixels[ppt->p[0].y][ppt->p[0].x+offset];
|
{
|
||||||
c[0]=(UBYTE)(p>>8);
|
p = pixels[ppt->p[0].y][ppt->p[0].x + offset];
|
||||||
c[1]=(UBYTE)(p>>16);
|
c[0] = (UBYTE)(p >> 8);
|
||||||
c[2]=(UBYTE)(p>>24);
|
c[1] = (UBYTE)(p >> 16);
|
||||||
} else {
|
c[2] = (UBYTE)(p >> 24);
|
||||||
for(i=0;i<4;i++) {
|
}
|
||||||
p1[i]=pixels[ppt->p[i].y][ppt->p[i].x+offset];
|
else
|
||||||
}
|
{
|
||||||
for(i=1;i<4;i++) {
|
for (i = 0; i < 4; i++)
|
||||||
c[i-1]=get_avg_rgb(p1,ppt->m,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
|
// 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[2] = GET_PHONG (255, ph);
|
||||||
c[0]=GET_PHONG(c[0]>>1,ph);
|
c[1] = GET_PHONG (c[1] >> 1, ph);
|
||||||
} else {
|
c[0] = GET_PHONG (c[0] >> 1, ph);
|
||||||
c[2]=GET_PHONG(c[2],ph);
|
}
|
||||||
c[1]=GET_PHONG(c[1],ph);
|
else
|
||||||
c[0]=GET_PHONG(c[0],ph);
|
{
|
||||||
|
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);
|
rgba[pt.y][pt.x] = frame_mapRGBA (
|
||||||
} else {
|
MaskFrame, c[2], c[1], c[0], (UBYTE)255);
|
||||||
rgba[pt.y][pt.x]=frame_mapRGBA (MaskFrame,0,0,0,0);
|
}
|
||||||
}
|
else
|
||||||
|
rgba[pt.y][pt.x] = frame_mapRGBA (MaskFrame, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Map the rgb bitmap onto the SDL_Surface
|
// Map the rgb bitmap onto the SDL_Surface
|
||||||
process_rgb_bmp(pSolarSysState->PlanetFrameArray[offset],rgba,DIAMETER,DIAMETER);
|
process_rgb_bmp (pSolarSysState->PlanetFrameArray[offset], rgba, DIAMETER, DIAMETER);
|
||||||
SetFrameHot (MaskFrame, MAKE_HOT_SPOT (RADIUS+1,RADIUS+1));
|
SetFrameHot (MaskFrame, MAKE_HOT_SPOT (RADIUS + 1, RADIUS + 1));
|
||||||
for (pt.y = 0, y=-RADIUS; pt.y <= TWORADIUS; ++pt.y,++y)
|
for (pt.y = 0; pt.y <= TWORADIUS; ++pt.y)
|
||||||
{
|
HFree (rgba[pt.y]);
|
||||||
free(rgba[pt.y]);
|
HFree(rgba);
|
||||||
}
|
|
||||||
free(rgba);
|
|
||||||
#if PROFILE
|
#if PROFILE
|
||||||
if(frames_done==MAP_WIDTH) {
|
t += clock() - t1;
|
||||||
t+=clock()-t1;
|
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;
|
fprintf (stderr, "frames/sec: %d/%d(msec)=%f\n", frames_done, t,
|
||||||
t=clock()-t1;
|
frames_done / ((double)t / CLOCKS_PER_SEC));
|
||||||
} else {
|
frames_done = 1;
|
||||||
t+=clock()-t1;
|
t = clock () - t1;
|
||||||
frames_done++;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
frames_done++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1071,23 +1083,31 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
|
|||||||
RECT r;
|
RECT r;
|
||||||
DWORD old_seed;
|
DWORD old_seed;
|
||||||
PLANDATAPTR PlanDataPtr;
|
PLANDATAPTR PlanDataPtr;
|
||||||
COUNT i;
|
COUNT i, x, y;
|
||||||
|
POINT loc;
|
||||||
|
CONTEXT OldContext;
|
||||||
|
|
||||||
old_seed = SeedRandom (pPlanetDesc->rand_seed);
|
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)
|
if (IsEarth)
|
||||||
{
|
{
|
||||||
//Earth uses a pixmap for the topography
|
//Earth uses a pixmap for the topography
|
||||||
pSolarSysState->TopoFrame = CaptureDrawable (
|
pSolarSysState->TopoFrame = CaptureDrawable (
|
||||||
LoadGraphic (EARTH_MASK_ANIM)
|
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 {
|
} else {
|
||||||
|
|
||||||
pSolarSysState->lpTopoMap=NULL;
|
|
||||||
PlanDataPtr = &PlanData[
|
PlanDataPtr = &PlanData[
|
||||||
pPlanetDesc->data_index & ~PLANET_SHIELDED
|
pPlanetDesc->data_index & ~PLANET_SHIELDED
|
||||||
];
|
];
|
||||||
@@ -1162,85 +1182,60 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
pSolarSysState->TopoFrame = CaptureDrawable (
|
||||||
|
CreateDrawable (WANT_PIXMAP, (SIZE)MAP_WIDTH, (SIZE)MAP_HEIGHT, 1)
|
||||||
|
);
|
||||||
|
pSolarSysState->OrbitalCMap = CaptureColorMap (
|
||||||
|
LoadColorMap (PlanDataPtr->CMapInstance)
|
||||||
|
);
|
||||||
|
pSolarSysState->XlatRef = CaptureStringTable (
|
||||||
|
LoadStringTable (PlanDataPtr->XlatTabInstance)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > HOT_THRESHOLD)
|
||||||
|
{
|
||||||
|
pSolarSysState->OrbitalCMap = SetAbsColorMapIndex (
|
||||||
|
pSolarSysState->OrbitalCMap, 2
|
||||||
|
);
|
||||||
|
pSolarSysState->XlatRef = SetAbsStringTableIndex (pSolarSysState->XlatRef, 2);
|
||||||
|
}
|
||||||
|
else if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > COLD_THRESHOLD)
|
||||||
|
{
|
||||||
|
pSolarSysState->OrbitalCMap = SetAbsColorMapIndex (
|
||||||
|
pSolarSysState->OrbitalCMap, 1
|
||||||
|
);
|
||||||
|
pSolarSysState->XlatRef = SetAbsStringTableIndex (pSolarSysState->XlatRef, 1);
|
||||||
|
}
|
||||||
|
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
|
||||||
|
x = MAP_WIDTH + MAP_HEIGHT;
|
||||||
|
y = MAP_HEIGHT;
|
||||||
|
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++)
|
||||||
|
pSolarSysState->lpTopoMap[y][x + MAP_WIDTH] = pSolarSysState->lpTopoMap[y][x];
|
||||||
|
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0])
|
||||||
{
|
{
|
||||||
CONTEXT OldContext;
|
// This is a planet. Get its location
|
||||||
|
loc = pSolarSysState->pOrbitalDesc->location;
|
||||||
|
} else {
|
||||||
|
// This is a moon. Get its planet's location
|
||||||
|
loc = pSolarSysState->pOrbitalDesc->pPrevDesc->location;
|
||||||
|
}
|
||||||
|
RenderPhongMask (loc);
|
||||||
|
|
||||||
OldContext = SetContext (TaskContext);
|
if (pPlanetDesc->data_index & PLANET_SHIELDED)
|
||||||
pSolarSysState->isPFADefined=(BYTE *)calloc(255,sizeof(BYTE));
|
CreateShieldMask();
|
||||||
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) {
|
SetContext (OldContext);
|
||||||
pSolarSysState->TopoFrame = CaptureDrawable (
|
|
||||||
CreateDrawable (WANT_PIXMAP, (SIZE)MAP_WIDTH, (SIZE)MAP_HEIGHT, 1)
|
|
||||||
);
|
|
||||||
pSolarSysState->OrbitalCMap = CaptureColorMap (
|
|
||||||
LoadColorMap (PlanDataPtr->CMapInstance)
|
|
||||||
);
|
|
||||||
pSolarSysState->XlatRef = CaptureStringTable (
|
|
||||||
LoadStringTable (PlanDataPtr->XlatTabInstance)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > HOT_THRESHOLD)
|
|
||||||
{
|
|
||||||
pSolarSysState->OrbitalCMap = SetAbsColorMapIndex (
|
|
||||||
pSolarSysState->OrbitalCMap, 2
|
|
||||||
);
|
|
||||||
pSolarSysState->XlatRef = SetAbsStringTableIndex (pSolarSysState->XlatRef, 2);
|
|
||||||
}
|
|
||||||
else if (pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature > COLD_THRESHOLD)
|
|
||||||
{
|
|
||||||
pSolarSysState->OrbitalCMap = SetAbsColorMapIndex (
|
|
||||||
pSolarSysState->OrbitalCMap, 1
|
|
||||||
);
|
|
||||||
pSolarSysState->XlatRef = SetAbsStringTableIndex (pSolarSysState->XlatRef, 1);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
// 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++) {
|
|
||||||
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
|
|
||||||
loc=pSolarSysState->pOrbitalDesc->location;
|
|
||||||
} else {
|
|
||||||
// This is a moon. Get its planet's location
|
|
||||||
loc=pSolarSysState->pOrbitalDesc->pPrevDesc->location;
|
|
||||||
}
|
|
||||||
RenderPhongMask(loc);
|
|
||||||
}
|
|
||||||
if (pPlanetDesc->data_index & PLANET_SHIELDED) {
|
|
||||||
fprintf(stderr,"Found shield\n");
|
|
||||||
CreateShieldMask();
|
|
||||||
}
|
|
||||||
|
|
||||||
SetContext (OldContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
SeedRandom (old_seed);
|
SeedRandom (old_seed);
|
||||||
|
|
||||||
@@ -1248,7 +1243,7 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rotate_planet_task(void *data)
|
rotate_planet_task (void *data)
|
||||||
{
|
{
|
||||||
SIZE i;
|
SIZE i;
|
||||||
DWORD TimeIn;
|
DWORD TimeIn;
|
||||||
@@ -1301,7 +1296,9 @@ rotate_planet_task(void *data)
|
|||||||
r.extent.height = SIS_SCREEN_HEIGHT - MAP_HEIGHT;
|
r.extent.height = SIS_SCREEN_HEIGHT - MAP_HEIGHT;
|
||||||
RepairBackRect (&r);
|
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 ();
|
UnbatchGraphics ();
|
||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user