#include #include #include #include "comconst.h" #include "worm.h" #include "pad.h" #include "pixmap.h" #include "arena.h" #include "score.h" #include "setup.h" #include "sound.h" #include "credits.h" #define HEAPADDR 0x80130000 #define HEAPLEN 0x20000 CPixMap WormMap(SCREENW, SCREENH); CPixMap HoleMap(SCREENW, SCREENH); // __CTOR_LIST__ symbol created by linker typedef void (*func_ptr) (void); extern func_ptr __CTOR_LIST__[]; GsOT WorldOT[2]; GsOT_TAG OTTags[2][1<=1; h--) { __CTOR_LIST__[h](); } SetVideoMode(MODE_NTSC); GsInitGraph(SWIDTH, SHEIGHT, GsINTER | GsOFSGPU, 0, 0); GsDefDispBuff(0, 0, 0, 0); GsInit3D(); TRACE("set up video\n"); for (int i=0; i<2; i++) { WorldOT[i].length=OT_LENGTH; WorldOT[i].org=OTTags[i]; } // Set Up 3D lighting flatLight.r=255/2; flatLight.g=255/3; flatLight.b=255/3; flatLight.vx=0; flatLight.vy=ONE; flatLight.vx=0; GsSetFlatLight(0, &flatLight); GsSetAmbient(ONE/2, ONE/2, ONE/2); GsSetProjection(500); GsSetOrign(XOFFSET, YOFFSET); //GsSetOrign(0, 0); pad[0]=new CPad(1, CPad::LEFT); pad[1]=new CPad(1, CPad::RIGHT); pad[2]=new CPad(2, CPad::LEFT); pad[3]=new CPad(2, CPad::RIGHT); CCredits credits; do { // Credits screen, first because it overwrites stuff in // frame buffer int activeBuff=GsGetActiveBuff(); GsSetWorkBase((PACKET*)GpuPacketArea[activeBuff]); GsClearOt(0, 0,&WorldOT[activeBuff]); credits.Timeslice(&WorldOT[activeBuff]); GsDrawOt(&WorldOT[activeBuff]); DrawSync(0); VSync(0); ResetGraph(1); GsSwapDispBuff(); } while (!pad[0]->StartPressed() && !pad[2]->StartPressed()); CWorm::SetUpWormSprites(); arena=new CArena; setup=new CSetup; sound=new CSound; board=new CScoreboard; sound->Setup(); int running=1; while (TRUE) { int h=0; int settingup; CSound::StartTitleTune(); do { //Title screen for selecting players int activeBuff=GsGetActiveBuff(); GsSetWorkBase((PACKET*)GpuPacketArea[activeBuff]); GsClearOt(0, 0,&WorldOT[activeBuff]); GsSortClear(0, 0, 0, &WorldOT[activeBuff]); settingup=setup->Timeslice(&WorldOT[activeBuff]); GsDrawOt(&WorldOT[activeBuff]); DrawSync(0); VSync(0); ResetGraph(1); GsSwapDispBuff(); if (settingup==2) { // Quit return 0; } } while (settingup || !CArena::AtLeastOneWormIn()); CSound::StopTitleTune(); // Start a game for (int g=0; gResetScore(); } } CSound::StartTune(); do { //Repeat this loop per round (to 10 for 2 players) arena->Start(); WormMap.Clear(); HoleMap.Clear(); for (int g=0; gReset(); } } for (int g=0; g<2; g++) { // Clear both interlace portions of screen int activeBuff=GsGetActiveBuff(); GsSetWorkBase((PACKET*)GpuPacketArea[activeBuff]); GsClearOt(0, 0,&WorldOT[activeBuff]); DrawSync(0); VSync(0); GsSwapDispBuff(); GsSortClear(0, 0, 0, &WorldOT[activeBuff]); GsDrawOt(&WorldOT[activeBuff]); } running=1; while (running==1) { // Main game loop int activeBuff=GsGetActiveBuff(); GsSetWorkBase((PACKET*)GpuPacketArea[activeBuff]); GsClearOt(0, 0,&WorldOT[activeBuff]); running=arena->Timeslice(&WorldOT[activeBuff]); board->DisplayScores(&WorldOT[activeBuff], arena); GsDrawOt(&WorldOT[activeBuff]); DrawSync(0); VSync(0); GsSwapDispBuff(); } do { // This stops flickering while we wait for the // start button to be pressed for next round int activeBuff=GsGetActiveBuff(); GsSetWorkBase((PACKET*)GpuPacketArea[activeBuff]); GsClearOt(0, 0,&WorldOT[activeBuff]); board->DisplayScores(&WorldOT[activeBuff], arena); GsDrawOt(&WorldOT[activeBuff]); DrawSync(0); VSync(0); GsSwapDispBuff(); h=(h+1)%4; } while ((!pad[h]->StartPressed()) && (!pad[h]->SelectPressed())); } while (pad[h]->StartPressed() && (running==0)); CSound::StopTune(); } return(0); }