aboutsummaryrefslogtreecommitdiff
path: root/engines/lab/graphics.cpp
blob: 41f4a7960a6036c100c12c8cf03da5d83e557ef5 (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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
/* 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 Labyrinth of Time code with assistance of
 *
 * Copyright (c) 1993 Terra Nova Development
 * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
 *
 */

#include "lab/stddefines.h"
#include "lab/diff.h"
#include "lab/parsetypes.h"
#include "lab/labfun.h"
#include "lab/parsefun.h"
#include "lab/mouse.h"
#include "lab/vga.h"
#include "lab/text.h"

namespace Lab {

BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;


extern BitMap RawDiffBM;
extern char diffcmap[256 * 3], lastcmap[256 * 3];
extern bool IsBM, NoFlip, nopalchange, ContMusic;

extern int32 ReadSoFar;
extern bool ReadIsDone, ReadIsError;
extern bool DoBlack, EffectPlaying, stopsound;
extern bool IsHiRes;
extern TextFont *MsgFont;
extern const char *CurFileName;





/*---------------------------------------------------------------------------*/
/*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
/*---------------------------------------------------------------------------*/


extern uint32 VGAScreenWidth, VGAScreenHeight, VGAPages, VGABytesPerPage;

/*****************************************************************************/
/* Reads in a picture into the dest bitmap.                                  */
/*****************************************************************************/
bool readPict(const char *filename, bool PlayOnce) {
	byte **file = NULL;

	stopDiff();

	ReadSoFar  = 0L;
	ReadIsDone = false;
	ReadIsError = false;

	file = g_music->newOpen(filename);

	if (file == NULL) {
		if ((filename[0] == 'p') || (filename[0] == 'P'))
			blackScreen();

		return false;
	}

	DispBitMap->BytesPerRow = VGAScreenWidth;
	DispBitMap->Rows        = VGAScreenHeight;
	DispBitMap->Flags       = BITMAPF_VIDEO;
	DispBitMap->Depth       = VGAPages;

	readDiff(PlayOnce);

	ungetVGABaseAddr();

	return true;
}




/*****************************************************************************/
/* Reads in a music file.  Ignores any graphics.                             */
/*****************************************************************************/
bool readMusic(const char *filename) {
	byte **file = NULL;

	file = g_music->newOpen(filename);

	if (file == NULL) {
		return false;
	}

	DoBlack = false;
	readSound();

	return true;
}




/*****************************************************************************/
/* Reads in a picture into buffer memory.                                    */
/*****************************************************************************/
byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
	byte **file = NULL;
	byte *Mem, *CurMem;

	stopDiff();

	ReadSoFar  = 0L;
	ReadIsDone = false;
	ReadIsError = false;

	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
	CurMem = Mem;

	file = g_music->newOpen(filename);

	if (file == NULL)
		return NULL;

	DispBitMap->BytesPerRow = x;
	DispBitMap->Rows        = y;
	DispBitMap->Flags       = 0;
	DispBitMap->Depth       = VGAPages;
	DispBitMap->Planes[0] = CurMem;
	DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
	DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
	DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
	DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;

	readDiff(true);

	return Mem;
}




/*---------------------------------------------------------------------------*/
/*------------ Does all the text rendering to the message boxes. ------------*/
/*---------------------------------------------------------------------------*/


bool DoNotDrawMessage = false;

extern bool LongWinInFront, Alternate;


/*----- The flowText routines -----*/




/******************************************************************************/
/* Extracts the first word from a string.                                     */
/******************************************************************************/
static void getWord(char *WordBuffer, const char *MainBuffer, uint16 *WordWidth) {
	uint16 width = 0;

	while ((MainBuffer[width] != ' ') && MainBuffer[width] &&
	        (MainBuffer[width] != '\n')) {
		WordBuffer[width] = MainBuffer[width];
		width++;
	}

	WordBuffer[width] = 0;

	*WordWidth = width;
}





/******************************************************************************/
/* Gets a line of text for flowText; makes sure that its length is less than  */
/* or equal to the maximum width.                                             */
/******************************************************************************/
static void getLine(TextFont *tf, char *LineBuffer, const char **MainBuffer, uint16 LineWidth) {
	uint16 CurWidth = 0, WordWidth;
	char WordBuffer[100];
	bool doit = true;

	LineWidth += textLength(tf, " ", 1);

	LineBuffer[0] = 0;

	while ((*MainBuffer)[0] && doit) {
		getWord(WordBuffer, *MainBuffer, &WordWidth);
		strcat(WordBuffer, " ");

		if ((CurWidth + textLength(tf, WordBuffer, WordWidth + 1)) <= LineWidth) {
			strcat(LineBuffer, WordBuffer);
			(*MainBuffer) += WordWidth;

			if ((*MainBuffer)[0] == '\n')
				doit = false;

			if ((*MainBuffer)[0])
				(*MainBuffer)++;

			CurWidth = textLength(tf, LineBuffer, strlen(LineBuffer));
		} else
			doit = false;
	}
}




/******************************************************************************/
/* Dumps a chunk of text to an arbitrary box; flows it within that box and    */
/* optionally centers it. Returns the number of characters that were          */
/* processed.                                                                 */
/*                                                                            */
/* Note: Every individual word MUST be int16 enough to fit on a line, and     */
/* each line less than 255 characters.                                        */
/******************************************************************************/
uint32 flowText(void *font,      /* the TextAttr pointer */
                uint16 spacing,          /* How much vertical spacing between the lines */
                uint16 pencolor,         /* pen number to use for text */
                uint16 backpen,          /* the background color */
                bool fillback,                /* Whether to fill the background */
                bool centerh,                 /* Whether to center the text horizontally */
                bool centerv,                 /* Whether to center the text vertically */
                bool output,                  /* Whether to output any text */
                uint16 x1,               /* Cords */
                uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
	TextFont *msgfont = (TextFont *)font;
	char linebuffer[256];
	const char *temp;
	uint16 numlines, actlines, fontheight, width;
	uint16 x, y;

	if (fillback) {
		setAPen(backpen);
		rectFill(x1, y1, x2, y2);
	}

	if (str == NULL)
		return 0L;

	setAPen(pencolor);

	fontheight = textHeight(msgfont) + spacing;
	numlines   = (y2 - y1 + 1) / fontheight;
	width      = x2 - x1 + 1;
	y          = y1;

	if (centerv && output) {
		temp = str;
		actlines = 0;

		while (temp[0]) {
			getLine(msgfont, linebuffer, &temp, width);
			actlines++;
		}

		if (actlines <= numlines)
			y += ((y2 - y1 + 1) - (actlines * fontheight)) / 2;
	}

	temp = str;

	while (numlines && str[0]) {
		getLine(msgfont, linebuffer, &str, width);

		x = x1;

		if (centerh)
			x += (width - textLength(msgfont, linebuffer, strlen(linebuffer))) / 2;

		if (output)
			text(msgfont, x, y, pencolor, linebuffer, strlen(linebuffer));

		numlines--;
		y += fontheight;
	}

	return (str - temp);
}


extern uint32 VGABytesPerPage;
extern byte *VGABASEADDRESS;


/******************************************************************************/
/* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
/******************************************************************************/
uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                     uint16 spacing,          /* How much vertical spacing between the lines */
                     uint16 pencolor,         /* pen number to use for text */
                     uint16 backpen,          /* the background color */
                     bool fillback,                /* Whether to fill the background */
                     bool centerh,                 /* Whether to center the text horizontally */
                     bool centerv,                 /* Whether to center the text vertically */
                     bool output,                  /* Whether to output any text */
                     uint16 x1,               /* Cords */
                     uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
	uint32 res, vgabyte = VGABytesPerPage;
	byte *tmp = VGABASEADDRESS;

	VGABASEADDRESS = DestIm->ImageData;
	VGABytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;

	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);

	VGABytesPerPage = vgabyte;
	VGABASEADDRESS = tmp;

	return res;
}




