1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * System variable handling.
22  */
23 
24 #include "tinsel/dw.h"
25 #include "tinsel/graphics.h"
26 #include "tinsel/dialogs.h"
27 #include "tinsel/strres.h"
28 #include "tinsel/sysvar.h"
29 #include "tinsel/tinsel.h"
30 
31 #include "common/textconsole.h"
32 
33 namespace Tinsel {
34 
35 // Return for SYS_Platform
36 typedef enum { DOS_PC, WIN_PC, APPLE_MAC, SONY_PSX, SEGA_SATURN } platform;
37 
38 //----------------- GLOBAL GLOBAL DATA --------------------
39 
40 extern int NewestSavedGame();
41 
42 //----------------- LOCAL GLOBAL DATA --------------------
43 
44 // FIXME: Avoid non-const global vars
45 
46 static int g_systemVars[SV_TOPVALID] = {
47 
48 		INV_1,		// Default inventory
49 
50 		10,		// Y-offset of Conversation(TOP)
51 		320,		// Y-offset of Conversation(BOT)
52 		15,		// Minimum distance from side
53 		10,		// Minimum distance from top
54 		115,		// Distance above actor
55 		10,		// Distance below actor
56 
57 		0,		// Current language **READ ONLY**
58 		0,		// Sample language **READ ONLY**
59 		0,		// Current state **READ ONLY**
60 		0,		// Saved Game Exists **READ ONLY**
61 
62 		true,		// Should Conversation() wait for scroll? [TRUE]
63 		true,		// Should Talk()/Say() wait for scroll? [TRUE]
64 
65 		true,		// Enable PointTag()
66 		true,		// Enable cursor with PrintCursor()
67 
68 		100,		// SV_SCROLL_XTRIGGER
69 		0,			// SV_SCROLL_XDISTANCE
70 		16,			// SV_SCROLL_XSPEED
71 		40,			// SV_SCROLL_YTRIGGERTOP
72 		40,			// SV_SCROLL_YTRIGGERBOT
73 		0,			// SV_SCROLL_YDISTANCE
74 		16,			// SV_SCROLL_YSPEED
75 
76 		2,		// Speech Delay
77 		2,		// Music dim factor
78 
79 		0,		// if set, default actor's text color gets poked in here
80 
81 		0,		// user 1
82 		0,		// user 2
83 		0,		// user 3
84 		0,		// user 4
85 		0,		// user 5
86 		0,		// user 6
87 
88 		0,		// SYS_MinimumXoffset
89 		0,		// SYS_MaximumXoffset
90 		0,		// SYS_MinimumYoffset
91 		0,		// SYS_MaximumYoffset
92 
93 		0,		// SYS_DefaultFxDimFactor
94 		0,		// SYS_SceneFxDimFactor
95 
96 		0x606060,	// SYS_HighlightRGB
97 		WIN_PC,		// SYS_Platform,
98 		0,		// SYS_Debug
99 
100 		0,		// ISV_DIVERT_ACTOR
101 		false,		// ISV_NO_BLOCKING
102 
103 		0,		// ISV_GHOST_ACTOR
104 		0,		// ISV_GHOST_BASE
105 		0		// ISV_GHOST_COLOR
106 };
107 
108 static SCNHANDLE g_systemStrings[SS_MAX_VALID];	// FIXME: Avoid non-const global vars
109 
110 //static bool bFlagNoBlocking = false;
111 
112 //----------------- FUNCTIONS --------------------------------
113 
114 /**
115  * Initializes the system variable list
116  */
117 
InitSysVars()118 void InitSysVars() {
119 	g_systemVars[SV_SCROLL_XDISTANCE] = SCREEN_WIDTH / 2;
120 	g_systemVars[SV_SCROLL_YDISTANCE] = SCREEN_BOX_HEIGHT1 / 2;
121 }
122 
123 /**
124  * SetSysVar
125  */
126 
SetSysVar(int varId,int newValue)127 void SetSysVar(int varId, int newValue) {
128 	if (varId < 0 || varId >= SV_TOPVALID)
129 		error("SetSystemVar(): out of range identifier");
130 
131 	switch (varId) {
132 	case SV_LANGUAGE:
133 	case SV_SAMPLE_LANGUAGE:
134 	case SV_SUBTITLES:
135 	case SV_SAVED_GAME_EXISTS:
136 	case SYS_Platform:
137 	case SYS_Debug:
138 		error("SetSystemVar(): read only identifier");
139 
140 	default:
141 		g_systemVars[varId] = newValue;
142 	}
143 }
144 
SysVar(int varId)145 int SysVar(int varId) {
146 	if (varId < 0 || varId >= SV_TOPVALID)
147 		error("SystemVar(): out of range identifier");
148 
149 	switch (varId) {
150 	case SV_LANGUAGE:
151 		return TextLanguage();
152 
153 	case SV_SAMPLE_LANGUAGE:
154 		return SampleLanguage();
155 
156 	case SV_SUBTITLES:
157 		// FIXME: This isn't currently defined
158 		return false;
159 		//return _vm->_config->_useSubtitles;
160 
161 	case SV_SAVED_GAME_EXISTS:
162 		return NewestSavedGame() != -1;
163 
164 	case SYS_Debug:
165 		// FIXME: This isn't currently defined
166 		return false;
167 		//return bDebuggingAllowed;
168 
169 	default:
170 		return g_systemVars[varId];
171 	}
172 }
173 
SaveSysVars(int * pSv)174 void SaveSysVars(int *pSv) {
175 	memcpy(pSv, g_systemVars, sizeof(g_systemVars));
176 }
177 
RestoreSysVars(int * pSv)178 void RestoreSysVars(int *pSv) {
179 	memcpy(g_systemVars, pSv, sizeof(g_systemVars));
180 }
181 
SetSysString(int number,SCNHANDLE hString)182 void SetSysString(int number, SCNHANDLE hString) {
183 	assert(number >= 0 && number < SS_MAX_VALID);
184 
185 	g_systemStrings[number] = hString;
186 }
187 
SysString(int number)188 SCNHANDLE SysString(int number) {
189 	assert(number >= 0 && number < SS_MAX_VALID);
190 
191 	return g_systemStrings[number];
192 }
193 
194 /**
195  * Gets the no blocking flag. Note that for convenience, the systemVars array
196  * entry is used even for Tinsel 1, which originally used a separate variable.
197  */
GetNoBlocking()198 bool GetNoBlocking() {
199 	return SysVar(ISV_NO_BLOCKING);
200 }
201 
202 /**
203  * Sets the no blocking flag. Note that for convenience, the systemVars array
204  * entry is used even for Tinsel 1, which originally used a separate variable.
205  */
SetNoBlocking(bool flag)206 void SetNoBlocking(bool flag) {
207 	SetSysVar(ISV_NO_BLOCKING, flag);
208 }
209 
210 } // End of namespace Tinsel
211