diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 63bb02a5f231..a87dd9bd0744 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -147,7 +147,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Tony::RMString saveName; byte difficulty; - byte thumbData[160 * 120 * 2]; + byte thumbData[160 * 120 * 2]; if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { // Convert the 565 thumbnail data to the needed overlay format diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a15a79b16c27..66f1ccdcd973 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -51,10 +51,10 @@ RMFont::~RMFont() { /** * Dumps a font to a buffer - * @param buf Buffer for font contents - * @param nChars Number of characters (max 256) - * @param dimx X dimension in pixels - * @param dimy Y dimension in pixels + * @param buf Buffer for font contents + * @param nChars Number of characters (max 256) + * @param dimx X dimension in pixels + * @param dimy Y dimension in pixels * \****************************************************************************/ @@ -323,7 +323,7 @@ void RMFontParla::Init(void) { lTable['E'] = 10; lTable['F'] = 11; - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ꣳ󌜯 @@ -370,7 +370,7 @@ void RMFontParla::Init(void) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 130; @@ -575,7 +575,7 @@ void RMFontParla::Init(void) { lTable[(byte)''] = 13; lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (_vm->getLanguage() == Common::FR_FRA) { // French cTable[(byte)''] = 226; @@ -687,7 +687,7 @@ void RMFontMacc::Init(void) { //cTable[(byte)''] = 100; // u with ball cTable[(byte)''] = 101; - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ꣳ󌜯 @@ -733,7 +733,7 @@ void RMFontMacc::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 120; cTable[(byte)''] = 121; @@ -1183,7 +1183,7 @@ void RMFontCredits::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; @@ -1581,7 +1581,7 @@ void RMFontObj::Init(void) { SetBothCase('R', 'R', 1); SetBothCase('R', 'U', 3); - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //ꣳ󌜯 //AaCcEeLlNnOoSsZzZz @@ -1614,8 +1614,8 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = cTable[(byte)''] = 85; @@ -1725,7 +1725,7 @@ void RMFontObj::Init(void) { lTable[(byte)''] = lTable[(byte)''] = 16; lTable[(byte)''] = lTable[(byte)''] = 16; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters @@ -1854,7 +1854,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Back to the first usable space // // BERNIE: In the original, sentences containing words that exceed the - // width of a line caused discontinuation of the whole sentence. + // width of a line caused discontinuation of the whole sentence. // This workaround has the partial word broken up so it will still display // old_p = p; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 8fe05abb3b05..dc5e412f0004 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,7 +43,7 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Global functions */ +/* Global functions */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6ec10b3aaafc..be59a2d9a5c1 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -173,7 +173,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int if (x1 > destw - 1) return false; - + if (y1 > desth - 1) return false; @@ -206,11 +206,11 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int /** * Initialises a surface by resource Id * - * @param resID Resource ID - * @param dimx Buffer X dimension - * @param dimy Buffer Y dimension + * @param resID Resource ID + * @param dimx Buffer X dimension + * @param dimy Buffer Y dimension */ - int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } @@ -478,7 +478,7 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer4::Bpp() { return 4; @@ -565,7 +565,7 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer8::Bpp() { return 8; @@ -1894,7 +1894,7 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer16::Bpp() { return 16; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index f7ea40fa9b4d..ffeb7724b251 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -39,7 +39,7 @@ namespace Tony { * Prototipi di classi \****************************************************************************/ -// Class Name Family Treee Abstract? +// Class Name Family Treee Abstract? class RMGfxTask; // Yes class RMGfxTaskSetPrior; // Task Yes class RMGfxBuffer; // diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index e090faacdcd2..539dd4e81b38 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -100,7 +100,7 @@ void RMInventory::Init(void) { assert(res.IsValid()); - // Initialise the MPAL inventory item by reading it in. + // Initialise the MPAL inventory item by reading it in. m_items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); ds >> m_items[i].icon; @@ -149,9 +149,9 @@ void RMInventory::Init(void) { RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); // Examine - m_hints[1].WriteText(msg2[0], 1); // Take - m_hints[2].WriteText(msg3[0], 1); // Use + m_hints[0].WriteText(msg1[0], 1); // Examine + m_hints[1].WriteText(msg2[0], 1); // Take + m_hints[2].WriteText(msg3[0], 1); // Use // Prepare initial inventory @@ -921,11 +921,11 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); // Take - m_hints[1].WriteText(msg1[0], 1); // Talk - m_hints[2].WriteText(msg2[0], 1); // Use - m_hints[3].WriteText(msg3[0], 1); // Examine - m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_hints[0].WriteText(msg0[0], 1); // Take + m_hints[1].WriteText(msg1[0], 1); // Talk + m_hints[2].WriteText(msg2[0], 1); // Use + m_hints[3].WriteText(msg3[0], 1); // Examine + m_hints[4].WriteText(msg4[0], 1); // Show Yourself m_bActive = false; m_bPalesati = false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 678caa1c7836..a5f02603e788 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -40,7 +40,7 @@ namespace Tony { struct RMInventoryItem { RMItem icon; - RMGfxSourceBuffer8RLEByteAA *pointer; + RMGfxSourceBuffer8RLEByteAA *pointer; int status; }; @@ -57,7 +57,7 @@ class RMInventory : public RMGfxWoodyBuffer { protected: int m_nItems; RMInventoryItem *m_items; - + int m_inv[256]; int m_nInv; int m_curPutY; @@ -69,13 +69,13 @@ class RMInventory : public RMGfxWoodyBuffer { int m_nSelectObj; int m_nCombine; bool m_bCombining; - + bool m_bBlinkingRight, m_bBlinkingLeft; int miniAction; RMItem miniInterface; RMText m_hints[3]; - + OSystem::MutexRef m_csModifyInterface; protected: @@ -90,7 +90,7 @@ class RMInventory : public RMGfxWoodyBuffer { virtual ~RMInventory(); // Prepare a frame - void DoFrame(RMGfxTargetBuffer& bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); + void DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); // Initialisation and closing void Init(void); @@ -111,20 +111,29 @@ class RMInventory : public RMGfxWoodyBuffer { // Handle the left mouse click (only when the inventory has the focus) bool LeftClick(const RMPoint &mpos, int &nCombineObj); - + // Handle the right mouse button (only when the inventory has the focus) void RightClick(const RMPoint &mpos); bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Warn that an item combine is over void EndCombine(void); - -public: + +public: // Add an item to the inventory void AddItem(int code); - RMInventory& operator+=(RMItem *item) { AddItem(item->MpalCode()); return *this; } - RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } - RMInventory& operator+=(int code) { AddItem(code); return *this; } + RMInventory &operator+=(RMItem *item) { + AddItem(item->MpalCode()); + return *this; + } + RMInventory &operator+=(RMItem &item) { + AddItem(item.MpalCode()); + return *this; + } + RMInventory &operator+=(int code) { + AddItem(code); + return *this; + } // Removes an item void RemoveItem(int code); @@ -163,10 +172,10 @@ class RMInterface : public RMGfxSourceBuffer8RLEByte { virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) - void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); + void DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); // TRUE if it is active (you can select items) - bool Active(); + bool Active(); // Initialisation void Init(void); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d14b6972c8dc..f0dd30b1a9b9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -44,13 +44,13 @@ using namespace ::Tony::MPAL; /** * Operator for reading palette information from a data stream. * - * @param ds Data stream - * @param pal Destination palette + * @param ds Data stream + * @param pal Destination palette * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal.m_data,1024); + ds.Read(pal.m_data, 1024); return ds; } @@ -61,10 +61,10 @@ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { /** * Operator for reading slot information from a data stream. * - * @param ds Data stream - * @param slot Destination slot + * @param ds Data stream + * @param slot Destination slot * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { slot.ReadFromStream(ds); @@ -78,7 +78,7 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { // Type ds >> type; m_type = (RMPattern::RMSlotType)type; - + // Dati ds >> m_data; @@ -97,10 +97,10 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { /** * Operator for reading pattern information from a data stream * - * @param ds Data stream - * @param pat Destination pattern + * @param ds Data stream + * @param pat Destination pattern * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { pat.ReadFromStream(ds); @@ -170,35 +170,35 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { m_nCurSprite = m_slots[i].m_data; if (bFlag) *bFlag = m_slots[i].m_flag; - + // Calculate the current coordinates UpdateCoord(); - + // Check for sound: // If the slot is 0, play // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop - for (i = 0;i < m_nSlots; i++) { + for (i = 0; i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { if (i == 0) { if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } else { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } } else if (m_speed == 0) { if (bPlayP0) { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } } else { if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } } @@ -214,13 +214,13 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { // If the speed is 0, then the pattern never advances if (m_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); - bFlag=m_slots[m_nCurSlot].m_flag; + bFlag = m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } // Is it time to change the slots? while (m_nStartTime + m_speed <= (uint32)CurTime) { - m_nStartTime += m_speed; + m_nStartTime += m_speed; if (m_slots[m_nCurSlot].m_type == SPRITE) m_nCurSlot++; if (m_nCurSlot == m_nSlots) { @@ -234,7 +234,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (!m_bLoop) { m_nCurSlot = m_nSlots - 1; bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + return m_nCurSprite; } } @@ -243,7 +243,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case SPRITE: // Read the next sprite m_nCurSprite = m_slots[m_nCurSlot].m_data; - + // Update the parent & child coordinates UpdateCoord(); break; @@ -262,7 +262,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case COMMAND: assert(0); break; - + default: assert(0); break; @@ -271,11 +271,11 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (m_slots[m_nCurSlot].m_type == SPRITE) break; m_nCurSlot++; - } + } } // Return the current sprite - bFlag=m_slots[m_nCurSlot].m_flag; + bFlag = m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -283,11 +283,11 @@ RMPattern::RMPattern() { m_slots = NULL; m_speed = 0; m_bLoop = 0; - m_nSlots = 0; + m_nSlots = 0; m_nCurSlot = 0; m_nCurSprite = 0; m_nStartTime = 0; - m_slots = NULL; + m_slots = NULL; } RMPattern::~RMPattern() { @@ -307,10 +307,10 @@ RMPattern::~RMPattern() { /** * Operator for reading sprite information from a data stream. * - * @param ds Data stream - * @param sprite Destination slot + * @param ds Data stream + * @param sprite Destination slot * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { sprite.ReadFromStream(ds); @@ -339,8 +339,8 @@ void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { } void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { - int dimx,dimy; - + int dimx, dimy; + // Sprite name if (!bLOX) ds >> m_name; @@ -364,11 +364,11 @@ void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) } void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal*)m_buf)->LoadPalette(buf); + ((RMGfxSourceBufferPal *)m_buf)->LoadPalette(buf); } RMSprite::RMSprite() { - m_buf= NULL; + m_buf = NULL; } RMSprite::~RMSprite() { @@ -386,10 +386,10 @@ RMSprite::~RMSprite() { /** * Operator for reading SFX information from a data stream. * - * @param ds Data stream - * @param sfx Destination SFX + * @param ds Data stream + * @param sfx Destination SFX * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { sfx.ReadFromStream(ds); @@ -400,10 +400,10 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { char id[4]; int size; byte *raw; - + // sfx name ds >> m_name; - + ds >> size; // Upload the sound effect identifier from the buffer @@ -416,7 +416,7 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds >> size; // Read the raw WAV data - raw = new byte[size]; + raw = new byte[size]; ds.Read(raw, size); // Create the sound effect @@ -477,10 +477,10 @@ void RMSfx::Stop(void) { /** * Operator for reading item information from a data stream. * - * @param ds Data stream - * @param tem Destination item + * @param ds Data stream + * @param tem Destination item * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { item.ReadFromStream(ds); @@ -491,15 +491,15 @@ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (m_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; - - if (m_FX == 2) { // AB + + if (m_FX == 2) { // AB spr = new RMGfxSourceBuffer8RLEWordAB; - } else if (m_FX == 1) { // OMBRA+AA + } else if (m_FX == 1) { // OMBRA+AA if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWordAA; else spr = new RMGfxSourceBuffer8RLEByteAA; - + spr->SetAlphaBlendColor(m_FXparm); if (bPreRLE) spr->SetAlreadyCompressed(); @@ -518,25 +518,25 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(const RMPoint &pt, int *size) { +bool RMItem::IsIn(const RMPoint &pt, int *size) { RMRect rc; - - if (!m_bIsActive) - return false; - + + if (!m_bIsActive) + return false; + // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) - rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); + rc = m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); else if (!m_rcBox.IsEmpty()) rc = m_rcBox; // If no box, return immediately else return false; - - if (size != NULL) - *size = rc.Size(); - - return rc.PtInRect(pt + m_curScroll); + + if (size != NULL) + *size = rc.Size(); + + return rc.PtInRect(pt + m_curScroll); } @@ -566,7 +566,8 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { ds >> m_nSprites >> m_nSfx >> m_nPatterns; // Color mode - ds >> cm; m_cm=(RMColorMode)cm; + ds >> cm; + m_cm = (RMColorMode)cm; // Flag for the presence of custom palette differences ds >> m_bPal; @@ -580,40 +581,40 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // MPAL data if (!bLOX) ds += 20; - + ds >> m_FX; ds >> m_FXparm; if (!bLOX) - ds += 106; - + ds += 106; + // Create sub-classes if (m_nSprites > 0) - m_sprites = new RMSprite[m_nSprites]; + m_sprites = new RMSprite[m_nSprites]; if (m_nSfx > 0) m_sfx = new RMSfx[m_nSfx]; - m_patterns = new RMPattern[m_nPatterns+1]; + m_patterns = new RMPattern[m_nPatterns + 1]; // Read in class data if (!ds.IsError()) for (i = 0; i < m_nSprites && !ds.IsError(); i++) { - // Download the sprites - if (bLOX) { - m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); - m_sprites[i].ReadFromStream(ds, true); - } else { - m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); - m_sprites[i].ReadFromStream(ds, false); - } - - if (m_cm == CM_256 && m_bPal) + // Download the sprites + if (bLOX) { + m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); + m_sprites[i].ReadFromStream(ds, true); + } else { + m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); + m_sprites[i].ReadFromStream(ds, false); + } + + if (m_cm == CM_256 && m_bPal) m_sprites[i].SetPalette(m_pal.m_data); - } + } if (!ds.IsError()) - for (i = 0;i < m_nSfx && !ds.IsError(); i++) { + for (i = 0; i < m_nSfx && !ds.IsError(); i++) { if (bLOX) m_sfx[i].ReadFromStream(ds, true); else @@ -622,7 +623,7 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // Read the pattern from pattern 1 if (!ds.IsError()) - for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { + for (i = 1; i <= m_nPatterns && !ds.IsError(); i++) { if (bLOX) m_patterns[i].ReadFromStream(ds, true); else @@ -692,8 +693,8 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // If CurSprite == -1, then the pattern is finished if (m_nCurSprite == -1) - return; - + return; + // Set the flag prim->SetFlag(m_bCurFlag); @@ -730,9 +731,9 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { assert(nPattern >= 0 && nPattern <= m_nPatterns); if (m_sfx) - if (m_nCurPattern>0) + if (m_nCurPattern > 0) m_patterns[m_nCurPattern].StopSfx(m_sfx); - + // Remember the current pattern m_nCurPattern = nPattern; @@ -741,10 +742,10 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); else { m_nCurSprite = -1; - + // Look for the sound effect for pattern 0 if (bPlayP0) - for (i = 0;i < m_nSfx; i++) + for (i = 0; i < m_nSfx; i++) if (strcmp(m_sfx[i].m_name, "p0") == 0) m_sfx[i].Play(); } @@ -758,7 +759,7 @@ bool RMItem::GetName(RMString &name) { name = buf; if (buf[0] == '\0') return false; - return true; + return true; } @@ -767,12 +768,12 @@ void RMItem::Unload(void) { delete[] m_patterns; m_patterns = NULL; } - + if (m_sprites != NULL) { delete[] m_sprites; m_sprites = NULL; } - + if (m_sfx != NULL) { delete[] m_sfx; m_sfx = NULL; @@ -809,7 +810,7 @@ RMItem::~RMItem() { void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; - uint32 h[2]; + uint32 h[2]; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -880,7 +881,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); m_bEndFade = true; m_bFading = false; @@ -910,7 +911,7 @@ void RMWipe::InitFade(int type) { ds.OpenBuffer(res); ds >> m_wip0r; ds.Close(); - + m_wip0r.SetPattern(1); m_bFading = true; @@ -921,12 +922,12 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); m_bMustRegister = false; } - + if (m_bFading) { m_wip0r.DoFrame(&bigBuf, false); m_nFadeStep++; - + if (m_nFadeStep == 10) { CoroScheduler.setEvent(m_hEndOfFade); } @@ -961,17 +962,17 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes + static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated static short NEXT[MAXBOXES]; // Prossimo Nodo short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; - g_system->lockMutex(csMove); + g_system->lockMutex(csMove); if (source == -1 || destination == -1) { - g_system->unlockMutex(csMove); + g_system->unlockMutex(csMove); return 0; } @@ -983,37 +984,37 @@ short RMCharacter::FindPath(short source, short destination) { memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->numbbox; i++) VALIDO[i] = 0; - + // Prepare source and variables for the procedure COSTO[source] = 0; VALIDO[source] = 1; fine = 0; - - // Find the shortest path - while(!fine) { - costominimo = 32000; // Reset the minimum cost - errore = 1; // Possible error + + // Find the shortest path + while (!fine) { + costominimo = 32000; // Reset the minimum cost + errore = 1; // Possible error // 1st cycle: explore possible new nodes for (i = 0; i < cur->numbbox; i++) if (VALIDO[i] == 1) { - errore = 0; // Failure de-bunked + errore = 0; // Failure de-bunked j = 0; - while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) j++; - - if (j >= cur->numbbox) + + if (j >= cur->numbbox) VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; - if (COSTO[i] + 1 < costominimo) + if (COSTO[i] + 1 < costominimo) costominimo = COSTO[i] + 1; } } - if (errore) + if (errore) fine = 1; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes @@ -1023,10 +1024,10 @@ short RMCharacter::FindPath(short source, short destination) { COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; for (j = 0; j < cur->numbbox; j++) - if (BOX[j].adj[NEXT[i]] == 1) + if (BOX[j].adj[NEXT[i]] == 1) BOX[j].adj[NEXT[i]] = 0; - - if (NEXT[i] == destination) + + if (NEXT[i] == destination) fine = 1; } } @@ -1036,7 +1037,7 @@ short RMCharacter::FindPath(short source, short destination) { pathlenght = COSTO[destination]; k = pathlenght; path[k] = destination; - + while (path[k] != source) { i = 0; while (BOX[i].adj[path[k]] != 2) @@ -1044,7 +1045,7 @@ short RMCharacter::FindPath(short source, short destination) { k--; path[k] = i; } - + pathlenght++; } @@ -1081,38 +1082,38 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkcount = 0; if (bReversed) { - while (0) ; + while (0) ; } int nPatt = GetCurPattern(); if (dx > dy) { slope = fy / fx; - if (lineend.x < linestart.x) + if (lineend.x < linestart.x) walkspeed = -walkspeed; walkstatus = 1; - + // Change the pattern for the new direction bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { - if (nPatt != PAT_WALKLEFT) - SetPattern(PAT_WALKLEFT); + if (nPatt != PAT_WALKLEFT) + SetPattern(PAT_WALKLEFT); } else { - if (nPatt != PAT_WALKRIGHT) + if (nPatt != PAT_WALKRIGHT) SetPattern(PAT_WALKRIGHT); } } else { slope = fx / fy; - if (lineend.y < linestart.y) + if (lineend.y < linestart.y) walkspeed = -walkspeed; walkstatus = 0; - + bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { - if (nPatt != PAT_WALKUP) - SetPattern(PAT_WALKUP); + if (nPatt != PAT_WALKUP) + SetPattern(PAT_WALKUP); } else { - if (nPatt != PAT_WALKDOWN) + if (nPatt != PAT_WALKDOWN) SetPattern(PAT_WALKDOWN); } } @@ -1132,9 +1133,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo)&& - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + while ((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { + nuovo.y--; + passi++; + } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.y--; // to avoid error? trovato = nuovo; @@ -1144,9 +1148,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { + nuovo.y++; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.y++; // to avoid error? trovato = nuovo; @@ -1156,9 +1163,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { + nuovo.x++; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.x++; // to avoid error? trovato = nuovo; @@ -1168,9 +1178,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { + nuovo.x--; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.x--; // to avoid error? trovato = nuovo; @@ -1210,7 +1223,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed =- Lspeed; + if (Lend.y < Lstart.y) Lspeed = - Lspeed; Lstatus = 0; } @@ -1227,7 +1240,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; - + if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; } @@ -1253,11 +1266,11 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { Ldy = ABS(Ldy); Lspeed = 1; Lcount = 0; - + if (Ldx > Ldy) { Lslope = Lfy / Lfx; if (Lend.x < Lstart.x) Lspeed = -Lspeed; - Lstatus=1; + Lstatus = 1; } else { Lslope = Lfx / Lfy; if (Lend.y < Lstart.y) Lspeed = -Lspeed; @@ -1268,9 +1281,9 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { for (;;) { if (InWhichBox(Lscan) != -1) { if (InWhichBox(Lscan) != Lbox) { - if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos),InWhichBox(Lscan))) + if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos), InWhichBox(Lscan))) return Lscan; - else + else Lbox = InWhichBox(Lscan); } } @@ -1279,10 +1292,10 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { if (Lstatus) { Ldx = Lspeed * Lcount; Ldy = Lslope * Ldx; - } else { + } else { Ldy = Lspeed * Lcount; Ldx = Lslope * Ldy; - } + } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; } @@ -1299,19 +1312,19 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { int x, y, distanzaminima; distanzaminima = 10000000; RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); - + for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); - + if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; } } - + return puntocaldo; } @@ -1333,7 +1346,7 @@ void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMCharacter::NewBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; - + // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); @@ -1371,11 +1384,11 @@ void RMCharacter::NewBoxEntered(int nBox) { // Recall On EnterBox mpalQueryDoAction(2, curLocation, curbox); } - -void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { + +void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CONTEXT; - bool bEndNow; - RMBoxLoc *cur; + bool bEndNow; + RMBoxLoc *cur; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1402,7 +1415,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { _ctx->bEndNow = true; } } - + // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; @@ -1431,11 +1444,11 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } - + walkcount++; // Update the character Z. @@@ Should remove only if the Z was changed - + // Check if the box was changed if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) NewBoxEntered(InWhichBox(m_pos)); @@ -1454,10 +1467,10 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { // If we still have to go through a box if (pathcount < pathlenght) { // Check if the box we're going into is active - if (_ctx->cur->boxes[path[pathcount-1]].attivo) { + if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); + CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); pathcount++; } else { // If the box is off, we can only block all @@ -1470,7 +1483,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { CoroScheduler.pulseEvent(hEndOfPath); } } else { - // If we have already entered the last box, we just have to move in a straight line towards the + // If we have already entered the last box, we just have to move in a straight line towards the // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; @@ -1520,7 +1533,7 @@ void RMCharacter::Stop(CORO_PARAM) { case PAT_WALKRIGHT: SetPattern(PAT_STANDRIGHT); break; - + default: SetPattern(PAT_STANDDOWN); break; @@ -1529,22 +1542,22 @@ void RMCharacter::Stop(CORO_PARAM) { CORO_END_CODE; } -inline int RMCharacter::InWhichBox(const RMPoint &pt) { - return theBoxes->WhichBox(curLocation, pt); +inline int RMCharacter::InWhichBox(const RMPoint &pt) { + return theBoxes->WhichBox(curLocation, pt); } void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CONTEXT; - RMPoint dest; - int numbox; - RMBoxLoc *cur; + RMPoint dest; + int numbox; + RMBoxLoc *cur; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); bMoving = true; - + // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { minpath = 0; @@ -1556,7 +1569,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { } // If clicked outside the box - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = InWhichBox(pt); if (_ctx->numbox == -1) { // Find neareste point inside the box _ctx->dest = NearestPoint(pt); @@ -1574,7 +1587,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { minpath = 0; status = STAND; bMovingWithoutMinpath = true; - if (ScanLine(pt)) + if (ScanLine(pt)) CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; @@ -1586,8 +1599,8 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { // a path to get there. We use the InvScanLine to search around a point _ctx->dest = InvScanLine(pt); pt = _ctx->dest; - - if (ScanLine(pt)) + + if (ScanLine(pt)) CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; @@ -1612,11 +1625,11 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; - + minpath = 0; status = STAND; m_pos = pt; - + if (newloc != -1) curLocation = newloc; @@ -1628,14 +1641,14 @@ void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { bRemoveFromOT = true; } -void RMCharacter::WaitForEndMovement(CORO_PARAM) { +void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (bMoving) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); + if (bMoving) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1722,9 +1735,12 @@ void RMBox::ReadFromStream(RMDataStream &ds) { // Hotspots for (i = 0; i < numhotspot; i++) { - ds >> w; hotspot[i].hotx = w; - ds >> w; hotspot[i].hoty = w; - ds >> w; hotspot[i].destination = w; + ds >> w; + hotspot[i].hotx = w; + ds >> w; + hotspot[i].hoty = w; + ds >> w; + hotspot[i].destination = w; } } @@ -1811,7 +1827,7 @@ void RMGameBoxes::Init(void) { RMRes res(10000 + i); ds.OpenBuffer(res); - + m_allBoxes[i] = new RMBoxLoc(); ds >> *m_allBoxes[i]; @@ -1832,7 +1848,7 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = GetBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && - (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) return true; else return false; @@ -1841,20 +1857,20 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { int i; RMBoxLoc *cur = GetBoxes(nLoc); - + if (!cur) return -1; - for (i = 0; inumbbox; i++) + for (i = 0; i < cur->numbbox; i++) if (cur->boxes[i].attivo) - if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && - (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && + (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) return i; return -1; } void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { - m_allBoxes[nLoc]->boxes[nBox].attivo=status; + m_allBoxes[nLoc]->boxes[nBox].attivo = status; m_allBoxes[nLoc]->RecalcAllAdj(); } @@ -1863,9 +1879,9 @@ int RMGameBoxes::GetSaveStateSize(void) { int size; int i; - size=4; + size = 4; - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { size += 4; size += m_allBoxes[i]->numbbox; } @@ -1874,17 +1890,17 @@ int RMGameBoxes::GetSaveStateSize(void) { } void RMGameBoxes::SaveState(byte *state) { - int i,j; - + int i, j; + // Save the number of locations with boxes WRITE_LE_UINT32(state, m_nLocBoxes); state += 4; // For each location, write out the number of boxes and their status - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); state += 4; - + for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; } @@ -1905,8 +1921,8 @@ void RMGameBoxes::LoadState(byte *state) { nbox = READ_LE_UINT32(state); state += 4; - for (j = 0; jnumbbox) + for (j = 0; j < nbox ; j++) { + if (j < m_allBoxes[i]->numbbox) m_allBoxes[i]->boxes[j].attivo = *state; state++; @@ -1933,7 +1949,7 @@ RMLocation::RMLocation() { /** * Load a location (.LOC) from a file that is provided. * - * @param lpszFileName Name of the file + * @param lpszFileName Name of the file */ bool RMLocation::Load(const char *lpszFileName) { Common::File f; @@ -1956,9 +1972,9 @@ bool RMLocation::Load(const char *lpszFileName) { /** * Load a location (.LOC) from a given open file * - * @param hFile File reference + * @param hFile File reference * - * @returns True if succeeded OK, false in case of error. + * @returns True if succeeded OK, false in case of error. */ bool RMLocation::Load(Common::File &file) { int size; @@ -1973,7 +1989,7 @@ bool RMLocation::Load(Common::File &file) { fs.OpenFile(file); bRet = Load(fs); fs.Close(); - + return bRet; } @@ -1992,8 +2008,8 @@ bool RMLocation::Load(const byte *buf) { /** * Load a location (.LOC) from a given data stream * - * @param ds Data stream - * @returns True if succeeded OK, false in case of error. + * @param ds Data stream + * @returns True if succeeded OK, false in case of error. */ bool RMLocation::Load(RMDataStream &ds) { char id[3]; @@ -2004,14 +2020,14 @@ bool RMLocation::Load(RMDataStream &ds) { // Check the ID ds >> id[0] >> id[1] >> id[2]; - + // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') return LoadLOX(ds); - + // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') - return false; + return false; // Version ds >> ver; @@ -2033,10 +2049,11 @@ bool RMLocation::Load(RMDataStream &ds) { m_curScroll.Set(0, 0); // Read the colour mode - ds >> cm; m_cmode = (RMColorMode)cm; + ds >> cm; + m_cmode = (RMColorMode)cm; // Initialise the source buffer and read the location - switch (m_cmode) { + switch (m_cmode) { case CM_256: m_buf = new RMGfxSourceBuffer8; break; @@ -2044,7 +2061,7 @@ bool RMLocation::Load(RMDataStream &ds) { case CM_65K: m_buf = new RMGfxSourceBuffer16; break; - + default: assert(0); break; @@ -2052,7 +2069,7 @@ bool RMLocation::Load(RMDataStream &ds) { // Initialise the surface, loading the palette if necessary m_buf->Init(ds, dimx, dimy, true); - + // Check the size of the location // assert(dimy!=512); @@ -2065,7 +2082,7 @@ bool RMLocation::Load(RMDataStream &ds) { _vm->FreezeTime(); - for (i = 0;i < m_nItems && !ds.IsError(); i++) + for (i = 0; i < m_nItems && !ds.IsError(); i++) ds >> m_items[i]; _vm->UnfreezeTime(); @@ -2099,14 +2116,14 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { // Initialise the surface, loading in the palette if necessary m_buf->Init(ds, dimx, dimy, true); - + // Number of items ds >> m_nItems; // Create and read objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; - + for (i = 0; i < m_nItems && !ds.IsError(); i++) m_items[i].ReadFromStream(ds, true); @@ -2124,12 +2141,12 @@ void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { - prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); + if (m_buf->Dimy() > RM_SY || m_buf->Dimx() > RM_SX) { + prim->SetSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); } prim->SetDst(m_fixedScroll); - + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); @@ -2148,33 +2165,33 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->AddPrim(new RMGfxPrimitive(this)); // Process all the location items - for (i = 0;i < m_nItems; i++) + for (i = 0; i < m_nItems; i++) m_items[i].DoFrame(bigBuf); } RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { int i; - + for (i = 0; i < m_nItems; i++) if (m_items[i].MpalCode() == (int)dwCode) return &m_items[i]; - - return NULL; + + return NULL; } RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; - + for (int i = 0; i < m_nItems; i++) { size = 0; if (m_items[i].IsIn(pt, &size)) { if (found == -1 || size < foundSize) { foundSize = size; found = i; - } + } } } @@ -2249,8 +2266,8 @@ void RMLocation::SetScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX>m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; - if (pt.y + RM_SY>m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + if (pt.x + RM_SX > m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; + if (pt.y + RM_SY > m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; m_curScroll = pt; @@ -2271,7 +2288,7 @@ void RMLocation::PauseSound(bool bPause) { * RMMessage Methods \****************************************************************************/ -RMMessage::RMMessage(uint32 dwId) { +RMMessage::RMMessage(uint32 dwId) { Load(dwId); } @@ -2287,19 +2304,19 @@ RMMessage::~RMMessage() { void RMMessage::Load(uint32 dwId) { lpMessage = mpalQueryMessage(dwId); assert(lpMessage != NULL); - + if (lpMessage) ParseMessage(); } void RMMessage::ParseMessage(void) { char *p; - + assert(lpMessage != NULL); - + nPeriods = 1; p = lpPeriods[0] = lpMessage; - + for (;;) { // Find the end of the current period while (*p != '\0') diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7085c81dcb69..612e7b5d3e4e 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -62,7 +62,7 @@ class RMPalette { byte m_data[1024]; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); + friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); }; @@ -79,14 +79,14 @@ class RMSfx { RMSfx(); virtual ~RMSfx(); - friend RMDataStream& operator>>(RMDataStream &ds, RMSfx &sfx); + friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); void Play(bool bLoop = false); void SetVolume(int vol); void Pause(bool bPause); void Stop(void); - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -111,44 +111,46 @@ class RMPattern { RMPoint m_pos; // Child co-ordinates public: - RMSlotType m_type; + RMSlotType m_type; int m_data; byte m_flag; public: - friend RMDataStream& operator>>(RMDataStream& ds, RMSlot& slot); + friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint Pos() { return m_pos; } + RMPoint Pos() { + return m_pos; + } - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; public: - RMString m_name; + RMString m_name; private: - int m_speed; - RMPoint m_pos; // Parent coordinates - RMPoint m_curPos; // Parent + child coordinates - int m_bLoop; - int m_nSlots; + int m_speed; + RMPoint m_pos; // Parent coordinates + RMPoint m_curPos; // Parent + child coordinates + int m_bLoop; + int m_nSlots; int m_nCurSlot; int m_nCurSprite; - RMSlot *m_slots; + RMSlot *m_slots; uint32 m_nStartTime; public: RMPattern(); virtual ~RMPattern(); - - friend RMDataStream& operator>>(RMDataStream& ds, RMPattern& pat); + + friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); // A warning that the pattern now and the current - int Init(RMSfx* sfx, bool bPlayP0=false, byte* bFlag=NULL); + int Init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); - // Update the pattern, checking to see if it's time to change slot and executing + // Update the pattern, checking to see if it's time to change slot and executing // any associated commands int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); @@ -156,9 +158,11 @@ class RMPattern { void StopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint Pos() { return m_curPos; } + RMPoint Pos() { + return m_curPos; + } - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); private: void UpdateCoord(void); @@ -170,24 +174,24 @@ class RMPattern { */ class RMSprite : public RMGfxTask { public: - RMString m_name; - RMRect m_rcBox; + RMString m_name; + RMRect m_rcBox; protected: - RMGfxSourceBuffer* m_buf; + RMGfxSourceBuffer *m_buf; public: RMSprite(); virtual ~RMSprite(); - void Init(RMGfxSourceBuffer* buf); - friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); + void Init(RMGfxSourceBuffer *buf); + friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); - void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); - void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -196,31 +200,33 @@ class RMSprite : public RMGfxTask { */ class RMItem : public RMGfxTask { public: - RMString m_name; + RMString m_name; protected: - int m_z; - RMPoint m_pos; // Coordinate nonno + int m_z; + RMPoint m_pos; // Coordinate nonno RMColorMode m_cm; RMPoint m_curScroll; byte m_FX; byte m_FXparm; - virtual int GetCurPattern() { return m_nCurPattern; } + virtual int GetCurPattern() { + return m_nCurPattern; + } private: int m_nCurPattern; int m_mpalCode; - RMPoint m_hot; + RMPoint m_hot; RMRect m_rcBox; - int m_nSprites,m_nSfx,m_nPatterns; - byte m_bPal; - RMPalette m_pal; + int m_nSprites, m_nSfx, m_nPatterns; + byte m_bPal; + RMPalette m_pal; - RMSprite *m_sprites; - RMSfx *m_sfx; - RMPattern *m_patterns; + RMSprite *m_sprites; + RMSfx *m_sfx; + RMPattern *m_patterns; byte m_bCurFlag; int m_nCurSprite; @@ -235,7 +241,7 @@ class RMItem : public RMGfxTask { RMItem(); virtual ~RMItem(); - friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); + friend RMDataStream &operator>>(RMDataStream &ds, RMItem &item); // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame @@ -246,15 +252,19 @@ class RMItem : public RMGfxTask { // Overloading of check whether to remove from active list virtual void RemoveThis(CORO_PARAM, bool &result); - + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int Priority() { return m_z; } + virtual int Priority() { + return m_z; + } // Pattern number - int NumPattern() { return m_nPatterns; } + int NumPattern() { + return m_nPatterns; + } // Set anew animation pattern, changing abruptly from the current virtual void SetPattern(int nPattern, bool bPlayP0 = false); @@ -263,9 +273,13 @@ class RMItem : public RMGfxTask { void SetStatus(int nStatus); bool IsIn(const RMPoint &pt, int *size = NULL); - RMPoint Hotspot() { return m_hot; } + RMPoint Hotspot() { + return m_hot; + } bool GetName(RMString &name); - int MpalCode() { return m_mpalCode; } + int MpalCode() { + return m_mpalCode; + } // Unload void Unload(void); @@ -276,11 +290,13 @@ class RMItem : public RMGfxTask { // Sets a new hotspot fro the object void ChangeHotspot(const RMPoint &pt); - void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } + void SetInitCurPattern(bool status) { + m_bInitCurPattern = status; + } void PlaySfx(int nSfx); -void ReadFromStream(RMDataStream& ds, bool bLOX=false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); void PauseSound(bool bPause); @@ -293,8 +309,8 @@ void ReadFromStream(RMDataStream& ds, bool bLOX=false); }; -#define MAXBOXES 50 // Maximum number of allowed boxes -#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots +#define MAXBOXES 50 // Maximum number of allowed boxes +#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots class RMBox { public: @@ -304,11 +320,11 @@ class RMBox { }; public: - int left, top, right, bottom; // Vertici bounding boxes - int adj[MAXBOXES]; // List of adjacent bounding boxes - int numhotspot; // Hotspot number - uint8 Zvalue; // Z value for the bounding box - T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots + int left, top, right, bottom; // Vertici bounding boxes + int adj[MAXBOXES]; // List of adjacent bounding boxes + int numhotspot; // Hotspot number + uint8 Zvalue; // Z value for the bounding box + T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots bool attivo; bool bReversed; @@ -327,19 +343,19 @@ class RMBoxLoc { RMBox *boxes; private: - void ReadFromStream(RMDataStream& ds); + void ReadFromStream(RMDataStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); - friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); + friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); void RecalcAllAdj(void); }; #define GAME_BOXES_SIZE 200 -class RMGameBoxes { +class RMGameBoxes { protected: RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; int m_nLocBoxes; @@ -348,19 +364,19 @@ class RMGameBoxes { RMGameBoxes(); ~RMGameBoxes(); - void Init(void); + void Init(void); void Close(void); // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); int GetLocBoxesCount() const { return m_nLocBoxes; } - + // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); // Check whether a point is inside a given box bool IsInBox(int nLoc, int nBox, const RMPoint &pt); - + // Change the status of a box void ChangeBoxStatus(int nLoc, int nBox, int status); @@ -380,7 +396,7 @@ class RMCharacter : protected RMItem { PAT_WALKUP, PAT_WALKDOWN, PAT_WALKLEFT, - PAT_WALKRIGHT + PAT_WALKRIGHT }; private: @@ -399,7 +415,7 @@ class RMCharacter : protected RMItem { short path[MAXBOXES]; short pathlenght, pathcount; int curbox; - + STATUS status; int curSpeed; bool bEndOfPath; @@ -409,17 +425,17 @@ class RMCharacter : protected RMItem { bool bRemoveFromOT; bool bMovingWithoutMinpath; RMGameBoxes *theBoxes; - + RMPoint m_fixedScroll; - + private: - int InWhichBox(const RMPoint &pt); - + int InWhichBox(const RMPoint &pt); + short FindPath(short source, short destination); RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); RMPoint NearestPoint(const RMPoint &punto); - - void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); + + void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); short ScanLine(const RMPoint &punto); RMPoint InvScanLine(const RMPoint &punto); RMPoint NearestHotSpot(int sourcebox, int destbox); @@ -439,21 +455,25 @@ class RMCharacter : protected RMItem { void LinkToBoxes(RMGameBoxes *theBoxes); virtual void RemoveThis(CORO_PARAM, bool &result); - + // Update the position of a character - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool EndOfPath() { return bEndOfPath; } + bool EndOfPath() { + return bEndOfPath; + } // Change the pattern of a character to STOP virtual void Stop(CORO_PARAM); // Check if the character is moving - bool IsMoving() { return bMoving; } + bool IsMoving() { + return bMoving; + } // Move the character to a certain position void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); @@ -464,8 +484,12 @@ class RMCharacter : protected RMItem { // Wait for the end of movement void WaitForEndMovement(CORO_PARAM); - void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } - void SetSpeed(int speed) { curSpeed = speed; } + void SetFixedScroll(const RMPoint &fix) { + m_fixedScroll = fix; + } + void SetSpeed(int speed) { + curSpeed = speed; + } }; @@ -485,9 +509,9 @@ class RMWipe : public RMGfxTask { RMWipe(); virtual ~RMWipe(); - void DoFrame(RMGfxTargetBuffer& bigBuf); + void DoFrame(RMGfxTargetBuffer &bigBuf); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - + void InitFade(int type); void CloseFade(void); void WaitForFadeEnd(CORO_PARAM); @@ -503,25 +527,29 @@ class RMWipe : public RMGfxTask { */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Name + RMString m_name; // Name - private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer *m_buf; // Location picture +private: + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer *m_buf; // Location picture - int m_nItems; // Number of objects - RMItem *m_items; // Objects + int m_nItems; // Number of objects + RMItem *m_items; // Objects - RMPoint m_curScroll; // Current scroll position + RMPoint m_curScroll; // Current scroll position RMPoint m_fixedScroll; public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; - RMPoint TEMPGetTonyStart() { return TEMPTonyStart; } + RMPoint TEMPGetTonyStart() { + return TEMPTonyStart; + } int TEMPNumLoc; - int TEMPGetNumLoc() { return TEMPNumLoc; } + int TEMPGetNumLoc() { + return TEMPNumLoc; + } public: RMLocation(); @@ -559,7 +587,9 @@ class RMLocation : public RMGfxTaskSetPrior { void UpdateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint ScrollPosition() { return m_curScroll; } + RMPoint ScrollPosition() { + return m_curScroll; + } // Pause sound void PauseSound(bool bPause); @@ -584,10 +614,18 @@ class RMMessage { virtual ~RMMessage(); void Load(uint32 dwId); - bool IsValid() { return lpMessage != NULL; } - int NumPeriods() { return nPeriods; } - char *Period(int num) { return lpPeriods[num]; } - char *operator[](int num) { return lpPeriods[num]; } + bool IsValid() { + return lpMessage != NULL; + } + int NumPeriods() { + return nPeriods; + } + char *Period(int num) { + return lpPeriods[num]; + } + char *operator[](int num) { + return lpPeriods[num]; + } }; } // End of namespace Tony diff --git a/engines/tony/resid.h b/engines/tony/resid.h index aec4d4c38cd3..5215801d5d3c 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -27,7 +27,7 @@ */ /* - Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli + Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli */ #ifndef TONY_RESID_H #define TONY_RESID_H @@ -42,18 +42,18 @@ #define RES_I_INTERP4 10306 #define RES_I_INTERP5 10307 -#define RES_I_DLGTEXT 10350 +#define RES_I_DLGTEXT 10350 #define RES_I_DLGTEXTLINE 10351 -#define RES_I_DLGTEXTPAL 10352 +#define RES_I_DLGTEXTPAL 10352 -#define RES_I_MINIINTER 10360 +#define RES_I_MINIINTER 10360 -#define RES_P_PAL 10410 -#define RES_P_GO 10400 -#define RES_P_TAKE 10401 -#define RES_P_USE 10402 -#define RES_P_EXAM 10403 -#define RES_P_TALK 10404 +#define RES_P_PAL 10410 +#define RES_P_GO 10400 +#define RES_P_TAKE 10401 +#define RES_P_USE 10402 +#define RES_P_EXAM 10403 +#define RES_P_TALK 10404 #define RES_P_PAP1 10420 #define RES_P_PAP2 10421 diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 33dd6e1497a2..2f55bfad429f 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -151,8 +151,7 @@ CODEC::CODEC(bool loop) { bEndReached = false; } -CODEC::~CODEC() -{ +CODEC::~CODEC() { } @@ -228,24 +227,21 @@ uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { bEndReached = false; dwEOF = 0; - ReadFile(hStream,lpBuf,dwSize, &dwRead, NULL); - - if (dwRead>4)&0xF; - } - else - delta=cache&0xF; - - /* Trova il nuovo indice */ - index+=indexTable[delta]; - if (index<0) index = 0; - if (index>88) index=88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign=delta&8; - delta=delta&7; - - /* Trova la differenza dal valore precedente */ - vpdiff=step>>3; - if (delta&4) vpdiff+=step; - if (delta&2) vpdiff+=step>>1; - if (delta&1) vpdiff+=step>>2; - - if (sign) - valpred-=vpdiff; - else - valpred+=vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred<-32768) - valpred=-32768; - - /* Aggiorna lo step */ - step=stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf++ = (signed short)valpred; - - bufferstep=!bufferstep; - } - - return eof/2; + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + uint32 dwRead; + + bufferstep = 1; + step = stepSizeTable[index]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = (cache >> 4) & 0xF; + } else + delta = cache & 0xF; + + /* Trova il nuovo indice */ + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step >> 3; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred = -32768; + + /* Aggiorna lo step */ + step = stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf++ = (signed short)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; #endif - return 0; + return 0; } uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { @@ -489,9 +479,9 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { bufferstep = 1; step = stepSizeTable[index]; - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); inp = lpTemp; @@ -506,18 +496,18 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { eof = 0; dwSize /= 2; - for (i = 0;i < dwSize; i++) { + for (i = 0; i < dwSize; i++) { /* Controlla se siamo alla fine del file, e bisogna loopare */ if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step = stepSizeTable[index]; } /* Legge il delta (4 bit) */ if (bufferstep) { cache = *inp++; - delta = (cache>>4)&0xF; + delta = (cache >> 4) & 0xF; } else delta = cache & 0xF; @@ -527,14 +517,14 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { if (index > 88) index = 88; /* Legge il segno e lo separa dall'ampliamento */ - sign = delta&8; - delta = delta&7; + sign = delta & 8; + delta = delta & 7; /* Trova la differenza dal valore precedente */ vpdiff = step >> 3; - if (delta&4) vpdiff += step; - if (delta&2) vpdiff += step >> 1; - if (delta&1) vpdiff += step >> 2; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; if (sign) valpred -= vpdiff; @@ -545,13 +535,13 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { if (valpred > 32767) valpred = 32767; else if (valpred < -32768) - valpred =- 32768; + valpred = - 32768; /* Aggiorna lo step */ step = stepSizeTable[index]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred; + *lpBuf ++ = (signed short)valpred; bufferstep = !bufferstep; } @@ -596,7 +586,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { /* Controlla se siamo alla fine del file, e bisogna loopare */ if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step[0] = stepSizeTable[index[0]]; step[1] = stepSizeTable[index[1]]; } @@ -609,7 +599,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { delta = (cache >> 4) & 0xF; /* Trova il nuovo indice */ - index[bufferstep]+=indexTable[delta]; + index[bufferstep] += indexTable[delta]; if (index[bufferstep] < 0) index[bufferstep] = 0; if (index[bufferstep] > 88) index[bufferstep] = 88; @@ -620,13 +610,13 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { /* Trova la differenza dal valore precedente */ vpdiff = step[bufferstep] >> 3; if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep]>>1; - if (delta & 1) vpdiff += step[bufferstep]>>2; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; if (sign) - valpred[bufferstep]-=vpdiff; + valpred[bufferstep] -= vpdiff; else - valpred[bufferstep]+=vpdiff; + valpred[bufferstep] += vpdiff; /* Controlla i limiti del valore trovato */ if (valpred[bufferstep] > 32767) @@ -638,9 +628,9 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { step[bufferstep] = stepSizeTable[index[bufferstep]]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred[bufferstep]; + *lpBuf ++ = (signed short)valpred[bufferstep]; - bufferstep=!bufferstep; + bufferstep = !bufferstep; } return eof / 2; @@ -655,7 +645,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) int delta; int sign; int vpdiff; - uint32 eof,i; + uint32 eof, i; int step[2]; bufferstep = 1; @@ -663,8 +653,8 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) step[1] = stepSizeTable[index[1]]; /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); inp = lpTemp; @@ -681,9 +671,9 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) dwSize /= 2; for (i = 0; i < dwSize; i++) { /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i==eof) { + if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step[0] = stepSizeTable[index[0]]; step[1] = stepSizeTable[index[1]]; } @@ -705,15 +695,15 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) delta = delta & 7; /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep]>>3; + vpdiff = step[bufferstep] >> 3; if (delta & 4) vpdiff += step[bufferstep]; if (delta & 2) vpdiff += step[bufferstep] >> 1; if (delta & 1) vpdiff += step[bufferstep] >> 2; if (sign) - valpred[bufferstep]-=vpdiff; + valpred[bufferstep] -= vpdiff; else - valpred[bufferstep]+=vpdiff; + valpred[bufferstep] += vpdiff; /* Controlla i limiti del valore trovato */ if (valpred[bufferstep] > 32767) @@ -725,7 +715,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) step[bufferstep] = stepSizeTable[index[bufferstep]]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred[bufferstep]; + *lpBuf ++ = (signed short)valpred[bufferstep]; bufferstep = !bufferstep; } @@ -775,17 +765,17 @@ bool FPSOUND::Init(/*HWND hWnd*/) { static char errbuf[128]; /* Salva l'handle della finestra nella variabile globale. DirectSound ha - bisogno dell'handle per effetuare il multitasking sonoro. */ + bisogno dell'handle per effetuare il multitasking sonoro. */ hwnd = hWnd; /* Di default, disabilita il sonoro. Se non troveremo problemi, lo - riabiliteremo alla fine della routine */ + riabiliteremo alla fine della routine */ bSoundSupported = false; /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. - In realta' sarebbe possibile richiedere una lista delle schede sonore - presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra - una perdita di tempo. */ + In realta' sarebbe possibile richiedere una lista delle schede sonore + presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra + una perdita di tempo. */ if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { return false; } @@ -799,50 +789,50 @@ bool FPSOUND::Init(/*HWND hWnd*/) { error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco - sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed - eventuali player in background saranno automaticamente stoppati. - Inoltre in questo modo e' possibile settare il formato di output sonoro - del primary buffer */ + sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed + eventuali player in background saranno automaticamente stoppati. + Inoltre in questo modo e' possibile settare il formato di output sonoro + del primary buffer */ if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { - MessageBox(hwnd,"Cannot set exclusive mode!","soundInit()", MB_OK); + MessageBox(hwnd, "Cannot set exclusive mode!", "soundInit()", MB_OK); return false; } /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, - ma noi vogliamo il pointer al primary perche' dobbiamo settare il - formato di output */ - ZeroMemory(&dsbdesc,sizeof(dsbdesc)); - dsbdesc.dwSize=sizeof(dsbdesc); - dsbdesc.dwFlags=DSBCAPS_CTRLVOLUME|DSBCAPS_PRIMARYBUFFER; + ma noi vogliamo il pointer al primary perche' dobbiamo settare il + formato di output */ + ZeroMemory(&dsbdesc, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_PRIMARYBUFFER; if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { - MessageBox(hwnd,"Cannot create primary buffer!","soundInit()", MB_OK); + MessageBox(hwnd, "Cannot create primary buffer!", "soundInit()", MB_OK); return false; } /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz - stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda - sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. - Inoltre in seguito sara' possibile lasciare scegliere all'utente il - formato da utilizzare */ - pcmwf.wBitsPerSample = ((dscaps.dwFlags&DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); + stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda + sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. + Inoltre in seguito sara' possibile lasciare scegliere all'utente il + formato da utilizzare */ + pcmwf.wBitsPerSample = ((dscaps.dwFlags & DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = ((dscaps.dwFlags&DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); + pcmwf.wf.nChannels = ((dscaps.dwFlags & DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); pcmwf.wf.nSamplesPerSec = 44100; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { - wsprintf(errbuf,"Error setting the output format (%lx)",err); - MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + wsprintf(errbuf, "Error setting the output format (%lx)", err); + MessageBox(hwnd, errbuf, "soundInit()", MB_OK); return false; } /* Controlla che il driver DirectSound supporti buffer secondari con - play di stream 16bit, 44khz stereo */ + play di stream 16bit, 44khz stereo */ if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { - wsprintf(errbuf,"Driver does not support 16bit 44khz stereo mixing! (%lu)",dscaps.dwMaxSecondarySampleRate); - MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + wsprintf(errbuf, "Driver does not support 16bit 44khz stereo mixing! (%lu)", dscaps.dwMaxSecondarySampleRate); + MessageBox(hwnd, errbuf, "soundInit()", MB_OK); return false; } @@ -911,7 +901,7 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { * * Return: true se tutto OK, false in caso di errore * -* Note: Vedi le note di CreateStream() +* Note: Vedi le note di CreateStream() * \****************************************************************************/ @@ -940,7 +930,7 @@ void FPSOUND::SetMasterVolume(int dwVolume) { return; if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); #endif @@ -961,7 +951,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { #ifdef REFACTOR_ME if (!bSoundSupported) return; - + lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; @@ -1026,8 +1016,8 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { * Function: ~FPSFX(); * * Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. * \****************************************************************************/ @@ -1076,7 +1066,7 @@ void FPSFX::Release() { * * Description: Apre un file di effetto sonoro e lo carica. * -* Input: byte *lpBuf Buffer dove si trova l'sfx +* Input: byte *lpBuf Buffer dove si trova l'sfx * uint32 dwCoded CODEC da utilizzare per decomprimere * i campioni sonori * @@ -1115,7 +1105,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') return false; - WAVHeader = (WAVH*)(lpBuf+8); + WAVHeader = (WAVH *)(lpBuf + 8); lpBuf += 8 + sizeof(WAVH); if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') @@ -1130,11 +1120,11 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { dwFreq = WAVHeader->nSamplesPerSec; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = (bStereo ? 2 : 1); pcmwf.wf.nSamplesPerSec = dwFreq; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1146,14 +1136,14 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } // Riempie il buffer - if ((err = lpDSBuffer->Lock(0,dwSize, &lpLock,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + if ((err = lpDSBuffer->Lock(0, dwSize, &lpLock, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1203,20 +1193,20 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { b16bit = true; bStereo = false; bIsVoice = true; - + // fread(&dwSize,1,4,vdbFP); // fread(&dwFreq,1,4,vdbFP); - ReadFile(vdbFP, &dwSize,4, &dwHi, NULL); - ReadFile(vdbFP, &dwFreq,4, &dwHi, NULL); + ReadFile(vdbFP, &dwSize, 4, &dwHi, NULL); + ReadFile(vdbFP, &dwFreq, 4, &dwHi, NULL); dwSize *= 4; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = (bStereo ? 2 : 1); pcmwf.wf.nSamplesPerSec = dwFreq; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1228,8 +1218,8 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } @@ -1239,10 +1229,10 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { return false; lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - + /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0,dwSize, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1255,10 +1245,10 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { delete lpCodec; /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { - wsprintf(errbuf,"Error creating notify object! (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::LoadVoiceFromVDB()", MB_OK); + wsprintf(errbuf, "Error creating notify object! (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::LoadVoiceFromVDB()", MB_OK); return false; } @@ -1268,7 +1258,7 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { dspnHot[0].hEventNotify = hEndOfBuffer; lpDSNotify->SetNotificationPositions(1, dspnHot); - + /* Tutto a posto, possiamo uscire */ bFileLoaded = true; SetVolume(62); @@ -1327,8 +1317,8 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { dwSize *= 4; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; @@ -1337,14 +1327,14 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwSize = sizeof(dsbdesc); dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; dsbdesc.dwBufferBytes = dwSize; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } @@ -1360,18 +1350,19 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { case FPCODEC_ADPCM: if (bStereo) - lpCodec = new CODECADPCMSTEREO(bLoop,lpTempBuffer); - else - lpCodec = new CODECADPCMMONO(bLoop,lpTempBuffer); - break; + lpCodec = new CODECADPCMSTEREO(bLoop, lpTempBuffer); + else + lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); + break; default: - return false;G + return false; + G } /* Riempie il buffer */ if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1504,7 +1495,7 @@ void FPSFX::SetVolume(int dwVolume) { if (!GLOBALS.bCfgDubbing) dwVolume = 0; else { dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; - if (dwVolume<0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; } } else { if (!GLOBALS.bCfgSFX) dwVolume = 0; @@ -1515,7 +1506,7 @@ void FPSFX::SetVolume(int dwVolume) { } #ifdef REFACTOR_ME if (bFileLoaded) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX-DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); #endif } @@ -1560,7 +1551,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; - lpDS=LPDS; + lpDS = LPDS; bSoundSupported = bSoundOn; bFileLoaded = false; bIsPlaying = false; @@ -1583,12 +1574,12 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { return true; /* Setta le strutture necessarie per la creazione di un secondary buffer - per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre - il controllo del volume, in modo da poter abbassare e alzare il volume - della musica indipendentemente da quello generale. Ovviamente si tratta - di un buffer in RAM */ + per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre + il controllo del volume, in modo da poter abbassare e alzare il volume + della musica indipendentemente da quello generale. Ovviamente si tratta + di un buffer in RAM */ pcmwf.wBitsPerSample = 16; - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = 2; pcmwf.wf.nSamplesPerSec = 44100; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1596,12 +1587,12 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { dsbdesc.dwSize = sizeof(dsbdesc); dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dwBufferSize=dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; + dwBufferSize = dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); bSoundSupported = false; return false; } @@ -1609,20 +1600,20 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave - all'interno dello stream. Le posizioni chiave si trovano rispettivamente - subito dopo l'inizio e subito dopo la meta' del buffer */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + all'interno dello stream. Le posizioni chiave si trovano rispettivamente + subito dopo l'inizio e subito dopo la meta' del buffer */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { - wsprintf(errbuf,"Error creating notify object! (%lx)",err); - MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + wsprintf(errbuf, "Error creating notify object! (%lx)", err); + MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); bSoundSupported = false; return false; } - hHot1=CreateEvent(NULL, false, false, NULL); - hHot2=CreateEvent(NULL, false, false, NULL); - hHot3=CreateEvent(NULL, false, false, NULL); + hHot1 = CreateEvent(NULL, false, false, NULL); + hHot2 = CreateEvent(NULL, false, false, NULL); + hHot3 = CreateEvent(NULL, false, false, NULL); hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); dspnHot[0].dwOffset = 32; @@ -1634,7 +1625,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - lpDSNotify->SetNotificationPositions(3,dspnHot); + lpDSNotify->SetNotificationPositions(3, dspnHot); #endif return true; } @@ -1681,7 +1672,7 @@ FPSTREAM::~FPSTREAM() { CloseHandle(hPlayThread_PlayNormal); hPlayThread_PlayNormal = NULL; } - + SyncToPlay = NULL; RELEASE(lpDSNotify); @@ -1743,18 +1734,18 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize if (!_file.open(lpszFileName)) //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); return false; - } +} - /* Si salva la lunghezza dello stream */ - dwSize = _file.size(); - _file.seek(0); +/* Si salva la lunghezza dello stream */ +dwSize = _file.size(); +_file.seek(0); - /* Tutto a posto, possiamo uscire */ - bFileLoaded = true; - bIsPlaying = false; - bPaused = false; +/* Tutto a posto, possiamo uscire */ +bFileLoaded = true; +bIsPlaying = false; +bPaused = false; #endif - return true; +return true; } @@ -1832,36 +1823,36 @@ void FPSTREAM::Prefetch(void) { /* Riempie il buffer per avere i dati gia' pronti */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock stream buffer!","soundLoadStream()", MB_OK); + MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); return; } - + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - + /* Unlocka il buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - + /* Crea il thread che fa il play dello stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - + /* Start il play del buffer DirectSound */ lpDSBuffer->SetCurrentPosition(0); bIsPlaying = true; dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { - int a=1; + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { + int a = 1; } #endif } @@ -1870,16 +1861,16 @@ void FPSTREAM::PlayFast(void) { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - + lpDSBuffer->Stop(); - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { warning("PlayFast SNP failed!"); } @@ -1908,58 +1899,57 @@ bool FPSTREAM::Play() { case FPCODEC_RAW: lpCodec = new CODECRAW(bLoop); break; - + case FPCODEC_ADPCM: lpCodec = new CODECADPCMSTEREO(bLoop); break; - + default: return false; } - + /* Posiziona lo stream file all'inizio */ _file.seek(0); lpDSBuffer->Stop(); lpDSBuffer->SetCurrentPosition(0); - + /* Riempie il buffer per avere i dati gia' pronti */ - if ((err = lpDSBuffer->Lock(0,dwBufferSize/2, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - error("Cannot lock stream buffer!","soundLoadStream()"); + if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + error("Cannot lock stream buffer!", "soundLoadStream()"); } - + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - + /* Unlocka il buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - + /* Crea il thread che fa il play dello stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); SetEvent(hPlayThread_PlayFast); - + #if 0 - /* Start il play del buffer DirectSound */ - lpDSBuffer->SetCurrentPosition(0); - - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize/2+32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) - { - int a=1; - } - - - lpDSBuffer->Play(0, 0,DSBPLAY_LOOPING); + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { + int a = 1; + } + + + lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING); #endif bIsPlaying = true; @@ -1996,9 +1986,9 @@ bool FPSTREAM::Stop(bool bSync) { // lpDSBuffer->Play(0, 0, 0); return true; } else { - /* Ferma il buffer DirectSound */ + /* Ferma il buffer DirectSound */ lpDSBuffer->Stop(); - + /* Avverte il thread che deve uscire e aspetta che si chiuda */ SetEvent(hThreadEnd); WaitForSingleObject(hPlayThread, CORO_INFINITE); @@ -2033,8 +2023,8 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { bSyncExit = true; char buf[1024]; - sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", - this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); + sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", + this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); warning(buf); WaitForSingleObject(hPlayThread, CORO_INFINITE); @@ -2043,7 +2033,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - + /* Disalloca e chiude il CODEC */ delete lpCodec; #endif @@ -2068,7 +2058,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { uint32 countEnd; bool bPrecache; char buf[1024]; - + /* Eventi che segnalano quando bisogna eseguire qualcosa */ HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; @@ -2077,7 +2067,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { while (cicla) { if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { countEnd++; - if (countEnd==3) + if (countEnd == 3) break; } @@ -2086,7 +2076,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); else if (bPrecache) This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); - + bPrecache = false; /* Attende il set di un evento. Dato che sono tutti in automatic reset, @@ -2100,12 +2090,12 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { // warning(buf); dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); -/* uint32 dwPlay, dwWrite; - This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); - sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); - warning(buf); */ + /* uint32 dwPlay, dwWrite; + This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); + sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); + warning(buf); */ - /* Fa uno switch per stabilire quale evento e' stato settato */ + /* Fa uno switch per stabilire quale evento e' stato settato */ switch (dwResult - WAIT_OBJECT_0) { case 0: /* Bisogna uscire dal thread */ @@ -2113,16 +2103,16 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { break; case 1: - /* Bisogna riempire la seconda meta' del buffer */ + /* Bisogna riempire la seconda meta' del buffer */ // if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) { // sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); // warning(buf); - This->lpDSBuffer->Lock(This->dwBufferSize/2,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult,(void **)&lpLockBuf2, &dwResult2, 0); - // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); - // warning(buf); - CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); - This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2,lpLockBuf2, 0); + This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); + // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); + // warning(buf); + CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); bPrecache = true; } break; @@ -2130,33 +2120,32 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { case 2: /* Bisogna riempire la prima meta' del buffer */ // if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) - { + { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); // warning(buf); - This->lpDSBuffer->Lock(0,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); - This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2, NULL, NULL); - bPrecache = true; - } - break; + This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); + CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); + bPrecache = true; + } + break; - case 3: - { + case 3: { // sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); // warning(buf); - if (This->bSyncExit) { + if (This->bSyncExit) { // sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); // warning(buf); - //This->SyncToPlay->PlayFast(); - SetEvent(This->SyncToPlay->hPlayThread_PlayFast); - // Transfer immediatly control to the other threads - Sleep(0); - This->bSyncExit = false; - cicla = false; - break; - } + //This->SyncToPlay->PlayFast(); + SetEvent(This->SyncToPlay->hPlayThread_PlayFast); + // Transfer immediatly control to the other threads + Sleep(0); + This->bSyncExit = false; + cicla = false; + break; } - break; + } + break; case 4: This->PlayFast(); @@ -2164,7 +2153,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { } } - /* Ferma il buffer DirectSound */ + /* Ferma il buffer DirectSound */ // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); @@ -2206,17 +2195,17 @@ void FPSTREAM::Pause(bool bPause) { } else if (!bPause && bPaused) { dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; } - + lpDSBuffer->Play(0, 0, bLoop); bIsPlaying = true; bPaused = false; @@ -2244,13 +2233,13 @@ void FPSTREAM::SetVolume(int dwVolume) { #ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; - + lastVolume = dwVolume; if (!GLOBALS.bCfgMusic) dwVolume = 0; else { dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; - if (dwVolume<0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; } if (lpDSBuffer) diff --git a/engines/tony/sound.h b/engines/tony/sound.h index bfa48f4d78c0..7defeb11493b 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -73,144 +73,144 @@ class FPSOUND { DSCAPS dscaps; HWND hwnd; -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSOUND::FPSOUND(); -* -* Description: Costruttore di default. Inizializza gli attributi. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSOUND::FPSOUND(); + * + * Description: Costruttore di default. Inizializza gli attributi. + * + \****************************************************************************/ FPSOUND(); -/****************************************************************************\ -* -* Function: FPSOUND::~FPSOUND(); -* -* Description: Deinizializza l'oggetto, disallocando la memoria. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSOUND::~FPSOUND(); + * + * Description: Deinizializza l'oggetto, disallocando la memoria. + * + \****************************************************************************/ ~FPSOUND(); -/****************************************************************************\ -* -* Function: bool FPSOUND::Init(HWND hWnd); -* -* Description: Inizializza l'oggetto, e prepara tutto il necessario per -* creare stream e effetti sonori. -* -* Input: HWND hWnd Handle della finestra principale -* -* Return: True se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool FPSOUND::Init(HWND hWnd); + * + * Description: Inizializza l'oggetto, e prepara tutto il necessario per + * creare stream e effetti sonori. + * + * Input: HWND hWnd Handle della finestra principale + * + * Return: True se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Init(/*HWND hWnd*/); -/****************************************************************************\ -* -* Function: bool CreateStream(FPSTREAM** lplpStream); -* -* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo -* puntatore dopo averlo inizializzato. -* -* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto -* appena creato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPSTREAM -* e FPSFX richiedono che DirectSound sia gia' stato -* inzializzato. In questo modo quindi si evitano dei bugs -* che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPSTREAM o FPSFX globale (o cmq prima della -* inizializzazione di DirectSound). -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool CreateStream(FPSTREAM** lplpStream); + * + * Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo + * puntatore dopo averlo inizializzato. + * + * Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto + * appena creato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), + * sono dovute al fatto che i costruttori delle classi FPSTREAM + * e FPSFX richiedono che DirectSound sia gia' stato + * inzializzato. In questo modo quindi si evitano dei bugs + * che si verrebbero a creare se venisse dichiarata un oggetto + * di tipo FPSTREAM o FPSFX globale (o cmq prima della + * inizializzazione di DirectSound). + * + \****************************************************************************/ bool CreateStream(FPSTREAM **lplpStream); -/****************************************************************************\ -* -* Function: bool CreateSfx(FPSFX** lplpSfx); -* -* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo -* puntatore dopo averlo inizializzato. -* -* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto -* appena creato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -* Note: Vedi le note di CreateStream() -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool CreateSfx(FPSFX** lplpSfx); + * + * Description: Alloca un oggetti di tipo FPSFX e ritorna il suo + * puntatore dopo averlo inizializzato. + * + * Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto + * appena creato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + * Note: Vedi le note di CreateStream() + * + \****************************************************************************/ bool CreateSfx(FPSFX **lplpSfx); -/****************************************************************************\ -* -* Function: void SetMasterVolume(int dwVolume); -* -* Description: Setta il volume generale -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetMasterVolume(int dwVolume); + * + * Description: Setta il volume generale + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ void SetMasterVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetMasterVolume(LPINT lpdwVolume); -* -* Description: Richiede il volume generale -* -* Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetMasterVolume(LPINT lpdwVolume); + * + * Description: Richiede il volume generale + * + * Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) + * + \****************************************************************************/ void GetMasterVolume(int *lpdwVolume); }; class FPSFX { -/****************************************************************************\ -* Attributi -\****************************************************************************/ + /****************************************************************************\ + * Attributi + \****************************************************************************/ private: -/* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound -*/ + /* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound + */ bool bSoundSupported; // TRUE se il suono e' attivo bool bFileLoaded; // TRUE se e' stato aperto un file bool bLoop; // TRUE se bisogna loopare l'effetto sonoro bool bPaused; int lastVolume; - bool bStereo; // TRUE se stereo - bool b16bit; // TRUE se 16 bit - uint32 dwFreq; // Frequenza originale di campionamento + bool bStereo; // TRUE se stereo + bool b16bit; // TRUE se 16 bit + uint32 dwFreq; // Frequenza originale di campionamento // CODEC* lpCodec; // CODEC da utilizzare. bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro @@ -219,178 +219,178 @@ class FPSFX { // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer // DSBPOSITIONNOTIFY dspnHot[2]; - + public: uint32 hEndOfBuffer; private: -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() -* -\****************************************************************************/ - - FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); - - -/****************************************************************************\ -* -* Function: ~FPSFX(); -* -* Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. -* -\****************************************************************************/ - - ~FPSFX(); - + /****************************************************************************\ + * + * Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); + * + * Description: Costruttore di default. *NON* bisogna dichiarare direttamente + * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() + * + \****************************************************************************/ + + FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + + + /****************************************************************************\ + * + * Function: ~FPSFX(); + * + * Description: Distruttore di default. Si preoccupa anche di fermare il sound + * effect eventualmente in esecuzione, e disallocare la memoria + * da esso occupata. + * + \****************************************************************************/ + + ~FPSFX(); + + + /****************************************************************************\ + * + * Function: Release(); + * + * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando + * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato + * creato con la FPSOUND::CreateStream(). + * + * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo + * questa chiamata. + * + \****************************************************************************/ -/****************************************************************************\ -* -* Function: Release(); -* -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). -* -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. -* -\****************************************************************************/ - - void Release(); + void Release(); -/****************************************************************************\ -* -* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Apre un file di effetto sonoro e lo carica. -* -* Input: char *lpszFile Nome del file di sfx da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * + * Description: Apre un file di effetto sonoro e lo carica. + * + * Input: char *lpszFile Nome del file di sfx da aprire + * uint32 dwCodec CODEC da utilizzare per decomprimere + * i campioni sonori + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); bool LoadVoiceFromVDB(Common::File &vdbFP); -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Suona lo sfx caricato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Play(); + * + * Description: Suona lo sfx caricato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ - bool Play(); + bool Play(); -/****************************************************************************\ -* -* Function: bool Stop(); -* -* Description: Ferma il play dello sfx. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Stop(); + * + * Description: Ferma il play dello sfx. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ - bool Stop(); + bool Stop(); -/****************************************************************************\ -* -* Function: void Pause(bool bPause); -* -* Description: Pause dell'effetto sonoro -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void Pause(bool bPause); + * + * Description: Pause dell'effetto sonoro + * + \****************************************************************************/ - void Pause(bool bPause); + void Pause(bool bPause); -/****************************************************************************\ -* -* Function: bool SetLoop(bool bLoop); -* -* Description: Attiva o disattiva il loop dello sfx. -* -* Input: bool bLoop TRUE per attivare il loop, FALSE per -* disattivarlo -* -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello sfx. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo sfx non viene fermato, -* e poi rimesso in play. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool SetLoop(bool bLoop); + * + * Description: Attiva o disattiva il loop dello sfx. + * + * Input: bool bLoop TRUE per attivare il loop, FALSE per + * disattivarlo + * + * Note: Il loop deve essere attivato PRIMA di eseguire il play + * dello sfx. Qualsiasi modifica effettuata durante il play + * non avra' effetto fino a che lo sfx non viene fermato, + * e poi rimesso in play. + * + \****************************************************************************/ - void SetLoop(bool bLoop); + void SetLoop(bool bLoop); -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Cambia il volume dello sfx -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetVolume(int dwVolume); + * + * Description: Cambia il volume dello sfx + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ - void SetVolume(int dwVolume); + void SetVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetVolume(int * lpdwVolume); -* -* Description: Chiede il volume dello sfx -* -* Input: int * lpdwVolume Variabile in cui verra' inserito -* il volume corrente -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetVolume(int * lpdwVolume); + * + * Description: Chiede il volume dello sfx + * + * Input: int * lpdwVolume Variabile in cui verra' inserito + * il volume corrente + * + \****************************************************************************/ - void GetVolume(int * lpdwVolume); + void GetVolume(int *lpdwVolume); }; class FPSTREAM { -/****************************************************************************\ -* Attributi -\****************************************************************************/ + /****************************************************************************\ + * Attributi + \****************************************************************************/ private: -/* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer -*/ + /* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer + */ byte *lpTempBuffer; // Buffer temporaneo per decompressione uint32 dwBufferSize; // Dimensione del buffer in bytes @@ -424,171 +424,171 @@ class FPSTREAM { static void PlayThread(FPSTREAM *This); -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); + * + * Description: Costruttore di default. *NON* bisogna dichiarare direttamente + * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() + * + \****************************************************************************/ FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); -/****************************************************************************\ -* -* Function: ~FPSTREAM(); -* -* Description: Distruttore di default. Si preoccupa anche di fermare stream -* eventualmente in esecuzione, e disallocare la memoria da -* essi occupata. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: ~FPSTREAM(); + * + * Description: Distruttore di default. Si preoccupa anche di fermare stream + * eventualmente in esecuzione, e disallocare la memoria da + * essi occupata. + * + \****************************************************************************/ ~FPSTREAM(); -/****************************************************************************\ -* -* Function: Release(); -* -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). -* -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: Release(); + * + * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando + * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato + * creato con la FPSOUND::CreateStream(). + * + * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo + * questa chiamata. + * + \****************************************************************************/ void Release(); -/****************************************************************************\ -* -* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Apre un file di stream. -* -* Input: char *lpszFile Nome del file di stream da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * + * Description: Apre un file di stream. + * + * Input: char *lpszFile Nome del file di stream da aprire + * uint32 dwCodec CODEC da utilizzare per decomprimere + * i campioni sonori + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); -/****************************************************************************\ -* -* Function: UnloadFile(); -* -* Description: Chiude un file di stream eventualmente aperto. E' necessario -* richiamare questa funzione per disallocare la memoria -* occupata dallo stream. -* -* Return: Il distruttore della classe per sicurezza richiama la -* UnloadFile() se non e' stata richiamata esplicitamente. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: UnloadFile(); + * + * Description: Chiude un file di stream eventualmente aperto. E' necessario + * richiamare questa funzione per disallocare la memoria + * occupata dallo stream. + * + * Return: Il distruttore della classe per sicurezza richiama la + * UnloadFile() se non e' stata richiamata esplicitamente. + * + \****************************************************************************/ bool UnloadFile(); -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Suona lo stream caricato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Play(); + * + * Description: Suona lo stream caricato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Play(); void PlayFast(void); void Prefetch(void); -/****************************************************************************\ -* -* Function: bool Stop(); -* -* Description: Ferma il play dello stream. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Stop(); + * + * Description: Ferma il play dello stream. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Stop(bool bSync = false); - void WaitForSync(FPSTREAM* toplay); + void WaitForSync(FPSTREAM *toplay); -/****************************************************************************\ -* -* Function: void Pause(bool bPause); -* -* Description: Pause dell'effetto sonoro -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void Pause(bool bPause); + * + * Description: Pause dell'effetto sonoro + * + \****************************************************************************/ void Pause(bool bPause); -/****************************************************************************\ -* -* Function: bool SetLoop(bool bLoop); -* -* Description: Attiva o disattiva il loop dello stream. -* -* Input: bool bLoop TRUE per attivare il loop, FALSE per -* disattivarlo -* -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello stream. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo stream non viene fermato, -* e poi rimesso in play. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool SetLoop(bool bLoop); + * + * Description: Attiva o disattiva il loop dello stream. + * + * Input: bool bLoop TRUE per attivare il loop, FALSE per + * disattivarlo + * + * Note: Il loop deve essere attivato PRIMA di eseguire il play + * dello stream. Qualsiasi modifica effettuata durante il play + * non avra' effetto fino a che lo stream non viene fermato, + * e poi rimesso in play. + * + \****************************************************************************/ void SetLoop(bool bLoop); -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Cambia il volume dello stream -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetVolume(int dwVolume); + * + * Description: Cambia il volume dello stream + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ void SetVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetVolume(LPINT lpdwVolume); -* -* Description: Chiede il volume dello stream -* -* Input: LPINT lpdwVolume Variabile in cui verra' inserito -* il volume corrente -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetVolume(LPINT lpdwVolume); + * + * Description: Chiede il volume dello stream + * + * Input: LPINT lpdwVolume Variabile in cui verra' inserito + * il volume corrente + * + \****************************************************************************/ void GetVolume(int *lpdwVolume); }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e5988e7c9bde..e5c30ffcec51 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,8 +36,8 @@ namespace Tony { TonyEngine *_vm; -TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony") { +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), + _gameDescription(gameDesc), _randomSource("tony") { _vm = this; _loadSlotNumber = -1; @@ -90,7 +90,7 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); - // Init static class fields + // Init static class fields RMText::InitStatics(); RMTony::InitStatics(); @@ -174,7 +174,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in if (nChannel < 4) if (GLOBALS.flipflop) nChannel = nChannel + 1; - + switch (nFX) { case 0: case 1: @@ -186,62 +186,57 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 22: break; } - -#ifdef REFACTOR_ME + +#ifdef REFACTOR_ME // Mette il path giusto if (nChannel < 4) GetDataDirectory(DD_MUSIC, path_buffer); else GetDataDirectory(DD_LAYER, path_buffer); - _splitpath(path_buffer,drive,dir,NULL,NULL); - _splitpath(fn,NULL,NULL,fname,ext); - _makepath(path_buffer,drive,dir,fname,ext); + _splitpath(path_buffer, drive, dir, NULL, NULL); + _splitpath(fn, NULL, NULL, fname, ext); + _makepath(path_buffer, drive, dir, fname, ext); - _makepath(path_buffer,drive,dir,fname,ext); + _makepath(path_buffer, drive, dir, fname, ext); - if (nFX==22) // Sync a tempo - { - curChannel=nChannel; + if (nFX == 22) { // Sync a tempo + curChannel = nChannel; strcpy(nextMusic, path_buffer); - nextLoop=bLoop; - nextSync=nSync; + nextLoop = bLoop; + nextSync = nSync; if (flipflop) - nextChannel=nChannel-1; + nextChannel = nChannel - 1; else - nextChannel=nChannel+1; + nextChannel = nChannel + 1; DWORD id; - HANDLE hThread=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)DoNextMusic,m_stream,0,&id); - SetThreadPriority(hThread,THREAD_PRIORITY_HIGHEST); - } - else if (nFX==44) // Cambia canale e lascia finire il primo - { + HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, m_stream, 0, &id); + SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); + } else if (nFX == 44) { // Cambia canale e lascia finire il primo if (flipflop) - nextChannel=nChannel-1; + nextChannel = nChannel - 1; else - nextChannel=nChannel+1; + nextChannel = nChannel + 1; m_stream[nextChannel]->Stop(); m_stream[nextChannel]->UnloadFile(); if (!getIsDemo()) { - if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + if (!m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } m_stream[nextChannel]->SetLoop(bLoop); m_stream[nextChannel]->Play(); - flipflop = 1-flipflop; - } - else - { + flipflop = 1 - flipflop; + } else { if (!getIsDemo()) { - if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + if (!m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } m_stream[nChannel]->SetLoop(bLoop); @@ -320,9 +315,9 @@ void TonyEngine::PreloadSFX(int nChannel, const char *fn) { FPSFX *TonyEngine::CreateSFX(byte *buf) { FPSFX *sfx; - + _theSound.CreateSfx(&sfx); - sfx->LoadFile(buf,FPCODEC_WAV); + sfx->LoadFile(buf, FPCODEC_WAV); return sfx; } @@ -343,7 +338,7 @@ void TonyEngine::InitMusic() { _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); - + for (i = 0; i < 6; i++) _theSound.CreateStream(&m_stream[i]); @@ -389,7 +384,7 @@ Common::String TonyEngine::GetSaveStateFileName(int n) { void TonyEngine::AutoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; - Common::String buf; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -414,7 +409,7 @@ void TonyEngine::SaveState(int n, const char *name) { void TonyEngine::LoadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; - Common::String buf; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -491,14 +486,14 @@ void TonyEngine::Abort(void) { /** * Main process for playing the game. * - * @remarks This needs to be in a separate process, since there are some things that can briefly + * @remarks This needs to be in a separate process, since there are some things that can briefly * block the execution of process. For now, all ScummVm event handling is dispatched to within the context of this * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain * in the outer 'main' process. */ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - Common::String fn; + Common::String fn; CORO_END_CONTEXT(_ctx); @@ -517,7 +512,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); - // Call the engine to handle the next frame + // Call the engine to handle the next frame CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished diff --git a/engines/tony/tony.h b/engines/tony/tony.h index bdaffee7c906..f4d9d8367498 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -69,7 +69,7 @@ enum { struct TonyGameDescription; -#define MAX_SFX_CHANNELS 32 +#define MAX_SFX_CHANNELS 32 struct VoiceHeader { int offset; @@ -100,7 +100,7 @@ class TonyEngine : public Engine { uint32 m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; - FPSOUND _theSound; + FPSOUND _theSound; Globals _globals; Debugger *_debugger; @@ -143,7 +143,9 @@ class TonyEngine : public Engine { Common::Language getLanguage() const; uint16 getVersion() const; bool getIsDemo() const; - RMGfxEngine *GetEngine() { return &_theEngine; } + RMGfxEngine *GetEngine() { + return &_theEngine; + } void GUIError(const Common::String &msg); virtual bool canLoadGameStateCurrently(); @@ -163,8 +165,12 @@ class TonyEngine : public Engine { void SwitchFullscreen(bool bFull); void OptionScreen(void); - void ShowLocation(void) { m_bDrawLocation = true; } - void HideLocation(void) { m_bDrawLocation = false; } + void ShowLocation(void) { + m_bDrawLocation = true; + } + void HideLocation(void) { + m_bDrawLocation = false; + } // Reads the time uint32 GetTime(void); @@ -186,7 +192,7 @@ class TonyEngine : public Engine { void PreloadSFX(int nSfx, const char *fn); void UnloadAllSFX(void); - + void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); @@ -204,9 +210,13 @@ class TonyEngine : public Engine { // Get a thumbnail void GrabThumbnail(void); - uint16 *GetThumbnail(void) { return m_curThumbnail; } + uint16 *GetThumbnail(void) { + return m_curThumbnail; + } - void Quit(void) { m_bQuitNow = true; } + void Quit(void) { + m_bQuitNow = true; + } void OpenInitLoadMenu(CORO_PARAM); void OpenInitOptions(CORO_PARAM); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 593a05d8631c..71f95f8133a3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -79,7 +79,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { RMGfxSourceBuffer8RLE *spr; - + assert(m_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; spr->SetAlphaBlendColor(1); @@ -109,7 +109,7 @@ void RMTony::Init(void) { // Reads his details from the stream ReadFromStream(ds, true); - + // Closes the buffer ds.Close(); @@ -130,15 +130,15 @@ void RMTony::Close(void) { void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CONTEXT; - int time; + int time; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); - - SetSpeed(GLOBALS.nCfgTonySpeed); + + SetSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->GetTime(); @@ -152,7 +152,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { // Check if we are at the end of a path if (EndOfPath() && m_bActionPending) { // Must perform the action on which we clicked - m_bActionPending = false; + m_bActionPending = false; } if (m_bIsTalking || m_bIsStaticTalk) @@ -192,9 +192,9 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Offest direction from scrolling prim->Dst().SetEmpty(); prim->Dst().Offset(-m_curScroll); - prim->Dst().Offset(m_pos); + prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); - prim->Dst() += m_nBodyOffset; + prim->Dst() += m_nBodyOffset; CORO_INVOKE_2(m_body.Draw, bigBuf, prim); } @@ -212,7 +212,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { CORO_BEGIN_CONTEXT; - bool result; + bool result; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -240,46 +240,46 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { uint32 pid; - + if (nAction == TA_COMBINE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); - + // If you failed the combine, we have RECEIVECOMBINE as a fallback if (pid == CORO_INVALID_PID_VALUE) { - pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); - + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + // If you failed with that, go with the generic // @@@ CombineGive! if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - - if (pid == CORO_INVALID_PID_VALUE){ + + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } } } else { // Perform the action - pid = mpalQueryDoAction(nAction, nActionItem, 0); + pid = mpalQueryDoAction(nAction, nActionItem, 0); } - + if (pid != CORO_INVALID_PID_VALUE) { m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { - pid = mpalQueryDoAction(6, 1, 0); + pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); - m_bAction = true; + m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + hActionThread = pid; } else { - pid = mpalQueryDoAction(5, 1, 0); + pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; @@ -306,7 +306,7 @@ void RMTony::StopNoAction(CORO_PARAM) { void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; - uint32 pid; + uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -318,7 +318,7 @@ void RMTony::Stop(CORO_PARAM) { if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { - bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). + bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } @@ -332,7 +332,7 @@ void RMTony::Stop(CORO_PARAM) { m_bActionPending = false; ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); - + m_ActionItem = NULL; CORO_END_CODE; @@ -344,7 +344,7 @@ int RMTony::GetCurPattern(void) { if (!m_bPastorella) return nPatt; - + switch (nPatt) { case PAT_PAST_STANDUP: return PAT_STANDUP; @@ -371,28 +371,28 @@ void RMTony::SetPattern(int nPatt, bool bPlayP0) { if (m_bPastorella) { switch (nPatt) { case PAT_STANDUP: - nPatt=PAT_PAST_STANDUP; + nPatt = PAT_PAST_STANDUP; break; case PAT_STANDDOWN: - nPatt=PAT_PAST_STANDDOWN; + nPatt = PAT_PAST_STANDDOWN; break; case PAT_STANDLEFT: - nPatt=PAT_PAST_STANDLEFT; + nPatt = PAT_PAST_STANDLEFT; break; case PAT_STANDRIGHT: - nPatt=PAT_PAST_STANDRIGHT; + nPatt = PAT_PAST_STANDRIGHT; break; case PAT_WALKUP: - nPatt=PAT_PAST_WALKUP; + nPatt = PAT_PAST_WALKUP; break; case PAT_WALKDOWN: - nPatt=PAT_PAST_WALKDOWN; + nPatt = PAT_PAST_WALKDOWN; break; case PAT_WALKLEFT: - nPatt=PAT_PAST_WALKLEFT; + nPatt = PAT_PAST_WALKLEFT; break; case PAT_WALKRIGHT: - nPatt=PAT_PAST_WALKRIGHT; + nPatt = PAT_PAST_WALKRIGHT; break; } } @@ -405,7 +405,7 @@ void RMTony::Take(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - assert(0); // Not while you're doing a StandDown + assert(0); // Not while you're doing a StandDown break; case PAT_STANDUP: @@ -552,7 +552,7 @@ void RMTony::Put(int nWhere, int nPart) { bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat) { + int &headLoopPat, int &bodyLoopPat) { assert(!m_bIsTalking); m_bIsTalking = true; @@ -573,7 +573,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_STANDLEFT: m_TalkDirection = LEFT; break; - + case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: @@ -605,7 +605,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: SetPattern(PAT_PAST_TALKDOWN); break; - + case LEFT: SetPattern(PAT_PAST_TALKLEFT); break; @@ -622,7 +622,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = 0; switch (nTalkType) { - case TALK_NORMAL: + case TALK_NORMAL: m_bCorpoDavanti = false; headStartPat = 0; bodyStartPat = 0; @@ -654,7 +654,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_FIANCHI: + case TALK_FIANCHI: m_bCorpoDavanti = false; switch (m_TalkDirection) { case UP: @@ -760,7 +760,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body m_nBodyOffset.Set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; - break; + break; } break; @@ -966,7 +966,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - // The beard is the only case in which the head is animated separately while the body is the standard + // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: switch (m_TalkDirection) { case LEFT: @@ -984,7 +984,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } break; - + case TALK_SCHIFATO: switch (m_TalkDirection) { case LEFT: @@ -1112,8 +1112,8 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_BEGIN_CONTEXT; - int headStartPat, bodyStartPat; - int headLoopPat, bodyLoopPat; + int headStartPat, bodyStartPat; + int headLoopPat, bodyLoopPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1122,7 +1122,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headLoopPat = _ctx->bodyLoopPat = 0; if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, - _ctx->headLoopPat, _ctx->bodyLoopPat)) + _ctx->headLoopPat, _ctx->bodyLoopPat)) return; // Perform the set pattern @@ -1131,13 +1131,13 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { SetPattern(_ctx->headStartPat); m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - + if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(m_body.WaitForEndPattern); if (_ctx->headStartPat != 0) CORO_INVOKE_0(WaitForEndPattern); } - + MainFreeze(); SetPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) @@ -1151,7 +1151,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; - + switch (m_TalkDirection) { case UP: finalPat = PAT_STANDUP; @@ -1178,7 +1178,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa MainFreeze(); SetPattern(finalPat); MainUnfreeze(); - m_bIsTalking = false; + m_bIsTalking = false; return false; } @@ -1203,7 +1203,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = BPAT_FIANCHILEFT_END; break; - case RIGHT: + case RIGHT: bodyEndPat = BPAT_FIANCHIRIGHT_END; break; } @@ -1219,12 +1219,12 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_RIDELEFT_END; else if (m_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; - + bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1235,12 +1235,12 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_SCHIFATORIGHT_END; break; } - + bodyEndPat = 0; break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1251,7 +1251,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_NAAHRIGHT_END; break; } - + bodyEndPat = 0; break; @@ -1259,7 +1259,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1282,7 +1282,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: bodyEndPat = 0; break; @@ -1305,7 +1305,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1321,7 +1321,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1337,7 +1337,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1353,7 +1353,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1396,7 +1396,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1427,9 +1427,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa void RMTony::EndTalk(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int headStandPat, headEndPat; - int bodyEndPat, finalPat; - bool bStatic; + int headStandPat, headEndPat; + int bodyEndPat, finalPat; + bool bStatic; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1465,7 +1465,7 @@ void RMTony::EndTalk(CORO_PARAM) { CORO_INVOKE_0(m_body.WaitForEndPattern); } - m_bIsTalking = false; + m_bIsTalking = false; return; } @@ -1480,7 +1480,7 @@ void RMTony::EndTalk(CORO_PARAM) { MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - + CORO_INVOKE_0(WaitForEndPattern); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->bodyEndPat != 0) { @@ -1493,7 +1493,7 @@ void RMTony::EndTalk(CORO_PARAM) { MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - + CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(m_body.WaitForEndPattern); @@ -1514,13 +1514,13 @@ void RMTony::EndTalk(CORO_PARAM) { MainUnfreeze(); } - m_bIsTalking = false; + m_bIsTalking = false; CORO_END_CODE; } void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat) { + int &bodyStartPat, int &bodyLoopPat) { int nPat = GetCurPattern(); headLoopPat = -1; @@ -1539,7 +1539,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat m_TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; - + case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: @@ -1728,8 +1728,8 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; - int headPat, headLoopPat; - int bodyStartPat, bodyLoopPat; + int headPat, headLoopPat; + int bodyStartPat, bodyLoopPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1745,7 +1745,7 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); CORO_INVOKE_0(WaitForEndPattern); MainFreeze(); @@ -1774,7 +1774,8 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: switch (m_TalkDirection) { - case UP: case LEFT: + case UP: + case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; break; @@ -1812,7 +1813,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; } break; - + case TALK_CONCARTESTATIC: switch (m_TalkDirection) { case UP: @@ -1895,9 +1896,9 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; - int bodyEndPat; - int finalPat; - int headEndPat; + int bodyEndPat; + int finalPat; + int headEndPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1913,21 +1914,21 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { SetPattern(_ctx->headEndPat); MainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(WaitForEndPattern); } else { // Play please MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); } MainFreeze(); SetPattern(_ctx->finalPat); m_body.SetPattern(0); MainUnfreeze(); - + m_bIsStaticTalk = false; CORO_END_CODE; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a7109256f540..a1c7fc152b14 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -112,7 +112,7 @@ class RMTony : public RMCharacter { // Watch thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); -public: +public: enum PATTERNS { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, @@ -120,7 +120,7 @@ class RMTony : public RMCharacter { PAT_TAKEUP_MID2, PAT_TAKEUP_DOWN1, PAT_TAKEUP_DOWN2, - + PAT_TAKELEFT_UP1, PAT_TAKELEFT_UP2, PAT_TAKELEFT_MID1, @@ -242,7 +242,7 @@ class RMTony : public RMCharacter { PAT_PUTUP_MID2, PAT_PUTUP_DOWN1, PAT_PUTUP_DOWN2, - + PAT_CONSEGRETARIA }; @@ -363,7 +363,7 @@ class RMTony : public RMCharacter { // Initialise Tony void Init(void); - + // Free all memory void Close(void); @@ -391,21 +391,29 @@ class RMTony : public RMCharacter { int GetCurPattern(); // Waits until the end of a pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } // Check if currently in an action - bool InAction() { return (m_bActionPending && m_Action != 0) | m_bAction; } + bool InAction() { + return (m_bActionPending && m_Action != 0) | m_bAction; + } // Check if there needs to be an update for scrolling movement - bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } + bool MustUpdateScrolling() { + return ((!InAction()) || (IsMoving())); + } // Returns Tony's position - RMPoint Position() { return m_pos; } + RMPoint Position() { + return m_pos; + } // Set the scrolling position - void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } + void SetScrollPosition(const RMPoint &pt) { + RMCharacter::SetScrollPosition(pt); + } // Set the take animation void Take(int nWhere, int nPart); @@ -413,26 +421,32 @@ class RMTony : public RMCharacter { // Start or End Talk bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat); + int &headLoopPat, int &bodyLoopPat); void StartTalk(CORO_PARAM, TALKTYPE nTalkType); bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void EndTalk(CORO_PARAM); // Start or End Static void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat); + int &bodyStartPat, int &bodyLoopPat); void StartStatic(CORO_PARAM, TALKTYPE nTalkType); void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void EndStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } - int GetPastorella(void) { return m_bPastorella; } + void SetPastorella(bool bIsPast) { + m_bPastorella = bIsPast; + } + int GetPastorella(void) { + return m_bPastorella; + } // Perform an action void ExecuteAction(int nAction, int nActionItem, int nParm); - void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } + void PlaySfx(int nSfx) { + RMItem::PlaySfx(nSfx); + } }; } // End of namespace Tony diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 9aaffefceba1..92b896b180b9 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -67,7 +67,7 @@ RMString::RMString(const RMString &str) { /** * Constructor from a char * */ -RMString::RMString(const char* str) { +RMString::RMString(const char *str) { // Use the overloaded '=' when copying m_string = NULL; m_length = 0; @@ -88,16 +88,16 @@ RMString::RMString(const int ch) { /** * Returns the length of the string - * @returns Length + * @returns Length */ int RMString::Length() const { - return m_length; + return m_length; } /** * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character + * @param nIndex Position of the character to return + * @returns Character */ char RMString::GetAt(int nIndex) { assert(nIndex < m_length); @@ -106,8 +106,8 @@ char RMString::GetAt(int nIndex) { /** * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character + * @param nIndex Position of the character to change + * @param c Character */ void RMString::SetAt(int nIndex, char c) { assert(nIndex < m_length); @@ -116,8 +116,8 @@ void RMString::SetAt(int nIndex, char c) { /** * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character + * @param nIndex Position of the charactre to reference + * @params Reference to the character */ char &RMString::operator[](int nIndex) { assert(nIndex < m_length); @@ -126,8 +126,8 @@ char &RMString::operator[](int nIndex) { /** * Copies a string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -147,16 +147,16 @@ const RMString &RMString::operator=(const RMString &str) { // Copy the string Common::copy(str.m_string, str.m_string + m_length + 1, m_string); } - + return *this; } /** * Copies a char * string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const char* str) { +const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { if (m_realLength > 0) { @@ -180,11 +180,11 @@ const RMString& RMString::operator=(const char* str) { /** * Forms a string from a passed character - * @param ch Character to copy - * @returns Refrence to our string + * @param ch Character to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const int ch) { - if (ch=='\0') { +const RMString &RMString::operator=(const int ch) { + if (ch == '\0') { // Destroy the current string if (m_realLength > 0) { delete [] m_string; @@ -203,17 +203,17 @@ const RMString& RMString::operator=(const int ch) { return *this; } -/** +/** * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string + * @param str String to concatenate + * @param size Length of the string */ void RMString::Connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length+size; + nlen = m_length + size; // Resize Resize(nlen + 1, true); @@ -228,18 +228,18 @@ void RMString::Connect(const char *str, int size) { /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str,str.Length()); + Connect(str, str.Length()); return *this; } /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { Connect(str, strlen(str)); @@ -248,8 +248,8 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character - * @param ch Character to concatenate - * @returns Refrence to our string + * @param ch Character to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -264,17 +264,17 @@ const RMString &RMString::operator+=(const int ch) { /** * Casts a string as char * - * @returns char * reference to string + * @returns char * reference to string */ -RMString::operator char*() const { +RMString::operator char *() const { return m_string; } /** * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. + * @param size New size necessary (in bytes) + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -282,7 +282,7 @@ void RMString::Resize(int size, bool bMantain) { m_realLength = size; } else if (size > m_realLength) { if (bMantain) { - char* app; + char *app; app = new char[size]; Common::copy(m_string, m_string + m_length + 1, app); @@ -346,13 +346,13 @@ RMString operator+(RMString &str, const char *s) { RMString operator+(const char *s, RMString &str) { RMString ret(s); - return (ret+=str); + return (ret += str); } /** * Extracts a string from a data stream - * @param df data stream - * @param var String + * @param df data stream + * @param var String */ RMDataStream &operator>>(RMDataStream &df, RMString &var) { uint8 len; @@ -360,14 +360,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { df >> len; var.Resize(len + 1); - var.m_length=len+1; - + var.m_length = len + 1; + for (i = 0; i < len; i++) df >> var[i]; - var[i] = '\0'; + var[i] = '\0'; var.m_length = len; - + return df; } @@ -422,7 +422,7 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { } -RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { +RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { Seek(nBytes); return *this; } @@ -440,7 +440,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); - + case END: return _stream->seek(nBytes, SEEK_END); @@ -467,7 +467,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var,1); + df.Read(&var, 1); return df; } @@ -487,7 +487,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v,4); + df.Read(&v, 4); var = FROM_LE_32(v); return df; } @@ -530,10 +530,10 @@ void RMDataStream::Close(void) { /** * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. */ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { m_length = size; @@ -544,7 +544,7 @@ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { /** * Returns the length of the stream - * @returns Stream length + * @returns Stream length */ int RMDataStream::Length() { return m_length; @@ -552,7 +552,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -560,9 +560,9 @@ bool RMDataStream::IsEOF() { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { df.Read(&var, 1); @@ -571,9 +571,9 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { df.Read(&var, 1); @@ -582,9 +582,9 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; @@ -596,9 +596,9 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; @@ -610,9 +610,9 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; @@ -624,9 +624,9 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; @@ -638,9 +638,9 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { /** * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -659,19 +659,19 @@ bool RMDataStream::Read(void *lpBuf, int size) { /** * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream + * @param nBytres Number of bytes to skip + * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos+=nBytes; + m_pos += nBytes; return *this; } /** * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes */ int RMDataStream::Seek(int nBytes, RMDSPos origin) { switch (origin) { @@ -689,13 +689,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; } - m_pos+=nBytes; + m_pos += nBytes; return m_pos; } /** * Returns the current position of the stream - * @returns The current position + * @returns The current position */ int RMDataStream::Pos() { return m_pos; @@ -703,7 +703,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -711,7 +711,7 @@ bool RMDataStream::IsError() { /** * Sets an error code for the stream - * @param code Error code + * @param code Error code */ void RMDataStream::SetError(int code) { m_bError = true; @@ -720,7 +720,7 @@ void RMDataStream::SetError(int code) { /** * Returns the error code for the stream - * @returns Error code + * @returns Error code */ int RMDataStream::GetError() { return m_ecode; @@ -903,11 +903,11 @@ RMPoint &RMRect::TopLeft() { RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad - return *((RMPoint*)this + 1); + return *((RMPoint *)this + 1); } RMPoint RMRect::Center() { - return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); + return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } int RMRect::Width() const { @@ -926,7 +926,7 @@ bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } -const RMRect& RMRect::operator=(const RMRect &rc) { +const RMRect &RMRect::operator=(const RMRect &rc) { CopyRect(rc); return *this; } @@ -960,29 +960,29 @@ RMRect operator+(const RMRect &rc, RMPoint p) { return (r += p); } -RMRect operator-(const RMRect& rc, RMPoint p) { +RMRect operator-(const RMRect &rc, RMPoint p) { RMRect r(rc); return (r -= p); } -RMRect operator+(RMPoint p, const RMRect& rc) { +RMRect operator+(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -RMRect operator-(RMPoint p, const RMRect& rc) { +RMRect operator-(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -bool RMRect::operator==(const RMRect& rc) { +bool RMRect::operator==(const RMRect &rc) { return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); } -bool RMRect::operator!=(const RMRect& rc) { +bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } @@ -1050,7 +1050,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // Found the index break; - if (i==_numUpd) + if (i == _numUpd) // Couldn't find a matching resource, so return NULL return NULL; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c823421c62af..2eb6c5c2da31 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -45,58 +45,58 @@ using namespace ::Tony::MPAL; class RMDataStream { protected: const byte *m_buf; - int m_length; - int m_pos; - bool m_bError; - int m_ecode; + int m_length; + int m_pos; + bool m_bError; + int m_ecode; public: - enum RMDSPos { - CUR, - START, - END - }; + enum RMDSPos { + CUR, + START, + END + }; private: - enum { - SIZENOTKNOWN = 0x7FFFFFFF - }; + enum { + SIZENOTKNOWN = 0x7FFFFFFF + }; public: - // Constructor and destructor - RMDataStream(); - virtual ~RMDataStream(); + // Constructor and destructor + RMDataStream(); + virtual ~RMDataStream(); - // Loading buffer - void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); + // Loading buffer + void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); void Close(void); - // Attributei - int Length(); - virtual int Pos(); - - // EOF - virtual bool IsEOF(); + // Attributei + int Length(); + virtual int Pos(); - // Read methods - friend RMDataStream &operator>>(RMDataStream &df, char &var); - friend RMDataStream &operator>>(RMDataStream &df, byte &var); - friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int &var); - friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - - // General read - virtual bool Read(void *buf, int size); - - // Skipping & Seeking - virtual RMDataStream &operator+=(int nBytes); - virtual int Seek(int nBytes, RMDSPos origin = CUR); + // EOF + virtual bool IsEOF(); - // Error handling - void SetError(int ecode); - int GetError(); - bool IsError(); + // Read methods + friend RMDataStream &operator>>(RMDataStream &df, char &var); + friend RMDataStream &operator>>(RMDataStream &df, byte &var); + friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int &var); + friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); + + // General read + virtual bool Read(void *buf, int size); + + // Skipping & Seeking + virtual RMDataStream &operator+=(int nBytes); + virtual int Seek(int nBytes, RMDSPos origin = CUR); + + // Error handling + void SetError(int ecode); + int GetError(); + bool IsError(); }; @@ -131,20 +131,20 @@ class RMFileStreamSlow : public RMDataStream { void Close(void); - RMDataStream& operator+=(int nBytes); - int Seek(int nBytes, RMDSPos where = CUR); + RMDataStream &operator+=(int nBytes); + int Seek(int nBytes, RMDSPos where = CUR); int Pos(); virtual bool IsEOF(); bool Read(void *buf, int size); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, char &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, byte &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint16 &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int16 &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint32 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); }; /** @@ -154,57 +154,57 @@ class RMString { private: char *m_string; int m_length; - int m_realLength; + int m_realLength; public: - RMString(); - ~RMString(); + RMString(); + ~RMString(); - // Assignment constructors - RMString(const RMString &str); - RMString(const char *str); - RMString(const int ch); + // Assignment constructors + RMString(const RMString &str); + RMString(const char *str); + RMString(const int ch); - // General methods - int Length() const; - void Compact(); + // General methods + int Length() const; + void Compact(); - // Access characters within string - char GetAt(int nIndex); - void SetAt(int nIndex, char c); - char& operator[](int nIndex); + // Access characters within string + char GetAt(int nIndex); + void SetAt(int nIndex, char c); + char &operator[](int nIndex); - // String cast - operator char*() const; + // String cast + operator char *() const; - // String assignments - const RMString &operator=(const RMString &str); - const RMString &operator=(const char *str); - const RMString &operator=(const int ch); + // String assignments + const RMString &operator=(const RMString &str); + const RMString &operator=(const char *str); + const RMString &operator=(const int ch); - // String concatenation - const RMString &operator+=(RMString &str); - const RMString &operator+=(const char *str); - const RMString &operator+=(const int ch); + // String concatenation + const RMString &operator+=(RMString &str); + const RMString &operator+=(const char *str); + const RMString &operator+=(const int ch); - // Concatentation of string or character - friend RMString operator+(const RMString &str1, const RMString &str2); + // Concatentation of string or character + friend RMString operator+(const RMString &str1, const RMString &str2); - friend RMString operator+(RMString& str, const int ch); - friend RMString operator+(const int ch, RMString &str); + friend RMString operator+(RMString &str, const int ch); + friend RMString operator+(const int ch, RMString &str); - friend RMString operator+(RMString &str, const char *s); - friend RMString operator+(const char *s, RMString &str); + friend RMString operator+(RMString &str, const char *s); + friend RMString operator+(const char *s, RMString &str); - // Extraction from data streams - friend RMDataStream& operator>>(RMDataStream& df, RMString &var); + // Extraction from data streams + friend RMDataStream &operator>>(RMDataStream &df, RMString &var); // String formatting void Format(const char *str, ...); private: - void Resize(int size, bool bMantain = false); - void Connect(const char* str, int size); + void Resize(int size, bool bMantain = false); + void Connect(const char *str, int size); }; /** @@ -215,89 +215,94 @@ class RMPoint { int x, y; public: - // Constructor - RMPoint(); - RMPoint(const RMPoint &p); - RMPoint(int x1, int y1); + // Constructor + RMPoint(); + RMPoint(const RMPoint &p); + RMPoint(int x1, int y1); - // Copy - RMPoint& operator=(RMPoint p); + // Copy + RMPoint &operator=(RMPoint p); // Set - void Set(int x1, int y1) { x = x1; y = y1; } - - // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); - friend RMPoint operator+(RMPoint p1, RMPoint p2); - friend RMPoint operator-(RMPoint p1, RMPoint p2); - RMPoint &operator+=(RMPoint p); - RMPoint &operator-=(RMPoint p); - RMPoint operator-(); - - // Comparison - bool operator==(RMPoint p); - bool operator!=(RMPoint p); - - // Casting a POINT + void Set(int x1, int y1) { + x = x1; + y = y1; + } + + // Offset + void Offset(int xOff, int yOff); + void Offset(const RMPoint &p); + friend RMPoint operator+(RMPoint p1, RMPoint p2); + friend RMPoint operator-(RMPoint p1, RMPoint p2); + RMPoint &operator+=(RMPoint p); + RMPoint &operator-=(RMPoint p); + RMPoint operator-(); + + // Comparison + bool operator==(RMPoint p); + bool operator!=(RMPoint p); + + // Casting a POINT operator Common::Point() const; - // Extraction from data streams - friend RMDataStream& operator>>(RMDataStream &ds, RMPoint &p); + // Extraction from data streams + friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); }; class RMRect { public: - int x1,y1; - int x2,y2; + int x1, y1; + int x2, y2; public: - RMRect(); - RMRect(int x1, int y1, int x2, int y2); - RMRect(const RMPoint &p1, const RMPoint &p2); - RMRect(const RMRect &rc); - - // Attributes - RMPoint &TopLeft(); - RMPoint &BottomRight(); - RMPoint Center(); - int Width() const; - int Height() const; - bool IsEmpty() const; + RMRect(); + RMRect(int x1, int y1, int x2, int y2); + RMRect(const RMPoint &p1, const RMPoint &p2); + RMRect(const RMRect &rc); + + // Attributes + RMPoint &TopLeft(); + RMPoint &BottomRight(); + RMPoint Center(); + int Width() const; + int Height() const; + bool IsEmpty() const; int Size() const; - // Set - void SetRect(int x1, int y1, int x2, int y2); - void SetRect(const RMPoint &p1, const RMPoint &p2); - void SetEmpty(void); - - // Copiers - void SetRect(const RMRect &rc); - void CopyRect(const RMRect &rc); - const RMRect &operator=(const RMRect &rc); - - // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); - friend RMRect operator+(const RMRect &rc, RMPoint p); - friend RMRect operator-(const RMRect &rc, RMPoint p); - friend RMRect operator+(RMPoint p, const RMRect &rc); - friend RMRect operator-(RMPoint p, const RMRect &rc); - const RMRect &operator+=(RMPoint p); - const RMRect &operator-=(RMPoint p); - - // Comparison - bool operator==(const RMRect &rc); - bool operator!=(const RMRect &rc); - - // Normalise - void NormalizeRect(); + // Set + void SetRect(int x1, int y1, int x2, int y2); + void SetRect(const RMPoint &p1, const RMPoint &p2); + void SetEmpty(void); + + // Copiers + void SetRect(const RMRect &rc); + void CopyRect(const RMRect &rc); + const RMRect &operator=(const RMRect &rc); + + // Offset + void Offset(int xOff, int yOff); + void Offset(const RMPoint &p); + friend RMRect operator+(const RMRect &rc, RMPoint p); + friend RMRect operator-(const RMRect &rc, RMPoint p); + friend RMRect operator+(RMPoint p, const RMRect &rc); + friend RMRect operator-(RMPoint p, const RMRect &rc); + const RMRect &operator+=(RMPoint p); + const RMRect &operator-=(RMPoint p); + + // Comparison + bool operator==(const RMRect &rc); + bool operator!=(const RMRect &rc); + + // Normalise + void NormalizeRect(); // Point in rect - bool PtInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } + bool PtInRect(const RMPoint &pt) { + return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); + } - // Extract from data stream - friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); + // Extract from data stream + friend RMDataStream &operator>>(RMDataStream &ds, RMRect &rc); }; /** diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 0f36c72f9765..6b61d25ea24c 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -39,7 +39,7 @@ namespace Tony { * RMWindow Methods \****************************************************************************/ -RMWindow::RMWindow() { +RMWindow::RMWindow() { } @@ -93,7 +93,7 @@ void RMWindow::Unlock() { */ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && - (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { + (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { // Full screen clear wanted, so use shortcut method g_system->fillScreen(0); } else { @@ -136,14 +136,14 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { if (!rcBoundEllipse.isValidRect()) return; - Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, - rcBoundEllipse.top + rcBoundEllipse.height() / 2); + Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, + rcBoundEllipse.top + rcBoundEllipse.height() / 2); // The rectangle technically defines the area inside the ellipse, with the corners touching // the ellipse boundary. Since we're currently simulating the ellipse using a plain circle, // we need to calculate a necessary width using the hypotenuse of X/2 & Y/2 int x2y2 = (rcBoundEllipse.width() / 2) * (rcBoundEllipse.width() / 2) + - (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); + (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); int radius = 0; while ((radius * radius) < x2y2) ++radius; @@ -155,11 +155,11 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { while (x >= y) { plotSplices(lpBuf, center, x, y); - + error += y; ++y; error += y; - + if (error >= 0) { error -= x; --x; @@ -173,7 +173,7 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { */ void RMWindow::plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y) { plotLines(lpBuf, center, x, y); - if (x != y) + if (x != y) plotLines(lpBuf, center, y, x); } @@ -206,11 +206,11 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; +byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; - + int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; @@ -219,13 +219,13 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; - + if (lpDestBuf == NULL) src += (RM_SY - 1) * RM_BBX; if (dezoom == 1 && 0) { byte *curOut = rgb; - + for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x]; @@ -242,32 +242,32 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src -= RM_BBX; else src += RM_BBX; - } + } } else { for (int y = 0; y < dimy; y++) { - for(int x = 0; x < dimx; x++) { + for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; sommar = sommab = sommag = 0; - + for (v = 0; v < dezoom; v++) { for (u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else curv = v; - + sommab += cursrc[curv * RM_BBX + u] & 0x1F; sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } - rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); + rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); - if (lpDestBuf!=NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + if (lpDestBuf != NULL) + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); k += 3; } diff --git a/engines/tony/window.h b/engines/tony/window.h index 73cc6d2005a7..0f614fca97d5 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -42,7 +42,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer used to convert to RGB - static byte rgb[RM_SX * RM_SY * 3]; + static byte rgb[RM_SX *RM_SY * 3]; public: // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); @@ -95,7 +95,9 @@ class RMWindow { // Request a thumbnail be grabbed during the next frame void GrabThumbnail(uint16 *buf); - int getFps() const { return fps; } + int getFps() const { + return fps; + } }; } // End of namespace Tony