aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/enid2.cpp
blob: 9c7d64a1b113591d0035b6fda11e242bc43eb205 (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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/* 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.
 *
 */

/*
 * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
 * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
 */

/* ENID		Edna's manager. */

#include "common/scummsys.h"
#include "common/textconsole.h"

#include "avalanche/enid2.h"
#include "avalanche/scrolls2.h"
#include "avalanche/lucerna2.h"
#include "avalanche/trip6.h"
#include "avalanche/timeout2.h"
#include "avalanche/celer2.h"
#include "avalanche/sequence2.h"
//#include "fileunit.h"
//#include "basher.h"


namespace Avalanche {

	namespace Enid {

	const Common::String crlf = Common::String(char(15)) + Common::String(char(12));
	const char tab = '\t';
	const char eof_ = '\n';

	const Common::String ednafirst =
		Common::String("This is an EDNA-based file, saved by a Thorsoft game. Good luck!") + /*64*/
		crlf + eof_ + crlf + crlf + /*7*/
		tab + "Glory to God in the highest," + crlf + /*31*/
		tab + "and on earth peace, goodwill toward men." + /*42*/
		crlf + tab + tab + tab + tab + /*6*/
		"Luke 2:14." + /*10*/
		crlf + crlf + crlf + /* 6 */
		"1234567890" +crlf; /*11*/

	const Common::String ednaid = Common::String("TT") + char(261) + char(60) + char(1) + char(165) + char(261) + char(231) + char(261);

	const int16 ttage = 18;
	const Common::String ttwashere = "Thomas was here ";

	bool bug;



	Common::String expanddate(byte d, byte m, uint16 y);
 
	static Common::String month;

	static Common::String day;

	static void addon(Common::String x) {
		//month[0]--;
		month = month + x;
	}

	Common::String expanddate(byte d, byte m, uint16 y) {
		const Common::String months[12] = {
			"Jan#", "Febr#", "March", "April", "May", "June", "July", "August",
			"Septem*", "Octo*", "Novem*", "Decem*"		
		};

		Common::String expanddate_result;
		month = months[m];
		switch (month[month.size()]) {
		case '#':
			addon("uary");
			break;
		case '*':
			addon("ber");
			break;
		}

		day = Gyro::strf(d);

		if (((d >= 0) && (d <= 9)) || ((d >= 21) && (d <= 31)))
			switch (d % 10) {
			case 1:
				day = day + "st";
				break;
			case 2:
				day = day + "nd";
				break;
			case 3:
				day = day + "rd";
				break;
			default:
				day = day + "th";
			}

		expanddate_result = day + ' ' + month + ' ' + Gyro::strf(y);
		return expanddate_result;
	}



	void edna_save(Common::String name);

	static void show_bug(char icon, Common::String strn) {
		Scrolls::display(Common::String("\7\6\23") + icon + "\26\r" + strn + '\15');
	}

	static bool test_bug(byte what) {
		bool test_bug_result;
		if (what == 0)  {
			test_bug_result = false;
			return test_bug_result;
		}
		switch (what) {
		case 2:
			show_bug('7', "Error in filename!");
			break;
		case 101:
			show_bug('6', "Disk full!");
			break;
		case 150:
			show_bug('4', "Disk is write-protected!");
			break;
		default:
			show_bug('B', "Saving error!");
		}
		test_bug_result = true;
		return test_bug_result;
	}

	void edna_save(Common::String name) {
		warning("STUB: Enid::edna_save()");
	}

	void loaderror(Common::String x, char icon) {
		if (Gyro::holdthedawn) {
			Gyro::holdthedawn = false;
			Lucerna::dawn();
		}
		Scrolls::display(Common::String('\7') + '\6' + '\23' + icon + '\26' + "Loading error:  " + "\r\r\22" + x);
		bug = true;
	}



	typedef char fourtype[5];



	const fourtype avaricius_file = "Avvy";

	void edna_load(Common::String name) {
		warning("STUB: Enid::edna_load()");
	}



	void dir(Common::String where);

	static Common::String path, groi;

	static void showheader() {
		Scrolls::display(Common::String("Dir: ") + path + "\r\r\4");
	}

	void dir(Common::String where) { /* OK, it worked in Avaricius, let's do it in Avalot! */
		warning("STUB: Enid::dir()");
	}

	void avvy_background() {    /* Not really a filing procedure,
	 but it's only called just before edna_load, so I thought I'd put it
	 in Enid instead of, say, Lucerna. */
	
		/* port[$3c4]:=2; port[$3ce]:=4; port[$3C5]:=1; port[$3CF]:=1; { Blue. }*/
		/*
		 asm
		  mov dx,$3c4; mov al,2; out dx,al; { Set up the VGA to use the "blue" }
		  mov dx,$3ce; mov al,4; out dx,al; { register. }
		  mov dx,$3c5; mov al,1; out dx,al;
		  mov dx,$3cf;           out dx,al;

		  mov bx,$A000; call far ptr @drawup;
		  mov bx,$A400; call far ptr @drawup;

		  jmp @the_end;

		 @drawup:

		  mov es,bx; { The segment to copy it to... }
		  mov di,$370;  { The offset (10 pixels down, plus 1 offset.) }

		  mov cx,10;
		  mov ax,$AA4A; call far ptr @sameline; { Print "AVVY" }
		  mov ax,$AEAA; call far ptr @sameline;
		  mov ax,$A4EA; call far ptr @sameline;
		  mov ax,$44A4; call far ptr @sameline;

		  mov cx,9;
		  mov ax,$AAA4; call far ptr @sameline; { Print "YAVV" }
		  mov ax,$AAEA; call far ptr @sameline;
		  mov ax,$AA4E; call far ptr @sameline;
		  mov ax,$444A; call far ptr @sameline;

		  mov ax,$4AAA; call far ptr @sameline; { Print "VYAV" }
		  mov ax,$AAAE; call far ptr @sameline;
		  mov ax,$EAA4; call far ptr @sameline;
		  mov ax,$A444; call far ptr @sameline;

		  mov ax,$A4AA; call far ptr @sameline; { Print "VVYA" }
		  mov ax,$EAAA; call far ptr @sameline;
		  mov ax,$4EAA; call far ptr @sameline;
		  mov ax,$4A44; call far ptr @sameline;

		  ret;


		  { Replicate the same line many times. }

		  @sameline:
		   { Requires:
			  what to copy in AX,
			  how many lines in CX, and
			  original offset in DI. }
		   push cx;
		   push di;

		   @samelineloop:

			push cx;
			mov cx,40; { No. of times to repeat it on one line. }

			repz stosw; { Fast uint16-copying }

			pop cx;

			add di,1200; { The next one will be 16 lines down. }

		   loop @samelineloop;
		   pop di;
		   add di,80;
		   pop cx;

		   ret;

		  @the_end:
		 end;
		*/
		Lucerna::blitfix();
	}

	void to_sundry(Gyro::sundry &sund) {
		{
			sund.qenid_filename = Gyro::enid_filename;
			sund.qsoundfx = Gyro::soundfx;
			sund.qthinks = Gyro::thinks;
			sund.qthinkthing = Gyro::thinkthing;
		}
	}

	void from_sundry(Gyro::sundry sund) {
		{
			Gyro::enid_filename = sund.qenid_filename;
			Gyro::soundfx = sund.qsoundfx;
			Gyro::thinks = sund.qthinks;
			Gyro::thinkthing = sund.qthinkthing;
		}
	}

	void restore_dna() {
		uint16 here, fv;
		Gyro::sundry sund;

		warning("STUB: Enid::restore_dna()");
	}

	void edna_reload() {

		restore_dna();

		Gyro::seescroll = true;  /* This prevents display of the new sprites before the
	  new picture is loaded. */

		Lucerna::major_redraw();

		Gyro::whereis[Gyro::pavalot] = Gyro::dna.room;

		Gyro::alive = true;

		Lucerna::objectlist();

		if (Gyro::holdthedawn) {
			Gyro::holdthedawn = false;
			Lucerna::dawn();
		}
	}

	void back_to_bootstrap(byte what) {
		warning("STUB: Enid::back_to_bootstrap()");
	}

	bool there_was_a_problem() {
		return bug;
	}

	} // End of namespace Enid.

} // End of namespace Avalanche.