aboutsummaryrefslogtreecommitdiff
path: root/engines/tony/game.cpp
blob: 109eefab24083c19d0e189d4e773619be42e584f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */
/**************************************************************************
 *                                     ���������������������������������� *
 *                                             Nayma Software srl         *
 *                    e                -= We create much MORE than ALL =- *
 *        u-        z$$$c        '.    ���������������������������������� *
 *      .d"        d$$$$$b        "b.                                     *
 *   .z$*         d$$$$$$$L        ^*$c.                                  *
 *  #$$$.         $$$$$$$$$         .$$$" Project: Roasted Moths........  *
 *    ^*$b       4$$$$$$$$$F      .d$*"                                   *
 *      ^$$.     4$$$$$$$$$F     .$P"     Module:  Loc.CPP..............  *
 *        *$.    '$$$$$$$$$     4$P 4                                     *
 *     J   *$     "$$$$$$$"     $P   r    Author:  Giovanni Bajo........  *
 *    z$   '$$$P*4c.*$$$*.z@*R$$$    $.                                   *
 *   z$"    ""       #$F^      ""    '$c                                  *
 *  z$$beu     .ue="  $  "=e..    .zed$$c                                 *
 *      "#$e z$*"   .  `.   ^*Nc e$""                                     *
 *         "$$".  .r"   ^4.  .^$$"                                        *
 *          ^.@*"6L=\ebu^+C$"*b."                                         *
 *        "**$.  "c 4$$$  J"  J$P*"    OS:  [ ] DOS  [X] WIN95  [ ] PORT  *
 *            ^"--.^ 9$"  .--""      COMP:  [ ] WATCOM  [X] VISUAL C++    *
 *                    "                     [ ] EIFFEL  [ ] GCC/GXX/DJGPP *
 *                                                                        *
 * This source code is Copyright (C) Nayma Software.  ALL RIGHTS RESERVED *
 *                                                                        *
 **************************************************************************/

#include "common/file.h"
#include "common/savefile.h"
#include "tony/mpal/lzo.h"
#include "tony/mpal/memory.h"
#include "tony/mpal/mpal.h"
#include "tony/mpal/mpalutils.h"
#include "tony/mpal/stubs.h"
#include "tony/custom.h"
#include "tony/game.h"
#include "tony/gfxengine.h"
#include "tony/tony.h"

namespace Tony {

using namespace MPAL;

/****************************************/
/*  Variabili globali di configurazione */
/****************************************/

// FIXME: Move into a class instance
bool bCfgInvLocked;
bool bCfgInvNoScroll;
bool bCfgTimerizedText;
bool bCfgInvUp;
bool bCfgAnni30;
bool bCfgAntiAlias;
bool bCfgSottotitoli;
bool bCfgTransparence;
bool bCfgInterTips;
bool bCfgDubbing;
bool bCfgMusic;
bool bCfgSFX;
int  nCfgTonySpeed;
int  nCfgTextSpeed;
int	 nCfgDubbingVolume;
int	 nCfgMusicVolume;
int	 nCfgSFXVolume;
bool bSkipSfxNoLoop;

bool bPatIrqFreeze;

/****************************************/
/*  Funzioni globali per la DLL Custom	*/
/****************************************/

static char path_buffer[_MAX_PATH];
static char drive[_MAX_DRIVE];
static char dir[_MAX_DIR];
static char fname[_MAX_FNAME];
static char ext[_MAX_EXT];

HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) {
	return _vm->GetEngine()->LoadLocation(nLoc,pt,start);
}

HANDLE MainUnloadLocation(bool bDoOnExit) {
	return _vm->GetEngine()->UnloadLocation(bDoOnExit);
}

void MainLinkGraphicTask(RMGfxTask *task) {
	_vm->GetEngine()->LinkGraphicTask(task);
}

void MainFreeze(void) {
	_vm->GetEngine()->Freeze();
}

void MainUnfreeze(void) {
	_vm->GetEngine()->Unfreeze();
}

void MainWaitFrame(void) {
	WaitForSingleObject(_vm->m_hEndOfFrame, INFINITE);
}

void MainShowMouse(void) {
  _vm->GetEngine()->EnableMouse();
}

void MainHideMouse(void) {
  _vm->GetEngine()->DisableMouse();
}

void MainPlayMusic(int nChannel, char* filename, int nFX, bool bLoop, int nSync) {
	_vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync);
}

void MainDisableInput(void) {
	_vm->GetEngine()->DisableInput();
}

void MainEnableInput(void) {
	_vm->GetEngine()->EnableInput();
}

void MainInitWipe(int type) {
	_vm->GetEngine()->InitWipe(type);
}

void MainCloseWipe(void) {
	_vm->GetEngine()->CloseWipe();
}

void MainWaitWipeEnd(void) {
	_vm->GetEngine()->WaitWipeEnd();
}

void MainEnableGUI(void) {
	_vm->GetEngine()->m_bGUIInterface = true;
	_vm->GetEngine()->m_bGUIInventory = true;
	_vm->GetEngine()->m_bGUIOption = true;
}

void MainDisableGUI(void) {
	_vm->GetEngine()->m_bGUIInterface = false;
	_vm->GetEngine()->m_bGUIInventory = false;
	_vm->GetEngine()->m_bGUIOption = false;
}

void MainSetPalesati(bool bPalesati) {
	_vm->GetEngine()->SetPalesati(bPalesati);
}

/****************************************************************************\
*       Metodi di RMOptionButton
\****************************************************************************/

RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) {
	RMResRaw raw(dwRes);
	assert(raw.IsValid());
	m_buf = new RMGfxSourceBuffer16(false);
	m_buf->Init(raw, raw.Width(), raw.Height());

	m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1);
	m_bActive = false;
	m_bHasGfx = true;
	m_bDoubleState = bDoubleState;
}

RMOptionButton::RMOptionButton(RMRect pt) {
	m_rect = pt;
	m_bActive = false;
	m_bHasGfx = false;
	m_bDoubleState = false;
}

RMOptionButton::~RMOptionButton() {
	if (m_bHasGfx)
		delete m_buf;
}

bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) {
	if (!m_bDoubleState) {
		if (m_rect.PtInRect(mousePos)) {
			if (!m_bActive) {
				m_bActive=true;
				return true;
			}
		} else {
			if (m_bActive) {
				m_bActive=false;
				return true;
			}
		}
	} else {
		if (bLeftClick && m_rect.PtInRect(mousePos)) {	
			m_bActive = !m_bActive;
			return true;
		}
	}

	return false;
}



void RMOptionButton::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
	if (!m_bActive)
		return;

	if (m_bHasGfx)
		m_buf->Draw(bigBuf,prim);
}

void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) {
	if (m_bHasGfx)
		bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect));
}

} // End of namespace Tony