/* GlintBox (Release 1.00) */ /* MrFrosty (Hex Heroes) - 2nd November 1997 */ /* website: http://www.netyaroze-europe.com/~mrfrosty */ /* email: j.t.rutherford@sms.ed.ac.uk */ /* Don't worry if you can't follow the code - it's a lot more complicated */ /* than it has to be because I built it with the flexibility to add */ /* more later. Watch out for updates... Have fun! */ /* To run this effect, after having installed 'djsetup' type 'make'. */ /* When the code has compiled, enter 'siocons auto'. */ #include // >>> THINGS TO PLAY WITH <<< /* Uncomment DEBUG for VSYNC counter */ /* Uncomment NTSC_SYSTEM for NTSC (default is PAL) */ //#define DEBUG //#define NTSC_SYSTEM /* Alter the colour values to between 0 and 255 */ /* (rand()/128) produces a random value (0 to 255) */ /* Setting one value at each end of the line produces a nice effect */ #define RED0 (rand()/128) #define GREEN0 0 #define BLUE0 0 #define RED1 0 #define GREEN1 0 #define BLUE1 (rand()/128) /* Play with the semitransparency effect */ /* Switches transparency on/off (1 is on) */ /* Bit 28 and 29 alter the transparency rate */ /* (See GsGLINE in the Library Reference) */ #define LINE_ATTRIBUTE ((1<<30)+(1<<28)+(1<<29)) /* MOVESPEED alters the speed of the points */ /* Altering this will give a very wide variety of effects */ /* Try: MOVESPEED0 MOVESPEED1 */ /* ---------- ---------- */ /* (SCALEFACTOR*4) (SCALEFACTOR*3) */ /* (SCALEFACTOR) (SCALEFACTOR*2) */ /* (SCALEFACTOR) (SCALEFACTOR) */ /* (SCALEFACTOR) -(SCALEFACTOR*2) */ #define MOVESPEED0 (SCALEFACTOR*4) #define MOVESPEED1 (SCALEFACTOR*3) // >>> THINGS YOU SHOULD BE CAREFUL PLAYING WITH <<< /* SCALEFACTOR sets the effect resolution */ #define SCALEFACTOR 32 #define OT_LENGTH 1 /* Ensure that the PACKETSIZE = (N_LINES * 25) plus a few bytes */ #define N_LINES 350 #define PACKETSIZE 8760 // >>> TYPEDEFS <<< typedef struct{ short x0; short y0; short x1; short y1; } BOX2D; typedef struct{ GsGLINE gsgline; BOX2D* box2d[2]; short xdir[2]; short ydir[2]; } BOX2DLINE; // >>> FUNCTION PROTOTYPES <<< int GlintBox(void); void SetupBOX2D(BOX2D* box2d, short x0, short y0, short x1, short y1); void SetupBOX2DLINE(BOX2DLINE* box2dline, u_long attribute, short x0, short y0, short x1, short y1, short r0, short g0, short b0, short r1, short g1, short b1, short xdir0, short ydir0, short xdir1, short ydir1, BOX2D* box2d0, BOX2D* box2d1); void MoveBOX2DLINE(BOX2DLINE* box2dline, short* lx, short* ly, int line); // >>> FUNCTIONS <<< void main(void) { #ifdef NTSC_SYSTEM SetVideoMode(MODE_NTSC); #else SetVideoMode(MODE_PAL); #endif GsInitGraph(320, 240, 4, 0, 0); GsDefDispBuff(0, 0, 0, 240); FntLoad(960, 256); FntOpen(16, 16, 256, 200, 0, 512); GlintBox(); } int GlintBox(void) { GsOT world_ot[2]; GsOT_TAG world_ot_tag[2][1<x0 = x0; box2d->y0 = y0; box2d->x1 = x1; box2d->y1 = y1; } void SetupBOX2DLINE(BOX2DLINE* box2dline, u_long attribute, short x0, short y0, short x1, short y1, short r0, short g0, short b0, short r1, short g1, short b1, short xdir0, short ydir0, short xdir1, short ydir1, BOX2D* box2d0, BOX2D* box2d1) { box2dline->gsgline.attribute = attribute; box2dline->gsgline.x0 = x0 / SCALEFACTOR; box2dline->gsgline.y0 = y0 / SCALEFACTOR; box2dline->gsgline.x1 = x1 / SCALEFACTOR; box2dline->gsgline.y1 = y1 / SCALEFACTOR; box2dline->gsgline.r0 = r0; box2dline->gsgline.g0 = g0; box2dline->gsgline.b0 = b0; box2dline->gsgline.r1 = r1; box2dline->gsgline.g1 = g1; box2dline->gsgline.b1 = b1; box2dline->xdir[0] = xdir0; box2dline->ydir[0] = ydir0; box2dline->xdir[1] = xdir1; box2dline->ydir[1] = ydir1; box2dline->box2d[0] = box2d0; box2dline->box2d[1] = box2d1; } void MoveBOX2DLINE(BOX2DLINE* box2dline, short* lx, short* ly, int line) { short newx = ((*lx) * SCALEFACTOR) + box2dline->xdir[line]; short newy = ((*ly) * SCALEFACTOR) + box2dline->ydir[line]; if(newx > box2dline->box2d[line]->x1) { newy = box2dline->box2d[line]->y0 + (newx - box2dline->box2d[line]->x1); newx = box2dline->box2d[line]->x1; box2dline->ydir[line] = box2dline->xdir[line]; box2dline->xdir[line] = 0; } if(newy > box2dline->box2d[line]->y1) { newx = box2dline->box2d[line]->x1 - (newy - box2dline->box2d[line]->y1); newy = box2dline->box2d[line]->y1; box2dline->xdir[line] = -box2dline->ydir[line]; box2dline->ydir[line] = 0; } if(newx < box2dline->box2d[line]->x0) { newy = box2dline->box2d[line]->y1 - (box2dline->box2d[line]->x0 - newx); newx = box2dline->box2d[line]->x0; box2dline->ydir[line] = box2dline->xdir[line]; box2dline->xdir[line] = 0; } if(newy < box2dline->box2d[line]->y0) { newx = box2dline->box2d[line]->x0 + (box2dline->box2d[line]->y0 - newy); newy = box2dline->box2d[line]->y0; box2dline->xdir[line] = -box2dline->ydir[line]; box2dline->ydir[line] = 0; } (*lx) = (newx / SCALEFACTOR); (*ly) = (newy / SCALEFACTOR); //FntPrint("LX %d\nXS %d\n", *lx, (newx/SCALEFACTOR)); }