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 
23 #include "common/config-manager.h"
24 #include "agi/agi.h"
25 #include "agi/font.h"
26 #include "agi/text.h"
27 
28 namespace Agi {
29 
GfxFont(AgiBase * vm)30 GfxFont::GfxFont(AgiBase *vm) {
31 	_vm = vm;
32 
33 	_fontData = nullptr;
34 	_fontDataAllocated = nullptr;
35 	_fontIsHires = false;
36 }
37 
~GfxFont()38 GfxFont::~GfxFont() {
39 	free(_fontDataAllocated);
40 }
41 
42 // Arrow to the right character, used for original saved game dialogs
43 // Needs to get patched into at least the Apple IIgs font, because the font didn't support
44 // that character and original AGI on Apple IIgs used Apple II menus for saving/restoring.
45 static const uint8 fontData_ArrowRightCharacter[8] = {
46 	0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00,
47 };
48 
49 // topaz data, same as in engines/parallaction/staticres.cpp
50 // seems to have been recreated and is not the original amiga font
51 static const uint8 fontData_AmigaPseudoTopaz[2600] = {
52 	0x00, 0x00, 0x03, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
53 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x79, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0x02, 0x79,
54 	0x70, 0xff, 0x4e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
55 	0x00, 0x1a, 0x0f, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x45, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 	0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x09, 0x74, 0x00, 0x08,
59 	0x00, 0x40, 0x00, 0x08, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x20, 0xff, 0x00, 0x00, 0x00, 0x6e,
60 	0x00, 0xbe, 0x00, 0x00, 0x06, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
61 	0x6c, 0x6c, 0x18, 0x00, 0x38, 0x18, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3c, 0x18,
62 	0x3c, 0x3c, 0x1c, 0x7e, 0x1c, 0x7e, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x3c,
63 	0x7c, 0x1e, 0x78, 0x7e, 0x7e, 0x3c, 0x66, 0x3c, 0x06, 0xc6, 0x60, 0xc6, 0xc6, 0x3c, 0x7c, 0x78,
64 	0x7c, 0x3c, 0x7e, 0x66, 0x66, 0xc6, 0xc3, 0xc3, 0xfe, 0x3c, 0xc0, 0x3c, 0x10, 0x00, 0x18, 0x00,
65 	0x60, 0x00, 0x06, 0x00, 0x1c, 0x00, 0x60, 0x18, 0x0c, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
66 	0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x18, 0x70, 0x72, 0x0f, 0x00, 0x18,
67 	0x00, 0x1c, 0x42, 0xc3, 0x18, 0x3c, 0x66, 0x7e, 0x1c, 0x00, 0x3e, 0x7e, 0x7e, 0x3c, 0x18, 0x78,
68 	0x78, 0x18, 0x00, 0x3e, 0x00, 0x00, 0x30, 0x38, 0x00, 0x40, 0x40, 0xc0, 0x18, 0x3c, 0x3c, 0x7e,
69 	0x06, 0x66, 0x18, 0x7e, 0x7e, 0x36, 0x0c, 0x0c, 0x18, 0x3c, 0xc6, 0x3c, 0x60, 0x76, 0x18, 0x00,
70 	0x0c, 0x7e, 0x71, 0x66, 0x00, 0x66, 0x60, 0x0e, 0x7e, 0x66, 0x18, 0x6e, 0x3c, 0x00, 0x18, 0x7e,
71 	0x06, 0x66, 0x18, 0x00, 0x7e, 0x34, 0x0c, 0x0c, 0x18, 0x0c, 0x60, 0x00, 0x18, 0x3c, 0x0c, 0x00,
72 	0x0c, 0x00, 0x71, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x7e, 0x00, 0x18, 0x3c, 0x00, 0x18, 0x6c, 0x6c,
73 	0x3e, 0x66, 0x6c, 0x18, 0x18, 0x18, 0x66, 0x18, 0x00, 0x00, 0x00, 0x06, 0x66, 0x38, 0x66, 0x66,
74 	0x3c, 0x60, 0x30, 0x06, 0x66, 0x66, 0x18, 0x18, 0x06, 0x00, 0x60, 0x66, 0xc6, 0x66, 0x66, 0x30,
75 	0x6c, 0x60, 0x60, 0x66, 0x66, 0x18, 0x06, 0xcc, 0x60, 0xee, 0xe6, 0x66, 0x66, 0xcc, 0x66, 0x66,
76 	0x18, 0x66, 0x66, 0xc6, 0x66, 0x66, 0x0c, 0x30, 0x60, 0x0c, 0x38, 0x00, 0x18, 0x00, 0x60, 0x00,
77 	0x06, 0x00, 0x30, 0x00, 0x60, 0x00, 0x00, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 	0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x9c, 0x3c, 0x7e, 0x00, 0x0c, 0x36,
79 	0x3c, 0x66, 0x18, 0x60, 0x66, 0x81, 0x24, 0x33, 0x06, 0x81, 0x00, 0x66, 0x18, 0x0c, 0x0c, 0x30,
80 	0x00, 0x7a, 0x00, 0x00, 0x70, 0x44, 0xcc, 0xc6, 0xc6, 0x23, 0x00, 0x66, 0x18, 0x00, 0x1c, 0x00,
81 	0x24, 0x60, 0x00, 0x1c, 0x18, 0x18, 0x00, 0x66, 0xcc, 0x00, 0x60, 0x3c, 0x30, 0xc6, 0x18, 0x00,
82 	0x8e, 0x00, 0xc6, 0x66, 0x60, 0x38, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x0c, 0x00,
83 	0x24, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x7e,
84 	0x8e, 0x66, 0x18, 0x00, 0x18, 0x18, 0x00, 0x66, 0x00, 0x18, 0x00, 0x18, 0x00, 0xfe, 0x60, 0xac,
85 	0x68, 0x30, 0x30, 0x0c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x6e, 0x78, 0x06, 0x06, 0x6c, 0x7c,
86 	0x60, 0x06, 0x66, 0x66, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x06, 0xde, 0x66, 0x66, 0x60, 0x66, 0x60,
87 	0x60, 0x60, 0x66, 0x18, 0x06, 0xd8, 0x60, 0xfe, 0xf6, 0x66, 0x66, 0xcc, 0x66, 0x70, 0x18, 0x66,
88 	0x66, 0xc6, 0x3c, 0x3c, 0x18, 0x30, 0x30, 0x0c, 0x6c, 0x00, 0x0c, 0x3c, 0x7c, 0x3c, 0x3e, 0x3c,
89 	0x7c, 0x3e, 0x7c, 0x18, 0x0c, 0x66, 0x18, 0xec, 0x7c, 0x3c, 0x7c, 0x3e, 0x7c, 0x3c, 0x7c, 0x66,
90 	0x66, 0xc6, 0xc6, 0x66, 0x7e, 0x18, 0x18, 0x18, 0x00, 0xf0, 0x66, 0x18, 0x3e, 0x30, 0x66, 0x3c,
91 	0x18, 0x3c, 0x00, 0x9d, 0x44, 0x66, 0x00, 0xb9, 0x00, 0x3c, 0x7e, 0x18, 0x18, 0x60, 0x66, 0x7a,
92 	0x18, 0x00, 0x30, 0x44, 0x66, 0x4c, 0x4c, 0x66, 0x18, 0x66, 0x18, 0x3c, 0x3c, 0x3c, 0x3c, 0x60,
93 	0x7e, 0x3c, 0x7e, 0x7e, 0x7e, 0x60, 0xd8, 0x3c, 0x60, 0x66, 0xc6, 0xe6, 0x3c, 0x3c, 0x3c, 0x3c,
94 	0x6c, 0x66, 0x6c, 0x66, 0x66, 0x66, 0x7e, 0x7e, 0x66, 0x3c, 0x18, 0x3c, 0x18, 0x3c, 0x3c, 0x3c,
95 	0x3c, 0x18, 0x3c, 0x7e, 0x3c, 0x3e, 0x6c, 0x00, 0x18, 0x3c, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00,
96 	0x00, 0x66, 0x1e, 0x3c, 0x66, 0x00, 0x7e, 0x7e, 0x00, 0x18, 0x00, 0x6c, 0x3c, 0xd8, 0x76, 0x00,
97 	0x30, 0x0c, 0xff, 0x7e, 0x00, 0x7e, 0x00, 0x18, 0x7e, 0x18, 0x0c, 0x1c, 0xcc, 0x06, 0x7c, 0x0c,
98 	0x3c, 0x3e, 0x00, 0x00, 0x60, 0x00, 0x06, 0x0c, 0xd6, 0x7e, 0x7c, 0x60, 0x66, 0x78, 0x78, 0x6e,
99 	0x7e, 0x18, 0x06, 0xf0, 0x60, 0xd6, 0xde, 0x66, 0x7c, 0xcc, 0x7c, 0x3c, 0x18, 0x66, 0x66, 0xd6,
100 	0x18, 0x18, 0x30, 0x30, 0x18, 0x0c, 0xc6, 0x00, 0x00, 0x06, 0x66, 0x60, 0x66, 0x66, 0x30, 0x66,
101 	0x66, 0x18, 0x0c, 0x6c, 0x18, 0xfe, 0x66, 0x66, 0x66, 0x66, 0x66, 0x60, 0x30, 0x66, 0x66, 0xc6,
102 	0x6c, 0x66, 0x0c, 0x70, 0x18, 0x0e, 0x00, 0xc3, 0x66, 0x18, 0x6c, 0x78, 0x3c, 0x18, 0x00, 0x66,
103 	0x00, 0xb1, 0x3c, 0xcc, 0x00, 0xa5, 0x00, 0x00, 0x18, 0x30, 0x0c, 0x00, 0x66, 0x3a, 0x18, 0x00,
104 	0x30, 0x38, 0x33, 0x58, 0x58, 0x2c, 0x30, 0x7e, 0x18, 0x66, 0x66, 0x66, 0x66, 0x78, 0x60, 0x66,
105 	0x60, 0x4c, 0x60, 0x6e, 0xf0, 0x18, 0x60, 0x30, 0xe6, 0xf6, 0x66, 0x66, 0x66, 0x66, 0x38, 0x66,
106 	0x70, 0x30, 0x66, 0x66, 0x4c, 0x4c, 0x6c, 0x06, 0x18, 0x06, 0x3c, 0x06, 0x06, 0x66, 0x66, 0x3c,
107 	0x66, 0x0c, 0x66, 0x66, 0x78, 0x18, 0x18, 0x60, 0x7c, 0x66, 0x3c, 0x3c, 0x3c, 0x3c, 0x7e, 0x66,
108 	0x78, 0x60, 0x66, 0x66, 0x0c, 0x0c, 0x00, 0x18, 0x00, 0xfe, 0x06, 0x36, 0xdc, 0x00, 0x30, 0x0c,
109 	0x3c, 0x18, 0x00, 0x00, 0x00, 0x30, 0x76, 0x18, 0x18, 0x06, 0xfe, 0x06, 0x66, 0x18, 0x66, 0x06,
110 	0x00, 0x00, 0x18, 0x7e, 0x18, 0x18, 0xde, 0x66, 0x66, 0x60, 0x66, 0x60, 0x60, 0x66, 0x66, 0x18,
111 	0x06, 0xd8, 0x60, 0xc6, 0xce, 0x66, 0x60, 0xcc, 0x6c, 0x0e, 0x18, 0x66, 0x3c, 0xfe, 0x3c, 0x18,
112 	0x60, 0x30, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x3e, 0x66, 0x60, 0x66, 0x7e, 0x30, 0x66, 0x66, 0x18,
113 	0x0c, 0x78, 0x18, 0xd6, 0x66, 0x66, 0x66, 0x66, 0x60, 0x3c, 0x30, 0x66, 0x66, 0xd6, 0x38, 0x66,
114 	0x18, 0x18, 0x18, 0x18, 0x00, 0x0f, 0x66, 0x18, 0x3e, 0x30, 0x42, 0x3c, 0x18, 0x3c, 0x00, 0x9d,
115 	0x00, 0x66, 0x00, 0xb9, 0x00, 0x00, 0x18, 0x7c, 0x78, 0x00, 0x66, 0x0a, 0x00, 0x00, 0x30, 0x00,
116 	0x66, 0x32, 0x3e, 0xd9, 0x60, 0x66, 0x18, 0x7e, 0x40, 0x7e, 0x7e, 0x60, 0x78, 0x40, 0x78, 0x18,
117 	0x78, 0x66, 0xd8, 0x18, 0x60, 0x0c, 0xf6, 0xde, 0x66, 0x66, 0x66, 0x66, 0x6c, 0x66, 0xe0, 0x0c,
118 	0x66, 0x66, 0x18, 0x18, 0x66, 0x3e, 0x18, 0x3e, 0x60, 0x3e, 0x3e, 0x7e, 0x7e, 0x60, 0x7e, 0x18,
119 	0x7e, 0x66, 0x6c, 0x18, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x18, 0x3c,
120 	0x66, 0x66, 0x18, 0x18, 0x00, 0x00, 0x00, 0x6c, 0x7c, 0x6a, 0xce, 0x00, 0x18, 0x18, 0x66, 0x18,
121 	0x18, 0x00, 0x18, 0x60, 0x66, 0x18, 0x30, 0x66, 0x0c, 0x66, 0x66, 0x18, 0x66, 0x0c, 0x18, 0x18,
122 	0x06, 0x00, 0x60, 0x00, 0xc0, 0x66, 0x66, 0x30, 0x6c, 0x60, 0x60, 0x66, 0x66, 0x18, 0x66, 0xcc,
123 	0x60, 0xc6, 0xc6, 0x66, 0x60, 0xdc, 0x66, 0x66, 0x18, 0x66, 0x3c, 0xee, 0x66, 0x18, 0xc0, 0x30,
124 	0x06, 0x0c, 0x00, 0x00, 0x00, 0x66, 0x66, 0x60, 0x66, 0x60, 0x30, 0x3e, 0x66, 0x18, 0x0c, 0x6c,
125 	0x18, 0xc6, 0x66, 0x66, 0x7c, 0x3e, 0x60, 0x06, 0x30, 0x66, 0x3c, 0xfe, 0x6c, 0x3c, 0x30, 0x18,
126 	0x18, 0x18, 0x00, 0x3c, 0x66, 0x18, 0x0c, 0x30, 0x00, 0x18, 0x18, 0x06, 0x00, 0x81, 0x7e, 0x33,
127 	0x00, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x0a, 0x00, 0x00, 0x00, 0x7c, 0xcc, 0x66,
128 	0x62, 0x33, 0x66, 0x66, 0x18, 0x66, 0x66, 0x66, 0x66, 0x60, 0x60, 0x66, 0x60, 0x32, 0x60, 0x3e,
129 	0xcc, 0x18, 0x7e, 0x66, 0xde, 0xce, 0x66, 0x66, 0x66, 0x66, 0xc6, 0x66, 0x60, 0x66, 0x66, 0x66,
130 	0x32, 0x32, 0x66, 0x66, 0x18, 0x66, 0x60, 0x66, 0x66, 0x60, 0x60, 0x60, 0x60, 0x30, 0x60, 0x3e,
131 	0x66, 0x18, 0x18, 0x06, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x18, 0x66, 0x18, 0x06, 0x66, 0x66,
132 	0x30, 0x30, 0x00, 0x18, 0x00, 0x6c, 0x18, 0xcc, 0x7b, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x18, 0x00,
133 	0x18, 0xc0, 0x3c, 0x18, 0x7e, 0x3c, 0x0c, 0x3c, 0x3c, 0x18, 0x3c, 0x38, 0x18, 0x18, 0x00, 0x00,
134 	0x00, 0x18, 0x78, 0x66, 0x7c, 0x1e, 0x78, 0x7e, 0x60, 0x3e, 0x66, 0x3c, 0x3c, 0xc6, 0x7e, 0xc6,
135 	0xc6, 0x3c, 0x60, 0x7e, 0x66, 0x3c, 0x18, 0x3c, 0x18, 0xc6, 0xc3, 0x18, 0xfe, 0x3c, 0x03, 0x3c,
136 	0x00, 0x00, 0x00, 0x3e, 0x7c, 0x3c, 0x3e, 0x3c, 0x30, 0x06, 0x66, 0x0c, 0x0c, 0x66, 0x0c, 0xc6,
137 	0x66, 0x3c, 0x60, 0x06, 0x60, 0x7c, 0x1c, 0x3e, 0x18, 0x6c, 0xc6, 0x18, 0x7e, 0x0e, 0x18, 0x70,
138 	0x00, 0xf0, 0x7e, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x3c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x81,
139 	0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7f, 0x0a, 0x00, 0x18, 0x00, 0x00, 0x00, 0xcf, 0xc4, 0x67,
140 	0x3c, 0x67, 0x3e, 0x66, 0x3c, 0x66, 0x66, 0x7f, 0x7e, 0x3c, 0x7e, 0x7e, 0x7e, 0x18, 0x30, 0x3c,
141 	0x18, 0x3c, 0xce, 0x18, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x3f, 0x7e, 0x3c, 0x3c, 0x3c, 0x7e, 0x7e,
142 	0x6c, 0x3f, 0x1e, 0x3e, 0x3c, 0x3e, 0x3e, 0x3c, 0x3c, 0x3c, 0x3c, 0x7e, 0x3c, 0x06, 0x18, 0x0c,
143 	0x0c, 0x7c, 0x66, 0x18, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x3f, 0x0c, 0x7c, 0x3e, 0x3e, 0x7e, 0x7e,
144 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
145 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
146 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
148 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00,
149 	0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00,
151 	0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x0e, 0x01, 0x00, 0x03,
152 	0x06, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x30, 0x00,
153 	0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03,
154 	0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x00, 0x18, 0x00,
155 	0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 	0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x08, 0x00, 0x18, 0x00, 0x08, 0x00, 0x20,
157 	0x00, 0x08, 0x00, 0x28, 0x00, 0x08, 0x00, 0x30, 0x00, 0x08, 0x00, 0x38, 0x00, 0x08, 0x00, 0x40,
158 	0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x50, 0x00, 0x08, 0x00, 0x58, 0x00, 0x08, 0x00, 0x60,
159 	0x00, 0x08, 0x00, 0x68, 0x00, 0x08, 0x00, 0x70, 0x00, 0x08, 0x00, 0x78, 0x00, 0x08, 0x00, 0x80,
160 	0x00, 0x08, 0x00, 0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0x98, 0x00, 0x08, 0x00, 0xa0,
161 	0x00, 0x08, 0x00, 0xa8, 0x00, 0x08, 0x00, 0xb0, 0x00, 0x08, 0x00, 0xb8, 0x00, 0x08, 0x00, 0xc0,
162 	0x00, 0x08, 0x00, 0xc8, 0x00, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x00, 0xd8, 0x00, 0x08, 0x00, 0xe0,
163 	0x00, 0x08, 0x00, 0xe8, 0x00, 0x08, 0x00, 0xf0, 0x00, 0x08, 0x00, 0xf8, 0x00, 0x08, 0x01, 0x00,
164 	0x00, 0x08, 0x01, 0x08, 0x00, 0x08, 0x01, 0x10, 0x00, 0x08, 0x01, 0x18, 0x00, 0x08, 0x01, 0x20,
165 	0x00, 0x08, 0x01, 0x28, 0x00, 0x08, 0x01, 0x30, 0x00, 0x08, 0x01, 0x38, 0x00, 0x08, 0x01, 0x40,
166 	0x00, 0x08, 0x01, 0x48, 0x00, 0x08, 0x01, 0x50, 0x00, 0x08, 0x01, 0x58, 0x00, 0x08, 0x01, 0x60,
167 	0x00, 0x08, 0x01, 0x68, 0x00, 0x08, 0x01, 0x70, 0x00, 0x08, 0x01, 0x78, 0x00, 0x08, 0x01, 0x80,
168 	0x00, 0x08, 0x01, 0x88, 0x00, 0x08, 0x01, 0x90, 0x00, 0x08, 0x01, 0x98, 0x00, 0x08, 0x01, 0xa0,
169 	0x00, 0x08, 0x01, 0xa8, 0x00, 0x08, 0x01, 0xb0, 0x00, 0x08, 0x01, 0xb8, 0x00, 0x08, 0x01, 0xc0,
170 	0x00, 0x08, 0x01, 0xc8, 0x00, 0x08, 0x01, 0xd0, 0x00, 0x08, 0x01, 0xd8, 0x00, 0x08, 0x01, 0xe0,
171 	0x00, 0x08, 0x01, 0xe8, 0x00, 0x08, 0x01, 0xf0, 0x00, 0x08, 0x01, 0xf8, 0x00, 0x08, 0x02, 0x00,
172 	0x00, 0x08, 0x02, 0x08, 0x00, 0x08, 0x02, 0x10, 0x00, 0x08, 0x02, 0x18, 0x00, 0x08, 0x02, 0x20,
173 	0x00, 0x08, 0x02, 0x28, 0x00, 0x08, 0x02, 0x30, 0x00, 0x08, 0x02, 0x38, 0x00, 0x08, 0x02, 0x40,
174 	0x00, 0x08, 0x02, 0x48, 0x00, 0x08, 0x02, 0x50, 0x00, 0x08, 0x02, 0x58, 0x00, 0x08, 0x02, 0x60,
175 	0x00, 0x08, 0x02, 0x68, 0x00, 0x08, 0x02, 0x70, 0x00, 0x08, 0x02, 0x78, 0x00, 0x08, 0x02, 0x80,
176 	0x00, 0x08, 0x02, 0x88, 0x00, 0x08, 0x02, 0x90, 0x00, 0x08, 0x02, 0x98, 0x00, 0x08, 0x02, 0xa0,
177 	0x00, 0x08, 0x02, 0xa8, 0x00, 0x08, 0x02, 0xb0, 0x00, 0x08, 0x02, 0xb8, 0x00, 0x08, 0x02, 0xc0,
178 	0x00, 0x08, 0x02, 0xc8, 0x00, 0x08, 0x02, 0xd0, 0x00, 0x08, 0x02, 0xd8, 0x00, 0x08, 0x02, 0xe0,
179 	0x00, 0x08, 0x02, 0xe8, 0x00, 0x08, 0x02, 0xf0, 0x00, 0x08, 0x02, 0xf8, 0x00, 0x08, 0x03, 0x00,
180 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
181 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
182 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
183 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
184 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
185 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
186 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00,
187 	0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00,
188 	0x00, 0x08, 0x03, 0x08, 0x00, 0x08, 0x03, 0x10, 0x00, 0x08, 0x03, 0x18, 0x00, 0x08, 0x03, 0x20,
189 	0x00, 0x08, 0x03, 0x28, 0x00, 0x08, 0x03, 0x30, 0x00, 0x08, 0x03, 0x38, 0x00, 0x08, 0x03, 0x40,
190 	0x00, 0x08, 0x03, 0x48, 0x00, 0x08, 0x03, 0x50, 0x00, 0x08, 0x03, 0x58, 0x00, 0x08, 0x03, 0x60,
191 	0x00, 0x08, 0x00, 0x68, 0x00, 0x08, 0x03, 0x68, 0x00, 0x08, 0x03, 0x70, 0x00, 0x08, 0x03, 0x78,
192 	0x00, 0x08, 0x03, 0x80, 0x00, 0x08, 0x03, 0x88, 0x00, 0x08, 0x03, 0x90, 0x00, 0x08, 0x03, 0x98,
193 	0x00, 0x08, 0x03, 0xa0, 0x00, 0x08, 0x03, 0xa8, 0x00, 0x08, 0x03, 0xb0, 0x00, 0x08, 0x03, 0xb8,
194 	0x00, 0x08, 0x03, 0xc0, 0x00, 0x08, 0x03, 0xc8, 0x00, 0x08, 0x03, 0xd0, 0x00, 0x08, 0x03, 0xd8,
195 	0x00, 0x08, 0x03, 0xe0, 0x00, 0x08, 0x03, 0xe8, 0x00, 0x08, 0x03, 0xf0, 0x00, 0x08, 0x03, 0xf8,
196 	0x00, 0x08, 0x04, 0x00, 0x00, 0x08, 0x04, 0x08, 0x00, 0x08, 0x04, 0x10, 0x00, 0x08, 0x04, 0x18,
197 	0x00, 0x08, 0x04, 0x20, 0x00, 0x08, 0x04, 0x28, 0x00, 0x08, 0x04, 0x30, 0x00, 0x08, 0x04, 0x38,
198 	0x00, 0x08, 0x04, 0x40, 0x00, 0x08, 0x04, 0x48, 0x00, 0x08, 0x04, 0x50, 0x00, 0x08, 0x04, 0x58,
199 	0x00, 0x08, 0x04, 0x60, 0x00, 0x08, 0x04, 0x68, 0x00, 0x08, 0x04, 0x70, 0x00, 0x08, 0x04, 0x78,
200 	0x00, 0x08, 0x04, 0x80, 0x00, 0x08, 0x04, 0x88, 0x00, 0x08, 0x04, 0x90, 0x00, 0x08, 0x04, 0x98,
201 	0x00, 0x08, 0x04, 0xa0, 0x00, 0x08, 0x04, 0xa8, 0x00, 0x08, 0x04, 0xb0, 0x00, 0x08, 0x04, 0xb8,
202 	0x00, 0x08, 0x04, 0xc0, 0x00, 0x08, 0x04, 0xc8, 0x00, 0x08, 0x04, 0xd0, 0x00, 0x08, 0x04, 0xd8,
203 	0x00, 0x08, 0x04, 0xe0, 0x00, 0x08, 0x04, 0xe8, 0x00, 0x08, 0x04, 0xf0, 0x00, 0x08, 0x04, 0xf8,
204 	0x00, 0x08, 0x05, 0x00, 0x00, 0x08, 0x05, 0x08, 0x00, 0x08, 0x05, 0x10, 0x00, 0x08, 0x05, 0x18,
205 	0x00, 0x08, 0x05, 0x20, 0x00, 0x08, 0x05, 0x28, 0x00, 0x08, 0x05, 0x30, 0x00, 0x08, 0x05, 0x38,
206 	0x00, 0x08, 0x05, 0x40, 0x00, 0x08, 0x05, 0x48, 0x00, 0x08, 0x05, 0x50, 0x00, 0x08, 0x05, 0x58,
207 	0x00, 0x08, 0x05, 0x60, 0x00, 0x08, 0x05, 0x68, 0x00, 0x08, 0x05, 0x70, 0x00, 0x08, 0x05, 0x78,
208 	0x00, 0x08, 0x05, 0x80, 0x00, 0x08, 0x05, 0x88, 0x00, 0x08, 0x05, 0x90, 0x00, 0x08, 0x05, 0x98,
209 	0x00, 0x08, 0x05, 0xa0, 0x00, 0x08, 0x05, 0xa8, 0x00, 0x08, 0x05, 0xb0, 0x00, 0x08, 0x05, 0xb8,
210 	0x00, 0x08, 0x05, 0xc0, 0x00, 0x08, 0x05, 0xc8, 0x00, 0x08, 0x05, 0xd0, 0x00, 0x08, 0x05, 0xd8,
211 	0x00, 0x08, 0x05, 0xe0, 0x00, 0x08, 0x05, 0xe8, 0x00, 0x08, 0x00, 0x38, 0x00, 0x08, 0x03, 0x00,
212 	0x00, 0x08, 0x03, 0x00, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
213 	0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x62,
214 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf2
215 };
216 
217 // 8x8 font patterns
218 
219 // this is basically the standard PC BIOS font, taken from Dos-Box, with a few modifications
220 static const uint8 fontData_PCBIOS[] = {
221 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
222 	0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E,
223 	0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E,
224 	0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00,
225 	0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00,
226 	0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C,
227 	0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C,
228 	0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00,
229 	0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF,
230 	0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
231 	0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF,
232 	0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78,
233 	0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18,
234 	0x08, 0x0C, 0x0A, 0x0A, 0x08, 0x78, 0xF0, 0x00, // 0x0D changed
235 	0x18, 0x14, 0x1A, 0x16, 0x72, 0xE2, 0x0E, 0x1C, // 0x0E changed
236 	0x10, 0x54, 0x38, 0xEE, 0x38, 0x54, 0x10, 0x00, // 0x0F changed
237 	//0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, // 0x0D original
238 	//0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, // 0x0E original
239 	//0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, // 0x0F original
240 	0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00,
241 	0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00,
242 	0x18, 0x3C, 0x5A, 0x18, 0x5A, 0x3C, 0x18, 0x00, // 0x12 changed
243 	//0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, // 0x12 original
244 	0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
245 	0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x00, // 0x14 changed
246 	0x1C, 0x22, 0x38, 0x44, 0x44, 0x38, 0x88, 0x70, // 0x14 changed
247 	//0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, // 0x14 original
248 	//0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0xCC, 0x78, // 0x15 original
249 	0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00,
250 	0x18, 0x3C, 0x5A, 0x18, 0x5A, 0x3C, 0x18, 0x7E, // 0x17 changed
251 	0x18, 0x3C, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x00, // 0x18 changed
252 	0x18, 0x18, 0x18, 0x18, 0x5A, 0x3C, 0x18, 0x00, // 0x19 changed
253 	//0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, // 0x17 original
254 	//0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, // 0x18 original
255 	//0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, // 0x19 original
256 	0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00,
257 	0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00,
258 	0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00,
259 	0x00, 0x24, 0x42, 0xFF, 0x42, 0x24, 0x00, 0x00, // 0x1D changed
260 	0x00, 0x10, 0x38, 0x7C, 0xFE, 0xFE, 0x00, 0x00, // 0x1E changed
261 	0x00, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x00, // 0x1F changed
262 	//0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, // 0x1D original
263 	//0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, // 0x1E original
264 	//0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, // 0x1F original
265 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20
266 	0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00,
267 	0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,
268 	0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00,
269 	0x30, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x30, 0x00,
270 	0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00,
271 	0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00,
272 	0x60, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
273 	0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00,
274 	0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
275 	0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00,
276 	0x00, 0x30, 0x30, 0xFC, 0x30, 0x30, 0x00, 0x00,
277 	0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60,
278 	0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00,
279 	0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00,
280 	0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00,
281 	0x7C, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x7C, 0x00, // 0x30
282 	0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00,
283 	0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00,
284 	0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00,
285 	0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00,
286 	0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00,
287 	0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00,
288 	0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00,
289 	0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00,
290 	0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00,
291 	0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00,
292 	0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60,
293 	0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00,
294 	0x00, 0x00, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x00,
295 	0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00,
296 	0x78, 0xCC, 0x0C, 0x18, 0x30, 0x00, 0x30, 0x00,
297 	0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x78, 0x00, // 0x40
298 	0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00,
299 	0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00,
300 	0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00,
301 	0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00,
302 	0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00,
303 	0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00,
304 	0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00,
305 	0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00,
306 	0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
307 	0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00,
308 	0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00,
309 	0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00,
310 	0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00,
311 	0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00,
312 	0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00,
313 	0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, // 0x50
314 	0x78, 0xCC, 0xCC, 0xCC, 0xDC, 0x78, 0x1C, 0x00,
315 	0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00,
316 	0x78, 0xCC, 0xE0, 0x70, 0x1C, 0xCC, 0x78, 0x00,
317 	0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
318 	0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00,
319 	0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00,
320 	0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00,
321 	0xC6, 0xC6, 0x6C, 0x38, 0x38, 0x6C, 0xC6, 0x00,
322 	0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00,
323 	0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00,
324 	0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00,
325 	0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00,
326 	0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00,
327 	0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00,
328 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
329 	0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60
330 	0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
331 	0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00,
332 	0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00,
333 	0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00,
334 	0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
335 	0x38, 0x6C, 0x60, 0xF0, 0x60, 0x60, 0xF0, 0x00,
336 	0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8,
337 	0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00,
338 	0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
339 	0x0C, 0x00, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78,
340 	0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00,
341 	0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
342 	0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xC6, 0x00,
343 	0x00, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00,
344 	0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00,
345 	0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, // 0x70
346 	0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E,
347 	0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0xF0, 0x00,
348 	0x00, 0x00, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x00,
349 	0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00,
350 	0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00,
351 	0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00,
352 	0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00,
353 	0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00,
354 	0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8,
355 	0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00,
356 	0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00,
357 	0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
358 	0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00,
359 	0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360 	0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00,
361 	0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x18, 0x0C, 0x78, // 0x80
362 	0x00, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00,
363 	0x1C, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
364 	0x7E, 0xC3, 0x3C, 0x06, 0x3E, 0x66, 0x3F, 0x00,
365 	0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00,
366 	0xE0, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00,
367 	0x30, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00,
368 	0x00, 0x00, 0x78, 0xC0, 0xC0, 0x78, 0x0C, 0x38,
369 	0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00,
370 	0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
371 	0xE0, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
372 	0xCC, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
373 	0x7C, 0xC6, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00,
374 	0xE0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
375 	0xC6, 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0xC6, 0x00,
376 	0x30, 0x30, 0x00, 0x78, 0xCC, 0xFC, 0xCC, 0x00,
377 	0x1C, 0x00, 0xFC, 0x60, 0x78, 0x60, 0xFC, 0x00,
378 	0x00, 0x00, 0x7F, 0x0C, 0x7F, 0xCC, 0x7F, 0x00,
379 	0x3E, 0x6C, 0xCC, 0xFE, 0xCC, 0xCC, 0xCE, 0x00,
380 	0x78, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
381 	0x00, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
382 	0x00, 0xE0, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
383 	0x78, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00,
384 	0x00, 0xE0, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00,
385 	0x00, 0xCC, 0x00, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8,
386 	0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00,
387 	0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00,
388 	0x18, 0x18, 0x7E, 0xC0, 0xC0, 0x7E, 0x18, 0x18,
389 	0x38, 0x6C, 0x64, 0xF0, 0x60, 0xE6, 0xFC, 0x00,
390 	0xCC, 0xCC, 0x78, 0xFC, 0x30, 0xFC, 0x30, 0x30,
391 	0xF8, 0xCC, 0xCC, 0xFA, 0xC6, 0xCF, 0xC6, 0xC7,
392 	0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0xD8, 0x70,
393 	0x1C, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x7E, 0x00,
394 	0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
395 	0x00, 0x1C, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
396 	0x00, 0x1C, 0x00, 0xCC, 0xCC, 0xCC, 0x7E, 0x00,
397 	0x00, 0xF8, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0x00,
398 	0xFC, 0x00, 0xCC, 0xEC, 0xFC, 0xDC, 0xCC, 0x00,
399 	0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00,
400 	0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00,
401 	0x30, 0x00, 0x30, 0x60, 0xC0, 0xCC, 0x78, 0x00,
402 	0x00, 0x00, 0x00, 0xFC, 0xC0, 0xC0, 0x00, 0x00,
403 	0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x00, 0x00,
404 	0xC3, 0xC6, 0xCC, 0xDE, 0x33, 0x66, 0xCC, 0x0F,
405 	0xC3, 0xC6, 0xCC, 0xDB, 0x37, 0x6F, 0xCF, 0x03,
406 	0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00,
407 	0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00,
408 	0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00,
409 	0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88,
410 	0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA,
411 	0xDB, 0x77, 0xDB, 0xEE, 0xDB, 0x77, 0xDB, 0xEE,
412 	0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
413 	0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18,
414 	0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18,
415 	0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36,
416 	0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36,
417 	0x00, 0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18,
418 	0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36,
419 	0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
420 	0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36,
421 	0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00,
422 	0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00,
423 	0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00,
424 	0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18,
425 	0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00,
426 	0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00,
427 	0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18,
428 	0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18,
429 	0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
430 	0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18,
431 	0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18,
432 	0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36,
433 	0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00,
434 	0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36,
435 	0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00,
436 	0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36,
437 	0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36,
438 	0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00,
439 	0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36,
440 	0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00,
441 	0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00,
442 	0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18,
443 	0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36,
444 	0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00,
445 	0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00,
446 	0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18,
447 	0x00, 0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36,
448 	0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36,
449 	0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18,
450 	0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00,
451 	0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18,
452 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
453 	0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
454 	0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
455 	0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
456 	0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
457 	0x00, 0x00, 0x76, 0xDC, 0xC8, 0xDC, 0x76, 0x00,
458 	0x00, 0x78, 0xCC, 0xF8, 0xCC, 0xF8, 0xC0, 0xC0,
459 	0x00, 0xFC, 0xCC, 0xC0, 0xC0, 0xC0, 0xC0, 0x00,
460 	0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00,
461 	0xFC, 0xCC, 0x60, 0x30, 0x60, 0xCC, 0xFC, 0x00,
462 	0x00, 0x00, 0x7E, 0xD8, 0xD8, 0xD8, 0x70, 0x00,
463 	0x00, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xC0,
464 	0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x00,
465 	0xFC, 0x30, 0x78, 0xCC, 0xCC, 0x78, 0x30, 0xFC,
466 	0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00,
467 	0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00,
468 	0x1C, 0x30, 0x18, 0x7C, 0xCC, 0xCC, 0x78, 0x00,
469 	0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00,
470 	0x06, 0x0C, 0x7E, 0xDB, 0xDB, 0x7E, 0x60, 0xC0,
471 	0x38, 0x60, 0xC0, 0xF8, 0xC0, 0x60, 0x38, 0x00,
472 	0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00,
473 	0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x00,
474 	0x30, 0x30, 0xFC, 0x30, 0x30, 0x00, 0xFC, 0x00,
475 	0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xFC, 0x00,
476 	0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xFC, 0x00,
477 	0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18,
478 	0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70,
479 	0x30, 0x30, 0x00, 0xFC, 0x00, 0x30, 0x30, 0x00,
480 	0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00,
481 	0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00,
482 	0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
483 	0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
484 	0x0F, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C,
485 	0x78, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00,
486 	0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00,
487 	0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00,
488 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
489 };
490 
491 // Extended set (0x80-0xFF) for Russian versions of games
492 static const uint8 fontData_ExtendedRussian[] = {
493 	0x1E, 0x36, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00, // 0x80
494 	0x7C, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00,
495 	0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00,
496 	0x7E, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00,
497 	0x38, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0xFE, 0xC6,
498 	0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x7E, 0x00,
499 	0xDB, 0xDB, 0x7E, 0x3C, 0x7E, 0xDB, 0xDB, 0x00,
500 	0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00,
501 	0x66, 0x66, 0x6E, 0x7E, 0x76, 0x66, 0x66, 0x00,
502 	0x3C, 0x66, 0x6E, 0x7E, 0x76, 0x66, 0x66, 0x00,
503 	0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00,
504 	0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00,
505 	0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00,
506 	0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00,
507 	0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,
508 	0x7E, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00,
509 	0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x00,
510 	0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00,
511 	0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
512 	0x66, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00,
513 	0x7E, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x18, 0x00,
514 	0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x00,
515 	0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7F, 0x03,
516 	0x66, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x06, 0x00,
517 	0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xFF, 0x00,
518 	0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xFF, 0x03,
519 	0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00,
520 	0xC6, 0xC6, 0xC6, 0xF6, 0xDE, 0xDE, 0xF6, 0x00,
521 	0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00,
522 	0x78, 0x8C, 0x06, 0x3E, 0x06, 0x8C, 0x78, 0x00,
523 	0xCE, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xCE, 0x00,
524 	0x3E, 0x66, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x00,
525 	0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3A, 0x00,
526 	0x00, 0x3C, 0x60, 0x3C, 0x66, 0x66, 0x3C, 0x00,
527 	0x00, 0x00, 0x7C, 0x66, 0x7C, 0x66, 0x7C, 0x00,
528 	0x00, 0x00, 0x7E, 0x60, 0x60, 0x60, 0x60, 0x00,
529 	0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x6C, 0xFE, 0xC6,
530 	0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00,
531 	0x00, 0x00, 0xDB, 0x7E, 0x3C, 0x7E, 0xDB, 0x00,
532 	0x00, 0x00, 0x3C, 0x66, 0x0C, 0x66, 0x3C, 0x00,
533 	0x00, 0x00, 0x66, 0x6E, 0x7E, 0x76, 0x66, 0x00,
534 	0x00, 0x18, 0x66, 0x6E, 0x7E, 0x76, 0x66, 0x00,
535 	0x00, 0x00, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x00,
536 	0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x00,
537 	0x00, 0x00, 0xC6, 0xFE, 0xFE, 0xD6, 0xC6, 0x00,
538 	0x00, 0x00, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00,
539 	0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00,
540 	0x00, 0x00, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00,
541 	0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
542 	0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA,
543 	0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77,
544 	0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
545 	0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18,
546 	0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18,
547 	0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, 0x36,
548 	0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, 0x36,
549 	0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18,
550 	0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36,
551 	0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
552 	0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36,
553 	0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, 0x00,
554 	0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x00,
555 	0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00,
556 	0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, 0x18,
557 	0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00,
558 	0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, 0x00,
559 	0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18,
560 	0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18,
561 	0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
562 	0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18,
563 	0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18,
564 	0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36,
565 	0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, 0x00,
566 	0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36,
567 	0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
568 	0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36,
569 	0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36,
570 	0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
571 	0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36,
572 	0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
573 	0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00, 0x00,
574 	0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18,
575 	0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, 0x36,
576 	0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00, 0x00,
577 	0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00,
578 	0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18,
579 	0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36, 0x36,
580 	0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, 0x36,
581 	0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18,
582 	0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00,
583 	0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, 0x18,
584 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
585 	0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
586 	0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
587 	0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
588 	0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
589 	0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x00,
590 	0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x00,
591 	0x00, 0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00,
592 	0x00, 0x00, 0x66, 0x66, 0x3E, 0x06, 0x7C, 0x00,
593 	0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x18, 0x00,
594 	0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x00,
595 	0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7F, 0x03,
596 	0x00, 0x00, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x00,
597 	0x00, 0x00, 0xDB, 0xDB, 0xDB, 0xDB, 0xFF, 0x00,
598 	0x00, 0x00, 0xDB, 0xDB, 0xDB, 0xDB, 0xFF, 0x03,
599 	0x00, 0x00, 0xE0, 0x60, 0x7C, 0x66, 0x7C, 0x00,
600 	0x00, 0x00, 0xC6, 0xC6, 0xF6, 0xDE, 0xF6, 0x00,
601 	0x00, 0x00, 0x60, 0x60, 0x7C, 0x66, 0x7C, 0x00,
602 	0x00, 0x00, 0x7C, 0x06, 0x3E, 0x06, 0x7C, 0x00,
603 	0x00, 0x00, 0xCE, 0xDB, 0xFB, 0xDB, 0xCE, 0x00,
604 	0x00, 0x00, 0x3E, 0x66, 0x3E, 0x36, 0x66, 0x00,
605 	0x00, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00,
606 	0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x7C, 0x00,
607 	0x00, 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30,
608 	0x00, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C,
609 	0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18,
610 	0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70,
611 	0x00, 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18,
612 	0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00,
613 	0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00,
614 	0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
615 	0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00,
616 	0x03, 0x02, 0x06, 0x04, 0xCC, 0x68, 0x38, 0x10,
617 	0x3C, 0x42, 0x99, 0xA1, 0xA1, 0x99, 0x42, 0x3C,
618 	0x30, 0x48, 0x10, 0x20, 0x78, 0x00, 0x00, 0x00,
619 	0x00, 0x00, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, 0x00,
620 	0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x7E, 0x00
621 };
622 
init()623 void GfxFont::init() {
624 	if (ConfMan.getBool("herculesfont")) {
625 		// User wants, that we use Hercules hires font, try to load it
626 		loadFontHercules();
627 	} else {
628 		switch (_vm->_renderMode) {
629 		case Common::kRenderHercA:
630 		case Common::kRenderHercG:
631 			// Render mode is Hercules, we try to load Hercules hires font
632 			loadFontHercules();
633 			break;
634 		default:
635 			break;
636 		}
637 	}
638 
639 	if (!_fontData) {
640 		switch (_vm->_renderMode) {
641 		case Common::kRenderAmiga:
642 			// Try user-file first, if that fails use our internal inaccurate topaz font
643 			loadFontScummVMFile("agi-font-amiga.bin");
644 			if (!_fontData) {
645 				loadFontAmigaPseudoTopaz();
646 			}
647 			break;
648 		case Common::kRenderApple2GS:
649 			// Special font, stored in file AGIFONT
650 			loadFontAppleIIgs();
651 			break;
652 		case Common::kRenderAtariST:
653 			// TODO: Atari ST uses another font
654 			// Seems to be the standard Atari ST 8x8 system font
655 			loadFontScummVMFile("agi-font-atarist.bin");
656 			if (!_fontData) {
657 				loadFontAtariST("agi-font-atarist-system.fnt");
658 				if (!_fontData) {
659 					// TODO: in case we find a recreation of the font, add it in here
660 				}
661 			}
662 			break;
663 		case Common::kRenderHercA:
664 		case Common::kRenderHercG:
665 		case Common::kRenderCGA:
666 		case Common::kRenderEGA:
667 		case Common::kRenderVGA:
668 			switch (_vm->getGameID()) {
669 			case GID_MICKEY:
670 				// load mickey mouse font from interpreter file
671 				loadFontMickey();
672 				break;
673 			default:
674 				loadFontScummVMFile("agi-font-dos.bin");
675 				break;
676 			}
677 			break;
678 
679 		default:
680 			break;
681 		}
682 
683 		if (!_fontData) {
684 			// no font assigned?
685 			// use regular PC-BIOS font (taken from Dos-Box with a few modifications)
686 			_fontData = fontData_PCBIOS;
687 			debug("AGI: Using PC-BIOS font");
688 		}
689 	}
690 
691 	if (_vm->getLanguage() == Common::RU_RUS) {
692 		// Russian versions need special extended set
693 		overwriteExtendedWithRussianSet();
694 	}
695 }
696 
getFontData()697 const byte *GfxFont::getFontData() {
698 	assert(_fontData);
699 	return _fontData;
700 }
701 
isFontHires()702 bool GfxFont::isFontHires() {
703 	return _fontIsHires;
704 }
705 
overwriteSaveRestoreDialogCharacter()706 void GfxFont::overwriteSaveRestoreDialogCharacter() {
707 	// overwrite character 0x1A with the standard Sierra arrow to the right character
708 	// required for the original save/restore dialogs
709 	memcpy(_fontDataAllocated + (0x1A * 8), fontData_ArrowRightCharacter, sizeof(fontData_ArrowRightCharacter));
710 }
711 
712 // Overwrite extended character set (0x80-0xFF) with Russian characters
overwriteExtendedWithRussianSet()713 void GfxFont::overwriteExtendedWithRussianSet() {
714 	if (_fontIsHires) {
715 		// TODO: Implement overwriting hires font characters too
716 		return;
717 	}
718 
719 	if (!_fontDataAllocated) {
720 		// nothing allocated, we need to allocate space ourselves to be able to modify an internal font
721 		_fontDataAllocated = (uint8 *)calloc(256, 8);
722 		memcpy(_fontDataAllocated, _fontData, 128 * 8); // copy ASCII set over
723 		_fontData = _fontDataAllocated;
724 	}
725 	// Overwrite extended set with Russian characters
726 	memcpy(_fontDataAllocated + (128 * 8), fontData_ExtendedRussian, 128 * 8);
727 
728 	debug("AGI: Using Russian extended font set");
729 }
730 
731 // This code loads a ScummVM-specific user-supplied binary font file
732 // It's assumed that it's a plain binary file, that contains 256 characters. 8 bytes per character.
733 // 8x8 pixels per character. File size 2048 bytes.
734 //
735 // Currently used for:
736 //  Atari ST - "agi-font-atarist.bin" -> should be the Atari ST 8x8 system font
737 //  Amiga    - "agi-font-amiga.bin"   -> should be the Amiga 8x8 Topaz font
738 //  DOS      - "agi-font-dos.bin"
loadFontScummVMFile(Common::String fontFilename)739 void GfxFont::loadFontScummVMFile(Common::String fontFilename) {
740 	Common::File fontFile;
741 	int32 fontFileSize = 0;
742 
743 	if (!fontFile.open(fontFilename)) {
744 		// Continue, if file not found
745 		// These ScummVM font files are totally optional, so don't show a warning
746 		return;
747 	}
748 
749 	fontFileSize = fontFile.size();
750 	if (fontFileSize != (256 * 8)) {
751 		// unexpected file size
752 		fontFile.close();
753 		warning("Fontfile '%s': unexpected file size", fontFilename.c_str());
754 		return;
755 	}
756 
757 	// allocate space for font bitmap data
758 	_fontDataAllocated = (uint8 *)calloc(256, 8);
759 	_fontData = _fontDataAllocated;
760 
761 	// read font data, is already in the format that we need (plain bitmap 8x8)
762 	fontFile.read(_fontDataAllocated, 256 * 8);
763 	fontFile.close();
764 
765 	overwriteSaveRestoreDialogCharacter();
766 
767 	debug("AGI: Using user-supplied font");
768 }
769 
770 // We load the Mickey Mouse font from MICKEY.EXE
loadFontMickey()771 void GfxFont::loadFontMickey() {
772 	Common::File interpreterFile;
773 	int32 interpreterFileSize = 0;
774 	byte *fontData = nullptr;
775 
776 	if (!interpreterFile.open("mickey.exe")) {
777 		// Continue, if file not found
778 		warning("Could not open file 'mickey.exe' for Mickey Mouse font");
779 		return;
780 	}
781 
782 	interpreterFileSize = interpreterFile.size();
783 	if (interpreterFileSize != 55136) {
784 		// unexpected file size
785 		interpreterFile.close();
786 		warning("File 'mickey.exe': unexpected file size");
787 		return;
788 	}
789 	interpreterFile.seek(32476); // offset of font data
790 
791 	// allocate space for font bitmap data
792 	fontData = (uint8 *)calloc(256, 8);
793 	_fontData = fontData;
794 	_fontDataAllocated = fontData;
795 
796 	// read font data, is already in the format that we need (plain bitmap 8x8)
797 	interpreterFile.read(fontData, 256 * 8);
798 	interpreterFile.close();
799 
800 	debug("AGI: Using Mickey Mouse font");
801 }
802 
803 // we create a bitmap out of the topaz data used in parallaction (which is normally found in staticres.cpp)
804 // it's a recreation of the Amiga Topaz font but not really accurate
loadFontAmigaPseudoTopaz()805 void GfxFont::loadFontAmigaPseudoTopaz() {
806 	const byte *topazStart = fontData_AmigaPseudoTopaz + 32;
807 	const byte *topazHeader = topazStart + 78;
808 	const byte *topazData = nullptr;
809 	const byte *topazLocations = nullptr;
810 	byte *fontData = nullptr;
811 	uint16 topazHeight = 0;
812 	uint16 topazWidth = 0;
813 	uint16 topazModulo = 0;
814 	uint32 topazDataOffset = 0;
815 	uint32 topazLocationOffset = 0;
816 	byte   topazLowChar = 0;
817 	byte   topazHighChar = 0;
818 	uint16 topazTotalChars = 0;
819 	uint16 topazBitLength = 0;
820 	uint16 topazBitOffset = 0;
821 	uint16 topazByteOffset = 0;
822 
823 	// allocate space for font bitmap data
824 	fontData = (uint8 *)calloc(256, 8);
825 	_fontData = fontData;
826 	_fontDataAllocated = fontData;
827 
828 	topazHeight = READ_BE_UINT16(topazHeader + 0);
829 	topazWidth = READ_BE_UINT16(topazHeader + 4);
830 
831 	// we expect 8x8
832 	assert(topazHeight == 8);
833 	assert(topazWidth == 8);
834 
835 	topazLowChar = topazHeader[12];
836 	topazHighChar = topazHeader[13];
837 	topazTotalChars = topazHighChar - topazLowChar + 1;
838 	topazDataOffset = READ_BE_UINT32(topazHeader + 14);
839 	topazModulo = READ_BE_UINT16(topazHeader + 18);
840 	topazLocationOffset = READ_BE_UINT32(topazHeader + 20);
841 
842 	// Security checks
843 	assert(topazLowChar == ' ');
844 	assert(topazHighChar == 0xFF);
845 
846 	// copy first 32 PC-BIOS characters over
847 	memcpy(fontData, fontData_PCBIOS, FONT_DISPLAY_WIDTH * 32);
848 	fontData += FONT_DISPLAY_WIDTH * 32;
849 
850 	// now actually convert from topaz data
851 	topazData = topazStart + topazDataOffset;
852 	topazLocations = topazStart + topazLocationOffset;
853 
854 	for (uint16 curChar = 0; curChar < topazTotalChars; curChar++) {
855 		topazBitOffset = READ_BE_UINT16(topazLocations + (curChar * 4) + 0);
856 		topazBitLength = READ_BE_UINT16(topazLocations + (curChar * 4) + 2);
857 
858 		if (topazBitLength == 8) {
859 			assert((topazBitOffset & 7) == 0);
860 
861 			topazByteOffset = topazBitOffset >> 3;
862 
863 			// Security check, although we are working on static const data from within ScummVM
864 			uint maxOffset = (topazByteOffset + ((topazHeight - 1) * topazModulo));
865 			assert(maxOffset < sizeof(fontData_AmigaPseudoTopaz));
866 
867 			for (uint16 curHeight = 0; curHeight < topazHeight; curHeight++) {
868 				*fontData = topazData[topazByteOffset];
869 				fontData++;
870 				topazByteOffset += topazModulo;
871 			}
872 		} else {
873 			memset(fontData, 0, 8);
874 			fontData += 8;
875 		}
876 	}
877 
878 	debug("AGI: Using recreation of Amiga Topaz font");
879 }
880 
loadFontAppleIIgs()881 void GfxFont::loadFontAppleIIgs() {
882 	Common::File fontFile;
883 	uint16 headerIIgs_OffsetMacHeader = 0;
884 	uint16 headerIIgs_Version = 0;
885 	uint16 macRecord_FirstChar = 0;
886 	uint16 macRecord_LastChar = 0;
887 	int16 macRecord_MaxKern = 0;
888 	uint16 macRecord_RectHeight = 0;
889 	uint16 macRecord_StrikeWidth = 0;
890 	uint16 strikeDataLen = 0;
891 	byte *strikeDataPtr = nullptr;
892 	uint16 actualCharacterCount = 0;
893 	uint16 totalCharacterCount = 0;
894 	uint16 *locationTablePtr = nullptr;
895 	uint16 *offsetWidthTablePtr = nullptr;
896 
897 	uint16 curCharNr = 0;
898 	uint16 curRow = 0;
899 	uint16 curLocation = 0;
900 	uint16 curLocationBytes = 0;
901 	uint16 curLocationBits = 0;
902 	uint16 curCharOffsetWidth = 0;
903 	uint16 curCharOffset = 0;
904 	uint16 curCharWidth = 0;
905 	uint16 curStrikeWidth = 0;
906 
907 	uint16 curPixelNr = 0;
908 	uint16 curBitMask = 0;
909 	int16 positionAdjust = 0;
910 	byte curByte = 0;
911 	byte fontByte = 0;
912 
913 	uint16 strikeRowOffset = 0;
914 	uint16 strikeCurOffset = 0;
915 
916 	byte *fontData = nullptr;
917 
918 	if (!fontFile.open("agifont")) {
919 		// Continue,
920 		// This also happens when the user selected Apple IIgs as render for the palette for non-AppleIIgs games
921 		warning("Could not open file 'agifont' for Apple IIgs font");
922 		return;
923 	}
924 
925 	// Apple IIgs header
926 	headerIIgs_OffsetMacHeader = fontFile.readUint16LE();
927 	fontFile.skip(2); // font family
928 	fontFile.skip(2); // font style
929 	fontFile.skip(2); // point size
930 	headerIIgs_Version = fontFile.readUint16LE();
931 	fontFile.skip(2); // bounds type
932 	// end of Apple IIgs header
933 	// Macintosh font record
934 	fontFile.skip(2); // font type
935 	macRecord_FirstChar = fontFile.readUint16LE();
936 	macRecord_LastChar = fontFile.readUint16LE();
937 	fontFile.skip(2); // max width
938 	macRecord_MaxKern = fontFile.readSint16LE();
939 	fontFile.skip(2); // negative descent
940 	fontFile.skip(2); // rect width
941 	macRecord_RectHeight = fontFile.readUint16LE();
942 	fontFile.skip(2); // low word ptr table
943 	fontFile.skip(2); // font ascent
944 	fontFile.skip(2); // font descent
945 	fontFile.skip(2); // leading
946 	macRecord_StrikeWidth = fontFile.readUint16LE();
947 
948 	// security-checks
949 	if (headerIIgs_OffsetMacHeader != 6)
950 		error("AppleIIgs-font: unexpected header");
951 	if (headerIIgs_Version != 0x0101)
952 		error("AppleIIgs-font: not a 1.1 font");
953 	if ((macRecord_FirstChar != 0) || (macRecord_LastChar != 255))
954 		error("AppleIIgs-font: unexpected characters");
955 	if (macRecord_RectHeight != 8)
956 		error("AppleIIgs-font: expected 8x8 font");
957 
958 	// Calculate table sizes
959 	strikeDataLen = macRecord_StrikeWidth * macRecord_RectHeight * 2;
960 	actualCharacterCount = (macRecord_LastChar - macRecord_FirstChar + 1);
961 	totalCharacterCount = actualCharacterCount + 2; // replacement-char + extra character
962 
963 	// Allocate memory for tables
964 	strikeDataPtr = (byte *)calloc(strikeDataLen, 1);
965 	locationTablePtr = (uint16 *)calloc(totalCharacterCount, 2); // 1 word per character
966 	offsetWidthTablePtr = (uint16 *)calloc(totalCharacterCount, 2); // ditto
967 
968 	// read tables
969 	fontFile.read(strikeDataPtr, strikeDataLen);
970 	for (curCharNr = 0; curCharNr < totalCharacterCount; curCharNr++) {
971 		locationTablePtr[curCharNr] = fontFile.readUint16LE();
972 	}
973 	for (curCharNr = 0; curCharNr < totalCharacterCount; curCharNr++) {
974 		offsetWidthTablePtr[curCharNr] = fontFile.readUint16LE();
975 	}
976 	fontFile.close();
977 
978 	// allocate space for font bitmap data
979 	fontData = (uint8 *)calloc(256, 8);
980 	_fontData = fontData;
981 	_fontDataAllocated = fontData;
982 
983 	// extract font bitmap data
984 	for (curCharNr = 0; curCharNr < actualCharacterCount; curCharNr++) {
985 		curCharOffsetWidth = offsetWidthTablePtr[curCharNr];
986 		curLocation = locationTablePtr[curCharNr];
987 		if (curCharOffsetWidth == 0xFFFF) {
988 			// character does not exist in font, use replacement character instead
989 			curCharOffsetWidth = offsetWidthTablePtr[actualCharacterCount];
990 			curLocation = locationTablePtr[actualCharacterCount];
991 			curStrikeWidth = locationTablePtr[actualCharacterCount + 1] - curLocation;
992 		} else {
993 			curStrikeWidth = locationTablePtr[curCharNr + 1] - curLocation;
994 		}
995 
996 		// Figure out bytes + bits location
997 		curLocationBytes = curLocation >> 3;
998 		curLocationBits = curLocation & 0x0007;
999 		curCharWidth = curCharOffsetWidth & 0x00FF; // isolate width
1000 		curCharOffset = curCharOffsetWidth >> 8; // isolate offset
1001 
1002 		if (!curCharWidth) {
1003 			fontData += 8; // skip over this character
1004 			continue;
1005 		}
1006 
1007 		if (curCharWidth != 8) {
1008 			if (curCharNr != 0x3B)
1009 				error("AppleIIgs-font: expected 8x8 font");
1010 		}
1011 
1012 		// Get all rows of the current character
1013 		strikeRowOffset = 0;
1014 		for (curRow = 0; curRow < macRecord_RectHeight; curRow++) {
1015 			strikeCurOffset = strikeRowOffset + curLocationBytes;
1016 
1017 			// Copy over bits
1018 			fontByte = 0;
1019 			curByte = strikeDataPtr[strikeCurOffset];
1020 			curBitMask = 0x80 >> curLocationBits;
1021 
1022 			for (curPixelNr = 0; curPixelNr < curStrikeWidth; curPixelNr++) {
1023 				fontByte = fontByte << 1;
1024 				if (curByte & curBitMask) {
1025 					fontByte |= 0x01;
1026 				}
1027 				curBitMask = curBitMask >> 1;
1028 				if (!curBitMask) {
1029 					curByte = strikeDataPtr[strikeCurOffset + 1];
1030 					curBitMask = 0x80;
1031 				}
1032 			}
1033 
1034 			// adjust, so that it's aligned to the left (starting at 0x80 bit)
1035 			fontByte = fontByte << (8 - curStrikeWidth);
1036 
1037 			// now adjust according to offset + MaxKern
1038 			positionAdjust = macRecord_MaxKern + curCharOffset;
1039 
1040 			// adjust may be negative for space, or 8 for "empty" characters
1041 			if (positionAdjust > 8)
1042 				error("AppleIIgs-font: invalid character spacing");
1043 
1044 			if (positionAdjust < 0) {
1045 				// negative adjust strangely happens for empty characters like space
1046 				if (curStrikeWidth)
1047 					error("AppleIIgs-font: invalid character spacing");
1048 			}
1049 
1050 			if (positionAdjust > 0) {
1051 				// move the amount of pixels to the right
1052 				fontByte = fontByte >> positionAdjust;
1053 			}
1054 
1055 			*fontData = fontByte;
1056 			fontData++;
1057 
1058 			strikeRowOffset += macRecord_StrikeWidth * 2;
1059 		}
1060 	}
1061 
1062 	free(offsetWidthTablePtr);
1063 	free(locationTablePtr);
1064 	free(strikeDataPtr);
1065 
1066 	overwriteSaveRestoreDialogCharacter();
1067 
1068 	debug("AGI: Using Apple IIgs font");
1069 }
1070 
1071 // Loads Atari ST font file
1072 // It's found inside Atari ST ROMs. Just search for "8x8 system font". Font starts 4 bytes before that.
loadFontAtariST(Common::String fontFilename)1073 void GfxFont::loadFontAtariST(Common::String fontFilename) {
1074 	Common::File fontFile;
1075 	uint16 header_FirstChar = 0;
1076 	uint16 header_LastChar = 0;
1077 	uint16 header_MaxWidth = 0;
1078 	uint16 header_MaxHeight = 0;
1079 	uint16 header_Flags = 0;
1080 	//uint32 header_OffsetOfCharOffsets = 0;
1081 	//uint32 header_OffsetOfFontData = 0;
1082 	uint16 header_FormWidth = 0;
1083 	uint16 header_FormHeight = 0;
1084 	uint16 totalCharacterCount = 0;
1085 	uint16 *charOffsetTablePtr = nullptr;
1086 	byte *rawDataTablePtr = nullptr;
1087 
1088 	uint16 curCharNr = 0;
1089 	uint16 curCharRawOffset = 0;
1090 	uint16 curCharDestOffset = 0;
1091 	uint16 curRow = 0;
1092 
1093 	byte *fontData = nullptr;
1094 
1095 	if (!fontFile.open(fontFilename)) {
1096 		// Continue, if file not found
1097 		warning("Could not open file 'agi-font-atarist-system.bin' for Atari ST 8x8 system font");
1098 		return;
1099 	}
1100 
1101 	// Atari ST font header
1102 	fontFile.skip(2); // face identifier
1103 	fontFile.skip(2); // point size
1104 	fontFile.skip(32); // font name
1105 	header_FirstChar = fontFile.readUint16BE();
1106 	header_LastChar = fontFile.readUint16BE();
1107 	fontFile.skip(10); // aligntment of cells
1108 	header_MaxWidth = fontFile.readUint16BE();
1109 	header_MaxHeight = fontFile.readUint16BE();
1110 	fontFile.skip(2); // left offset cel
1111 	fontFile.skip(2); // right offset cel
1112 	fontFile.skip(2); // number of pixels to thicken pixels
1113 	fontFile.skip(2); // underline width
1114 	fontFile.skip(2); // lightening mask
1115 	fontFile.skip(2); // skewing mask
1116 	header_Flags = fontFile.readUint16BE();
1117 	// bit 0 - default system font
1118 	// bit 1 - horizontal offset table (not supported)
1119 	// bit 2 - byte orientation word is high->low
1120 	// bit 3 - mono spaced font
1121 	fontFile.skip(4); // horizontal table offset
1122 	fontFile.skip(4); // header_OffsetOfCharOffsets = fontFile.readUint32BE();
1123 	fontFile.skip(4); // header_OffsetOfFontData = fontFile.readUint32BE();
1124 	header_FormWidth = fontFile.readUint16BE();
1125 	header_FormHeight = fontFile.readUint16BE();
1126 	fontFile.skip(4); // pointer to next font
1127 
1128 	totalCharacterCount = header_LastChar - header_FirstChar + 1;
1129 
1130 	// security-checks
1131 	if (header_MaxWidth > 8)
1132 		error("AtariST-font: not a 8x8 font");
1133 	if (header_MaxHeight != 8)
1134 		error("AtariST-font: not a 8x8 font");
1135 	if (header_FormHeight != 8)
1136 		error("AtariST-font: not a 8x8 font");
1137 	if ((header_FirstChar != 0) || (header_LastChar != 255))
1138 		error("AtariST-font: unexpected characters");
1139 	if (header_FormWidth != totalCharacterCount)
1140 		error("AtariST-font: header inconsistency");
1141 	if (!(header_Flags & 0x04))
1142 		error("AtariST-font: font data not in high->low order");
1143 	if (!(header_Flags & 0x08))
1144 		error("AtariST-font: not a mono-spaced font");
1145 
1146 	// Now we should normally use the offsets, but they don't make sense to me
1147 	// So I just read the data directly. For the 8x8 system font that works
1148 	fontFile.skip(2); // extra bytes
1149 
1150 	// Allocate memory for tables
1151 	charOffsetTablePtr = (uint16 *)calloc(totalCharacterCount, 2); // 1 word per character
1152 	rawDataTablePtr = (byte *)calloc(header_FormWidth, header_FormHeight);
1153 
1154 	// Char-Offset Table (2 * total number of characters)
1155 	for (curCharNr = 0; curCharNr < totalCharacterCount; curCharNr++) {
1156 		charOffsetTablePtr[curCharNr] = fontFile.readUint16BE();
1157 	}
1158 
1159 	// Followed by actual font data
1160 	// Attention: Atari ST fonts contain every same row of all characters after each other.
1161 	// So it's basically like this:
1162 	// [character data of first row of first character]
1163 	// [character data of first row of second character]
1164 	// ...
1165 	// [character data of first row of last character]
1166 	// [character data of second row of first character]
1167 	fontFile.skip(2); // extra bytes
1168 	fontFile.read(rawDataTablePtr, header_FormWidth * header_FormHeight);
1169 	fontFile.close();
1170 
1171 	// allocate space for font bitmap data
1172 	fontData = (uint8 *)calloc(256, 8);
1173 	_fontData = fontData;
1174 	_fontDataAllocated = fontData;
1175 
1176 	// extract font bitmap data
1177 	for (curCharNr = 0; curCharNr < totalCharacterCount; curCharNr++) {
1178 		// Figure out base offset from char offset table
1179 		curCharRawOffset = charOffsetTablePtr[curCharNr] >> 3;
1180 		curCharDestOffset = curCharNr * 8; // destination offset into our font data
1181 
1182 		// now copy over every row of the character
1183 		for (curRow = 0; curRow < header_FormHeight; curRow++) {
1184 			fontData[curCharDestOffset] = rawDataTablePtr[curCharRawOffset];
1185 			curCharDestOffset++;
1186 			curCharRawOffset += header_FormWidth;
1187 		}
1188 	}
1189 
1190 	free(rawDataTablePtr);
1191 	free(charOffsetTablePtr);
1192 
1193 	overwriteSaveRestoreDialogCharacter();
1194 
1195 	debug("AGI: Using Atari ST 8x8 system font");
1196 }
1197 
1198 // Loads a Sierra Hercules font file
loadFontHercules()1199 void GfxFont::loadFontHercules() {
1200 	Common::File fontFile;
1201 	int32 fontFileSize = 0;
1202 	byte *fontData = nullptr;
1203 	byte *rawData = nullptr;
1204 
1205 	uint16 rawDataPos = 0;
1206 	uint16 curCharNr = 0;
1207 	uint16 curCharLine = 0;
1208 
1209 	if (fontFile.open("hgc_font")) {
1210 		// hgc_font file found, this is interleaved font data 16x12, should be 3072 bytes
1211 		// 24 bytes per character, 128 characters
1212 		fontFileSize = fontFile.size();
1213 		if (fontFileSize == (128 * 24)) {
1214 			// size seems to be fine
1215 			fontData = (uint8 *)calloc(256, 32);
1216 			_fontDataAllocated = fontData;
1217 
1218 			rawData = (byte *)calloc(128, 24);
1219 			fontFile.read(rawData, 128 * 24);
1220 
1221 			// convert interleaved 16x12 -> non-interleaved 16x16
1222 			for (curCharNr = 0; curCharNr < 128; curCharNr++) {
1223 				fontData += 4; // skip the first 2 lines
1224 				for (curCharLine = 0; curCharLine < 6; curCharLine++) {
1225 					fontData[0] = rawData[rawDataPos + 2 + 0];
1226 					fontData[1] = rawData[rawDataPos + 2 + 1];
1227 					fontData[2] = rawData[rawDataPos + 0 + 0];
1228 					fontData[3] = rawData[rawDataPos + 0 + 1];
1229 					rawDataPos += 4;
1230 					fontData += 4;
1231 				}
1232 				fontData += 4; // skip the last 2 lines
1233 			}
1234 
1235 			free(rawData);
1236 		} else {
1237 			warning("Fontfile 'hgc_font': unexpected file size");
1238 		}
1239 		fontFile.close();
1240 
1241 	}
1242 
1243 	// It seems hgc_graf.ovl holds a low-res font. It makes no real sense to use it.
1244 	// This was only done to AGI3 games and those rendered differently (2 pixel lines -> 3 pixel lines instead of 4)
1245 	// User could copy hgc_font from another AGI game over to get the hires font working.
1246 #if 0
1247 	if (!_fontDataAllocated) {
1248 		if (fontFile.open("hgc_graf.ovl")) {
1249 			// hgc_graf.ovl file found, this is font data + code. non-interleaved font data, should be 3075 bytes
1250 			// 16 bytes per character, 128 characters, 2048 bytes of font data, starting offset 21
1251 			fontFileSize = fontFile.size();
1252 			if (fontFileSize == 3075) {
1253 				// size seems to be fine
1254 				fontData = (uint8 *)calloc(256, 32);
1255 				_fontDataAllocated = fontData;
1256 
1257 				fontFile.seek(21);
1258 				rawData = (byte *)calloc(128, 16);
1259 				fontFile.read(rawData, 128 * 16);
1260 
1261 				// repeat every line 2 times to get 16x16 pixels
1262 				for (curCharNr = 0; curCharNr < 128; curCharNr++) {
1263 					for (curCharLine = 0; curCharLine < 8; curCharLine++) {
1264 						fontData[0] = rawData[rawDataPos + 0];
1265 						fontData[1] = rawData[rawDataPos + 1];
1266 						fontData[2] = rawData[rawDataPos + 0];
1267 						fontData[3] = rawData[rawDataPos + 1];
1268 						rawDataPos += 2;
1269 						fontData += 4;
1270 					}
1271 				}
1272 
1273 				free(rawData);
1274 
1275 			} else {
1276 				warning("Fontfile 'hgc_graf.ovl': unexpected file size");
1277 			}
1278 			fontFile.close();
1279 		}
1280 	}
1281 #endif
1282 
1283 	if (_fontDataAllocated) {
1284 		// font loaded
1285 		_fontData = _fontDataAllocated;
1286 		_fontIsHires = true;
1287 
1288 		debug("AGI: Using Hercules hires font");
1289 
1290 	} else {
1291 		// Continue, if no file was not found
1292 		warning("Could not open/use file 'hgc_font' for Hercules hires font");
1293 	}
1294 }
1295 
1296 } // End of namespace Agi
1297