| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
|
| 13 |
#include "sagagraphics.h" |
| 14 |
#include "scott.h" |
| 15 |
|
| 16 |
extern int x, y, count; |
| 17 |
extern int xlen, ylen; |
| 18 |
extern int xoff, yoff; |
| 19 |
extern int size; |
| 20 |
|
| 21 |
typedef uint8_t RGB[3]; |
| 22 |
|
| 23 |
static void DrawA8C64Pixels(int pattern, int pattern2) |
| 24 |
{ |
| 25 |
int pix1, pix2, pix3, pix4; |
| 26 |
|
| 27 |
if (x > (xlen - 3) * 8) |
| 28 |
return; |
| 29 |
|
| 30 |
pix1 = (pattern & 0xc0) >> 6; |
| 31 |
pix2 = (pattern & 0x30) >> 4; |
| 32 |
pix3 = (pattern & 0x0c) >> 2; |
| 33 |
pix4 = (pattern & 0x03); |
| 34 |
|
| 35 |
PutDoublePixel(x, y, pix1); |
| 36 |
x += 2; |
| 37 |
PutDoublePixel(x, y, pix2); |
| 38 |
x += 2; |
| 39 |
PutDoublePixel(x, y, pix3); |
| 40 |
x += 2; |
| 41 |
PutDoublePixel(x, y, pix4); |
| 42 |
x += 2; |
| 43 |
y++; |
| 44 |
x -= 8; |
| 45 |
|
| 46 |
pix1 = (pattern2 & 0xc0) >> 6; |
| 47 |
pix2 = (pattern2 & 0x30) >> 4; |
| 48 |
pix3 = (pattern2 & 0x0c) >> 2; |
| 49 |
pix4 = (pattern2 & 0x03); |
| 50 |
|
| 51 |
PutDoublePixel(x, y, pix1); |
| 52 |
x += 2; |
| 53 |
PutDoublePixel(x, y, pix2); |
| 54 |
x += 2; |
| 55 |
PutDoublePixel(x, y, pix3); |
| 56 |
x += 2; |
| 57 |
PutDoublePixel(x, y, pix4); |
| 58 |
x += 2; |
| 59 |
y++; |
| 60 |
x -= 8; |
| 61 |
|
| 62 |
if (y > ylen) { |
| 63 |
x += 8; |
| 64 |
y = yoff; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
static const RGB black = { 0, 0, 0 }; |
| 70 |
static const RGB white = { 255, 255, 255 }; |
| 71 |
static const RGB red = { 191, 97, 72 }; |
| 72 |
static const RGB purple = { 177, 89, 185 }; |
| 73 |
static const RGB green = { 121, 213, 112 }; |
| 74 |
static const RGB blue = { 95, 72, 233 }; |
| 75 |
static const RGB yellow = { 247, 255, 108 }; |
| 76 |
static const RGB orange = { 186, 134, 32 }; |
| 77 |
static const RGB brown = { 131, 112, 0 }; |
| 78 |
static const RGB lred = { 231, 154, 132 }; |
| 79 |
static const RGB grey = { 167, 167, 167 }; |
| 80 |
static const RGB lgreen = { 192, 255, 185 }; |
| 81 |
static const RGB lblue = { 162, 143, 255 }; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
RGB colors[256] = { |
| 87 |
{ 0x00, 0x00, 0x00 }, |
| 88 |
{ 0x0e, 0x0e, 0x0e }, |
| 89 |
{ 0x1d, 0x1d, 0x1d }, |
| 90 |
|
| 91 |
{ 0x2c, 0x2c, 0x2c }, |
| 92 |
{ 0x3b, 0x3b, 0x3b }, |
| 93 |
{ 0x4a, 0x4a, 0x4a }, |
| 94 |
{ 0x59, 0x59, 0x59 }, |
| 95 |
{ 0x68, 0x68, 0x68 }, |
| 96 |
{ 0x77, 0x77, 0x77 }, |
| 97 |
{ 0x86, 0x86, 0x86 }, |
| 98 |
{ 0x95, 0x95, 0x95 }, |
| 99 |
{ 0xa4, 0xa4, 0xa4 }, |
| 100 |
{ 0xb3, 0xb3, 0xb3 }, |
| 101 |
{ 0xc2, 0xc2, 0xc2 }, |
| 102 |
|
| 103 |
{ 0xe0, 0xe0, 0xe0 }, |
| 104 |
{ 0xe0, 0xe0, 0xe0 }, |
| 105 |
{ 0x34, 0x00, 0x00 }, |
| 106 |
{ 0x43, 0x0e, 0x00 }, |
| 107 |
|
| 108 |
{ 0xad, 0x5f, 0x64 }, |
| 109 |
{ 0x61, 0x2c, 0x00 }, |
| 110 |
{ 0x70, 0x3b, 0x00 }, |
| 111 |
{ 0x7e, 0x4a, 0x00 }, |
| 112 |
{ 0x8d, 0x59, 0x00 }, |
| 113 |
{ 0x9c, 0x68, 0x00 }, |
| 114 |
{ 0xab, 0x77, 0x00 }, |
| 115 |
{ 0xba, 0x86, 0x00 }, |
| 116 |
{ 0xc9, 0x95, 0x0b }, |
| 117 |
{ 0xd8, 0xa4, 0x1a }, |
| 118 |
{ 0xe7, 0xb3, 0x29 }, |
| 119 |
{ 0xee, 0xc2, 0x38 }, |
| 120 |
{ 0xee, 0xd1, 0x46 }, |
| 121 |
{ 0xee, 0xe0, 0x55 }, |
| 122 |
{ 0x3a, 0x00, 0x00 }, |
| 123 |
{ 0x49, 0x01, 0x00 }, |
| 124 |
{ 0x58, 0x10, 0x00 }, |
| 125 |
{ 0x67, 0x1f, 0x00 }, |
| 126 |
{ 0x76, 0x2e, 0x00 }, |
| 127 |
|
| 128 |
{ 0xad, 0x5f, 0x64 }, |
| 129 |
{ 0x94, 0x4c, 0x02 }, |
| 130 |
{ 0xa3, 0x5b, 0x11 }, |
| 131 |
{ 0xb2, 0x6a, 0x20 }, |
| 132 |
{ 0xc1, 0x79, 0x2f }, |
| 133 |
{ 0xd0, 0x88, 0x3e }, |
| 134 |
{ 0xdf, 0x97, 0x4d }, |
| 135 |
{ 0xee, 0xa6, 0x5c }, |
| 136 |
{ 0xee, 0xb5, 0x6b }, |
| 137 |
{ 0xee, 0xc4, 0x7a }, |
| 138 |
{ 0xee, 0xd2, 0x89 }, |
| 139 |
{ 0x36, 0x00, 0x00 }, |
| 140 |
{ 0x45, 0x00, 0x00 }, |
| 141 |
|
| 142 |
{ 0xad, 0x5f, 0x64 }, |
| 143 |
{ 0x62, 0x14, 0x1a }, |
| 144 |
{ 0x71, 0x23, 0x29 }, |
| 145 |
{ 0x80, 0x32, 0x38 }, |
| 146 |
|
| 147 |
{ 0xad, 0x5f, 0x64 }, |
| 148 |
{ 0x9e, 0x50, 0x55 }, |
| 149 |
{ 0xad, 0x5f, 0x64 }, |
| 150 |
{ 0xbc, 0x6e, 0x73 }, |
| 151 |
|
| 152 |
{ 0xad, 0x5f, 0x64 }, |
| 153 |
{ 0xda, 0x8c, 0x91 }, |
| 154 |
{ 0xe9, 0x9a, 0xa0 }, |
| 155 |
{ 0xee, 0xa9, 0xaf }, |
| 156 |
{ 0xee, 0xb8, 0xbe }, |
| 157 |
{ 0xee, 0xc7, 0xcd }, |
| 158 |
{ 0x27, 0x00, 0x34 }, |
| 159 |
{ 0x36, 0x00, 0x43 }, |
| 160 |
{ 0x45, 0x00, 0x52 }, |
| 161 |
{ 0x54, 0x0f, 0x61 }, |
| 162 |
{ 0x62, 0x1e, 0x70 }, |
| 163 |
{ 0x71, 0x2d, 0x7e }, |
| 164 |
{ 0x80, 0x3c, 0x8d }, |
| 165 |
{ 0x8f, 0x4b, 0x9c }, |
| 166 |
{ 0x9e, 0x5a, 0xab }, |
| 167 |
{ 0xad, 0x69, 0xba }, |
| 168 |
{ 0xbc, 0x78, 0xc9 }, |
| 169 |
{ 0xcb, 0x87, 0xd8 }, |
| 170 |
{ 0xda, 0x96, 0xe7 }, |
| 171 |
{ 0xe9, 0xa5, 0xee }, |
| 172 |
{ 0xee, 0xb4, 0xee }, |
| 173 |
{ 0xee, 0xc3, 0xee }, |
| 174 |
{ 0x0f, 0x00, 0x71 }, |
| 175 |
{ 0x1e, 0x00, 0x80 }, |
| 176 |
{ 0x2d, 0x00, 0x8f }, |
| 177 |
{ 0x3c, 0x0f, 0x9e }, |
| 178 |
{ 0x4b, 0x1e, 0xad }, |
| 179 |
{ 0x5a, 0x2d, 0xbc }, |
| 180 |
|
| 181 |
{ 0x4b, 0x1e, 0xad }, |
| 182 |
{ 0x78, 0x4b, 0xda }, |
| 183 |
{ 0x87, 0x5a, 0xe9 }, |
| 184 |
{ 0x96, 0x69, 0xee }, |
| 185 |
{ 0xa5, 0x78, 0xee }, |
| 186 |
{ 0xb4, 0x87, 0xee }, |
| 187 |
{ 0xc3, 0x96, 0xee }, |
| 188 |
{ 0xd2, 0xa5, 0xee }, |
| 189 |
{ 0xe0, 0xb4, 0xee }, |
| 190 |
{ 0xee, 0xc3, 0xee }, |
| 191 |
{ 0x00, 0x00, 0x99 }, |
| 192 |
{ 0x04, 0x00, 0xa7 }, |
| 193 |
{ 0x13, 0x07, 0xb6 }, |
| 194 |
{ 0x22, 0x16, 0xc5 }, |
| 195 |
{ 0x31, 0x25, 0xd4 }, |
| 196 |
{ 0x40, 0x34, 0xe3 }, |
| 197 |
{ 0x4f, 0x43, 0xee }, |
| 198 |
{ 0x5e, 0x52, 0xee }, |
| 199 |
{ 0x6d, 0x61, 0xee }, |
| 200 |
{ 0x7c, 0x70, 0xee }, |
| 201 |
{ 0x8b, 0x7e, 0xee }, |
| 202 |
{ 0x9a, 0x8d, 0xee }, |
| 203 |
{ 0xa8, 0x9c, 0xee }, |
| 204 |
{ 0xb7, 0xab, 0xee }, |
| 205 |
{ 0xc6, 0xba, 0xee }, |
| 206 |
{ 0xd5, 0xc9, 0xee }, |
| 207 |
{ 0x00, 0x00, 0xa1 }, |
| 208 |
{ 0x00, 0x02, 0xb0 }, |
| 209 |
{ 0x00, 0x11, 0xbf }, |
| 210 |
{ 0x0a, 0x20, 0xce }, |
| 211 |
{ 0x19, 0x2f, 0xdd }, |
| 212 |
{ 0x28, 0x3e, 0xec }, |
| 213 |
{ 0x37, 0x4d, 0xee }, |
| 214 |
{ 0x46, 0x5c, 0xee }, |
| 215 |
{ 0x54, 0x6b, 0xee }, |
| 216 |
{ 0x63, 0x7a, 0xee }, |
| 217 |
{ 0x72, 0x89, 0xee }, |
| 218 |
{ 0x81, 0x98, 0xee }, |
| 219 |
{ 0x90, 0xa7, 0xee }, |
| 220 |
{ 0x9f, 0xb6, 0xee }, |
| 221 |
{ 0xae, 0xc4, 0xee }, |
| 222 |
{ 0xbd, 0xd3, 0xee }, |
| 223 |
{ 0x00, 0x00, 0x8a }, |
| 224 |
{ 0x00, 0x0e, 0x99 }, |
| 225 |
{ 0x00, 0x1d, 0xa8 }, |
| 226 |
{ 0x00, 0x2c, 0xb6 }, |
| 227 |
{ 0x07, 0x3b, 0xc5 }, |
| 228 |
|
| 229 |
{ 0x34, 0x68, 0xee }, |
| 230 |
{ 0x25, 0x59, 0xe3 }, |
| 231 |
{ 0x34, 0x68, 0xee }, |
| 232 |
{ 0x43, 0x77, 0xee }, |
| 233 |
{ 0x52, 0x86, 0xed }, |
| 234 |
{ 0x61, 0x95, 0xee }, |
| 235 |
{ 0x70, 0xa4, 0xee }, |
| 236 |
{ 0x7e, 0xb3, 0xee }, |
| 237 |
{ 0x8d, 0xc2, 0xee }, |
| 238 |
{ 0x9c, 0xd1, 0xee }, |
| 239 |
{ 0xab, 0xe0, 0xee }, |
| 240 |
{ 0x00, 0x0d, 0x56 }, |
| 241 |
{ 0x00, 0x1c, 0x65 }, |
| 242 |
{ 0x00, 0x2a, 0x74 }, |
| 243 |
{ 0x00, 0x39, 0x83 }, |
| 244 |
{ 0x00, 0x48, 0x92 }, |
| 245 |
{ 0x0f, 0x57, 0xa1 }, |
| 246 |
{ 0x1e, 0x66, 0xb0 }, |
| 247 |
{ 0x2d, 0x75, 0xbf }, |
| 248 |
{ 0x3c, 0x84, 0xce }, |
| 249 |
{ 0x4b, 0x93, 0xdd }, |
| 250 |
{ 0x5a, 0xa2, 0xec }, |
| 251 |
{ 0x69, 0xb1, 0xee }, |
| 252 |
{ 0x78, 0xc0, 0xee }, |
| 253 |
{ 0x87, 0xcf, 0xee }, |
| 254 |
{ 0x96, 0xde, 0xee }, |
| 255 |
{ 0xa5, 0xed, 0xee }, |
| 256 |
{ 0x00, 0x18, 0x12 }, |
| 257 |
{ 0x00, 0x27, 0x21 }, |
| 258 |
{ 0x00, 0x36, 0x30 }, |
| 259 |
{ 0x00, 0x45, 0x3f }, |
| 260 |
{ 0x05, 0x54, 0x4e }, |
| 261 |
{ 0x14, 0x62, 0x5d }, |
| 262 |
{ 0x23, 0x71, 0x6c }, |
| 263 |
{ 0x32, 0x80, 0x7b }, |
| 264 |
{ 0x41, 0x8f, 0x8a }, |
| 265 |
{ 0x50, 0x9e, 0x99 }, |
| 266 |
{ 0x5f, 0xad, 0xa8 }, |
| 267 |
{ 0x6e, 0xbc, 0xb6 }, |
| 268 |
{ 0x7d, 0xcb, 0xc5 }, |
| 269 |
{ 0x8c, 0xda, 0xd4 }, |
| 270 |
{ 0x9a, 0xe9, 0xe3 }, |
| 271 |
{ 0xa9, 0xee, 0xee }, |
| 272 |
{ 0x00, 0x1c, 0x00 }, |
| 273 |
{ 0x00, 0x2b, 0x00 }, |
| 274 |
{ 0x00, 0x3a, 0x00 }, |
| 275 |
{ 0x05, 0x49, 0x00 }, |
| 276 |
{ 0x14, 0x58, 0x07 }, |
| 277 |
{ 0x23, 0x67, 0x16 }, |
| 278 |
{ 0x32, 0x76, 0x25 }, |
| 279 |
{ 0x41, 0x85, 0x34 }, |
| 280 |
{ 0x50, 0x94, 0x43 }, |
| 281 |
{ 0x5f, 0xa3, 0x52 }, |
| 282 |
{ 0x6e, 0xb2, 0x61 }, |
| 283 |
{ 0x7d, 0xc1, 0x70 }, |
| 284 |
{ 0x8c, 0xd0, 0x7e }, |
| 285 |
{ 0x9a, 0xdf, 0x8d }, |
| 286 |
{ 0xa9, 0xee, 0x9c }, |
| 287 |
{ 0xb8, 0xee, 0xab }, |
| 288 |
{ 0x00, 0x1c, 0x00 }, |
| 289 |
{ 0x00, 0x2b, 0x00 }, |
| 290 |
{ 0x0e, 0x3a, 0x00 }, |
| 291 |
{ 0x1c, 0x49, 0x00 }, |
| 292 |
{ 0x2b, 0x58, 0x00 }, |
| 293 |
{ 0x3a, 0x67, 0x00 }, |
| 294 |
|
| 295 |
{ 0x2b, 0x58, 0x00 }, |
| 296 |
|
| 297 |
{ 0x3a, 0x67, 0x00 }, |
| 298 |
{ 0x67, 0x94, 0x05 }, |
| 299 |
{ 0x76, 0xa3, 0x14 }, |
| 300 |
{ 0x85, 0xb2, 0x23 }, |
| 301 |
{ 0x94, 0xc1, 0x32 }, |
| 302 |
{ 0xa3, 0xd0, 0x41 }, |
| 303 |
{ 0xb2, 0xdf, 0x50 }, |
| 304 |
{ 0xc1, 0xee, 0x5f }, |
| 305 |
{ 0xd0, 0xee, 0x6e }, |
| 306 |
{ 0x0a, 0x16, 0x00 }, |
| 307 |
{ 0x19, 0x25, 0x00 }, |
| 308 |
{ 0x28, 0x34, 0x00 }, |
| 309 |
{ 0x37, 0x43, 0x00 }, |
| 310 |
{ 0x46, 0x52, 0x00 }, |
| 311 |
{ 0x54, 0x61, 0x00 }, |
| 312 |
{ 0x63, 0x70, 0x00 }, |
| 313 |
{ 0x72, 0x7e, 0x00 }, |
| 314 |
|
| 315 |
{ 0x63, 0x70, 0x00 }, |
| 316 |
{ 0x90, 0x9c, 0x00 }, |
| 317 |
{ 0x9f, 0xab, 0x00 }, |
| 318 |
{ 0xae, 0xba, 0x0b }, |
| 319 |
{ 0xbd, 0xc9, 0x1a }, |
| 320 |
{ 0xcc, 0xd8, 0x29 }, |
| 321 |
{ 0xdb, 0xe7, 0x38 }, |
| 322 |
{ 0xea, 0xee, 0x46 }, |
| 323 |
{ 0x22, 0x0c, 0x00 }, |
| 324 |
{ 0x31, 0x1b, 0x00 }, |
| 325 |
{ 0x40, 0x2a, 0x00 }, |
| 326 |
{ 0x4f, 0x38, 0x00 }, |
| 327 |
|
| 328 |
{ 0x94, 0x4c, 0x02 }, |
| 329 |
{ 0x6d, 0x56, 0x00 }, |
| 330 |
{ 0x7c, 0x65, 0x00 }, |
| 331 |
{ 0x8b, 0x74, 0x00 }, |
| 332 |
{ 0x9a, 0x83, 0x00 }, |
| 333 |
{ 0xa8, 0x92, 0x00 }, |
| 334 |
{ 0xb7, 0xa1, 0x00 }, |
| 335 |
{ 0xc6, 0xb0, 0x02 }, |
| 336 |
{ 0xd5, 0xbf, 0x11 }, |
| 337 |
{ 0xe4, 0xce, 0x20 }, |
| 338 |
{ 0xee, 0xdd, 0x2f }, |
| 339 |
{ 0xee, 0xec, 0x3e }, |
| 340 |
{ 0x34, 0x00, 0x00 }, |
| 341 |
{ 0x43, 0x0e, 0x00 }, |
| 342 |
{ 0x52, 0x1d, 0x00 }, |
| 343 |
{ 0x61, 0x2c, 0x00 }, |
| 344 |
{ 0x70, 0x3b, 0x00 }, |
| 345 |
{ 0x7e, 0x4a, 0x00 }, |
| 346 |
{ 0x8d, 0x59, 0x00 }, |
| 347 |
|
| 348 |
{ 0xad, 0x5f, 0x64 }, |
| 349 |
|
| 350 |
{ 0x8d, 0x59, 0x00 }, |
| 351 |
{ 0xba, 0x86, 0x00 }, |
| 352 |
{ 0xc9, 0x95, 0x0b }, |
| 353 |
{ 0xd8, 0xa4, 0x1a }, |
| 354 |
{ 0xe7, 0xb3, 0x29 }, |
| 355 |
{ 0xee, 0xc2, 0x38 }, |
| 356 |
{ 0xee, 0xd1, 0x46 }, |
| 357 |
|
| 358 |
{ 0xba, 0x86, 0x00 } |
| 359 |
}; |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
static void TranslateAtariColorRGB(int index, uint8_t value) |
| 364 |
{ |
| 365 |
SetColor(index, &colors[value]); |
| 366 |
} |
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
static void TranslateC64Color(int index, uint8_t value) |
| 375 |
{ |
| 376 |
debug_print("Color %d: %d\n", index, value); |
| 377 |
switch (value) { |
| 378 |
case 2: |
| 379 |
case 3: |
| 380 |
case 4: |
| 381 |
case 8: |
| 382 |
case 9: |
| 383 |
case 10: |
| 384 |
case 12: |
| 385 |
case 14: |
| 386 |
case 15: |
| 387 |
case 255: |
| 388 |
case 137: |
| 389 |
case 142: |
| 390 |
SetColor(index, &white); |
| 391 |
break; |
| 392 |
case 35: |
| 393 |
case 36: |
| 394 |
case 38: |
| 395 |
case 40: |
| 396 |
case 244: |
| 397 |
case 246: |
| 398 |
case 248: |
| 399 |
SetColor(index, &brown); |
| 400 |
break; |
| 401 |
case 24: |
| 402 |
case 26: |
| 403 |
case 30: |
| 404 |
case 46: |
| 405 |
case 16: |
| 406 |
case 230: |
| 407 |
case 237: |
| 408 |
case 238: |
| 409 |
case 252: |
| 410 |
SetColor(index, &yellow); |
| 411 |
break; |
| 412 |
case 50: |
| 413 |
case 51: |
| 414 |
case 52: |
| 415 |
case 53: |
| 416 |
case 54: |
| 417 |
case 56: |
| 418 |
case 58: |
| 419 |
case 59: |
| 420 |
case 60: |
| 421 |
case 66: |
| 422 |
case 62: |
| 423 |
SetColor(index, &orange); |
| 424 |
break; |
| 425 |
case 67: |
| 426 |
case 68: |
| 427 |
case 69: |
| 428 |
case 70: |
| 429 |
case 71: |
| 430 |
SetColor(index, &red); |
| 431 |
break; |
| 432 |
case 0: |
| 433 |
case 77: |
| 434 |
case 81: |
| 435 |
case 84: |
| 436 |
case 85: |
| 437 |
case 86: |
| 438 |
case 87: |
| 439 |
case 97: |
| 440 |
case 101: |
| 441 |
case 102: |
| 442 |
case 103: |
| 443 |
case 105: |
| 444 |
case 224: |
| 445 |
SetColor(index, &purple); |
| 446 |
break; |
| 447 |
case 89: |
| 448 |
SetColor(index, &lred); |
| 449 |
break; |
| 450 |
case 1: |
| 451 |
case 7: |
| 452 |
case 116: |
| 453 |
case 135: |
| 454 |
case 148: |
| 455 |
case 151: |
| 456 |
SetColor(index, &blue); |
| 457 |
break; |
| 458 |
case 110: |
| 459 |
case 157: |
| 460 |
SetColor(index, &lblue); |
| 461 |
break; |
| 462 |
case 161: |
| 463 |
SetColor(index, &grey); |
| 464 |
break; |
| 465 |
case 17: |
| 466 |
case 20: |
| 467 |
case 179: |
| 468 |
case 182: |
| 469 |
case 183: |
| 470 |
case 194: |
| 471 |
case 195: |
| 472 |
case 196: |
| 473 |
case 197: |
| 474 |
case 198: |
| 475 |
case 199: |
| 476 |
case 200: |
| 477 |
case 212: |
| 478 |
case 214: |
| 479 |
case 215: |
| 480 |
case 216: |
| 481 |
SetColor(index, &green); |
| 482 |
break; |
| 483 |
case 201: |
| 484 |
SetColor(index, &lgreen); |
| 485 |
break; |
| 486 |
default: |
| 487 |
fprintf(stderr, "Unknown color %d ", value); |
| 488 |
break; |
| 489 |
} |
| 490 |
} |
| 491 |
|
| 492 |
int DrawAtariC64Image(USImage *image) |
| 493 |
{ |
| 494 |
uint8_t *ptr = image->imagedata; |
| 495 |
size_t datasize = image->datasize; |
| 496 |
|
| 497 |
int work, work2; |
| 498 |
int c; |
| 499 |
int i; |
| 500 |
int countflag = (CurrentGame == COUNT_US || CurrentGame == VOODOO_CASTLE_US); |
| 501 |
|
| 502 |
uint8_t *origptr = ptr; |
| 503 |
|
| 504 |
x = 0; |
| 505 |
y = 0; |
| 506 |
|
| 507 |
ptr += 2; |
| 508 |
|
| 509 |
work = *ptr++; |
| 510 |
size = work + *ptr++ * 256; |
| 511 |
|
| 512 |
xoff = *ptr++ - 3; |
| 513 |
yoff = *ptr++; |
| 514 |
x = xoff * 8; |
| 515 |
y = yoff; |
| 516 |
|
| 517 |
|
| 518 |
xlen = *ptr++; |
| 519 |
|
| 520 |
ylen = *ptr++; |
| 521 |
if (countflag) |
| 522 |
ylen -= 2; |
| 523 |
|
| 524 |
glui32 curheight, curwidth; |
| 525 |
glk_window_get_size(Graphics, &curwidth, &curheight); |
| 526 |
|
| 527 |
if (image->usage == IMG_ROOM || (xlen == 38 && xoff < 1)) { |
| 528 |
xlen = xlen - 1 - image->cropright / 8; |
| 529 |
left_margin = image->cropleft; |
| 530 |
|
| 531 |
ImageWidth = xlen * 8 - 17 + left_margin; |
| 532 |
ImageHeight = ylen + 2; |
| 533 |
|
| 534 |
if (image->index == 19 && image->systype == SYS_ATARI8) { |
| 535 |
xlen++; |
| 536 |
ImageWidth = 308; |
| 537 |
} |
| 538 |
|
| 539 |
int width_in_pixels = ImageWidth * pixel_size; |
| 540 |
while (width_in_pixels > curwidth && pixel_size > 1) { |
| 541 |
pixel_size--; |
| 542 |
width_in_pixels = ImageWidth * pixel_size; |
| 543 |
} |
| 544 |
|
| 545 |
x_offset = (curwidth - width_in_pixels) / 2; |
| 546 |
|
| 547 |
int optimal_height = ImageHeight * pixel_size; |
| 548 |
|
| 549 |
if (curheight != optimal_height) { |
| 550 |
winid_t parent = glk_window_get_parent(Graphics); |
| 551 |
if (parent) |
| 552 |
glk_window_set_arrangement(parent, winmethod_Above | winmethod_Fixed, |
| 553 |
optimal_height, NULL); |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
SetColor(0, &black); |
| 558 |
|
| 559 |
|
| 560 |
for (i = 1; i < 5; i++) { |
| 561 |
work = *ptr++; |
| 562 |
if (image->systype == SYS_C64) |
| 563 |
TranslateC64Color(i, work); |
| 564 |
else |
| 565 |
TranslateAtariColorRGB(i, work); |
| 566 |
} |
| 567 |
|
| 568 |
while (ptr - origptr < datasize - 2) { |
| 569 |
|
| 570 |
c = *ptr++; |
| 571 |
|
| 572 |
if (((c & 0x80) == 0x80) || countflag) { |
| 573 |
if (countflag) { |
| 574 |
c -= 1; |
| 575 |
} else { |
| 576 |
c &= 0x7f; |
| 577 |
} |
| 578 |
work = *ptr++; |
| 579 |
work2 = *ptr++; |
| 580 |
for (i = 0; i < c + 1; i++) { |
| 581 |
DrawA8C64Pixels(work, work2); |
| 582 |
} |
| 583 |
} else { |
| 584 |
|
| 585 |
for (i = 0; i < c + 1 && ptr - origptr < datasize - 1; i++) { |
| 586 |
work = *ptr++; |
| 587 |
work2 = *ptr++; |
| 588 |
DrawA8C64Pixels(work, work2); |
| 589 |
} |
| 590 |
} |
| 591 |
} |
| 592 |
return 1; |
| 593 |
} |