// lib2dh.h // Hi-res version // Complete 2D development library // High performance macros & functions // Compiled by Harvey Cotton // ****************************************************************************************************************** Defines #define VIDEO_MODE MODE_PAL #define SCREEN_WIDTH 512 #define SCREEN_HEIGHT 480 #define HALF_WIDTH 256 #define HALF_HEIGHT 240 #define BG_RED 0 #define BG_GREEN 0 #define BG_BLUE 0 #define TRUE 1 #define FALSE 0 #define ORDERING_TABLE_LENGTH 12 #define MAX_NO_PACKETS 64000 // *********************************************************************************************************** Ordering table long CurrentBuffer; GsOT TableHeader [2]; GsOT_TAG TableArray [2][1<u=_w*_xf, \ (_s)->v=_h*_yf, \ (_s)->w=_w, \ (_s)->h=_h, \ (_s)->m=_w>>1, \ (_s)->my=_h>>1 #define SetLinePos(_l,_x0,_y0,_x1,_y1) \ (_l)->x0=_x0, \ (_l)->y0=_y0, \ (_l)->x1=_x1, \ (_l)->y1=_y1 #define SetRect(_r,_x,_y,_w,_h) \ (_r)->x=_x, \ (_r)->y=_y, \ (_r)->w=_w, \ (_r)->h=_h #define SetRGB(_x,_r,_g,_b) \ (_x)->r=_r, \ (_x)->g=_g, \ (_x)->b=_b #define SetRGB2(_x,_r0,_g0,_b0,_r1,_g1,_b1) \ (_x)->r0=_r0, \ (_x)->g0=_g0, \ (_x)->b0=_b0, \ (_x)->r1=_r1, \ (_x)->g1=_g1, \ (_x)->b1=_b1 // ****************************************************************************************************** Collision detection #define Collision(_x1,_y1,_w1,_h1,_x2,_y2,_w2,_h2) (_w1+_w2)>abs(_x1-_x2) && (_h1+_h2)>abs(_y1-_y2) #define PointCollision(_x1,_y1,_x2,_y2,_w2,_h2) abs(_x1-_x2)<_w2 && abs(_y1-_y2)<_h2 #define ClipSprite(_x,_y,_w,_h) _w+HALF_WIDTH>abs(HALF_WIDTH-_x) && _h+HALF_HEIGHT>abs(HALF_HEIGHT-_y) #define ClipSpriteFast(_x,_y) abs(HALF_WIDTH-_x)(_h)?(_h):(_x)) #define BoundsWrap(_x,_l,_h) ((_x)<(_l)?(_x)+(_h)+(_l):(_x)>(_h)?(_x)-(_h):(_x)) #define Sign(_x) ((_x)<0?-1:1) #define Bearing(_x1,_y1,_x2,_y2) ATanFast(_x2-_x1,_y2-_y1) #define AngleDifference(_angle1,_angle2) (abs(_angle1-_angle2)>180?abs(abs(_angle1-_angle2)-360):abs(_angle1-_angle2)) #define MoveVector(_x,_y,_a,_f) \ _x+=(_f*FCOS[_a])>>12, \ _y+=(_f*FSIN[_a])>>12 u_long IntegerSqrt (u_long x); short ATanFast (long x, long y); u_long Distance (long x1,long y1,long x2,long y2); void AdjustAngle (short *angle1,short angle2,short step); // ************************************************************************************************************** Control pad volatile u_long PAD,PADBUFFER; volatile u_char *bb0,*bb1; #define PADLup 4096 #define PADLdown 16384 #define PADLleft 32768 #define PADLright 8192 #define PADLtriangle 16 #define PADLcircle 32 #define PADLcross 64 #define PADLsquare 128 #define PADLL1 4 #define PADLL2 1 #define PADLR1 8 #define PADLR2 2 #define PADLstart 2048 #define PADLselect 256 #define PADRup 268435456 #define PADRdown 1073741824 #define PADRleft 2147483648 #define PADRright 536870912 #define PADRtriangle 1048576 #define PADRcircle 2097152 #define PADRcross 4194304 #define PADRsquare 8388608 #define PADRL1 262144 #define PADRL2 65536 #define PADRR1 524288 #define PADRR2 131072 #define PADRstart 134217728 #define PADRselect 16777216 #define ReadPad() (~(*(bb0+3) | *(bb0+2)<<8 | *(bb1+3)<<16 | *(bb1+2)<<24)) #define ReadPad2() \ PADBUFFER=PAD, \ PAD=(~(*(bb0+3) | *(bb0+2)<<8 | *(bb1+3)<<16 | *(bb1+2)<<24))