/*----- The control panel stuff -----*/



void createBox(uint16 y2) {
	setAPen(7);                 /* Message box area */
	rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));

	setAPen(0);                 /* Box around message area */
	drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
	drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
	drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
	drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
}




int32 longcharsdrawn = 0L;
bool LastMessageLong = false;

void longDrawMessage(const char *str) {
	char NewText[512];

	if (str == NULL)
		return;

	attachGadgetList(NULL);
	mouseHide();
	strcpy(NewText, str);

	if (!LongWinInFront) {
		LongWinInFront = true;
		setAPen(3);                 /* Clear Area */
		rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
	}

	createBox(198);
	longcharsdrawn = flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
	mouseShow();
}




/******************************************************************************/
/* Draws a message to the message box.                                        */
/******************************************************************************/
void drawMessage(const char *str) {
	if (DoNotDrawMessage) {
		DoNotDrawMessage = false;
		return;
	}

	if (str) {
		if ((textLength(MsgFont, str, strlen(str)) > VGAScaleX(306))) {
			longDrawMessage(str);
			LastMessageLong = true;
		} else {
			if (LongWinInFront) {
				LongWinInFront = false;
				drawPanel();
			}

			mouseHide();
			createBox(168);
			text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
			mouseShow();
			LastMessageLong = false;
		}
	}
}


/*---------------------------------------------------------------------------*/
/*--------------------------- All the wipe stuff. ---------------------------*/
/*---------------------------------------------------------------------------*/



