Skip to content

Commit

Permalink
TONY: Implemented some missing and incorrect init code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 3, 2012
1 parent 6d0f1fc commit 5b2c69b
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 36 deletions.
7 changes: 4 additions & 3 deletions engines/tony/custom.cpp
Expand Up @@ -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);
*/
Expand Down
6 changes: 4 additions & 2 deletions engines/tony/font.cpp
Expand Up @@ -702,7 +702,7 @@ void RMFontMacc::Init(void) {
cTable[':'] = 80;
cTable['-'] = 81;
cTable['<'] = 82;
cTable[' > '] = 83;
cTable['>'] = 83;
cTable['/'] = 84;
cTable['ÿ'] = 85;
cTable['à'] = 86;
Expand Down Expand Up @@ -1541,7 +1541,7 @@ void RMFontObj::Init(void) {
cTable['^'] = 56;
cTable['*'] = 57;
cTable['<'] = 58;
cTable[' > '] = 59;
cTable['>'] = 59;
cTable['«'] = 60;
cTable['»'] = 61;
cTable['ø'] = 62;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions engines/tony/gfxcore.cpp
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions engines/tony/gfxengine.cpp
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions engines/tony/inventory.cpp
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions engines/tony/loc.cpp
Expand Up @@ -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;
Expand All @@ -1639,7 +1639,7 @@ RMCharacter::RMCharacter() {
}

RMCharacter::~RMCharacter() {
// DeleteCriticalSection(&csMove);
g_system->deleteMutex(csMove);
CloseHandle(hEndOfPath);
}

Expand Down
8 changes: 4 additions & 4 deletions engines/tony/mpal/mpal.cpp
Expand Up @@ -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();
Expand Down
82 changes: 72 additions & 10 deletions engines/tony/tony.cpp
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
33 changes: 21 additions & 12 deletions engines/tony/tony.h
Expand Up @@ -63,6 +63,8 @@ enum {

struct TonyGameDescription;

#define MAX_SFX_CHANNELS 32

struct VoiceHeader {
int offset;
int code;
Expand Down Expand Up @@ -91,18 +93,6 @@ class TonyEngine : public Engine {
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,
Expand All @@ -114,6 +104,25 @@ class TonyEngine : public Engine {
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();
Expand Down

0 comments on commit 5b2c69b

Please sign in to comment.