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 
22 #include "tinsel/actors.h"
23 #include "tinsel/dw.h"
24 #include "tinsel/font.h"
25 #include "tinsel/handle.h"
26 #include "tinsel/object.h"
27 #include "tinsel/sysvar.h"
28 #include "tinsel/text.h"
29 #include "tinsel/tinsel.h"
30 
31 namespace Tinsel {
32 
33 //----------------- LOCAL GLOBAL DATA --------------------
34 
35 // FIXME: Avoid non-const global vars
36 
37 static char g_tBuffer[TBUFSZ];
38 
39 static SCNHANDLE g_hTagFont = 0, g_hTalkFont = 0;
40 static SCNHANDLE g_hRegularTalkFont = 0, g_hRegularTagFont = 0;
41 
42 
43 /**
44  * Return address of tBuffer
45  */
TextBufferAddr()46 char *TextBufferAddr() {
47 	return g_tBuffer;
48 }
49 
50 /**
51  * Return hTagFont handle.
52  */
GetTagFontHandle()53 SCNHANDLE GetTagFontHandle() {
54 	return g_hTagFont;
55 }
56 
57 /**
58  * Return hTalkFont handle.
59  */
GetTalkFontHandle()60 SCNHANDLE GetTalkFontHandle() {
61 	return g_hTalkFont;
62 }
63 
64 /**
65  * Called from dec_tagfont() Glitter function. Store the tag font handle.
66  */
SetTagFontHandle(SCNHANDLE hFont)67 void SetTagFontHandle(SCNHANDLE hFont) {
68 	g_hTagFont = g_hRegularTagFont = hFont;		// Store the font handle
69 }
70 
71 /**
72  * Called from dec_talkfont() Glitter function.
73  * Store the talk font handle.
74  */
SetTalkFontHandle(SCNHANDLE hFont)75 void SetTalkFontHandle(SCNHANDLE hFont) {
76 	g_hTalkFont = g_hRegularTalkFont = hFont;		// Store the font handle
77 }
78 
SetTempTagFontHandle(SCNHANDLE hFont)79 void SetTempTagFontHandle(SCNHANDLE hFont) {
80 	g_hTagFont = hFont;
81 }
82 
SetTempTalkFontHandle(SCNHANDLE hFont)83 void SetTempTalkFontHandle(SCNHANDLE hFont) {
84 	g_hTalkFont = hFont;
85 }
86 
ResetFontHandles()87 void ResetFontHandles() {
88 	g_hTagFont = g_hRegularTagFont;
89 	g_hTalkFont = g_hRegularTalkFont;
90 }
91 
92 
93 /**
94  * Poke the background palette into character 0's images.
95  */
FettleFontPal(SCNHANDLE fontPal)96 void FettleFontPal(SCNHANDLE fontPal) {
97 	const FONT *pFont;
98 	IMAGE *pImg;
99 
100 	assert(fontPal);
101 	assert(g_hTagFont); // Tag font not declared
102 	assert(g_hTalkFont); // Talk font not declared
103 
104 	pFont = (const FONT *)LockMem(g_hTagFont);
105 	pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg));	// get image for char 0
106 	if (!TinselV2)
107 		pImg->hImgPal = TO_32(fontPal);
108 	else
109 		pImg->hImgPal = 0;
110 
111 	pFont = (const FONT *)LockMem(g_hTalkFont);
112 	pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg));	// get image for char 0
113 	if (!TinselV2)
114 		pImg->hImgPal = TO_32(fontPal);
115 	else
116 		pImg->hImgPal = 0;
117 
118 	if (TinselV2 && SysVar(SV_TAGCOLOR)) {
119 		const COLORREF c = GetActorRGB(-1);
120 		SetTagColorRef(c);
121 		UpdateDACqueue(SysVar(SV_TAGCOLOR), c);
122 	}
123 }
124 
125 } // End of namespace Tinsel
126