1 | #include "stdafx.h"
|
---|
2 | #include "scumm.h"
|
---|
3 | #include "charset.h"
|
---|
4 | #include "nut_renderer.h"
|
---|
5 | #include "smush/smush_font.h"
|
---|
6 |
|
---|
7 | extern _gid;
|
---|
8 |
|
---|
9 | inline int get2byteIndex(int idx)
|
---|
10 | {
|
---|
11 | /*
|
---|
12 | switch(language)
|
---|
13 | case korean:
|
---|
14 | return ( (idx % 256) - 0xb0) * 94 + (idx / 256) - 0xa1;
|
---|
15 | case japanese:
|
---|
16 | ...
|
---|
17 | case taiwan:
|
---|
18 | ...
|
---|
19 | */
|
---|
20 | return ( (idx % 256) - 0xb0) * 94 + (idx / 256) - 0xa1; // only for korean
|
---|
21 | }
|
---|
22 |
|
---|
23 | bool Scumm::checkCJKLanguage()
|
---|
24 | {
|
---|
25 | bool result = false;
|
---|
26 | if(_language == KO_KOR || _language == JA_JPN || _language == ZH_TWN)
|
---|
27 | result = true;
|
---|
28 | return result;
|
---|
29 | }
|
---|
30 |
|
---|
31 | int SmushFont::get2byteCharWidth() {
|
---|
32 | if(_gid == GID_CMI)
|
---|
33 | return 8;
|
---|
34 | if(_gid == GID_DIG)
|
---|
35 | return 6;
|
---|
36 | return 0;
|
---|
37 | }
|
---|
38 | int SmushFont::get2byteCharHeight() {
|
---|
39 | if(_gid == GID_CMI)
|
---|
40 | return 16;
|
---|
41 | if(_gid == GID_DIG)
|
---|
42 | return 10;
|
---|
43 | return 0;
|
---|
44 | }
|
---|
45 |
|
---|
46 | int SmushFont::draw2byte(byte *buffer, int dst_width, int x, int y, byte fst, byte snd) {
|
---|
47 | int w = _2byte_width;
|
---|
48 | int h = _2byte_height;
|
---|
49 |
|
---|
50 | byte maskidx[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
---|
51 | int _2byteIndex = get2byteIndex(fst + (snd * 256));
|
---|
52 | int width = _2byte_width;
|
---|
53 | int height = _2byte_height;
|
---|
54 | char *_2bytePtr = &_2byte[_2byteIndex * (_2byte_height * 2)];
|
---|
55 | char *pData = _2bytePtr;
|
---|
56 | byte *dst = buffer + dst_width * (y + (_gid == GID_CMI ? 7 : 2)) + x;
|
---|
57 |
|
---|
58 | if(_original) {
|
---|
59 | for(int32 j = 0; j < h; j++) {
|
---|
60 | for(int32 i = 0; i < w; i++) {
|
---|
61 | char value = 1;//*src++;
|
---|
62 | if(value) dst[i] = value;
|
---|
63 | }
|
---|
64 | dst += dst_width;
|
---|
65 | }
|
---|
66 | } else {
|
---|
67 | char color = (_color != -1) ? _color : 1;
|
---|
68 | if (_new_colors == true) {
|
---|
69 | for(int j = 0; j < h; j++) {
|
---|
70 | for(int i = 0; i < w; i++) {
|
---|
71 | if(i && ((i % 8) == 0))
|
---|
72 | pData++;
|
---|
73 | if (*pData & maskidx[i % 8]) {
|
---|
74 | dst[i + 1] = 0;
|
---|
75 | dst[i] = 0xff; //FIXME
|
---|
76 | }
|
---|
77 | }
|
---|
78 | pData++;
|
---|
79 | dst += dst_width;
|
---|
80 | }
|
---|
81 | } else {
|
---|
82 | for(int j = 0; j < h; j++) {
|
---|
83 | for(int i = 0; i < w; i++) {
|
---|
84 | if(i && ((i % 8) == 0))
|
---|
85 | pData++;
|
---|
86 | if (*pData & maskidx[i % 8]) {
|
---|
87 | dst[i + 1] = 0;
|
---|
88 | dst[i] = color;
|
---|
89 | }
|
---|
90 | }
|
---|
91 | pData++;
|
---|
92 | dst += dst_width;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|
96 | return w + 1;
|
---|
97 | }
|
---|
98 |
|
---|
99 | void CharsetRendererClassic::draw2byte(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int idx) {
|
---|
100 | byte maskmask;
|
---|
101 | int y, x;
|
---|
102 | int maskpos;
|
---|
103 | //int color;
|
---|
104 | byte maskidx[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
---|
105 | byte numbits;
|
---|
106 | bool useMask = (vs->number == 0 && !_ignoreCharsetMask);
|
---|
107 |
|
---|
108 | numbits = 8;
|
---|
109 |
|
---|
110 | int _2byteIndex = get2byteIndex(idx);
|
---|
111 | int width = _2byte_width;
|
---|
112 | int height = _2byte_height;
|
---|
113 | char *pData = &_2byte[_2byteIndex * 18];
|
---|
114 |
|
---|
115 | for (y = 0; y < height && y + drawTop < vs->height; y++) {
|
---|
116 | maskmask = revBitMask[_left & 7];
|
---|
117 | maskpos = 0;
|
---|
118 |
|
---|
119 | for (x = 0; x < width; x++) {
|
---|
120 | if(x && ((x % 8) == 0))
|
---|
121 | pData++;
|
---|
122 | if (*pData & maskidx[x % 8]) {
|
---|
123 | *(dst + x + 1) = _vm->_charsetColorMap[0];
|
---|
124 | *(dst + x ) = _vm->_charsetColorMap[1]; //FIXME?
|
---|
125 | if (useMask) {
|
---|
126 | mask[maskpos] |= maskmask;
|
---|
127 | if (maskmask == 1) {
|
---|
128 | mask[maskpos + 1] |= 0x80;
|
---|
129 | } else {
|
---|
130 | mask[maskpos] |= (maskmask >> 1);
|
---|
131 | }
|
---|
132 | }
|
---|
133 | }
|
---|
134 | maskmask >>= 1;
|
---|
135 | if (maskmask == 0) {
|
---|
136 | maskmask = 0x80;
|
---|
137 | maskpos++;
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | pData++;
|
---|
142 | dst += _vm->_screenWidth;
|
---|
143 | mask += _vm->gdi._numStrips;
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | void NutRenderer::draw2byte(int c, int32 x, int32 y, byte color, bool useMask) {
|
---|
148 | if (_loaded == false) {
|
---|
149 | debug(2, "NutRenderer::draw2byte() Font is not loaded");
|
---|
150 | return;
|
---|
151 | }
|
---|
152 |
|
---|
153 | byte maskidx[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
---|
154 | int _2byteIndex = get2byteIndex(c);
|
---|
155 | int width = _2byte_width;
|
---|
156 | int height = _2byte_height;
|
---|
157 | char *_2bPtr = &_2byte[_2byteIndex * (_2byte_height * 2)];
|
---|
158 |
|
---|
159 | byte *dst, *mask = NULL;
|
---|
160 | byte maskmask;
|
---|
161 | int maskpos;
|
---|
162 |
|
---|
163 | dst = _vm->virtscr[0].screenPtr + y * _vm->_screenWidth + x + _vm->virtscr[0].xstart;
|
---|
164 | mask = _vm->getResourceAddress(rtBuffer, 9)
|
---|
165 | + (y * _vm->_screenWidth + x) / 8 + _vm->_screenStartStrip;
|
---|
166 |
|
---|
167 | for (int ty = 0; ty < height; ty++) {
|
---|
168 | maskmask = revBitMask[x & 7];
|
---|
169 | maskpos = 0;
|
---|
170 | for (int tx = 0; tx < width; tx++) {
|
---|
171 | if (x + tx < 0 || x + tx >= _vm->_screenWidth || y + ty < 0 || y + ty >= _vm->_screenHeight)
|
---|
172 | continue;
|
---|
173 | if(tx && ((tx % 8) == 0))
|
---|
174 | _2bPtr++;
|
---|
175 | if (*_2bPtr & maskidx[tx % 8]) {
|
---|
176 | *(dst + tx + 1) = 0;
|
---|
177 | *(dst + tx) = color;
|
---|
178 | if (useMask) {
|
---|
179 | mask[maskpos] |= maskmask;
|
---|
180 | if (maskmask == 1) {
|
---|
181 | mask[maskpos + 1] |= 0x80;
|
---|
182 | } else {
|
---|
183 | mask[maskpos] |= (maskmask >> 1);
|
---|
184 | }
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 | maskmask >>= 1;
|
---|
189 | if (maskmask == 0) {
|
---|
190 | maskmask = 0x80;
|
---|
191 | maskpos++;
|
---|
192 | }
|
---|
193 | }
|
---|
194 |
|
---|
195 | _2bPtr++;
|
---|
196 | dst += _vm->_screenWidth;
|
---|
197 | mask += _vm->gdi._numStrips;
|
---|
198 | }
|
---|
199 | }
|
---|