summaryrefslogtreecommitdiff
path: root/apps/codecs/libasap
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libasap')
-rw-r--r--apps/codecs/libasap/acpu.c2270
-rw-r--r--apps/codecs/libasap/apokeysnd.c920
-rw-r--r--apps/codecs/libasap/asap.c3716
-rw-r--r--apps/codecs/libasap/asap.h204
-rw-r--r--apps/codecs/libasap/players.h2736
5 files changed, 4923 insertions, 4923 deletions
diff --git a/apps/codecs/libasap/acpu.c b/apps/codecs/libasap/acpu.c
index 7c3c8f6f28..c5bff47a5d 100644
--- a/apps/codecs/libasap/acpu.c
+++ b/apps/codecs/libasap/acpu.c
@@ -52,105 +52,105 @@
52#include "asap_internal.h" 52#include "asap_internal.h"
53 53
54CONST_ARRAY(int, opcode_cycles) 54CONST_ARRAY(int, opcode_cycles)
55/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ 55/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
56 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0x */ 56 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0x */
57 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1x */ 57 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1x */
58 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2x */ 58 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2x */
59 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3x */ 59 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3x */
60 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4x */ 60 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4x */
61 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5x */ 61 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5x */
62 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6x */ 62 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6x */
63 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7x */ 63 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7x */
64 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8x */ 64 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8x */
65 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9x */ 65 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9x */
66 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* Ax */ 66 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* Ax */
67 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* Bx */ 67 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* Bx */
68 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Cx */ 68 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Cx */
69 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* Dx */ 69 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* Dx */
70 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Ex */ 70 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Ex */
71 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* Fx */ 71 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* Fx */
72END_CONST_ARRAY; 72END_CONST_ARRAY;
73 73
74#ifdef ACPU_NO_DECIMAL 74#ifdef ACPU_NO_DECIMAL
75 75
76#define DO_ADC \ 76#define DO_ADC \
77 { \ 77 { \
78 /* binary mode */ \ 78 /* binary mode */ \
79 V(int, tmp) = a + data + c; \ 79 V(int, tmp) = a + data + c; \
80 c = tmp >> 8; \ 80 c = tmp >> 8; \
81 vdi &= D_FLAG | I_FLAG; \ 81 vdi &= D_FLAG | I_FLAG; \
82 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \ 82 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \
83 vdi += V_FLAG; \ 83 vdi += V_FLAG; \
84 nz = a = tmp & 0xff; \ 84 nz = a = tmp & 0xff; \
85 } 85 }
86 86
87#define DO_SBC \ 87#define DO_SBC \
88 { \ 88 { \
89 /* binary mode */ \ 89 /* binary mode */ \
90 V(int, tmp) = a - data - 1 + c; \ 90 V(int, tmp) = a - data - 1 + c; \
91 c = (tmp >= 0) ? 1 : 0; \ 91 c = (tmp >= 0) ? 1 : 0; \
92 vdi &= D_FLAG | I_FLAG; \ 92 vdi &= D_FLAG | I_FLAG; \
93 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \ 93 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \
94 vdi += V_FLAG; \ 94 vdi += V_FLAG; \
95 nz = a = tmp & 0xff; \ 95 nz = a = tmp & 0xff; \
96 } 96 }
97 97
98#else /* ACPU_NO_DECIMAL */ 98#else /* ACPU_NO_DECIMAL */
99 99
100#define DO_ADC \ 100#define DO_ADC \
101 if ((vdi & D_FLAG) == 0) { \ 101 if ((vdi & D_FLAG) == 0) { \
102 /* binary mode */ \ 102 /* binary mode */ \
103 V(int, tmp) = a + data + c; \ 103 V(int, tmp) = a + data + c; \
104 c = tmp >> 8; \ 104 c = tmp >> 8; \
105 vdi &= D_FLAG | I_FLAG; \ 105 vdi &= D_FLAG | I_FLAG; \
106 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \ 106 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \
107 vdi += V_FLAG; \ 107 vdi += V_FLAG; \
108 nz = a = tmp & 0xff; \ 108 nz = a = tmp & 0xff; \
109 } \ 109 } \
110 else { \ 110 else { \
111 /* decimal mode */ \ 111 /* decimal mode */ \
112 V(int, tmp) = (a & 0x0f) + (data & 0x0f) + c; \ 112 V(int, tmp) = (a & 0x0f) + (data & 0x0f) + c; \
113 if (tmp >= 10) \ 113 if (tmp >= 10) \
114 tmp = (tmp - 10) | 0x10; \ 114 tmp = (tmp - 10) | 0x10; \
115 tmp += (a & 0xf0) + (data & 0xf0); \ 115 tmp += (a & 0xf0) + (data & 0xf0); \
116 nz = ((tmp & 0x80) << 1) + ((a + data + c) & 0xff); \ 116 nz = ((tmp & 0x80) << 1) + ((a + data + c) & 0xff); \
117 vdi &= D_FLAG | I_FLAG; \ 117 vdi &= D_FLAG | I_FLAG; \
118 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \ 118 if (((a ^ data) & 0x80) == 0 && ((data ^ tmp) & 0x80) != 0) \
119 vdi += V_FLAG; \ 119 vdi += V_FLAG; \
120 if (tmp > 0x9f) \ 120 if (tmp > 0x9f) \
121 tmp += 0x60; \ 121 tmp += 0x60; \
122 c = (tmp > 0xff) ? 1 : 0; \ 122 c = (tmp > 0xff) ? 1 : 0; \
123 a = tmp & 0xff; \ 123 a = tmp & 0xff; \
124 } 124 }
125 125
126#define DO_SBC \ 126#define DO_SBC \
127 if ((vdi & D_FLAG) == 0) { \ 127 if ((vdi & D_FLAG) == 0) { \
128 /* binary mode */ \ 128 /* binary mode */ \
129 V(int, tmp) = a - data - 1 + c; \ 129 V(int, tmp) = a - data - 1 + c; \
130 c = (tmp >= 0) ? 1 : 0; \ 130 c = (tmp >= 0) ? 1 : 0; \
131 vdi &= D_FLAG | I_FLAG; \ 131 vdi &= D_FLAG | I_FLAG; \
132 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \ 132 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \
133 vdi += V_FLAG; \ 133 vdi += V_FLAG; \
134 nz = a = tmp & 0xff; \ 134 nz = a = tmp & 0xff; \
135 } \ 135 } \
136 else { \ 136 else { \
137 /* decimal mode */ \ 137 /* decimal mode */ \
138 V(int, tmp) = a - data - 1 + c; \ 138 V(int, tmp) = a - data - 1 + c; \
139 V(int, al) = (a & 0x0f) - (data & 0x0f) - 1 + c; \ 139 V(int, al) = (a & 0x0f) - (data & 0x0f) - 1 + c; \
140 V(int, ah) = (a >> 4) - (data >> 4); \ 140 V(int, ah) = (a >> 4) - (data >> 4); \
141 if ((al & 0x10) != 0) { \ 141 if ((al & 0x10) != 0) { \
142 al -= 6; \ 142 al -= 6; \
143 ah--; \ 143 ah--; \
144 } \ 144 } \
145 if ((ah & 0x10) != 0) \ 145 if ((ah & 0x10) != 0) \
146 ah -= 6; \ 146 ah -= 6; \
147 c = tmp >= 0 ? 1 : 0; \ 147 c = tmp >= 0 ? 1 : 0; \
148 vdi &= D_FLAG | I_FLAG; \ 148 vdi &= D_FLAG | I_FLAG; \
149 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \ 149 if (((a ^ tmp) & 0x80) != 0 && ((a ^ data) & 0x80) != 0) \
150 vdi += V_FLAG; \ 150 vdi += V_FLAG; \
151 nz = tmp & 0xff; \ 151 nz = tmp & 0xff; \
152 a = ((ah & 0xf) << 4) + (al & 0x0f); \ 152 a = ((ah & 0xf) << 4) + (al & 0x0f); \
153 } 153 }
154 154
155#endif /* ACPU_NO_DECIMAL */ 155#endif /* ACPU_NO_DECIMAL */
156 156
@@ -239,1068 +239,1068 @@ END_CONST_ARRAY;
239#define INS_ZP INC_ZP; data = nz; DO_SBC 239#define INS_ZP INC_ZP; data = nz; DO_SBC
240 240
241#define BRANCH(cond) \ 241#define BRANCH(cond) \
242 if (cond) { \ 242 if (cond) { \
243 addr = SBYTE(PEEK); \ 243 addr = SBYTE(PEEK); \
244 pc++; \ 244 pc++; \
245 addr += pc; \ 245 addr += pc; \
246 if ((addr ^ pc) >> 8 != 0) \ 246 if ((addr ^ pc) >> 8 != 0) \
247 ast _ cycle++; \ 247 ast _ cycle++; \
248 ast _ cycle++; \ 248 ast _ cycle++; \
249 pc = addr; \ 249 pc = addr; \
250 break; \ 250 break; \
251 } \ 251 } \
252 pc++; \ 252 pc++; \
253 break 253 break
254 254
255#define CHECK_IRQ \ 255#define CHECK_IRQ \
256 if ((vdi & I_FLAG) == 0 && ast _ irqst != 0xff) { \ 256 if ((vdi & I_FLAG) == 0 && ast _ irqst != 0xff) { \
257 PHPC; \ 257 PHPC; \
258 PHPB0; \ 258 PHPB0; \
259 vdi |= I_FLAG; \ 259 vdi |= I_FLAG; \
260 pc = dGetWord(0xfffe); \ 260 pc = dGetWord(0xfffe); \
261 ast _ cycle += 7; \ 261 ast _ cycle += 7; \
262 } 262 }
263 263
264/* Runs 6502 emulation for the specified number of Atari scanlines. 264/* Runs 6502 emulation for the specified number of Atari scanlines.
265 Each scanline is 114 cycles of which 9 is taken by ANTIC for memory refresh. */ 265 Each scanline is 114 cycles of which 9 is taken by ANTIC for memory refresh. */
266FUNC(void, Cpu_RunScanlines, (P(ASAP_State PTR, ast), P(int, scanlines))) 266FUNC(void, Cpu_RunScanlines, (P(ASAP_State PTR, ast), P(int, scanlines)))
267{ 267{
268 /* copy registers from ASAP_State to local variables for improved performance */ 268 /* copy registers from ASAP_State to local variables for improved performance */
269 V(int, pc); 269 V(int, pc);
270 V(int, nz); 270 V(int, nz);
271 V(int, a); 271 V(int, a);
272 V(int, x); 272 V(int, x);
273 V(int, y); 273 V(int, y);
274 V(int, c); 274 V(int, c);
275 V(int, s); 275 V(int, s);
276 V(int, vdi); 276 V(int, vdi);
277 V(int, next_event_cycle); 277 V(int, next_event_cycle);
278 V(int, cycle_limit); 278 V(int, cycle_limit);
279 pc = ast _ cpu_pc; 279 pc = ast _ cpu_pc;
280 nz = ast _ cpu_nz; 280 nz = ast _ cpu_nz;
281 a = ast _ cpu_a; 281 a = ast _ cpu_a;
282 x = ast _ cpu_x; 282 x = ast _ cpu_x;
283 y = ast _ cpu_y; 283 y = ast _ cpu_y;
284 c = ast _ cpu_c; 284 c = ast _ cpu_c;
285 s = ast _ cpu_s; 285 s = ast _ cpu_s;
286 vdi = ast _ cpu_vdi; 286 vdi = ast _ cpu_vdi;
287 ast _ next_scanline_cycle = 114; 287 ast _ next_scanline_cycle = 114;
288 next_event_cycle = 114; 288 next_event_cycle = 114;
289 cycle_limit = 114 * scanlines; 289 cycle_limit = 114 * scanlines;
290 if (next_event_cycle > ast _ timer1_cycle) 290 if (next_event_cycle > ast _ timer1_cycle)
291 next_event_cycle = ast _ timer1_cycle; 291 next_event_cycle = ast _ timer1_cycle;
292 if (next_event_cycle > ast _ timer2_cycle) 292 if (next_event_cycle > ast _ timer2_cycle)
293 next_event_cycle = ast _ timer2_cycle; 293 next_event_cycle = ast _ timer2_cycle;
294 if (next_event_cycle > ast _ timer4_cycle) 294 if (next_event_cycle > ast _ timer4_cycle)
295 next_event_cycle = ast _ timer4_cycle; 295 next_event_cycle = ast _ timer4_cycle;
296 ast _ nearest_event_cycle = next_event_cycle; 296 ast _ nearest_event_cycle = next_event_cycle;
297 for (;;) { 297 for (;;) {
298 V(int, cycle); 298 V(int, cycle);
299 V(int, addr); 299 V(int, addr);
300 V(int, data); 300 V(int, data);
301 cycle = ast _ cycle; 301 cycle = ast _ cycle;
302 if (cycle >= ast _ nearest_event_cycle) { 302 if (cycle >= ast _ nearest_event_cycle) {
303 if (cycle >= ast _ next_scanline_cycle) { 303 if (cycle >= ast _ next_scanline_cycle) {
304 if (++ast _ scanline_number == 312) 304 if (++ast _ scanline_number == 312)
305 ast _ scanline_number = 0; 305 ast _ scanline_number = 0;
306 ast _ cycle = cycle += 9; 306 ast _ cycle = cycle += 9;
307 ast _ next_scanline_cycle += 114; 307 ast _ next_scanline_cycle += 114;
308 if (--scanlines <= 0) 308 if (--scanlines <= 0)
309 break; 309 break;
310 } 310 }
311 next_event_cycle = ast _ next_scanline_cycle; 311 next_event_cycle = ast _ next_scanline_cycle;
312#define CHECK_TIMER_IRQ(ch) \ 312#define CHECK_TIMER_IRQ(ch) \
313 if (cycle >= ast _ timer##ch##_cycle) { \ 313 if (cycle >= ast _ timer##ch##_cycle) { \
314 ast _ irqst &= ~ch; \ 314 ast _ irqst &= ~ch; \
315 ast _ timer##ch##_cycle = NEVER; \ 315 ast _ timer##ch##_cycle = NEVER; \
316 } \ 316 } \
317 else if (next_event_cycle > ast _ timer##ch##_cycle) \ 317 else if (next_event_cycle > ast _ timer##ch##_cycle) \
318 next_event_cycle = ast _ timer##ch##_cycle; 318 next_event_cycle = ast _ timer##ch##_cycle;
319 CHECK_TIMER_IRQ(1); 319 CHECK_TIMER_IRQ(1);
320 CHECK_TIMER_IRQ(2); 320 CHECK_TIMER_IRQ(2);
321 CHECK_TIMER_IRQ(4); 321 CHECK_TIMER_IRQ(4);
322 ast _ nearest_event_cycle = next_event_cycle; 322 ast _ nearest_event_cycle = next_event_cycle;
323 CHECK_IRQ; 323 CHECK_IRQ;
324 } 324 }
325#ifdef ASAPSCAN 325#ifdef ASAPSCAN
326 if (cpu_trace != 0) 326 if (cpu_trace != 0)
327 trace_cpu(ast, pc, a, x, y, s, nz, vdi, c); 327 trace_cpu(ast, pc, a, x, y, s, nz, vdi, c);
328#endif 328#endif
329 data = FETCH; 329 data = FETCH;
330 ast _ cycle += opcode_cycles[data]; 330 ast _ cycle += opcode_cycles[data];
331 switch (data) { 331 switch (data) {
332 case 0x00: /* BRK */ 332 case 0x00: /* BRK */
333 pc++; 333 pc++;
334 PHPC; 334 PHPC;
335 PHPB1; 335 PHPB1;
336 vdi |= I_FLAG; 336 vdi |= I_FLAG;
337 pc = dGetWord(0xfffe); 337 pc = dGetWord(0xfffe);
338 break; 338 break;
339 case 0x01: /* ORA (ab,x) */ 339 case 0x01: /* ORA (ab,x) */
340 INDIRECT_X; 340 INDIRECT_X;
341 ORA; 341 ORA;
342 break; 342 break;
343 case 0x02: /* CIM [unofficial] */ 343 case 0x02: /* CIM [unofficial] */
344 case 0x12: 344 case 0x12:
345 case 0x22: 345 case 0x22:
346 case 0x32: 346 case 0x32:
347 case 0x42: 347 case 0x42:
348 case 0x52: 348 case 0x52:
349 case 0x62: 349 case 0x62:
350 case 0x72: 350 case 0x72:
351 case 0x92: 351 case 0x92:
352 case 0xb2: 352 case 0xb2:
353 case 0xd2: 353 case 0xd2:
354 case 0xf2: 354 case 0xf2:
355 ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % 312; 355 ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % 312;
356 scanlines = 1; 356 scanlines = 1;
357 ast _ cycle = cycle_limit; 357 ast _ cycle = cycle_limit;
358 break; 358 break;
359#ifndef ACPU_NO_UNOFFICIAL 359#ifndef ACPU_NO_UNOFFICIAL
360 case 0x03: /* ASO (ab,x) [unofficial] */ 360 case 0x03: /* ASO (ab,x) [unofficial] */
361 INDIRECT_X; 361 INDIRECT_X;
362 ASO; 362 ASO;
363 break; 363 break;
364 case 0x04: /* NOP ab [unofficial] */ 364 case 0x04: /* NOP ab [unofficial] */
365 case 0x44: 365 case 0x44:
366 case 0x64: 366 case 0x64:
367 case 0x14: /* NOP ab,x [unofficial] */ 367 case 0x14: /* NOP ab,x [unofficial] */
368 case 0x34: 368 case 0x34:
369 case 0x54: 369 case 0x54:
370 case 0x74: 370 case 0x74:
371 case 0xd4: 371 case 0xd4:
372 case 0xf4: 372 case 0xf4:
373 case 0x80: /* NOP #ab [unofficial] */ 373 case 0x80: /* NOP #ab [unofficial] */
374 case 0x82: 374 case 0x82:
375 case 0x89: 375 case 0x89:
376 case 0xc2: 376 case 0xc2:
377 case 0xe2: 377 case 0xe2:
378 pc++; 378 pc++;
379 break; 379 break;
380 case 0x07: /* ASO ab [unofficial] */ 380 case 0x07: /* ASO ab [unofficial] */
381 ZPAGE; 381 ZPAGE;
382 ASO_ZP; 382 ASO_ZP;
383 break; 383 break;
384 case 0x0b: /* ANC #ab [unofficial] */ 384 case 0x0b: /* ANC #ab [unofficial] */
385 case 0x2b: 385 case 0x2b:
386 nz = a &= FETCH; 386 nz = a &= FETCH;
387 c = nz >> 7; 387 c = nz >> 7;
388 break; 388 break;
389 case 0x0c: /* NOP abcd [unofficial] */ 389 case 0x0c: /* NOP abcd [unofficial] */
390 pc += 2; 390 pc += 2;
391 break; 391 break;
392 case 0x0f: /* ASO abcd [unofficial] */ 392 case 0x0f: /* ASO abcd [unofficial] */
393 ABSOLUTE; 393 ABSOLUTE;
394 ASO; 394 ASO;
395 break; 395 break;
396 case 0x13: /* ASO (ab),y [unofficial] */ 396 case 0x13: /* ASO (ab),y [unofficial] */
397 INDIRECT_Y; 397 INDIRECT_Y;
398 ASO; 398 ASO;
399 break; 399 break;
400 case 0x17: /* ASO ab,x [unofficial] */ 400 case 0x17: /* ASO ab,x [unofficial] */
401 ZPAGE_X; 401 ZPAGE_X;
402 ASO_ZP; 402 ASO_ZP;
403 break; 403 break;
404 case 0x1b: /* ASO abcd,y [unofficial] */ 404 case 0x1b: /* ASO abcd,y [unofficial] */
405 ABSOLUTE_Y; 405 ABSOLUTE_Y;
406 ASO; 406 ASO;
407 break; 407 break;
408 case 0x1c: /* NOP abcd,x [unofficial] */ 408 case 0x1c: /* NOP abcd,x [unofficial] */
409 case 0x3c: 409 case 0x3c:
410 case 0x5c: 410 case 0x5c:
411 case 0x7c: 411 case 0x7c:
412 case 0xdc: 412 case 0xdc:
413 case 0xfc: 413 case 0xfc:
414 if (FETCH + x >= 0x100) 414 if (FETCH + x >= 0x100)
415 ast _ cycle++; 415 ast _ cycle++;
416 pc++; 416 pc++;
417 break; 417 break;
418 case 0x1f: /* ASO abcd,x [unofficial] */ 418 case 0x1f: /* ASO abcd,x [unofficial] */
419 ABSOLUTE_X; 419 ABSOLUTE_X;
420 ASO; 420 ASO;
421 break; 421 break;
422 case 0x23: /* RLA (ab,x) [unofficial] */ 422 case 0x23: /* RLA (ab,x) [unofficial] */
423 INDIRECT_X; 423 INDIRECT_X;
424 RLA; 424 RLA;
425 break; 425 break;
426 case 0x27: /* RLA ab [unofficial] */ 426 case 0x27: /* RLA ab [unofficial] */
427 ZPAGE; 427 ZPAGE;
428 RLA_ZP; 428 RLA_ZP;
429 break; 429 break;
430 case 0x2f: /* RLA abcd [unofficial] */ 430 case 0x2f: /* RLA abcd [unofficial] */
431 ABSOLUTE; 431 ABSOLUTE;
432 RLA; 432 RLA;
433 break; 433 break;
434 case 0x33: /* RLA (ab),y [unofficial] */ 434 case 0x33: /* RLA (ab),y [unofficial] */
435 INDIRECT_Y; 435 INDIRECT_Y;
436 RLA; 436 RLA;
437 break; 437 break;
438 case 0x37: /* RLA ab,x [unofficial] */ 438 case 0x37: /* RLA ab,x [unofficial] */
439 ZPAGE_X; 439 ZPAGE_X;
440 RLA_ZP; 440 RLA_ZP;
441 break; 441 break;
442 case 0x3b: /* RLA abcd,y [unofficial] */ 442 case 0x3b: /* RLA abcd,y [unofficial] */
443 ABSOLUTE_Y; 443 ABSOLUTE_Y;
444 RLA; 444 RLA;
445 break; 445 break;
446 case 0x3f: /* RLA abcd,x [unofficial] */ 446 case 0x3f: /* RLA abcd,x [unofficial] */
447 ABSOLUTE_X; 447 ABSOLUTE_X;
448 RLA; 448 RLA;
449 break; 449 break;
450 case 0x43: /* LSE (ab,x) [unofficial] */ 450 case 0x43: /* LSE (ab,x) [unofficial] */
451 INDIRECT_X; 451 INDIRECT_X;
452 LSE; 452 LSE;
453 break; 453 break;
454 case 0x47: /* LSE ab [unofficial] */ 454 case 0x47: /* LSE ab [unofficial] */
455 ZPAGE; 455 ZPAGE;
456 LSE_ZP; 456 LSE_ZP;
457 break; 457 break;
458 case 0x4b: /* ALR #ab [unofficial] */ 458 case 0x4b: /* ALR #ab [unofficial] */
459 a &= FETCH; 459 a &= FETCH;
460 c = a & 1; 460 c = a & 1;
461 nz = a >>= 1; 461 nz = a >>= 1;
462 break; 462 break;
463 case 0x4f: /* LSE abcd [unofficial] */ 463 case 0x4f: /* LSE abcd [unofficial] */
464 ABSOLUTE; 464 ABSOLUTE;
465 LSE; 465 LSE;
466 break; 466 break;
467 case 0x53: /* LSE (ab),y [unofficial] */ 467 case 0x53: /* LSE (ab),y [unofficial] */
468 INDIRECT_Y; 468 INDIRECT_Y;
469 LSE; 469 LSE;
470 break; 470 break;
471 case 0x57: /* LSE ab,x [unofficial] */ 471 case 0x57: /* LSE ab,x [unofficial] */
472 ZPAGE_X; 472 ZPAGE_X;
473 LSE_ZP; 473 LSE_ZP;
474 break; 474 break;
475 case 0x5b: /* LSE abcd,y [unofficial] */ 475 case 0x5b: /* LSE abcd,y [unofficial] */
476 ABSOLUTE_Y; 476 ABSOLUTE_Y;
477 LSE; 477 LSE;
478 break; 478 break;
479 case 0x5f: /* LSE abcd,x [unofficial] */ 479 case 0x5f: /* LSE abcd,x [unofficial] */
480 ABSOLUTE_X; 480 ABSOLUTE_X;
481 LSE; 481 LSE;
482 break; 482 break;
483 case 0x63: /* RRA (ab,x) [unofficial] */ 483 case 0x63: /* RRA (ab,x) [unofficial] */
484 INDIRECT_X; 484 INDIRECT_X;
485 RRA; 485 RRA;
486 break; 486 break;
487 case 0x67: /* RRA ab [unofficial] */ 487 case 0x67: /* RRA ab [unofficial] */
488 ZPAGE; 488 ZPAGE;
489 RRA_ZP; 489 RRA_ZP;
490 break; 490 break;
491 case 0x6b: /* ARR #ab [unofficial] */ 491 case 0x6b: /* ARR #ab [unofficial] */
492 data = a & FETCH; 492 data = a & FETCH;
493 nz = a = (data >> 1) + (c << 7); 493 nz = a = (data >> 1) + (c << 7);
494 vdi = (vdi & (D_FLAG | I_FLAG)) + ((a ^ data) & V_FLAG); 494 vdi = (vdi & (D_FLAG | I_FLAG)) + ((a ^ data) & V_FLAG);
495#ifdef ACPU_NO_DECIMAL 495#ifdef ACPU_NO_DECIMAL
496 c = data >> 7; 496 c = data >> 7;
497#else 497#else
498 if ((vdi & D_FLAG) == 0) 498 if ((vdi & D_FLAG) == 0)
499 c = data >> 7; 499 c = data >> 7;
500 else { 500 else {
501 if ((data & 0xf) >= 5) 501 if ((data & 0xf) >= 5)
502 a = (a & 0xf0) + ((a + 6) & 0xf); 502 a = (a & 0xf0) + ((a + 6) & 0xf);
503 if (data >= 0x50) { 503 if (data >= 0x50) {
504 a = (a + 0x60) & 0xff; 504 a = (a + 0x60) & 0xff;
505 c = 1; 505 c = 1;
506 } 506 }
507 else 507 else
508 c = 0; 508 c = 0;
509 } 509 }
510#endif 510#endif
511 break; 511 break;
512 case 0x6f: /* RRA abcd [unofficial] */ 512 case 0x6f: /* RRA abcd [unofficial] */
513 ABSOLUTE; 513 ABSOLUTE;
514 RRA; 514 RRA;
515 break; 515 break;
516 case 0x73: /* RRA (ab),y [unofficial] */ 516 case 0x73: /* RRA (ab),y [unofficial] */
517 INDIRECT_Y; 517 INDIRECT_Y;
518 RRA; 518 RRA;
519 break; 519 break;
520 case 0x77: /* RRA ab,x [unofficial] */ 520 case 0x77: /* RRA ab,x [unofficial] */
521 ZPAGE_X; 521 ZPAGE_X;
522 RRA_ZP; 522 RRA_ZP;
523 break; 523 break;
524 case 0x7b: /* RRA abcd,y [unofficial] */ 524 case 0x7b: /* RRA abcd,y [unofficial] */
525 ABSOLUTE_Y; 525 ABSOLUTE_Y;
526 RRA; 526 RRA;
527 break; 527 break;
528 case 0x7f: /* RRA abcd,x [unofficial] */ 528 case 0x7f: /* RRA abcd,x [unofficial] */
529 ABSOLUTE_X; 529 ABSOLUTE_X;
530 RRA; 530 RRA;
531 break; 531 break;
532 case 0x83: /* SAX (ab,x) [unofficial] */ 532 case 0x83: /* SAX (ab,x) [unofficial] */
533 INDIRECT_X; 533 INDIRECT_X;
534 SAX; 534 SAX;
535 break; 535 break;
536 case 0x87: /* SAX ab [unofficial] */ 536 case 0x87: /* SAX ab [unofficial] */
537 ZPAGE; 537 ZPAGE;
538 SAX_ZP; 538 SAX_ZP;
539 break; 539 break;
540 case 0x8b: /* ANE #ab [unofficial] */ 540 case 0x8b: /* ANE #ab [unofficial] */
541 data = FETCH; 541 data = FETCH;
542 a &= x; 542 a &= x;
543 nz = a & data; 543 nz = a & data;
544 a &= data | 0xef; 544 a &= data | 0xef;
545 break; 545 break;
546 case 0x8f: /* SAX abcd [unofficial] */ 546 case 0x8f: /* SAX abcd [unofficial] */
547 ABSOLUTE; 547 ABSOLUTE;
548 SAX; 548 SAX;
549 break; 549 break;
550 case 0x93: /* SHA (ab),y [unofficial, unstable] */ 550 case 0x93: /* SHA (ab),y [unofficial, unstable] */
551 ZPAGE; 551 ZPAGE;
552 data = zGetByte(addr + 1); 552 data = zGetByte(addr + 1);
553 addr = (dGetByte(addr) + (data << 8) + y) & 0xffff; 553 addr = (dGetByte(addr) + (data << 8) + y) & 0xffff;
554 data = a & x & (data + 1); 554 data = a & x & (data + 1);
555 PutByte(addr, data); 555 PutByte(addr, data);
556 break; 556 break;
557 case 0x97: /* SAX ab,y [unofficial] */ 557 case 0x97: /* SAX ab,y [unofficial] */
558 ZPAGE_Y; 558 ZPAGE_Y;
559 SAX_ZP; 559 SAX_ZP;
560 break; 560 break;
561 case 0x9b: /* SHS abcd,y [unofficial, unstable] */ 561 case 0x9b: /* SHS abcd,y [unofficial, unstable] */
562 /* S seems to be stable, only memory values vary */ 562 /* S seems to be stable, only memory values vary */
563 addr = FETCH; 563 addr = FETCH;
564 data = FETCH; 564 data = FETCH;
565 addr = (addr + (data << 8) + y) & 0xffff; 565 addr = (addr + (data << 8) + y) & 0xffff;
566 s = a & x; 566 s = a & x;
567 data = s & (data + 1); 567 data = s & (data + 1);
568 PutByte(addr, data); 568 PutByte(addr, data);
569 break; 569 break;
570 case 0x9c: /* SHY abcd,x [unofficial] */ 570 case 0x9c: /* SHY abcd,x [unofficial] */
571 addr = FETCH; 571 addr = FETCH;
572 data = FETCH; 572 data = FETCH;
573 addr = (addr + (data << 8) + x) & 0xffff; 573 addr = (addr + (data << 8) + x) & 0xffff;
574 data = y & (data + 1); 574 data = y & (data + 1);
575 PutByte(addr, data); 575 PutByte(addr, data);
576 break; 576 break;
577 case 0x9e: /* SHX abcd,y [unofficial] */ 577 case 0x9e: /* SHX abcd,y [unofficial] */
578 addr = FETCH; 578 addr = FETCH;
579 data = FETCH; 579 data = FETCH;
580 addr = (addr + (data << 8) + y) & 0xffff; 580 addr = (addr + (data << 8) + y) & 0xffff;
581 data = x & (data + 1); 581 data = x & (data + 1);
582 PutByte(addr, data); 582 PutByte(addr, data);
583 break; 583 break;
584 case 0x9f: /* SHA abcd,y [unofficial, unstable] */ 584 case 0x9f: /* SHA abcd,y [unofficial, unstable] */
585 addr = FETCH; 585 addr = FETCH;
586 data = FETCH; 586 data = FETCH;
587 addr = (addr + (data << 8) + y) & 0xffff; 587 addr = (addr + (data << 8) + y) & 0xffff;
588 data = a & x & (data + 1); 588 data = a & x & (data + 1);
589 PutByte(addr, data); 589 PutByte(addr, data);
590 break; 590 break;
591 case 0xa3: /* LAX (ab,x) [unofficial] */ 591 case 0xa3: /* LAX (ab,x) [unofficial] */
592 INDIRECT_X; 592 INDIRECT_X;
593 LAX; 593 LAX;
594 break; 594 break;
595 case 0xa7: /* LAX ab [unofficial] */ 595 case 0xa7: /* LAX ab [unofficial] */
596 ZPAGE; 596 ZPAGE;
597 LAX_ZP; 597 LAX_ZP;
598 break; 598 break;
599 case 0xab: /* ANX #ab [unofficial] */ 599 case 0xab: /* ANX #ab [unofficial] */
600 nz = x = a &= FETCH; 600 nz = x = a &= FETCH;
601 break; 601 break;
602 case 0xaf: /* LAX abcd [unofficial] */ 602 case 0xaf: /* LAX abcd [unofficial] */
603 ABSOLUTE; 603 ABSOLUTE;
604 LAX; 604 LAX;
605 break; 605 break;
606 case 0xb3: /* LAX (ab),y [unofficial] */ 606 case 0xb3: /* LAX (ab),y [unofficial] */
607 INDIRECT_Y; 607 INDIRECT_Y;
608 NCYCLES_Y; 608 NCYCLES_Y;
609 LAX; 609 LAX;
610 break; 610 break;
611 case 0xb7: /* LAX ab,y [unofficial] */ 611 case 0xb7: /* LAX ab,y [unofficial] */
612 ZPAGE_Y; 612 ZPAGE_Y;
613 LAX_ZP; 613 LAX_ZP;
614 break; 614 break;
615 case 0xbb: /* LAS abcd,y [unofficial] */ 615 case 0xbb: /* LAS abcd,y [unofficial] */
616 ABSOLUTE_Y; 616 ABSOLUTE_Y;
617 NCYCLES_Y; 617 NCYCLES_Y;
618 nz = x = a = s &= GetByte(addr); 618 nz = x = a = s &= GetByte(addr);
619 break; 619 break;
620 case 0xbf: /* LAX abcd,y [unofficial] */ 620 case 0xbf: /* LAX abcd,y [unofficial] */
621 ABSOLUTE_Y; 621 ABSOLUTE_Y;
622 NCYCLES_Y; 622 NCYCLES_Y;
623 LAX; 623 LAX;
624 break; 624 break;
625 case 0xc3: /* DCM (ab,x) [unofficial] */ 625 case 0xc3: /* DCM (ab,x) [unofficial] */
626 INDIRECT_X; 626 INDIRECT_X;
627 DCM; 627 DCM;
628 break; 628 break;
629 case 0xc7: /* DCM ab [unofficial] */ 629 case 0xc7: /* DCM ab [unofficial] */
630 ZPAGE; 630 ZPAGE;
631 DCM_ZP; 631 DCM_ZP;
632 break; 632 break;
633 case 0xcb: /* SBX #ab [unofficial] */ 633 case 0xcb: /* SBX #ab [unofficial] */
634 nz = FETCH; 634 nz = FETCH;
635 x &= a; 635 x &= a;
636 c = (x >= nz) ? 1 : 0; 636 c = (x >= nz) ? 1 : 0;
637 nz = x = (x - nz) & 0xff; 637 nz = x = (x - nz) & 0xff;
638 break; 638 break;
639 case 0xcf: /* DCM abcd [unofficial] */ 639 case 0xcf: /* DCM abcd [unofficial] */
640 ABSOLUTE; 640 ABSOLUTE;
641 DCM; 641 DCM;
642 break; 642 break;
643 case 0xd3: /* DCM (ab),y [unofficial] */ 643 case 0xd3: /* DCM (ab),y [unofficial] */
644 INDIRECT_Y; 644 INDIRECT_Y;
645 DCM; 645 DCM;
646 break; 646 break;
647 case 0xd7: /* DCM ab,x [unofficial] */ 647 case 0xd7: /* DCM ab,x [unofficial] */
648 ZPAGE_X; 648 ZPAGE_X;
649 DCM_ZP; 649 DCM_ZP;
650 break; 650 break;
651 case 0xdb: /* DCM abcd,y [unofficial] */ 651 case 0xdb: /* DCM abcd,y [unofficial] */
652 ABSOLUTE_Y; 652 ABSOLUTE_Y;
653 DCM; 653 DCM;
654 break; 654 break;
655 case 0xdf: /* DCM abcd,x [unofficial] */ 655 case 0xdf: /* DCM abcd,x [unofficial] */
656 ABSOLUTE_X; 656 ABSOLUTE_X;
657 DCM; 657 DCM;
658 break; 658 break;
659 case 0xe3: /* INS (ab,x) [unofficial] */ 659 case 0xe3: /* INS (ab,x) [unofficial] */
660 INDIRECT_X; 660 INDIRECT_X;
661 INS; 661 INS;
662 break; 662 break;
663 case 0xe7: /* INS ab [unofficial] */ 663 case 0xe7: /* INS ab [unofficial] */
664 ZPAGE; 664 ZPAGE;
665 INS_ZP; 665 INS_ZP;
666 break; 666 break;
667 case 0xef: /* INS abcd [unofficial] */ 667 case 0xef: /* INS abcd [unofficial] */
668 ABSOLUTE; 668 ABSOLUTE;
669 INS; 669 INS;
670 break; 670 break;
671 case 0xf3: /* INS (ab),y [unofficial] */ 671 case 0xf3: /* INS (ab),y [unofficial] */
672 INDIRECT_Y; 672 INDIRECT_Y;
673 INS; 673 INS;
674 break; 674 break;
675 case 0xf7: /* INS ab,x [unofficial] */ 675 case 0xf7: /* INS ab,x [unofficial] */
676 ZPAGE_X; 676 ZPAGE_X;
677 INS_ZP; 677 INS_ZP;
678 break; 678 break;
679 case 0xfb: /* INS abcd,y [unofficial] */ 679 case 0xfb: /* INS abcd,y [unofficial] */
680 ABSOLUTE_Y; 680 ABSOLUTE_Y;
681 INS; 681 INS;
682 break; 682 break;
683 case 0xff: /* INS abcd,x [unofficial] */ 683 case 0xff: /* INS abcd,x [unofficial] */
684 ABSOLUTE_X; 684 ABSOLUTE_X;
685 INS; 685 INS;
686 break; 686 break;
687#endif /* ACPU_NO_UNOFFICIAL */ 687#endif /* ACPU_NO_UNOFFICIAL */
688 case 0x05: /* ORA ab */ 688 case 0x05: /* ORA ab */
689 ZPAGE; 689 ZPAGE;
690 ORA_ZP; 690 ORA_ZP;
691 break; 691 break;
692 case 0x06: /* ASL ab */ 692 case 0x06: /* ASL ab */
693 ZPAGE; 693 ZPAGE;
694 ASL_ZP; 694 ASL_ZP;
695 break; 695 break;
696 case 0x08: /* PHP */ 696 case 0x08: /* PHP */
697 PHPB1; 697 PHPB1;
698 break; 698 break;
699 case 0x09: /* ORA #ab */ 699 case 0x09: /* ORA #ab */
700 nz = a |= FETCH; 700 nz = a |= FETCH;
701 break; 701 break;
702 case 0x0a: /* ASL */ 702 case 0x0a: /* ASL */
703 c = a >> 7; 703 c = a >> 7;
704 nz = a = (a << 1) & 0xff; 704 nz = a = (a << 1) & 0xff;
705 break; 705 break;
706 case 0x0d: /* ORA abcd */ 706 case 0x0d: /* ORA abcd */
707 ABSOLUTE; 707 ABSOLUTE;
708 ORA; 708 ORA;
709 break; 709 break;
710 case 0x0e: /* ASL abcd */ 710 case 0x0e: /* ASL abcd */
711 ABSOLUTE; 711 ABSOLUTE;
712 ASL; 712 ASL;
713 break; 713 break;
714 case 0x10: /* BPL */ 714 case 0x10: /* BPL */
715 BRANCH(nz < 0x80); 715 BRANCH(nz < 0x80);
716 case 0x11: /* ORA (ab),y */ 716 case 0x11: /* ORA (ab),y */
717 INDIRECT_Y; 717 INDIRECT_Y;
718 NCYCLES_Y; 718 NCYCLES_Y;
719 ORA; 719 ORA;
720 break; 720 break;
721 case 0x15: /* ORA ab,x */ 721 case 0x15: /* ORA ab,x */
722 ZPAGE_X; 722 ZPAGE_X;
723 ORA_ZP; 723 ORA_ZP;
724 break; 724 break;
725 case 0x16: /* ASL ab,x */ 725 case 0x16: /* ASL ab,x */
726 ZPAGE_X; 726 ZPAGE_X;
727 ASL_ZP; 727 ASL_ZP;
728 break; 728 break;
729 case 0x18: /* CLC */ 729 case 0x18: /* CLC */
730 c = 0; 730 c = 0;
731 break; 731 break;
732 case 0x19: /* ORA abcd,y */ 732 case 0x19: /* ORA abcd,y */
733 ABSOLUTE_Y; 733 ABSOLUTE_Y;
734 NCYCLES_Y; 734 NCYCLES_Y;
735 ORA; 735 ORA;
736 break; 736 break;
737 case 0x1d: /* ORA abcd,x */ 737 case 0x1d: /* ORA abcd,x */
738 ABSOLUTE_X; 738 ABSOLUTE_X;
739 NCYCLES_X; 739 NCYCLES_X;
740 ORA; 740 ORA;
741 break; 741 break;
742 case 0x1e: /* ASL abcd,x */ 742 case 0x1e: /* ASL abcd,x */
743 ABSOLUTE_X; 743 ABSOLUTE_X;
744 ASL; 744 ASL;
745 break; 745 break;
746 case 0x20: /* JSR abcd */ 746 case 0x20: /* JSR abcd */
747 addr = FETCH; 747 addr = FETCH;
748 PHPC; 748 PHPC;
749 pc = addr + (PEEK << 8); 749 pc = addr + (PEEK << 8);
750 break; 750 break;
751 case 0x21: /* AND (ab,x) */ 751 case 0x21: /* AND (ab,x) */
752 INDIRECT_X; 752 INDIRECT_X;
753 AND; 753 AND;
754 break; 754 break;
755 case 0x24: /* BIT ab */ 755 case 0x24: /* BIT ab */
756 ZPAGE; 756 ZPAGE;
757 nz = dGetByte(addr); 757 nz = dGetByte(addr);
758 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); 758 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG);
759 nz = ((nz & 0x80) << 1) + (nz & a); 759 nz = ((nz & 0x80) << 1) + (nz & a);
760 break; 760 break;
761 case 0x25: /* AND ab */ 761 case 0x25: /* AND ab */
762 ZPAGE; 762 ZPAGE;
763 AND_ZP; 763 AND_ZP;
764 break; 764 break;
765 case 0x26: /* ROL ab */ 765 case 0x26: /* ROL ab */
766 ZPAGE; 766 ZPAGE;
767 ROL_ZP; 767 ROL_ZP;
768 break; 768 break;
769 case 0x28: /* PLP */ 769 case 0x28: /* PLP */
770 PLP; 770 PLP;
771 CHECK_IRQ; 771 CHECK_IRQ;
772 break; 772 break;
773 case 0x29: /* AND #ab */ 773 case 0x29: /* AND #ab */
774 nz = a &= FETCH; 774 nz = a &= FETCH;
775 break; 775 break;
776 case 0x2a: /* ROL */ 776 case 0x2a: /* ROL */
777 a = (a << 1) + c; 777 a = (a << 1) + c;
778 c = a >> 8; 778 c = a >> 8;
779 nz = a &= 0xff; 779 nz = a &= 0xff;
780 break; 780 break;
781 case 0x2c: /* BIT abcd */ 781 case 0x2c: /* BIT abcd */
782 ABSOLUTE; 782 ABSOLUTE;
783 nz = GetByte(addr); 783 nz = GetByte(addr);
784 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); 784 vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG);
785 nz = ((nz & 0x80) << 1) + (nz & a); 785 nz = ((nz & 0x80) << 1) + (nz & a);
786 break; 786 break;
787 case 0x2d: /* AND abcd */ 787 case 0x2d: /* AND abcd */
788 ABSOLUTE; 788 ABSOLUTE;
789 AND; 789 AND;
790 break; 790 break;
791 case 0x2e: /* ROL abcd */ 791 case 0x2e: /* ROL abcd */
792 ABSOLUTE; 792 ABSOLUTE;
793 ROL; 793 ROL;
794 break; 794 break;
795 case 0x30: /* BMI */ 795 case 0x30: /* BMI */
796 BRANCH(nz >= 0x80); 796 BRANCH(nz >= 0x80);
797 case 0x31: /* AND (ab),y */ 797 case 0x31: /* AND (ab),y */
798 INDIRECT_Y; 798 INDIRECT_Y;
799 NCYCLES_Y; 799 NCYCLES_Y;
800 AND; 800 AND;
801 break; 801 break;
802 case 0x35: /* AND ab,x */ 802 case 0x35: /* AND ab,x */
803 ZPAGE_X; 803 ZPAGE_X;
804 AND_ZP; 804 AND_ZP;
805 break; 805 break;
806 case 0x36: /* ROL ab,x */ 806 case 0x36: /* ROL ab,x */
807 ZPAGE_X; 807 ZPAGE_X;
808 ROL_ZP; 808 ROL_ZP;
809 break; 809 break;
810 case 0x38: /* SEC */ 810 case 0x38: /* SEC */
811 c = 1; 811 c = 1;
812 break; 812 break;
813 case 0x39: /* AND abcd,y */ 813 case 0x39: /* AND abcd,y */
814 ABSOLUTE_Y; 814 ABSOLUTE_Y;
815 NCYCLES_Y; 815 NCYCLES_Y;
816 AND; 816 AND;
817 break; 817 break;
818 case 0x3d: /* AND abcd,x */ 818 case 0x3d: /* AND abcd,x */
819 ABSOLUTE_X; 819 ABSOLUTE_X;
820 NCYCLES_X; 820 NCYCLES_X;
821 AND; 821 AND;
822 break; 822 break;
823 case 0x3e: /* ROL abcd,x */ 823 case 0x3e: /* ROL abcd,x */
824 ABSOLUTE_X; 824 ABSOLUTE_X;
825 ROL; 825 ROL;
826 break; 826 break;
827 case 0x40: /* RTI */ 827 case 0x40: /* RTI */
828 PLP; 828 PLP;
829 PL(pc); 829 PL(pc);
830 PL(addr); 830 PL(addr);
831 pc += addr << 8; 831 pc += addr << 8;
832 CHECK_IRQ; 832 CHECK_IRQ;
833 break; 833 break;
834 case 0x41: /* EOR (ab,x) */ 834 case 0x41: /* EOR (ab,x) */
835 INDIRECT_X; 835 INDIRECT_X;
836 EOR; 836 EOR;
837 break; 837 break;
838 case 0x45: /* EOR ab */ 838 case 0x45: /* EOR ab */
839 ZPAGE; 839 ZPAGE;
840 EOR_ZP; 840 EOR_ZP;
841 break; 841 break;
842 case 0x46: /* LSR ab */ 842 case 0x46: /* LSR ab */
843 ZPAGE; 843 ZPAGE;
844 LSR_ZP; 844 LSR_ZP;
845 break; 845 break;
846 case 0x48: /* PHA */ 846 case 0x48: /* PHA */
847 PH(a); 847 PH(a);
848 break; 848 break;
849 case 0x49: /* EOR #ab */ 849 case 0x49: /* EOR #ab */
850 nz = a ^= FETCH; 850 nz = a ^= FETCH;
851 break; 851 break;
852 case 0x4a: /* LSR */ 852 case 0x4a: /* LSR */
853 c = a & 1; 853 c = a & 1;
854 nz = a >>= 1; 854 nz = a >>= 1;
855 break; 855 break;
856 case 0x4c: /* JMP abcd */ 856 case 0x4c: /* JMP abcd */
857 addr = FETCH; 857 addr = FETCH;
858 pc = addr + (PEEK << 8); 858 pc = addr + (PEEK << 8);
859 break; 859 break;
860 case 0x4d: /* EOR abcd */ 860 case 0x4d: /* EOR abcd */
861 ABSOLUTE; 861 ABSOLUTE;
862 EOR; 862 EOR;
863 break; 863 break;
864 case 0x4e: /* LSR abcd */ 864 case 0x4e: /* LSR abcd */
865 ABSOLUTE; 865 ABSOLUTE;
866 LSR; 866 LSR;
867 break; 867 break;
868 case 0x50: /* BVC */ 868 case 0x50: /* BVC */
869 BRANCH((vdi & V_FLAG) == 0); 869 BRANCH((vdi & V_FLAG) == 0);
870 case 0x51: /* EOR (ab),y */ 870 case 0x51: /* EOR (ab),y */
871 INDIRECT_Y; 871 INDIRECT_Y;
872 NCYCLES_Y; 872 NCYCLES_Y;
873 EOR; 873 EOR;
874 break; 874 break;
875 case 0x55: /* EOR ab,x */ 875 case 0x55: /* EOR ab,x */
876 ZPAGE_X; 876 ZPAGE_X;
877 EOR_ZP; 877 EOR_ZP;
878 break; 878 break;
879 case 0x56: /* LSR ab,x */ 879 case 0x56: /* LSR ab,x */
880 ZPAGE_X; 880 ZPAGE_X;
881 LSR_ZP; 881 LSR_ZP;
882 break; 882 break;
883 case 0x58: /* CLI */ 883 case 0x58: /* CLI */
884 vdi &= V_FLAG | D_FLAG; 884 vdi &= V_FLAG | D_FLAG;
885 CHECK_IRQ; 885 CHECK_IRQ;
886 break; 886 break;
887 case 0x59: /* EOR abcd,y */ 887 case 0x59: /* EOR abcd,y */
888 ABSOLUTE_Y; 888 ABSOLUTE_Y;
889 NCYCLES_Y; 889 NCYCLES_Y;
890 EOR; 890 EOR;
891 break; 891 break;
892 case 0x5d: /* EOR abcd,x */ 892 case 0x5d: /* EOR abcd,x */
893 ABSOLUTE_X; 893 ABSOLUTE_X;
894 NCYCLES_X; 894 NCYCLES_X;
895 EOR; 895 EOR;
896 break; 896 break;
897 case 0x5e: /* LSR abcd,x */ 897 case 0x5e: /* LSR abcd,x */
898 ABSOLUTE_X; 898 ABSOLUTE_X;
899 LSR; 899 LSR;
900 break; 900 break;
901 case 0x60: /* RTS */ 901 case 0x60: /* RTS */
902 PL(pc); 902 PL(pc);
903 PL(addr); 903 PL(addr);
904 pc += (addr << 8) + 1; 904 pc += (addr << 8) + 1;
905 break; 905 break;
906 case 0x61: /* ADC (ab,x) */ 906 case 0x61: /* ADC (ab,x) */
907 INDIRECT_X; 907 INDIRECT_X;
908 ADC; 908 ADC;
909 break; 909 break;
910 case 0x65: /* ADC ab */ 910 case 0x65: /* ADC ab */
911 ZPAGE; 911 ZPAGE;
912 ADC_ZP; 912 ADC_ZP;
913 break; 913 break;
914 case 0x66: /* ROR ab */ 914 case 0x66: /* ROR ab */
915 ZPAGE; 915 ZPAGE;
916 ROR_ZP; 916 ROR_ZP;
917 break; 917 break;
918 case 0x68: /* PLA */ 918 case 0x68: /* PLA */
919 PL(a); 919 PL(a);
920 nz = a; 920 nz = a;
921 break; 921 break;
922 case 0x69: /* ADC #ab */ 922 case 0x69: /* ADC #ab */
923 data = FETCH; 923 data = FETCH;
924 DO_ADC; 924 DO_ADC;
925 break; 925 break;
926 case 0x6a: /* ROR */ 926 case 0x6a: /* ROR */
927 nz = (c << 7) + (a >> 1); 927 nz = (c << 7) + (a >> 1);
928 c = a & 1; 928 c = a & 1;
929 a = nz; 929 a = nz;
930 break; 930 break;
931 case 0x6c: /* JMP (abcd) */ 931 case 0x6c: /* JMP (abcd) */
932 ABSOLUTE; 932 ABSOLUTE;
933 if ((addr & 0xff) == 0xff) 933 if ((addr & 0xff) == 0xff)
934 pc = (dGetByte(addr - 0xff) << 8) + dGetByte(addr); 934 pc = (dGetByte(addr - 0xff) << 8) + dGetByte(addr);
935 else 935 else
936 pc = dGetWord(addr); 936 pc = dGetWord(addr);
937 break; 937 break;
938 case 0x6d: /* ADC abcd */ 938 case 0x6d: /* ADC abcd */
939 ABSOLUTE; 939 ABSOLUTE;
940 ADC; 940 ADC;
941 break; 941 break;
942 case 0x6e: /* ROR abcd */ 942 case 0x6e: /* ROR abcd */
943 ABSOLUTE; 943 ABSOLUTE;
944 ROR; 944 ROR;
945 break; 945 break;
946 case 0x70: /* BVS */ 946 case 0x70: /* BVS */
947 BRANCH((vdi & V_FLAG) != 0); 947 BRANCH((vdi & V_FLAG) != 0);
948 case 0x71: /* ADC (ab),y */ 948 case 0x71: /* ADC (ab),y */
949 INDIRECT_Y; 949 INDIRECT_Y;
950 NCYCLES_Y; 950 NCYCLES_Y;
951 ADC; 951 ADC;
952 break; 952 break;
953 case 0x75: /* ADC ab,x */ 953 case 0x75: /* ADC ab,x */
954 ZPAGE_X; 954 ZPAGE_X;
955 ADC_ZP; 955 ADC_ZP;
956 break; 956 break;
957 case 0x76: /* ROR ab,x */ 957 case 0x76: /* ROR ab,x */
958 ZPAGE_X; 958 ZPAGE_X;
959 ROR_ZP; 959 ROR_ZP;
960 break; 960 break;
961 case 0x78: /* SEI */ 961 case 0x78: /* SEI */
962 vdi |= I_FLAG; 962 vdi |= I_FLAG;
963 break; 963 break;
964 case 0x79: /* ADC abcd,y */ 964 case 0x79: /* ADC abcd,y */
965 ABSOLUTE_Y; 965 ABSOLUTE_Y;
966 NCYCLES_Y; 966 NCYCLES_Y;
967 ADC; 967 ADC;
968 break; 968 break;
969 case 0x7d: /* ADC abcd,x */ 969 case 0x7d: /* ADC abcd,x */
970 ABSOLUTE_X; 970 ABSOLUTE_X;
971 NCYCLES_X; 971 NCYCLES_X;
972 ADC; 972 ADC;
973 break; 973 break;
974 case 0x7e: /* ROR abcd,x */ 974 case 0x7e: /* ROR abcd,x */
975 ABSOLUTE_X; 975 ABSOLUTE_X;
976 ROR; 976 ROR;
977 break; 977 break;
978 case 0x81: /* STA (ab,x) */ 978 case 0x81: /* STA (ab,x) */
979 INDIRECT_X; 979 INDIRECT_X;
980 STA; 980 STA;
981 break; 981 break;
982 case 0x84: /* STY ab */ 982 case 0x84: /* STY ab */
983 ZPAGE; 983 ZPAGE;
984 STY_ZP; 984 STY_ZP;
985 break; 985 break;
986 case 0x85: /* STA ab */ 986 case 0x85: /* STA ab */
987 ZPAGE; 987 ZPAGE;
988 STA_ZP; 988 STA_ZP;
989 break; 989 break;
990 case 0x86: /* STX ab */ 990 case 0x86: /* STX ab */
991 ZPAGE; 991 ZPAGE;
992 STX_ZP; 992 STX_ZP;
993 break; 993 break;
994 case 0x88: /* DEY */ 994 case 0x88: /* DEY */
995 nz = y = (y - 1) & 0xff; 995 nz = y = (y - 1) & 0xff;
996 break; 996 break;
997 case 0x8a: /* TXA */ 997 case 0x8a: /* TXA */
998 nz = a = x; 998 nz = a = x;
999 break; 999 break;
1000 case 0x8c: /* STY abcd */ 1000 case 0x8c: /* STY abcd */
1001 ABSOLUTE; 1001 ABSOLUTE;
1002 STY; 1002 STY;
1003 break; 1003 break;
1004 case 0x8d: /* STA abcd */ 1004 case 0x8d: /* STA abcd */
1005 ABSOLUTE; 1005 ABSOLUTE;
1006 STA; 1006 STA;
1007 break; 1007 break;
1008 case 0x8e: /* STX abcd */ 1008 case 0x8e: /* STX abcd */
1009 ABSOLUTE; 1009 ABSOLUTE;
1010 STX; 1010 STX;
1011 break; 1011 break;
1012 case 0x90: /* BCC */ 1012 case 0x90: /* BCC */
1013 BRANCH(c == 0); 1013 BRANCH(c == 0);
1014 case 0x91: /* STA (ab),y */ 1014 case 0x91: /* STA (ab),y */
1015 INDIRECT_Y; 1015 INDIRECT_Y;
1016 STA; 1016 STA;
1017 break; 1017 break;
1018 case 0x94: /* STY ab,x */ 1018 case 0x94: /* STY ab,x */
1019 ZPAGE_X; 1019 ZPAGE_X;
1020 STY_ZP; 1020 STY_ZP;
1021 break; 1021 break;
1022 case 0x95: /* STA ab,x */ 1022 case 0x95: /* STA ab,x */
1023 ZPAGE_X; 1023 ZPAGE_X;
1024 STA_ZP; 1024 STA_ZP;
1025 break; 1025 break;
1026 case 0x96: /* STX ab,y */ 1026 case 0x96: /* STX ab,y */
1027 ZPAGE_Y; 1027 ZPAGE_Y;
1028 STX_ZP; 1028 STX_ZP;
1029 break; 1029 break;
1030 case 0x98: /* TYA */ 1030 case 0x98: /* TYA */
1031 nz = a = y; 1031 nz = a = y;
1032 break; 1032 break;
1033 case 0x99: /* STA abcd,y */ 1033 case 0x99: /* STA abcd,y */
1034 ABSOLUTE_Y; 1034 ABSOLUTE_Y;
1035 STA; 1035 STA;
1036 break; 1036 break;
1037 case 0x9a: /* TXS */ 1037 case 0x9a: /* TXS */
1038 s = x; 1038 s = x;
1039 break; 1039 break;
1040 case 0x9d: /* STA abcd,x */ 1040 case 0x9d: /* STA abcd,x */
1041 ABSOLUTE_X; 1041 ABSOLUTE_X;
1042 STA; 1042 STA;
1043 break; 1043 break;
1044 case 0xa0: /* LDY #ab */ 1044 case 0xa0: /* LDY #ab */
1045 nz = y = FETCH; 1045 nz = y = FETCH;
1046 break; 1046 break;
1047 case 0xa1: /* LDA (ab,x) */ 1047 case 0xa1: /* LDA (ab,x) */
1048 INDIRECT_X; 1048 INDIRECT_X;
1049 LDA; 1049 LDA;
1050 break; 1050 break;
1051 case 0xa2: /* LDX #ab */ 1051 case 0xa2: /* LDX #ab */
1052 nz = x = FETCH; 1052 nz = x = FETCH;
1053 break; 1053 break;
1054 case 0xa4: /* LDY ab */ 1054 case 0xa4: /* LDY ab */
1055 ZPAGE; 1055 ZPAGE;
1056 LDY_ZP; 1056 LDY_ZP;
1057 break; 1057 break;
1058 case 0xa5: /* LDA ab */ 1058 case 0xa5: /* LDA ab */
1059 ZPAGE; 1059 ZPAGE;
1060 LDA_ZP; 1060 LDA_ZP;
1061 break; 1061 break;
1062 case 0xa6: /* LDX ab */ 1062 case 0xa6: /* LDX ab */
1063 ZPAGE; 1063 ZPAGE;
1064 LDX_ZP; 1064 LDX_ZP;
1065 break; 1065 break;
1066 case 0xa8: /* TAY */ 1066 case 0xa8: /* TAY */
1067 nz = y = a; 1067 nz = y = a;
1068 break; 1068 break;
1069 case 0xa9: /* LDA #ab */ 1069 case 0xa9: /* LDA #ab */
1070 nz = a = FETCH; 1070 nz = a = FETCH;
1071 break; 1071 break;
1072 case 0xaa: /* TAX */ 1072 case 0xaa: /* TAX */
1073 nz = x = a; 1073 nz = x = a;
1074 break; 1074 break;
1075 case 0xac: /* LDY abcd */ 1075 case 0xac: /* LDY abcd */
1076 ABSOLUTE; 1076 ABSOLUTE;
1077 LDY; 1077 LDY;
1078 break; 1078 break;
1079 case 0xad: /* LDA abcd */ 1079 case 0xad: /* LDA abcd */
1080 ABSOLUTE; 1080 ABSOLUTE;
1081 LDA; 1081 LDA;
1082 break; 1082 break;
1083 case 0xae: /* LDX abcd */ 1083 case 0xae: /* LDX abcd */
1084 ABSOLUTE; 1084 ABSOLUTE;
1085 LDX; 1085 LDX;
1086 break; 1086 break;
1087 case 0xb0: /* BCS */ 1087 case 0xb0: /* BCS */
1088 BRANCH(c != 0); 1088 BRANCH(c != 0);
1089 case 0xb1: /* LDA (ab),y */ 1089 case 0xb1: /* LDA (ab),y */
1090 INDIRECT_Y; 1090 INDIRECT_Y;
1091 NCYCLES_Y; 1091 NCYCLES_Y;
1092 LDA; 1092 LDA;
1093 break; 1093 break;
1094 case 0xb4: /* LDY ab,x */ 1094 case 0xb4: /* LDY ab,x */
1095 ZPAGE_X; 1095 ZPAGE_X;
1096 LDY_ZP; 1096 LDY_ZP;
1097 break; 1097 break;
1098 case 0xb5: /* LDA ab,x */ 1098 case 0xb5: /* LDA ab,x */
1099 ZPAGE_X; 1099 ZPAGE_X;
1100 LDA_ZP; 1100 LDA_ZP;
1101 break; 1101 break;
1102 case 0xb6: /* LDX ab,y */ 1102 case 0xb6: /* LDX ab,y */
1103 ZPAGE_Y; 1103 ZPAGE_Y;
1104 LDX_ZP; 1104 LDX_ZP;
1105 break; 1105 break;
1106 case 0xb8: /* CLV */ 1106 case 0xb8: /* CLV */
1107 vdi &= D_FLAG | I_FLAG; 1107 vdi &= D_FLAG | I_FLAG;
1108 break; 1108 break;
1109 case 0xb9: /* LDA abcd,y */ 1109 case 0xb9: /* LDA abcd,y */
1110 ABSOLUTE_Y; 1110 ABSOLUTE_Y;
1111 NCYCLES_Y; 1111 NCYCLES_Y;
1112 LDA; 1112 LDA;
1113 break; 1113 break;
1114 case 0xba: /* TSX */ 1114 case 0xba: /* TSX */
1115 nz = x = s; 1115 nz = x = s;
1116 break; 1116 break;
1117 case 0xbc: /* LDY abcd,x */ 1117 case 0xbc: /* LDY abcd,x */
1118 ABSOLUTE_X; 1118 ABSOLUTE_X;
1119 NCYCLES_X; 1119 NCYCLES_X;
1120 LDY; 1120 LDY;
1121 break; 1121 break;
1122 case 0xbd: /* LDA abcd,x */ 1122 case 0xbd: /* LDA abcd,x */
1123 ABSOLUTE_X; 1123 ABSOLUTE_X;
1124 NCYCLES_X; 1124 NCYCLES_X;
1125 LDA; 1125 LDA;
1126 break; 1126 break;
1127 case 0xbe: /* LDX abcd,y */ 1127 case 0xbe: /* LDX abcd,y */
1128 ABSOLUTE_Y; 1128 ABSOLUTE_Y;
1129 NCYCLES_Y; 1129 NCYCLES_Y;
1130 LDX; 1130 LDX;
1131 break; 1131 break;
1132 case 0xc0: /* CPY #ab */ 1132 case 0xc0: /* CPY #ab */
1133 nz = FETCH; 1133 nz = FETCH;
1134 c = (y >= nz) ? 1 : 0; 1134 c = (y >= nz) ? 1 : 0;
1135 nz = (y - nz) & 0xff; 1135 nz = (y - nz) & 0xff;
1136 break; 1136 break;
1137 case 0xc1: /* CMP (ab,x) */ 1137 case 0xc1: /* CMP (ab,x) */
1138 INDIRECT_X; 1138 INDIRECT_X;
1139 CMP; 1139 CMP;
1140 break; 1140 break;
1141 case 0xc4: /* CPY ab */ 1141 case 0xc4: /* CPY ab */
1142 ZPAGE; 1142 ZPAGE;
1143 CPY_ZP; 1143 CPY_ZP;
1144 break; 1144 break;
1145 case 0xc5: /* CMP ab */ 1145 case 0xc5: /* CMP ab */
1146 ZPAGE; 1146 ZPAGE;
1147 CMP_ZP; 1147 CMP_ZP;
1148 break; 1148 break;
1149 case 0xc6: /* DEC ab */ 1149 case 0xc6: /* DEC ab */
1150 ZPAGE; 1150 ZPAGE;
1151 DEC_ZP; 1151 DEC_ZP;
1152 break; 1152 break;
1153 case 0xc8: /* INY */ 1153 case 0xc8: /* INY */
1154 nz = y = (y + 1) & 0xff; 1154 nz = y = (y + 1) & 0xff;
1155 break; 1155 break;
1156 case 0xc9: /* CMP #ab */ 1156 case 0xc9: /* CMP #ab */
1157 nz = FETCH; 1157 nz = FETCH;
1158 c = (a >= nz) ? 1 : 0; 1158 c = (a >= nz) ? 1 : 0;
1159 nz = (a - nz) & 0xff; 1159 nz = (a - nz) & 0xff;
1160 break; 1160 break;
1161 case 0xca: /* DEX */ 1161 case 0xca: /* DEX */
1162 nz = x = (x - 1) & 0xff; 1162 nz = x = (x - 1) & 0xff;
1163 break; 1163 break;
1164 case 0xcc: /* CPY abcd */ 1164 case 0xcc: /* CPY abcd */
1165 ABSOLUTE; 1165 ABSOLUTE;
1166 CPY; 1166 CPY;
1167 break; 1167 break;
1168 case 0xcd: /* CMP abcd */ 1168 case 0xcd: /* CMP abcd */
1169 ABSOLUTE; 1169 ABSOLUTE;
1170 CMP; 1170 CMP;
1171 break; 1171 break;
1172 case 0xce: /* DEC abcd */ 1172 case 0xce: /* DEC abcd */
1173 ABSOLUTE; 1173 ABSOLUTE;
1174 DEC; 1174 DEC;
1175 break; 1175 break;
1176 case 0xd0: /* BNE */ 1176 case 0xd0: /* BNE */
1177 BRANCH((nz & 0xff) != 0); 1177 BRANCH((nz & 0xff) != 0);
1178 case 0xd1: /* CMP (ab),y */ 1178 case 0xd1: /* CMP (ab),y */
1179 INDIRECT_Y; 1179 INDIRECT_Y;
1180 NCYCLES_Y; 1180 NCYCLES_Y;
1181 CMP; 1181 CMP;
1182 break; 1182 break;
1183 case 0xd5: /* CMP ab,x */ 1183 case 0xd5: /* CMP ab,x */
1184 ZPAGE_X; 1184 ZPAGE_X;
1185 CMP_ZP; 1185 CMP_ZP;
1186 break; 1186 break;
1187 case 0xd6: /* DEC ab,x */ 1187 case 0xd6: /* DEC ab,x */
1188 ZPAGE_X; 1188 ZPAGE_X;
1189 DEC_ZP; 1189 DEC_ZP;
1190 break; 1190 break;
1191 case 0xd8: /* CLD */ 1191 case 0xd8: /* CLD */
1192 vdi &= V_FLAG | I_FLAG; 1192 vdi &= V_FLAG | I_FLAG;
1193 break; 1193 break;
1194 case 0xd9: /* CMP abcd,y */ 1194 case 0xd9: /* CMP abcd,y */
1195 ABSOLUTE_Y; 1195 ABSOLUTE_Y;
1196 NCYCLES_Y; 1196 NCYCLES_Y;
1197 CMP; 1197 CMP;
1198 break; 1198 break;
1199 case 0xdd: /* CMP abcd,x */ 1199 case 0xdd: /* CMP abcd,x */
1200 ABSOLUTE_X; 1200 ABSOLUTE_X;
1201 NCYCLES_X; 1201 NCYCLES_X;
1202 CMP; 1202 CMP;
1203 break; 1203 break;
1204 case 0xde: /* DEC abcd,x */ 1204 case 0xde: /* DEC abcd,x */
1205 ABSOLUTE_X; 1205 ABSOLUTE_X;
1206 DEC; 1206 DEC;
1207 break; 1207 break;
1208 case 0xe0: /* CPX #ab */ 1208 case 0xe0: /* CPX #ab */
1209 nz = FETCH; 1209 nz = FETCH;
1210 c = (x >= nz) ? 1 : 0; 1210 c = (x >= nz) ? 1 : 0;
1211 nz = (x - nz) & 0xff; 1211 nz = (x - nz) & 0xff;
1212 break; 1212 break;
1213 case 0xe1: /* SBC (ab,x) */ 1213 case 0xe1: /* SBC (ab,x) */
1214 INDIRECT_X; 1214 INDIRECT_X;
1215 SBC; 1215 SBC;
1216 break; 1216 break;
1217 case 0xe4: /* CPX ab */ 1217 case 0xe4: /* CPX ab */
1218 ZPAGE; 1218 ZPAGE;
1219 CPX_ZP; 1219 CPX_ZP;
1220 break; 1220 break;
1221 case 0xe5: /* SBC ab */ 1221 case 0xe5: /* SBC ab */
1222 ZPAGE; 1222 ZPAGE;
1223 SBC_ZP; 1223 SBC_ZP;
1224 break; 1224 break;
1225 case 0xe6: /* INC ab */ 1225 case 0xe6: /* INC ab */
1226 ZPAGE; 1226 ZPAGE;
1227 INC_ZP; 1227 INC_ZP;
1228 break; 1228 break;
1229 case 0xe8: /* INX */ 1229 case 0xe8: /* INX */
1230 nz = x = (x + 1) & 0xff; 1230 nz = x = (x + 1) & 0xff;
1231 break; 1231 break;
1232 case 0xe9: /* SBC #ab */ 1232 case 0xe9: /* SBC #ab */
1233 case 0xeb: /* SBC #ab [unofficial] */ 1233 case 0xeb: /* SBC #ab [unofficial] */
1234 data = FETCH; 1234 data = FETCH;
1235 DO_SBC; 1235 DO_SBC;
1236 break; 1236 break;
1237 case 0xea: /* NOP */ 1237 case 0xea: /* NOP */
1238 case 0x1a: /* NOP [unofficial] */ 1238 case 0x1a: /* NOP [unofficial] */
1239 case 0x3a: 1239 case 0x3a:
1240 case 0x5a: 1240 case 0x5a:
1241 case 0x7a: 1241 case 0x7a:
1242 case 0xda: 1242 case 0xda:
1243 case 0xfa: 1243 case 0xfa:
1244 break; 1244 break;
1245 case 0xec: /* CPX abcd */ 1245 case 0xec: /* CPX abcd */
1246 ABSOLUTE; 1246 ABSOLUTE;
1247 CPX; 1247 CPX;
1248 break; 1248 break;
1249 case 0xed: /* SBC abcd */ 1249 case 0xed: /* SBC abcd */
1250 ABSOLUTE; 1250 ABSOLUTE;
1251 SBC; 1251 SBC;
1252 break; 1252 break;
1253 case 0xee: /* INC abcd */ 1253 case 0xee: /* INC abcd */
1254 ABSOLUTE; 1254 ABSOLUTE;
1255 INC; 1255 INC;
1256 break; 1256 break;
1257 case 0xf0: /* BEQ */ 1257 case 0xf0: /* BEQ */
1258 BRANCH((nz & 0xff) == 0); 1258 BRANCH((nz & 0xff) == 0);
1259 case 0xf1: /* SBC (ab),y */ 1259 case 0xf1: /* SBC (ab),y */
1260 INDIRECT_Y; 1260 INDIRECT_Y;
1261 NCYCLES_Y; 1261 NCYCLES_Y;
1262 SBC; 1262 SBC;
1263 break; 1263 break;
1264 case 0xf5: /* SBC ab,x */ 1264 case 0xf5: /* SBC ab,x */
1265 ZPAGE_X; 1265 ZPAGE_X;
1266 SBC_ZP; 1266 SBC_ZP;
1267 break; 1267 break;
1268 case 0xf6: /* INC ab,x */ 1268 case 0xf6: /* INC ab,x */
1269 ZPAGE_X; 1269 ZPAGE_X;
1270 INC_ZP; 1270 INC_ZP;
1271 break; 1271 break;
1272 case 0xf8: /* SED */ 1272 case 0xf8: /* SED */
1273 vdi |= D_FLAG; 1273 vdi |= D_FLAG;
1274 break; 1274 break;
1275 case 0xf9: /* SBC abcd,y */ 1275 case 0xf9: /* SBC abcd,y */
1276 ABSOLUTE_Y; 1276 ABSOLUTE_Y;
1277 NCYCLES_Y; 1277 NCYCLES_Y;
1278 SBC; 1278 SBC;
1279 break; 1279 break;
1280 case 0xfd: /* SBC abcd,x */ 1280 case 0xfd: /* SBC abcd,x */
1281 ABSOLUTE_X; 1281 ABSOLUTE_X;
1282 NCYCLES_X; 1282 NCYCLES_X;
1283 SBC; 1283 SBC;
1284 break; 1284 break;
1285 case 0xfe: /* INC abcd,x */ 1285 case 0xfe: /* INC abcd,x */
1286 ABSOLUTE_X; 1286 ABSOLUTE_X;
1287 INC; 1287 INC;
1288 break; 1288 break;
1289 } 1289 }
1290 } 1290 }
1291 ast _ cpu_pc = pc; 1291 ast _ cpu_pc = pc;
1292 ast _ cpu_nz = nz; 1292 ast _ cpu_nz = nz;
1293 ast _ cpu_a = a; 1293 ast _ cpu_a = a;
1294 ast _ cpu_x = x; 1294 ast _ cpu_x = x;
1295 ast _ cpu_y = y; 1295 ast _ cpu_y = y;
1296 ast _ cpu_c = c; 1296 ast _ cpu_c = c;
1297 ast _ cpu_s = s; 1297 ast _ cpu_s = s;
1298 ast _ cpu_vdi = vdi; 1298 ast _ cpu_vdi = vdi;
1299 ast _ cycle -= cycle_limit; 1299 ast _ cycle -= cycle_limit;
1300 if (ast _ timer1_cycle != NEVER) 1300 if (ast _ timer1_cycle != NEVER)
1301 ast _ timer1_cycle -= cycle_limit; 1301 ast _ timer1_cycle -= cycle_limit;
1302 if (ast _ timer2_cycle != NEVER) 1302 if (ast _ timer2_cycle != NEVER)
1303 ast _ timer2_cycle -= cycle_limit; 1303 ast _ timer2_cycle -= cycle_limit;
1304 if (ast _ timer4_cycle != NEVER) 1304 if (ast _ timer4_cycle != NEVER)
1305 ast _ timer4_cycle -= cycle_limit; 1305 ast _ timer4_cycle -= cycle_limit;
1306} 1306}
diff --git a/apps/codecs/libasap/apokeysnd.c b/apps/codecs/libasap/apokeysnd.c
index a461fa96da..ead611be5f 100644
--- a/apps/codecs/libasap/apokeysnd.c
+++ b/apps/codecs/libasap/apokeysnd.c
@@ -30,178 +30,178 @@
30#define MUTE_USER 4 30#define MUTE_USER 4
31 31
32CONST_ARRAY(byte, poly4_lookup) 32CONST_ARRAY(byte, poly4_lookup)
33 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1 33 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1
34END_CONST_ARRAY; 34END_CONST_ARRAY;
35CONST_ARRAY(byte, poly5_lookup) 35CONST_ARRAY(byte, poly5_lookup)
36 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 36 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1,
37 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1 37 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1
38END_CONST_ARRAY; 38END_CONST_ARRAY;
39 39
40PRIVATE FUNC(void, PokeySound_InitializeChip, (P(PokeyState PTR, pst))) 40PRIVATE FUNC(void, PokeySound_InitializeChip, (P(PokeyState PTR, pst)))
41{ 41{
42 pst _ audctl = 0; 42 pst _ audctl = 0;
43 pst _ init = FALSE; 43 pst _ init = FALSE;
44 pst _ poly_index = 15 * 31 * 131071; 44 pst _ poly_index = 15 * 31 * 131071;
45 pst _ div_cycles = 28; 45 pst _ div_cycles = 28;
46 pst _ mute1 = MUTE_FREQUENCY | MUTE_USER; 46 pst _ mute1 = MUTE_FREQUENCY | MUTE_USER;
47 pst _ mute2 = MUTE_FREQUENCY | MUTE_USER; 47 pst _ mute2 = MUTE_FREQUENCY | MUTE_USER;
48 pst _ mute3 = MUTE_FREQUENCY | MUTE_USER; 48 pst _ mute3 = MUTE_FREQUENCY | MUTE_USER;
49 pst _ mute4 = MUTE_FREQUENCY | MUTE_USER; 49 pst _ mute4 = MUTE_FREQUENCY | MUTE_USER;
50 pst _ audf1 = 0; 50 pst _ audf1 = 0;
51 pst _ audf2 = 0; 51 pst _ audf2 = 0;
52 pst _ audf3 = 0; 52 pst _ audf3 = 0;
53 pst _ audf4 = 0; 53 pst _ audf4 = 0;
54 pst _ audc1 = 0; 54 pst _ audc1 = 0;
55 pst _ audc2 = 0; 55 pst _ audc2 = 0;
56 pst _ audc3 = 0; 56 pst _ audc3 = 0;
57 pst _ audc4 = 0; 57 pst _ audc4 = 0;
58 pst _ tick_cycle1 = NEVER; 58 pst _ tick_cycle1 = NEVER;
59 pst _ tick_cycle2 = NEVER; 59 pst _ tick_cycle2 = NEVER;
60 pst _ tick_cycle3 = NEVER; 60 pst _ tick_cycle3 = NEVER;
61 pst _ tick_cycle4 = NEVER; 61 pst _ tick_cycle4 = NEVER;
62 pst _ period_cycles1 = 28; 62 pst _ period_cycles1 = 28;
63 pst _ period_cycles2 = 28; 63 pst _ period_cycles2 = 28;
64 pst _ period_cycles3 = 28; 64 pst _ period_cycles3 = 28;
65 pst _ period_cycles4 = 28; 65 pst _ period_cycles4 = 28;
66 pst _ reload_cycles1 = 28; 66 pst _ reload_cycles1 = 28;
67 pst _ reload_cycles3 = 28; 67 pst _ reload_cycles3 = 28;
68 pst _ out1 = 0; 68 pst _ out1 = 0;
69 pst _ out2 = 0; 69 pst _ out2 = 0;
70 pst _ out3 = 0; 70 pst _ out3 = 0;
71 pst _ out4 = 0; 71 pst _ out4 = 0;
72 pst _ delta1 = 0; 72 pst _ delta1 = 0;
73 pst _ delta2 = 0; 73 pst _ delta2 = 0;
74 pst _ delta3 = 0; 74 pst _ delta3 = 0;
75 pst _ delta4 = 0; 75 pst _ delta4 = 0;
76 pst _ skctl = 3; 76 pst _ skctl = 3;
77 ZERO_ARRAY(pst _ delta_buffer); 77 ZERO_ARRAY(pst _ delta_buffer);
78} 78}
79 79
80FUNC(void, PokeySound_Initialize, (P(ASAP_State PTR, ast))) 80FUNC(void, PokeySound_Initialize, (P(ASAP_State PTR, ast)))
81{ 81{
82 V(int, i); 82 V(int, i);
83 V(int, reg); 83 V(int, reg);
84 reg = 0x1ff; 84 reg = 0x1ff;
85 for (i = 0; i < 511; i++) { 85 for (i = 0; i < 511; i++) {
86 reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1); 86 reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1);
87 ast _ poly9_lookup[i] = TO_BYTE(reg); 87 ast _ poly9_lookup[i] = TO_BYTE(reg);
88 } 88 }
89 reg = 0x1ffff; 89 reg = 0x1ffff;
90 for (i = 0; i < 16385; i++) { 90 for (i = 0; i < 16385; i++) {
91 reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8); 91 reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8);
92 ast _ poly17_lookup[i] = TO_BYTE(reg >> 1); 92 ast _ poly17_lookup[i] = TO_BYTE(reg >> 1);
93 } 93 }
94 ast _ sample_offset = 0; 94 ast _ sample_offset = 0;
95 ast _ sample_index = 0; 95 ast _ sample_index = 0;
96 ast _ samples = 0; 96 ast _ samples = 0;
97 ast _ iir_acc_left = 0; 97 ast _ iir_acc_left = 0;
98 ast _ iir_acc_right = 0; 98 ast _ iir_acc_right = 0;
99 PokeySound_InitializeChip(ADDRESSOF ast _ base_pokey); 99 PokeySound_InitializeChip(ADDRESSOF ast _ base_pokey);
100 PokeySound_InitializeChip(ADDRESSOF ast _ extra_pokey); 100 PokeySound_InitializeChip(ADDRESSOF ast _ extra_pokey);
101} 101}
102 102
103#define DO_TICK(ch) \ 103#define DO_TICK(ch) \
104 if (pst _ init) { \ 104 if (pst _ init) { \
105 switch (pst _ audc##ch >> 4) { \ 105 switch (pst _ audc##ch >> 4) { \
106 case 10: \ 106 case 10: \
107 case 14: \ 107 case 14: \
108 pst _ out##ch ^= 1; \ 108 pst _ out##ch ^= 1; \
109 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ 109 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \
110 break; \ 110 break; \
111 default: \ 111 default: \
112 break; \ 112 break; \
113 } \ 113 } \
114 } \ 114 } \
115 else { \ 115 else { \
116 V(int, poly) = cycle + pst _ poly_index - (ch - 1); \ 116 V(int, poly) = cycle + pst _ poly_index - (ch - 1); \
117 V(int, newout) = pst _ out##ch; \ 117 V(int, newout) = pst _ out##ch; \
118 switch (pst _ audc##ch >> 4) { \ 118 switch (pst _ audc##ch >> 4) { \
119 case 0: \ 119 case 0: \
120 if (poly5_lookup[poly % 31] != 0) { \ 120 if (poly5_lookup[poly % 31] != 0) { \
121 if ((pst _ audctl & 0x80) != 0) \ 121 if ((pst _ audctl & 0x80) != 0) \
122 newout = ast _ poly9_lookup[poly % 511] & 1; \ 122 newout = ast _ poly9_lookup[poly % 511] & 1; \
123 else { \ 123 else { \
124 poly %= 131071; \ 124 poly %= 131071; \
125 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ 125 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \
126 } \ 126 } \
127 } \ 127 } \
128 break; \ 128 break; \
129 case 2: \ 129 case 2: \
130 case 6: \ 130 case 6: \
131 newout ^= poly5_lookup[poly % 31]; \ 131 newout ^= poly5_lookup[poly % 31]; \
132 break; \ 132 break; \
133 case 4: \ 133 case 4: \
134 if (poly5_lookup[poly % 31] != 0) \ 134 if (poly5_lookup[poly % 31] != 0) \
135 newout = poly4_lookup[poly % 15]; \ 135 newout = poly4_lookup[poly % 15]; \
136 break; \ 136 break; \
137 case 8: \ 137 case 8: \
138 if ((pst _ audctl & 0x80) != 0) \ 138 if ((pst _ audctl & 0x80) != 0) \
139 newout = ast _ poly9_lookup[poly % 511] & 1; \ 139 newout = ast _ poly9_lookup[poly % 511] & 1; \
140 else { \ 140 else { \
141 poly %= 131071; \ 141 poly %= 131071; \
142 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ 142 newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \
143 } \ 143 } \
144 break; \ 144 break; \
145 case 10: \ 145 case 10: \
146 case 14: \ 146 case 14: \
147 newout ^= 1; \ 147 newout ^= 1; \
148 break; \ 148 break; \
149 case 12: \ 149 case 12: \
150 newout = poly4_lookup[poly % 15]; \ 150 newout = poly4_lookup[poly % 15]; \
151 break; \ 151 break; \
152 default: \ 152 default: \
153 break; \ 153 break; \
154 } \ 154 } \
155 if (newout != pst _ out##ch) { \ 155 if (newout != pst _ out##ch) { \
156 pst _ out##ch = newout; \ 156 pst _ out##ch = newout; \
157 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ 157 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \
158 } \ 158 } \
159 } 159 }
160 160
161/* Fills delta_buffer up to current_cycle basing on current AUDF/AUDC/AUDCTL values. */ 161/* Fills delta_buffer up to current_cycle basing on current AUDF/AUDC/AUDCTL values. */
162PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, current_cycle))) 162PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, current_cycle)))
163{ 163{
164 for (;;) { 164 for (;;) {
165 V(int, cycle) = current_cycle; 165 V(int, cycle) = current_cycle;
166 if (cycle > pst _ tick_cycle1) 166 if (cycle > pst _ tick_cycle1)
167 cycle = pst _ tick_cycle1; 167 cycle = pst _ tick_cycle1;
168 if (cycle > pst _ tick_cycle2) 168 if (cycle > pst _ tick_cycle2)
169 cycle = pst _ tick_cycle2; 169 cycle = pst _ tick_cycle2;
170 if (cycle > pst _ tick_cycle3) 170 if (cycle > pst _ tick_cycle3)
171 cycle = pst _ tick_cycle3; 171 cycle = pst _ tick_cycle3;
172 if (cycle > pst _ tick_cycle4) 172 if (cycle > pst _ tick_cycle4)
173 cycle = pst _ tick_cycle4; 173 cycle = pst _ tick_cycle4;
174 if (cycle == current_cycle) 174 if (cycle == current_cycle)
175 break; 175 break;
176 if (cycle == pst _ tick_cycle3) { 176 if (cycle == pst _ tick_cycle3) {
177 pst _ tick_cycle3 += pst _ period_cycles3; 177 pst _ tick_cycle3 += pst _ period_cycles3;
178 if ((pst _ audctl & 4) != 0 && pst _ delta1 > 0 && pst _ mute1 == 0) 178 if ((pst _ audctl & 4) != 0 && pst _ delta1 > 0 && pst _ mute1 == 0)
179 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta1 = -pst _ delta1; 179 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta1 = -pst _ delta1;
180 DO_TICK(3); 180 DO_TICK(3);
181 } 181 }
182 if (cycle == pst _ tick_cycle4) { 182 if (cycle == pst _ tick_cycle4) {
183 pst _ tick_cycle4 += pst _ period_cycles4; 183 pst _ tick_cycle4 += pst _ period_cycles4;
184 if ((pst _ audctl & 8) != 0) 184 if ((pst _ audctl & 8) != 0)
185 pst _ tick_cycle3 = cycle + pst _ reload_cycles3; 185 pst _ tick_cycle3 = cycle + pst _ reload_cycles3;
186 if ((pst _ audctl & 2) != 0 && pst _ delta2 > 0 && pst _ mute2 == 0) 186 if ((pst _ audctl & 2) != 0 && pst _ delta2 > 0 && pst _ mute2 == 0)
187 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta2 = -pst _ delta2; 187 pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta2 = -pst _ delta2;
188 DO_TICK(4); 188 DO_TICK(4);
189 } 189 }
190 if (cycle == pst _ tick_cycle1) { 190 if (cycle == pst _ tick_cycle1) {
191 pst _ tick_cycle1 += pst _ period_cycles1; 191 pst _ tick_cycle1 += pst _ period_cycles1;
192 if ((pst _ skctl & 0x88) == 8) /* two-tone, sending 1 (i.e. timer1) */ 192 if ((pst _ skctl & 0x88) == 8) /* two-tone, sending 1 (i.e. timer1) */
193 pst _ tick_cycle2 = cycle + pst _ period_cycles2; 193 pst _ tick_cycle2 = cycle + pst _ period_cycles2;
194 DO_TICK(1); 194 DO_TICK(1);
195 } 195 }
196 if (cycle == pst _ tick_cycle2) { 196 if (cycle == pst _ tick_cycle2) {
197 pst _ tick_cycle2 += pst _ period_cycles2; 197 pst _ tick_cycle2 += pst _ period_cycles2;
198 if ((pst _ audctl & 0x10) != 0) 198 if ((pst _ audctl & 0x10) != 0)
199 pst _ tick_cycle1 = cycle + pst _ reload_cycles1; 199 pst _ tick_cycle1 = cycle + pst _ reload_cycles1;
200 else if ((pst _ skctl & 8) != 0) /* two-tone */ 200 else if ((pst _ skctl & 8) != 0) /* two-tone */
201 pst _ tick_cycle1 = cycle + pst _ period_cycles1; 201 pst _ tick_cycle1 = cycle + pst _ period_cycles1;
202 DO_TICK(2); 202 DO_TICK(2);
203 } 203 }
204 } 204 }
205} 205}
206 206
207#ifdef APOKEYSND 207#ifdef APOKEYSND
@@ -209,351 +209,351 @@ PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(Pok
209#define CURRENT_CYCLE 0 209#define CURRENT_CYCLE 0
210#define CURRENT_SAMPLE 0 210#define CURRENT_SAMPLE 0
211#define DO_STORE(reg) \ 211#define DO_STORE(reg) \
212 if (data == pst _ reg) \ 212 if (data == pst _ reg) \
213 break; \ 213 break; \
214 pst _ reg = data; 214 pst _ reg = data;
215 215
216#else 216#else
217 217
218#define CURRENT_CYCLE ast _ cycle 218#define CURRENT_CYCLE ast _ cycle
219#define CURRENT_SAMPLE CYCLE_TO_SAMPLE(ast _ cycle) 219#define CURRENT_SAMPLE CYCLE_TO_SAMPLE(ast _ cycle)
220#define DO_STORE(reg) \ 220#define DO_STORE(reg) \
221 if (data == pst _ reg) \ 221 if (data == pst _ reg) \
222 break; \ 222 break; \
223 PokeySound_GenerateUntilCycle(ast, pst, ast _ cycle); \ 223 PokeySound_GenerateUntilCycle(ast, pst, ast _ cycle); \
224 pst _ reg = data; 224 pst _ reg = data;
225 225
226#endif /* APOKEYSND */ 226#endif /* APOKEYSND */
227 227
228#define MUTE_CHANNEL(ch, cond, mask) \ 228#define MUTE_CHANNEL(ch, cond, mask) \
229 if (cond) { \ 229 if (cond) { \
230 pst _ mute##ch |= mask; \ 230 pst _ mute##ch |= mask; \
231 pst _ tick_cycle##ch = NEVER; \ 231 pst _ tick_cycle##ch = NEVER; \
232 } \ 232 } \
233 else { \ 233 else { \
234 pst _ mute##ch &= ~mask; \ 234 pst _ mute##ch &= ~mask; \
235 if (pst _ tick_cycle##ch == NEVER && pst _ mute##ch == 0) \ 235 if (pst _ tick_cycle##ch == NEVER && pst _ mute##ch == 0) \
236 pst _ tick_cycle##ch = CURRENT_CYCLE; \ 236 pst _ tick_cycle##ch = CURRENT_CYCLE; \
237 } 237 }
238 238
239#define DO_ULTRASOUND(ch) \ 239#define DO_ULTRASOUND(ch) \
240 MUTE_CHANNEL(ch, pst _ period_cycles##ch <= ULTRASOUND_CYCLES && (pst _ audc##ch >> 4 == 10 || pst _ audc##ch >> 4 == 14), MUTE_FREQUENCY) 240 MUTE_CHANNEL(ch, pst _ period_cycles##ch <= ULTRASOUND_CYCLES && (pst _ audc##ch >> 4 == 10 || pst _ audc##ch >> 4 == 14), MUTE_FREQUENCY)
241 241
242#define DO_AUDC(ch) \ 242#define DO_AUDC(ch) \
243 DO_STORE(audc##ch); \ 243 DO_STORE(audc##ch); \
244 if ((data & 0x10) != 0) { \ 244 if ((data & 0x10) != 0) { \
245 data = (data & 0xf) << DELTA_SHIFT_POKEY; \ 245 data = (data & 0xf) << DELTA_SHIFT_POKEY; \
246 if ((pst _ mute##ch & MUTE_USER) == 0) \ 246 if ((pst _ mute##ch & MUTE_USER) == 0) \
247 pst _ delta_buffer[CURRENT_SAMPLE] \ 247 pst _ delta_buffer[CURRENT_SAMPLE] \
248 += pst _ delta##ch > 0 ? data - pst _ delta##ch : data; \ 248 += pst _ delta##ch > 0 ? data - pst _ delta##ch : data; \
249 pst _ delta##ch = data; \ 249 pst _ delta##ch = data; \
250 } \ 250 } \
251 else { \ 251 else { \
252 data = (data & 0xf) << DELTA_SHIFT_POKEY; \ 252 data = (data & 0xf) << DELTA_SHIFT_POKEY; \
253 DO_ULTRASOUND(ch); \ 253 DO_ULTRASOUND(ch); \
254 if (pst _ delta##ch > 0) { \ 254 if (pst _ delta##ch > 0) { \
255 if ((pst _ mute##ch & MUTE_USER) == 0) \ 255 if ((pst _ mute##ch & MUTE_USER) == 0) \
256 pst _ delta_buffer[CURRENT_SAMPLE] \ 256 pst _ delta_buffer[CURRENT_SAMPLE] \
257 += data - pst _ delta##ch; \ 257 += data - pst _ delta##ch; \
258 pst _ delta##ch = data; \ 258 pst _ delta##ch = data; \
259 } \ 259 } \
260 else \ 260 else \
261 pst _ delta##ch = -data; \ 261 pst _ delta##ch = -data; \
262 } \ 262 } \
263 break; 263 break;
264 264
265#define DO_INIT(ch, cond) \ 265#define DO_INIT(ch, cond) \
266 MUTE_CHANNEL(ch, pst _ init && cond, MUTE_INIT) 266 MUTE_CHANNEL(ch, pst _ init && cond, MUTE_INIT)
267 267
268FUNC(void, PokeySound_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) 268FUNC(void, PokeySound_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data)))
269{ 269{
270 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 270 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0
271 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; 271 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey;
272 switch (addr & 0xf) { 272 switch (addr & 0xf) {
273 case 0x00: 273 case 0x00:
274 DO_STORE(audf1); 274 DO_STORE(audf1);
275 switch (pst _ audctl & 0x50) { 275 switch (pst _ audctl & 0x50) {
276 case 0x00: 276 case 0x00:
277 pst _ period_cycles1 = pst _ div_cycles * (data + 1); 277 pst _ period_cycles1 = pst _ div_cycles * (data + 1);
278 break; 278 break;
279 case 0x10: 279 case 0x10:
280 pst _ period_cycles2 = pst _ div_cycles * (data + 256 * pst _ audf2 + 1); 280 pst _ period_cycles2 = pst _ div_cycles * (data + 256 * pst _ audf2 + 1);
281 pst _ reload_cycles1 = pst _ div_cycles * (data + 1); 281 pst _ reload_cycles1 = pst _ div_cycles * (data + 1);
282 DO_ULTRASOUND(2); 282 DO_ULTRASOUND(2);
283 break; 283 break;
284 case 0x40: 284 case 0x40:
285 pst _ period_cycles1 = data + 4; 285 pst _ period_cycles1 = data + 4;
286 break; 286 break;
287 case 0x50: 287 case 0x50:
288 pst _ period_cycles2 = data + 256 * pst _ audf2 + 7; 288 pst _ period_cycles2 = data + 256 * pst _ audf2 + 7;
289 pst _ reload_cycles1 = data + 4; 289 pst _ reload_cycles1 = data + 4;
290 DO_ULTRASOUND(2); 290 DO_ULTRASOUND(2);
291 break; 291 break;
292 } 292 }
293 DO_ULTRASOUND(1); 293 DO_ULTRASOUND(1);
294 break; 294 break;
295 case 0x01: 295 case 0x01:
296 DO_AUDC(1) 296 DO_AUDC(1)
297 case 0x02: 297 case 0x02:
298 DO_STORE(audf2); 298 DO_STORE(audf2);
299 switch (pst _ audctl & 0x50) { 299 switch (pst _ audctl & 0x50) {
300 case 0x00: 300 case 0x00:
301 case 0x40: 301 case 0x40:
302 pst _ period_cycles2 = pst _ div_cycles * (data + 1); 302 pst _ period_cycles2 = pst _ div_cycles * (data + 1);
303 break; 303 break;
304 case 0x10: 304 case 0x10:
305 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * data + 1); 305 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * data + 1);
306 break; 306 break;
307 case 0x50: 307 case 0x50:
308 pst _ period_cycles2 = pst _ audf1 + 256 * data + 7; 308 pst _ period_cycles2 = pst _ audf1 + 256 * data + 7;
309 break; 309 break;
310 } 310 }
311 DO_ULTRASOUND(2); 311 DO_ULTRASOUND(2);
312 break; 312 break;
313 case 0x03: 313 case 0x03:
314 DO_AUDC(2) 314 DO_AUDC(2)
315 case 0x04: 315 case 0x04:
316 DO_STORE(audf3); 316 DO_STORE(audf3);
317 switch (pst _ audctl & 0x28) { 317 switch (pst _ audctl & 0x28) {
318 case 0x00: 318 case 0x00:
319 pst _ period_cycles3 = pst _ div_cycles * (data + 1); 319 pst _ period_cycles3 = pst _ div_cycles * (data + 1);
320 break; 320 break;
321 case 0x08: 321 case 0x08:
322 pst _ period_cycles4 = pst _ div_cycles * (data + 256 * pst _ audf4 + 1); 322 pst _ period_cycles4 = pst _ div_cycles * (data + 256 * pst _ audf4 + 1);
323 pst _ reload_cycles3 = pst _ div_cycles * (data + 1); 323 pst _ reload_cycles3 = pst _ div_cycles * (data + 1);
324 DO_ULTRASOUND(4); 324 DO_ULTRASOUND(4);
325 break; 325 break;
326 case 0x20: 326 case 0x20:
327 pst _ period_cycles3 = data + 4; 327 pst _ period_cycles3 = data + 4;
328 break; 328 break;
329 case 0x28: 329 case 0x28:
330 pst _ period_cycles4 = data + 256 * pst _ audf4 + 7; 330 pst _ period_cycles4 = data + 256 * pst _ audf4 + 7;
331 pst _ reload_cycles3 = data + 4; 331 pst _ reload_cycles3 = data + 4;
332 DO_ULTRASOUND(4); 332 DO_ULTRASOUND(4);
333 break; 333 break;
334 } 334 }
335 DO_ULTRASOUND(3); 335 DO_ULTRASOUND(3);
336 break; 336 break;
337 case 0x05: 337 case 0x05:
338 DO_AUDC(3) 338 DO_AUDC(3)
339 case 0x06: 339 case 0x06:
340 DO_STORE(audf4); 340 DO_STORE(audf4);
341 switch (pst _ audctl & 0x28) { 341 switch (pst _ audctl & 0x28) {
342 case 0x00: 342 case 0x00:
343 case 0x20: 343 case 0x20:
344 pst _ period_cycles4 = pst _ div_cycles * (data + 1); 344 pst _ period_cycles4 = pst _ div_cycles * (data + 1);
345 break; 345 break;
346 case 0x08: 346 case 0x08:
347 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * data + 1); 347 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * data + 1);
348 break; 348 break;
349 case 0x28: 349 case 0x28:
350 pst _ period_cycles4 = pst _ audf3 + 256 * data + 7; 350 pst _ period_cycles4 = pst _ audf3 + 256 * data + 7;
351 break; 351 break;
352 } 352 }
353 DO_ULTRASOUND(4); 353 DO_ULTRASOUND(4);
354 break; 354 break;
355 case 0x07: 355 case 0x07:
356 DO_AUDC(4) 356 DO_AUDC(4)
357 case 0x08: 357 case 0x08:
358 DO_STORE(audctl); 358 DO_STORE(audctl);
359 pst _ div_cycles = ((data & 1) != 0) ? 114 : 28; 359 pst _ div_cycles = ((data & 1) != 0) ? 114 : 28;
360 /* TODO: tick_cycles */ 360 /* TODO: tick_cycles */
361 switch (data & 0x50) { 361 switch (data & 0x50) {
362 case 0x00: 362 case 0x00:
363 pst _ period_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); 363 pst _ period_cycles1 = pst _ div_cycles * (pst _ audf1 + 1);
364 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); 364 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1);
365 break; 365 break;
366 case 0x10: 366 case 0x10:
367 pst _ period_cycles1 = pst _ div_cycles * 256; 367 pst _ period_cycles1 = pst _ div_cycles * 256;
368 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * pst _ audf2 + 1); 368 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * pst _ audf2 + 1);
369 pst _ reload_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); 369 pst _ reload_cycles1 = pst _ div_cycles * (pst _ audf1 + 1);
370 break; 370 break;
371 case 0x40: 371 case 0x40:
372 pst _ period_cycles1 = pst _ audf1 + 4; 372 pst _ period_cycles1 = pst _ audf1 + 4;
373 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); 373 pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1);
374 break; 374 break;
375 case 0x50: 375 case 0x50:
376 pst _ period_cycles1 = 256; 376 pst _ period_cycles1 = 256;
377 pst _ period_cycles2 = pst _ audf1 + 256 * pst _ audf2 + 7; 377 pst _ period_cycles2 = pst _ audf1 + 256 * pst _ audf2 + 7;
378 pst _ reload_cycles1 = pst _ audf1 + 4; 378 pst _ reload_cycles1 = pst _ audf1 + 4;
379 break; 379 break;
380 } 380 }
381 DO_ULTRASOUND(1); 381 DO_ULTRASOUND(1);
382 DO_ULTRASOUND(2); 382 DO_ULTRASOUND(2);
383 switch (data & 0x28) { 383 switch (data & 0x28) {
384 case 0x00: 384 case 0x00:
385 pst _ period_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); 385 pst _ period_cycles3 = pst _ div_cycles * (pst _ audf3 + 1);
386 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); 386 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1);
387 break; 387 break;
388 case 0x08: 388 case 0x08:
389 pst _ period_cycles3 = pst _ div_cycles * 256; 389 pst _ period_cycles3 = pst _ div_cycles * 256;
390 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * pst _ audf4 + 1); 390 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * pst _ audf4 + 1);
391 pst _ reload_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); 391 pst _ reload_cycles3 = pst _ div_cycles * (pst _ audf3 + 1);
392 break; 392 break;
393 case 0x20: 393 case 0x20:
394 pst _ period_cycles3 = pst _ audf3 + 4; 394 pst _ period_cycles3 = pst _ audf3 + 4;
395 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); 395 pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1);
396 break; 396 break;
397 case 0x28: 397 case 0x28:
398 pst _ period_cycles3 = 256; 398 pst _ period_cycles3 = 256;
399 pst _ period_cycles4 = pst _ audf3 + 256 * pst _ audf4 + 7; 399 pst _ period_cycles4 = pst _ audf3 + 256 * pst _ audf4 + 7;
400 pst _ reload_cycles3 = pst _ audf3 + 4; 400 pst _ reload_cycles3 = pst _ audf3 + 4;
401 break; 401 break;
402 } 402 }
403 DO_ULTRASOUND(3); 403 DO_ULTRASOUND(3);
404 DO_ULTRASOUND(4); 404 DO_ULTRASOUND(4);
405 DO_INIT(1, (data & 0x40) == 0); 405 DO_INIT(1, (data & 0x40) == 0);
406 DO_INIT(2, (data & 0x50) != 0x50); 406 DO_INIT(2, (data & 0x50) != 0x50);
407 DO_INIT(3, (data & 0x20) == 0); 407 DO_INIT(3, (data & 0x20) == 0);
408 DO_INIT(4, (data & 0x28) != 0x28); 408 DO_INIT(4, (data & 0x28) != 0x28);
409 break; 409 break;
410 case 0x09: 410 case 0x09:
411 /* TODO: STIMER */ 411 /* TODO: STIMER */
412 break; 412 break;
413 case 0x0f: 413 case 0x0f:
414 DO_STORE(skctl); 414 DO_STORE(skctl);
415 pst _ init = ((data & 3) == 0); 415 pst _ init = ((data & 3) == 0);
416 DO_INIT(1, (pst _ audctl & 0x40) == 0); 416 DO_INIT(1, (pst _ audctl & 0x40) == 0);
417 DO_INIT(2, (pst _ audctl & 0x50) != 0x50); 417 DO_INIT(2, (pst _ audctl & 0x50) != 0x50);
418 DO_INIT(3, (pst _ audctl & 0x20) == 0); 418 DO_INIT(3, (pst _ audctl & 0x20) == 0);
419 DO_INIT(4, (pst _ audctl & 0x28) != 0x28); 419 DO_INIT(4, (pst _ audctl & 0x28) != 0x28);
420 break; 420 break;
421 default: 421 default:
422 break; 422 break;
423 } 423 }
424} 424}
425 425
426FUNC(int, PokeySound_GetRandom, (P(ASAP_State PTR, ast), P(int, addr), P(int, cycle))) 426FUNC(int, PokeySound_GetRandom, (P(ASAP_State PTR, ast), P(int, addr), P(int, cycle)))
427{ 427{
428 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 428 V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0
429 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; 429 ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey;
430 V(int, i); 430 V(int, i);
431 if (pst _ init) 431 if (pst _ init)
432 return 0xff; 432 return 0xff;
433 i = cycle + pst _ poly_index; 433 i = cycle + pst _ poly_index;
434 if ((pst _ audctl & 0x80) != 0) 434 if ((pst _ audctl & 0x80) != 0)
435 return ast _ poly9_lookup[i % 511]; 435 return ast _ poly9_lookup[i % 511];
436 else { 436 else {
437 V(int, j); 437 V(int, j);
438 i %= 131071; 438 i %= 131071;
439 j = i >> 3; 439 j = i >> 3;
440 i &= 7; 440 i &= 7;
441 return ((ast _ poly17_lookup[j] >> i) + (ast _ poly17_lookup[j + 1] << (8 - i))) & 0xff; 441 return ((ast _ poly17_lookup[j] >> i) + (ast _ poly17_lookup[j + 1] << (8 - i))) & 0xff;
442 } 442 }
443} 443}
444 444
445PRIVATE FUNC(void, end_frame, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, cycle_limit))) 445PRIVATE FUNC(void, end_frame, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, cycle_limit)))
446{ 446{
447 V(int, m); 447 V(int, m);
448 PokeySound_GenerateUntilCycle(ast, pst, cycle_limit); 448 PokeySound_GenerateUntilCycle(ast, pst, cycle_limit);
449 pst _ poly_index += cycle_limit; 449 pst _ poly_index += cycle_limit;
450 m = ((pst _ audctl & 0x80) != 0) ? 15 * 31 * 511 : 15 * 31 * 131071; 450 m = ((pst _ audctl & 0x80) != 0) ? 15 * 31 * 511 : 15 * 31 * 131071;
451 if (pst _ poly_index >= 2 * m) 451 if (pst _ poly_index >= 2 * m)
452 pst _ poly_index -= m; 452 pst _ poly_index -= m;
453 if (pst _ tick_cycle1 != NEVER) 453 if (pst _ tick_cycle1 != NEVER)
454 pst _ tick_cycle1 -= cycle_limit; 454 pst _ tick_cycle1 -= cycle_limit;
455 if (pst _ tick_cycle2 != NEVER) 455 if (pst _ tick_cycle2 != NEVER)
456 pst _ tick_cycle2 -= cycle_limit; 456 pst _ tick_cycle2 -= cycle_limit;
457 if (pst _ tick_cycle3 != NEVER) 457 if (pst _ tick_cycle3 != NEVER)
458 pst _ tick_cycle3 -= cycle_limit; 458 pst _ tick_cycle3 -= cycle_limit;
459 if (pst _ tick_cycle4 != NEVER) 459 if (pst _ tick_cycle4 != NEVER)
460 pst _ tick_cycle4 -= cycle_limit; 460 pst _ tick_cycle4 -= cycle_limit;
461} 461}
462 462
463FUNC(void, PokeySound_StartFrame, (P(ASAP_State PTR, ast))) 463FUNC(void, PokeySound_StartFrame, (P(ASAP_State PTR, ast)))
464{ 464{
465 ZERO_ARRAY(ast _ base_pokey.delta_buffer); 465 ZERO_ARRAY(ast _ base_pokey.delta_buffer);
466 if (ast _ extra_pokey_mask != 0) 466 if (ast _ extra_pokey_mask != 0)
467 ZERO_ARRAY(ast _ extra_pokey.delta_buffer); 467 ZERO_ARRAY(ast _ extra_pokey.delta_buffer);
468} 468}
469 469
470FUNC(void, PokeySound_EndFrame, (P(ASAP_State PTR, ast), P(int, current_cycle))) 470FUNC(void, PokeySound_EndFrame, (P(ASAP_State PTR, ast), P(int, current_cycle)))
471{ 471{
472 end_frame(ast, ADDRESSOF ast _ base_pokey, current_cycle); 472 end_frame(ast, ADDRESSOF ast _ base_pokey, current_cycle);
473 if (ast _ extra_pokey_mask != 0) 473 if (ast _ extra_pokey_mask != 0)
474 end_frame(ast, ADDRESSOF ast _ extra_pokey, current_cycle); 474 end_frame(ast, ADDRESSOF ast _ extra_pokey, current_cycle);
475 ast _ sample_offset += current_cycle * ASAP_SAMPLE_RATE; 475 ast _ sample_offset += current_cycle * ASAP_SAMPLE_RATE;
476 ast _ sample_index = 0; 476 ast _ sample_index = 0;
477 ast _ samples = TO_INT(ast _ sample_offset / ASAP_MAIN_CLOCK); 477 ast _ samples = TO_INT(ast _ sample_offset / ASAP_MAIN_CLOCK);
478 ast _ sample_offset %= ASAP_MAIN_CLOCK; 478 ast _ sample_offset %= ASAP_MAIN_CLOCK;
479} 479}
480 480
481/* Fills buffer with samples from delta_buffer. */ 481/* Fills buffer with samples from delta_buffer. */
482FUNC(int, PokeySound_Generate, (P(ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(int, buffer_offset), P(int, blocks), P(ASAP_SampleFormat, format))) 482FUNC(int, PokeySound_Generate, (P(ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(int, buffer_offset), P(int, blocks), P(ASAP_SampleFormat, format)))
483{ 483{
484 V(int, i) = ast _ sample_index; 484 V(int, i) = ast _ sample_index;
485 V(int, samples) = ast _ samples; 485 V(int, samples) = ast _ samples;
486 V(int, acc_left) = ast _ iir_acc_left; 486 V(int, acc_left) = ast _ iir_acc_left;
487 V(int, acc_right) = ast _ iir_acc_right; 487 V(int, acc_right) = ast _ iir_acc_right;
488 if (blocks < samples - i) 488 if (blocks < samples - i)
489 samples = i + blocks; 489 samples = i + blocks;
490 else 490 else
491 blocks = samples - i; 491 blocks = samples - i;
492 for (; i < samples; i++) { 492 for (; i < samples; i++) {
493#ifdef ACTIONSCRIPT 493#ifdef ACTIONSCRIPT
494 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); 494 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10);
495 var sample : Number = acc_left / 33553408; 495 var sample : Number = acc_left / 33553408;
496 buffer.writeFloat(sample); 496 buffer.writeFloat(sample);
497 if (ast.extra_pokey_mask != 0) { 497 if (ast.extra_pokey_mask != 0) {
498 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); 498 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10);
499 sample = acc_right / 33553408; 499 sample = acc_right / 33553408;
500 } 500 }
501 buffer.writeFloat(sample); 501 buffer.writeFloat(sample);
502#else 502#else
503 V(int, sample); 503 V(int, sample);
504 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); 504 acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10);
505 sample = acc_left >> 10; 505 sample = acc_left >> 10;
506#define STORE_SAMPLE \ 506#define STORE_SAMPLE \
507 if (sample < -32767) \ 507 if (sample < -32767) \
508 sample = -32767; \ 508 sample = -32767; \
509 else if (sample > 32767) \ 509 else if (sample > 32767) \
510 sample = 32767; \ 510 sample = 32767; \
511 switch (format) { \ 511 switch (format) { \
512 case ASAP_FORMAT_U8: \ 512 case ASAP_FORMAT_U8: \
513 buffer[buffer_offset++] = CAST(byte) ((sample >> 8) + 128); \ 513 buffer[buffer_offset++] = CAST(byte) ((sample >> 8) + 128); \
514 break; \ 514 break; \
515 case ASAP_FORMAT_S16_LE: \ 515 case ASAP_FORMAT_S16_LE: \
516 buffer[buffer_offset++] = TO_BYTE(sample); \ 516 buffer[buffer_offset++] = TO_BYTE(sample); \
517 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ 517 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \
518 break; \ 518 break; \
519 case ASAP_FORMAT_S16_BE: \ 519 case ASAP_FORMAT_S16_BE: \
520 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ 520 buffer[buffer_offset++] = TO_BYTE(sample >> 8); \
521 buffer[buffer_offset++] = TO_BYTE(sample); \ 521 buffer[buffer_offset++] = TO_BYTE(sample); \
522 break; \ 522 break; \
523 } 523 }
524 STORE_SAMPLE; 524 STORE_SAMPLE;
525 if (ast _ extra_pokey_mask != 0) { 525 if (ast _ extra_pokey_mask != 0) {
526 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); 526 acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10);
527 sample = acc_right >> 10; 527 sample = acc_right >> 10;
528 STORE_SAMPLE; 528 STORE_SAMPLE;
529 } 529 }
530#endif /* ACTIONSCRIPT */ 530#endif /* ACTIONSCRIPT */
531 } 531 }
532 if (i == ast _ samples) { 532 if (i == ast _ samples) {
533 acc_left += ast _ base_pokey.delta_buffer[i]; 533 acc_left += ast _ base_pokey.delta_buffer[i];
534 acc_right += ast _ extra_pokey.delta_buffer[i]; 534 acc_right += ast _ extra_pokey.delta_buffer[i];
535 } 535 }
536 ast _ sample_index = i; 536 ast _ sample_index = i;
537 ast _ iir_acc_left = acc_left; 537 ast _ iir_acc_left = acc_left;
538 ast _ iir_acc_right = acc_right; 538 ast _ iir_acc_right = acc_right;
539#ifdef APOKEYSND 539#ifdef APOKEYSND
540 return buffer_offset; 540 return buffer_offset;
541#else 541#else
542 return blocks; 542 return blocks;
543#endif 543#endif
544} 544}
545 545
546FUNC(abool, PokeySound_IsSilent, (P(CONST PokeyState PTR, pst))) 546FUNC(abool, PokeySound_IsSilent, (P(CONST PokeyState PTR, pst)))
547{ 547{
548 return ((pst _ audc1 | pst _ audc2 | pst _ audc3 | pst _ audc4) & 0xf) == 0; 548 return ((pst _ audc1 | pst _ audc2 | pst _ audc3 | pst _ audc4) & 0xf) == 0;
549} 549}
550 550
551FUNC(void, PokeySound_Mute, (P(CONST ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, mask))) 551FUNC(void, PokeySound_Mute, (P(CONST ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, mask)))
552{ 552{
553 MUTE_CHANNEL(1, (mask & 1) != 0, MUTE_USER); 553 MUTE_CHANNEL(1, (mask & 1) != 0, MUTE_USER);
554 MUTE_CHANNEL(2, (mask & 2) != 0, MUTE_USER); 554 MUTE_CHANNEL(2, (mask & 2) != 0, MUTE_USER);
555 MUTE_CHANNEL(3, (mask & 4) != 0, MUTE_USER); 555 MUTE_CHANNEL(3, (mask & 4) != 0, MUTE_USER);
556 MUTE_CHANNEL(4, (mask & 8) != 0, MUTE_USER); 556 MUTE_CHANNEL(4, (mask & 8) != 0, MUTE_USER);
557} 557}
558 558
559#ifdef APOKEYSND 559#ifdef APOKEYSND
@@ -562,37 +562,37 @@ static ASAP_State asap;
562 562
563__declspec(dllexport) void APokeySound_Initialize(abool stereo) 563__declspec(dllexport) void APokeySound_Initialize(abool stereo)
564{ 564{
565 asap.extra_pokey_mask = stereo ? 0x10 : 0; 565 asap.extra_pokey_mask = stereo ? 0x10 : 0;
566 PokeySound_Initialize(&asap); 566 PokeySound_Initialize(&asap);
567 PokeySound_Mute(&asap, &asap.base_pokey, 0); 567 PokeySound_Mute(&asap, &asap.base_pokey, 0);
568 PokeySound_Mute(&asap, &asap.extra_pokey, 0); 568 PokeySound_Mute(&asap, &asap.extra_pokey, 0);
569 PokeySound_StartFrame(&asap); 569 PokeySound_StartFrame(&asap);
570} 570}
571 571
572__declspec(dllexport) void APokeySound_PutByte(int addr, int data) 572__declspec(dllexport) void APokeySound_PutByte(int addr, int data)
573{ 573{
574 PokeySound_PutByte(&asap, addr, data); 574 PokeySound_PutByte(&asap, addr, data);
575} 575}
576 576
577__declspec(dllexport) int APokeySound_GetRandom(int addr, int cycle) 577__declspec(dllexport) int APokeySound_GetRandom(int addr, int cycle)
578{ 578{
579 return PokeySound_GetRandom(&asap, addr, cycle); 579 return PokeySound_GetRandom(&asap, addr, cycle);
580} 580}
581 581
582__declspec(dllexport) int APokeySound_Generate(int cycles, byte buffer[], ASAP_SampleFormat format) 582__declspec(dllexport) int APokeySound_Generate(int cycles, byte buffer[], ASAP_SampleFormat format)
583{ 583{
584 int len; 584 int len;
585 PokeySound_EndFrame(&asap, cycles); 585 PokeySound_EndFrame(&asap, cycles);
586 len = PokeySound_Generate(&asap, buffer, 0, asap.samples, format); 586 len = PokeySound_Generate(&asap, buffer, 0, asap.samples, format);
587 PokeySound_StartFrame(&asap); 587 PokeySound_StartFrame(&asap);
588 return len; 588 return len;
589} 589}
590 590
591__declspec(dllexport) void APokeySound_About(const char **name, const char **author, const char **description) 591__declspec(dllexport) void APokeySound_About(const char **name, const char **author, const char **description)
592{ 592{
593 *name = "Another POKEY sound emulator, v" ASAP_VERSION; 593 *name = "Another POKEY sound emulator, v" ASAP_VERSION;
594 *author = "Piotr Fusik, (C) " ASAP_YEARS; 594 *author = "Piotr Fusik, (C) " ASAP_YEARS;
595 *description = "Part of ASAP, http://asap.sourceforge.net"; 595 *description = "Part of ASAP, http://asap.sourceforge.net";
596} 596}
597 597
598#endif /* APOKEYSND */ 598#endif /* APOKEYSND */
diff --git a/apps/codecs/libasap/asap.c b/apps/codecs/libasap/asap.c
index 87b537ef63..c79682c38b 100644
--- a/apps/codecs/libasap/asap.c
+++ b/apps/codecs/libasap/asap.c
@@ -25,78 +25,78 @@
25 25
26FUNC(int, ASAP_GetByte, (P(ASAP_State PTR, ast), P(int, addr))) 26FUNC(int, ASAP_GetByte, (P(ASAP_State PTR, ast), P(int, addr)))
27{ 27{
28 switch (addr & 0xff0f) { 28 switch (addr & 0xff0f) {
29 case 0xd20a: 29 case 0xd20a:
30 return PokeySound_GetRandom(ast, addr, ast _ cycle); 30 return PokeySound_GetRandom(ast, addr, ast _ cycle);
31 case 0xd20e: 31 case 0xd20e:
32 if ((addr & ast _ extra_pokey_mask) != 0) { 32 if ((addr & ast _ extra_pokey_mask) != 0) {
33 /* interrupts in the extra POKEY not emulated at the moment */ 33 /* interrupts in the extra POKEY not emulated at the moment */
34 return 0xff; 34 return 0xff;
35 } 35 }
36 return ast _ irqst; 36 return ast _ irqst;
37 case 0xd20f: 37 case 0xd20f:
38 /* just because some SAP files rely on this */ 38 /* just because some SAP files rely on this */
39 return 0xff; 39 return 0xff;
40 case 0xd40b: 40 case 0xd40b:
41 return ast _ scanline_number >> 1; 41 return ast _ scanline_number >> 1;
42 default: 42 default:
43 return dGetByte(addr); 43 return dGetByte(addr);
44 } 44 }
45} 45}
46 46
47FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) 47FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data)))
48{ 48{
49 if ((addr >> 8) == 0xd2) { 49 if ((addr >> 8) == 0xd2) {
50 if ((addr & (ast _ extra_pokey_mask + 0xf)) == 0xe) { 50 if ((addr & (ast _ extra_pokey_mask + 0xf)) == 0xe) {
51 ast _ irqst |= data ^ 0xff; 51 ast _ irqst |= data ^ 0xff;
52#define SET_TIMER_IRQ(ch) \ 52#define SET_TIMER_IRQ(ch) \
53 if ((data & ast _ irqst & ch) != 0) { \ 53 if ((data & ast _ irqst & ch) != 0) { \
54 if (ast _ timer##ch##_cycle == NEVER) { \ 54 if (ast _ timer##ch##_cycle == NEVER) { \
55 V(int, t) = ast _ base_pokey.tick_cycle##ch; \ 55 V(int, t) = ast _ base_pokey.tick_cycle##ch; \
56 while (t < ast _ cycle) \ 56 while (t < ast _ cycle) \
57 t += ast _ base_pokey.period_cycles##ch; \ 57 t += ast _ base_pokey.period_cycles##ch; \
58 ast _ timer##ch##_cycle = t; \ 58 ast _ timer##ch##_cycle = t; \
59 if (ast _ nearest_event_cycle > t) \ 59 if (ast _ nearest_event_cycle > t) \
60 ast _ nearest_event_cycle = t; \ 60 ast _ nearest_event_cycle = t; \
61 } \ 61 } \
62 } \ 62 } \
63 else \ 63 else \
64 ast _ timer##ch##_cycle = NEVER; 64 ast _ timer##ch##_cycle = NEVER;
65 SET_TIMER_IRQ(1); 65 SET_TIMER_IRQ(1);
66 SET_TIMER_IRQ(2); 66 SET_TIMER_IRQ(2);
67 SET_TIMER_IRQ(4); 67 SET_TIMER_IRQ(4);
68 } 68 }
69 else 69 else
70 PokeySound_PutByte(ast, addr, data); 70 PokeySound_PutByte(ast, addr, data);
71 } 71 }
72 else if ((addr & 0xff0f) == 0xd40a) { 72 else if ((addr & 0xff0f) == 0xd40a) {
73 if (ast _ cycle <= ast _ next_scanline_cycle - 8) 73 if (ast _ cycle <= ast _ next_scanline_cycle - 8)
74 ast _ cycle = ast _ next_scanline_cycle - 8; 74 ast _ cycle = ast _ next_scanline_cycle - 8;
75 else 75 else
76 ast _ cycle = ast _ next_scanline_cycle + 106; 76 ast _ cycle = ast _ next_scanline_cycle + 106;
77 } 77 }
78 else if ((addr & 0xff00) == ast _ module_info.covox_addr) { 78 else if ((addr & 0xff00) == ast _ module_info.covox_addr) {
79 V(PokeyState PTR, pst); 79 V(PokeyState PTR, pst);
80 addr &= 3; 80 addr &= 3;
81 if (addr == 0 || addr == 3) 81 if (addr == 0 || addr == 3)
82 pst = ADDRESSOF ast _ base_pokey; 82 pst = ADDRESSOF ast _ base_pokey;
83 else 83 else
84 pst = ADDRESSOF ast _ extra_pokey; 84 pst = ADDRESSOF ast _ extra_pokey;
85 pst _ delta_buffer[CYCLE_TO_SAMPLE(ast _ cycle)] += (data - UBYTE(ast _ covox[addr])) << DELTA_SHIFT_COVOX; 85 pst _ delta_buffer[CYCLE_TO_SAMPLE(ast _ cycle)] += (data - UBYTE(ast _ covox[addr])) << DELTA_SHIFT_COVOX;
86 ast _ covox[addr] = CAST(byte) (data); 86 ast _ covox[addr] = CAST(byte) (data);
87 } 87 }
88 else if ((addr & 0xff1f) == 0xd01f) { 88 else if ((addr & 0xff1f) == 0xd01f) {
89 V(int, sample) = CYCLE_TO_SAMPLE(ast _ cycle); 89 V(int, sample) = CYCLE_TO_SAMPLE(ast _ cycle);
90 V(int, delta); 90 V(int, delta);
91 data &= 8; 91 data &= 8;
92 /* NOT data - ast _ consol; reverse to the POKEY sound */ 92 /* NOT data - ast _ consol; reverse to the POKEY sound */
93 delta = (ast _ consol - data) << DELTA_SHIFT_GTIA; 93 delta = (ast _ consol - data) << DELTA_SHIFT_GTIA;
94 ast _ consol = data; 94 ast _ consol = data;
95 ast _ base_pokey.delta_buffer[sample] += delta; 95 ast _ base_pokey.delta_buffer[sample] += delta;
96 ast _ extra_pokey.delta_buffer[sample] += delta; 96 ast _ extra_pokey.delta_buffer[sample] += delta;
97 } 97 }
98 else 98 else
99 dPutByte(addr, data); 99 dPutByte(addr, data);
100} 100}
101 101
102#define UWORD(array, index) (UBYTE(array[index]) + (UBYTE(array[(index) + 1]) << 8)) 102#define UWORD(array, index) (UBYTE(array[index]) + (UBYTE(array[(index) + 1]) << 8))
@@ -110,61 +110,61 @@ FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data)))
110#define CMR_BASS_TABLE_OFFSET 0x70f 110#define CMR_BASS_TABLE_OFFSET 0x70f
111 111
112CONST_ARRAY(byte, cmr_bass_table) 112CONST_ARRAY(byte, cmr_bass_table)
113 0x5C, 0x56, 0x50, 0x4D, 0x47, 0x44, 0x41, 0x3E, 113 0x5C, 0x56, 0x50, 0x4D, 0x47, 0x44, 0x41, 0x3E,
114 0x38, 0x35, CAST(byte) (0x88), 0x7F, 0x79, 0x73, 0x6C, 0x67, 114 0x38, 0x35, CAST(byte) (0x88), 0x7F, 0x79, 0x73, 0x6C, 0x67,
115 0x60, 0x5A, 0x55, 0x51, 0x4C, 0x48, 0x43, 0x3F, 115 0x60, 0x5A, 0x55, 0x51, 0x4C, 0x48, 0x43, 0x3F,
116 0x3D, 0x39, 0x34, 0x33, 0x30, 0x2D, 0x2A, 0x28, 116 0x3D, 0x39, 0x34, 0x33, 0x30, 0x2D, 0x2A, 0x28,
117 0x25, 0x24, 0x21, 0x1F, 0x1E 117 0x25, 0x24, 0x21, 0x1F, 0x1E
118END_CONST_ARRAY; 118END_CONST_ARRAY;
119 119
120CONST_ARRAY(int, perframe2fastplay) 120CONST_ARRAY(int, perframe2fastplay)
121 312, 312 / 2, 312 / 3, 312 / 4 121 312, 312 / 2, 312 / 3, 312 / 4
122END_CONST_ARRAY; 122END_CONST_ARRAY;
123 123
124/* Loads native module (anything except SAP) and 6502 player routine. */ 124/* Loads native module (anything except SAP) and 6502 player routine. */
125PRIVATE FUNC(abool, load_native, ( 125PRIVATE FUNC(abool, load_native, (
126 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 126 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
127 P(CONST BYTEARRAY, module), P(int, module_len), P(RESOURCE, player))) 127 P(CONST BYTEARRAY, module), P(int, module_len), P(RESOURCE, player)))
128{ 128{
129 V(int, player_last_byte); 129 V(int, player_last_byte);
130 V(int, music_last_byte); 130 V(int, music_last_byte);
131 V(int, block_len); 131 V(int, block_len);
132 if ((UBYTE(module[0]) != 0xff || UBYTE(module[1]) != 0xff) 132 if ((UBYTE(module[0]) != 0xff || UBYTE(module[1]) != 0xff)
133 && (module[0] != 0 || module[1] != 0)) /* some CMC and clones start with zeros */ 133 && (module[0] != 0 || module[1] != 0)) /* some CMC and clones start with zeros */
134 return FALSE; 134 return FALSE;
135 module_info _ player = UWORD(player, 2); 135 module_info _ player = UWORD(player, 2);
136 player_last_byte = UWORD(player, 4); 136 player_last_byte = UWORD(player, 4);
137 module_info _ music = UWORD(module, 2); 137 module_info _ music = UWORD(module, 2);
138 if (module_info _ music <= player_last_byte) 138 if (module_info _ music <= player_last_byte)
139 return FALSE; 139 return FALSE;
140 music_last_byte = UWORD(module, 4); 140 music_last_byte = UWORD(module, 4);
141 if (module_info _ music <= 0xd7ff && music_last_byte >= 0xd000) 141 if (module_info _ music <= 0xd7ff && music_last_byte >= 0xd000)
142 return FALSE; 142 return FALSE;
143 block_len = music_last_byte + 1 - module_info _ music; 143 block_len = music_last_byte + 1 - module_info _ music;
144 if (6 + block_len != module_len) { 144 if (6 + block_len != module_len) {
145 V(int, info_addr); 145 V(int, info_addr);
146 V(int, info_len); 146 V(int, info_len);
147 if (module_info _ type != ASAP_TYPE_RMT || 11 + block_len > module_len) 147 if (module_info _ type != ASAP_TYPE_RMT || 11 + block_len > module_len)
148 return FALSE; 148 return FALSE;
149 /* allow optional info for Raster Music Tracker */ 149 /* allow optional info for Raster Music Tracker */
150 info_addr = UWORD(module, 6 + block_len); 150 info_addr = UWORD(module, 6 + block_len);
151 if (info_addr != module_info _ music + block_len) 151 if (info_addr != module_info _ music + block_len)
152 return FALSE; 152 return FALSE;
153 info_len = UWORD(module, 8 + block_len) + 1 - info_addr; 153 info_len = UWORD(module, 8 + block_len) + 1 - info_addr;
154 if (10 + block_len + info_len != module_len) 154 if (10 + block_len + info_len != module_len)
155 return FALSE; 155 return FALSE;
156 } 156 }
157 if (ast != NULL) { 157 if (ast != NULL) {
158 COPY_ARRAY(ast _ memory, module_info _ music, module, 6, block_len); 158 COPY_ARRAY(ast _ memory, module_info _ music, module, 6, block_len);
159 COPY_ARRAY(ast _ memory, module_info _ player, player, 6, player_last_byte + 1 - module_info _ player); 159 COPY_ARRAY(ast _ memory, module_info _ player, player, 6, player_last_byte + 1 - module_info _ player);
160 } 160 }
161 return TRUE; 161 return TRUE;
162} 162}
163 163
164PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(int, player_calls))) 164PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(int, player_calls)))
165{ 165{
166 module_info _ durations[module_info _ songs] = TO_INT(player_calls * module_info _ fastplay * 114000.0 / 1773447); 166 module_info _ durations[module_info _ songs] = TO_INT(player_calls * module_info _ fastplay * 114000.0 / 1773447);
167 module_info _ songs++; 167 module_info _ songs++;
168} 168}
169 169
170#define SEEN_THIS_CALL 1 170#define SEEN_THIS_CALL 1
@@ -173,901 +173,901 @@ PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(in
173 173
174PRIVATE FUNC(void, parse_cmc_song, (P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) 174PRIVATE FUNC(void, parse_cmc_song, (P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos)))
175{ 175{
176 V(int, tempo) = UBYTE(module[0x19]); 176 V(int, tempo) = UBYTE(module[0x19]);
177 V(int, player_calls) = 0; 177 V(int, player_calls) = 0;
178 V(int, rep_start_pos) = 0; 178 V(int, rep_start_pos) = 0;
179 V(int, rep_end_pos) = 0; 179 V(int, rep_end_pos) = 0;
180 V(int, rep_times) = 0; 180 V(int, rep_times) = 0;
181 NEW_ARRAY(byte, seen, 0x55); 181 NEW_ARRAY(byte, seen, 0x55);
182 INIT_ARRAY(seen); 182 INIT_ARRAY(seen);
183 while (pos >= 0 && pos < 0x55) { 183 while (pos >= 0 && pos < 0x55) {
184 V(int, p1); 184 V(int, p1);
185 V(int, p2); 185 V(int, p2);
186 V(int, p3); 186 V(int, p3);
187 if (pos == rep_end_pos && rep_times > 0) { 187 if (pos == rep_end_pos && rep_times > 0) {
188 for (p1 = 0; p1 < 0x55; p1++) 188 for (p1 = 0; p1 < 0x55; p1++)
189 if (seen[p1] == SEEN_THIS_CALL || seen[p1] == SEEN_REPEAT) 189 if (seen[p1] == SEEN_THIS_CALL || seen[p1] == SEEN_REPEAT)
190 seen[p1] = 0; 190 seen[p1] = 0;
191 rep_times--; 191 rep_times--;
192 pos = rep_start_pos; 192 pos = rep_start_pos;
193 } 193 }
194 if (seen[pos] != 0) { 194 if (seen[pos] != 0) {
195 if (seen[pos] != SEEN_THIS_CALL) 195 if (seen[pos] != SEEN_THIS_CALL)
196 module_info _ loops[module_info _ songs] = TRUE; 196 module_info _ loops[module_info _ songs] = TRUE;
197 break; 197 break;
198 } 198 }
199 seen[pos] = SEEN_THIS_CALL; 199 seen[pos] = SEEN_THIS_CALL;
200 p1 = UBYTE(module[0x206 + pos]); 200 p1 = UBYTE(module[0x206 + pos]);
201 p2 = UBYTE(module[0x25b + pos]); 201 p2 = UBYTE(module[0x25b + pos]);
202 p3 = UBYTE(module[0x2b0 + pos]); 202 p3 = UBYTE(module[0x2b0 + pos]);
203 if (p1 == 0xfe || p2 == 0xfe || p3 == 0xfe) { 203 if (p1 == 0xfe || p2 == 0xfe || p3 == 0xfe) {
204 pos++; 204 pos++;
205 continue; 205 continue;
206 } 206 }
207 p1 >>= 4; 207 p1 >>= 4;
208 if (p1 == 8) 208 if (p1 == 8)
209 break; 209 break;
210 if (p1 == 9) { 210 if (p1 == 9) {
211 pos = p2; 211 pos = p2;
212 continue; 212 continue;
213 } 213 }
214 if (p1 == 0xa) { 214 if (p1 == 0xa) {
215 pos -= p2; 215 pos -= p2;
216 continue; 216 continue;
217 } 217 }
218 if (p1 == 0xb) { 218 if (p1 == 0xb) {
219 pos += p2; 219 pos += p2;
220 continue; 220 continue;
221 } 221 }
222 if (p1 == 0xc) { 222 if (p1 == 0xc) {
223 tempo = p2; 223 tempo = p2;
224 pos++; 224 pos++;
225 continue; 225 continue;
226 } 226 }
227 if (p1 == 0xd) { 227 if (p1 == 0xd) {
228 pos++; 228 pos++;
229 rep_start_pos = pos; 229 rep_start_pos = pos;
230 rep_end_pos = pos + p2; 230 rep_end_pos = pos + p2;
231 rep_times = p3 - 1; 231 rep_times = p3 - 1;
232 continue; 232 continue;
233 } 233 }
234 if (p1 == 0xe) { 234 if (p1 == 0xe) {
235 module_info _ loops[module_info _ songs] = TRUE; 235 module_info _ loops[module_info _ songs] = TRUE;
236 break; 236 break;
237 } 237 }
238 p2 = rep_times > 0 ? SEEN_REPEAT : SEEN_BEFORE; 238 p2 = rep_times > 0 ? SEEN_REPEAT : SEEN_BEFORE;
239 for (p1 = 0; p1 < 0x55; p1++) 239 for (p1 = 0; p1 < 0x55; p1++)
240 if (seen[p1] == SEEN_THIS_CALL) 240 if (seen[p1] == SEEN_THIS_CALL)
241 seen[p1] = CAST(byte) p2; 241 seen[p1] = CAST(byte) p2;
242 player_calls += tempo * (module_info _ type == ASAP_TYPE_CM3 ? 48 : 64); 242 player_calls += tempo * (module_info _ type == ASAP_TYPE_CM3 ? 48 : 64);
243 pos++; 243 pos++;
244 } 244 }
245 set_song_duration(module_info, player_calls); 245 set_song_duration(module_info, player_calls);
246} 246}
247 247
248PRIVATE FUNC(abool, parse_cmc, ( 248PRIVATE FUNC(abool, parse_cmc, (
249 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 249 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
250 P(CONST BYTEARRAY, module), P(int, module_len), P(int, type), P(RESOURCE, player))) 250 P(CONST BYTEARRAY, module), P(int, module_len), P(int, type), P(RESOURCE, player)))
251{ 251{
252 V(int, last_pos); 252 V(int, last_pos);
253 V(int, pos); 253 V(int, pos);
254 if (module_len < 0x306) 254 if (module_len < 0x306)
255 return FALSE; 255 return FALSE;
256 module_info _ type = type; 256 module_info _ type = type;
257 if (!load_native(ast, module_info, module, module_len, player)) 257 if (!load_native(ast, module_info, module, module_len, player))
258 return FALSE; 258 return FALSE;
259 if (ast != NULL && type == ASAP_TYPE_CMR) 259 if (ast != NULL && type == ASAP_TYPE_CMR)
260 COPY_ARRAY(ast _ memory, 0x500 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, 0, sizeof(cmr_bass_table)); 260 COPY_ARRAY(ast _ memory, 0x500 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, 0, sizeof(cmr_bass_table));
261 last_pos = 0x54; 261 last_pos = 0x54;
262 while (--last_pos >= 0) { 262 while (--last_pos >= 0) {
263 if (UBYTE(module[0x206 + last_pos]) < 0xb0 263 if (UBYTE(module[0x206 + last_pos]) < 0xb0
264 || UBYTE(module[0x25b + last_pos]) < 0x40 264 || UBYTE(module[0x25b + last_pos]) < 0x40
265 || UBYTE(module[0x2b0 + last_pos]) < 0x40) 265 || UBYTE(module[0x2b0 + last_pos]) < 0x40)
266 break; 266 break;
267 if (module_info _ channels == 2) { 267 if (module_info _ channels == 2) {
268 if (UBYTE(module[0x306 + last_pos]) < 0xb0 268 if (UBYTE(module[0x306 + last_pos]) < 0xb0
269 || UBYTE(module[0x35b + last_pos]) < 0x40 269 || UBYTE(module[0x35b + last_pos]) < 0x40
270 || UBYTE(module[0x3b0 + last_pos]) < 0x40) 270 || UBYTE(module[0x3b0 + last_pos]) < 0x40)
271 break; 271 break;
272 } 272 }
273 } 273 }
274 module_info _ songs = 0; 274 module_info _ songs = 0;
275 parse_cmc_song(module_info, module, 0); 275 parse_cmc_song(module_info, module, 0);
276 for (pos = 0; pos < last_pos && module_info _ songs < ASAP_SONGS_MAX; pos++) 276 for (pos = 0; pos < last_pos && module_info _ songs < ASAP_SONGS_MAX; pos++)
277 if (UBYTE(module[0x206 + pos]) == 0x8f || UBYTE(module[0x206 + pos]) == 0xef) 277 if (UBYTE(module[0x206 + pos]) == 0x8f || UBYTE(module[0x206 + pos]) == 0xef)
278 parse_cmc_song(module_info, module, pos + 1); 278 parse_cmc_song(module_info, module, pos + 1);
279 return TRUE; 279 return TRUE;
280} 280}
281 281
282PRIVATE FUNC(abool, is_dlt_track_empty, (P(CONST BYTEARRAY, module), P(int, pos))) 282PRIVATE FUNC(abool, is_dlt_track_empty, (P(CONST BYTEARRAY, module), P(int, pos)))
283{ 283{
284 return UBYTE(module[0x2006 + pos]) >= 0x43 284 return UBYTE(module[0x2006 + pos]) >= 0x43
285 && UBYTE(module[0x2106 + pos]) >= 0x40 285 && UBYTE(module[0x2106 + pos]) >= 0x40
286 && UBYTE(module[0x2206 + pos]) >= 0x40 286 && UBYTE(module[0x2206 + pos]) >= 0x40
287 && UBYTE(module[0x2306 + pos]) >= 0x40; 287 && UBYTE(module[0x2306 + pos]) >= 0x40;
288} 288}
289 289
290PRIVATE FUNC(abool, is_dlt_pattern_end, (P(CONST BYTEARRAY, module), P(int, pos), P(int, i))) 290PRIVATE FUNC(abool, is_dlt_pattern_end, (P(CONST BYTEARRAY, module), P(int, pos), P(int, i)))
291{ 291{
292 V(int, ch); 292 V(int, ch);
293 for (ch = 0; ch < 4; ch++) { 293 for (ch = 0; ch < 4; ch++) {
294 V(int, pattern) = UBYTE(module[0x2006 + (ch << 8) + pos]); 294 V(int, pattern) = UBYTE(module[0x2006 + (ch << 8) + pos]);
295 if (pattern < 64) { 295 if (pattern < 64) {
296 V(int, offset) = 6 + (pattern << 7) + (i << 1); 296 V(int, offset) = 6 + (pattern << 7) + (i << 1);
297 if ((module[offset] & 0x80) == 0 && (module[offset + 1] & 0x80) != 0) 297 if ((module[offset] & 0x80) == 0 && (module[offset + 1] & 0x80) != 0)
298 return TRUE; 298 return TRUE;
299 } 299 }
300 } 300 }
301 return FALSE; 301 return FALSE;
302} 302}
303 303
304PRIVATE FUNC(void, parse_dlt_song, ( 304PRIVATE FUNC(void, parse_dlt_song, (
305 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), 305 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module),
306 P(BOOLARRAY, seen), P(int, pos))) 306 P(BOOLARRAY, seen), P(int, pos)))
307{ 307{
308 V(int, player_calls) = 0; 308 V(int, player_calls) = 0;
309 V(abool, loop) = FALSE; 309 V(abool, loop) = FALSE;
310 V(int, tempo) = 6; 310 V(int, tempo) = 6;
311 while (pos < 128 && !seen[pos] && is_dlt_track_empty(module, pos)) 311 while (pos < 128 && !seen[pos] && is_dlt_track_empty(module, pos))
312 seen[pos++] = TRUE; 312 seen[pos++] = TRUE;
313 module_info _ song_pos[module_info _ songs] = CAST(byte) pos; 313 module_info _ song_pos[module_info _ songs] = CAST(byte) pos;
314 while (pos < 128) { 314 while (pos < 128) {
315 V(int, p1); 315 V(int, p1);
316 if (seen[pos]) { 316 if (seen[pos]) {
317 loop = TRUE; 317 loop = TRUE;
318 break; 318 break;
319 } 319 }
320 seen[pos] = TRUE; 320 seen[pos] = TRUE;
321 p1 = module[0x2006 + pos]; 321 p1 = module[0x2006 + pos];
322 if (p1 == 0x40 || is_dlt_track_empty(module, pos)) 322 if (p1 == 0x40 || is_dlt_track_empty(module, pos))
323 break; 323 break;
324 if (p1 == 0x41) 324 if (p1 == 0x41)
325 pos = UBYTE(module[0x2086 + pos]); 325 pos = UBYTE(module[0x2086 + pos]);
326 else if (p1 == 0x42) 326 else if (p1 == 0x42)
327 tempo = UBYTE(module[0x2086 + pos++]); 327 tempo = UBYTE(module[0x2086 + pos++]);
328 else { 328 else {
329 V(int, i); 329 V(int, i);
330 for (i = 0; i < 64 && !is_dlt_pattern_end(module, pos, i); i++) 330 for (i = 0; i < 64 && !is_dlt_pattern_end(module, pos, i); i++)
331 player_calls += tempo; 331 player_calls += tempo;
332 pos++; 332 pos++;
333 } 333 }
334 } 334 }
335 if (player_calls > 0) { 335 if (player_calls > 0) {
336 module_info _ loops[module_info _ songs] = loop; 336 module_info _ loops[module_info _ songs] = loop;
337 set_song_duration(module_info, player_calls); 337 set_song_duration(module_info, player_calls);
338 } 338 }
339} 339}
340 340
341PRIVATE FUNC(abool, parse_dlt, ( 341PRIVATE FUNC(abool, parse_dlt, (
342 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 342 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
343 P(CONST BYTEARRAY, module), P(int, module_len))) 343 P(CONST BYTEARRAY, module), P(int, module_len)))
344{ 344{
345 V(int, pos); 345 V(int, pos);
346 NEW_ARRAY(abool, seen, 128); 346 NEW_ARRAY(abool, seen, 128);
347 if (module_len == 0x2c06) { 347 if (module_len == 0x2c06) {
348 if (ast != NULL) 348 if (ast != NULL)
349 ast _ memory[0x4c00] = 0; 349 ast _ memory[0x4c00] = 0;
350 } 350 }
351 else if (module_len != 0x2c07) 351 else if (module_len != 0x2c07)
352 return FALSE; 352 return FALSE;
353 module_info _ type = ASAP_TYPE_DLT; 353 module_info _ type = ASAP_TYPE_DLT;
354 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(dlt, obx)) 354 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(dlt, obx))
355 || module_info _ music != 0x2000) { 355 || module_info _ music != 0x2000) {
356 return FALSE; 356 return FALSE;
357 } 357 }
358 INIT_ARRAY(seen); 358 INIT_ARRAY(seen);
359 module_info _ songs = 0; 359 module_info _ songs = 0;
360 for (pos = 0; pos < 128 && module_info _ songs < ASAP_SONGS_MAX; pos++) { 360 for (pos = 0; pos < 128 && module_info _ songs < ASAP_SONGS_MAX; pos++) {
361 if (!seen[pos]) 361 if (!seen[pos])
362 parse_dlt_song(module_info, module, seen, pos); 362 parse_dlt_song(module_info, module, seen, pos);
363 } 363 }
364 return module_info _ songs > 0; 364 return module_info _ songs > 0;
365} 365}
366 366
367PRIVATE FUNC(void, parse_mpt_song, ( 367PRIVATE FUNC(void, parse_mpt_song, (
368 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), 368 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module),
369 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos))) 369 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos)))
370{ 370{
371 V(int, addr_to_offset) = UWORD(module, 2) - 6; 371 V(int, addr_to_offset) = UWORD(module, 2) - 6;
372 V(int, tempo) = UBYTE(module[0x1cf]); 372 V(int, tempo) = UBYTE(module[0x1cf]);
373 V(int, player_calls) = 0; 373 V(int, player_calls) = 0;
374 NEW_ARRAY(byte, seen, 256); 374 NEW_ARRAY(byte, seen, 256);
375 NEW_ARRAY(int, pattern_offset, 4); 375 NEW_ARRAY(int, pattern_offset, 4);
376 NEW_ARRAY(int, blank_rows, 4); 376 NEW_ARRAY(int, blank_rows, 4);
377 NEW_ARRAY(int, blank_rows_counter, 4); 377 NEW_ARRAY(int, blank_rows_counter, 4);
378 INIT_ARRAY(seen); 378 INIT_ARRAY(seen);
379 INIT_ARRAY(blank_rows); 379 INIT_ARRAY(blank_rows);
380 while (pos < song_len) { 380 while (pos < song_len) {
381 V(int, i); 381 V(int, i);
382 V(int, ch); 382 V(int, ch);
383 V(int, pattern_rows); 383 V(int, pattern_rows);
384 if (seen[pos] != 0) { 384 if (seen[pos] != 0) {
385 if (seen[pos] != SEEN_THIS_CALL) 385 if (seen[pos] != SEEN_THIS_CALL)
386 module_info _ loops[module_info _ songs] = TRUE; 386 module_info _ loops[module_info _ songs] = TRUE;
387 break; 387 break;
388 } 388 }
389 seen[pos] = SEEN_THIS_CALL; 389 seen[pos] = SEEN_THIS_CALL;
390 global_seen[pos] = TRUE; 390 global_seen[pos] = TRUE;
391 i = UBYTE(module[0x1d0 + pos * 2]); 391 i = UBYTE(module[0x1d0 + pos * 2]);
392 if (i == 0xff) { 392 if (i == 0xff) {
393 pos = UBYTE(module[0x1d1 + pos * 2]); 393 pos = UBYTE(module[0x1d1 + pos * 2]);
394 continue; 394 continue;
395 } 395 }
396 for (ch = 3; ch >= 0; ch--) { 396 for (ch = 3; ch >= 0; ch--) {
397 i = UBYTE(module[0x1c6 + ch]) + (UBYTE(module[0x1ca + ch]) << 8) - addr_to_offset; 397 i = UBYTE(module[0x1c6 + ch]) + (UBYTE(module[0x1ca + ch]) << 8) - addr_to_offset;
398 i = UBYTE(module[i + pos * 2]); 398 i = UBYTE(module[i + pos * 2]);
399 if (i >= 0x40) 399 if (i >= 0x40)
400 break; 400 break;
401 i <<= 1; 401 i <<= 1;
402 i = UWORD(module, 0x46 + i); 402 i = UWORD(module, 0x46 + i);
403 pattern_offset[ch] = i == 0 ? 0 : i - addr_to_offset; 403 pattern_offset[ch] = i == 0 ? 0 : i - addr_to_offset;
404 blank_rows_counter[ch] = 0; 404 blank_rows_counter[ch] = 0;
405 } 405 }
406 if (ch >= 0) 406 if (ch >= 0)
407 break; 407 break;
408 for (i = 0; i < song_len; i++) 408 for (i = 0; i < song_len; i++)
409 if (seen[i] == SEEN_THIS_CALL) 409 if (seen[i] == SEEN_THIS_CALL)
410 seen[i] = SEEN_BEFORE; 410 seen[i] = SEEN_BEFORE;
411 for (pattern_rows = UBYTE(module[0x1ce]); --pattern_rows >= 0; ) { 411 for (pattern_rows = UBYTE(module[0x1ce]); --pattern_rows >= 0; ) {
412 for (ch = 3; ch >= 0; ch--) { 412 for (ch = 3; ch >= 0; ch--) {
413 if (pattern_offset[ch] == 0 || --blank_rows_counter[ch] >= 0) 413 if (pattern_offset[ch] == 0 || --blank_rows_counter[ch] >= 0)
414 continue; 414 continue;
415 for (;;) { 415 for (;;) {
416 i = UBYTE(module[pattern_offset[ch]++]); 416 i = UBYTE(module[pattern_offset[ch]++]);
417 if (i < 0x40 || i == 0xfe) 417 if (i < 0x40 || i == 0xfe)
418 break; 418 break;
419 if (i < 0x80) 419 if (i < 0x80)
420 continue; 420 continue;
421 if (i < 0xc0) { 421 if (i < 0xc0) {
422 blank_rows[ch] = i - 0x80; 422 blank_rows[ch] = i - 0x80;
423 continue; 423 continue;
424 } 424 }
425 if (i < 0xd0) 425 if (i < 0xd0)
426 continue; 426 continue;
427 if (i < 0xe0) { 427 if (i < 0xe0) {
428 tempo = i - 0xcf; 428 tempo = i - 0xcf;
429 continue; 429 continue;
430 } 430 }
431 pattern_rows = 0; 431 pattern_rows = 0;
432 } 432 }
433 blank_rows_counter[ch] = blank_rows[ch]; 433 blank_rows_counter[ch] = blank_rows[ch];
434 } 434 }
435 player_calls += tempo; 435 player_calls += tempo;
436 } 436 }
437 pos++; 437 pos++;
438 } 438 }
439 if (player_calls > 0) 439 if (player_calls > 0)
440 set_song_duration(module_info, player_calls); 440 set_song_duration(module_info, player_calls);
441} 441}
442 442
443PRIVATE FUNC(abool, parse_mpt, ( 443PRIVATE FUNC(abool, parse_mpt, (
444 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 444 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
445 P(CONST BYTEARRAY, module), P(int, module_len))) 445 P(CONST BYTEARRAY, module), P(int, module_len)))
446{ 446{
447 V(int, track0_addr); 447 V(int, track0_addr);
448 V(int, pos); 448 V(int, pos);
449 V(int, song_len); 449 V(int, song_len);
450 /* seen[i] == TRUE if the track position i has been processed */ 450 /* seen[i] == TRUE if the track position i has been processed */
451 NEW_ARRAY(abool, global_seen, 256); 451 NEW_ARRAY(abool, global_seen, 256);
452 if (module_len < 0x1d0) 452 if (module_len < 0x1d0)
453 return FALSE; 453 return FALSE;
454 module_info _ type = ASAP_TYPE_MPT; 454 module_info _ type = ASAP_TYPE_MPT;
455 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(mpt, obx))) 455 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(mpt, obx)))
456 return FALSE; 456 return FALSE;
457 track0_addr = UWORD(module, 2) + 0x1ca; 457 track0_addr = UWORD(module, 2) + 0x1ca;
458 if (UBYTE(module[0x1c6]) + (UBYTE(module[0x1ca]) << 8) != track0_addr) 458 if (UBYTE(module[0x1c6]) + (UBYTE(module[0x1ca]) << 8) != track0_addr)
459 return FALSE; 459 return FALSE;
460 /* Calculate the length of the first track. Address of the second track minus 460 /* Calculate the length of the first track. Address of the second track minus
461 address of the first track equals the length of the first track in bytes. 461 address of the first track equals the length of the first track in bytes.
462 Divide by two to get number of track positions. */ 462 Divide by two to get number of track positions. */
463 song_len = (UBYTE(module[0x1c7]) + (UBYTE(module[0x1cb]) << 8) - track0_addr) >> 1; 463 song_len = (UBYTE(module[0x1c7]) + (UBYTE(module[0x1cb]) << 8) - track0_addr) >> 1;
464 if (song_len > 0xfe) 464 if (song_len > 0xfe)
465 return FALSE; 465 return FALSE;
466 INIT_ARRAY(global_seen); 466 INIT_ARRAY(global_seen);
467 module_info _ songs = 0; 467 module_info _ songs = 0;
468 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { 468 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) {
469 if (!global_seen[pos]) { 469 if (!global_seen[pos]) {
470 module_info _ song_pos[module_info _ songs] = CAST(byte) pos; 470 module_info _ song_pos[module_info _ songs] = CAST(byte) pos;
471 parse_mpt_song(module_info, module, global_seen, song_len, pos); 471 parse_mpt_song(module_info, module, global_seen, song_len, pos);
472 } 472 }
473 } 473 }
474 return module_info _ songs > 0; 474 return module_info _ songs > 0;
475} 475}
476 476
477CONST_ARRAY(byte, rmt_volume_silent) 477CONST_ARRAY(byte, rmt_volume_silent)
478 16, 8, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 478 16, 8, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1
479END_CONST_ARRAY; 479END_CONST_ARRAY;
480 480
481PRIVATE FUNC(int, rmt_instrument_frames, ( 481PRIVATE FUNC(int, rmt_instrument_frames, (
482 P(CONST BYTEARRAY, module), P(int, instrument), 482 P(CONST BYTEARRAY, module), P(int, instrument),
483 P(int, volume), P(int, volume_frame), P(abool, extra_pokey))) 483 P(int, volume), P(int, volume_frame), P(abool, extra_pokey)))
484{ 484{
485 V(int, addr_to_offset) = UWORD(module, 2) - 6; 485 V(int, addr_to_offset) = UWORD(module, 2) - 6;
486 V(int, per_frame) = module[0xc]; 486 V(int, per_frame) = module[0xc];
487 V(int, player_call); 487 V(int, player_call);
488 V(int, player_calls); 488 V(int, player_calls);
489 V(int, index); 489 V(int, index);
490 V(int, index_end); 490 V(int, index_end);
491 V(int, index_loop); 491 V(int, index_loop);
492 V(int, volume_slide_depth); 492 V(int, volume_slide_depth);
493 V(int, volume_min); 493 V(int, volume_min);
494 V(int, volume_slide); 494 V(int, volume_slide);
495 V(abool, silent_loop); 495 V(abool, silent_loop);
496 instrument = UWORD(module, 0xe) - addr_to_offset + (instrument << 1); 496 instrument = UWORD(module, 0xe) - addr_to_offset + (instrument << 1);
497 if (module[instrument + 1] == 0) 497 if (module[instrument + 1] == 0)
498 return 0; 498 return 0;
499 instrument = UWORD(module, instrument) - addr_to_offset; 499 instrument = UWORD(module, instrument) - addr_to_offset;
500 player_calls = player_call = volume_frame * per_frame; 500 player_calls = player_call = volume_frame * per_frame;
501 index = UBYTE(module[instrument]) + 1 + player_call * 3; 501 index = UBYTE(module[instrument]) + 1 + player_call * 3;
502 index_end = UBYTE(module[instrument + 2]) + 3; 502 index_end = UBYTE(module[instrument + 2]) + 3;
503 index_loop = UBYTE(module[instrument + 3]); 503 index_loop = UBYTE(module[instrument + 3]);
504 if (index_loop >= index_end) 504 if (index_loop >= index_end)
505 return 0; /* error */ 505 return 0; /* error */
506 volume_slide_depth = UBYTE(module[instrument + 6]); 506 volume_slide_depth = UBYTE(module[instrument + 6]);
507 volume_min = UBYTE(module[instrument + 7]); 507 volume_min = UBYTE(module[instrument + 7]);
508 if (index >= index_end) 508 if (index >= index_end)
509 index = (index - index_end) % (index_end - index_loop) + index_loop; 509 index = (index - index_end) % (index_end - index_loop) + index_loop;
510 else { 510 else {
511 do { 511 do {
512 V(int, vol) = module[instrument + index]; 512 V(int, vol) = module[instrument + index];
513 if (extra_pokey) 513 if (extra_pokey)
514 vol >>= 4; 514 vol >>= 4;
515 if ((vol & 0xf) >= rmt_volume_silent[volume]) 515 if ((vol & 0xf) >= rmt_volume_silent[volume])
516 player_calls = player_call + 1; 516 player_calls = player_call + 1;
517 player_call++; 517 player_call++;
518 index += 3; 518 index += 3;
519 } while (index < index_end); 519 } while (index < index_end);
520 } 520 }
521 if (volume_slide_depth == 0) 521 if (volume_slide_depth == 0)
522 return player_calls / per_frame; 522 return player_calls / per_frame;
523 volume_slide = 128; 523 volume_slide = 128;
524 silent_loop = FALSE; 524 silent_loop = FALSE;
525 for (;;) { 525 for (;;) {
526 V(int, vol); 526 V(int, vol);
527 if (index >= index_end) { 527 if (index >= index_end) {
528 if (silent_loop) 528 if (silent_loop)
529 break; 529 break;
530 silent_loop = TRUE; 530 silent_loop = TRUE;
531 index = index_loop; 531 index = index_loop;
532 } 532 }
533 vol = module[instrument + index]; 533 vol = module[instrument + index];
534 if (extra_pokey) 534 if (extra_pokey)
535 vol >>= 4; 535 vol >>= 4;
536 if ((vol & 0xf) >= rmt_volume_silent[volume]) { 536 if ((vol & 0xf) >= rmt_volume_silent[volume]) {
537 player_calls = player_call + 1; 537 player_calls = player_call + 1;
538 silent_loop = FALSE; 538 silent_loop = FALSE;
539 } 539 }
540 player_call++; 540 player_call++;
541 index += 3; 541 index += 3;
542 volume_slide -= volume_slide_depth; 542 volume_slide -= volume_slide_depth;
543 if (volume_slide < 0) { 543 if (volume_slide < 0) {
544 volume_slide += 256; 544 volume_slide += 256;
545 if (--volume <= volume_min) 545 if (--volume <= volume_min)
546 break; 546 break;
547 } 547 }
548 } 548 }
549 return player_calls / per_frame; 549 return player_calls / per_frame;
550} 550}
551 551
552PRIVATE FUNC(void, parse_rmt_song, ( 552PRIVATE FUNC(void, parse_rmt_song, (
553 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), 553 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module),
554 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos_shift), P(int, pos))) 554 P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos_shift), P(int, pos)))
555{ 555{
556 V(int, ch); 556 V(int, ch);
557 V(int, addr_to_offset) = UWORD(module, 2) - 6; 557 V(int, addr_to_offset) = UWORD(module, 2) - 6;
558 V(int, tempo) = UBYTE(module[0xb]); 558 V(int, tempo) = UBYTE(module[0xb]);
559 V(int, frames) = 0; 559 V(int, frames) = 0;
560 V(int, song_offset) = UWORD(module, 0x14) - addr_to_offset; 560 V(int, song_offset) = UWORD(module, 0x14) - addr_to_offset;
561 V(int, pattern_lo_offset) = UWORD(module, 0x10) - addr_to_offset; 561 V(int, pattern_lo_offset) = UWORD(module, 0x10) - addr_to_offset;
562 V(int, pattern_hi_offset) = UWORD(module, 0x12) - addr_to_offset; 562 V(int, pattern_hi_offset) = UWORD(module, 0x12) - addr_to_offset;
563 V(int, instrument_frames); 563 V(int, instrument_frames);
564 NEW_ARRAY(byte, seen, 256); 564 NEW_ARRAY(byte, seen, 256);
565 NEW_ARRAY(int, pattern_begin, 8); 565 NEW_ARRAY(int, pattern_begin, 8);
566 NEW_ARRAY(int, pattern_offset, 8); 566 NEW_ARRAY(int, pattern_offset, 8);
567 NEW_ARRAY(int, blank_rows, 8); 567 NEW_ARRAY(int, blank_rows, 8);
568 NEW_ARRAY(int, instrument_no, 8); 568 NEW_ARRAY(int, instrument_no, 8);
569 NEW_ARRAY(int, instrument_frame, 8); 569 NEW_ARRAY(int, instrument_frame, 8);
570 NEW_ARRAY(int, volume_value, 8); 570 NEW_ARRAY(int, volume_value, 8);
571 NEW_ARRAY(int, volume_frame, 8); 571 NEW_ARRAY(int, volume_frame, 8);
572 INIT_ARRAY(seen); 572 INIT_ARRAY(seen);
573 INIT_ARRAY(instrument_no); 573 INIT_ARRAY(instrument_no);
574 INIT_ARRAY(instrument_frame); 574 INIT_ARRAY(instrument_frame);
575 INIT_ARRAY(volume_value); 575 INIT_ARRAY(volume_value);
576 INIT_ARRAY(volume_frame); 576 INIT_ARRAY(volume_frame);
577 while (pos < song_len) { 577 while (pos < song_len) {
578 V(int, i); 578 V(int, i);
579 V(int, pattern_rows); 579 V(int, pattern_rows);
580 if (seen[pos] != 0) { 580 if (seen[pos] != 0) {
581 if (seen[pos] != SEEN_THIS_CALL) 581 if (seen[pos] != SEEN_THIS_CALL)
582 module_info _ loops[module_info _ songs] = TRUE; 582 module_info _ loops[module_info _ songs] = TRUE;
583 break; 583 break;
584 } 584 }
585 seen[pos] = SEEN_THIS_CALL; 585 seen[pos] = SEEN_THIS_CALL;
586 global_seen[pos] = TRUE; 586 global_seen[pos] = TRUE;
587 if (UBYTE(module[song_offset + (pos << pos_shift)]) == 0xfe) { 587 if (UBYTE(module[song_offset + (pos << pos_shift)]) == 0xfe) {
588 pos = UBYTE(module[song_offset + (pos << pos_shift) + 1]); 588 pos = UBYTE(module[song_offset + (pos << pos_shift) + 1]);
589 continue; 589 continue;
590 } 590 }
591 for (ch = 0; ch < 1 << pos_shift; ch++) { 591 for (ch = 0; ch < 1 << pos_shift; ch++) {
592 i = UBYTE(module[song_offset + (pos << pos_shift) + ch]); 592 i = UBYTE(module[song_offset + (pos << pos_shift) + ch]);
593 if (i == 0xff) 593 if (i == 0xff)
594 blank_rows[ch] = 256; 594 blank_rows[ch] = 256;
595 else { 595 else {
596 pattern_offset[ch] = pattern_begin[ch] = UBYTE(module[pattern_lo_offset + i]) 596 pattern_offset[ch] = pattern_begin[ch] = UBYTE(module[pattern_lo_offset + i])
597 + (UBYTE(module[pattern_hi_offset + i]) << 8) - addr_to_offset; 597 + (UBYTE(module[pattern_hi_offset + i]) << 8) - addr_to_offset;
598 blank_rows[ch] = 0; 598 blank_rows[ch] = 0;
599 } 599 }
600 } 600 }
601 for (i = 0; i < song_len; i++) 601 for (i = 0; i < song_len; i++)
602 if (seen[i] == SEEN_THIS_CALL) 602 if (seen[i] == SEEN_THIS_CALL)
603 seen[i] = SEEN_BEFORE; 603 seen[i] = SEEN_BEFORE;
604 for (pattern_rows = UBYTE(module[0xa]); --pattern_rows >= 0; ) { 604 for (pattern_rows = UBYTE(module[0xa]); --pattern_rows >= 0; ) {
605 for (ch = 0; ch < 1 << pos_shift; ch++) { 605 for (ch = 0; ch < 1 << pos_shift; ch++) {
606 if (--blank_rows[ch] > 0) 606 if (--blank_rows[ch] > 0)
607 continue; 607 continue;
608 for (;;) { 608 for (;;) {
609 i = UBYTE(module[pattern_offset[ch]++]); 609 i = UBYTE(module[pattern_offset[ch]++]);
610 if ((i & 0x3f) < 62) { 610 if ((i & 0x3f) < 62) {
611 i += UBYTE(module[pattern_offset[ch]++]) << 8; 611 i += UBYTE(module[pattern_offset[ch]++]) << 8;
612 if ((i & 0x3f) != 61) { 612 if ((i & 0x3f) != 61) {
613 instrument_no[ch] = i >> 10; 613 instrument_no[ch] = i >> 10;
614 instrument_frame[ch] = frames; 614 instrument_frame[ch] = frames;
615 } 615 }
616 volume_value[ch] = (i >> 6) & 0xf; 616 volume_value[ch] = (i >> 6) & 0xf;
617 volume_frame[ch] = frames; 617 volume_frame[ch] = frames;
618 break; 618 break;
619 } 619 }
620 if (i == 62) { 620 if (i == 62) {
621 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); 621 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]);
622 break; 622 break;
623 } 623 }
624 if ((i & 0x3f) == 62) { 624 if ((i & 0x3f) == 62) {
625 blank_rows[ch] = i >> 6; 625 blank_rows[ch] = i >> 6;
626 break; 626 break;
627 } 627 }
628 if ((i & 0xbf) == 63) { 628 if ((i & 0xbf) == 63) {
629 tempo = UBYTE(module[pattern_offset[ch]++]); 629 tempo = UBYTE(module[pattern_offset[ch]++]);
630 continue; 630 continue;
631 } 631 }
632 if (i == 0xbf) { 632 if (i == 0xbf) {
633 pattern_offset[ch] = pattern_begin[ch] + UBYTE(module[pattern_offset[ch]]); 633 pattern_offset[ch] = pattern_begin[ch] + UBYTE(module[pattern_offset[ch]]);
634 continue; 634 continue;
635 } 635 }
636 /* assert(i == 0xff); */ 636 /* assert(i == 0xff); */
637 pattern_rows = -1; 637 pattern_rows = -1;
638 break; 638 break;
639 } 639 }
640 if (pattern_rows < 0) 640 if (pattern_rows < 0)
641 break; 641 break;
642 } 642 }
643 if (pattern_rows >= 0) 643 if (pattern_rows >= 0)
644 frames += tempo; 644 frames += tempo;
645 } 645 }
646 pos++; 646 pos++;
647 } 647 }
648 instrument_frames = 0; 648 instrument_frames = 0;
649 for (ch = 0; ch < 1 << pos_shift; ch++) { 649 for (ch = 0; ch < 1 << pos_shift; ch++) {
650 V(int, frame) = instrument_frame[ch]; 650 V(int, frame) = instrument_frame[ch];
651 frame += rmt_instrument_frames(module, instrument_no[ch], volume_value[ch], volume_frame[ch] - frame, ch >= 4); 651 frame += rmt_instrument_frames(module, instrument_no[ch], volume_value[ch], volume_frame[ch] - frame, ch >= 4);
652 if (instrument_frames < frame) 652 if (instrument_frames < frame)
653 instrument_frames = frame; 653 instrument_frames = frame;
654 } 654 }
655 if (frames > instrument_frames) { 655 if (frames > instrument_frames) {
656 if (frames - instrument_frames > 100) 656 if (frames - instrument_frames > 100)
657 module_info _ loops[module_info _ songs] = FALSE; 657 module_info _ loops[module_info _ songs] = FALSE;
658 frames = instrument_frames; 658 frames = instrument_frames;
659 } 659 }
660 if (frames > 0) 660 if (frames > 0)
661 set_song_duration(module_info, frames); 661 set_song_duration(module_info, frames);
662} 662}
663 663
664PRIVATE FUNC(abool, parse_rmt, ( 664PRIVATE FUNC(abool, parse_rmt, (
665 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 665 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
666 P(CONST BYTEARRAY, module), P(int, module_len))) 666 P(CONST BYTEARRAY, module), P(int, module_len)))
667{ 667{
668 V(int, per_frame); 668 V(int, per_frame);
669 V(int, pos_shift); 669 V(int, pos_shift);
670 V(int, song_len); 670 V(int, song_len);
671 V(int, pos); 671 V(int, pos);
672 NEW_ARRAY(abool, global_seen, 256); 672 NEW_ARRAY(abool, global_seen, 256);
673 if (module_len < 0x30 || module[6] != CHARCODE('R') || module[7] != CHARCODE('M') 673 if (module_len < 0x30 || module[6] != CHARCODE('R') || module[7] != CHARCODE('M')
674 || module[8] != CHARCODE('T') || module[0xd] != 1) 674 || module[8] != CHARCODE('T') || module[0xd] != 1)
675 return FALSE; 675 return FALSE;
676 switch (CAST(char) module[9]) { 676 switch (CAST(char) module[9]) {
677 case CHARCODE('4'): 677 case CHARCODE('4'):
678 pos_shift = 2; 678 pos_shift = 2;
679 break; 679 break;
680 case CHARCODE('8'): 680 case CHARCODE('8'):
681 module_info _ channels = 2; 681 module_info _ channels = 2;
682 pos_shift = 3; 682 pos_shift = 3;
683 break; 683 break;
684 default: 684 default:
685 return FALSE; 685 return FALSE;
686 } 686 }
687 per_frame = module[0xc]; 687 per_frame = module[0xc];
688 if (per_frame < 1 || per_frame > 4) 688 if (per_frame < 1 || per_frame > 4)
689 return FALSE; 689 return FALSE;
690 module_info _ type = ASAP_TYPE_RMT; 690 module_info _ type = ASAP_TYPE_RMT;
691 if (!load_native(ast, module_info, module, module_len, 691 if (!load_native(ast, module_info, module, module_len,
692 module_info _ channels == 2 ? GET_RESOURCE(rmt8, obx) : GET_RESOURCE(rmt4, obx))) 692 module_info _ channels == 2 ? GET_RESOURCE(rmt8, obx) : GET_RESOURCE(rmt4, obx)))
693 return FALSE; 693 return FALSE;
694 song_len = UWORD(module, 4) + 1 - UWORD(module, 0x14); 694 song_len = UWORD(module, 4) + 1 - UWORD(module, 0x14);
695 if (pos_shift == 3 && (song_len & 4) != 0 695 if (pos_shift == 3 && (song_len & 4) != 0
696 && UBYTE(module[6 + UWORD(module, 4) - UWORD(module, 2) - 3]) == 0xfe) 696 && UBYTE(module[6 + UWORD(module, 4) - UWORD(module, 2) - 3]) == 0xfe)
697 song_len += 4; 697 song_len += 4;
698 song_len >>= pos_shift; 698 song_len >>= pos_shift;
699 if (song_len >= 0x100) 699 if (song_len >= 0x100)
700 return FALSE; 700 return FALSE;
701 INIT_ARRAY(global_seen); 701 INIT_ARRAY(global_seen);
702 module_info _ songs = 0; 702 module_info _ songs = 0;
703 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { 703 for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) {
704 if (!global_seen[pos]) { 704 if (!global_seen[pos]) {
705 module_info _ song_pos[module_info _ songs] = CAST(byte) pos; 705 module_info _ song_pos[module_info _ songs] = CAST(byte) pos;
706 parse_rmt_song(module_info, module, global_seen, song_len, pos_shift, pos); 706 parse_rmt_song(module_info, module, global_seen, song_len, pos_shift, pos);
707 } 707 }
708 } 708 }
709 /* must set fastplay after song durations calculations, so they assume 312 */ 709 /* must set fastplay after song durations calculations, so they assume 312 */
710 module_info _ fastplay = perframe2fastplay[per_frame - 1]; 710 module_info _ fastplay = perframe2fastplay[per_frame - 1];
711 module_info _ player = 0x600; 711 module_info _ player = 0x600;
712 return module_info _ songs > 0; 712 return module_info _ songs > 0;
713} 713}
714 714
715PRIVATE FUNC(void, parse_tmc_song, ( 715PRIVATE FUNC(void, parse_tmc_song, (
716 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) 716 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos)))
717{ 717{
718 V(int, addr_to_offset) = UWORD(module, 2) - 6; 718 V(int, addr_to_offset) = UWORD(module, 2) - 6;
719 V(int, tempo) = UBYTE(module[0x24]) + 1; 719 V(int, tempo) = UBYTE(module[0x24]) + 1;
720 V(int, frames) = 0; 720 V(int, frames) = 0;
721 NEW_ARRAY(int, pattern_offset, 8); 721 NEW_ARRAY(int, pattern_offset, 8);
722 NEW_ARRAY(int, blank_rows, 8); 722 NEW_ARRAY(int, blank_rows, 8);
723 while (UBYTE(module[0x1a6 + 15 + pos]) < 0x80) { 723 while (UBYTE(module[0x1a6 + 15 + pos]) < 0x80) {
724 V(int, ch); 724 V(int, ch);
725 V(int, pattern_rows); 725 V(int, pattern_rows);
726 for (ch = 7; ch >= 0; ch--) { 726 for (ch = 7; ch >= 0; ch--) {
727 V(int, pat) = UBYTE(module[0x1a6 + 15 + pos - 2 * ch]); 727 V(int, pat) = UBYTE(module[0x1a6 + 15 + pos - 2 * ch]);
728 pattern_offset[ch] = UBYTE(module[0xa6 + pat]) + (UBYTE(module[0x126 + pat]) << 8) - addr_to_offset; 728 pattern_offset[ch] = UBYTE(module[0xa6 + pat]) + (UBYTE(module[0x126 + pat]) << 8) - addr_to_offset;
729 blank_rows[ch] = 0; 729 blank_rows[ch] = 0;
730 } 730 }
731 for (pattern_rows = 64; --pattern_rows >= 0; ) { 731 for (pattern_rows = 64; --pattern_rows >= 0; ) {
732 for (ch = 7; ch >= 0; ch--) { 732 for (ch = 7; ch >= 0; ch--) {
733 if (--blank_rows[ch] >= 0) 733 if (--blank_rows[ch] >= 0)
734 continue; 734 continue;
735 for (;;) { 735 for (;;) {
736 V(int, i) = UBYTE(module[pattern_offset[ch]++]); 736 V(int, i) = UBYTE(module[pattern_offset[ch]++]);
737 if (i < 0x40) { 737 if (i < 0x40) {
738 pattern_offset[ch]++; 738 pattern_offset[ch]++;
739 break; 739 break;
740 } 740 }
741 if (i == 0x40) { 741 if (i == 0x40) {
742 i = UBYTE(module[pattern_offset[ch]++]); 742 i = UBYTE(module[pattern_offset[ch]++]);
743 if ((i & 0x7f) == 0) 743 if ((i & 0x7f) == 0)
744 pattern_rows = 0; 744 pattern_rows = 0;
745 else 745 else
746 tempo = (i & 0x7f) + 1; 746 tempo = (i & 0x7f) + 1;
747 if (i >= 0x80) 747 if (i >= 0x80)
748 pattern_offset[ch]++; 748 pattern_offset[ch]++;
749 break; 749 break;
750 } 750 }
751 if (i < 0x80) { 751 if (i < 0x80) {
752 i = module[pattern_offset[ch]++] & 0x7f; 752 i = module[pattern_offset[ch]++] & 0x7f;
753 if (i == 0) 753 if (i == 0)
754 pattern_rows = 0; 754 pattern_rows = 0;
755 else 755 else
756 tempo = i + 1; 756 tempo = i + 1;
757 pattern_offset[ch]++; 757 pattern_offset[ch]++;
758 break; 758 break;
759 } 759 }
760 if (i < 0xc0) 760 if (i < 0xc0)
761 continue; 761 continue;
762 blank_rows[ch] = i - 0xbf; 762 blank_rows[ch] = i - 0xbf;
763 break; 763 break;
764 } 764 }
765 } 765 }
766 frames += tempo; 766 frames += tempo;
767 } 767 }
768 pos += 16; 768 pos += 16;
769 } 769 }
770 if (UBYTE(module[0x1a6 + 14 + pos]) < 0x80) 770 if (UBYTE(module[0x1a6 + 14 + pos]) < 0x80)
771 module_info _ loops[module_info _ songs] = TRUE; 771 module_info _ loops[module_info _ songs] = TRUE;
772 set_song_duration(module_info, frames); 772 set_song_duration(module_info, frames);
773} 773}
774 774
775PRIVATE FUNC(abool, parse_tmc, ( 775PRIVATE FUNC(abool, parse_tmc, (
776 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 776 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
777 P(CONST BYTEARRAY, module), P(int, module_len))) 777 P(CONST BYTEARRAY, module), P(int, module_len)))
778{ 778{
779 V(int, i); 779 V(int, i);
780 V(int, last_pos); 780 V(int, last_pos);
781 if (module_len < 0x1d0) 781 if (module_len < 0x1d0)
782 return FALSE; 782 return FALSE;
783 module_info _ type = ASAP_TYPE_TMC; 783 module_info _ type = ASAP_TYPE_TMC;
784 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tmc, obx))) 784 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tmc, obx)))
785 return FALSE; 785 return FALSE;
786 module_info _ channels = 2; 786 module_info _ channels = 2;
787 i = 0; 787 i = 0;
788 /* find first instrument */ 788 /* find first instrument */
789 while (module[0x66 + i] == 0) { 789 while (module[0x66 + i] == 0) {
790 if (++i >= 64) 790 if (++i >= 64)
791 return FALSE; /* no instrument */ 791 return FALSE; /* no instrument */
792 } 792 }
793 last_pos = (UBYTE(module[0x66 + i]) << 8) + UBYTE(module[0x26 + i]) 793 last_pos = (UBYTE(module[0x66 + i]) << 8) + UBYTE(module[0x26 + i])
794 - UWORD(module, 2) - 0x1b0; 794 - UWORD(module, 2) - 0x1b0;
795 if (0x1b5 + last_pos >= module_len) 795 if (0x1b5 + last_pos >= module_len)
796 return FALSE; 796 return FALSE;
797 /* skip trailing jumps */ 797 /* skip trailing jumps */
798 do { 798 do {
799 if (last_pos <= 0) 799 if (last_pos <= 0)
800 return FALSE; /* no pattern to play */ 800 return FALSE; /* no pattern to play */
801 last_pos -= 16; 801 last_pos -= 16;
802 } while (UBYTE(module[0x1b5 + last_pos]) >= 0x80); 802 } while (UBYTE(module[0x1b5 + last_pos]) >= 0x80);
803 module_info _ songs = 0; 803 module_info _ songs = 0;
804 parse_tmc_song(module_info, module, 0); 804 parse_tmc_song(module_info, module, 0);
805 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 16) 805 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 16)
806 if (UBYTE(module[0x1b5 + i]) >= 0x80) 806 if (UBYTE(module[0x1b5 + i]) >= 0x80)
807 parse_tmc_song(module_info, module, i + 16); 807 parse_tmc_song(module_info, module, i + 16);
808 /* must set fastplay after song durations calculations, so they assume 312 */ 808 /* must set fastplay after song durations calculations, so they assume 312 */
809 i = module[0x25]; 809 i = module[0x25];
810 if (i < 1 || i > 4) 810 if (i < 1 || i > 4)
811 return FALSE; 811 return FALSE;
812 if (ast != NULL) 812 if (ast != NULL)
813 ast _ tmc_per_frame = module[0x25]; 813 ast _ tmc_per_frame = module[0x25];
814 module_info _ fastplay = perframe2fastplay[i - 1]; 814 module_info _ fastplay = perframe2fastplay[i - 1];
815 return TRUE; 815 return TRUE;
816} 816}
817 817
818PRIVATE FUNC(void, parse_tm2_song, ( 818PRIVATE FUNC(void, parse_tm2_song, (
819 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) 819 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos)))
820{ 820{
821 V(int, addr_to_offset) = UWORD(module, 2) - 6; 821 V(int, addr_to_offset) = UWORD(module, 2) - 6;
822 V(int, tempo) = UBYTE(module[0x24]) + 1; 822 V(int, tempo) = UBYTE(module[0x24]) + 1;
823 V(int, player_calls) = 0; 823 V(int, player_calls) = 0;
824 NEW_ARRAY(int, pattern_offset, 8); 824 NEW_ARRAY(int, pattern_offset, 8);
825 NEW_ARRAY(int, blank_rows, 8); 825 NEW_ARRAY(int, blank_rows, 8);
826 for (;;) { 826 for (;;) {
827 V(int, ch); 827 V(int, ch);
828 V(int, pattern_rows) = UBYTE(module[0x386 + 16 + pos]); 828 V(int, pattern_rows) = UBYTE(module[0x386 + 16 + pos]);
829 if (pattern_rows == 0) 829 if (pattern_rows == 0)
830 break; 830 break;
831 if (pattern_rows >= 0x80) { 831 if (pattern_rows >= 0x80) {
832 module_info _ loops[module_info _ songs] = TRUE; 832 module_info _ loops[module_info _ songs] = TRUE;
833 break; 833 break;
834 } 834 }
835 for (ch = 7; ch >= 0; ch--) { 835 for (ch = 7; ch >= 0; ch--) {
836 V(int, pat) = UBYTE(module[0x386 + 15 + pos - 2 * ch]); 836 V(int, pat) = UBYTE(module[0x386 + 15 + pos - 2 * ch]);
837 pattern_offset[ch] = UBYTE(module[0x106 + pat]) + (UBYTE(module[0x206 + pat]) << 8) - addr_to_offset; 837 pattern_offset[ch] = UBYTE(module[0x106 + pat]) + (UBYTE(module[0x206 + pat]) << 8) - addr_to_offset;
838 blank_rows[ch] = 0; 838 blank_rows[ch] = 0;
839 } 839 }
840 while (--pattern_rows >= 0) { 840 while (--pattern_rows >= 0) {
841 for (ch = 7; ch >= 0; ch--) { 841 for (ch = 7; ch >= 0; ch--) {
842 if (--blank_rows[ch] >= 0) 842 if (--blank_rows[ch] >= 0)
843 continue; 843 continue;
844 for (;;) { 844 for (;;) {
845 V(int, i) = UBYTE(module[pattern_offset[ch]++]); 845 V(int, i) = UBYTE(module[pattern_offset[ch]++]);
846 if (i == 0) { 846 if (i == 0) {
847 pattern_offset[ch]++; 847 pattern_offset[ch]++;
848 break; 848 break;
849 } 849 }
850 if (i < 0x40) { 850 if (i < 0x40) {
851 if (UBYTE(module[pattern_offset[ch]++]) >= 0x80) 851 if (UBYTE(module[pattern_offset[ch]++]) >= 0x80)
852 pattern_offset[ch]++; 852 pattern_offset[ch]++;
853 break; 853 break;
854 } 854 }
855 if (i < 0x80) { 855 if (i < 0x80) {
856 pattern_offset[ch]++; 856 pattern_offset[ch]++;
857 break; 857 break;
858 } 858 }
859 if (i == 0x80) { 859 if (i == 0x80) {
860 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); 860 blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]);
861 break; 861 break;
862 } 862 }
863 if (i < 0xc0) 863 if (i < 0xc0)
864 break; 864 break;
865 if (i < 0xd0) { 865 if (i < 0xd0) {
866 tempo = i - 0xbf; 866 tempo = i - 0xbf;
867 continue; 867 continue;
868 } 868 }
869 if (i < 0xe0) { 869 if (i < 0xe0) {
870 pattern_offset[ch]++; 870 pattern_offset[ch]++;
871 break; 871 break;
872 } 872 }
873 if (i < 0xf0) { 873 if (i < 0xf0) {
874 pattern_offset[ch] += 2; 874 pattern_offset[ch] += 2;
875 break; 875 break;
876 } 876 }
877 if (i < 0xff) { 877 if (i < 0xff) {
878 blank_rows[ch] = i - 0xf0; 878 blank_rows[ch] = i - 0xf0;
879 break; 879 break;
880 } 880 }
881 blank_rows[ch] = 64; 881 blank_rows[ch] = 64;
882 break; 882 break;
883 } 883 }
884 } 884 }
885 player_calls += tempo; 885 player_calls += tempo;
886 } 886 }
887 pos += 17; 887 pos += 17;
888 } 888 }
889 set_song_duration(module_info, player_calls); 889 set_song_duration(module_info, player_calls);
890} 890}
891 891
892PRIVATE FUNC(abool, parse_tm2, ( 892PRIVATE FUNC(abool, parse_tm2, (
893 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 893 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
894 P(CONST BYTEARRAY, module), P(int, module_len))) 894 P(CONST BYTEARRAY, module), P(int, module_len)))
895{ 895{
896 V(int, i); 896 V(int, i);
897 V(int, last_pos); 897 V(int, last_pos);
898 V(int, c); 898 V(int, c);
899 if (module_len < 0x3a4) 899 if (module_len < 0x3a4)
900 return FALSE; 900 return FALSE;
901 module_info _ type = ASAP_TYPE_TM2; 901 module_info _ type = ASAP_TYPE_TM2;
902 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tm2, obx))) 902 if (!load_native(ast, module_info, module, module_len, GET_RESOURCE(tm2, obx)))
903 return FALSE; 903 return FALSE;
904 i = module[0x25]; 904 i = module[0x25];
905 if (i < 1 || i > 4) 905 if (i < 1 || i > 4)
906 return FALSE; 906 return FALSE;
907 module_info _ fastplay = perframe2fastplay[i - 1]; 907 module_info _ fastplay = perframe2fastplay[i - 1];
908 module_info _ player = 0x500; 908 module_info _ player = 0x500;
909 if (module[0x1f] != 0) 909 if (module[0x1f] != 0)
910 module_info _ channels = 2; 910 module_info _ channels = 2;
911 last_pos = 0xffff; 911 last_pos = 0xffff;
912 for (i = 0; i < 0x80; i++) { 912 for (i = 0; i < 0x80; i++) {
913 V(int, instr_addr) = UBYTE(module[0x86 + i]) + (UBYTE(module[0x306 + i]) << 8); 913 V(int, instr_addr) = UBYTE(module[0x86 + i]) + (UBYTE(module[0x306 + i]) << 8);
914 if (instr_addr != 0 && instr_addr < last_pos) 914 if (instr_addr != 0 && instr_addr < last_pos)
915 last_pos = instr_addr; 915 last_pos = instr_addr;
916 } 916 }
917 for (i = 0; i < 0x100; i++) { 917 for (i = 0; i < 0x100; i++) {
918 V(int, pattern_addr) = UBYTE(module[0x106 + i]) + (UBYTE(module[0x206 + i]) << 8); 918 V(int, pattern_addr) = UBYTE(module[0x106 + i]) + (UBYTE(module[0x206 + i]) << 8);
919 if (pattern_addr != 0 && pattern_addr < last_pos) 919 if (pattern_addr != 0 && pattern_addr < last_pos)
920 last_pos = pattern_addr; 920 last_pos = pattern_addr;
921 } 921 }
922 last_pos -= UWORD(module, 2) + 0x380; 922 last_pos -= UWORD(module, 2) + 0x380;
923 if (0x386 + last_pos >= module_len) 923 if (0x386 + last_pos >= module_len)
924 return FALSE; 924 return FALSE;
925 /* skip trailing stop/jump commands */ 925 /* skip trailing stop/jump commands */
926 do { 926 do {
927 if (last_pos <= 0) 927 if (last_pos <= 0)
928 return FALSE; 928 return FALSE;
929 last_pos -= 17; 929 last_pos -= 17;
930 c = UBYTE(module[0x386 + 16 + last_pos]); 930 c = UBYTE(module[0x386 + 16 + last_pos]);
931 } while (c == 0 || c >= 0x80); 931 } while (c == 0 || c >= 0x80);
932 module_info _ songs = 0; 932 module_info _ songs = 0;
933 parse_tm2_song(module_info, module, 0); 933 parse_tm2_song(module_info, module, 0);
934 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 17) { 934 for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 17) {
935 c = UBYTE(module[0x386 + 16 + i]); 935 c = UBYTE(module[0x386 + 16 + i]);
936 if (c == 0 || c >= 0x80) 936 if (c == 0 || c >= 0x80)
937 parse_tm2_song(module_info, module, i + 17); 937 parse_tm2_song(module_info, module, i + 17);
938 } 938 }
939 return TRUE; 939 return TRUE;
940} 940}
941 941
942#endif /* ASAP_ONLY_SAP */ 942#endif /* ASAP_ONLY_SAP */
943 943
944PRIVATE FUNC(abool, has_string_at, (P(CONST BYTEARRAY, module), P(int, module_index), P(STRING, s))) 944PRIVATE FUNC(abool, has_string_at, (P(CONST BYTEARRAY, module), P(int, module_index), P(STRING, s)))
945{ 945{
946 V(int, i); 946 V(int, i);
947 V(int, n) = strlen(s); 947 V(int, n) = strlen(s);
948 for (i = 0; i < n; i++) 948 for (i = 0; i < n; i++)
949 if (module[module_index + i] != CHARCODEAT(s, i)) 949 if (module[module_index + i] != CHARCODEAT(s, i))
950 return FALSE; 950 return FALSE;
951 return TRUE; 951 return TRUE;
952} 952}
953 953
954PRIVATE FUNC(STRING, parse_text, (P(OUT_STRING, dest), P(CONST BYTEARRAY, module), P(int, module_index))) 954PRIVATE FUNC(STRING, parse_text, (P(OUT_STRING, dest), P(CONST BYTEARRAY, module), P(int, module_index)))
955{ 955{
956 V(int, i); 956 V(int, i);
957 if (module[module_index] != CHARCODE('"')) 957 if (module[module_index] != CHARCODE('"'))
958 return NULL; 958 return NULL;
959 if (has_string_at(module, module_index + 1, "<?>\"")) 959 if (has_string_at(module, module_index + 1, "<?>\""))
960 return dest; 960 return dest;
961 for (i = 0; ; i++) { 961 for (i = 0; ; i++) {
962 V(int, c) = module[module_index + 1 + i]; 962 V(int, c) = module[module_index + 1 + i];
963 if (c == CHARCODE('"')) 963 if (c == CHARCODE('"'))
964 break; 964 break;
965 if (c < 32 || c >= 127) 965 if (c < 32 || c >= 127)
966 return NULL; 966 return NULL;
967 } 967 }
968 BYTES_TO_STRING(dest, module, module_index + 1, i); 968 BYTES_TO_STRING(dest, module, module_index + 1, i);
969 return dest; 969 return dest;
970} 970}
971 971
972PRIVATE FUNC(int, parse_dec, (P(CONST BYTEARRAY, module), P(int, module_index), P(int, maxval))) 972PRIVATE FUNC(int, parse_dec, (P(CONST BYTEARRAY, module), P(int, module_index), P(int, maxval)))
973{ 973{
974 V(int, r); 974 V(int, r);
975 if (module[module_index] == 0xd) 975 if (module[module_index] == 0xd)
976 return -1; 976 return -1;
977 for (r = 0;;) { 977 for (r = 0;;) {
978 V(int, c) = module[module_index++]; 978 V(int, c) = module[module_index++];
979 if (c == 0xd) 979 if (c == 0xd)
980 break; 980 break;
981 if (c < CHARCODE('0') || c > CHARCODE('9')) 981 if (c < CHARCODE('0') || c > CHARCODE('9'))
982 return -1; 982 return -1;
983 r = 10 * r + c - 48; 983 r = 10 * r + c - 48;
984 if (r > maxval) 984 if (r > maxval)
985 return -1; 985 return -1;
986 } 986 }
987 return r; 987 return r;
988} 988}
989 989
990PRIVATE FUNC(int, parse_hex, (P(CONST BYTEARRAY, module), P(int, module_index))) 990PRIVATE FUNC(int, parse_hex, (P(CONST BYTEARRAY, module), P(int, module_index)))
991{ 991{
992 V(int, r); 992 V(int, r);
993 if (module[module_index] == 0xd) 993 if (module[module_index] == 0xd)
994 return -1; 994 return -1;
995 for (r = 0;;) { 995 for (r = 0;;) {
996 V(int, c) = module[module_index++]; 996 V(int, c) = module[module_index++];
997 if (c == 0xd) 997 if (c == 0xd)
998 break; 998 break;
999 if (r > 0xfff) 999 if (r > 0xfff)
1000 return -1; 1000 return -1;
1001 r <<= 4; 1001 r <<= 4;
1002 if (c >= CHARCODE('0') && c <= CHARCODE('9')) 1002 if (c >= CHARCODE('0') && c <= CHARCODE('9'))
1003 r += c - CHARCODE('0'); 1003 r += c - CHARCODE('0');
1004 else if (c >= CHARCODE('A') && c <= CHARCODE('F')) 1004 else if (c >= CHARCODE('A') && c <= CHARCODE('F'))
1005 r += c - CHARCODE('A') + 10; 1005 r += c - CHARCODE('A') + 10;
1006 else if (c >= CHARCODE('a') && c <= CHARCODE('f')) 1006 else if (c >= CHARCODE('a') && c <= CHARCODE('f'))
1007 r += c - CHARCODE('a') + 10; 1007 r += c - CHARCODE('a') + 10;
1008 else 1008 else
1009 return -1; 1009 return -1;
1010 } 1010 }
1011 return r; 1011 return r;
1012} 1012}
1013 1013
1014FUNC(int, ASAP_ParseDuration, (P(STRING, s))) 1014FUNC(int, ASAP_ParseDuration, (P(STRING, s)))
1015{ 1015{
1016 V(int, i) = 0; 1016 V(int, i) = 0;
1017 V(int, r); 1017 V(int, r);
1018 V(int, d); 1018 V(int, d);
1019 V(int, n) = strlen(s); 1019 V(int, n) = strlen(s);
1020#define PARSE_DIGIT(maxdig, retifnot) \ 1020#define PARSE_DIGIT(maxdig, retifnot) \
1021 if (i >= n) \ 1021 if (i >= n) \
1022 return retifnot; \ 1022 return retifnot; \
1023 d = CHARCODEAT(s, i) - 48; \ 1023 d = CHARCODEAT(s, i) - 48; \
1024 if (d < 0 || d > maxdig) \ 1024 if (d < 0 || d > maxdig) \
1025 return -1; \ 1025 return -1; \
1026 i++; 1026 i++;
1027 1027
1028 PARSE_DIGIT(9, -1); 1028 PARSE_DIGIT(9, -1);
1029 r = d; 1029 r = d;
1030 if (i < n) { 1030 if (i < n) {
1031 d = CHARCODEAT(s, i) - 48; 1031 d = CHARCODEAT(s, i) - 48;
1032 if (d >= 0 && d <= 9) { 1032 if (d >= 0 && d <= 9) {
1033 i++; 1033 i++;
1034 r = 10 * r + d; 1034 r = 10 * r + d;
1035 } 1035 }
1036 if (i < n && CHARAT(s, i) == ':') { 1036 if (i < n && CHARAT(s, i) == ':') {
1037 i++; 1037 i++;
1038 PARSE_DIGIT(5, -1); 1038 PARSE_DIGIT(5, -1);
1039 r = (6 * r + d) * 10; 1039 r = (6 * r + d) * 10;
1040 PARSE_DIGIT(9, -1); 1040 PARSE_DIGIT(9, -1);
1041 r += d; 1041 r += d;
1042 } 1042 }
1043 } 1043 }
1044 r *= 1000; 1044 r *= 1000;
1045 if (i >= n) 1045 if (i >= n)
1046 return r; 1046 return r;
1047 if (CHARAT(s, i) != '.') 1047 if (CHARAT(s, i) != '.')
1048 return -1; 1048 return -1;
1049 i++; 1049 i++;
1050 PARSE_DIGIT(9, -1); 1050 PARSE_DIGIT(9, -1);
1051 r += 100 * d; 1051 r += 100 * d;
1052 PARSE_DIGIT(9, r); 1052 PARSE_DIGIT(9, r);
1053 r += 10 * d; 1053 r += 10 * d;
1054 PARSE_DIGIT(9, r); 1054 PARSE_DIGIT(9, r);
1055 r += d; 1055 r += d;
1056 return r; 1056 return r;
1057} 1057}
1058 1058
1059PRIVATE FUNC(abool, parse_sap_header, ( 1059PRIVATE FUNC(abool, parse_sap_header, (
1060 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, module_len))) 1060 P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, module_len)))
1061{ 1061{
1062 V(int, module_index); 1062 V(int, module_index);
1063 V(int, type) = 0; 1063 V(int, type) = 0;
1064 V(int, duration_index) = 0; 1064 V(int, duration_index) = 0;
1065 if (!has_string_at(module, 0, "SAP\r\n")) 1065 if (!has_string_at(module, 0, "SAP\r\n"))
1066 return FALSE; 1066 return FALSE;
1067 module_index = 5; 1067 module_index = 5;
1068 while (UBYTE(module[module_index]) != 0xff) { 1068 while (UBYTE(module[module_index]) != 0xff) {
1069 if (module_index + 8 >= module_len) 1069 if (module_index + 8 >= module_len)
1070 return FALSE; 1070 return FALSE;
1071#define TAG_IS(s) has_string_at(module, module_index, s) 1071#define TAG_IS(s) has_string_at(module, module_index, s)
1072#ifdef C 1072#ifdef C
1073#define SET_TEXT(v, i) if (parse_text(v, module, module_index + i) == NULL) return FALSE 1073#define SET_TEXT(v, i) if (parse_text(v, module, module_index + i) == NULL) return FALSE
@@ -1076,287 +1076,287 @@ PRIVATE FUNC(abool, parse_sap_header, (
1076#endif 1076#endif
1077#define SET_DEC(v, i, min, max) v = parse_dec(module, module_index + i, max); if (v < min) return FALSE 1077#define SET_DEC(v, i, min, max) v = parse_dec(module, module_index + i, max); if (v < min) return FALSE
1078#define SET_HEX(v, i) v = parse_hex(module, module_index + i) 1078#define SET_HEX(v, i) v = parse_hex(module, module_index + i)
1079 if (TAG_IS("AUTHOR ")) { 1079 if (TAG_IS("AUTHOR ")) {
1080 SET_TEXT(module_info _ author, 7); 1080 SET_TEXT(module_info _ author, 7);
1081 } 1081 }
1082 else if (TAG_IS("NAME ")) { 1082 else if (TAG_IS("NAME ")) {
1083 SET_TEXT(module_info _ name, 5); 1083 SET_TEXT(module_info _ name, 5);
1084 } 1084 }
1085 else if (TAG_IS("DATE ")) { 1085 else if (TAG_IS("DATE ")) {
1086 SET_TEXT(module_info _ date, 5); 1086 SET_TEXT(module_info _ date, 5);
1087 } 1087 }
1088 else if (TAG_IS("SONGS ")) { 1088 else if (TAG_IS("SONGS ")) {
1089 SET_DEC(module_info _ songs, 6, 1, ASAP_SONGS_MAX); 1089 SET_DEC(module_info _ songs, 6, 1, ASAP_SONGS_MAX);
1090 } 1090 }
1091 else if (TAG_IS("DEFSONG ")) { 1091 else if (TAG_IS("DEFSONG ")) {
1092 SET_DEC(module_info _ default_song, 8, 0, ASAP_SONGS_MAX - 1); 1092 SET_DEC(module_info _ default_song, 8, 0, ASAP_SONGS_MAX - 1);
1093 } 1093 }
1094 else if (TAG_IS("STEREO\r")) 1094 else if (TAG_IS("STEREO\r"))
1095 module_info _ channels = 2; 1095 module_info _ channels = 2;
1096 else if (TAG_IS("TIME ")) { 1096 else if (TAG_IS("TIME ")) {
1097 V(int, i); 1097 V(int, i);
1098#ifdef C 1098#ifdef C
1099 char s[ASAP_DURATION_CHARS]; 1099 char s[ASAP_DURATION_CHARS];
1100#else 1100#else
1101 V(STRING, s); 1101 V(STRING, s);
1102#endif 1102#endif
1103 module_index += 5; 1103 module_index += 5;
1104 for (i = 0; module[module_index + i] != 0xd; i++); 1104 for (i = 0; module[module_index + i] != 0xd; i++);
1105 if (i > 5 && has_string_at(module, module_index + i - 5, " LOOP")) { 1105 if (i > 5 && has_string_at(module, module_index + i - 5, " LOOP")) {
1106 module_info _ loops[duration_index] = TRUE; 1106 module_info _ loops[duration_index] = TRUE;
1107 i -= 5; 1107 i -= 5;
1108 } 1108 }
1109#ifdef C 1109#ifdef C
1110 if (i >= ASAP_DURATION_CHARS) 1110 if (i >= ASAP_DURATION_CHARS)
1111 return FALSE; 1111 return FALSE;
1112#endif 1112#endif
1113 BYTES_TO_STRING(s, module, module_index, i); 1113 BYTES_TO_STRING(s, module, module_index, i);
1114 i = ASAP_ParseDuration(s); 1114 i = ASAP_ParseDuration(s);
1115 if (i < 0 || duration_index >= ASAP_SONGS_MAX) 1115 if (i < 0 || duration_index >= ASAP_SONGS_MAX)
1116 return FALSE; 1116 return FALSE;
1117 module_info _ durations[duration_index++] = i; 1117 module_info _ durations[duration_index++] = i;
1118 } 1118 }
1119 else if (TAG_IS("TYPE ")) 1119 else if (TAG_IS("TYPE "))
1120 type = module[module_index + 5]; 1120 type = module[module_index + 5];
1121 else if (TAG_IS("FASTPLAY ")) { 1121 else if (TAG_IS("FASTPLAY ")) {
1122 SET_DEC(module_info _ fastplay, 9, 1, 312); 1122 SET_DEC(module_info _ fastplay, 9, 1, 312);
1123 } 1123 }
1124 else if (TAG_IS("MUSIC ")) { 1124 else if (TAG_IS("MUSIC ")) {
1125 SET_HEX(module_info _ music, 6); 1125 SET_HEX(module_info _ music, 6);
1126 } 1126 }
1127 else if (TAG_IS("INIT ")) { 1127 else if (TAG_IS("INIT ")) {
1128 SET_HEX(module_info _ init, 5); 1128 SET_HEX(module_info _ init, 5);
1129 } 1129 }
1130 else if (TAG_IS("PLAYER ")) { 1130 else if (TAG_IS("PLAYER ")) {
1131 SET_HEX(module_info _ player, 7); 1131 SET_HEX(module_info _ player, 7);
1132 } 1132 }
1133 else if (TAG_IS("COVOX ")) { 1133 else if (TAG_IS("COVOX ")) {
1134 SET_HEX(module_info _ covox_addr, 6); 1134 SET_HEX(module_info _ covox_addr, 6);
1135 if (module_info _ covox_addr != 0xd600) 1135 if (module_info _ covox_addr != 0xd600)
1136 return FALSE; 1136 return FALSE;
1137 module_info _ channels = 2; 1137 module_info _ channels = 2;
1138 } 1138 }
1139 1139
1140 while (module[module_index++] != 0x0d) { 1140 while (module[module_index++] != 0x0d) {
1141 if (module_index >= module_len) 1141 if (module_index >= module_len)
1142 return FALSE; 1142 return FALSE;
1143 } 1143 }
1144 if (module[module_index++] != 0x0a) 1144 if (module[module_index++] != 0x0a)
1145 return FALSE; 1145 return FALSE;
1146 } 1146 }
1147 if (module_info _ default_song >= module_info _ songs) 1147 if (module_info _ default_song >= module_info _ songs)
1148 return FALSE; 1148 return FALSE;
1149 switch (type) { 1149 switch (type) {
1150 case CHARCODE('B'): 1150 case CHARCODE('B'):
1151 if (module_info _ player < 0 || module_info _ init < 0) 1151 if (module_info _ player < 0 || module_info _ init < 0)
1152 return FALSE; 1152 return FALSE;
1153 module_info _ type = ASAP_TYPE_SAP_B; 1153 module_info _ type = ASAP_TYPE_SAP_B;
1154 break; 1154 break;
1155 case CHARCODE('C'): 1155 case CHARCODE('C'):
1156 if (module_info _ player < 0 || module_info _ music < 0) 1156 if (module_info _ player < 0 || module_info _ music < 0)
1157 return FALSE; 1157 return FALSE;
1158 module_info _ type = ASAP_TYPE_SAP_C; 1158 module_info _ type = ASAP_TYPE_SAP_C;
1159 break; 1159 break;
1160 case CHARCODE('D'): 1160 case CHARCODE('D'):
1161 if (module_info _ init < 0) 1161 if (module_info _ init < 0)
1162 return FALSE; 1162 return FALSE;
1163 module_info _ type = ASAP_TYPE_SAP_D; 1163 module_info _ type = ASAP_TYPE_SAP_D;
1164 break; 1164 break;
1165 case CHARCODE('S'): 1165 case CHARCODE('S'):
1166 if (module_info _ init < 0) 1166 if (module_info _ init < 0)
1167 return FALSE; 1167 return FALSE;
1168 module_info _ type = ASAP_TYPE_SAP_S; 1168 module_info _ type = ASAP_TYPE_SAP_S;
1169 module_info _ fastplay = 78; 1169 module_info _ fastplay = 78;
1170 break; 1170 break;
1171 default: 1171 default:
1172 return FALSE; 1172 return FALSE;
1173 } 1173 }
1174 if (UBYTE(module[module_index + 1]) != 0xff) 1174 if (UBYTE(module[module_index + 1]) != 0xff)
1175 return FALSE; 1175 return FALSE;
1176 module_info _ header_len = module_index; 1176 module_info _ header_len = module_index;
1177 return TRUE; 1177 return TRUE;
1178} 1178}
1179 1179
1180PRIVATE FUNC(abool, parse_sap, ( 1180PRIVATE FUNC(abool, parse_sap, (
1181 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 1181 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
1182 P(CONST BYTEARRAY, module), P(int, module_len))) 1182 P(CONST BYTEARRAY, module), P(int, module_len)))
1183{ 1183{
1184 V(int, module_index); 1184 V(int, module_index);
1185 if (!parse_sap_header(module_info, module, module_len)) 1185 if (!parse_sap_header(module_info, module, module_len))
1186 return FALSE; 1186 return FALSE;
1187 if (ast == NULL) 1187 if (ast == NULL)
1188 return TRUE; 1188 return TRUE;
1189 ZERO_ARRAY(ast _ memory); 1189 ZERO_ARRAY(ast _ memory);
1190 module_index = module_info _ header_len + 2; 1190 module_index = module_info _ header_len + 2;
1191 while (module_index + 5 <= module_len) { 1191 while (module_index + 5 <= module_len) {
1192 V(int, start_addr) = UWORD(module, module_index); 1192 V(int, start_addr) = UWORD(module, module_index);
1193 V(int, block_len) = UWORD(module, module_index + 2) + 1 - start_addr; 1193 V(int, block_len) = UWORD(module, module_index + 2) + 1 - start_addr;
1194 if (block_len <= 0 || module_index + block_len > module_len) 1194 if (block_len <= 0 || module_index + block_len > module_len)
1195 return FALSE; 1195 return FALSE;
1196 module_index += 4; 1196 module_index += 4;
1197 COPY_ARRAY(ast _ memory, start_addr, module, module_index, block_len); 1197 COPY_ARRAY(ast _ memory, start_addr, module, module_index, block_len);
1198 module_index += block_len; 1198 module_index += block_len;
1199 if (module_index == module_len) 1199 if (module_index == module_len)
1200 return TRUE; 1200 return TRUE;
1201 if (module_index + 7 <= module_len 1201 if (module_index + 7 <= module_len
1202 && UBYTE(module[module_index]) == 0xff && UBYTE(module[module_index + 1]) == 0xff) 1202 && UBYTE(module[module_index]) == 0xff && UBYTE(module[module_index + 1]) == 0xff)
1203 module_index += 2; 1203 module_index += 2;
1204 } 1204 }
1205 return FALSE; 1205 return FALSE;
1206} 1206}
1207 1207
1208#define ASAP_EXT(c1, c2, c3) ((CHARCODE(c1) + (CHARCODE(c2) << 8) + (CHARCODE(c3) << 16)) | 0x202020) 1208#define ASAP_EXT(c1, c2, c3) ((CHARCODE(c1) + (CHARCODE(c2) << 8) + (CHARCODE(c3) << 16)) | 0x202020)
1209 1209
1210PRIVATE FUNC(int, get_packed_ext, (P(STRING, filename))) 1210PRIVATE FUNC(int, get_packed_ext, (P(STRING, filename)))
1211{ 1211{
1212 V(int, i) = strlen(filename); 1212 V(int, i) = strlen(filename);
1213 V(int, ext) = 0; 1213 V(int, ext) = 0;
1214 while (--i > 0) { 1214 while (--i > 0) {
1215 V(char, c) = CHARAT(filename, i); 1215 V(char, c) = CHARAT(filename, i);
1216 if (c <= ' ' || c > 'z') 1216 if (c <= ' ' || c > 'z')
1217 return 0; 1217 return 0;
1218 if (c == '.') 1218 if (c == '.')
1219 return ext | 0x202020; 1219 return ext | 0x202020;
1220 ext = (ext << 8) + CHARCODE(c); 1220 ext = (ext << 8) + CHARCODE(c);
1221 } 1221 }
1222 return 0; 1222 return 0;
1223} 1223}
1224 1224
1225PRIVATE FUNC(abool, is_our_ext, (P(int, ext))) 1225PRIVATE FUNC(abool, is_our_ext, (P(int, ext)))
1226{ 1226{
1227 switch (ext) { 1227 switch (ext) {
1228 case ASAP_EXT('S', 'A', 'P'): 1228 case ASAP_EXT('S', 'A', 'P'):
1229#ifndef ASAP_ONLY_SAP 1229#ifndef ASAP_ONLY_SAP
1230 case ASAP_EXT('C', 'M', 'C'): 1230 case ASAP_EXT('C', 'M', 'C'):
1231 case ASAP_EXT('C', 'M', '3'): 1231 case ASAP_EXT('C', 'M', '3'):
1232 case ASAP_EXT('C', 'M', 'R'): 1232 case ASAP_EXT('C', 'M', 'R'):
1233 case ASAP_EXT('C', 'M', 'S'): 1233 case ASAP_EXT('C', 'M', 'S'):
1234 case ASAP_EXT('D', 'M', 'C'): 1234 case ASAP_EXT('D', 'M', 'C'):
1235 case ASAP_EXT('D', 'L', 'T'): 1235 case ASAP_EXT('D', 'L', 'T'):
1236 case ASAP_EXT('M', 'P', 'T'): 1236 case ASAP_EXT('M', 'P', 'T'):
1237 case ASAP_EXT('M', 'P', 'D'): 1237 case ASAP_EXT('M', 'P', 'D'):
1238 case ASAP_EXT('R', 'M', 'T'): 1238 case ASAP_EXT('R', 'M', 'T'):
1239 case ASAP_EXT('T', 'M', 'C'): 1239 case ASAP_EXT('T', 'M', 'C'):
1240 case ASAP_EXT('T', 'M', '8'): 1240 case ASAP_EXT('T', 'M', '8'):
1241 case ASAP_EXT('T', 'M', '2'): 1241 case ASAP_EXT('T', 'M', '2'):
1242#endif 1242#endif
1243 return TRUE; 1243 return TRUE;
1244 default: 1244 default:
1245 return FALSE; 1245 return FALSE;
1246 } 1246 }
1247} 1247}
1248 1248
1249FUNC(abool, ASAP_IsOurFile, (P(STRING, filename))) 1249FUNC(abool, ASAP_IsOurFile, (P(STRING, filename)))
1250{ 1250{
1251 V(int, ext) = get_packed_ext(filename); 1251 V(int, ext) = get_packed_ext(filename);
1252 return is_our_ext(ext); 1252 return is_our_ext(ext);
1253} 1253}
1254 1254
1255FUNC(abool, ASAP_IsOurExt, (P(STRING, ext))) 1255FUNC(abool, ASAP_IsOurExt, (P(STRING, ext)))
1256{ 1256{
1257 return strlen(ext) == 3 1257 return strlen(ext) == 3
1258 && is_our_ext(ASAP_EXT(CHARAT(ext, 0), CHARAT(ext, 1), CHARAT(ext, 2))); 1258 && is_our_ext(ASAP_EXT(CHARAT(ext, 0), CHARAT(ext, 1), CHARAT(ext, 2)));
1259} 1259}
1260 1260
1261PRIVATE FUNC(abool, parse_file, ( 1261PRIVATE FUNC(abool, parse_file, (
1262 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), 1262 P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info),
1263 P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len))) 1263 P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len)))
1264{ 1264{
1265 V(int, i); 1265 V(int, i);
1266 V(int, len) = strlen(filename); 1266 V(int, len) = strlen(filename);
1267 V(int, basename) = 0; 1267 V(int, basename) = 0;
1268 V(int, ext) = -1; 1268 V(int, ext) = -1;
1269 for (i = 0; i < len; i++) { 1269 for (i = 0; i < len; i++) {
1270 V(char, c) = CHARAT(filename, i); 1270 V(char, c) = CHARAT(filename, i);
1271 if (c == '/' || c == '\\') { 1271 if (c == '/' || c == '\\') {
1272 basename = i + 1; 1272 basename = i + 1;
1273 ext = -1; 1273 ext = -1;
1274 } 1274 }
1275 else if (c == '.') 1275 else if (c == '.')
1276 ext = i; 1276 ext = i;
1277 } 1277 }
1278 if (ext < 0) 1278 if (ext < 0)
1279 return FALSE; 1279 return FALSE;
1280 EMPTY_STRING(module_info _ author); 1280 EMPTY_STRING(module_info _ author);
1281 SUBSTRING(module_info _ name, filename, basename, ext - basename); 1281 SUBSTRING(module_info _ name, filename, basename, ext - basename);
1282 EMPTY_STRING(module_info _ date); 1282 EMPTY_STRING(module_info _ date);
1283 module_info _ channels = 1; 1283 module_info _ channels = 1;
1284 module_info _ songs = 1; 1284 module_info _ songs = 1;
1285 module_info _ default_song = 0; 1285 module_info _ default_song = 0;
1286 for (i = 0; i < ASAP_SONGS_MAX; i++) { 1286 for (i = 0; i < ASAP_SONGS_MAX; i++) {
1287 module_info _ durations[i] = -1; 1287 module_info _ durations[i] = -1;
1288 module_info _ loops[i] = FALSE; 1288 module_info _ loops[i] = FALSE;
1289 } 1289 }
1290 module_info _ fastplay = 312; 1290 module_info _ fastplay = 312;
1291 module_info _ music = -1; 1291 module_info _ music = -1;
1292 module_info _ init = -1; 1292 module_info _ init = -1;
1293 module_info _ player = -1; 1293 module_info _ player = -1;
1294 module_info _ covox_addr = -1; 1294 module_info _ covox_addr = -1;
1295 switch (get_packed_ext(filename)) { 1295 switch (get_packed_ext(filename)) {
1296 case ASAP_EXT('S', 'A', 'P'): 1296 case ASAP_EXT('S', 'A', 'P'):
1297 return parse_sap(ast, module_info, module, module_len); 1297 return parse_sap(ast, module_info, module, module_len);
1298#ifndef ASAP_ONLY_SAP 1298#ifndef ASAP_ONLY_SAP
1299 case ASAP_EXT('C', 'M', 'C'): 1299 case ASAP_EXT('C', 'M', 'C'):
1300 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx)); 1300 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx));
1301 case ASAP_EXT('C', 'M', '3'): 1301 case ASAP_EXT('C', 'M', '3'):
1302 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CM3, GET_RESOURCE(cm3, obx)); 1302 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CM3, GET_RESOURCE(cm3, obx));
1303 case ASAP_EXT('C', 'M', 'R'): 1303 case ASAP_EXT('C', 'M', 'R'):
1304 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMR, GET_RESOURCE(cmc, obx)); 1304 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMR, GET_RESOURCE(cmc, obx));
1305 case ASAP_EXT('C', 'M', 'S'): 1305 case ASAP_EXT('C', 'M', 'S'):
1306 module_info _ channels = 2; 1306 module_info _ channels = 2;
1307 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMS, GET_RESOURCE(cms, obx)); 1307 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMS, GET_RESOURCE(cms, obx));
1308 case ASAP_EXT('D', 'M', 'C'): 1308 case ASAP_EXT('D', 'M', 'C'):
1309 module_info _ fastplay = 156; 1309 module_info _ fastplay = 156;
1310 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx)); 1310 return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_RESOURCE(cmc, obx));
1311 case ASAP_EXT('D', 'L', 'T'): 1311 case ASAP_EXT('D', 'L', 'T'):
1312 return parse_dlt(ast, module_info, module, module_len); 1312 return parse_dlt(ast, module_info, module, module_len);
1313 case ASAP_EXT('M', 'P', 'T'): 1313 case ASAP_EXT('M', 'P', 'T'):
1314 return parse_mpt(ast, module_info, module, module_len); 1314 return parse_mpt(ast, module_info, module, module_len);
1315 case ASAP_EXT('M', 'P', 'D'): 1315 case ASAP_EXT('M', 'P', 'D'):
1316 module_info _ fastplay = 156; 1316 module_info _ fastplay = 156;
1317 return parse_mpt(ast, module_info, module, module_len); 1317 return parse_mpt(ast, module_info, module, module_len);
1318 case ASAP_EXT('R', 'M', 'T'): 1318 case ASAP_EXT('R', 'M', 'T'):
1319 return parse_rmt(ast, module_info, module, module_len); 1319 return parse_rmt(ast, module_info, module, module_len);
1320 case ASAP_EXT('T', 'M', 'C'): 1320 case ASAP_EXT('T', 'M', 'C'):
1321 case ASAP_EXT('T', 'M', '8'): 1321 case ASAP_EXT('T', 'M', '8'):
1322 return parse_tmc(ast, module_info, module, module_len); 1322 return parse_tmc(ast, module_info, module, module_len);
1323 case ASAP_EXT('T', 'M', '2'): 1323 case ASAP_EXT('T', 'M', '2'):
1324 return parse_tm2(ast, module_info, module, module_len); 1324 return parse_tm2(ast, module_info, module, module_len);
1325#endif 1325#endif
1326 default: 1326 default:
1327 return FALSE; 1327 return FALSE;
1328 } 1328 }
1329} 1329}
1330 1330
1331FUNC(abool, ASAP_GetModuleInfo, ( 1331FUNC(abool, ASAP_GetModuleInfo, (
1332 P(ASAP_ModuleInfo PTR, module_info), P(STRING, filename), 1332 P(ASAP_ModuleInfo PTR, module_info), P(STRING, filename),
1333 P(CONST BYTEARRAY, module), P(int, module_len))) 1333 P(CONST BYTEARRAY, module), P(int, module_len)))
1334{ 1334{
1335 return parse_file(NULL, module_info, filename, module, module_len); 1335 return parse_file(NULL, module_info, filename, module, module_len);
1336} 1336}
1337 1337
1338FUNC(abool, ASAP_Load, ( 1338FUNC(abool, ASAP_Load, (
1339 P(ASAP_State PTR, ast), P(STRING, filename), 1339 P(ASAP_State PTR, ast), P(STRING, filename),
1340 P(CONST BYTEARRAY, module), P(int, module_len))) 1340 P(CONST BYTEARRAY, module), P(int, module_len)))
1341{ 1341{
1342 ast _ silence_cycles = 0; 1342 ast _ silence_cycles = 0;
1343 return parse_file(ast, ADDRESSOF ast _ module_info, filename, module, module_len); 1343 return parse_file(ast, ADDRESSOF ast _ module_info, filename, module, module_len);
1344} 1344}
1345 1345
1346FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds))) 1346FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds)))
1347{ 1347{
1348 ast _ silence_cycles = seconds * ASAP_MAIN_CLOCK; 1348 ast _ silence_cycles = seconds * ASAP_MAIN_CLOCK;
1349} 1349}
1350 1350
1351PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_scanlines))) 1351PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_scanlines)))
1352{ 1352{
1353 ast _ cpu_pc = addr; 1353 ast _ cpu_pc = addr;
1354 /* put a CIM at 0xd20a and a return address on stack */ 1354 /* put a CIM at 0xd20a and a return address on stack */
1355 dPutByte(0xd20a, 0xd2); 1355 dPutByte(0xd20a, 0xd2);
1356 dPutByte(0x01fe, 0x09); 1356 dPutByte(0x01fe, 0x09);
1357 dPutByte(0x01ff, 0xd2); 1357 dPutByte(0x01ff, 0xd2);
1358 ast _ cpu_s = 0xfd; 1358 ast _ cpu_s = 0xfd;
1359 Cpu_RunScanlines(ast, max_scanlines); 1359 Cpu_RunScanlines(ast, max_scanlines);
1360} 1360}
1361 1361
1362/* 50 Atari frames for the initialization routine - some SAPs are self-extracting. */ 1362/* 50 Atari frames for the initialization routine - some SAPs are self-extracting. */
@@ -1364,843 +1364,843 @@ PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_
1364 1364
1365PRIVATE FUNC(void, call_6502_init, (P(ASAP_State PTR, ast), P(int, addr), P(int, a), P(int, x), P(int, y))) 1365PRIVATE FUNC(void, call_6502_init, (P(ASAP_State PTR, ast), P(int, addr), P(int, a), P(int, x), P(int, y)))
1366{ 1366{
1367 ast _ cpu_a = a & 0xff; 1367 ast _ cpu_a = a & 0xff;
1368 ast _ cpu_x = x & 0xff; 1368 ast _ cpu_x = x & 0xff;
1369 ast _ cpu_y = y & 0xff; 1369 ast _ cpu_y = y & 0xff;
1370 call_6502(ast, addr, SCANLINES_FOR_INIT); 1370 call_6502(ast, addr, SCANLINES_FOR_INIT);
1371} 1371}
1372 1372
1373FUNC(void, ASAP_PlaySong, (P(ASAP_State PTR, ast), P(int, song), P(int, duration))) 1373FUNC(void, ASAP_PlaySong, (P(ASAP_State PTR, ast), P(int, song), P(int, duration)))
1374{ 1374{
1375 ast _ current_song = song; 1375 ast _ current_song = song;
1376 ast _ current_duration = duration; 1376 ast _ current_duration = duration;
1377 ast _ blocks_played = 0; 1377 ast _ blocks_played = 0;
1378 ast _ silence_cycles_counter = ast _ silence_cycles; 1378 ast _ silence_cycles_counter = ast _ silence_cycles;
1379 ast _ extra_pokey_mask = ast _ module_info.channels > 1 ? 0x10 : 0; 1379 ast _ extra_pokey_mask = ast _ module_info.channels > 1 ? 0x10 : 0;
1380 ast _ consol = 8; 1380 ast _ consol = 8;
1381 ast _ covox[0] = CAST(byte) 0x80; 1381 ast _ covox[0] = CAST(byte) 0x80;
1382 ast _ covox[1] = CAST(byte) 0x80; 1382 ast _ covox[1] = CAST(byte) 0x80;
1383 ast _ covox[2] = CAST(byte) 0x80; 1383 ast _ covox[2] = CAST(byte) 0x80;
1384 ast _ covox[3] = CAST(byte) 0x80; 1384 ast _ covox[3] = CAST(byte) 0x80;
1385 PokeySound_Initialize(ast); 1385 PokeySound_Initialize(ast);
1386 ast _ cycle = 0; 1386 ast _ cycle = 0;
1387 ast _ cpu_nz = 0; 1387 ast _ cpu_nz = 0;
1388 ast _ cpu_c = 0; 1388 ast _ cpu_c = 0;
1389 ast _ cpu_vdi = 0; 1389 ast _ cpu_vdi = 0;
1390 ast _ scanline_number = 0; 1390 ast _ scanline_number = 0;
1391 ast _ next_scanline_cycle = 0; 1391 ast _ next_scanline_cycle = 0;
1392 ast _ timer1_cycle = NEVER; 1392 ast _ timer1_cycle = NEVER;
1393 ast _ timer2_cycle = NEVER; 1393 ast _ timer2_cycle = NEVER;
1394 ast _ timer4_cycle = NEVER; 1394 ast _ timer4_cycle = NEVER;
1395 ast _ irqst = 0xff; 1395 ast _ irqst = 0xff;
1396 switch (ast _ module_info.type) { 1396 switch (ast _ module_info.type) {
1397 case ASAP_TYPE_SAP_B: 1397 case ASAP_TYPE_SAP_B:
1398 call_6502_init(ast, ast _ module_info.init, song, 0, 0); 1398 call_6502_init(ast, ast _ module_info.init, song, 0, 0);
1399 break; 1399 break;
1400 case ASAP_TYPE_SAP_C: 1400 case ASAP_TYPE_SAP_C:
1401#ifndef ASAP_ONLY_SAP 1401#ifndef ASAP_ONLY_SAP
1402 case ASAP_TYPE_CMC: 1402 case ASAP_TYPE_CMC:
1403 case ASAP_TYPE_CM3: 1403 case ASAP_TYPE_CM3:
1404 case ASAP_TYPE_CMR: 1404 case ASAP_TYPE_CMR:
1405 case ASAP_TYPE_CMS: 1405 case ASAP_TYPE_CMS:
1406#endif 1406#endif
1407 call_6502_init(ast, ast _ module_info.player + 3, 0x70, ast _ module_info.music, ast _ module_info.music >> 8); 1407 call_6502_init(ast, ast _ module_info.player + 3, 0x70, ast _ module_info.music, ast _ module_info.music >> 8);
1408 call_6502_init(ast, ast _ module_info.player + 3, 0x00, song, 0); 1408 call_6502_init(ast, ast _ module_info.player + 3, 0x00, song, 0);
1409 break; 1409 break;
1410 case ASAP_TYPE_SAP_D: 1410 case ASAP_TYPE_SAP_D:
1411 case ASAP_TYPE_SAP_S: 1411 case ASAP_TYPE_SAP_S:
1412 ast _ cpu_a = song; 1412 ast _ cpu_a = song;
1413 ast _ cpu_x = 0x00; 1413 ast _ cpu_x = 0x00;
1414 ast _ cpu_y = 0x00; 1414 ast _ cpu_y = 0x00;
1415 ast _ cpu_s = 0xff; 1415 ast _ cpu_s = 0xff;
1416 ast _ cpu_pc = ast _ module_info.init; 1416 ast _ cpu_pc = ast _ module_info.init;
1417 break; 1417 break;
1418#ifndef ASAP_ONLY_SAP 1418#ifndef ASAP_ONLY_SAP
1419 case ASAP_TYPE_DLT: 1419 case ASAP_TYPE_DLT:
1420 call_6502_init(ast, ast _ module_info.player + 0x100, 0x00, 0x00, ast _ module_info.song_pos[song]); 1420 call_6502_init(ast, ast _ module_info.player + 0x100, 0x00, 0x00, ast _ module_info.song_pos[song]);
1421 break; 1421 break;
1422 case ASAP_TYPE_MPT: 1422 case ASAP_TYPE_MPT:
1423 call_6502_init(ast, ast _ module_info.player, 0x00, ast _ module_info.music >> 8, ast _ module_info.music); 1423 call_6502_init(ast, ast _ module_info.player, 0x00, ast _ module_info.music >> 8, ast _ module_info.music);
1424 call_6502_init(ast, ast _ module_info.player, 0x02, ast _ module_info.song_pos[song], 0); 1424 call_6502_init(ast, ast _ module_info.player, 0x02, ast _ module_info.song_pos[song], 0);
1425 break; 1425 break;
1426 case ASAP_TYPE_RMT: 1426 case ASAP_TYPE_RMT:
1427 call_6502_init(ast, ast _ module_info.player, ast _ module_info.song_pos[song], ast _ module_info.music, ast _ module_info.music >> 8); 1427 call_6502_init(ast, ast _ module_info.player, ast _ module_info.song_pos[song], ast _ module_info.music, ast _ module_info.music >> 8);
1428 break; 1428 break;
1429 case ASAP_TYPE_TMC: 1429 case ASAP_TYPE_TMC:
1430 case ASAP_TYPE_TM2: 1430 case ASAP_TYPE_TM2:
1431 call_6502_init(ast, ast _ module_info.player, 0x70, ast _ module_info.music >> 8, ast _ module_info.music); 1431 call_6502_init(ast, ast _ module_info.player, 0x70, ast _ module_info.music >> 8, ast _ module_info.music);
1432 call_6502_init(ast, ast _ module_info.player, 0x00, song, 0); 1432 call_6502_init(ast, ast _ module_info.player, 0x00, song, 0);
1433 ast _ tmc_per_frame_counter = 1; 1433 ast _ tmc_per_frame_counter = 1;
1434 break; 1434 break;
1435#endif 1435#endif
1436 } 1436 }
1437 ASAP_MutePokeyChannels(ast, 0); 1437 ASAP_MutePokeyChannels(ast, 0);
1438} 1438}
1439 1439
1440FUNC(void, ASAP_MutePokeyChannels, (P(ASAP_State PTR, ast), P(int, mask))) 1440FUNC(void, ASAP_MutePokeyChannels, (P(ASAP_State PTR, ast), P(int, mask)))
1441{ 1441{
1442 PokeySound_Mute(ast, ADDRESSOF ast _ base_pokey, mask); 1442 PokeySound_Mute(ast, ADDRESSOF ast _ base_pokey, mask);
1443 PokeySound_Mute(ast, ADDRESSOF ast _ extra_pokey, mask >> 4); 1443 PokeySound_Mute(ast, ADDRESSOF ast _ extra_pokey, mask >> 4);
1444} 1444}
1445 1445
1446FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast))) 1446FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast)))
1447{ 1447{
1448 V(int, player) = ast _ module_info.player; 1448 V(int, player) = ast _ module_info.player;
1449 PokeySound_StartFrame(ast); 1449 PokeySound_StartFrame(ast);
1450 switch (ast _ module_info.type) { 1450 switch (ast _ module_info.type) {
1451 case ASAP_TYPE_SAP_B: 1451 case ASAP_TYPE_SAP_B:
1452 call_6502(ast, player, ast _ module_info.fastplay); 1452 call_6502(ast, player, ast _ module_info.fastplay);
1453 break; 1453 break;
1454 case ASAP_TYPE_SAP_C: 1454 case ASAP_TYPE_SAP_C:
1455#ifndef ASAP_ONLY_SAP 1455#ifndef ASAP_ONLY_SAP
1456 case ASAP_TYPE_CMC: 1456 case ASAP_TYPE_CMC:
1457 case ASAP_TYPE_CM3: 1457 case ASAP_TYPE_CM3:
1458 case ASAP_TYPE_CMR: 1458 case ASAP_TYPE_CMR:
1459 case ASAP_TYPE_CMS: 1459 case ASAP_TYPE_CMS:
1460#endif 1460#endif
1461 call_6502(ast, player + 6, ast _ module_info.fastplay); 1461 call_6502(ast, player + 6, ast _ module_info.fastplay);
1462 break; 1462 break;
1463 case ASAP_TYPE_SAP_D: 1463 case ASAP_TYPE_SAP_D:
1464 if (player >= 0) { 1464 if (player >= 0) {
1465 V(int, s)= ast _ cpu_s; 1465 V(int, s)= ast _ cpu_s;
1466#define PUSH_ON_6502_STACK(x) dPutByte(0x100 + s, x); s = (s - 1) & 0xff 1466#define PUSH_ON_6502_STACK(x) dPutByte(0x100 + s, x); s = (s - 1) & 0xff
1467#define RETURN_FROM_PLAYER_ADDR 0xd200 1467#define RETURN_FROM_PLAYER_ADDR 0xd200
1468 /* save 6502 state on 6502 stack */ 1468 /* save 6502 state on 6502 stack */
1469 PUSH_ON_6502_STACK(ast _ cpu_pc >> 8); 1469 PUSH_ON_6502_STACK(ast _ cpu_pc >> 8);
1470 PUSH_ON_6502_STACK(ast _ cpu_pc & 0xff); 1470 PUSH_ON_6502_STACK(ast _ cpu_pc & 0xff);
1471 PUSH_ON_6502_STACK(((ast _ cpu_nz | (ast _ cpu_nz >> 1)) & 0x80) + ast _ cpu_vdi + \ 1471 PUSH_ON_6502_STACK(((ast _ cpu_nz | (ast _ cpu_nz >> 1)) & 0x80) + ast _ cpu_vdi + \
1472 ((ast _ cpu_nz & 0xff) == 0 ? Z_FLAG : 0) + ast _ cpu_c + 0x20); 1472 ((ast _ cpu_nz & 0xff) == 0 ? Z_FLAG : 0) + ast _ cpu_c + 0x20);
1473 PUSH_ON_6502_STACK(ast _ cpu_a); 1473 PUSH_ON_6502_STACK(ast _ cpu_a);
1474 PUSH_ON_6502_STACK(ast _ cpu_x); 1474 PUSH_ON_6502_STACK(ast _ cpu_x);
1475 PUSH_ON_6502_STACK(ast _ cpu_y); 1475 PUSH_ON_6502_STACK(ast _ cpu_y);
1476 /* RTS will jump to 6502 code that restores the state */ 1476 /* RTS will jump to 6502 code that restores the state */
1477 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) >> 8); 1477 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) >> 8);
1478 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) & 0xff); 1478 PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) & 0xff);
1479 ast _ cpu_s = s; 1479 ast _ cpu_s = s;
1480 dPutByte(RETURN_FROM_PLAYER_ADDR, 0x68); /* PLA */ 1480 dPutByte(RETURN_FROM_PLAYER_ADDR, 0x68); /* PLA */
1481 dPutByte(RETURN_FROM_PLAYER_ADDR + 1, 0xa8); /* TAY */ 1481 dPutByte(RETURN_FROM_PLAYER_ADDR + 1, 0xa8); /* TAY */
1482 dPutByte(RETURN_FROM_PLAYER_ADDR + 2, 0x68); /* PLA */ 1482 dPutByte(RETURN_FROM_PLAYER_ADDR + 2, 0x68); /* PLA */
1483 dPutByte(RETURN_FROM_PLAYER_ADDR + 3, 0xaa); /* TAX */ 1483 dPutByte(RETURN_FROM_PLAYER_ADDR + 3, 0xaa); /* TAX */
1484 dPutByte(RETURN_FROM_PLAYER_ADDR + 4, 0x68); /* PLA */ 1484 dPutByte(RETURN_FROM_PLAYER_ADDR + 4, 0x68); /* PLA */
1485 dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */ 1485 dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */
1486 ast _ cpu_pc = player; 1486 ast _ cpu_pc = player;
1487 } 1487 }
1488 Cpu_RunScanlines(ast, ast _ module_info.fastplay); 1488 Cpu_RunScanlines(ast, ast _ module_info.fastplay);
1489 break; 1489 break;
1490 case ASAP_TYPE_SAP_S: 1490 case ASAP_TYPE_SAP_S:
1491 Cpu_RunScanlines(ast, ast _ module_info.fastplay); 1491 Cpu_RunScanlines(ast, ast _ module_info.fastplay);
1492 { 1492 {
1493 V(int, i) = dGetByte(0x45) - 1; 1493 V(int, i) = dGetByte(0x45) - 1;
1494 dPutByte(0x45, i); 1494 dPutByte(0x45, i);
1495 if (i == 0) 1495 if (i == 0)
1496 dPutByte(0xb07b, dGetByte(0xb07b) + 1); 1496 dPutByte(0xb07b, dGetByte(0xb07b) + 1);
1497 } 1497 }
1498 break; 1498 break;
1499#ifndef ASAP_ONLY_SAP 1499#ifndef ASAP_ONLY_SAP
1500 case ASAP_TYPE_DLT: 1500 case ASAP_TYPE_DLT:
1501 call_6502(ast, player + 0x103, ast _ module_info.fastplay); 1501 call_6502(ast, player + 0x103, ast _ module_info.fastplay);
1502 break; 1502 break;
1503 case ASAP_TYPE_MPT: 1503 case ASAP_TYPE_MPT:
1504 case ASAP_TYPE_RMT: 1504 case ASAP_TYPE_RMT:
1505 case ASAP_TYPE_TM2: 1505 case ASAP_TYPE_TM2:
1506 call_6502(ast, player + 3, ast _ module_info.fastplay); 1506 call_6502(ast, player + 3, ast _ module_info.fastplay);
1507 break; 1507 break;
1508 case ASAP_TYPE_TMC: 1508 case ASAP_TYPE_TMC:
1509 if (--ast _ tmc_per_frame_counter <= 0) { 1509 if (--ast _ tmc_per_frame_counter <= 0) {
1510 ast _ tmc_per_frame_counter = ast _ tmc_per_frame; 1510 ast _ tmc_per_frame_counter = ast _ tmc_per_frame;
1511 call_6502(ast, player + 3, ast _ module_info.fastplay); 1511 call_6502(ast, player + 3, ast _ module_info.fastplay);
1512 } 1512 }
1513 else 1513 else
1514 call_6502(ast, player + 6, ast _ module_info.fastplay); 1514 call_6502(ast, player + 6, ast _ module_info.fastplay);
1515 break; 1515 break;
1516#endif 1516#endif
1517 } 1517 }
1518 PokeySound_EndFrame(ast, ast _ module_info.fastplay * 114); 1518 PokeySound_EndFrame(ast, ast _ module_info.fastplay * 114);
1519 if (ast _ silence_cycles > 0) { 1519 if (ast _ silence_cycles > 0) {
1520 if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey) 1520 if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey)
1521 && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) { 1521 && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) {
1522 ast _ silence_cycles_counter -= ast _ module_info.fastplay * 114; 1522 ast _ silence_cycles_counter -= ast _ module_info.fastplay * 114;
1523 if (ast _ silence_cycles_counter <= 0) 1523 if (ast _ silence_cycles_counter <= 0)
1524 return FALSE; 1524 return FALSE;
1525 } 1525 }
1526 else 1526 else
1527 ast _ silence_cycles_counter = ast _ silence_cycles; 1527 ast _ silence_cycles_counter = ast _ silence_cycles;
1528 } 1528 }
1529 return TRUE; 1529 return TRUE;
1530} 1530}
1531 1531
1532FUNC(int, ASAP_GetPosition, (P(CONST ASAP_State PTR, ast))) 1532FUNC(int, ASAP_GetPosition, (P(CONST ASAP_State PTR, ast)))
1533{ 1533{
1534 return ast _ blocks_played * 10 / (ASAP_SAMPLE_RATE / 100); 1534 return ast _ blocks_played * 10 / (ASAP_SAMPLE_RATE / 100);
1535} 1535}
1536 1536
1537FUNC(int, milliseconds_to_blocks, (P(int, milliseconds))) 1537FUNC(int, milliseconds_to_blocks, (P(int, milliseconds)))
1538{ 1538{
1539 return milliseconds * (ASAP_SAMPLE_RATE / 100) / 10; 1539 return milliseconds * (ASAP_SAMPLE_RATE / 100) / 10;
1540} 1540}
1541 1541
1542#ifndef ACTIONSCRIPT 1542#ifndef ACTIONSCRIPT
1543 1543
1544FUNC(void, ASAP_Seek, (P(ASAP_State PTR, ast), P(int, position))) 1544FUNC(void, ASAP_Seek, (P(ASAP_State PTR, ast), P(int, position)))
1545{ 1545{
1546 V(int, block) = milliseconds_to_blocks(position); 1546 V(int, block) = milliseconds_to_blocks(position);
1547 if (block < ast _ blocks_played) 1547 if (block < ast _ blocks_played)
1548 ASAP_PlaySong(ast, ast _ current_song, ast _ current_duration); 1548 ASAP_PlaySong(ast, ast _ current_song, ast _ current_duration);
1549 while (ast _ blocks_played + ast _ samples - ast _ sample_index < block) { 1549 while (ast _ blocks_played + ast _ samples - ast _ sample_index < block) {
1550 ast _ blocks_played += ast _ samples - ast _ sample_index; 1550 ast _ blocks_played += ast _ samples - ast _ sample_index;
1551 call_6502_player(ast); 1551 call_6502_player(ast);
1552 } 1552 }
1553 ast _ sample_index += block - ast _ blocks_played; 1553 ast _ sample_index += block - ast _ blocks_played;
1554 ast _ blocks_played = block; 1554 ast _ blocks_played = block;
1555} 1555}
1556 1556
1557PRIVATE FUNC(void, serialize_int, (P(BYTEARRAY, buffer), P(int, offset), P(int, value))) 1557PRIVATE FUNC(void, serialize_int, (P(BYTEARRAY, buffer), P(int, offset), P(int, value)))
1558{ 1558{
1559 buffer[offset] = TO_BYTE(value); 1559 buffer[offset] = TO_BYTE(value);
1560 buffer[offset + 1] = TO_BYTE(value >> 8); 1560 buffer[offset + 1] = TO_BYTE(value >> 8);
1561 buffer[offset + 2] = TO_BYTE(value >> 16); 1561 buffer[offset + 2] = TO_BYTE(value >> 16);
1562 buffer[offset + 3] = TO_BYTE(value >> 24); 1562 buffer[offset + 3] = TO_BYTE(value >> 24);
1563} 1563}
1564 1564
1565FUNC(void, ASAP_GetWavHeaderForPart, ( 1565FUNC(void, ASAP_GetWavHeaderForPart, (
1566 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), 1566 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer),
1567 P(ASAP_SampleFormat, format), P(int, blocks))) 1567 P(ASAP_SampleFormat, format), P(int, blocks)))
1568{ 1568{
1569 V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0; 1569 V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0;
1570 V(int, block_size) = ast _ module_info.channels << use_16bit; 1570 V(int, block_size) = ast _ module_info.channels << use_16bit;
1571 V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size; 1571 V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size;
1572 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played; 1572 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played;
1573 V(int, n_bytes); 1573 V(int, n_bytes);
1574 if (blocks > remaining_blocks) 1574 if (blocks > remaining_blocks)
1575 blocks = remaining_blocks; 1575 blocks = remaining_blocks;
1576 n_bytes = blocks * block_size; 1576 n_bytes = blocks * block_size;
1577 buffer[0] = CAST(byte) CHARCODE('R'); 1577 buffer[0] = CAST(byte) CHARCODE('R');
1578 buffer[1] = CAST(byte) CHARCODE('I'); 1578 buffer[1] = CAST(byte) CHARCODE('I');
1579 buffer[2] = CAST(byte) CHARCODE('F'); 1579 buffer[2] = CAST(byte) CHARCODE('F');
1580 buffer[3] = CAST(byte) CHARCODE('F'); 1580 buffer[3] = CAST(byte) CHARCODE('F');
1581 serialize_int(buffer, 4, n_bytes + 36); 1581 serialize_int(buffer, 4, n_bytes + 36);
1582 buffer[8] = CAST(byte) CHARCODE('W'); 1582 buffer[8] = CAST(byte) CHARCODE('W');
1583 buffer[9] = CAST(byte) CHARCODE('A'); 1583 buffer[9] = CAST(byte) CHARCODE('A');
1584 buffer[10] = CAST(byte) CHARCODE('V'); 1584 buffer[10] = CAST(byte) CHARCODE('V');
1585 buffer[11] = CAST(byte) CHARCODE('E'); 1585 buffer[11] = CAST(byte) CHARCODE('E');
1586 buffer[12] = CAST(byte) CHARCODE('f'); 1586 buffer[12] = CAST(byte) CHARCODE('f');
1587 buffer[13] = CAST(byte) CHARCODE('m'); 1587 buffer[13] = CAST(byte) CHARCODE('m');
1588 buffer[14] = CAST(byte) CHARCODE('t'); 1588 buffer[14] = CAST(byte) CHARCODE('t');
1589 buffer[15] = CAST(byte) CHARCODE(' '); 1589 buffer[15] = CAST(byte) CHARCODE(' ');
1590 buffer[16] = 16; 1590 buffer[16] = 16;
1591 buffer[17] = 0; 1591 buffer[17] = 0;
1592 buffer[18] = 0; 1592 buffer[18] = 0;
1593 buffer[19] = 0; 1593 buffer[19] = 0;
1594 buffer[20] = 1; 1594 buffer[20] = 1;
1595 buffer[21] = 0; 1595 buffer[21] = 0;
1596 buffer[22] = CAST(byte) ast _ module_info.channels; 1596 buffer[22] = CAST(byte) ast _ module_info.channels;
1597 buffer[23] = 0; 1597 buffer[23] = 0;
1598 serialize_int(buffer, 24, ASAP_SAMPLE_RATE); 1598 serialize_int(buffer, 24, ASAP_SAMPLE_RATE);
1599 serialize_int(buffer, 28, bytes_per_second); 1599 serialize_int(buffer, 28, bytes_per_second);
1600 buffer[32] = CAST(byte) block_size; 1600 buffer[32] = CAST(byte) block_size;
1601 buffer[33] = 0; 1601 buffer[33] = 0;
1602 buffer[34] = CAST(byte) (8 << use_16bit); 1602 buffer[34] = CAST(byte) (8 << use_16bit);
1603 buffer[35] = 0; 1603 buffer[35] = 0;
1604 buffer[36] = CAST(byte) CHARCODE('d'); 1604 buffer[36] = CAST(byte) CHARCODE('d');
1605 buffer[37] = CAST(byte) CHARCODE('a'); 1605 buffer[37] = CAST(byte) CHARCODE('a');
1606 buffer[38] = CAST(byte) CHARCODE('t'); 1606 buffer[38] = CAST(byte) CHARCODE('t');
1607 buffer[39] = CAST(byte) CHARCODE('a'); 1607 buffer[39] = CAST(byte) CHARCODE('a');
1608 serialize_int(buffer, 40, n_bytes); 1608 serialize_int(buffer, 40, n_bytes);
1609} 1609}
1610 1610
1611FUNC(void, ASAP_GetWavHeader, ( 1611FUNC(void, ASAP_GetWavHeader, (
1612 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format))) 1612 P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format)))
1613{ 1613{
1614 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played; 1614 V(int, remaining_blocks) = milliseconds_to_blocks(ast _ current_duration) - ast _ blocks_played;
1615 ASAP_GetWavHeaderForPart(ast, buffer, format, remaining_blocks); 1615 ASAP_GetWavHeaderForPart(ast, buffer, format, remaining_blocks);
1616} 1616}
1617 1617
1618#endif /* ACTIONSCRIPT */ 1618#endif /* ACTIONSCRIPT */
1619 1619
1620PRIVATE FUNC(int, ASAP_GenerateAt, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_offset), P(int, buffer_len), P(ASAP_SampleFormat, format))) 1620PRIVATE FUNC(int, ASAP_GenerateAt, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_offset), P(int, buffer_len), P(ASAP_SampleFormat, format)))
1621{ 1621{
1622 V(int, block_shift); 1622 V(int, block_shift);
1623 V(int, buffer_blocks); 1623 V(int, buffer_blocks);
1624 V(int, block); 1624 V(int, block);
1625 if (ast _ silence_cycles > 0 && ast _ silence_cycles_counter <= 0) 1625 if (ast _ silence_cycles > 0 && ast _ silence_cycles_counter <= 0)
1626 return 0; 1626 return 0;
1627#ifdef ACTIONSCRIPT 1627#ifdef ACTIONSCRIPT
1628 block_shift = 0; 1628 block_shift = 0;
1629#else 1629#else
1630 block_shift = (ast _ module_info.channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0); 1630 block_shift = (ast _ module_info.channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0);
1631#endif 1631#endif
1632 buffer_blocks = buffer_len >> block_shift; 1632 buffer_blocks = buffer_len >> block_shift;
1633 if (ast _ current_duration > 0) { 1633 if (ast _ current_duration > 0) {
1634 V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); 1634 V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration);
1635 if (buffer_blocks > total_blocks - ast _ blocks_played) 1635 if (buffer_blocks > total_blocks - ast _ blocks_played)
1636 buffer_blocks = total_blocks - ast _ blocks_played; 1636 buffer_blocks = total_blocks - ast _ blocks_played;
1637 } 1637 }
1638 block = 0; 1638 block = 0;
1639 do { 1639 do {
1640 V(int, blocks) = PokeySound_Generate(ast, CAST(BYTEARRAY) buffer, 1640 V(int, blocks) = PokeySound_Generate(ast, CAST(BYTEARRAY) buffer,
1641 buffer_offset + (block << block_shift), buffer_blocks - block, format); 1641 buffer_offset + (block << block_shift), buffer_blocks - block, format);
1642 ast _ blocks_played += blocks; 1642 ast _ blocks_played += blocks;
1643 block += blocks; 1643 block += blocks;
1644 } while (block < buffer_blocks && call_6502_player(ast)); 1644 } while (block < buffer_blocks && call_6502_player(ast));
1645 return block << block_shift; 1645 return block << block_shift;
1646} 1646}
1647 1647
1648FUNC(int, ASAP_Generate, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_len), P(ASAP_SampleFormat, format))) 1648FUNC(int, ASAP_Generate, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_len), P(ASAP_SampleFormat, format)))
1649{ 1649{
1650 return ASAP_GenerateAt(ast, buffer, 0, buffer_len, format); 1650 return ASAP_GenerateAt(ast, buffer, 0, buffer_len, format);
1651} 1651}
1652 1652
1653#if defined(C) && !defined(ASAP_ONLY_SAP) 1653#if defined(C) && !defined(ASAP_ONLY_SAP)
1654 1654
1655abool ASAP_ChangeExt(char *filename, const char *ext) 1655abool ASAP_ChangeExt(char *filename, const char *ext)
1656{ 1656{
1657 char *dest = NULL; 1657 char *dest = NULL;
1658 while (*filename != '\0') { 1658 while (*filename != '\0') {
1659 if (*filename == '/' || *filename == '\\') 1659 if (*filename == '/' || *filename == '\\')
1660 dest = NULL; 1660 dest = NULL;
1661 else if (*filename == '.') 1661 else if (*filename == '.')
1662 dest = filename + 1; 1662 dest = filename + 1;
1663 filename++; 1663 filename++;
1664 } 1664 }
1665 if (dest == NULL) 1665 if (dest == NULL)
1666 return FALSE; 1666 return FALSE;
1667 strcpy(dest, ext); 1667 strcpy(dest, ext);
1668 return TRUE; 1668 return TRUE;
1669} 1669}
1670 1670
1671abool ASAP_CanSetModuleInfo(const char *filename) 1671abool ASAP_CanSetModuleInfo(const char *filename)
1672{ 1672{
1673 int ext = get_packed_ext(filename); 1673 int ext = get_packed_ext(filename);
1674 return ext == ASAP_EXT('S', 'A', 'P'); 1674 return ext == ASAP_EXT('S', 'A', 'P');
1675} 1675}
1676 1676
1677static byte *put_string(byte *dest, const char *str) 1677static byte *put_string(byte *dest, const char *str)
1678{ 1678{
1679 while (*str != '\0') 1679 while (*str != '\0')
1680 *dest++ = *str++; 1680 *dest++ = *str++;
1681 return dest; 1681 return dest;
1682} 1682}
1683 1683
1684static byte *put_dec(byte *dest, int value) 1684static byte *put_dec(byte *dest, int value)
1685{ 1685{
1686 if (value >= 10) { 1686 if (value >= 10) {
1687 dest = put_dec(dest, value / 10); 1687 dest = put_dec(dest, value / 10);
1688 value %= 10; 1688 value %= 10;
1689 } 1689 }
1690 *dest++ = '0' + value; 1690 *dest++ = '0' + value;
1691 return dest; 1691 return dest;
1692} 1692}
1693 1693
1694static byte *put_text_tag(byte *dest, const char *tag, const char *value) 1694static byte *put_text_tag(byte *dest, const char *tag, const char *value)
1695{ 1695{
1696 dest = put_string(dest, tag); 1696 dest = put_string(dest, tag);
1697 *dest++ = '"'; 1697 *dest++ = '"';
1698 if (*value == '\0') 1698 if (*value == '\0')
1699 value = "<?>"; 1699 value = "<?>";
1700 while (*value != '\0') { 1700 while (*value != '\0') {
1701 if (*value < ' ' || *value > 'z' || *value == '"' || *value == '`') 1701 if (*value < ' ' || *value > 'z' || *value == '"' || *value == '`')
1702 return NULL; 1702 return NULL;
1703 *dest++ = *value++; 1703 *dest++ = *value++;
1704 } 1704 }
1705 *dest++ = '"'; 1705 *dest++ = '"';
1706 *dest++ = '\r'; 1706 *dest++ = '\r';
1707 *dest++ = '\n'; 1707 *dest++ = '\n';
1708 return dest; 1708 return dest;
1709} 1709}
1710 1710
1711static byte *put_dec_tag(byte *dest, const char *tag, int value) 1711static byte *put_dec_tag(byte *dest, const char *tag, int value)
1712{ 1712{
1713 dest = put_string(dest, tag); 1713 dest = put_string(dest, tag);
1714 dest = put_dec(dest, value); 1714 dest = put_dec(dest, value);
1715 *dest++ = '\r'; 1715 *dest++ = '\r';
1716 *dest++ = '\n'; 1716 *dest++ = '\n';
1717 return dest; 1717 return dest;
1718} 1718}
1719 1719
1720static byte *put_hex_tag(byte *dest, const char *tag, int value) 1720static byte *put_hex_tag(byte *dest, const char *tag, int value)
1721{ 1721{
1722 int i; 1722 int i;
1723 if (value < 0) 1723 if (value < 0)
1724 return dest; 1724 return dest;
1725 dest = put_string(dest, tag); 1725 dest = put_string(dest, tag);
1726 for (i = 12; i >= 0; i -= 4) { 1726 for (i = 12; i >= 0; i -= 4) {
1727 int digit = (value >> i) & 0xf; 1727 int digit = (value >> i) & 0xf;
1728 *dest++ = (byte) (digit + (digit < 10 ? '0' : 'A' - 10)); 1728 *dest++ = (byte) (digit + (digit < 10 ? '0' : 'A' - 10));
1729 } 1729 }
1730 *dest++ = '\r'; 1730 *dest++ = '\r';
1731 *dest++ = '\n'; 1731 *dest++ = '\n';
1732 return dest; 1732 return dest;
1733} 1733}
1734 1734
1735static byte *start_sap_header(byte *dest, const ASAP_ModuleInfo *module_info) 1735static byte *start_sap_header(byte *dest, const ASAP_ModuleInfo *module_info)
1736{ 1736{
1737 dest = put_string(dest, "SAP\r\n"); 1737 dest = put_string(dest, "SAP\r\n");
1738 dest = put_text_tag(dest, "AUTHOR ", module_info->author); 1738 dest = put_text_tag(dest, "AUTHOR ", module_info->author);
1739 if (dest == NULL) 1739 if (dest == NULL)
1740 return NULL; 1740 return NULL;
1741 dest = put_text_tag(dest, "NAME ", module_info->name); 1741 dest = put_text_tag(dest, "NAME ", module_info->name);
1742 if (dest == NULL) 1742 if (dest == NULL)
1743 return NULL; 1743 return NULL;
1744 dest = put_text_tag(dest, "DATE ", module_info->date); 1744 dest = put_text_tag(dest, "DATE ", module_info->date);
1745 if (dest == NULL) 1745 if (dest == NULL)
1746 return NULL; 1746 return NULL;
1747 if (module_info->songs > 1) { 1747 if (module_info->songs > 1) {
1748 dest = put_dec_tag(dest, "SONGS ", module_info->songs); 1748 dest = put_dec_tag(dest, "SONGS ", module_info->songs);
1749 if (module_info->default_song > 0) 1749 if (module_info->default_song > 0)
1750 dest = put_dec_tag(dest, "DEFSONG ", module_info->default_song); 1750 dest = put_dec_tag(dest, "DEFSONG ", module_info->default_song);
1751 } 1751 }
1752 if (module_info->channels > 1) 1752 if (module_info->channels > 1)
1753 dest = put_string(dest, "STEREO\r\n"); 1753 dest = put_string(dest, "STEREO\r\n");
1754 return dest; 1754 return dest;
1755} 1755}
1756 1756
1757static char *two_digits(char *s, int x) 1757static char *two_digits(char *s, int x)
1758{ 1758{
1759 s[0] = '0' + x / 10; 1759 s[0] = '0' + x / 10;
1760 s[1] = '0' + x % 10; 1760 s[1] = '0' + x % 10;
1761 return s + 2; 1761 return s + 2;
1762} 1762}
1763 1763
1764void ASAP_DurationToString(char *s, int duration) 1764void ASAP_DurationToString(char *s, int duration)
1765{ 1765{
1766 if (duration >= 0 && duration < 100 * 60 * 1000) { 1766 if (duration >= 0 && duration < 100 * 60 * 1000) {
1767 int seconds = duration / 1000; 1767 int seconds = duration / 1000;
1768 s = two_digits(s, seconds / 60); 1768 s = two_digits(s, seconds / 60);
1769 *s++ = ':'; 1769 *s++ = ':';
1770 s = two_digits(s, seconds % 60); 1770 s = two_digits(s, seconds % 60);
1771 duration %= 1000; 1771 duration %= 1000;
1772 if (duration != 0) { 1772 if (duration != 0) {
1773 *s++ = '.'; 1773 *s++ = '.';
1774 s = two_digits(s, duration / 10); 1774 s = two_digits(s, duration / 10);
1775 duration %= 10; 1775 duration %= 10;
1776 if (duration != 0) 1776 if (duration != 0)
1777 *s++ = '0' + duration; 1777 *s++ = '0' + duration;
1778 } 1778 }
1779 } 1779 }
1780 *s = '\0'; 1780 *s = '\0';
1781} 1781}
1782 1782
1783static byte *put_durations(byte *dest, const ASAP_ModuleInfo *module_info) 1783static byte *put_durations(byte *dest, const ASAP_ModuleInfo *module_info)
1784{ 1784{
1785 int song; 1785 int song;
1786 for (song = 0; song < module_info->songs; song++) { 1786 for (song = 0; song < module_info->songs; song++) {
1787 if (module_info->durations[song] < 0) 1787 if (module_info->durations[song] < 0)
1788 break; 1788 break;
1789 dest = put_string(dest, "TIME "); 1789 dest = put_string(dest, "TIME ");
1790 ASAP_DurationToString((char *) dest, module_info->durations[song]); 1790 ASAP_DurationToString((char *) dest, module_info->durations[song]);
1791 while (*dest != '\0') 1791 while (*dest != '\0')
1792 dest++; 1792 dest++;
1793 if (module_info->loops[song]) 1793 if (module_info->loops[song])
1794 dest = put_string(dest, " LOOP"); 1794 dest = put_string(dest, " LOOP");
1795 *dest++ = '\r'; 1795 *dest++ = '\r';
1796 *dest++ = '\n'; 1796 *dest++ = '\n';
1797 } 1797 }
1798 return dest; 1798 return dest;
1799} 1799}
1800 1800
1801static byte *put_sap_header(byte *dest, const ASAP_ModuleInfo *module_info, char type, int music, int init, int player) 1801static byte *put_sap_header(byte *dest, const ASAP_ModuleInfo *module_info, char type, int music, int init, int player)
1802{ 1802{
1803 dest = start_sap_header(dest, module_info); 1803 dest = start_sap_header(dest, module_info);
1804 if (dest == NULL) 1804 if (dest == NULL)
1805 return NULL; 1805 return NULL;
1806 dest = put_string(dest, "TYPE "); 1806 dest = put_string(dest, "TYPE ");
1807 *dest++ = type; 1807 *dest++ = type;
1808 *dest++ = '\r'; 1808 *dest++ = '\r';
1809 *dest++ = '\n'; 1809 *dest++ = '\n';
1810 if (module_info->fastplay != 312) 1810 if (module_info->fastplay != 312)
1811 dest = put_dec_tag(dest, "FASTPLAY ", module_info->fastplay); 1811 dest = put_dec_tag(dest, "FASTPLAY ", module_info->fastplay);
1812 dest = put_hex_tag(dest, "MUSIC ", music); 1812 dest = put_hex_tag(dest, "MUSIC ", music);
1813 dest = put_hex_tag(dest, "INIT ", init); 1813 dest = put_hex_tag(dest, "INIT ", init);
1814 dest = put_hex_tag(dest, "PLAYER ", player); 1814 dest = put_hex_tag(dest, "PLAYER ", player);
1815 dest = put_durations(dest, module_info); 1815 dest = put_durations(dest, module_info);
1816 return dest; 1816 return dest;
1817} 1817}
1818 1818
1819int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const BYTEARRAY module, int module_len, BYTEARRAY out_module) 1819int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const BYTEARRAY module, int module_len, BYTEARRAY out_module)
1820{ 1820{
1821 byte *dest; 1821 byte *dest;
1822 int i; 1822 int i;
1823 if (memcmp(module, "SAP\r\n", 5) != 0) 1823 if (memcmp(module, "SAP\r\n", 5) != 0)
1824 return -1; 1824 return -1;
1825 dest = start_sap_header(out_module, module_info); 1825 dest = start_sap_header(out_module, module_info);
1826 if (dest == NULL) 1826 if (dest == NULL)
1827 return -1; 1827 return -1;
1828 i = 5; 1828 i = 5;
1829 while (i < module_len && module[i] != 0xff) { 1829 while (i < module_len && module[i] != 0xff) {
1830 if (memcmp(module + i, "AUTHOR ", 7) == 0 1830 if (memcmp(module + i, "AUTHOR ", 7) == 0
1831 || memcmp(module + i, "NAME ", 5) == 0 1831 || memcmp(module + i, "NAME ", 5) == 0
1832 || memcmp(module + i, "DATE ", 5) == 0 1832 || memcmp(module + i, "DATE ", 5) == 0
1833 || memcmp(module + i, "SONGS ", 6) == 0 1833 || memcmp(module + i, "SONGS ", 6) == 0
1834 || memcmp(module + i, "DEFSONG ", 8) == 0 1834 || memcmp(module + i, "DEFSONG ", 8) == 0
1835 || memcmp(module + i, "STEREO\r", 7) == 0 1835 || memcmp(module + i, "STEREO\r", 7) == 0
1836 || memcmp(module + i, "TIME ", 5) == 0) { 1836 || memcmp(module + i, "TIME ", 5) == 0) {
1837 while (i < module_len && module[i++] != 0x0a); 1837 while (i < module_len && module[i++] != 0x0a);
1838 } 1838 }
1839 else { 1839 else {
1840 int b; 1840 int b;
1841 do { 1841 do {
1842 b = module[i++]; 1842 b = module[i++];
1843 *dest++ = b; 1843 *dest++ = b;
1844 } while (i < module_len && b != 0x0a); 1844 } while (i < module_len && b != 0x0a);
1845 } 1845 }
1846 } 1846 }
1847 dest = put_durations(dest, module_info); 1847 dest = put_durations(dest, module_info);
1848 module_len -= i; 1848 module_len -= i;
1849 memcpy(dest, module + i, module_len); 1849 memcpy(dest, module + i, module_len);
1850 dest += module_len; 1850 dest += module_len;
1851 return dest - out_module; 1851 return dest - out_module;
1852} 1852}
1853 1853
1854#define RMT_INIT 0x0c80 1854#define RMT_INIT 0x0c80
1855#define TM2_INIT 0x1080 1855#define TM2_INIT 0x1080
1856 1856
1857const char *ASAP_CanConvert( 1857const char *ASAP_CanConvert(
1858 const char *filename, const ASAP_ModuleInfo *module_info, 1858 const char *filename, const ASAP_ModuleInfo *module_info,
1859 const BYTEARRAY module, int module_len) 1859 const BYTEARRAY module, int module_len)
1860{ 1860{
1861 (void) filename; 1861 (void) filename;
1862 switch (module_info->type) { 1862 switch (module_info->type) {
1863 case ASAP_TYPE_SAP_B: 1863 case ASAP_TYPE_SAP_B:
1864 if ((module_info->init == 0x3fb || module_info->init == 0x3f9) && module_info->player == 0x503) 1864 if ((module_info->init == 0x3fb || module_info->init == 0x3f9) && module_info->player == 0x503)
1865 return "dlt"; 1865 return "dlt";
1866 if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef) 1866 if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef)
1867 return module_info->fastplay == 156 ? "mpd" : "mpt"; 1867 return module_info->fastplay == 156 ? "mpd" : "mpt";
1868 if (module_info->init == RMT_INIT) 1868 if (module_info->init == RMT_INIT)
1869 return "rmt"; 1869 return "rmt";
1870 if ((module_info->init == 0x4f5 || module_info->init == 0xf4f5 || module_info->init == 0x4f2) 1870 if ((module_info->init == 0x4f5 || module_info->init == 0xf4f5 || module_info->init == 0x4f2)
1871 || ((module_info->init == 0x4e7 || module_info->init == 0xf4e7 || module_info->init == 0x4e4) && module_info->fastplay == 156) 1871 || ((module_info->init == 0x4e7 || module_info->init == 0xf4e7 || module_info->init == 0x4e4) && module_info->fastplay == 156)
1872 || ((module_info->init == 0x4e5 || module_info->init == 0xf4e5 || module_info->init == 0x4e2) && (module_info->fastplay == 104 || module_info->fastplay == 78))) 1872 || ((module_info->init == 0x4e5 || module_info->init == 0xf4e5 || module_info->init == 0x4e2) && (module_info->fastplay == 104 || module_info->fastplay == 78)))
1873 return "tmc"; 1873 return "tmc";
1874 if (module_info->init == TM2_INIT) 1874 if (module_info->init == TM2_INIT)
1875 return "tm2"; 1875 return "tm2";
1876 break; 1876 break;
1877 case ASAP_TYPE_SAP_C: 1877 case ASAP_TYPE_SAP_C:
1878 if (module_info->player == 0x500 || module_info->player == 0xf500) { 1878 if (module_info->player == 0x500 || module_info->player == 0xf500) {
1879 if (module_info->fastplay == 156) 1879 if (module_info->fastplay == 156)
1880 return "dmc"; 1880 return "dmc";
1881 if (module_info->channels > 1) 1881 if (module_info->channels > 1)
1882 return "cms"; 1882 return "cms";
1883 if (module[module_len - 170] == 0x1e) 1883 if (module[module_len - 170] == 0x1e)
1884 return "cmr"; 1884 return "cmr";
1885 if (module[module_len - 909] == 0x30) 1885 if (module[module_len - 909] == 0x30)
1886 return "cm3"; 1886 return "cm3";
1887 return "cmc"; 1887 return "cmc";
1888 } 1888 }
1889 break; 1889 break;
1890 case ASAP_TYPE_CMC: 1890 case ASAP_TYPE_CMC:
1891 case ASAP_TYPE_CM3: 1891 case ASAP_TYPE_CM3:
1892 case ASAP_TYPE_CMR: 1892 case ASAP_TYPE_CMR:
1893 case ASAP_TYPE_CMS: 1893 case ASAP_TYPE_CMS:
1894 case ASAP_TYPE_DLT: 1894 case ASAP_TYPE_DLT:
1895 case ASAP_TYPE_MPT: 1895 case ASAP_TYPE_MPT:
1896 case ASAP_TYPE_RMT: 1896 case ASAP_TYPE_RMT:
1897 case ASAP_TYPE_TMC: 1897 case ASAP_TYPE_TMC:
1898 case ASAP_TYPE_TM2: 1898 case ASAP_TYPE_TM2:
1899 return "sap"; 1899 return "sap";
1900 default: 1900 default:
1901 break; 1901 break;
1902 } 1902 }
1903 return NULL; 1903 return NULL;
1904} 1904}
1905 1905
1906int ASAP_Convert( 1906int ASAP_Convert(
1907 const char *filename, const ASAP_ModuleInfo *module_info, 1907 const char *filename, const ASAP_ModuleInfo *module_info,
1908 const BYTEARRAY module, int module_len, BYTEARRAY out_module) 1908 const BYTEARRAY module, int module_len, BYTEARRAY out_module)
1909{ 1909{
1910 (void) filename; 1910 (void) filename;
1911 int out_len; 1911 int out_len;
1912 byte *dest; 1912 byte *dest;
1913 int addr; 1913 int addr;
1914 int player; 1914 int player;
1915 static const int tmc_player[4] = { 3, -9, -10, -10 }; 1915 static const int tmc_player[4] = { 3, -9, -10, -10 };
1916 static const int tmc_init[4] = { -14, -16, -17, -17 }; 1916 static const int tmc_init[4] = { -14, -16, -17, -17 };
1917 switch (module_info->type) { 1917 switch (module_info->type) {
1918 case ASAP_TYPE_SAP_B: 1918 case ASAP_TYPE_SAP_B:
1919 case ASAP_TYPE_SAP_C: 1919 case ASAP_TYPE_SAP_C:
1920 out_len = UWORD(module, module_info->header_len + 4) - UWORD(module, module_info->header_len + 2) + 7; 1920 out_len = UWORD(module, module_info->header_len + 4) - UWORD(module, module_info->header_len + 2) + 7;
1921 if (out_len < 7 || module_info->header_len + out_len >= module_len) 1921 if (out_len < 7 || module_info->header_len + out_len >= module_len)
1922 return -1; 1922 return -1;
1923 memcpy(out_module, module + module_info->header_len, out_len); 1923 memcpy(out_module, module + module_info->header_len, out_len);
1924 return out_len; 1924 return out_len;
1925 case ASAP_TYPE_CMC: 1925 case ASAP_TYPE_CMC:
1926 case ASAP_TYPE_CM3: 1926 case ASAP_TYPE_CM3:
1927 case ASAP_TYPE_CMR: 1927 case ASAP_TYPE_CMR:
1928 case ASAP_TYPE_CMS: 1928 case ASAP_TYPE_CMS:
1929 dest = put_sap_header(out_module, module_info, 'C', module_info->music, -1, module_info->player); 1929 dest = put_sap_header(out_module, module_info, 'C', module_info->music, -1, module_info->player);
1930 if (dest == NULL) 1930 if (dest == NULL)
1931 return -1; 1931 return -1;
1932 memcpy(dest, module, module_len); 1932 memcpy(dest, module, module_len);
1933 dest[0] = 0xff; /* some modules start with zeros */ 1933 dest[0] = 0xff; /* some modules start with zeros */
1934 dest[1] = 0xff; 1934 dest[1] = 0xff;
1935 dest += module_len; 1935 dest += module_len;
1936 if (module_info->type == ASAP_TYPE_CM3) { 1936 if (module_info->type == ASAP_TYPE_CM3) {
1937 memcpy(dest, cm3_obx + 2, sizeof(cm3_obx) - 2); 1937 memcpy(dest, cm3_obx + 2, sizeof(cm3_obx) - 2);
1938 dest += sizeof(cm3_obx) - 2; 1938 dest += sizeof(cm3_obx) - 2;
1939 } 1939 }
1940 else if (module_info->type == ASAP_TYPE_CMS) { 1940 else if (module_info->type == ASAP_TYPE_CMS) {
1941 memcpy(dest, cms_obx + 2, sizeof(cms_obx) - 2); 1941 memcpy(dest, cms_obx + 2, sizeof(cms_obx) - 2);
1942 dest += sizeof(cms_obx) - 2; 1942 dest += sizeof(cms_obx) - 2;
1943 } 1943 }
1944 else { 1944 else {
1945 memcpy(dest, cmc_obx + 2, sizeof(cmc_obx) - 2); 1945 memcpy(dest, cmc_obx + 2, sizeof(cmc_obx) - 2);
1946 if (module_info->type == ASAP_TYPE_CMR) 1946 if (module_info->type == ASAP_TYPE_CMR)
1947 memcpy(dest + 4 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, sizeof(cmr_bass_table)); 1947 memcpy(dest + 4 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, sizeof(cmr_bass_table));
1948 dest += sizeof(cmc_obx) - 2; 1948 dest += sizeof(cmc_obx) - 2;
1949 } 1949 }
1950 return dest - out_module; 1950 return dest - out_module;
1951 case ASAP_TYPE_DLT: 1951 case ASAP_TYPE_DLT:
1952 if (module_info->songs != 1) { 1952 if (module_info->songs != 1) {
1953 addr = module_info->player - 7 - module_info->songs; 1953 addr = module_info->player - 7 - module_info->songs;
1954 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 7, module_info->player + 0x103); 1954 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 7, module_info->player + 0x103);
1955 } 1955 }
1956 else { 1956 else {
1957 addr = module_info->player - 5; 1957 addr = module_info->player - 5;
1958 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 0x103); 1958 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 0x103);
1959 } 1959 }
1960 if (dest == NULL) 1960 if (dest == NULL)
1961 return -1; 1961 return -1;
1962 memcpy(dest, module, module_len); 1962 memcpy(dest, module, module_len);
1963 if (module_len == 0x2c06) { 1963 if (module_len == 0x2c06) {
1964 dest[4] = 0; 1964 dest[4] = 0;
1965 dest[5] = 0x4c; 1965 dest[5] = 0x4c;
1966 dest[0x2c06] = 0; 1966 dest[0x2c06] = 0;
1967 } 1967 }
1968 dest += 0x2c07; 1968 dest += 0x2c07;
1969 *dest++ = (byte) addr; 1969 *dest++ = (byte) addr;
1970 *dest++ = (byte) (addr >> 8); 1970 *dest++ = (byte) (addr >> 8);
1971 *dest++ = dlt_obx[4]; 1971 *dest++ = dlt_obx[4];
1972 *dest++ = dlt_obx[5]; 1972 *dest++ = dlt_obx[5];
1973 if (module_info->songs != 1) { 1973 if (module_info->songs != 1) {
1974 memcpy(dest, module_info->song_pos, module_info->songs); 1974 memcpy(dest, module_info->song_pos, module_info->songs);
1975 dest += module_info->songs; 1975 dest += module_info->songs;
1976 *dest++ = 0xaa; /* tax */ 1976 *dest++ = 0xaa; /* tax */
1977 *dest++ = 0xbc; /* ldy song2pos,x */ 1977 *dest++ = 0xbc; /* ldy song2pos,x */
1978 *dest++ = (byte) addr; 1978 *dest++ = (byte) addr;
1979 *dest++ = (byte) (addr >> 8); 1979 *dest++ = (byte) (addr >> 8);
1980 } 1980 }
1981 else { 1981 else {
1982 *dest++ = 0xa0; /* ldy #0 */ 1982 *dest++ = 0xa0; /* ldy #0 */
1983 *dest++ = 0; 1983 *dest++ = 0;
1984 } 1984 }
1985 *dest++ = 0x4c; /* jmp init */ 1985 *dest++ = 0x4c; /* jmp init */
1986 *dest++ = (byte) module_info->player; 1986 *dest++ = (byte) module_info->player;
1987 *dest++ = (byte) ((module_info->player >> 8) + 1); 1987 *dest++ = (byte) ((module_info->player >> 8) + 1);
1988 memcpy(dest, dlt_obx + 6, sizeof(dlt_obx) - 6); 1988 memcpy(dest, dlt_obx + 6, sizeof(dlt_obx) - 6);
1989 dest += sizeof(dlt_obx) - 6; 1989 dest += sizeof(dlt_obx) - 6;
1990 return dest - out_module; 1990 return dest - out_module;
1991 case ASAP_TYPE_MPT: 1991 case ASAP_TYPE_MPT:
1992 if (module_info->songs != 1) { 1992 if (module_info->songs != 1) {
1993 addr = module_info->player - 17 - module_info->songs; 1993 addr = module_info->player - 17 - module_info->songs;
1994 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 17, module_info->player + 3); 1994 dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 17, module_info->player + 3);
1995 } 1995 }
1996 else { 1996 else {
1997 addr = module_info->player - 13; 1997 addr = module_info->player - 13;
1998 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 3); 1998 dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 3);
1999 } 1999 }
2000 if (dest == NULL) 2000 if (dest == NULL)
2001 return -1; 2001 return -1;
2002 memcpy(dest, module, module_len); 2002 memcpy(dest, module, module_len);
2003 dest += module_len; 2003 dest += module_len;
2004 *dest++ = (byte) addr; 2004 *dest++ = (byte) addr;
2005 *dest++ = (byte) (addr >> 8); 2005 *dest++ = (byte) (addr >> 8);
2006 *dest++ = mpt_obx[4]; 2006 *dest++ = mpt_obx[4];
2007 *dest++ = mpt_obx[5]; 2007 *dest++ = mpt_obx[5];
2008 if (module_info->songs != 1) { 2008 if (module_info->songs != 1) {
2009 memcpy(dest, module_info->song_pos, module_info->songs); 2009 memcpy(dest, module_info->song_pos, module_info->songs);
2010 dest += module_info->songs; 2010 dest += module_info->songs;
2011 *dest++ = 0x48; /* pha */ 2011 *dest++ = 0x48; /* pha */
2012 } 2012 }
2013 *dest++ = 0xa0; /* ldy #<music */ 2013 *dest++ = 0xa0; /* ldy #<music */
2014 *dest++ = (byte) module_info->music; 2014 *dest++ = (byte) module_info->music;
2015 *dest++ = 0xa2; /* ldx #>music */ 2015 *dest++ = 0xa2; /* ldx #>music */
2016 *dest++ = (byte) (module_info->music >> 8); 2016 *dest++ = (byte) (module_info->music >> 8);
2017 *dest++ = 0xa9; /* lda #0 */ 2017 *dest++ = 0xa9; /* lda #0 */
2018 *dest++ = 0; 2018 *dest++ = 0;
2019 *dest++ = 0x20; /* jsr player */ 2019 *dest++ = 0x20; /* jsr player */
2020 *dest++ = (byte) module_info->player; 2020 *dest++ = (byte) module_info->player;
2021 *dest++ = (byte) (module_info->player >> 8); 2021 *dest++ = (byte) (module_info->player >> 8);
2022 if (module_info->songs != 1) { 2022 if (module_info->songs != 1) {
2023 *dest++ = 0x68; /* pla */ 2023 *dest++ = 0x68; /* pla */
2024 *dest++ = 0xa8; /* tay */ 2024 *dest++ = 0xa8; /* tay */
2025 *dest++ = 0xbe; /* ldx song2pos,y */ 2025 *dest++ = 0xbe; /* ldx song2pos,y */
2026 *dest++ = (byte) addr; 2026 *dest++ = (byte) addr;
2027 *dest++ = (byte) (addr >> 8); 2027 *dest++ = (byte) (addr >> 8);
2028 } 2028 }
2029 else { 2029 else {
2030 *dest++ = 0xa2; /* ldx #0 */ 2030 *dest++ = 0xa2; /* ldx #0 */
2031 *dest++ = 0; 2031 *dest++ = 0;
2032 } 2032 }
2033 *dest++ = 0xa9; /* lda #2 */ 2033 *dest++ = 0xa9; /* lda #2 */
2034 *dest++ = 2; 2034 *dest++ = 2;
2035 memcpy(dest, mpt_obx + 6, sizeof(mpt_obx) - 6); 2035 memcpy(dest, mpt_obx + 6, sizeof(mpt_obx) - 6);
2036 dest += sizeof(mpt_obx) - 6; 2036 dest += sizeof(mpt_obx) - 6;
2037 return dest - out_module; 2037 return dest - out_module;
2038 case ASAP_TYPE_RMT: 2038 case ASAP_TYPE_RMT:
2039 dest = put_sap_header(out_module, module_info, 'B', -1, RMT_INIT, module_info->player + 3); 2039 dest = put_sap_header(out_module, module_info, 'B', -1, RMT_INIT, module_info->player + 3);
2040 if (dest == NULL) 2040 if (dest == NULL)
2041 return -1; 2041 return -1;
2042 memcpy(dest, module, module_len); 2042 memcpy(dest, module, module_len);
2043 dest += module_len; 2043 dest += module_len;
2044 *dest++ = (byte) RMT_INIT; 2044 *dest++ = (byte) RMT_INIT;
2045 *dest++ = (byte) (RMT_INIT >> 8); 2045 *dest++ = (byte) (RMT_INIT >> 8);
2046 if (module_info->songs != 1) { 2046 if (module_info->songs != 1) {
2047 addr = RMT_INIT + 10 + module_info->songs; 2047 addr = RMT_INIT + 10 + module_info->songs;
2048 *dest++ = (byte) addr; 2048 *dest++ = (byte) addr;
2049 *dest++ = (byte) (addr >> 8); 2049 *dest++ = (byte) (addr >> 8);
2050 *dest++ = 0xa8; /* tay */ 2050 *dest++ = 0xa8; /* tay */
2051 *dest++ = 0xb9; /* lda song2pos,y */ 2051 *dest++ = 0xb9; /* lda song2pos,y */
2052 *dest++ = (byte) (RMT_INIT + 11); 2052 *dest++ = (byte) (RMT_INIT + 11);
2053 *dest++ = (byte) ((RMT_INIT + 11) >> 8); 2053 *dest++ = (byte) ((RMT_INIT + 11) >> 8);
2054 } 2054 }
2055 else { 2055 else {
2056 *dest++ = (byte) (RMT_INIT + 8); 2056 *dest++ = (byte) (RMT_INIT + 8);
2057 *dest++ = (byte) ((RMT_INIT + 8) >> 8); 2057 *dest++ = (byte) ((RMT_INIT + 8) >> 8);
2058 *dest++ = 0xa9; /* lda #0 */ 2058 *dest++ = 0xa9; /* lda #0 */
2059 *dest++ = 0; 2059 *dest++ = 0;
2060 } 2060 }
2061 *dest++ = 0xa2; /* ldx #<music */ 2061 *dest++ = 0xa2; /* ldx #<music */
2062 *dest++ = (byte) module_info->music; 2062 *dest++ = (byte) module_info->music;
2063 *dest++ = 0xa0; /* ldy #>music */ 2063 *dest++ = 0xa0; /* ldy #>music */
2064 *dest++ = (byte) (module_info->music >> 8); 2064 *dest++ = (byte) (module_info->music >> 8);
2065 *dest++ = 0x4c; /* jmp player */ 2065 *dest++ = 0x4c; /* jmp player */
2066 *dest++ = (byte) module_info->player; 2066 *dest++ = (byte) module_info->player;
2067 *dest++ = (byte) (module_info->player >> 8); 2067 *dest++ = (byte) (module_info->player >> 8);
2068 if (module_info->songs != 1) { 2068 if (module_info->songs != 1) {
2069 memcpy(dest, module_info->song_pos, module_info->songs); 2069 memcpy(dest, module_info->song_pos, module_info->songs);
2070 dest += module_info->songs; 2070 dest += module_info->songs;
2071 } 2071 }
2072 if (module_info->channels == 1) { 2072 if (module_info->channels == 1) {
2073 memcpy(dest, rmt4_obx + 2, sizeof(rmt4_obx) - 2); 2073 memcpy(dest, rmt4_obx + 2, sizeof(rmt4_obx) - 2);
2074 dest += sizeof(rmt4_obx) - 2; 2074 dest += sizeof(rmt4_obx) - 2;
2075 } 2075 }
2076 else { 2076 else {
2077 memcpy(dest, rmt8_obx + 2, sizeof(rmt8_obx) - 2); 2077 memcpy(dest, rmt8_obx + 2, sizeof(rmt8_obx) - 2);
2078 dest += sizeof(rmt8_obx) - 2; 2078 dest += sizeof(rmt8_obx) - 2;
2079 } 2079 }
2080 return dest - out_module; 2080 return dest - out_module;
2081 case ASAP_TYPE_TMC: 2081 case ASAP_TYPE_TMC:
2082 player = module_info->player + tmc_player[module[0x25] - 1]; 2082 player = module_info->player + tmc_player[module[0x25] - 1];
2083 addr = player + tmc_init[module[0x25] - 1]; 2083 addr = player + tmc_init[module[0x25] - 1];
2084 if (module_info->songs != 1) 2084 if (module_info->songs != 1)
2085 addr -= 3; 2085 addr -= 3;
2086 dest = put_sap_header(out_module, module_info, 'B', -1, addr, player); 2086 dest = put_sap_header(out_module, module_info, 'B', -1, addr, player);
2087 if (dest == NULL) 2087 if (dest == NULL)
2088 return -1; 2088 return -1;
2089 memcpy(dest, module, module_len); 2089 memcpy(dest, module, module_len);
2090 dest += module_len; 2090 dest += module_len;
2091 *dest++ = (byte) addr; 2091 *dest++ = (byte) addr;
2092 *dest++ = (byte) (addr >> 8); 2092 *dest++ = (byte) (addr >> 8);
2093 *dest++ = tmc_obx[4]; 2093 *dest++ = tmc_obx[4];
2094 *dest++ = tmc_obx[5]; 2094 *dest++ = tmc_obx[5];
2095 if (module_info->songs != 1) 2095 if (module_info->songs != 1)
2096 *dest++ = 0x48; /* pha */ 2096 *dest++ = 0x48; /* pha */
2097 *dest++ = 0xa0; /* ldy #<music */ 2097 *dest++ = 0xa0; /* ldy #<music */
2098 *dest++ = (byte) module_info->music; 2098 *dest++ = (byte) module_info->music;
2099 *dest++ = 0xa2; /* ldx #>music */ 2099 *dest++ = 0xa2; /* ldx #>music */
2100 *dest++ = (byte) (module_info->music >> 8); 2100 *dest++ = (byte) (module_info->music >> 8);
2101 *dest++ = 0xa9; /* lda #$70 */ 2101 *dest++ = 0xa9; /* lda #$70 */
2102 *dest++ = 0x70; 2102 *dest++ = 0x70;
2103 *dest++ = 0x20; /* jsr player */ 2103 *dest++ = 0x20; /* jsr player */
2104 *dest++ = (byte) module_info->player; 2104 *dest++ = (byte) module_info->player;
2105 *dest++ = (byte) (module_info->player >> 8); 2105 *dest++ = (byte) (module_info->player >> 8);
2106 if (module_info->songs != 1) { 2106 if (module_info->songs != 1) {
2107 *dest++ = 0x68; /* pla */ 2107 *dest++ = 0x68; /* pla */
2108 *dest++ = 0xaa; /* tax */ 2108 *dest++ = 0xaa; /* tax */
2109 *dest++ = 0xa9; /* lda #0 */ 2109 *dest++ = 0xa9; /* lda #0 */
2110 *dest++ = 0; 2110 *dest++ = 0;
2111 } 2111 }
2112 else { 2112 else {
2113 *dest++ = 0xa9; /* lda #$60 */ 2113 *dest++ = 0xa9; /* lda #$60 */
2114 *dest++ = 0x60; 2114 *dest++ = 0x60;
2115 } 2115 }
2116 switch (module[0x25]) { 2116 switch (module[0x25]) {
2117 case 2: 2117 case 2:
2118 *dest++ = 0x06; /* asl 0 */ 2118 *dest++ = 0x06; /* asl 0 */
2119 *dest++ = 0; 2119 *dest++ = 0;
2120 *dest++ = 0x4c; /* jmp player */ 2120 *dest++ = 0x4c; /* jmp player */
2121 *dest++ = (byte) module_info->player; 2121 *dest++ = (byte) module_info->player;
2122 *dest++ = (byte) (module_info->player >> 8); 2122 *dest++ = (byte) (module_info->player >> 8);
2123 *dest++ = 0xa5; /* lda 0 */ 2123 *dest++ = 0xa5; /* lda 0 */
2124 *dest++ = 0; 2124 *dest++ = 0;
2125 *dest++ = 0xe6; /* inc 0 */ 2125 *dest++ = 0xe6; /* inc 0 */
2126 *dest++ = 0; 2126 *dest++ = 0;
2127 *dest++ = 0x4a; /* lsr @ */ 2127 *dest++ = 0x4a; /* lsr @ */
2128 *dest++ = 0x90; /* bcc player+3 */ 2128 *dest++ = 0x90; /* bcc player+3 */
2129 *dest++ = 5; 2129 *dest++ = 5;
2130 *dest++ = 0xb0; /* bcs player+6 */ 2130 *dest++ = 0xb0; /* bcs player+6 */
2131 *dest++ = 6; 2131 *dest++ = 6;
2132 break; 2132 break;
2133 case 3: 2133 case 3:
2134 case 4: 2134 case 4:
2135 *dest++ = 0xa0; /* ldy #1 */ 2135 *dest++ = 0xa0; /* ldy #1 */
2136 *dest++ = 1; 2136 *dest++ = 1;
2137 *dest++ = 0x84; /* sty 0 */ 2137 *dest++ = 0x84; /* sty 0 */
2138 *dest++ = 0; 2138 *dest++ = 0;
2139 *dest++ = 0xd0; /* bne player */ 2139 *dest++ = 0xd0; /* bne player */
2140 *dest++ = 10; 2140 *dest++ = 10;
2141 *dest++ = 0xc6; /* dec 0 */ 2141 *dest++ = 0xc6; /* dec 0 */
2142 *dest++ = 0; 2142 *dest++ = 0;
2143 *dest++ = 0xd0; /* bne player+6 */ 2143 *dest++ = 0xd0; /* bne player+6 */
2144 *dest++ = 12; 2144 *dest++ = 12;
2145 *dest++ = 0xa0; /* ldy #3 */ 2145 *dest++ = 0xa0; /* ldy #3 */
2146 *dest++ = module[0x25]; 2146 *dest++ = module[0x25];
2147 *dest++ = 0x84; /* sty 0 */ 2147 *dest++ = 0x84; /* sty 0 */
2148 *dest++ = 0; 2148 *dest++ = 0;
2149 *dest++ = 0xd0; /* bne player+3 */ 2149 *dest++ = 0xd0; /* bne player+3 */
2150 *dest++ = 3; 2150 *dest++ = 3;
2151 break; 2151 break;
2152 default: 2152 default:
2153 break; 2153 break;
2154 } 2154 }
2155 memcpy(dest, tmc_obx + 6, sizeof(tmc_obx) - 6); 2155 memcpy(dest, tmc_obx + 6, sizeof(tmc_obx) - 6);
2156 dest += sizeof(tmc_obx) - 6; 2156 dest += sizeof(tmc_obx) - 6;
2157 return dest - out_module; 2157 return dest - out_module;
2158 case ASAP_TYPE_TM2: 2158 case ASAP_TYPE_TM2:
2159 dest = put_sap_header(out_module, module_info, 'B', -1, TM2_INIT, module_info->player + 3); 2159 dest = put_sap_header(out_module, module_info, 'B', -1, TM2_INIT, module_info->player + 3);
2160 if (dest == NULL) 2160 if (dest == NULL)
2161 return -1; 2161 return -1;
2162 memcpy(dest, module, module_len); 2162 memcpy(dest, module, module_len);
2163 dest += module_len; 2163 dest += module_len;
2164 *dest++ = (byte) TM2_INIT; 2164 *dest++ = (byte) TM2_INIT;
2165 *dest++ = (byte) (TM2_INIT >> 8); 2165 *dest++ = (byte) (TM2_INIT >> 8);
2166 if (module_info->songs != 1) { 2166 if (module_info->songs != 1) {
2167 *dest++ = (byte) (TM2_INIT + 16); 2167 *dest++ = (byte) (TM2_INIT + 16);
2168 *dest++ = (byte) ((TM2_INIT + 16) >> 8); 2168 *dest++ = (byte) ((TM2_INIT + 16) >> 8);
2169 *dest++ = 0x48; /* pha */ 2169 *dest++ = 0x48; /* pha */
2170 } 2170 }
2171 else { 2171 else {
2172 *dest++ = (byte) (TM2_INIT + 14); 2172 *dest++ = (byte) (TM2_INIT + 14);
2173 *dest++ = (byte) ((TM2_INIT + 14) >> 8); 2173 *dest++ = (byte) ((TM2_INIT + 14) >> 8);
2174 } 2174 }
2175 *dest++ = 0xa0; /* ldy #<music */ 2175 *dest++ = 0xa0; /* ldy #<music */
2176 *dest++ = (byte) module_info->music; 2176 *dest++ = (byte) module_info->music;
2177 *dest++ = 0xa2; /* ldx #>music */ 2177 *dest++ = 0xa2; /* ldx #>music */
2178 *dest++ = (byte) (module_info->music >> 8); 2178 *dest++ = (byte) (module_info->music >> 8);
2179 *dest++ = 0xa9; /* lda #$70 */ 2179 *dest++ = 0xa9; /* lda #$70 */
2180 *dest++ = 0x70; 2180 *dest++ = 0x70;
2181 *dest++ = 0x20; /* jsr player */ 2181 *dest++ = 0x20; /* jsr player */
2182 *dest++ = (byte) module_info->player; 2182 *dest++ = (byte) module_info->player;
2183 *dest++ = (byte) (module_info->player >> 8); 2183 *dest++ = (byte) (module_info->player >> 8);
2184 if (module_info->songs != 1) { 2184 if (module_info->songs != 1) {
2185 *dest++ = 0x68; /* pla */ 2185 *dest++ = 0x68; /* pla */
2186 *dest++ = 0xaa; /* tax */ 2186 *dest++ = 0xaa; /* tax */
2187 *dest++ = 0xa9; /* lda #0 */ 2187 *dest++ = 0xa9; /* lda #0 */
2188 *dest++ = 0; 2188 *dest++ = 0;
2189 } 2189 }
2190 else { 2190 else {
2191 *dest++ = 0xa9; /* lda #0 */ 2191 *dest++ = 0xa9; /* lda #0 */
2192 *dest++ = 0; 2192 *dest++ = 0;
2193 *dest++ = 0xaa; /* tax */ 2193 *dest++ = 0xaa; /* tax */
2194 } 2194 }
2195 *dest++ = 0x4c; /* jmp player */ 2195 *dest++ = 0x4c; /* jmp player */
2196 *dest++ = (byte) module_info->player; 2196 *dest++ = (byte) module_info->player;
2197 *dest++ = (byte) (module_info->player >> 8); 2197 *dest++ = (byte) (module_info->player >> 8);
2198 memcpy(dest, tm2_obx + 2, sizeof(tm2_obx) - 2); 2198 memcpy(dest, tm2_obx + 2, sizeof(tm2_obx) - 2);
2199 dest += sizeof(tm2_obx) - 2; 2199 dest += sizeof(tm2_obx) - 2;
2200 return dest - out_module; 2200 return dest - out_module;
2201 default: 2201 default:
2202 return -1; 2202 return -1;
2203 } 2203 }
2204} 2204}
2205 2205
2206#endif /* defined(C) && !defined(ASAP_ONLY_SAP) */ 2206#endif /* defined(C) && !defined(ASAP_ONLY_SAP) */
diff --git a/apps/codecs/libasap/asap.h b/apps/codecs/libasap/asap.h
index 02f6e680f2..b43b3ce0c2 100644
--- a/apps/codecs/libasap/asap.h
+++ b/apps/codecs/libasap/asap.h
@@ -37,19 +37,19 @@ extern "C" {
37/* Short credits of the ASAP engine. */ 37/* Short credits of the ASAP engine. */
38#define ASAP_YEARS "2005-2010" 38#define ASAP_YEARS "2005-2010"
39#define ASAP_CREDITS \ 39#define ASAP_CREDITS \
40 "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \ 40 "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \
41 "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \ 41 "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \
42 "RMT player (C) 2002-2005 Radek Sterba\n" \ 42 "RMT player (C) 2002-2005 Radek Sterba\n" \
43 "DLT player (C) 2009 Marek Konopka\n" \ 43 "DLT player (C) 2009 Marek Konopka\n" \
44 "CMS player (C) 1999 David Spilka\n" 44 "CMS player (C) 1999 David Spilka\n"
45 45
46/* Short GPL notice. 46/* Short GPL notice.
47 Display after the credits. */ 47 Display after the credits. */
48#define ASAP_COPYRIGHT \ 48#define ASAP_COPYRIGHT \
49 "This program is free software; you can redistribute it and/or modify\n" \ 49 "This program is free software; you can redistribute it and/or modify\n" \
50 "it under the terms of the GNU General Public License as published\n" \ 50 "it under the terms of the GNU General Public License as published\n" \
51 "by the Free Software Foundation; either version 2 of the License,\n" \ 51 "by the Free Software Foundation; either version 2 of the License,\n" \
52 "or (at your option) any later version." 52 "or (at your option) any later version."
53 53
54/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */ 54/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */
55#define ASAP_INFO_CHARS 128 55#define ASAP_INFO_CHARS 128
@@ -72,9 +72,9 @@ extern "C" {
72 72
73/* Output formats. */ 73/* Output formats. */
74typedef enum { 74typedef enum {
75 ASAP_FORMAT_U8 = 8, /* unsigned char */ 75 ASAP_FORMAT_U8 = 8, /* unsigned char */
76 ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */ 76 ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */
77 ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */ 77 ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */
78} ASAP_SampleFormat; 78} ASAP_SampleFormat;
79 79
80/* Useful type definitions. */ 80/* Useful type definitions. */
@@ -89,106 +89,106 @@ typedef unsigned char byte;
89 89
90/* Information about a music file. */ 90/* Information about a music file. */
91typedef struct { 91typedef struct {
92 char author[ASAP_INFO_CHARS]; /* author's name */ 92 char author[ASAP_INFO_CHARS]; /* author's name */
93 char name[ASAP_INFO_CHARS]; /* title */ 93 char name[ASAP_INFO_CHARS]; /* title */
94 char date[ASAP_INFO_CHARS]; /* creation date */ 94 char date[ASAP_INFO_CHARS]; /* creation date */
95 int channels; /* 1 for mono or 2 for stereo */ 95 int channels; /* 1 for mono or 2 for stereo */
96 int songs; /* number of subsongs */ 96 int songs; /* number of subsongs */
97 int default_song; /* 0-based index of the "main" subsong */ 97 int default_song; /* 0-based index of the "main" subsong */
98 int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */ 98 int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */
99 abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */ 99 abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */
100 /* the following technical information should not be used outside ASAP. */ 100 /* the following technical information should not be used outside ASAP. */
101 int type; 101 int type;
102 int fastplay; 102 int fastplay;
103 int music; 103 int music;
104 int init; 104 int init;
105 int player; 105 int player;
106 int covox_addr; 106 int covox_addr;
107 int header_len; 107 int header_len;
108 byte song_pos[ASAP_SONGS_MAX]; 108 byte song_pos[ASAP_SONGS_MAX];
109} ASAP_ModuleInfo; 109} ASAP_ModuleInfo;
110 110
111/* POKEY state. 111/* POKEY state.
112 Not for use outside the ASAP engine. */ 112 Not for use outside the ASAP engine. */
113typedef struct { 113typedef struct {
114 int audctl; 114 int audctl;
115 abool init; 115 abool init;
116 int poly_index; 116 int poly_index;
117 int div_cycles; 117 int div_cycles;
118 int mute1; 118 int mute1;
119 int mute2; 119 int mute2;
120 int mute3; 120 int mute3;
121 int mute4; 121 int mute4;
122 int audf1; 122 int audf1;
123 int audf2; 123 int audf2;
124 int audf3; 124 int audf3;
125 int audf4; 125 int audf4;
126 int audc1; 126 int audc1;
127 int audc2; 127 int audc2;
128 int audc3; 128 int audc3;
129 int audc4; 129 int audc4;
130 int tick_cycle1; 130 int tick_cycle1;
131 int tick_cycle2; 131 int tick_cycle2;
132 int tick_cycle3; 132 int tick_cycle3;
133 int tick_cycle4; 133 int tick_cycle4;
134 int period_cycles1; 134 int period_cycles1;
135 int period_cycles2; 135 int period_cycles2;
136 int period_cycles3; 136 int period_cycles3;
137 int period_cycles4; 137 int period_cycles4;
138 int reload_cycles1; 138 int reload_cycles1;
139 int reload_cycles3; 139 int reload_cycles3;
140 int out1; 140 int out1;
141 int out2; 141 int out2;
142 int out3; 142 int out3;
143 int out4; 143 int out4;
144 int delta1; 144 int delta1;
145 int delta2; 145 int delta2;
146 int delta3; 146 int delta3;
147 int delta4; 147 int delta4;
148 int skctl; 148 int skctl;
149 int delta_buffer[888]; 149 int delta_buffer[888];
150} PokeyState; 150} PokeyState;
151 151
152/* Player state. 152/* Player state.
153 Only module_info is meant to be read outside the ASAP engine. */ 153 Only module_info is meant to be read outside the ASAP engine. */
154typedef struct { 154typedef struct {
155 int cycle; 155 int cycle;
156 int cpu_pc; 156 int cpu_pc;
157 int cpu_a; 157 int cpu_a;
158 int cpu_x; 158 int cpu_x;
159 int cpu_y; 159 int cpu_y;
160 int cpu_s; 160 int cpu_s;
161 int cpu_nz; 161 int cpu_nz;
162 int cpu_c; 162 int cpu_c;
163 int cpu_vdi; 163 int cpu_vdi;
164 int scanline_number; 164 int scanline_number;
165 int nearest_event_cycle; 165 int nearest_event_cycle;
166 int next_scanline_cycle; 166 int next_scanline_cycle;
167 int timer1_cycle; 167 int timer1_cycle;
168 int timer2_cycle; 168 int timer2_cycle;
169 int timer4_cycle; 169 int timer4_cycle;
170 int irqst; 170 int irqst;
171 int extra_pokey_mask; 171 int extra_pokey_mask;
172 int consol; 172 int consol;
173 byte covox[4]; 173 byte covox[4];
174 PokeyState base_pokey; 174 PokeyState base_pokey;
175 PokeyState extra_pokey; 175 PokeyState extra_pokey;
176 int sample_offset; 176 int sample_offset;
177 int sample_index; 177 int sample_index;
178 int samples; 178 int samples;
179 int iir_acc_left; 179 int iir_acc_left;
180 int iir_acc_right; 180 int iir_acc_right;
181 ASAP_ModuleInfo module_info; 181 ASAP_ModuleInfo module_info;
182 int tmc_per_frame; 182 int tmc_per_frame;
183 int tmc_per_frame_counter; 183 int tmc_per_frame_counter;
184 int current_song; 184 int current_song;
185 int current_duration; 185 int current_duration;
186 int blocks_played; 186 int blocks_played;
187 int silence_cycles; 187 int silence_cycles;
188 int silence_cycles_counter; 188 int silence_cycles_counter;
189 byte poly9_lookup[511]; 189 byte poly9_lookup[511];
190 byte poly17_lookup[16385]; 190 byte poly17_lookup[16385];
191 byte memory[65536]; 191 byte memory[65536];
192} ASAP_State; 192} ASAP_State;
193 193
194/* Parses the string in the "mm:ss.xxx" format 194/* Parses the string in the "mm:ss.xxx" format
diff --git a/apps/codecs/libasap/players.h b/apps/codecs/libasap/players.h
index 893de67821..fb90b0c76a 100644
--- a/apps/codecs/libasap/players.h
+++ b/apps/codecs/libasap/players.h
@@ -1,1386 +1,1386 @@
1CONST_ARRAY(byte, cmc_obx) 1CONST_ARRAY(byte, cmc_obx)
2 255,255,0,5,220,12,76,15,11,76,120,5,76,203,7,0, 2 255,255,0,5,220,12,76,15,11,76,120,5,76,203,7,0,
3 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, 3 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225,
4 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, 4 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0,
5 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 5 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
6 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
7 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, 7 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0,
8 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 8 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, 9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110,
10 5,142,111,5,140,112,5,41,112,74,74,74,170,189,145,11, 10 5,142,111,5,140,112,5,41,112,74,74,74,170,189,145,11,
11 141,169,5,189,146,11,141,170,5,169,3,141,15,210,216,165, 11 141,169,5,189,146,11,141,170,5,169,3,141,15,210,216,165,
12 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, 12 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178,
13 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, 13 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5,
14 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, 14 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208,
15 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, 15 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84,
16 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, 16 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5,
17 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, 17 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5,
18 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, 18 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173,
19 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, 19 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207,
20 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, 20 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201,
21 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, 21 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5,
22 96,41,15,240,245,142,218,10,142,240,10,142,255,10,140,219, 22 96,41,15,240,245,142,218,10,142,240,10,142,255,10,140,219,
23 10,140,241,10,140,0,11,96,142,114,5,134,254,140,115,5, 23 10,140,241,10,140,0,11,96,142,114,5,134,254,140,115,5,
24 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, 24 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142,
25 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, 25 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109,
26 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, 26 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157,
27 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, 27 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75,
28 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, 28 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3,
29 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, 29 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157,
30 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, 30 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5,
31 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, 31 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105,
32 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, 32 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152,
33 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, 33 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5,
34 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, 34 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157,
35 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, 35 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254,
36 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, 36 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200,
37 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, 37 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2,
38 201,7,208,2,160,4,185,175,11,133,254,185,176,11,133,255, 38 201,7,208,2,160,4,185,175,11,133,254,185,176,11,133,255,
39 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, 39 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194,
40 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, 40 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45,
41 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, 41 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5,
42 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, 42 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201,
43 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, 43 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157,
44 48,5,189,79,5,72,41,3,168,185,181,11,157,54,5,104, 44 48,5,189,79,5,72,41,3,168,185,181,11,157,54,5,104,
45 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, 45 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10,
46 160,48,201,13,240,4,24,105,0,168,185,185,11,157,51,5, 46 160,48,201,13,240,4,24,105,0,168,185,185,11,157,51,5,
47 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, 47 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113,
48 5,208,3,76,2,11,173,78,5,240,3,76,107,9,173,108, 48 5,208,3,76,2,11,173,78,5,240,3,76,107,9,173,108,
49 5,205,109,5,240,3,76,88,9,173,103,5,240,3,76,220, 49 5,205,109,5,240,3,76,88,9,173,103,5,240,3,76,220,
50 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, 50 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16,
51 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, 51 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254,
52 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, 52 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5,
53 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, 53 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0,
54 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, 54 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104,
55 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, 55 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144,
56 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, 56 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41,
57 14,170,189,161,11,141,126,8,189,162,11,141,127,8,173,67, 57 14,170,189,161,11,141,126,8,189,162,11,141,127,8,173,67,
58 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, 58 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208,
59 143,164,254,140,104,5,76,2,11,32,148,6,160,255,96,48, 59 143,164,254,140,104,5,76,2,11,32,148,6,160,255,96,48,
60 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, 60 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101,
61 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, 61 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173,
62 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, 62 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141,
63 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, 63 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243,
64 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, 64 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75,
65 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, 65 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173,
66 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, 66 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133,
67 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, 67 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12,
68 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, 68 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19,
69 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, 69 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6,
70 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, 70 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69,
71 5,202,16,144,174,103,5,232,138,41,63,141,103,5,206,109, 71 5,202,16,144,174,103,5,232,138,41,63,141,103,5,206,109,
72 5,208,14,173,108,5,141,109,5,173,103,5,208,3,238,104, 72 5,208,14,173,108,5,141,109,5,173,103,5,208,3,238,104,
73 5,172,48,5,173,82,5,41,7,201,5,240,4,201,6,208, 73 5,172,48,5,173,82,5,41,7,201,5,240,4,201,6,208,
74 1,136,140,39,5,160,0,201,5,240,4,201,6,208,2,160, 74 1,136,140,39,5,160,0,201,5,240,4,201,6,208,2,160,
75 2,201,7,208,2,160,40,140,44,5,162,2,189,82,5,41, 75 2,201,7,208,2,160,40,140,44,5,162,2,189,82,5,41,
76 224,157,40,5,189,97,5,133,252,189,100,5,133,253,189,57, 76 224,157,40,5,189,97,5,133,252,189,100,5,133,253,189,57,
77 5,201,255,240,54,201,15,208,32,189,63,5,240,45,222,63, 77 5,201,255,240,54,201,15,208,32,189,63,5,240,45,222,63,
78 5,189,63,5,208,37,188,9,5,240,1,136,152,157,9,5, 78 5,189,63,5,208,37,188,9,5,240,1,136,152,157,9,5,
79 189,88,5,157,63,5,76,229,9,189,57,5,74,168,177,252, 79 189,88,5,157,63,5,76,229,9,189,57,5,74,168,177,252,
80 144,4,74,74,74,74,41,15,157,9,5,188,45,5,189,82, 80 144,4,74,74,74,74,41,15,157,9,5,188,45,5,189,82,
81 5,41,7,201,1,208,31,136,152,200,221,48,5,8,169,1, 81 5,41,7,201,1,208,31,136,152,200,221,48,5,8,169,1,
82 40,208,2,10,10,61,60,5,240,12,188,48,5,192,255,208, 82 40,208,2,10,10,61,60,5,240,12,188,48,5,192,255,208,
83 5,169,0,157,9,5,152,157,36,5,169,1,141,110,5,189, 83 5,169,0,157,9,5,152,157,36,5,169,1,141,110,5,189,
84 57,5,201,15,240,56,41,7,168,185,205,12,133,254,189,57, 84 57,5,201,15,240,56,41,7,168,185,205,12,133,254,189,57,
85 5,41,8,8,138,40,24,240,2,105,3,168,185,91,5,37, 85 5,41,8,8,138,40,24,240,2,105,3,168,185,91,5,37,
86 254,240,27,189,51,5,157,36,5,142,110,5,202,16,8,141, 86 254,240,27,189,51,5,157,36,5,142,110,5,202,16,8,141,
87 39,5,169,0,141,44,5,232,189,54,5,157,40,5,189,57, 87 39,5,169,0,141,44,5,232,189,54,5,157,40,5,189,57,
88 5,41,15,201,15,240,16,254,57,5,189,57,5,201,15,208, 88 5,41,15,201,15,240,16,254,57,5,189,57,5,201,15,208,
89 6,189,88,5,157,63,5,189,75,5,16,10,189,9,5,208, 89 6,189,88,5,157,63,5,189,75,5,16,10,189,9,5,208,
90 5,169,64,157,75,5,254,60,5,160,0,189,82,5,74,74, 90 5,169,64,157,75,5,254,60,5,160,0,189,82,5,74,74,
91 74,74,144,1,136,74,144,1,200,24,152,125,45,5,157,45, 91 74,74,144,1,136,74,144,1,200,24,152,125,45,5,157,45,
92 5,189,48,5,201,255,208,2,160,0,24,152,125,48,5,157, 92 5,189,48,5,201,255,208,2,160,0,24,152,125,48,5,157,
93 48,5,202,48,3,76,150,9,173,40,5,141,43,5,173,82, 93 48,5,202,48,3,76,150,9,173,40,5,141,43,5,173,82,
94 5,41,7,170,160,3,173,110,5,240,3,188,213,12,152,72, 94 5,41,7,170,160,3,173,110,5,240,3,188,213,12,152,72,
95 185,185,12,8,41,127,170,152,41,3,10,168,189,36,5,153, 95 185,185,12,8,41,127,170,152,41,3,10,168,189,36,5,153,
96 0,210,200,189,9,5,224,3,208,3,173,9,5,29,40,5, 96 0,210,200,189,9,5,224,3,208,3,173,9,5,29,40,5,
97 40,16,2,169,0,153,0,210,104,168,136,41,3,208,207,160, 97 40,16,2,169,0,153,0,210,104,168,136,41,3,208,207,160,
98 8,173,44,5,153,0,210,24,104,133,255,104,133,254,104,133, 98 8,173,44,5,153,0,210,24,104,133,255,104,133,254,104,133,
99 253,104,133,252,96,104,170,240,78,201,2,240,6,104,104,202, 99 253,104,133,252,96,104,170,240,78,201,2,240,6,104,104,202,
100 208,251,96,165,20,197,20,240,252,173,36,2,201,134,208,7, 100 208,251,96,165,20,197,20,240,252,173,36,2,201,134,208,7,
101 173,37,2,201,11,240,230,173,36,2,141,143,11,173,37,2, 101 173,37,2,201,11,240,230,173,36,2,141,143,11,173,37,2,
102 141,144,11,169,134,141,36,2,169,11,141,37,2,104,104,240, 102 141,144,11,169,134,141,36,2,169,11,141,37,2,104,104,240,
103 3,56,233,1,141,93,11,104,168,104,170,169,112,32,120,5, 103 3,56,233,1,141,93,11,104,168,104,170,169,112,32,120,5,
104 169,0,162,0,76,120,5,165,20,197,20,240,252,173,36,2, 104 169,0,162,0,76,120,5,165,20,197,20,240,252,173,36,2,
105 201,134,208,174,173,37,2,201,11,208,167,173,143,11,141,36, 105 201,134,208,174,173,37,2,201,11,208,167,173,143,11,141,36,
106 2,173,144,11,141,37,2,169,64,76,120,5,32,203,7,144, 106 2,173,144,11,141,37,2,169,64,76,120,5,32,203,7,144,
107 3,32,117,11,76,255,255,178,5,221,5,168,6,59,6,123, 107 3,32,117,11,76,255,255,178,5,221,5,168,6,59,6,123,
108 6,148,6,159,6,82,6,147,8,153,8,157,8,165,8,173, 108 6,148,6,159,6,82,6,147,8,153,8,157,8,165,8,173,
109 8,183,8,205,8,185,11,250,11,59,12,128,160,32,64,255, 109 8,183,8,205,8,185,11,250,11,59,12,128,160,32,64,255,
110 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, 110 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101,
111 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, 111 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39,
112 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, 112 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15,
113 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, 113 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0,
114 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, 114 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128,
115 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, 115 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67,
116 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, 116 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0,
117 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, 117 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
118 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, 118 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128,
119 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, 119 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176,
120 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, 120 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244,
121 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, 121 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216,
122 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, 122 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39,
123 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, 123 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184,
124 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, 124 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112,
125 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, 125 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0,
126 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, 126 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1,
127 2,128,3,128,64,32,16,8,4,2,1,3,3,3,3,7, 127 2,128,3,128,64,32,16,8,4,2,1,3,3,3,3,7,
128 11,15,19 128 11,15,19
129END_CONST_ARRAY; 129END_CONST_ARRAY;
130CONST_ARRAY(byte, cm3_obx) 130CONST_ARRAY(byte, cm3_obx)
131 255,255,0,5,223,12,76,18,11,76,120,5,76,203,7,0, 131 255,255,0,5,223,12,76,18,11,76,120,5,76,203,7,0,
132 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, 132 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225,
133 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, 133 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0,
134 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, 134 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
135 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 135 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
136 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, 136 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0,
137 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 137 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
138 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, 138 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110,
139 5,142,111,5,140,112,5,41,112,74,74,74,170,189,148,11, 139 5,142,111,5,140,112,5,41,112,74,74,74,170,189,148,11,
140 141,169,5,189,149,11,141,170,5,169,3,141,15,210,216,165, 140 141,169,5,189,149,11,141,170,5,169,3,141,15,210,216,165,
141 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, 141 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178,
142 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, 142 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5,
143 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, 143 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208,
144 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, 144 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84,
145 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, 145 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5,
146 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, 146 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5,
147 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, 147 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173,
148 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, 148 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207,
149 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, 149 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201,
150 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, 150 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5,
151 96,41,15,240,245,142,221,10,142,243,10,142,2,11,140,222, 151 96,41,15,240,245,142,221,10,142,243,10,142,2,11,140,222,
152 10,140,244,10,140,3,11,96,142,114,5,134,254,140,115,5, 152 10,140,244,10,140,3,11,96,142,114,5,134,254,140,115,5,
153 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, 153 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142,
154 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, 154 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109,
155 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, 155 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157,
156 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, 156 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75,
157 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, 157 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3,
158 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, 158 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157,
159 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, 159 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5,
160 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, 160 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105,
161 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, 161 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152,
162 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, 162 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5,
163 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, 163 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157,
164 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, 164 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254,
165 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, 165 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200,
166 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, 166 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2,
167 201,7,208,2,160,4,185,178,11,133,254,185,179,11,133,255, 167 201,7,208,2,160,4,185,178,11,133,254,185,179,11,133,255,
168 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, 168 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194,
169 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, 169 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45,
170 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, 170 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5,
171 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, 171 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201,
172 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, 172 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157,
173 48,5,189,79,5,72,41,3,168,185,184,11,157,54,5,104, 173 48,5,189,79,5,72,41,3,168,185,184,11,157,54,5,104,
174 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, 174 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10,
175 160,48,201,13,240,4,24,105,0,168,185,188,11,157,51,5, 175 160,48,201,13,240,4,24,105,0,168,185,188,11,157,51,5,
176 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, 176 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113,
177 5,208,3,76,5,11,173,78,5,240,3,76,110,9,173,108, 177 5,208,3,76,5,11,173,78,5,240,3,76,110,9,173,108,
178 5,205,109,5,240,3,76,91,9,173,103,5,240,3,76,220, 178 5,205,109,5,240,3,76,91,9,173,103,5,240,3,76,220,
179 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, 179 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16,
180 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, 180 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254,
181 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, 181 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5,
182 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, 182 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0,
183 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, 183 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104,
184 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, 184 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144,
185 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, 185 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41,
186 14,170,189,164,11,141,126,8,189,165,11,141,127,8,173,67, 186 14,170,189,164,11,141,126,8,189,165,11,141,127,8,173,67,
187 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, 187 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208,
188 143,164,254,140,104,5,76,5,11,32,148,6,160,255,96,48, 188 143,164,254,140,104,5,76,5,11,32,148,6,160,255,96,48,
189 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, 189 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101,
190 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, 190 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173,
191 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, 191 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141,
192 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, 192 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243,
193 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, 193 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75,
194 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, 194 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173,
195 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, 195 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133,
196 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, 196 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12,
197 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, 197 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19,
198 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, 198 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6,
199 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, 199 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69,
200 5,202,16,144,174,103,5,232,224,48,144,2,162,0,142,103, 200 5,202,16,144,174,103,5,232,224,48,144,2,162,0,142,103,
201 5,206,109,5,208,14,173,108,5,141,109,5,173,103,5,208, 201 5,206,109,5,208,14,173,108,5,141,109,5,173,103,5,208,
202 3,238,104,5,172,48,5,173,82,5,41,7,201,5,240,4, 202 3,238,104,5,172,48,5,173,82,5,41,7,201,5,240,4,
203 201,6,208,1,136,140,39,5,160,0,201,5,240,4,201,6, 203 201,6,208,1,136,140,39,5,160,0,201,5,240,4,201,6,
204 208,2,160,2,201,7,208,2,160,40,140,44,5,162,2,189, 204 208,2,160,2,201,7,208,2,160,40,140,44,5,162,2,189,
205 82,5,41,224,157,40,5,189,97,5,133,252,189,100,5,133, 205 82,5,41,224,157,40,5,189,97,5,133,252,189,100,5,133,
206 253,189,57,5,201,255,240,54,201,15,208,32,189,63,5,240, 206 253,189,57,5,201,255,240,54,201,15,208,32,189,63,5,240,
207 45,222,63,5,189,63,5,208,37,188,9,5,240,1,136,152, 207 45,222,63,5,189,63,5,208,37,188,9,5,240,1,136,152,
208 157,9,5,189,88,5,157,63,5,76,232,9,189,57,5,74, 208 157,9,5,189,88,5,157,63,5,76,232,9,189,57,5,74,
209 168,177,252,144,4,74,74,74,74,41,15,157,9,5,188,45, 209 168,177,252,144,4,74,74,74,74,41,15,157,9,5,188,45,
210 5,189,82,5,41,7,201,1,208,31,136,152,200,221,48,5, 210 5,189,82,5,41,7,201,1,208,31,136,152,200,221,48,5,
211 8,169,1,40,208,2,10,10,61,60,5,240,12,188,48,5, 211 8,169,1,40,208,2,10,10,61,60,5,240,12,188,48,5,
212 192,255,208,5,169,0,157,9,5,152,157,36,5,169,1,141, 212 192,255,208,5,169,0,157,9,5,152,157,36,5,169,1,141,
213 110,5,189,57,5,201,15,240,56,41,7,168,185,208,12,133, 213 110,5,189,57,5,201,15,240,56,41,7,168,185,208,12,133,
214 254,189,57,5,41,8,8,138,40,24,240,2,105,3,168,185, 214 254,189,57,5,41,8,8,138,40,24,240,2,105,3,168,185,
215 91,5,37,254,240,27,189,51,5,157,36,5,142,110,5,202, 215 91,5,37,254,240,27,189,51,5,157,36,5,142,110,5,202,
216 16,8,141,39,5,169,0,141,44,5,232,189,54,5,157,40, 216 16,8,141,39,5,169,0,141,44,5,232,189,54,5,157,40,
217 5,189,57,5,41,15,201,15,240,16,254,57,5,189,57,5, 217 5,189,57,5,41,15,201,15,240,16,254,57,5,189,57,5,
218 201,15,208,6,189,88,5,157,63,5,189,75,5,16,10,189, 218 201,15,208,6,189,88,5,157,63,5,189,75,5,16,10,189,
219 9,5,208,5,169,64,157,75,5,254,60,5,160,0,189,82, 219 9,5,208,5,169,64,157,75,5,254,60,5,160,0,189,82,
220 5,74,74,74,74,144,1,136,74,144,1,200,24,152,125,45, 220 5,74,74,74,74,144,1,136,74,144,1,200,24,152,125,45,
221 5,157,45,5,189,48,5,201,255,208,2,160,0,24,152,125, 221 5,157,45,5,189,48,5,201,255,208,2,160,0,24,152,125,
222 48,5,157,48,5,202,48,3,76,153,9,173,40,5,141,43, 222 48,5,157,48,5,202,48,3,76,153,9,173,40,5,141,43,
223 5,173,82,5,41,7,170,160,3,173,110,5,240,3,188,216, 223 5,173,82,5,41,7,170,160,3,173,110,5,240,3,188,216,
224 12,152,72,185,188,12,8,41,127,170,152,41,3,10,168,189, 224 12,152,72,185,188,12,8,41,127,170,152,41,3,10,168,189,
225 36,5,153,0,210,200,189,9,5,224,3,208,3,173,9,5, 225 36,5,153,0,210,200,189,9,5,224,3,208,3,173,9,5,
226 29,40,5,40,16,2,169,0,153,0,210,104,168,136,41,3, 226 29,40,5,40,16,2,169,0,153,0,210,104,168,136,41,3,
227 208,207,160,8,173,44,5,153,0,210,24,104,133,255,104,133, 227 208,207,160,8,173,44,5,153,0,210,24,104,133,255,104,133,
228 254,104,133,253,104,133,252,96,104,170,240,78,201,2,240,6, 228 254,104,133,253,104,133,252,96,104,170,240,78,201,2,240,6,
229 104,104,202,208,251,96,165,20,197,20,240,252,173,36,2,201, 229 104,104,202,208,251,96,165,20,197,20,240,252,173,36,2,201,
230 137,208,7,173,37,2,201,11,240,230,173,36,2,141,146,11, 230 137,208,7,173,37,2,201,11,240,230,173,36,2,141,146,11,
231 173,37,2,141,147,11,169,137,141,36,2,169,11,141,37,2, 231 173,37,2,141,147,11,169,137,141,36,2,169,11,141,37,2,
232 104,104,240,3,56,233,1,141,96,11,104,168,104,170,169,112, 232 104,104,240,3,56,233,1,141,96,11,104,168,104,170,169,112,
233 32,120,5,169,0,162,0,76,120,5,165,20,197,20,240,252, 233 32,120,5,169,0,162,0,76,120,5,165,20,197,20,240,252,
234 173,36,2,201,137,208,174,173,37,2,201,11,208,167,173,146, 234 173,36,2,201,137,208,174,173,37,2,201,11,208,167,173,146,
235 11,141,36,2,173,147,11,141,37,2,169,64,76,120,5,32, 235 11,141,36,2,173,147,11,141,37,2,169,64,76,120,5,32,
236 203,7,144,3,32,120,11,76,255,255,178,5,221,5,168,6, 236 203,7,144,3,32,120,11,76,255,255,178,5,221,5,168,6,
237 59,6,123,6,148,6,159,6,82,6,147,8,153,8,157,8, 237 59,6,123,6,148,6,159,6,82,6,147,8,153,8,157,8,
238 165,8,173,8,183,8,205,8,188,11,253,11,62,12,128,160, 238 165,8,173,8,183,8,205,8,188,11,253,11,62,12,128,160,
239 32,64,255,241,228,215,203,192,181,170,161,152,143,135,127,120, 239 32,64,255,241,228,215,203,192,181,170,161,152,143,135,127,120,
240 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, 240 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47,
241 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, 241 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18,
242 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 242 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
243 1,0,0,0,0,0,0,242,233,218,206,191,182,170,161,152, 243 1,0,0,0,0,0,0,242,233,218,206,191,182,170,161,152,
244 143,137,128,122,113,107,101,95,0,86,80,103,96,90,85,81, 244 143,137,128,122,113,107,101,95,0,86,80,103,96,90,85,81,
245 76,72,67,63,61,57,52,51,57,45,42,40,37,36,33,31, 245 76,72,67,63,61,57,52,51,57,45,42,40,37,36,33,31,
246 30,0,0,15,14,13,12,11,10,9,8,7,6,5,4,3, 246 30,0,0,15,14,13,12,11,10,9,8,7,6,5,4,3,
247 2,1,0,0,56,11,140,10,0,10,106,9,232,8,106,8, 247 2,1,0,0,56,11,140,10,0,10,106,9,232,8,106,8,
248 239,7,128,7,8,7,174,6,70,6,230,5,149,5,65,5, 248 239,7,128,7,8,7,174,6,70,6,230,5,149,5,65,5,
249 246,4,176,4,110,4,48,4,246,3,187,3,132,3,82,3, 249 246,4,176,4,110,4,48,4,246,3,187,3,132,3,82,3,
250 34,3,244,2,200,2,160,2,122,2,85,2,52,2,20,2, 250 34,3,244,2,200,2,160,2,122,2,85,2,52,2,20,2,
251 245,1,216,1,189,1,164,1,141,1,119,1,96,1,78,1, 251 245,1,216,1,189,1,164,1,141,1,119,1,96,1,78,1,
252 56,1,39,1,21,1,6,1,247,0,232,0,219,0,207,0, 252 56,1,39,1,21,1,6,1,247,0,232,0,219,0,207,0,
253 195,0,184,0,172,0,162,0,154,0,144,0,136,0,127,0, 253 195,0,184,0,172,0,162,0,154,0,144,0,136,0,127,0,
254 120,0,112,0,106,0,100,0,94,0,87,0,82,0,50,0, 254 120,0,112,0,106,0,100,0,94,0,87,0,82,0,50,0,
255 10,0,0,1,2,131,0,1,2,3,1,0,2,131,1,0, 255 10,0,0,1,2,131,0,1,2,3,1,0,2,131,1,0,
256 2,3,1,2,128,3,128,64,32,16,8,4,2,1,3,3, 256 2,3,1,2,128,3,128,64,32,16,8,4,2,1,3,3,
257 3,3,7,11,15,19 257 3,3,7,11,15,19
258END_CONST_ARRAY; 258END_CONST_ARRAY;
259CONST_ARRAY(byte, cms_obx) 259CONST_ARRAY(byte, cms_obx)
260 255,255,0,5,186,15,234,234,234,76,21,8,76,92,15,35, 260 255,255,0,5,186,15,234,234,234,76,21,8,76,92,15,35,
261 5,169,5,173,5,184,5,0,0,0,0,0,0,0,0,0, 261 5,169,5,173,5,184,5,0,0,0,0,0,0,0,0,0,
262 0,0,0,128,128,128,128,128,128,0,0,0,0,0,0,255, 262 0,0,0,128,128,128,128,128,128,0,0,0,0,0,0,255,
263 255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0, 263 255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,
264 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 264 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
265 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 265 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
266 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 266 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
267 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 267 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
268 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 268 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
269 0,0,0,0,0,0,0,0,0,0,130,0,0,6,6,0, 269 0,0,0,0,0,0,0,0,0,0,130,0,0,6,6,0,
270 128,20,128,128,0,0,0,0,0,0,0,0,0,0,0,15, 270 128,20,128,128,0,0,0,0,0,0,0,0,0,0,0,15,
271 15,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0, 271 15,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,
272 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, 272 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1,
273 2,128,3,128,64,32,16,8,4,2,1,75,8,118,8,133, 273 2,128,3,128,64,32,16,8,4,2,1,75,8,118,8,133,
274 9,19,9,80,9,110,9,124,9,26,9,128,160,32,64,255, 274 9,19,9,80,9,110,9,124,9,26,9,128,160,32,64,255,
275 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, 275 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101,
276 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, 276 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39,
277 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, 277 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15,
278 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, 278 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0,
279 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, 279 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128,
280 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, 280 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67,
281 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, 281 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0,
282 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, 282 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
283 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, 283 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128,
284 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, 284 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176,
285 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, 285 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244,
286 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, 286 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216,
287 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, 287 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39,
288 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, 288 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184,
289 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, 289 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112,
290 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, 290 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0,
291 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 291 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
292 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0, 292 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,
293 0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,0, 293 0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,0,
294 0,0,0,1,1,1,1,2,2,2,2,2,3,3,3,0, 294 0,0,0,1,1,1,1,2,2,2,2,2,3,3,3,0,
295 0,1,1,1,2,2,2,2,2,3,3,3,3,4,4,0, 295 0,1,1,1,2,2,2,2,2,3,3,3,3,4,4,0,
296 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,0, 296 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,0,
297 0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,0, 297 0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,0,
298 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,0, 298 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,0,
299 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,0, 299 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,0,
300 1,1,2,2,3,4,4,5,5,6,7,7,8,8,9,0, 300 1,1,2,2,3,4,4,5,5,6,7,7,8,8,9,0,
301 1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,0, 301 1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,0,
302 1,1,2,3,4,4,5,6,7,7,8,9,10,10,11,0, 302 1,1,2,3,4,4,5,6,7,7,8,9,10,10,11,0,
303 1,2,2,3,4,5,6,7,8,9,9,10,11,11,12,0, 303 1,2,2,3,4,5,6,7,8,9,9,10,11,11,12,0,
304 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,0, 304 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,0,
305 1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,0, 305 1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,0,
306 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,6, 306 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,6,
307 12,12,12,18,12,28,12,38,12,50,12,79,12,233,5,42, 307 12,12,12,18,12,28,12,38,12,50,12,79,12,233,5,42,
308 6,107,6,161,11,196,11,185,11,0,0,0,0,0,0,0, 308 6,107,6,161,11,196,11,185,11,0,0,0,0,0,0,0,
309 0,0,0,3,3,3,3,7,11,15,19,141,143,5,142,144, 309 0,0,0,3,3,3,3,7,11,15,19,141,143,5,142,144,
310 5,140,145,5,41,112,74,74,74,170,169,3,141,15,210,189, 310 5,140,145,5,41,112,74,74,74,170,169,3,141,15,210,189,
311 213,5,141,73,8,189,214,5,141,74,8,169,3,141,31,210, 311 213,5,141,73,8,189,214,5,141,74,8,169,3,141,31,210,
312 169,1,141,146,5,172,145,5,174,144,5,173,143,5,76,72, 312 169,1,141,146,5,172,145,5,174,144,5,173,143,5,76,72,
313 8,173,147,5,133,252,173,148,5,133,253,160,0,138,240,28, 313 8,173,147,5,133,252,173,148,5,133,253,160,0,138,240,28,
314 177,252,201,143,240,4,201,239,208,12,202,208,9,200,192,84, 314 177,252,201,143,240,4,201,239,208,12,202,208,9,200,192,84,
315 176,9,152,170,16,6,200,192,84,144,229,96,142,149,5,169, 315 176,9,152,170,16,6,200,192,84,144,229,96,142,149,5,169,
316 0,162,5,157,17,5,157,23,5,157,29,5,202,16,244,141, 316 0,162,5,157,17,5,157,23,5,157,29,5,202,16,244,141,
317 150,5,141,157,5,160,255,140,159,5,173,153,5,133,252,173, 317 150,5,141,157,5,160,255,140,159,5,173,153,5,133,252,173,
318 154,5,133,253,160,19,177,252,170,173,147,5,133,252,173,148, 318 154,5,133,253,160,19,177,252,170,173,147,5,133,252,173,148,
319 5,133,253,172,149,5,152,72,169,15,141,169,5,141,170,5, 319 5,133,253,172,149,5,152,72,169,15,141,169,5,141,170,5,
320 177,252,201,135,208,35,152,72,24,105,85,168,177,252,16,2, 320 177,252,201,135,208,35,152,72,24,105,85,168,177,252,16,2,
321 169,15,41,15,141,169,5,152,24,105,85,168,177,252,16,3, 321 169,15,41,15,141,169,5,152,24,105,85,168,177,252,16,3,
322 173,169,5,41,15,141,170,5,104,76,243,8,177,252,201,143, 322 173,169,5,41,15,141,170,5,104,76,243,8,177,252,201,143,
323 240,7,201,239,240,3,136,16,199,104,168,177,252,201,207,208, 323 240,7,201,239,240,3,136,16,199,104,168,177,252,201,207,208,
324 13,152,24,105,85,168,177,252,48,15,170,76,19,9,201,143, 324 13,152,24,105,85,168,177,252,48,15,170,76,19,9,201,143,
325 240,7,201,239,240,3,136,16,226,142,151,5,142,152,5,96, 325 240,7,201,239,240,3,136,16,226,142,151,5,142,152,5,96,
326 142,153,5,134,252,140,154,5,132,253,24,138,105,20,141,155, 326 142,153,5,134,252,140,154,5,132,253,24,138,105,20,141,155,
327 5,152,105,0,141,156,5,24,138,105,0,141,147,5,152,105, 327 5,152,105,0,141,156,5,24,138,105,0,141,147,5,152,105,
328 2,141,148,5,160,19,177,252,141,151,5,141,152,5,162,3, 328 2,141,148,5,160,19,177,252,141,151,5,141,152,5,162,3,
329 142,31,210,142,15,210,169,0,141,146,5,160,8,169,0,153, 329 142,31,210,142,15,210,169,0,141,146,5,160,8,169,0,153,
330 0,210,153,16,210,192,6,176,8,153,35,5,169,255,153,41, 330 0,210,153,16,210,192,6,176,8,153,35,5,169,255,153,41,
331 5,136,16,233,169,128,162,5,157,29,5,202,16,250,141,157, 331 5,136,16,233,169,128,162,5,157,29,5,202,16,250,141,157,
332 5,96,169,0,240,240,141,157,5,240,11,173,143,5,41,7, 332 5,96,169,0,240,240,141,157,5,240,11,173,143,5,41,7,
333 170,169,128,157,29,5,172,145,5,173,144,5,141,143,5,140, 333 170,169,128,157,29,5,172,145,5,173,144,5,141,143,5,140,
334 145,5,169,0,157,83,5,157,41,5,157,77,5,152,10,10, 334 145,5,169,0,157,83,5,157,41,5,157,77,5,152,10,10,
335 10,133,254,24,173,153,5,105,48,72,173,154,5,105,1,168, 335 10,133,254,24,173,153,5,105,48,72,173,154,5,105,1,168,
336 104,24,101,254,157,101,5,152,105,0,157,71,5,24,173,153, 336 104,24,101,254,157,101,5,152,105,0,157,71,5,24,173,153,
337 5,105,148,133,252,173,154,5,105,0,133,253,173,145,5,10, 337 5,105,148,133,252,173,154,5,105,0,133,253,173,145,5,10,
338 109,145,5,10,168,140,145,5,200,200,200,200,200,177,252,157, 338 109,145,5,10,168,140,145,5,200,200,200,200,200,177,252,157,
339 113,5,136,177,252,157,107,5,136,177,252,157,119,5,136,136, 339 113,5,136,177,252,157,107,5,136,177,252,157,119,5,136,136,
340 177,252,157,59,5,160,0,41,7,201,3,208,2,160,2,201, 340 177,252,157,59,5,160,0,41,7,201,3,208,2,160,2,201,
341 7,208,2,160,4,185,247,7,133,254,185,248,7,133,255,172, 341 7,208,2,160,4,185,247,7,133,254,185,248,7,133,255,172,
342 145,5,200,200,177,252,74,74,74,74,24,109,143,5,141,143, 342 145,5,200,200,177,252,74,74,74,74,24,109,143,5,141,143,
343 5,141,159,10,168,189,59,5,41,7,201,7,208,15,152,10, 343 5,141,159,10,168,189,59,5,41,7,201,7,208,15,152,10,
344 168,177,254,157,125,5,200,140,143,5,76,92,10,177,254,157, 344 168,177,254,157,125,5,200,140,143,5,76,92,10,177,254,157,
345 125,5,172,145,5,200,200,177,252,41,15,24,109,143,5,141, 345 125,5,172,145,5,200,200,177,252,41,15,24,109,143,5,141,
346 143,5,172,143,5,189,59,5,41,7,201,5,8,177,254,40, 346 143,5,172,143,5,189,59,5,41,7,201,5,8,177,254,40,
347 240,8,221,125,5,208,3,56,233,1,157,89,5,172,145,5, 347 240,8,221,125,5,208,3,56,233,1,157,89,5,172,145,5,
348 177,252,72,41,3,168,185,229,5,157,131,5,104,74,74,74, 348 177,252,72,41,3,168,185,229,5,157,131,5,104,74,74,74,
349 74,160,62,201,15,240,16,160,55,201,14,240,10,160,48,201, 349 74,160,62,201,15,240,16,160,55,201,14,240,10,160,48,201,
350 13,240,4,24,105,50,168,185,233,5,157,137,5,96,216,165, 350 13,240,4,24,105,50,168,185,233,5,157,137,5,96,216,165,
351 252,72,165,253,72,165,254,72,165,255,72,173,146,5,208,3, 351 252,72,165,253,72,165,254,72,165,255,72,173,146,5,208,3,
352 76,47,15,173,157,5,240,3,76,225,12,173,152,5,205,151, 352 76,47,15,173,157,5,240,3,76,225,12,173,152,5,205,151,
353 5,176,3,76,206,12,173,150,5,240,3,76,158,11,162,5, 353 5,176,3,76,206,12,173,150,5,240,3,76,158,11,162,5,
354 169,0,188,29,5,48,3,157,29,5,157,17,5,202,16,242, 354 169,0,188,29,5,48,3,157,29,5,157,17,5,202,16,242,
355 173,147,5,133,252,173,148,5,133,253,172,149,5,140,161,5, 355 173,147,5,133,252,173,148,5,133,253,172,149,5,140,161,5,
356 204,159,5,208,25,173,160,5,240,20,173,149,5,172,158,5, 356 204,159,5,208,25,173,160,5,240,20,173,149,5,172,158,5,
357 140,149,5,206,160,5,208,232,141,149,5,168,16,226,162,0, 357 140,149,5,206,160,5,208,232,141,149,5,168,16,226,162,0,
358 177,252,201,254,240,28,157,53,5,230,253,177,252,198,253,201, 358 177,252,201,254,240,28,157,53,5,230,253,177,252,198,253,201,
359 254,240,15,157,56,5,24,152,105,85,168,232,224,3,144,224, 359 254,240,15,157,56,5,24,152,105,85,168,232,224,3,144,224,
360 176,34,172,149,5,200,204,161,5,240,80,140,149,5,76,250, 360 176,34,172,149,5,200,204,161,5,240,80,140,149,5,76,250,
361 10,104,41,14,170,189,253,7,141,135,11,189,254,7,141,136, 361 10,104,41,14,170,189,253,7,141,135,11,189,254,7,141,136,
362 11,76,129,11,172,149,5,177,252,16,57,201,255,240,53,74, 362 11,76,129,11,172,149,5,177,252,16,57,201,255,240,53,74,
363 74,74,72,41,1,240,218,104,41,14,170,189,233,7,141,135, 363 74,74,72,41,1,240,218,104,41,14,170,189,233,7,141,135,
364 11,189,234,7,141,136,11,173,54,5,133,254,32,134,11,140, 364 11,189,234,7,141,136,11,173,54,5,133,254,32,134,11,140,
365 149,5,192,85,176,5,204,161,5,208,179,172,161,5,140,149, 365 149,5,192,85,176,5,204,161,5,208,179,172,161,5,140,149,
366 5,76,47,15,76,94,12,165,254,48,18,41,15,141,169,5, 366 5,76,47,15,76,94,12,165,254,48,18,41,15,141,169,5,
367 173,55,5,16,3,173,169,5,41,15,141,170,5,200,96,165, 367 173,55,5,16,3,173,169,5,41,15,141,170,5,200,96,165,
368 254,48,250,41,1,141,184,5,200,96,173,179,5,48,20,206, 368 254,48,250,41,1,141,184,5,200,96,173,179,5,48,20,206,
369 180,5,208,51,169,50,141,180,5,206,179,5,208,41,206,179, 369 180,5,208,51,169,50,141,180,5,206,179,5,208,41,206,179,
370 5,200,96,165,254,48,214,141,180,5,238,180,5,165,254,48, 370 5,200,96,165,254,48,214,141,180,5,238,180,5,165,254,48,
371 204,141,180,5,238,180,5,173,55,5,141,179,5,16,5,169, 371 204,141,180,5,238,180,5,173,55,5,141,179,5,16,5,169,
372 0,141,179,5,238,179,5,104,104,76,225,12,32,110,9,160, 372 0,141,179,5,238,179,5,104,104,76,225,12,32,110,9,160,
373 255,96,165,254,48,249,168,96,165,254,48,243,56,152,229,254, 373 255,96,165,254,48,249,168,96,165,254,48,243,56,152,229,254,
374 168,96,165,254,48,233,24,152,101,254,168,96,165,254,48,223, 374 168,96,165,254,48,233,24,152,101,254,168,96,165,254,48,223,
375 141,151,5,141,152,5,200,96,165,254,48,211,173,55,5,48, 375 141,151,5,141,152,5,200,96,165,254,48,211,173,55,5,48,
376 206,200,140,158,5,24,152,101,254,141,159,5,173,55,5,141, 376 206,200,140,158,5,24,152,101,254,141,159,5,173,55,5,141,
377 160,5,192,84,96,136,48,10,177,252,201,143,240,4,201,239, 377 160,5,192,84,96,136,48,10,177,252,201,143,240,4,201,239,
378 208,243,200,96,162,5,189,23,5,240,5,222,23,5,16,87, 378 208,243,200,96,162,5,189,23,5,240,5,222,23,5,16,87,
379 189,29,5,208,82,188,53,5,201,64,176,75,173,155,5,133, 379 189,29,5,208,82,188,53,5,201,64,176,75,173,155,5,133,
380 252,173,156,5,133,253,177,252,133,254,24,152,105,64,168,177, 380 252,173,156,5,133,253,177,252,133,254,24,152,105,64,168,177,
381 252,133,255,188,17,5,177,254,41,192,208,12,177,254,41,63, 381 252,133,255,188,17,5,177,254,41,192,208,12,177,254,41,63,
382 157,47,5,254,17,5,16,235,201,64,208,13,177,254,41,63, 382 157,47,5,254,17,5,16,235,201,64,208,13,177,254,41,63,
383 188,47,5,32,150,9,76,190,12,201,128,208,10,177,254,41, 383 188,47,5,32,150,9,76,190,12,201,128,208,10,177,254,41,
384 63,157,23,5,254,17,5,202,16,156,174,150,5,232,138,41, 384 63,157,23,5,254,17,5,202,16,156,174,150,5,232,138,41,
385 63,141,150,5,206,152,5,208,14,173,151,5,141,152,5,173, 385 63,141,150,5,206,152,5,208,14,173,151,5,141,152,5,173,
386 150,5,208,3,238,149,5,172,89,5,173,59,5,41,7,201, 386 150,5,208,3,238,149,5,172,89,5,173,59,5,41,7,201,
387 5,240,4,201,6,208,1,136,140,162,5,160,0,201,5,240, 387 5,240,4,201,6,208,1,136,140,162,5,160,0,201,5,240,
388 4,201,6,208,2,160,2,201,7,208,2,160,40,140,164,5, 388 4,201,6,208,2,160,2,201,7,208,2,160,40,140,164,5,
389 172,92,5,173,62,5,41,7,201,5,240,4,201,6,208,1, 389 172,92,5,173,62,5,41,7,201,5,240,4,201,6,208,1,
390 136,140,163,5,160,0,201,5,240,4,201,6,208,2,160,2, 390 136,140,163,5,160,0,201,5,240,4,201,6,208,2,160,2,
391 201,7,208,2,160,40,140,165,5,162,5,189,59,5,41,224, 391 201,7,208,2,160,40,140,165,5,162,5,189,59,5,41,224,
392 157,65,5,189,101,5,133,252,189,71,5,133,253,189,41,5, 392 157,65,5,189,101,5,133,252,189,71,5,133,253,189,41,5,
393 201,255,240,55,201,15,208,33,189,77,5,240,46,222,77,5, 393 201,255,240,55,201,15,208,33,189,77,5,240,46,222,77,5,
394 189,77,5,208,38,188,35,5,240,1,136,152,157,35,5,189, 394 189,77,5,208,38,188,35,5,240,1,136,152,157,35,5,189,
395 119,5,157,77,5,136,76,133,13,189,41,5,74,168,177,252, 395 119,5,157,77,5,136,76,133,13,189,41,5,74,168,177,252,
396 144,4,74,74,74,74,41,15,157,35,5,188,125,5,189,59, 396 144,4,74,74,74,74,41,15,157,35,5,188,125,5,189,59,
397 5,41,7,201,1,208,31,136,152,200,221,89,5,8,169,1, 397 5,41,7,201,1,208,31,136,152,200,221,89,5,8,169,1,
398 40,208,2,10,10,61,83,5,240,12,188,89,5,192,255,208, 398 40,208,2,10,10,61,83,5,240,12,188,89,5,192,255,208,
399 5,169,0,157,35,5,152,157,95,5,169,1,141,168,5,189, 399 5,169,0,157,35,5,152,157,95,5,169,1,141,168,5,189,
400 41,5,201,15,240,76,41,7,168,185,205,5,133,254,189,41, 400 41,5,201,15,240,76,41,7,168,185,205,5,133,254,189,41,
401 5,41,8,8,138,40,24,240,2,105,6,168,185,107,5,37, 401 5,41,8,8,138,40,24,240,2,105,6,168,185,107,5,37,
402 254,240,47,189,137,5,157,95,5,142,168,5,202,224,2,240, 402 254,240,47,189,137,5,157,95,5,142,168,5,202,224,2,240,
403 15,224,255,208,22,141,162,5,169,0,141,164,5,76,5,14, 403 15,224,255,208,22,141,162,5,169,0,141,164,5,76,5,14,
404 173,140,5,141,163,5,169,0,141,165,5,232,189,131,5,157, 404 173,140,5,141,163,5,169,0,141,165,5,232,189,131,5,157,
405 65,5,189,41,5,41,15,201,15,240,18,254,41,5,189,41, 405 65,5,189,41,5,41,15,201,15,240,18,254,41,5,189,41,
406 5,41,15,201,15,208,6,189,119,5,157,77,5,189,29,5, 406 5,41,15,201,15,208,6,189,119,5,157,77,5,189,29,5,
407 16,10,189,35,5,208,5,169,64,157,29,5,254,83,5,160, 407 16,10,189,35,5,208,5,169,64,157,29,5,254,83,5,160,
408 0,189,59,5,74,74,74,74,144,1,136,74,144,1,200,24, 408 0,189,59,5,74,74,74,74,144,1,136,74,144,1,200,24,
409 152,125,125,5,157,125,5,189,89,5,201,255,208,2,160,0, 409 152,125,125,5,157,125,5,189,89,5,201,255,208,2,160,0,
410 24,152,125,89,5,157,89,5,202,48,3,76,53,13,32,123, 410 24,152,125,89,5,157,89,5,202,48,3,76,53,13,32,123,
411 15,173,65,5,141,166,5,173,68,5,141,167,5,173,59,5, 411 15,173,65,5,141,166,5,173,68,5,141,167,5,173,59,5,
412 41,7,32,181,15,152,72,185,185,5,8,41,127,170,152,41, 412 41,7,32,181,15,152,72,185,185,5,8,41,127,170,152,41,
413 3,10,168,224,3,208,3,76,196,14,189,173,5,208,39,189, 413 3,10,168,224,3,208,3,76,196,14,189,173,5,208,39,189,
414 95,5,153,0,210,189,35,5,29,65,5,40,16,2,169,0, 414 95,5,153,0,210,189,35,5,29,65,5,40,16,2,169,0,
415 153,1,210,104,168,136,41,3,240,3,76,127,14,173,164,5, 415 153,1,210,104,168,136,41,3,240,3,76,127,14,173,164,5,
416 141,8,210,76,228,14,40,76,173,14,173,173,5,208,23,173, 416 141,8,210,76,228,14,40,76,173,14,173,173,5,208,23,173,
417 162,5,153,0,210,173,35,5,13,166,5,40,16,2,169,0, 417 162,5,153,0,210,173,35,5,13,166,5,40,16,2,169,0,
418 153,1,210,76,173,14,40,76,173,14,173,62,5,41,7,32, 418 153,1,210,76,173,14,40,76,173,14,173,62,5,41,7,32,
419 181,15,152,72,185,185,5,8,41,127,170,152,41,3,10,168, 419 181,15,152,72,185,185,5,8,41,127,170,152,41,3,10,168,
420 224,3,208,3,76,60,15,189,176,5,208,30,189,98,5,153, 420 224,3,208,3,76,60,15,189,176,5,208,30,189,98,5,153,
421 16,210,189,38,5,29,68,5,40,16,2,169,0,153,17,210, 421 16,210,189,38,5,29,68,5,40,16,2,169,0,153,17,210,
422 104,168,136,41,3,240,7,76,236,14,40,76,26,15,173,165, 422 104,168,136,41,3,240,7,76,236,14,40,76,26,15,173,165,
423 5,141,24,210,24,104,133,255,104,133,254,104,133,253,104,133, 423 5,141,24,210,24,104,133,255,104,133,254,104,133,253,104,133,
424 252,96,173,176,5,208,23,173,163,5,153,16,210,173,38,5, 424 252,96,173,176,5,208,23,173,163,5,153,16,210,173,38,5,
425 13,167,5,40,16,2,169,0,153,17,210,76,26,15,40,76, 425 13,167,5,40,16,2,169,0,153,17,210,76,26,15,40,76,
426 26,15,32,168,10,176,25,173,184,5,240,20,173,157,5,141, 426 26,15,32,168,10,176,25,173,184,5,240,20,173,157,5,141,
427 183,5,169,1,141,157,5,32,168,10,173,183,5,141,157,5, 427 183,5,169,1,141,157,5,32,168,10,173,183,5,141,157,5,
428 96,173,169,5,10,10,10,10,141,171,5,173,170,5,10,10, 428 96,173,169,5,10,10,10,10,141,171,5,173,170,5,10,10,
429 10,10,141,172,5,162,2,134,200,173,171,5,29,35,5,170, 429 10,10,141,172,5,162,2,134,200,173,171,5,29,35,5,170,
430 189,233,6,166,200,157,35,5,173,172,5,29,38,5,170,189, 430 189,233,6,166,200,157,35,5,173,172,5,29,38,5,170,189,
431 233,6,166,200,157,38,5,202,16,221,96,168,185,13,8,168, 431 233,6,166,200,157,38,5,202,16,221,96,168,185,13,8,168,
432 96 432 96
433END_CONST_ARRAY; 433END_CONST_ARRAY;
434CONST_ARRAY(byte, dlt_obx) 434CONST_ARRAY(byte, dlt_obx)
435 255,255,0,4,70,12,255,241,228,215,203,192,181,170,161,152, 435 255,255,0,4,70,12,255,241,228,215,203,192,181,170,161,152,
436 143,135,127,121,114,107,101,95,90,85,80,75,71,67,63,60, 436 143,135,127,121,114,107,101,95,90,85,80,75,71,67,63,60,
437 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, 437 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23,
438 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 438 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
439 5,4,255,241,228,215,242,233,218,206,191,182,170,161,152,143, 439 5,4,255,241,228,215,242,233,218,206,191,182,170,161,152,143,
440 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, 440 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76,
441 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, 441 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30,
442 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, 442 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2,
443 1,0,242,233,218,206,242,233,218,206,191,182,170,161,152,143, 443 1,0,242,233,218,206,242,233,218,206,191,182,170,161,152,143,
444 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, 444 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76,
445 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, 445 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30,
446 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, 446 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2,
447 1,0,242,233,218,206,255,241,228,216,202,192,181,171,162,153, 447 1,0,242,233,218,206,255,241,228,216,202,192,181,171,162,153,
448 142,135,127,120,115,108,102,97,90,85,81,75,72,67,63,60, 448 142,135,127,120,115,108,102,97,90,85,81,75,72,67,63,60,
449 57,52,51,48,45,42,40,37,36,33,31,30,28,27,25,23, 449 57,52,51,48,45,42,40,37,36,33,31,30,28,27,25,23,
450 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 450 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
451 5,4,3,2,1,255,76,9,5,76,200,5,76,183,5,136, 451 5,4,3,2,1,255,76,9,5,76,200,5,76,183,5,136,
452 140,54,3,169,126,141,53,3,162,6,142,51,3,162,1,142, 452 140,54,3,169,126,141,53,3,162,6,142,51,3,162,1,142,
453 52,3,32,51,5,32,95,5,32,163,5,32,139,5,169,1, 453 52,3,32,51,5,32,95,5,32,163,5,32,139,5,169,1,
454 141,50,3,169,3,141,15,210,96,162,0,160,32,142,48,3, 454 141,50,3,169,3,141,15,210,96,162,0,160,32,142,48,3,
455 140,49,3,160,0,173,48,3,153,0,2,173,49,3,153,64, 455 140,49,3,160,0,173,48,3,153,0,2,173,49,3,153,64,
456 2,173,48,3,24,105,128,141,48,3,144,3,238,49,3,200, 456 2,173,48,3,24,105,128,141,48,3,144,3,238,49,3,200,
457 192,64,208,225,96,162,0,160,68,142,48,3,140,49,3,160, 457 192,64,208,225,96,162,0,160,68,142,48,3,140,49,3,160,
458 0,173,48,3,153,128,2,173,49,3,153,160,2,173,48,3, 458 0,173,48,3,153,128,2,173,49,3,153,160,2,173,48,3,
459 24,105,64,141,48,3,144,3,238,49,3,200,192,32,208,225, 459 24,105,64,141,48,3,144,3,238,49,3,200,192,32,208,225,
460 96,173,0,76,41,1,74,106,106,168,162,0,185,128,4,157, 460 96,173,0,76,41,1,74,106,106,168,162,0,185,128,4,157,
461 64,4,200,232,224,64,208,244,96,160,3,169,0,153,40,3, 461 64,4,200,232,224,64,208,244,96,160,3,169,0,153,40,3,
462 153,32,3,153,36,3,153,44,3,136,16,241,96,169,0,141, 462 153,32,3,153,36,3,153,44,3,136,16,241,96,169,0,141,
463 50,3,160,7,169,0,153,0,210,136,16,250,96,96,173,50, 463 50,3,160,7,169,0,153,0,210,136,16,250,96,96,173,50,
464 3,240,250,173,40,3,13,41,3,13,42,3,13,43,3,141, 464 3,240,250,173,40,3,13,41,3,13,42,3,13,43,3,141,
465 8,210,174,36,3,172,32,3,142,0,210,140,1,210,174,37, 465 8,210,174,36,3,172,32,3,142,0,210,140,1,210,174,37,
466 3,172,33,3,142,2,210,140,3,210,174,38,3,172,34,3, 466 3,172,33,3,142,2,210,140,3,210,174,38,3,172,34,3,
467 142,4,210,140,5,210,174,39,3,172,35,3,142,6,210,140, 467 142,4,210,140,5,210,174,39,3,172,35,3,142,6,210,140,
468 7,210,206,52,3,208,74,173,51,3,141,52,3,238,53,3, 468 7,210,206,52,3,208,74,173,51,3,141,52,3,238,53,3,
469 238,53,3,16,28,238,54,3,169,0,141,53,3,32,199,6, 469 238,53,3,16,28,238,54,3,169,0,141,53,3,32,199,6,
470 173,4,3,13,5,3,13,6,3,13,7,3,208,3,76,183, 470 173,4,3,13,5,3,13,6,3,13,7,3,208,3,76,183,
471 5,173,4,3,240,3,32,97,7,173,5,3,240,3,32,192, 471 5,173,4,3,240,3,32,97,7,173,5,3,240,3,32,192,
472 7,173,6,3,240,3,32,31,8,173,7,3,240,3,32,126, 472 7,173,6,3,240,3,32,31,8,173,7,3,240,3,32,126,
473 8,173,4,3,240,8,173,44,3,240,3,32,221,8,173,5, 473 8,173,4,3,240,8,173,44,3,240,3,32,221,8,173,5,
474 3,240,8,173,45,3,240,3,32,206,9,173,6,3,240,8, 474 3,240,8,173,45,3,240,3,32,206,9,173,6,3,240,8,
475 173,46,3,240,3,32,191,10,173,7,3,240,8,173,47,3, 475 173,46,3,240,3,32,191,10,173,7,3,240,8,173,47,3,
476 240,3,32,131,11,96,192,67,144,14,169,0,141,4,3,141, 476 240,3,32,131,11,96,192,67,144,14,169,0,141,4,3,141,
477 32,3,141,40,3,76,230,6,192,66,208,15,189,128,64,141, 477 32,3,141,40,3,76,230,6,192,66,208,15,189,128,64,141,
478 51,3,141,52,3,238,54,3,76,199,6,192,65,208,9,189, 478 51,3,141,52,3,238,54,3,76,199,6,192,65,208,9,189,
479 128,64,141,54,3,76,199,6,104,104,76,183,5,174,54,3, 479 128,64,141,54,3,76,199,6,104,104,76,183,5,174,54,3,
480 188,0,64,192,64,176,191,189,128,64,141,24,3,185,0,2, 480 188,0,64,192,64,176,191,189,128,64,141,24,3,185,0,2,
481 133,224,185,64,2,133,225,169,1,141,4,3,188,0,65,192, 481 133,224,185,64,2,133,225,169,1,141,4,3,188,0,65,192,
482 64,176,78,189,128,65,141,25,3,185,0,2,133,226,185,64, 482 64,176,78,189,128,65,141,25,3,185,0,2,133,226,185,64,
483 2,133,227,169,1,141,5,3,188,0,66,192,64,176,63,189, 483 2,133,227,169,1,141,5,3,188,0,66,192,64,176,63,189,
484 128,66,141,26,3,185,0,2,133,228,185,64,2,133,229,169, 484 128,66,141,26,3,185,0,2,133,228,185,64,2,133,229,169,
485 1,141,6,3,188,0,67,192,64,176,48,189,128,67,141,27, 485 1,141,6,3,188,0,67,192,64,176,48,189,128,67,141,27,
486 3,185,0,2,133,230,185,64,2,133,231,169,1,141,7,3, 486 3,185,0,2,133,230,185,64,2,133,231,169,1,141,7,3,
487 96,169,0,141,5,3,141,33,3,141,41,3,240,186,169,0, 487 96,169,0,141,5,3,141,33,3,141,41,3,240,186,169,0,
488 141,6,3,141,34,3,141,42,3,240,201,169,0,141,7,3, 488 141,6,3,141,34,3,141,42,3,240,201,169,0,141,7,3,
489 141,35,3,141,43,3,96,172,53,3,177,224,48,11,200,177, 489 141,35,3,141,43,3,96,172,53,3,177,224,48,11,200,177,
490 224,48,1,96,104,104,76,31,6,24,109,24,3,41,127,141, 490 224,48,1,96,104,104,76,31,6,24,109,24,3,41,127,141,
491 8,3,169,15,141,0,3,141,44,3,200,177,224,170,189,160, 491 8,3,169,15,141,0,3,141,44,3,200,177,224,170,189,160,
492 2,133,233,133,241,133,249,189,128,2,133,232,73,16,133,240, 492 2,133,233,133,241,133,249,189,128,2,133,232,73,16,133,240,
493 73,48,133,248,160,49,177,232,141,12,3,160,51,177,232,41, 493 73,48,133,248,160,49,177,232,141,12,3,160,51,177,232,41,
494 127,141,16,3,169,0,141,20,3,141,28,3,160,48,177,232, 494 127,141,16,3,169,0,141,20,3,141,28,3,160,48,177,232,
495 41,213,141,40,3,96,172,53,3,177,226,48,11,200,177,226, 495 41,213,141,40,3,96,172,53,3,177,226,48,11,200,177,226,
496 48,1,96,104,104,76,31,6,24,109,25,3,41,127,141,9, 496 48,1,96,104,104,76,31,6,24,109,25,3,41,127,141,9,
497 3,169,15,141,1,3,141,45,3,200,177,226,170,189,160,2, 497 3,169,15,141,1,3,141,45,3,200,177,226,170,189,160,2,
498 133,235,133,243,133,251,189,128,2,133,234,73,16,133,242,73, 498 133,235,133,243,133,251,189,128,2,133,234,73,16,133,242,73,
499 48,133,250,160,49,177,234,141,13,3,160,51,177,234,41,127, 499 48,133,250,160,49,177,234,141,13,3,160,51,177,234,41,127,
500 141,17,3,169,0,141,21,3,141,29,3,160,48,177,234,41, 500 141,17,3,169,0,141,21,3,141,29,3,160,48,177,234,41,
501 131,141,41,3,96,172,53,3,177,228,48,11,200,177,228,48, 501 131,141,41,3,96,172,53,3,177,228,48,11,200,177,228,48,
502 1,96,104,104,76,31,6,24,109,26,3,41,127,141,10,3, 502 1,96,104,104,76,31,6,24,109,26,3,41,127,141,10,3,
503 169,15,141,2,3,141,46,3,200,177,228,170,189,160,2,133, 503 169,15,141,2,3,141,46,3,200,177,228,170,189,160,2,133,
504 237,133,245,133,253,189,128,2,133,236,73,16,133,244,73,48, 504 237,133,245,133,253,189,128,2,133,236,73,16,133,244,73,48,
505 133,252,160,49,177,236,141,14,3,160,51,177,236,41,127,141, 505 133,252,160,49,177,236,141,14,3,160,51,177,236,41,127,141,
506 18,3,169,0,141,22,3,141,30,3,160,48,177,236,41,169, 506 18,3,169,0,141,22,3,141,30,3,160,48,177,236,41,169,
507 141,42,3,96,172,53,3,177,230,48,11,200,177,230,48,1, 507 141,42,3,96,172,53,3,177,230,48,11,200,177,230,48,1,
508 96,104,104,76,31,6,24,109,27,3,41,127,141,11,3,169, 508 96,104,104,76,31,6,24,109,27,3,41,127,141,11,3,169,
509 15,141,3,3,141,47,3,200,177,230,170,189,160,2,133,239, 509 15,141,3,3,141,47,3,200,177,230,170,189,160,2,133,239,
510 133,247,133,255,189,128,2,133,238,73,16,133,246,73,48,133, 510 133,247,133,255,189,128,2,133,238,73,16,133,246,73,48,133,
511 254,160,49,177,238,141,15,3,160,51,177,238,41,127,141,19, 511 254,160,49,177,238,141,15,3,160,51,177,238,41,127,141,19,
512 3,169,0,141,23,3,141,31,3,160,48,177,238,41,129,141, 512 3,169,0,141,23,3,141,31,3,160,48,177,238,41,129,141,
513 43,3,96,172,0,3,48,70,177,232,141,32,3,177,240,208, 513 43,3,96,172,0,3,48,70,177,232,141,32,3,177,240,208,
514 9,32,108,9,206,0,3,76,79,9,201,1,240,39,201,3, 514 9,32,108,9,206,0,3,76,79,9,201,1,240,39,201,3,
515 208,16,173,8,3,24,113,248,170,173,28,3,141,55,3,76, 515 208,16,173,8,3,24,113,248,170,173,28,3,141,55,3,76,
516 24,9,173,28,3,24,113,248,141,55,3,174,8,3,32,150, 516 24,9,173,28,3,24,113,248,141,55,3,174,8,3,32,150,
517 9,206,0,3,96,177,248,141,36,3,206,0,3,96,32,108, 517 9,206,0,3,96,177,248,141,36,3,206,0,3,96,32,108,
518 9,160,49,177,232,240,30,206,12,3,240,3,76,79,9,173, 518 9,160,49,177,232,240,30,206,12,3,240,3,76,79,9,173,
519 32,3,41,15,240,11,206,32,3,177,232,141,12,3,76,79, 519 32,3,41,15,240,11,206,32,3,177,232,141,12,3,76,79,
520 9,141,44,3,96,173,28,3,24,160,50,113,232,141,28,3, 520 9,141,44,3,96,173,28,3,24,160,50,113,232,141,28,3,
521 206,16,3,208,12,238,20,3,160,51,177,232,41,127,141,16, 521 206,16,3,208,12,238,20,3,160,51,177,232,41,127,141,16,
522 3,96,173,20,3,41,3,24,105,52,168,177,232,170,160,51, 522 3,96,173,20,3,41,3,24,105,52,168,177,232,170,160,51,
523 177,232,48,14,138,109,8,3,170,173,28,3,141,55,3,76, 523 177,232,48,14,138,109,8,3,170,173,28,3,141,55,3,76,
524 150,9,138,109,28,3,141,55,3,174,8,3,189,0,4,24, 524 150,9,138,109,28,3,141,55,3,174,8,3,189,0,4,24,
525 109,55,3,141,36,3,173,40,3,41,4,208,1,96,172,0, 525 109,55,3,141,36,3,173,40,3,41,4,208,1,96,172,0,
526 3,177,240,208,21,138,24,160,0,113,248,170,189,0,4,24, 526 3,177,240,208,21,138,24,160,0,113,248,170,189,0,4,24,
527 109,55,3,24,105,255,141,38,3,96,173,36,3,24,105,255, 527 109,55,3,24,105,255,141,38,3,96,173,36,3,24,105,255,
528 141,38,3,96,172,1,3,48,70,177,234,141,33,3,177,242, 528 141,38,3,96,172,1,3,48,70,177,234,141,33,3,177,242,
529 208,9,32,93,10,206,1,3,76,64,10,201,1,240,39,201, 529 208,9,32,93,10,206,1,3,76,64,10,201,1,240,39,201,
530 3,208,16,173,9,3,24,113,250,170,173,29,3,141,55,3, 530 3,208,16,173,9,3,24,113,250,170,173,29,3,141,55,3,
531 76,9,10,173,29,3,24,113,250,141,55,3,174,9,3,32, 531 76,9,10,173,29,3,24,113,250,141,55,3,174,9,3,32,
532 135,10,206,1,3,96,177,250,141,37,3,206,1,3,96,32, 532 135,10,206,1,3,96,177,250,141,37,3,206,1,3,96,32,
533 93,10,160,49,177,234,240,30,206,13,3,240,3,76,64,10, 533 93,10,160,49,177,234,240,30,206,13,3,240,3,76,64,10,
534 173,33,3,41,15,240,11,206,33,3,177,234,141,13,3,76, 534 173,33,3,41,15,240,11,206,33,3,177,234,141,13,3,76,
535 64,10,141,45,3,96,173,29,3,24,160,50,113,234,141,29, 535 64,10,141,45,3,96,173,29,3,24,160,50,113,234,141,29,
536 3,206,17,3,208,12,238,21,3,160,51,177,234,41,127,141, 536 3,206,17,3,208,12,238,21,3,160,51,177,234,41,127,141,
537 17,3,96,173,21,3,41,3,24,105,52,168,177,234,170,160, 537 17,3,96,173,21,3,41,3,24,105,52,168,177,234,170,160,
538 51,177,234,48,14,138,109,9,3,170,173,29,3,141,55,3, 538 51,177,234,48,14,138,109,9,3,170,173,29,3,141,55,3,
539 76,135,10,138,109,29,3,141,55,3,174,9,3,189,0,4, 539 76,135,10,138,109,29,3,141,55,3,174,9,3,189,0,4,
540 24,109,55,3,141,37,3,173,41,3,41,2,208,1,96,172, 540 24,109,55,3,141,37,3,173,41,3,41,2,208,1,96,172,
541 1,3,177,242,208,21,138,24,160,0,113,250,170,189,0,4, 541 1,3,177,242,208,21,138,24,160,0,113,250,170,189,0,4,
542 24,109,55,3,24,105,255,141,39,3,96,173,37,3,24,105, 542 24,109,55,3,24,105,255,141,39,3,96,173,37,3,24,105,
543 255,141,39,3,96,172,2,3,48,70,177,236,141,34,3,177, 543 255,141,39,3,96,172,2,3,48,70,177,236,141,34,3,177,
544 244,208,9,32,78,11,206,2,3,76,49,11,201,1,240,39, 544 244,208,9,32,78,11,206,2,3,76,49,11,201,1,240,39,
545 201,3,208,16,173,10,3,24,113,252,170,173,30,3,141,55, 545 201,3,208,16,173,10,3,24,113,252,170,173,30,3,141,55,
546 3,76,250,10,173,30,3,24,113,252,141,55,3,174,10,3, 546 3,76,250,10,173,30,3,24,113,252,141,55,3,174,10,3,
547 32,120,11,206,2,3,96,177,252,141,38,3,206,2,3,96, 547 32,120,11,206,2,3,96,177,252,141,38,3,206,2,3,96,
548 32,78,11,160,49,177,236,240,30,206,14,3,240,3,76,49, 548 32,78,11,160,49,177,236,240,30,206,14,3,240,3,76,49,
549 11,173,34,3,41,15,240,11,206,34,3,177,236,141,14,3, 549 11,173,34,3,41,15,240,11,206,34,3,177,236,141,14,3,
550 76,49,11,141,46,3,96,173,30,3,24,160,50,113,236,141, 550 76,49,11,141,46,3,96,173,30,3,24,160,50,113,236,141,
551 30,3,206,18,3,208,12,238,22,3,160,51,177,236,41,127, 551 30,3,206,18,3,208,12,238,22,3,160,51,177,236,41,127,
552 141,18,3,96,173,22,3,41,3,24,105,52,168,177,236,170, 552 141,18,3,96,173,22,3,41,3,24,105,52,168,177,236,170,
553 160,51,177,236,48,14,138,109,10,3,170,173,30,3,141,55, 553 160,51,177,236,48,14,138,109,10,3,170,173,30,3,141,55,
554 3,76,120,11,138,109,30,3,141,55,3,174,10,3,189,0, 554 3,76,120,11,138,109,30,3,141,55,3,174,10,3,189,0,
555 4,24,109,55,3,141,38,3,96,172,3,3,48,70,177,238, 555 4,24,109,55,3,141,38,3,96,172,3,3,48,70,177,238,
556 141,35,3,177,246,208,9,32,18,12,206,3,3,76,245,11, 556 141,35,3,177,246,208,9,32,18,12,206,3,3,76,245,11,
557 201,1,240,39,201,3,208,16,173,11,3,24,113,254,170,173, 557 201,1,240,39,201,3,208,16,173,11,3,24,113,254,170,173,
558 31,3,141,55,3,76,190,11,173,31,3,24,113,254,141,55, 558 31,3,141,55,3,76,190,11,173,31,3,24,113,254,141,55,
559 3,174,11,3,32,60,12,206,3,3,96,177,254,141,39,3, 559 3,174,11,3,32,60,12,206,3,3,96,177,254,141,39,3,
560 206,3,3,96,32,18,12,160,49,177,238,240,30,206,15,3, 560 206,3,3,96,32,18,12,160,49,177,238,240,30,206,15,3,
561 240,3,76,245,11,173,35,3,41,15,240,11,206,35,3,177, 561 240,3,76,245,11,173,35,3,41,15,240,11,206,35,3,177,
562 238,141,15,3,76,245,11,141,47,3,96,173,31,3,24,160, 562 238,141,15,3,76,245,11,141,47,3,96,173,31,3,24,160,
563 50,113,238,141,31,3,206,19,3,208,12,238,23,3,160,51, 563 50,113,238,141,31,3,206,19,3,208,12,238,23,3,160,51,
564 177,238,41,127,141,19,3,96,173,23,3,41,3,24,105,52, 564 177,238,41,127,141,19,3,96,173,23,3,41,3,24,105,52,
565 168,177,238,170,160,51,177,238,48,14,138,109,11,3,170,173, 565 168,177,238,170,160,51,177,238,48,14,138,109,11,3,170,173,
566 31,3,141,55,3,76,60,12,138,109,31,3,141,55,3,174, 566 31,3,141,55,3,76,60,12,138,109,31,3,141,55,3,174,
567 11,3,189,0,4,24,109,55,3,141,39,3,96 567 11,3,189,0,4,24,109,55,3,141,39,3,96
568END_CONST_ARRAY; 568END_CONST_ARRAY;
569CONST_ARRAY(byte, mpt_obx) 569CONST_ARRAY(byte, mpt_obx)
570 255,255,0,5,178,13,76,205,11,173,46,7,208,1,96,169, 570 255,255,0,5,178,13,76,205,11,173,46,7,208,1,96,169,
571 0,141,28,14,238,29,14,173,23,14,205,187,13,144,80,206, 571 0,141,28,14,238,29,14,173,23,14,205,187,13,144,80,206,
572 21,14,240,3,76,197,5,162,0,142,23,14,169,0,157,237, 572 21,14,240,3,76,197,5,162,0,142,23,14,169,0,157,237,
573 13,157,245,13,189,179,13,133,236,189,183,13,133,237,172,22, 573 13,157,245,13,189,179,13,133,236,189,183,13,133,237,172,22,
574 14,177,236,200,201,255,240,7,201,254,208,15,76,42,12,177, 574 14,177,236,200,201,255,240,7,201,254,208,15,76,42,12,177,
575 236,48,249,10,168,140,22,14,76,59,5,157,233,13,177,236, 575 236,48,249,10,168,140,22,14,76,59,5,157,233,13,177,236,
576 157,213,13,232,224,4,208,196,200,140,22,14,76,197,5,206, 576 157,213,13,232,224,4,208,196,200,140,22,14,76,197,5,206,
577 21,14,16,87,173,188,13,141,21,14,162,3,222,245,13,16, 577 21,14,16,87,173,188,13,141,21,14,162,3,222,245,13,16,
578 68,189,233,13,10,168,185,255,255,133,236,200,185,255,255,133, 578 68,189,233,13,10,168,185,255,255,133,236,200,185,255,255,133,
579 237,5,236,240,48,189,237,13,141,31,14,32,62,7,172,31, 579 237,5,236,240,48,189,237,13,141,31,14,32,62,7,172,31,
580 14,200,152,157,237,13,189,241,13,157,245,13,224,2,208,21, 580 14,200,152,157,237,13,189,241,13,157,245,13,224,2,208,21,
581 189,197,13,73,15,10,10,10,10,105,69,141,161,13,169,10, 581 189,197,13,73,15,10,10,10,10,105,69,141,161,13,169,10,
582 105,0,141,162,13,202,16,180,238,23,14,162,1,173,27,14, 582 105,0,141,162,13,202,16,180,238,23,14,162,1,173,27,14,
583 201,2,240,2,162,3,173,27,14,201,2,208,5,236,25,14, 583 201,2,240,2,162,3,173,27,14,201,2,208,5,236,25,14,
584 240,3,76,118,6,181,240,61,114,6,240,18,160,40,177,236, 584 240,3,76,118,6,181,240,61,114,6,240,18,160,40,177,236,
585 24,125,225,13,32,117,9,56,125,1,14,157,203,13,202,16, 585 24,125,225,13,32,117,9,56,125,1,14,157,203,13,202,16,
586 213,169,3,141,15,210,165,241,41,16,240,15,172,226,13,185, 586 213,169,3,141,15,210,165,241,41,16,240,15,172,226,13,185,
587 198,9,141,201,13,185,5,10,141,202,13,173,201,13,141,0, 587 198,9,141,201,13,185,5,10,141,202,13,173,201,13,141,0,
588 210,173,202,13,141,2,210,173,203,13,141,4,210,173,204,13, 588 210,173,202,13,141,2,210,173,203,13,141,4,210,173,204,13,
589 141,6,210,173,193,13,162,255,172,27,14,192,1,208,5,174, 589 141,6,210,173,193,13,162,255,172,27,14,192,1,208,5,174,
590 25,14,240,3,141,1,210,173,194,13,224,1,240,3,141,3, 590 25,14,240,3,141,1,210,173,194,13,224,1,240,3,141,3,
591 210,192,2,240,20,173,195,13,224,2,240,3,141,5,210,173, 591 210,192,2,240,20,173,195,13,224,2,240,3,141,5,210,173,
592 196,13,224,3,240,3,141,7,210,165,240,5,241,5,242,5, 592 196,13,224,3,240,3,141,7,210,165,240,5,241,5,242,5,
593 243,13,28,14,141,8,210,96,4,2,0,0,189,217,13,133, 593 243,13,28,14,141,8,210,96,4,2,0,0,189,217,13,133,
594 236,189,221,13,133,237,5,236,208,8,157,193,13,149,240,76, 594 236,189,221,13,133,237,5,236,208,8,157,193,13,149,240,76,
595 248,5,180,244,192,32,240,66,177,236,56,253,197,13,44,58, 595 248,5,180,244,192,32,240,66,177,236,56,253,197,13,44,58,
596 7,240,2,41,240,157,193,13,200,177,236,141,30,14,200,148, 596 7,240,2,41,240,157,193,13,200,177,236,141,30,14,200,148,
597 244,41,7,240,60,168,185,126,9,141,203,6,185,133,9,141, 597 244,41,7,240,60,168,185,126,9,141,203,6,185,133,9,141,
598 204,6,173,30,14,74,74,74,74,74,9,40,168,177,236,24, 598 204,6,173,30,14,74,74,74,74,74,9,40,168,177,236,24,
599 32,255,255,169,0,149,240,76,248,5,189,9,14,240,18,222, 599 32,255,255,169,0,149,240,76,248,5,189,9,14,240,18,222,
600 13,14,208,13,157,13,14,189,193,13,41,15,240,3,222,193, 600 13,14,208,13,157,13,14,189,193,13,41,15,240,3,222,193,
601 13,160,35,177,236,149,240,189,17,14,24,105,37,168,41,3, 601 13,160,35,177,236,149,240,189,17,14,24,105,37,168,41,3,
602 157,17,14,136,177,236,125,209,13,157,225,13,32,119,9,157, 602 157,17,14,136,177,236,125,209,13,157,225,13,32,119,9,157,
603 201,13,189,5,14,240,6,222,5,14,76,223,5,189,189,13, 603 201,13,189,5,14,240,6,222,5,14,76,223,5,189,189,13,
604 141,30,7,16,254,76,194,8,0,76,229,8,0,76,251,8, 604 141,30,7,16,254,76,194,8,0,76,229,8,0,76,251,8,
605 0,76,21,9,0,76,37,9,0,76,56,9,0,76,66,9, 605 0,76,21,9,0,76,37,9,0,76,56,9,0,76,66,9,
606 16,76,72,9,169,0,157,197,13,172,31,14,136,200,177,236, 606 16,76,72,9,169,0,157,197,13,172,31,14,136,200,177,236,
607 201,254,208,4,140,31,14,96,201,224,144,8,173,187,13,141, 607 201,254,208,4,140,31,14,96,201,224,144,8,173,187,13,141,
608 23,14,208,233,201,208,144,10,41,15,141,188,13,141,21,14, 608 23,14,208,233,201,208,144,10,41,15,141,188,13,141,21,14,
609 16,219,201,192,144,9,41,15,73,15,157,197,13,16,206,201, 609 16,219,201,192,144,9,41,15,73,15,157,197,13,16,206,201,
610 128,144,7,41,63,157,241,13,16,195,201,64,144,27,200,140, 610 128,144,7,41,63,157,241,13,16,195,201,64,144,27,200,140,
611 31,14,41,31,157,229,13,10,168,185,255,255,157,217,13,200, 611 31,14,41,31,157,229,13,10,168,185,255,255,157,217,13,200,
612 185,255,255,157,221,13,76,62,7,140,31,14,141,30,14,24, 612 185,255,255,157,221,13,76,62,7,140,31,14,141,30,14,24,
613 125,213,13,157,209,13,173,27,14,240,66,201,2,240,58,189, 613 125,213,13,157,209,13,173,27,14,240,66,201,2,240,58,189,
614 229,13,201,31,208,55,173,30,14,56,233,1,41,15,168,177, 614 229,13,201,31,208,55,173,30,14,56,233,1,41,15,168,177,
615 254,133,253,152,9,16,168,177,254,133,248,160,1,5,253,208, 615 254,133,253,152,9,16,168,177,254,133,248,160,1,5,253,208,
616 2,160,0,140,26,14,169,0,133,252,157,217,13,157,221,13, 616 2,160,0,140,26,14,169,0,133,252,157,217,13,157,221,13,
617 138,10,141,24,14,142,25,14,96,224,2,176,99,189,217,13, 617 138,10,141,24,14,142,25,14,96,224,2,176,99,189,217,13,
618 133,238,189,221,13,133,239,5,238,240,74,160,32,177,238,41, 618 133,238,189,221,13,133,239,5,238,240,74,160,32,177,238,41,
619 15,157,249,13,177,238,41,112,74,74,157,189,13,200,177,238, 619 15,157,249,13,177,238,41,112,74,74,157,189,13,200,177,238,
620 10,10,72,41,63,157,5,14,104,41,192,157,205,13,200,177, 620 10,10,72,41,63,157,5,14,104,41,192,157,205,13,200,177,
621 238,157,9,14,157,13,14,169,0,149,244,157,17,14,157,253, 621 238,157,9,14,157,13,14,169,0,149,244,157,17,14,157,253,
622 13,157,1,14,189,209,13,157,225,13,32,117,9,157,201,13, 622 13,157,1,14,189,209,13,157,225,13,32,117,9,157,201,13,
623 236,25,14,240,1,96,160,255,140,25,14,200,140,26,14,96, 623 236,25,14,240,1,96,160,255,140,25,14,200,140,26,14,96,
624 224,2,208,51,172,211,13,185,69,11,141,121,13,185,129,11, 624 224,2,208,51,172,211,13,185,69,11,141,121,13,185,129,11,
625 141,127,13,169,0,133,249,133,250,173,231,13,41,15,168,177, 625 141,127,13,169,0,133,249,133,250,173,231,13,41,15,168,177,
626 254,133,251,152,9,16,168,177,254,141,137,13,5,251,208,6, 626 254,133,251,152,9,16,168,177,254,141,137,13,5,251,208,6,
627 141,121,13,141,127,13,96,173,232,13,41,15,168,177,254,133, 627 141,121,13,141,127,13,96,173,232,13,41,15,168,177,254,133,
628 253,152,9,16,168,177,254,5,253,240,15,177,254,56,229,253, 628 253,152,9,16,168,177,254,5,253,240,15,177,254,56,229,253,
629 133,248,169,0,133,252,169,141,208,2,169,173,141,97,13,141, 629 133,248,169,0,133,252,169,141,208,2,169,173,141,97,13,141,
630 56,13,169,24,141,7,210,96,173,29,14,41,7,74,74,144, 630 56,13,169,24,141,7,210,96,173,29,14,41,7,74,74,144,
631 18,208,24,189,249,13,24,157,1,14,125,201,13,157,201,13, 631 18,208,24,189,249,13,24,157,1,14,125,201,13,157,201,13,
632 76,223,5,169,0,157,1,14,76,223,5,189,201,13,56,253, 632 76,223,5,169,0,157,1,14,76,223,5,189,201,13,56,253,
633 249,13,157,201,13,56,169,0,253,249,13,157,1,14,76,223, 633 249,13,157,201,13,56,169,0,253,249,13,157,1,14,76,223,
634 5,189,253,13,24,157,1,14,125,201,13,157,201,13,24,189, 634 5,189,253,13,24,157,1,14,125,201,13,157,201,13,24,189,
635 253,13,125,249,13,157,253,13,76,223,5,189,225,13,56,253, 635 253,13,125,249,13,157,253,13,76,223,5,189,225,13,56,253,
636 253,13,157,225,13,32,117,9,76,5,9,169,0,56,253,253, 636 253,13,157,225,13,32,117,9,76,5,9,169,0,56,253,253,
637 13,157,1,14,189,201,13,56,253,253,13,76,5,9,189,225, 637 13,157,1,14,189,201,13,56,253,253,13,76,5,9,189,225,
638 13,24,125,253,13,76,28,9,32,85,9,76,208,8,32,85, 638 13,24,125,253,13,76,28,9,32,85,9,76,208,8,32,85,
639 9,24,125,225,13,32,155,9,76,223,5,188,253,13,189,249, 639 9,24,125,225,13,32,155,9,76,223,5,188,253,13,189,249,
640 13,48,2,200,200,136,152,157,253,13,221,249,13,208,8,189, 640 13,48,2,200,200,136,152,157,253,13,221,249,13,208,8,189,
641 249,13,73,255,157,249,13,189,253,13,96,41,63,29,205,13, 641 249,13,73,255,157,249,13,189,253,13,96,41,63,29,205,13,
642 168,185,255,255,96,148,145,152,165,173,180,192,9,9,9,9, 642 168,185,255,255,96,148,145,152,165,173,180,192,9,9,9,9,
643 9,9,9,64,0,32,0,125,201,13,157,201,13,96,125,209, 643 9,9,9,64,0,32,0,125,201,13,157,201,13,96,125,209,
644 13,157,225,13,32,117,9,157,201,13,96,157,201,13,189,141, 644 13,157,225,13,32,117,9,157,201,13,96,157,201,13,189,141,
645 9,16,12,157,201,13,169,128,208,5,157,201,13,169,1,13, 645 9,16,12,157,201,13,169,128,208,5,157,201,13,169,1,13,
646 28,14,141,28,14,96,45,10,210,157,201,13,96,242,51,150, 646 28,14,141,28,14,96,45,10,210,157,201,13,96,242,51,150,
647 226,56,140,0,106,232,106,239,128,8,174,70,230,149,65,246, 647 226,56,140,0,106,232,106,239,128,8,174,70,230,149,65,246,
648 176,110,48,246,187,132,82,34,244,200,160,122,85,52,20,245, 648 176,110,48,246,187,132,82,34,244,200,160,122,85,52,20,245,
649 216,189,164,141,119,96,78,56,39,21,6,247,232,219,207,195, 649 216,189,164,141,119,96,78,56,39,21,6,247,232,219,207,195,
650 184,172,162,154,144,136,127,120,112,106,100,94,13,13,12,11, 650 184,172,162,154,144,136,127,120,112,106,100,94,13,13,12,11,
651 11,10,10,9,8,8,7,7,7,6,6,5,5,5,4,4, 651 11,10,10,9,8,8,7,7,7,6,6,5,5,5,4,4,
652 4,4,3,3,3,3,3,2,2,2,2,2,2,2,1,1, 652 4,4,3,3,3,3,3,2,2,2,2,2,2,2,1,1,
653 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, 653 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
654 0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24, 654 0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24,
655 24,24,24,24,24,24,24,24,24,24,24,22,22,23,23,23, 655 24,24,24,24,24,24,24,24,24,24,24,22,22,23,23,23,
656 23,24,24,24,24,24,25,25,25,25,26,21,21,22,22,22, 656 23,24,24,24,24,24,25,25,25,25,26,21,21,22,22,22,
657 23,23,24,24,24,25,25,26,26,26,27,20,21,21,22,22, 657 23,23,24,24,24,25,25,26,26,26,27,20,21,21,22,22,
658 23,23,24,24,24,25,25,26,26,27,27,20,20,21,21,22, 658 23,23,24,24,24,25,25,26,26,27,27,20,20,21,21,22,
659 22,23,23,24,25,25,26,26,27,27,28,19,20,20,21,22, 659 22,23,23,24,25,25,26,26,27,27,28,19,20,20,21,22,
660 22,23,23,24,25,25,26,26,27,28,28,19,19,20,21,21, 660 22,23,23,24,25,25,26,26,27,28,28,19,19,20,21,21,
661 22,23,23,24,25,25,26,27,27,28,29,18,19,20,20,21, 661 22,23,23,24,25,25,26,27,27,28,29,18,19,20,20,21,
662 22,23,23,24,25,25,26,27,28,28,29,18,19,19,20,21, 662 22,23,23,24,25,25,26,27,28,28,29,18,19,19,20,21,
663 22,22,23,24,25,26,26,27,28,29,29,18,18,19,20,21, 663 22,22,23,24,25,26,26,27,28,29,29,18,18,19,20,21,
664 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, 664 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21,
665 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, 665 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21,
666 21,22,23,24,25,26,27,27,28,29,30,17,18,19,20,20, 666 21,22,23,24,25,26,27,27,28,29,30,17,18,19,20,20,
667 21,22,23,24,25,26,27,28,28,29,30,17,18,19,19,20, 667 21,22,23,24,25,26,27,28,28,29,30,17,18,19,19,20,
668 21,22,23,24,25,26,27,28,29,29,30,17,18,18,19,20, 668 21,22,23,24,25,26,27,28,29,29,30,17,18,18,19,20,
669 21,22,23,24,25,26,27,28,29,30,30,16,17,18,19,20, 669 21,22,23,24,25,26,27,28,29,30,30,16,17,18,19,20,
670 21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,41, 670 21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,41,
671 43,46,48,51,55,58,61,65,69,73,77,82,87,92,97,103, 671 43,46,48,51,55,58,61,65,69,73,77,82,87,92,97,103,
672 110,116,123,130,138,146,155,164,174,184,195,207,220,233,246,5, 672 110,116,123,130,138,146,155,164,174,184,195,207,220,233,246,5,
673 21,37,55,73,93,113,135,159,184,210,237,11,42,75,110,147, 673 21,37,55,73,93,113,135,159,184,210,237,11,42,75,110,147,
674 186,227,15,62,112,164,219,0,0,0,0,0,0,0,0,0, 674 186,227,15,62,112,164,219,0,0,0,0,0,0,0,0,0,
675 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 675 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
676 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, 676 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,
677 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3, 677 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,
678 3,3,3,229,42,64,89,100,238,8,166,11,12,12,12,12, 678 3,3,3,229,42,64,89,100,238,8,166,11,12,12,12,12,
679 12,13,13,142,50,7,140,54,7,41,7,168,185,189,11,141, 679 12,13,13,142,50,7,140,54,7,41,7,168,185,189,11,141,
680 227,11,185,197,11,141,228,11,76,255,255,173,54,7,174,50, 680 227,11,185,197,11,141,228,11,76,255,255,173,54,7,174,50,
681 7,141,148,7,141,155,7,142,149,7,142,156,7,24,105,64, 681 7,141,148,7,141,155,7,142,149,7,142,156,7,24,105,64,
682 141,129,5,141,135,5,144,1,232,142,130,5,142,136,5,24, 682 141,129,5,141,135,5,144,1,232,142,130,5,142,136,5,24,
683 105,128,141,124,9,144,1,232,142,125,9,232,141,31,12,142, 683 105,128,141,124,9,144,1,232,142,125,9,232,141,31,12,142,
684 32,12,162,9,189,255,255,157,179,13,202,16,247,206,188,13, 684 32,12,162,9,189,255,255,157,179,13,202,16,247,206,188,13,
685 169,0,141,46,7,162,98,157,189,13,202,16,250,162,8,157, 685 169,0,141,46,7,162,98,157,189,13,202,16,250,162,8,157,
686 0,210,202,16,250,96,32,42,12,173,50,7,10,141,22,14, 686 0,210,202,16,250,96,32,42,12,173,50,7,10,141,22,14,
687 173,187,13,141,23,14,169,1,141,21,14,141,46,7,96,173, 687 173,187,13,141,23,14,169,1,141,21,14,141,46,7,96,173,
688 54,7,133,254,173,50,7,133,255,96,173,54,7,41,3,170, 688 54,7,133,254,173,50,7,133,255,96,173,54,7,41,3,170,
689 173,50,7,32,198,7,173,26,14,240,238,14,54,7,32,190, 689 173,50,7,32,198,7,173,26,14,240,238,14,54,7,32,190,
690 12,169,1,141,27,14,173,26,14,240,222,201,1,208,5,160, 690 12,169,1,141,27,14,173,26,14,240,222,201,1,208,5,160,
691 0,238,26,14,177,252,174,24,14,74,74,74,74,9,16,141, 691 0,238,26,14,177,252,174,24,14,74,74,74,74,9,16,141,
692 10,212,141,10,212,157,1,210,177,252,9,16,141,10,212,141, 692 10,212,141,10,212,157,1,210,177,252,9,16,141,10,212,141,
693 10,212,157,1,210,200,208,206,230,253,165,253,197,248,208,198, 693 10,212,157,1,210,200,208,206,230,253,165,253,197,248,208,198,
694 140,26,14,96,144,21,169,234,141,153,12,141,154,12,141,155, 694 140,26,14,96,144,21,169,234,141,153,12,141,154,12,141,155,
695 12,141,166,12,141,167,12,141,168,12,96,169,141,141,153,12, 695 12,141,166,12,141,167,12,141,168,12,96,169,141,141,153,12,
696 141,166,12,169,10,141,154,12,141,167,12,169,212,141,155,12, 696 141,166,12,169,10,141,154,12,141,167,12,169,212,141,155,12,
697 141,168,12,96,169,0,141,26,14,173,50,7,74,32,190,12, 697 141,168,12,96,169,0,141,26,14,173,50,7,74,32,190,12,
698 169,1,141,27,14,32,128,12,173,27,14,208,248,96,169,2, 698 169,1,141,27,14,32,128,12,173,27,14,208,248,96,169,2,
699 141,27,14,141,25,14,169,24,141,7,210,169,17,133,250,169, 699 141,27,14,141,25,14,169,24,141,7,210,169,17,133,250,169,
700 13,133,251,169,173,141,97,13,141,56,13,160,0,140,121,13, 700 13,133,251,169,173,141,97,13,141,56,13,160,0,140,121,13,
701 140,127,13,174,11,212,177,252,74,74,74,74,9,16,141,7, 701 140,127,13,174,11,212,177,252,74,74,74,74,9,16,141,7,
702 210,32,117,13,236,11,212,240,251,141,5,210,174,11,212,177, 702 210,32,117,13,236,11,212,240,251,141,5,210,174,11,212,177,
703 252,230,252,208,16,230,253,198,248,208,10,169,173,141,97,13, 703 252,230,252,208,16,230,253,198,248,208,10,169,173,141,97,13,
704 141,56,13,169,8,9,16,141,7,210,32,117,13,236,11,212, 704 141,56,13,169,8,9,16,141,7,210,32,117,13,236,11,212,
705 240,251,141,5,210,173,27,14,208,185,96,24,165,249,105,0, 705 240,251,141,5,210,173,27,14,208,185,96,24,165,249,105,0,
706 133,249,165,250,105,0,133,250,144,15,230,251,165,251,201,0, 706 133,249,165,250,105,0,133,250,144,15,230,251,165,251,201,0,
707 208,7,140,121,13,140,127,13,96,177,250,36,249,48,4,74, 707 208,7,140,121,13,140,127,13,96,177,250,36,249,48,4,74,
708 74,74,74,41,15,168,185,69,10,160,0,96,160,0,140,27, 708 74,74,74,41,15,168,185,69,10,160,0,96,160,0,140,27,
709 14,140,26,14,136,140,25,14,96 709 14,140,26,14,136,140,25,14,96
710END_CONST_ARRAY; 710END_CONST_ARRAY;
711CONST_ARRAY(byte, rmt4_obx) 711CONST_ARRAY(byte, rmt4_obx)
712 255,255,144,3,96,11,128,0,128,32,128,64,0,192,128,128, 712 255,255,144,3,96,11,128,0,128,32,128,64,0,192,128,128,
713 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, 713 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1,
714 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, 714 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1,
715 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, 715 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106,
716 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, 716 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82,
717 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, 717 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78,
718 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, 718 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127,
719 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, 719 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230,
720 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, 720 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92,
721 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, 721 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35,
722 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, 722 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13,
723 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, 723 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153,
724 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, 724 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60,
725 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, 725 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23,
726 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 726 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
727 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, 727 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144,
728 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, 728 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57,
729 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, 729 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22,
730 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, 730 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,
731 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, 731 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8,
732 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, 732 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3,
733 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, 733 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,
734 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 734 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
735 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 735 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
736 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 736 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
737 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, 737 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,
738 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, 738 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2,
739 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, 739 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2,
740 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, 740 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3,
741 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, 741 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4,
742 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, 742 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4,
743 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, 743 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5,
744 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, 744 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5,
745 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, 745 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6,
746 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, 746 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7,
747 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, 747 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7,
748 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, 748 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8,
749 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, 749 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8,
750 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, 750 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,
751 10,11,12,13,14,15,76,15,6,76,252,7,76,33,8,76, 751 10,11,12,13,14,15,76,15,6,76,252,7,76,33,8,76,
752 88,6,76,43,11,134,211,132,212,72,160,168,169,0,153,127, 752 88,6,76,43,11,134,211,132,212,72,160,168,169,0,153,127,
753 2,136,208,250,160,4,177,211,141,21,8,200,177,211,141,36, 753 2,136,208,250,160,4,177,211,141,21,8,200,177,211,141,36,
754 3,200,177,211,141,5,8,141,38,3,160,8,177,211,153,195, 754 3,200,177,211,141,5,8,141,38,3,160,8,177,211,153,195,
755 0,200,192,16,208,246,104,72,10,10,24,101,209,133,209,104, 755 0,200,192,16,208,246,104,72,10,10,24,101,209,133,209,104,
756 8,41,192,10,42,42,40,101,210,133,210,32,110,6,169,0, 756 8,41,192,10,42,42,40,101,210,133,210,32,110,6,169,0,
757 141,8,210,160,3,140,15,210,160,8,153,0,210,136,16,250, 757 141,8,210,160,3,140,15,210,160,8,153,0,210,136,16,250,
758 173,5,8,96,162,0,142,39,3,138,168,177,209,201,254,176, 758 173,5,8,96,162,0,142,39,3,138,168,177,209,201,254,176,
759 45,168,177,205,157,128,2,177,207,157,132,2,169,0,157,136, 759 45,168,177,205,157,128,2,177,207,157,132,2,169,0,157,136,
760 2,169,1,157,140,2,169,128,157,180,2,232,224,4,208,217, 760 2,169,1,157,140,2,169,128,157,180,2,232,224,4,208,217,
761 165,209,24,105,4,133,209,144,27,230,210,76,190,6,240,4, 761 165,209,24,105,4,133,209,144,27,230,210,76,190,6,240,4,
762 169,0,240,223,160,2,177,209,170,200,177,209,133,210,134,209, 762 169,0,240,223,160,2,177,209,170,200,177,209,133,210,134,209,
763 162,0,240,181,173,36,3,141,22,7,162,255,232,222,140,2, 763 162,0,240,181,173,36,3,141,22,7,162,255,232,222,140,2,
764 208,69,189,128,2,133,211,189,132,2,133,212,188,136,2,254, 764 208,69,189,128,2,133,211,189,132,2,133,212,188,136,2,254,
765 136,2,177,211,133,217,41,63,201,61,240,17,176,56,157,144, 765 136,2,177,211,133,217,41,63,201,61,240,17,176,56,157,144,
766 2,157,16,3,200,177,211,74,41,126,157,180,2,169,1,157, 766 2,157,16,3,200,177,211,74,41,126,157,180,2,169,1,157,
767 140,2,188,136,2,254,136,2,177,211,74,102,217,74,102,217, 767 140,2,188,136,2,254,136,2,177,211,74,102,217,74,102,217,
768 165,217,41,240,157,148,2,224,3,208,177,169,255,141,36,3, 768 165,217,41,240,157,148,2,224,3,208,177,169,255,141,36,3,
769 141,37,3,76,101,7,201,63,240,27,165,217,41,192,240,9, 769 141,37,3,76,101,7,201,63,240,27,165,217,41,192,240,9,
770 10,42,42,157,140,2,76,17,7,200,177,211,157,140,2,254, 770 10,42,42,157,140,2,76,17,7,200,177,211,157,140,2,254,
771 136,2,76,17,7,165,217,48,12,200,177,211,141,22,7,254, 771 136,2,76,17,7,165,217,48,12,200,177,211,141,22,7,254,
772 136,2,76,214,6,201,255,240,9,200,177,211,157,136,2,76, 772 136,2,76,214,6,201,255,240,9,200,177,211,157,136,2,76,
773 214,6,76,110,6,76,33,8,202,48,250,188,180,2,48,248, 773 214,6,76,110,6,76,33,8,202,48,250,188,180,2,48,248,
774 177,203,157,184,2,133,215,200,177,203,157,188,2,133,216,169, 774 177,203,157,184,2,133,215,200,177,203,157,188,2,133,216,169,
775 1,157,20,3,168,177,215,157,4,3,200,177,215,157,196,2, 775 1,157,20,3,168,177,215,157,4,3,200,177,215,157,196,2,
776 200,177,215,157,200,2,200,177,215,157,240,2,41,63,157,8, 776 200,177,215,157,200,2,200,177,215,157,240,2,41,63,157,8,
777 3,177,215,41,64,157,244,2,200,177,215,157,32,3,200,177, 777 3,177,215,41,64,157,244,2,200,177,215,157,32,3,200,177,
778 215,157,208,2,200,177,215,157,216,2,200,177,215,157,220,2, 778 215,157,208,2,200,177,215,157,216,2,200,177,215,157,220,2,
779 200,177,215,168,185,160,3,157,224,2,157,228,2,185,161,3, 779 200,177,215,168,185,160,3,157,224,2,157,228,2,185,161,3,
780 157,232,2,160,10,177,215,157,236,2,169,128,157,212,2,157, 780 157,232,2,160,10,177,215,157,236,2,169,128,157,212,2,157,
781 180,2,10,157,204,2,157,156,2,168,177,215,157,0,3,105, 781 180,2,10,157,204,2,157,156,2,168,177,215,157,0,3,105,
782 0,157,192,2,169,12,157,252,2,168,177,215,157,248,2,76, 782 0,157,192,2,169,12,157,252,2,168,177,215,157,248,2,76,
783 98,7,32,43,11,206,38,3,208,29,169,255,141,38,3,206, 783 98,7,32,43,11,206,38,3,208,29,169,255,141,38,3,206,
784 37,3,208,19,238,39,3,173,39,3,201,255,240,3,76,190, 784 37,3,208,19,238,39,3,173,39,3,201,255,240,3,76,190,
785 6,76,110,6,76,95,10,169,4,133,214,162,3,189,188,2, 785 6,76,110,6,76,95,10,169,4,133,214,162,3,189,188,2,
786 240,242,133,212,189,184,2,133,211,188,192,2,177,211,133,217, 786 240,242,133,212,189,184,2,133,211,188,192,2,177,211,133,217,
787 200,177,211,133,218,200,177,211,133,219,200,152,221,196,2,144, 787 200,177,211,133,218,200,177,211,133,219,200,152,221,196,2,144,
788 10,240,8,169,128,157,204,2,189,200,2,157,192,2,165,217, 788 10,240,8,169,128,157,204,2,189,200,2,157,192,2,165,217,
789 41,15,29,148,2,168,185,0,5,133,220,165,218,41,14,168, 789 41,15,29,148,2,168,185,0,5,133,220,165,218,41,14,168,
790 185,144,3,133,213,165,220,25,145,3,157,28,3,189,220,2, 790 185,144,3,133,213,165,220,25,145,3,157,28,3,189,220,2,
791 240,40,201,1,208,33,189,156,2,24,125,236,2,24,188,224, 791 240,40,201,1,208,33,189,156,2,24,125,236,2,24,188,224,
792 2,121,165,3,157,156,2,200,152,221,232,2,208,3,189,228, 792 2,121,165,3,157,156,2,200,152,221,232,2,208,3,189,228,
793 2,157,224,2,76,164,8,222,220,2,188,0,3,192,13,144, 793 2,157,224,2,76,164,8,222,220,2,188,0,3,192,13,144,
794 60,189,8,3,16,49,152,221,252,2,208,8,189,4,3,157, 794 60,189,8,3,16,49,152,221,252,2,208,8,189,4,3,157,
795 252,2,208,3,254,252,2,189,184,2,133,215,189,188,2,133, 795 252,2,208,3,254,252,2,189,184,2,133,215,189,188,2,133,
796 216,188,252,2,177,215,188,244,2,240,4,24,125,248,2,157, 796 216,188,252,2,177,215,188,244,2,240,4,24,125,248,2,157,
797 248,2,189,240,2,41,63,56,233,1,157,8,3,189,204,2, 797 248,2,189,240,2,41,63,56,233,1,157,8,3,189,204,2,
798 16,31,189,148,2,240,26,221,216,2,240,21,144,19,168,189, 798 16,31,189,148,2,240,26,221,216,2,240,21,144,19,168,189,
799 212,2,24,125,208,2,157,212,2,144,6,152,233,16,157,148, 799 212,2,24,125,208,2,157,212,2,144,6,152,233,16,157,148,
800 2,169,0,133,221,165,218,157,12,3,41,112,74,74,141,28, 800 2,169,0,133,221,165,218,157,12,3,41,112,74,74,141,28,
801 9,144,254,76,210,9,234,76,60,9,234,76,65,9,234,76, 801 9,144,254,76,210,9,234,76,60,9,234,76,65,9,234,76,
802 75,9,234,76,87,9,234,76,102,9,234,76,169,9,234,76, 802 75,9,234,76,87,9,234,76,102,9,234,76,169,9,234,76,
803 184,9,165,219,76,21,10,165,219,133,221,189,144,2,76,216, 803 184,9,165,219,76,21,10,165,219,133,221,189,144,2,76,216,
804 9,189,144,2,24,101,219,157,144,2,76,216,9,189,156,2, 804 9,189,144,2,24,101,219,157,144,2,76,216,9,189,156,2,
805 24,101,219,157,156,2,189,144,2,76,216,9,189,240,2,16, 805 24,101,219,157,156,2,189,144,2,76,216,9,189,240,2,16,
806 12,188,144,2,177,213,24,125,248,2,76,135,9,189,144,2, 806 12,188,144,2,177,213,24,125,248,2,76,135,9,189,144,2,
807 24,125,248,2,201,61,144,2,169,63,168,177,213,157,160,2, 807 24,125,248,2,201,61,144,2,169,63,168,177,213,157,160,2,
808 164,219,208,3,157,164,2,152,74,74,74,74,157,168,2,157, 808 164,219,208,3,157,164,2,152,74,74,74,74,157,168,2,157,
809 172,2,165,219,41,15,157,176,2,189,144,2,76,216,9,165, 809 172,2,165,219,41,15,157,176,2,189,144,2,76,216,9,165,
810 219,24,125,20,3,157,20,3,189,144,2,76,216,9,165,219, 810 219,24,125,20,3,157,20,3,189,144,2,76,216,9,165,219,
811 201,128,240,6,157,144,2,76,216,9,189,28,3,9,240,157, 811 201,128,240,6,157,144,2,76,216,9,189,28,3,9,240,157,
812 28,3,189,144,2,76,216,9,189,144,2,24,101,219,188,240, 812 28,3,189,144,2,76,216,9,189,144,2,24,101,219,188,240,
813 2,48,31,24,125,248,2,201,61,144,7,169,0,157,28,3, 813 2,48,31,24,125,248,2,201,61,144,7,169,0,157,28,3,
814 169,63,157,16,3,168,177,213,24,125,156,2,24,101,221,76, 814 169,63,157,16,3,168,177,213,24,125,156,2,24,101,221,76,
815 21,10,201,61,144,7,169,0,157,28,3,169,63,168,189,156, 815 21,10,201,61,144,7,169,0,157,28,3,169,63,168,189,156,
816 2,24,125,248,2,24,113,213,24,101,221,157,24,3,189,172, 816 2,24,125,248,2,24,113,213,24,101,221,157,24,3,189,172,
817 2,240,50,222,172,2,208,45,189,168,2,157,172,2,189,164, 817 2,240,50,222,172,2,208,45,189,168,2,157,172,2,189,164,
818 2,221,160,2,240,31,176,13,125,176,2,176,18,221,160,2, 818 2,221,160,2,240,31,176,13,125,176,2,176,18,221,160,2,
819 176,13,76,76,10,253,176,2,144,5,221,160,2,176,3,189, 819 176,13,76,76,10,253,176,2,144,5,221,160,2,176,3,189,
820 160,2,157,164,2,165,218,41,1,240,10,189,164,2,24,125, 820 160,2,157,164,2,165,218,41,1,240,10,189,164,2,24,125,
821 156,2,157,24,3,202,48,3,76,39,8,173,32,3,13,33, 821 156,2,157,24,3,202,48,3,76,39,8,173,32,3,13,33,
822 3,13,34,3,13,35,3,170,142,44,11,173,12,3,16,33, 822 3,13,34,3,13,35,3,170,142,44,11,173,12,3,16,33,
823 173,28,3,41,15,240,26,173,24,3,24,109,20,3,141,26, 823 173,28,3,41,15,240,26,173,24,3,24,109,20,3,141,26,
824 3,173,30,3,41,16,208,5,169,0,141,30,3,138,9,4, 824 3,173,30,3,41,16,208,5,169,0,141,30,3,138,9,4,
825 170,173,13,3,16,33,173,29,3,41,15,240,26,173,25,3, 825 170,173,13,3,16,33,173,29,3,41,15,240,26,173,25,3,
826 24,109,21,3,141,27,3,173,31,3,41,16,208,5,169,0, 826 24,109,21,3,141,27,3,173,31,3,41,16,208,5,169,0,
827 141,31,3,138,9,2,170,236,44,11,208,94,173,13,3,41, 827 141,31,3,138,9,2,170,236,44,11,208,94,173,13,3,41,
828 14,201,6,208,38,173,29,3,41,15,240,31,172,17,3,185, 828 14,201,6,208,38,173,29,3,41,15,240,31,172,17,3,185,
829 192,3,141,24,3,185,192,4,141,25,3,173,28,3,41,16, 829 192,3,141,24,3,185,192,4,141,25,3,173,28,3,41,16,
830 208,5,169,0,141,28,3,138,9,80,170,173,15,3,41,14, 830 208,5,169,0,141,28,3,138,9,80,170,173,15,3,41,14,
831 201,6,208,38,173,31,3,41,15,240,31,172,19,3,185,192, 831 201,6,208,38,173,31,3,41,15,240,31,172,19,3,185,192,
832 3,141,26,3,185,192,4,141,27,3,173,30,3,41,16,208, 832 3,141,26,3,185,192,4,141,27,3,173,30,3,41,16,208,
833 5,169,0,141,30,3,138,9,40,170,142,44,11,173,38,3, 833 5,169,0,141,30,3,138,9,40,170,142,44,11,173,38,3,
834 96,160,255,173,24,3,174,28,3,141,0,210,142,1,210,173, 834 96,160,255,173,24,3,174,28,3,141,0,210,142,1,210,173,
835 25,3,174,29,3,141,2,210,142,3,210,173,26,3,174,30, 835 25,3,174,29,3,141,2,210,142,3,210,173,26,3,174,30,
836 3,141,4,210,142,5,210,173,27,3,174,31,3,141,6,210, 836 3,141,4,210,142,5,210,173,27,3,174,31,3,141,6,210,
837 142,7,210,140,8,210,96 837 142,7,210,140,8,210,96
838END_CONST_ARRAY; 838END_CONST_ARRAY;
839CONST_ARRAY(byte, rmt8_obx) 839CONST_ARRAY(byte, rmt8_obx)
840 255,255,144,3,108,12,128,0,128,32,128,64,0,192,128,128, 840 255,255,144,3,108,12,128,0,128,32,128,64,0,192,128,128,
841 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, 841 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1,
842 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, 842 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1,
843 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, 843 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106,
844 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, 844 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82,
845 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, 845 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78,
846 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, 846 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127,
847 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, 847 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230,
848 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, 848 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92,
849 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, 849 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35,
850 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, 850 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13,
851 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, 851 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153,
852 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, 852 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60,
853 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, 853 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23,
854 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 854 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
855 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, 855 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144,
856 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, 856 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57,
857 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, 857 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22,
858 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, 858 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,
859 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, 859 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8,
860 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, 860 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3,
861 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, 861 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,
862 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 862 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
863 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 863 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
864 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 864 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
865 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, 865 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,
866 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, 866 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2,
867 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, 867 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2,
868 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, 868 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3,
869 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, 869 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4,
870 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, 870 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4,
871 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, 871 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5,
872 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, 872 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5,
873 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, 873 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6,
874 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, 874 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7,
875 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, 875 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7,
876 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, 876 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8,
877 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, 877 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8,
878 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, 878 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,
879 10,11,12,13,14,15,76,15,6,76,9,8,76,46,8,76, 879 10,11,12,13,14,15,76,15,6,76,9,8,76,46,8,76,
880 92,6,76,2,12,134,211,132,212,72,160,0,152,153,0,2, 880 92,6,76,2,12,134,211,132,212,72,160,0,152,153,0,2,
881 153,76,2,200,208,247,160,4,177,211,141,34,8,200,177,211, 881 153,76,2,200,208,247,160,4,177,211,141,34,8,200,177,211,
882 141,72,3,200,177,211,141,18,8,141,74,3,160,8,177,211, 882 141,72,3,200,177,211,141,18,8,141,74,3,160,8,177,211,
883 153,195,0,200,192,16,208,246,104,72,10,10,10,24,101,209, 883 153,195,0,200,192,16,208,246,104,72,10,10,10,24,101,209,
884 133,209,104,8,41,224,10,42,42,42,40,101,210,133,210,32, 884 133,209,104,8,41,224,10,42,42,42,40,101,210,133,210,32,
885 123,6,169,0,141,8,210,141,24,210,160,3,140,15,210,140, 885 123,6,169,0,141,8,210,141,24,210,160,3,140,15,210,140,
886 31,210,160,8,153,0,210,153,16,210,136,16,247,173,18,8, 886 31,210,160,8,153,0,210,153,16,210,136,16,247,173,18,8,
887 96,162,0,142,75,3,138,168,177,209,201,254,176,45,168,177, 887 96,162,0,142,75,3,138,168,177,209,201,254,176,45,168,177,
888 205,157,0,2,177,207,157,8,2,169,0,157,16,2,169,1, 888 205,157,0,2,177,207,157,8,2,169,0,157,16,2,169,1,
889 157,24,2,169,128,157,104,2,232,224,8,208,217,165,209,24, 889 157,24,2,169,128,157,104,2,232,224,8,208,217,165,209,24,
890 105,8,133,209,144,27,230,210,76,203,6,240,4,169,0,240, 890 105,8,133,209,144,27,230,210,76,203,6,240,4,169,0,240,
891 223,160,2,177,209,170,200,177,209,133,210,134,209,162,0,240, 891 223,160,2,177,209,170,200,177,209,133,210,134,209,162,0,240,
892 181,173,72,3,141,35,7,162,255,232,222,24,2,208,69,189, 892 181,173,72,3,141,35,7,162,255,232,222,24,2,208,69,189,
893 0,2,133,211,189,8,2,133,212,188,16,2,254,16,2,177, 893 0,2,133,211,189,8,2,133,212,188,16,2,254,16,2,177,
894 211,133,217,41,63,201,61,240,17,176,56,157,32,2,157,32, 894 211,133,217,41,63,201,61,240,17,176,56,157,32,2,157,32,
895 3,200,177,211,74,41,126,157,104,2,169,1,157,24,2,188, 895 3,200,177,211,74,41,126,157,104,2,169,1,157,24,2,188,
896 16,2,254,16,2,177,211,74,102,217,74,102,217,165,217,41, 896 16,2,254,16,2,177,211,74,102,217,74,102,217,165,217,41,
897 240,157,40,2,224,7,208,177,169,255,141,72,3,141,73,3, 897 240,157,40,2,224,7,208,177,169,255,141,72,3,141,73,3,
898 76,114,7,201,63,240,27,165,217,41,192,240,9,10,42,42, 898 76,114,7,201,63,240,27,165,217,41,192,240,9,10,42,42,
899 157,24,2,76,30,7,200,177,211,157,24,2,254,16,2,76, 899 157,24,2,76,30,7,200,177,211,157,24,2,254,16,2,76,
900 30,7,165,217,48,12,200,177,211,141,35,7,254,16,2,76, 900 30,7,165,217,48,12,200,177,211,141,35,7,254,16,2,76,
901 227,6,201,255,240,9,200,177,211,157,16,2,76,227,6,76, 901 227,6,201,255,240,9,200,177,211,157,16,2,76,227,6,76,
902 123,6,76,46,8,202,48,250,188,104,2,48,248,177,203,157, 902 123,6,76,46,8,202,48,250,188,104,2,48,248,177,203,157,
903 112,2,133,215,200,177,203,157,120,2,133,216,169,1,157,40, 903 112,2,133,215,200,177,203,157,120,2,133,216,169,1,157,40,
904 3,168,177,215,157,8,3,200,177,215,157,136,2,200,177,215, 904 3,168,177,215,157,8,3,200,177,215,157,136,2,200,177,215,
905 157,144,2,200,177,215,157,224,2,41,63,157,16,3,177,215, 905 157,144,2,200,177,215,157,224,2,41,63,157,16,3,177,215,
906 41,64,157,232,2,200,177,215,157,64,3,200,177,215,157,160, 906 41,64,157,232,2,200,177,215,157,64,3,200,177,215,157,160,
907 2,200,177,215,157,176,2,200,177,215,157,184,2,200,177,215, 907 2,200,177,215,157,176,2,200,177,215,157,184,2,200,177,215,
908 168,185,160,3,157,192,2,157,200,2,185,161,3,157,208,2, 908 168,185,160,3,157,192,2,157,200,2,185,161,3,157,208,2,
909 160,10,177,215,157,216,2,169,128,157,168,2,157,104,2,10, 909 160,10,177,215,157,216,2,169,128,157,168,2,157,104,2,10,
910 157,152,2,157,56,2,168,177,215,157,0,3,105,0,157,128, 910 157,152,2,157,56,2,168,177,215,157,0,3,105,0,157,128,
911 2,169,12,157,248,2,168,177,215,157,240,2,76,111,7,32, 911 2,169,12,157,248,2,168,177,215,157,240,2,76,111,7,32,
912 2,12,206,74,3,208,29,169,255,141,74,3,206,73,3,208, 912 2,12,206,74,3,208,29,169,255,141,74,3,206,73,3,208,
913 19,238,75,3,173,75,3,201,255,240,3,76,203,6,76,123, 913 19,238,75,3,173,75,3,201,255,240,3,76,203,6,76,123,
914 6,76,116,10,169,4,133,214,162,7,189,120,2,240,242,133, 914 6,76,116,10,169,4,133,214,162,7,189,120,2,240,242,133,
915 212,189,112,2,133,211,188,128,2,177,211,133,217,200,177,211, 915 212,189,112,2,133,211,188,128,2,177,211,133,217,200,177,211,
916 133,218,200,177,211,133,219,200,152,221,136,2,144,10,240,8, 916 133,218,200,177,211,133,219,200,152,221,136,2,144,10,240,8,
917 169,128,157,152,2,189,144,2,157,128,2,165,217,224,4,144, 917 169,128,157,152,2,189,144,2,157,128,2,165,217,224,4,144,
918 4,74,74,74,74,41,15,29,40,2,168,185,0,5,133,220, 918 4,74,74,74,74,41,15,29,40,2,168,185,0,5,133,220,
919 165,218,41,14,168,185,144,3,133,213,165,220,25,145,3,157, 919 165,218,41,14,168,185,144,3,133,213,165,220,25,145,3,157,
920 56,3,189,184,2,240,40,201,1,208,33,189,56,2,24,125, 920 56,3,189,184,2,240,40,201,1,208,33,189,56,2,24,125,
921 216,2,24,188,192,2,121,165,3,157,56,2,200,152,221,208, 921 216,2,24,188,192,2,121,165,3,157,56,2,200,152,221,208,
922 2,208,3,189,200,2,157,192,2,76,185,8,222,184,2,188, 922 2,208,3,189,200,2,157,192,2,76,185,8,222,184,2,188,
923 0,3,192,13,144,60,189,16,3,16,49,152,221,248,2,208, 923 0,3,192,13,144,60,189,16,3,16,49,152,221,248,2,208,
924 8,189,8,3,157,248,2,208,3,254,248,2,189,112,2,133, 924 8,189,8,3,157,248,2,208,3,254,248,2,189,112,2,133,
925 215,189,120,2,133,216,188,248,2,177,215,188,232,2,240,4, 925 215,189,120,2,133,216,188,248,2,177,215,188,232,2,240,4,
926 24,125,240,2,157,240,2,189,224,2,41,63,56,233,1,157, 926 24,125,240,2,157,240,2,189,224,2,41,63,56,233,1,157,
927 16,3,189,152,2,16,31,189,40,2,240,26,221,176,2,240, 927 16,3,189,152,2,16,31,189,40,2,240,26,221,176,2,240,
928 21,144,19,168,189,168,2,24,125,160,2,157,168,2,144,6, 928 21,144,19,168,189,168,2,24,125,160,2,157,168,2,144,6,
929 152,233,16,157,40,2,169,0,133,221,165,218,157,24,3,41, 929 152,233,16,157,40,2,169,0,133,221,165,218,157,24,3,41,
930 112,74,74,141,49,9,144,254,76,231,9,234,76,81,9,234, 930 112,74,74,141,49,9,144,254,76,231,9,234,76,81,9,234,
931 76,86,9,234,76,96,9,234,76,108,9,234,76,123,9,234, 931 76,86,9,234,76,96,9,234,76,108,9,234,76,123,9,234,
932 76,190,9,234,76,205,9,165,219,76,42,10,165,219,133,221, 932 76,190,9,234,76,205,9,165,219,76,42,10,165,219,133,221,
933 189,32,2,76,237,9,189,32,2,24,101,219,157,32,2,76, 933 189,32,2,76,237,9,189,32,2,24,101,219,157,32,2,76,
934 237,9,189,56,2,24,101,219,157,56,2,189,32,2,76,237, 934 237,9,189,56,2,24,101,219,157,56,2,189,32,2,76,237,
935 9,189,224,2,16,12,188,32,2,177,213,24,125,240,2,76, 935 9,189,224,2,16,12,188,32,2,177,213,24,125,240,2,76,
936 156,9,189,32,2,24,125,240,2,201,61,144,2,169,63,168, 936 156,9,189,32,2,24,125,240,2,201,61,144,2,169,63,168,
937 177,213,157,64,2,164,219,208,3,157,72,2,152,74,74,74, 937 177,213,157,64,2,164,219,208,3,157,72,2,152,74,74,74,
938 74,157,80,2,157,88,2,165,219,41,15,157,96,2,189,32, 938 74,157,80,2,157,88,2,165,219,41,15,157,96,2,189,32,
939 2,76,237,9,165,219,24,125,40,3,157,40,3,189,32,2, 939 2,76,237,9,165,219,24,125,40,3,157,40,3,189,32,2,
940 76,237,9,165,219,201,128,240,6,157,32,2,76,237,9,189, 940 76,237,9,165,219,201,128,240,6,157,32,2,76,237,9,189,
941 56,3,9,240,157,56,3,189,32,2,76,237,9,189,32,2, 941 56,3,9,240,157,56,3,189,32,2,76,237,9,189,32,2,
942 24,101,219,188,224,2,48,31,24,125,240,2,201,61,144,7, 942 24,101,219,188,224,2,48,31,24,125,240,2,201,61,144,7,
943 169,0,157,56,3,169,63,157,32,3,168,177,213,24,125,56, 943 169,0,157,56,3,169,63,157,32,3,168,177,213,24,125,56,
944 2,24,101,221,76,42,10,201,61,144,7,169,0,157,56,3, 944 2,24,101,221,76,42,10,201,61,144,7,169,0,157,56,3,
945 169,63,168,189,56,2,24,125,240,2,24,113,213,24,101,221, 945 169,63,168,189,56,2,24,125,240,2,24,113,213,24,101,221,
946 157,48,3,189,88,2,240,50,222,88,2,208,45,189,80,2, 946 157,48,3,189,88,2,240,50,222,88,2,208,45,189,80,2,
947 157,88,2,189,72,2,221,64,2,240,31,176,13,125,96,2, 947 157,88,2,189,72,2,221,64,2,240,31,176,13,125,96,2,
948 176,18,221,64,2,176,13,76,97,10,253,96,2,144,5,221, 948 176,18,221,64,2,176,13,76,97,10,253,96,2,144,5,221,
949 64,2,176,3,189,64,2,157,72,2,165,218,41,1,240,10, 949 64,2,176,3,189,64,2,157,72,2,165,218,41,1,240,10,
950 189,72,2,24,125,56,2,157,48,3,202,48,3,76,52,8, 950 189,72,2,24,125,56,2,157,48,3,202,48,3,76,52,8,
951 173,64,3,13,65,3,13,66,3,13,67,3,170,142,101,12, 951 173,64,3,13,65,3,13,66,3,13,67,3,170,142,101,12,
952 173,24,3,16,33,173,56,3,41,15,240,26,173,48,3,24, 952 173,24,3,16,33,173,56,3,41,15,240,26,173,48,3,24,
953 109,40,3,141,50,3,173,58,3,41,16,208,5,169,0,141, 953 109,40,3,141,50,3,173,58,3,41,16,208,5,169,0,141,
954 58,3,138,9,4,170,173,25,3,16,33,173,57,3,41,15, 954 58,3,138,9,4,170,173,25,3,16,33,173,57,3,41,15,
955 240,26,173,49,3,24,109,41,3,141,51,3,173,59,3,41, 955 240,26,173,49,3,24,109,41,3,141,51,3,173,59,3,41,
956 16,208,5,169,0,141,59,3,138,9,2,170,236,101,12,208, 956 16,208,5,169,0,141,59,3,138,9,2,170,236,101,12,208,
957 94,173,25,3,41,14,201,6,208,38,173,57,3,41,15,240, 957 94,173,25,3,41,14,201,6,208,38,173,57,3,41,15,240,
958 31,172,33,3,185,192,3,141,48,3,185,192,4,141,49,3, 958 31,172,33,3,185,192,3,141,48,3,185,192,4,141,49,3,
959 173,56,3,41,16,208,5,169,0,141,56,3,138,9,80,170, 959 173,56,3,41,16,208,5,169,0,141,56,3,138,9,80,170,
960 173,27,3,41,14,201,6,208,38,173,59,3,41,15,240,31, 960 173,27,3,41,14,201,6,208,38,173,59,3,41,15,240,31,
961 172,35,3,185,192,3,141,50,3,185,192,4,141,51,3,173, 961 172,35,3,185,192,3,141,50,3,185,192,4,141,51,3,173,
962 58,3,41,16,208,5,169,0,141,58,3,138,9,40,170,142, 962 58,3,41,16,208,5,169,0,141,58,3,138,9,40,170,142,
963 101,12,173,68,3,13,69,3,13,70,3,13,71,3,170,142, 963 101,12,173,68,3,13,69,3,13,70,3,13,71,3,170,142,
964 3,12,173,28,3,16,33,173,60,3,41,15,240,26,173,52, 964 3,12,173,28,3,16,33,173,60,3,41,15,240,26,173,52,
965 3,24,109,44,3,141,54,3,173,62,3,41,16,208,5,169, 965 3,24,109,44,3,141,54,3,173,62,3,41,16,208,5,169,
966 0,141,62,3,138,9,4,170,173,29,3,16,33,173,61,3, 966 0,141,62,3,138,9,4,170,173,29,3,16,33,173,61,3,
967 41,15,240,26,173,53,3,24,109,45,3,141,55,3,173,63, 967 41,15,240,26,173,53,3,24,109,45,3,141,55,3,173,63,
968 3,41,16,208,5,169,0,141,63,3,138,9,2,170,236,3, 968 3,41,16,208,5,169,0,141,63,3,138,9,2,170,236,3,
969 12,208,94,173,29,3,41,14,201,6,208,38,173,61,3,41, 969 12,208,94,173,29,3,41,14,201,6,208,38,173,61,3,41,
970 15,240,31,172,37,3,185,192,3,141,52,3,185,192,4,141, 970 15,240,31,172,37,3,185,192,3,141,52,3,185,192,4,141,
971 53,3,173,60,3,41,16,208,5,169,0,141,60,3,138,9, 971 53,3,173,60,3,41,16,208,5,169,0,141,60,3,138,9,
972 80,170,173,31,3,41,14,201,6,208,38,173,63,3,41,15, 972 80,170,173,31,3,41,14,201,6,208,38,173,63,3,41,15,
973 240,31,172,39,3,185,192,3,141,54,3,185,192,4,141,55, 973 240,31,172,39,3,185,192,3,141,54,3,185,192,4,141,55,
974 3,173,62,3,41,16,208,5,169,0,141,62,3,138,9,40, 974 3,173,62,3,41,16,208,5,169,0,141,62,3,138,9,40,
975 170,142,3,12,173,74,3,96,160,255,173,52,3,174,48,3, 975 170,142,3,12,173,74,3,96,160,255,173,52,3,174,48,3,
976 141,16,210,142,0,210,173,60,3,174,56,3,141,17,210,142, 976 141,16,210,142,0,210,173,60,3,174,56,3,141,17,210,142,
977 1,210,173,53,3,174,49,3,141,18,210,142,2,210,173,61, 977 1,210,173,53,3,174,49,3,141,18,210,142,2,210,173,61,
978 3,174,57,3,141,19,210,142,3,210,173,54,3,174,50,3, 978 3,174,57,3,141,19,210,142,3,210,173,54,3,174,50,3,
979 141,20,210,142,4,210,173,62,3,174,58,3,141,21,210,142, 979 141,20,210,142,4,210,173,62,3,174,58,3,141,21,210,142,
980 5,210,173,55,3,174,51,3,141,22,210,142,6,210,173,63, 980 5,210,173,55,3,174,51,3,141,22,210,142,6,210,173,63,
981 3,174,59,3,141,23,210,142,7,210,169,255,140,24,210,141, 981 3,174,59,3,141,23,210,142,7,210,169,255,140,24,210,141,
982 8,210,96 982 8,210,96
983END_CONST_ARRAY; 983END_CONST_ARRAY;
984CONST_ARRAY(byte, tmc_obx) 984CONST_ARRAY(byte, tmc_obx)
985 255,255,0,5,104,15,76,206,13,76,208,8,76,239,9,15, 985 255,255,0,5,104,15,76,206,13,76,208,8,76,239,9,15,
986 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 986 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
987 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 987 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
988 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 988 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
989 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 989 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
990 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1, 990 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,
991 1,1,0,0,0,0,1,1,1,1,1,1,1,1,2,2, 991 1,1,0,0,0,0,1,1,1,1,1,1,1,1,2,2,
992 2,2,0,0,0,1,1,1,1,1,2,2,2,2,2,3, 992 2,2,0,0,0,1,1,1,1,1,2,2,2,2,2,3,
993 3,3,0,0,1,1,1,1,2,2,2,2,3,3,3,3, 993 3,3,0,0,1,1,1,1,2,2,2,2,3,3,3,3,
994 4,4,0,0,1,1,1,2,2,2,3,3,3,4,4,4, 994 4,4,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
995 5,5,0,0,1,1,2,2,2,3,3,4,4,4,5,5, 995 5,5,0,0,1,1,2,2,2,3,3,4,4,4,5,5,
996 6,6,0,0,1,1,2,2,3,3,4,4,5,5,6,6, 996 6,6,0,0,1,1,2,2,3,3,4,4,5,5,6,6,
997 7,7,0,1,1,2,2,3,3,4,4,5,5,6,6,7, 997 7,7,0,1,1,2,2,3,3,4,4,5,5,6,6,7,
998 7,8,0,1,1,2,2,3,4,4,5,5,6,7,7,8, 998 7,8,0,1,1,2,2,3,4,4,5,5,6,7,7,8,
999 8,9,0,1,1,2,3,3,4,5,5,6,7,7,8,9, 999 8,9,0,1,1,2,3,3,4,5,5,6,7,7,8,9,
1000 9,10,0,1,1,2,3,4,4,5,6,7,7,8,9,10, 1000 9,10,0,1,1,2,3,4,4,5,6,7,7,8,9,10,
1001 10,11,0,1,2,2,3,4,5,6,6,7,8,9,10,10, 1001 10,11,0,1,2,2,3,4,5,6,6,7,8,9,10,10,
1002 11,12,0,1,2,3,3,4,5,6,7,8,9,10,10,11, 1002 11,12,0,1,2,3,3,4,5,6,7,8,9,10,10,11,
1003 12,13,0,1,2,3,4,5,6,7,7,8,9,10,11,12, 1003 12,13,0,1,2,3,4,5,6,7,7,8,9,10,11,12,
1004 13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13, 1004 13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13,
1005 14,15,0,241,228,215,203,192,181,170,161,152,143,135,127,120, 1005 14,15,0,241,228,215,203,192,181,170,161,152,143,135,127,120,
1006 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, 1006 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47,
1007 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, 1007 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18,
1008 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 1008 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
1009 1,0,0,242,230,218,206,191,182,170,161,152,143,137,128,122, 1009 1,0,0,242,230,218,206,191,182,170,161,152,143,137,128,122,
1010 113,107,101,95,92,86,80,77,71,68,62,60,56,53,50,47, 1010 113,107,101,95,92,86,80,77,71,68,62,60,56,53,50,47,
1011 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, 1011 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18,
1012 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 1012 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
1013 1,0,0,255,241,228,216,202,192,181,171,162,153,142,135,127, 1013 1,0,0,255,241,228,216,202,192,181,171,162,153,142,135,127,
1014 121,115,112,102,97,90,85,82,75,72,67,63,60,57,55,51, 1014 121,115,112,102,97,90,85,82,75,72,67,63,60,57,55,51,
1015 48,45,42,40,37,36,33,31,30,28,27,25,23,22,21,19, 1015 48,45,42,40,37,36,33,31,30,28,27,25,23,22,21,19,
1016 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3, 1016 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,
1017 2,1,0,243,230,217,204,193,181,173,162,153,144,136,128,121, 1017 2,1,0,243,230,217,204,193,181,173,162,153,144,136,128,121,
1018 114,108,102,96,91,85,81,76,72,68,64,60,57,53,50,47, 1018 114,108,102,96,91,85,81,76,72,68,64,60,57,53,50,47,
1019 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, 1019 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18,
1020 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, 1020 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,
1021 1,0,0,242,51,150,226,56,140,0,106,232,106,239,128,8, 1021 1,0,0,242,51,150,226,56,140,0,106,232,106,239,128,8,
1022 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, 1022 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200,
1023 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, 1023 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21,
1024 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, 1024 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106,
1025 100,94,0,13,13,12,11,11,10,10,9,8,8,7,7,7, 1025 100,94,0,13,13,12,11,11,10,10,9,8,8,7,7,7,
1026 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, 1026 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2,
1027 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, 1027 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,
1028 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1028 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1029 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1029 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1030 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1030 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1031 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1031 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1032 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1032 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1033 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1033 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1034 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1034 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1035 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1035 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1036 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1036 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1037 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1037 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1038 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1038 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1039 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1039 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1040 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1040 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1041 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1041 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1042 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1042 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1043 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1043 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1044 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, 1044 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,
1045 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, 1045 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16,
1046 0,8,0,16,0,8,173,183,8,240,94,173,182,8,201,64, 1046 0,8,0,16,0,8,173,183,8,240,94,173,182,8,201,64,
1047 144,90,206,181,8,240,3,76,239,9,162,7,169,0,157,196, 1047 144,90,206,181,8,240,3,76,239,9,162,7,169,0,157,196,
1048 7,157,204,7,202,16,247,141,182,8,170,160,15,177,254,16, 1048 7,157,204,7,202,16,247,141,182,8,170,160,15,177,254,16,
1049 32,136,177,254,16,3,76,95,14,134,252,10,10,38,252,10, 1049 32,136,177,254,16,3,76,95,14,134,252,10,10,38,252,10,
1050 38,252,10,38,252,105,0,133,254,165,252,105,0,133,255,144, 1050 38,252,10,38,252,105,0,133,254,165,252,105,0,133,255,144,
1051 218,157,212,7,136,177,254,157,220,7,232,136,16,207,24,165, 1051 218,157,212,7,136,177,254,157,220,7,232,136,16,207,24,165,
1052 254,105,16,133,254,144,2,230,255,76,239,9,206,181,8,16, 1052 254,105,16,133,254,144,2,230,255,76,239,9,206,181,8,16,
1053 248,238,182,8,173,180,8,141,181,8,162,7,222,204,7,48, 1053 248,238,182,8,173,180,8,141,181,8,162,7,222,204,7,48,
1054 3,76,233,9,188,212,7,185,255,255,133,252,185,255,255,133, 1054 3,76,233,9,188,212,7,185,255,255,133,252,185,255,255,133,
1055 253,188,196,7,177,252,208,6,32,109,13,76,230,9,201,64, 1055 253,188,196,7,177,252,208,6,32,109,13,76,230,9,201,64,
1056 176,18,125,220,7,157,228,7,32,109,13,188,42,5,32,188, 1056 176,18,125,220,7,157,228,7,32,109,13,188,42,5,32,188,
1057 14,76,230,9,208,34,200,254,196,7,177,252,16,7,133,251, 1057 14,76,230,9,208,34,200,254,196,7,177,252,16,7,133,251,
1058 32,109,13,165,251,41,127,208,7,169,64,141,182,8,208,76, 1058 32,109,13,165,251,41,127,208,7,169,64,141,182,8,208,76,
1059 141,180,8,141,181,8,208,68,201,128,176,43,41,63,125,220, 1059 141,180,8,141,181,8,208,68,201,128,176,43,41,63,125,220,
1060 7,157,228,7,200,254,196,7,177,252,41,127,208,7,169,64, 1060 7,157,228,7,200,254,196,7,177,252,41,127,208,7,169,64,
1061 141,182,8,208,6,141,180,8,141,181,8,32,109,13,188,42, 1061 141,182,8,208,6,141,180,8,141,181,8,32,109,13,188,42,
1062 5,32,188,14,76,230,9,201,192,176,12,41,63,157,42,5, 1062 5,32,188,14,76,230,9,201,192,176,12,41,63,157,42,5,
1063 200,254,196,7,76,94,9,41,63,157,204,7,254,196,7,202, 1063 200,254,196,7,76,94,9,41,63,157,204,7,254,196,7,202,
1064 48,3,76,70,9,162,7,189,188,7,240,33,32,46,11,189, 1064 48,3,76,70,9,162,7,189,188,7,240,33,32,46,11,189,
1065 50,5,61,192,8,240,22,160,71,177,252,24,125,34,5,157, 1065 50,5,61,192,8,240,22,160,71,177,252,24,125,34,5,157,
1066 36,5,168,185,60,6,56,125,100,8,157,246,7,202,16,215, 1066 36,5,168,185,60,6,56,125,100,8,157,246,7,202,16,215,
1067 14,9,5,14,9,5,14,9,5,14,9,5,232,134,252,134, 1067 14,9,5,14,9,5,14,9,5,14,9,5,232,134,252,134,
1068 253,162,7,138,168,185,252,7,208,12,188,184,8,185,4,8, 1068 253,162,7,138,168,185,252,7,208,12,188,184,8,185,4,8,
1069 208,4,138,168,169,0,133,250,152,157,26,5,185,244,7,157, 1069 208,4,138,168,169,0,133,250,152,157,26,5,185,244,7,157,
1070 18,5,185,50,5,133,251,5,253,133,253,165,251,61,192,8, 1070 18,5,185,50,5,133,251,5,253,133,253,165,251,61,192,8,
1071 240,6,185,246,7,157,20,5,165,251,61,200,8,240,18,185, 1071 240,6,185,246,7,157,20,5,165,251,61,200,8,240,18,185,
1072 34,5,41,63,168,200,132,252,185,123,7,157,18,5,76,137, 1072 34,5,41,63,168,200,132,252,185,123,7,157,18,5,76,137,
1073 10,164,252,240,10,185,59,7,157,18,5,169,0,133,252,165, 1073 10,164,252,240,10,185,59,7,157,18,5,169,0,133,252,165,
1074 250,13,9,5,168,185,60,5,188,26,5,25,236,7,157,10, 1074 250,13,9,5,168,185,60,5,188,26,5,25,236,7,157,10,
1075 5,224,4,208,9,165,253,141,59,5,169,0,133,253,202,16, 1075 5,224,4,208,9,165,253,141,59,5,169,0,133,253,202,16,
1076 130,78,9,5,78,9,5,78,9,5,78,9,5,165,253,162, 1076 130,78,9,5,78,9,5,78,9,5,78,9,5,165,253,162,
1077 3,142,31,210,142,15,210,174,22,5,172,18,5,142,16,210, 1077 3,142,31,210,142,15,210,174,22,5,172,18,5,142,16,210,
1078 140,0,210,174,14,5,172,10,5,142,17,210,140,1,210,174, 1078 140,0,210,174,14,5,172,10,5,142,17,210,140,1,210,174,
1079 23,5,172,19,5,142,18,210,140,2,210,174,15,5,172,11, 1079 23,5,172,19,5,142,18,210,140,2,210,174,15,5,172,11,
1080 5,142,19,210,140,3,210,174,24,5,172,20,5,142,20,210, 1080 5,142,19,210,140,3,210,174,24,5,172,20,5,142,20,210,
1081 140,4,210,174,16,5,172,12,5,142,21,210,140,5,210,174, 1081 140,4,210,174,16,5,172,12,5,142,21,210,140,5,210,174,
1082 25,5,172,21,5,142,22,210,140,6,210,174,17,5,172,13, 1082 25,5,172,21,5,142,22,210,140,6,210,174,17,5,172,13,
1083 5,142,23,210,140,7,210,141,58,5,174,59,5,142,24,210, 1083 5,142,23,210,140,7,210,141,58,5,174,59,5,142,24,210,
1084 141,8,210,96,189,28,8,133,252,189,36,8,133,253,188,44, 1084 141,8,210,96,189,28,8,133,252,189,36,8,133,253,188,44,
1085 8,192,63,240,123,254,44,8,254,44,8,254,44,8,177,252, 1085 8,192,63,240,123,254,44,8,254,44,8,254,44,8,177,252,
1086 41,240,157,236,7,177,252,41,15,56,253,12,8,16,2,169, 1086 41,240,157,236,7,177,252,41,15,56,253,12,8,16,2,169,
1087 0,157,252,7,200,177,252,41,15,56,253,20,8,16,2,169, 1087 0,157,252,7,200,177,252,41,15,56,253,20,8,16,2,169,
1088 0,157,4,8,177,252,41,240,240,116,16,11,160,73,177,252, 1088 0,157,4,8,177,252,41,240,240,116,16,11,160,73,177,252,
1089 188,44,8,136,136,16,2,169,0,157,50,5,177,252,41,112, 1089 188,44,8,136,136,16,2,169,0,157,50,5,177,252,41,112,
1090 240,99,74,74,141,154,11,169,0,157,100,8,200,177,252,144, 1090 240,99,74,74,141,154,11,169,0,157,100,8,200,177,252,144,
1091 254,234,234,234,234,76,56,13,234,76,53,13,234,76,60,13, 1091 254,234,234,234,234,76,56,13,234,76,53,13,234,76,60,13,
1092 234,76,74,13,234,76,84,13,234,76,95,13,234,76,81,13, 1092 234,76,74,13,234,76,84,13,234,76,95,13,234,76,81,13,
1093 189,52,8,240,18,222,68,8,208,13,157,68,8,189,252,7, 1093 189,52,8,240,18,222,68,8,208,13,157,68,8,189,252,7,
1094 41,15,240,3,222,252,7,189,60,8,240,18,222,76,8,208, 1094 41,15,240,3,222,252,7,189,60,8,240,18,222,76,8,208,
1095 13,157,76,8,189,4,8,41,15,240,3,222,4,8,160,72, 1095 13,157,76,8,189,4,8,41,15,240,3,222,4,8,160,72,
1096 177,252,157,50,5,189,148,8,24,105,63,168,177,252,125,228, 1096 177,252,157,50,5,189,148,8,24,105,63,168,177,252,125,228,
1097 7,157,34,5,168,185,60,6,157,244,7,222,164,8,16,51, 1097 7,157,34,5,168,185,60,6,157,244,7,222,164,8,16,51,
1098 189,156,8,157,164,8,189,172,8,240,24,24,125,148,8,157, 1098 189,156,8,157,164,8,189,172,8,240,24,24,125,148,8,157,
1099 148,8,240,7,221,140,8,208,26,169,254,24,105,1,157,172, 1099 148,8,240,7,221,140,8,208,26,169,254,24,105,1,157,172,
1100 8,208,16,254,148,8,189,140,8,221,148,8,176,5,169,0, 1100 8,208,16,254,148,8,189,140,8,221,148,8,176,5,169,0,
1101 157,148,8,189,116,8,240,4,222,116,8,96,189,108,8,133, 1101 157,148,8,189,116,8,240,4,222,116,8,96,189,108,8,133,
1102 250,189,92,8,133,251,32,105,12,222,132,8,16,16,165,250, 1102 250,189,92,8,133,251,32,105,12,222,132,8,16,16,165,250,
1103 157,108,8,165,251,157,92,8,189,124,8,157,132,8,96,189, 1103 157,108,8,165,251,157,92,8,189,124,8,157,132,8,96,189,
1104 84,8,141,112,12,16,254,76,167,12,234,76,144,12,234,76, 1104 84,8,141,112,12,16,254,76,167,12,234,76,144,12,234,76,
1105 174,12,234,76,180,12,234,76,190,12,234,76,210,12,234,76, 1105 174,12,234,76,180,12,234,76,190,12,234,76,210,12,234,76,
1106 226,12,234,76,244,12,165,250,230,250,41,3,74,144,15,208, 1106 226,12,234,76,244,12,165,250,230,250,41,3,74,144,15,208,
1107 71,165,251,157,100,8,24,125,244,7,157,244,7,96,169,0, 1107 71,165,251,157,100,8,24,125,244,7,157,244,7,96,169,0,
1108 157,100,8,96,32,29,13,76,157,12,32,29,13,24,125,34, 1108 157,100,8,96,32,29,13,76,157,12,32,29,13,24,125,34,
1109 5,76,84,13,165,250,157,100,8,24,125,244,7,157,244,7, 1109 5,76,84,13,165,250,157,100,8,24,125,244,7,157,244,7,
1110 165,250,24,101,251,133,250,96,189,34,5,56,229,250,157,34, 1110 165,250,24,101,251,133,250,96,189,34,5,56,229,250,157,34,
1111 5,168,185,60,6,76,199,12,189,244,7,56,229,251,157,244, 1111 5,168,185,60,6,76,199,12,189,244,7,56,229,251,157,244,
1112 7,56,169,0,229,251,157,100,8,96,189,132,8,208,174,165, 1112 7,56,169,0,229,251,157,100,8,96,189,132,8,208,174,165,
1113 251,16,16,189,4,8,240,165,189,252,7,201,15,240,158,254, 1113 251,16,16,189,4,8,240,165,189,252,7,201,15,240,158,254,
1114 252,7,96,189,252,7,240,149,189,4,8,201,15,240,142,254, 1114 252,7,96,189,252,7,240,149,189,4,8,201,15,240,142,254,
1115 4,8,96,164,250,165,251,48,2,200,200,136,152,133,250,197, 1115 4,8,96,164,250,165,251,48,2,200,200,136,152,133,250,197,
1116 251,208,6,165,251,73,255,133,251,152,96,125,244,7,157,244, 1116 251,208,6,165,251,73,255,133,251,152,96,125,244,7,157,244,
1117 7,96,188,228,7,121,60,6,157,244,7,152,157,34,5,96, 1117 7,96,188,228,7,121,60,6,157,244,7,152,157,34,5,96,
1118 45,10,210,157,244,7,96,125,228,7,157,34,5,168,185,60, 1118 45,10,210,157,244,7,96,125,228,7,157,34,5,168,185,60,
1119 6,157,244,7,96,157,34,5,168,189,244,7,121,60,6,157, 1119 6,157,244,7,96,157,34,5,168,189,244,7,121,60,6,157,
1120 244,7,96,200,254,196,7,177,252,74,74,74,74,157,12,8, 1120 244,7,96,200,254,196,7,177,252,74,74,74,74,157,12,8,
1121 177,252,41,15,157,20,8,96,32,95,14,160,15,169,0,133, 1121 177,252,41,15,157,20,8,96,32,95,14,160,15,169,0,133,
1122 254,169,0,133,255,138,240,46,177,254,16,1,202,24,165,254, 1122 254,169,0,133,255,138,240,46,177,254,16,1,202,24,165,254,
1123 105,16,133,254,144,239,230,255,176,235,32,95,14,169,0,133, 1123 105,16,133,254,144,239,230,255,176,235,32,95,14,169,0,133,
1124 252,138,10,10,38,252,10,38,252,10,38,252,105,0,133,254, 1124 252,138,10,10,38,252,10,38,252,10,38,252,105,0,133,254,
1125 165,252,105,0,133,255,169,64,141,182,8,169,1,141,181,8, 1125 165,252,105,0,133,255,169,64,141,182,8,169,1,141,181,8,
1126 141,183,8,96,201,16,144,176,201,32,144,206,201,48,176,3, 1126 141,183,8,96,201,16,144,176,201,32,144,206,201,48,176,3,
1127 76,174,14,201,64,176,9,138,41,15,240,3,141,180,8,96, 1127 76,174,14,201,64,176,9,138,41,15,240,3,141,180,8,96,
1128 201,80,144,113,201,96,176,6,169,0,141,183,8,96,201,112, 1128 201,80,144,113,201,96,176,6,169,0,141,183,8,96,201,112,
1129 144,248,169,1,141,181,8,169,64,141,182,8,132,252,134,253, 1129 144,248,169,1,141,181,8,169,64,141,182,8,132,252,134,253,
1130 160,30,177,252,141,180,8,165,252,24,105,32,141,194,14,144, 1130 160,30,177,252,141,180,8,165,252,24,105,32,141,194,14,144,
1131 1,232,142,195,14,24,105,64,141,202,14,144,1,232,142,203, 1131 1,232,142,195,14,24,105,64,141,202,14,144,1,232,142,203,
1132 14,24,105,64,141,82,9,144,1,232,142,83,9,24,105,128, 1132 14,24,105,64,141,82,9,144,1,232,142,83,9,24,105,128,
1133 141,87,9,144,1,232,142,88,9,24,105,128,133,254,141,16, 1133 141,87,9,144,1,232,142,88,9,24,105,128,133,254,141,16,
1134 9,141,136,13,141,183,13,144,1,232,134,255,142,22,9,142, 1134 9,141,136,13,141,183,13,144,1,232,134,255,142,22,9,142,
1135 140,13,142,189,13,160,7,169,0,141,183,8,153,0,210,153, 1135 140,13,142,189,13,160,7,169,0,141,183,8,153,0,210,153,
1136 16,210,153,10,5,153,252,7,153,4,8,153,50,5,153,188, 1136 16,210,153,10,5,153,252,7,153,4,8,153,50,5,153,188,
1137 7,136,16,232,141,8,210,141,24,210,141,58,5,141,59,5, 1137 7,136,16,232,141,8,210,141,24,210,141,58,5,141,59,5,
1138 96,157,252,7,157,4,8,157,50,5,189,228,7,157,34,5, 1138 96,157,252,7,157,4,8,157,50,5,189,228,7,157,34,5,
1139 96,152,73,240,74,74,74,74,157,12,8,152,41,15,73,15, 1139 96,152,73,240,74,74,74,74,157,12,8,152,41,15,73,15,
1140 157,20,8,96,41,7,133,252,138,166,252,41,63,240,226,157, 1140 157,20,8,96,41,7,133,252,138,166,252,41,63,240,226,157,
1141 228,7,169,0,157,188,7,185,255,255,157,28,8,133,252,185, 1141 228,7,169,0,157,188,7,185,255,255,157,28,8,133,252,185,
1142 255,255,157,36,8,133,253,5,252,240,182,160,74,177,252,157, 1142 255,255,157,36,8,133,253,5,252,240,182,160,74,177,252,157,
1143 52,8,157,68,8,200,177,252,157,60,8,157,76,8,200,177, 1143 52,8,157,68,8,200,177,252,157,60,8,157,76,8,200,177,
1144 252,41,112,74,74,157,84,8,177,252,41,15,157,92,8,177, 1144 252,41,112,74,74,157,84,8,177,252,41,15,157,92,8,177,
1145 252,16,11,189,92,8,73,255,24,105,1,157,92,8,200,177, 1145 252,16,11,189,92,8,73,255,24,105,1,157,92,8,200,177,
1146 252,157,116,8,200,177,252,41,63,157,124,8,157,132,8,200, 1146 252,157,116,8,200,177,252,41,63,157,124,8,157,132,8,200,
1147 177,252,41,128,240,2,169,1,157,172,8,177,252,41,112,74, 1147 177,252,41,128,240,2,169,1,157,172,8,177,252,41,112,74,
1148 74,74,74,157,140,8,208,3,157,172,8,177,252,41,15,157, 1148 74,74,74,157,140,8,208,3,157,172,8,177,252,41,15,157,
1149 156,8,157,164,8,136,177,252,41,192,24,125,228,7,157,228, 1149 156,8,157,164,8,136,177,252,41,192,24,125,228,7,157,228,
1150 7,157,34,5,168,185,60,6,157,244,7,169,0,157,44,8, 1150 7,157,34,5,168,185,60,6,157,244,7,169,0,157,44,8,
1151 157,100,8,157,108,8,157,148,8,169,1,157,188,7,96 1151 157,100,8,157,108,8,157,148,8,169,1,157,188,7,96
1152END_CONST_ARRAY; 1152END_CONST_ARRAY;
1153CONST_ARRAY(byte, tm2_obx) 1153CONST_ARRAY(byte, tm2_obx)
1154 255,255,0,2,107,16,0,0,0,0,0,0,0,0,0,0, 1154 255,255,0,2,107,16,0,0,0,0,0,0,0,0,0,0,
1155 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 1155 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1156 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, 1156 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,
1157 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, 1157 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2,
1158 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, 1158 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2,
1159 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, 1159 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3,
1160 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, 1160 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4,
1161 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, 1161 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4,
1162 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, 1162 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5,
1163 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, 1163 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5,
1164 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, 1164 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6,
1165 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, 1165 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7,
1166 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, 1166 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7,
1167 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, 1167 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8,
1168 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, 1168 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8,
1169 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, 1169 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9,
1170 10,11,12,13,14,15,0,241,228,215,203,192,181,170,161,152, 1170 10,11,12,13,14,15,0,241,228,215,203,192,181,170,161,152,
1171 143,135,127,120,114,107,101,95,90,85,80,75,71,67,63,60, 1171 143,135,127,120,114,107,101,95,90,85,80,75,71,67,63,60,
1172 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, 1172 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23,
1173 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 1173 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
1174 5,4,3,2,1,0,0,242,233,218,206,191,182,170,161,152, 1174 5,4,3,2,1,0,0,242,233,218,206,191,182,170,161,152,
1175 143,137,128,122,113,107,101,95,92,86,80,77,71,68,62,60, 1175 143,137,128,122,113,107,101,95,92,86,80,77,71,68,62,60,
1176 56,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, 1176 56,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,
1177 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 1177 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
1178 5,4,3,2,1,0,0,255,241,228,216,202,192,181,171,162, 1178 5,4,3,2,1,0,0,255,241,228,216,202,192,181,171,162,
1179 153,142,135,127,121,115,112,102,97,90,85,82,75,72,67,63, 1179 153,142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,
1180 60,57,55,51,48,45,42,40,37,36,33,31,30,28,27,25, 1180 60,57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,
1181 23,22,21,19,18,17,16,15,14,13,12,11,10,9,8,7, 1181 23,22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,
1182 6,5,4,3,2,1,0,243,230,217,204,193,181,173,162,153, 1182 6,5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,
1183 144,136,128,121,114,108,102,96,91,85,81,76,72,68,64,60, 1183 144,136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,
1184 57,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, 1184 57,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,
1185 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, 1185 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,
1186 5,4,3,2,1,0,226,56,140,0,106,232,106,239,128,8, 1186 5,4,3,2,1,0,226,56,140,0,106,232,106,239,128,8,
1187 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, 1187 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200,
1188 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, 1188 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21,
1189 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, 1189 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106,
1190 100,94,87,82,50,10,0,242,51,150,226,56,140,0,106,232, 1190 100,94,87,82,50,10,0,242,51,150,226,56,140,0,106,232,
1191 106,239,128,8,174,70,230,149,65,246,176,110,48,246,187,132, 1191 106,239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,
1192 82,34,244,200,160,122,85,52,20,245,216,189,164,141,119,96, 1192 82,34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,
1193 78,56,39,21,6,247,232,219,207,195,184,172,162,154,144,136, 1193 78,56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,
1194 127,120,112,106,100,94,11,11,10,10,9,8,8,7,7,7, 1194 127,120,112,106,100,94,11,11,10,10,9,8,8,7,7,7,
1195 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, 1195 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2,
1196 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, 1196 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,
1197 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1197 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1198 0,0,0,0,0,0,0,13,13,12,11,11,10,10,9,8, 1198 0,0,0,0,0,0,0,13,13,12,11,11,10,10,9,8,
1199 8,7,7,7,6,6,5,5,5,4,4,4,4,3,3,3, 1199 8,7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,
1200 3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1, 1200 3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,
1201 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0, 1201 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
1202 0,0,0,0,0,0,76,228,13,76,227,6,76,159,8,1, 1202 0,0,0,0,0,0,76,228,13,76,227,6,76,159,8,1,
1203 16,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1203 16,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1204 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1204 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1205 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1205 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1206 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1206 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1207 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1207 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1208 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1208 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1209 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1209 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1210 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1210 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1211 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1211 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1212 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1212 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1213 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1213 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1215 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1215 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1216 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1216 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1217 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1217 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1218 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1218 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1219 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1219 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1220 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1220 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1221 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1221 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1222 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1222 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1223 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1223 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1224 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1224 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1225 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1225 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1226 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1226 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1227 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, 1227 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,
1228 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, 1228 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16,
1229 0,8,0,16,0,8,133,211,129,169,133,211,129,169,136,177, 1229 0,8,0,16,0,8,133,211,129,169,133,211,129,169,136,177,
1230 250,141,23,5,162,0,134,252,10,38,252,10,38,252,10,38, 1230 250,141,23,5,162,0,134,252,10,38,252,10,38,252,10,38,
1231 252,10,38,252,109,23,5,144,2,230,252,24,105,0,133,250, 1231 252,10,38,252,109,23,5,144,2,230,252,24,105,0,133,250,
1232 165,252,105,0,133,251,76,7,7,32,181,9,173,22,5,240, 1232 165,252,105,0,133,251,76,7,7,32,181,9,173,22,5,240,
1233 5,206,28,5,48,3,76,162,8,206,29,5,208,82,162,0, 1233 5,206,28,5,48,3,76,162,8,206,29,5,208,82,162,0,
1234 238,23,5,173,25,5,133,250,173,26,5,133,251,160,16,177, 1234 238,23,5,173,25,5,133,250,173,26,5,133,251,160,16,177,
1235 250,48,171,208,3,76,44,15,141,29,5,136,177,250,136,132, 1235 250,48,171,208,3,76,44,15,141,29,5,136,177,250,136,132,
1236 252,168,185,255,255,157,80,5,185,255,255,157,88,5,169,0, 1236 252,168,185,255,255,157,80,5,185,255,255,157,88,5,169,0,
1237 157,112,5,157,96,5,164,252,177,250,157,104,5,232,136,16, 1237 157,112,5,157,96,5,164,252,177,250,157,104,5,232,136,16,
1238 219,169,17,24,101,250,141,25,5,169,0,101,251,141,26,5, 1238 219,169,17,24,101,250,141,25,5,169,0,101,251,141,26,5,
1239 173,27,5,141,28,5,162,7,222,112,5,48,6,202,16,248, 1239 173,27,5,141,28,5,162,7,222,112,5,48,6,202,16,248,
1240 76,162,8,189,80,5,133,250,189,88,5,133,251,188,96,5, 1240 76,162,8,189,80,5,133,250,189,88,5,133,251,188,96,5,
1241 177,250,208,28,200,177,250,157,208,5,41,240,157,216,5,177, 1241 177,250,208,28,200,177,250,157,208,5,41,240,157,216,5,177,
1242 250,10,10,10,10,157,224,5,200,152,157,96,5,76,87,7, 1242 250,10,10,10,10,157,224,5,200,152,157,96,5,76,87,7,
1243 201,64,176,79,125,104,5,157,152,5,200,177,250,16,37,41, 1243 201,64,176,79,125,104,5,157,152,5,200,177,250,16,37,41,
1244 127,133,252,200,177,250,157,208,5,41,240,157,216,5,177,250, 1244 127,133,252,200,177,250,157,208,5,41,240,157,216,5,177,250,
1245 10,10,10,10,157,224,5,200,152,157,96,5,164,252,32,156, 1245 10,10,10,10,157,224,5,200,152,157,96,5,164,252,32,156,
1246 15,76,87,7,168,254,96,5,254,96,5,189,208,5,41,240, 1246 15,76,87,7,168,254,96,5,254,96,5,189,208,5,41,240,
1247 157,216,5,189,208,5,10,10,10,10,157,224,5,32,156,15, 1247 157,216,5,189,208,5,10,10,10,10,157,224,5,32,156,15,
1248 76,87,7,201,128,176,37,41,63,24,125,104,5,157,152,5, 1248 76,87,7,201,128,176,37,41,63,24,125,104,5,157,152,5,
1249 200,177,250,157,208,5,41,240,157,216,5,177,250,10,10,10, 1249 200,177,250,157,208,5,41,240,157,216,5,177,250,10,10,10,
1250 10,157,224,5,200,152,157,96,5,76,87,7,208,14,200,177, 1250 10,157,224,5,200,152,157,96,5,76,87,7,208,14,200,177,
1251 250,157,112,5,200,152,157,96,5,76,87,7,201,192,176,15, 1251 250,157,112,5,200,152,157,96,5,76,87,7,201,192,176,15,
1252 41,63,24,125,104,5,157,152,5,254,96,5,76,87,7,201, 1252 41,63,24,125,104,5,157,152,5,254,96,5,76,87,7,201,
1253 208,176,15,200,254,96,5,41,15,141,27,5,141,28,5,76, 1253 208,176,15,200,254,96,5,41,15,141,27,5,141,28,5,76,
1254 106,7,201,224,176,22,177,250,133,252,200,177,250,133,253,200, 1254 106,7,201,224,176,22,177,250,133,252,200,177,250,133,253,200,
1255 152,157,96,5,165,252,32,14,14,76,87,7,201,240,176,46, 1255 152,157,96,5,165,252,32,14,14,76,87,7,201,240,176,46,
1256 177,250,133,252,200,177,250,133,253,165,252,32,14,14,188,96, 1256 177,250,133,252,200,177,250,133,253,165,252,32,14,14,188,96,
1257 5,200,200,177,250,157,208,5,41,240,157,216,5,177,250,10, 1257 5,200,200,177,250,157,208,5,41,240,157,216,5,177,250,10,
1258 10,10,10,157,224,5,200,152,157,96,5,76,87,7,201,255, 1258 10,10,10,157,224,5,200,152,157,96,5,76,87,7,201,255,
1259 176,11,233,239,157,112,5,254,96,5,76,87,7,169,64,157, 1259 176,11,233,239,157,112,5,254,96,5,76,87,7,169,64,157,
1260 112,5,76,87,7,32,181,9,162,7,189,120,5,240,115,76, 1260 112,5,76,87,7,32,181,9,162,7,189,120,5,240,115,76,
1261 217,10,189,14,5,240,14,169,0,157,32,5,157,40,5,202, 1261 217,10,189,14,5,240,14,169,0,157,32,5,157,40,5,202,
1262 16,232,76,31,9,164,253,185,0,3,24,101,252,157,56,5, 1262 16,232,76,31,9,164,253,185,0,3,24,101,252,157,56,5,
1263 152,157,160,5,189,176,5,61,168,6,240,40,165,253,41,127, 1263 152,157,160,5,189,176,5,61,168,6,240,40,165,253,41,127,
1264 168,185,0,4,24,101,252,157,55,5,185,128,4,105,0,157, 1264 168,185,0,4,24,101,252,157,55,5,185,128,4,105,0,157,
1265 56,5,169,0,157,31,5,188,152,6,153,39,5,202,202,16, 1265 56,5,169,0,157,31,5,188,152,6,153,39,5,202,202,16,
1266 169,76,31,9,189,176,5,61,160,6,240,22,189,104,6,24, 1266 169,76,31,9,189,176,5,61,160,6,240,22,189,104,6,24,
1267 101,253,157,162,5,168,185,0,3,24,101,252,56,101,254,157, 1267 101,253,157,162,5,168,185,0,3,24,101,252,56,101,254,157,
1268 58,5,202,16,133,232,134,252,162,3,173,9,5,240,6,41, 1268 58,5,202,16,133,232,134,252,162,3,173,9,5,240,6,41,
1269 64,208,60,162,7,138,168,185,32,5,208,12,188,152,6,185, 1269 64,208,60,162,7,138,168,185,32,5,208,12,188,152,6,185,
1270 40,5,208,4,138,168,169,0,25,168,5,157,48,5,185,56, 1270 40,5,208,4,138,168,169,0,25,168,5,157,48,5,185,56,
1271 5,157,72,5,185,160,5,157,64,5,185,176,5,5,252,133, 1271 5,157,72,5,185,160,5,157,64,5,185,176,5,5,252,133,
1272 252,224,4,208,3,141,31,5,202,16,202,141,30,5,96,189, 1272 252,224,4,208,3,141,31,5,202,16,202,141,30,5,96,189,
1273 32,5,29,168,5,157,48,5,189,44,5,29,172,5,157,52, 1273 32,5,29,168,5,157,48,5,189,44,5,29,172,5,157,52,
1274 5,189,56,5,157,72,5,189,60,5,157,76,5,189,160,5, 1274 5,189,56,5,157,72,5,189,60,5,157,76,5,189,160,5,
1275 157,64,5,189,164,5,157,68,5,202,16,211,173,176,5,13, 1275 157,64,5,189,164,5,157,68,5,202,16,211,173,176,5,13,
1276 177,5,13,178,5,13,179,5,141,30,5,173,180,5,13,181, 1276 177,5,13,178,5,13,179,5,141,30,5,173,180,5,13,181,
1277 5,13,182,5,13,183,5,141,31,5,96,173,9,5,208,3, 1277 5,13,182,5,13,183,5,141,31,5,96,173,9,5,208,3,
1278 76,144,10,48,3,76,72,10,173,13,5,170,74,74,41,1, 1278 76,144,10,48,3,76,72,10,173,13,5,170,74,74,41,1,
1279 168,185,30,5,141,56,210,138,41,4,168,185,56,5,141,48, 1279 168,185,30,5,141,56,210,138,41,4,168,185,56,5,141,48,
1280 210,189,32,5,141,49,210,185,57,5,141,50,210,189,33,5, 1280 210,189,32,5,141,49,210,185,57,5,141,50,210,189,33,5,
1281 141,51,210,185,58,5,141,52,210,189,34,5,141,53,210,185, 1281 141,51,210,185,58,5,141,52,210,189,34,5,141,53,210,185,
1282 59,5,141,54,210,189,35,5,141,55,210,173,12,5,170,74, 1282 59,5,141,54,210,189,35,5,141,55,210,173,12,5,170,74,
1283 74,41,1,168,185,30,5,141,40,210,138,41,4,168,185,56, 1283 74,41,1,168,185,30,5,141,40,210,138,41,4,168,185,56,
1284 5,141,32,210,189,32,5,141,33,210,185,57,5,141,34,210, 1284 5,141,32,210,189,32,5,141,33,210,185,57,5,141,34,210,
1285 189,33,5,141,35,210,185,58,5,141,36,210,189,34,5,141, 1285 189,33,5,141,35,210,185,58,5,141,36,210,189,34,5,141,
1286 37,210,185,59,5,141,38,210,189,35,5,141,39,210,173,11, 1286 37,210,185,59,5,141,38,210,189,35,5,141,39,210,173,11,
1287 5,170,74,74,41,1,168,185,30,5,141,24,210,138,172,9, 1287 5,170,74,74,41,1,168,185,30,5,141,24,210,138,172,9,
1288 5,16,2,41,4,168,185,56,5,141,16,210,189,32,5,141, 1288 5,16,2,41,4,168,185,56,5,141,16,210,189,32,5,141,
1289 17,210,185,57,5,141,18,210,189,33,5,141,19,210,185,58, 1289 17,210,185,57,5,141,18,210,189,33,5,141,19,210,185,58,
1290 5,141,20,210,189,34,5,141,21,210,185,59,5,141,22,210, 1290 5,141,20,210,189,34,5,141,21,210,185,59,5,141,22,210,
1291 189,35,5,141,23,210,173,10,5,170,74,74,41,1,168,185, 1291 189,35,5,141,23,210,173,10,5,170,74,74,41,1,168,185,
1292 30,5,141,8,210,138,172,9,5,16,2,41,4,168,185,56, 1292 30,5,141,8,210,138,172,9,5,16,2,41,4,168,185,56,
1293 5,141,0,210,189,32,5,141,1,210,185,57,5,141,2,210, 1293 5,141,0,210,189,32,5,141,1,210,185,57,5,141,2,210,
1294 189,33,5,141,3,210,185,58,5,141,4,210,189,34,5,141, 1294 189,33,5,141,3,210,185,58,5,141,4,210,189,34,5,141,
1295 5,210,185,59,5,141,6,210,189,35,5,141,7,210,96,189, 1295 5,210,185,59,5,141,6,210,189,35,5,141,7,210,96,189,
1296 128,5,133,250,189,136,5,133,251,189,128,6,133,252,189,136, 1296 128,5,133,250,189,136,5,133,251,189,128,6,133,252,189,136,
1297 6,133,253,189,144,6,133,254,189,184,5,221,192,5,144,12, 1297 6,133,253,189,144,6,133,254,189,184,5,221,192,5,144,12,
1298 157,8,6,189,200,5,157,184,5,76,11,11,189,8,6,240, 1298 157,8,6,189,200,5,157,184,5,76,11,11,189,8,6,240,
1299 48,189,232,5,240,19,222,248,5,208,14,157,248,5,189,216, 1299 48,189,232,5,240,19,222,248,5,208,14,157,248,5,189,216,
1300 5,240,6,56,233,16,157,216,5,189,240,5,240,19,222,0, 1300 5,240,6,56,233,16,157,216,5,189,240,5,240,19,222,0,
1301 6,208,14,157,0,6,189,224,5,240,6,56,233,16,157,224, 1301 6,208,14,157,0,6,189,224,5,240,6,56,233,16,157,224,
1302 5,188,72,6,177,250,24,125,152,5,24,101,253,133,253,222, 1302 5,188,72,6,177,250,24,125,152,5,24,101,253,133,253,222,
1303 88,6,16,57,189,80,6,157,88,6,189,96,6,240,30,24, 1303 88,6,16,57,189,80,6,157,88,6,189,96,6,240,30,24,
1304 125,72,6,157,72,6,240,13,221,64,6,144,32,169,255,157, 1304 125,72,6,157,72,6,240,13,221,64,6,144,32,169,255,157,
1305 96,6,76,135,11,169,1,157,96,6,76,135,11,254,72,6, 1305 96,6,76,135,11,169,1,157,96,6,76,135,11,254,72,6,
1306 189,64,6,221,72,6,176,5,169,0,157,72,6,169,19,24, 1306 189,64,6,221,72,6,176,5,169,0,157,72,6,169,19,24,
1307 101,250,133,250,144,2,230,251,188,184,5,177,250,41,240,157, 1307 101,250,133,250,144,2,230,251,188,184,5,177,250,41,240,157,
1308 168,5,177,250,41,15,29,216,5,168,185,0,2,5,255,168, 1308 168,5,177,250,41,15,29,216,5,168,185,0,2,5,255,168,
1309 185,0,2,157,32,5,188,184,5,200,177,250,41,15,29,224, 1309 185,0,2,157,32,5,188,184,5,200,177,250,41,15,29,224,
1310 5,168,185,0,2,5,255,168,185,0,2,157,40,5,189,40, 1310 5,168,185,0,2,5,255,168,185,0,2,157,40,5,189,40,
1311 6,208,39,189,16,6,141,212,11,16,254,76,209,12,234,76, 1311 6,208,39,189,16,6,141,212,11,16,254,76,209,12,234,76,
1312 108,12,234,76,167,12,234,76,212,12,234,76,1,13,234,76, 1312 108,12,234,76,167,12,234,76,212,12,234,76,1,13,234,76,
1313 33,13,234,76,65,13,234,76,73,13,222,40,6,188,184,5, 1313 33,13,234,76,65,13,234,76,73,13,222,40,6,188,184,5,
1314 200,177,250,41,112,74,74,74,141,34,12,177,250,48,6,189, 1314 200,177,250,41,112,74,74,74,141,34,12,177,250,48,6,189,
1315 112,6,76,18,12,189,120,6,61,176,6,157,176,5,200,200, 1315 112,6,76,18,12,189,120,6,61,176,6,157,176,5,200,200,
1316 152,157,184,5,136,177,250,144,254,144,22,144,12,144,34,144, 1316 152,157,184,5,136,177,250,144,254,144,22,144,12,144,34,144,
1317 24,144,46,144,36,144,50,144,52,125,128,6,157,128,6,177, 1317 24,144,46,144,36,144,50,144,52,125,128,6,157,128,6,177,
1318 250,24,101,252,133,252,76,172,8,125,136,6,157,136,6,177, 1318 250,24,101,252,133,252,76,172,8,125,136,6,157,136,6,177,
1319 250,24,101,253,133,253,76,172,8,125,144,6,157,144,6,177, 1319 250,24,101,253,133,253,76,172,8,125,144,6,157,144,6,177,
1320 250,24,101,254,133,254,76,172,8,133,252,169,0,133,253,76, 1320 250,24,101,254,133,254,76,172,8,133,252,169,0,133,253,76,
1321 172,8,189,32,6,41,3,74,144,10,208,25,189,24,6,24, 1321 172,8,189,32,6,41,3,74,144,10,208,25,189,24,6,24,
1322 101,252,133,252,222,56,6,16,78,254,32,6,189,48,6,157, 1322 101,252,133,252,222,56,6,16,78,254,32,6,189,48,6,157,
1323 56,6,76,247,11,165,252,253,24,6,133,252,222,56,6,16, 1323 56,6,76,247,11,165,252,253,24,6,133,252,222,56,6,16,
1324 54,254,32,6,189,48,6,157,56,6,76,247,11,188,32,6, 1324 54,254,32,6,189,48,6,157,56,6,76,247,11,188,32,6,
1325 189,24,6,48,2,200,200,136,152,24,101,252,133,252,222,56, 1325 189,24,6,48,2,200,200,136,152,24,101,252,133,252,222,56,
1326 6,16,20,152,157,32,6,221,24,6,208,5,73,255,157,24, 1326 6,16,20,152,157,32,6,221,24,6,208,5,73,255,157,24,
1327 6,189,48,6,157,56,6,76,247,11,188,32,6,189,24,6, 1327 6,189,48,6,157,56,6,76,247,11,188,32,6,189,24,6,
1328 48,2,200,200,136,152,24,101,253,133,253,222,56,6,16,231, 1328 48,2,200,200,136,152,24,101,253,133,253,222,56,6,16,231,
1329 152,157,32,6,221,24,6,208,216,73,255,157,24,6,189,48, 1329 152,157,32,6,221,24,6,208,216,73,255,157,24,6,189,48,
1330 6,157,56,6,76,247,11,189,32,6,24,101,252,133,252,222, 1330 6,157,56,6,76,247,11,189,32,6,24,101,252,133,252,222,
1331 56,6,16,195,189,24,6,24,125,32,6,157,32,6,189,48, 1331 56,6,16,195,189,24,6,24,125,32,6,157,32,6,189,48,
1332 6,157,56,6,76,247,11,165,253,56,253,32,6,133,253,222, 1332 6,157,56,6,76,247,11,165,253,56,253,32,6,133,253,222,
1333 56,6,16,163,189,24,6,24,125,32,6,157,32,6,189,48, 1333 56,6,16,163,189,24,6,24,125,32,6,157,32,6,189,48,
1334 6,157,56,6,76,247,11,189,24,6,24,101,252,133,252,76, 1334 6,157,56,6,76,247,11,189,24,6,24,101,252,133,252,76,
1335 247,11,160,16,169,0,133,250,169,0,133,251,169,0,141,23, 1335 247,11,160,16,169,0,133,250,169,0,133,251,169,0,141,23,
1336 5,138,240,63,177,250,240,2,16,1,202,169,17,24,101,250, 1336 5,138,240,63,177,250,240,2,16,1,202,169,17,24,101,250,
1337 133,250,144,2,230,251,238,23,5,208,230,162,0,169,0,133, 1337 133,250,144,2,230,251,238,23,5,208,230,162,0,169,0,133,
1338 252,138,141,23,5,10,38,252,10,38,252,10,38,252,10,38, 1338 252,138,141,23,5,10,38,252,10,38,252,10,38,252,10,38,
1339 252,109,23,5,144,2,230,252,24,105,0,133,250,165,252,105, 1339 252,109,23,5,144,2,230,252,24,105,0,133,250,165,252,105,
1340 0,133,251,32,44,15,165,250,141,25,5,165,251,141,26,5, 1340 0,133,251,32,44,15,165,250,141,25,5,165,251,141,26,5,
1341 162,7,169,255,157,208,5,169,240,157,216,5,157,224,5,202, 1341 162,7,169,255,157,208,5,169,240,157,216,5,157,224,5,202,
1342 16,240,169,3,141,15,210,141,31,210,141,47,210,141,63,210, 1342 16,240,169,3,141,15,210,141,31,210,141,47,210,141,63,210,
1343 206,23,5,232,142,28,5,232,142,29,5,142,22,5,96,138, 1343 206,23,5,232,142,28,5,232,142,29,5,142,22,5,96,138,
1344 41,15,141,27,5,96,142,22,5,96,201,16,176,3,76,76, 1344 41,15,141,27,5,96,142,22,5,96,201,16,176,3,76,76,
1345 13,201,32,144,136,201,48,176,3,76,133,15,201,64,144,223, 1345 13,201,32,144,136,201,48,176,3,76,133,15,201,64,144,223,
1346 201,80,176,3,76,44,15,201,96,144,219,201,112,144,3,76, 1346 201,80,176,3,76,44,15,201,96,144,219,201,112,144,3,76,
1347 180,14,132,253,41,15,10,141,23,14,165,253,144,254,144,30, 1347 180,14,132,253,41,15,10,141,23,14,165,253,144,254,144,30,
1348 144,56,144,89,144,96,144,26,144,28,144,30,144,32,144,34, 1348 144,56,144,89,144,96,144,26,144,28,144,30,144,32,144,34,
1349 144,36,144,13,144,11,144,9,144,7,144,5,144,3,141,24, 1349 144,36,144,13,144,11,144,9,144,7,144,5,144,3,141,24,
1350 5,96,157,104,6,96,157,112,6,96,157,120,6,96,157,144, 1350 5,96,157,104,6,96,157,112,6,96,157,120,6,96,157,144,
1351 6,96,157,128,6,96,157,136,6,96,41,112,74,74,157,16, 1351 6,96,157,128,6,96,157,136,6,96,41,112,74,74,157,16,
1352 6,41,48,208,3,157,32,6,165,253,48,6,41,15,157,24, 1352 6,41,48,208,3,157,32,6,165,253,48,6,41,15,157,24,
1353 6,96,41,15,73,255,24,105,1,157,24,6,96,41,63,157, 1353 6,96,41,15,73,255,24,105,1,157,24,6,96,41,63,157,
1354 48,6,157,56,6,96,41,128,10,42,157,96,6,165,253,41, 1354 48,6,157,56,6,96,41,128,10,42,157,96,6,165,253,41,
1355 112,74,74,74,74,157,64,6,208,3,157,96,6,165,253,41, 1355 112,74,74,74,74,157,64,6,208,3,157,96,6,165,253,41,
1356 15,157,80,6,157,88,6,189,72,6,221,64,6,144,143,189, 1356 15,157,80,6,157,88,6,189,72,6,221,64,6,144,143,189,
1357 64,6,240,2,233,1,157,72,6,96,132,250,134,251,160,25, 1357 64,6,240,2,233,1,157,72,6,96,132,250,134,251,160,25,
1358 177,250,200,141,9,5,177,250,200,141,10,5,177,250,200,141, 1358 177,250,200,141,9,5,177,250,200,141,10,5,177,250,200,141,
1359 11,5,177,250,200,141,12,5,177,250,200,141,13,5,177,250, 1359 11,5,177,250,200,141,12,5,177,250,200,141,13,5,177,250,
1360 141,27,5,165,250,73,128,48,1,232,141,172,15,142,173,15, 1360 141,27,5,165,250,73,128,48,1,232,141,172,15,142,173,15,
1361 73,128,48,1,232,141,29,7,142,30,7,232,141,35,7,142, 1361 73,128,48,1,232,141,29,7,142,30,7,232,141,35,7,142,
1362 36,7,232,141,162,15,142,163,15,73,128,48,1,232,141,25, 1362 36,7,232,141,162,15,142,163,15,73,128,48,1,232,141,25,
1363 5,141,215,6,141,79,13,141,148,13,142,26,5,142,221,6, 1363 5,141,215,6,141,79,13,141,148,13,142,26,5,142,221,6,
1364 142,83,13,142,154,13,169,240,133,255,169,0,141,22,5,141, 1364 142,83,13,142,154,13,169,240,133,255,169,0,141,22,5,141,
1365 24,5,162,7,169,0,141,22,5,157,120,5,157,176,5,157, 1365 24,5,162,7,169,0,141,22,5,157,120,5,157,176,5,157,
1366 32,5,157,40,5,157,48,5,157,48,210,157,32,210,157,16, 1366 32,5,157,40,5,157,48,5,157,48,210,157,32,210,157,16,
1367 210,157,0,210,202,16,226,141,24,210,141,8,210,141,56,210, 1367 210,157,0,210,202,16,226,141,24,210,141,8,210,141,56,210,
1368 141,40,210,141,30,5,141,31,5,96,157,32,5,157,40,5, 1368 141,40,210,141,30,5,141,31,5,96,157,32,5,157,40,5,
1369 157,48,5,157,176,5,96,152,157,208,5,41,240,157,216,5, 1369 157,48,5,157,176,5,96,152,157,208,5,41,240,157,216,5,
1370 189,208,5,10,10,10,10,157,224,5,96,41,7,133,250,138, 1370 189,208,5,10,10,10,10,157,224,5,96,41,7,133,250,138,
1371 166,250,41,63,240,225,157,152,5,152,48,238,189,208,5,32, 1371 166,250,41,63,240,225,157,152,5,152,48,238,189,208,5,32,
1372 117,15,169,0,157,120,5,185,255,255,240,190,157,136,5,133, 1372 117,15,169,0,157,120,5,185,255,255,240,190,157,136,5,133,
1373 251,185,255,255,157,128,5,133,250,152,157,144,5,160,8,177, 1373 251,185,255,255,157,128,5,133,250,152,157,144,5,160,8,177,
1374 250,200,157,192,5,177,250,200,157,200,5,177,250,200,157,104, 1374 250,200,157,192,5,177,250,200,157,200,5,177,250,200,157,104,
1375 6,177,250,200,157,112,6,177,250,200,157,120,6,177,250,200, 1375 6,177,250,200,157,112,6,177,250,200,157,120,6,177,250,200,
1376 157,232,5,157,248,5,177,250,200,157,240,5,157,0,6,177, 1376 157,232,5,157,248,5,177,250,200,157,240,5,157,0,6,177,
1377 250,41,112,74,74,157,16,6,177,250,200,48,8,41,15,157, 1377 250,41,112,74,74,157,16,6,177,250,200,48,8,41,15,157,
1378 24,6,76,9,16,41,15,73,255,24,105,1,157,24,6,177, 1378 24,6,76,9,16,41,15,73,255,24,105,1,157,24,6,177,
1379 250,200,157,40,6,177,250,200,41,63,157,48,6,157,56,6, 1379 250,200,157,40,6,177,250,200,41,63,157,48,6,157,56,6,
1380 177,250,41,128,10,42,157,96,6,177,250,41,112,74,74,74, 1380 177,250,41,128,10,42,157,96,6,177,250,41,112,74,74,74,
1381 74,157,64,6,208,3,157,96,6,177,250,136,41,15,157,80, 1381 74,157,64,6,208,3,157,96,6,177,250,136,41,15,157,80,
1382 6,157,88,6,177,250,41,192,29,152,5,157,152,5,168,185, 1382 6,157,88,6,177,250,41,192,29,152,5,157,152,5,168,185,
1383 0,3,157,56,5,169,0,157,184,5,157,32,6,157,8,6, 1383 0,3,157,56,5,169,0,157,184,5,157,32,6,157,8,6,
1384 157,72,6,157,128,6,157,136,6,157,144,6,169,1,157,120, 1384 157,72,6,157,128,6,157,136,6,157,144,6,169,1,157,120,
1385 5,96 1385 5,96
1386END_CONST_ARRAY; 1386END_CONST_ARRAY;