#define TRANSWIPE      1
#define SCROLLWIPE     2
#define SCROLLBLACK    3
#define SCROLLBOUNCE   4
#define TRANSPORTER    5
#define READFIRSTFRAME 6
#define READNEXTFRAME  7




/*****************************************************************************/
/* Copies memory from one location to another 64 bytes at a time.            */
/*****************************************************************************/
void copyLong64(uint32 *Dest, uint32 *Source, uint32 Many64) {
	while (Many64) {
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;
		*Dest = *Source;
		Dest++;
		Source++;

		Many64--;
	}
}




/*****************************************************************************/
/* Scrolls the display to black.                                             */
/*****************************************************************************/
static void doScrollBlack(void) {
	byte *mem, *tempmem;
	Image Im;
	uint16 width, height, by, nheight, CurPage;
	uint32 size, copysize;
	uint32 *BaseAddr;

	mouseHide();
	width = VGAScaleX(320);
	height = VGAScaleY(149) + SVGACord(2);

	allocFile((void **) &mem, (int32) width * (int32) height, "Temp Mem");

	Im.Width = width;
	Im.Height = height;
	Im.ImageData = mem;
	g_music->fillUpMusic(true);
	readScreenImage(&Im, 0, 0);
	g_music->fillUpMusic(true);

	BaseAddr = (uint32 *) getVGABaseAddr();

	by      = VGAScaleX(4);
	nheight = height;

	while (nheight) {
		g_music->newCheckMusic();

		if (!IsHiRes)
			waitTOF();

		BaseAddr = (uint32 *) getVGABaseAddr();

		if (by > nheight)
			by = nheight;

		mem += by * width;
		nheight -= by;
		size = (int32) nheight * (int32) width;
		CurPage = 0;
		tempmem = mem;

		while (size) {
			if (size > VGABytesPerPage)
				copysize = VGABytesPerPage;
			else
				copysize = size;

			size -= copysize;

			setPage(CurPage);
			copyLong64(BaseAddr, (uint32 *) tempmem, copysize >> 6);
			tempmem += copysize;
			CurPage++;
		}

		setAPen(0);
		rectFill(0, nheight, width - 1, nheight + by - 1);

		WSDL_UpdateScreen();

		if (!IsHiRes) {
			if (nheight <= (height / 8))
				by = 1;
			else if (nheight <= (height / 4))
				by = 2;
			else if (nheight <= (height / 2))
				by = 3;
		}
	}

	freeAllStolenMem();
	mouseShow();
	ungetVGABaseAddr();
}




extern BitMap RawDiffBM;
extern DIFFHeader headerdata;




static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
	uint32 size, OffSet, copysize;
	uint16 CurPage;
	uint32 *BaseAddr;

	BaseAddr = (uint32 *)getVGABaseAddr();

	size = (int32)(height - nheight) * (int32) width;
	mem += startline * width;
	CurPage = ((int32) nheight * (int32) width) / VGABytesPerPage;
	OffSet = ((int32) nheight * (int32) width) - (CurPage * VGABytesPerPage);

	while (size) {
		if (size > (VGABytesPerPage - OffSet))
			copysize = VGABytesPerPage - OffSet;
		else
			copysize = size;

		size -= copysize;

		setPage(CurPage);
		copyLong64(BaseAddr + (OffSet >> 2), (uint32 *) mem, copysize >> 6);
		mem += copysize;
		CurPage++;
		OffSet = 0;
	}

	ungetVGABaseAddr();
}


/*****************************************************************************/
/* Scrolls the display to a new picture from a black screen.                 */
/*****************************************************************************/
static void doScrollWipe(char *filename) {
	byte *mem;
	uint16 width, height, by, nheight, startline = 0, onrow = 0;

	mouseHide();
	width = VGAScaleX(320);
	height = VGAScaleY(149) + SVGACord(2);

	while (EffectPlaying) {
		g_music->newCheckMusic();
		waitTOF();
	}

	IsBM = true;
	readPict(filename, true);
	VGASetPal(diffcmap, 256);
	IsBM = false;
	mem = RawDiffBM.Planes[0];

	g_music->fillUpMusic(true);
	by      = VGAScaleX(3);
	nheight = height;

	while (onrow < headerdata.y) {
		g_music->newCheckMusic();

		if ((by > nheight) && nheight)
			by = nheight;

		if ((startline + by) > (headerdata.y - height - 1))
			break;

		if (nheight)
			nheight -= by;

		copyPage(width, height, nheight, startline, mem);

		WSDL_UpdateScreen();

		if (!nheight)
			startline += by;

		onrow += by;

		if (nheight <= (height / 4))
			by = VGAScaleX(5);
		else if (nheight <= (height / 3))
			by = VGAScaleX(4);
		else if (nheight <= (height / 2))
			by = VGAScaleX(3);
	}

	mouseShow();
}




