From 5b2c69b1f291b1ee3d7f3be4ffd40e427b437ac6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 00:11:38 +1000 Subject: TONY: Implemented some missing and incorrect init code --- engines/tony/custom.cpp | 7 ++-- engines/tony/font.cpp | 6 ++-- engines/tony/gfxcore.cpp | 5 ++- engines/tony/gfxengine.cpp | 3 ++ engines/tony/inventory.cpp | 2 ++ engines/tony/loc.cpp | 4 +-- engines/tony/mpal/mpal.cpp | 8 ++--- engines/tony/tony.cpp | 82 ++++++++++++++++++++++++++++++++++++++++------ engines/tony/tony.h | 33 ++++++++++++------- 9 files changed, 114 insertions(+), 36 deletions(-) (limited to 'engines/tony') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 209fc11212..6f6e7a1534 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -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); */ diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 4bfddc8d68..ec5a78731b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -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); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index a25c28a03d..b5dc79687a 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -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; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 77a196f853..940fb2afe8 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -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); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 50969afca8..1442708d56 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -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) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 3d86b78f31..c6a54aa1ef 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -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); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 74dbedd90f..610dd59984 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -626,13 +626,13 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i=0;iSetLoop(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) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 06fe357c0d..1c08028b91 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -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 _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(); -- cgit v1.2.3