#include #include "define.h" /* General Stuff */ void GraphicsLoopStart( void ) { ActiveBuff=GsGetActiveBuff(); /* ActiveBuff must be global */ GsSetWorkBase((PACKET *)GpuPacketArea[ActiveBuff]); /* Set memory area for grpahics, send pointer to area relating to current buffer */ GsClearOt(0,0,&OrderingTable[ActiveBuff]); /* Clear ordering table, for new stuff */ } void GraphicsLoopEnd( void ) { DrawSync(0); /* Wait for end of drawing */ VSync(0); /* Wait for TV to finish showing current display */ GsSwapDispBuff(); /* Change display buffer */ GsSortClear(sortr,sortg,sortb,&OrderingTable[ActiveBuff]); /* Sort OT */ GsDrawOt(&OrderingTable[ActiveBuff]); /* Put OT on screen */ } void GraphicsInitStart( void ) { GsInitGraph(SCREEN_WIDTH,SCREEN_HEIGHT,4,0,0); /* Init basic graphics functions */ GsDefDispBuff(0,0,0,SCREEN_HEIGHT); /* Tell VRAM where I want my 2 buffers */ SetVideoMode(MODE_PAL); /* Make PAL, sorry NTSC users, not worth it for this basic crap */ /* Setup OT info */ for(i=0;i<2;i++) { OrderingTable[i].length=OT_LENGTH; OrderingTable[i].org=OTTags[i]; } } /* 2d Stuff */ void LoadTIM(long timaddr) { RECT rect; /* multi-used RECT struct */ GsIMAGE tim; /* Used to store info on TIM file */ GsGetTimInfo((u_long *)(timaddr+4), &tim); /* Get info on TIM file, and put it in the tim GsIMAGE struct */ rect.x=tim.px; /* x co-ord of tim */ rect.y=tim.py; /* y co-ord of tim */ rect.w=tim.pw; /* width of tim */ rect.h=tim.ph; /* height of tim */ LoadImage(&rect,tim.pixel); /* Load tim info into VRAM */ if((tim.pmode>>3)&0x01) /* If tim is 4 0r 8 bit */ { rect.x=tim.cx; /* x co-ord of clut */ rect.y=tim.cy; /* y co-ord of clut */ rect.w=tim.cw; /* width of clut */ rect.h=tim.ch; /* height of clut */ LoadImage(&rect,tim.clut); /* Load clut info into VRAM */ } DrawSync(0); /* Wait for LoadImage()s to finish */ } void InitGsSPRITE(long timaddr, GsSPRITE *loadsprite, short spritex, short spritey) { GsIMAGE tim; /* Used to store info on TIM file */ LoadTIM(timaddr); /* Load tim into VRAM */ GsGetTimInfo((u_long *)(timaddr+4),&tim); /* Get info on TIM file, and put it in the tim GsIMAGE struct */ loadsprite->attribute=(unsigned long int)(tim.pmode<<24); /* Set sprite attribute to the value passed to function */ loadsprite->x=spritex; /* Set starting x pos to a passed value */ loadsprite->y=spritey; /* Set starting y pos to a passed value */ if((tim.pmode<<24)& 0x01000000) loadsprite->w=tim.pw*2; else if((tim.pmode<<24)& 0x02000000) loadsprite->w=tim.pw; else loadsprite->w=tim.pw*4; loadsprite->h=tim.ph; /* Set sprite height */ loadsprite->tpage=GetTPage(1,0, tim.px, tim.py); /* Texture page info */ loadsprite->u=0; /* Set tpage x offset */ loadsprite->v=0; /* Set tpage y offset */ loadsprite->cx=tim.cx; /* Tell sprite x pos of clut */ loadsprite->cy=tim.cy; /* Tell sprite y pos of clut */ loadsprite->r=128; /* Set the r brightness */ loadsprite->g=128; /* Set the g brightness */ loadsprite->b=128; /* Set the b brightness */ loadsprite->mx=0; /* Set manipulation point x */ loadsprite->my=0; /* Set manipulation point y */ loadsprite->scalex=ONE; /* scale in x direction */ loadsprite->scaley=ONE; /* scale in y direction */ loadsprite->rotate=0; /* amount of rotation */ } void CentraliseSprite(GsSPRITE *centresprite) { centresprite->x=(SCREEN_WIDTH-centresprite->w)/2; /* Put sprite's x in middle */ centresprite->y=(SCREEN_HEIGHT-centresprite->h)/2; /* Put sprite's y in middle */ } void CheckSpritePosition(GsSPRITE *spritepos) { /* All stuff to put sprite back on screen if it goes off */ if(spritepos->x<0) spritepos->x=0; if((spritepos->x+spritepos->w)>SCREEN_WIDTH) spritepos->x=(SCREEN_WIDTH-spritepos->w); if(spritepos->y<0) spritepos->y=0; if((spritepos->y+spritepos->h)>SCREEN_HEIGHT) spritepos->y=(SCREEN_HEIGHT-spritepos->h); } void InitGsLINE(GsLINE *initline, short firstx, short firsty, short secondx, short secondy, u_char red, u_char green, u_char blue) { initline->x0=firstx; initline->y0=firsty; initline->x1=secondx; initline->y1=secondy; initline->r=red; initline->g=green; initline->b=blue; } void InitGsBOXF(GsBOXF *initbox, short xbox, short ybox, u_short boxw, u_short boxh, u_char red, u_char green, u_char blue) { initbox->x=xbox; initbox->y=ybox; initbox->w=boxw; initbox->h=boxh; initbox->r=red; initbox->g=green; initbox->b=blue; }