workaround a problem with the harmattan gcc
[drnoksnes] / globals.cpp
1 /*
2  * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3  *
4  * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5  *                           Jerremy Koot (jkoot@snes9x.com)
6  *
7  * Super FX C emulator code 
8  * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
9  *                           Gary Henderson.
10  * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
11  *
12  * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13  * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14  * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
15  *
16  * DOS port code contains the works of other authors. See headers in
17  * individual files.
18  *
19  * Snes9x homepage: http://www.snes9x.com
20  *
21  * Permission to use, copy, modify and distribute Snes9x in both binary and
22  * source form, for non-commercial purposes, is hereby granted without fee,
23  * providing that this license information and copyright notice appear with
24  * all copies and any derived work.
25  *
26  * This software is provided 'as-is', without any express or implied
27  * warranty. In no event shall the authors be held liable for any damages
28  * arising from the use of this software.
29  *
30  * Snes9x is freeware for PERSONAL USE only. Commercial users should
31  * seek permission of the copyright holders first. Commercial use includes
32  * charging money for Snes9x or software derived from Snes9x.
33  *
34  * The copyright holders request that bug fixes and improvements to the code
35  * should be forwarded to them so everyone can benefit from the modifications
36  * in future versions.
37  *
38  * Super NES and Super Nintendo Entertainment System are trademarks of
39  * Nintendo Co., Limited and its subsidiary companies.
40  */
41 #include "snes9x.h"
42 #include "memmap.h"
43 #include "ppu.h"
44 #include "dsp1.h"
45 #include "missing.h"
46 #include "cpuexec.h"
47 #include "debug.h"
48 #include "apu.h"
49 #include "dma.h"
50 #include "fxemu.h"
51 #include "gfx.h"
52 #include "soundux.h"
53 #include "cheats.h"
54 #include "sa1.h"
55
56 #ifdef NETPLAY_SUPPORT
57 #include "netplay.h"
58 #endif
59
60 START_EXTERN_C
61 char String[513];
62
63 struct Missing missing;
64
65 struct SICPU ICPU;
66
67 struct SCPUState CPU;
68
69 //struct SRegisters Registers;
70
71 struct SAPU APU;
72
73 struct SIAPU IAPU;
74
75 struct SAPURegisters APURegisters;
76
77 struct SSettings Settings;
78
79 struct SDSP1 DSP1;
80
81 struct SSA1Registers SA1Registers;
82
83 struct SSA1 SA1;
84
85
86 uint8 *SRAM = NULL;
87 uint8 *ROM = NULL;
88 uint8 *RegRAM = NULL;
89 uint8 *C4RAM = NULL;
90
91 long OpAddress = 0;
92
93 CMemory Memory;
94
95 struct SSNESGameFixes SNESGameFixes;
96
97 #ifndef ASM_SPC700
98 uint8 A1 = 0, A2 = 0, A3 = 0, A4 = 0, W1 = 0, W2 = 0, W3 = 0, W4 = 0;
99 uint8 Ans8 = 0;
100 uint16 Ans16 = 0;
101 uint32 Ans32 = 0;
102 uint8 Work8 = 0;
103 uint16 Work16 = 0;
104 uint32 Work32 = 0;
105 signed char Int8 = 0;
106 short Int16 = 0;
107 long Int32 = 0;
108 #endif
109
110 END_EXTERN_C
111
112 #ifndef ZSNES_FX
113 struct FxInit_s SuperFX;
114 #else
115 START_EXTERN_C
116 uint8 *SFXPlotTable = NULL;
117 END_EXTERN_C
118 #endif
119
120 struct SPPU PPU;
121 struct InternalPPU IPPU;
122
123 struct SDMA DMA[8];
124
125 uint8 *HDMAMemPointers [8];
126 uint8 *HDMABasePointers [8];
127
128 struct SBG BG;
129
130 struct SGFX GFX;
131 struct SLineData LineData[240];
132 struct SLineMatrixData LineMatrixData [240];
133
134 uint8 Mode7Depths [2];
135 NormalTileRenderer DrawTilePtr = NULL;
136 ClippedTileRenderer DrawClippedTilePtr = NULL;
137 NormalTileRenderer DrawHiResTilePtr = NULL;
138 ClippedTileRenderer DrawHiResClippedTilePtr = NULL;
139 LargePixelRenderer DrawLargePixelPtr = NULL;
140
141 uint32 odd_high[4][16];
142 uint32 odd_low[4][16];
143 uint32 even_high[4][16];
144 uint32 even_low[4][16];
145
146 #ifdef GFX_MULTI_FORMAT
147
148 uint32 RED_LOW_BIT_MASK = RED_LOW_BIT_MASK_RGB565;
149 uint32 GREEN_LOW_BIT_MASK = GREEN_LOW_BIT_MASK_RGB565;
150 uint32 BLUE_LOW_BIT_MASK = BLUE_LOW_BIT_MASK_RGB565;
151 uint32 RED_HI_BIT_MASK = RED_HI_BIT_MASK_RGB565;
152 uint32 GREEN_HI_BIT_MASK = GREEN_HI_BIT_MASK_RGB565;
153 uint32 BLUE_HI_BIT_MASK = BLUE_HI_BIT_MASK_RGB565;
154 uint32 MAX_RED = MAX_RED_RGB565;
155 uint32 MAX_GREEN = MAX_GREEN_RGB565;
156 uint32 MAX_BLUE = MAX_BLUE_RGB565;
157 uint32 SPARE_RGB_BIT_MASK = SPARE_RGB_BIT_MASK_RGB565;
158 uint32 GREEN_HI_BIT = (MAX_GREEN_RGB565 + 1) >> 1;
159 uint32 RGB_LOW_BITS_MASK = (RED_LOW_BIT_MASK_RGB565 | 
160                             GREEN_LOW_BIT_MASK_RGB565 |
161                             BLUE_LOW_BIT_MASK_RGB565);
162 uint32 RGB_HI_BITS_MASK = (RED_HI_BIT_MASK_RGB565 |
163                            GREEN_HI_BIT_MASK_RGB565 |
164                            BLUE_HI_BIT_MASK_RGB565);
165 uint32 RGB_HI_BITS_MASKx2 = (RED_HI_BIT_MASK_RGB565 |
166                              GREEN_HI_BIT_MASK_RGB565 |
167                              BLUE_HI_BIT_MASK_RGB565) << 1;
168 uint32 RGB_REMOVE_LOW_BITS_MASK = ~RGB_LOW_BITS_MASK;
169 uint32 FIRST_COLOR_MASK = FIRST_COLOR_MASK_RGB565;
170 uint32 SECOND_COLOR_MASK = SECOND_COLOR_MASK_RGB565;
171 uint32 THIRD_COLOR_MASK = THIRD_COLOR_MASK_RGB565;
172 uint32 ALPHA_BITS_MASK = ALPHA_BITS_MASK_RGB565;
173 uint32 FIRST_THIRD_COLOR_MASK = 0;
174 uint32 TWO_LOW_BITS_MASK = 0;
175 uint32 HIGH_BITS_SHIFTED_TWO_MASK = 0;
176
177 uint32 current_graphic_format = RGB565;
178 #endif
179
180 uint8 GetBank = 0;
181 struct SCheatData Cheat;
182
183 SoundStatus so;
184 SSoundData SoundData;
185 int Echo [24000];
186 int DummyEchoBuffer [SOUND_BUFFER_SIZE];
187 int MixBuffer [SOUND_BUFFER_SIZE];
188 int EchoBuffer [SOUND_BUFFER_SIZE];
189 int FilterTaps [8];
190 unsigned long Z = 0;
191 int Loop [16];
192
193 uint16 SignExtend [2] = {
194     0x00, 0xff00
195 };
196
197 int HDMA_ModeByteCounts [8] = {
198     1, 2, 2, 4, 4, 0, 0, 0
199 };
200
201 uint8 BitShifts[8][4] =
202 {
203     {2, 2, 2, 2},       // 0
204     {4, 4, 2, 0},       // 1
205     {4, 4, 0, 0},       // 2
206     {8, 4, 0, 0},       // 3
207     {8, 2, 0, 0},       // 4
208     {4, 2, 0, 0},       // 5
209     {4, 0, 0, 0},       // 6
210     {8, 0, 0, 0}        // 7
211 };
212 uint8 TileShifts[8][4] =
213 {
214     {4, 4, 4, 4},       // 0
215     {5, 5, 4, 0},       // 1
216     {5, 5, 0, 0},       // 2
217     {6, 5, 0, 0},       // 3
218     {6, 4, 0, 0},       // 4
219     {5, 4, 0, 0},       // 5
220     {5, 0, 0, 0},       // 6
221     {6, 0, 0, 0}        // 7
222 };
223 uint8 PaletteShifts[8][4] =
224 {
225     {2, 2, 2, 2},       // 0
226     {4, 4, 2, 0},       // 1
227     {4, 4, 0, 0},       // 2
228     {0, 4, 0, 0},       // 3
229     {0, 2, 0, 0},       // 4
230     {4, 2, 0, 0},       // 5
231     {4, 0, 0, 0},       // 6
232     {0, 0, 0, 0}        // 7
233 };
234 uint8 PaletteMasks[8][4] =
235 {
236     {7, 7, 7, 7},       // 0
237     {7, 7, 7, 0},       // 1
238     {7, 7, 0, 0},       // 2
239     {0, 7, 0, 0},       // 3
240     {0, 7, 0, 0},       // 4
241     {7, 7, 0, 0},       // 5
242     {7, 0, 0, 0},       // 6
243     {0, 0, 0, 0}        // 7
244 };
245 uint8 Depths[8][4] =
246 {
247     {TILE_2BIT, TILE_2BIT, TILE_2BIT, TILE_2BIT}, // 0
248     {TILE_4BIT, TILE_4BIT, TILE_2BIT, 0},         // 1
249     {TILE_4BIT, TILE_4BIT, 0, 0},                 // 2
250     {TILE_8BIT, TILE_4BIT, 0, 0},                 // 3
251     {TILE_8BIT, TILE_2BIT, 0, 0},                 // 4
252     {TILE_4BIT, TILE_2BIT, 0, 0},                 // 5
253     {TILE_8BIT, 0, 0, 0},                         // 6
254     {0, 0, 0, 0}                                  // 7
255 };
256 uint8 BGSizes [2] = {
257     8, 16
258 };
259 uint16 DirectColourMaps [8][256];
260
261 long FilterValues[4][2] =
262 {
263     {0, 0},
264     {240, 0},
265     {488, -240},
266     {460, -208}
267 };
268
269 int NoiseFreq [32] = {
270     0, 16, 21, 25, 31, 42, 50, 63, 84, 100, 125, 167, 200, 250, 333,
271     400, 500, 667, 800, 1000, 1300, 1600, 2000, 2700, 3200, 4000,
272     5300, 6400, 8000, 10700, 16000, 32000
273 };
274
275 uint32 HeadMask [4] = {
276 #ifdef LSB_FIRST
277     0xffffffff, 0xffffff00, 0xffff0000, 0xff000000
278 #else
279     0xffffffff, 0x00ffffff, 0x0000ffff, 0x000000ff
280 #endif
281 };
282
283 uint32 TailMask [5] = {
284 #ifdef LSB_FIRST
285     0x00000000, 0x000000ff, 0x0000ffff, 0x00ffffff, 0xffffffff
286 #else
287     0x00000000, 0xff000000, 0xffff0000, 0xffffff00, 0xffffffff
288 #endif
289 };
290
291 START_EXTERN_C
292 uint8 APUROM [64] =
293 {
294     0xCD,0xEF,0xBD,0xE8,0x00,0xC6,0x1D,0xD0,0xFC,0x8F,0xAA,0xF4,0x8F,
295     0xBB,0xF5,0x78,0xCC,0xF4,0xD0,0xFB,0x2F,0x19,0xEB,0xF4,0xD0,0xFC,
296     0x7E,0xF4,0xD0,0x0B,0xE4,0xF5,0xCB,0xF4,0xD7,0x00,0xFC,0xD0,0xF3,
297     0xAB,0x01,0x10,0xEF,0x7E,0xF4,0x10,0xEB,0xBA,0xF6,0xDA,0x00,0xBA,
298     0xF4,0xC4,0xF4,0xDD,0x5D,0xD0,0xDB,0x1F,0x00,0x00,0xC0,0xFF
299 };
300
301 #ifdef NETPLAY_SUPPORT
302 struct SNetPlay NetPlay;
303 #endif
304
305 // Raw SPC700 instruction cycle lengths
306 int32 S9xAPUCycleLengths [256] = 
307 {
308     /*        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, */
309     /* 00 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 6, 8, 
310     /* 10 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 4, 6, 
311     /* 20 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 5, 4, 
312     /* 30 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 3, 8, 
313     /* 40 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 6, 6, 
314     /* 50 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 4, 5, 2, 2, 4, 3, 
315     /* 60 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 5, 5, 
316     /* 70 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 6, 
317     /* 80 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 2, 4, 5, 
318     /* 90 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2,12, 5, 
319     /* a0 */  3, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 2, 4, 4, 
320     /* b0 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 4, 
321     /* c0 */  3, 8, 4, 5, 4, 5, 4, 7, 2, 5, 6, 4, 5, 2, 4, 9, 
322     /* d0 */  2, 8, 4, 5, 5, 6, 6, 7, 4, 5, 4, 5, 2, 2, 6, 3, 
323     /* e0 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 4, 5, 3, 4, 3, 4, 3, 
324     /* f0 */  2, 8, 4, 5, 4, 5, 5, 6, 3, 4, 5, 4, 2, 2, 4, 3
325 };
326
327 // Actual data used by CPU emulation, will be scaled by APUReset routine
328 // to be relative to the 65c816 instruction lengths.
329 int32 S9xAPUCycles [256] =
330 {
331     /*        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, */
332     /* 00 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 6, 8, 
333     /* 10 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 4, 6, 
334     /* 20 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 4, 5, 4, 
335     /* 30 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 6, 5, 2, 2, 3, 8, 
336     /* 40 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 6, 6, 
337     /* 50 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 4, 5, 2, 2, 4, 3, 
338     /* 60 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 4, 5, 5, 
339     /* 70 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 6, 
340     /* 80 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 6, 5, 4, 5, 2, 4, 5, 
341     /* 90 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2,12, 5, 
342     /* a0 */  3, 8, 4, 5, 3, 4, 3, 6, 2, 6, 4, 4, 5, 2, 4, 4, 
343     /* b0 */  2, 8, 4, 5, 4, 5, 5, 6, 5, 5, 5, 5, 2, 2, 3, 4, 
344     /* c0 */  3, 8, 4, 5, 4, 5, 4, 7, 2, 5, 6, 4, 5, 2, 4, 9, 
345     /* d0 */  2, 8, 4, 5, 5, 6, 6, 7, 4, 5, 4, 5, 2, 2, 6, 3, 
346     /* e0 */  2, 8, 4, 5, 3, 4, 3, 6, 2, 4, 5, 3, 4, 3, 4, 3, 
347     /* f0 */  2, 8, 4, 5, 4, 5, 5, 6, 3, 4, 5, 4, 2, 2, 4, 3
348 };
349
350 #ifndef VAR_CYCLES
351 uint8 S9xE1M1X1 [256] = {
352         8, 6, 8, 4, 5, 3, 5, 6, 3, 2, 2, 4, 6, 4, 6, 5,         /* e=1, m=1, x=1 */
353         2, 5, 5, 7, 5, 4, 6, 6, 2, 4, 2, 2, 6, 4, 7, 5,
354         6, 6, 8, 4, 3, 3, 5, 6, 4, 2, 2, 5, 4, 4, 6, 5,
355         2, 5, 5, 7, 4, 4, 6, 6, 2, 4, 2, 2, 4, 4, 7, 5,
356         7, 6, 2, 4, 0, 3, 5, 6, 3, 2, 2, 3, 3, 4, 6, 5,
357         2, 5, 5, 7, 0, 4, 6, 6, 2, 4, 3, 2, 4, 4, 7, 5,
358         6, 6, 6, 4, 3, 3, 5, 6, 4, 2, 2, 6, 5, 4, 6, 5,
359         2, 5, 5, 7, 4, 4, 6, 6, 2, 4, 4, 2, 6, 4, 7, 5,
360         2, 6, 3, 4, 3, 3, 3, 6, 2, 2, 2, 3, 4, 4, 4, 5,
361         2, 5, 5, 7, 4, 4, 4, 6, 2, 4, 2, 2, 4, 4, 4, 5,
362         2, 6, 2, 4, 3, 3, 3, 6, 2, 2, 2, 4, 4, 4, 4, 5,
363         2, 5, 5, 7, 4, 4, 4, 6, 2, 4, 2, 2, 4, 4, 4, 5,
364         2, 6, 3, 4, 3, 3, 5, 6, 2, 2, 2, 3, 4, 4, 6, 5,
365         2, 5, 5, 7, 6, 4, 6, 6, 2, 4, 3, 3, 6, 4, 7, 5,
366         2, 6, 3, 4, 3, 3, 5, 6, 2, 2, 2, 3, 4, 4, 6, 5,
367         2, 5, 5, 7, 5, 4, 6, 6, 2, 4, 4, 2, 6, 4, 7, 5
368 };
369
370 uint8 S9xE0M1X1 [256] = {
371         8, 6, 8, 4, 5, 3, 5, 6, 3, 2, 2, 4, 6, 4, 6, 5,         /* e=0, m=1, x=1 */
372         2, 5, 5, 7, 5, 4, 6, 6, 2, 4, 2, 2, 6, 4, 7, 5,
373         6, 6, 8, 4, 3, 3, 5, 6, 4, 2, 2, 5, 4, 4, 6, 5,
374         2, 5, 5, 7, 4, 4, 6, 6, 2, 4, 2, 2, 4, 4, 7, 5,
375         7, 6, 2, 4, 0, 3, 5, 6, 3, 2, 2, 3, 3, 4, 6, 5,
376         2, 5, 5, 7, 0, 4, 6, 6, 2, 4, 3, 2, 4, 4, 7, 5,
377         6, 6, 6, 4, 3, 3, 5, 6, 4, 2, 2, 6, 5, 4, 6, 5,
378         2, 5, 5, 7, 4, 4, 6, 6, 2, 4, 4, 2, 6, 4, 7, 5,
379         2, 6, 3, 4, 3, 3, 3, 6, 2, 2, 2, 3, 4, 4, 4, 5,
380         2, 5, 5, 7, 4, 4, 4, 6, 2, 4, 2, 2, 4, 4, 4, 5,
381         2, 6, 2, 4, 3, 3, 3, 6, 2, 2, 2, 4, 4, 4, 4, 5,
382         2, 5, 5, 7, 4, 4, 4, 6, 2, 4, 2, 2, 4, 4, 4, 5,
383         2, 6, 3, 4, 3, 3, 5, 6, 2, 2, 2, 3, 4, 4, 6, 5,
384         2, 5, 5, 7, 6, 4, 6, 6, 2, 4, 3, 3, 6, 4, 7, 5,
385         2, 6, 3, 4, 3, 3, 5, 6, 2, 2, 2, 3, 4, 4, 6, 5,
386         2, 5, 5, 7, 5, 4, 6, 6, 2, 4, 4, 2, 6, 4, 7, 5
387 };
388
389 uint8 S9xE0M0X1 [256] = {
390         8, 7, 8, 5, 7, 4, 7, 7, 3, 3, 2, 4, 8, 5, 8, 6,         /* e=0, m=0, x=1 */
391         2, 6, 6, 8, 7, 5, 8, 7, 2, 5, 2, 2, 8, 5, 9, 6,
392         6, 7, 8, 5, 4, 4, 7, 7, 4, 3, 2, 5, 5, 5, 8, 6,
393         2, 6, 6, 8, 5, 5, 8, 7, 2, 5, 2, 2, 5, 5, 9, 6,
394         7, 7, 2, 5, 0, 4, 7, 7, 4, 3, 2, 3, 3, 5, 8, 6,
395         2, 6, 6, 8, 0, 5, 8, 7, 2, 5, 3, 2, 4, 5, 9, 6,
396         6, 7, 6, 5, 4, 4, 7, 7, 5, 3, 2, 6, 5, 5, 8, 6,
397         2, 6, 6, 8, 5, 5, 8, 7, 2, 5, 4, 2, 6, 5, 9, 6,
398         2, 7, 3, 5, 3, 4, 3, 7, 2, 3, 2, 3, 4, 5, 4, 6,
399         2, 6, 6, 8, 4, 5, 4, 7, 2, 5, 2, 2, 5, 5, 5, 6,
400         2, 7, 2, 5, 3, 4, 3, 7, 2, 3, 2, 4, 4, 5, 4, 6,
401         2, 6, 6, 8, 4, 5, 4, 7, 2, 5, 2, 2, 4, 5, 4, 6,
402         2, 7, 3, 5, 3, 4, 7, 7, 2, 3, 2, 3, 4, 5, 8, 6,
403         2, 6, 6, 8, 6, 5, 8, 7, 2, 5, 3, 3, 6, 5, 9, 6,
404         2, 7, 3, 5, 3, 4, 7, 7, 2, 3, 2, 3, 4, 5, 8, 6,
405         2, 6, 6, 8, 5, 5, 8, 7, 2, 5, 4, 2, 6, 5, 9, 6
406 };
407
408 uint8 S9xE0M1X0 [256] = {
409         8, 6, 8, 4, 5, 3, 5, 6, 3, 2, 2, 4, 6, 4, 6, 5,         /* e=0, m=1, x=0 */
410         2, 6, 5, 7, 5, 4, 6, 6, 2, 5, 2, 2, 6, 5, 7, 5,
411         6, 6, 8, 4, 3, 3, 5, 6, 4, 2, 2, 5, 4, 4, 6, 5,
412         2, 6, 5, 7, 4, 4, 6, 6, 2, 5, 2, 2, 5, 5, 7, 5,
413         7, 6, 2, 4, 0, 3, 5, 6, 4, 2, 2, 3, 3, 4, 6, 5,
414         2, 6, 5, 7, 0, 4, 6, 6, 2, 5, 4, 2, 4, 5, 7, 5,
415         6, 6, 6, 4, 3, 3, 5, 6, 5, 2, 2, 6, 5, 4, 6, 5,
416         2, 6, 5, 7, 4, 4, 6, 6, 2, 5, 5, 2, 6, 5, 7, 5,
417         2, 6, 3, 4, 4, 3, 4, 6, 2, 2, 2, 3, 5, 4, 5, 5,
418         2, 6, 5, 7, 5, 4, 5, 6, 2, 5, 2, 2, 4, 5, 5, 5,
419         3, 6, 3, 4, 4, 3, 4, 6, 2, 2, 2, 4, 5, 4, 5, 5,
420         2, 6, 5, 7, 5, 4, 5, 6, 2, 5, 2, 2, 5, 5, 5, 5,
421         3, 6, 3, 4, 4, 3, 6, 6, 2, 2, 2, 3, 5, 4, 6, 5,
422         2, 6, 5, 7, 6, 4, 8, 6, 2, 5, 4, 3, 6, 5, 7, 5,
423         3, 6, 3, 4, 4, 3, 6, 6, 2, 2, 2, 3, 5, 4, 6, 5,
424         2, 6, 5, 7, 5, 4, 8, 6, 2, 5, 5, 2, 6, 5, 7, 5
425 };
426
427 uint8 S9xE0M0X0 [256] = {
428         8, 7, 8, 5, 7, 4, 7, 7, 3, 3, 2, 4, 8, 5, 8, 6,         /* e=0, m=0, x=0 */
429         2, 7, 6, 8, 7, 5, 8, 7, 2, 6, 2, 2, 8, 6, 9, 6,
430         6, 7, 8, 5, 4, 4, 7, 7, 4, 3, 2, 5, 5, 5, 8, 6,
431         2, 7, 6, 8, 5, 5, 8, 7, 2, 6, 2, 2, 6, 6, 9, 6,
432         7, 7, 2, 5, 0, 4, 7, 7, 3, 3, 2, 3, 3, 5, 8, 6,
433         2, 7, 6, 8, 0, 5, 8, 7, 2, 6, 4, 2, 4, 6, 9, 6,
434         6, 7, 6, 5, 4, 4, 7, 7, 4, 3, 2, 6, 5, 5, 8, 6,
435         2, 7, 6, 8, 5, 5, 8, 7, 2, 6, 5, 2, 6, 6, 9, 6,
436         2, 7, 3, 5, 4, 4, 4, 7, 2, 3, 2, 3, 5, 5, 5, 6,
437         2, 7, 6, 8, 5, 5, 5, 7, 2, 6, 2, 2, 5, 6, 6, 6,
438         3, 7, 3, 5, 4, 4, 4, 7, 2, 3, 2, 4, 5, 5, 5, 6,
439         2, 7, 6, 8, 5, 5, 5, 7, 2, 6, 2, 2, 5, 6, 5, 6,
440         3, 7, 3, 5, 4, 4, 7, 7, 2, 3, 2, 3, 5, 5, 8, 6,
441         2, 7, 6, 8, 6, 5, 8, 7, 2, 6, 4, 3, 6, 6, 9, 6,
442         3, 7, 3, 5, 4, 4, 7, 7, 2, 3, 2, 3, 5, 5, 8, 6,
443         2, 7, 6, 8, 5, 5, 8, 7, 2, 6, 5, 2, 6, 6, 9, 6
444 };
445 #endif
446
447 END_EXTERN_C