TONY: Engine is now compiling and linking again

This commit is contained in:
Paul Gilbert 2012-05-03 22:49:30 +10:00
parent ba2711b5e3
commit a2982a0b20
13 changed files with 1570 additions and 59 deletions

View file

@ -92,7 +92,7 @@ void MainShowMouse(void);
void MainHideMouse(void);
void MainEnableInput(void);
void MainDisableInput(void);
void MainPlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync);
void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync);
void MainInitWipe(int type);
void MainCloseWipe(void);
void MainWaitWipeEnd(void);

View file

@ -125,6 +125,14 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes
nLetters=nChars;
}
void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) {
RMRes res(resID);
if ((int)res.Size() < nChars * (dimy * dimx + 8))
nChars = res.Size() / (dimy * dimx + 8);
Load(res, nChars, dimx, dimy, palResID);
}
void RMFont::Unload(void) {
if (m_letter != NULL) {
@ -2273,6 +2281,25 @@ void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
RMText::Draw(bigBuf,prim);
}
RMPoint RMTextItemName::GetHotspot() {
if (m_item == NULL)
return m_mpos + m_curscroll;
else
return m_item->Hotspot();
}
RMItem *RMTextItemName::GetSelectedItem() {
return m_item;
}
bool RMTextItemName::IsItemSelected() {
return m_item != NULL;
}
bool RMTextItemName::IsNormalItemSelected() {
return m_item != NULL && m_itemName.Length() > 0;
}
/****************************************************************************\
* Metodi di RMDialogChoice

View file

@ -130,7 +130,7 @@ void MainHideMouse(void) {
_vm->GetEngine()->DisableMouse();
}
void MainPlayMusic(int nChannel, char* filename, int nFX, bool bLoop, int nSync) {
void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) {
_vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync);
}

View file

@ -138,15 +138,15 @@ void RMGfxBuffer::OffsetY(int nLines, int nBpp) {
}
inline RMGfxBuffer::operator byte *() {
RMGfxBuffer::operator byte *() {
return m_buf;
}
inline RMGfxBuffer::operator void *() {
RMGfxBuffer::operator void *() {
return (void *)m_buf;
}
inline RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) {
RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) {
Create(dimx, dimy, nBpp, bUseDDraw);
}
@ -255,7 +255,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int
*
\****************************************************************************/
inline 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);
}
@ -275,11 +275,11 @@ void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
RMGfxSourceBuffer16::Draw(bigBuf, prim);
}
inline RMGfxWoodyBuffer::RMGfxWoodyBuffer() {
RMGfxWoodyBuffer::RMGfxWoodyBuffer() {
}
inline RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw)
RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw)
: RMGfxBuffer(dimx,dimy,16,bUseDDraw) {
}
@ -407,7 +407,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) {
g_system->unlockMutex(csModifyingOT);
}
inline void RMGfxTargetBuffer::AddClearTask(void) {
void RMGfxTargetBuffer::AddClearTask(void) {
AddPrim(new RMGfxPrimitive(&taskClear));
}
@ -486,11 +486,11 @@ void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoad
}
}
inline int RMGfxSourceBufferPal::LoadPalette(uint32 resID) {
int RMGfxSourceBufferPal::LoadPalette(uint32 resID) {
return LoadPalette(RMRes(resID));
}
inline int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) {
int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) {
return LoadPaletteWA(RMRes(resID), bSwapped);
}
@ -501,7 +501,7 @@ inline int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) {
void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
}
inline RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw)
RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw)
: RMGfxBuffer(dimx,dimy,4,bUseDDraw) {
SetPriority(0);
}
@ -516,11 +516,11 @@ inline RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw
*
\****************************************************************************/
inline int RMGfxSourceBuffer4::Bpp() {
int RMGfxSourceBuffer4::Bpp() {
return 4;
}
inline void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) {
void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) {
RMGfxBuffer::Create(dimx,dimy,4,bUseDDraw);
}
@ -589,12 +589,12 @@ void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
}
}
inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw)
RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw)
: RMGfxBuffer(dimx,dimy,8,bUseDDraw) {
SetPriority(0);
}
inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) {
RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) {
m_bTrasp0=bTrasp0;
}
@ -609,11 +609,11 @@ inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) {
*
\****************************************************************************/
inline int RMGfxSourceBuffer8::Bpp() {
int RMGfxSourceBuffer8::Bpp() {
return 8;
}
inline void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) {
void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) {
RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw);
}
@ -630,7 +630,7 @@ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() {
}
inline int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back)
int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back)
{
int r,g,b;
@ -1919,7 +1919,7 @@ void RMGfxSourceBuffer16::PrepareImage(void) {
}
inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw)
RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw)
: RMGfxBuffer(dimx,dimy,16,bUseDDraw) {
SetPriority(0);
}
@ -1934,11 +1934,11 @@ inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDr
*
\****************************************************************************/
inline int RMGfxSourceBuffer16::Bpp() {
int RMGfxSourceBuffer16::Bpp() {
return 16;
}
inline void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) {
void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) {
RMGfxBuffer::Create(dimx,dimy,16,bUseDDraw);
}
@ -1980,17 +1980,17 @@ void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
* Metodi di RMGfxClearTask
\****************************************************************************/
inline int RMGfxClearTask::Priority() {
int RMGfxClearTask::Priority() {
// Priorita' massima (deve essere fatto per primo)
return 1;
}
inline void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) {
void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) {
// Pulisce tutto il target buffer
Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0);
}
inline bool RMGfxClearTask::RemoveThis() {
bool RMGfxClearTask::RemoveThis() {
// Il task di clear si disattiva sempre
return true;
}

View file

@ -58,12 +58,22 @@ extern bool bIdleExited;
extern bool bPatIrqFreeze;
extern bool bSkipSfxNoLoop;
extern void ExitAllIdles(int nCurLoc);
/****************************************************************************\
* Metodi di RMGfxEngine
\****************************************************************************/
bool bIdleExited;
void ExitAllIdles(int nCurLoc) {
// Chiude le idle
bSkipSfxNoLoop = true;
mpalEndIdlePoll(nCurLoc);
bIdleExited = true;
bSkipSfxNoLoop = false;
ExitThread(0);
}
RMGfxEngine::RMGfxEngine() {
// Crea il big buffer dove verranno disegnati i frame
m_bigBuf.Create(RM_BBX, RM_BBY, 16);

View file

@ -14,6 +14,7 @@ MODULE_OBJS := \
tony.o \
tonychar.o \
utils.o \
window.o \
mpal/expr.o \
mpal/loadmpc.o \
mpal/memory.o \

View file

@ -505,7 +505,7 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) {
uint16 *lpBuf = (uint16 *)buf;
byte *inp;
int bufferstep;
int cache;
int cache = 0;
int delta;
int sign;
int vpdiff;
@ -1551,12 +1551,10 @@ void FPSFX::GetVolume(int *lpdwVolume) {
*lpdwVolume -= (DSBVOLUME_MIN);
*lpdwVolume *= 64;
*lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN);
#endregion
#endif
}
/****************************************************************************\
* Metodi di FPSTREAM
\****************************************************************************/
@ -1571,6 +1569,7 @@ void FPSFX::GetVolume(int *lpdwVolume) {
\****************************************************************************/
FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) {
#ifdef REFACTOR_ME
//hwnd=hWnd;
lpDS=LPDS;
bSoundSupported = bSoundOn;
@ -1581,6 +1580,7 @@ FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) {
lpDSBuffer = NULL;
lpDSNotify = NULL;
hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL;
#endif
}
bool FPSTREAM::CreateBuffer(int nBufSize) {
@ -1661,6 +1661,8 @@ bool FPSTREAM::CreateBuffer(int nBufSize) {
\****************************************************************************/
FPSTREAM::~FPSTREAM() {
#ifdef REFACTOR_ME
if (!bSoundSupported)
return;
@ -1695,6 +1697,7 @@ FPSTREAM::~FPSTREAM() {
RELEASE(lpDSNotify);
RELEASE(lpDSBuffer);
#endif
}
@ -1711,9 +1714,9 @@ FPSTREAM::~FPSTREAM() {
*
\****************************************************************************/
FPSTREAM::Release() {
void FPSTREAM::Release() {
delete this;
return NULL;
// return NULL;
}
@ -1780,6 +1783,8 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize
\****************************************************************************/
bool FPSTREAM::UnloadFile() {
#ifdef REFACTOR_ME
if (!bSoundSupported || !bFileLoaded)
return true;
@ -1791,7 +1796,7 @@ bool FPSTREAM::UnloadFile() {
/* Si ricorda che non c'e' piu' nessun file in memoria */
bFileLoaded = false;
#endif
return true;
}
@ -1985,6 +1990,8 @@ bool FPSTREAM::Play() {
\****************************************************************************/
bool FPSTREAM::Stop(bool bSync) {
#ifdef REFACTOR_ME
if (!bSoundSupported)
return true;
@ -2018,7 +2025,7 @@ bool FPSTREAM::Stop(bool bSync) {
bIsPlaying = false;
bPaused = false;
}
#endif
return true;
}
@ -2199,6 +2206,8 @@ void FPSTREAM::SetLoop(bool loop) {
void FPSTREAM::Pause(bool bPause) {
#ifdef REFACTOR_ME
if (bFileLoaded) {
if (bPause && bIsPlaying) {
lpDSBuffer->Stop();
@ -2227,6 +2236,7 @@ void FPSTREAM::Pause(bool bPause) {
SetVolume(lastVolume);
}
}
#endif
}
@ -2278,7 +2288,7 @@ void FPSTREAM::GetVolume(int *lpdwVolume) {
*lpdwVolume -= (DSBVOLUME_MIN);
*lpdwVolume *= 64;
*lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN);
#endregion
#endif
}
} // End of namespace Tony

View file

@ -139,7 +139,7 @@ int flipflop=0;
OSystem::MutexRef csMusic;
void TonyEngine::PlayMusic(int nChannel, char* fn, int nFX, bool bLoop, int nSync) {
void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) {
warning("TonyEngine::PlayMusic");
}
@ -202,6 +202,46 @@ int TonyEngine::GetMusicVolume(int nChannel) {
return 255;
}
void TonyEngine::GetSaveStateFileName(int n, char *buf) {
RMString name;
if (n > 0)
name.Format("%02d", n);
else
name.Format("autosave");
name += ".sav";
}
void TonyEngine::AutoSave(void) {
char buf[256];
GrabThumbnail();
MainWaitFrame();
MainWaitFrame();
MainFreeze();
GetSaveStateFileName(0,buf);
_theEngine.SaveState(buf, (byte *)m_curThumbnail, "Autosave", true);
MainUnfreeze();
}
void TonyEngine::SaveState(int n, const char *name) {
char buf[256];
GetSaveStateFileName(n, buf);
_theEngine.SaveState(buf,(byte *)m_curThumbnail, name);
}
void TonyEngine::LoadState(int n) {
char buf[256];
GetSaveStateFileName(n, buf);
_theEngine.LoadState(buf);
}
bool TonyEngine::OpenVoiceDatabase() {
char id[4];
uint32 numfiles;
@ -251,6 +291,21 @@ void TonyEngine::GrabThumbnail(void) {
warning("TODO: TonyEngine::GrabThumbnail");
}
void TonyEngine::OptionScreen(void) {
}
void TonyEngine::OpenInitLoadMenu(void) {
_theEngine.OpenOptionScreen(1);
}
void TonyEngine::OpenInitOptions(void) {
_theEngine.OpenOptionScreen(2);
}
void TonyEngine::Abort(void) {
m_bQuitNow = true;
}
void TonyEngine::Play(void) {
warning("TODO TonyEngine::Play");
@ -314,14 +369,14 @@ void TonyEngine::PauseLoop(void) {
MSG msg;
int st,et;
st = timeGetTime();
st = GetTime();
while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
et = timeGetTime();
et = GetTime();
m_startTime += et - st;
#endif
@ -345,4 +400,22 @@ warning("TODO: TonyEninge::Pause");
*/
}
void TonyEngine::FreezeTime(void) {
m_bTimeFreezed = true;
m_nTimeFreezed = GetTime() - m_startTime;
}
void TonyEngine::UnfreezeTime(void)
{
m_bTimeFreezed = false;
}
/**
* Returns the millisecond timer
*/
uint32 TonyEngine::GetTime() {
return g_system->getMillis();
}
} // End of namespace Tony

View file

@ -158,7 +158,7 @@ public:
// Music
// ******
void PlayMusic(int nChannel, char *fn, int nFX, bool bLoop, int nSync);
void PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync);
void StopMusic(int nChannel);
void PlaySFX(int nSfx, int nFX = 0);
@ -183,7 +183,7 @@ public:
// Salvataggio
void AutoSave(void);
void SaveState(int n, char *name);
void SaveState(int n, const char *name);
void LoadState(int n);
void GetSaveStateFileName(int n, char* buf);

View file

@ -292,8 +292,8 @@ RMString::operator char*() const {
/**
* 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 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) {
@ -406,6 +406,122 @@ void RMString::Format(char* str, ...) {
*/
}
/****************************************************************************\
* Metodi di RMFileStreamSlow
\****************************************************************************/
RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() {
_stream = NULL;
}
RMFileStreamSlow::~RMFileStreamSlow() {
Close();
}
void RMFileStreamSlow::Close() {
delete _stream;
}
bool RMFileStreamSlow::OpenFile(Common::File &file) {
_stream = file.readStream(file.size());
m_length = _stream->pos();
return true;
}
bool RMFileStreamSlow::OpenFile(const char *lpFN) {
// Apre il file in lettura
Common::File f;
if (!f.open(lpFN))
return false;
m_length = f.size();
_stream = f.readStream(f.size());
return true;
}
RMDataStream& RMFileStreamSlow::operator+=(int nBytes) {
Seek(nBytes);
return *this;
}
int RMFileStreamSlow::Pos() {
return _stream->pos();
}
bool RMFileStreamSlow::IsEOF() {
return (Pos() >= m_length);
}
int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) {
switch (where) {
case START:
return _stream->seek(nBytes);
case END:
return _stream->seek(nBytes, SEEK_END);
case CUR:
return _stream->seek(nBytes, SEEK_CUR);
default:
return 0;
}
}
bool RMFileStreamSlow::Read(void *buf, int size) {
uint32 dwRead;
dwRead = _stream->read(buf, size);
return ((int)dwRead == size);
}
RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) {
df.Read(&var, 1);
return df;
}
RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) {
df.Read(&var,1);
return df;
}
RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) {
uint16 v;
df.Read(&v, 2);
v = FROM_LE_16(v);
return df;
}
RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) {
uint16 v;
df.Read(&v, 2);
var = (int16)FROM_LE_16(v);
return df;
}
RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) {
int v;
df.Read(&v,4);
var = FROM_LE_32(v);
return df;
}
RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) {
uint32 v;
df.Read(&v, 4);
var = FROM_LE_32(v);
return df;
}
/****************************************************************************\
* RMDataStream methods
\****************************************************************************/
@ -458,7 +574,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);
@ -546,7 +662,7 @@ 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
* @returns true if we have reached the end, false if not
*/
bool RMDataStream::Read(void *lpBuf, int size) {
byte *dest = (byte *)lpBuf;
@ -609,7 +725,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;

View file

@ -140,9 +140,7 @@ public:
class RMFileStreamSlow : public RMDataStream {
private:
Common::File f;
bool bMustClose;
Common::SeekableReadStream *_stream;
public:
RMFileStreamSlow();
virtual ~RMFileStreamSlow();

1255
engines/tony/window.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -50,15 +50,36 @@
#include "common/scummsys.h"
#include "common/rect.h"
#include "tony/adv.h"
namespace Tony {
typedef uint32 HWND;
struct DDSURFACEDESC {
};
class RMSnapshot {
private:
// Buffer per la creazione dei path
static char bufDrive[_MAX_DRIVE], bufDir[_MAX_DIR], bufName[_MAX_FNAME], bufExt[_MAX_EXT];
static char filename[512];
// Buffer per la conversione a RGB
static byte rgb[RM_SX * RM_SY * 3];
private:
bool GetFreeSnapName(char *fn);
public:
// Prende uno screenshot
void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL);
};
class RMWindow {
private:
bool Lock(/*DDSURFACEDESC& ddsd */);
void Unlock(/*DDSURFACEDESC& ddsd */);
bool Lock(DDSURFACEDESC &ddsd);
void Unlock(DDSURFACEDESC &ddsd);
// Inizializza DirectDraw
void DDInit(void);
@ -115,7 +136,7 @@ protected:
void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse);
// Avverte di grabbare un thumbnail per il salvataggio
// void GrabThumbnail(uint16 *buf);
void GrabThumbnail(uint16 *buf);
operator HWND() { return m_hWnd; }