This commit is contained in:
parent
e9f123dec7
commit
74ac11a27f
40 changed files with 6829 additions and 0 deletions
76
source/system/global.h
Normal file
76
source/system/global.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/**********************/
|
||||
/*** Global Defines ***/
|
||||
/**********************/
|
||||
|
||||
#ifndef _GLOBAL_HEADER_
|
||||
#define _GLOBAL_HEADER_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <libetc.h>
|
||||
#include <libgte.h>
|
||||
#include <libgpu.h>
|
||||
#include <libsn.h>
|
||||
#include <libcd.h>
|
||||
#include <libspu.h>
|
||||
#include <libapi.h>
|
||||
#include <inline_c.h>
|
||||
#include <sys\types.h>
|
||||
#include "utils\replace.h"
|
||||
#include <gtemac.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed long s32;
|
||||
typedef long long s64;
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef s8 S8;
|
||||
typedef s16 S16;
|
||||
typedef s32 S32;
|
||||
typedef s64 S64;
|
||||
|
||||
typedef u8 U8;
|
||||
typedef u16 U16;
|
||||
typedef u32 U32;
|
||||
typedef u64 U64;
|
||||
|
||||
/*****************************************************************************/
|
||||
#define SCRATCH_RAM 0x1f800000
|
||||
#define FAST_STACK (SCRATCH_RAM+0x3f0)
|
||||
|
||||
enum
|
||||
{
|
||||
FRACTION_SHIFT = 8,
|
||||
};
|
||||
|
||||
enum DRAW_TYPE
|
||||
{
|
||||
DT_NORMAL,
|
||||
DT_TRANSPARENT,
|
||||
DT_SUBTRACT,
|
||||
DT_ADDITION,
|
||||
DT_MULTIPLY,
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
#include "mem\memory.h"
|
||||
#include "system\gte.h"
|
||||
#include "utils\cmxmacro.h"
|
||||
#include "utils\fixed.h"
|
||||
|
||||
#include "system\debug.h"
|
||||
#include "system\info.h"
|
||||
#include "system\lnkopt.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
18
source/system/gp.h
Normal file
18
source/system/gp.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/****************/
|
||||
/*** GP Stuph ***/
|
||||
/****************/
|
||||
|
||||
#ifndef __GP_H__
|
||||
#define __GP_H__
|
||||
|
||||
/*****************************************************************************/
|
||||
extern "C"
|
||||
{
|
||||
void SaveGP(void);
|
||||
u32 ReloadGP(void);
|
||||
void SetGP(u32 GpVal);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
97
source/system/gstate.cpp
Normal file
97
source/system/gstate.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*=========================================================================
|
||||
|
||||
gstate.cpp
|
||||
|
||||
Author: PKG
|
||||
Created:
|
||||
Project: PRLSR
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 2000 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
|
||||
#include "system\global.h"
|
||||
#include "system\gstate.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
static CScene *s_currentScene;
|
||||
static CScene *s_pendingScene;
|
||||
|
||||
int GameState::s_timeSinceLast;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void GameState::initialise()
|
||||
{
|
||||
s_currentScene=NULL;
|
||||
s_pendingScene=NULL;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void GameState::think()
|
||||
{
|
||||
updateTimer();
|
||||
|
||||
if( s_pendingScene )
|
||||
{
|
||||
if( !s_currentScene)
|
||||
{
|
||||
if( s_currentScene )
|
||||
{
|
||||
s_currentScene->Shutdown();
|
||||
}
|
||||
|
||||
s_currentScene=s_pendingScene;
|
||||
s_pendingScene=NULL;
|
||||
|
||||
s_currentScene->Init();
|
||||
}
|
||||
}
|
||||
ASSERT(s_currentScene);
|
||||
s_currentScene->Control();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void GameState::render()
|
||||
{
|
||||
ASSERT(s_currentScene);
|
||||
s_currentScene->Render();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void GameState::setNextScene( CScene *_nextScene )
|
||||
{
|
||||
ASSERT(!s_pendingScene);
|
||||
|
||||
s_pendingScene=_nextScene;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
CScene * GameState::getCurrentScene()
|
||||
{
|
||||
return s_currentScene;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void GameState::updateTimer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
69
source/system/gstate.h
Normal file
69
source/system/gstate.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*=========================================================================
|
||||
|
||||
gstate.h
|
||||
|
||||
Author: PKG
|
||||
Created:
|
||||
Project: PRLSR
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 2000 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __SYSTEM_GSTATE_H__
|
||||
#define __SYSTEM_GSTATE_H__
|
||||
|
||||
class CScene
|
||||
{
|
||||
public:
|
||||
CScene() {}
|
||||
virtual ~CScene() {}
|
||||
|
||||
virtual void Init()=0;
|
||||
virtual void Shutdown()=0;
|
||||
virtual void Render()=0;
|
||||
virtual bool Control()=0;
|
||||
virtual char *GetSceneName()=0;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
class GameState
|
||||
{
|
||||
public:
|
||||
static void initialise();
|
||||
static void think();
|
||||
static void render();
|
||||
|
||||
static void setNextScene( CScene *_nextScene );
|
||||
|
||||
inline static u32 getTimeSinceLast() {return s_timeSinceLast;}
|
||||
inline static u32 getFramesSinceLast() {return (s_timeSinceLast>>12)+1;}
|
||||
|
||||
static void setTimeSpeed( int speed );
|
||||
|
||||
static CScene * getCurrentScene();
|
||||
|
||||
#if defined(__TERRITORY_USA__) || defined(__TERRITORY_JAP__)
|
||||
static int getOneSecondInFrames() {return 60;}
|
||||
#else
|
||||
static int getOneSecondInFrames() {return 50;}
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Try and instantiate a GameState and you will fail miserably :)
|
||||
GameState();
|
||||
|
||||
static void updateTimer();
|
||||
static int s_timeSinceLast;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* __SYSTEM_GSTATE_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
47
source/system/gte.h
Normal file
47
source/system/gte.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef _included_gte_
|
||||
#define _included_gte_
|
||||
|
||||
//
|
||||
// Store individual components of sv
|
||||
//
|
||||
|
||||
#define gte_stsv_x( r0 ) __asm__ volatile ( \
|
||||
"mfc2 $12, $9;" \
|
||||
"sh $12, 0( %0 );" \
|
||||
: \
|
||||
: "r"( r0 ) \
|
||||
: "$12", "memory" )
|
||||
|
||||
#define gte_stsv_y( r0 ) __asm__ volatile ( \
|
||||
"mfc2 $12, $10;" \
|
||||
"sh $12, 0( %0 );" \
|
||||
: \
|
||||
: "r"( r0 ) \
|
||||
: "$12", "memory" )
|
||||
|
||||
#define gte_stsv_z( r0 ) __asm__ volatile ( \
|
||||
"mfc2 $12, $11;" \
|
||||
"sh $12, 0( %0 );" \
|
||||
: \
|
||||
: "r"( r0 ) \
|
||||
: "$12", "memory" )
|
||||
|
||||
#define gte_stlvl_x( r0 ) __asm__ volatile ( \
|
||||
"swc2 $9, 0( %0 );" \
|
||||
: \
|
||||
: "r"( r0 ) \
|
||||
: "memory" )
|
||||
|
||||
#define gte_stlvl_y( r0 ) __asm__ volatile ( \
|
||||
"swc2 $10, 0( %0 );" \
|
||||
: \
|
||||
: "r"( r0 ) \
|
||||
: "memory" )
|
||||
|
||||
#define gte_stlvl_z( r0 ) __asm__ volatile ( \
|
||||
"swc2 $11, 0( %0 );" \
|
||||
: \
|
||||
: "r"( r0 ) \
|
||||
: "memory" )
|
||||
|
||||
#endif
|
61
source/system/info.h
Normal file
61
source/system/info.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*=========================================================================
|
||||
|
||||
INFO.H
|
||||
|
||||
Author:
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __SYSTEM_INFO_H__
|
||||
#define __SYSTEM_INFO_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
extern char INF_Version[];
|
||||
extern char INF_Territory[];
|
||||
extern char INF_FileSystem[];
|
||||
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __SYSTEM_INFO_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
37
source/system/lnkopt.h
Normal file
37
source/system/lnkopt.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
#ifndef __SYSTEM_LNKOPT_H__
|
||||
#define __SYSTEM_LNKOPT_H__
|
||||
|
||||
enum FILE_SYSTEM
|
||||
{
|
||||
FS_PC =0,
|
||||
FS_CD
|
||||
};
|
||||
|
||||
|
||||
enum DEV_KIT
|
||||
{
|
||||
DK_SONY_ISA =0,
|
||||
DK_SONY_PCI,
|
||||
DK_CLIMAX,
|
||||
DK_TPWART,
|
||||
};
|
||||
|
||||
|
||||
struct LNK_OPTS
|
||||
{
|
||||
u32 RamSize;
|
||||
u32 StackSize;
|
||||
void * OrgAddress;
|
||||
void * FreeMemAddress;
|
||||
u32 FreeMemSize;
|
||||
FILE_SYSTEM FileSystem;
|
||||
DEV_KIT DevKit;
|
||||
u32 extraCtorsSize;
|
||||
void * extraCtorsAddress;
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern LNK_OPTS OPT_LinkerOpts;
|
||||
#endif /* __SYSTEM_LNKOPT_H__ */
|
229
source/system/main.cpp
Normal file
229
source/system/main.cpp
Normal file
|
@ -0,0 +1,229 @@
|
|||
/****************/
|
||||
/*** 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"
|
||||
|
||||
#include "system\gp.h"
|
||||
|
||||
// scenes
|
||||
#include "game\game.h"
|
||||
|
||||
#ifndef __SYSTEM_GSTATE_H__
|
||||
#include "system\gstate.h"
|
||||
#endif
|
||||
|
||||
#ifndef __LOCALE_TEXTDBASE_H__
|
||||
#include "locale\textdbase.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define SCREEN_GRAB
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void SaveScreen(RECT R);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void InitSystem() // reordered to reduce black screen (hope all is well
|
||||
{
|
||||
ResetCallback();
|
||||
SaveGP();
|
||||
SetSp(GetSp()|0x807f0000);
|
||||
// SetDispMask(0);
|
||||
|
||||
MemInit();
|
||||
// MemCardInit( 1 );
|
||||
// MemCardStart();
|
||||
PadsInit();
|
||||
// MemCardStop();
|
||||
|
||||
CFileIO::Init();
|
||||
TranslationDatabase::initialise(false);
|
||||
TranslationDatabase::loadLanguage(ENGLISH);
|
||||
PrimInit();
|
||||
TPInit();
|
||||
VidInit();
|
||||
|
||||
setRndSeed( VidGetTickCount() );
|
||||
|
||||
SetDispMask(1);
|
||||
|
||||
GameState::initialise();
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static int s_time = 0;
|
||||
void dumpDebugMem();
|
||||
|
||||
void MainLoop()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
GameState::think();
|
||||
GameState::render();
|
||||
|
||||
while(DrawSync(1));
|
||||
|
||||
VSync(0);
|
||||
|
||||
VidSwapDraw();
|
||||
PrimDisplay();
|
||||
PadUpdate();
|
||||
|
||||
DbgPollHost();
|
||||
|
||||
#if defined(__VERSION_DEBUG__)
|
||||
|
||||
#if defined(__DEBUG_MEM__)
|
||||
dumpDebugMem();
|
||||
#endif
|
||||
|
||||
#if defined(SCREEN_GRAB)
|
||||
if (PadGetHeld(0) & PAD_L2)
|
||||
if (PadGetDown(0) & PAD_START) SaveScreen(VidGetScreen()->Draw.clip);
|
||||
#endif
|
||||
|
||||
// PKG - Moved vram viewer to SELECT on pad 2 for art dev machines
|
||||
if (PadGetDown(0) & PAD_SELECT) VRamViewer();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
int main()
|
||||
{
|
||||
CFileIO::GetAllFilePos();
|
||||
InitSystem();
|
||||
|
||||
GameState::setNextScene( &GameScene );
|
||||
|
||||
// CXAStream::Init(); // PKG - Stuck here so that it doesn't affect any startup stuff (7/8/00)
|
||||
MainLoop();
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
#if defined(SCREEN_GRAB)
|
||||
#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];
|
||||
|
||||
sprintf( Filename, "PRLSR%04d.tga", ScreenNo );
|
||||
while (FileExists( Filename ) )
|
||||
{
|
||||
ScreenNo++;
|
||||
sprintf( Filename, "PRLSR%04d.tga", ScreenNo );
|
||||
}
|
||||
|
||||
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
|
||||
|
445
source/system/vid.cpp
Normal file
445
source/system/vid.cpp
Normal file
|
@ -0,0 +1,445 @@
|
|||
/******************/
|
||||
/*** GFx System ***/
|
||||
/******************/
|
||||
|
||||
#include "system/global.h"
|
||||
#include "system\vid.h"
|
||||
#include "gfx\prim.h"
|
||||
#include "fileio\fileio.h"
|
||||
|
||||
#ifndef __SPR_UIGFX_H__
|
||||
#include <uigfx.h>
|
||||
#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; i<MaxVBFuncs; i++)
|
||||
{
|
||||
if (!VbFuncList[i])
|
||||
{
|
||||
VbFuncList[i] = v;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ASSERT(!"Number of Vsync Funcs == MaxVBFuncs");
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void VidRemoveVSyncFunc(VbFuncType v)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<MaxVBFuncs; i++)
|
||||
{
|
||||
if (VbFuncList[i] == v)
|
||||
{
|
||||
VbFuncList[i] = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ASSERT(!"VSYNC Func Not Found");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
int VidGetXOfs() {return(ScreenXOfs);}
|
||||
int VidGetYOfs() {return(ScreenYOfs);}
|
||||
void VidSetXYOfs(int x,int y) {ScreenXOfs = x; ScreenYOfs = y;}
|
||||
int VidGetScrW() {return(ScreenW);}
|
||||
int VidGetScrH() {return(ScreenH);}
|
||||
sVidScreen *VidGetScreen() {return &Screen[FrameFlipFlag];}
|
||||
sVidScreen *VidGetDispScreen() {return (VidGetScreen());}
|
||||
sVidScreen *VidGetDrawScreen() {return &Screen[FrameFlipFlag^1];}
|
||||
u32 VidGetFrameCount() {return(FrameCounter);}
|
||||
u32 VidGetTickCount() {return(TickBuffer[FrameFlipFlag^1]);}
|
||||
|
||||
void SetScreenImage(u8 *Ptr) {ScreenImage=Ptr;}
|
||||
u8 *GetScreenImage() {return ScreenImage;}
|
||||
void ClearScreenImage() {ScreenImage=0;}
|
||||
|
||||
/*****************************************************************************/
|
||||
void ClearVRam()
|
||||
{
|
||||
#if defined(__VERSION_DEBUG__) && !defined(__USER_CDBUILD__)
|
||||
RECT Rect;
|
||||
//Clear All Videoram
|
||||
setRECT(&Rect,512,0,512,512);
|
||||
ClearImage(&Rect,0,0,0);
|
||||
|
||||
int X;
|
||||
for (X=0;X<16;X++)
|
||||
{
|
||||
u8 C0=0xff*(X&1);
|
||||
DrawSync(0); setRECT(&Rect,X*64, 0,1024/16,256); ClearImage(&Rect,C0,0,0xff-C0);
|
||||
DrawSync(0); setRECT(&Rect,X*64,256,1024/16,256); ClearImage(&Rect,0xff-C0,0,C0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void VidScrOn()
|
||||
{
|
||||
Screen[0].Draw.isbg = ClearScreen;
|
||||
Screen[1].Draw.isbg = ClearScreen;
|
||||
VSync(0); // wait for V-BLANK
|
||||
SetDispMask(1); // display on
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void VidSetDrawEnv()
|
||||
{
|
||||
int x = VidGetScrW();
|
||||
int y = VidGetScrH();
|
||||
|
||||
SetDefDrawEnv( &Screen[0].Draw, 0, 0, x, y );
|
||||
SetDefDispEnv( &Screen[0].Disp, 0, y, x, y );
|
||||
|
||||
SetDefDrawEnv( &Screen[1].Draw, 0, y, x, y );
|
||||
SetDefDispEnv( &Screen[1].Disp, 0, 0, x, y );
|
||||
|
||||
Screen[0].Draw.isbg = ClearScreen;
|
||||
Screen[1].Draw.isbg = ClearScreen;
|
||||
|
||||
Screen[0].Draw.dtd = 1;
|
||||
Screen[1].Draw.dtd = 1;
|
||||
|
||||
VidSetClearColor( s_defClearCol );
|
||||
|
||||
SetDrawEnv( &Screen[0].Draw.dr_env, &Screen[0].Draw );
|
||||
SetDrawEnv( &Screen[1].Draw.dr_env, &Screen[1].Draw );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void VidSetClearColor( const CVECTOR & col )
|
||||
{
|
||||
Screen[0].Draw.r0 = Screen[1].Draw.r0 = col.r;
|
||||
Screen[0].Draw.g0 = Screen[1].Draw.g0 = col.g;
|
||||
Screen[0].Draw.b0 = Screen[1].Draw.b0 = col.b;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void VidSetClearScreen(int Flag)
|
||||
{
|
||||
ClearScreen = Flag;
|
||||
VidSetDrawEnv();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void VidSetRes(int x, int y)
|
||||
{
|
||||
ASSERT( y == 256 );
|
||||
|
||||
if ((VidGetScrW() != x) || (VidGetScrH() != y))
|
||||
{
|
||||
RECT clrRect;
|
||||
|
||||
ScreenW=x;
|
||||
ScreenH=y;
|
||||
|
||||
VidSetDrawEnv();
|
||||
SetGeomOffset( (x / 2), (y / 2) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void VidInit()
|
||||
{
|
||||
// Wap up a loading screen
|
||||
//u8 *screenData=CFileIO::loadFile(SCREENS_LOADING_GFX,"Loading Screen");
|
||||
// SetScreenImage(screenData);
|
||||
|
||||
// VidSetXYOfs( ScreenXOfs, ScreenYOfs );
|
||||
|
||||
SetDispMask(0);
|
||||
#if defined(__TERRITORY_USA__) || defined(__TERRITORY_JAP__)
|
||||
SetVideoMode( MODE_NTSC );
|
||||
#else
|
||||
SetVideoMode( MODE_PAL );
|
||||
#endif
|
||||
|
||||
VSync(0);
|
||||
VSync(0);
|
||||
ResetGraph(0);
|
||||
SetGraphDebug(0);
|
||||
ClearVRam();
|
||||
InitGeom();
|
||||
SetGeomScreen(GEOM_SCREEN_H);
|
||||
|
||||
VidSetRes( 512, 256 );
|
||||
DrawSync(0);
|
||||
VidSwapDraw();
|
||||
DrawSync(0);
|
||||
VidSwapDraw();
|
||||
DrawSync(0);
|
||||
SetScreenImage(0);
|
||||
// MemFree(screenData);
|
||||
VidScrOn();
|
||||
|
||||
// Init VBL
|
||||
VbFunc = NULL;
|
||||
for (int i=0; i<MaxVBFuncs; i++) VbFuncList[i] = NULL;
|
||||
VSyncCallback( VidVSyncCallback );
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int pofx=0;
|
||||
int pofy=0;
|
||||
#ifdef __USER_paul__
|
||||
int ScreenClipBox=1;
|
||||
#else
|
||||
int ScreenClipBox=0;
|
||||
#endif
|
||||
void VidSwapDraw()
|
||||
{
|
||||
DRAWENV *Draw;
|
||||
DISPENV *Disp;
|
||||
int LastFrame=FrameFlipFlag;
|
||||
int ScrH=VidGetScrH()*FrameFlipFlag;
|
||||
|
||||
FrameFlipFlag^=1;
|
||||
TickBuffer[FrameFlipFlag]=TickCount; TickCount=0;
|
||||
Draw=&Screen[FrameFlipFlag].Draw;
|
||||
Disp=&Screen[FrameFlipFlag].Disp;
|
||||
Disp->disp.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
|
56
source/system/vid.h
Normal file
56
source/system/vid.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/******************/
|
||||
/*** GFx System ***/
|
||||
/******************/
|
||||
|
||||
#ifndef __VID_HEADER_
|
||||
#define __VID_HEADER_
|
||||
|
||||
#include "system\global.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
#define GEOM_SCREEN_H 350
|
||||
|
||||
/*****************************************************************************/
|
||||
typedef void (*VbFuncType)(void);
|
||||
|
||||
/*****************************************************************************/
|
||||
struct sVidScreen
|
||||
{
|
||||
DRAWENV Draw;
|
||||
DISPENV Disp;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
void VidInit();
|
||||
|
||||
void VidScrOn();
|
||||
void VidSetRes(int x, int y);
|
||||
void VidSetClearScreen(int );
|
||||
void VidSetClearColor( const CVECTOR & col );
|
||||
|
||||
int VidGetXOfs();
|
||||
int VidGetYOfs();
|
||||
void VidSetXYOfs(int x,int y);
|
||||
int VidGetScrW();
|
||||
int VidGetScrH();
|
||||
sVidScreen *VidGetScreen();
|
||||
sVidScreen *VidGetDispScreen();
|
||||
sVidScreen *VidGetDrawScreen();
|
||||
u32 VidGetFrameCount();
|
||||
u32 VidGetTickCount();
|
||||
|
||||
void VidSwapDraw();
|
||||
|
||||
void VidAddVSyncFunc(VbFuncType v);
|
||||
void VidRemoveVSyncFunc(VbFuncType v);
|
||||
|
||||
void VRamViewer();
|
||||
|
||||
void StartLoad(int _loadX=430,int _loadY=202);
|
||||
void StopLoad();
|
||||
|
||||
void SetScreenImage(u8 *Ptr);
|
||||
u8 *GetScreenImage();
|
||||
void ClearScreenImage();
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue