Previous 15994 Revisions Next

r6120 Sunday 18th October, 2009 at 02:03:34 UTC by Nathan Woods
Reverted CoCo over to an old copy of the 6847 code. I _really_ hate doing this
but this is probably desirable until the GIME is properly emulated.
[src/mess]mess.mak
[src/mess/drivers]coco.c
[src/mess/includes]coco.h
[src/mess/machine]coco.c
[src/mess/video]coco.c coco3.c coco6847.c* coco6847.h*

src/mess/video/coco6847.c
r0r6120
1/*********************************************************************
2
3    coco6847.c
4
5   OBSOLETE Implementation of Motorola 6847 video hardware chip
6
7   Sources:
8   M6847 data sheet
9   M6847T1 info from Rainbow magazine (10/1986-12/1986)
10
11
12   AG  AS  INTEXT  INV  GM2  GM1  GM0
13   --  --  ------  ---  ---  ---  ---
14    0   0       0    0    X    X    X   Internal Alphanumerics
15    0   0       0    1    X    X    X   Internal Alphanumerics Inverted
16    0   0       1    0    X    X    X   External Alphanumerics
17    0   0       1    1    X    X    X   External Alphanumerics Inverted
18    0   1       0    X    X    X    X  Semigraphics 4
19    0   1       1    X    X    X    X  Semigraphics 6
20    1   X       X    X    0    0    0  Graphics CG1 (64x64x4)     (16 bpr)
21    1   X       X    X    0    0    1  Graphics RG1 (128x64x2)   (16 bpr)
22    1   X       X    X    0    1    0  Graphics CG2 (128x64x4)   (32 bpr)
23    1   X       X    X    0    1    1  Graphics RG2 (128x96x2)   (16 bpr)
24    1   X       X    X    1    0    0  Graphics CG3 (128x96x4)   (32 bpr)
25    1   X       X    X    1    0    1  Graphics RG3 (128x192x2)  (16 bpr)
26    1   X       X    X    1    1    0  Graphics CG6 (128x192x4)  (32 bpr)
27    1   X       X    X    1    1    1  Graphics RG6 (256x192x2)  (32 bpr)
28
29   Note: The M6847 relies on an external source (typically a 6883 SAM chip)
30   to feed it bytes; so the BPR (bytes per row) figures are effectively
31   suggestions.  Mismatching modes is responsible for the semigraphic modes
32   on the CoCo.
33
34   Timing:
35   (source Motorola M6847 Manual)
36
37   Horizontal Sync:  Total Period: 227.5 clock cycles
38      @ CLK(0) + DHS_F         - falling edge (high to low)
39      @ CLK(16.5) + DHS_R         - rising edge (low to high)
40      @ CLK(42)               - left border start
41      @ CLK(71.5)               - body start
42      @ CLK(199.5)            - right border start
43      @ CLK(227.5) + DHS_F      - falling edge (high to low)
44      ...
45
46   Field Sync:   Total Period 262*227.5 clock cycles
47      @ CLK(0) + DFS_F         - falling edge (high to low)
48       @ CLK(32*227.5) + DFS_R      - rising edge (low to high)
49      @ CLK(262*227.5) + DFS_F   - falling edge (high to low) (262.5 for the M6847Y)
50
51   DHS_F:   550ns
52   DHS_R:   740ns
53   DFS_F:   520ns
54   DFS_R:   500ns
55
56   The M6847T1 is a later variant of the M6847 chip that implements lower
57   case support and some other nifty features.  This chip is in the CoCo 2B.
58   I have not been able to find a pinout diagram for this chip so I am
59   assuming that the extra text modes on the CoCo 2B are activated by the
60   GM2-0 pins.  This needs to be confirmed.
61
62   TODO: Implement PAL support
63
64**********************************************************************/
65
66#include "driver.h"
67#include "coco6847.h"
68
69#include "debug/debugcpu.h"
70#include "debug/debugcon.h"
71
72
73#define LOG_FS         0
74#define LOG_HS         0
75#define LOG_STATS      0
76#define LOG_PREPARE      0
77
78typedef struct _m6847_variant m6847_variant;
79struct _m6847_variant
80{
81   const UINT8 *fontdata;
82   unsigned int has_lowercase : 1;
83   unsigned int text_offset : 1;
84
85   int frames_per_second;
86   double scanlines_per_frame;
87   double clocks_per_scanline;
88
89   double vblank_scanlines;
90   int top_border_scanlines;
91   int display_scanlines;
92   int bottom_border_scanlines;
93   int vretrace_scanlines;
94
95   double field_sync_scanlines;
96};
97
98typedef struct _m6847_pixel m6847_pixel;
99struct _m6847_pixel
100{
101   UINT8 data;
102   UINT8 attr;
103};
104
105typedef struct _m6847_vdg m6847_vdg;
106struct _m6847_vdg
107{
108   /* callbacks */
109   void (*horizontal_sync_callback)(running_machine *machine, int line);
110   void (*field_sync_callback)(running_machine *machine, int line);
111   UINT8 (*get_attributes)(running_machine *machine, UINT8 c,int scanline, int pos);
112   const UINT8 *(*get_video_ram)(running_machine *machine, int scanline);
113   int (*new_frame_callback)(running_machine *machine);   /* returns whether the M6847 is in charge of this frame */
114   void (*custom_prepare_scanline)(running_machine *machine, int scanline);
115   UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch,int line);
116
117   /* timers */
118   emu_timer *fs_rise_timer;
119   emu_timer *fs_fall_timer;
120   emu_timer *hs_rise_timer;
121   emu_timer *hs_fall_timer;
122
123   /* things that vary according to chip version */
124   attoseconds_t clock_period;
125   attoseconds_t scanline_period;
126   attoseconds_t field_sync_period;
127   attoseconds_t horizontal_sync_period;
128   attoseconds_t vblank_period;
129   int top_border_scanlines;
130   int display_scanlines;
131   int bottom_border_scanlines;
132   const UINT32 *palette;
133
134   /* flags */
135   unsigned int has_lowercase : 1;         /* M6847T1 has lower case */
136   unsigned int has_custom_palette : 1;   /* needed for CoCo 3 */
137   unsigned int text_offset : 2;         /* needed for CoCo 3 */
138
139   /* video state; every scanline the video state for the scanline is copied
140    * here and only rendered in VIDEO_UPDATE */
141   int dirty;
142   int using_custom;
143   UINT32 border[384];
144   UINT8 attrs[384];
145   m6847_pixel screendata[192][32];
146
147   /* saved palette; used with CoCo 3 */
148   UINT32 saved_palette[16];
149
150   /* 2^7 modes, 256/16 character groups, background/foreground */
151   UINT8 colordata[128][256/16][2];
152
153   /* 2^7 modes, 256 characters, 12 scanlines */
154   UINT8 fontdata[128][256][12];
155};
156
157
158
159static void apply_artifacts(running_machine *machine, UINT32 *line);
160
161static m6847_vdg *m6847;
162
163
164static const UINT8 pal_round_fontdata8x12[] =
165{
166   0x00, 0x00, 0x38, 0x44, 0x04, 0x34, 0x4C, 0x4C, 0x38, 0x00, 0x00, 0x00,
167   0x00, 0x00, 0x10, 0x28, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x00, 0x00, 0x00,
168   0x00, 0x00, 0x78, 0x24, 0x24, 0x38, 0x24, 0x24, 0x78, 0x00, 0x00, 0x00,
169   0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
170   0x00, 0x00, 0x78, 0x24, 0x24, 0x24, 0x24, 0x24, 0x78, 0x00, 0x00, 0x00,
171   0x00, 0x00, 0x7C, 0x40, 0x40, 0x70, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00,
172   0x00, 0x00, 0x7C, 0x40, 0x40, 0x70, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,
173   0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x4C, 0x44, 0x38, 0x00, 0x00, 0x00,
174   0x00, 0x00, 0x44, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
175   0x00, 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
176   0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
177   0x00, 0x00, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00, 0x00, 0x00,
178   0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00,
179   0x00, 0x00, 0x44, 0x6C, 0x54, 0x54, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
180   0x00, 0x00, 0x44, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x44, 0x00, 0x00, 0x00,
181   0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
182   0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,
183   0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, 0x00, 0x00, 0x00,
184   0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x00, 0x00, 0x00,
185   0x00, 0x00, 0x38, 0x44, 0x40, 0x38, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
186   0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
187   0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
188   0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, 0x00,
189   0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x54, 0x6C, 0x44, 0x00, 0x00, 0x00,
190   0x00, 0x00, 0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x00, 0x00, 0x00,
191   0x00, 0x00, 0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
192   0x00, 0x00, 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7C, 0x00, 0x00, 0x00,
193   0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x00, 0x00,
194   0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00,
195   0x00, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x00,
196   0x00, 0x00, 0x10, 0x38, 0x54, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
197   0x00, 0x00, 0x00, 0x10, 0x20, 0x7C, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00,
198   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199   0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,
200   0x00, 0x00, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201   0x00, 0x00, 0x28, 0x28, 0x7C, 0x28, 0x7C, 0x28, 0x28, 0x00, 0x00, 0x00,
202   0x00, 0x00, 0x10, 0x3C, 0x50, 0x38, 0x14, 0x78, 0x10, 0x00, 0x00, 0x00,
203   0x00, 0x00, 0x60, 0x64, 0x08, 0x10, 0x20, 0x4C, 0x0C, 0x00, 0x00, 0x00,
204   0x00, 0x00, 0x20, 0x50, 0x50, 0x20, 0x54, 0x48, 0x34, 0x00, 0x00, 0x00,
205   0x00, 0x00, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206   0x00, 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00,
207   0x00, 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00,
208   0x00, 0x00, 0x00, 0x10, 0x54, 0x38, 0x38, 0x54, 0x10, 0x00, 0x00, 0x00,
209   0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
210   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x40, 0x00, 0x00,
211   0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
213   0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00,
214   0x00, 0x00, 0x38, 0x44, 0x4C, 0x54, 0x64, 0x44, 0x38, 0x00, 0x00, 0x00,
215   0x00, 0x00, 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
216   0x00, 0x00, 0x38, 0x44, 0x04, 0x38, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00,
217   0x00, 0x00, 0x38, 0x44, 0x04, 0x08, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
218   0x00, 0x00, 0x08, 0x18, 0x28, 0x48, 0x7C, 0x08, 0x08, 0x00, 0x00, 0x00,
219   0x00, 0x00, 0x7C, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
220   0x00, 0x00, 0x38, 0x40, 0x40, 0x78, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
221   0x00, 0x00, 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00, 0x00,
222   0x00, 0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
223   0x00, 0x00, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x04, 0x38, 0x00, 0x00, 0x00,
224   0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
225   0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x20, 0x00, 0x00,
226   0x00, 0x00, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00,
227   0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00,
228   0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00,
229   0x00, 0x00, 0x38, 0x44, 0x04, 0x08, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,
230
231   /* Lower case */
232   0x00, 0x00, 0x18, 0x24, 0x20, 0x70, 0x20, 0x24, 0x78, 0x00, 0x00, 0x00,
233   0x00, 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00, 0x00, 0x00,
234   0x00, 0x00, 0x40, 0x40, 0x58, 0x64, 0x44, 0x64, 0x58, 0x00, 0x00, 0x00,
235   0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
236   0x00, 0x00, 0x04, 0x04, 0x34, 0x4C, 0x44, 0x4C, 0x34, 0x00, 0x00, 0x00,
237   0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00, 0x00, 0x00,
238   0x00, 0x00, 0x08, 0x14, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
239   0x00, 0x00, 0x00, 0x00, 0x34, 0x4C, 0x44, 0x4C, 0x34, 0x04, 0x38, 0x00,
240   0x00, 0x00, 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
241   0x00, 0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
242   0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00,
243   0x00, 0x00, 0x40, 0x40, 0x48, 0x50, 0x60, 0x50, 0x48, 0x00, 0x00, 0x00,
244   0x00, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
245   0x00, 0x00, 0x00, 0x00, 0x78, 0x54, 0x54, 0x54, 0x54, 0x00, 0x00, 0x00,
246   0x00, 0x00, 0x00, 0x00, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
247   0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
248   0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x78, 0x40, 0x40, 0x00,
249   0x00, 0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x04, 0x00,
250   0x00, 0x00, 0x00, 0x00, 0x58, 0x64, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,
251   0x00, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x38, 0x04, 0x78, 0x00, 0x00, 0x00,
252   0x00, 0x00, 0x20, 0x20, 0x70, 0x20, 0x20, 0x24, 0x18, 0x00, 0x00, 0x00,
253   0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00, 0x00, 0x00,
254   0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00,
255   0x00, 0x00, 0x00, 0x00, 0x44, 0x54, 0x54, 0x28, 0x28, 0x00, 0x00, 0x00,
256   0x00, 0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00,
257   0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x38, 0x00, 0x00,
258   0x00, 0x00, 0x00, 0x00, 0x7C, 0x08, 0x10, 0x20, 0x7C, 0x00, 0x00, 0x00,
259   0x00, 0x00, 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00,
260   0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
261   0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00,
262   0x00, 0x00, 0x20, 0x54, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
263   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
264
265   /* Semigraphics 6 */
266   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
268   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
269   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
270   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
271   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
272   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
273   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
274   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
275   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
276   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
277   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
278   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
279   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
280   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
281   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
282   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
283   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
284   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
285   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
286   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
287   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
288   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
289   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
290   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
291   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
292   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
293   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
294   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
295   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
296   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
297   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
298   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
300   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
301   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
302   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
303   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
304   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
305   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
306   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
307   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
308   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
309   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
310   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
311   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
312   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
313   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
314   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
316   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
317   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
318   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
319   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
320   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
321   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
322   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
323   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
324   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
325   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
326   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
327   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
328   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
329   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
330
331   /* Block Graphics (Semigraphics 4 Graphics ) */
332   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
333   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
334   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
335   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
336   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
337   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
338   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
339   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
340   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
342   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
343   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
344   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
345   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
346   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
347   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
348};
349
350
351
352static const UINT8 pal_square_fontdata8x12[] =
353{
354   0x00, 0x00, 0x00, 0x1C, 0x22, 0x02, 0x1A, 0x2A, 0x2A, 0x1C, 0x00, 0x00,
355   0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x00, 0x00,
356   0x00, 0x00, 0x00, 0x3C, 0x12, 0x12, 0x1C, 0x12, 0x12, 0x3C, 0x00, 0x00,
357   0x00, 0x00, 0x00, 0x1C, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1C, 0x00, 0x00,
358   0x00, 0x00, 0x00, 0x3C, 0x12, 0x12, 0x12, 0x12, 0x12, 0x3C, 0x00, 0x00,
359   0x00, 0x00, 0x00, 0x3E, 0x20, 0x20, 0x3C, 0x20, 0x20, 0x3E, 0x00, 0x00,
360   0x00, 0x00, 0x00, 0x3E, 0x20, 0x20, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00,
361   0x00, 0x00, 0x00, 0x1E, 0x20, 0x20, 0x26, 0x22, 0x22, 0x1E, 0x00, 0x00,
362   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x22, 0x00, 0x00,
363   0x00, 0x00, 0x00, 0x1C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
364   0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x22, 0x22, 0x1C, 0x00, 0x00,
365   0x00, 0x00, 0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22, 0x00, 0x00,
366   0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3E, 0x00, 0x00,
367   0x00, 0x00, 0x00, 0x22, 0x36, 0x2A, 0x2A, 0x22, 0x22, 0x22, 0x00, 0x00,
368   0x00, 0x00, 0x00, 0x22, 0x32, 0x2A, 0x26, 0x22, 0x22, 0x22, 0x00, 0x00,
369   0x00, 0x00, 0x00, 0x3E, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3E, 0x00, 0x00,
370   0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00,
371   0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x2A, 0x24, 0x1A, 0x00, 0x00,
372   0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x28, 0x24, 0x22, 0x00, 0x00,
373   0x00, 0x00, 0x00, 0x1C, 0x22, 0x10, 0x08, 0x04, 0x22, 0x1C, 0x00, 0x00,
374   0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
375   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C, 0x00, 0x00,
376   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00,
377   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x2A, 0x2A, 0x36, 0x22, 0x00, 0x00,
378   0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22, 0x00, 0x00,
379   0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
380   0x00, 0x00, 0x00, 0x3E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3E, 0x00, 0x00,
381   0x00, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x00,
382   0x00, 0x00, 0x00, 0x20, 0x20, 0x10, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00,
383   0x00, 0x00, 0x00, 0x0E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0E, 0x00, 0x00,
384   0x00, 0x00, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
385   0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x3E, 0x10, 0x08, 0x00, 0x00, 0x00,
386   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387   0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00,
388   0x00, 0x00, 0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
389   0x00, 0x00, 0x00, 0x14, 0x14, 0x36, 0x00, 0x36, 0x14, 0x14, 0x00, 0x00,
390   0x00, 0x00, 0x00, 0x08, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x08, 0x00, 0x00,
391   0x00, 0x00, 0x00, 0x32, 0x32, 0x04, 0x08, 0x10, 0x26, 0x26, 0x00, 0x00,
392   0x00, 0x00, 0x00, 0x10, 0x28, 0x28, 0x10, 0x2A, 0x24, 0x1A, 0x00, 0x00,
393   0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
394   0x00, 0x00, 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, 0x00,
395   0x00, 0x00, 0x00, 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08, 0x00, 0x00,
396   0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, 0x00, 0x00,
397   0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x00,
398   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x10, 0x20, 0x00, 0x00,
399   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
400   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00,
401   0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00,
402   0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x24, 0x24, 0x24, 0x18, 0x00, 0x00,
403   0x00, 0x00, 0x00, 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
404   0x00, 0x00, 0x00, 0x1C, 0x22, 0x02, 0x1C, 0x20, 0x20, 0x3E, 0x00, 0x00,
405   0x00, 0x00, 0x00, 0x1C, 0x22, 0x02, 0x0C, 0x02, 0x22, 0x1C, 0x00, 0x00,
406   0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x3E, 0x04, 0x04, 0x04, 0x00, 0x00,
407   0x00, 0x00, 0x00, 0x3E, 0x20, 0x3C, 0x02, 0x02, 0x22, 0x1C, 0x00, 0x00,
408   0x00, 0x00, 0x00, 0x1C, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x1C, 0x00, 0x00,
409   0x00, 0x00, 0x00, 0x3E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00,
410   0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x1C, 0x22, 0x22, 0x1C, 0x00, 0x00,
411   0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x1E, 0x02, 0x02, 0x1C, 0x00, 0x00,
412   0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
413   0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00,
414   0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00,
415   0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00,
416   0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00,
417   0x00, 0x00, 0x00, 0x18, 0x24, 0x04, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00,
418
419   /* Lower case */
420   0x00, 0x00, 0x00, 0x0C, 0x12, 0x10, 0x38, 0x10, 0x12, 0x3C, 0x00, 0x00,
421   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x02, 0x1E, 0x22, 0x1E, 0x00, 0x00,
422   0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x3C, 0x00, 0x00,
423   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x20, 0x20, 0x1C, 0x00, 0x00,
424   0x00, 0x00, 0x00, 0x02, 0x02, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x00, 0x00,
425   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x3E, 0x20, 0x1C, 0x00, 0x00,
426   0x00, 0x00, 0x00, 0x0C, 0x12, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00,
427   0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x1C,
428   0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00,
429   0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
430   0x00, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x24, 0x18,
431   0x00, 0x00, 0x00, 0x20, 0x20, 0x24, 0x28, 0x38, 0x24, 0x22, 0x00, 0x00,
432   0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
433   0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, 0x00,
434   0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x32, 0x22, 0x22, 0x22, 0x00, 0x00,
435   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00, 0x00,
436   0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x22, 0x3C, 0x20, 0x20,
437   0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x03,
438   0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
439   0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x00, 0x00,
440   0x00, 0x00, 0x00, 0x10, 0x3C, 0x10, 0x10, 0x10, 0x12, 0x0C, 0x00, 0x00,
441   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x26, 0x1A, 0x00, 0x00,
442   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x14, 0x08, 0x00, 0x00,
443   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x2A, 0x2A, 0x1C, 0x14, 0x00, 0x00,
444   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, 0x00,
445   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x1C,
446   0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x04, 0x08, 0x10, 0x3E, 0x00, 0x00,
447   0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, 0x00, 0x00,
448   0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00,
449   0x00, 0x00, 0x00, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08, 0x00, 0x00,
450   0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x00,
451   0x00, 0x00, 0x00, 0x08, 0x04, 0x3E, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
452
453   /* Semigraphics 6 */
454   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
455   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
456   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
457   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
458   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
459   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
460   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
461   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
462   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
463   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
464   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
465   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
466   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
467   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
468   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
469   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
470   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
471   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
472   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
473   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
474   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
475   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
476   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
477   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
478   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
479   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
480   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
481   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
482   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
483   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
484   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
485   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
486   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
487   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
488   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
489   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
490   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
491   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
492   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
493   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
494   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
495   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
496   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
497   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
498   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
499   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
500   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
501   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
502   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
503   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
504   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
505   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
506   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
507   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
508   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
509   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
510   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
511   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
512   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
513   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
514   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
515   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
516   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
517   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
518
519   /* Block Graphics (Semigraphics 4 Graphics ) */
520   0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,
521   0x00,0x00,0x00,0x00,0x00,0x00, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
522   0x00,0x00,0x00,0x00,0x00,0x00, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
523   0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,
524   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0x00,0x00,0x00,0x00,0x00,0x00,
525   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
526   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
527   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0xff,0xff,0xff,0xff,0xff,0xff,
528   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0x00,0x00,0x00,0x00,0x00,0x00,
529   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
530   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
531   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0xff,0xff,0xff,0xff,0xff,0xff,
532   0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x00,0x00,0x00,0x00,
533   0xff,0xff,0xff,0xff,0xff,0xff, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
534   0xff,0xff,0xff,0xff,0xff,0xff, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
535   0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
536};
537
538
539
540static const UINT8 ntsc_round_fontdata8x12[] =
541{
542   0x00, 0x00, 0x38, 0x44, 0x04, 0x34, 0x4C, 0x4C, 0x38, 0x00, 0x00, 0x00,
543   0x00, 0x00, 0x10, 0x28, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x00, 0x00, 0x00,
544   0x00, 0x00, 0x78, 0x24, 0x24, 0x38, 0x24, 0x24, 0x78, 0x00, 0x00, 0x00,
545   0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
546   0x00, 0x00, 0x78, 0x24, 0x24, 0x24, 0x24, 0x24, 0x78, 0x00, 0x00, 0x00,
547   0x00, 0x00, 0x7C, 0x40, 0x40, 0x70, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00,
548   0x00, 0x00, 0x7C, 0x40, 0x40, 0x70, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,
549   0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x4C, 0x44, 0x38, 0x00, 0x00, 0x00,
550   0x00, 0x00, 0x44, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
551   0x00, 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
552   0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
553   0x00, 0x00, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00, 0x00, 0x00,
554   0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00,
555   0x00, 0x00, 0x44, 0x6C, 0x54, 0x54, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
556   0x00, 0x00, 0x44, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x44, 0x00, 0x00, 0x00,
557   0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
558   0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,
559   0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, 0x00, 0x00, 0x00,
560   0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x00, 0x00, 0x00,
561   0x00, 0x00, 0x38, 0x44, 0x40, 0x38, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
562   0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
563   0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
564   0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, 0x00,
565   0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x54, 0x6C, 0x44, 0x00, 0x00, 0x00,
566   0x00, 0x00, 0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x00, 0x00, 0x00,
567   0x00, 0x00, 0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
568   0x00, 0x00, 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7C, 0x00, 0x00, 0x00,
569   0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x00, 0x00,
570   0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00,
571   0x00, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x00,
572   0x00, 0x00, 0x10, 0x38, 0x54, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
573   0x00, 0x00, 0x00, 0x10, 0x20, 0x7C, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00,
574   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
575   0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,
576   0x00, 0x00, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
577   0x00, 0x00, 0x28, 0x28, 0x7C, 0x28, 0x7C, 0x28, 0x28, 0x00, 0x00, 0x00,
578   0x00, 0x00, 0x10, 0x3C, 0x50, 0x38, 0x14, 0x78, 0x10, 0x00, 0x00, 0x00,
579   0x00, 0x00, 0x60, 0x64, 0x08, 0x10, 0x20, 0x4C, 0x0C, 0x00, 0x00, 0x00,
580   0x00, 0x00, 0x20, 0x50, 0x50, 0x20, 0x54, 0x48, 0x34, 0x00, 0x00, 0x00,
581   0x00, 0x00, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
582   0x00, 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00,
583   0x00, 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00,
584   0x00, 0x00, 0x00, 0x10, 0x54, 0x38, 0x38, 0x54, 0x10, 0x00, 0x00, 0x00,
585   0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
586   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x40, 0x00, 0x00,
587   0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
588   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
589   0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00,
590   0x00, 0x00, 0x38, 0x44, 0x4C, 0x54, 0x64, 0x44, 0x38, 0x00, 0x00, 0x00,
591   0x00, 0x00, 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
592   0x00, 0x00, 0x38, 0x44, 0x04, 0x38, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00,
593   0x00, 0x00, 0x38, 0x44, 0x04, 0x08, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
594   0x00, 0x00, 0x08, 0x18, 0x28, 0x48, 0x7C, 0x08, 0x08, 0x00, 0x00, 0x00,
595   0x00, 0x00, 0x7C, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
596   0x00, 0x00, 0x38, 0x40, 0x40, 0x78, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
597   0x00, 0x00, 0x7C, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00, 0x00,
598   0x00, 0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
599   0x00, 0x00, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x04, 0x38, 0x00, 0x00, 0x00,
600   0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
601   0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x20, 0x00, 0x00,
602   0x00, 0x00, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00,
603   0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00,
604   0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00,
605   0x00, 0x00, 0x38, 0x44, 0x04, 0x08, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,
606
607   /* Lower case */
608   0x00, 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
609   0x00, 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00, 0x00, 0x00,
610   0x00, 0x00, 0x40, 0x40, 0x58, 0x64, 0x44, 0x64, 0x58, 0x00, 0x00, 0x00,
611   0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
612   0x00, 0x00, 0x04, 0x04, 0x34, 0x4C, 0x44, 0x4C, 0x34, 0x00, 0x00, 0x00,
613   0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x38, 0x00, 0x00, 0x00,
614   0x00, 0x00, 0x08, 0x14, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
615   0x00, 0x00, 0x00, 0x00, 0x34, 0x4C, 0x44, 0x4C, 0x34, 0x04, 0x38, 0x00,
616   0x00, 0x00, 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
617   0x00, 0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
618   0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00,
619   0x00, 0x00, 0x40, 0x40, 0x48, 0x50, 0x60, 0x50, 0x48, 0x00, 0x00, 0x00,
620   0x00, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00,
621   0x00, 0x00, 0x00, 0x00, 0x78, 0x54, 0x54, 0x54, 0x54, 0x00, 0x00, 0x00,
622   0x00, 0x00, 0x00, 0x00, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
623   0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
624   0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x78, 0x40, 0x40, 0x00,
625   0x00, 0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x04, 0x00,
626   0x00, 0x00, 0x00, 0x00, 0x58, 0x64, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,
627   0x00, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x38, 0x04, 0x78, 0x00, 0x00, 0x00,
628   0x00, 0x00, 0x20, 0x20, 0x70, 0x20, 0x20, 0x24, 0x18, 0x00, 0x00, 0x00,
629   0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00, 0x00, 0x00,
630   0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00,
631   0x00, 0x00, 0x00, 0x00, 0x44, 0x54, 0x54, 0x28, 0x28, 0x00, 0x00, 0x00,
632   0x00, 0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00,
633   0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x38, 0x00, 0x00,
634   0x00, 0x00, 0x00, 0x00, 0x7C, 0x08, 0x10, 0x20, 0x7C, 0x00, 0x00, 0x00,
635   0x00, 0x00, 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00,
636   0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
637   0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00,
638   0x00, 0x00, 0x20, 0x54, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
639   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00,
640
641   /* Semigraphics 6 */
642   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
643   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
644   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
645   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
646   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
647   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
648   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
649   0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
650   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
651   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
652   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
653   0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
654   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
655   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
656   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
657   0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
658   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
659   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
660   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
661   0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
662   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
663   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
664   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
665   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
666   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
667   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
668   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
669   0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
670   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
671   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
672   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
673   0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
674   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
675   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
676   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
677   0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
678   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
679   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
680   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
681   0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
682   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
683   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
684   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
685   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
686   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
687   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
688   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
689   0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
690   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
691   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
692   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0,
693   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
694   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
695   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
696   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0,
697   0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF,
698   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00,
699   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F,
700   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
701   0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
702   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
703   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F,
704   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0,
705   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
706
707   /* Block Graphics (Semigraphics 4 Graphics ) */
708   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
709   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
710   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
711   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
712   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
713   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
714   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
715   0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
716   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
717   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
718   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
719   0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
720   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
721   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
722   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
723   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
724};
725
726
727
728static const UINT8 ntsc_square_fontdata8x12[] =
729{
730   0x00, 0x00, 0x00, 0x1C, 0x22, 0x02, 0x1A, 0x2A, 0x2A, 0x1C, 0x00, 0x00,
731   0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x00, 0x00,
732   0x00, 0x00, 0x00, 0x3C, 0x12, 0x12, 0x1C, 0x12, 0x12, 0x3C, 0x00, 0x00,
733   0x00, 0x00, 0x00, 0x1C, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1C, 0x00, 0x00,
734   0x00, 0x00, 0x00, 0x3C, 0x12, 0x12, 0x12, 0x12, 0x12, 0x3C, 0x00, 0x00,
735   0x00, 0x00, 0x00, 0x3E, 0x20, 0x20, 0x38, 0x20, 0x20, 0x3E, 0x00, 0x00,
736   0x00, 0x00, 0x00, 0x3E, 0x20, 0x20, 0x38, 0x20, 0x20, 0x20, 0x00, 0x00,
737   0x00, 0x00, 0x00, 0x1E, 0x20, 0x20, 0x26, 0x22, 0x22, 0x1E, 0x00, 0x00,
738   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x22, 0x00, 0x00,
739   0x00, 0x00, 0x00, 0x1C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
740   0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x22, 0x22, 0x1C, 0x00, 0x00,
741   0x00, 0x00, 0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22, 0x00, 0x00,
742   0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3E, 0x00, 0x00,
743   0x00, 0x00, 0x00, 0x22, 0x36, 0x2A, 0x2A, 0x22, 0x22, 0x22, 0x00, 0x00,
744   0x00, 0x00, 0x00, 0x22, 0x32, 0x2A, 0x26, 0x22, 0x22, 0x22, 0x00, 0x00,
745   0x00, 0x00, 0x00, 0x3E, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3E, 0x00, 0x00,
746   0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00,
747   0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x2A, 0x24, 0x1A, 0x00, 0x00,
748   0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x3C, 0x28, 0x24, 0x22, 0x00, 0x00,
749   0x00, 0x00, 0x00, 0x1C, 0x22, 0x10, 0x08, 0x04, 0x22, 0x1C, 0x00, 0x00,
750   0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
751   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C, 0x00, 0x00,
752   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00,
753   0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x2A, 0x2A, 0x36, 0x22, 0x00, 0x00,
754   0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22, 0x00, 0x00,
755   0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
756   0x00, 0x00, 0x00, 0x3E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3E, 0x00, 0x00,
757   0x00, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x00,
758   0x00, 0x00, 0x00, 0x20, 0x20, 0x10, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00,
759   0x00, 0x00, 0x00, 0x0E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0E, 0x00, 0x00,
760   0x00, 0x00, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
761   0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x3E, 0x10, 0x08, 0x00, 0x00, 0x00,
762   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
763   0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00,
764   0x00, 0x00, 0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
765   0x00, 0x00, 0x00, 0x14, 0x14, 0x36, 0x00, 0x36, 0x14, 0x14, 0x00, 0x00,
766   0x00, 0x00, 0x00, 0x08, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x08, 0x00, 0x00,
767   0x00, 0x00, 0x00, 0x32, 0x32, 0x04, 0x08, 0x10, 0x26, 0x26, 0x00, 0x00,
768   0x00, 0x00, 0x00, 0x10, 0x28, 0x28, 0x10, 0x2A, 0x24, 0x1A, 0x00, 0x00,
769   0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
770   0x00, 0x00, 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, 0x00,
771   0x00, 0x00, 0x00, 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08, 0x00, 0x00,
772   0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x3E, 0x1C, 0x08, 0x00, 0x00, 0x00,
773   0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x00,
774   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x10, 0x20, 0x00, 0x00,
775   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
776   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00,
777   0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00,
778   0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x24, 0x24, 0x24, 0x18, 0x00, 0x00,
779   0x00, 0x00, 0x00, 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
780   0x00, 0x00, 0x00, 0x1C, 0x22, 0x02, 0x1C, 0x20, 0x20, 0x3E, 0x00, 0x00,
781   0x00, 0x00, 0x00, 0x1C, 0x22, 0x02, 0x04, 0x02, 0x22, 0x1C, 0x00, 0x00,
782   0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x3E, 0x04, 0x04, 0x04, 0x00, 0x00,
783   0x00, 0x00, 0x00, 0x3E, 0x20, 0x3C, 0x02, 0x02, 0x22, 0x1C, 0x00, 0x00,
784   0x00, 0x00, 0x00, 0x1C, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x1C, 0x00, 0x00,
785   0x00, 0x00, 0x00, 0x3E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00,
786   0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x1C, 0x22, 0x22, 0x1C, 0x00, 0x00,
787   0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x1E, 0x02, 0x02, 0x1C, 0x00, 0x00,
788   0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
789   0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00,
790   0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00,
791   0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00,
792   0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00,
793   0x00, 0x00, 0x00, 0x18, 0x24, 0x04, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00,
794
795   /* Lower case */
796   0x00, 0x00, 0x00, 0x0C, 0x12, 0x10, 0x38, 0x10, 0x12, 0x3C, 0x00, 0x00,
797   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x02, 0x1E, 0x22, 0x1E, 0x00, 0x00,
798   0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x3C, 0x00, 0x00,
799   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x20, 0x20, 0x1C, 0x00, 0x00,
800   0x00, 0x00, 0x00, 0x02, 0x02, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x00, 0x00,
801   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x3E, 0x20, 0x1C, 0x00, 0x00,
802   0x00, 0x00, 0x00, 0x0C, 0x12, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00,
803   0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x1C,
804   0x00, 0x00, 0x00, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00,
805   0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
806   0x00, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x24, 0x18,
807   0x00, 0x00, 0x00, 0x20, 0x20, 0x24, 0x28, 0x38, 0x24, 0x22, 0x00, 0x00,
808   0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00,
809   0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x2A, 0x2A, 0x2A, 0x2A, 0x00, 0x00,
810   0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x32, 0x22, 0x22, 0x22, 0x00, 0x00,
811   0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00, 0x00,
812   0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x22, 0x3C, 0x20, 0x20,
813   0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x03,
814   0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
815   0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x00, 0x00,
816   0x00, 0x00, 0x00, 0x10, 0x3C, 0x10, 0x10, 0x10, 0x12, 0x0C, 0x00, 0x00,
817   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x26, 0x1A, 0x00, 0x00,
818   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x14, 0x08, 0x00, 0x00,
819   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x2A, 0x2A, 0x1C, 0x14, 0x00, 0x00,
820   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, 0x00,
821   0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x1E, 0x02, 0x1C,
822   0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x04, 0x08, 0x10, 0x3E, 0x00, 0x00,
823   0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, 0x00, 0x00,
824   0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00,
825   0x00, 0x00, 0x00, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08, 0x00, 0x00,
826   0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x00,
827   0x00, 0x00, 0x00, 0x08, 0x04, 0x3E, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
828
829   /* Semigraphics 6 */
830   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
831   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
832   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
833   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
834   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
835   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
836   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
837   0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
838   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
839   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
840   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
841   0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
842   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
843   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
844   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
845   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
846   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
847   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
848   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
849   0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
850   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
851   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
852   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
853   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
854   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
855   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
856   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
857   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
858   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
859   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
860   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
861   0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
862   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
863   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
864   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
865   0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
866   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
867   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
868   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
869   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
870   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
871   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
872   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
873   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
874   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
875   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
876   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
877   0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
878   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
879   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f,
880   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0,
881   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
882   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00,
883   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
884   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
885   0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
886   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00,
887   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
888   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
889   0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff,
890   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
891   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f,
892   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
893   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
894
895   /* Block Graphics (Semigraphics 4 Graphics ) */
896   0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,
897   0x00,0x00,0x00,0x00,0x00,0x00, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
898   0x00,0x00,0x00,0x00,0x00,0x00, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
899   0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,
900   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0x00,0x00,0x00,0x00,0x00,0x00,
901   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
902   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
903   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0xff,0xff,0xff,0xff,0xff,0xff,
904   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0x00,0x00,0x00,0x00,0x00,0x00,
905   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
906   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
907   0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, 0xff,0xff,0xff,0xff,0xff,0xff,
908   0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x00,0x00,0x00,0x00,
909   0xff,0xff,0xff,0xff,0xff,0xff, 0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
910   0xff,0xff,0xff,0xff,0xff,0xff, 0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
911   0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff
912};
913
914
915
916enum
917{
918   GREEN, YELLOW, BLUE, RED,      /*  0 -  3 */
919   BUFF, CYAN, MAGENTA, ORANGE,   /*  4 -  7 */
920
921   BLACK,                     /*  8 */
922
923   DKGREEN = 12, LTGREEN = 13,      /* 12 - 13 */
924   DKORANGE = 14, LTORANGE = 15,   /* 14 - 15 */
925};
926
927
928
929
930#define ATTOTIME_STRING_PRECISION   9
931
932#define M6847_RGB(r,g,b)   ((r << 16) | (g << 8) | (b << 0))
933
934
935static const UINT32 palette[] =
936{
937   M6847_RGB(0x00, 0xff, 0x00),   /* GREEN */
938   M6847_RGB(0xff, 0xff, 0x00),   /* YELLOW */
939   M6847_RGB(0x00, 0x00, 0xff),   /* BLUE */
940   M6847_RGB(0xff, 0x00, 0x00),   /* RED */
941   M6847_RGB(0xff, 0xff, 0xff),   /* BUFF */
942   M6847_RGB(0x00, 0xff, 0xff),   /* CYAN */
943   M6847_RGB(0xff, 0x00, 0xff),   /* MAGENTA */
944   M6847_RGB(0xff, 0x80, 0x00),   /* ORANGE */
945
946   M6847_RGB(0x00, 0x00, 0x00),   /* BLACK */
947   M6847_RGB(0x00, 0xff, 0x00),   /* GREEN */
948   M6847_RGB(0x00, 0x00, 0x00),   /* BLACK */
949   M6847_RGB(0xff, 0xff, 0xff),   /* BUFF */
950
951   M6847_RGB(0x00, 0x40, 0x00),   /* ALPHANUMERIC DARK GREEN */
952   M6847_RGB(0x00, 0xff, 0x00),   /* ALPHANUMERIC BRIGHT GREEN */
953   M6847_RGB(0x40, 0x10, 0x00),   /* ALPHANUMERIC DARK ORANGE */
954   M6847_RGB(0xff, 0xc4, 0x18)      /* ALPHANUMERIC BRIGHT ORANGE */
955};
956
957
958
959#define FACTOR_SCANLINES_PER_FRAME   2
960#define FACTOR_CLOCKS_PER_SCANLINE   2
961
962#define GROSS_FACTOR   (FACTOR_SCANLINES_PER_FRAME * FACTOR_CLOCKS_PER_SCANLINE)
963
964static const m6847_variant variants[] =
965{
966   {
967      /* M6847_VERSION_ORIGINAL_NTSC */
968      ntsc_square_fontdata8x12,
969      FALSE, 0,
970      60, 262, 227.5,            /* frames, scanlines, clocks per scanline */
971      13, 25, 192, 26, 6,
972      13+25+192               /* field sync period */
973   },
974   {
975      /* M6847_VERSION_ORIGINAL_PAL */
976      pal_square_fontdata8x12,
977      FALSE, 0,
978      50, 262, 227.5,            /* frames, scanlines, clocks per scanline */
979      13, 25, 192, 26, 6,
980      13+25+192               /* field sync period */
981   },
982   {
983      /* M6847_VERSION_M6847Y_NTSC */
984      ntsc_square_fontdata8x12,
985      FALSE, 0,
986      60, 262.5, 227.5,         /* frames, scanlines, clocks per scanline */
987      13.5, 25, 192, 26, 6,
988      13+25+192               /* field sync period */
989   },
990   {
991      /* M6847_VERSION_M6847Y_PAL */
992      pal_square_fontdata8x12,
993      FALSE, 0,
994      50, 262.5, 227.5,         /* frames, scanlines, clocks per scanline */
995      13.5, 25, 192, 26, 6,
996      13+25+192               /* field sync period */
997   },
998   {
999      /* M6847_VERSION_M6847T1_NTSC */
1000      ntsc_round_fontdata8x12,
1001      TRUE, 0,
1002      60, 262.5, 227.5,         /* frames, scanlines, clocks per scanline */
1003      13.5, 25, 192, 26, 6,
1004      13+25+192               /* field sync period */
1005   },
1006   {
1007      /* M6847_VERSION_M6847T1_PAL */
1008      pal_round_fontdata8x12,
1009      TRUE, 0,
1010      50, 262.5, 227.5,         /* frames, scanlines, clocks per scanline */
1011      13.5, 25, 192, 26, 6,
1012      13+25+192               /* field sync period */
1013   },
1014   {
1015      /* M6847_VERSION_GIME_NTSC */
1016      ntsc_round_fontdata8x12,
1017      TRUE, 1,
1018      60, 262.5, 227.5,         /* frames, scanlines, clocks per scanline */
1019      13.5, 25, 192, 26, 6,
1020      262.5 - 3               /* field sync period */
1021   },
1022   {
1023      /* M6847_VERSION_GIME_PAL */
1024      pal_round_fontdata8x12,
1025      TRUE, 1,
1026      50, 262.5, 227.5,         /* frames, scanlines, clocks per scanline */
1027      13.5, 25, 192, 26, 6,
1028      262.5 - 3               /* field sync period */
1029   }
1030};
1031
1032
1033
1034/*************************************
1035 *
1036 *  Utilities
1037 *
1038 *************************************/
1039
1040static UINT32 color(int c)
1041{
1042   return m6847->palette[c];
1043}
1044
1045
1046
1047static int attr_index_from_attribute(UINT8 attr)
1048{
1049   int result;
1050
1051   result = ((attr & (M6847_AG | M6847_AS | M6847_INTEXT | M6847_INV | M6847_CSS)) >> 3)
1052      | ((attr & (M6847_GM1 | M6847_GM0)) << 5);
1053
1054   /* sanity check */
1055   assert(result < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]));
1056   return result;
1057}
1058
1059
1060
1061static UINT8 attribute_from_attr_index(int attr_index)
1062{
1063   /* sanity check */
1064   assert(attr_index >= 0);
1065   assert(attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]));
1066
1067   return (UINT8) ((attr_index & 0x1F) << 3)
1068      | ((attr_index & 0x60) >> 5);
1069}
1070
1071
1072
1073/*************************************
1074 *
1075 *  Video modes
1076 *
1077 *************************************/
1078
1079static void graphics_color_64(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1080{
1081   int x;
1082   UINT8 byte, attr;
1083
1084   for (x = 0; x < 16; x++)
1085   {
1086      byte = video_data[x].data;
1087      attr = video_data[x].attr;
1088
1089      line[ 0] = line[ 1] = line[ 2] = line[ 3] = color(((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1090      line[ 4] = line[ 5] = line[ 6] = line[ 7] = color(((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1091      line[ 8] = line[ 9] = line[10] = line[11] = color(((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1092      line[12] = line[13] = line[14] = line[15] = color(((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1093      line += 16;
1094   }
1095}
1096
1097
1098
1099static void graphics_color_128(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1100{
1101   int x;
1102   UINT8 byte, attr;
1103
1104   for (x = 0; x < 32; x++)
1105   {
1106      byte = video_data[x].data;
1107      attr = video_data[x].attr;
1108
1109      line[ 0] = line[ 1] = color(((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1110      line[ 2] = line[ 3] = color(((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1111      line[ 4] = line[ 5] = color(((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1112      line[ 6] = line[ 7] = color(((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1113      line += 8;
1114   }
1115}
1116
1117
1118
1119static void graphics_bw_128(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1120{
1121   int x;
1122   UINT8 byte, attr;
1123   UINT32 bg, fg;
1124
1125   for (x = 0; x < 16; x++)
1126   {
1127      byte = video_data[x].data;
1128      attr = video_data[x].attr;
1129
1130      bg = color(attr & M6847_CSS ? 10 :  8);
1131      fg = color(attr & M6847_CSS ? 11 :  9);
1132
1133      line[ 0] = line[ 1] = ((byte >> 7) & 0x01) ? fg : bg;
1134      line[ 2] = line[ 3] = ((byte >> 6) & 0x01) ? fg : bg;
1135      line[ 4] = line[ 5] = ((byte >> 5) & 0x01) ? fg : bg;
1136      line[ 6] = line[ 7] = ((byte >> 4) & 0x01) ? fg : bg;
1137      line[ 8] = line[ 9] = ((byte >> 3) & 0x01) ? fg : bg;
1138      line[10] = line[11] = ((byte >> 2) & 0x01) ? fg : bg;
1139      line[12] = line[13] = ((byte >> 1) & 0x01) ? fg : bg;
1140      line[14] = line[15] = ((byte >> 0) & 0x01) ? fg : bg;
1141      line += 16;
1142   }
1143}
1144
1145
1146
1147static void graphics_bw_256(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1148{
1149   int x;
1150   UINT8 byte, attr;
1151   UINT32 bg, fg;
1152
1153   for (x = 0; x < 32; x++)
1154   {
1155      byte = video_data[x].data;
1156      attr = video_data[x].attr;
1157
1158      bg = color(attr & M6847_CSS ? 10 :  8);
1159      fg = color(attr & M6847_CSS ? 11 :  9);
1160
1161      line[0] = ((byte >> 7) & 0x01) ? fg : bg;
1162      line[1] = ((byte >> 6) & 0x01) ? fg : bg;
1163      line[2] = ((byte >> 5) & 0x01) ? fg : bg;
1164      line[3] = ((byte >> 4) & 0x01) ? fg : bg;
1165      line[4] = ((byte >> 3) & 0x01) ? fg : bg;
1166      line[5] = ((byte >> 2) & 0x01) ? fg : bg;
1167      line[6] = ((byte >> 1) & 0x01) ? fg : bg;
1168      line[7] = ((byte >> 0) & 0x01) ? fg : bg;
1169      line += 8;
1170   }
1171}
1172
1173
1174
1175static void (*const graphics_modes[8])(UINT32 *line, const m6847_pixel *video_data) =
1176{
1177   graphics_color_64,   graphics_bw_128,
1178   graphics_color_128,   graphics_bw_128,
1179   graphics_color_128,   graphics_bw_128,
1180   graphics_color_128,   graphics_bw_256
1181};
1182
1183
1184
1185static void text_mode(running_machine *machine, int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1186{
1187   int x;
1188   UINT8 byte, attr;
1189   int attr_index;
1190   UINT32 bg_color, fg_color;
1191   UINT8 char_data;
1192
1193   for (x = 0; x < 32; x++)
1194   {
1195      byte = video_data[x].data;
1196      attr = video_data[x].attr;
1197
1198      attr_index = attr_index_from_attribute(attr);
1199
1200      bg_color = color(m6847->colordata[attr_index][byte / 16][0]);
1201      fg_color = color(m6847->colordata[attr_index][byte / 16][1]);
1202
1203      if( (!m6847->has_lowercase) && (attr & M6847_INTEXT) && !(attr & M6847_AS)) {
1204         if (m6847->get_char_rom) {
1205            char_data = m6847->get_char_rom(machine,byte,scanline % 12);
1206         } else {
1207            char_data = 0xff;
1208         }
1209      } else {
1210         if (m6847->get_char_rom)
1211            char_data = m6847->get_char_rom(machine,byte,scanline % 12);
1212         else
1213            char_data = m6847->fontdata[attr_index][byte][scanline % 12];
1214      }
1215
1216      line[x*8+0] = (char_data & 0x80) ? fg_color : bg_color;
1217      line[x*8+1] = (char_data & 0x40) ? fg_color : bg_color;
1218      line[x*8+2] = (char_data & 0x20) ? fg_color : bg_color;
1219      line[x*8+3] = (char_data & 0x10) ? fg_color : bg_color;
1220      line[x*8+4] = (char_data & 0x08) ? fg_color : bg_color;
1221      line[x*8+5] = (char_data & 0x04) ? fg_color : bg_color;
1222      line[x*8+6] = (char_data & 0x02) ? fg_color : bg_color;
1223      line[x*8+7] = (char_data & 0x01) ? fg_color : bg_color;
1224   }
1225}
1226
1227
1228
1229static void render_scanline(running_machine *machine, bitmap_t *bitmap, int scanline)
1230{
1231   UINT32 border_color;
1232   UINT32 *line;
1233   UINT8 attrs;
1234   int mode, x;
1235   const m6847_pixel *video_data;
1236
1237   /* get the scanline */
1238   line = BITMAP_ADDR32(bitmap, scanline, 0);
1239
1240   /* choose the border color */
1241   border_color = m6847->border[scanline];
1242   attrs = m6847->attrs[scanline];
1243
1244   /* is this a border scanline? */
1245   scanline -= m6847->top_border_scanlines;
1246   if ((scanline >= 0) && (scanline < m6847->display_scanlines))
1247   {
1248      video_data = m6847->screendata[scanline];
1249
1250      /* left border */
1251      for (x = 0; x < 32; x++)
1252         line[x] = border_color;
1253
1254      if (attrs & M6847_AG)
1255      {
1256         /* graphics */
1257         mode = attrs & (M6847_GM2|M6847_GM1|M6847_GM0);
1258         graphics_modes[mode](line + 32, video_data);
1259      }
1260      else
1261      {
1262         /* text/semigraphics */
1263         text_mode(machine, scanline, line + 32, video_data);
1264      }
1265
1266      /* right border */
1267      for (x = 288; x < 320; x++)
1268         line[x] = border_color;
1269
1270      /* special case for artifacting */
1271      if ((attrs & (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0))
1272         == (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0))
1273      {
1274         apply_artifacts(machine, line + 32);
1275      }
1276   }
1277   else
1278   {
1279      /* we are drawing a border */
1280      for (x = 0; x < bitmap->width; x++)
1281         line[x] = border_color;
1282   }
1283}
1284
1285
1286
1287static void set_dirty(void)
1288{
1289   m6847->dirty = TRUE;
1290}
1291
1292
1293
1294/*************************************
1295 *
1296 *  Artifacting hack; should be in core
1297 *
1298 *************************************/
1299
1300static UINT32 mix_color(double factor, UINT8 c0, UINT8 c1)
1301{
1302   return (UINT32) (UINT8) ((c0 * (1.0 - factor)) + (c1 * (0.0 + factor)) + 0.5);
1303}
1304
1305
1306
1307static void apply_artifacts(running_machine *machine, UINT32 *line)
1308{
1309   /* Boy this code sucks; this code was adapted from the old M6847
1310    * artifacting implmentation.  The only reason that it didn't look as
1311    * horrible was because the code around it sucked as well.  Now that I
1312    * have cleaned everything up, the ugliness is much more prominent.
1313    *
1314    * Hopefully we will have a generic artifacting algorithm that plugs into
1315    * the MESS/MAME core directly so we can chuck this hack */
1316   static const double artifact_colors[14*3] =
1317   {
1318      0.157, 0.000, 0.157, /* [ 1] - dk purple   (reverse  2) */
1319      0.000, 0.157, 0.000, /* [ 2] - dk green    (reverse  1) */
1320      1.000, 0.824, 1.000, /* [ 3] - lt purple   (reverse  4) */
1321      0.824, 1.000, 0.824, /* [ 4] - lt green    (reverse  3) */
1322      0.706, 0.236, 0.118, /* [ 5] - dk blue     (reverse  6) */
1323      0.000, 0.197, 0.471, /* [ 6] - dk red      (reverse  5) */
1324      1.000, 0.550, 0.393, /* [ 7] - lt blue     (reverse  8) */
1325      0.275, 0.785, 1.000, /* [ 8] - lt red      (reverse  7) */
1326      0.000, 0.500, 1.000, /* [ 9] - red         (reverse 10) */
1327      1.000, 0.500, 0.000, /* [10] - blue        (reverse  9) */
1328      1.000, 0.942, 0.785, /* [11] - cyan        (reverse 12) */
1329      0.393, 0.942, 1.000, /* [12] - yellow      (reverse 11) */
1330      0.236, 0.000, 0.000, /* [13] - black-blue  (reverse 14) */
1331      0.000, 0.000, 0.236  /* [14] - black-red   (reverse 13) */
1332   };
1333
1334   static const UINT8 artifactcorrection[128] =
1335   {
1336      0,  0,       0,    0,       0,  6,       0,    2,
1337      5,  7,       5,    7,       1,  3,       1, 11,
1338      8,  6,       8, 14,       8,  9,       8,    9,
1339      4,  4,       4, 15,      12, 12,      12, 15,
1340
1341      5, 13,       5, 13,      13,  0,      13,    2,
1342      10, 10,      10, 10,      10, 15,      10, 11,
1343      3,  1,       3,    1,      15,  9,      15,    9,
1344      11, 11,      11, 11,      15, 15,      15, 15,
1345
1346      14,  0,      14,    0,      14,  6,      14,    2,
1347      0,  7,       0,    7,       1,  3,       1, 11,
1348      9,  6,       9, 14,       9,  9,       9,    9,
1349      15,  4,      15, 15,      12, 12,      12, 15,
1350
1351      2, 13,       2, 13,       2,  0,       2,    2,
1352      10, 10,      10, 10,      10, 15,      10, 11,
1353      12,  1,      12,    1,      12,  9,      12,    9,
1354      15, 11,      15, 11,      15, 15,      15, 15
1355   };
1356
1357   UINT32 artifacting, c0, c1;
1358   UINT32 colors[16];
1359   static UINT32 saved_artifacting, saved_c0, saved_c1;
1360   static UINT32 expanded_colors[128];
1361   const double *factors;
1362   UINT8 val;
1363   UINT32 new_line[256];
1364   int i;
1365
1366   /* are we artifacting? */
1367   artifacting = input_port_read_safe(machine, "artifacting", 0x00) & 0x03;
1368   if (artifacting == 0x00)
1369      return;
1370   artifacting &= 0x01;
1371
1372   /* determine the base artifact colors */
1373   c1 = line[-1];
1374   for (i = 0; i < 256; i++)
1375   {
1376      if (line[i] != c1)
1377         break;
1378   }
1379   if (i >= 256)
1380      return;   /* if everything is the same color as the border, no need for anything */
1381   c0 = line[i];
1382
1383   /* do we need to update our artifact colors table? */
1384   if ((artifacting != saved_artifacting) || (c0 != saved_c0) || (c1 != saved_c1))
1385   {
1386      saved_artifacting = artifacting;
1387      saved_c0 = colors[0] = c0;
1388      saved_c1 = colors[15] = c1;
1389
1390      /* mix the other colors */
1391      for (i = 1; i <= 14; i++)
1392      {
1393         factors = &artifact_colors[((i - 1) ^ artifacting) * 3];
1394
1395         colors[i] =   (mix_color(factors[0], c0 >> 16, c1 >> 16) << 16)
1396               |   (mix_color(factors[1], c0 >>  8, c1 >>  8) <<  8)
1397               |   (mix_color(factors[2], c0 >>  0, c1 >>  0) <<  0);
1398      }
1399      for (i = 0; i < 128; i++)
1400         expanded_colors[i] = colors[artifactcorrection[i]];
1401   }
1402
1403   /* artifact the line */
1404   for (i = 0; i < 256; i += 2)
1405   {
1406      val =   ((line[i - 2] == c1) ? 0x20 : 0x00)
1407         |   ((line[i - 1] == c1) ? 0x10 : 0x00)
1408         |   ((line[i + 0] == c1) ? 0x08 : 0x00)
1409         |   ((line[i + 1] == c1) ? 0x04 : 0x00)
1410         |   ((line[i + 2] == c1) ? 0x02 : 0x00)
1411         |   ((line[i + 3] == c1) ? 0x01 : 0x00);
1412
1413      new_line[i + 0] = expanded_colors[val * 2 + 0];
1414      new_line[i + 1] = expanded_colors[val * 2 + 1];
1415   }
1416
1417   /* and copy the results back */
1418   memcpy(line, new_line, sizeof(*line) * 256);
1419}
1420
1421
1422
1423static INPUT_CHANGED( artifacting_changed )
1424{
1425   set_dirty();
1426}
1427
1428
1429
1430INPUT_PORTS_START( coco6847_artifacting )
1431   PORT_START("artifacting")
1432   PORT_CONFNAME( 0x03, 0x01, "Artifacting" ) PORT_CHANGED(artifacting_changed, NULL)
1433   PORT_CONFSETTING(    0x00, DEF_STR( Off ) )
1434   PORT_CONFSETTING(    0x01, DEF_STR( Standard ) )
1435   PORT_CONFSETTING(    0x02, DEF_STR( Reverse ) )
1436INPUT_PORTS_END
1437
1438
1439
1440/*************************************
1441 *
1442 *  Scanline operations
1443 *
1444 *************************************/
1445
1446static int get_scanline(void)
1447{
1448   int result;
1449   attotime duration;
1450
1451   /* get the time since last field sync */
1452   duration = attotime_sub(
1453      timer_starttime(m6847->hs_rise_timer),
1454      timer_starttime(m6847->fs_rise_timer));
1455   assert_always(duration.seconds == 0, "get_scanline(): duration exceeds one second");
1456
1457   if (duration.attoseconds < m6847->vblank_period)
1458   {
1459      result = -1;   /* vblank */
1460   }
1461   else
1462   {
1463      result = (duration.attoseconds - m6847->vblank_period)
1464         / m6847->scanline_period;
1465   }
1466   return result;
1467}
1468
1469
1470static int get_beamx(void)
1471{
1472   attotime scanline_time;
1473   int result;
1474
1475   scanline_time = timer_timeelapsed(m6847->hs_rise_timer);
1476   if (scanline_time.seconds != 0)
1477      return 0;
1478   assert(attotime_to_attoseconds(scanline_time) < m6847->scanline_period);
1479
1480   if (attotime_to_attoseconds(scanline_time) < (m6847->clock_period * 42))
1481   {
1482      /* hsync */
1483      result = 0;
1484   }
1485   else if (attotime_to_attoseconds(scanline_time) < (m6847->clock_period * 95 / 2))
1486   {
1487      /* left border */
1488      result = 0;
1489   }
1490   else if (attotime_to_attoseconds(scanline_time) < (m6847->clock_period * 351 / 2))
1491   {
1492      /* body */
1493      result = (attotime_to_attoseconds(scanline_time) - (m6847->clock_period * 95 / 2))
1494         / m6847->clock_period * 2;
1495   }
1496   else
1497   {
1498      /* right border */
1499      result = 256;
1500   }
1501   return result;
1502}
1503
1504
1505INLINE void prepare_scanline(running_machine *machine, int xpos)
1506{
1507   UINT8 attrs, data, attr;
1508   int scanline;
1509   int i, border_color;
1510   int dirty;
1511   const UINT8 *RESTRICT video_ram;
1512   m6847_pixel *scanline_data;
1513
1514   scanline = get_scanline();
1515
1516   if (LOG_PREPARE)
1517      logerror("m6847_prepare_scanline(): scanline=%d xpos=%d\n", scanline, xpos);
1518
1519   if ((scanline >= 0) && (scanline < (m6847->top_border_scanlines
1520      + m6847->display_scanlines + m6847->bottom_border_scanlines)))
1521   {
1522      if (m6847->using_custom)
1523      {
1524         m6847->custom_prepare_scanline(machine, scanline);
1525      }
1526      else
1527      {
1528         /* has the border color changed? */
1529         attrs = (*m6847->get_attributes)(machine, 0, 0, 0);
1530         if (attrs != m6847->attrs[scanline])
1531         {
1532            m6847->dirty = TRUE;
1533            m6847->attrs[scanline] = attrs;
1534
1535            /* choose the border color */
1536            if (attrs & M6847_AG)
1537               border_color = (attrs & M6847_CSS) ? BUFF : GREEN;
1538            else if (m6847->has_lowercase && (attrs & M6847_GM2))
1539               border_color = (attrs & M6847_CSS) ? LTORANGE : LTGREEN;
1540            else
1541               border_color = BLACK;
1542
1543            /* need to use palette table directly; border colors are constant */
1544            m6847->border[scanline] = m6847->palette[border_color];
1545         }
1546
1547         /* is this a display scanline? */
1548         scanline -= m6847->top_border_scanlines;
1549         if ((scanline >= 0) && (scanline < m6847->display_scanlines))
1550         {
1551            video_ram = m6847->get_video_ram(machine,scanline);
1552            dirty = m6847->dirty;
1553            scanline_data = m6847->screendata[scanline];
1554
1555            for (i = xpos; i < 32; i++)
1556            {
1557               data = video_ram[i];
1558               attr = (*m6847->get_attributes)(machine, data, scanline, i);
1559
1560               if ((data != scanline_data[i].data)   || (attr != scanline_data[i].attr))
1561               {
1562                  dirty = TRUE;
1563                  scanline_data[i].data = data;
1564                  scanline_data[i].attr = attr;
1565               }
1566            }
1567            m6847->dirty = dirty;
1568         }
1569      }
1570   }
1571}
1572
1573
1574
1575void coco6847_video_changed(void)
1576{
1577   /* NPW 2-May-2006 - Commenting this out until we properly fix bug #878 */
1578   /* prepare_scanline(get_beamx() / 8); */
1579}
1580
1581
1582
1583/*************************************
1584 *
1585 *  Sync callbacks
1586 *
1587 *************************************/
1588
1589int m6847_get_horizontal_sync(running_machine *machine)
1590{
1591   attotime fire_time = timer_firetime(m6847->hs_fall_timer);
1592   return attotime_compare(fire_time, timer_get_time(machine)) > 0;
1593}
1594
1595
1596
1597static void set_horizontal_sync(running_machine *machine)
1598{
1599   attotime fire_time = timer_firetime(m6847->hs_fall_timer);
1600   int horizontal_sync = attotime_compare(fire_time, timer_get_time(machine)) > 0;
1601   if (m6847->horizontal_sync_callback)
1602      m6847->horizontal_sync_callback(machine, !horizontal_sync);
1603}
1604
1605
1606
1607int m6847_get_field_sync(running_machine *machine)
1608{
1609   attotime fire_time = timer_firetime(m6847->fs_fall_timer);
1610   return attotime_compare(fire_time, timer_get_time(machine)) > 0;
1611}
1612
1613
1614
1615static void set_field_sync(running_machine *machine)
1616{
1617   attotime fire_time = timer_firetime(m6847->fs_fall_timer);
1618   int field_sync = attotime_compare(fire_time, timer_get_time(machine)) > 0;
1619   if (m6847->field_sync_callback)
1620      m6847->field_sync_callback(machine,field_sync);
1621}
1622
1623
1624
1625/*************************************
1626 *
1627 *  Field sync/Horizontal sync timers
1628 *
1629 *************************************/
1630
1631static TIMER_CALLBACK(hs_fall)
1632{
1633   if (LOG_HS)
1634      logerror("hs_fall(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION));
1635
1636   set_horizontal_sync(machine);
1637}
1638
1639static TIMER_CALLBACK(hs_rise)
1640{
1641   if (LOG_HS)
1642      logerror("hs_rise(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION));
1643
1644   timer_adjust_oneshot(m6847->hs_rise_timer,
1645      attotime_make(0, m6847->scanline_period), 0);
1646   timer_adjust_oneshot(m6847->hs_fall_timer,
1647      attotime_make(0, m6847->horizontal_sync_period), 0);
1648
1649   set_horizontal_sync(machine);
1650   prepare_scanline(machine,0);
1651}
1652
1653static TIMER_CALLBACK(fs_fall)
1654{
1655   if (LOG_FS)
1656      logerror("fs_fall(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline());
1657
1658   set_field_sync(machine);
1659}
1660
1661static TIMER_CALLBACK(fs_rise)
1662{
1663   if (LOG_FS)
1664      logerror("fs_rise(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline());
1665
1666   /* adjust field sync falling edge timer */
1667   timer_adjust_oneshot(m6847->fs_fall_timer,
1668      attotime_make(0, m6847->field_sync_period), 0);
1669
1670   /* adjust horizontal sync rising timer */
1671   timer_adjust_oneshot(m6847->hs_rise_timer, attotime_zero, 0);
1672
1673   /* this is a hook for the CoCo 3 code to extend this stuff */
1674   if (m6847->new_frame_callback)
1675      m6847->using_custom = !m6847->new_frame_callback(machine);
1676
1677   set_field_sync(machine);
1678}
1679
1680
1681
1682/*************************************
1683 *
1684 *  Debugging
1685 *
1686 *************************************/
1687
1688
1689static void execute_m6847_dumpscanline(running_machine *machine, int ref, int params, const char **param)
1690{
1691   int i;
1692   int beamx = get_beamx() / 8;
1693   int scanline = get_scanline();
1694   const m6847_pixel *pixel = m6847->screendata[scanline];
1695
1696   for (i = 0; i < beamx; i++)
1697   {
1698      debug_console_printf(machine, "[%02d]: 0x%02X (", i, pixel[i].data);
1699
1700      if (pixel[i].attr & M6847_AG)      debug_console_printf(machine, " AG");
1701      if (pixel[i].attr & M6847_AS)      debug_console_printf(machine, " AS");
1702      if (pixel[i].attr & M6847_INTEXT)   debug_console_printf(machine, " INTEXT");
1703      if (pixel[i].attr & M6847_INV)      debug_console_printf(machine, " INV");
1704      if (pixel[i].attr & M6847_CSS)      debug_console_printf(machine, " CSS");
1705      if (pixel[i].attr & M6847_GM2)      debug_console_printf(machine, " GM2");
1706      if (pixel[i].attr & M6847_GM1)      debug_console_printf(machine, " GM1");
1707      if (pixel[i].attr & M6847_GM0)      debug_console_printf(machine, " GM0");
1708
1709      debug_console_printf(machine, " )\n");
1710   }
1711}
1712
1713
1714
1715
1716/*************************************
1717 *
1718 *  Initialization
1719 *
1720 *************************************/
1721
1722static const UINT8 *find_char(const m6847_variant *v,
1723   UINT8 byte, UINT8 attr, int *fg, int *bg)
1724{
1725   int ch;
1726   size_t offset = 0;
1727
1728   if (attr & M6847_AS)
1729   {
1730      /* semigraphics */
1731      *bg = BLACK;
1732
1733      if (!v->has_lowercase && (attr & M6847_INTEXT))
1734      {
1735         /* semigraphics 6 */
1736         ch = (byte & 0x3F) + 0x60;
1737         *fg = ((byte >> 6) & 0x03) + ((attr & M6847_CSS) ? BUFF : GREEN);
1738      }
1739      else
1740      {
1741         /* semigraphics 4 */
1742         ch = (byte & 0x0F) + 0xA0;
1743         *fg = ((byte >> 4) & 0x07) + GREEN;
1744      }
1745   }
1746   else
1747   {
1748      /* text */
1749      ch = (byte & 0x3F) + 0x00;
1750
1751      if (v->has_lowercase)
1752      {
1753         if ((ch < 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV))
1754         {
1755            /* this is a lowercase character */
1756            attr |= M6847_INV;
1757            ch += 0x40;
1758         }
1759
1760         if ((ch > 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV)) {
1761            ch += 0x20;
1762         }
1763
1764         if (attr & M6847_GM1)
1765            attr ^= M6847_INV;
1766
1767      }
1768
1769      if (attr & M6847_INV)
1770      {
1771         /* dark foreground, light background */
1772         *fg = (attr & M6847_CSS) ? DKORANGE : DKGREEN;
1773         *bg = (attr & M6847_CSS) ? LTORANGE : LTGREEN;
1774      }
1775      else
1776      {
1777         /* light foreground, dark background */
1778         *fg = (attr & M6847_CSS) ? LTORANGE : LTGREEN;
1779         *bg = (attr & M6847_CSS) ? DKORANGE : DKGREEN;
1780      }
1781
1782      offset = v->text_offset;
1783   }
1784
1785   return &v->fontdata[ch * 12] + offset;
1786}
1787
1788
1789
1790static void build_fontdata(const m6847_variant *v)
1791{
1792   int attr_index, row;
1793   int fg, bg;
1794   int byte;
1795   const UINT8 *char_data;
1796
1797   for (attr_index = 0; attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]); attr_index++)
1798   {
1799      UINT8 attr = attribute_from_attr_index(attr_index);
1800
1801      for (byte = 0; byte < 256; byte++)
1802      {
1803         char_data = find_char(v, byte, attr, &fg, &bg);
1804
1805         /* specify colors */
1806         m6847->colordata[attr_index][byte / 16][0] = bg;
1807         m6847->colordata[attr_index][byte / 16][1] = fg;
1808
1809         for (row = 0; row < 12; row++)
1810         {
1811            m6847->fontdata[attr_index][byte][row] = char_data[row];
1812         }
1813      }
1814   }
1815}
1816
1817
1818
1819static STATE_POSTLOAD( m6847_postload )
1820{
1821   set_field_sync(machine);
1822   set_horizontal_sync(machine);
1823   set_dirty();
1824}
1825
1826
1827
1828void m6847_init(running_machine *machine, const m6847_config *cfg)
1829{
1830   const m6847_variant *v;
1831   UINT32 frequency;
1832   attoseconds_t period, frame_period, cpu0_clock_period = 0;
1833   double total_scanlines;
1834
1835   /* identify proper M6847 variant */
1836   assert(cfg->type < sizeof(variants) / sizeof(variants[0]));
1837   v = &variants[cfg->type];
1838
1839   /* allocate instance */
1840   m6847 = auto_alloc_clear(machine, m6847_vdg);
1841   set_dirty();
1842
1843   /* copy configuration */
1844   m6847->get_attributes = cfg->get_attributes;
1845   m6847->get_video_ram = cfg->get_video_ram;
1846   m6847->horizontal_sync_callback = cfg->horizontal_sync_callback;
1847   m6847->field_sync_callback = cfg->field_sync_callback;
1848   m6847->new_frame_callback = cfg->new_frame_callback;
1849   m6847->custom_prepare_scanline = cfg->custom_prepare_scanline;
1850   m6847->has_lowercase = v->has_lowercase;
1851   m6847->get_char_rom = cfg->get_char_rom;
1852
1853   /* assert our assumptions */
1854   assert((v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)
1855      == (UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME));
1856   assert((v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE)
1857      == (UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE));
1858   assert((v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR)
1859      == (UINT32) (v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR));
1860
1861   /* choose palette */
1862   if (cfg->custom_palette)
1863   {
1864      m6847->has_custom_palette = 1;
1865      m6847->palette = cfg->custom_palette;
1866   }
1867   else
1868   {
1869      m6847->palette = palette;
1870   }
1871
1872   /* allocate timers */
1873   m6847->fs_rise_timer = timer_alloc(machine, fs_rise, NULL);
1874   m6847->fs_fall_timer = timer_alloc(machine, fs_fall, NULL);
1875   m6847->hs_rise_timer = timer_alloc(machine, hs_rise, NULL);
1876   m6847->hs_fall_timer = timer_alloc(machine, hs_fall, NULL);
1877
1878   /* setup dimensions */
1879   m6847->top_border_scanlines = v->top_border_scanlines;
1880   m6847->display_scanlines = v->display_scanlines;
1881   m6847->bottom_border_scanlines = v->bottom_border_scanlines;
1882
1883   /* compute frequency and period */
1884   frequency = v->frames_per_second
1885      * ((UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME))
1886      * ((UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE));
1887   period = ATTOSECONDS_PER_SECOND / frequency;
1888
1889   /* choose CPU clock, if specified */
1890   if (cfg->cpu0_timing_factor > 0)
1891   {
1892      cpu0_clock_period = period * cfg->cpu0_timing_factor * GROSS_FACTOR;
1893      cpu_set_clock(machine->firstcpu, ATTOSECONDS_PER_SECOND / cpu0_clock_period);
1894   }
1895
1896   /* calculate timing */
1897   total_scanlines = v->vblank_scanlines
1898      + v->top_border_scanlines
1899      + v->display_scanlines
1900      + v->bottom_border_scanlines
1901      + v->vretrace_scanlines;
1902   m6847->clock_period = period * GROSS_FACTOR;
1903   m6847->scanline_period = period * (UINT32) (v->clocks_per_scanline * GROSS_FACTOR);
1904   m6847->field_sync_period = period * (UINT32) (v->clocks_per_scanline * v->field_sync_scanlines * GROSS_FACTOR);
1905   m6847->horizontal_sync_period = period * GROSS_FACTOR * 33 / 2;
1906   m6847->vblank_period = period * (UINT32) (v->clocks_per_scanline * v->vblank_scanlines * GROSS_FACTOR);
1907
1908   /* setup timing */
1909   frame_period = period *
1910      (UINT32) (v->clocks_per_scanline * total_scanlines * GROSS_FACTOR);
1911   timer_adjust_periodic(m6847->fs_rise_timer, attotime_zero, 0, attotime_make(0, frame_period));
1912
1913   /* setup save states */
1914   state_save_register_postload(machine, m6847_postload, NULL);
1915
1916   /* build font */
1917   build_fontdata(v);
1918
1919   /* dump stats */
1920   if (LOG_STATS)
1921   {
1922      logerror("m6847_init():\n");
1923      logerror("\tclock:      %30s sec\n", attotime_string(attotime_make(0, period * GROSS_FACTOR), ATTOTIME_STRING_PRECISION));
1924      if (cpu0_clock_period > 0)
1925         logerror("\tCPU0 clock: %30s sec\n", attotime_string(attotime_make(0, cpu0_clock_period), ATTOTIME_STRING_PRECISION));
1926      logerror("\tscanline:   %30s sec\n", attotime_string(attotime_make(0, m6847->scanline_period), ATTOTIME_STRING_PRECISION));
1927      logerror("\tfield sync: %30s sec\n", attotime_string(attotime_make(0, m6847->field_sync_period), ATTOTIME_STRING_PRECISION));
1928      logerror("\thorz sync:  %30s sec\n", attotime_string(attotime_make(0, m6847->horizontal_sync_period), ATTOTIME_STRING_PRECISION));
1929      logerror("\tvblank:     %30s sec\n", attotime_string(attotime_make(0, m6847->vblank_period), ATTOTIME_STRING_PRECISION));
1930      logerror("\tframe:      %30s sec\n", attotime_string(attotime_make(0, frame_period), ATTOTIME_STRING_PRECISION));
1931      logerror("\n");
1932   }
1933
1934   /* setup debug commands */
1935   if (machine->debug_flags & DEBUG_FLAG_ENABLED)
1936      debug_console_register_command(machine, "m6847_dumpscanline", CMDFLAG_NONE, 0, 0, 0, execute_m6847_dumpscanline);
1937}
1938
1939
1940
1941VIDEO_UPDATE(m6847)
1942{
1943   int row, i;
1944   UINT32 rc = 0;
1945
1946   /* if we have a custom palette, check to see if it has changed */
1947   if (!m6847->dirty && m6847->has_custom_palette)
1948   {
1949      for (i = 0; i < 16; i++)
1950      {
1951         if (m6847->palette[i] != m6847->saved_palette[i])
1952         {
1953            m6847->dirty = TRUE;
1954            break;
1955         }
1956      }
1957   }
1958
1959   if (m6847->dirty)
1960   {
1961      /* this frame is dirty; render it */
1962      m6847->dirty = FALSE;
1963
1964      /* copy palette if we have a custom palete */
1965      if (m6847->has_custom_palette)
1966      {
1967         for (i = 0; i < 16; i++)
1968            m6847->saved_palette[i] = m6847->palette[i];
1969      }
1970
1971      /* the video RAM has been dirtied; need to draw */
1972      for (row = cliprect->min_y; row <= cliprect->max_y; row++)
1973         render_scanline(screen->machine, bitmap, row);
1974   }
1975   else
1976   {
1977      /* skip this frame */
1978      rc = UPDATE_HAS_NOT_CHANGED;
1979   }
1980   return rc;
1981}
1982
1983
1984
1985/*************************************
1986 *
1987 *  Timing calculations
1988 *
1989 *************************************/
1990
1991static UINT64 divide_mame_time(attotime dividend, attotime divisor)
1992{
1993   /* TODO: it should not be necessary to use floating point here */
1994   double dividend_dbl = attotime_to_double(dividend);
1995   double divisor_dbl = attotime_to_double(divisor);
1996   return (UINT64) (dividend_dbl / divisor_dbl);
1997}
1998
1999
2000
2001static attotime interval(m6847_timing_type timing)
2002{
2003   attotime result;
2004
2005   switch(timing)
2006   {
2007      case M6847_CLOCK:
2008         result = attotime_make(0, m6847->clock_period);
2009         break;
2010      case M6847_HSYNC:
2011         result = attotime_make(0, m6847->scanline_period);
2012         break;
2013      default:
2014         fatalerror("invalid timing type");
2015         break;
2016   }
2017   return result;
2018}
2019
2020
2021
2022UINT64 coco6847_time(running_machine *machine, m6847_timing_type timing)
2023{
2024   attotime current_time = timer_get_time(machine);
2025   attotime divisor = interval(timing);
2026   return divide_mame_time(current_time, divisor);
2027}
2028
2029
2030
2031attotime coco6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time)
2032{
2033   attotime target_mame_time, current_time;
2034   target_mame_time = attotime_mul(interval(timing), target_time);
2035   current_time = timer_get_time(machine);
2036
2037   if (attotime_compare(target_mame_time, current_time) < 0)
2038      fatalerror("coco6847_time_until(): cannot target past times");
2039
2040   return attotime_sub(target_mame_time, current_time);
2041}
2042
2043
2044
2045attotime coco6847_scanline_time(int scanline)
2046{
2047   return attotime_make(0, m6847->scanline_period *
2048         (13 /* FIXME */ + scanline));
2049}
src/mess/video/coco6847.h
r0r6120
1/*********************************************************************
2
3    coco6847.h
4
5   OBSOLETE Implementation of Motorola 6847 video hardware chip
6
7**********************************************************************/
8
9#ifndef __COCO6847_H__
10#define __COCO6847_H__
11
12
13/* for now, the MAME core forces us to use these */
14#define M6847_NTSC_FRAMES_PER_SECOND   60
15#define M6847_PAL_FRAMES_PER_SECOND      50
16
17typedef enum
18{
19   M6847_VERSION_ORIGINAL_NTSC,
20   M6847_VERSION_ORIGINAL_PAL,
21   M6847_VERSION_M6847Y_NTSC,
22   M6847_VERSION_M6847Y_PAL,
23   M6847_VERSION_M6847T1_NTSC,
24   M6847_VERSION_M6847T1_PAL,
25   M6847_VERSION_GIME_NTSC,
26   M6847_VERSION_GIME_PAL
27} m6847_type;
28
29enum
30{
31   M6847_AG      = 0x80,
32   M6847_AS      = 0x40,
33   M6847_INTEXT   = 0x20,
34   M6847_INV      = 0x10,
35   M6847_CSS      = 0x08,
36   M6847_GM2      = 0x04,
37   M6847_GM1      = 0x02,
38   M6847_GM0      = 0x01
39};
40
41typedef enum
42{
43   M6847_CLOCK,
44   M6847_HSYNC
45} m6847_timing_type;
46
47typedef struct _m6847_config m6847_config;
48struct _m6847_config
49{
50   m6847_type type;
51   int cpu0_timing_factor;
52
53   /* callbacks */
54   void (*horizontal_sync_callback)(running_machine *machine, int line);
55   void (*field_sync_callback)(running_machine *machine,int line);
56   UINT8 (*get_attributes)(running_machine *machine, UINT8 c, int scanline, int pos) ATTR_CONST;
57   const UINT8 *(*get_video_ram)(running_machine *machine, int scanline);
58   UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch, int line);
59
60   /* needed for the CoCo 3 */
61   int (*new_frame_callback)(running_machine *machine);   /* returns whether the M6847 is in charge of this frame */
62   void (*custom_prepare_scanline)(running_machine *machine, int scanline);
63
64   const UINT32 *custom_palette;
65};
66
67/* creates a new M6847 instance */
68void m6847_init(running_machine *machine, const m6847_config *cfg);
69
70/* video update proc */
71VIDEO_UPDATE(m6847);
72void coco6847_video_changed(void);
73
74/* sync */
75int m6847_get_horizontal_sync(running_machine *machine);
76int m6847_get_field_sync(running_machine *machine);
77
78/* timing functions */
79UINT64 coco6847_time(running_machine *machine,m6847_timing_type timing);
80attotime coco6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time);
81
82/* CoCo 3 hooks */
83attotime coco6847_scanline_time(int scanline);
84
85INPUT_PORTS_EXTERN( coco6847_artifacting );
86
87
88#endif /* __COCO6847_H__ */
src/mess/video/coco.c
r6119r6120
1717***************************************************************************/
1818
1919#include "driver.h"
20#include "machine/6821pia.h"
2021#include "machine/6883sam.h"
21#include "video/m6847.h"
22#include "video/coco6847.h"
2223#include "includes/coco.h"
2324
2425
25/* TODO: this is really hacky, needs an updated/rewritten sam emulation
26 * to work correctly.
27 */
26/*************************************
27 *
28 *   Code
29 *
30 *************************************/
2831
29static int last_scanline = -1;
30const UINT8 *coco_videoram = 0;
32ATTR_CONST UINT8 coco_get_attributes_2(running_machine *machine, UINT8 c, int scanline, int pos)
33{
34   coco_state *state = machine->driver_data;
35   UINT8 result = 0x00;
36   UINT8 pia1_pb = pia6821_get_output_b(state->pia_1);
3137
32READ8_DEVICE_HANDLER( coco_mc6847_videoram_r )
38   if (c & 0x40)      result |= M6847_INV;
39   if (c & 0x80)      result |= M6847_AS;
40   if (pia1_pb & 0x08)   result |= M6847_CSS;
41   if (pia1_pb & 0x10)   result |= M6847_GM0;
42   if (pia1_pb & 0x20)   result |= M6847_GM1;
43   if (pia1_pb & 0x40)   result |= M6847_GM2;
44   if (pia1_pb & 0x80)   result |= M6847_AG;
45   return result;
46}
47
48ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
3349{
34   coco_state *state = device->machine->driver_data;
35   int scanline;
50   coco_state *state = machine->driver_data;
51   UINT8 result = 0x00;
52   UINT8 pia1_pb = pia6821_get_output_b(state->pia_1);
3653
37   scanline = mc6847_get_scanline(device);
54   if (c & 0x40)      result |= M6847_INV;
55   if (c & 0x80)      result |= M6847_AS;
56   if (pia1_pb & 0x08)   result |= M6847_CSS;
57   if (pia1_pb & 0x10)   result |= M6847_GM0 | M6847_INTEXT;
58   if (pia1_pb & 0x20)   result |= M6847_GM1;
59   if (pia1_pb & 0x40)   result |= M6847_GM2;
60   if (pia1_pb & 0x80)   result |= M6847_AG;
61   return result;
62}
3863
39   if (last_scanline != scanline)
40   {
41      coco_videoram = sam_m6847_get_video_ram(state->sam, scanline);
42      last_scanline = scanline;
64
65static void coco_horizontal_sync_callback(running_machine *machine, int data)
66{
67   coco_state *state = machine->driver_data;
68   pia6821_ca1_w(state->pia_0, 0, data);
69}
70
71
72
73static void coco_field_sync_callback(running_machine *machine, int data)
74{
75   coco_state *state = machine->driver_data;
76   pia6821_cb1_w(state->pia_0, 0, data);
77}
78
79static const UINT8 *get_video_ram_coco(running_machine *machine,int scanline)
80{
81   coco_state *state = machine->driver_data;
82   return sam_m6847_get_video_ram(state->sam, scanline);
83}
84
85static void internal_video_start_coco(running_machine *machine, m6847_type type)
86{
87   m6847_config cfg;
88
89   memset(&cfg, 0, sizeof(cfg));
90   cfg.type = type;
91
92   /* NPW 14-May-2006 - Ugly hack; using CPU timing factor seems to break some
93    * Dragon games */
94   if (machine->gamedrv->name[0] == 'c')
95      cfg.cpu0_timing_factor = 4;
96
97   if (type==M6847_VERSION_M6847T1_NTSC) {
98      cfg.get_attributes = coco_get_attributes;
99   } else {
100      cfg.get_attributes = coco_get_attributes_2;
43101   }
102   cfg.get_video_ram = get_video_ram_coco;
103   cfg.horizontal_sync_callback = coco_horizontal_sync_callback;
104   cfg.field_sync_callback = coco_field_sync_callback;
44105
45   offset = offset % 32;
106   m6847_init(machine, &cfg);
107}
46108
47   mc6847_inv_w(device, BIT(coco_videoram[offset], 6));
48   mc6847_as_w(device, BIT(coco_videoram[offset], 7));
49109
50   return coco_videoram[offset];
110
111VIDEO_START( dragon )
112{
113   internal_video_start_coco(machine, M6847_VERSION_ORIGINAL_PAL);
51114}
52115
53VIDEO_UPDATE( coco )
116VIDEO_START( coco )
54117{
55   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
56   return mc6847_update(mc6847, bitmap, cliprect);
118   internal_video_start_coco(machine, M6847_VERSION_ORIGINAL_NTSC);
57119}
120
121VIDEO_START( coco2b )
122{
123   internal_video_start_coco(machine, M6847_VERSION_M6847T1_NTSC);
124}
125
src/mess/video/coco3.c
r6119r6120
2929
3030#include "driver.h"
3131#include "machine/6883sam.h"
32#include "video/m6847.h"
32#include "video/coco6847.h"
3333#include "includes/coco.h"
3434#include "devices/messram.h"
3535
r6119r6120
422422   if (video->legacy_video)
423423   {
424424      /* legacy CoCo 1/2 graphics */
425      const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
426      rc = mc6847_update(mc6847, bitmap, cliprect);
425      rc = VIDEO_UPDATE_CALL(m6847);
427426
428427      if ((rc & UPDATE_HAS_NOT_CHANGED) == 0)
429428      {
r6119r6120
472471
473472int coco3_new_frame(running_machine *machine)
474473{
475   const device_config *mc6847 = devtag_get_device(machine, "mc6847");
476474   int gime_field_sync = 0;
477475
478476   /* changing from non-legacy to legacy video? */
r6119r6120
523521
524522   /* set up GIME field sync */
525523   timer_adjust_oneshot(video->gime_fs_timer,
526      m6847_scanline_time(mc6847, gime_field_sync), 0);
524      coco6847_scanline_time(gime_field_sync), 0);
527525
528526   return video->legacy_video;
529527}
r6119r6120
540538
541539
542540
543void coco3_prepare_scanline(running_machine *machine,int scanline)
541static void coco3_prepare_scanline(running_machine *machine, int scanline)
544542{
545543   static const UINT32 lines_per_row[] = { 1, 1, 2, 8, 9, 10, 11, ~0 };
546544   static const UINT32 gfx_bytes_per_row[] = { 16, 20, 32, 40, 64, 80, 128, 160 };
r6119r6120
791789}
792790
793791
794static int last_scanline = -1;
795const UINT8 *coco3_videoram = 0;
796
797READ8_DEVICE_HANDLER( coco3_mc6847_videoram_r )
792static const UINT8 *get_video_ram_coco3(running_machine *machine,int scanline)
798793{
799   const device_config *sam = devtag_get_device(device->machine, "sam");
800   int scanline;
801
802   scanline = mc6847_get_scanline(device);
803
804   if (last_scanline != scanline)
805   {
806      coco3_videoram = sam_m6847_get_video_ram(sam, scanline);
807      last_scanline = scanline;
808   }
809
810   offset = offset % 32;
811
812   mc6847_inv_w(device, BIT(coco3_videoram[offset], 6));
813   mc6847_as_w(device, BIT(coco3_videoram[offset], 7));
814
815   return coco3_videoram[offset];
794   const device_config *sam = devtag_get_device(machine, "sam");
795   return sam_m6847_get_video_ram(sam,scanline);
816796}
817797
818
819VIDEO_START( coco3 )
798static void internal_video_start_coco3(running_machine *machine, m6847_type type)
820799{
821   const device_config *mc6847 = devtag_get_device(machine, "mc6847");
822800   int i;
801   m6847_config cfg;
823802   const UINT8 *rom;
824803
825804   /* allocate video */
r6119r6120
854833   video->gime_fs_timer = timer_alloc(machine, gime_fs, NULL);
855834
856835   /* initialize the CoCo video code */
857   mc6847_set_palette(mc6847, video->palette_colors);
836   memset(&cfg, 0, sizeof(cfg));
837   cfg.type = type;
838   cfg.cpu0_timing_factor = 4;
839   cfg.get_attributes = coco_get_attributes;
840   cfg.get_video_ram = get_video_ram_coco3;
841   cfg.horizontal_sync_callback = coco3_horizontal_sync_callback;
842   cfg.field_sync_callback = coco3_field_sync_callback;
843   cfg.custom_palette = video->palette_colors;
844   cfg.new_frame_callback = coco3_new_frame;
845   cfg.custom_prepare_scanline = coco3_prepare_scanline;
846   m6847_init(machine, &cfg);
858847
859848   /* save state stuff */
860849   state_save_register_global_array(machine, video->palette_ram);
r6119r6120
865854}
866855
867856
857
858VIDEO_START( coco3 )
859{
860   internal_video_start_coco3(machine, M6847_VERSION_GIME_NTSC);
861}
862
863VIDEO_START( coco3p )
864{
865   internal_video_start_coco3(machine, M6847_VERSION_GIME_PAL);
866}
867
868
869
868870void coco3_vh_blink(void)
869871{
870872   video->blink = !video->blink;
src/mess/includes/coco.h
r6119r6120
4141   const device_config *pia_0;
4242   const device_config *pia_1;
4343   const device_config *pia_2;
44   const device_config *mc6847;
4544};
4645
4746
r6119r6120
5150
5251/*----------- defined in video/coco.c -----------*/
5352
54READ8_DEVICE_HANDLER( coco_mc6847_videoram_r );
55VIDEO_UPDATE( coco );
53ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c,int scanline, int pos);
5654
55VIDEO_START( dragon );
56VIDEO_START( coco );
57VIDEO_START( coco2b );
5758
59
5860/*----------- defined in video/coco3.c -----------*/
5961
60int coco3_new_frame(running_machine *machine);
61void coco3_prepare_scanline(running_machine *machine,int scanline);
62READ8_DEVICE_HANDLER( coco3_mc6847_videoram_r );
6362VIDEO_START( coco3 );
63VIDEO_START( coco3p );
6464VIDEO_UPDATE( coco3 );
6565WRITE8_HANDLER ( coco3_palette_w );
6666UINT32 coco3_get_video_base(UINT8 ff9d_mask, UINT8 ff9e_mask);
r6119r6120
110110WRITE8_HANDLER ( coco3_gime_w );
111111offs_t coco3_mmu_translate(running_machine *machine,int bank, int offset);
112112WRITE8_DEVICE_HANDLER( coco_pia_1_w );
113WRITE_LINE_DEVICE_HANDLER( coco3_hs_w );
114WRITE_LINE_DEVICE_HANDLER( coco3_fs_w );
113void coco3_horizontal_sync_callback(running_machine *machine,int data);
114void coco3_field_sync_callback(running_machine *machine,int data);
115115void coco3_gime_field_sync_callback(running_machine *machine);
116116
117117void coco_cart_w(const device_config *device, int data);
src/mess/machine/coco.c
r6119r6120
8989#include "includes/cococart.h"
9090#include "machine/6883sam.h"
9191#include "machine/6551.h"
92#include "video/m6847.h"
92#include "video/coco6847.h"
9393#include "formats/cocopak.h"
9494#include "devices/bitbngr.h"
9595#include "devices/printer.h"
r6119r6120
126126static UINT8 mux_sel1, mux_sel2;
127127
128128static WRITE8_DEVICE_HANDLER ( d_pia1_pb_w );
129static WRITE8_DEVICE_HANDLER( d_pia1_pb_w_coco2 );
130129static WRITE8_DEVICE_HANDLER ( d_pia1_pa_w );
131130static READ8_DEVICE_HANDLER ( d_pia1_pa_r );
132131static WRITE8_DEVICE_HANDLER ( d_pia0_pa_w );
r6119r6120
334333   DEVCB_NULL,
335334   /*outputs: A/B,CA/B2       */
336335   DEVCB_HANDLER(d_pia1_pa_w),
337   DEVCB_HANDLER(d_pia1_pb_w_coco2),
336   DEVCB_HANDLER(d_pia1_pb_w),
338337   DEVCB_HANDLER(d_pia1_ca2_w),
339338   DEVCB_HANDLER(d_pia1_cb2_w),
340339   /*irqs   : A/B             */
r6119r6120
10341033
10351034
10361035
1037WRITE_LINE_DEVICE_HANDLER( coco3_hs_w )
1036void coco3_horizontal_sync_callback(running_machine *machine,int data)
10381037{
1039   coco_state *coco = device->machine->driver_data;
1040   pia6821_ca1_w(coco->pia_0, 0, state);
1041   coco3_raise_interrupt(device->machine, COCO3_INT_HBORD, state);
1038   coco_state *state = machine->driver_data;
1039   pia6821_ca1_w(state->pia_0, 0, data);
1040   coco3_raise_interrupt(machine, COCO3_INT_HBORD, data);
10421041}
10431042
10441043
1045WRITE_LINE_DEVICE_HANDLER( coco3_fs_w )
1044
1045void coco3_field_sync_callback(running_machine *machine,int data)
10461046{
1047   coco_state *coco = device->machine->driver_data;
1048   pia6821_cb1_w(coco->pia_0, 0, state);
1047   coco_state *state = machine->driver_data;
1048   pia6821_cb1_w(state->pia_0, 0, data);
10491049}
10501050
10511051void coco3_gime_field_sync_callback(running_machine *machine)
r6119r6120
16271627
16281628static WRITE8_DEVICE_HANDLER( d_pia1_pb_w )
16291629{
1630   coco_state *state = device->machine->driver_data;
1630   coco6847_video_changed();
16311631
1632   mc6847_css_w(state->mc6847, BIT(data, 3));
1633   mc6847_gm0_w(state->mc6847, BIT(data, 4));
1634   mc6847_intext_w(state->mc6847, BIT(data, 4));
1635   mc6847_gm1_w(state->mc6847, BIT(data, 5));
1636   mc6847_gm2_w(state->mc6847, BIT(data, 6));
1637   mc6847_ag_w(state->mc6847, BIT(data, 7));
1638
16391632   /* PB1 will drive the sound output.  This is a rarely
1640     * used single bit sound mode. It is always connected thus
1641     * cannot be disabled.
1642     *
1643     * Source:  Page 31 of the Tandy Color Computer Service Manual
1644     */
1633    * used single bit sound mode. It is always connected thus
1634    * cannot be disabled.
1635    *
1636    * Source:  Page 31 of the Tandy Color Computer Serice Manual
1637    */
16451638   coco_sound_update(device->machine);
16461639}
16471640
1648static WRITE8_DEVICE_HANDLER( d_pia1_pb_w_coco2 )
1649{
1650   coco_state *state = device->machine->driver_data;
1651
1652   mc6847_css_w(state->mc6847, BIT(data, 3));
1653   mc6847_gm0_w(state->mc6847, BIT(data, 4));
1654   mc6847_gm1_w(state->mc6847, BIT(data, 5));
1655   mc6847_gm2_w(state->mc6847, BIT(data, 6));
1656   mc6847_ag_w(state->mc6847, BIT(data, 7));
1657
1658   /* PB1 will drive the sound output.  This is a rarely
1659     * used single bit sound mode. It is always connected thus
1660     * cannot be disabled.
1661     *
1662     * Source:  Page 31 of the Tandy Color Computer Serice Manual
1663     */
1664   coco_sound_update(device->machine);
1665}
1666
16671641static WRITE8_DEVICE_HANDLER( dragon64_pia1_pb_w )
16681642{
16691643   int ddr;
r6119r6120
22002174
22012175static void coco3_timer_reset(running_machine *machine)
22022176{
2203   coco_state *state = machine->driver_data;
2204
22052177   /* reset the timer; take the value stored in $FF94-5 and start the timer ticking */
22062178   UINT64 current_time;
22072179   UINT16 timer_value;
r6119r6120
22232195      timing = (coco3_gimereg[1] & 0x20) ? M6847_CLOCK : M6847_HSYNC;
22242196
22252197      /* determine the current time */
2226      current_time = m6847_time(state->mc6847, timing);
2198      current_time = coco6847_time(machine, timing);
22272199
22282200      /* calculate the time */
2229      target_time = m6847_time_until(state->mc6847, timing, current_time + timer_value);
2201      target_time = coco6847_time_until(machine, timing, current_time + timer_value);
22302202      if (LOG_TIMER)
22312203         logerror("coco3_reset_timer(): target_time=%g\n", attotime_to_double(target_time));
22322204
r6119r6120
28182790   state->pia_0         = devtag_get_device(machine, "pia_0");
28192791   state->pia_1         = devtag_get_device(machine, "pia_1");
28202792   state->pia_2         = devtag_get_device(machine, "pia_2");
2821   state->mc6847         = devtag_get_device(machine, "mc6847");
28222793
28232794   /* clear static variables */
28242795   coco_hiresjoy_ca = 1;
src/mess/mess.mak
r6119r6120
14311431   $(MESS_FORMATS)/trs_dsk.o   \
14321432   $(MESS_FORMATS)/trs_cas.o   \
14331433   $(MESS_DRIVERS)/trs80.o      \
1434   $(MESS_VIDEO)/coco6847.o   \
14341435
14351436$(MESSOBJ)/unisys.a:         \
14361437   $(MESS_DRIVERS)/univac.o   \
src/mess/drivers/coco.c
r6119r6120
2828#include "cpu/hd6309/hd6309.h"
2929#include "sound/wave.h"
3030#include "machine/6821pia.h"
31#include "video/m6847.h"
31#include "video/coco6847.h"
3232#include "machine/msm6242.h"
3333#include "machine/ds1315.h"
3434#include "machine/6883sam.h"
r6119r6120
451451
452452   PORT_INCLUDE( coco_joystick )
453453   PORT_INCLUDE( coco_joystick_buttons )
454   PORT_INCLUDE( m6847_artifacting )
454   PORT_INCLUDE( coco6847_artifacting )
455455
456456   PORT_INCLUDE( cart_autostart )
457457INPUT_PORTS_END
r6119r6120
535535   PORT_BIT(0x78, IP_ACTIVE_LOW, IPT_UNUSED)
536536   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CHANGED(coco_keyboard_changed, NULL) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
537537
538   PORT_INCLUDE( m6847_artifacting )
538   PORT_INCLUDE( coco6847_artifacting )
539539
540540   PORT_START("real_time_clock") /* 13 */
541541   PORT_CONFNAME( 0x03, 0x00, "Real Time Clock" )
r6119r6120
654654   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CHANGED(coco_keyboard_changed, NULL) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
655655   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CHANGED(coco_keyboard_changed, NULL) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
656656
657   PORT_INCLUDE( m6847_artifacting )
657   PORT_INCLUDE( coco6847_artifacting )
658658
659659   PORT_START("real_time_clock")
660660   PORT_CONFNAME( 0x03, 0x00, "Real Time Clock" )
r6119r6120
777777   DO_NOT_KEEP_GEOMETRY
778778};
779779
780static const mc6847_interface coco_mc6847_intf =
781{
782   DEVCB_HANDLER(coco_mc6847_videoram_r),
783   DEVCB_NULL,
784   DEVCB_NULL,
785   DEVCB_NULL,
786   DEVCB_NULL,
787   DEVCB_NULL,
788   DEVCB_NULL,
789   DEVCB_NULL,
790   DEVCB_NULL,
791   DEVCB_DEVICE_HANDLER("pia_0", pia6821_cb1_w),
792   DEVCB_DEVICE_HANDLER("pia_0", pia6821_ca1_w),
793   DEVCB_NULL
794};
795
796static const mc6847_interface coco3_mc6847_intf =
797{
798   DEVCB_HANDLER(coco3_mc6847_videoram_r),
799   DEVCB_NULL,
800   DEVCB_NULL,
801   DEVCB_NULL,
802   DEVCB_NULL,
803   DEVCB_NULL,
804   DEVCB_NULL,
805   DEVCB_NULL,
806   DEVCB_NULL,
807   DEVCB_LINE(coco3_fs_w),
808   DEVCB_LINE(coco3_hs_w),
809   DEVCB_NULL
810};
811
812780static MACHINE_DRIVER_START( dragon32 )
813781   /* basic machine hardware */
814782   MDRV_CPU_ADD("maincpu", M6809E, COCO_CPU_SPEED_HZ * 4)        /* 0,894886 MHz */
r6119r6120
820788   MDRV_DRIVER_DATA( coco_state )
821789
822790   /* video hardware */
791   MDRV_VIDEO_START(dragon)
792   MDRV_VIDEO_UPDATE(m6847)
823793   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
824794   MDRV_SCREEN_SIZE(320, 25+192+26)
825795   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
826796
827   MDRV_VIDEO_UPDATE(coco)
828
829   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
830   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
831
832797   /* sound hardware */
833798   MDRV_IMPORT_FROM( coco_sound )
834799
r6119r6120
867832   MDRV_DRIVER_DATA( coco_state )
868833
869834   /* video hardware */
835   MDRV_VIDEO_START(dragon)
836   MDRV_VIDEO_UPDATE(m6847)
870837   MDRV_SCREEN_ADD("screen", RASTER)
871838   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
872839   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
873840   MDRV_SCREEN_SIZE(320, 25+192+26)
874841   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
875842
876   MDRV_VIDEO_UPDATE(coco)
877
878   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
879   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
880
881843   /* sound hardware */
882844   MDRV_IMPORT_FROM( coco_sound )
883845
r6119r6120
925887   MDRV_SCREEN_SIZE(320, 25+192+26)
926888   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
927889
928   MDRV_VIDEO_UPDATE(coco)
890   MDRV_VIDEO_START(dragon)
891   MDRV_VIDEO_UPDATE(m6847)
929892
930   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
931   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
932
933893   /* sound hardware */
934894   MDRV_IMPORT_FROM( coco_sound )
935895
r6119r6120
977937   MDRV_SCREEN_SIZE(320, 25+192+26)
978938   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
979939
980   MDRV_VIDEO_UPDATE(coco)
940   MDRV_VIDEO_START(dragon)
941   MDRV_VIDEO_UPDATE(m6847)
981942
982   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
983   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
984
985943   /* sound hardware */
986944   MDRV_IMPORT_FROM( coco_sound )
987945   MDRV_SOUND_ADD("ay8912", AY8912, 1000000)
r6119r6120
1036994   MDRV_SCREEN_SIZE(320, 25+192+26)
1037995   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
1038996
1039   MDRV_VIDEO_UPDATE(coco)
997   MDRV_VIDEO_START(dragon)
998   MDRV_VIDEO_UPDATE(m6847)
1040999
1041   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1042   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
1043
10441000   /* sound hardware */
10451001   MDRV_IMPORT_FROM( coco_sound )
10461002
r6119r6120
10881044   MDRV_SCREEN_SIZE(320, 25+192+26)
10891045   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
10901046
1091   MDRV_VIDEO_UPDATE(coco)
1047   MDRV_VIDEO_START(coco)
1048   MDRV_VIDEO_UPDATE(m6847)
10921049
1093   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1094   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC)
1095   MDRV_MC6847_TIMING_FACTOR(4)
1096
10971050   /* sound hardware */
10981051   MDRV_IMPORT_FROM( coco_sound )
10991052
r6119r6120
11391092   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
11401093   MDRV_SCREEN_SIZE(320, 25+192+26)
11411094   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
1095   MDRV_VIDEO_START(coco)
1096   MDRV_VIDEO_UPDATE(m6847)
11421097
1143   MDRV_VIDEO_UPDATE(coco)
1144
1145   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1146   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC)
1147   MDRV_MC6847_TIMING_FACTOR(4)
1148
11491098   /* sound hardware */
11501099   MDRV_IMPORT_FROM( coco_sound )
11511100
r6119r6120
11911140   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
11921141   MDRV_SCREEN_SIZE(320, 25+192+26)
11931142   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
1143   MDRV_VIDEO_START(coco2b)
1144   MDRV_VIDEO_UPDATE(m6847)
11941145
1195   MDRV_VIDEO_UPDATE(coco)
1196
1197   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1198   MDRV_MC6847_TYPE(M6847_VERSION_M6847T1_NTSC)
1199   MDRV_MC6847_TIMING_FACTOR(4)
1200
12011146   /* sound hardware */
12021147   MDRV_IMPORT_FROM( coco_sound )
12031148
r6119r6120
12551200   MDRV_SCREEN_SIZE(640, 25+192+26)
12561201   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 239)
12571202
1258   MDRV_MC6847_ADD("mc6847", coco3_mc6847_intf)
1259   MDRV_MC6847_TYPE(M6847_VERSION_GIME_NTSC)
1260   MDRV_MC6847_TIMING_FACTOR(4)
1261   MDRV_MC6847_FRAME_CALLBACK(coco3_new_frame)
1262   MDRV_MC6847_PREPARE_SCANLINE(coco3_prepare_scanline)
1263
12641203   MDRV_PIA6821_ADD( "pia_0", coco3_pia_intf_0 )
12651204   MDRV_PIA6821_ADD( "pia_1", coco3_pia_intf_1 )
12661205
r6119r6120
12991238   MDRV_IMPORT_FROM( coco3 )
13001239
13011240   /* video hardware */
1241   MDRV_VIDEO_START(coco3p)
1242   MDRV_VIDEO_UPDATE(coco3)
13021243   MDRV_SCREEN_MODIFY("composite")
13031244   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
13041245   MDRV_SCREEN_MODIFY("rgb")
13051246   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
1306
1307   MDRV_DEVICE_MODIFY("mc6847")
1308   MDRV_MC6847_TYPE(M6847_VERSION_GIME_PAL)
13091247MACHINE_DRIVER_END
13101248
13111249static MACHINE_DRIVER_START( coco3h )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team