/******************/ /*** GFx System ***/ /******************/ #include "system/global.h" #include "system\vid.h" #include "gfx\prim.h" #include "fileio\fileio.h" #ifndef __SPR_UIGFX_H__ #include #endif /*****************************************************************************/ #define MaxVBFuncs 4 /*****************************************************************************/ static void (*VbFunc)(void); static VbFuncType VbFuncList[MaxVBFuncs]; static u32 FrameCounter=0,TickCount=0,TickBuffer[2]; static sVidScreen Screen[2]; static int ScreenXOfs=0,ScreenYOfs=0; static int ScreenW, ScreenH; static RECT ScreenRect; /*static*/ int FrameFlipFlag=0; static int ClearScreen=0; static u8 *ScreenImage=0; static const CVECTOR s_defClearCol = {0, 0, 0}; /*****************************************************************************/ /*** Loading Icon Cack *******************************************************/ /*****************************************************************************/ POLY_FT4 LoadPoly[2]; static int LoadX=430; static int LoadY=161; static int LoadHalfWidth; static int LoadIconSide; static int DrawLoadIcon=0; static RECT LoadBackRect; static int LoadBackY; static int LoadTime=0; /*****************************************************************************/ // Altered to keep aspect ratio s8 LoadTab[]= { 21,21,21,21,20,20,20,20,19,19,19,18,18,17,17,16,15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,17,18,18,19,19,19,20,20,20,20,20,21 }; const int LoadTabSize=sizeof(LoadTab)/sizeof(s8); /*****************************************************************************/ void LoadingIcon() { int Dst; int rgb; POLY_FT4 *PolyPtr=&LoadPoly[LoadIconSide]; Dst=LoadTab[LoadTime]; PolyPtr->x0=PolyPtr->x2=LoadX-Dst+LoadHalfWidth+2; PolyPtr->x1=PolyPtr->x3=LoadX+Dst+LoadHalfWidth+2; rgb=128-(LoadTab[(LoadTime+LoadTabSize/2)%LoadTabSize]*3); setRGB0(PolyPtr,rgb,rgb,rgb); MoveImage(&LoadBackRect,LoadX,LoadY+LoadBackY); PutDrawEnv(&Screen[FrameFlipFlag^1].Draw); DrawPrim(PolyPtr); LoadTime++; if (LoadTime>=LoadTabSize) LoadTime=0; if(LoadTime==LoadTabSize/2) LoadIconSide^=1; } /*****************************************************************************/ void StartLoad(int _loadX,int _loadY) { /* sFrameHdr *fh; SpriteBank *spr; spr=UIGetSharedSpriteBank(); LoadX=_loadX; LoadY=_loadY; setPolyFT4(&LoadPoly[0]); fh=spr->getFrameHeader(FRM__CD); setXYWH(&LoadPoly[0],LoadX,LoadY,fh->W,fh->H); setUVWH(&LoadPoly[0],fh->U,fh->V,fh->W,fh->H); LoadPoly[0].tpage=fh->TPage; LoadPoly[0].clut=fh->Clut; setPolyFT4(&LoadPoly[1]); fh=spr->getFrameHeader(FRM__CDFRONT); setXYWH(&LoadPoly[1],LoadX,LoadY,fh->W,fh->H); setUVWH(&LoadPoly[1],fh->U,fh->V,fh->W,fh->H); LoadPoly[1].tpage=fh->TPage; LoadPoly[1].clut=fh->Clut; LoadHalfWidth=fh->W/2; Screen[0].Draw.isbg=Screen[1].Draw.isbg=0; PutDrawEnv(&Screen[FrameFlipFlag^1].Draw); PutDispEnv(&Screen[FrameFlipFlag].Disp); LoadBackY=Screen[FrameFlipFlag^1].Disp.disp.y; setRECT(&LoadBackRect,LoadX,LoadY+(LoadBackY^256),fh->W+4,fh->H+4); LoadTime=0; DrawLoadIcon=1; LoadIconSide=0; */ } /*****************************************************************************/ void StopLoad() { while(LoadTime) { VSync(0); } Screen[0].Draw.isbg=Screen[1].Draw.isbg=1; DrawLoadIcon=0; } /*****************************************************************************/ /*** VSync *******************************************************************/ /*****************************************************************************/ extern "C" { static void VidVSyncCallback() { int i; FrameCounter++; TickCount++; if (DrawLoadIcon) LoadingIcon(); if (VbFunc) { VbFunc(); VbFunc = NULL; } for (i=0; i< MaxVBFuncs; i++) if (VbFuncList[i]) VbFuncList[i](); } } /*****************************************************************************/ void VidAddVSyncFunc(VbFuncType v) { int i; for (i=0; idisp.x=0; Disp->disp.y=ScrH; Disp->disp.w=512; Disp->disp.h=256; Disp->screen.x=ScreenXOfs; Disp->screen.y=ScreenYOfs; Disp->screen.w=256; Disp->screen.h=256; PutDispEnv(Disp); PutDrawEnv(Draw); // If set, load background screen if (ScreenImage) LoadImage2(&Screen[LastFrame].Disp.disp ,(u_long*)ScreenImage); if(ScreenClipBox==1) { DrawLine(15,25,512-15,25,255,0,0,0); DrawLine(15,256-25,512-15,256-25,255,0,0,0); DrawLine(15,25,15,256-25,255,0,0,0); DrawLine(512-15,25,512-15,256-25,255,0,0,0); DrawLine(0,0,511,0,0,255,0,0); DrawLine(0,255,511,255,0,255,0,0); DrawLine(0,0,0,255,0,255,0,0); DrawLine(511,0,511,255,0,255,0,0); } if(ScreenClipBox==2) { POLY_F4 *f4; f4=GetPrimF4(); setXYWH(f4,0,0,512,20); setRGB0(f4,50,50,50); AddPrimToList(f4,0); f4=GetPrimF4(); setXYWH(f4,0,256-20,512,20); setRGB0(f4,50,50,50); AddPrimToList(f4,0); f4=GetPrimF4(); setXYWH(f4,512-10,20,10,256-40); setRGB0(f4,50,50,50); AddPrimToList(f4,0); f4=GetPrimF4(); setXYWH(f4,0,20,10,256-40); setRGB0(f4,50,50,50); AddPrimToList(f4,0); } } /*****************************************************************************/ /*** VRAM VIEWER *************************************************************/ /*****************************************************************************/ #define UseVRamViewer #ifdef UseVRamViewer #include "pad\pads.H" void VRamViewer() { bool Done=0; sVidScreen *Scr=VidGetScreen(); u16 Pad; int OldX=Scr->Disp.disp.x,OldY=Scr->Disp.disp.y; while(!Done) { PadUpdate(); DbgPollHost(); #ifdef __USER_ARTDEV__ Pad=PadGetHeld(1); #else Pad=PadGetHeld(0); #endif #ifdef __USER_paul__ // my finger was hurting.. if((PadGetDown(0) & PAD_SELECT)) Done=1; #else if(!(Pad & PAD_SELECT)) Done=1; #endif if(Pad&PAD_LEFT) if(Scr->Disp.disp.x) Scr->Disp.disp.x--; if(Pad&PAD_RIGHT) if(Scr->Disp.disp.x<700) Scr->Disp.disp.x++; if(Pad&PAD_UP) if(Scr->Disp.disp.y) Scr->Disp.disp.y--; if(Pad&PAD_DOWN) if(Scr->Disp.disp.y<256) Scr->Disp.disp.y++; PutDispEnv(&Scr->Disp); PutDrawEnv(&Scr->Draw); } Scr->Disp.disp.x=OldX; Scr->Disp.disp.y=OldY; } #endif