TONY: Implemented some missing and incorrect init code

This commit is contained in:
Paul Gilbert 2012-05-04 00:11:38 +10:00
parent 6d0f1fca46
commit 5b2c69b1f2
9 changed files with 114 additions and 36 deletions

View File

@ -2447,13 +2447,14 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation
EnableGUI = MainEnableGUI;
SetPalesati = MainSetPalesati;
g_system->lockMutex(vdb);
vdb = g_system->createMutex();
bAlwaysDisplay = false;
int i;
/*
for (i = 0;i < 10; i++)
InitializeCriticalSection(&cs[i]);
cs[i] = g_system->createMutex();
/*
for (i = 0;i < 10; i++)
mut[i] = CreateMutex(NULL, false, NULL);
*/

View File

@ -702,7 +702,7 @@ void RMFontMacc::Init(void) {
cTable[':'] = 80;
cTable['-'] = 81;
cTable['<'] = 82;
cTable[' > '] = 83;
cTable['>'] = 83;
cTable['/'] = 84;
cTable['ÿ'] = 85;
cTable['à'] = 86;
@ -1541,7 +1541,7 @@ void RMFontObj::Init(void) {
cTable['^'] = 56;
cTable['*'] = 57;
cTable['<'] = 58;
cTable[' > '] = 59;
cTable['>'] = 59;
cTable['«'] = 60;
cTable['»'] = 61;
cTable['ø'] = 62;
@ -1847,6 +1847,8 @@ void RMText::WriteText(RMString text, int nFont, int *time) {
m_fonts[1] = new RMFontObj; m_fonts[1]->Init();
m_fonts[2] = new RMFontMacc; m_fonts[2]->Init();
m_fonts[3] = new RMFontCredits; m_fonts[3]->Init();
m_cs = g_system->createMutex();
}
g_system->lockMutex(m_cs);

View File

@ -290,15 +290,14 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear;
RMGfxTargetBuffer::RMGfxTargetBuffer() {
otlist = NULL;
// InitializeCriticalSection(&csModifyingOT);
csModifyingOT = g_system->createMutex();
}
RMGfxTargetBuffer::~RMGfxTargetBuffer() {
ClearOT();
// DeleteCriticalSection(&csModifyingOT);
g_system->deleteMutex(csModifyingOT);
}
void RMGfxTargetBuffer::ClearOT(void) {
OTList *cur, *n;

View File

@ -572,6 +572,9 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) {
m_bWiping = false;
m_hWipeEvent = CreateEvent(NULL, false, false, NULL);
// Crea l'evento di freeze
csMainLoop = g_system->createMutex();
// Inizializza la funzione di IRQ di Item per l'MPAL
ItemIrq((uint32)-1, (uint32)this, 0);
mpalInstallItemIrq(ItemIrq);

View File

@ -62,10 +62,12 @@ RMInventory::RMInventory() {
m_items = NULL;
m_state = CLOSED;
m_bCombining = false;
m_csModifyInterface = g_system->createMutex();
}
RMInventory::~RMInventory() {
Close();
g_system->deleteMutex(m_csModifyInterface);
}
bool RMInventory::CheckPointInside(RMPoint &pt) {

View File

@ -1628,7 +1628,7 @@ bool RMCharacter::RemoveThis(void) {
}
RMCharacter::RMCharacter() {
// InitializeCriticalSection(&csMove);
csMove = g_system->createMutex();
hEndOfPath = CreateEvent(NULL, false, false, NULL);
minpath = 0;
curSpeed = 3;
@ -1639,7 +1639,7 @@ RMCharacter::RMCharacter() {
}
RMCharacter::~RMCharacter() {
// DeleteCriticalSection(&csMove);
g_system->deleteMutex(csMove);
CloseHandle(hEndOfPath);
}

View File

@ -626,13 +626,13 @@ HGLOBAL resLoad(uint32 dwId) {
uint32 nSizeComp, nSizeDecomp;
byte *temp, *buf;
for (i=0;i<nResources;i++)
if (lpResources[i*2]==dwId) {
for (i = 0; i < nResources; i++)
if (lpResources[i * 2] == dwId) {
hMpr.seek(lpResources[i * 2 + 1]);
nBytesRead = hMpr.read(head, 4);
if (nBytesRead!=4)
if (nBytesRead != 4)
return NULL;
if (head[0]!='R' || head[1]!='E' || head[2]!='S' || head[3]!='D')
if (head[0] != 'R' || head[1] != 'E' || head[2] != 'S' || head[3] != 'D')
return NULL;
nSizeDecomp = hMpr.readUint32LE();

View File

@ -144,32 +144,65 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in
}
void TonyEngine::PlaySFX(int nChannel, int nFX) {
warning("TonyEngine::PlaySFX");
if (m_sfx[nChannel] == NULL)
return;
switch (nFX) {
case 0:
m_sfx[nChannel]->SetLoop(false);
break;
case 1:
m_sfx[nChannel]->SetLoop(true);
break;
}
m_sfx[nChannel]->Play();
}
void TonyEngine::StopMusic(int nChannel) {
warning("TonyEngine::StopMusic");
warning("TODO TonyEngine::StopMusic");
}
void TonyEngine::StopSFX(int nChannel) {
warning("TonyEngine::StopSFX");
warning("TODO TonyEngine::StopSFX");
}
void TonyEngine::PlayUtilSFX(int nChannel, int nFX) {
warning("TonyEngine::PlayUtilSFX");
warning("TODO TonyEngine::PlayUtilSFX");
}
void TonyEngine::StopUtilSFX(int nChannel) {
warning("TonyEngine::StopUtilSFX");
warning("TODO TonyEngine::StopUtilSFX");
}
void TonyEngine::PreloadSFX(int nChannel, char* fn) {
warning("TonyEngine::PreloadSFX");
if (m_sfx[nChannel] != NULL) {
m_sfx[nChannel]->Stop();
m_sfx[nChannel]->Release();
m_sfx[nChannel] = NULL;
}
_theSound.CreateSfx(&m_sfx[nChannel]);
/*
// Mette il path giusto
GetDataDirectory(DD_UTILSFX, path_buffer);
_splitpath(path_buffer,drive,dir,NULL,NULL);
_splitpath(fn,NULL,NULL,fname,ext);
_makepath(path_buffer,drive,dir,fname,ext);
m_sfx[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM);
*/
m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM);
}
FPSFX *TonyEngine::CreateSFX(byte *buf) {
warning("TonyEngine::CreateSFX");
return NULL;
FPSFX *sfx;
_theSound.CreateSfx(&sfx);
sfx->LoadFile(buf,FPCODEC_WAV);
return sfx;
}
void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) {
@ -185,11 +218,40 @@ void TonyEngine::UnloadAllUtilSFX(void) {
}
void TonyEngine::InitMusic() {
warning("TODO: TonyEngine::InitMusic");
int i;
_theSound.Init(/*m_wnd*/);
_theSound.SetMasterVolume(63);
for (i = 0; i < 6; i++)
_theSound.CreateStream(&m_stream[i]);
for (i = 0; i < MAX_SFX_CHANNELS; i++) {
m_sfx[i] = m_utilSfx[i] = NULL;
}
// Crea la critical section per la musica
csMusic = g_system->createMutex();
// Carica effetti sonori
// PreloadUtilSFX(0,"AccendiOpzione.ADP");
// PreloadUtilSFX(1,"ApriInterfaccia.ADP");
PreloadUtilSFX(0, "U01.ADP"); // invertiti!!
PreloadUtilSFX(1, "U02.ADP");
}
void TonyEngine::CloseMusic() {
warning("TODO: TonyEngine::CloseMusic");
for (int i = 0; i < 6; i++) {
m_stream[i]->Stop();
m_stream[i]->UnloadFile();
m_stream[i]->Release();
}
g_system->deleteMutex(csMusic);
UnloadAllSFX();
UnloadAllUtilSFX();
}
void TonyEngine::PauseSound(bool bPause) {

View File

@ -63,6 +63,8 @@ enum {
struct TonyGameDescription;
#define MAX_SFX_CHANNELS 32
struct VoiceHeader {
int offset;
int code;
@ -91,18 +93,6 @@ public:
Common::File _vdbFP;
Common::Array<VoiceHeader> _voices;
FPSOUND _theSound;
// Bounding box list manager
RMGameBoxes _theBoxes;
RMGfxEngine _theEngine;
RMWindow m_wnd;
bool m_bPaused;
bool m_bDrawLocation;
int m_startTime;
uint16 *m_curThumbnail;
bool m_bQuitNow;
bool m_bTimeFreezed;
int m_nTimeFreezed;
enum DATADIR {
DD_BASE = 1,
@ -114,6 +104,25 @@ public:
DD_VOICES,
DD_BASE2
};
FPSTREAM *m_stream[6];
FPSFX *m_sfx[MAX_SFX_CHANNELS];
FPSFX *m_utilSfx[MAX_SFX_CHANNELS];
RMGfxEngine theEngine;
RMFont *fonts[2];
bool m_bPaused;
bool m_bDrawLocation;
int m_startTime;
uint16 *m_curThumbnail;
// Bounding box list manager
RMGameBoxes _theBoxes;
RMGfxEngine _theEngine;
RMWindow m_wnd;
bool m_bQuitNow;
bool m_bTimeFreezed;
int m_nTimeFreezed;
public:
TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc);
virtual ~TonyEngine();