2000-08-29 21:54:22 +02:00
|
|
|
/****************/
|
|
|
|
/*** PSX Main ***/
|
|
|
|
/****************/
|
|
|
|
|
|
|
|
#include <libmcrd.h>
|
|
|
|
|
|
|
|
#include "system\global.h"
|
|
|
|
#include "fileio\fileio.h"
|
|
|
|
#include "pad\pads.h"
|
|
|
|
#include "system\vid.h"
|
|
|
|
#include "gfx\prim.h"
|
|
|
|
#include "gfx\tpage.h"
|
|
|
|
#include "utils\utils.h"
|
2001-04-01 22:22:49 +02:00
|
|
|
#include "gfx\actor.h"
|
2000-08-29 21:54:22 +02:00
|
|
|
|
|
|
|
#include "system\gp.h"
|
|
|
|
|
|
|
|
// scenes
|
|
|
|
#include "game\game.h"
|
|
|
|
|
2000-11-15 16:37:12 +01:00
|
|
|
#ifndef __FRONTEND_FRONTEND_H__
|
|
|
|
#include "frontend\frontend.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __USER_paul__
|
|
|
|
#include "paul\paul.h"
|
|
|
|
CPaulScene s_paulScene;
|
2001-01-11 18:09:44 +01:00
|
|
|
#include "paul\scenesel.h"
|
2000-11-15 16:37:12 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-29 21:54:22 +02:00
|
|
|
#ifndef __SYSTEM_GSTATE_H__
|
|
|
|
#include "system\gstate.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __LOCALE_TEXTDBASE_H__
|
|
|
|
#include "locale\textdbase.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-06 00:40:39 +02:00
|
|
|
#ifndef __SOUND_SOUND_H__
|
|
|
|
#include "sound\sound.h"
|
|
|
|
#endif
|
|
|
|
|
2000-09-12 01:55:20 +02:00
|
|
|
|
2000-10-20 23:52:46 +02:00
|
|
|
#ifndef __SYSTEM_EXCEPT_H__
|
|
|
|
#include "system\except.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-09 17:58:22 +01:00
|
|
|
#ifndef __GFX_FONT_H__
|
|
|
|
#include "gfx\font.h"
|
|
|
|
#endif
|
2000-10-20 23:52:46 +02:00
|
|
|
|
2000-11-09 17:58:22 +01:00
|
|
|
#ifndef __GUI_GUI_H__
|
|
|
|
#include "gui\gui.h"
|
|
|
|
#endif
|
2000-10-20 23:52:46 +02:00
|
|
|
|
2001-01-10 23:03:20 +01:00
|
|
|
#ifndef __GAME_GAMESLOT_H__
|
|
|
|
#include "game\gameslot.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-15 16:37:12 +01:00
|
|
|
#ifndef __GFX_FADER_H__
|
|
|
|
#include "gfx\fader.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GFX_BUBICLES_H__
|
|
|
|
#include "gfx\bubicles.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-04-04 02:16:57 +02:00
|
|
|
#if __FILE_SYSTEM__==PC
|
|
|
|
#if !defined(__USER_CDBUILD__)
|
|
|
|
#if defined(__VERSION_DEBUG__)
|
2001-05-12 19:24:44 +02:00
|
|
|
#define USE_SCREEN_UTILS
|
2001-04-04 02:16:57 +02:00
|
|
|
#endif
|
2001-01-19 17:08:06 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
2000-10-20 23:52:46 +02:00
|
|
|
|
2000-09-12 01:55:20 +02:00
|
|
|
|
2001-04-20 16:53:35 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
static SpriteBank GenericSpriteBank;
|
|
|
|
|
2000-08-29 21:54:22 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
void SaveScreen(RECT R);
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void InitSystem() // reordered to reduce black screen (hope all is well
|
|
|
|
{
|
|
|
|
ResetCallback();
|
|
|
|
SaveGP();
|
|
|
|
SetSp(GetSp()|0x807f0000);
|
|
|
|
// SetDispMask(0);
|
|
|
|
|
|
|
|
MemInit();
|
2001-01-03 16:57:20 +01:00
|
|
|
MemCardInit( 1 );
|
|
|
|
MemCardStart();
|
2000-08-29 21:54:22 +02:00
|
|
|
PadsInit();
|
2001-01-03 16:57:20 +01:00
|
|
|
MemCardStop();
|
2000-08-29 21:54:22 +02:00
|
|
|
|
|
|
|
CFileIO::Init();
|
|
|
|
TranslationDatabase::initialise(false);
|
|
|
|
TranslationDatabase::loadLanguage(ENGLISH);
|
|
|
|
PrimInit();
|
|
|
|
TPInit();
|
|
|
|
VidInit();
|
|
|
|
|
2000-10-20 23:52:46 +02:00
|
|
|
#ifdef __USER_paul__
|
|
|
|
installExceptionHandler(); // Where is the earliest we can do this?
|
|
|
|
#endif
|
|
|
|
|
2000-08-29 21:54:22 +02:00
|
|
|
setRndSeed( VidGetTickCount() );
|
|
|
|
|
|
|
|
SetDispMask(1);
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
GenericSpriteBank.load(SPRITES_SPRITES_SPR);
|
|
|
|
CGameScene::setSpriteBank(&GenericSpriteBank);
|
|
|
|
|
2000-08-29 21:54:22 +02:00
|
|
|
GameState::initialise();
|
2000-10-06 00:40:39 +02:00
|
|
|
CSoundMediator::initialise();
|
2001-01-31 16:51:46 +01:00
|
|
|
CSoundMediator::setSfxBank(CSoundMediator::SFX_INGAME);
|
2000-11-09 17:58:22 +01:00
|
|
|
initGUIStuff();
|
2001-01-10 23:03:20 +01:00
|
|
|
CGameSlotManager::init();
|
2000-11-09 17:58:22 +01:00
|
|
|
|
2000-11-15 16:37:12 +01:00
|
|
|
CBubicleFactory::init();
|
|
|
|
|
2001-04-01 22:22:49 +02:00
|
|
|
CActorPool::AddActor(ACTORS_SPONGEBOB_SBK);
|
2001-02-09 18:01:04 +01:00
|
|
|
|
2000-11-20 16:45:17 +01:00
|
|
|
#if defined(__DEBUG_MEM__)
|
|
|
|
DebugMemFontInit();
|
|
|
|
#endif
|
|
|
|
|
2000-09-12 01:55:20 +02:00
|
|
|
#ifdef __USER_paul__
|
|
|
|
s_paulScene.init();
|
|
|
|
#endif
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
static int s_time = 0;
|
2000-11-20 16:45:17 +01:00
|
|
|
#if defined(__DEBUG_MEM__)
|
2000-08-29 21:54:22 +02:00
|
|
|
void dumpDebugMem();
|
2000-11-20 16:45:17 +01:00
|
|
|
void DebugMemFontInit();
|
|
|
|
#endif
|
2000-08-29 21:54:22 +02:00
|
|
|
|
|
|
|
void MainLoop()
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2000-10-19 17:40:24 +02:00
|
|
|
int frames;
|
|
|
|
|
|
|
|
frames=GameState::getFramesSinceLast();
|
2000-11-09 17:58:22 +01:00
|
|
|
|
2001-01-03 16:48:42 +01:00
|
|
|
// System Think
|
2000-11-09 17:58:22 +01:00
|
|
|
FontBank::think(frames);
|
2001-01-03 16:48:42 +01:00
|
|
|
CSoundMediator::think(frames);
|
2000-08-29 21:54:22 +02:00
|
|
|
|
2001-01-03 16:48:42 +01:00
|
|
|
// Think States
|
|
|
|
GameState::think();
|
2000-11-15 16:37:12 +01:00
|
|
|
CBubicleFactory::think(frames);
|
|
|
|
CFader::think(frames);
|
|
|
|
|
2000-09-12 01:55:20 +02:00
|
|
|
#ifdef __USER_paul__
|
2000-10-19 17:40:24 +02:00
|
|
|
s_paulScene.think(frames);
|
2000-09-12 01:55:20 +02:00
|
|
|
#endif
|
2000-08-29 21:54:22 +02:00
|
|
|
while(DrawSync(1));
|
|
|
|
|
2001-01-03 16:48:42 +01:00
|
|
|
// Render States
|
2001-05-02 00:40:25 +02:00
|
|
|
CFader::render();
|
2001-01-03 16:48:42 +01:00
|
|
|
GameState::render();
|
|
|
|
CBubicleFactory::render();
|
|
|
|
|
|
|
|
#ifdef __USER_paul__
|
|
|
|
s_paulScene.render();
|
|
|
|
#endif
|
2000-08-29 21:54:22 +02:00
|
|
|
|
2001-01-03 16:48:42 +01:00
|
|
|
VSync(0);
|
2001-01-04 22:53:14 +01:00
|
|
|
VidSwapDraw();
|
2001-01-04 23:12:40 +01:00
|
|
|
PrimDisplay();
|
2001-01-03 16:48:42 +01:00
|
|
|
|
2000-08-29 21:54:22 +02:00
|
|
|
PadUpdate();
|
|
|
|
|
|
|
|
DbgPollHost();
|
|
|
|
|
|
|
|
#if defined(__VERSION_DEBUG__)
|
|
|
|
|
|
|
|
#if defined(__DEBUG_MEM__)
|
|
|
|
dumpDebugMem();
|
|
|
|
#endif
|
|
|
|
|
2001-05-12 19:24:44 +02:00
|
|
|
#if defined(USE_SCREEN_UTILS)
|
2000-08-29 21:54:22 +02:00
|
|
|
if (PadGetHeld(0) & PAD_L2)
|
|
|
|
if (PadGetDown(0) & PAD_START) SaveScreen(VidGetScreen()->Draw.clip);
|
2000-10-19 17:40:24 +02:00
|
|
|
if (PadGetDown(0) & PAD_SELECT) VRamViewer();
|
2001-05-12 19:24:44 +02:00
|
|
|
#endif
|
2000-08-29 21:54:22 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
CFileIO::GetAllFilePos();
|
|
|
|
InitSystem();
|
|
|
|
|
2001-01-11 18:09:44 +01:00
|
|
|
#ifdef __USER_paul__
|
|
|
|
GameState::setNextScene( &SceneSelector );
|
2001-06-11 17:32:20 +02:00
|
|
|
#elif defined(__USER_daveo__)
|
|
|
|
GameState::setNextScene( &GameScene );
|
2000-11-15 16:37:12 +01:00
|
|
|
#else
|
2001-06-11 01:21:48 +02:00
|
|
|
GameState::setNextScene( &FrontEndScene );
|
2000-11-15 16:37:12 +01:00
|
|
|
#endif
|
2000-08-29 21:54:22 +02:00
|
|
|
|
|
|
|
// CXAStream::Init(); // PKG - Stuck here so that it doesn't affect any startup stuff (7/8/00)
|
|
|
|
MainLoop();
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-05-12 19:24:44 +02:00
|
|
|
#if defined(USE_SCREEN_UTILS)
|
2000-08-29 21:54:22 +02:00
|
|
|
#if defined(__VERSION_DEBUG__)
|
|
|
|
struct sTgaHdr
|
|
|
|
{
|
|
|
|
char id; // 0
|
|
|
|
char colmaptype; // 1
|
|
|
|
char imagetype; // 2
|
|
|
|
char fei[2]; // 3
|
|
|
|
char cml[2]; // 5
|
|
|
|
char cmes; // 7
|
|
|
|
short xorig; // 8
|
|
|
|
short yorig; // 10
|
|
|
|
short width; // 12
|
|
|
|
short height; // 14
|
|
|
|
char depth; // 15
|
|
|
|
char imagedesc; // 16
|
|
|
|
};
|
|
|
|
|
|
|
|
bool FileExists(char const * Name)
|
|
|
|
{
|
|
|
|
int FileHnd;
|
|
|
|
|
|
|
|
FileHnd=PCopen((char *)Name,0,0);
|
|
|
|
|
|
|
|
if (FileHnd!=-1)
|
|
|
|
{
|
|
|
|
PCclose(FileHnd);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveScreen(RECT SR)
|
|
|
|
{
|
|
|
|
int FileHnd;
|
|
|
|
static int ScreenNo=0;
|
|
|
|
sTgaHdr FileHdr;
|
|
|
|
int W=SR.w;
|
|
|
|
int H=SR.h;
|
|
|
|
char Filename[32];
|
|
|
|
|
2001-01-11 00:05:30 +01:00
|
|
|
sprintf( Filename, "SBSP%04d.tga", ScreenNo );
|
2000-08-29 21:54:22 +02:00
|
|
|
while (FileExists( Filename ) )
|
|
|
|
{
|
|
|
|
ScreenNo++;
|
2001-01-11 00:05:30 +01:00
|
|
|
sprintf( Filename, "SBSP%04d.tga", ScreenNo );
|
2000-08-29 21:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FileHnd=PCcreat((char *)Filename,0);
|
|
|
|
ASSERT(FileHnd != -1);
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Header
|
|
|
|
memset(&FileHdr,0 ,sizeof(sTgaHdr));
|
|
|
|
|
|
|
|
FileHdr.imagetype= 2; //imagetype
|
|
|
|
FileHdr.width = W;
|
|
|
|
FileHdr.height= H;
|
|
|
|
FileHdr.depth=24;
|
|
|
|
// FileHdr.imagedesc=24;
|
|
|
|
|
|
|
|
PCwrite(FileHnd,(char *)&FileHdr,sizeof(sTgaHdr));
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Data
|
|
|
|
int x,y;
|
|
|
|
u16 InBuffer[1024];
|
|
|
|
u8 OutBuffer[1024*3];
|
|
|
|
|
|
|
|
SR.y+=SR.h;
|
|
|
|
SR.h=1;
|
|
|
|
for (y=0; y<H; y++)
|
|
|
|
{
|
|
|
|
SR.y--;
|
|
|
|
StoreImage(&SR,(u32*)InBuffer);
|
|
|
|
|
|
|
|
for (x=0; x<W; x++)
|
|
|
|
{
|
|
|
|
u16 Col;
|
|
|
|
u8 R,G,B;
|
|
|
|
Col=InBuffer[x];
|
|
|
|
|
|
|
|
R=Col&0x1f;
|
|
|
|
G=(Col>>5)&0x1f;
|
|
|
|
B=(Col>>10)&0x1f;
|
|
|
|
|
|
|
|
R=R*255/31;
|
|
|
|
G=G*255/31;
|
|
|
|
B=B*255/31;
|
|
|
|
|
|
|
|
OutBuffer[(x*3)+0]=B;
|
|
|
|
OutBuffer[(x*3)+1]=G;
|
|
|
|
OutBuffer[(x*3)+2]=R;
|
|
|
|
}
|
|
|
|
PCwrite(FileHnd,(char *)OutBuffer,W*3);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
PCclose(FileHnd);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|