This commit is contained in:
parent
e9f123dec7
commit
74ac11a27f
40 changed files with 6829 additions and 0 deletions
38
source/PsxBoot/PSXBOOT.H
Normal file
38
source/PsxBoot/PSXBOOT.H
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*********************/
|
||||||
|
/*** PSX Bootstrap ***/
|
||||||
|
/*** Dave 190697 ***/
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
#ifndef PSXBootHeader
|
||||||
|
#define PSXBootHeader
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef unsigned char byte;
|
||||||
|
typedef unsigned int word;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// Screen position and dimensions.
|
||||||
|
#define FRAME_X 512
|
||||||
|
|
||||||
|
#ifdef __TERRITORY_USA__
|
||||||
|
#define FRAME_Y 240
|
||||||
|
#define SCREEN_X 0 //-24
|
||||||
|
#define SCREEN_Y -8
|
||||||
|
#else
|
||||||
|
#define FRAME_Y 256
|
||||||
|
#define SCREEN_X 0 //-8
|
||||||
|
#define SCREEN_Y 8
|
||||||
|
#endif // NTSC
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------------------------------*/
|
||||||
|
#define LoadBuffer 0x80010000 // psx boot
|
||||||
|
#define BinLoadAddr 0x80010000 // psx boot
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DRAWENV draw;
|
||||||
|
DISPENV disp;
|
||||||
|
} DB;
|
||||||
|
|
||||||
|
#endif
|
263
source/PsxBoot/psxboot.cpp
Normal file
263
source/PsxBoot/psxboot.cpp
Normal file
|
@ -0,0 +1,263 @@
|
||||||
|
#include <sys\types.h>
|
||||||
|
#include <libapi.h>
|
||||||
|
#include <libetc.h>
|
||||||
|
#include <libgte.h>
|
||||||
|
#include <libgpu.h>
|
||||||
|
#include <libcd.h>
|
||||||
|
#include <kernel.h>
|
||||||
|
#include <libspu.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <libsnd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "psxboot\PsxBoot.H"
|
||||||
|
#include "fileio\filetab.h"
|
||||||
|
#include "fileio\filetab.cpp"
|
||||||
|
|
||||||
|
#define PiracyFilename "\\PIRACY.GFX;1"
|
||||||
|
#define LegalFilename "\\LEGAL.GFX;1"
|
||||||
|
#define ScreenDelay 50*(5-2)
|
||||||
|
#define ExeFilename "\\PRLSR.BIN;1"
|
||||||
|
|
||||||
|
#define CHUNKSIZE 2048
|
||||||
|
|
||||||
|
#define PrgAddr 0x80010000
|
||||||
|
#define SCRATCH_RAM 0x1f800000
|
||||||
|
|
||||||
|
//#define DBGMsg printf
|
||||||
|
#define DBGMsg
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
DB *CurDBuf,DBuf[2];
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
static volatile int cdread_status=0;
|
||||||
|
static u_char current_cd_mode;
|
||||||
|
static int cd_speed=-1;//,buf_sec=-1;
|
||||||
|
static void cdread_callback(u_char intr, u_char *result)
|
||||||
|
{
|
||||||
|
if (intr==CdlComplete)
|
||||||
|
{
|
||||||
|
cdread_status=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (intr==CdlDiskError)
|
||||||
|
{
|
||||||
|
cdread_status=-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cdread_status=-2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
static void set_cd_speed(int speed)
|
||||||
|
{
|
||||||
|
if (speed!=cd_speed)
|
||||||
|
{
|
||||||
|
current_cd_mode=speed?CdlModeSpeed:0;
|
||||||
|
|
||||||
|
do { // Yuk!
|
||||||
|
while (CdControl(CdlSetmode,¤t_cd_mode,0)==0);
|
||||||
|
} while (CdSync(0,NULL)!=CdlComplete);
|
||||||
|
|
||||||
|
VSync(5);
|
||||||
|
|
||||||
|
cd_speed=speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
void LoadFile(char *Filename,char *Dst,long Length)
|
||||||
|
{
|
||||||
|
CdlFILE RetFile;
|
||||||
|
int Len;
|
||||||
|
|
||||||
|
DBGMsg("Load %s\n",Filename);
|
||||||
|
|
||||||
|
while ( !CdSearchFile(&RetFile,(char *)Filename) ) DBGMsg("Not Found\n");
|
||||||
|
|
||||||
|
if(!Length)
|
||||||
|
Len=(RetFile.size);
|
||||||
|
else
|
||||||
|
Len=Length;
|
||||||
|
|
||||||
|
unsigned char mode=CdlModeSpeed;
|
||||||
|
|
||||||
|
DBGMsg("Found\n");
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
set_cd_speed(1);
|
||||||
|
CdReadCallback(cdread_callback);
|
||||||
|
|
||||||
|
while ( (CdControlB(CdlSetloc,(u_char *)&RetFile.pos,NULL)==0) );
|
||||||
|
|
||||||
|
const unsigned long NumSectors=(unsigned long) (Len / CHUNKSIZE)+1;
|
||||||
|
|
||||||
|
cdread_status=1;
|
||||||
|
int OK=CdRead(NumSectors,(u_long *)Dst,current_cd_mode);
|
||||||
|
|
||||||
|
if (OK)
|
||||||
|
{
|
||||||
|
int C=0;
|
||||||
|
while(cdread_status>0)
|
||||||
|
{
|
||||||
|
C++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cdread_status==0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawSync(0);
|
||||||
|
|
||||||
|
CdReadCallback(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** System Stuff ************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void InitSys(void)
|
||||||
|
{
|
||||||
|
int Count;
|
||||||
|
ResetCallback();
|
||||||
|
ResetGraph(0);
|
||||||
|
SetGraphDebug(0);
|
||||||
|
while (!CdInit());
|
||||||
|
// InitGeom();
|
||||||
|
CdSetDebug(0);
|
||||||
|
// SpuInit();
|
||||||
|
SsInit();
|
||||||
|
|
||||||
|
#if defined(__TERRITORY_USA__)
|
||||||
|
SetVideoMode(MODE_NTSC);
|
||||||
|
#else
|
||||||
|
SetVideoMode(MODE_PAL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SetDefDrawEnv(&DBuf[0].draw, 0,0, FRAME_X, FRAME_Y);
|
||||||
|
SetDefDispEnv(&DBuf[0].disp, 0,0, FRAME_X, FRAME_Y);
|
||||||
|
SetDefDrawEnv(&DBuf[1].draw, 0,0, FRAME_X, FRAME_Y);
|
||||||
|
SetDefDispEnv(&DBuf[1].disp, 0,0, FRAME_X, FRAME_Y);
|
||||||
|
|
||||||
|
setRECT(&DBuf[0].disp.screen, SCREEN_X, SCREEN_Y, 0, FRAME_Y);
|
||||||
|
setRECT(&DBuf[1].disp.screen, SCREEN_X, SCREEN_Y, 0, FRAME_Y);
|
||||||
|
DBuf[0].disp.isrgb24=DBuf[1].disp.isrgb24=0;
|
||||||
|
DBuf[0].draw.isbg = DBuf[1].draw.isbg = 1;
|
||||||
|
CurDBuf=DBuf;
|
||||||
|
|
||||||
|
#if !defined(__TERRITORY_USA__)
|
||||||
|
DBuf[0].disp.screen.y=24;
|
||||||
|
DBuf[1].disp.screen.y=24;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Stop flicker!!
|
||||||
|
Count=2;
|
||||||
|
while(Count--)
|
||||||
|
{
|
||||||
|
PutDrawEnv(&CurDBuf->draw);
|
||||||
|
PutDispEnv(&CurDBuf->disp);
|
||||||
|
DrawSync(0);
|
||||||
|
}
|
||||||
|
DBuf[0].draw.isbg = DBuf[1].draw.isbg = 0;
|
||||||
|
|
||||||
|
SetDispMask(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void ShowScreen(char *Filename,int Delay,int FadeOutOnly)
|
||||||
|
{
|
||||||
|
u_long Count;
|
||||||
|
char Fade;
|
||||||
|
RECT PicRect;
|
||||||
|
POLY_FT4 fp,*Poly=&fp;
|
||||||
|
int *Ptr;
|
||||||
|
// Set up shade polys
|
||||||
|
// SetPolyFT4(Poly);
|
||||||
|
// setXYWH(Poly,0,0,SCR_WIDTH,SCR_HEIGHT);
|
||||||
|
// Poly->tpage=GetTPage(2,0,512,0);
|
||||||
|
|
||||||
|
// if (!FadeOutOnly)
|
||||||
|
{
|
||||||
|
setRECT(&PicRect,0,0,1024,512);
|
||||||
|
ClearImage(&PicRect,0,0,0);
|
||||||
|
|
||||||
|
|
||||||
|
// load Screen
|
||||||
|
LoadFile(Filename,(char*)LoadBuffer,FRAME_X * FRAME_Y*2);
|
||||||
|
setRECT(&PicRect,0,0,FRAME_X,FRAME_Y);
|
||||||
|
LoadImage(&PicRect,(u_long*)LoadBuffer);
|
||||||
|
|
||||||
|
// Fade in
|
||||||
|
Fade=0;
|
||||||
|
// while(Fade<128)
|
||||||
|
// {
|
||||||
|
// setRGB0(Poly,Fade,Fade,Fade);
|
||||||
|
// Fade+=2;
|
||||||
|
// DrawPrim(Poly);
|
||||||
|
// DrawSync(0);
|
||||||
|
// VSync(0);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Wait a while
|
||||||
|
// if (Delay<0) return;
|
||||||
|
// Count=Delay;
|
||||||
|
// while(Count--)
|
||||||
|
// {
|
||||||
|
// DrawSync(0);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
// Fade Out
|
||||||
|
|
||||||
|
// Fade=128;
|
||||||
|
// while(Fade>0)
|
||||||
|
// {
|
||||||
|
// setRGB0(&Poly[0],Fade,Fade,Fade);
|
||||||
|
// Fade-=2;
|
||||||
|
// DrawPrim(&Poly[0]);
|
||||||
|
// DrawPrim(&Poly[1]);
|
||||||
|
// DrawSync(0);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
DrawSync(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void (*Func)()=(void (*)())0x80010000;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
InitSys();
|
||||||
|
|
||||||
|
ShowScreen(LegalFilename,-1,0);
|
||||||
|
CalcFilePos((int*)SCRATCH_RAM);
|
||||||
|
int *Ptr=(int*)SCRATCH_RAM;
|
||||||
|
// for (int Loop=0;Loop<FILEPOS_MAX;Loop++) printf("%i\n",*Ptr++);
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int count = VSync( -1 );
|
||||||
|
|
||||||
|
LoadFile(ExeFilename,(char *)PrgAddr,0);
|
||||||
|
|
||||||
|
while ((VSync( -1 ) - count) < ScreenDelay);
|
||||||
|
|
||||||
|
RECT clearRect;
|
||||||
|
setRECT(&clearRect,0,0,1024,512);
|
||||||
|
// ClearImage(&clearRect,0,0,0);
|
||||||
|
// DrawSync(0);
|
||||||
|
// SetDispMask(0);
|
||||||
|
EnterCriticalSection();
|
||||||
|
FlushCache();
|
||||||
|
ExitCriticalSection();
|
||||||
|
StopCallback();
|
||||||
|
Func();
|
||||||
|
(((void(**)(void))PrgAddr)[0])();
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
51
source/game/game.cpp
Normal file
51
source/game/game.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/**********************/
|
||||||
|
/*** Main Game File ***/
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
#include "system\global.h"
|
||||||
|
#include "fileio\fileio.h"
|
||||||
|
#include "pad\pads.h"
|
||||||
|
#include "system\vid.h"
|
||||||
|
#include "gfx\prim.h"
|
||||||
|
#include "utils\utils.h"
|
||||||
|
#include "game\game.h"
|
||||||
|
#include "system\gstate.h"
|
||||||
|
#include "gfx\font.h"
|
||||||
|
#include "gfx\fdata.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
FontBank *CGameScene::s_genericFont;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
CGameScene GameScene;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// Note, do not load any data in this function
|
||||||
|
void CGameScene::Init()
|
||||||
|
{
|
||||||
|
s_genericFont=new ("CGameScene::Init") FontBank();
|
||||||
|
s_genericFont->initialise( &standardFont );
|
||||||
|
s_genericFont->setColour( 128, 80, 100 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void CGameScene::Shutdown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CGameScene::Render()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
bool CGameScene::Control()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
40
source/game/game.h
Normal file
40
source/game/game.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/**********************/
|
||||||
|
/*** Main Game File ***/
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
#ifndef __GAME_GAME_H__
|
||||||
|
#define __GAME_GAME_H__
|
||||||
|
|
||||||
|
#include "system\gstate.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
class FontBank;
|
||||||
|
|
||||||
|
class CGameScene : public CScene
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGameScene() {};
|
||||||
|
virtual ~CGameScene() {};
|
||||||
|
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void Shutdown();
|
||||||
|
void Render();
|
||||||
|
bool Control();
|
||||||
|
char *GetSceneName() {return "Game";}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static FontBank *s_genericFont;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern CGameScene GameScene;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#endif
|
104
source/gfx/fdata.cpp
Normal file
104
source/gfx/fdata.cpp
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
fdata.cpp
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: PRLSR
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "gfx\fdata.h"
|
||||||
|
|
||||||
|
#include "biglump.h"
|
||||||
|
|
||||||
|
#include <UiGfx.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Positional Vars
|
||||||
|
--------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
s16 standardFontTab[]=
|
||||||
|
{
|
||||||
|
-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ! " # $ % & ' */ -1,FRM_PR_FONTINGAME_0037,FRM_PR_FONTINGAME_0038,-1,FRM_PR_FONTINGAME_0052,FRM_PR_FONTINGAME_0039,FRM_PR_FONTINGAME_0040,FRM_PR_FONTINGAME_0036,
|
||||||
|
/* ( ) * + , - . / */ FRM_PR_FONTINGAME_0042,FRM_PR_FONTINGAME_0043,FRM_PR_FONTINGAME_0041,-1,FRM_PR_FONTINGAME_0047,FRM_PR_FONTINGAME_0044,FRM_PR_FONTINGAME_0053,FRM_PR_FONTINGAME_0050,
|
||||||
|
/* 0 1 2 3 4 5 6 7 */ FRM_PR_FONTINGAME_0026,FRM_PR_FONTINGAME_0027,FRM_PR_FONTINGAME_0028,FRM_PR_FONTINGAME_0029,FRM_PR_FONTINGAME_0030,FRM_PR_FONTINGAME_0031,FRM_PR_FONTINGAME_0032,FRM_PR_FONTINGAME_0033,
|
||||||
|
/* 8 9 : ; < = > ? */ FRM_PR_FONTINGAME_0034,FRM_PR_FONTINGAME_0035,FRM_PR_FONTINGAME_0045,FRM_PR_FONTINGAME_0046,FRM_PR_FONTINGAME_0149,-1,FRM_PR_FONTINGAME_0150,FRM_PR_FONTINGAME_0048,
|
||||||
|
/* @ A B C D E F G */ -1,FRM_PR_FONTINGAME_0000,FRM_PR_FONTINGAME_0001,FRM_PR_FONTINGAME_0002,FRM_PR_FONTINGAME_0003,FRM_PR_FONTINGAME_0004,FRM_PR_FONTINGAME_0005,FRM_PR_FONTINGAME_0006,
|
||||||
|
/* H I J K L M N O */ FRM_PR_FONTINGAME_0007,FRM_PR_FONTINGAME_0008,FRM_PR_FONTINGAME_0009,FRM_PR_FONTINGAME_0010,FRM_PR_FONTINGAME_0011,FRM_PR_FONTINGAME_0012,FRM_PR_FONTINGAME_0013,FRM_PR_FONTINGAME_0014,
|
||||||
|
/* P Q R S T U V W */ FRM_PR_FONTINGAME_0015,FRM_PR_FONTINGAME_0016,FRM_PR_FONTINGAME_0017,FRM_PR_FONTINGAME_0018,FRM_PR_FONTINGAME_0019,FRM_PR_FONTINGAME_0020,FRM_PR_FONTINGAME_0021,FRM_PR_FONTINGAME_0022,
|
||||||
|
/* X Y Z [ \ ] ^ _ */ FRM_PR_FONTINGAME_0023,FRM_PR_FONTINGAME_0024,FRM_PR_FONTINGAME_0025,FRM_PR_FONTINGAME_0054,FRM_PR_FONTINGAME_0049,FRM_PR_FONTINGAME_0055,-1,FRM_PR_FONTINGAME_0151,
|
||||||
|
/* ` a b c d e f g */ -1,FRM_PR_FONTINGAME_0056,FRM_PR_FONTINGAME_0057,FRM_PR_FONTINGAME_0058,FRM_PR_FONTINGAME_0059,FRM_PR_FONTINGAME_0060,FRM_PR_FONTINGAME_0061,FRM_PR_FONTINGAME_0062,
|
||||||
|
/* h i j k l m n o */ FRM_PR_FONTINGAME_0063,FRM_PR_FONTINGAME_0064,FRM_PR_FONTINGAME_0065,FRM_PR_FONTINGAME_0066,FRM_PR_FONTINGAME_0067,FRM_PR_FONTINGAME_0068,FRM_PR_FONTINGAME_0069,FRM_PR_FONTINGAME_0070,
|
||||||
|
/* p q r s t u v w */ FRM_PR_FONTINGAME_0071,FRM_PR_FONTINGAME_0072,FRM_PR_FONTINGAME_0073,FRM_PR_FONTINGAME_0074,FRM_PR_FONTINGAME_0075,FRM_PR_FONTINGAME_0076,FRM_PR_FONTINGAME_0077,FRM_PR_FONTINGAME_0078,
|
||||||
|
/* x y z { | } ~ . */ FRM_PR_FONTINGAME_0079,FRM_PR_FONTINGAME_0080,FRM_PR_FONTINGAME_0081,-1,-1,-1,-1,-1,
|
||||||
|
/* € <20> ‚ ƒ „ … † ‡ */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ˆ ‰ Š ‹ Œ <20> Ž <20> */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* <20> ‘ ’ “ ” • – — */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ˜ ™ š › œ <20> ž Ÿ */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ¡ ¢ £ ¤ ¥ ¦ § */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ¨ © ª « ¬ ® ¯ */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ° ± ² ³ ´ µ ¶ · */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ¸ ¹ º » ¼ ½ ¾ ¿ */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* À Á Â Ã Ä Å Æ Ç */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* È É Ê Ë Ì Í Î Ï */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* Ð Ñ Ò Ó Ô Õ Ö × */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* Ø Ù Ú Û Ü Ý Þ ß */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* à á â ã ä å æ ç */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* è é ê ë ì í î ï */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ð ñ ò ó ô õ ö ÷ */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
/* ø ù ú û ü ý þ ÿ */ -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
};
|
||||||
|
FontData standardFont( UI_UIGFX_SPR, standardFontTab, 9, 1,1, 4 );
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
FontData::FontData( FileEquate _fontFileId, s16 *_fontTab, s16 _charHeight, s16 _charGapX, s16 _charGapY, s16 _spaceWidth )
|
||||||
|
{
|
||||||
|
fontFileId=_fontFileId;
|
||||||
|
fontTab=_fontTab;
|
||||||
|
charHeight=_charHeight;
|
||||||
|
charGapX=_charGapX;
|
||||||
|
charGapY=_charGapY;
|
||||||
|
spaceWidth=_spaceWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
71
source/gfx/fdata.h
Normal file
71
source/gfx/fdata.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
fdata.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: PRLSR
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __GFX_FDATA_H__
|
||||||
|
#define __GFX_FDATA_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "system\global.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <biglump.h>
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class FontData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FontData( FileEquate _fontFileId, s16 *_fontTab, s16 _charHeight, s16 _charGapX, s16 _charGapY, s16 _spaceWidth );
|
||||||
|
|
||||||
|
FileEquate fontFileId;
|
||||||
|
s16 *fontTab;
|
||||||
|
s16 charHeight;
|
||||||
|
s16 charGapX;
|
||||||
|
s16 charGapY;
|
||||||
|
s16 spaceWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
// Available fonts
|
||||||
|
extern FontData standardFont;
|
||||||
|
|
||||||
|
/* Data
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/* Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __GFX_FDATA_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
367
source/gfx/font.cpp
Normal file
367
source/gfx/font.cpp
Normal file
|
@ -0,0 +1,367 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
font.cpp
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project:
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef __GFX_FONT_H__
|
||||||
|
#include "font.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system\vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PRIM_HEADER__
|
||||||
|
#include "gfx\prim.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MATHTABLE_HEADER__
|
||||||
|
#include "utils\mathtab.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __LOCALE_TEXTDBASE_H__
|
||||||
|
#include "locale\textdbase.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Local
|
||||||
|
----- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Data
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::initialise( FontData *_fontData )
|
||||||
|
{
|
||||||
|
ASSERT( !m_initialised );
|
||||||
|
|
||||||
|
m_fontData=_fontData;
|
||||||
|
|
||||||
|
m_spriteBank.load( m_fontData->fontFileId );
|
||||||
|
|
||||||
|
setOt( DEFAULT_OT );
|
||||||
|
setColour( DEFAULT_R, DEFAULT_G, DEFAULT_B );
|
||||||
|
setJustification( (Justification)DEFAULT_JUSTIFICATION );
|
||||||
|
setPrintArea( 0,0, VidGetScrW(),VidGetScrH() );
|
||||||
|
|
||||||
|
setTrans( 0 );
|
||||||
|
setSMode( 0 );
|
||||||
|
|
||||||
|
m_initialised=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::dump()
|
||||||
|
{
|
||||||
|
m_spriteBank.dump();
|
||||||
|
|
||||||
|
m_initialised=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::print( int _x, int _y, s32 _textId )
|
||||||
|
{
|
||||||
|
print(_x,_y,(u8*)TranslationDatabase::getString(_textId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::print( int _x, int _y, u8 *_text )
|
||||||
|
{
|
||||||
|
ASSERT( m_initialised );
|
||||||
|
|
||||||
|
int Size;
|
||||||
|
int StartX;
|
||||||
|
int Length=0;
|
||||||
|
int RectWidth;
|
||||||
|
|
||||||
|
switch(m_justification)
|
||||||
|
{
|
||||||
|
case JUST_CENTRE:
|
||||||
|
RectWidth=m_printArea.w;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RectWidth=m_printArea.w-_x;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_x+=m_printArea.x;
|
||||||
|
_y+=m_printArea.y;
|
||||||
|
_y+=m_fontData->charHeight; // origin at top left please...
|
||||||
|
StartX=_x;
|
||||||
|
|
||||||
|
while (*_text)
|
||||||
|
{
|
||||||
|
Length=getStrWrapLen(_text,RectWidth);
|
||||||
|
switch (m_justification)
|
||||||
|
{
|
||||||
|
case JUST_LEFT:
|
||||||
|
_x=StartX;
|
||||||
|
break;
|
||||||
|
case JUST_RIGHT:
|
||||||
|
_x=StartX/*+RectWidth*/-Length;
|
||||||
|
break;
|
||||||
|
case JUST_CENTRE:
|
||||||
|
_x=StartX-(Length/2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*_text && Length>0)
|
||||||
|
{
|
||||||
|
Size=printChar(*_text++,_x,_y)+m_fontData->charGapX;
|
||||||
|
_x+=Size;
|
||||||
|
Length-=Size;
|
||||||
|
}
|
||||||
|
_y+=(m_fontData->charHeight+m_fontData->charGapY);
|
||||||
|
if(*_text=='\n') _text++; // kill newline if there is one ( preserve multiple \n )
|
||||||
|
while (*_text==' ') _text++; // kill trailing spaces
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::setColour( u8 _r, u8 _g, u8 _b )
|
||||||
|
{
|
||||||
|
m_r = _r;
|
||||||
|
m_g = _g;
|
||||||
|
m_b = _b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::setJustification( Justification _justification )
|
||||||
|
{
|
||||||
|
m_justification = _justification;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::setOt( u16 _ot )
|
||||||
|
{
|
||||||
|
m_ot = _ot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::setPrintArea( int _x, int _y, int _w, int _h )
|
||||||
|
{
|
||||||
|
m_printArea.x=_x;
|
||||||
|
m_printArea.y=_y;
|
||||||
|
m_printArea.w=_w;
|
||||||
|
m_printArea.h=_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void FontBank::setTrans( int _trans )
|
||||||
|
{
|
||||||
|
m_trans=_trans;
|
||||||
|
}
|
||||||
|
void FontBank::setSMode( int _sMode )
|
||||||
|
{
|
||||||
|
m_sMode=_sMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int FontBank::getCharWidth( u8 _char )
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if( _char!=' ' )
|
||||||
|
{
|
||||||
|
if( m_fontData->fontTab[_char]==-1 ) _char='X';
|
||||||
|
size=m_spriteBank.getFrameWidth( m_fontData->fontTab[_char] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size=m_fontData->spaceWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int FontBank::getCharHeight()
|
||||||
|
{
|
||||||
|
return m_fontData->charHeight+m_fontData->charGapY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose: return height of a string when wrapped to print area
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int FontBank::getStringHeight( u8 *_text )
|
||||||
|
{
|
||||||
|
int length=0;
|
||||||
|
int height=0;
|
||||||
|
|
||||||
|
while (*_text)
|
||||||
|
{
|
||||||
|
length=getStrWrapLen(_text,m_printArea.w);
|
||||||
|
while(*_text && length>0)
|
||||||
|
{
|
||||||
|
length-=getCharWidth(*_text++)+m_fontData->charGapX;
|
||||||
|
}
|
||||||
|
height+=(m_fontData->charHeight+m_fontData->charGapY);
|
||||||
|
if(*_text=='\n') _text++; // kill newline if there is one ( preserve multiple \n )
|
||||||
|
while (*_text==' ') _text++; // kill trailing spaces
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int FontBank::printChar( u8 _char,int _x,int _y )
|
||||||
|
{
|
||||||
|
if (_char!=' ')
|
||||||
|
{
|
||||||
|
if( m_fontData->fontTab[_char]==-1 ) _char='X';
|
||||||
|
POLY_FT4 *Ft4=m_spriteBank.printFT4(m_fontData->fontTab[_char],_x,_y,0,0,m_ot);
|
||||||
|
setRGB0(Ft4,m_r,m_g,m_b);
|
||||||
|
setShadeTex(Ft4,0);
|
||||||
|
|
||||||
|
Ft4->tpage |= ( m_sMode << 5 );
|
||||||
|
setSemiTrans( Ft4,m_trans );
|
||||||
|
setShadeTex( Ft4,0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return getCharWidth(_char);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int FontBank::getStringWidth( char * text )
|
||||||
|
{
|
||||||
|
return getStrWrapLen( (u8 *)text, VidGetScrW() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int FontBank::getStrWrapLen( u8 *_text,int _maxWidth )
|
||||||
|
{
|
||||||
|
int length=0,spaceW;
|
||||||
|
u8 C;
|
||||||
|
|
||||||
|
spaceW=length+1; // +1 to prevent infinite loop
|
||||||
|
while (*_text && length<=_maxWidth)
|
||||||
|
{
|
||||||
|
C=*_text++;
|
||||||
|
if (C=='\n') break;
|
||||||
|
if (C==' ') spaceW=length;
|
||||||
|
length+=getCharWidth(C)+m_fontData->charGapX;
|
||||||
|
}
|
||||||
|
if (length>_maxWidth) length=spaceW;
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
101
source/gfx/font.h
Normal file
101
source/gfx/font.h
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
font.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project:
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __GFX_FONT_H__
|
||||||
|
#define __GFX_FONT_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef __GFX_FDATA_H__
|
||||||
|
#include "gfx\fdata.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GFX_SPRBANK_H__
|
||||||
|
#include "gfx\sprbank.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class FontBank
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Justification
|
||||||
|
{
|
||||||
|
JUST_LEFT,
|
||||||
|
JUST_RIGHT,
|
||||||
|
JUST_CENTRE
|
||||||
|
};
|
||||||
|
|
||||||
|
FontBank() { m_initialised=false; };
|
||||||
|
virtual ~FontBank() { ASSERT( !m_initialised ); }
|
||||||
|
|
||||||
|
virtual void initialise( FontData *_fontData );
|
||||||
|
void dump();
|
||||||
|
int isInitialised() { return m_initialised; }
|
||||||
|
virtual void print( int _x, int _y, u8 *_text );
|
||||||
|
void print( int _x, int _y, s32 _textId );
|
||||||
|
void setColour( u8 _r, u8 _g, u8 _b );
|
||||||
|
void setJustification( Justification _justification );
|
||||||
|
void setOt( u16 _ot );
|
||||||
|
void setPrintArea( int _x, int _y, int _w, int _h );
|
||||||
|
void setTrans( int _trans );
|
||||||
|
void setSMode( int _sMode );
|
||||||
|
|
||||||
|
int getCharWidth( u8 _char );
|
||||||
|
int getCharHeight();
|
||||||
|
int getStringWidth( char * text );
|
||||||
|
int getStringHeight( u8 *_text );
|
||||||
|
|
||||||
|
int getStrWrapLen( u8 *_text,int _maxWidth );
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual int printChar( u8 _char,int _x,int _y );
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DEFAULT_R=128,
|
||||||
|
DEFAULT_G=128,
|
||||||
|
DEFAULT_B=128,
|
||||||
|
DEFAULT_JUSTIFICATION=JUST_LEFT,
|
||||||
|
DEFAULT_OT=1,
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FontData *m_fontData;
|
||||||
|
u8 m_r, m_g, m_b; // Font colour
|
||||||
|
Justification m_justification;
|
||||||
|
u16 m_ot; // Depth
|
||||||
|
RECT m_printArea;
|
||||||
|
SpriteBank m_spriteBank;
|
||||||
|
int m_initialised;
|
||||||
|
|
||||||
|
int m_trans, m_sMode;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __GFX_FONT_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
159
source/gfx/prim.cpp
Normal file
159
source/gfx/prim.cpp
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
///**********************/
|
||||||
|
/*** Psx Prim Stuff ***/
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
#include "system\global.h"
|
||||||
|
#include "gfx\TPage.h"
|
||||||
|
#include "gfx\AnimTex.h"
|
||||||
|
#include "gfx\Prim.h"
|
||||||
|
#include "system\vid.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
sOT *OtList[2],*OtPtr;
|
||||||
|
u32 DmaStart[2];
|
||||||
|
u8 *PrimBuffer[2],*PrimListStart,*PrimListEnd;
|
||||||
|
u8 *CurrPrim,*EndPrim;
|
||||||
|
int PrimFlipFlag;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void PrimInit()
|
||||||
|
{
|
||||||
|
// Alloc Lists
|
||||||
|
OtList[0]=(sOT*)MemAlloc(MAX_OT*2*sizeof(sOT), "-Ot-");
|
||||||
|
OtList[1]=OtList[0]+MAX_OT;
|
||||||
|
PrimBuffer[0]=(u8*)MemAlloc(PRIMPOOL_SIZE*2, "Prim");
|
||||||
|
PrimBuffer[1]=PrimBuffer[0]+(PRIMPOOL_SIZE);
|
||||||
|
|
||||||
|
PrimFlipFlag=0;
|
||||||
|
OtPtr=(sOT*)OtList[PrimFlipFlag];
|
||||||
|
CurrPrim=(u8*)PrimBuffer[PrimFlipFlag];
|
||||||
|
EndPrim=CurrPrim+(PRIMPOOL_SIZE);
|
||||||
|
|
||||||
|
PrimListStart=PrimBuffer[0];
|
||||||
|
PrimListEnd=PrimListStart+(PRIMPOOL_SIZE*2);
|
||||||
|
|
||||||
|
InitOTagR(OtList[0],MAX_OT);
|
||||||
|
InitOTagR(OtList[1],MAX_OT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void PrimDisplay()
|
||||||
|
{
|
||||||
|
CAnimTex::AnimateTex();
|
||||||
|
UnlinkOTagR(OtPtr, MAX_OT, &DmaStart[PrimFlipFlag]);
|
||||||
|
|
||||||
|
#ifdef USE_NTAGS
|
||||||
|
DrawOTag((u32*)&DmaStart[PrimFlipFlag]);
|
||||||
|
#else
|
||||||
|
DrawOTag(OtPtr+(MAX_OT-1));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PrimFlipFlag^=1;
|
||||||
|
OtPtr=(sOT*)OtList[PrimFlipFlag];
|
||||||
|
CurrPrim=(u8*)PrimBuffer[PrimFlipFlag];
|
||||||
|
EndPrim=CurrPrim+(PRIMPOOL_SIZE);
|
||||||
|
|
||||||
|
ResetOTagR(OtPtr,MAX_OT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*** Clipping ****************************************************************/
|
||||||
|
extern int FrameFlipFlag;
|
||||||
|
void PrimClip(RECT *R, u32 Depth)
|
||||||
|
{
|
||||||
|
DR_AREA *CPtr=(DR_AREA*)CurrPrim;
|
||||||
|
RECT Real;
|
||||||
|
sVidScreen *Scr=VidGetDrawScreen();
|
||||||
|
|
||||||
|
Real=*R;
|
||||||
|
CurrPrim+=sizeof(DR_AREA);
|
||||||
|
Real.x+=Scr->Draw.clip.x;
|
||||||
|
Real.y+=Scr->Draw.clip.y;
|
||||||
|
|
||||||
|
int xLimit=512;
|
||||||
|
int yLimit=((FrameFlipFlag^1)+1)*256;
|
||||||
|
if(Real.x+Real.w>xLimit)Real.w=xLimit-Real.x;
|
||||||
|
if(Real.y+Real.h>yLimit)Real.h=yLimit-Real.y;
|
||||||
|
|
||||||
|
SetDrawArea(CPtr,&Real);
|
||||||
|
AddPrimToList(CPtr,Depth);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void PrimFullScreen(int Depth)
|
||||||
|
{
|
||||||
|
RECT FullScreenRect={0,0,VidGetScrW(),VidGetScrH()};
|
||||||
|
PrimClip(&FullScreenRect,Depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** NTag Functions **********************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
#ifdef USE_NTAGS
|
||||||
|
void ClearNTag(sOT *Ptr, long Count)
|
||||||
|
{
|
||||||
|
for (; Count; Ptr++,Count--) Ptr->FirstPrim = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void UnlinkNTag(sOT *Ptr, long Count, u32 *StartOt)
|
||||||
|
{
|
||||||
|
u32 *Tag;
|
||||||
|
for (; Count; Ptr++,Count--)
|
||||||
|
{
|
||||||
|
if ((Tag = Ptr->FirstPrim) == NULL) continue;
|
||||||
|
setaddr(StartOt, Tag);
|
||||||
|
StartOt = Ptr->LastPrim;
|
||||||
|
Ptr->FirstPrim = NULL; // Reset while Im at it!
|
||||||
|
}
|
||||||
|
termPrim(StartOt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void UnlinkNTagR(sOT *Ptr, long Count, u32 *StartOt)
|
||||||
|
{
|
||||||
|
u32 *Tag;
|
||||||
|
Ptr+=Count-1;
|
||||||
|
for (; Count; Ptr--,Count--)
|
||||||
|
{
|
||||||
|
if ((Tag = Ptr->FirstPrim) == NULL) continue;
|
||||||
|
setaddr(StartOt, Tag);
|
||||||
|
StartOt = Ptr->LastPrim;
|
||||||
|
Ptr->FirstPrim = NULL; // Reset while Im at it!
|
||||||
|
}
|
||||||
|
termPrim(StartOt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
LINE_F2 *DrawLine(int _x0,int _y0,int _x1,int _y1,int _r,int _g,int _b,int _ot)
|
||||||
|
{
|
||||||
|
LINE_F2 *lf2=GetPrimLF2();
|
||||||
|
lf2->x0=_x0;
|
||||||
|
lf2->y0=_y0;
|
||||||
|
lf2->x1=_x1;
|
||||||
|
lf2->y1=_y1;
|
||||||
|
setRGB0(lf2,_r,_g,_b);
|
||||||
|
AddPrimToList(lf2,_ot);
|
||||||
|
return lf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
LINE_G2 *DrawGLine(int _x0,int _y0,int _x1,int _y1,int _r1,int _g1,int _b1,int _r2,int _g2,int _b2,int _ot)
|
||||||
|
{
|
||||||
|
LINE_G2 *lg2=GetPrimLG2();
|
||||||
|
lg2->x0=_x0;
|
||||||
|
lg2->y0=_y0;
|
||||||
|
lg2->x1=_x1;
|
||||||
|
lg2->y1=_y1;
|
||||||
|
setRGB0(lg2,_r1,_g1,_b1);
|
||||||
|
setRGB1(lg2,_r2,_g2,_b2);
|
||||||
|
AddPrimToList(lg2,_ot);
|
||||||
|
return lg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
256
source/gfx/prim.h
Normal file
256
source/gfx/prim.h
Normal file
|
@ -0,0 +1,256 @@
|
||||||
|
/******************/
|
||||||
|
/*** Prim Stuff ***/
|
||||||
|
/******************/
|
||||||
|
|
||||||
|
#ifndef __PRIM_HEADER__
|
||||||
|
#define __PRIM_HEADER__
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "system\global.h"
|
||||||
|
#endif
|
||||||
|
#include "gfx\gpugte.h"
|
||||||
|
#include "gfx\tpage.h"
|
||||||
|
|
||||||
|
#define MAX_OT (2048)
|
||||||
|
#define MAX_PRIMS (2048+512)
|
||||||
|
|
||||||
|
#define USE_NTAGS 1
|
||||||
|
|
||||||
|
/*** Fast Replacements *********************************************************************************/
|
||||||
|
#undef setaddr
|
||||||
|
#undef getaddr
|
||||||
|
#define set3(r0,r1) ({ __asm__ ( "swl %1, 2( %0 )" : : "r"( r0 ), "r"( r1 ) : "memory" ); })
|
||||||
|
#define get3(r0) ({ unsigned long t; __asm__ ( "lwl %0, 2( %1 )" : "=r"(t) : "r"( r0) : "memory" ); t; })
|
||||||
|
#define setaddr(_p0,_p1) set3((_p0), ((u32) (_p1)) << 8)
|
||||||
|
#define getaddr(_p) (get3(_p) >> 8)
|
||||||
|
|
||||||
|
#undef catPrim
|
||||||
|
#define CatPrim catPrim
|
||||||
|
#define catPrim( r0, r1 ) __asm__ volatile ( \
|
||||||
|
"sll $12, %1, 8;" \
|
||||||
|
"swl $12, 2( %0 )" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ), "r"( r1 ) \
|
||||||
|
: "$12", "memory" )
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_NTAGS
|
||||||
|
/*** NTag Stuff **************************************************************************************/
|
||||||
|
struct sOT
|
||||||
|
{
|
||||||
|
u32 *FirstPrim,*LastPrim;
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef addPrim
|
||||||
|
#define AddPrim addPrim
|
||||||
|
#define addPrim(OT,Prim) \
|
||||||
|
{ \
|
||||||
|
if ((OT)->FirstPrim) \
|
||||||
|
setaddr(((u32*)Prim), (OT)->FirstPrim); \
|
||||||
|
else \
|
||||||
|
(OT)->LastPrim = (u32*)(Prim); \
|
||||||
|
(OT)->FirstPrim = (u32*)(Prim); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NTAG_addPrims(_nt,_ps,_pe) \
|
||||||
|
{ \
|
||||||
|
if ((_nt)->FirstPrim) \
|
||||||
|
setaddr((_pe), (_nt)->FirstPrim); \
|
||||||
|
else \
|
||||||
|
(_nt)->LastPrim = (_pe); \
|
||||||
|
(_nt)->FirstPrim = (_ps); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ClearNTag(sOT *Ptr, long Count);
|
||||||
|
void UnlinkNTag(sOT *Ptr, long Count, u32 *FirstNT);
|
||||||
|
void UnlinkNTagR(sOT *Ptr, long Count, u32 *FirstNT);
|
||||||
|
|
||||||
|
inline void UnlinkNTagtoNTag(sOT *to, sOT *from, long count)
|
||||||
|
{
|
||||||
|
sOT *ptr = from;
|
||||||
|
for (; count; ptr++,count--) // for all NTAGs...
|
||||||
|
{
|
||||||
|
u_long *tag = ptr->FirstPrim;
|
||||||
|
|
||||||
|
if (tag == NULL) // if it's blank...
|
||||||
|
continue; // ...skip past it...
|
||||||
|
|
||||||
|
NTAG_addPrims(to, ptr->FirstPrim, ptr->LastPrim);
|
||||||
|
|
||||||
|
ptr->FirstPrim = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define InitOTag(Ot, Count) ClearNTag(Ot,Count);
|
||||||
|
#define InitOTagR(Ot, Count) ClearNTag(Ot,Count);
|
||||||
|
#define ResetOTag(Ot, Count) ;
|
||||||
|
#define ResetOTagR(Ot, Count) ;
|
||||||
|
#define UnlinkOTag(Ot, Count, Dma) UnlinkNTag(Ot, Count, Dma);
|
||||||
|
#define UnlinkOTagR(Ot, Count, Dma) UnlinkNTagR(Ot, Count, Dma);
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
/*** OTag Stuff **************************************************************************************/
|
||||||
|
typedef u32 sOT;
|
||||||
|
|
||||||
|
#undef addPrim
|
||||||
|
#define AddPrim addPrim
|
||||||
|
#define addPrim( r0, r1 ) __asm__ ( \
|
||||||
|
"lwl $12, 2( %0 );" \
|
||||||
|
"sll $13, %1, 8;" \
|
||||||
|
"swl $13, 2( %0 );" \
|
||||||
|
"swl $12, 2( %1 )" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ), "r"( r1 ) \
|
||||||
|
: "$12", "$13", "memory" )
|
||||||
|
|
||||||
|
#undef addPrims
|
||||||
|
#define AddPrims addPrims
|
||||||
|
#define addPrims( r0, r1, r2 ) __asm__ ( \
|
||||||
|
"lwl $12, 2( %0 );" \
|
||||||
|
"sll $13, %1, 8;" \
|
||||||
|
"swl $13, 2( %0 );" \
|
||||||
|
"swl $12, 2( %2 )" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ), "r"( r1 ), "r"( r2 ) \
|
||||||
|
: "$12", "$13", "memory" )
|
||||||
|
|
||||||
|
#define InitOTag(Ot, Count) ClearOTag(Ot,Count);
|
||||||
|
#define InitOTagR(Ot, Count) ClearOTagR(Ot,Count);
|
||||||
|
#define ResetOTag(Ot, Count) InitOTag(Ot,Count);
|
||||||
|
#define ResetOTagR(Ot, Count) InitOTagR(Ot,Count);
|
||||||
|
#define UnlinkOTag(OtPtr, MAX_OT, Dma) ;
|
||||||
|
#define UnlinkOTagR(OtPtr, MAX_OT, Dma) ;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/*** Main Prim Stuff **********************************************************************************/
|
||||||
|
#define GetPrim(Ptype) GetPrimSpace(Ptype,CurrPrim);
|
||||||
|
|
||||||
|
#define GetPrimF3() GetPrim(POLY_F3);\
|
||||||
|
setPolyF3(CurrPrim-sizeof(POLY_F3))
|
||||||
|
|
||||||
|
#define GetPrimF4() GetPrim(POLY_F4);\
|
||||||
|
setPolyF4(CurrPrim-sizeof(POLY_F4))
|
||||||
|
|
||||||
|
#define GetPrimFT3() GetPrim(POLY_FT3);\
|
||||||
|
setPolyFT3(CurrPrim-sizeof(POLY_FT3))
|
||||||
|
|
||||||
|
#define GetPrimFT4() GetPrim(POLY_FT4);\
|
||||||
|
setPolyFT4(CurrPrim-sizeof(POLY_FT4))
|
||||||
|
|
||||||
|
#define GetPrimG3() GetPrim(POLY_G3);\
|
||||||
|
setPolyG3(CurrPrim-sizeof(POLY_G3))
|
||||||
|
|
||||||
|
#define GetPrimG4() GetPrim(POLY_G4);\
|
||||||
|
setPolyG4(CurrPrim-sizeof(POLY_G4))
|
||||||
|
|
||||||
|
#define GetPrimGT3() GetPrim(POLY_GT3);\
|
||||||
|
setPolyGT3(CurrPrim-sizeof(POLY_GT3))
|
||||||
|
|
||||||
|
#define GetPrimGT4() GetPrim(POLY_GT4);\
|
||||||
|
setPolyGT4(CurrPrim-sizeof(POLY_GT4))
|
||||||
|
|
||||||
|
#define GetPrimLF2() GetPrim(LINE_F2); \
|
||||||
|
setLineF2(CurrPrim-sizeof(LINE_F2))
|
||||||
|
|
||||||
|
#define GetPrimLF3() GetPrim(LINE_F3);\
|
||||||
|
setLineF3(CurrPrim-sizeof(LINE_F3))
|
||||||
|
|
||||||
|
#define GetPrimLF4() GetPrim(LINE_F4);\
|
||||||
|
setLineF4((LINE_F4*)CurrPrim-1)
|
||||||
|
|
||||||
|
#define GetPrimLG2() GetPrim(LINE_G2);\
|
||||||
|
setLineG2(CurrPrim-sizeof(LINE_G2))
|
||||||
|
|
||||||
|
#define GetPrimLG3() GetPrim(LINE_G3);\
|
||||||
|
setLineG3(CurrPrim-sizeof(LINE_G3))
|
||||||
|
|
||||||
|
#define GetPrimLG4() GetPrim(LINE_G4);\
|
||||||
|
setLineG4(CurrPrim-sizeof(LINE_G4))
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
#define OtInRange (MAX_OT-1)
|
||||||
|
#define OtOutRange (0xffffffff-OtInRange)
|
||||||
|
#define OTCheck(x) (x&OtOutRange)
|
||||||
|
#define IsInOTRange(x) (!OTCheck(x))
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
#define MAX_PRIM_SIZE (sizeof(POLY_FT4))
|
||||||
|
#define PRIMPOOL_SIZE (MAX_PRIMS*MAX_PRIM_SIZE)
|
||||||
|
#define OTLIST_SIZE (MAX_OT*sizeof(sOT))
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
extern sOT *OtPtr;
|
||||||
|
extern u8 *CurrPrim,*EndPrim;
|
||||||
|
extern u8 *PrimListStart,*PrimListEnd;
|
||||||
|
extern int PrimFlipFlag;
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
const u32 PrimSXY_ClipCode = (256 << 16) | 512;
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
void PrimInit();
|
||||||
|
|
||||||
|
void PrimDisplay();
|
||||||
|
void PrimClip(RECT *r, u32 Depth);
|
||||||
|
void PrimFullScreen(int Depth);
|
||||||
|
inline u8 *GetPrimPtr() {return(CurrPrim);}
|
||||||
|
inline void SetPrimPtr(u8 *Ptr) {CurrPrim=Ptr;}
|
||||||
|
|
||||||
|
void SetPrimCheck();
|
||||||
|
|
||||||
|
LINE_F2 *DrawLine(int _x0,int _y0,int _x1,int _y1,int _r,int _g,int _b,int _ot);
|
||||||
|
LINE_G2 *DrawGLine(int _x0,int _y0,int _x1,int _y1,int _r1,int _g1,int _b1,int _r2,int _g2,int _b2,int _ot);
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
/*** Inlines ********************************************************************************************/
|
||||||
|
/********************************************************************************************************/
|
||||||
|
inline void AddPrimToList(void *Prim,u32 Depth)
|
||||||
|
{
|
||||||
|
ASSERT(Depth<MAX_OT);
|
||||||
|
addPrim(OtPtr+Depth,(u32*)Prim);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------------------------*/
|
||||||
|
inline void GetFrameUV(sFrameHdr *Fr, u8 *U,u8 *V)
|
||||||
|
{
|
||||||
|
*U=Fr->U;
|
||||||
|
*V=Fr->V;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------------------------*/
|
||||||
|
inline void GetFrameUVWH(sFrameHdr *Fr,u8 *U,u8 *V,u8 *W,u8 *H)
|
||||||
|
{
|
||||||
|
*U=Fr->U;
|
||||||
|
*V=Fr->V;
|
||||||
|
*W=Fr->W;
|
||||||
|
*H=Fr->H;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------------------------*/
|
||||||
|
inline void GetFrameWH(sFrameHdr *Fr,u8 *W,u8 *H)
|
||||||
|
{
|
||||||
|
*W=Fr->W;
|
||||||
|
*H=Fr->H;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------------------------*/
|
||||||
|
inline int GetFrameClut(sFrameHdr *Fr)
|
||||||
|
{
|
||||||
|
return(Fr->Clut);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------------------------*/
|
||||||
|
inline int GetFrameTPage(sFrameHdr *Fr)
|
||||||
|
{
|
||||||
|
return(Fr->TPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
415
source/gfx/sprbank.cpp
Normal file
415
source/gfx/sprbank.cpp
Normal file
|
@ -0,0 +1,415 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
sprbank.cpp
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: PRLSR
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef __GFX_SPRBANK_H__
|
||||||
|
#include "gfx\sprbank.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _FILEIO_HEADER_
|
||||||
|
#include "FileIO/FileIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MEMORY_HEADER__
|
||||||
|
#include "Mem\Memory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PRIM_HEADER__
|
||||||
|
#include "gfx\prim.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Positional Vars
|
||||||
|
--------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
// Linked list of loaded instances
|
||||||
|
static SpriteBankInstance *s_bankList = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
//#define SPRITE_BANK_DEBUG
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
SpriteBankInstance::SpriteBankInstance( SpriteBankInstance *_next )
|
||||||
|
{
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf("SpriteBankInstance()\n");
|
||||||
|
#endif
|
||||||
|
m_frameHdr=NULL;
|
||||||
|
m_file=FileEquate( -1 );
|
||||||
|
m_refCount=0;
|
||||||
|
m_next=_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
SpriteBankInstance::~SpriteBankInstance()
|
||||||
|
{
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf("~SpriteBankInstance() file=%d\n",m_file);
|
||||||
|
#endif
|
||||||
|
ASSERT( !m_frameHdr );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int loadcount=0;
|
||||||
|
void SpriteBankInstance::load( FileEquate _file )
|
||||||
|
{
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf("SpriteBankInstance::load() file=%d\n",_file);
|
||||||
|
#endif
|
||||||
|
if( m_refCount )
|
||||||
|
{
|
||||||
|
ASSERT( _file == m_file );
|
||||||
|
m_refCount++;
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf(" loaded reference" );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_tpageDesc=TPLoadTexWithHeaders(_file,&m_frameHdr);
|
||||||
|
|
||||||
|
m_file=_file;
|
||||||
|
m_refCount=1;
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf(" loaded physical %d",m_file );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf(" - refcount=%d\n",m_refCount);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
loadcount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns: true if there are no more references to this bank
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int SpriteBankInstance::dump()
|
||||||
|
{
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf("SpriteBankInstance::dump() file=%d\n",m_file);
|
||||||
|
#endif
|
||||||
|
int ret=false;
|
||||||
|
ASSERT(m_frameHdr);
|
||||||
|
|
||||||
|
m_refCount--;
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf(" refcount now %d",m_refCount);
|
||||||
|
#endif
|
||||||
|
if( m_refCount == 0 )
|
||||||
|
{
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf(" ..freeing\n");
|
||||||
|
#endif
|
||||||
|
TPFree(m_tpageDesc);
|
||||||
|
MemFree(m_frameHdr);
|
||||||
|
m_frameHdr=NULL;
|
||||||
|
ret=true;
|
||||||
|
}
|
||||||
|
#ifdef SPRITE_BANK_DEBUG
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
loadcount--;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
SpriteBank::SpriteBank()
|
||||||
|
{
|
||||||
|
m_SpriteBankInstance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
SpriteBank::~SpriteBank()
|
||||||
|
{
|
||||||
|
ASSERT(!m_SpriteBankInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params: also creates the instance if required
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void SpriteBank::load( FileEquate _file )
|
||||||
|
{
|
||||||
|
ASSERT(!m_SpriteBankInstance);
|
||||||
|
|
||||||
|
if( !s_bankList )
|
||||||
|
{
|
||||||
|
// first sprite bank load
|
||||||
|
s_bankList=new ("SpriteBank::load") SpriteBankInstance( NULL );
|
||||||
|
s_bankList->load( _file );
|
||||||
|
m_SpriteBankInstance=s_bankList;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SpriteBankInstance *sbiPtr=s_bankList;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if( sbiPtr->getFile() == _file )
|
||||||
|
{
|
||||||
|
// file already loaded - reference it
|
||||||
|
sbiPtr->load( _file );
|
||||||
|
m_SpriteBankInstance=sbiPtr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sbiPtr=sbiPtr->getNext();
|
||||||
|
}
|
||||||
|
while( sbiPtr );
|
||||||
|
|
||||||
|
// file not loaded - create new instance
|
||||||
|
sbiPtr=s_bankList;
|
||||||
|
s_bankList=new ("SpriteBank::load") SpriteBankInstance( sbiPtr );
|
||||||
|
s_bankList->load( _file );
|
||||||
|
m_SpriteBankInstance=s_bankList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params: also deletes the instance if required
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void SpriteBank::dump()
|
||||||
|
{
|
||||||
|
ASSERT( m_SpriteBankInstance );
|
||||||
|
if( m_SpriteBankInstance->dump() )
|
||||||
|
{
|
||||||
|
// just removed last last reference - delete instance
|
||||||
|
if( m_SpriteBankInstance==s_bankList)
|
||||||
|
{
|
||||||
|
// first entry in bank list
|
||||||
|
s_bankList=m_SpriteBankInstance->getNext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SpriteBankInstance *sbiPtr=s_bankList;
|
||||||
|
while( sbiPtr->getNext() != m_SpriteBankInstance )
|
||||||
|
{
|
||||||
|
sbiPtr=sbiPtr->getNext();
|
||||||
|
};
|
||||||
|
sbiPtr->setNext( sbiPtr->getNext()->getNext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_SpriteBankInstance;
|
||||||
|
}
|
||||||
|
m_SpriteBankInstance=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void SpriteBank::prepareFT4(POLY_FT4 *_ft4,sFrameHdr *_fh,int _x,int _y,bool _xFlip,bool _yFlip)
|
||||||
|
{
|
||||||
|
int W=_fh->W,H=_fh->H;
|
||||||
|
|
||||||
|
setShadeTexPolyFT4(_ft4);
|
||||||
|
setShadeTex(_ft4,0);
|
||||||
|
setRGB0(_ft4,128,128,128);
|
||||||
|
if (_xFlip)
|
||||||
|
{
|
||||||
|
_x-=_fh->XOfs;
|
||||||
|
_x-=W;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_x+=_fh->XOfs;
|
||||||
|
|
||||||
|
if (_yFlip)
|
||||||
|
{
|
||||||
|
_y-=_fh->YOfs;
|
||||||
|
_y-=H;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_y+=_fh->YOfs;
|
||||||
|
|
||||||
|
setXYWH(_ft4,_x,_y,W,H);
|
||||||
|
setUVTp(_fh,_ft4,_xFlip,_yFlip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose: Pass Z scale as 8 bit fraction, 256 = 1:1, 512 = enlarge X2, etc.
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void SpriteBank::prepareFT4Scaled(POLY_FT4 *_ft4,sFrameHdr *_fh,int _x,int _y,bool _xFlip,bool _yFlip,long _z)
|
||||||
|
{
|
||||||
|
int W=_fh->W,H=_fh->H;
|
||||||
|
|
||||||
|
W *= _z;
|
||||||
|
H *= _z;
|
||||||
|
W>>=8;
|
||||||
|
H>>=8;
|
||||||
|
|
||||||
|
setShadeTexPolyFT4(_ft4);
|
||||||
|
if (_xFlip)
|
||||||
|
{
|
||||||
|
_x-=_fh->XOfs;
|
||||||
|
_x-=W;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_z+=_fh->XOfs;
|
||||||
|
|
||||||
|
_y+=_fh->YOfs;
|
||||||
|
|
||||||
|
setXYWH(_ft4,_x,_y,W,H);
|
||||||
|
setUVTp(_fh,_ft4,_xFlip,_yFlip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void SpriteBank::setUVTp(sFrameHdr *_fh,POLY_FT4 *_ft4,int _xFlip,int _yFlip)
|
||||||
|
{
|
||||||
|
int U=_fh->U;
|
||||||
|
int V=_fh->V;
|
||||||
|
int W=_fh->W;
|
||||||
|
int H=_fh->H;
|
||||||
|
|
||||||
|
if (!_fh->Rotated)
|
||||||
|
{
|
||||||
|
if (_xFlip)
|
||||||
|
{
|
||||||
|
_ft4->u0=U+W-1;
|
||||||
|
_ft4->u1=U-1;
|
||||||
|
_ft4->u2=U+W-1;
|
||||||
|
_ft4->u3=U-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ft4->u0=U;
|
||||||
|
_ft4->u1=U+W;
|
||||||
|
_ft4->u2=U;
|
||||||
|
_ft4->u3=U+W;
|
||||||
|
}
|
||||||
|
if (_yFlip)
|
||||||
|
{
|
||||||
|
_ft4->v0=V+H-1;
|
||||||
|
_ft4->v1=V+H-1;
|
||||||
|
_ft4->v2=V-1;
|
||||||
|
_ft4->v3=V-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ft4->v0=V;
|
||||||
|
_ft4->v1=V;
|
||||||
|
_ft4->v2=V+H;
|
||||||
|
_ft4->v3=V+H;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_xFlip)
|
||||||
|
{
|
||||||
|
_ft4->v0=V;
|
||||||
|
_ft4->v2=V;
|
||||||
|
_ft4->v1=V+W;
|
||||||
|
_ft4->v3=V+W;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ft4->v0=V+W-1;
|
||||||
|
_ft4->v2=V+W-1;
|
||||||
|
_ft4->v1=V-1;
|
||||||
|
_ft4->v3=V-1;
|
||||||
|
}
|
||||||
|
if (_yFlip)
|
||||||
|
{
|
||||||
|
_ft4->u0=U+H-1;
|
||||||
|
_ft4->u1=U+H-1;
|
||||||
|
_ft4->u2=U-1;
|
||||||
|
_ft4->u3=U-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ft4->u0=U;
|
||||||
|
_ft4->u1=U;
|
||||||
|
_ft4->u2=U+H;
|
||||||
|
_ft4->u3=U+H;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ft4->tpage=_fh->TPage;
|
||||||
|
_ft4->clut=_fh->Clut;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
117
source/gfx/sprbank.h
Normal file
117
source/gfx/sprbank.h
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
sprbank.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: PRLSR
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __GFX_SPRBANK_H__
|
||||||
|
#define __GFX_SPRBANK_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "system\global.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VRAM_H__
|
||||||
|
#include "gfx\tpage.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PRIM_HEADER__
|
||||||
|
#include "gfx\prim.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
// Single instance of a sprite bank
|
||||||
|
class SpriteBankInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpriteBankInstance( SpriteBankInstance *_next );
|
||||||
|
~SpriteBankInstance();
|
||||||
|
|
||||||
|
sFrameHdr *getFrameHeaders() {return m_frameHdr;}
|
||||||
|
|
||||||
|
void load( FileEquate _file );
|
||||||
|
int dump();
|
||||||
|
|
||||||
|
SpriteBankInstance *getNext() { return m_next; }
|
||||||
|
void setNext( SpriteBankInstance *_next) { m_next = _next; }
|
||||||
|
FileEquate getFile() { return m_file; }
|
||||||
|
|
||||||
|
//private:
|
||||||
|
sFrameHdr *m_frameHdr;
|
||||||
|
TPAGE_DESC m_tpageDesc;
|
||||||
|
|
||||||
|
FileEquate m_file;
|
||||||
|
int m_refCount;
|
||||||
|
|
||||||
|
SpriteBankInstance *m_next;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Class for a bank of sprites ( actually a reference to a SpriteBankInstance )
|
||||||
|
class SpriteBank
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpriteBank();
|
||||||
|
~SpriteBank();
|
||||||
|
|
||||||
|
void load( FileEquate _file );
|
||||||
|
void dump();
|
||||||
|
|
||||||
|
sFrameHdr * getHeaders() {return (m_SpriteBankInstance->getFrameHeaders());}
|
||||||
|
sFrameHdr * getFrameHeader( int _frame ) {return (&m_SpriteBankInstance->getFrameHeaders()[ _frame ]);}
|
||||||
|
s32 getFrameWidth( int _frame ) {return (m_SpriteBankInstance->getFrameHeaders()[ _frame ].W);}
|
||||||
|
s32 getFrameHeight( int _frame ) {return (m_SpriteBankInstance->getFrameHeaders()[ _frame ].H);}
|
||||||
|
|
||||||
|
inline POLY_FT4 *printFT4(int _frame,int _x,int _y,int _xFlip,int _yFlip,int _ot) {return printFT4(&m_SpriteBankInstance->getFrameHeaders()[ _frame ],_x,_y,_xFlip,_yFlip,_ot);}
|
||||||
|
inline POLY_FT4 *printFT4(sFrameHdr *_fh,int _x,int _y,int _xFlip,int _yFlip,int _ot)
|
||||||
|
{
|
||||||
|
POLY_FT4 *ft4=GetPrimFT4();
|
||||||
|
|
||||||
|
prepareFT4(ft4,_fh,_x,_y,_xFlip,_yFlip);
|
||||||
|
AddPrimToList(ft4,_ot);
|
||||||
|
return(ft4);
|
||||||
|
}
|
||||||
|
inline POLY_FT4 *printFT4Scaled(int _frame,int _x,int _y,int _xFlip,int _yFlip,int _ot,long _z) {return printFT4Scaled(&m_SpriteBankInstance->getFrameHeaders()[ _frame ],_x,_y,_xFlip,_yFlip,_ot,_z);}
|
||||||
|
inline POLY_FT4 *printFT4Scaled(sFrameHdr *_fh,int _x,int _y,int _xFlip,int _yFlip,int _ot, long _z)
|
||||||
|
{
|
||||||
|
POLY_FT4 *ft4=GetPrimFT4();
|
||||||
|
|
||||||
|
prepareFT4Scaled(ft4,_fh,_x,_y,_xFlip,_yFlip,_z );
|
||||||
|
AddPrimToList(ft4,_ot);
|
||||||
|
return(ft4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void prepareFT4(POLY_FT4 *_ft4,sFrameHdr *_fh,int _x,int _y,bool _xFlip,bool _yFlip);
|
||||||
|
void prepareFT4Scaled(POLY_FT4 *_ft4,sFrameHdr *_fh,int _x,int _y,bool _xFlip,bool _yFlip,long _z);
|
||||||
|
void setUVTp(sFrameHdr *_fh,POLY_FT4 *_ft4,int _xFlip,int _yYFlip);
|
||||||
|
|
||||||
|
class SpriteBankInstance *m_SpriteBankInstance;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __GFX_SPRBANK_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
283
source/gfx/tpage.cpp
Normal file
283
source/gfx/tpage.cpp
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
/**********************/
|
||||||
|
/*** PSX Vram Stuff ***/
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
#include "System\global.h"
|
||||||
|
#include "Gfx\TPage.h"
|
||||||
|
#include "Gfx\AnimTex.h"
|
||||||
|
#include "Gfx\Prim.h"
|
||||||
|
#include "System\vid.h"
|
||||||
|
#include "FileIO/FileIO.h"
|
||||||
|
#include "Mem\Memory.h"
|
||||||
|
#include "utils\utils.h"
|
||||||
|
|
||||||
|
enum TPAGE_ENUMS
|
||||||
|
{
|
||||||
|
TPAGE_HALF0 = 0,
|
||||||
|
TPAGE_HALF1 = 1,
|
||||||
|
TPAGE_FULL = 0,
|
||||||
|
TPAGE_DYN_START = (24),
|
||||||
|
TPAGE_DYN_END = (26),
|
||||||
|
MAX_TPAGES = 32,
|
||||||
|
};
|
||||||
|
|
||||||
|
//#define INVALIDATE_CACHE 1
|
||||||
|
|
||||||
|
const int TPRawW=64;
|
||||||
|
const int TPRawH=256;
|
||||||
|
|
||||||
|
static sTPageCache s_TPCache[MAX_TPAGES];
|
||||||
|
|
||||||
|
// Theory!!
|
||||||
|
// Filenames stored so IF tpage is set to load, AND is found within table (free or not) then use that
|
||||||
|
// Will only work if people are good with the tpage allocation (due to no checks on width)
|
||||||
|
// Will write a InvalidDate routine
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void TPInit()
|
||||||
|
{
|
||||||
|
// Likes to be a multiple of 65536, dunno why, Im shit like that
|
||||||
|
|
||||||
|
for (int i=0; i<MAX_TPAGES ;i++)
|
||||||
|
{
|
||||||
|
s_TPCache[i].Info[0].RefCount=s_TPCache[i].Info[1].RefCount=0;
|
||||||
|
s_TPCache[i].Info[0].TPageName=s_TPCache[i].Info[1].TPageName=(FileEquate)0;
|
||||||
|
s_TPCache[i].Info[0].AnimTexCount=s_TPCache[i].Info[1].AnimTexCount=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void TPFree( const TPAGE_DESC & desc,int Invalidate)
|
||||||
|
{
|
||||||
|
#if defined(INVALIDATE_CACHE)
|
||||||
|
RECT R;
|
||||||
|
setRECT(&R,(desc.tpage&0xf)*TPRawW,(desc.tpage>15)*TPRawH,64,128);
|
||||||
|
Invalidate=1;
|
||||||
|
#endif
|
||||||
|
s_TPCache[desc.tpage].Info[desc.Half].RefCount--;
|
||||||
|
if (!s_TPCache[desc.tpage].Info[desc.Half].RefCount)
|
||||||
|
{
|
||||||
|
if (Invalidate) s_TPCache[desc.tpage].Info[desc.Half].TPageName=(FileEquate)0;
|
||||||
|
if (desc.Half==0 && s_TPCache[desc.tpage].Info[1].RefCount==-1) // Check for full tpage
|
||||||
|
{
|
||||||
|
s_TPCache[desc.tpage].Info[1].RefCount=0;
|
||||||
|
#if defined(INVALIDATE_CACHE)
|
||||||
|
R.h=256;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
CAnimTex::DumpThisTPage(s_TPCache[desc.tpage].Info[desc.Half].TPageName);
|
||||||
|
#if defined(INVALIDATE_CACHE)
|
||||||
|
R.y+=desc.Half*128;
|
||||||
|
ClearImage(&R,0,255,0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void IsTPageInCache(FileEquate Filename,int &TPage,int &Half)
|
||||||
|
{
|
||||||
|
TPage=0;
|
||||||
|
for (int Loop=0; Loop<MAX_TPAGES && !TPage; Loop++)
|
||||||
|
{
|
||||||
|
if (s_TPCache[Loop].Info[0].TPageName==Filename)
|
||||||
|
{
|
||||||
|
Half=0;
|
||||||
|
TPage=Loop;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (s_TPCache[Loop].Info[1].TPageName==Filename)
|
||||||
|
{
|
||||||
|
Half=1;
|
||||||
|
TPage=Loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
sTPageInfo *FindSpareTPage(FileEquate Filename, int &TPage,int &Half,sTPageHdr *TPHdr)
|
||||||
|
{
|
||||||
|
TPage=TPHdr->TPageStart;
|
||||||
|
Half=0;
|
||||||
|
if (TPage>=TPAGE_DYN_START && TPage<=TPAGE_DYN_END) // Its a dynamic TPage!
|
||||||
|
{
|
||||||
|
// Find spare VRam
|
||||||
|
if (TPHdr->TPageHeightInPixels <= 128) // Half TPage
|
||||||
|
{
|
||||||
|
// Find spare half
|
||||||
|
while(s_TPCache[TPage].Info[0].RefCount && s_TPCache[TPage].Info[1].RefCount)
|
||||||
|
{
|
||||||
|
TPage++;
|
||||||
|
ASSERT(TPage <= TPAGE_DYN_END);// ASSERT(!"VRAM FULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!s_TPCache[TPage].Info[0].RefCount)
|
||||||
|
Half = TPAGE_HALF0;
|
||||||
|
else
|
||||||
|
Half=TPAGE_HALF1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Full TPage
|
||||||
|
while(s_TPCache[TPage].Info[0].RefCount || s_TPCache[TPage].Info[1].RefCount)
|
||||||
|
{
|
||||||
|
TPage++;
|
||||||
|
if (TPage >= MAX_TPAGES) ASSERT(!"VRAM FULL");
|
||||||
|
}
|
||||||
|
Half = TPAGE_FULL;
|
||||||
|
s_TPCache[TPage].Info[1].TPageName=(FileEquate)0;
|
||||||
|
s_TPCache[TPage].Info[1].RefCount=-1; // lock 2nd half
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sTPageInfo *Cache=&s_TPCache[TPage].Info[Half];
|
||||||
|
Cache->RefCount++;
|
||||||
|
Cache->TPageName=Filename;
|
||||||
|
Cache->XOfs=TPage-TPHdr->TPageStart;
|
||||||
|
Cache->YOfs=Half*128;
|
||||||
|
Cache->AnimTexCount=0;
|
||||||
|
return(Cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void TPLoadVRam(sTPageHdr *TPHdr, int TPage, int Half, u32 *VRamData)
|
||||||
|
{
|
||||||
|
RECT Rect;
|
||||||
|
|
||||||
|
// Read and DMA TP to VRam
|
||||||
|
Rect.x=(TPage%16)*TPRawW;
|
||||||
|
Rect.y=((TPage>>4)*TPRawH)+(Half*128);
|
||||||
|
Rect.w=TPHdr->TPageWidth*TPRawW;
|
||||||
|
Rect.h=TPHdr->TPageHeightInPixels;
|
||||||
|
|
||||||
|
DrawSync( 0 );
|
||||||
|
LoadImage( &Rect, VRamData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void AddAnimTexToList(sTPageInfo *Cache,sFrameHdr *FramePtr,int TPage,int Half)
|
||||||
|
{
|
||||||
|
sFrameHdr *AT=&Cache->AnimTexFrame[Cache->AnimTexCount];
|
||||||
|
|
||||||
|
MCmemcpy(AT,FramePtr,sizeof(sFrameHdr));
|
||||||
|
Cache->AnimTexCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
TPAGE_DESC TPLoadTex(FileEquate Filename)
|
||||||
|
{
|
||||||
|
TPAGE_DESC Desc;
|
||||||
|
sTPageHdr *TPHdr;
|
||||||
|
sFrameHdr *FramePtr;
|
||||||
|
u32 *VRAMData;
|
||||||
|
int TPage,Half;
|
||||||
|
sTPageInfo *Cache;
|
||||||
|
|
||||||
|
// Is it already loaded in TCache?
|
||||||
|
IsTPageInCache(Filename,TPage,Half);
|
||||||
|
|
||||||
|
if (TPage) // Is in cache, no need to load it again :o)
|
||||||
|
{
|
||||||
|
DBG_MSG2("TPLoadTex Cached (%i,%i)",TPage,Half);
|
||||||
|
s_TPCache[TPage].Info[Half].RefCount++;
|
||||||
|
Cache=&s_TPCache[TPage].Info[Half];
|
||||||
|
FramePtr=&Cache->AnimTexFrame[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Better load it then
|
||||||
|
DBG_MSG0("TPLoadTex");
|
||||||
|
TPHdr=(sTPageHdr*)CFileIO::loadFile(Filename,"TPLoadTEX");
|
||||||
|
ASSERT(!TPHdr->NumOfSpareBoxes);
|
||||||
|
FramePtr=(sFrameHdr*) MakePtr(TPHdr,sizeof(sTPageHdr));
|
||||||
|
VRAMData=(u32*) MakePtr(FramePtr,TPHdr->NoOfFrames*sizeof(sFrameHdr));
|
||||||
|
Cache=FindSpareTPage(Filename,TPage,Half,TPHdr);
|
||||||
|
for (int Frm=0;Frm<TPHdr->NoOfFrames; Frm++) // Add Animated Texture references
|
||||||
|
{
|
||||||
|
if (FramePtr->Cycle) AddAnimTexToList(Cache,FramePtr++,TPage,Half);
|
||||||
|
}
|
||||||
|
TPLoadVRam(TPHdr, TPage,Half,VRAMData);
|
||||||
|
MemFree(TPHdr);
|
||||||
|
}
|
||||||
|
// If first instance, add animated textures
|
||||||
|
if (Cache->RefCount==1)
|
||||||
|
{
|
||||||
|
FramePtr=Cache->AnimTexFrame;
|
||||||
|
for (int Frm=0; Frm<Cache->AnimTexCount; Frm++) CAnimTex::AddAnimTex(FramePtr++,Filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
Desc.Half= Half;
|
||||||
|
Desc.tpage = TPage;
|
||||||
|
Desc.xoffset = Cache->XOfs;
|
||||||
|
Desc.yoffset = Cache->YOfs;
|
||||||
|
|
||||||
|
return (Desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// These are NEVER dynamic, but need to store the frame headers
|
||||||
|
// Plus, this should only happen at system startup now :o)
|
||||||
|
TPAGE_DESC TPLoadTexWithHeaders(FileEquate Filename, sFrameHdr **hdrs )
|
||||||
|
{
|
||||||
|
TPAGE_DESC Desc;
|
||||||
|
sTPageHdr TPHdr;
|
||||||
|
sFrameHdr *FramePtr;
|
||||||
|
u32 *VRAMData;
|
||||||
|
int TPage,Half=0;
|
||||||
|
sTPageInfo *Cache;
|
||||||
|
int ReadLeft;
|
||||||
|
|
||||||
|
// Is it already loaded in TCache?
|
||||||
|
IsTPageInCache(Filename,TPage,Half);
|
||||||
|
|
||||||
|
if (TPage) // Found one!!
|
||||||
|
{
|
||||||
|
DBG_MSG2("TPLoadTexWithHeaders Cached (%i,%i)",TPage,Half);
|
||||||
|
s_TPCache[TPage].Info[Half].RefCount++;
|
||||||
|
Cache=&s_TPCache[TPage].Info[Half];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG_MSG0("TPLoadTexWithHeaders");
|
||||||
|
CFileIO::OpenFile(Filename);
|
||||||
|
// Load Main Header
|
||||||
|
CFileIO::ReadFile((void*)&TPHdr,sizeof(sTPageHdr));
|
||||||
|
ASSERT(!TPHdr.NumOfSpareBoxes);
|
||||||
|
TPage=TPHdr.TPageStart;
|
||||||
|
// Load Rest
|
||||||
|
*hdrs=(sFrameHdr*)MemAlloc(sizeof(sFrameHdr)*TPHdr.NoOfFrames,"TpFh");
|
||||||
|
ReadLeft=CFileIO::GetReadLeft();
|
||||||
|
FramePtr=(sFrameHdr*)MemAlloc(ReadLeft,"TPLoadTemp");
|
||||||
|
CFileIO::ReadFile(FramePtr,ReadLeft);
|
||||||
|
CFileIO::CloseFile();
|
||||||
|
VRAMData=(u32*) MakePtr(FramePtr,TPHdr.NoOfFrames*sizeof(sFrameHdr));
|
||||||
|
MCmemcpy(*hdrs,FramePtr,TPHdr.NoOfFrames*sizeof(sFrameHdr));
|
||||||
|
TPLoadVRam(&TPHdr, TPage,Half,VRAMData);
|
||||||
|
Cache=&s_TPCache[TPage].Info[Half];
|
||||||
|
MemFree(FramePtr);
|
||||||
|
FramePtr=*hdrs;
|
||||||
|
for (int Frm=0;Frm<TPHdr.NoOfFrames; Frm++) // Add Animated Texture references
|
||||||
|
{
|
||||||
|
if (FramePtr->Cycle) AddAnimTexToList(Cache,FramePtr++,TPage,Half);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache->RefCount=1;
|
||||||
|
Cache->TPageName=Filename;
|
||||||
|
Cache->XOfs=0;
|
||||||
|
Cache->YOfs=0;
|
||||||
|
s_TPCache[TPage].Info[1].RefCount=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If first instance, add animated textures
|
||||||
|
if (Cache->RefCount==1)
|
||||||
|
{
|
||||||
|
FramePtr=Cache->AnimTexFrame;
|
||||||
|
for (int Frm=0; Frm<Cache->AnimTexCount; Frm++) CAnimTex::AddAnimTex(FramePtr++,Filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
Desc.Half= Half;
|
||||||
|
Desc.tpage = TPage;
|
||||||
|
Desc.xoffset = Cache->XOfs;
|
||||||
|
Desc.yoffset = Cache->YOfs;
|
||||||
|
|
||||||
|
return (Desc);
|
||||||
|
}
|
||||||
|
|
63
source/gfx/tpage.h
Normal file
63
source/gfx/tpage.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/**********************/
|
||||||
|
/*** PSX Vram Stuff ***/
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
#ifndef __VRAM_H__
|
||||||
|
#define __VRAM_H__
|
||||||
|
|
||||||
|
#include <BigLump.h>
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
#define TPAGE_MAX_ANIM_TEX 8
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u16 NoOfFrames,NoOfTPages;
|
||||||
|
u16 TPageStart;
|
||||||
|
u16 TPageWidth,TPageHeightInPixels;
|
||||||
|
u16 NumOfSpareBoxes;
|
||||||
|
u16 Compress,Pad;
|
||||||
|
} sTPageHdr;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u16 TPage;
|
||||||
|
u16 Clut;
|
||||||
|
s8 XOfs,YOfs;
|
||||||
|
|
||||||
|
u8 W,H;
|
||||||
|
u8 U,V;
|
||||||
|
u8 Rotated;
|
||||||
|
u8 Cycle;
|
||||||
|
} sFrameHdr;
|
||||||
|
|
||||||
|
struct TPAGE_DESC
|
||||||
|
{
|
||||||
|
u8 Half;
|
||||||
|
u8 tpage;
|
||||||
|
u8 xoffset;
|
||||||
|
u8 yoffset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sTPageInfo
|
||||||
|
{
|
||||||
|
s16 RefCount;
|
||||||
|
FileEquate TPageName;
|
||||||
|
s16 XOfs,YOfs;
|
||||||
|
u16 AnimTexCount;
|
||||||
|
sFrameHdr AnimTexFrame[TPAGE_MAX_ANIM_TEX];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sTPageCache
|
||||||
|
{
|
||||||
|
sTPageInfo Info[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
/********************************************************************************************************/
|
||||||
|
|
||||||
|
void TPInit();
|
||||||
|
TPAGE_DESC TPLoadTex(FileEquate Filename);
|
||||||
|
TPAGE_DESC TPLoadTexWithHeaders( FileEquate Filename, sFrameHdr **hdrs );
|
||||||
|
void TPFree( const TPAGE_DESC & desc ,int blah=0);
|
||||||
|
|
||||||
|
#endif
|
228
source/locale/textdbase.cpp
Normal file
228
source/locale/textdbase.cpp
Normal file
|
@ -0,0 +1,228 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
textdbase.cpp
|
||||||
|
|
||||||
|
Author: G R Liddon @ Fareham
|
||||||
|
Created: Monday 23rd August 1999
|
||||||
|
Project: TPW PSX
|
||||||
|
Purpose: Language Database Handling Code
|
||||||
|
|
||||||
|
Copyright (c) 1998 / 1999 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
/* Module Header File
|
||||||
|
------------------ */
|
||||||
|
#include "textdbase.h"
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Glib
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/* Local
|
||||||
|
----- */
|
||||||
|
|
||||||
|
#ifndef __MEMORY_HEADER__
|
||||||
|
#include "mem\memory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __BigLump_H__
|
||||||
|
#include <biglump.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _FILEIO_HEADER_
|
||||||
|
#include "fileio\fileio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Graphics
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
struct TransHeader
|
||||||
|
{
|
||||||
|
u32 m_numOfStrings;
|
||||||
|
char * m_stringPtrs[1];
|
||||||
|
|
||||||
|
void relocate(void)
|
||||||
|
{
|
||||||
|
for (unsigned int f=0;f<m_numOfStrings;f++)
|
||||||
|
m_stringPtrs[f]=(char *)((u32)m_stringPtrs[f]+(u32)this);
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * getString(unsigned int stringNum) const
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(__VERSION_debug__)
|
||||||
|
if (stringNum > m_numOfStrings)
|
||||||
|
{
|
||||||
|
DBG_MSG2("stringNum %d > m_numOfStrings %d", stringNum, m_numOfStrings);
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return(m_stringPtrs[stringNum]);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
static void loadDatabase(FileEquate f);
|
||||||
|
static void dumpDatabase(void);
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Vars
|
||||||
|
---- */
|
||||||
|
static TransHeader * s_database;
|
||||||
|
static bool s_loaded;
|
||||||
|
static TransHeader * s_idDatabase;
|
||||||
|
static bool s_idShow;
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Data
|
||||||
|
---- */
|
||||||
|
static FileEquate const s_languageFileEquates[NUM_OF_LANGUAGES]=
|
||||||
|
{
|
||||||
|
TRANSLATIONS_ENG_DAT,
|
||||||
|
TRANSLATIONS_SWE_DAT,
|
||||||
|
TRANSLATIONS_DUT_DAT,
|
||||||
|
TRANSLATIONS_ITA_DAT,
|
||||||
|
TRANSLATIONS_GER_DAT,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void TranslationDatabase::initialise(bool includeIds)
|
||||||
|
{
|
||||||
|
int largestSize;
|
||||||
|
|
||||||
|
|
||||||
|
largestSize=0;
|
||||||
|
|
||||||
|
/* first find which language is the largest */
|
||||||
|
|
||||||
|
for (int f=0;f<NUM_OF_LANGUAGES;f++)
|
||||||
|
{
|
||||||
|
int thisFileSize=CFileIO::getFileSize(s_languageFileEquates[f]);
|
||||||
|
if (thisFileSize > largestSize)
|
||||||
|
largestSize = thisFileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now Allocate some mem for it */
|
||||||
|
|
||||||
|
DBG_MSG1("Translation Database allocating %d bytes string space",largestSize);
|
||||||
|
|
||||||
|
s_database=(TransHeader*)MemAlloc(largestSize,"TextDB");
|
||||||
|
s_loaded=false;
|
||||||
|
|
||||||
|
if (includeIds)
|
||||||
|
{
|
||||||
|
int len=CFileIO::getFileSize(TRANSLATIONS_ID_DAT);
|
||||||
|
s_idDatabase=(TransHeader*)MemAlloc(len,"TextID");
|
||||||
|
CFileIO::OpenFile(TRANSLATIONS_ID_DAT);
|
||||||
|
CFileIO::ReadFile(s_idDatabase,len);
|
||||||
|
CFileIO::CloseFile();
|
||||||
|
|
||||||
|
s_idDatabase->relocate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
s_idDatabase=NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void TranslationDatabase::setShowIds(bool idShowVal)
|
||||||
|
{
|
||||||
|
if (s_idDatabase)
|
||||||
|
s_idShow=idShowVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void TranslationDatabase::loadLanguage(unsigned int langType)
|
||||||
|
{
|
||||||
|
ASSERT(langType < NUM_OF_LANGUAGES);
|
||||||
|
|
||||||
|
if (s_loaded)
|
||||||
|
dumpDatabase();
|
||||||
|
|
||||||
|
loadDatabase(FileEquate(s_languageFileEquates[langType]));
|
||||||
|
|
||||||
|
s_loaded=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
char const * TranslationDatabase::getString(unsigned int strNum)
|
||||||
|
{
|
||||||
|
ASSERT(s_loaded);
|
||||||
|
if (s_idShow)
|
||||||
|
return(s_idDatabase->getString(strNum));
|
||||||
|
else
|
||||||
|
return(s_database->getString(strNum));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
static void loadDatabase(FileEquate f)
|
||||||
|
{
|
||||||
|
ASSERT(!s_loaded);
|
||||||
|
|
||||||
|
CFileIO::OpenFile(f);
|
||||||
|
CFileIO::ReadFile(s_database,CFileIO::getFileSize(f));
|
||||||
|
CFileIO::CloseFile();
|
||||||
|
|
||||||
|
s_database->relocate();
|
||||||
|
s_loaded=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
static void dumpDatabase(void)
|
||||||
|
{
|
||||||
|
ASSERT(s_loaded);
|
||||||
|
|
||||||
|
s_loaded=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
82
source/locale/textdbase.h
Normal file
82
source/locale/textdbase.h
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
textdbase.cpp
|
||||||
|
|
||||||
|
Author: G R Liddon @ Fareham
|
||||||
|
Created: Monday 23rd August 1999
|
||||||
|
Project: TPW PSX
|
||||||
|
Purpose: Language Database Handling Code
|
||||||
|
|
||||||
|
Copyright (c) 1998 / 1999 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __LOCALE_TEXTDBASE_H__
|
||||||
|
#define __LOCALE_TEXTDBASE_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
// May as well include the string IDs in here..
|
||||||
|
#ifndef __STRING_ENUMS__
|
||||||
|
#include <trans.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Glib
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/* Local
|
||||||
|
----- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENGLISH,
|
||||||
|
SWEDISH,
|
||||||
|
DUTCH,
|
||||||
|
ITALIAN,
|
||||||
|
GERMAN,
|
||||||
|
NUM_OF_LANGUAGES,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
class TranslationDatabase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
static void initialise(bool includeIds);
|
||||||
|
static void loadLanguage(unsigned int langType);
|
||||||
|
static char const * getString(unsigned int strNum);
|
||||||
|
static void setShowIds(bool idShowVal);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/* Data
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/* Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __LOCALE_TEXTDBASE_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
636
source/mem/memory.cpp
Normal file
636
source/mem/memory.cpp
Normal file
|
@ -0,0 +1,636 @@
|
||||||
|
/**************************/
|
||||||
|
/*** Memory Alloc Stuff ***/
|
||||||
|
/**************************/
|
||||||
|
|
||||||
|
#include "system\global.h"
|
||||||
|
#include "mem\memory.h"
|
||||||
|
#include "fileio/fileio.h" // Poo, need this for Databank stuff
|
||||||
|
|
||||||
|
#if defined(__USER_daveo__)
|
||||||
|
#define MemPrint
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void MemAddNode(sLList *LList,u_long Len,char *Addr);
|
||||||
|
void MemRemoveNode(sLList *LList,u_short Node);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
sLList MainRam;
|
||||||
|
int MemNodeCount=0;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __DEBUG_MEM__
|
||||||
|
|
||||||
|
#ifndef __PRIM_HEADER__
|
||||||
|
#include "gfx/prim.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PADS_H__
|
||||||
|
#include "pad/pads.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system/vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SYSTEM_GSTATE_H__
|
||||||
|
#include "system/gstate.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GFX_FONT_H__
|
||||||
|
#include "gfx/font.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_MEM_DUMP 1024
|
||||||
|
|
||||||
|
enum MEM_ID
|
||||||
|
{
|
||||||
|
MEM_BACKEND,
|
||||||
|
MEM_FRONTEND,
|
||||||
|
MEM_GAME,
|
||||||
|
MEM_GAMEOPTIONS,
|
||||||
|
MEM_SYSTEM,
|
||||||
|
|
||||||
|
MEM_ID_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct MEM_PART
|
||||||
|
{
|
||||||
|
void * addr;
|
||||||
|
MEM_ID id;
|
||||||
|
const char * name;
|
||||||
|
const char * file;
|
||||||
|
int line;
|
||||||
|
u32 frameTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static MEM_PART memDump[ MAX_MEM_DUMP ];
|
||||||
|
|
||||||
|
static bool s_dumpMem = false;
|
||||||
|
|
||||||
|
static const int s_dumpX = 16;
|
||||||
|
static const int s_dumpY = 190;
|
||||||
|
static const int s_dumpWidth = 400;
|
||||||
|
static const int s_dumpHeight = 32;
|
||||||
|
static const int s_dumpScale = ONE;
|
||||||
|
|
||||||
|
static const int s_dumpTextX = 32;
|
||||||
|
static const int s_dumpTextY = 120;
|
||||||
|
|
||||||
|
static const int s_dumpShift = 20;
|
||||||
|
|
||||||
|
static const int s_shadeX = 16;
|
||||||
|
static const int s_shadeY = 110;
|
||||||
|
static const int s_shadeW = 400;
|
||||||
|
static const int s_shadeH = 80;
|
||||||
|
static const CVECTOR s_shadeCol = { 0, 0, 0 };
|
||||||
|
|
||||||
|
|
||||||
|
static int s_currentMemPart = 0;
|
||||||
|
|
||||||
|
static const CVECTOR s_colors[ MEM_ID_MAX ] =
|
||||||
|
{
|
||||||
|
{ 255, 0, 0 }, // MEM_BACKEND
|
||||||
|
{ 0, 255, 0 }, // MEM_FRONTEND
|
||||||
|
{ 0, 0, 255 }, // MEM_GAME
|
||||||
|
{ 255, 0, 255 }, // MEM_GAMEOPTIONS
|
||||||
|
{ 255, 255, 255 }, // MEM_SYSTEM
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char * s_sceneNames[] =
|
||||||
|
{
|
||||||
|
"BackEnd",
|
||||||
|
"FrontEnd",
|
||||||
|
"Game",
|
||||||
|
"GameOptions",
|
||||||
|
"System",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int s_nbSceneNames = sizeof(s_sceneNames) / sizeof(char *);
|
||||||
|
|
||||||
|
static FontBank s_debugFont;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void dumpDebugMem()
|
||||||
|
{
|
||||||
|
if (s_dumpMem)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
u16 padh, padd;
|
||||||
|
u32 freeMem;
|
||||||
|
u32 memBase;
|
||||||
|
u32 byteWidth;
|
||||||
|
MEM_PART * mem;
|
||||||
|
CVECTOR black = {0, 0, 0};
|
||||||
|
|
||||||
|
padd = PadGetDown( 1 );
|
||||||
|
padh = PadGetHeld( 1 );
|
||||||
|
|
||||||
|
// if (padh & PAD_SQUARE)
|
||||||
|
{
|
||||||
|
int dir;
|
||||||
|
|
||||||
|
dir = 0;
|
||||||
|
if (padd & PAD_LEFT)
|
||||||
|
{
|
||||||
|
dir = -1;
|
||||||
|
s_currentMemPart--;
|
||||||
|
}
|
||||||
|
if (padd & PAD_RIGHT)
|
||||||
|
{
|
||||||
|
dir = +1;
|
||||||
|
s_currentMemPart++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_currentMemPart < 0) s_currentMemPart = MAX_MEM_DUMP - 1;
|
||||||
|
if (s_currentMemPart >= MAX_MEM_DUMP-1) s_currentMemPart = 0;
|
||||||
|
|
||||||
|
while( !memDump[s_currentMemPart].addr )
|
||||||
|
{
|
||||||
|
s_currentMemPart += dir;
|
||||||
|
if (s_currentMemPart < 0) s_currentMemPart = MAX_MEM_DUMP - 1;
|
||||||
|
if (s_currentMemPart >= MAX_MEM_DUMP-1) s_currentMemPart = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* else
|
||||||
|
{
|
||||||
|
if (padh & PAD_UP) s_dumpScale += 64;
|
||||||
|
if (padh & PAD_DOWN) s_dumpScale -= 64;
|
||||||
|
|
||||||
|
if (padh & PAD_LEFT) s_dumpX -= (2 * s_dumpScale) >> 12;
|
||||||
|
if (padh & PAD_RIGHT) s_dumpX += (2 * s_dumpScale) >> 12;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
memBase = (u32)OPT_LinkerOpts.FreeMemAddress;
|
||||||
|
freeMem = OPT_LinkerOpts.FreeMemSize - 4;
|
||||||
|
if (freeMem > 6*1024*1024) freeMem -= 6*1024*1024;
|
||||||
|
byteWidth = ((s_dumpWidth << s_dumpShift) / freeMem);
|
||||||
|
|
||||||
|
x = s_dumpX;
|
||||||
|
y = s_dumpY;
|
||||||
|
|
||||||
|
mem = memDump;
|
||||||
|
|
||||||
|
/*
|
||||||
|
for (int i=0;i<MAX_MEM_DUMP;i++)
|
||||||
|
{
|
||||||
|
if (mem->addr)
|
||||||
|
{
|
||||||
|
u32 len;
|
||||||
|
u32 * addr;
|
||||||
|
POLY_F4 * F4;
|
||||||
|
CVECTOR * col;
|
||||||
|
|
||||||
|
addr = (u32 *)mem->addr;
|
||||||
|
|
||||||
|
x = (((u32)addr) - ((u32)memBase));
|
||||||
|
x *= s_dumpScale;
|
||||||
|
x >>= 12;
|
||||||
|
x *= byteWidth;
|
||||||
|
x >>= s_dumpShift;
|
||||||
|
x += s_dumpX;
|
||||||
|
|
||||||
|
len = *(addr - 1);
|
||||||
|
len *= s_dumpScale;
|
||||||
|
len >>= 12;
|
||||||
|
len *= byteWidth;
|
||||||
|
len >>= s_dumpShift;
|
||||||
|
|
||||||
|
col = &s_colors[ mem->id ];
|
||||||
|
|
||||||
|
if (i == s_currentMemPart)
|
||||||
|
{
|
||||||
|
col = &black;
|
||||||
|
}
|
||||||
|
|
||||||
|
F4 = GetPrimF4();
|
||||||
|
setPolyF4( F4 );
|
||||||
|
setXY4( F4, x, y,
|
||||||
|
x + len, y,
|
||||||
|
x, y + s_dumpHeight,
|
||||||
|
x + len, y + s_dumpHeight );
|
||||||
|
setSemiTrans( F4, 0 );
|
||||||
|
setShadeTex( F4, 0 );
|
||||||
|
setRGB0( F4, col->r, col->g, col->b );
|
||||||
|
AddPrimToList( F4, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
mem++;
|
||||||
|
}
|
||||||
|
*/ int len;
|
||||||
|
char Text[ 2048 ];
|
||||||
|
char * name;
|
||||||
|
char * file;
|
||||||
|
POLY_F4 * F4;
|
||||||
|
|
||||||
|
F4 = GetPrimF4();
|
||||||
|
setPolyF4( F4 );
|
||||||
|
setXYWH( F4, s_shadeX, s_shadeY, s_shadeW, s_shadeH );
|
||||||
|
setSemiTrans( F4, 1 );
|
||||||
|
setShadeTex( F4, 0 );
|
||||||
|
setRGB0( F4, s_shadeCol.r, s_shadeCol.g, s_shadeCol.b );
|
||||||
|
AddPrimToList( F4, 1 );
|
||||||
|
|
||||||
|
mem = &memDump[ s_currentMemPart ];
|
||||||
|
if (mem->addr) len = *(((u32 *)mem->addr) - 1);
|
||||||
|
else len = 0;
|
||||||
|
|
||||||
|
sprintf( Text, "%d\n", s_currentMemPart );
|
||||||
|
if (mem->addr)
|
||||||
|
{
|
||||||
|
sprintf( Text, "%sAddr - %X Len - %d\n", Text, (int)mem->addr, len );
|
||||||
|
sprintf( Text, "%sAddrEnd - %X\n\n", Text, (int)mem->addr+len );
|
||||||
|
|
||||||
|
if (mem->name) sprintf( Text, "%sName - %s\n", Text, mem->name );
|
||||||
|
else sprintf( Text, "%sName - Undefined", Text );
|
||||||
|
|
||||||
|
sprintf( Text, "%sFile - %s, Line - %d\n", Text, mem->file, mem->line );
|
||||||
|
sprintf( Text, "%sScene - %s\n", Text, s_sceneNames[ mem->id ] );
|
||||||
|
// sprintf( Text, "%sTime - %lu", Text, mem->frameTime );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( Text, "%sAddr - NULL\nLen - 0\nName - Undefined\nFile - Undefined, Line - 0", Text );
|
||||||
|
}
|
||||||
|
|
||||||
|
s_debugFont.print( s_dumpTextX, s_dumpTextY, (u8*)Text );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void resetDebugMem()
|
||||||
|
{
|
||||||
|
for (int i=0;i<MAX_MEM_DUMP;i++)
|
||||||
|
{
|
||||||
|
memDump[i].addr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void addDebugMem( void * addr, const char * name, const char * file, int line )
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
char * sname;
|
||||||
|
CScene * scene;
|
||||||
|
|
||||||
|
scene = GameState::getCurrentScene();
|
||||||
|
if (scene)
|
||||||
|
{
|
||||||
|
sname = scene->GetSceneName();
|
||||||
|
|
||||||
|
id = -1;
|
||||||
|
for (int i=0;i<s_nbSceneNames;i++)
|
||||||
|
{
|
||||||
|
if (!strcmp( sname, s_sceneNames[i] ))
|
||||||
|
{
|
||||||
|
id = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id == -1) id = MEM_SYSTEM;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = MEM_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0;i<MAX_MEM_DUMP;i++)
|
||||||
|
{
|
||||||
|
if (!memDump[i].addr)
|
||||||
|
{
|
||||||
|
memDump[i].addr = addr;
|
||||||
|
memDump[i].id = MEM_ID( id );
|
||||||
|
memDump[i].name = name;
|
||||||
|
memDump[i].file = file;
|
||||||
|
memDump[i].line = line;
|
||||||
|
memDump[i].frameTime = VidGetTickCount();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ASSERT( !"Out of debug mem slots" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void freeDebugMem( void * addr )
|
||||||
|
{
|
||||||
|
ASSERT( addr );
|
||||||
|
|
||||||
|
for (int i=0;i<MAX_MEM_DUMP;i++)
|
||||||
|
{
|
||||||
|
if (memDump[i].addr == addr)
|
||||||
|
{
|
||||||
|
memDump[i].addr = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ASSERT( !"Can't find debug mem node" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void MemInit()
|
||||||
|
{
|
||||||
|
u16 stack = LListLen - 1;
|
||||||
|
sLList * mem = &MainRam;
|
||||||
|
char * addr = (char*)OPT_LinkerOpts.FreeMemAddress;
|
||||||
|
u32 len = OPT_LinkerOpts.FreeMemSize - 4;
|
||||||
|
|
||||||
|
mem->SP = stack;
|
||||||
|
mem->Head = 0xffff;
|
||||||
|
mem->Tail = 0xffff;
|
||||||
|
|
||||||
|
for (int i=0;i<LListLen;i++)
|
||||||
|
{
|
||||||
|
mem->Stack[ i ] = stack--;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemAddNode( mem, len, addr );
|
||||||
|
|
||||||
|
mem->RamUsed = 0;
|
||||||
|
mem->TotalRam = len;
|
||||||
|
|
||||||
|
#ifdef __DEBUG_MEM__
|
||||||
|
resetDebugMem();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// hmm.. have to alloc this memory before the first scene, but have to wait until all the
|
||||||
|
// systems are active so can't do it in the standard MemInit() thing
|
||||||
|
void DebugMemFontInit()
|
||||||
|
{
|
||||||
|
#ifdef __DEBUG_MEM__
|
||||||
|
s_debugFont.initialise( &standardFont );
|
||||||
|
s_debugFont.setOt( 0 );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// 030700 Dave - Implemented smart allocation
|
||||||
|
// It now looks thru the whole node list, and takes from the smallest VALID node
|
||||||
|
// I now understand how this memory stuff works, it aint all bad!
|
||||||
|
|
||||||
|
char * MemAllocate( u32 TLen, char const *Name, char const * File, int LineNumber )
|
||||||
|
{
|
||||||
|
sLList *mem = &MainRam;
|
||||||
|
u16 Head = mem->Head;
|
||||||
|
char *Addr = (char*)-1;
|
||||||
|
u32 Len = ((TLen + 3) & 0xfffffffc);
|
||||||
|
int BestNode,FirstNode;
|
||||||
|
|
||||||
|
Len += 4; //add on 4 to store Addr !
|
||||||
|
|
||||||
|
// Find First (and possably only)
|
||||||
|
while (Head != 0xffff && mem->Nodes[ Head ].Len<Len) Head = mem->Nodes[ Head ].Next;
|
||||||
|
ASSERT(Head != 0xffff);
|
||||||
|
|
||||||
|
BestNode=FirstNode=Head;
|
||||||
|
|
||||||
|
// Check rest of list
|
||||||
|
while (Head != 0xffff)
|
||||||
|
{
|
||||||
|
if (mem->Nodes[Head].Len>=Len)
|
||||||
|
{
|
||||||
|
if (mem->Nodes[Head].Len<mem->Nodes[BestNode].Len) BestNode=Head;
|
||||||
|
}
|
||||||
|
Head = mem->Nodes[ Head ].Next;
|
||||||
|
}
|
||||||
|
//--------------------
|
||||||
|
#ifdef MemPrintx
|
||||||
|
if (Len>300000)
|
||||||
|
{
|
||||||
|
Head=mem->Head;
|
||||||
|
while (Head != 0xffff)
|
||||||
|
{
|
||||||
|
printf("%i %i\n",Head,(int)mem->Nodes[Head].Len);
|
||||||
|
Head = mem->Nodes[ Head ].Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (FirstNode!=BestNode)
|
||||||
|
printf("Need %i, %i (%i) \t%i (%i) \n",(int)Len,FirstNode,(int)mem->Nodes[FirstNode].Len, BestNode,(int)mem->Nodes[BestNode].Len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------
|
||||||
|
// Alloc it
|
||||||
|
if (mem->Nodes[BestNode].Len >= Len)
|
||||||
|
{
|
||||||
|
Addr = mem->Nodes[BestNode].Addr;
|
||||||
|
mem->Nodes[BestNode].Len -= Len;
|
||||||
|
mem->Nodes[BestNode].Addr += Len;
|
||||||
|
if (mem->Nodes[BestNode].Len == 0) MemRemoveNode( mem, BestNode);
|
||||||
|
*(u32*)Addr = Len;
|
||||||
|
Addr += 4;
|
||||||
|
mem->RamUsed += Len;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __DEBUG_MEM__
|
||||||
|
addDebugMem( Addr, Name, File, LineNumber );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ASSERT( (Addr != (char*)-1) );
|
||||||
|
return Addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void MemFree( void * Address )
|
||||||
|
{
|
||||||
|
u32 Len;
|
||||||
|
sLLNode *node;
|
||||||
|
sLList *mem = &MainRam;
|
||||||
|
u16 Head = mem->Head;
|
||||||
|
char *Addr = (char*)Address;
|
||||||
|
|
||||||
|
// If file from Databank, dont try and clear it (simple!!)
|
||||||
|
if (CFileIO::IsFromDataBank(Address)) return;
|
||||||
|
Addr -= 4;
|
||||||
|
|
||||||
|
Len = *(u32*)Addr;
|
||||||
|
|
||||||
|
mem->RamUsed -= Len;
|
||||||
|
|
||||||
|
node = &mem->Nodes[ Head ];
|
||||||
|
while (Head != 0xffff)
|
||||||
|
{
|
||||||
|
if (mem->Nodes[ Head ].Addr == Addr + Len)
|
||||||
|
{
|
||||||
|
Len += mem->Nodes[ Head ].Len;
|
||||||
|
node = &mem->Nodes[ Head ];
|
||||||
|
MemRemoveNode( mem, Head );
|
||||||
|
Head = mem->Head;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mem->Nodes[ Head ].Addr + mem->Nodes[ Head ].Len == Addr)
|
||||||
|
{
|
||||||
|
node = &mem->Nodes[ Head ];
|
||||||
|
Addr = mem->Nodes[ Head ].Addr;
|
||||||
|
Len += mem->Nodes[ Head ].Len;
|
||||||
|
MemRemoveNode( mem, Head );
|
||||||
|
Head = mem->Head;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Head = mem->Nodes[ Head ].Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MemAddNode( mem, Len, Addr );
|
||||||
|
|
||||||
|
#ifdef __DEBUG_MEM__
|
||||||
|
freeDebugMem( Address );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void MemFree( void * Address )
|
||||||
|
{
|
||||||
|
u32 Len;
|
||||||
|
sLLNode * node;
|
||||||
|
sLList * mem = &MainRam;
|
||||||
|
u16 Head = mem->Head;
|
||||||
|
char * Addr = (char*)Address;
|
||||||
|
|
||||||
|
Addr -= 4;
|
||||||
|
|
||||||
|
Len = *(u32*)Addr;
|
||||||
|
|
||||||
|
mem->RamUsed -= Len;
|
||||||
|
|
||||||
|
node = &mem->Nodes[ Head ];
|
||||||
|
while (Head != 0xffff)
|
||||||
|
{
|
||||||
|
if (mem->Nodes[ Head ].Addr == Addr + Len)
|
||||||
|
{
|
||||||
|
Len += mem->Nodes[ Head ].Len;
|
||||||
|
node = &mem->Nodes[ Head ];
|
||||||
|
MemRemoveNode( mem, Head );
|
||||||
|
Head = mem->Head;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mem->Nodes[ Head ].Addr + mem->Nodes[ Head ].Len == Addr)
|
||||||
|
{
|
||||||
|
node = &mem->Nodes[ Head ];
|
||||||
|
Addr = mem->Nodes[ Head ].Addr;
|
||||||
|
Len += mem->Nodes[ Head ].Len;
|
||||||
|
MemRemoveNode( mem, Head );
|
||||||
|
Head = mem->Head;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Head = mem->Nodes[ Head ].Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MemAddNode( mem, Len, Addr );
|
||||||
|
|
||||||
|
#ifdef __DEBUG_MEM__
|
||||||
|
|
||||||
|
freeDebugMem( Address );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void MemAddNode( sLList * LList, u32 Len, char * Addr )
|
||||||
|
{
|
||||||
|
u16 Head = LList->Head;
|
||||||
|
u16 Tail = LList->Tail;
|
||||||
|
u16 Node = LList->Stack[ LList->SP-- ];
|
||||||
|
|
||||||
|
MemNodeCount++;
|
||||||
|
|
||||||
|
if (Head == 0xffff && Tail == 0xffff)
|
||||||
|
{
|
||||||
|
LList->Head = Node;
|
||||||
|
LList->Tail = Node;
|
||||||
|
LList->Nodes[ Node ].Len = Len;
|
||||||
|
LList->Nodes[ Node ].Addr = Addr;
|
||||||
|
LList->Nodes[ Node ].Prev = 0xffff;
|
||||||
|
LList->Nodes[ Node ].Next = 0xffff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LList->Head = Node;
|
||||||
|
LList->Nodes[ Node ].Len = Len;
|
||||||
|
LList->Nodes[ Node ].Addr = Addr;
|
||||||
|
LList->Nodes[ Head ].Prev = Node;
|
||||||
|
LList->Nodes[ Node ].Prev = 0xffff;
|
||||||
|
LList->Nodes[ Node ].Next = Head;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void MemRemoveNode ( sLList * LList, u16 Node )
|
||||||
|
{
|
||||||
|
u16 Head = LList->Head;
|
||||||
|
u16 Tail = LList->Tail;
|
||||||
|
u16 Prev = LList->Nodes[ Node ].Prev;
|
||||||
|
u16 Next = LList->Nodes[ Node ].Next;
|
||||||
|
|
||||||
|
MemNodeCount--;
|
||||||
|
|
||||||
|
if (Head == Tail)
|
||||||
|
{
|
||||||
|
LList->Head = 0xffff;
|
||||||
|
LList->Tail = 0xffff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Node == Head)
|
||||||
|
{
|
||||||
|
LList->Head = Next;
|
||||||
|
LList->Nodes[ Next ].Prev = 0xffff;
|
||||||
|
}
|
||||||
|
else if (Node == Tail)
|
||||||
|
{
|
||||||
|
LList->Tail = Prev;
|
||||||
|
LList->Nodes[ Prev ].Next = 0xffff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LList->Nodes[ Next ].Prev = Prev;
|
||||||
|
LList->Nodes[ Prev ].Next = Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LList->Nodes[Node].Len=0;
|
||||||
|
LList->SP++;
|
||||||
|
LList->Stack[ LList->SP ] = Node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void *operator new(size_t Size, const char * name )
|
||||||
|
{
|
||||||
|
return MemAlloc( Size, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void *operator new[](size_t Size, const char * name)
|
||||||
|
{
|
||||||
|
return MemAlloc( Size, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void operator delete(void *Ptr)
|
||||||
|
{
|
||||||
|
MemFree((char*)Ptr);
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
void operator delete[](void *Ptr)
|
||||||
|
{
|
||||||
|
MemFree((char*)Ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
75
source/mem/memory.h
Normal file
75
source/mem/memory.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/**************************/
|
||||||
|
/*** Memory Alloc Stuff ***/
|
||||||
|
/**************************/
|
||||||
|
|
||||||
|
#ifndef __MEMORY_HEADER__
|
||||||
|
#define __MEMORY_HEADER__
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "system\global.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// #define __DEBUG_MEM__ // Define if you want to debug memory - TS
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define LListLen 50
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *Addr;
|
||||||
|
u32 Len;
|
||||||
|
u16 Prev;
|
||||||
|
u16 Next;
|
||||||
|
}sLLNode;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32 TotalRam;
|
||||||
|
u32 RamUsed;
|
||||||
|
|
||||||
|
u16 Head;
|
||||||
|
u16 Tail;
|
||||||
|
u16 SP;
|
||||||
|
|
||||||
|
u16 Stack[LListLen];
|
||||||
|
|
||||||
|
sLLNode Nodes[LListLen];
|
||||||
|
} sLList;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
char * MemAllocate( u32 Size, char const *Name, char const * File, int LineNumber);
|
||||||
|
|
||||||
|
void MemInit();
|
||||||
|
void DebugMemFontInit();
|
||||||
|
void MemFree(void *Addr);
|
||||||
|
|
||||||
|
void * operator new(size_t Size, const char * name = NULL);
|
||||||
|
void * operator new[](size_t Size, const char * name = NULL);
|
||||||
|
void operator delete(void *Ptr);
|
||||||
|
void operator delete[](void *Ptr);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __VERSION_DEBUG__
|
||||||
|
|
||||||
|
void dumpDebugMem();
|
||||||
|
|
||||||
|
#define MemAlloc( Size, Name ) MemAllocate( (Size), (Name), __FILE__, __LINE__ )
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MemAlloc(Size,Name) MemAllocate( (Size), NULL, NULL, 0 )
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern sLList MainRam; // Ah well!
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#endif
|
411
source/pad/pads.cpp
Normal file
411
source/pad/pads.cpp
Normal file
|
@ -0,0 +1,411 @@
|
||||||
|
/*****************/
|
||||||
|
/*** Pad Stuff ***/
|
||||||
|
/*****************/
|
||||||
|
|
||||||
|
#include <LibPad.H>
|
||||||
|
#include "system/global.h"
|
||||||
|
#include "pad/pads.H"
|
||||||
|
|
||||||
|
#ifndef __SYSTEM_GSTATE_H__
|
||||||
|
#include "system\gstate.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
static sPadConfigTable PadConfigDefault=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
0, // PAD_CFG_NONE
|
||||||
|
PAD_LEFT, // PAD_CFG_LEFT
|
||||||
|
PAD_RIGHT, // PAD_CFG_RIGHT
|
||||||
|
PAD_UP, // PAD_CFG_UP
|
||||||
|
PAD_DOWN, // PAD_CFG_DOWN
|
||||||
|
|
||||||
|
PAD_START, // PAD_CFG_START
|
||||||
|
PAD_SELECT, // PAD_CFG_SELECT
|
||||||
|
|
||||||
|
PAD_CIRCLE, // PAD_CFG_KICK
|
||||||
|
PAD_CROSS, // PAD_CFG_PUNCH
|
||||||
|
PAD_SQUARE, // PAD_CFG_JUMP
|
||||||
|
PAD_TRIANGLE, // PAD_CFG_BLOCK
|
||||||
|
PAD_L2, // PAD_CFG_RUN
|
||||||
|
PAD_R2, // PAD_CFG_SPECIAL
|
||||||
|
PAD_L1, // PAD_CFG_STEPLEFT
|
||||||
|
PAD_R1 // PAD_CFG_STEPRIGHT
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static sPadConfigTable BloodyOddPadConfigDefault=
|
||||||
|
{
|
||||||
|
{
|
||||||
|
0, // PAD_CFG_NONE
|
||||||
|
PAD_LEFT, // PAD_CFG_LEFT
|
||||||
|
PAD_RIGHT, // PAD_CFG_RIGHT
|
||||||
|
PAD_UP, // PAD_CFG_UP
|
||||||
|
PAD_DOWN, // PAD_CFG_DOWN
|
||||||
|
|
||||||
|
PAD_START, // PAD_CFG_START
|
||||||
|
PAD_SELECT, // PAD_CFG_SELECT
|
||||||
|
|
||||||
|
PAD_R2, // PAD_CFG_KICK
|
||||||
|
PAD_R1, // PAD_CFG_PUNCH
|
||||||
|
PAD_CROSS, // PAD_CFG_JUMP
|
||||||
|
PAD_L1, // PAD_CFG_BLOCK
|
||||||
|
PAD_SQUARE, // PAD_CFG_RUN
|
||||||
|
PAD_L2, // PAD_CFG_SPECIAL
|
||||||
|
PAD_TRIANGLE, // PAD_CFG_STEPLEFT
|
||||||
|
PAD_CIRCLE // PAD_CFG_STEPRIGHT
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
sPadData PadData[2];
|
||||||
|
u8 PadBuffer[2][34];
|
||||||
|
u8 PadAlign[6]={0,1,0xFF,0xFF,0xFF,0xFF};
|
||||||
|
u8 PadMotor[2][2];
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// 701
|
||||||
|
// 6 2
|
||||||
|
// 543
|
||||||
|
u16 PADAngeDirTable[16]=
|
||||||
|
{
|
||||||
|
0, // 0
|
||||||
|
(ONE/8)*0, // 1 U
|
||||||
|
(ONE/8)*2, // 2 R
|
||||||
|
(ONE/8)*1, // 3 UR
|
||||||
|
(ONE/8)*4, // 4 D
|
||||||
|
0, // 5 UD !!
|
||||||
|
(ONE/8)*3, // 6 DR
|
||||||
|
0, // 7 DUR !!
|
||||||
|
(ONE/8)*6, // 8 L
|
||||||
|
(ONE/8)*7, // 9 UL
|
||||||
|
0, // 10 LR !!
|
||||||
|
0, // 11 LUR !!
|
||||||
|
(ONE/8)*5, // 12 DL
|
||||||
|
0, // 13 LUD
|
||||||
|
0, // 14 LDR
|
||||||
|
0, // 15 LDUR
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void PadInitShock(int Port)
|
||||||
|
{
|
||||||
|
int offs,maxID,set;
|
||||||
|
|
||||||
|
if(!PadData[Port].Active)return;
|
||||||
|
|
||||||
|
// ReInit Dual Shock if required
|
||||||
|
VSync(20);
|
||||||
|
maxID = PadInfoMode(0x00,InfoModeIdTable,-1);
|
||||||
|
VSync(5);
|
||||||
|
for(offs=0;offs<maxID;offs++)
|
||||||
|
{
|
||||||
|
if( PadInfoMode(0x00,InfoModeIdTable,offs) ==7)
|
||||||
|
{
|
||||||
|
VSync(6);
|
||||||
|
PadSetMainMode(0x00,offs,2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait till it's stable
|
||||||
|
set = 0;
|
||||||
|
while(!set)
|
||||||
|
{
|
||||||
|
if(PadGetState(Port<<4) == PadStateStable)
|
||||||
|
{
|
||||||
|
if(PadInfoMode(Port,InfoModeCurExID,0))
|
||||||
|
{
|
||||||
|
PadSetAct(0x00,&PadMotor[Port][0],2);
|
||||||
|
VSync(20);
|
||||||
|
while( PadSetActAlign(0x00,PadAlign) == 0)
|
||||||
|
{
|
||||||
|
for(int ctr=0;ctr<6;ctr++)
|
||||||
|
VSync(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set = 1;
|
||||||
|
}
|
||||||
|
if(PadGetState(Port<<4) == PadStateFindCTP1)
|
||||||
|
{
|
||||||
|
set = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
sPadData *PadGet(int Port)
|
||||||
|
{
|
||||||
|
return(&PadData[Port]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void PadsInit()
|
||||||
|
{
|
||||||
|
PadClear(0);
|
||||||
|
PadClear(1);
|
||||||
|
PadInitDirect(PadBuffer[0],PadBuffer[1]);
|
||||||
|
PadStartCom();
|
||||||
|
PadInitShock(0);
|
||||||
|
PadInitShock(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u16 TranslatePadVals(u16 PadVal)
|
||||||
|
{
|
||||||
|
u16 RetVal;
|
||||||
|
|
||||||
|
RetVal = PadVal&PADLup ? PAD_UP : 0;
|
||||||
|
RetVal |= PadVal&PADLdown ? PAD_DOWN : 0;
|
||||||
|
RetVal |= PadVal&PADLleft ? PAD_LEFT : 0;
|
||||||
|
RetVal |= PadVal&PADLright ? PAD_RIGHT : 0;
|
||||||
|
RetVal |= PadVal&PADstart ? PAD_START : 0;
|
||||||
|
RetVal |= PadVal&PADselect ? PAD_SELECT : 0;
|
||||||
|
RetVal |= PadVal&PADRdown ? PAD_CROSS : 0;
|
||||||
|
RetVal |= PadVal&PADRleft ? PAD_SQUARE : 0;
|
||||||
|
RetVal |= PadVal&PADRright ? PAD_CIRCLE : 0;
|
||||||
|
RetVal |= PadVal&PADRup ? PAD_TRIANGLE : 0;
|
||||||
|
RetVal |= PadVal&PADL1 ? PAD_L1 : 0;
|
||||||
|
RetVal |= PadVal&PADL2 ? PAD_L2 : 0;
|
||||||
|
RetVal |= PadVal&PADR1 ? PAD_R1 : 0;
|
||||||
|
RetVal |= PadVal&PADR2 ? PAD_R2 : 0;
|
||||||
|
return(RetVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void PadSetVals(sPadData *Pad,u16 Val)
|
||||||
|
{
|
||||||
|
u16 Held,Old;
|
||||||
|
Val=TranslatePadVals(Val);
|
||||||
|
|
||||||
|
Old=Pad->Old=Pad->Held;
|
||||||
|
Held=Pad->Held=Val;
|
||||||
|
Pad->Down=(Held^Old)&Held;
|
||||||
|
Pad->Up=(Held^0xffff)&Old;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
const s16 AnalogThresh=64;
|
||||||
|
void Pad2Digital(sPadData *Pad)
|
||||||
|
{
|
||||||
|
u16 Button;
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
Button = ~((Pad->Button1<<8) | Pad->Button2);
|
||||||
|
// Motion
|
||||||
|
if (Pad->IsAnalogue)
|
||||||
|
{
|
||||||
|
s16 XOfs=Pad->Analog2-127;
|
||||||
|
s16 YOfs=Pad->Analog3-127;
|
||||||
|
|
||||||
|
if (XOfs<-AnalogThresh) Button|=PAD_LEFT;
|
||||||
|
else
|
||||||
|
if (XOfs>+AnalogThresh) Button|=PAD_RIGHT;
|
||||||
|
if (YOfs<-AnalogThresh) Button|=PAD_UP;
|
||||||
|
else
|
||||||
|
if (YOfs>+AnalogThresh) Button|=PAD_DOWN;
|
||||||
|
}
|
||||||
|
PadSetVals(Pad,Button);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
int PadIsDualShock(int Port)
|
||||||
|
{
|
||||||
|
return (PadData[Port].IsAnalogue==2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void ReadController(int Port)
|
||||||
|
{
|
||||||
|
u8 *PadBuf=&PadBuffer[Port][0];
|
||||||
|
sPadData *Pad=&PadData[Port];
|
||||||
|
int PortShift=Port<<4;
|
||||||
|
|
||||||
|
Pad->IsAnalogue=0;
|
||||||
|
Pad->Status=PadGetState(PortShift);
|
||||||
|
|
||||||
|
if ((Pad->Status==PadStateDiscon) || PadBuf[0])
|
||||||
|
{
|
||||||
|
Pad->Active=0;
|
||||||
|
Pad->Type=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pad->Active=1;
|
||||||
|
Pad->Type = PadBuf[1]>>4;
|
||||||
|
Pad->Button1 = PadBuf[2];
|
||||||
|
Pad->Button2 = PadBuf[3];
|
||||||
|
Pad->Analog0 = PadBuf[4];
|
||||||
|
Pad->Analog1 = PadBuf[5];
|
||||||
|
Pad->Analog2 = PadBuf[6];
|
||||||
|
Pad->Analog3 = PadBuf[7];
|
||||||
|
|
||||||
|
switch( Pad->Type )
|
||||||
|
{
|
||||||
|
case PsxPadTypeNone:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PsxPadTypeMouse: // Sony Mouse
|
||||||
|
Pad->Dx = Pad->Analog0;
|
||||||
|
Pad->Dy = Pad->Analog1;
|
||||||
|
if ( Pad->Dx & 0x80) Pad->Dx|= 0xffffff80;
|
||||||
|
if ( Pad->Dy & 0x80) Pad->Dy|= 0xffffff80;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PsxPadTypeNegiCon: // Namco negCon
|
||||||
|
// Steering wheel
|
||||||
|
// Sankyo Pachinko controler
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PsxPadTypeKonamiGun: // Light Gun
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PsxPadTypeStandard: // Standard Sony PAD controller
|
||||||
|
// Pad->Motor0=PadMotor[Port][0];
|
||||||
|
// Pad->Motor1=PadMotor[Port][1];
|
||||||
|
Pad2Digital(Pad);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PsxPadTypeAnalogStick:
|
||||||
|
case PsxPadTypeAnalogController:// Analog 2-stick
|
||||||
|
|
||||||
|
if (PadInfoMode(0,InfoModeCurExID,0)==7)
|
||||||
|
Pad->IsAnalogue=2;
|
||||||
|
else
|
||||||
|
Pad->IsAnalogue=1;
|
||||||
|
|
||||||
|
// Set vibration values ( motor 0 is 0..1, motor 1 is 0..255 )
|
||||||
|
// Pad->Motor0 = s_vibData[ Port ].CurrentIntensityValue & 1;
|
||||||
|
// Pad->Motor1 = (s_vibData[ Port ].CurrentIntensityValue >> 1) & 0xff;
|
||||||
|
|
||||||
|
Pad2Digital(Pad);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PsxPadTypeNamcoGun:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Pad->Status == PadStateFindPad)
|
||||||
|
{
|
||||||
|
Pad->Send = 0;
|
||||||
|
}
|
||||||
|
if ( Pad->Send==0 )
|
||||||
|
{
|
||||||
|
printf("%d,%d\n",Pad->Motor0,Pad->Motor1);
|
||||||
|
|
||||||
|
PadSetAct(PortShift,&(Pad->Motor0),2);
|
||||||
|
|
||||||
|
if (Pad->Status == PadStateFindCTP1)
|
||||||
|
{
|
||||||
|
Pad->Send = 1;
|
||||||
|
}
|
||||||
|
if (Pad->Status == PadStateStable)
|
||||||
|
{
|
||||||
|
if (PadSetActAlign(PortShift,PadAlign)) Pad->Send = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u16 PadGetUp(int Port)
|
||||||
|
{
|
||||||
|
return(PadData[Port].Up);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u16 PadGetDown(int Port)
|
||||||
|
{
|
||||||
|
return(PadData[Port].Down);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u16 PadGetHeld(int Port)
|
||||||
|
{
|
||||||
|
return(PadData[Port].Held);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void PadClear(int Port)
|
||||||
|
{
|
||||||
|
PadData[Port].Up=PadData[Port].Down=PadData[Port].Held=PadData[Port].Old=0;
|
||||||
|
PadData[Port].Dx=PadData[Port].Dy=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void PadUpdate()
|
||||||
|
{
|
||||||
|
PadData[0].Dx= PadData[1].Dx=0;
|
||||||
|
PadData[0].Dy= PadData[1].Dy=0;
|
||||||
|
PadData[0].Dx1=PadData[1].Dx1=0;
|
||||||
|
PadData[0].Dy1=PadData[1].Dy1=0;
|
||||||
|
|
||||||
|
ReadController(0);
|
||||||
|
ReadController(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u16 PadGetPadAngle(u16 Pad, s16 angleAdjust)
|
||||||
|
{
|
||||||
|
return((PADAngeDirTable[Pad>>PAD_DIR_SHIFT]+((ONE/4)*2)+angleAdjust)&(ONE-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
bool PadIsConnected(int port)
|
||||||
|
{
|
||||||
|
sPadData *pad=&PadData[port];
|
||||||
|
|
||||||
|
return pad->Status!=PadStateDiscon&&pad->Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
sPadConfigTable *getPadConfigTable(int _padConfig)
|
||||||
|
{
|
||||||
|
if(_padConfig==0)return &PadConfigDefault;
|
||||||
|
if(_padConfig==1)return &BloodyOddPadConfigDefault;
|
||||||
|
ASSERT(0);
|
||||||
|
return &PadConfigDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
CPadConfig::CPadConfig()
|
||||||
|
{
|
||||||
|
Cfg=&PadConfigDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPadConfig::SetConfig(sPadConfigTable *NewCfg)
|
||||||
|
{
|
||||||
|
Cfg=NewCfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CPadConfig::GetButton(PAD_CFG But)
|
||||||
|
{
|
||||||
|
return(Cfg->Buttons[But]);
|
||||||
|
}
|
149
source/pad/pads.h
Normal file
149
source/pad/pads.h
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
/*****************/
|
||||||
|
/*** Pad Stuff ***/
|
||||||
|
/*****************/
|
||||||
|
|
||||||
|
#ifndef __PADS_H__
|
||||||
|
#define __PADS_H__
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define DUALSHOCKMODE ((u_long *)0x80010000)
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define PsxPadTypeNone 0
|
||||||
|
#define PsxPadTypeMouse 1
|
||||||
|
#define PsxPadTypeNegiCon 2
|
||||||
|
#define PsxPadTypeKonamiGun 3
|
||||||
|
#define PsxPadTypeStandard 4
|
||||||
|
#define PsxPadTypeAnalogStick 5
|
||||||
|
#define PsxPadTypeNamcoGun 6
|
||||||
|
#define PsxPadTypeAnalogController 7
|
||||||
|
|
||||||
|
#define PAD_UP PADLup
|
||||||
|
#define PAD_DOWN PADLdown
|
||||||
|
#define PAD_LEFT PADLleft
|
||||||
|
#define PAD_RIGHT PADLright
|
||||||
|
#define PAD_SELECT PADselect
|
||||||
|
#define PAD_START PADstart
|
||||||
|
#define PAD_CROSS PADRdown
|
||||||
|
#define PAD_SQUARE PADRleft
|
||||||
|
#define PAD_CIRCLE PADRright
|
||||||
|
#define PAD_TRIANGLE PADRup
|
||||||
|
#define PAD_L1 PADL1
|
||||||
|
#define PAD_L2 PADL2
|
||||||
|
#define PAD_R1 PADR1
|
||||||
|
#define PAD_R2 PADR2
|
||||||
|
|
||||||
|
#define PAD_BUTTONS (PAD_CROSS|PAD_SQUARE|PAD_CIRCLE|PAD_TRIANGLE|PAD_L1|PAD_L2|PAD_R1|PAD_R2)
|
||||||
|
#define PAD_ALL_DIRS (PAD_UP|PAD_DOWN|PAD_LEFT|PAD_RIGHT)
|
||||||
|
#define PAD_DIR_SHIFT 12
|
||||||
|
|
||||||
|
#define BUTTON_SELECT PAD_CROSS
|
||||||
|
#define BUTTON_BACK PAD_TRIANGLE
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u16 Up,Held,Down,Old;
|
||||||
|
int XPos, YPos, XPos1, YPos1; // For analog
|
||||||
|
int Dx,Dy, Dx1,Dy1;
|
||||||
|
u8 Status; // These 8 values are obtained
|
||||||
|
u8 Type; // directly from the controller
|
||||||
|
u8 Button1; // buffer we installed with InitPAD.
|
||||||
|
u8 Button2;
|
||||||
|
u8 Analog0;
|
||||||
|
u8 Analog1;
|
||||||
|
u8 Analog2;
|
||||||
|
u8 Analog3;
|
||||||
|
u8 Motor0,Motor1; // Analog
|
||||||
|
u8 Send;
|
||||||
|
u8 IsAnalogue;
|
||||||
|
bool Active;
|
||||||
|
} sPadData;
|
||||||
|
|
||||||
|
struct VIBE_DATA
|
||||||
|
{
|
||||||
|
int frame;
|
||||||
|
int amplitude;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define VIBE( a, b ) { a, b }
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void PadsInit();
|
||||||
|
void PadClear(int Port);
|
||||||
|
void PadUpdate();
|
||||||
|
|
||||||
|
sPadData *PadGet(int Port);
|
||||||
|
|
||||||
|
u16 PadGetUp(int Port);
|
||||||
|
u16 PadGetDown(int Port);
|
||||||
|
u16 PadGetHeld(int Port);
|
||||||
|
u16 PadGetTick(int Port);
|
||||||
|
|
||||||
|
int PadIsDualShock(int Port);
|
||||||
|
|
||||||
|
u16 PadGetPadAngle(u16 Pad, s16 angleAdjust);
|
||||||
|
|
||||||
|
bool PadIsConnected(int port);
|
||||||
|
|
||||||
|
bool PAD_IsRumbling( int port );
|
||||||
|
void PAD_SetVibrationEnvelope( int Port, int count, const VIBE_DATA * data, int ferocity=255 );
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define PAD_ACCEPT PAD_CROSS
|
||||||
|
#define PAD_CANCEL PAD_TRIANGLE
|
||||||
|
#define PAD_UI_LEFT PAD_LEFT
|
||||||
|
#define PAD_UI_RIGHT PAD_RIGHT
|
||||||
|
#define PAD_UI_UP PAD_UP
|
||||||
|
#define PAD_UI_DOWN PAD_DOWN
|
||||||
|
|
||||||
|
enum PAD_CFG
|
||||||
|
{
|
||||||
|
PAD_CFG_NONE=0,
|
||||||
|
|
||||||
|
PAD_CFG_LEFT,
|
||||||
|
PAD_CFG_RIGHT,
|
||||||
|
PAD_CFG_UP,
|
||||||
|
PAD_CFG_DOWN,
|
||||||
|
|
||||||
|
PAD_CFG_START,
|
||||||
|
PAD_CFG_SELECT,
|
||||||
|
|
||||||
|
PAD_CFG_KICK, // CIRCLE
|
||||||
|
PAD_CFG_PUNCH, // CROSS
|
||||||
|
PAD_CFG_JUMP, // SQUARE
|
||||||
|
PAD_CFG_BLOCK, // TRIANGLE
|
||||||
|
PAD_CFG_RUN, // L2
|
||||||
|
PAD_CFG_SPECIAL, // R2
|
||||||
|
PAD_CFG_STEPLEFT, // L1
|
||||||
|
PAD_CFG_STEPRIGHT, // R1
|
||||||
|
|
||||||
|
PAD_CFG_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sPadConfigTable
|
||||||
|
{
|
||||||
|
u16 Buttons[PAD_CFG_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
class CPadConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPadConfig();
|
||||||
|
void SetConfig(sPadConfigTable *NewCfg);
|
||||||
|
int GetButton(PAD_CFG But);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sPadConfigTable *Cfg;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern sPadConfigTable *getPadConfigTable(int _padConfig);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#endif
|
338
source/sound/cdxa.cpp
Normal file
338
source/sound/cdxa.cpp
Normal file
|
@ -0,0 +1,338 @@
|
||||||
|
/*****************************/
|
||||||
|
/*** PSX CDXA Player Stuff ***/
|
||||||
|
/*** Another one by Dave ***/
|
||||||
|
/*****************************/
|
||||||
|
|
||||||
|
// Note, need to add blanks in between tracks
|
||||||
|
#include "system\global.h"
|
||||||
|
#include "fileio/fileio.h"
|
||||||
|
#include "fileio/filetab.h"
|
||||||
|
#include "sound\cdxa.h"
|
||||||
|
|
||||||
|
#include <libcd.h>
|
||||||
|
#include <libsnd.h>
|
||||||
|
|
||||||
|
#ifndef __SOUND_SNDBANK_H__
|
||||||
|
#include "sound\sndbank.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Add this to have CDXA on PC build!!
|
||||||
|
// You will need a CD with Track1 synced to something, oh, and a CD drive
|
||||||
|
#if defined(__USER_paul__)//|| defined(__USER_daveo__)
|
||||||
|
#define FORCE_XA 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __FILE_SYSTEM__==CD | FORCE_XA
|
||||||
|
#define ENABLE_XA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__USER_CDBUILD__)
|
||||||
|
#undef FORCE_XA
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
XA_MODE CXAStream::Mode=XA_MODE_NOTINIT;
|
||||||
|
int CXAStream::Status;
|
||||||
|
int CXAStream::StartSector;
|
||||||
|
sXAStream CXAStream::Stream[XA_STREAM_MAX];
|
||||||
|
int CXAStream::CurrentStream;
|
||||||
|
int CXAStream::PauseFlag;
|
||||||
|
|
||||||
|
// Speech
|
||||||
|
SpeechEquate CXAStream::Queue[XA_QUEUE_MAX];
|
||||||
|
u16 CXAStream::QueueCount;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void XACDReadyCallback(int Intr, u8 *Result)
|
||||||
|
{
|
||||||
|
static int ErrorRetry;
|
||||||
|
u32 XABuffer[8];
|
||||||
|
u16 ID,Track;
|
||||||
|
sXAStream &ThisStream=CXAStream::Stream[CXAStream::CurrentStream];
|
||||||
|
|
||||||
|
CXAStream::Status=Intr;
|
||||||
|
if (CXAStream::Mode==XA_MODE_IDLE) return;
|
||||||
|
|
||||||
|
switch (Intr)
|
||||||
|
{
|
||||||
|
case CdlNoIntr:
|
||||||
|
break;
|
||||||
|
case CdlDataReady:
|
||||||
|
// Check end of XA using video termination
|
||||||
|
ErrorRetry=0;
|
||||||
|
CdGetSector((u_long *)XABuffer,8);
|
||||||
|
ID = *(unsigned short *)(XABuffer+3);
|
||||||
|
Track = *((unsigned short *)(XABuffer+3)+1);
|
||||||
|
Track = (Track&31744)>>10;
|
||||||
|
if (Track==0)
|
||||||
|
{
|
||||||
|
ThisStream.Entry.CurrentSector++; // track position
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ID==352)
|
||||||
|
{
|
||||||
|
if (Track==ThisStream.Entry.Channel)
|
||||||
|
{
|
||||||
|
// DbgMsg0("TrackEnd\n");
|
||||||
|
CXAStream::SetVolumeOff();
|
||||||
|
CdControlF(CdlPause,0);
|
||||||
|
CXAStream::Mode=XA_MODE_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CdlComplete:
|
||||||
|
break;
|
||||||
|
case CdlAcknowledge:
|
||||||
|
break;
|
||||||
|
case CdlDataEnd:
|
||||||
|
break;
|
||||||
|
case CdlDiskError:
|
||||||
|
if (!ErrorRetry)
|
||||||
|
{
|
||||||
|
ErrorRetry=25;
|
||||||
|
// CXAStream::Mode=XA_MODE_RESUME;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ErrorRetry--;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Init()
|
||||||
|
{
|
||||||
|
#ifdef FORCE_XA
|
||||||
|
DbgMsg0("FORCE XA\n");
|
||||||
|
while (!CdInit());
|
||||||
|
CFileIO::FindAllFilePos();
|
||||||
|
CXAStream::SetSector(CFileIO::GetFilePos(FILEPOS_TRACK1));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
DBG_MSG0("XA INITIALISED");
|
||||||
|
|
||||||
|
// Set defaults
|
||||||
|
CurrentStream=XA_STREAM_MUSIC;
|
||||||
|
Stream[XA_STREAM_MUSIC].BaseChannel =XA_MUSIC_TRACK;
|
||||||
|
Stream[XA_STREAM_SPEECH].BaseChannel=XA_SPEECH_TRACK;
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Start(int Str,u32 Sector,u32 Channel,s32 LVol,s32 RVol)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_XA
|
||||||
|
if (Mode==XA_MODE_NOTINIT) Init();
|
||||||
|
|
||||||
|
sXAStream &ThisStream=Stream[Str];
|
||||||
|
SetVolumeOff();
|
||||||
|
CdControlF(CdlPause,0);
|
||||||
|
CurrentStream=Str;
|
||||||
|
ThisStream.Entry.StartSector=Sector;
|
||||||
|
ThisStream.Entry.CurrentSector=Sector;
|
||||||
|
ThisStream.Entry.Channel=Channel+ThisStream.BaseChannel;
|
||||||
|
ThisStream.Entry.LVol=LVol;
|
||||||
|
ThisStream.Entry.RVol=RVol;
|
||||||
|
Mode=XA_MODE_START;
|
||||||
|
CdReadyCallback((CdlCB)XACDReadyCallback);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Stop()
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
Mode=XA_MODE_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::PlayMusic(u32 TrackNo)
|
||||||
|
{
|
||||||
|
Start(XA_STREAM_MUSIC,0,0,XA_DEFAULT_VOL,XA_DEFAULT_VOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void CXAStream::PlaySpeech(SpeechEquate SpeechNo,int ForcePlay)
|
||||||
|
{
|
||||||
|
u32 Channel=SpeechNo>>XA_CHANNEL_SHIFT;
|
||||||
|
u32 Speech=SpeechNo & XA_SPEECH_MASK;
|
||||||
|
u32 Sector=Speech*XA_TRACK_MAX;
|
||||||
|
|
||||||
|
if (CurrentStream==XA_STREAM_SPEECH && Mode==XA_MODE_PLAY && !ForcePlay)
|
||||||
|
{
|
||||||
|
// Check Current
|
||||||
|
if (Stream[CurrentStream].Entry.Channel==Channel && Stream[CurrentStream].Entry.StartSector==Sector) return;
|
||||||
|
// Check Queue
|
||||||
|
if (QueueCount>=(int)XA_QUEUE_MAX) return;
|
||||||
|
for (int Loop=0;Loop<QueueCount ; Loop++) if (Queue[Loop]==SpeechNo) return;
|
||||||
|
Queue[QueueCount++]=SpeechNo;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetVolumeOff();
|
||||||
|
Start(XA_STREAM_SPEECH,Sector,Channel,XA_DEFAULT_VOL,XA_DEFAULT_VOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Pause()
|
||||||
|
{
|
||||||
|
Mode=XA_MODE_PAUSE;
|
||||||
|
PauseFlag=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Resume()
|
||||||
|
{
|
||||||
|
if (PauseFlag)
|
||||||
|
{
|
||||||
|
Mode=XA_MODE_RESUME;
|
||||||
|
PauseFlag=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::ControlXA()
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_XA
|
||||||
|
CdlFILTER theFilter;
|
||||||
|
u8 Cmd[4];
|
||||||
|
sXAStream &ThisStream=Stream[CurrentStream];
|
||||||
|
|
||||||
|
switch(Mode)
|
||||||
|
{
|
||||||
|
case XA_MODE_IDLE:
|
||||||
|
break;
|
||||||
|
case XA_MODE_RESUME:
|
||||||
|
Status=0;
|
||||||
|
case XA_MODE_START:
|
||||||
|
SetVolumeOff();
|
||||||
|
Cmd[0] = CdlModeSpeed|CdlModeRT|CdlModeSF|CdlModeSize1;
|
||||||
|
CdControlB(CdlSetmode,Cmd, 0);
|
||||||
|
CdIntToPos(ThisStream.Entry.CurrentSector+StartSector,&ThisStream.CDPos);
|
||||||
|
theFilter.file=1;
|
||||||
|
// theFilter.chan=ThisStream.BaseChannel+ThisStream.Entry.Channel;
|
||||||
|
theFilter.chan=ThisStream.Entry.Channel;
|
||||||
|
CdControlF(CdlSetfilter, (u8*)&theFilter);
|
||||||
|
CdControlF(CdlReadS,(u8*)&ThisStream.CDPos);
|
||||||
|
Mode=XA_MODE_PLAY;
|
||||||
|
break;
|
||||||
|
case XA_MODE_PLAY:
|
||||||
|
if (Status==CdlDiskError) Mode=XA_MODE_RESUME;
|
||||||
|
SetVolume(XA_DEFAULT_VOL,XA_DEFAULT_VOL);
|
||||||
|
break;
|
||||||
|
case XA_MODE_END:
|
||||||
|
SetVolumeOff();
|
||||||
|
if (CurrentStream==XA_STREAM_SPEECH)
|
||||||
|
{
|
||||||
|
if (QueueCount)
|
||||||
|
{
|
||||||
|
PlaySpeech(Queue[0]);
|
||||||
|
for (int Loop=0;Loop<(int)XA_QUEUE_MAX-1;Loop++) Queue[Loop]=Queue[Loop+1]; // shuffle queue in a crap way!!
|
||||||
|
QueueCount--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mode=XA_MODE_PAUSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ThisStream.Entry.CurrentSector=ThisStream.Entry.StartSector;
|
||||||
|
Mode=XA_MODE_START;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XA_MODE_PAUSE:
|
||||||
|
SetVolumeOff();
|
||||||
|
CdControlF(CdlPause,0);
|
||||||
|
Mode=XA_MODE_IDLE;
|
||||||
|
break;
|
||||||
|
case XA_MODE_STOP:
|
||||||
|
ThisStream.Entry.CurrentSector=ThisStream.Entry.StartSector;
|
||||||
|
SetVolumeOff();
|
||||||
|
CdControlF(CdlPause,0);
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Interrupt()
|
||||||
|
{
|
||||||
|
Mode=XA_MODE_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::Reset()
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_XA
|
||||||
|
SetVolumeOff();
|
||||||
|
// if (Mode!=XA_MODE_NOTINIT)
|
||||||
|
{
|
||||||
|
CdControlF(CdlPause,0);
|
||||||
|
Mode=XA_MODE_IDLE;
|
||||||
|
}
|
||||||
|
// Clear Queue
|
||||||
|
for (int Loop=0;Loop<(int)XA_QUEUE_MAX; Loop++) Queue[Loop]=0;
|
||||||
|
QueueCount=0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::SetVolume(s32 LVol,s32 RVol)
|
||||||
|
{
|
||||||
|
CdlATV CDVol;
|
||||||
|
SpuCommonAttr Attr;
|
||||||
|
int VolumeSetting;
|
||||||
|
|
||||||
|
if (CurrentStream==XA_STREAM_SPEECH)
|
||||||
|
VolumeSetting=CSfxFactory::SNDVOL_SFX;
|
||||||
|
else
|
||||||
|
VolumeSetting=CSfxFactory::SNDVOL_MUSIC;
|
||||||
|
|
||||||
|
LVol=(LVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256;
|
||||||
|
RVol=(RVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256;
|
||||||
|
Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX);
|
||||||
|
Attr.cd.volume.left =LVol;
|
||||||
|
Attr.cd.volume.right=RVol;
|
||||||
|
Attr.cd.mix=SPU_ON;
|
||||||
|
SpuSetCommonAttr(&Attr);
|
||||||
|
CDVol.val0 = 127; // CdL -> SpuL
|
||||||
|
CDVol.val1 = 127; // CdL -> SpuR
|
||||||
|
CDVol.val2 = 127; // CdR -> SpuR
|
||||||
|
CDVol.val3 = 127; // CdR -> SpuL
|
||||||
|
CdMix(&CDVol);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::SetVolumeOff()
|
||||||
|
{
|
||||||
|
CdlATV CDVol;
|
||||||
|
SpuCommonAttr Attr;
|
||||||
|
// SsSetSerialVol(SS_SERIAL_A,0,0);
|
||||||
|
|
||||||
|
|
||||||
|
Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX);
|
||||||
|
Attr.cd.volume.left =0;
|
||||||
|
Attr.cd.volume.right=0;
|
||||||
|
Attr.cd.mix=SPU_ON;
|
||||||
|
SpuSetCommonAttr(&Attr);
|
||||||
|
CDVol.val0 = 0; // CdL -> SpuL
|
||||||
|
CDVol.val1 = 0; // CdL -> SpuR
|
||||||
|
CDVol.val2 = 0; // CdR -> SpuR
|
||||||
|
CDVol.val3 = 0; // CdR -> SpuL
|
||||||
|
CdMix(&CDVol);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
113
source/sound/cdxa.h
Normal file
113
source/sound/cdxa.h
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
/*****************************/
|
||||||
|
/*** PSX CDXA Player Stuff ***/
|
||||||
|
/*** Another one by Dave ***/
|
||||||
|
/*****************************/
|
||||||
|
|
||||||
|
#ifndef __CDXAHeader__
|
||||||
|
#define __CDXAHeader__
|
||||||
|
|
||||||
|
#include "sound/Speech.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
enum XA_ENUM
|
||||||
|
{
|
||||||
|
XA_MUSIC_TRACK =1,
|
||||||
|
XA_SPEECH_TRACK =2,
|
||||||
|
XA_QUEUE_MAX =8,
|
||||||
|
XA_TRACK_MAX =32,
|
||||||
|
XA_DEFAULT_VOL =32000,
|
||||||
|
XA_CHANNEL_SHIFT =16,
|
||||||
|
XA_CHANNEL_MASK =(0xffffffff<<XA_CHANNEL_SHIFT),
|
||||||
|
XA_SPEECH_MASK =(0xffffffff-XA_CHANNEL_MASK),
|
||||||
|
};
|
||||||
|
|
||||||
|
enum XA_STREAMS
|
||||||
|
{
|
||||||
|
XA_STREAM_MUSIC=0,
|
||||||
|
XA_STREAM_SPEECH,
|
||||||
|
|
||||||
|
XA_STREAM_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
enum XA_MODE
|
||||||
|
{
|
||||||
|
XA_MODE_NOTINIT=-1,
|
||||||
|
XA_MODE_IDLE=0,
|
||||||
|
XA_MODE_START,
|
||||||
|
XA_MODE_PLAY,
|
||||||
|
XA_MODE_END,
|
||||||
|
XA_MODE_PAUSE,
|
||||||
|
XA_MODE_RESUME,
|
||||||
|
XA_MODE_STOP,
|
||||||
|
};
|
||||||
|
struct sXAEntry
|
||||||
|
{
|
||||||
|
u32 Channel;
|
||||||
|
u32 StartSector,CurrentSector;
|
||||||
|
s32 LVol,RVol;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sXAStream
|
||||||
|
{
|
||||||
|
int BaseChannel;
|
||||||
|
sXAEntry Entry;
|
||||||
|
// int Volume;
|
||||||
|
CdlLOC CDPos;
|
||||||
|
} ;
|
||||||
|
/*
|
||||||
|
struct sXAStream
|
||||||
|
{
|
||||||
|
int BaseChannel,Channel;
|
||||||
|
// int Volume;
|
||||||
|
int CurrentSector;
|
||||||
|
CdlLOC CDPos;
|
||||||
|
} ;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
class CXAStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CXAStream(){};
|
||||||
|
~CXAStream(){};
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
static void Start(int Str,u32 Sector,u32 Channel,s32 LVol,s32 RVol);
|
||||||
|
static void Stop();
|
||||||
|
|
||||||
|
static void PlayMusic(u32 Track);
|
||||||
|
static void StopMusic() {Stop();}
|
||||||
|
static void PlaySpeech(SpeechEquate SpeechNo,int ForcePlay=0);
|
||||||
|
static void StopSpeech() {Stop();}
|
||||||
|
|
||||||
|
static void ControlXA();
|
||||||
|
static void SetVolumeOff();
|
||||||
|
static void SetVolume(s32 LVol,s32 RVol);
|
||||||
|
static void Interrupt();
|
||||||
|
static void Pause();
|
||||||
|
static void Resume();
|
||||||
|
static void SetSector(u32 Sector) {StartSector=Sector;}
|
||||||
|
static void SetLanguage(int Lang) {Stream[XA_STREAM_SPEECH].BaseChannel=XA_SPEECH_TRACK+Lang;}
|
||||||
|
|
||||||
|
static void Reset();
|
||||||
|
static int IsPlaying() {return(Mode==XA_MODE_PLAY);}
|
||||||
|
static XA_MODE Mode;
|
||||||
|
static int Status;
|
||||||
|
static int StartSector;
|
||||||
|
static sXAStream Stream[XA_STREAM_MAX];
|
||||||
|
static int CurrentStream;
|
||||||
|
static int PauseFlag;
|
||||||
|
|
||||||
|
static int CurrentChannel;
|
||||||
|
|
||||||
|
// Speech
|
||||||
|
static SpeechEquate Queue[XA_QUEUE_MAX];
|
||||||
|
static u16 QueueCount;
|
||||||
|
static int SpeechChannel;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
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
|
84
source/utils/cmxmacro.h
Normal file
84
source/utils/cmxmacro.h
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*********************/
|
||||||
|
/*** Climax Macros ***/
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
#ifndef __CMX_MACROS_HEADER__
|
||||||
|
#define __CMX_MACROS_HEADER__
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
// Get the summed magnitude of the vector XYZ (after sqr)
|
||||||
|
#define CMX_StVecXYZMag(r0) __asm__ volatile ( \
|
||||||
|
"mfc2 $12, $25;" \
|
||||||
|
"mfc2 $13, $26;" \
|
||||||
|
"mfc2 $14, $27;" \
|
||||||
|
"add $12, $12, $13;" \
|
||||||
|
"add $12, $12, $14;" \
|
||||||
|
"sw $12, 0( %0 );" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ) \
|
||||||
|
: "$12", "$13", "$14", "memory" )
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
// Get the summed magnitude of the vector XZ (after sqr)
|
||||||
|
#define CMX_StVecXZMag(r0) __asm__ volatile ( \
|
||||||
|
"mfc2 $12, $25;" \
|
||||||
|
"mfc2 $13, $27;" \
|
||||||
|
"add $12, $12, $13;" \
|
||||||
|
"sw $12, 0( %0 );" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ) \
|
||||||
|
: "$12", "$13", "memory" )
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
// Load IR0,IR1,IR2 with values (for SQR)
|
||||||
|
#define CMX_ldXYZ(r0,r1,r2) __asm__ ( \
|
||||||
|
"mtc2 %0,$9;" \
|
||||||
|
"mtc2 %1,$10;" \
|
||||||
|
"mtc2 %2,$11" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ),"r"( r1 ),"r"( r2 ) )
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
// Load IR0,IR1,IR2 with values (for SQR)
|
||||||
|
#define CMX_ldXZ(r0,r1) __asm__ ( \
|
||||||
|
"mtc2 %0,$9;" \
|
||||||
|
"mtc2 %1,$11" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ),"r"( r1 ))
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** Smaller Translation Macros (no return flags) ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define CMX_RotTransPers(r1,r2) \
|
||||||
|
{ gte_ldv0(r1); \
|
||||||
|
gte_rtps(); \
|
||||||
|
gte_stsxy(r2); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define CMX_RotTransPers3(r1,r2,r3,r4,r5,r6) \
|
||||||
|
{ gte_ldv3(r1,r2,r3); \
|
||||||
|
gte_rtpt(); \
|
||||||
|
gte_stsxy3(r4,r5,r6); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define CMX_RotTransPers4(r1,r2,r3,r4,r5,r6,r7,r8) \
|
||||||
|
{ gte_ldv0(r4); \
|
||||||
|
gte_rtps(); \
|
||||||
|
gte_ldv3(r1,r2,r3); \
|
||||||
|
gte_stsxy(r8); \
|
||||||
|
gte_rtpt(); \
|
||||||
|
gte_stsxy3(r5,r6,r7); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define CMX_RotTrans(r1,r2) \
|
||||||
|
{ gte_ldv0(r1); \
|
||||||
|
gte_rt(); \
|
||||||
|
gte_stlvnl(r2); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#endif
|
30
source/utils/fixed.h
Normal file
30
source/utils/fixed.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*******************/
|
||||||
|
/*** Fixed Stupg ***/
|
||||||
|
/*******************/
|
||||||
|
|
||||||
|
#ifndef __DAVES_FIXED__
|
||||||
|
#define __DAVES_FIXED__
|
||||||
|
|
||||||
|
#include "system/global.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef s32 Fixed;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define FixedShift 16
|
||||||
|
#define FixedMultFactor (1<<FixedShift)
|
||||||
|
#define FixedIntMask (0xffffffff<<FixedShift)
|
||||||
|
#define FixedFractMask ((0xffffffff-FixedIntMask)/* | 0x80000000*/) // save sign bit
|
||||||
|
|
||||||
|
#define FixedInt(Fixed) (Fixed & FixedIntMask)
|
||||||
|
#define FixedFract(Fixed) (Fixed & FixedFractMask)
|
||||||
|
|
||||||
|
#define Fixed2NumQ(Fixed) (*((s16*)&Fixed+1))
|
||||||
|
#define Num2Fixed(Num) ((s32)Num*FixedMultFactor)
|
||||||
|
#define Fixed2Num(Fixed) ((s16)(Fixed>>FixedShift))
|
||||||
|
|
||||||
|
#define FixedMult(a,b) ((a*b)>>FixedShift)
|
||||||
|
#define FixedMult2(a,b) ((a>>(FixedShift/2))*(b>>(FixedShift/2)))
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#endif
|
11
source/utils/mathmip.h
Normal file
11
source/utils/mathmip.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/*****************/
|
||||||
|
/*** Math Mips ***/
|
||||||
|
/*****************/
|
||||||
|
|
||||||
|
#ifndef __MISCMIP_HEADER__
|
||||||
|
#define __MISCMIP_HEADER__
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern "C" s32 FixedMul(s32 a, s32 b);
|
||||||
|
|
||||||
|
#endif
|
95
source/utils/mathtab.H
Normal file
95
source/utils/mathtab.H
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/*************************/
|
||||||
|
/*** Math Table Header ***/
|
||||||
|
/*************************/
|
||||||
|
|
||||||
|
#ifndef __MATHTABLE_HEADER__
|
||||||
|
#define __MATHTABLE_HEADER__
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "system\global.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern VECTOR upVec;
|
||||||
|
|
||||||
|
extern const s16 ACosTable[4097];
|
||||||
|
extern const s16 SinTable[1024];
|
||||||
|
extern const s32 OneSinTable[1024];
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline s32 macos(const s32 &a)
|
||||||
|
{
|
||||||
|
return(ACosTable[a>>1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
inline s32 msin(const s32 &a)
|
||||||
|
{
|
||||||
|
if (a>3071)
|
||||||
|
{
|
||||||
|
return(-SinTable[1023 - (a&1023)]);
|
||||||
|
} else
|
||||||
|
if (a>2047)
|
||||||
|
{
|
||||||
|
return(-SinTable[a&1023]);
|
||||||
|
} else
|
||||||
|
if (a>1023)
|
||||||
|
{
|
||||||
|
return(SinTable[1023 - (a&1023)]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return(SinTable[a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
inline s32 mcos(const s32 &a)
|
||||||
|
{
|
||||||
|
if (a>3071)
|
||||||
|
{
|
||||||
|
return(SinTable[(a&1023)]);
|
||||||
|
} else
|
||||||
|
if (a>2047)
|
||||||
|
{
|
||||||
|
return(-SinTable[1023 - (a&1023)]);
|
||||||
|
} else
|
||||||
|
if (a>1023)
|
||||||
|
{
|
||||||
|
return(-SinTable[a&1023]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return(SinTable[1023 - a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
inline s32 monesin(const s32 &a)
|
||||||
|
{
|
||||||
|
if (a>3071)
|
||||||
|
{
|
||||||
|
return(-OneSinTable[1024 - (a&1023)]);
|
||||||
|
} else
|
||||||
|
if (a>2047)
|
||||||
|
{
|
||||||
|
return(-OneSinTable[a&1023]);
|
||||||
|
} else
|
||||||
|
if (a>1023)
|
||||||
|
{
|
||||||
|
return(OneSinTable[1024 - (a&1023)]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return(OneSinTable[a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*
|
||||||
|
#define msin(x) rsin((x))
|
||||||
|
#define mcos(x) rcos((x))
|
||||||
|
#define monesin(x) (((s32)4096<<12)/rsin((x)))
|
||||||
|
*/
|
||||||
|
#endif
|
8
source/utils/replace.h
Normal file
8
source/utils/replace.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef __REPLACE_H__
|
||||||
|
#define __REPLACE_H__
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" void MCmemcpy(void *Dst,void *Src,int Length);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
403
source/utils/sincos.cpp
Normal file
403
source/utils/sincos.cpp
Normal file
|
@ -0,0 +1,403 @@
|
||||||
|
/********************/
|
||||||
|
/*** SinCos Table ***/
|
||||||
|
/********************/
|
||||||
|
|
||||||
|
#include "system\global.h"
|
||||||
|
|
||||||
|
VECTOR upVec = { 0, ONE, 0, 0 };
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
s16 ACosTable[4097] = {
|
||||||
|
2047 ,2027 ,2019 ,2012 ,2007 ,2002 ,1998 ,1994 ,1990 ,1986 ,1983 ,1980 ,1977 ,1974 ,1971 ,1969 ,
|
||||||
|
1966 ,1963 ,1961 ,1959 ,1956 ,1954 ,1952 ,1950 ,1948 ,1946 ,1944 ,1942 ,1940 ,1938 ,1936 ,1934 ,
|
||||||
|
1932 ,1930 ,1929 ,1927 ,1925 ,1923 ,1922 ,1920 ,1918 ,1917 ,1915 ,1914 ,1912 ,1911 ,1909 ,1908 ,
|
||||||
|
1906 ,1905 ,1903 ,1902 ,1900 ,1899 ,1897 ,1896 ,1895 ,1893 ,1892 ,1891 ,1889 ,1888 ,1887 ,1885 ,
|
||||||
|
1884 ,1883 ,1882 ,1880 ,1879 ,1878 ,1877 ,1875 ,1874 ,1873 ,1872 ,1871 ,1869 ,1868 ,1867 ,1866 ,
|
||||||
|
1865 ,1864 ,1862 ,1861 ,1860 ,1859 ,1858 ,1857 ,1856 ,1855 ,1854 ,1852 ,1851 ,1850 ,1849 ,1848 ,
|
||||||
|
1847 ,1846 ,1845 ,1844 ,1843 ,1842 ,1841 ,1840 ,1839 ,1838 ,1837 ,1836 ,1835 ,1834 ,1833 ,1832 ,
|
||||||
|
1831 ,1830 ,1829 ,1828 ,1827 ,1826 ,1825 ,1824 ,1823 ,1822 ,1821 ,1820 ,1819 ,1819 ,1818 ,1817 ,
|
||||||
|
1816 ,1815 ,1814 ,1813 ,1812 ,1811 ,1810 ,1809 ,1809 ,1808 ,1807 ,1806 ,1805 ,1804 ,1803 ,1802 ,
|
||||||
|
1802 ,1801 ,1800 ,1799 ,1798 ,1797 ,1796 ,1796 ,1795 ,1794 ,1793 ,1792 ,1791 ,1791 ,1790 ,1789 ,
|
||||||
|
1788 ,1787 ,1786 ,1786 ,1785 ,1784 ,1783 ,1782 ,1782 ,1781 ,1780 ,1779 ,1778 ,1778 ,1777 ,1776 ,
|
||||||
|
1775 ,1774 ,1774 ,1773 ,1772 ,1771 ,1771 ,1770 ,1769 ,1768 ,1768 ,1767 ,1766 ,1765 ,1764 ,1764 ,
|
||||||
|
1763 ,1762 ,1761 ,1761 ,1760 ,1759 ,1758 ,1758 ,1757 ,1756 ,1756 ,1755 ,1754 ,1753 ,1753 ,1752 ,
|
||||||
|
1751 ,1750 ,1750 ,1749 ,1748 ,1748 ,1747 ,1746 ,1745 ,1745 ,1744 ,1743 ,1743 ,1742 ,1741 ,1740 ,
|
||||||
|
1740 ,1739 ,1738 ,1738 ,1737 ,1736 ,1736 ,1735 ,1734 ,1734 ,1733 ,1732 ,1731 ,1731 ,1730 ,1729 ,
|
||||||
|
1729 ,1728 ,1727 ,1727 ,1726 ,1725 ,1725 ,1724 ,1723 ,1723 ,1722 ,1721 ,1721 ,1720 ,1719 ,1719 ,
|
||||||
|
1718 ,1717 ,1717 ,1716 ,1715 ,1715 ,1714 ,1713 ,1713 ,1712 ,1712 ,1711 ,1710 ,1710 ,1709 ,1708 ,
|
||||||
|
1708 ,1707 ,1706 ,1706 ,1705 ,1705 ,1704 ,1703 ,1703 ,1702 ,1701 ,1701 ,1700 ,1699 ,1699 ,1698 ,
|
||||||
|
1698 ,1697 ,1696 ,1696 ,1695 ,1694 ,1694 ,1693 ,1693 ,1692 ,1691 ,1691 ,1690 ,1690 ,1689 ,1688 ,
|
||||||
|
1688 ,1687 ,1687 ,1686 ,1685 ,1685 ,1684 ,1684 ,1683 ,1682 ,1682 ,1681 ,1681 ,1680 ,1679 ,1679 ,
|
||||||
|
1678 ,1678 ,1677 ,1676 ,1676 ,1675 ,1675 ,1674 ,1673 ,1673 ,1672 ,1672 ,1671 ,1671 ,1670 ,1669 ,
|
||||||
|
1669 ,1668 ,1668 ,1667 ,1666 ,1666 ,1665 ,1665 ,1664 ,1664 ,1663 ,1662 ,1662 ,1661 ,1661 ,1660 ,
|
||||||
|
1660 ,1659 ,1658 ,1658 ,1657 ,1657 ,1656 ,1656 ,1655 ,1655 ,1654 ,1653 ,1653 ,1652 ,1652 ,1651 ,
|
||||||
|
1651 ,1650 ,1649 ,1649 ,1648 ,1648 ,1647 ,1647 ,1646 ,1646 ,1645 ,1645 ,1644 ,1643 ,1643 ,1642 ,
|
||||||
|
1642 ,1641 ,1641 ,1640 ,1640 ,1639 ,1639 ,1638 ,1637 ,1637 ,1636 ,1636 ,1635 ,1635 ,1634 ,1634 ,
|
||||||
|
1633 ,1633 ,1632 ,1632 ,1631 ,1630 ,1630 ,1629 ,1629 ,1628 ,1628 ,1627 ,1627 ,1626 ,1626 ,1625 ,
|
||||||
|
1625 ,1624 ,1624 ,1623 ,1623 ,1622 ,1621 ,1621 ,1620 ,1620 ,1619 ,1619 ,1618 ,1618 ,1617 ,1617 ,
|
||||||
|
1616 ,1616 ,1615 ,1615 ,1614 ,1614 ,1613 ,1613 ,1612 ,1612 ,1611 ,1611 ,1610 ,1610 ,1609 ,1609 ,
|
||||||
|
1608 ,1608 ,1607 ,1607 ,1606 ,1605 ,1605 ,1604 ,1604 ,1603 ,1603 ,1602 ,1602 ,1601 ,1601 ,1600 ,
|
||||||
|
1600 ,1599 ,1599 ,1598 ,1598 ,1597 ,1597 ,1596 ,1596 ,1595 ,1595 ,1594 ,1594 ,1593 ,1593 ,1592 ,
|
||||||
|
1592 ,1591 ,1591 ,1590 ,1590 ,1589 ,1589 ,1589 ,1588 ,1588 ,1587 ,1587 ,1586 ,1586 ,1585 ,1585 ,
|
||||||
|
1584 ,1584 ,1583 ,1583 ,1582 ,1582 ,1581 ,1581 ,1580 ,1580 ,1579 ,1579 ,1578 ,1578 ,1577 ,1577 ,
|
||||||
|
1576 ,1576 ,1575 ,1575 ,1574 ,1574 ,1573 ,1573 ,1573 ,1572 ,1572 ,1571 ,1571 ,1570 ,1570 ,1569 ,
|
||||||
|
1569 ,1568 ,1568 ,1567 ,1567 ,1566 ,1566 ,1565 ,1565 ,1564 ,1564 ,1563 ,1563 ,1563 ,1562 ,1562 ,
|
||||||
|
1561 ,1561 ,1560 ,1560 ,1559 ,1559 ,1558 ,1558 ,1557 ,1557 ,1556 ,1556 ,1556 ,1555 ,1555 ,1554 ,
|
||||||
|
1554 ,1553 ,1553 ,1552 ,1552 ,1551 ,1551 ,1550 ,1550 ,1550 ,1549 ,1549 ,1548 ,1548 ,1547 ,1547 ,
|
||||||
|
1546 ,1546 ,1545 ,1545 ,1544 ,1544 ,1544 ,1543 ,1543 ,1542 ,1542 ,1541 ,1541 ,1540 ,1540 ,1539 ,
|
||||||
|
1539 ,1539 ,1538 ,1538 ,1537 ,1537 ,1536 ,1536 ,1535 ,1535 ,1535 ,1534 ,1534 ,1533 ,1533 ,1532 ,
|
||||||
|
1532 ,1531 ,1531 ,1530 ,1530 ,1530 ,1529 ,1529 ,1528 ,1528 ,1527 ,1527 ,1526 ,1526 ,1526 ,1525 ,
|
||||||
|
1525 ,1524 ,1524 ,1523 ,1523 ,1523 ,1522 ,1522 ,1521 ,1521 ,1520 ,1520 ,1519 ,1519 ,1519 ,1518 ,
|
||||||
|
1518 ,1517 ,1517 ,1516 ,1516 ,1515 ,1515 ,1515 ,1514 ,1514 ,1513 ,1513 ,1512 ,1512 ,1512 ,1511 ,
|
||||||
|
1511 ,1510 ,1510 ,1509 ,1509 ,1509 ,1508 ,1508 ,1507 ,1507 ,1506 ,1506 ,1505 ,1505 ,1505 ,1504 ,
|
||||||
|
1504 ,1503 ,1503 ,1502 ,1502 ,1502 ,1501 ,1501 ,1500 ,1500 ,1499 ,1499 ,1499 ,1498 ,1498 ,1497 ,
|
||||||
|
1497 ,1497 ,1496 ,1496 ,1495 ,1495 ,1494 ,1494 ,1494 ,1493 ,1493 ,1492 ,1492 ,1491 ,1491 ,1491 ,
|
||||||
|
1490 ,1490 ,1489 ,1489 ,1488 ,1488 ,1488 ,1487 ,1487 ,1486 ,1486 ,1486 ,1485 ,1485 ,1484 ,1484 ,
|
||||||
|
1483 ,1483 ,1483 ,1482 ,1482 ,1481 ,1481 ,1481 ,1480 ,1480 ,1479 ,1479 ,1478 ,1478 ,1478 ,1477 ,
|
||||||
|
1477 ,1476 ,1476 ,1476 ,1475 ,1475 ,1474 ,1474 ,1473 ,1473 ,1473 ,1472 ,1472 ,1471 ,1471 ,1471 ,
|
||||||
|
1470 ,1470 ,1469 ,1469 ,1469 ,1468 ,1468 ,1467 ,1467 ,1466 ,1466 ,1466 ,1465 ,1465 ,1464 ,1464 ,
|
||||||
|
1464 ,1463 ,1463 ,1462 ,1462 ,1462 ,1461 ,1461 ,1460 ,1460 ,1460 ,1459 ,1459 ,1458 ,1458 ,1458 ,
|
||||||
|
1457 ,1457 ,1456 ,1456 ,1456 ,1455 ,1455 ,1454 ,1454 ,1453 ,1453 ,1453 ,1452 ,1452 ,1451 ,1451 ,
|
||||||
|
1451 ,1450 ,1450 ,1449 ,1449 ,1449 ,1448 ,1448 ,1447 ,1447 ,1447 ,1446 ,1446 ,1445 ,1445 ,1445 ,
|
||||||
|
1444 ,1444 ,1443 ,1443 ,1443 ,1442 ,1442 ,1441 ,1441 ,1441 ,1440 ,1440 ,1440 ,1439 ,1439 ,1438 ,
|
||||||
|
1438 ,1438 ,1437 ,1437 ,1436 ,1436 ,1436 ,1435 ,1435 ,1434 ,1434 ,1434 ,1433 ,1433 ,1432 ,1432 ,
|
||||||
|
1432 ,1431 ,1431 ,1430 ,1430 ,1430 ,1429 ,1429 ,1428 ,1428 ,1428 ,1427 ,1427 ,1427 ,1426 ,1426 ,
|
||||||
|
1425 ,1425 ,1425 ,1424 ,1424 ,1423 ,1423 ,1423 ,1422 ,1422 ,1421 ,1421 ,1421 ,1420 ,1420 ,1420 ,
|
||||||
|
1419 ,1419 ,1418 ,1418 ,1418 ,1417 ,1417 ,1416 ,1416 ,1416 ,1415 ,1415 ,1414 ,1414 ,1414 ,1413 ,
|
||||||
|
1413 ,1413 ,1412 ,1412 ,1411 ,1411 ,1411 ,1410 ,1410 ,1409 ,1409 ,1409 ,1408 ,1408 ,1408 ,1407 ,
|
||||||
|
1407 ,1406 ,1406 ,1406 ,1405 ,1405 ,1405 ,1404 ,1404 ,1403 ,1403 ,1403 ,1402 ,1402 ,1401 ,1401 ,
|
||||||
|
1401 ,1400 ,1400 ,1400 ,1399 ,1399 ,1398 ,1398 ,1398 ,1397 ,1397 ,1397 ,1396 ,1396 ,1395 ,1395 ,
|
||||||
|
1395 ,1394 ,1394 ,1394 ,1393 ,1393 ,1392 ,1392 ,1392 ,1391 ,1391 ,1390 ,1390 ,1390 ,1389 ,1389 ,
|
||||||
|
1389 ,1388 ,1388 ,1387 ,1387 ,1387 ,1386 ,1386 ,1386 ,1385 ,1385 ,1384 ,1384 ,1384 ,1383 ,1383 ,
|
||||||
|
1383 ,1382 ,1382 ,1381 ,1381 ,1381 ,1380 ,1380 ,1380 ,1379 ,1379 ,1379 ,1378 ,1378 ,1377 ,1377 ,
|
||||||
|
1377 ,1376 ,1376 ,1376 ,1375 ,1375 ,1374 ,1374 ,1374 ,1373 ,1373 ,1373 ,1372 ,1372 ,1371 ,1371 ,
|
||||||
|
1371 ,1370 ,1370 ,1370 ,1369 ,1369 ,1369 ,1368 ,1368 ,1367 ,1367 ,1367 ,1366 ,1366 ,1366 ,1365 ,
|
||||||
|
1365 ,1364 ,1364 ,1364 ,1363 ,1363 ,1363 ,1362 ,1362 ,1362 ,1361 ,1361 ,1360 ,1360 ,1360 ,1359 ,
|
||||||
|
1359 ,1359 ,1358 ,1358 ,1358 ,1357 ,1357 ,1356 ,1356 ,1356 ,1355 ,1355 ,1355 ,1354 ,1354 ,1353 ,
|
||||||
|
1353 ,1353 ,1352 ,1352 ,1352 ,1351 ,1351 ,1351 ,1350 ,1350 ,1349 ,1349 ,1349 ,1348 ,1348 ,1348 ,
|
||||||
|
1347 ,1347 ,1347 ,1346 ,1346 ,1346 ,1345 ,1345 ,1344 ,1344 ,1344 ,1343 ,1343 ,1343 ,1342 ,1342 ,
|
||||||
|
1342 ,1341 ,1341 ,1340 ,1340 ,1340 ,1339 ,1339 ,1339 ,1338 ,1338 ,1338 ,1337 ,1337 ,1337 ,1336 ,
|
||||||
|
1336 ,1335 ,1335 ,1335 ,1334 ,1334 ,1334 ,1333 ,1333 ,1333 ,1332 ,1332 ,1331 ,1331 ,1331 ,1330 ,
|
||||||
|
1330 ,1330 ,1329 ,1329 ,1329 ,1328 ,1328 ,1328 ,1327 ,1327 ,1327 ,1326 ,1326 ,1325 ,1325 ,1325 ,
|
||||||
|
1324 ,1324 ,1324 ,1323 ,1323 ,1323 ,1322 ,1322 ,1322 ,1321 ,1321 ,1320 ,1320 ,1320 ,1319 ,1319 ,
|
||||||
|
1319 ,1318 ,1318 ,1318 ,1317 ,1317 ,1317 ,1316 ,1316 ,1316 ,1315 ,1315 ,1314 ,1314 ,1314 ,1313 ,
|
||||||
|
1313 ,1313 ,1312 ,1312 ,1312 ,1311 ,1311 ,1311 ,1310 ,1310 ,1310 ,1309 ,1309 ,1308 ,1308 ,1308 ,
|
||||||
|
1307 ,1307 ,1307 ,1306 ,1306 ,1306 ,1305 ,1305 ,1305 ,1304 ,1304 ,1304 ,1303 ,1303 ,1303 ,1302 ,
|
||||||
|
1302 ,1301 ,1301 ,1301 ,1300 ,1300 ,1300 ,1299 ,1299 ,1299 ,1298 ,1298 ,1298 ,1297 ,1297 ,1297 ,
|
||||||
|
1296 ,1296 ,1296 ,1295 ,1295 ,1294 ,1294 ,1294 ,1293 ,1293 ,1293 ,1292 ,1292 ,1292 ,1291 ,1291 ,
|
||||||
|
1291 ,1290 ,1290 ,1290 ,1289 ,1289 ,1289 ,1288 ,1288 ,1288 ,1287 ,1287 ,1286 ,1286 ,1286 ,1285 ,
|
||||||
|
1285 ,1285 ,1284 ,1284 ,1284 ,1283 ,1283 ,1283 ,1282 ,1282 ,1282 ,1281 ,1281 ,1281 ,1280 ,1280 ,
|
||||||
|
1280 ,1279 ,1279 ,1279 ,1278 ,1278 ,1278 ,1277 ,1277 ,1276 ,1276 ,1276 ,1275 ,1275 ,1275 ,1274 ,
|
||||||
|
1274 ,1274 ,1273 ,1273 ,1273 ,1272 ,1272 ,1272 ,1271 ,1271 ,1271 ,1270 ,1270 ,1270 ,1269 ,1269 ,
|
||||||
|
1269 ,1268 ,1268 ,1268 ,1267 ,1267 ,1267 ,1266 ,1266 ,1266 ,1265 ,1265 ,1265 ,1264 ,1264 ,1263 ,
|
||||||
|
1263 ,1263 ,1262 ,1262 ,1262 ,1261 ,1261 ,1261 ,1260 ,1260 ,1260 ,1259 ,1259 ,1259 ,1258 ,1258 ,
|
||||||
|
1258 ,1257 ,1257 ,1257 ,1256 ,1256 ,1256 ,1255 ,1255 ,1255 ,1254 ,1254 ,1254 ,1253 ,1253 ,1253 ,
|
||||||
|
1252 ,1252 ,1252 ,1251 ,1251 ,1251 ,1250 ,1250 ,1250 ,1249 ,1249 ,1249 ,1248 ,1248 ,1248 ,1247 ,
|
||||||
|
1247 ,1247 ,1246 ,1246 ,1245 ,1245 ,1245 ,1244 ,1244 ,1244 ,1243 ,1243 ,1243 ,1242 ,1242 ,1242 ,
|
||||||
|
1241 ,1241 ,1241 ,1240 ,1240 ,1240 ,1239 ,1239 ,1239 ,1238 ,1238 ,1238 ,1237 ,1237 ,1237 ,1236 ,
|
||||||
|
1236 ,1236 ,1235 ,1235 ,1235 ,1234 ,1234 ,1234 ,1233 ,1233 ,1233 ,1232 ,1232 ,1232 ,1231 ,1231 ,
|
||||||
|
1231 ,1230 ,1230 ,1230 ,1229 ,1229 ,1229 ,1228 ,1228 ,1228 ,1227 ,1227 ,1227 ,1226 ,1226 ,1226 ,
|
||||||
|
1225 ,1225 ,1225 ,1224 ,1224 ,1224 ,1223 ,1223 ,1223 ,1222 ,1222 ,1222 ,1221 ,1221 ,1221 ,1220 ,
|
||||||
|
1220 ,1220 ,1219 ,1219 ,1219 ,1218 ,1218 ,1218 ,1217 ,1217 ,1217 ,1216 ,1216 ,1216 ,1215 ,1215 ,
|
||||||
|
1215 ,1214 ,1214 ,1214 ,1213 ,1213 ,1213 ,1212 ,1212 ,1212 ,1211 ,1211 ,1211 ,1210 ,1210 ,1210 ,
|
||||||
|
1209 ,1209 ,1209 ,1208 ,1208 ,1208 ,1207 ,1207 ,1207 ,1206 ,1206 ,1206 ,1205 ,1205 ,1205 ,1204 ,
|
||||||
|
1204 ,1204 ,1203 ,1203 ,1203 ,1202 ,1202 ,1202 ,1201 ,1201 ,1201 ,1200 ,1200 ,1200 ,1199 ,1199 ,
|
||||||
|
1199 ,1198 ,1198 ,1198 ,1197 ,1197 ,1197 ,1196 ,1196 ,1196 ,1195 ,1195 ,1195 ,1194 ,1194 ,1194 ,
|
||||||
|
1193 ,1193 ,1193 ,1192 ,1192 ,1192 ,1192 ,1191 ,1191 ,1191 ,1190 ,1190 ,1190 ,1189 ,1189 ,1189 ,
|
||||||
|
1188 ,1188 ,1188 ,1187 ,1187 ,1187 ,1186 ,1186 ,1186 ,1185 ,1185 ,1185 ,1184 ,1184 ,1184 ,1183 ,
|
||||||
|
1183 ,1183 ,1182 ,1182 ,1182 ,1181 ,1181 ,1181 ,1180 ,1180 ,1180 ,1179 ,1179 ,1179 ,1178 ,1178 ,
|
||||||
|
1178 ,1177 ,1177 ,1177 ,1176 ,1176 ,1176 ,1175 ,1175 ,1175 ,1174 ,1174 ,1174 ,1173 ,1173 ,1173 ,
|
||||||
|
1172 ,1172 ,1172 ,1172 ,1171 ,1171 ,1171 ,1170 ,1170 ,1170 ,1169 ,1169 ,1169 ,1168 ,1168 ,1168 ,
|
||||||
|
1167 ,1167 ,1167 ,1166 ,1166 ,1166 ,1165 ,1165 ,1165 ,1164 ,1164 ,1164 ,1163 ,1163 ,1163 ,1162 ,
|
||||||
|
1162 ,1162 ,1161 ,1161 ,1161 ,1160 ,1160 ,1160 ,1159 ,1159 ,1159 ,1158 ,1158 ,1158 ,1157 ,1157 ,
|
||||||
|
1157 ,1157 ,1156 ,1156 ,1156 ,1155 ,1155 ,1155 ,1154 ,1154 ,1154 ,1153 ,1153 ,1153 ,1152 ,1152 ,
|
||||||
|
1152 ,1151 ,1151 ,1151 ,1150 ,1150 ,1150 ,1149 ,1149 ,1149 ,1148 ,1148 ,1148 ,1147 ,1147 ,1147 ,
|
||||||
|
1146 ,1146 ,1146 ,1145 ,1145 ,1145 ,1145 ,1144 ,1144 ,1144 ,1143 ,1143 ,1143 ,1142 ,1142 ,1142 ,
|
||||||
|
1141 ,1141 ,1141 ,1140 ,1140 ,1140 ,1139 ,1139 ,1139 ,1138 ,1138 ,1138 ,1137 ,1137 ,1137 ,1136 ,
|
||||||
|
1136 ,1136 ,1135 ,1135 ,1135 ,1134 ,1134 ,1134 ,1134 ,1133 ,1133 ,1133 ,1132 ,1132 ,1132 ,1131 ,
|
||||||
|
1131 ,1131 ,1130 ,1130 ,1130 ,1129 ,1129 ,1129 ,1128 ,1128 ,1128 ,1127 ,1127 ,1127 ,1126 ,1126 ,
|
||||||
|
1126 ,1125 ,1125 ,1125 ,1124 ,1124 ,1124 ,1124 ,1123 ,1123 ,1123 ,1122 ,1122 ,1122 ,1121 ,1121 ,
|
||||||
|
1121 ,1120 ,1120 ,1120 ,1119 ,1119 ,1119 ,1118 ,1118 ,1118 ,1117 ,1117 ,1117 ,1116 ,1116 ,1116 ,
|
||||||
|
1115 ,1115 ,1115 ,1115 ,1114 ,1114 ,1114 ,1113 ,1113 ,1113 ,1112 ,1112 ,1112 ,1111 ,1111 ,1111 ,
|
||||||
|
1110 ,1110 ,1110 ,1109 ,1109 ,1109 ,1108 ,1108 ,1108 ,1107 ,1107 ,1107 ,1106 ,1106 ,1106 ,1106 ,
|
||||||
|
1105 ,1105 ,1105 ,1104 ,1104 ,1104 ,1103 ,1103 ,1103 ,1102 ,1102 ,1102 ,1101 ,1101 ,1101 ,1100 ,
|
||||||
|
1100 ,1100 ,1099 ,1099 ,1099 ,1098 ,1098 ,1098 ,1098 ,1097 ,1097 ,1097 ,1096 ,1096 ,1096 ,1095 ,
|
||||||
|
1095 ,1095 ,1094 ,1094 ,1094 ,1093 ,1093 ,1093 ,1092 ,1092 ,1092 ,1091 ,1091 ,1091 ,1090 ,1090 ,
|
||||||
|
1090 ,1090 ,1089 ,1089 ,1089 ,1088 ,1088 ,1088 ,1087 ,1087 ,1087 ,1086 ,1086 ,1086 ,1085 ,1085 ,
|
||||||
|
1085 ,1084 ,1084 ,1084 ,1083 ,1083 ,1083 ,1082 ,1082 ,1082 ,1082 ,1081 ,1081 ,1081 ,1080 ,1080 ,
|
||||||
|
1080 ,1079 ,1079 ,1079 ,1078 ,1078 ,1078 ,1077 ,1077 ,1077 ,1076 ,1076 ,1076 ,1075 ,1075 ,1075 ,
|
||||||
|
1074 ,1074 ,1074 ,1074 ,1073 ,1073 ,1073 ,1072 ,1072 ,1072 ,1071 ,1071 ,1071 ,1070 ,1070 ,1070 ,
|
||||||
|
1069 ,1069 ,1069 ,1068 ,1068 ,1068 ,1067 ,1067 ,1067 ,1067 ,1066 ,1066 ,1066 ,1065 ,1065 ,1065 ,
|
||||||
|
1064 ,1064 ,1064 ,1063 ,1063 ,1063 ,1062 ,1062 ,1062 ,1061 ,1061 ,1061 ,1060 ,1060 ,1060 ,1059 ,
|
||||||
|
1059 ,1059 ,1059 ,1058 ,1058 ,1058 ,1057 ,1057 ,1057 ,1056 ,1056 ,1056 ,1055 ,1055 ,1055 ,1054 ,
|
||||||
|
1054 ,1054 ,1053 ,1053 ,1053 ,1052 ,1052 ,1052 ,1052 ,1051 ,1051 ,1051 ,1050 ,1050 ,1050 ,1049 ,
|
||||||
|
1049 ,1049 ,1048 ,1048 ,1048 ,1047 ,1047 ,1047 ,1046 ,1046 ,1046 ,1045 ,1045 ,1045 ,1045 ,1044 ,
|
||||||
|
1044 ,1044 ,1043 ,1043 ,1043 ,1042 ,1042 ,1042 ,1041 ,1041 ,1041 ,1040 ,1040 ,1040 ,1039 ,1039 ,
|
||||||
|
1039 ,1038 ,1038 ,1038 ,1038 ,1037 ,1037 ,1037 ,1036 ,1036 ,1036 ,1035 ,1035 ,1035 ,1034 ,1034 ,
|
||||||
|
1034 ,1033 ,1033 ,1033 ,1032 ,1032 ,1032 ,1031 ,1031 ,1031 ,1031 ,1030 ,1030 ,1030 ,1029 ,1029 ,
|
||||||
|
1029 ,1028 ,1028 ,1028 ,1027 ,1027 ,1027 ,1026 ,1026 ,1026 ,1025 ,1025 ,1025 ,1024 ,1024 ,1024 ,
|
||||||
|
1023 ,1023 ,1023 ,1023 ,1022 ,1022 ,1022 ,1021 ,1021 ,1021 ,1020 ,1020 ,1020 ,1019 ,1019 ,1019 ,
|
||||||
|
1018 ,1018 ,1018 ,1017 ,1017 ,1017 ,1016 ,1016 ,1016 ,1016 ,1015 ,1015 ,1015 ,1014 ,1014 ,1014 ,
|
||||||
|
1013 ,1013 ,1013 ,1012 ,1012 ,1012 ,1011 ,1011 ,1011 ,1010 ,1010 ,1010 ,1009 ,1009 ,1009 ,1009 ,
|
||||||
|
1008 ,1008 ,1008 ,1007 ,1007 ,1007 ,1006 ,1006 ,1006 ,1005 ,1005 ,1005 ,1004 ,1004 ,1004 ,1003 ,
|
||||||
|
1003 ,1003 ,1002 ,1002 ,1002 ,1002 ,1001 ,1001 ,1001 ,1000 ,1000 ,1000 ,999 ,999 ,999 ,998 ,
|
||||||
|
998 ,998 ,997 ,997 ,997 ,996 ,996 ,996 ,995 ,995 ,995 ,995 ,994 ,994 ,994 ,993 ,
|
||||||
|
993 ,993 ,992 ,992 ,992 ,991 ,991 ,991 ,990 ,990 ,990 ,989 ,989 ,989 ,988 ,988 ,
|
||||||
|
988 ,988 ,987 ,987 ,987 ,986 ,986 ,986 ,985 ,985 ,985 ,984 ,984 ,984 ,983 ,983 ,
|
||||||
|
983 ,982 ,982 ,982 ,981 ,981 ,981 ,980 ,980 ,980 ,980 ,979 ,979 ,979 ,978 ,978 ,
|
||||||
|
978 ,977 ,977 ,977 ,976 ,976 ,976 ,975 ,975 ,975 ,974 ,974 ,974 ,973 ,973 ,973 ,
|
||||||
|
973 ,972 ,972 ,972 ,971 ,971 ,971 ,970 ,970 ,970 ,969 ,969 ,969 ,968 ,968 ,968 ,
|
||||||
|
967 ,967 ,967 ,966 ,966 ,966 ,965 ,965 ,965 ,965 ,964 ,964 ,964 ,963 ,963 ,963 ,
|
||||||
|
962 ,962 ,962 ,961 ,961 ,961 ,960 ,960 ,960 ,959 ,959 ,959 ,958 ,958 ,958 ,957 ,
|
||||||
|
957 ,957 ,957 ,956 ,956 ,956 ,955 ,955 ,955 ,954 ,954 ,954 ,953 ,953 ,953 ,952 ,
|
||||||
|
952 ,952 ,951 ,951 ,951 ,950 ,950 ,950 ,949 ,949 ,949 ,949 ,948 ,948 ,948 ,947 ,
|
||||||
|
947 ,947 ,946 ,946 ,946 ,945 ,945 ,945 ,944 ,944 ,944 ,943 ,943 ,943 ,942 ,942 ,
|
||||||
|
942 ,941 ,941 ,941 ,941 ,940 ,940 ,940 ,939 ,939 ,939 ,938 ,938 ,938 ,937 ,937 ,
|
||||||
|
937 ,936 ,936 ,936 ,935 ,935 ,935 ,934 ,934 ,934 ,933 ,933 ,933 ,932 ,932 ,932 ,
|
||||||
|
932 ,931 ,931 ,931 ,930 ,930 ,930 ,929 ,929 ,929 ,928 ,928 ,928 ,927 ,927 ,927 ,
|
||||||
|
926 ,926 ,926 ,925 ,925 ,925 ,924 ,924 ,924 ,923 ,923 ,923 ,923 ,922 ,922 ,922 ,
|
||||||
|
921 ,921 ,921 ,920 ,920 ,920 ,919 ,919 ,919 ,918 ,918 ,918 ,917 ,917 ,917 ,916 ,
|
||||||
|
916 ,916 ,915 ,915 ,915 ,914 ,914 ,914 ,913 ,913 ,913 ,913 ,912 ,912 ,912 ,911 ,
|
||||||
|
911 ,911 ,910 ,910 ,910 ,909 ,909 ,909 ,908 ,908 ,908 ,907 ,907 ,907 ,906 ,906 ,
|
||||||
|
906 ,905 ,905 ,905 ,904 ,904 ,904 ,903 ,903 ,903 ,902 ,902 ,902 ,902 ,901 ,901 ,
|
||||||
|
901 ,900 ,900 ,900 ,899 ,899 ,899 ,898 ,898 ,898 ,897 ,897 ,897 ,896 ,896 ,896 ,
|
||||||
|
895 ,895 ,895 ,894 ,894 ,894 ,893 ,893 ,893 ,892 ,892 ,892 ,891 ,891 ,891 ,890 ,
|
||||||
|
890 ,890 ,890 ,889 ,889 ,889 ,888 ,888 ,888 ,887 ,887 ,887 ,886 ,886 ,886 ,885 ,
|
||||||
|
885 ,885 ,884 ,884 ,884 ,883 ,883 ,883 ,882 ,882 ,882 ,881 ,881 ,881 ,880 ,880 ,
|
||||||
|
880 ,879 ,879 ,879 ,878 ,878 ,878 ,877 ,877 ,877 ,876 ,876 ,876 ,875 ,875 ,875 ,
|
||||||
|
875 ,874 ,874 ,874 ,873 ,873 ,873 ,872 ,872 ,872 ,871 ,871 ,871 ,870 ,870 ,870 ,
|
||||||
|
869 ,869 ,869 ,868 ,868 ,868 ,867 ,867 ,867 ,866 ,866 ,866 ,865 ,865 ,865 ,864 ,
|
||||||
|
864 ,864 ,863 ,863 ,863 ,862 ,862 ,862 ,861 ,861 ,861 ,860 ,860 ,860 ,859 ,859 ,
|
||||||
|
859 ,858 ,858 ,858 ,857 ,857 ,857 ,856 ,856 ,856 ,855 ,855 ,855 ,855 ,854 ,854 ,
|
||||||
|
854 ,853 ,853 ,853 ,852 ,852 ,852 ,851 ,851 ,851 ,850 ,850 ,850 ,849 ,849 ,849 ,
|
||||||
|
848 ,848 ,848 ,847 ,847 ,847 ,846 ,846 ,846 ,845 ,845 ,845 ,844 ,844 ,844 ,843 ,
|
||||||
|
843 ,843 ,842 ,842 ,842 ,841 ,841 ,841 ,840 ,840 ,840 ,839 ,839 ,839 ,838 ,838 ,
|
||||||
|
838 ,837 ,837 ,837 ,836 ,836 ,836 ,835 ,835 ,835 ,834 ,834 ,834 ,833 ,833 ,833 ,
|
||||||
|
832 ,832 ,832 ,831 ,831 ,831 ,830 ,830 ,830 ,829 ,829 ,829 ,828 ,828 ,828 ,827 ,
|
||||||
|
827 ,827 ,826 ,826 ,826 ,825 ,825 ,825 ,824 ,824 ,824 ,823 ,823 ,823 ,822 ,822 ,
|
||||||
|
822 ,821 ,821 ,821 ,820 ,820 ,820 ,819 ,819 ,819 ,818 ,818 ,818 ,817 ,817 ,817 ,
|
||||||
|
816 ,816 ,816 ,815 ,815 ,815 ,814 ,814 ,814 ,813 ,813 ,813 ,812 ,812 ,812 ,811 ,
|
||||||
|
811 ,811 ,810 ,810 ,810 ,809 ,809 ,809 ,808 ,808 ,808 ,807 ,807 ,807 ,806 ,806 ,
|
||||||
|
806 ,805 ,805 ,805 ,804 ,804 ,804 ,803 ,803 ,803 ,802 ,802 ,802 ,801 ,801 ,800 ,
|
||||||
|
800 ,800 ,799 ,799 ,799 ,798 ,798 ,798 ,797 ,797 ,797 ,796 ,796 ,796 ,795 ,795 ,
|
||||||
|
795 ,794 ,794 ,794 ,793 ,793 ,793 ,792 ,792 ,792 ,791 ,791 ,791 ,790 ,790 ,790 ,
|
||||||
|
789 ,789 ,789 ,788 ,788 ,788 ,787 ,787 ,787 ,786 ,786 ,786 ,785 ,785 ,785 ,784 ,
|
||||||
|
784 ,784 ,783 ,783 ,782 ,782 ,782 ,781 ,781 ,781 ,780 ,780 ,780 ,779 ,779 ,779 ,
|
||||||
|
778 ,778 ,778 ,777 ,777 ,777 ,776 ,776 ,776 ,775 ,775 ,775 ,774 ,774 ,774 ,773 ,
|
||||||
|
773 ,773 ,772 ,772 ,772 ,771 ,771 ,771 ,770 ,770 ,769 ,769 ,769 ,768 ,768 ,768 ,
|
||||||
|
767 ,767 ,767 ,766 ,766 ,766 ,765 ,765 ,765 ,764 ,764 ,764 ,763 ,763 ,763 ,762 ,
|
||||||
|
762 ,762 ,761 ,761 ,761 ,760 ,760 ,759 ,759 ,759 ,758 ,758 ,758 ,757 ,757 ,757 ,
|
||||||
|
756 ,756 ,756 ,755 ,755 ,755 ,754 ,754 ,754 ,753 ,753 ,753 ,752 ,752 ,751 ,751 ,
|
||||||
|
751 ,750 ,750 ,750 ,749 ,749 ,749 ,748 ,748 ,748 ,747 ,747 ,747 ,746 ,746 ,746 ,
|
||||||
|
745 ,745 ,744 ,744 ,744 ,743 ,743 ,743 ,742 ,742 ,742 ,741 ,741 ,741 ,740 ,740 ,
|
||||||
|
740 ,739 ,739 ,739 ,738 ,738 ,737 ,737 ,737 ,736 ,736 ,736 ,735 ,735 ,735 ,734 ,
|
||||||
|
734 ,734 ,733 ,733 ,733 ,732 ,732 ,731 ,731 ,731 ,730 ,730 ,730 ,729 ,729 ,729 ,
|
||||||
|
728 ,728 ,728 ,727 ,727 ,727 ,726 ,726 ,725 ,725 ,725 ,724 ,724 ,724 ,723 ,723 ,
|
||||||
|
723 ,722 ,722 ,722 ,721 ,721 ,720 ,720 ,720 ,719 ,719 ,719 ,718 ,718 ,718 ,717 ,
|
||||||
|
717 ,717 ,716 ,716 ,716 ,715 ,715 ,714 ,714 ,714 ,713 ,713 ,713 ,712 ,712 ,712 ,
|
||||||
|
711 ,711 ,710 ,710 ,710 ,709 ,709 ,709 ,708 ,708 ,708 ,707 ,707 ,707 ,706 ,706 ,
|
||||||
|
705 ,705 ,705 ,704 ,704 ,704 ,703 ,703 ,703 ,702 ,702 ,701 ,701 ,701 ,700 ,700 ,
|
||||||
|
700 ,699 ,699 ,699 ,698 ,698 ,698 ,697 ,697 ,696 ,696 ,696 ,695 ,695 ,695 ,694 ,
|
||||||
|
694 ,694 ,693 ,693 ,692 ,692 ,692 ,691 ,691 ,691 ,690 ,690 ,689 ,689 ,689 ,688 ,
|
||||||
|
688 ,688 ,687 ,687 ,687 ,686 ,686 ,685 ,685 ,685 ,684 ,684 ,684 ,683 ,683 ,683 ,
|
||||||
|
682 ,682 ,681 ,681 ,681 ,680 ,680 ,680 ,679 ,679 ,678 ,678 ,678 ,677 ,677 ,677 ,
|
||||||
|
676 ,676 ,676 ,675 ,675 ,674 ,674 ,674 ,673 ,673 ,673 ,672 ,672 ,671 ,671 ,671 ,
|
||||||
|
670 ,670 ,670 ,669 ,669 ,668 ,668 ,668 ,667 ,667 ,667 ,666 ,666 ,666 ,665 ,665 ,
|
||||||
|
664 ,664 ,664 ,663 ,663 ,663 ,662 ,662 ,661 ,661 ,661 ,660 ,660 ,660 ,659 ,659 ,
|
||||||
|
658 ,658 ,658 ,657 ,657 ,657 ,656 ,656 ,655 ,655 ,655 ,654 ,654 ,653 ,653 ,653 ,
|
||||||
|
652 ,652 ,652 ,651 ,651 ,650 ,650 ,650 ,649 ,649 ,649 ,648 ,648 ,647 ,647 ,647 ,
|
||||||
|
646 ,646 ,646 ,645 ,645 ,644 ,644 ,644 ,643 ,643 ,642 ,642 ,642 ,641 ,641 ,641 ,
|
||||||
|
640 ,640 ,639 ,639 ,639 ,638 ,638 ,638 ,637 ,637 ,636 ,636 ,636 ,635 ,635 ,634 ,
|
||||||
|
634 ,634 ,633 ,633 ,633 ,632 ,632 ,631 ,631 ,631 ,630 ,630 ,629 ,629 ,629 ,628 ,
|
||||||
|
628 ,627 ,627 ,627 ,626 ,626 ,626 ,625 ,625 ,624 ,624 ,624 ,623 ,623 ,622 ,622 ,
|
||||||
|
622 ,621 ,621 ,620 ,620 ,620 ,619 ,619 ,619 ,618 ,618 ,617 ,617 ,617 ,616 ,616 ,
|
||||||
|
615 ,615 ,615 ,614 ,614 ,613 ,613 ,613 ,612 ,612 ,611 ,611 ,611 ,610 ,610 ,609 ,
|
||||||
|
609 ,609 ,608 ,608 ,607 ,607 ,607 ,606 ,606 ,606 ,605 ,605 ,604 ,604 ,604 ,603 ,
|
||||||
|
603 ,602 ,602 ,602 ,601 ,601 ,600 ,600 ,600 ,599 ,599 ,598 ,598 ,598 ,597 ,597 ,
|
||||||
|
596 ,596 ,596 ,595 ,595 ,594 ,594 ,594 ,593 ,593 ,592 ,592 ,591 ,591 ,591 ,590 ,
|
||||||
|
590 ,589 ,589 ,589 ,588 ,588 ,587 ,587 ,587 ,586 ,586 ,585 ,585 ,585 ,584 ,584 ,
|
||||||
|
583 ,583 ,583 ,582 ,582 ,581 ,581 ,581 ,580 ,580 ,579 ,579 ,578 ,578 ,578 ,577 ,
|
||||||
|
577 ,576 ,576 ,576 ,575 ,575 ,574 ,574 ,574 ,573 ,573 ,572 ,572 ,571 ,571 ,571 ,
|
||||||
|
570 ,570 ,569 ,569 ,569 ,568 ,568 ,567 ,567 ,566 ,566 ,566 ,565 ,565 ,564 ,564 ,
|
||||||
|
564 ,563 ,563 ,562 ,562 ,561 ,561 ,561 ,560 ,560 ,559 ,559 ,559 ,558 ,558 ,557 ,
|
||||||
|
557 ,556 ,556 ,556 ,555 ,555 ,554 ,554 ,553 ,553 ,553 ,552 ,552 ,551 ,551 ,550 ,
|
||||||
|
550 ,550 ,549 ,549 ,548 ,548 ,548 ,547 ,547 ,546 ,546 ,545 ,545 ,545 ,544 ,544 ,
|
||||||
|
543 ,543 ,542 ,542 ,542 ,541 ,541 ,540 ,540 ,539 ,539 ,538 ,538 ,538 ,537 ,537 ,
|
||||||
|
536 ,536 ,535 ,535 ,535 ,534 ,534 ,533 ,533 ,532 ,532 ,532 ,531 ,531 ,530 ,530 ,
|
||||||
|
529 ,529 ,528 ,528 ,528 ,527 ,527 ,526 ,526 ,525 ,525 ,524 ,524 ,524 ,523 ,523 ,
|
||||||
|
522 ,522 ,521 ,521 ,521 ,520 ,520 ,519 ,519 ,518 ,518 ,517 ,517 ,517 ,516 ,516 ,
|
||||||
|
515 ,515 ,514 ,514 ,513 ,513 ,512 ,512 ,512 ,511 ,511 ,510 ,510 ,509 ,509 ,508 ,
|
||||||
|
508 ,508 ,507 ,507 ,506 ,506 ,505 ,505 ,504 ,504 ,503 ,503 ,503 ,502 ,502 ,501 ,
|
||||||
|
501 ,500 ,500 ,499 ,499 ,498 ,498 ,497 ,497 ,497 ,496 ,496 ,495 ,495 ,494 ,494 ,
|
||||||
|
493 ,493 ,492 ,492 ,491 ,491 ,491 ,490 ,490 ,489 ,489 ,488 ,488 ,487 ,487 ,486 ,
|
||||||
|
486 ,485 ,485 ,484 ,484 ,484 ,483 ,483 ,482 ,482 ,481 ,481 ,480 ,480 ,479 ,479 ,
|
||||||
|
478 ,478 ,477 ,477 ,476 ,476 ,475 ,475 ,474 ,474 ,474 ,473 ,473 ,472 ,472 ,471 ,
|
||||||
|
471 ,470 ,470 ,469 ,469 ,468 ,468 ,467 ,467 ,466 ,466 ,465 ,465 ,464 ,464 ,463 ,
|
||||||
|
463 ,462 ,462 ,461 ,461 ,460 ,460 ,459 ,459 ,458 ,458 ,458 ,457 ,457 ,456 ,456 ,
|
||||||
|
455 ,455 ,454 ,454 ,453 ,453 ,452 ,452 ,451 ,451 ,450 ,450 ,449 ,449 ,448 ,448 ,
|
||||||
|
447 ,447 ,446 ,446 ,445 ,445 ,444 ,444 ,443 ,443 ,442 ,442 ,441 ,440 ,440 ,439 ,
|
||||||
|
439 ,438 ,438 ,437 ,437 ,436 ,436 ,435 ,435 ,434 ,434 ,433 ,433 ,432 ,432 ,431 ,
|
||||||
|
431 ,430 ,430 ,429 ,429 ,428 ,428 ,427 ,427 ,426 ,426 ,425 ,424 ,424 ,423 ,423 ,
|
||||||
|
422 ,422 ,421 ,421 ,420 ,420 ,419 ,419 ,418 ,418 ,417 ,417 ,416 ,415 ,415 ,414 ,
|
||||||
|
414 ,413 ,413 ,412 ,412 ,411 ,411 ,410 ,410 ,409 ,408 ,408 ,407 ,407 ,406 ,406 ,
|
||||||
|
405 ,405 ,404 ,404 ,403 ,402 ,402 ,401 ,401 ,400 ,400 ,399 ,399 ,398 ,398 ,397 ,
|
||||||
|
396 ,396 ,395 ,395 ,394 ,394 ,393 ,392 ,392 ,391 ,391 ,390 ,390 ,389 ,389 ,388 ,
|
||||||
|
387 ,387 ,386 ,386 ,385 ,385 ,384 ,383 ,383 ,382 ,382 ,381 ,381 ,380 ,379 ,379 ,
|
||||||
|
378 ,378 ,377 ,376 ,376 ,375 ,375 ,374 ,374 ,373 ,372 ,372 ,371 ,371 ,370 ,369 ,
|
||||||
|
369 ,368 ,368 ,367 ,366 ,366 ,365 ,365 ,364 ,363 ,363 ,362 ,362 ,361 ,360 ,360 ,
|
||||||
|
359 ,359 ,358 ,357 ,357 ,356 ,356 ,355 ,354 ,354 ,353 ,353 ,352 ,351 ,351 ,350 ,
|
||||||
|
349 ,349 ,348 ,348 ,347 ,346 ,346 ,345 ,344 ,344 ,343 ,342 ,342 ,341 ,341 ,340 ,
|
||||||
|
339 ,339 ,338 ,337 ,337 ,336 ,335 ,335 ,334 ,334 ,333 ,332 ,332 ,331 ,330 ,330 ,
|
||||||
|
329 ,328 ,328 ,327 ,326 ,326 ,325 ,324 ,324 ,323 ,322 ,322 ,321 ,320 ,320 ,319 ,
|
||||||
|
318 ,318 ,317 ,316 ,316 ,315 ,314 ,313 ,313 ,312 ,311 ,311 ,310 ,309 ,309 ,308 ,
|
||||||
|
307 ,307 ,306 ,305 ,304 ,304 ,303 ,302 ,302 ,301 ,300 ,299 ,299 ,298 ,297 ,297 ,
|
||||||
|
296 ,295 ,294 ,294 ,293 ,292 ,291 ,291 ,290 ,289 ,289 ,288 ,287 ,286 ,286 ,285 ,
|
||||||
|
284 ,283 ,283 ,282 ,281 ,280 ,279 ,279 ,278 ,277 ,276 ,276 ,275 ,274 ,273 ,273 ,
|
||||||
|
272 ,271 ,270 ,269 ,269 ,268 ,267 ,266 ,265 ,265 ,264 ,263 ,262 ,261 ,261 ,260 ,
|
||||||
|
259 ,258 ,257 ,256 ,256 ,255 ,254 ,253 ,252 ,251 ,251 ,250 ,249 ,248 ,247 ,246 ,
|
||||||
|
245 ,245 ,244 ,243 ,242 ,241 ,240 ,239 ,238 ,238 ,237 ,236 ,235 ,234 ,233 ,232 ,
|
||||||
|
231 ,230 ,229 ,228 ,228 ,227 ,226 ,225 ,224 ,223 ,222 ,221 ,220 ,219 ,218 ,217 ,
|
||||||
|
216 ,215 ,214 ,213 ,212 ,211 ,210 ,209 ,208 ,207 ,206 ,205 ,204 ,203 ,202 ,201 ,
|
||||||
|
200 ,199 ,198 ,197 ,196 ,195 ,193 ,192 ,191 ,190 ,189 ,188 ,187 ,186 ,185 ,183 ,
|
||||||
|
182 ,181 ,180 ,179 ,178 ,176 ,175 ,174 ,173 ,172 ,170 ,169 ,168 ,167 ,165 ,164 ,
|
||||||
|
163 ,162 ,160 ,159 ,158 ,156 ,155 ,154 ,152 ,151 ,150 ,148 ,147 ,145 ,144 ,142 ,
|
||||||
|
141 ,139 ,138 ,136 ,135 ,133 ,132 ,130 ,129 ,127 ,125 ,124 ,122 ,120 ,118 ,117 ,
|
||||||
|
115 ,113 ,111 ,109 ,107 ,105 ,103 ,101 ,99 ,97 ,95 ,93 ,91 ,88 ,86 ,84 ,
|
||||||
|
81 ,78 ,76 ,73 ,70 ,67 ,64 ,61 ,57 ,53 ,49 ,45 ,40 ,35 ,28 ,20 ,
|
||||||
|
0 };
|
||||||
|
|
||||||
|
|
||||||
|
s16 SinTable[1024] = {
|
||||||
|
0 ,6 ,12 ,18 ,25 ,31 ,37 ,43 ,50 ,56 ,62 ,69 ,75 ,81 ,87 ,94 ,
|
||||||
|
100 ,106 ,113 ,119 ,125 ,131 ,138 ,144 ,150 ,157 ,163 ,169 ,175 ,182 ,188 ,194 ,
|
||||||
|
200 ,207 ,213 ,219 ,226 ,232 ,238 ,244 ,251 ,257 ,263 ,269 ,276 ,282 ,288 ,295 ,
|
||||||
|
301 ,307 ,313 ,320 ,326 ,332 ,338 ,345 ,351 ,357 ,363 ,370 ,376 ,382 ,388 ,395 ,
|
||||||
|
401 ,407 ,413 ,420 ,426 ,432 ,438 ,445 ,451 ,457 ,463 ,470 ,476 ,482 ,488 ,495 ,
|
||||||
|
501 ,507 ,513 ,520 ,526 ,532 ,538 ,545 ,551 ,557 ,563 ,569 ,576 ,582 ,588 ,594 ,
|
||||||
|
601 ,607 ,613 ,619 ,625 ,632 ,638 ,644 ,650 ,656 ,663 ,669 ,675 ,681 ,687 ,694 ,
|
||||||
|
700 ,706 ,712 ,718 ,725 ,731 ,737 ,743 ,749 ,755 ,762 ,768 ,774 ,780 ,786 ,792 ,
|
||||||
|
799 ,805 ,811 ,817 ,823 ,829 ,836 ,842 ,848 ,854 ,860 ,866 ,872 ,879 ,885 ,891 ,
|
||||||
|
897 ,903 ,909 ,915 ,921 ,928 ,934 ,940 ,946 ,952 ,958 ,964 ,970 ,976 ,983 ,989 ,
|
||||||
|
995 ,1001 ,1007 ,1013 ,1019 ,1025 ,1031 ,1037 ,1043 ,1050 ,1056 ,1062 ,1068 ,1074 ,1080 ,1086 ,
|
||||||
|
1092 ,1098 ,1104 ,1110 ,1116 ,1122 ,1128 ,1134 ,1140 ,1146 ,1152 ,1158 ,1164 ,1170 ,1176 ,1182 ,
|
||||||
|
1189 ,1195 ,1201 ,1207 ,1213 ,1219 ,1225 ,1231 ,1237 ,1243 ,1248 ,1254 ,1260 ,1266 ,1272 ,1278 ,
|
||||||
|
1284 ,1290 ,1296 ,1302 ,1308 ,1314 ,1320 ,1326 ,1332 ,1338 ,1344 ,1350 ,1356 ,1362 ,1368 ,1373 ,
|
||||||
|
1379 ,1385 ,1391 ,1397 ,1403 ,1409 ,1415 ,1421 ,1427 ,1433 ,1438 ,1444 ,1450 ,1456 ,1462 ,1468 ,
|
||||||
|
1474 ,1479 ,1485 ,1491 ,1497 ,1503 ,1509 ,1515 ,1520 ,1526 ,1532 ,1538 ,1544 ,1550 ,1555 ,1561 ,
|
||||||
|
1567 ,1573 ,1579 ,1584 ,1590 ,1596 ,1602 ,1608 ,1613 ,1619 ,1625 ,1631 ,1636 ,1642 ,1648 ,1654 ,
|
||||||
|
1659 ,1665 ,1671 ,1677 ,1682 ,1688 ,1694 ,1699 ,1705 ,1711 ,1717 ,1722 ,1728 ,1734 ,1739 ,1745 ,
|
||||||
|
1751 ,1756 ,1762 ,1768 ,1773 ,1779 ,1785 ,1790 ,1796 ,1802 ,1807 ,1813 ,1819 ,1824 ,1830 ,1835 ,
|
||||||
|
1841 ,1847 ,1852 ,1858 ,1864 ,1869 ,1875 ,1880 ,1886 ,1891 ,1897 ,1903 ,1908 ,1914 ,1919 ,1925 ,
|
||||||
|
1930 ,1936 ,1941 ,1947 ,1952 ,1958 ,1964 ,1969 ,1975 ,1980 ,1986 ,1991 ,1997 ,2002 ,2007 ,2013 ,
|
||||||
|
2018 ,2024 ,2029 ,2035 ,2040 ,2046 ,2051 ,2057 ,2062 ,2067 ,2073 ,2078 ,2084 ,2089 ,2094 ,2100 ,
|
||||||
|
2105 ,2111 ,2116 ,2121 ,2127 ,2132 ,2138 ,2143 ,2148 ,2154 ,2159 ,2164 ,2170 ,2175 ,2180 ,2186 ,
|
||||||
|
2191 ,2196 ,2201 ,2207 ,2212 ,2217 ,2223 ,2228 ,2233 ,2238 ,2244 ,2249 ,2254 ,2259 ,2265 ,2270 ,
|
||||||
|
2275 ,2280 ,2286 ,2291 ,2296 ,2301 ,2306 ,2312 ,2317 ,2322 ,2327 ,2332 ,2337 ,2343 ,2348 ,2353 ,
|
||||||
|
2358 ,2363 ,2368 ,2373 ,2379 ,2384 ,2389 ,2394 ,2399 ,2404 ,2409 ,2414 ,2419 ,2424 ,2429 ,2434 ,
|
||||||
|
2439 ,2445 ,2450 ,2455 ,2460 ,2465 ,2470 ,2475 ,2480 ,2485 ,2490 ,2495 ,2500 ,2505 ,2510 ,2515 ,
|
||||||
|
2519 ,2524 ,2529 ,2534 ,2539 ,2544 ,2549 ,2554 ,2559 ,2564 ,2569 ,2574 ,2578 ,2583 ,2588 ,2593 ,
|
||||||
|
2598 ,2603 ,2608 ,2613 ,2617 ,2622 ,2627 ,2632 ,2637 ,2641 ,2646 ,2651 ,2656 ,2661 ,2665 ,2670 ,
|
||||||
|
2675 ,2680 ,2684 ,2689 ,2694 ,2699 ,2703 ,2708 ,2713 ,2717 ,2722 ,2727 ,2732 ,2736 ,2741 ,2746 ,
|
||||||
|
2750 ,2755 ,2760 ,2764 ,2769 ,2773 ,2778 ,2783 ,2787 ,2792 ,2796 ,2801 ,2806 ,2810 ,2815 ,2819 ,
|
||||||
|
2824 ,2828 ,2833 ,2837 ,2842 ,2847 ,2851 ,2856 ,2860 ,2865 ,2869 ,2874 ,2878 ,2882 ,2887 ,2891 ,
|
||||||
|
2896 ,2900 ,2905 ,2909 ,2914 ,2918 ,2922 ,2927 ,2931 ,2936 ,2940 ,2944 ,2949 ,2953 ,2957 ,2962 ,
|
||||||
|
2966 ,2970 ,2975 ,2979 ,2983 ,2988 ,2992 ,2996 ,3000 ,3005 ,3009 ,3013 ,3018 ,3022 ,3026 ,3030 ,
|
||||||
|
3034 ,3039 ,3043 ,3047 ,3051 ,3055 ,3060 ,3064 ,3068 ,3072 ,3076 ,3080 ,3085 ,3089 ,3093 ,3097 ,
|
||||||
|
3101 ,3105 ,3109 ,3113 ,3117 ,3121 ,3126 ,3130 ,3134 ,3138 ,3142 ,3146 ,3150 ,3154 ,3158 ,3162 ,
|
||||||
|
3166 ,3170 ,3174 ,3178 ,3182 ,3186 ,3190 ,3193 ,3197 ,3201 ,3205 ,3209 ,3213 ,3217 ,3221 ,3225 ,
|
||||||
|
3229 ,3232 ,3236 ,3240 ,3244 ,3248 ,3252 ,3255 ,3259 ,3263 ,3267 ,3271 ,3274 ,3278 ,3282 ,3286 ,
|
||||||
|
3289 ,3293 ,3297 ,3301 ,3304 ,3308 ,3312 ,3315 ,3319 ,3323 ,3326 ,3330 ,3334 ,3337 ,3341 ,3345 ,
|
||||||
|
3348 ,3352 ,3356 ,3359 ,3363 ,3366 ,3370 ,3373 ,3377 ,3381 ,3384 ,3388 ,3391 ,3395 ,3398 ,3402 ,
|
||||||
|
3405 ,3409 ,3412 ,3416 ,3419 ,3423 ,3426 ,3429 ,3433 ,3436 ,3440 ,3443 ,3447 ,3450 ,3453 ,3457 ,
|
||||||
|
3460 ,3463 ,3467 ,3470 ,3473 ,3477 ,3480 ,3483 ,3487 ,3490 ,3493 ,3497 ,3500 ,3503 ,3506 ,3510 ,
|
||||||
|
3513 ,3516 ,3519 ,3522 ,3526 ,3529 ,3532 ,3535 ,3538 ,3541 ,3545 ,3548 ,3551 ,3554 ,3557 ,3560 ,
|
||||||
|
3563 ,3566 ,3570 ,3573 ,3576 ,3579 ,3582 ,3585 ,3588 ,3591 ,3594 ,3597 ,3600 ,3603 ,3606 ,3609 ,
|
||||||
|
3612 ,3615 ,3618 ,3621 ,3624 ,3627 ,3629 ,3632 ,3635 ,3638 ,3641 ,3644 ,3647 ,3650 ,3652 ,3655 ,
|
||||||
|
3658 ,3661 ,3664 ,3667 ,3669 ,3672 ,3675 ,3678 ,3680 ,3683 ,3686 ,3689 ,3691 ,3694 ,3697 ,3700 ,
|
||||||
|
3702 ,3705 ,3708 ,3710 ,3713 ,3716 ,3718 ,3721 ,3723 ,3726 ,3729 ,3731 ,3734 ,3736 ,3739 ,3742 ,
|
||||||
|
3744 ,3747 ,3749 ,3752 ,3754 ,3757 ,3759 ,3762 ,3764 ,3767 ,3769 ,3772 ,3774 ,3776 ,3779 ,3781 ,
|
||||||
|
3784 ,3786 ,3789 ,3791 ,3793 ,3796 ,3798 ,3800 ,3803 ,3805 ,3807 ,3810 ,3812 ,3814 ,3816 ,3819 ,
|
||||||
|
3821 ,3823 ,3826 ,3828 ,3830 ,3832 ,3834 ,3837 ,3839 ,3841 ,3843 ,3845 ,3848 ,3850 ,3852 ,3854 ,
|
||||||
|
3856 ,3858 ,3860 ,3862 ,3864 ,3867 ,3869 ,3871 ,3873 ,3875 ,3877 ,3879 ,3881 ,3883 ,3885 ,3887 ,
|
||||||
|
3889 ,3891 ,3893 ,3895 ,3897 ,3899 ,3900 ,3902 ,3904 ,3906 ,3908 ,3910 ,3912 ,3914 ,3915 ,3917 ,
|
||||||
|
3919 ,3921 ,3923 ,3925 ,3926 ,3928 ,3930 ,3932 ,3933 ,3935 ,3937 ,3939 ,3940 ,3942 ,3944 ,3945 ,
|
||||||
|
3947 ,3949 ,3950 ,3952 ,3954 ,3955 ,3957 ,3959 ,3960 ,3962 ,3963 ,3965 ,3967 ,3968 ,3970 ,3971 ,
|
||||||
|
3973 ,3974 ,3976 ,3977 ,3979 ,3980 ,3982 ,3983 ,3985 ,3986 ,3988 ,3989 ,3990 ,3992 ,3993 ,3995 ,
|
||||||
|
3996 ,3997 ,3999 ,4000 ,4001 ,4003 ,4004 ,4005 ,4007 ,4008 ,4009 ,4011 ,4012 ,4013 ,4014 ,4016 ,
|
||||||
|
4017 ,4018 ,4019 ,4020 ,4022 ,4023 ,4024 ,4025 ,4026 ,4027 ,4029 ,4030 ,4031 ,4032 ,4033 ,4034 ,
|
||||||
|
4035 ,4036 ,4037 ,4038 ,4039 ,4040 ,4041 ,4042 ,4043 ,4044 ,4045 ,4046 ,4047 ,4048 ,4049 ,4050 ,
|
||||||
|
4051 ,4052 ,4053 ,4054 ,4055 ,4056 ,4057 ,4057 ,4058 ,4059 ,4060 ,4061 ,4062 ,4062 ,4063 ,4064 ,
|
||||||
|
4065 ,4065 ,4066 ,4067 ,4068 ,4068 ,4069 ,4070 ,4071 ,4071 ,4072 ,4073 ,4073 ,4074 ,4075 ,4075 ,
|
||||||
|
4076 ,4076 ,4077 ,4078 ,4078 ,4079 ,4079 ,4080 ,4080 ,4081 ,4081 ,4082 ,4082 ,4083 ,4083 ,4084 ,
|
||||||
|
4084 ,4085 ,4085 ,4086 ,4086 ,4087 ,4087 ,4087 ,4088 ,4088 ,4089 ,4089 ,4089 ,4090 ,4090 ,4090 ,
|
||||||
|
4091 ,4091 ,4091 ,4091 ,4092 ,4092 ,4092 ,4092 ,4093 ,4093 ,4093 ,4093 ,4094 ,4094 ,4094 ,4094 ,
|
||||||
|
4094 ,4094 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 ,4095 };
|
||||||
|
|
||||||
|
|
||||||
|
s32 OneSinTable[1024] = {
|
||||||
|
0 ,2670177 ,1335090 ,890062 ,667548 ,534040 ,445035 ,381461 ,333780 ,296695 ,267028 ,242754 ,222527 ,205411 ,190741 ,178027 ,
|
||||||
|
166902 ,157087 ,148362 ,140555 ,133529 ,127173 ,121394 ,116118 ,111282 ,106833 ,102726 ,98923 ,95392 ,92105 ,89037 ,86167 ,
|
||||||
|
83476 ,80949 ,78570 ,76327 ,74209 ,72205 ,70307 ,68506 ,66796 ,65169 ,63619 ,62142 ,60731 ,59384 ,58095 ,56861 ,
|
||||||
|
55678 ,54544 ,53455 ,52409 ,51404 ,50436 ,49504 ,48606 ,47740 ,46904 ,46098 ,45319 ,44565 ,43837 ,43132 ,42449 ,
|
||||||
|
41788 ,41147 ,40526 ,39923 ,39338 ,38770 ,38218 ,37682 ,37161 ,36654 ,36161 ,35681 ,35213 ,34758 ,34314 ,33882 ,
|
||||||
|
33461 ,33050 ,32649 ,32257 ,31875 ,31503 ,31138 ,30782 ,30435 ,30095 ,29763 ,29438 ,29120 ,28809 ,28504 ,28206 ,
|
||||||
|
27915 ,27629 ,27349 ,27075 ,26806 ,26543 ,26285 ,26032 ,25784 ,25540 ,25301 ,25067 ,24837 ,24611 ,24389 ,24172 ,
|
||||||
|
23958 ,23748 ,23542 ,23339 ,23140 ,22945 ,22752 ,22563 ,22377 ,22194 ,22014 ,21838 ,21664 ,21492 ,21324 ,21158 ,
|
||||||
|
20995 ,20834 ,20676 ,20520 ,20367 ,20216 ,20067 ,19921 ,19776 ,19634 ,19494 ,19356 ,19220 ,19085 ,18953 ,18823 ,
|
||||||
|
18694 ,18567 ,18442 ,18319 ,18197 ,18077 ,17959 ,17842 ,17727 ,17613 ,17501 ,17390 ,17280 ,17173 ,17066 ,16961 ,
|
||||||
|
16857 ,16754 ,16653 ,16553 ,16454 ,16356 ,16260 ,16165 ,16071 ,15978 ,15886 ,15795 ,15705 ,15617 ,15529 ,15442 ,
|
||||||
|
15357 ,15272 ,15189 ,15106 ,15024 ,14943 ,14863 ,14784 ,14706 ,14628 ,14552 ,14476 ,14401 ,14327 ,14254 ,14182 ,
|
||||||
|
14110 ,14039 ,13969 ,13899 ,13830 ,13762 ,13695 ,13628 ,13562 ,13497 ,13432 ,13368 ,13305 ,13242 ,13180 ,13118 ,
|
||||||
|
13057 ,12997 ,12937 ,12878 ,12819 ,12761 ,12704 ,12647 ,12591 ,12535 ,12479 ,12424 ,12370 ,12316 ,12263 ,12210 ,
|
||||||
|
12158 ,12106 ,12054 ,12004 ,11953 ,11903 ,11853 ,11804 ,11755 ,11707 ,11659 ,11612 ,11565 ,11518 ,11472 ,11426 ,
|
||||||
|
11381 ,11336 ,11291 ,11247 ,11203 ,11159 ,11116 ,11073 ,11030 ,10988 ,10947 ,10905 ,10864 ,10823 ,10783 ,10743 ,
|
||||||
|
10703 ,10663 ,10624 ,10585 ,10547 ,10509 ,10471 ,10433 ,10396 ,10359 ,10322 ,10285 ,10249 ,10213 ,10178 ,10142 ,
|
||||||
|
10107 ,10072 ,10038 ,10003 ,9969 ,9935 ,9902 ,9869 ,9835 ,9803 ,9770 ,9738 ,9706 ,9674 ,9642 ,9611 ,
|
||||||
|
9580 ,9549 ,9518 ,9487 ,9457 ,9427 ,9397 ,9367 ,9338 ,9309 ,9280 ,9251 ,9222 ,9194 ,9166 ,9137 ,
|
||||||
|
9110 ,9082 ,9054 ,9027 ,9000 ,8973 ,8946 ,8920 ,8893 ,8867 ,8841 ,8815 ,8790 ,8764 ,8739 ,8714 ,
|
||||||
|
8689 ,8664 ,8639 ,8614 ,8590 ,8566 ,8542 ,8518 ,8494 ,8471 ,8447 ,8424 ,8401 ,8378 ,8355 ,8332 ,
|
||||||
|
8310 ,8287 ,8265 ,8243 ,8221 ,8199 ,8177 ,8155 ,8134 ,8113 ,8091 ,8070 ,8049 ,8029 ,8008 ,7987 ,
|
||||||
|
7967 ,7946 ,7926 ,7906 ,7886 ,7866 ,7847 ,7827 ,7808 ,7788 ,7769 ,7750 ,7731 ,7712 ,7693 ,7674 ,
|
||||||
|
7656 ,7637 ,7619 ,7600 ,7582 ,7564 ,7546 ,7528 ,7511 ,7493 ,7475 ,7458 ,7441 ,7423 ,7406 ,7389 ,
|
||||||
|
7372 ,7355 ,7338 ,7322 ,7305 ,7289 ,7272 ,7256 ,7240 ,7224 ,7207 ,7192 ,7176 ,7160 ,7144 ,7129 ,
|
||||||
|
7113 ,7098 ,7082 ,7067 ,7052 ,7037 ,7022 ,7007 ,6992 ,6977 ,6962 ,6948 ,6933 ,6918 ,6904 ,6890 ,
|
||||||
|
6875 ,6861 ,6847 ,6833 ,6819 ,6805 ,6791 ,6778 ,6764 ,6750 ,6737 ,6723 ,6710 ,6697 ,6683 ,6670 ,
|
||||||
|
6657 ,6644 ,6631 ,6618 ,6605 ,6593 ,6580 ,6567 ,6555 ,6542 ,6530 ,6517 ,6505 ,6493 ,6480 ,6468 ,
|
||||||
|
6456 ,6444 ,6432 ,6420 ,6408 ,6396 ,6385 ,6373 ,6361 ,6350 ,6338 ,6327 ,6315 ,6304 ,6293 ,6282 ,
|
||||||
|
6270 ,6259 ,6248 ,6237 ,6226 ,6215 ,6204 ,6194 ,6183 ,6172 ,6162 ,6151 ,6140 ,6130 ,6119 ,6109 ,
|
||||||
|
6099 ,6088 ,6078 ,6068 ,6058 ,6048 ,6038 ,6028 ,6018 ,6008 ,5998 ,5988 ,5978 ,5969 ,5959 ,5949 ,
|
||||||
|
5940 ,5930 ,5921 ,5911 ,5902 ,5892 ,5883 ,5874 ,5865 ,5855 ,5846 ,5837 ,5828 ,5819 ,5810 ,5801 ,
|
||||||
|
5792 ,5783 ,5774 ,5766 ,5757 ,5748 ,5740 ,5731 ,5722 ,5714 ,5705 ,5697 ,5688 ,5680 ,5672 ,5663 ,
|
||||||
|
5655 ,5647 ,5639 ,5630 ,5622 ,5614 ,5606 ,5598 ,5590 ,5582 ,5574 ,5566 ,5559 ,5551 ,5543 ,5535 ,
|
||||||
|
5528 ,5520 ,5512 ,5505 ,5497 ,5490 ,5482 ,5475 ,5467 ,5460 ,5452 ,5445 ,5438 ,5430 ,5423 ,5416 ,
|
||||||
|
5409 ,5402 ,5395 ,5388 ,5380 ,5373 ,5366 ,5360 ,5353 ,5346 ,5339 ,5332 ,5325 ,5318 ,5312 ,5305 ,
|
||||||
|
5298 ,5292 ,5285 ,5278 ,5272 ,5265 ,5259 ,5252 ,5246 ,5239 ,5233 ,5227 ,5220 ,5214 ,5208 ,5201 ,
|
||||||
|
5195 ,5189 ,5183 ,5177 ,5171 ,5164 ,5158 ,5152 ,5146 ,5140 ,5134 ,5128 ,5122 ,5117 ,5111 ,5105 ,
|
||||||
|
5099 ,5093 ,5088 ,5082 ,5076 ,5070 ,5065 ,5059 ,5053 ,5048 ,5042 ,5037 ,5031 ,5026 ,5020 ,5015 ,
|
||||||
|
5009 ,5004 ,4999 ,4993 ,4988 ,4983 ,4977 ,4972 ,4967 ,4962 ,4956 ,4951 ,4946 ,4941 ,4936 ,4931 ,
|
||||||
|
4926 ,4921 ,4916 ,4911 ,4906 ,4901 ,4896 ,4891 ,4886 ,4881 ,4876 ,4871 ,4867 ,4862 ,4857 ,4852 ,
|
||||||
|
4848 ,4843 ,4838 ,4834 ,4829 ,4824 ,4820 ,4815 ,4811 ,4806 ,4802 ,4797 ,4793 ,4788 ,4784 ,4779 ,
|
||||||
|
4775 ,4771 ,4766 ,4762 ,4757 ,4753 ,4749 ,4745 ,4740 ,4736 ,4732 ,4728 ,4724 ,4719 ,4715 ,4711 ,
|
||||||
|
4707 ,4703 ,4699 ,4695 ,4691 ,4687 ,4683 ,4679 ,4675 ,4671 ,4667 ,4663 ,4659 ,4655 ,4652 ,4648 ,
|
||||||
|
4644 ,4640 ,4636 ,4633 ,4629 ,4625 ,4621 ,4618 ,4614 ,4610 ,4607 ,4603 ,4599 ,4596 ,4592 ,4589 ,
|
||||||
|
4585 ,4582 ,4578 ,4575 ,4571 ,4568 ,4564 ,4561 ,4557 ,4554 ,4551 ,4547 ,4544 ,4540 ,4537 ,4534 ,
|
||||||
|
4531 ,4527 ,4524 ,4521 ,4518 ,4514 ,4511 ,4508 ,4505 ,4502 ,4498 ,4495 ,4492 ,4489 ,4486 ,4483 ,
|
||||||
|
4480 ,4477 ,4474 ,4471 ,4468 ,4465 ,4462 ,4459 ,4456 ,4453 ,4450 ,4447 ,4444 ,4441 ,4439 ,4436 ,
|
||||||
|
4433 ,4430 ,4427 ,4425 ,4422 ,4419 ,4416 ,4414 ,4411 ,4408 ,4406 ,4403 ,4400 ,4398 ,4395 ,4392 ,
|
||||||
|
4390 ,4387 ,4385 ,4382 ,4379 ,4377 ,4374 ,4372 ,4369 ,4367 ,4364 ,4362 ,4359 ,4357 ,4355 ,4352 ,
|
||||||
|
4350 ,4347 ,4345 ,4343 ,4340 ,4338 ,4336 ,4333 ,4331 ,4329 ,4327 ,4324 ,4322 ,4320 ,4318 ,4315 ,
|
||||||
|
4313 ,4311 ,4309 ,4307 ,4305 ,4302 ,4300 ,4298 ,4296 ,4294 ,4292 ,4290 ,4288 ,4286 ,4284 ,4282 ,
|
||||||
|
4280 ,4278 ,4276 ,4274 ,4272 ,4270 ,4268 ,4266 ,4264 ,4262 ,4260 ,4259 ,4257 ,4255 ,4253 ,4251 ,
|
||||||
|
4249 ,4248 ,4246 ,4244 ,4242 ,4241 ,4239 ,4237 ,4235 ,4234 ,4232 ,4230 ,4229 ,4227 ,4225 ,4224 ,
|
||||||
|
4222 ,4220 ,4219 ,4217 ,4216 ,4214 ,4213 ,4211 ,4209 ,4208 ,4206 ,4205 ,4203 ,4202 ,4200 ,4199 ,
|
||||||
|
4198 ,4196 ,4195 ,4193 ,4192 ,4190 ,4189 ,4188 ,4186 ,4185 ,4184 ,4182 ,4181 ,4180 ,4178 ,4177 ,
|
||||||
|
4176 ,4174 ,4173 ,4172 ,4171 ,4170 ,4168 ,4167 ,4166 ,4165 ,4164 ,4162 ,4161 ,4160 ,4159 ,4158 ,
|
||||||
|
4157 ,4156 ,4155 ,4153 ,4152 ,4151 ,4150 ,4149 ,4148 ,4147 ,4146 ,4145 ,4144 ,4143 ,4142 ,4141 ,
|
||||||
|
4140 ,4139 ,4138 ,4138 ,4137 ,4136 ,4135 ,4134 ,4133 ,4132 ,4131 ,4131 ,4130 ,4129 ,4128 ,4127 ,
|
||||||
|
4127 ,4126 ,4125 ,4124 ,4123 ,4123 ,4122 ,4121 ,4121 ,4120 ,4119 ,4119 ,4118 ,4117 ,4117 ,4116 ,
|
||||||
|
4115 ,4115 ,4114 ,4113 ,4113 ,4112 ,4112 ,4111 ,4111 ,4110 ,4110 ,4109 ,4109 ,4108 ,4108 ,4107 ,
|
||||||
|
4107 ,4106 ,4106 ,4105 ,4105 ,4104 ,4104 ,4104 ,4103 ,4103 ,4102 ,4102 ,4102 ,4101 ,4101 ,4101 ,
|
||||||
|
4100 ,4100 ,4100 ,4100 ,4099 ,4099 ,4099 ,4099 ,4098 ,4098 ,4098 ,4098 ,4097 ,4097 ,4097 ,4097 ,
|
||||||
|
4097 ,4097 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 ,4096 };
|
||||||
|
|
||||||
|
|
52
source/utils/utils.cpp
Normal file
52
source/utils/utils.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/******************/
|
||||||
|
/*** Misc Utils ***/
|
||||||
|
/******************/
|
||||||
|
|
||||||
|
#include "system\global.h"
|
||||||
|
#include "utils\utils.h"
|
||||||
|
#include "gfx\Prim.h"
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system/vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SYSTEM_GSTATE_H__
|
||||||
|
#include "system\gstate.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MATHTABLE_HEADER__
|
||||||
|
#include "utils\mathtab.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
const s16 c_circle[ NO_SIN ] =
|
||||||
|
{
|
||||||
|
0,25,49,74,97,120,142,162,181,197,212,225,236,244,251,254,
|
||||||
|
255,254,251,244,236,225,212,197,181,162,142,120,97,74,49,25,
|
||||||
|
0,-25,-49,-74,-97,-120,-142,-162,-181,-197,-212,-225,-236,-244,-251,-254,
|
||||||
|
-255,-254,-251,-244,-236,-225,-212,-197,-181,-162,-142,-120,-97,-74,-49,-25
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
const MATRIX IdentityMtx =
|
||||||
|
{
|
||||||
|
{{ONE, 0, 0},
|
||||||
|
{ 0,ONE, 0},
|
||||||
|
{ 0, 0,ONE}},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
const u32 NOTNEG = ((u32)1<<(u32)31) | ((u32)1<<(u32)15);
|
||||||
|
long s_randomSeed;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u8 *MakePtr(void *BasePtr,int Offset)
|
||||||
|
{
|
||||||
|
u8 *Ret;
|
||||||
|
Ret=(u8*)BasePtr+(Offset);
|
||||||
|
return(Ret);
|
||||||
|
}
|
651
source/utils/utils.h
Normal file
651
source/utils/utils.h
Normal file
|
@ -0,0 +1,651 @@
|
||||||
|
/******************/
|
||||||
|
/*** Misc Utils ***/
|
||||||
|
/******************/
|
||||||
|
|
||||||
|
#ifndef __UTILS_HEADER__
|
||||||
|
#define __UTILS_HEADER__
|
||||||
|
|
||||||
|
#include "utils\mathmip.h"
|
||||||
|
|
||||||
|
#ifndef __GLOBAL_STRUCTS_HEADER__
|
||||||
|
#include "gstruct.h"
|
||||||
|
#endif
|
||||||
|
#ifndef __MATHTABLE_HEADER__
|
||||||
|
#include "utils\mathtab.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#define NO_SIN 64
|
||||||
|
#define SINMASK (NO_SIN - 1)
|
||||||
|
#define COSPOS (NO_SIN / 4)
|
||||||
|
|
||||||
|
extern const s16 c_circle[ NO_SIN ];
|
||||||
|
extern const MATRIX IdentityMtx;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
u8 *MakePtr(void *BasePtr,int Offset);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** Loads of inlines ********************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void SetIdent(MATRIX *Mtx)
|
||||||
|
{
|
||||||
|
Mtx->m[0][0]=ONE; Mtx->m[0][1]=0; Mtx->m[0][2]=0;
|
||||||
|
Mtx->m[1][0]=0; Mtx->m[1][1]=ONE; Mtx->m[1][2]=0;
|
||||||
|
Mtx->m[2][0]=0; Mtx->m[2][1]=0; Mtx->m[2][2]=ONE;
|
||||||
|
Mtx->t[0]=0; Mtx->t[1]=0; Mtx->t[2]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void SetIdentNoTrans(MATRIX *Mtx)
|
||||||
|
{
|
||||||
|
Mtx->m[0][0]=ONE; Mtx->m[0][1]=0; Mtx->m[0][2]=0;
|
||||||
|
Mtx->m[1][0]=0; Mtx->m[1][1]=ONE; Mtx->m[1][2]=0;
|
||||||
|
Mtx->m[2][0]=0; Mtx->m[2][1]=0; Mtx->m[2][2]=ONE;
|
||||||
|
// Mtx->t[0]=0; Mtx->t[1]=0; Mtx->t[2]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void SetIdentScale(MATRIX *Mtx,u32 Scale)
|
||||||
|
{
|
||||||
|
Mtx->m[0][0]=Scale; Mtx->m[0][1]=0; Mtx->m[0][2]=0;
|
||||||
|
Mtx->m[1][0]=0; Mtx->m[1][1]=Scale; Mtx->m[1][2]=0;
|
||||||
|
Mtx->m[2][0]=0; Mtx->m[2][1]=0; Mtx->m[2][2]=Scale;
|
||||||
|
Mtx->t[0]=0; Mtx->t[1]=0; Mtx->t[2]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void SetIdentScaleNoTrans(MATRIX *Mtx,u32 Scale)
|
||||||
|
{
|
||||||
|
Mtx->m[0][0]=Scale; Mtx->m[0][1]=0; Mtx->m[0][2]=0;
|
||||||
|
Mtx->m[1][0]=0; Mtx->m[1][1]=Scale; Mtx->m[1][2]=0;
|
||||||
|
Mtx->m[2][0]=0; Mtx->m[2][1]=0; Mtx->m[2][2]=Scale;
|
||||||
|
// Mtx->t[0]=0; Mtx->t[1]=0; Mtx->t[2]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void InverseMatrix(MATRIX *m, MATRIX &im) //assumes no scale, just transformation and rotation
|
||||||
|
{
|
||||||
|
TransposeMatrix(m, &im);
|
||||||
|
ApplyMatrixLV(&im, (VECTOR*)&m->t[0], (VECTOR*)&im.t[0]);
|
||||||
|
im.t[0] = -im.t[0];
|
||||||
|
im.t[1] = -im.t[1];
|
||||||
|
im.t[2] = -im.t[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern long s_randomSeed;
|
||||||
|
inline long getRndSeed()
|
||||||
|
{
|
||||||
|
const u32 INCREMENT = 1;
|
||||||
|
const u32 MULTIPLIER = 0x015a4e35L;
|
||||||
|
s_randomSeed = MULTIPLIER * s_randomSeed + INCREMENT;
|
||||||
|
return abs(s_randomSeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void setRndSeed( long seed )
|
||||||
|
{
|
||||||
|
s_randomSeed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline long getRnd()
|
||||||
|
{
|
||||||
|
return getRndSeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline long getRndRange( long v )
|
||||||
|
{
|
||||||
|
if (v <= 0) return 0;
|
||||||
|
|
||||||
|
// high order bits are more "random" than low order bits
|
||||||
|
if (v < 0x0ffff) return (getRndSeed() >> 16) % v;
|
||||||
|
|
||||||
|
return getRndSeed() % v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
// -- VECTOR Operator Arithmetic operation --
|
||||||
|
|
||||||
|
inline VECTOR operator - (const VECTOR& a)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = -a.vx;
|
||||||
|
ret.vy = -a.vy;
|
||||||
|
ret.vz = -a.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator + (const VECTOR& a, const VECTOR& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx + b.vx;
|
||||||
|
ret.vy = a.vy + b.vy;
|
||||||
|
ret.vz = a.vz + b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator - (const VECTOR& a, const VECTOR& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx - b.vx;
|
||||||
|
ret.vy = a.vy - b.vy;
|
||||||
|
ret.vz = a.vz - b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator *= (const VECTOR& a, const int & b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx * b;
|
||||||
|
ret.vy = a.vy * b;
|
||||||
|
ret.vz = a.vz * b;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator >>= (const VECTOR& a, const int & b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx >> b;
|
||||||
|
ret.vy = a.vy >> b;
|
||||||
|
ret.vz = a.vz >> b;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator += (const VECTOR& a, const VECTOR& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx + b.vx;
|
||||||
|
ret.vy = a.vy + b.vy;
|
||||||
|
ret.vz = a.vz + b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator == (const VECTOR& a, const VECTOR& b)
|
||||||
|
{
|
||||||
|
return (a.vx == b.vx) && (a.vy == b.vy) && (a.vz == b.vz);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator != (const VECTOR& a, const VECTOR& b)
|
||||||
|
{
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -- VECTOR to sVtx Operator Arithmetic operation --
|
||||||
|
|
||||||
|
inline VECTOR operator - (const sShortXYZ& a, const sVtx& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx - b.vx;
|
||||||
|
ret.vy = a.vy - b.vy;
|
||||||
|
ret.vz = a.vz - b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator - (const sVtx& a, const sVtx& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx - b.vx;
|
||||||
|
ret.vy = a.vy - b.vy;
|
||||||
|
ret.vz = a.vz - b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator *= (const sVtx& a, const int & b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx * b;
|
||||||
|
ret.vy = a.vy * b;
|
||||||
|
ret.vz = a.vz * b;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator >>= (const sVtx& a, const int & b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx >> b;
|
||||||
|
ret.vy = a.vy >> b;
|
||||||
|
ret.vz = a.vz >> b;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- sShortXYZ Operator Arithmetic operation --
|
||||||
|
|
||||||
|
inline sShortXYZ operator - (const sShortXYZ& a)
|
||||||
|
{
|
||||||
|
sShortXYZ ret;
|
||||||
|
ret.vx = -a.vx;
|
||||||
|
ret.vy = -a.vy;
|
||||||
|
ret.vz = -a.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline sShortXYZ operator + (const sShortXYZ& a, const sShortXYZ& b)
|
||||||
|
{
|
||||||
|
sShortXYZ ret;
|
||||||
|
ret.vx = a.vx + b.vx;
|
||||||
|
ret.vy = a.vy + b.vy;
|
||||||
|
ret.vz = a.vz + b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline sShortXYZ operator >> (const VECTOR& a, const int& b)
|
||||||
|
{
|
||||||
|
sShortXYZ ret;
|
||||||
|
ret.vx = a.vx >> b;
|
||||||
|
ret.vy = a.vy >> b;
|
||||||
|
ret.vz = a.vz >> b;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator * (const sShortXYZ& a, const sShortXYZ& b) // DOT PRODUCT
|
||||||
|
{
|
||||||
|
return (a.vx * b.vx) + (a.vy * b.vy) + (a.vz * b.vz);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator == (const sShortXYZ& a, const sShortXYZ& b)
|
||||||
|
{
|
||||||
|
return (a.vx == b.vx) && (a.vy == b.vy) && (a.vz == b.vz);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator != (const sShortXYZ& a, const sShortXYZ& b)
|
||||||
|
{
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- sShortXYZ to VECTOR Operator Arithmetic operation --
|
||||||
|
|
||||||
|
inline VECTOR operator + (const VECTOR& a, const sShortXYZ& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx + b.vx;
|
||||||
|
ret.vy = a.vy + b.vy;
|
||||||
|
ret.vz = a.vz + b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator - (const VECTOR& a, const sShortXYZ& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx - b.vx;
|
||||||
|
ret.vy = a.vy - b.vy;
|
||||||
|
ret.vz = a.vz - b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator - (const sShortXYZ& a, const sShortXYZ& b)
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = a.vx - b.vx;
|
||||||
|
ret.vy = a.vy - b.vy;
|
||||||
|
ret.vz = a.vz - b.vz;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator * (const VECTOR& a, const sShortXYZ& b) // DOT PRODUCT
|
||||||
|
{
|
||||||
|
return (a.vx * b.vx) + (a.vy * b.vy) + (a.vz * b.vz);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator * (const sShortXYZ& a, const VECTOR& b) // DOT PRODUCT
|
||||||
|
{
|
||||||
|
return (a.vx * b.vx) + (a.vy * b.vy) + (a.vz * b.vz);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator ^ (const VECTOR& a, const sShortXYZ& b) // CROSS PRODUCT
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = (a.vy * b.vz) - (a.vz * b.vy);
|
||||||
|
ret.vy = (a.vz * b.vx) - (a.vx * b.vz);
|
||||||
|
ret.vz = (a.vx * b.vy) - (a.vy * b.vx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline VECTOR operator ^ (const sShortXYZ& a, const sShortXYZ& b) // CROSS PRODUCT
|
||||||
|
{
|
||||||
|
VECTOR ret;
|
||||||
|
ret.vx = (a.vy * b.vz) - (a.vz * b.vy);
|
||||||
|
ret.vy = (a.vz * b.vx) - (a.vx * b.vz);
|
||||||
|
ret.vz = (a.vx * b.vy) - (a.vy * b.vx);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** Inlines *****************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 isqrt2(u32 v)
|
||||||
|
{
|
||||||
|
register u32 root = 0;
|
||||||
|
register u32 remhi = 0;
|
||||||
|
register u32 remlo = v;
|
||||||
|
register u32 count = 15;
|
||||||
|
register u32 testdiv;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
remhi = (remhi << 2) | (remlo >> 30);
|
||||||
|
remlo <<= 2;
|
||||||
|
root <<= 1;
|
||||||
|
testdiv = (root << 1) + 1;
|
||||||
|
if (remhi >= testdiv)
|
||||||
|
{
|
||||||
|
remhi -= testdiv;
|
||||||
|
root += 1;
|
||||||
|
}
|
||||||
|
} while (count -- != 0);
|
||||||
|
return(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcLength(const SVECTOR *s)
|
||||||
|
{
|
||||||
|
int Dt;
|
||||||
|
gte_ldsv(s);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(Dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcLengthSquared(const SVECTOR *s)
|
||||||
|
{
|
||||||
|
u32 Dt;
|
||||||
|
gte_ldsv(s);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(Dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcLengthV(const VECTOR *s)
|
||||||
|
{
|
||||||
|
u32 Dt;
|
||||||
|
gte_ldlvl(s);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcLengthSquaredV(const VECTOR *s)
|
||||||
|
{
|
||||||
|
u32 Dt;
|
||||||
|
gte_ldlvl(s);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(Dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDist(const SVECTOR *s, const SVECTOR *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dy = s->vy - e->vy;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXYZ(Dx,Dy,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistXZ(const SVECTOR *s, const SVECTOR *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistV(const VECTOR *s, const VECTOR *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dy = s->vy - e->vy;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXYZ(Dx,Dy,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistV(const VECTOR *s, const VECTOR *e, u16 shift)
|
||||||
|
{
|
||||||
|
s32 Dx = (s->vx - e->vx) >> shift;
|
||||||
|
s32 Dz = (s->vz - e->vz) >> shift;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return(isqrt2(Dt) << shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistXZV(const VECTOR *s, const VECTOR *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistXZVSquared(const VECTOR *s, const VECTOR *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return abs(Dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistXZV(const VECTOR *s, const VECTOR *e, u16 shift)
|
||||||
|
{
|
||||||
|
s32 Dx = (s->vx - e->vx) >> shift;
|
||||||
|
s32 Dz = (s->vz - e->vz) >> shift;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return(isqrt2(Dt) << shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline long CalcDistXZVAccurate(const VECTOR *s, const VECTOR *e)
|
||||||
|
{
|
||||||
|
long Dx = s->vx - e->vx;
|
||||||
|
long Dz = s->vz - e->vz;
|
||||||
|
long Dt = (Dx*Dx) + (Dz*Dz);
|
||||||
|
long len = SquareRoot0(Dt);
|
||||||
|
return(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDist(const sShortXYZ *s, const sShortXYZ *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dy = s->vy - e->vy;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXYZ(Dx,Dy,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXYZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistXZ(const sShortXYZ *s, const sShortXYZ *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return(isqrt2(Dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline u32 CalcDistXZSquared(const sShortXYZ *s, const sShortXYZ *e)
|
||||||
|
{
|
||||||
|
s32 Dx = s->vx - e->vx;
|
||||||
|
s32 Dz = s->vz - e->vz;
|
||||||
|
u32 Dt;
|
||||||
|
|
||||||
|
CMX_ldXZ(Dx,Dz);
|
||||||
|
gte_sqr0();
|
||||||
|
CMX_StVecXZMag(&Dt);
|
||||||
|
return(Dt);
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline s32 DotProduct(const SVECTOR *V0, const SVECTOR *V1)
|
||||||
|
{
|
||||||
|
s32 Dpx,Dpy,Dpz;
|
||||||
|
Dpx=V0->vx*V1->vx;
|
||||||
|
Dpy=V0->vy*V1->vy;
|
||||||
|
Dpz=V0->vz*V1->vz;
|
||||||
|
return(Dpx+Dpy+Dpz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline s32 DotProductV( const VECTOR *V0, const VECTOR *V1 )
|
||||||
|
{
|
||||||
|
s32 ax, ay, az;
|
||||||
|
s32 bx, by, bz;
|
||||||
|
s32 Dpx, Dpy, Dpz;
|
||||||
|
|
||||||
|
ax = V0->vx;
|
||||||
|
ay = V0->vy;
|
||||||
|
az = V0->vz;
|
||||||
|
|
||||||
|
bx = V1->vx;
|
||||||
|
by = V1->vy;
|
||||||
|
bz = V1->vz;
|
||||||
|
|
||||||
|
Dpx = ax * bx;
|
||||||
|
Dpy = ay * by;
|
||||||
|
Dpz = az * bz;
|
||||||
|
|
||||||
|
return (Dpx + Dpy + Dpz);
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline s32 DotProductSV( const SVECTOR *V0, const VECTOR *V1 )
|
||||||
|
{
|
||||||
|
s32 ax, ay, az;
|
||||||
|
s32 bx, by, bz;
|
||||||
|
s32 Dpx, Dpy, Dpz;
|
||||||
|
|
||||||
|
ax = V0->vx;
|
||||||
|
ay = V0->vy;
|
||||||
|
az = V0->vz;
|
||||||
|
|
||||||
|
bx = V1->vx;
|
||||||
|
by = V1->vy;
|
||||||
|
bz = V1->vz;
|
||||||
|
|
||||||
|
Dpx = ax * bx;
|
||||||
|
Dpy = ay * by;
|
||||||
|
Dpz = az * bz;
|
||||||
|
|
||||||
|
return (Dpx + Dpy + Dpz);
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
inline void QuatSlerp(sQuat *s, sQuat *d, int t, sQuat *o)
|
||||||
|
{
|
||||||
|
s32 xx, yy, zz, ww;
|
||||||
|
s32 cs;
|
||||||
|
s32 c0, c1;
|
||||||
|
sQuat to;
|
||||||
|
|
||||||
|
xx = (s->vx * d->vx);
|
||||||
|
yy = (s->vy * d->vy);
|
||||||
|
zz = (s->vz * d->vz);
|
||||||
|
ww = (s->vw * d->vw);
|
||||||
|
|
||||||
|
cs = xx + yy + zz + ww;
|
||||||
|
if (cs<0)
|
||||||
|
{
|
||||||
|
cs = -cs;
|
||||||
|
to.vx = -d->vx;
|
||||||
|
to.vy = -d->vy;
|
||||||
|
to.vz = -d->vz;
|
||||||
|
to.vw = -d->vw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to.vx = d->vx;
|
||||||
|
to.vy = d->vy;
|
||||||
|
to.vz = d->vz;
|
||||||
|
to.vw = d->vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
cs >>= 12;
|
||||||
|
s32 omega;
|
||||||
|
if (cs < 3500)
|
||||||
|
{ // standard case (slerp)
|
||||||
|
omega = macos(cs);
|
||||||
|
s32 sinom = monesin(omega);
|
||||||
|
c0 = (msin((((4096 - t) * omega) >> 12) & 4095) * sinom)>>12;
|
||||||
|
c1 = (msin(((t * omega) >> 12) & 4095) * sinom)>>12;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c0 = 4096 - t;
|
||||||
|
c1 = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
gte_LoadAverageShort12(s, &to, c0, c1, o);
|
||||||
|
o->vw = ((c0 * s->vw) + (c1 * to.vw)) >> 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
static const s32 DeltaErr = 1000;
|
||||||
|
inline void NormalizeQuaternion(sQuat *o)
|
||||||
|
{
|
||||||
|
s32 t = (u32)((s32)o->vx*o->vx+(s32)o->vy*o->vy+(s32)o->vz*o->vz+(s32)o->vw*o->vw);
|
||||||
|
s32 diff = abs((1<<24) - t);
|
||||||
|
if (diff>DeltaErr)
|
||||||
|
{
|
||||||
|
s32 isqrs = isqrt2(t);
|
||||||
|
if (isqrs)
|
||||||
|
{
|
||||||
|
o->vx = (s16)(((s32)o->vx << 12) / (s32)isqrs);
|
||||||
|
o->vy = (s16)(((s32)o->vy << 12) / (s32)isqrs);
|
||||||
|
o->vz = (s16)(((s32)o->vz << 12) / (s32)isqrs);
|
||||||
|
o->vw = (s16)(((s32)o->vw << 12) / (s32)isqrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue