aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/vgafades.cpp
blob: 83725d63d1beab83060dafd4dfccb43dd0aa4f2b (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
/* 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.
 *
 */

#include "dreamweb/dreamweb.h"

namespace DreamGen {

uint8 *DreamGenContext::mainPalette() {
	return getSegment(data.word(kBuffers)).ptr(kMaingamepal, 256*3);
}

uint8 *DreamGenContext::startPalette() {
	return getSegment(data.word(kBuffers)).ptr(kStartpal, 256*3);
}

uint8 *DreamGenContext::endPalette() {
	return getSegment(data.word(kBuffers)).ptr(kEndpal, 256*3);
}

void DreamGenContext::clearStartPal() {
	memset(startPalette(), 0, 256*3);
}

void DreamGenContext::clearEndPal() {
	memset(endPalette(), 0, 256*3);
}

void DreamGenContext::palToStartPal() {
	memcpy(startPalette(), mainPalette(), 256*3);
}

void DreamGenContext::endPalToStart() {
	memcpy(startPalette(), endPalette(), 256*3);
}

void DreamGenContext::startPalToEnd() {
	memcpy(endPalette(), startPalette(), 256*3);
}

void DreamGenContext::palToEndPal() {
	memcpy(endPalette(), mainPalette(), 256*3);
}

void DreamGenContext::fadeCalculation() {
	if (data.byte(kFadecount) == 0) {
		data.byte(kFadedirection) = 0;
		return;
	}

	uint8 *startPal = startPalette();
	const uint8 *endPal = endPalette();
	for (size_t i = 0; i < 256 * 3; ++i, ++si, ++di) {
		uint8 s = startPal[i];
		uint8 e = endPal[i];
		if (s == e)
			continue;
		else if (s > e)
			--startPal[i];
		else {
			if (data.byte(kFadecount) <= e)
				++startPal[i];
		}
	}
	--data.byte(kFadecount);
}

void DreamGenContext::fadeupYellows() {
	palToEndPal();
	memset(endPalette() + 231*3, 0, 8*3);
	memset(endPalette() + 246*3, 0, 1*3);
	data.byte(kFadedirection) = 1;
	data.byte(kFadecount) = 63;
	data.byte(kColourpos) = 0;
	data.byte(kNumtofade) = 128;
	hangOn(128);
}

void DreamGenContext::fadeupMonFirst() {
	palToStartPal();
	palToEndPal();
	memset(startPalette() + 231*3, 0, 8*3);
	memset(startPalette() + 246*3, 0, 1*3);
	data.byte(kFadedirection) = 1;
	data.byte(kFadecount) = 63;
	data.byte(kColourpos) = 0;
	data.byte(kNumtofade) = 128;
	hangOn(64);
	playChannel1(26);
	hangOn(64);
}

} /*namespace dreamgen */