/*****************************************************************************/
/* Does the scroll bounce.  Assumes bitmap already in memory.                */
/*****************************************************************************/
static void doScrollBounce(void) {
	byte *mem;
	uint16 width, height, startline, counter,
#if defined(DOSCODE)
	       newby[5] = {5, 4, 3, 2, 1}, newby1[8] = {3, 3, 2, 2, 2, 1, 1, 1};
#else
	       newby[5] = {10, 8, 6, 4, 2}, newby1[8] = {6, 6, 4, 4, 4, 2, 2, 2};
#endif

	mouseHide();
	width = VGAScaleX(320);
	height = VGAScaleY(149) + SVGACord(2);
	mem = RawDiffBM.Planes[0];

	g_music->fillUpMusic(true);
	startline = headerdata.y - height - 1;

	for (counter = 0; counter < 5; counter++) {
		g_music->newCheckMusic();
		startline -= newby[counter];
		copyPage(width, height, 0, startline, mem);

		WSDL_UpdateScreen();
		waitTOF();
	}

	for (counter = 8; counter > 0; counter--) {
		g_music->newCheckMusic();
		startline += newby1[counter - 1];
		copyPage(width, height, 0, startline, mem);

		WSDL_UpdateScreen();
		waitTOF();

	}

	mouseShow();
}



/*****************************************************************************/
/* Does the transporter wipe.                                                */
/*****************************************************************************/
static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
	uint16 LastY, CurY, counter, linesdone = 0, lineslast;
	Image ImSource, ImDest;

	if (IsHiRes) {
		lineslast = 3;
		LastY = 358;
	} else {
		lineslast = 1;
		LastY = 148;
	}

	for (counter = 0; counter < 2; counter++) {
		CurY = counter * 2;

		while (CurY < LastY) {
			if (linesdone >= lineslast) {
				g_music->updateMusic();
				waitTOF();
				linesdone = 0;
			}

			ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
			CurY += 4;
			linesdone++;
		}
	}

	setAPen(0);

	for (counter = 0; counter < 2; counter++) {
		CurY = counter * 2;

		while (CurY <= LastY) {
			if (linesdone >= lineslast) {
				g_music->updateMusic();
				waitTOF();
				linesdone = 0;
			}

			rectFill(0, CurY, VGAScreenWidth - 1, CurY + 1);
			CurY += 4;
			linesdone++;
		}
	}

	if (filename == NULL)
		CurFileName = getPictName(CPtr);
	else if (filename[0] > ' ')
		CurFileName = filename;
	else
		CurFileName = getPictName(CPtr);

	byte *BitMapMem = readPictToMem(CurFileName, VGAScreenWidth, LastY + 5);
	VGASetPal(diffcmap, 256);

	if (BitMapMem) {
		ImSource.Width = VGAScreenWidth;
		ImSource.Height = LastY;
		ImSource.ImageData = BitMapMem;

		ImDest.Width = VGAScreenWidth;
		ImDest.Height = VGAScreenHeight;
		ImDest.ImageData = getVGABaseAddr();

		for (counter = 0; counter < 2; counter++) {
			CurY = counter * 2;

			while (CurY < LastY) {
				if (linesdone >= lineslast) {
					g_music->updateMusic();
					waitTOF();
					linesdone = 0;
				}

				ImDest.ImageData = getVGABaseAddr();

				bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);
				ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
				CurY += 4;
				linesdone++;
			}
		}

		for (counter = 0; counter < 2; counter++) {
			CurY = counter * 2;

			while (CurY <= LastY) {
				if (linesdone >= lineslast) {
					g_music->updateMusic();
					waitTOF();
					linesdone = 0;
				}

				ImDest.ImageData = getVGABaseAddr();

				if (CurY == LastY)
					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 1);
				else
					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);

				CurY += 4;
				linesdone++;
			}
		}
	}

	ungetVGABaseAddr();
}



/*****************************************************************************/
/* Does a certain number of pre-programmed wipes.                            */
/*****************************************************************************/
void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
	if ((WipeType == TRANSWIPE) || (WipeType == TRANSPORTER))
		doTransWipe(CPtr, filename);
	else if (WipeType == SCROLLWIPE)
		doScrollWipe(filename);
	else if (WipeType == SCROLLBLACK)
		doScrollBlack();
	else if (WipeType == SCROLLBOUNCE)
		doScrollBounce();
	else if (WipeType == READFIRSTFRAME)
		readPict(filename, false);
	else if (WipeType == READNEXTFRAME)
		diffNextFrame();
}

} // End of namespace Lab