// Explosion test program (c)1998 James Shaughnessy // // ----------------------------------------- // James Shaughnessy james@manc.u-net.com // http://www.netyaroze-europe.com/~shaughnj // ----------------------------------------- #include #include #include "pad.h" // DEBUG flag //#define DEBUG #define FIREBALL_ADDR (0x80090000) #define OT_LENGTH (1) #define NUM_SPRITES (512) #define NUM_PARTICLES (NUM_SPRITES/2) #define EXPLODE_TIME (256) #define GRAVITY_FORCE (256) #define AIR_RESISTANCE (64) typedef struct { long x, y; // coords *4096 short vx, vy; // velocity short rotation; short floor; // "floor" of explosion GsSPRITE sprite; // it's actual sprite } GsPARTICLE; typedef struct { short x, y; // coords u_long timer; GsPARTICLE particle[NUM_PARTICLES]; // list of it's particles } GsEXPLOSION; // Global Variables int activeBuff; int hsyncs; u_long timer = 0; u_long padStatus = 0; extern DISPENV GsDISPENV; // Two Ordering Tables, one for each buffer GsOT WorldOT[2]; // Two Ordering Table Tags, one for each buffer GsOT_TAG OTTag[2][1<>12; Explosion.particle[i].vy -= ((Explosion.particle[i].vy*AIR_RESISTANCE)>>12) - GRAVITY_FORCE; Explosion.particle[i].x += Explosion.particle[i].vx; Explosion.particle[i].y += Explosion.particle[i].vy; Explosion.particle[i].sprite.x = (Explosion.particle[i].x>>12); Explosion.particle[i].sprite.y = (Explosion.particle[i].y>>12); Explosion.particle[i].sprite.rotate += Explosion.particle[i].rotation; // Bounce off "floor" if (Explosion.particle[i].sprite.y > Explosion.particle[i].floor) { Explosion.particle[i].y -= Explosion.particle[i].vy; Explosion.particle[i].vy = -Explosion.particle[i].vy; } // Sort particle sprites in OT GsSortSprite(&Explosion.particle[i].sprite, &WorldOT[activeBuff], 0); } } // Inits explosion data void InitExplosion(short floor) { int i; LoadTIM(FIREBALL_ADDR); srand(timer); Explosion.x = 160; Explosion.y = 128; Explosion.timer = EXPLODE_TIME; for (i=0; i>3) & 1) { setRECT(&rect, im.cx, im.cy, im.cw, im.ch); LoadImage(&rect, im.clut); } DrawSync(0); } // ****** PAD routines ****** // call once only in program initialisation void PadInit (void) { GetPadBuf(&bb0, &bb1); } // call once per VSync(0) // puts controller pad status into unsigned long integer // please refer to the manuals if you want explanation // of the internals of this function u_long PadRead(void) { return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); }