Previous 15994 Revisions Next

r5923 Wednesday 30th September, 2009 at 11:59:39 UTC by Dirk Best
Converted the MC6847 VDG into a device. There are some changes how it access the video ram, so please be on the lookout for regressions.
[src/mess]mess.mak
[src/mess/drivers]apf.c atom.c coco.c mc10.c mc1000.c spc1000.c vtech1.c z80ne.c
[src/mess/includes]apf.h atom.h coco.h mc10.h vtech1.h z80ne.h
[src/mess/machine]6883sam.c 6883sam.h atom.c coco.c mc10.c vtech1.c z80ne.c
[src/mess/video]apf.c atom.c coco.c coco3.c m6847.c m6847.h vtech1.c z80ne.c

src/mess/video/z80ne.c
r5922r5923
1/***************************************************************************
2
3   Video hardware for Z80NE
4
5   driver by Roberto Lavarone
6
7   See mess/machine/z80ne.c for references
8
9***************************************************************************/
10
11/* MC6847 pin connections:
12 * GM0 to GND
13 * GM1 to GND
14 * GM2 to GND
15 * AG  to GND
16 * CSS to GND
17 * DD6 to GND
18 * DD7 to GND
19 *
20 * D7 D6 PIN32 PIN31 PIN34
21 *        INV  INTEXT AS
22 * 0  0    0     0     0   Alphanumeric
23 * 0  1    0     0     0   Alphanumeric
24 * 1  0    0     1     1   Semigraphic 6
25 * 1  1    1     0     0   Inverted Alphanumeric
26 */
27
28
29#include "driver.h"
30#include "video/m6847.h"
31#include "includes/z80ne.h"
32
33#define M6847_RGB(r,g,b)   ((r << 16) | (g << 8) | (b << 0))
34
35static const UINT32 lx388palette[] =
36{
37   M6847_RGB(0x00, 0xff, 0x00),   /* GREEN */
38   M6847_RGB(0x00, 0xff, 0x00),   /* YELLOW in original, here GREEN */
39   M6847_RGB(0x00, 0x00, 0xff),   /* BLUE */
40   M6847_RGB(0xff, 0x00, 0x00),   /* RED */
41   M6847_RGB(0xff, 0xff, 0xff),   /* BUFF */
42   M6847_RGB(0x00, 0xff, 0xff),   /* CYAN */
43   M6847_RGB(0xff, 0x00, 0xff),   /* MAGENTA */
44   M6847_RGB(0xff, 0x80, 0x00),   /* ORANGE */
45
46   M6847_RGB(0x00, 0x20, 0x00),   /* BLACK in original, here DARK green */
47   M6847_RGB(0x00, 0xff, 0x00),   /* GREEN */
48   M6847_RGB(0x00, 0x00, 0x00),   /* BLACK */
49   M6847_RGB(0xff, 0xff, 0xff),   /* BUFF */
50
51   M6847_RGB(0x00, 0x20, 0x00),   /* ALPHANUMERIC DARK GREEN */
52   M6847_RGB(0x00, 0xff, 0x00),   /* ALPHANUMERIC BRIGHT GREEN */
53   M6847_RGB(0x40, 0x10, 0x00),   /* ALPHANUMERIC DARK ORANGE */
54   M6847_RGB(0xff, 0xc4, 0x18)      /* ALPHANUMERIC BRIGHT ORANGE */
55};
56
57static ATTR_CONST UINT8 lx388_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
58{
59   UINT8 result = 0x00;
60   if (c & 0x80)
61   {
62      if (c & 0x40)
63         result |= M6847_INV;
64      else
65         result |= M6847_INTEXT | M6847_AS;
66   }
67   return result;
68}
69
70static const UINT8 *lx388_get_video_ram(running_machine *machine, int scanline)
71{
72   return videoram + (scanline / 12) * 0x20;
73}
74
75VIDEO_START(lx388)
76{
77   m6847_config cfg;
78
79   memset(&cfg, 0, sizeof(cfg));
80   cfg.type = M6847_VERSION_ORIGINAL_PAL;
81   cfg.get_attributes = lx388_get_attributes;
82   cfg.get_video_ram = lx388_get_video_ram;
83   cfg.custom_palette = lx388palette;
84   m6847_init(machine, &cfg);
85}
src/mess/video/atom.c
r5922r5923
1/******************************************************************************
2
3atom.c
4
5******************************************************************************/
6
7
8#include "driver.h"
9#include "video/m6847.h"
10#include "includes/atom.h"
11
12
13static ATTR_CONST UINT8 atom_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
14{
15   UINT8 result = 0x00;
16   if (c & 0x40)            result |= M6847_AS | M6847_INTEXT;
17   if (c & 0x80)            result |= M6847_INV;
18   if (atom_8255_porta & 0x80)   result |= M6847_GM2;
19   if (atom_8255_porta & 0x40)   result |= M6847_GM1;
20   if (atom_8255_porta & 0x20)   result |= M6847_GM0;
21   if (atom_8255_porta & 0x10)   result |= M6847_AG;
22   if (atom_8255_portc & 0x08)   result |= M6847_CSS;
23   return result;
24}
25
26static const UINT8 *atom_get_video_ram(running_machine *machine, int scanline)
27{
28   return videoram + (scanline / 12) * 0x20;
29}
30
31VIDEO_START( atom )
32{
33   m6847_config cfg;
34
35   memset(&cfg, 0, sizeof(cfg));
36   cfg.type = M6847_VERSION_ORIGINAL_PAL;
37   cfg.get_attributes = atom_get_attributes;
38   cfg.get_video_ram = atom_get_video_ram;
39   m6847_init(machine, &cfg);
40}
41
src/mess/video/apf.c
r5922r5923
1/******************************************************************************
2
3******************************************************************************/
4
5#include "driver.h"
6#include "video/m6847.h"
7#include "includes/apf.h"
8
9UINT8 *apf_video_ram;
10UINT8 apf_m6847_attr;
11static UINT8 apf_chars[0x20], apf_video[0x20];
12
13static ATTR_CONST UINT8 apf_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
14{
15
16   /* this seems to be the same so far, as it gives the same result as vapf */
17  UINT8 result = apf_m6847_attr;
18  if (apf_m6847_attr&M6847_AG) {
19    //    if ( !(result&M6847_GM0)&&(c&0x20)) result|=M6847_CSS; // not working since m6847 doesn't deliver character
20    result |= M6847_GM2|M6847_GM1;
21  } else {
22   if (c & 0x40)   result |= M6847_INV;
23   if (c & 0x80)   result |= M6847_AS;
24  }
25   return result;
26}
27
28static UINT8 apf_get_character(int character, int line)
29{
30  return apf_video_ram[(character&0x1f)*0x10+line+0x200];
31}
32
33static void apf_vsync_int(running_machine *machine, int line)
34{
35   if (line)
36      apf_ints |= 0x10;
37   else
38      apf_ints &= ~0x10;
39   apf_update_ints(machine);
40}
41
42
43
44static const UINT8 *apf_get_video_ram(running_machine *machine, int scanline)
45{
46  if (apf_m6847_attr&M6847_AG) {
47    /* apf has only 1kbyte ram and can't use all for video of course
48       it doesn't combine the 6847 with the 6883, instead it has own circuit
49       to do special 32x12 tilemap at 0x0000 with 8x16 sized characters. The 32 characters are defined at address 0x0200
50       and delivers resulting byte to the m6847 which operates in graphics mode
51     */
52    int i;
53    if ((scanline&0xf)==0)
54      memcpy (apf_chars, &apf_video_ram[(scanline/16)*0x20], sizeof(apf_chars));
55    for (i=0; i<sizeof(apf_video); i++)
56      apf_video[i]=apf_get_character(apf_chars[i], scanline&0xf);
57    return apf_video;
58  } else {
59    return &apf_video_ram[(scanline / 12) * 0x20 + 0x200];
60  }
61}
62
63
64
65VIDEO_START(apf)
66{
67   m6847_config cfg;
68
69   memset(&cfg, 0, sizeof(cfg));
70   cfg.type = M6847_VERSION_ORIGINAL_NTSC;
71   cfg.field_sync_callback = apf_vsync_int;
72   cfg.get_attributes = apf_get_attributes;
73   cfg.get_video_ram = apf_get_video_ram;
74   m6847_init(machine, &cfg);
75}
76
77#ifdef UNUSED_FUNCTION
78VIDEO_UPDATE(apf)
79{
80    return VIDEO_UPDATE_CALL(m6847);
81}
82#endif
src/mess/video/vtech1.c
r5922r5923
1/******************************************************************************
2
3Video Technology Laser 110-310 computers:
4
5    Video Technology Laser 110
6      Sanyo Laser 110
7    Video Technology Laser 200
8      Salora Fellow
9      Texet TX-8000
10      Video Technology VZ-200
11    Video Technology Laser 210
12      Dick Smith Electronics VZ-200
13      Sanyo Laser 210
14    Video Technology Laser 310
15      Dick Smith Electronics VZ-300
16
17Video hardware:
18
19    Juergen Buchmueller <pullmoll@t-online.de>, Dec 1999
20
21    Thanks go to:
22    - Guy Thomason
23    - Jason Oakley
24    - Bushy Maunder
25    - and anybody else on the vzemu list :)
26    - Davide Moretti for the detailed description of the colors.
27
28******************************************************************************/
29
30#include "driver.h"
31#include "includes/vtech1.h"
32#include "video/m6847.h"
33
34
35/******************************************************************************
36 Palette Initialisation
37******************************************************************************/
38
39static UINT32 vtech1_palette_mono[16];
40
41/* note - Juergen's colors do not match the colors in the m6847 code */
42static const UINT8 vtech1_palette[] =
43{
44      0, 224,   0,    /* green */
45    208, 255,   0,    /* yellow (greenish) */
46      0,   0, 255,    /* blue */
47    255,   0,   0,    /* red */
48    224, 224, 144,    /* buff */
49      0, 255, 160,    /* cyan (greenish) */
50    255,   0, 255,    /* magenta */
51    240, 112,   0,    /* orange */
52      0,   0,   0,    /* black (block graphics) */
53      0, 224,   0,    /* green */
54      0,   0,   0,    /* black (block graphics) */
55    224, 224, 144,    /* buff */
56      0,  64,   0,    /* dark green (alphanumeric characters) */
57      0, 224,  24,    /* bright green (alphanumeric characters) */
58     64,  16,   0,    /* dark orange (alphanumeric characters) */
59    255, 196,  24,    /* bright orange (alphanumeric characters) */
60};
61
62
63static ATTR_CONST UINT8 vtech1_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
64{
65   UINT8 result = 0x00;
66   if (c & 0x40)            result |= M6847_INV;
67   if (c & 0x80)            result |= M6847_AS;
68   if (vtech1_latch & 0x10)   result |= M6847_CSS;
69   if (vtech1_latch & 0x08)   result |= M6847_AG | M6847_GM1;
70   return result;
71}
72
73
74static const UINT8 *vtech1_get_video_ram(running_machine *machine, int scanline)
75{
76   return videoram + (scanline / (vtech1_latch & 0x08 ? 3 : 12)) * 0x20;
77}
78
79
80/*
81 * The interrupt pin (pin 16 INT) of the Z80 CPU is connected to pin 37 (FS)
82 * of the 6847 video controller chip. This pin is pulled low by the 6847 chip
83 * during the vertical retrace period of the video output signal. That is, the
84 * field sync output pin goes low every 1/50 of a second (video frame rate of
85 * 50 per second) causing the Z80 CPU to be interrupted and diverted to
86 * location 0038 HEX every 20ms.
87 *
88 */
89static void vtech1_field_sync_callback(running_machine *machine, int data)
90{
91   if (data)
92      cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
93   else
94      cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE);
95}
96
97
98static void common_video_start(running_machine *machine, UINT32 *palette)
99{
100   m6847_config cfg;
101
102   memset(&cfg, 0, sizeof(cfg));
103   cfg.type = M6847_VERSION_ORIGINAL_PAL;
104   cfg.get_attributes = vtech1_get_attributes;
105   cfg.get_video_ram = vtech1_get_video_ram;
106   cfg.custom_palette = palette;
107   cfg.field_sync_callback = vtech1_field_sync_callback;
108   m6847_init(machine, &cfg);
109}
110
111
112VIDEO_START( vtech1_monochrome )
113{
114   int i;
115
116   /* TODO: Monochrome should be moved into M6847 code */
117   for (i = 0; i < sizeof(vtech1_palette_mono); i++)
118   {
119        int mono;
120        mono  = (int)(vtech1_palette[i*3+0] * 0.299);  /* red */
121        mono += (int)(vtech1_palette[i*3+1] * 0.587);  /* green */
122        mono += (int)(vtech1_palette[i*3+2] * 0.114);  /* blue */
123        vtech1_palette_mono[i] = MAKE_RGB(mono, mono, mono);
124   }
125
126   common_video_start(machine, vtech1_palette_mono);
127}
128
129
130VIDEO_START( vtech1 )
131{
132   common_video_start(machine, NULL);
133}
src/mess/video/coco.c
r5922r5923
1717***************************************************************************/
1818
1919#include "driver.h"
20#include "machine/6821pia.h"
2120#include "machine/6883sam.h"
2221#include "video/m6847.h"
2322#include "includes/coco.h"
2423
2524
26/*************************************
27 *
28 *   Code
29 *
30 *************************************/
25/* TODO: this is really hacky, needs an updated/rewritten sam emulation
26 * to work correctly.
27 */
3128
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);
29static int last_scanline = -1;
30const UINT8 *coco_videoram = 0;
3731
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)
32READ8_DEVICE_HANDLER( coco_mc6847_videoram_r )
4933{
50   coco_state *state = machine->driver_data;
51   UINT8 result = 0x00;
52   UINT8 pia1_pb = pia6821_get_output_b(state->pia_1);
34   coco_state *state = device->machine->driver_data;
35   int scanline;
5336
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}
37   scanline = mc6847_get_scanline(device);
6338
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;
39   if (last_scanline != scanline)
40   {
41      coco_videoram = sam_m6847_get_video_ram(state->sam, scanline);
42      last_scanline = scanline;
10143   }
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;
10544
106   m6847_init(machine, &cfg);
107}
45   offset = offset % 32;
10846
47   mc6847_inv_w(device, BIT(coco_videoram[offset], 6));
48   mc6847_as_w(device, BIT(coco_videoram[offset], 7));
10949
110
111VIDEO_START( dragon )
112{
113   internal_video_start_coco(machine, M6847_VERSION_ORIGINAL_PAL);
50   return coco_videoram[offset];
11451}
11552
116VIDEO_START( coco )
53VIDEO_UPDATE( coco )
11754{
118   internal_video_start_coco(machine, M6847_VERSION_ORIGINAL_NTSC);
55   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
56   return mc6847_update(mc6847, bitmap, cliprect);
11957}
120
121VIDEO_START( coco2b )
122{
123   internal_video_start_coco(machine, M6847_VERSION_M6847T1_NTSC);
124}
125
src/mess/video/m6847.c
r5922r5923
6969#include "debug/debugcpu.h"
7070#include "debug/debugcon.h"
7171
72enum
73{
74   M6847_AG      = 0x80,
75   M6847_AS      = 0x40,
76   M6847_INTEXT   = 0x20,
77   M6847_INV      = 0x10,
78   M6847_CSS      = 0x08,
79   M6847_GM2      = 0x04,
80   M6847_GM1      = 0x02,
81   M6847_GM0      = 0x01
82};
7283
84
85
7386#define LOG_FS         0
7487#define LOG_HS         0
7588#define LOG_STATS      0
76#define LOG_PREPARE     
89#define LOG_PREPARE      1
7790
7891typedef struct _m6847_variant m6847_variant;
7992struct _m6847_variant
r5922r5923
102115   UINT8 attr;
103116};
104117
105typedef struct _m6847_vdg m6847_vdg;
106struct _m6847_vdg
118typedef struct _mc6847_state mc6847_state;
119struct _mc6847_state
107120{
108121   /* 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)(void);   /* returns whether the M6847 is in charge of this frame */
122   devcb_resolved_read8 in_dd_func;
123
124   devcb_resolved_read_line in_gm2_func;
125   devcb_resolved_read_line in_gm1_func;
126   devcb_resolved_read_line in_gm0_func;
127   devcb_resolved_read_line in_intext_func;
128   devcb_resolved_read_line in_inv_func;
129   devcb_resolved_read_line in_as_func;
130   devcb_resolved_read_line in_ag_func;
131   devcb_resolved_read_line in_css_func;
132
133   devcb_resolved_write_line out_fs_func;
134   devcb_resolved_write_line out_hs_func;
135   devcb_resolved_write_line out_rs_func;
136
137   /* state of mode control lines */
138   unsigned int gm2 : 1;
139   unsigned int gm1 : 1;
140   unsigned int gm0 : 1;
141   unsigned int intext : 1;
142   unsigned int inv : 1;
143   unsigned int as : 1;
144   unsigned int ag : 1;
145   unsigned int css : 1;
146
147   /* sync control line status */
148   unsigned int fs : 1;
149   unsigned int hs : 1;
150
151   /* to be cleaned up... */
152   int (*new_frame_callback)(running_machine *machine);   /* returns whether the M6847 is in charge of this frame */
114153   void (*custom_prepare_scanline)(int scanline);
115154   UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch,int line);
116155
r5922r5923
158197
159198static void apply_artifacts(running_machine *machine, UINT32 *line);
160199
161static m6847_vdg *m6847;
162200
163
164201static const UINT8 pal_round_fontdata8x12[] =
165202{
166203   0x00, 0x00, 0x38, 0x44, 0x04, 0x34, 0x4C, 0x4C, 0x38, 0x00, 0x00, 0x00,
r5922r5923
10311068
10321069
10331070
1071/*****************************************************************************
1072    INLINE FUNCTIONS
1073*****************************************************************************/
1074
1075INLINE mc6847_state *get_safe_token(const device_config *device)
1076{
1077   assert(device != NULL);
1078   assert(device->token != NULL);
1079   assert(device->type == MC6847);
1080
1081   return (mc6847_state *)device->token;
1082}
1083
1084
10341085/*************************************
10351086 *
10361087 *  Utilities
10371088 *
10381089 *************************************/
10391090
1040static UINT32 color(int c)
1091static UINT32 color(const device_config *device, int c)
10411092{
1042   return m6847->palette[c];
1093   mc6847_state *mc6847 = get_safe_token(device);
1094   return mc6847->palette[c];
10431095}
10441096
1045
1046
1047static int attr_index_from_attribute(UINT8 attr)
1097static int attr_index_from_attribute(const device_config *device, UINT8 attr)
10481098{
1099   mc6847_state *mc6847 = get_safe_token(device);
10491100   int result;
10501101
10511102   result = ((attr & (M6847_AG | M6847_AS | M6847_INTEXT | M6847_INV | M6847_CSS)) >> 3)
10521103      | ((attr & (M6847_GM1 | M6847_GM0)) << 5);
10531104
10541105   /* sanity check */
1055   assert(result < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]));
1106   assert(result < ARRAY_LENGTH(mc6847->fontdata));
10561107   return result;
10571108}
10581109
1110static UINT8 attribute_from_attr_index(const device_config *device, int attr_index)
1111{
1112   mc6847_state *mc6847 = get_safe_token(device);
10591113
1060
1061static UINT8 attribute_from_attr_index(int attr_index)
1062{
10631114   /* sanity check */
10641115   assert(attr_index >= 0);
1065   assert(attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]));
1116   assert(attr_index < ARRAY_LENGTH(mc6847->fontdata));
10661117
10671118   return (UINT8) ((attr_index & 0x1F) << 3)
10681119      | ((attr_index & 0x60) >> 5);
r5922r5923
10721123
10731124/*************************************
10741125 *
1126 *  Scanline operations
1127 *
1128 *************************************/
1129
1130static int get_scanline(mc6847_state *mc6847)
1131{
1132   int result;
1133   attotime duration;
1134
1135   /* get the time since last field sync */
1136   duration = attotime_sub(
1137      timer_starttime(mc6847->hs_rise_timer),
1138      timer_starttime(mc6847->fs_rise_timer));
1139   assert_always(duration.seconds == 0, "get_scanline(): duration exceeds one second");
1140
1141   if (duration.attoseconds < mc6847->vblank_period)
1142   {
1143      result = -1;   /* vblank */
1144   }
1145   else
1146   {
1147      result = (duration.attoseconds - mc6847->vblank_period)
1148         / mc6847->scanline_period;
1149   }
1150   return result;
1151}
1152
1153
1154
1155static offs_t scanline_to_address(mc6847_state *mc6847, int scanline)
1156{
1157   if (mc6847->ag)
1158   {
1159      /* graphics */
1160      int gm = (mc6847->gm0 << 2) | (mc6847->gm1 << 1) | mc6847->gm2;
1161
1162      switch (gm)
1163      {
1164      case 0: return (scanline / 3) * 0x10;
1165      case 1: return (scanline / 3) * 0x10;
1166      case 2: return (scanline / 3) * 0x20;
1167      case 3: return (scanline / 2) * 0x20;
1168      case 4: return (scanline / 2) * 0x20;
1169      case 5: return (scanline / 1) * 0x10;
1170      case 6: return (scanline / 1) * 0x20;
1171      case 7: return (scanline / 1) * 0x20;
1172      }
1173   }
1174   else
1175   {
1176      /* text, semi-graphics */
1177      return (scanline / 12) * 0x20;
1178   }
1179
1180   /* we never get here */
1181   return 0;
1182}
1183
1184
1185/* TODO: attributes should be read on demand rather then all at once */
1186static UINT8 update_attributes(mc6847_state *mc6847)
1187{
1188   if (mc6847->in_gm0_func.read != NULL)
1189      mc6847->gm0 = devcb_call_read_line(&mc6847->in_gm0_func);
1190   if (mc6847->in_gm1_func.read != NULL)
1191      mc6847->gm1 = devcb_call_read_line(&mc6847->in_gm1_func);
1192   if (mc6847->in_gm2_func.read != NULL)
1193      mc6847->gm2 = devcb_call_read_line(&mc6847->in_gm2_func);
1194   if (mc6847->in_css_func.read != NULL)
1195      mc6847->css = devcb_call_read_line(&mc6847->in_css_func);
1196   if (mc6847->in_inv_func.read != NULL)
1197      mc6847->inv = devcb_call_read_line(&mc6847->in_inv_func);
1198   if (mc6847->in_intext_func.read != NULL)
1199      mc6847->intext = devcb_call_read_line(&mc6847->in_intext_func);
1200   if (mc6847->in_as_func.read != NULL)
1201      mc6847->as = devcb_call_read_line(&mc6847->in_as_func);
1202   if (mc6847->in_ag_func.read != NULL)
1203      mc6847->ag = devcb_call_read_line(&mc6847->in_ag_func);
1204
1205   return (mc6847->ag << 7) | (mc6847->as << 6) | (mc6847->intext << 5) | (mc6847->inv << 4) |
1206          (mc6847->css << 3) | (mc6847->gm2 << 2) | (mc6847->gm1 << 1) | mc6847->gm0;
1207}
1208
1209
1210INLINE void prepare_scanline(running_machine *machine, mc6847_state *mc6847, int xpos)
1211{
1212   UINT8 attrs, data, attr;
1213   int scanline;
1214   int i, border_color;
1215   int dirty;
1216   m6847_pixel *scanline_data;
1217
1218   scanline = get_scanline(mc6847);
1219
1220   if (LOG_PREPARE)
1221      logerror("m6847_prepare_scanline(): scanline=%d xpos=%d\n", scanline, xpos);
1222
1223   if ((scanline >= 0) && (scanline < (mc6847->top_border_scanlines
1224      + mc6847->display_scanlines + mc6847->bottom_border_scanlines)))
1225   {
1226      if (mc6847->using_custom)
1227      {
1228         mc6847->custom_prepare_scanline(scanline);
1229      }
1230      else
1231      {
1232         /* has the border color changed? */
1233         attrs = update_attributes(mc6847);
1234
1235         if (attrs != mc6847->attrs[scanline])
1236         {
1237            mc6847->dirty = TRUE;
1238            mc6847->attrs[scanline] = attrs;
1239
1240            /* choose the border color */
1241            if (attrs & M6847_AG)
1242               border_color = (attrs & M6847_CSS) ? BUFF : GREEN;
1243            else if (mc6847->has_lowercase && (attrs & M6847_GM2))
1244               border_color = (attrs & M6847_CSS) ? LTORANGE : LTGREEN;
1245            else
1246               border_color = BLACK;
1247
1248            /* need to use palette table directly; border colors are constant */
1249            mc6847->border[scanline] = mc6847->palette[border_color];
1250         }
1251
1252         /* is this a display scanline? */
1253         scanline -= mc6847->top_border_scanlines;
1254         if ((scanline >= 0) && (scanline < mc6847->display_scanlines))
1255         {
1256            offs_t addr = scanline_to_address(mc6847, scanline);
1257            dirty = mc6847->dirty;
1258            scanline_data = mc6847->screendata[scanline];
1259
1260            for (i = xpos; i < 32; i++)
1261            {
1262               data = devcb_call_read8(&mc6847->in_dd_func, addr + i);
1263               attr = update_attributes(mc6847);
1264
1265               if ((data != scanline_data[i].data)   || (attr != scanline_data[i].attr))
1266               {
1267                  dirty = TRUE;
1268                  scanline_data[i].data = data;
1269                  scanline_data[i].attr = attr;
1270               }
1271            }
1272            mc6847->dirty = dirty;
1273         }
1274      }
1275   }
1276}
1277
1278
1279
1280void m6847_video_changed(void)
1281{
1282   /* NPW 2-May-2006 - Commenting this out until we properly fix bug #878 */
1283   /* prepare_scanline(get_beamx() / 8); */
1284}
1285
1286
1287
1288/*************************************
1289 *
1290 *  Field sync/Horizontal sync timers
1291 *
1292 *************************************/
1293
1294static TIMER_CALLBACK( hs_fall )
1295{
1296   mc6847_state *mc6847 = (mc6847_state *) ptr;
1297
1298   if (LOG_HS)
1299      logerror("hs_fall(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION));
1300
1301   mc6847->hs = CLEAR_LINE;
1302   devcb_call_write_line(&mc6847->out_hs_func, CLEAR_LINE);
1303}
1304
1305static TIMER_CALLBACK( hs_rise )
1306{
1307   mc6847_state *mc6847 = (mc6847_state *) ptr;
1308
1309   if (LOG_HS)
1310      logerror("hs_rise(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION));
1311
1312   timer_adjust_oneshot(mc6847->hs_rise_timer,
1313      attotime_make(0, mc6847->scanline_period), 0);
1314   timer_adjust_oneshot(mc6847->hs_fall_timer,
1315      attotime_make(0, mc6847->horizontal_sync_period), 0);
1316
1317   mc6847->hs = ASSERT_LINE;
1318   devcb_call_write_line(&mc6847->out_hs_func, ASSERT_LINE);
1319
1320   prepare_scanline(machine, mc6847, 0);
1321}
1322
1323static TIMER_CALLBACK( fs_fall )
1324{
1325   mc6847_state *mc6847 = (mc6847_state *) ptr;
1326
1327   if (LOG_FS)
1328      logerror("fs_fall(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline(mc6847));
1329
1330   mc6847->fs = CLEAR_LINE;
1331   devcb_call_write_line(&mc6847->out_fs_func, CLEAR_LINE);
1332}
1333
1334static TIMER_CALLBACK( fs_rise )
1335{
1336   mc6847_state *mc6847 = (mc6847_state *) ptr;
1337
1338   if (LOG_FS)
1339      logerror("fs_rise(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline(mc6847));
1340
1341   /* adjust field sync falling edge timer */
1342   timer_adjust_oneshot(mc6847->fs_fall_timer,
1343      attotime_make(0, mc6847->field_sync_period), 0);
1344
1345   /* adjust horizontal sync rising timer */
1346   timer_adjust_oneshot(mc6847->hs_rise_timer, attotime_zero, 0);
1347
1348   /* this is a hook for the CoCo 3 code to extend this stuff */
1349   if (mc6847->new_frame_callback)
1350      mc6847->using_custom = !mc6847->new_frame_callback(machine);
1351
1352   mc6847->fs = ASSERT_LINE;
1353   devcb_call_write_line(&mc6847->out_fs_func, ASSERT_LINE);
1354}
1355
1356
1357
1358#if 0
1359/*************************************
1360 *
1361 *  Debugging
1362 *
1363 *************************************/
1364
1365
1366static int get_beamx(mc6847_state *mc6847)
1367{
1368   attotime scanline_time;
1369   int result;
1370
1371   scanline_time = timer_timeelapsed(mc6847->hs_rise_timer);
1372   if (scanline_time.seconds != 0)
1373      return 0;
1374   assert(attotime_to_attoseconds(scanline_time) < mc6847->scanline_period);
1375
1376   if (attotime_to_attoseconds(scanline_time) < (mc6847->clock_period * 42))
1377   {
1378      /* hsync */
1379      result = 0;
1380   }
1381   else if (attotime_to_attoseconds(scanline_time) < (mc6847->clock_period * 95 / 2))
1382   {
1383      /* left border */
1384      result = 0;
1385   }
1386   else if (attotime_to_attoseconds(scanline_time) < (mc6847->clock_period * 351 / 2))
1387   {
1388      /* body */
1389      result = (attotime_to_attoseconds(scanline_time) - (mc6847->clock_period * 95 / 2))
1390         / mc6847->clock_period * 2;
1391   }
1392   else
1393   {
1394      /* right border */
1395      result = 256;
1396   }
1397   return result;
1398}
1399
1400
1401static void execute_m6847_dumpscanline(const device_config *device, int ref, int params, const char **param)
1402{
1403   mc6847_state *mc6847 = get_safe_token(device);
1404
1405   int i;
1406   int beamx = get_beamx(mc6847) / 8;
1407   int scanline = get_scanline(mc6847);
1408   const m6847_pixel *pixel = mc6847->screendata[scanline];
1409
1410   for (i = 0; i < beamx; i++)
1411   {
1412      debug_console_printf(device->machine, "[%02d]: 0x%02X (", i, pixel[i].data);
1413
1414      if (pixel[i].attr & M6847_AG)      debug_console_printf(device->machine, " AG");
1415      if (pixel[i].attr & M6847_AS)      debug_console_printf(device->machine, " AS");
1416      if (pixel[i].attr & M6847_INTEXT)   debug_console_printf(device->machine, " INTEXT");
1417      if (pixel[i].attr & M6847_INV)      debug_console_printf(device->machine, " INV");
1418      if (pixel[i].attr & M6847_CSS)      debug_console_printf(device->machine, " CSS");
1419      if (pixel[i].attr & M6847_GM2)      debug_console_printf(device->machine, " GM2");
1420      if (pixel[i].attr & M6847_GM1)      debug_console_printf(device->machine, " GM1");
1421      if (pixel[i].attr & M6847_GM0)      debug_console_printf(device->machine, " GM0");
1422
1423      debug_console_printf(device->machine, " )\n");
1424   }
1425}
1426#endif
1427
1428
1429
1430/*************************************
1431 *
1432 *  Initialization
1433 *
1434 *************************************/
1435
1436static const UINT8 *find_char(const m6847_variant *v,
1437   UINT8 byte, UINT8 attr, int *fg, int *bg)
1438{
1439   int ch;
1440   size_t offset = 0;
1441
1442   if (attr & M6847_AS)
1443   {
1444      /* semigraphics */
1445      *bg = BLACK;
1446
1447      if (!v->has_lowercase && (attr & M6847_INTEXT))
1448      {
1449         /* semigraphics 6 */
1450         ch = (byte & 0x3F) + 0x60;
1451         *fg = ((byte >> 6) & 0x03) + ((attr & M6847_CSS) ? BUFF : GREEN);
1452      }
1453      else
1454      {
1455         /* semigraphics 4 */
1456         ch = (byte & 0x0F) + 0xA0;
1457         *fg = ((byte >> 4) & 0x07) + GREEN;
1458      }
1459   }
1460   else
1461   {
1462      /* text */
1463      ch = (byte & 0x3F) + 0x00;
1464
1465      if (v->has_lowercase)
1466      {
1467         if ((ch < 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV))
1468         {
1469            /* this is a lowercase character */
1470            attr |= M6847_INV;
1471            ch += 0x40;
1472         }
1473
1474         if ((ch > 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV)) {
1475            ch += 0x20;
1476         }
1477
1478         if (attr & M6847_GM1)
1479            attr ^= M6847_INV;
1480
1481      }
1482
1483      if (attr & M6847_INV)
1484      {
1485         /* dark foreground, light background */
1486         *fg = (attr & M6847_CSS) ? DKORANGE : DKGREEN;
1487         *bg = (attr & M6847_CSS) ? LTORANGE : LTGREEN;
1488      }
1489      else
1490      {
1491         /* light foreground, dark background */
1492         *fg = (attr & M6847_CSS) ? LTORANGE : LTGREEN;
1493         *bg = (attr & M6847_CSS) ? DKORANGE : DKGREEN;
1494      }
1495
1496      offset = v->text_offset;
1497   }
1498
1499   return &v->fontdata[ch * 12] + offset;
1500}
1501
1502
1503
1504static void build_fontdata(const device_config *device, const m6847_variant *v)
1505{
1506   mc6847_state *mc6847 = get_safe_token(device);
1507
1508   int attr_index, row;
1509   int fg, bg;
1510   int byte;
1511   const UINT8 *char_data;
1512
1513   for (attr_index = 0; attr_index < ARRAY_LENGTH(mc6847->fontdata); attr_index++)
1514   {
1515      UINT8 attr = attribute_from_attr_index(device, attr_index);
1516
1517      for (byte = 0; byte < 256; byte++)
1518      {
1519         char_data = find_char(v, byte, attr, &fg, &bg);
1520
1521         /* specify colors */
1522         mc6847->colordata[attr_index][byte / 16][0] = bg;
1523         mc6847->colordata[attr_index][byte / 16][1] = fg;
1524
1525         for (row = 0; row < 12; row++)
1526         {
1527            mc6847->fontdata[attr_index][byte][row] = char_data[row];
1528         }
1529      }
1530   }
1531}
1532
1533
1534
1535/*************************************
1536 *
10751537 *  Video modes
10761538 *
10771539 *************************************/
10781540
1079static void graphics_color_64(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1541static void graphics_color_64(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
10801542{
10811543   int x;
10821544   UINT8 byte, attr;
r5922r5923
10861548      byte = video_data[x].data;
10871549      attr = video_data[x].attr;
10881550
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));
1551      line[ 0] = line[ 1] = line[ 2] = line[ 3] = color(device, ((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1552      line[ 4] = line[ 5] = line[ 6] = line[ 7] = color(device, ((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1553      line[ 8] = line[ 9] = line[10] = line[11] = color(device, ((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1554      line[12] = line[13] = line[14] = line[15] = color(device, ((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
10931555      line += 16;
10941556   }
10951557}
10961558
10971559
10981560
1099static void graphics_color_128(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1561static void graphics_color_128(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
11001562{
11011563   int x;
11021564   UINT8 byte, attr;
r5922r5923
11061568      byte = video_data[x].data;
11071569      attr = video_data[x].attr;
11081570
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));
1571      line[ 0] = line[ 1] = color(device, ((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1572      line[ 2] = line[ 3] = color(device, ((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1573      line[ 4] = line[ 5] = color(device, ((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
1574      line[ 6] = line[ 7] = color(device, ((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN));
11131575      line += 8;
11141576   }
11151577}
11161578
11171579
11181580
1119static void graphics_bw_128(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1581static void graphics_bw_128(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
11201582{
11211583   int x;
11221584   UINT8 byte, attr;
r5922r5923
11271589      byte = video_data[x].data;
11281590      attr = video_data[x].attr;
11291591
1130      bg = color(attr & M6847_CSS ? 10 :  8);
1131      fg = color(attr & M6847_CSS ? 11 :  9);
1592      bg = color(device, attr & M6847_CSS ? 10 :  8);
1593      fg = color(device, attr & M6847_CSS ? 11 :  9);
11321594
11331595      line[ 0] = line[ 1] = ((byte >> 7) & 0x01) ? fg : bg;
11341596      line[ 2] = line[ 3] = ((byte >> 6) & 0x01) ? fg : bg;
r5922r5923
11441606
11451607
11461608
1147static void graphics_bw_256(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1609static void graphics_bw_256(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
11481610{
11491611   int x;
11501612   UINT8 byte, attr;
r5922r5923
11551617      byte = video_data[x].data;
11561618      attr = video_data[x].attr;
11571619
1158      bg = color(attr & M6847_CSS ? 10 :  8);
1159      fg = color(attr & M6847_CSS ? 11 :  9);
1620      bg = color(device, attr & M6847_CSS ? 10 :  8);
1621      fg = color(device, attr & M6847_CSS ? 11 :  9);
11601622
11611623      line[0] = ((byte >> 7) & 0x01) ? fg : bg;
11621624      line[1] = ((byte >> 6) & 0x01) ? fg : bg;
r5922r5923
11721634
11731635
11741636
1175static void (*const graphics_modes[8])(UINT32 *line, const m6847_pixel *video_data) =
1637static void (*const graphics_modes[8])(const device_config *device, UINT32 *line, const m6847_pixel *video_data) =
11761638{
11771639   graphics_color_64,   graphics_bw_128,
11781640   graphics_color_128,   graphics_bw_128,
r5922r5923
11821644
11831645
11841646
1185static void text_mode(running_machine *machine, int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1647static void text_mode(const device_config *device, int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
11861648{
1649   mc6847_state *mc6847 = get_safe_token(device);
11871650   int x;
11881651   UINT8 byte, attr;
11891652   int attr_index;
r5922r5923
11951658      byte = video_data[x].data;
11961659      attr = video_data[x].attr;
11971660
1198      attr_index = attr_index_from_attribute(attr);
1661      attr_index = attr_index_from_attribute(device, attr);
11991662
1200      bg_color = color(m6847->colordata[attr_index][byte / 16][0]);
1201      fg_color = color(m6847->colordata[attr_index][byte / 16][1]);
1663      bg_color = color(device, mc6847->colordata[attr_index][byte / 16][0]);
1664      fg_color = color(device, mc6847->colordata[attr_index][byte / 16][1]);
12021665
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);
1666      if( (!mc6847->has_lowercase) && (attr & M6847_INTEXT) && !(attr & M6847_AS)) {
1667         if (mc6847->get_char_rom) {
1668            char_data = mc6847->get_char_rom(device->machine,byte,scanline % 12);
12061669         } else {
12071670            char_data = 0xff;
12081671         }
12091672      } else {
1210         if (m6847->get_char_rom)
1211            char_data = m6847->get_char_rom(machine,byte,scanline % 12);
1673         if (mc6847->get_char_rom)
1674            char_data = mc6847->get_char_rom(device->machine,byte,scanline % 12);
12121675         else
1213            char_data = m6847->fontdata[attr_index][byte][scanline % 12];
1676            char_data = mc6847->fontdata[attr_index][byte][scanline % 12];
12141677      }
12151678
12161679      line[x*8+0] = (char_data & 0x80) ? fg_color : bg_color;
r5922r5923
12261689
12271690
12281691
1229static void render_scanline(running_machine *machine, bitmap_t *bitmap, int scanline)
1692static void render_scanline(const device_config *device, bitmap_t *bitmap, int scanline)
12301693{
1694   mc6847_state *mc6847 = get_safe_token(device);
12311695   UINT32 border_color;
12321696   UINT32 *line;
12331697   UINT8 attrs;
r5922r5923
12381702   line = BITMAP_ADDR32(bitmap, scanline, 0);
12391703
12401704   /* choose the border color */
1241   border_color = m6847->border[scanline];
1242   attrs = m6847->attrs[scanline];
1705   border_color = mc6847->border[scanline];
1706   attrs = mc6847->attrs[scanline];
12431707
12441708   /* is this a border scanline? */
1245   scanline -= m6847->top_border_scanlines;
1246   if ((scanline >= 0) && (scanline < m6847->display_scanlines))
1709   scanline -= mc6847->top_border_scanlines;
1710   if ((scanline >= 0) && (scanline < mc6847->display_scanlines))
12471711   {
1248      video_data = m6847->screendata[scanline];
1712      video_data = mc6847->screendata[scanline];
12491713
12501714      /* left border */
12511715      for (x = 0; x < 32; x++)
r5922r5923
12551719      {
12561720         /* graphics */
12571721         mode = attrs & (M6847_GM2|M6847_GM1|M6847_GM0);
1258         graphics_modes[mode](line + 32, video_data);
1722         graphics_modes[mode](device, line + 32, video_data);
12591723      }
12601724      else
12611725      {
12621726         /* text/semigraphics */
1263         text_mode(machine, scanline, line + 32, video_data);
1727         text_mode(device, scanline, line + 32, video_data);
12641728      }
12651729
12661730      /* right border */
r5922r5923
12711735      if ((attrs & (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0))
12721736         == (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0))
12731737      {
1274         apply_artifacts(machine, line + 32);
1738         apply_artifacts(device->machine, line + 32);
12751739      }
12761740   }
12771741   else
r5922r5923
12841748
12851749
12861750
1287static void set_dirty(void)
1751static void set_dirty(mc6847_state *mc6847)
12881752{
1289   m6847->dirty = TRUE;
1753   mc6847->dirty = TRUE;
12901754}
12911755
12921756
12931757
1758/*****************************************************************************
1759    DEVICE INTERFACE
1760*****************************************************************************/
1761
1762static STATE_POSTLOAD( mc6847_postload )
1763{
1764   set_dirty(param);
1765}
1766
1767static DEVICE_START( mc6847 )
1768{
1769   mc6847_state *mc6847 = get_safe_token(device);
1770   const mc6847_interface *intf = device->static_config;
1771   const mc6847_config *cfg = device->inline_config;
1772
1773   const m6847_variant *v;
1774   UINT32 frequency;
1775   attoseconds_t period, frame_period, cpu0_clock_period = 0;
1776   double total_scanlines;
1777
1778   /* validate some basic stuff */
1779   assert(device->static_config != NULL);
1780   assert(device->inline_config != NULL);
1781
1782
1783
1784   /* identify proper M6847 variant */
1785   assert(cfg->type < ARRAY_LENGTH(variants));
1786   v = &variants[cfg->type];
1787
1788   /* allocate instance */
1789   set_dirty(mc6847);
1790
1791   /* copy configuration */
1792   mc6847->new_frame_callback = cfg->new_frame_callback;
1793   mc6847->custom_prepare_scanline = cfg->custom_prepare_scanline;
1794   mc6847->has_lowercase = v->has_lowercase;
1795   mc6847->get_char_rom = cfg->get_char_rom;
1796
1797   /* assert our assumptions */
1798   assert((v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)
1799      == (UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME));
1800   assert((v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE)
1801      == (UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE));
1802   assert((v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR)
1803      == (UINT32) (v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR));
1804
1805   /* choose palette */
1806   if (cfg->custom_palette)
1807   {
1808      mc6847->has_custom_palette = 1;
1809      mc6847->palette = cfg->custom_palette;
1810   }
1811   else
1812   {
1813      mc6847->palette = palette;
1814   }
1815
1816   /* allocate timers */
1817   mc6847->fs_rise_timer = timer_alloc(device->machine, fs_rise, mc6847);
1818   mc6847->fs_fall_timer = timer_alloc(device->machine, fs_fall, mc6847);
1819   mc6847->hs_rise_timer = timer_alloc(device->machine, hs_rise, mc6847);
1820   mc6847->hs_fall_timer = timer_alloc(device->machine, hs_fall, mc6847);
1821
1822   /* setup dimensions */
1823   mc6847->top_border_scanlines = v->top_border_scanlines;
1824   mc6847->display_scanlines = v->display_scanlines;
1825   mc6847->bottom_border_scanlines = v->bottom_border_scanlines;
1826
1827   /* compute frequency and period */
1828   frequency = v->frames_per_second
1829      * ((UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME))
1830      * ((UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE));
1831   period = ATTOSECONDS_PER_SECOND / frequency;
1832
1833   /* choose CPU clock, if specified */
1834   if (cfg->cpu0_timing_factor > 0)
1835   {
1836      cpu0_clock_period = period * cfg->cpu0_timing_factor * GROSS_FACTOR;
1837      cpu_set_clock(device->machine->firstcpu, ATTOSECONDS_PER_SECOND / cpu0_clock_period);
1838   }
1839
1840   /* calculate timing */
1841   total_scanlines = v->vblank_scanlines
1842      + v->top_border_scanlines
1843      + v->display_scanlines
1844      + v->bottom_border_scanlines
1845      + v->vretrace_scanlines;
1846   mc6847->clock_period = period * GROSS_FACTOR;
1847   mc6847->scanline_period = period * (UINT32) (v->clocks_per_scanline * GROSS_FACTOR);
1848   mc6847->field_sync_period = period * (UINT32) (v->clocks_per_scanline * v->field_sync_scanlines * GROSS_FACTOR);
1849   mc6847->horizontal_sync_period = period * GROSS_FACTOR * 33 / 2;
1850   mc6847->vblank_period = period * (UINT32) (v->clocks_per_scanline * v->vblank_scanlines * GROSS_FACTOR);
1851
1852   /* setup timing */
1853   frame_period = period *
1854      (UINT32) (v->clocks_per_scanline * total_scanlines * GROSS_FACTOR);
1855   timer_adjust_periodic(mc6847->fs_rise_timer, attotime_zero, 0, attotime_make(0, frame_period));
1856
1857   /* build font */
1858   build_fontdata(device, v);
1859
1860   /* dump stats */
1861   if (LOG_STATS)
1862   {
1863      logerror("m6847_init():\n");
1864      logerror("\tclock:      %30s sec\n", attotime_string(attotime_make(0, period * GROSS_FACTOR), ATTOTIME_STRING_PRECISION));
1865      if (cpu0_clock_period > 0)
1866         logerror("\tCPU0 clock: %30s sec\n", attotime_string(attotime_make(0, cpu0_clock_period), ATTOTIME_STRING_PRECISION));
1867      logerror("\tscanline:   %30s sec\n", attotime_string(attotime_make(0, mc6847->scanline_period), ATTOTIME_STRING_PRECISION));
1868      logerror("\tfield sync: %30s sec\n", attotime_string(attotime_make(0, mc6847->field_sync_period), ATTOTIME_STRING_PRECISION));
1869      logerror("\thorz sync:  %30s sec\n", attotime_string(attotime_make(0, mc6847->horizontal_sync_period), ATTOTIME_STRING_PRECISION));
1870      logerror("\tvblank:     %30s sec\n", attotime_string(attotime_make(0, mc6847->vblank_period), ATTOTIME_STRING_PRECISION));
1871      logerror("\tframe:      %30s sec\n", attotime_string(attotime_make(0, frame_period), ATTOTIME_STRING_PRECISION));
1872      logerror("\n");
1873   }
1874
1875#if 0
1876   /* setup debug commands */
1877   if (device->machine->debug_flags & DEBUG_FLAG_ENABLED)
1878      debug_console_register_command(device->machine, "m6847_dumpscanline", CMDFLAG_NONE, 0, 0, 0, execute_m6847_dumpscanline);
1879#endif
1880
1881
1882   /* resolve callbacks */
1883   devcb_resolve_read8(&mc6847->in_dd_func, &intf->in_dd_func, device);
1884   devcb_resolve_read_line(&mc6847->in_gm2_func, &intf->in_gm2_func, device);
1885   devcb_resolve_read_line(&mc6847->in_gm1_func, &intf->in_gm1_func, device);
1886   devcb_resolve_read_line(&mc6847->in_gm0_func, &intf->in_gm0_func, device);
1887   devcb_resolve_read_line(&mc6847->in_intext_func, &intf->in_intext_func, device);
1888   devcb_resolve_read_line(&mc6847->in_inv_func, &intf->in_inv_func, device);
1889   devcb_resolve_read_line(&mc6847->in_as_func, &intf->in_as_func, device);
1890   devcb_resolve_read_line(&mc6847->in_ag_func, &intf->in_ag_func, device);
1891   devcb_resolve_write_line(&mc6847->out_fs_func, &intf->out_fs_func, device);
1892   devcb_resolve_write_line(&mc6847->out_hs_func, &intf->out_hs_func, device);
1893   devcb_resolve_read_line(&mc6847->in_css_func, &intf->in_css_func, device);
1894
1895   /* setup save states */
1896   state_save_register_postload(device->machine, mc6847_postload, mc6847);
1897}
1898
1899static DEVICE_RESET( mc6847 )
1900{
1901   mc6847_state *mc6847 = get_safe_token(device);
1902
1903   mc6847->gm2 = 0;
1904   mc6847->gm1 = 0;
1905   mc6847->gm0 = 0;
1906   mc6847->intext = 0;
1907   mc6847->inv = 0;
1908   mc6847->as = 0;
1909   mc6847->ag = 0;
1910   mc6847->css = 0;
1911}
1912
1913DEVICE_GET_INFO( mc6847 )
1914{
1915   switch (state)
1916   {
1917      /* --- the following bits of info are returned as 64-bit signed integers --- */
1918      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(mc6847_state);               break;
1919      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = sizeof(mc6847_config);            break;
1920      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_OTHER;               break;
1921
1922      /* --- the following bits of info are returned as pointers to data or functions --- */
1923      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(mc6847);      break;
1924      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
1925      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(mc6847);      break;
1926
1927      /* --- the following bits of info are returned as NULL-terminated strings --- */
1928      case DEVINFO_STR_NAME:               strcpy(info->s, "Motorola 6847");            break;
1929      case DEVINFO_STR_FAMILY:            strcpy(info->s, "MC6847 VDG");               break;
1930      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
1931      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
1932      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MESS Team");         break;
1933   }
1934}
1935
1936
1937/***************************************************************************
1938    IMPLEMENTATION
1939***************************************************************************/
1940
1941WRITE_LINE_DEVICE_HANDLER( mc6847_gm2_w )
1942{
1943   mc6847_state *mc6847 = get_safe_token(device);
1944   mc6847->gm2 = state;
1945}
1946
1947WRITE_LINE_DEVICE_HANDLER( mc6847_gm1_w )
1948{
1949   mc6847_state *mc6847 = get_safe_token(device);
1950   mc6847->gm1 = state;
1951}
1952
1953WRITE_LINE_DEVICE_HANDLER( mc6847_gm0_w )
1954{
1955   mc6847_state *mc6847 = get_safe_token(device);
1956   mc6847->gm0 = state;
1957}
1958
1959WRITE_LINE_DEVICE_HANDLER( mc6847_intext_w )
1960{
1961   mc6847_state *mc6847 = get_safe_token(device);
1962   mc6847->intext = state;
1963}
1964
1965WRITE_LINE_DEVICE_HANDLER( mc6847_inv_w )
1966{
1967   mc6847_state *mc6847 = get_safe_token(device);
1968   mc6847->inv = state;
1969}
1970
1971WRITE_LINE_DEVICE_HANDLER( mc6847_as_w )
1972{
1973   mc6847_state *mc6847 = get_safe_token(device);
1974   mc6847->as = state;
1975}
1976
1977WRITE_LINE_DEVICE_HANDLER( mc6847_ag_w )
1978{
1979   mc6847_state *mc6847 = get_safe_token(device);
1980   mc6847->ag = state;
1981}
1982
1983WRITE_LINE_DEVICE_HANDLER( mc6847_css_w )
1984{
1985   mc6847_state *mc6847 = get_safe_token(device);
1986   mc6847->css = state;
1987}
1988
1989READ_LINE_DEVICE_HANDLER( mc6847_fs_r )
1990{
1991   mc6847_state *mc6847 = get_safe_token(device);
1992   return mc6847->fs;
1993}
1994
1995READ_LINE_DEVICE_HANDLER( mc6847_hs_r )
1996{
1997   mc6847_state *mc6847 = get_safe_token(device);
1998   return mc6847->hs;
1999}
2000
2001
2002void mc6847_set_palette(const device_config *device, UINT32 *palette)
2003{
2004   mc6847_state *mc6847 = get_safe_token(device);
2005   mc6847->has_custom_palette = 1;
2006   mc6847->palette = palette;
2007}
2008
2009
12942010/*************************************
12952011 *
12962012 *  Artifacting hack; should be in core
r5922r5923
14222138
14232139static INPUT_CHANGED( artifacting_changed )
14242140{
1425   set_dirty();
2141   /* TODO: not sure how to do this with a device... */
2142//   set_dirty();
14262143}
14272144
14282145
r5922r5923
14372154
14382155
14392156
1440/*************************************
1441 *
1442 *  Scanline operations
1443 *
1444 *************************************/
14452157
1446static int get_scanline(void)
2158UINT32 mc6847_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
14472159{
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(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 m6847_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();
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{
2160   mc6847_state *mc6847 = get_safe_token(device);
19432161   int row, i;
19442162   UINT32 rc = 0;
19452163
19462164   /* if we have a custom palette, check to see if it has changed */
1947   if (!m6847->dirty && m6847->has_custom_palette)
2165   if (!mc6847->dirty && mc6847->has_custom_palette)
19482166   {
19492167      for (i = 0; i < 16; i++)
19502168      {
1951         if (m6847->palette[i] != m6847->saved_palette[i])
2169         if (mc6847->palette[i] != mc6847->saved_palette[i])
19522170         {
1953            m6847->dirty = TRUE;
2171            mc6847->dirty = TRUE;
19542172            break;
19552173         }
19562174      }
19572175   }
19582176
1959   if (m6847->dirty)
2177   if (mc6847->dirty)
19602178   {
19612179      /* this frame is dirty; render it */
1962      m6847->dirty = FALSE;
2180      mc6847->dirty = FALSE;
19632181
19642182      /* copy palette if we have a custom palete */
1965      if (m6847->has_custom_palette)
2183      if (mc6847->has_custom_palette)
19662184      {
19672185         for (i = 0; i < 16; i++)
1968            m6847->saved_palette[i] = m6847->palette[i];
2186            mc6847->saved_palette[i] = mc6847->palette[i];
19692187      }
19702188
19712189      /* the video RAM has been dirtied; need to draw */
19722190      for (row = cliprect->min_y; row <= cliprect->max_y; row++)
1973         render_scanline(screen->machine, bitmap, row);
2191         render_scanline(device, bitmap, row);
19742192   }
19752193   else
19762194   {
r5922r5923
19982216
19992217
20002218
2001static attotime interval(m6847_timing_type timing)
2219static attotime interval(const device_config *device, m6847_timing_type timing)
20022220{
2221   mc6847_state *mc6847 = get_safe_token(device);
20032222   attotime result;
20042223
20052224   switch(timing)
20062225   {
20072226      case M6847_CLOCK:
2008         result = attotime_make(0, m6847->clock_period);
2227         result = attotime_make(0, mc6847->clock_period);
20092228         break;
20102229      case M6847_HSYNC:
2011         result = attotime_make(0, m6847->scanline_period);
2230         result = attotime_make(0, mc6847->scanline_period);
20122231         break;
20132232      default:
20142233         fatalerror("invalid timing type");
r5922r5923
20192238
20202239
20212240
2022UINT64 m6847_time(running_machine *machine, m6847_timing_type timing)
2241UINT64 m6847_time(const device_config *device, m6847_timing_type timing)
20232242{
2024   attotime current_time = timer_get_time(machine);
2025   attotime divisor = interval(timing);
2243   attotime current_time = timer_get_time(device->machine);
2244   attotime divisor = interval(device, timing);
20262245   return divide_mame_time(current_time, divisor);
20272246}
20282247
20292248
20302249
2031attotime m6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time)
2250attotime m6847_time_until(const device_config *device, m6847_timing_type timing, UINT64 target_time)
20322251{
20332252   attotime target_mame_time, current_time;
2034   target_mame_time = attotime_mul(interval(timing), target_time);
2035   current_time = timer_get_time(machine);
2253   target_mame_time = attotime_mul(interval(device, timing), target_time);
2254   current_time = timer_get_time(device->machine);
20362255
20372256   if (attotime_compare(target_mame_time, current_time) < 0)
20382257      fatalerror("m6847_time_until(): cannot target past times");
r5922r5923
20422261
20432262
20442263
2045attotime m6847_scanline_time(int scanline)
2264attotime m6847_scanline_time(const device_config *device, int scanline)
20462265{
2047   return attotime_make(0, m6847->scanline_period *
2266   mc6847_state *mc6847 = get_safe_token(device);
2267
2268   return attotime_make(0, mc6847->scanline_period *
20482269         (13 /* FIXME */ + scanline));
20492270}
20502271
r5922r5923
20602281void m6847_set_dirty(void) { set_dirty(); }
20612282int m6847_get_scanline(void) { return get_scanline(); }
20622283#endif
2284
2285int mc6847_get_scanline(const device_config *device)
2286{
2287   mc6847_state *mc6847 = get_safe_token(device);
2288   return get_scanline(mc6847) - mc6847->top_border_scanlines;
2289}
src/mess/video/m6847.h
r5922r5923
99#ifndef __M6847_H__
1010#define __M6847_H__
1111
12#include "devcb.h"
1213
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
1614
15/***************************************************************************
16    CONSTANTS
17***************************************************************************/
18
1719typedef enum
1820{
1921   M6847_VERSION_ORIGINAL_NTSC,
r5922r5923
2628   M6847_VERSION_GIME_PAL
2729} m6847_type;
2830
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};
31/* for now, the MAME core forces us to use these */
32#define M6847_NTSC_FRAMES_PER_SECOND   60
33#define M6847_PAL_FRAMES_PER_SECOND      50
4034
4135typedef enum
4236{
r5922r5923
4438   M6847_HSYNC
4539} m6847_timing_type;
4640
47typedef struct _m6847_config m6847_config;
48struct _m6847_config
41
42/***************************************************************************
43    TYPE DEFINITIONS
44***************************************************************************/
45
46typedef struct _mc6847_interface mc6847_interface;
47struct _mc6847_interface
4948{
49   /* data fetch */
50   devcb_read8 in_dd_func;
51
52   /* mode control lines input */
53   devcb_read_line in_gm2_func;
54   devcb_read_line in_gm1_func;
55   devcb_read_line in_gm0_func;
56   devcb_read_line in_intext_func;
57   devcb_read_line in_inv_func;
58   devcb_read_line in_as_func;
59   devcb_read_line in_ag_func;
60   devcb_read_line in_css_func;
61
62   /* synchronizing outputs */
63   devcb_write_line out_fs_func;
64   devcb_write_line out_hs_func;
65   devcb_write_line out_rs_func;
66};
67
68typedef struct _mc6847_config mc6847_config;
69struct _mc6847_config
70{
5071   m6847_type type;
5172   int cpu0_timing_factor;
5273
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);
5874   UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch, int line);
5975
6076   /* needed for the CoCo 3 */
61   int (*new_frame_callback)(void);   /* returns whether the M6847 is in charge of this frame */
77   int (*new_frame_callback)(running_machine *machine);   /* returns whether the M6847 is in charge of this frame */
6278   void (*custom_prepare_scanline)(int scanline);
6379
6480   const UINT32 *custom_palette;
6581};
6682
67/* creates a new M6847 instance */
68void m6847_init(running_machine *machine, const m6847_config *cfg);
6983
84/***************************************************************************
85    FUNCTION PROTOTYPES
86***************************************************************************/
87
88DEVICE_GET_INFO( mc6847 );
89
90
91/***************************************************************************
92    DEVICE CONFIGURATION MACROS
93***************************************************************************/
94
95#define MC6847 DEVICE_GET_INFO_NAME(mc6847)
96
97#define MDRV_MC6847_ADD(_tag, _interface) \
98   MDRV_DEVICE_ADD(_tag, MC6847, 0) \
99   MDRV_DEVICE_CONFIG(_interface)
100
101#define MDRV_MC6847_TYPE(_type) \
102   MDRV_DEVICE_CONFIG_DATA32(mc6847_config, type, _type)
103
104#define MDRV_MC6847_TIMING_FACTOR(_factor) \
105   MDRV_DEVICE_CONFIG_DATA32(mc6847_config, cpu0_timing_factor, _factor)
106
107#define MDRV_MC6847_CHAR_ROM(_get_char_rom) \
108   MDRV_DEVICE_CONFIG_DATAPTR(mc6847_config, get_char_rom, _get_char_rom)
109
110#define MDRV_MC6847_FRAME_CALLBACK(_new_frame_callback) \
111   MDRV_DEVICE_CONFIG_DATAPTR(mc6847_config, new_frame_callback, _new_frame_callback)
112
113#define MDRV_MC6847_PREPARE_SCANLINE(_prepare_scanline) \
114   MDRV_DEVICE_CONFIG_DATAPTR(mc6847_config, custom_prepare_scanline, _prepare_scanline)
115
116#define MDRV_MC6847_PALETTE(_palette) \
117   MDRV_DEVICE_CONFIG_DATAPTR(mc6847_config, custom_palette, _palette)
118
119
120/***************************************************************************
121    DEVICE I/O FUNCTIONS
122***************************************************************************/
123
124/* mode control input lines */
125WRITE_LINE_DEVICE_HANDLER( mc6847_gm2_w );
126WRITE_LINE_DEVICE_HANDLER( mc6847_gm1_w );
127WRITE_LINE_DEVICE_HANDLER( mc6847_gm0_w );
128WRITE_LINE_DEVICE_HANDLER( mc6847_intext_w );
129WRITE_LINE_DEVICE_HANDLER( mc6847_inv_w );
130WRITE_LINE_DEVICE_HANDLER( mc6847_as_w );
131WRITE_LINE_DEVICE_HANDLER( mc6847_ag_w );
132WRITE_LINE_DEVICE_HANDLER( mc6847_css_w );
133
134/* synchronizing outputs */
135READ_LINE_DEVICE_HANDLER( mc6847_fs_r );
136READ_LINE_DEVICE_HANDLER( mc6847_hs_r );
137
138
139
70140/* video update proc */
71VIDEO_UPDATE(m6847);
141UINT32 mc6847_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
142
143void mc6847_set_palette(const device_config *device, UINT32 *palette);
144
145/* hack for the coco until the 6883sam can be updated */
146int mc6847_get_scanline(const device_config *device);
147
148
72149void m6847_video_changed(void);
73150
74/* sync */
75int m6847_get_horizontal_sync(running_machine *machine);
76int m6847_get_field_sync(running_machine *machine);
77
78151/* timing functions */
79UINT64 m6847_time(running_machine *machine,m6847_timing_type timing);
80attotime m6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time);
152UINT64 m6847_time(const device_config *device, m6847_timing_type timing);
153attotime m6847_time_until(const device_config *device, m6847_timing_type timing, UINT64 target_time);
81154
82155/* CoCo 3 hooks */
83attotime m6847_scanline_time(int scanline);
156attotime m6847_scanline_time(const device_config *device, int scanline);
84157
85158INPUT_PORTS_EXTERN( m6847_artifacting );
86159
src/mess/video/coco3.c
r5922r5923
422422   if (video->legacy_video)
423423   {
424424      /* legacy CoCo 1/2 graphics */
425      rc = VIDEO_UPDATE_CALL(m6847);
425      const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
426      rc = mc6847_update(mc6847, bitmap, cliprect);
426427
427428      if ((rc & UPDATE_HAS_NOT_CHANGED) == 0)
428429      {
r5922r5923
469470
470471
471472
472static int coco3_new_frame(void)
473int coco3_new_frame(running_machine *machine)
473474{
475   const device_config *mc6847 = devtag_get_device(machine, "mc6847");
474476   int gime_field_sync = 0;
475477
476478   /* changing from non-legacy to legacy video? */
r5922r5923
521523
522524   /* set up GIME field sync */
523525   timer_adjust_oneshot(video->gime_fs_timer,
524      m6847_scanline_time(gime_field_sync), 0);
526      m6847_scanline_time(mc6847, gime_field_sync), 0);
525527
526528   return video->legacy_video;
527529}
r5922r5923
538540
539541
540542
541static void coco3_prepare_scanline(int scanline)
543void coco3_prepare_scanline(int scanline)
542544{
543545   static const UINT32 lines_per_row[] = { 1, 1, 2, 8, 9, 10, 11, ~0 };
544546   static const UINT32 gfx_bytes_per_row[] = { 16, 20, 32, 40, 64, 80, 128, 160 };
r5922r5923
789791}
790792
791793
792static const UINT8 *get_video_ram_coco3(running_machine *machine,int scanline)
794static int last_scanline = -1;
795const UINT8 *coco3_videoram = 0;
796
797READ8_DEVICE_HANDLER( coco3_mc6847_videoram_r )
793798{
794   const device_config *sam = devtag_get_device(machine, "sam");
795   return sam_m6847_get_video_ram(sam,scanline);
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];
796816}
797817
798static void internal_video_start_coco3(running_machine *machine, m6847_type type)
818
819VIDEO_START( coco3 )
799820{
821   const device_config *mc6847 = devtag_get_device(machine, "mc6847");
800822   int i;
801   m6847_config cfg;
802823   const UINT8 *rom;
803824
804825   /* allocate video */
r5922r5923
833854   video->gime_fs_timer = timer_alloc(machine, gime_fs, NULL);
834855
835856   /* initialize the CoCo video code */
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);
857   mc6847_set_palette(mc6847, video->palette_colors);
847858
848859   /* save state stuff */
849860   state_save_register_global_array(machine, video->palette_ram);
r5922r5923
854865}
855866
856867
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
870868void coco3_vh_blink(void)
871869{
872870   video->blink = !video->blink;
src/mess/includes/z80ne.h
r5922r5923
2525#define LX385_TAPE_SAMPLE_FREQ 38400
2626
2727
28/*----------- defined in video/z80ne.c -----------*/
29
30VIDEO_START(lx388);
31
3228/*----------- defined in machine/z80ne.c -----------*/
3329
3430READ8_HANDLER(lx383_r);
r5922r5923
3733WRITE8_HANDLER(lx385_data_w);
3834READ8_HANDLER(lx385_ctrl_r);
3935WRITE8_HANDLER(lx385_ctrl_w);
36READ8_DEVICE_HANDLER(lx388_mc6847_videoram_r);
37VIDEO_UPDATE(lx388);
4038READ8_HANDLER(lx388_data_r);
4139READ8_HANDLER(lx388_read_field_sync);
4240READ8_DEVICE_HANDLER(lx390_fdc_r);
src/mess/includes/coco.h
r5922r5923
4141   const device_config *pia_0;
4242   const device_config *pia_1;
4343   const device_config *pia_2;
44   const device_config *mc6847;
4445};
4546
4647
r5922r5923
5051
5152/*----------- defined in video/coco.c -----------*/
5253
53ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c,int scanline, int pos);
54READ8_DEVICE_HANDLER( coco_mc6847_videoram_r );
55VIDEO_UPDATE( coco );
5456
55VIDEO_START( dragon );
56VIDEO_START( coco );
57VIDEO_START( coco2b );
5857
59
6058/*----------- defined in video/coco3.c -----------*/
6159
60int coco3_new_frame(running_machine *machine);
61void coco3_prepare_scanline(int scanline);
62READ8_DEVICE_HANDLER( coco3_mc6847_videoram_r );
6263VIDEO_START( coco3 );
63VIDEO_START( coco3p );
6464VIDEO_UPDATE( coco3 );
6565WRITE8_HANDLER ( coco3_palette_w );
6666UINT32 coco3_get_video_base(UINT8 ff9d_mask, UINT8 ff9e_mask);
r5922r5923
110110WRITE8_HANDLER ( coco3_gime_w );
111111offs_t coco3_mmu_translate(int bank, int offset);
112112WRITE8_DEVICE_HANDLER( coco_pia_1_w );
113void coco3_horizontal_sync_callback(running_machine *machine,int data);
114void coco3_field_sync_callback(running_machine *machine,int data);
113WRITE_LINE_DEVICE_HANDLER( coco3_hs_w );
114WRITE_LINE_DEVICE_HANDLER( coco3_fs_w );
115115void coco3_gime_field_sync_callback(running_machine *machine);
116116
117117void coco_cart_w(const device_config *device, int data);
src/mess/includes/atom.h
r5922r5923
1313#include "machine/i8271.h"
1414
1515/* Motherboard crystals
16 
16
1717Source: http://acorn.chriswhy.co.uk/docs/Acorn/Manuals/Acorn_AtomTechnicalManual.pdf
1818
1919*/
r5922r5923
4545
4646MACHINE_RESET( atomeb );
4747
48READ8_DEVICE_HANDLER( atom_mc6847_videoram_r );
49VIDEO_UPDATE( atom );
4850
49/*----------- defined in video/atom.c -----------*/
5051
51VIDEO_START( atom );
52
53
5452#endif /* ATOM_H_ */
src/mess/includes/mc10.h
r5922r5923
1919WRITE8_HANDLER ( mc10_port1_w );
2020WRITE8_HANDLER ( mc10_port2_w );
2121
22VIDEO_START( mc10 );
22READ8_DEVICE_HANDLER(mc10_mc6847_videoram_r);
23VIDEO_UPDATE(mc10);
2324MACHINE_START( mc10 );
2425
2526
src/mess/includes/apf.h
r5922r5923
88#define APF_H_
99
1010
11/*----------- defined in video/apf.c -----------*/
12
13extern unsigned char *apf_video_ram;
14
15VIDEO_START(apf);
16extern UINT8 apf_m6847_attr;
17
18
1911/*----------- defined in drivers/apf.c -----------*/
2012
2113extern unsigned char apf_ints;
src/mess/includes/vtech1.h
r5922r5923
4040WRITE8_HANDLER( vtech1_serial_w );
4141WRITE8_HANDLER( vtech1_memory_bank_w );
4242
43READ8_DEVICE_HANDLER(vtech1_mc6847_videoram_r);
44VIDEO_UPDATE(vtech1);
4345
44/*----------- defined in video/vtech1.c -----------*/
4546
46VIDEO_START( vtech1_monochrome );
47VIDEO_START( vtech1 );
48
49
5047#endif /* VTECH1_H_ */
src/mess/machine/coco.c
r5922r5923
125125static UINT8 mux_sel1, mux_sel2;
126126
127127static WRITE8_DEVICE_HANDLER ( d_pia1_pb_w );
128static WRITE8_DEVICE_HANDLER( d_pia1_pb_w_coco2 );
128129static WRITE8_DEVICE_HANDLER ( d_pia1_pa_w );
129130static READ8_DEVICE_HANDLER ( d_pia1_pa_r );
130131static WRITE8_DEVICE_HANDLER ( d_pia0_pa_w );
r5922r5923
332333   DEVCB_NULL,
333334   /*outputs: A/B,CA/B2      */
334335   DEVCB_HANDLER(d_pia1_pa_w),
335   DEVCB_HANDLER(d_pia1_pb_w),
336   DEVCB_HANDLER(d_pia1_pb_w_coco2),
336337   DEVCB_HANDLER(d_pia1_ca2_w),
337338   DEVCB_HANDLER(d_pia1_cb2_w),
338339   /*irqs    : A/B            */
r5922r5923
10321033
10331034
10341035
1035void coco3_horizontal_sync_callback(running_machine *machine,int data)
1036WRITE_LINE_DEVICE_HANDLER( coco3_hs_w )
10361037{
1037   coco_state *state = machine->driver_data;
1038   pia6821_ca1_w(state->pia_0, 0, data);
1039   coco3_raise_interrupt(machine, COCO3_INT_HBORD, data);
1038   coco_state *coco = device->machine->driver_data;
1039   pia6821_ca1_w(coco->pia_0, 0, state);
1040   coco3_raise_interrupt(device->machine, COCO3_INT_HBORD, state);
10401041}
10411042
10421043
1043
1044void coco3_field_sync_callback(running_machine *machine,int data)
1044WRITE_LINE_DEVICE_HANDLER( coco3_fs_w )
10451045{
1046   coco_state *state = machine->driver_data;
1047   pia6821_cb1_w(state->pia_0, 0, data);
1046   coco_state *coco = device->machine->driver_data;
1047   pia6821_cb1_w(coco->pia_0, 0, state);
10481048}
10491049
10501050void coco3_gime_field_sync_callback(running_machine *machine)
r5922r5923
10961096{
10971097   double val;
10981098   UINT8 ctrl = input_port_read_safe(machine, "ctrl_sel", 0x00);
1099   /* this function gets only called for hi-res joystick. hence, ctrl can only take values
1099   /* this function gets only called for hi-res joystick. hence, ctrl can only take values
11001100      0x04, 0x40 (hi-res) or 0x05, 0x50 (hi-res coco3max) */
11011101   UINT8 coco3max = ((ctrl & 0x0f) == 0x05 || (ctrl & 0xf0) == 0x50) ? 1 : 0;
11021102
r5922r5923
13701370
13711371   static const char *const portnames[2][6][2] =
13721372         {
1373            { {0}, {"joystick_rx", "joystick_ry"}, {"rat_mouse_rx", "rat_mouse_ry"}, {"dclg_rx", "dclg_ry"},
1373            { {0}, {"joystick_rx", "joystick_ry"}, {"rat_mouse_rx", "rat_mouse_ry"}, {"dclg_rx", "dclg_ry"},
13741374               {"joystick_hires_rx", "joystick_hires_ry"}, {"joystick_hires_max_rx", "joystick_hires_max_ry"} },   /* right ports */
1375            { {0}, {"joystick_lx", "joystick_ly"}, {"rat_mouse_lx", "rat_mouse_ly"}, {"dclg_lx", "dclg_ly"},
1375            { {0}, {"joystick_lx", "joystick_ly"}, {"rat_mouse_lx", "rat_mouse_ly"}, {"dclg_lx", "dclg_ly"},
13761376               {"joystick_hires_lx", "joystick_hires_ly"}, {"joystick_hires_max_lx", "joystick_hires_max_ly"} },   /* left ports */
13771377         };
13781378
r5922r5923
15561556   coco_sound_update(device->machine);
15571557
15581558   /* Diecom Light Gun (either in Left or in Right Port) writes here */
1559   if ((input_port_read_safe(device->machine, "ctrl_sel", 0x00) & 0x0f) == 0x03 ||
1559   if ((input_port_read_safe(device->machine, "ctrl_sel", 0x00) & 0x0f) == 0x03 ||
15601560      (input_port_read_safe(device->machine, "ctrl_sel", 0x00) & 0xf0) == 0x30)
15611561   {
15621562      int dclg_this_bit = ((data & 2) >> 1);
r5922r5923
16111611   else if ((input_port_read_safe(device->machine, "ctrl_sel", 0x00) & 0xf0) == 0x40)
16121612      coco_hiresjoy_w(device->machine, dac >= 0x80, 1);
16131613
1614   /* Handle printer output, serial for CoCos, Paralell for Dragons */
1614   /* Handle printer output, serial for CoCos, parallel for Dragons */
16151615
16161616   printer_out(device->machine, data);
16171617}
r5922r5923
16261626
16271627static WRITE8_DEVICE_HANDLER( d_pia1_pb_w )
16281628{
1629   m6847_video_changed();
1629   coco_state *state = device->machine->driver_data;
16301630
1631   mc6847_css_w(state->mc6847, BIT(data, 3));
1632   mc6847_gm0_w(state->mc6847, BIT(data, 4));
1633   mc6847_intext_w(state->mc6847, BIT(data, 4));
1634   mc6847_gm1_w(state->mc6847, BIT(data, 5));
1635   mc6847_gm2_w(state->mc6847, BIT(data, 6));
1636   mc6847_ag_w(state->mc6847, BIT(data, 7));
1637
16311638   /* PB1 will drive the sound output.  This is a rarely
16321639    * used single bit sound mode. It is always connected thus
16331640    * cannot be disabled.
16341641    *
1642    * Source:  Page 31 of the Tandy Color Computer Service Manual
1643    */
1644   coco_sound_update(device->machine);
1645}
1646
1647static WRITE8_DEVICE_HANDLER( d_pia1_pb_w_coco2 )
1648{
1649   coco_state *state = device->machine->driver_data;
1650
1651   mc6847_css_w(state->mc6847, BIT(data, 3));
1652   mc6847_gm0_w(state->mc6847, BIT(data, 4));
1653   mc6847_gm1_w(state->mc6847, BIT(data, 5));
1654   mc6847_gm2_w(state->mc6847, BIT(data, 6));
1655   mc6847_ag_w(state->mc6847, BIT(data, 7));
1656
1657   /* PB1 will drive the sound output.  This is a rarely
1658    * used single bit sound mode. It is always connected thus
1659    * cannot be disabled.
1660    *
16351661    * Source:  Page 31 of the Tandy Color Computer Serice Manual
16361662    */
16371663   coco_sound_update(device->machine);
r5922r5923
21742200
21752201static void coco3_timer_reset(running_machine *machine)
21762202{
2203   coco_state *state = machine->driver_data;
2204
21772205   /* reset the timer; take the value stored in $FF94-5 and start the timer ticking */
21782206   UINT64 current_time;
21792207   UINT16 timer_value;
r5922r5923
21952223      timing = (coco3_gimereg[1] & 0x20) ? M6847_CLOCK : M6847_HSYNC;
21962224
21972225      /* determine the current time */
2198      current_time = m6847_time(machine, timing);
2226      current_time = m6847_time(state->mc6847, timing);
21992227
22002228      /* calculate the time */
2201      target_time = m6847_time_until(machine, timing, current_time + timer_value);
2229      target_time = m6847_time_until(state->mc6847, timing, current_time + timer_value);
22022230      if (LOG_TIMER)
22032231         logerror("coco3_reset_timer(): target_time=%g\n", attotime_to_double(target_time));
22042232
r5922r5923
27902818   state->pia_0         = devtag_get_device(machine, "pia_0");
27912819   state->pia_1         = devtag_get_device(machine, "pia_1");
27922820   state->pia_2         = devtag_get_device(machine, "pia_2");
2821   state->mc6847         = devtag_get_device(machine, "mc6847");
27932822
27942823   /* clear static variables */
27952824   coco_hiresjoy_ca = 1;
r5922r5923
29452974static void update_lightgun(running_machine *machine)
29462975{
29472976   /* is there a Diecom Light Gun either in Left or in Right Port? */
2948   int is_lightgun = ((input_port_read_safe(machine, "ctrl_sel", 0x00) & 0x0f) == 0x03 ||
2977   int is_lightgun = ((input_port_read_safe(machine, "ctrl_sel", 0x00) & 0x0f) == 0x03 ||
29492978               (input_port_read_safe(machine, "ctrl_sel", 0x00) & 0xf0) == 0x30) ? 1 :0;
29502979
29512980   crosshair_set_screen(machine, 0, is_lightgun ? CROSSHAIR_SCREEN_ALL : CROSSHAIR_SCREEN_NONE);
r5922r5923
29692998   memset(&init, 0, sizeof(init));
29702999   init.recalc_interrupts_   = coco3_recalc_interrupts;
29713000   init.printer_out_      = printer_out_coco;
2972     
3001
29733002   generic_init_machine(machine, &init);
29743003
29753004   /* CoCo 3 specific function pointers */
src/mess/machine/6883sam.c
r5922r5923
171171   }
172172}
173173
174#if 0
175WRITE_LINE_DEVICE_HANDLER( sam6883_hs_w )
176{
177   sam6883_t *sam = get_safe_token(device);
178}
179
180WRITE8_DEVICE_HANDLER( sam6883_da_w )
181{
182   sam6883_t *sam = get_safe_token(device);
183}
184#endif
185
174186const UINT8 *sam_m6847_get_video_ram(const device_config *device,int scanline)
175187{
176188   sam6883_t *sam = get_safe_token(device);
src/mess/machine/6883sam.h
r5922r5923
1818#define __6833SAM_H__
1919
2020#include "driver.h"
21#include "devcb.h"
2122
2223
2324/***************************************************************************
r5922r5923
8081UINT8 get_sam_pagemode(const device_config *device);
8182UINT8 get_sam_maptype(const device_config *device);
8283
84#if 0
85WRITE_LINE_DEVICE_HANDLER( sam6883_hs_w );
86#endif
8387
88
8489/***************************************************************************
8590    DEVICE CONFIGURATION MACROS
8691***************************************************************************/
src/mess/machine/vtech1.c
r5922r5923
519519 * 1    cassette out (LSB)
520520 * 0    speaker A
521521 ************************************************/
522WRITE8_HANDLER(vtech1_latch_w)
522WRITE8_HANDLER( vtech1_latch_w )
523523{
524524   const device_config *speaker = devtag_get_device(space->machine, "speaker");
525   const device_config *mc6847 = devtag_get_device(space->machine, "mc6847");
525526
526527   if (LOG_VTECH1_LATCH)
527528      logerror("vtech1_latch_w $%02X\n", data);
528529
530   /* vdc mode control lines */
531   mc6847_ag_w(mc6847, BIT(data, 3));
532   mc6847_css_w(mc6847, BIT(data, 4));
533
529534   /* cassette data bits toggle? */
530535   if ((vtech1_latch ^ data ) & 0x06)
531536   {
r5922r5923
585590{
586591   logerror("vtech1_serial_w $%02x, offset %02x\n", data, offset);
587592}
593
594
595/***************************************************************************
596    MC6847
597***************************************************************************/
598
599READ8_DEVICE_HANDLER( vtech1_mc6847_videoram_r )
600{
601   mc6847_inv_w(device, BIT(videoram[offset], 6));
602   mc6847_as_w(device, BIT(videoram[offset], 7));
603
604   return videoram[offset];
605}
606
607VIDEO_UPDATE( vtech1 )
608{
609   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
610   return mc6847_update(mc6847, bitmap, cliprect);
611}
src/mess/machine/z80ne.c
r5922r5923
646646   }
647647}
648648
649READ8_DEVICE_HANDLER( lx388_mc6847_videoram_r )
650{
651   int d6 = BIT(videoram[offset], 6);
652   int d7 = BIT(videoram[offset], 7);
653
654   mc6847_inv_w(device, d6 && d7);
655   mc6847_as_w(device, !d6 && d7);
656   mc6847_intext_w(device, !d6 && d7);
657
658   return videoram[offset];
659}
660
661VIDEO_UPDATE( lx388 )
662{
663   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
664   return mc6847_update(mc6847, bitmap, cliprect);
665}
666
649667READ8_HANDLER(lx388_data_r)
650668{
651669   UINT8 data;
r5922r5923
655673   return data;
656674}
657675
658READ8_HANDLER(lx388_read_field_sync)
676READ8_HANDLER( lx388_read_field_sync )
659677{
660   UINT8 data;
661
662   data = m6847_get_field_sync(space->machine) ? 0x00 : 0x80;
663   return data;
678   const device_config *mc6847 = devtag_get_device(space->machine, "mc6847");
679   return mc6847_fs_r(mc6847) << 7;
664680}
665681
666682/*
src/mess/machine/atom.c
r5922r5923
288288
289289READ8_DEVICE_HANDLER ( atom_8255_portc_r )
290290{
291   const device_config *mc6847 = devtag_get_device(device->machine, "mc6847");
292
291293   atom_8255_portc &= 0x0f;
292294
293295   /* cassette input */
r5922r5923
302304      atom_8255_portc |= (1<<4);
303305   }
304306
305   atom_8255_portc |= (m6847_get_field_sync(device->machine) ? 0x00 : 0x80);
306307   atom_8255_portc |= (input_port_read(device->machine, "KEY11") & 0x40);
308   atom_8255_portc |= mc6847_fs_r(mc6847) << 7;
307309   /* logerror("8255: Read port c (%02X)\n",atom_8255.atom_8255_portc); */
308310   return (atom_8255_portc);
309311}
r5922r5923
322324
323325*/
324326
325WRITE8_DEVICE_HANDLER ( atom_8255_porta_w )
327WRITE8_DEVICE_HANDLER( atom_8255_porta_w )
326328{
329   const device_config *mc6847 = devtag_get_device(device->machine, "mc6847");
330
331   mc6847_ag_w(mc6847, BIT(data, 4));
332   mc6847_gm0_w(mc6847, BIT(data, 5));
333   mc6847_gm1_w(mc6847, BIT(data, 6));
334   mc6847_gm2_w(mc6847, BIT(data, 7));
335
327336   atom_8255_porta = data;
328337}
329338
r5922r5923
334343
335344WRITE8_DEVICE_HANDLER(atom_8255_portc_w)
336345{
346   const device_config *mc6847 = devtag_get_device(device->machine, "mc6847");
347
348   speaker_level_w(device, BIT(data, 2));
349   mc6847_css_w(mc6847, BIT(data, 3));
350
337351   atom_8255_portc = data;
338   speaker_level_w(device, BIT(data, 2));
339352}
340353
341354
r5922r5923
382395   atom_eprom_box_init(machine);
383396}
384397
398
399/***************************************************************************
400    MC6847 VDP
401***************************************************************************/
402
403READ8_DEVICE_HANDLER( atom_mc6847_videoram_r )
404{
405   mc6847_as_w(device, BIT(videoram[offset], 6));
406   mc6847_intext_w(device, BIT(videoram[offset], 6));
407   mc6847_inv_w(device, BIT(videoram[offset], 7));
408
409   return videoram[offset];
410}
411
412VIDEO_UPDATE( atom )
413{
414   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
415   return mc6847_update(mc6847, bitmap, cliprect);
416}
src/mess/machine/mc10.c
r5922r5923
2727*****************************************************************************/
2828
2929
30static UINT8 mc10_bfff;
3130static UINT8 mc10_keyboard_strobe;
3231
3332
r5922r5923
3938
4039MACHINE_START( mc10 )
4140{
42   mc10_bfff = 0x00;
4341   mc10_keyboard_strobe = 0x00;
4442
4543   memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),
4644         0x4000,   0x4000 + mess_ram_size - 1,   0, 0, SMH_BANK(1), SMH_BANK(1));
4745   memory_set_bankptr(machine, 1, mess_ram);
4846
49   state_save_register_global(machine, mc10_bfff);
5047   state_save_register_global(machine, mc10_keyboard_strobe);
5148}
5249
r5922r5923
8986WRITE8_HANDLER ( mc10_bfff_w )
9087{
9188   const device_config *dac_device = devtag_get_device(space->machine, "dac");
89   const device_config *mc6847 = devtag_get_device(space->machine, "mc6847");
9290
9391   /*   BIT 2 GM2 6847 CONTROL & INT/EXT CONTROL
9492     *   BIT 3 GM1 6847 CONTROL
r5922r5923
9795     *   BIT 6 CSS 6847 CONTROL
9896     *   BIT 7 SOUND OUTPUT BIT
9997     */
100   mc10_bfff = data;
101   dac_data_w(dac_device, data & 0x80);
98   mc6847_gm2_w(mc6847, BIT(data, 2));
99   mc6847_intext_w(mc6847, BIT(data, 2));
100   mc6847_gm1_w(mc6847, BIT(data, 3));
101   mc6847_gm0_w(mc6847, BIT(data, 4));
102   mc6847_ag_w(mc6847, BIT(data, 5));
103   mc6847_css_w(mc6847, BIT(data, 6));
104   dac_data_w(dac_device, BIT(data, 7));
102105}
103106
104107
r5922r5923
161164}
162165
163166
167/***************************************************************************
168    MC6847
169***************************************************************************/
164170
165/*****************************************************************************
166 Video hardware
167*****************************************************************************/
168
169
170static ATTR_CONST UINT8 mc10_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
171READ8_DEVICE_HANDLER( mc10_mc6847_videoram_r )
171172{
172   UINT8 result = 0x00;
173   if (c & 0x40)         result |= M6847_INV;
174   if (c & 0x80)         result |= M6847_AS;
175   if (mc10_bfff & 0x04)   result |= M6847_GM2 | M6847_INTEXT;
176   if (mc10_bfff & 0x08)   result |= M6847_GM1;
177   if (mc10_bfff & 0x10)   result |= M6847_GM0;
178   if (mc10_bfff & 0x20)   result |= M6847_AG;
179   if (mc10_bfff & 0x40)   result |= M6847_CSS;
180   return result;
181}
173   mc6847_inv_w(device, BIT(mess_ram[offset], 6));
174   mc6847_as_w(device, BIT(mess_ram[offset], 7));
182175
183
184static const UINT8 *mc10_get_video_ram(running_machine *machine, int scanline)
185{
186   offs_t offset = 0;
187
188   switch(mc10_bfff & 0x3C)
189   {
190      case 0x00: case 0x04: case 0x08: case 0x0C:
191      case 0x10: case 0x14: case 0x18: case 0x1C:
192         offset = (scanline / 12) * 0x20;   /* text/semigraphic */
193         break;
194
195      case 0x20:   offset = (scanline / 3) * 0x10;   break;   /* CG1 */
196      case 0x30:   offset = (scanline / 3) * 0x10;   break;   /* RG1 */
197      case 0x28:   offset = (scanline / 3) * 0x20;   break;   /* CG2 */
198      case 0x38:   offset = (scanline / 2) * 0x20;   break;   /* RG2 */
199      case 0x24:   offset = (scanline / 2) * 0x20;   break;   /* CG3 */
200      case 0x34:   offset = (scanline / 1) * 0x10;   break;   /* RG3 */
201      case 0x2C:   offset = (scanline / 1) * 0x20;   break;   /* CG6 */
202      case 0x3C:   offset = (scanline / 1) * 0x20;   break;   /* RG6 */
203   }
204
205   return mess_ram + offset;
176   return mess_ram[offset];
206177}
207178
208
209VIDEO_START( mc10 )
179VIDEO_UPDATE( mc10 )
210180{
211   m6847_config cfg;
212
213   memset(&cfg, 0, sizeof(cfg));
214   cfg.type = M6847_VERSION_ORIGINAL_NTSC;
215   cfg.get_attributes = mc10_get_attributes;
216   cfg.get_video_ram = mc10_get_video_ram;
217   m6847_init(machine, &cfg);
181   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
182   return mc6847_update(mc6847, bitmap, cliprect);
218183}
src/mess/mess.mak
r5922r5923
509509   $(MAME_MACHINE)/archimds.o   \
510510   $(MESS_DRIVERS)/z88.o      \
511511   $(MESS_VIDEO)/z88.o         \
512   $(MESS_VIDEO)/atom.o      \
513512   $(MESS_DRIVERS)/atom.o      \
514513   $(MESS_MACHINE)/atom.o      \
515514   $(MESS_FORMATS)/uef_cas.o   \
r5922r5923
545544
546545$(MESSOBJ)/apf.a:            \
547546   $(MESS_DRIVERS)/apf.o      \
548   $(MESS_VIDEO)/apf.o         \
549547   $(MESS_FORMATS)/apf_apt.o   \
550548
551549$(MESSOBJ)/apple.a:            \
r5922r5923
10121010
10131011$(MESSOBJ)/ne.a:            \
10141012   $(MESS_DRIVERS)/z80ne.o     \
1015   $(MESS_VIDEO)/z80ne.o       \
10161013   $(MESS_FORMATS)/z80ne_dsk.o \
10171014   $(MESS_MACHINE)/z80ne.o     \
10181015
r5922r5923
14551452   $(MESS_DRIVERS)/votrtnt.o   \
14561453
14571454$(MESSOBJ)/vtech.a:            \
1458   $(MESS_VIDEO)/vtech1.o      \
14591455   $(MESS_MACHINE)/vtech1.o   \
14601456   $(MESS_DRIVERS)/vtech1.o   \
14611457   $(MESS_VIDEO)/vtech2.o      \
src/mess/drivers/mc1000.c
r5922r5923
124124   mc1000_state *state = space->machine->driver_data;
125125
126126   state->mc6847_bank = BIT(data, 0);
127   mc6847_css_w(state->mc6847, BIT(data, 1));
128   mc6847_gm0_w(state->mc6847, BIT(data, 2));
129   mc6847_gm1_w(state->mc6847, BIT(data, 3));
130   mc6847_gm2_w(state->mc6847, BIT(data, 4));
131   mc6847_intext_w(state->mc6847, BIT(data, 5));
132   mc6847_as_w(state->mc6847, BIT(data, 6));
133   mc6847_ag_w(state->mc6847, BIT(data, 7));
127134
128135   mc1000_bankswitch(space->machine);
129
130   state->mc6847_attr = data;
131136}
132137
133138/* Memory Maps */
r5922r5923
239244
240245/* Video */
241246
242static void mc1000_hsync(running_machine *machine, int data)
247static WRITE_LINE_DEVICE_HANDLER( mc1000_mc6847_fs_w )
243248{
244   mc1000_state *state = machine->driver_data;
245
246   state->hsync = data;
249   mc1000_state *mc1000 = device->machine->driver_data;
250   mc1000->vsync = state;
247251}
248252
249static void mc1000_vsync(running_machine *machine, int data)
253static WRITE_LINE_DEVICE_HANDLER( mc1000_mc6847_hs_w )
250254{
251   mc1000_state *state = machine->driver_data;
252
253   state->vsync = data;
255   mc1000_state *mc1000 = device->machine->driver_data;
256   mc1000->hsync = state;
254257}
255258
256static ATTR_CONST UINT8 mc1000_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
259static READ8_DEVICE_HANDLER( mc1000_mc6847_videoram_r )
257260{
258   mc1000_state *state = machine->driver_data;
261   mc1000_state *state = device->machine->driver_data;
259262
260   UINT8 data = 0;
263   mc6847_inv_w(device, BIT(state->mc6847_video_ram[offset], 7));
261264
262   data |= BIT(c, 7) ? M6847_INV : 0;
263   data |= BIT(state->mc6847_attr, 1) ? M6847_CSS : 0;
264   data |= BIT(state->mc6847_attr, 2) ? M6847_GM0 : 0;
265   data |= BIT(state->mc6847_attr, 3) ? M6847_GM1 : 0;
266   data |= BIT(state->mc6847_attr, 4) ? M6847_GM2 : 0;
267   data |= BIT(state->mc6847_attr, 5) ? M6847_INTEXT : 0;
268   data |= BIT(state->mc6847_attr, 6) ? M6847_AS : 0;
269   data |= BIT(state->mc6847_attr, 7) ? M6847_AG : 0;
270
271   return data;
265   return state->mc6847_video_ram[offset];
272266}
273267
274#if 0
275static UINT8 mc1000_get_char_rom(running_machine *machine, UINT8 ch,int line)
268static VIDEO_UPDATE( mc1000 )
276269{
277   return ch;
270   mc1000_state *state = screen->machine->driver_data;
271   return mc6847_update(state->mc6847, bitmap, cliprect);
278272}
279#endif
280273
281static const UINT8 *mc1000_get_video_ram(running_machine *machine, int scanline)
282{
283   mc1000_state *state = machine->driver_data;
284
285   UINT16 addr = 0;
286
287   if (BIT(state->mc6847_attr, 7))
288   {
289      switch ((state->mc6847_attr >> 2) & 0x07)
290      {
291      case 0:   case 1: addr = (scanline / 3) * 0x10; break;
292      case 2:         addr = (scanline / 3) * 0x20; break;
293      case 3:   case 5: addr = (scanline / 2) * 0x10; break;
294      case 4:         addr = (scanline / 2) * 0x20; break;
295      case 6:   case 7: addr = scanline * 0x20; break;
296      }
297   }
298   else
299   {
300      addr = (scanline / 12) * 0x20;
301   }
302
303   return state->mc6847_video_ram + addr;
304}
305
306static VIDEO_START( mc1000 )
307{
308   m6847_config cfg;
309
310   memset(&cfg, 0, sizeof(cfg));
311
312   cfg.type = M6847_VERSION_ORIGINAL_NTSC;
313   cfg.horizontal_sync_callback = mc1000_hsync;
314   cfg.field_sync_callback = mc1000_vsync;
315   cfg.get_attributes = mc1000_get_attributes;
316   cfg.get_video_ram = mc1000_get_video_ram;
317//   cfg.get_char_rom = mc1000_get_char_rom;
318
319   m6847_init(machine, &cfg);
320}
321
322274/* AY-3-8910 Interface */
323275
324276static WRITE8_DEVICE_HANDLER( keylatch_w )
r5922r5923
371323
372324   /* find devices */
373325   state->mc6845 = devtag_get_device(machine, MC6845_TAG);
326   state->mc6847 = devtag_get_device(machine, MC6847_TAG);
374327   state->centronics = devtag_get_device(machine, CENTRONICS_TAG);
375328   state->cassette = devtag_get_device(machine, CASSETTE_TAG);
376329
r5922r5923
406359   state_save_register_global(machine, state->keylatch);
407360   state_save_register_global(machine, state->hsync);
408361   state_save_register_global(machine, state->vsync);
409   state_save_register_global(machine, state->mc6847_attr);
410362}
411363
412364static MACHINE_RESET( mc1000 )
r5922r5923
443395   CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED
444396};
445397
398static const mc6847_interface mc1000_mc6847_intf =
399{
400   DEVCB_HANDLER(mc1000_mc6847_videoram_r),
401   DEVCB_NULL,
402   DEVCB_NULL,
403   DEVCB_NULL,
404   DEVCB_NULL,
405   DEVCB_NULL,
406   DEVCB_NULL,
407   DEVCB_NULL,
408   DEVCB_NULL,
409   DEVCB_LINE(mc1000_mc6847_fs_w),
410   DEVCB_LINE(mc1000_mc6847_hs_w),
411   DEVCB_NULL
412};
413
446414static MACHINE_DRIVER_START( mc1000 )
447415   MDRV_DRIVER_DATA(mc1000_state)
448416
r5922r5923
465433   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
466434    MDRV_PALETTE_LENGTH(16)
467435
468    MDRV_VIDEO_START(mc1000)
469    MDRV_VIDEO_UPDATE(m6847)
436    MDRV_VIDEO_UPDATE(mc1000)
470437
438    MDRV_MC6847_ADD(MC6847_TAG, mc1000_mc6847_intf)
439    MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC)
440
471441   /* sound hardware */
472442   MDRV_SPEAKER_STANDARD_MONO("mono")
473443   MDRV_SOUND_ADD(AY8910_TAG, AY8910, 3579545/2)
src/mess/drivers/coco.c
r5922r5923
541541   PORT_CONFSETTING(    0x00, "Disto" )
542542   PORT_CONFSETTING(    0x01, "Cloud-9" )
543543
544   /* Port Condition is used because you can plug Hi-Res joystick,
544   /* Port Condition is used because you can plug Hi-Res joystick,
545545   Rat Mouse and Lightgun in either ports, but not both */
546546   /* Fix me: should Rat Mouse and Diecom Light Gun be available also for coco & coco2? */
547547   PORT_START("ctrl_sel")  /* Select Controller Type */
r5922r5923
660660   PORT_CONFSETTING(    0x00, "Disto" )
661661   PORT_CONFSETTING(    0x01, "Cloud-9" )
662662
663   /* Port Condition is used because you can plug Hi-Res joystick,
663   /* Port Condition is used because you can plug Hi-Res joystick,
664664   Rat Mouse and Lightgun in either ports, but not both */
665665   /* Fix me: should Rat Mouse and Diecom Light Gun be available also for coco & coco2? */
666666   PORT_START("ctrl_sel")  /* Select Controller Type */
r5922r5923
771771   DO_NOT_KEEP_GEOMETRY
772772};
773773
774static const mc6847_interface coco_mc6847_intf =
775{
776   DEVCB_HANDLER(coco_mc6847_videoram_r),
777   DEVCB_NULL,
778   DEVCB_NULL,
779   DEVCB_NULL,
780   DEVCB_NULL,
781   DEVCB_NULL,
782   DEVCB_NULL,
783   DEVCB_NULL,
784   DEVCB_NULL,
785   DEVCB_DEVICE_HANDLER("pia_0", pia6821_cb1_w),
786   DEVCB_DEVICE_HANDLER("pia_0", pia6821_ca1_w),
787   DEVCB_NULL
788};
789
790static const mc6847_interface coco3_mc6847_intf =
791{
792   DEVCB_HANDLER(coco3_mc6847_videoram_r),
793   DEVCB_NULL,
794   DEVCB_NULL,
795   DEVCB_NULL,
796   DEVCB_NULL,
797   DEVCB_NULL,
798   DEVCB_NULL,
799   DEVCB_NULL,
800   DEVCB_NULL,
801   DEVCB_LINE(coco3_fs_w),
802   DEVCB_LINE(coco3_hs_w),
803   DEVCB_NULL
804};
805
774806static MACHINE_DRIVER_START( dragon32 )
775807   /* basic machine hardware */
776808   MDRV_CPU_ADD("maincpu", M6809E, COCO_CPU_SPEED_HZ * 4)        /* 0,894886 MHz */
r5922r5923
782814   MDRV_DRIVER_DATA( coco_state )
783815
784816   /* video hardware */
785   MDRV_VIDEO_START(dragon)
786   MDRV_VIDEO_UPDATE(m6847)
787817   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
788818   MDRV_SCREEN_SIZE(320, 25+192+26)
789819   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
790820
821   MDRV_VIDEO_UPDATE(coco)
822
823   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
824   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
825
791826   /* sound hardware */
792827   MDRV_IMPORT_FROM( coco_sound )
793828
r5922r5923
798833   MDRV_SNAPSHOT_ADD("snapshot", coco_pak, "pak", 0)
799834
800835   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
801   
836
802837   MDRV_PIA6821_ADD( "pia_0", dragon32_pia_intf_0 )
803838   MDRV_PIA6821_ADD( "pia_1", dragon32_pia_intf_1 )
804839
805840   MDRV_SAM6883_ADD("sam", coco_sam_intf)
806   
841
807842   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
808843   MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w)
809844   MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
810845   MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
811   
846
812847   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
813848MACHINE_DRIVER_END
814849
r5922r5923
821856   MDRV_DRIVER_DATA( coco_state )
822857
823858   /* video hardware */
824   MDRV_VIDEO_START(dragon)
825   MDRV_VIDEO_UPDATE(m6847)
826859   MDRV_SCREEN_ADD("screen", RASTER)
827860   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
828861   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
829862   MDRV_SCREEN_SIZE(320, 25+192+26)
830863   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
831864
865   MDRV_VIDEO_UPDATE(coco)
866
867   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
868   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
869
832870   /* sound hardware */
833871   MDRV_IMPORT_FROM( coco_sound )
834872
r5922r5923
843881
844882   /* acia */
845883   MDRV_ACIA6551_ADD("acia")
846   
884
847885   MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf_0 )
848886   MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf_1 )
849887
850888   MDRV_SAM6883_ADD("sam", coco_sam_intf)
851   
889
852890   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
853891   MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w)
854892   MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
855893   MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
856   
894
857895   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
858896MACHINE_DRIVER_END
859897
r5922r5923
866904   MDRV_DRIVER_DATA( coco_state )
867905
868906   /* video hardware */
869   MDRV_VIDEO_START(dragon)
870   MDRV_VIDEO_UPDATE(m6847)
871907   MDRV_SCREEN_ADD("screen", RASTER)
872908   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
873909   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
874910   MDRV_SCREEN_SIZE(320, 25+192+26)
875911   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
876912
913   MDRV_VIDEO_UPDATE(coco)
914
915   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
916   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
917
877918   /* sound hardware */
878919   MDRV_IMPORT_FROM( coco_sound )
879920
r5922r5923
888929
889930   /* acia */
890931   MDRV_ACIA6551_ADD("acia")
891   
932
892933   MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf_0 )
893934   MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf_1 )
894935
895936   MDRV_SAM6883_ADD("sam", coco_sam_intf)
896   
937
897938   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
898939   MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w)
899940   MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
900941   MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
901   
942
902943   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
903944MACHINE_DRIVER_END
904945
r5922r5923
911952   MDRV_DRIVER_DATA( coco_state )
912953
913954   /* video hardware */
914   MDRV_VIDEO_START(dragon)
915   MDRV_VIDEO_UPDATE(m6847)
916955   MDRV_SCREEN_ADD("screen", RASTER)
917956   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
918957   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
919958   MDRV_SCREEN_SIZE(320, 25+192+26)
920959   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
921960
961   MDRV_VIDEO_UPDATE(coco)
962
963   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
964   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
965
922966   /* sound hardware */
923967   MDRV_IMPORT_FROM( coco_sound )
924968   MDRV_SOUND_ADD("ay8912", AY8912, 1000000)
r5922r5923
939983
940984   /* acia */
941985   MDRV_ACIA6551_ADD("acia")
942   
986
943987   MDRV_PIA6821_ADD( "pia_0", dgnalpha_pia_intf_0 )
944988   MDRV_PIA6821_ADD( "pia_1", dgnalpha_pia_intf_1 )
945989   MDRV_PIA6821_ADD( "pia_2", dgnalpha_pia_intf_2 )
946990
947991   MDRV_SAM6883_ADD("sam", coco_sam_intf)
948   
992
949993   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
950994   MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w)
951995   MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
952996   MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
953   
997
954998   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
955999MACHINE_DRIVER_END
9561000
r5922r5923
9631007   MDRV_DRIVER_DATA( coco_state )
9641008
9651009   /* video hardware */
966   MDRV_VIDEO_START(dragon)
967   MDRV_VIDEO_UPDATE(m6847)
9681010   MDRV_SCREEN_ADD("screen", RASTER)
9691011   MDRV_SCREEN_REFRESH_RATE(COCO_FRAMES_PER_SECOND)         /* Tano Dragon 64 is NTSC */
9701012   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
9711013   MDRV_SCREEN_SIZE(320, 25+192+26)
9721014   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
9731015
1016   MDRV_VIDEO_UPDATE(coco)
1017
1018   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1019   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
1020
9741021   /* sound hardware */
9751022   MDRV_IMPORT_FROM( coco_sound )
9761023
r5922r5923
9851032
9861033   /* acia */
9871034   MDRV_ACIA6551_ADD("acia")
988   
1035
9891036   MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf_0 )
9901037   MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf_1 )
9911038
9921039   MDRV_SAM6883_ADD("sam", coco_sam_intf)
993   
1040
9941041   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
9951042   MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w)
9961043   MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
9971044   MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
998   
1045
9991046   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
10001047MACHINE_DRIVER_END
10011048
r5922r5923
10101057   /* video hardware */
10111058   MDRV_SCREEN_ADD("screen", RASTER)
10121059   MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND)
1013   MDRV_VIDEO_START(coco)
1014   MDRV_VIDEO_UPDATE(m6847)
10151060   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
10161061   MDRV_SCREEN_SIZE(320, 25+192+26)
10171062   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
10181063
1064   MDRV_VIDEO_UPDATE(coco)
1065
1066   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1067   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC)
1068   MDRV_MC6847_TIMING_FACTOR(4)
1069
10191070   /* sound hardware */
10201071   MDRV_IMPORT_FROM( coco_sound )
10211072
r5922r5923
10281079
10291080   /* cassette */
10301081   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
1031   
1082
10321083   MDRV_PIA6821_ADD( "pia_0", coco_pia_intf_0 )
10331084   MDRV_PIA6821_ADD( "pia_1", coco_pia_intf_1 )
10341085
10351086   MDRV_SAM6883_ADD("sam", coco_sam_intf)
1036   
1087
10371088   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
10381089   MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco_cart_w)
10391090   MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
10401091   MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
1041   
1092
10421093   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
10431094MACHINE_DRIVER_END
10441095
r5922r5923
10561107   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
10571108   MDRV_SCREEN_SIZE(320, 25+192+26)
10581109   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
1059   MDRV_VIDEO_START(coco)
1060   MDRV_VIDEO_UPDATE(m6847)
10611110
1111   MDRV_VIDEO_UPDATE(coco)
1112
1113   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1114   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC)
1115   MDRV_MC6847_TIMING_FACTOR(4)
1116
10621117   /* sound hardware */
10631118   MDRV_IMPORT_FROM( coco_sound )
10641119
r5922r5923
10711126
10721127   /* cassette */
10731128   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
1074   
1129
10751130   MDRV_PIA6821_ADD( "pia_0", coco2_pia_intf_0 )
10761131   MDRV_PIA6821_ADD( "pia_1", coco2_pia_intf_1 )
10771132
10781133   MDRV_SAM6883_ADD("sam", coco_sam_intf)
1079   
1134
10801135   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
10811136   MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco_cart_w)
10821137   MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
10831138   MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
1084   
1139
10851140   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
10861141MACHINE_DRIVER_END
10871142
r5922r5923
10991154   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
11001155   MDRV_SCREEN_SIZE(320, 25+192+26)
11011156   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
1102   MDRV_VIDEO_START(coco2b)
1103   MDRV_VIDEO_UPDATE(m6847)
11041157
1158   MDRV_VIDEO_UPDATE(coco)
1159
1160   MDRV_MC6847_ADD("mc6847", coco_mc6847_intf)
1161   MDRV_MC6847_TYPE(M6847_VERSION_M6847T1_NTSC)
1162   MDRV_MC6847_TIMING_FACTOR(4)
1163
11051164   /* sound hardware */
11061165   MDRV_IMPORT_FROM( coco_sound )
11071166
r5922r5923
11141173
11151174   /* cassette */
11161175   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
1117   
1176
11181177   MDRV_PIA6821_ADD( "pia_0", coco2_pia_intf_0 )
11191178   MDRV_PIA6821_ADD( "pia_1", coco2_pia_intf_1 )
11201179
11211180   MDRV_SAM6883_ADD("sam", coco_sam_intf)
1122   
1181
11231182   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
11241183   MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco_cart_w)
11251184   MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
11261185   MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
1127   
1186
11281187   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
11291188MACHINE_DRIVER_END
11301189
r5922r5923
11541213   MDRV_SCREEN_SIZE(640, 25+192+26)
11551214   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 239)
11561215
1216   MDRV_MC6847_ADD("mc6847", coco3_mc6847_intf)
1217   MDRV_MC6847_TYPE(M6847_VERSION_GIME_NTSC)
1218   MDRV_MC6847_TIMING_FACTOR(4)
1219   MDRV_MC6847_FRAME_CALLBACK(coco3_new_frame)
1220   MDRV_MC6847_PREPARE_SCANLINE(coco3_prepare_scanline)
1221
11571222   MDRV_PIA6821_ADD( "pia_0", coco3_pia_intf_0 )
11581223   MDRV_PIA6821_ADD( "pia_1", coco3_pia_intf_1 )
11591224
r5922r5923
11721237
11731238   /* cassette */
11741239   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
1175   
1240
11761241   MDRV_SAM6883_GIME_ADD("sam", coco3_sam_intf)
1177   
1242
11781243   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
11791244   MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco3_cart_w)
11801245   MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w)
11811246   MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w)
1182   
1247
11831248   MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config)
11841249MACHINE_DRIVER_END
11851250
r5922r5923
11871252   MDRV_IMPORT_FROM( coco3 )
11881253
11891254   /* video hardware */
1190   MDRV_VIDEO_START(coco3p)
1191   MDRV_VIDEO_UPDATE(coco3)
11921255   MDRV_SCREEN_MODIFY("composite")
11931256   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
11941257   MDRV_SCREEN_MODIFY("rgb")
11951258   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
1259
1260   MDRV_DEVICE_MODIFY("mc6847")
1261   MDRV_MC6847_TYPE(M6847_VERSION_GIME_PAL)
11961262MACHINE_DRIVER_END
11971263
11981264static MACHINE_DRIVER_START( coco3h )
r5922r5923
13841450   CONFIG_RAM_DEFAULT   (64 * 1024)
13851451SYSTEM_CONFIG_END
13861452
1387static SYSTEM_CONFIG_START(dgnalpha)   
1453static SYSTEM_CONFIG_START(dgnalpha)
13881454   CONFIG_RAM_DEFAULT   (64 * 1024)
13891455SYSTEM_CONFIG_END
13901456
src/mess/drivers/spc1000.c
r5922r5923
6868   return input_port_read(space->machine, keynames[offset]);
6969}
7070
71static WRITE8_HANDLER(spc1000_gmode_w)
71static WRITE8_DEVICE_HANDLER(spc1000_gmode_w)
7272{
7373   GMODE = data;
74
75   mc6847_gm1_w(device, BIT(data, 1));
76   mc6847_gm2_w(device, BIT(data, 2));
77   mc6847_ag_w(device, BIT(data, 3));
78   mc6847_gm0_w(device, BIT(data, 7));
7479}
7580
76static READ8_HANDLER(spc1000_gmode_r)
81static READ8_DEVICE_HANDLER(spc1000_gmode_r)
7782{
7883   return GMODE;
7984}
r5922r5923
8186static ADDRESS_MAP_START( spc1000_io , ADDRESS_SPACE_IO, 8)
8287   ADDRESS_MAP_UNMAP_HIGH
8388   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(spc1000_video_ram_r, spc1000_video_ram_w)
84   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(spc1000_gmode_r, spc1000_gmode_w)
89   AM_RANGE(0x2000, 0x3fff) AM_DEVREADWRITE("mc6847", spc1000_gmode_r, spc1000_gmode_w)
8590   AM_RANGE(0x8000, 0x8009) AM_READ(spc1000_keyboard_r)
8691   AM_RANGE(0xA000, 0xA000) AM_READWRITE(spc1000_iplk_r, spc1000_iplk_w)
8792   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("ay8910", ay8910_address_w)
r5922r5923
201206   IPLK = 1;
202207}
203208
204
205static ATTR_CONST UINT8 spc1000_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
209static READ8_DEVICE_HANDLER( spc1000_mc6847_videoram_r )
206210{
207   UINT8 result = 0x00;
208   UINT8 attr = spc1000_video_ram [(scanline / 12) * 0x20 + pos + 0x0800];
211   mc6847_inv_w(device, BIT(spc1000_video_ram[offset], 7));
209212
210   //if (c & 0x40)             result |= M6847_INTEXT;
211   if (attr & 0x01)            result |= M6847_INV;
212   if (attr & 0x02)            result |= M6847_CSS;
213   if (attr & 0x04)            result |= M6847_AS;
214   if (attr & 0x08)            result |= M6847_GM0;
215
216   if (GMODE & 0x08)   result |= M6847_AG;
217   if (GMODE & 0x04)   result |= M6847_GM2;
218   if (GMODE & 0x02)   result |= M6847_GM1;
219   if (GMODE & 0x80)   result |= M6847_GM0;
220
221   return result;
213   return spc1000_video_ram[offset];
222214}
223215
224static const UINT8 *spc1000_get_video_ram(running_machine *machine, int scanline)
216static VIDEO_START( spc1000 )
225217{
226   return spc1000_video_ram + (scanline / 12) * 0x20;
218   spc1000_video_ram = auto_alloc_array(machine, UINT8, 0x2000);
227219}
228220
229static VIDEO_START( spc1000 )
221static VIDEO_UPDATE( spc1000 )
230222{
231   m6847_config cfg;
232
233   spc1000_video_ram = auto_alloc_array (machine, UINT8, 0x2000);
234
235   memset(&cfg, 0, sizeof(cfg));
236   cfg.type = M6847_VERSION_M6847T1_NTSC;
237   cfg.get_attributes = spc1000_get_attributes;
238   cfg.get_video_ram = spc1000_get_video_ram;
239   m6847_init(machine, &cfg);
223   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
224   return mc6847_update(mc6847, bitmap, cliprect);
240225}
241226
242227static const ay8910_interface spc1000_ay_interface =
r5922r5923
253238   CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED | CASSETTE_MOTOR_ENABLED
254239};
255240
241static const mc6847_interface spc1000_mc6847_intf =
242{
243   DEVCB_HANDLER(spc1000_mc6847_videoram_r),
244   DEVCB_NULL,
245   DEVCB_NULL,
246   DEVCB_NULL,
247   DEVCB_NULL,
248   DEVCB_NULL,
249   DEVCB_NULL,
250   DEVCB_NULL,
251   DEVCB_NULL,
252   DEVCB_NULL,
253   DEVCB_NULL,
254   DEVCB_NULL
255};
256256
257257static MACHINE_DRIVER_START( spc1000 )
258258   /* basic machine hardware */
r5922r5923
265265    /* video hardware */
266266   MDRV_SCREEN_ADD("screen", RASTER)
267267   MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND)
268   MDRV_VIDEO_START(spc1000)
269   MDRV_VIDEO_UPDATE(m6847)
270268   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
271269   MDRV_SCREEN_SIZE(320, 25+192+26)
272270   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
273271
272   MDRV_VIDEO_START(spc1000)
273   MDRV_VIDEO_UPDATE(spc1000)
274
275   MDRV_MC6847_ADD("mc6847", spc1000_mc6847_intf)
276   MDRV_MC6847_TYPE(M6847_VERSION_M6847T1_NTSC)
277
274278   /* sound hardware */
275279   MDRV_SPEAKER_STANDARD_MONO("mono")
276280   MDRV_SOUND_ADD("ay8910", AY8910, XTAL_4MHz / 1)
src/mess/drivers/vtech1.c
r5922r5923
118118
119119static Z80BIN_EXECUTE(vtech1);
120120
121
121122/******************************************************************************
122123 Address Maps
123124******************************************************************************/
r5922r5923
311312   CASSETTE_PLAY
312313};
313314
315static const UINT32 vtech1_palette_mono[] =
316{
317   MAKE_RGB(131, 131, 131),
318   MAKE_RGB(211, 211, 211),
319   MAKE_RGB(29, 29, 29),
320   MAKE_RGB(76, 76, 76),
321   MAKE_RGB(213, 213, 213),
322   MAKE_RGB(167, 167, 167),
323   MAKE_RGB(105, 105, 105),
324   MAKE_RGB(136, 136, 136),
325   MAKE_RGB(0, 0, 0),
326   MAKE_RGB(131, 131, 131),
327   MAKE_RGB(0, 0, 0),
328   MAKE_RGB(213, 213, 213),
329   MAKE_RGB(37, 37, 37),
330   MAKE_RGB(133, 133, 133),
331   MAKE_RGB(28, 28, 28),
332   MAKE_RGB(193, 193, 193)
333};
314334
335static const mc6847_interface vtech1_mc6847_intf =
336{
337   DEVCB_HANDLER(vtech1_mc6847_videoram_r),
338   DEVCB_LINE_GND,
339   DEVCB_LINE_VCC,
340   DEVCB_LINE_GND,
341   DEVCB_LINE_GND,
342   DEVCB_NULL,
343   DEVCB_NULL,
344   DEVCB_NULL,
345   DEVCB_NULL,
346   DEVCB_CPU_INPUT_LINE("maincpu", 0),
347   DEVCB_NULL,
348   DEVCB_NULL,
349};
350
315351static MACHINE_DRIVER_START(laser110)
316352    /* basic machine hardware */
317353    MDRV_CPU_ADD("maincpu", Z80, VTECH1_CLK)  /* 3.57950 MHz */
318354    MDRV_CPU_PROGRAM_MAP(laser110_mem)
319355    MDRV_CPU_IO_MAP(vtech1_io)
320   MDRV_SCREEN_ADD("screen", RASTER)
321   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
322    MDRV_QUANTUM_TIME(HZ(60))
323356
324357   MDRV_MACHINE_START(laser110)
325358
326359    /* video hardware */
327   MDRV_VIDEO_START(vtech1_monochrome)
328   MDRV_VIDEO_UPDATE(m6847)
360   MDRV_SCREEN_ADD("screen", RASTER)
361   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
329362   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
330363   MDRV_SCREEN_SIZE(320, 25+192+26)
331364   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
332365
366   MDRV_VIDEO_UPDATE(vtech1)
367
368   MDRV_MC6847_ADD("mc6847", vtech1_mc6847_intf)
369   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
370   MDRV_MC6847_PALETTE(vtech1_palette_mono)
371
333372    /* sound hardware */
334373   MDRV_SPEAKER_STANDARD_MONO("mono")
335374   MDRV_SOUND_WAVE_ADD("wave", "cassette")
r5922r5923
355394static MACHINE_DRIVER_START(laser200)
356395    MDRV_IMPORT_FROM(laser110)
357396
358   MDRV_VIDEO_START(vtech1)
397    MDRV_DEVICE_MODIFY("mc6847")
398    MDRV_MC6847_PALETTE(NULL)
359399MACHINE_DRIVER_END
360400
361401static MACHINE_DRIVER_START(laser210)
src/mess/drivers/z80ne.c
r5922r5923
381381 Machine Drivers
382382******************************************************************************/
383383
384static const UINT32 lx388palette[] =
385{
386   MAKE_RGB(0x00, 0xff, 0x00),   /* GREEN */
387   MAKE_RGB(0x00, 0xff, 0x00),   /* YELLOW in original, here GREEN */
388   MAKE_RGB(0x00, 0x00, 0xff),   /* BLUE */
389   MAKE_RGB(0xff, 0x00, 0x00),   /* RED */
390   MAKE_RGB(0xff, 0xff, 0xff),   /* BUFF */
391   MAKE_RGB(0x00, 0xff, 0xff),   /* CYAN */
392   MAKE_RGB(0xff, 0x00, 0xff),   /* MAGENTA */
393   MAKE_RGB(0xff, 0x80, 0x00),   /* ORANGE */
384394
395   MAKE_RGB(0x00, 0x20, 0x00),   /* BLACK in original, here DARK green */
396   MAKE_RGB(0x00, 0xff, 0x00),   /* GREEN */
397   MAKE_RGB(0x00, 0x00, 0x00),   /* BLACK */
398   MAKE_RGB(0xff, 0xff, 0xff),   /* BUFF */
399
400   MAKE_RGB(0x00, 0x20, 0x00),   /* ALPHANUMERIC DARK GREEN */
401   MAKE_RGB(0x00, 0xff, 0x00),   /* ALPHANUMERIC BRIGHT GREEN */
402   MAKE_RGB(0x40, 0x10, 0x00),   /* ALPHANUMERIC DARK ORANGE */
403   MAKE_RGB(0xff, 0xc4, 0x18)      /* ALPHANUMERIC BRIGHT ORANGE */
404};
405
385406static const ay31015_config z80ne_ay31015_config =
386407{
387408   AY_3_1015,
r5922r5923
419440   DO_NOT_KEEP_GEOMETRY
420441};
421442
443static const mc6847_interface z80net_mc6847_intf =
444{
445   DEVCB_HANDLER(lx388_mc6847_videoram_r),
446   DEVCB_LINE_GND,
447   DEVCB_LINE_GND,
448   DEVCB_LINE_GND,
449   DEVCB_NULL,
450   DEVCB_NULL,
451   DEVCB_NULL,
452   DEVCB_LINE_GND,
453   DEVCB_LINE_GND,
454   DEVCB_NULL,
455   DEVCB_NULL,
456   DEVCB_NULL
457};
458
422459static MACHINE_DRIVER_START( z80ne )
423460   /* basic machine hardware */
424461   MDRV_CPU_ADD("z80ne", Z80, Z80NE_CPU_SPEED_HZ)
r5922r5923
451488   /* video hardware */
452489   MDRV_SCREEN_ADD("lx388", RASTER)
453490   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
454
455   MDRV_VIDEO_START(lx388)
456   MDRV_VIDEO_UPDATE(m6847)
457491   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
458492   MDRV_SCREEN_SIZE(320, 25+192+26)
459493   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
460494
495   MDRV_VIDEO_UPDATE(lx388)
496
497   MDRV_MC6847_ADD("mc6847", z80net_mc6847_intf)
498   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
499   MDRV_MC6847_PALETTE(lx388palette)
500
461501   MDRV_DEFAULT_LAYOUT(layout_z80net)
462
463502MACHINE_DRIVER_END
464503
465504static MACHINE_DRIVER_START( z80netb )
r5922r5923
481520   /* video hardware */
482521   MDRV_SCREEN_ADD("lx388", RASTER)
483522   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
484
485   MDRV_VIDEO_START(lx388)
486   MDRV_VIDEO_UPDATE(m6847)
487523   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
488524   MDRV_SCREEN_SIZE(320, 25+192+26)
489525   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
490526   MDRV_DEFAULT_LAYOUT(layout_z80netb)
527
528   MDRV_VIDEO_UPDATE(lx388)
529
530   MDRV_MC6847_ADD("mc6847", z80net_mc6847_intf)
531   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
532   MDRV_MC6847_PALETTE(lx388palette)
491533MACHINE_DRIVER_END
492534
493535static MACHINE_DRIVER_START( z80netf )
r5922r5923
509551   /* video hardware */
510552   MDRV_SCREEN_ADD("lx388", RASTER)
511553   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
512
513   MDRV_VIDEO_START(lx388)
514   MDRV_VIDEO_UPDATE(m6847)
515554   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
516555   MDRV_SCREEN_SIZE(320, 25+192+26)
517556   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
518557
558   MDRV_VIDEO_UPDATE(lx388)
559
560   MDRV_MC6847_ADD("mc6847", z80net_mc6847_intf)
561   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
562   MDRV_MC6847_PALETTE(lx388palette)
563
519564   MDRV_WD1771_ADD("wd1771", default_wd17xx_interface)
520   MDRV_FLOPPY_4_DRIVES_ADD(z80netf_floppy_config)   
565   MDRV_FLOPPY_4_DRIVES_ADD(z80netf_floppy_config)
521566
522567   MDRV_DEFAULT_LAYOUT(layout_z80netf)
523568MACHINE_DRIVER_END
src/mess/drivers/atom.c
r5922r5923
272272   DO_NOT_KEEP_GEOMETRY
273273};
274274
275static const mc6847_interface atom_mc6847_intf =
276{
277   DEVCB_HANDLER(atom_mc6847_videoram_r),
278   DEVCB_NULL,
279   DEVCB_NULL,
280   DEVCB_NULL,
281   DEVCB_NULL,
282   DEVCB_NULL,
283   DEVCB_NULL,
284   DEVCB_NULL,
285   DEVCB_NULL,
286   DEVCB_NULL,
287   DEVCB_NULL,
288   DEVCB_NULL
289};
290
275291/* machine definition */
276292static MACHINE_DRIVER_START( atom )
277293   /* basic machine hardware */
r5922r5923
286302   MDRV_SCREEN_ADD("screen", RASTER)
287303   MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
288304
289   MDRV_VIDEO_START(atom)
290   MDRV_VIDEO_UPDATE(m6847)
305   MDRV_VIDEO_UPDATE(atom)
291306   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
292307   MDRV_SCREEN_SIZE(320, 25+192+26)
293308   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
294309
310   MDRV_MC6847_ADD("mc6847", atom_mc6847_intf)
311   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
312
295313   /* sound hardware */
296314   MDRV_SPEAKER_STANDARD_MONO("mono")
297315   MDRV_SOUND_ADD("speaker", SPEAKER, 0)
r5922r5923
311329
312330   /* i8271 */
313331   MDRV_I8271_ADD("i8271", atom_8271_interface)
314   
332
315333   MDRV_FLOPPY_2_DRIVES_ADD(atom_floppy_config)
316334MACHINE_DRIVER_END
317335
src/mess/drivers/mc10.c
r5922r5923
212212   CASSETTE_PLAY
213213};
214214
215static const mc6847_interface mc10_mc6847_intf =
216{
217   DEVCB_HANDLER(mc10_mc6847_videoram_r),
218   DEVCB_NULL,
219   DEVCB_NULL,
220   DEVCB_NULL,
221   DEVCB_NULL,
222   DEVCB_NULL,
223   DEVCB_NULL,
224   DEVCB_NULL,
225   DEVCB_NULL,
226   DEVCB_NULL,
227   DEVCB_NULL,
228   DEVCB_NULL
229};
215230
216231static MACHINE_DRIVER_START( mc10 )
217232   /* basic machine hardware */
r5922r5923
224239   MDRV_MACHINE_START(mc10)
225240
226241   /* video hardware */
227   MDRV_VIDEO_START(mc10)
228   MDRV_VIDEO_UPDATE(m6847)
242   MDRV_VIDEO_UPDATE(mc10)
229243   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
230244   MDRV_SCREEN_SIZE(320, 25+192+26)
231245   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
232246
247   MDRV_MC6847_ADD("mc6847", mc10_mc6847_intf)
248   MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC)
249
233250   /* sound hardware */
234251   MDRV_SPEAKER_STANDARD_MONO("mono")
235252   MDRV_SOUND_ADD("dac", DAC, 0)
src/mess/drivers/apf.c
r5922r5923
4949/* 6600, 6500-6503 wd179x disc controller? 6400, 6401 */
5050static unsigned char keyboard_data;
5151static unsigned char pad_data;
52static UINT8 mc6847_css = 0;
53static UINT8 *apf_video_ram;
5254
55static READ8_DEVICE_HANDLER( apf_mc6847_videoram_r )
56{
57   mc6847_css_w(device, mc6847_css && BIT(apf_video_ram[offset + 0x200], 6));
58   mc6847_inv_w(device, BIT(apf_video_ram[offset + 0x200], 6));
59   mc6847_as_w(device, BIT(apf_video_ram[offset + 0x200], 7));
60
61   return apf_video_ram[offset + 0x200];
62}
63
64static WRITE_LINE_DEVICE_HANDLER( apf_mc6847_fs_w )
65{
66   if (state)
67        apf_ints |= 0x10;
68   else
69      apf_ints &= ~0x10;
70
71   apf_update_ints(device->machine);
72}
73
74static VIDEO_UPDATE( apf )
75{
76   const device_config *mc6847 = devtag_get_device(screen->machine, "mc6847");
77   return mc6847_update(mc6847, bitmap, cliprect);
78}
79
5380static  READ8_DEVICE_HANDLER(apf_m1000_pia_in_a_func)
5481{
5582
r5922r5923
96123{
97124}
98125
99static unsigned char previous_mode;
126//static unsigned char previous_mode;
100127
101static WRITE8_DEVICE_HANDLER(apf_m1000_pia_out_b_func)
128static WRITE8_DEVICE_HANDLER( apf_m1000_pia_out_b_func )
102129{
103   pad_data = data;
130   const device_config *mc6847 = devtag_get_device(device->machine, "mc6847");
104131
105   /* bit 7..4 video control */
132   /* bit 7..4 video control -- TODO: bit 5 and 4? */
133   mc6847_ag_w(mc6847, BIT(data, 7));
134   mc6847_gm0_w(mc6847, BIT(data, 6));
135
106136   /* bit 3..0 keypad line select */
107
108   /* 1b standard, 5b, db */
109   /* 0001 */
110   /* 0101 */
111   /* 1101 */
112
113   /* multi colour graphics mode */
114   /* 158 = 1001 multi-colour graphics */
115   /* 222 = 1101 mono graphics */
116   if (((previous_mode^data) & 0x0f0)!=0)
117   {
118     //     logerror("apf vidmode %02x\n", data);
119
120      /* not sure if this is correct - need to check */
121      apf_m6847_attr = 0x00;
122             if (data & 0x80)   apf_m6847_attr |= M6847_AG;
123      if (data & 0x40)   apf_m6847_attr |= M6847_GM0;
124      //      if (data & 0x20)   apf_m6847_attr |= M6847_GM1; //?
125      //      if (data & 0x10)   apf_m6847_attr |= M6847_GM2; //M6847_GM0; //?
126      previous_mode = data;
127   }
137   pad_data = data;
128138}
129139
130static WRITE8_DEVICE_HANDLER(apf_m1000_pia_out_ca2_func)
140static WRITE_LINE_DEVICE_HANDLER(apf_m1000_pia_out_ca2_func)
131141{
142   mc6847_css = state;
132143}
133144
134145static WRITE8_DEVICE_HANDLER(apf_m1000_pia_out_cb2_func)
r5922r5923
192203   DEVCB_HANDLER(apf_m1000_pia_in_cb2_func),
193204   DEVCB_HANDLER(apf_m1000_pia_out_a_func),
194205   DEVCB_HANDLER(apf_m1000_pia_out_b_func),
195   DEVCB_HANDLER(apf_m1000_pia_out_ca2_func),
206   DEVCB_LINE(apf_m1000_pia_out_ca2_func),
196207   DEVCB_HANDLER(apf_m1000_pia_out_cb2_func),
197208   DEVCB_LINE(apf_m1000_irq_a_func),
198209   DEVCB_LINE(apf_m1000_irq_b_func)
r5922r5923
351362}
352363
353364static WRITE8_HANDLER(apf_wd179x_command_w)
354{   
365{
355366   wd17xx_command_w(devtag_get_device(space->machine, "wd179x"), offset,~data);
356367}
357368
r5922r5923
638649   DO_NOT_KEEP_GEOMETRY
639650};
640651
652static const mc6847_interface apf_mc6847_intf =
653{
654   DEVCB_HANDLER(apf_mc6847_videoram_r),
655   DEVCB_LINE_VCC,
656   DEVCB_LINE_VCC,
657   DEVCB_NULL,
658   DEVCB_NULL,
659   DEVCB_NULL,
660   DEVCB_NULL,
661   DEVCB_NULL,
662   DEVCB_NULL,
663   DEVCB_LINE(apf_mc6847_fs_w),
664   DEVCB_NULL,
665   DEVCB_NULL
666};
667
641668static MACHINE_DRIVER_START( apf_imagination )
642669   /* basic machine hardware */
643670   //   MDRV_CPU_ADD("maincpu", M6800, 3750000)        /* 7.8336 MHz, only 6800p type used 1 MHz max*/
r5922r5923
649676   MDRV_MACHINE_START( apf_imagination )
650677
651678   /* video hardware */
652   MDRV_VIDEO_START(apf)
653   MDRV_VIDEO_UPDATE(m6847)
679   MDRV_VIDEO_UPDATE(apf)
654680   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
655681   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
656682   MDRV_SCREEN_SIZE(320, 25+192+26)
657683   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
658684
685   MDRV_MC6847_ADD("mc6847", apf_mc6847_intf)
686
659687   MDRV_PIA6821_ADD( "pia_0", apf_m1000_pia_interface )
660688   MDRV_PIA6821_ADD( "pia_1", apf_imagination_pia_interface )
661689
r5922r5923
665693   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
666694
667695   MDRV_CASSETTE_ADD( "cassette", apf_cassette_config )
668   
669   MDRV_WD179X_ADD("wd179x", default_wd17xx_interface )   
670   
696
697   MDRV_WD179X_ADD("wd179x", default_wd17xx_interface )
698
671699   MDRV_FLOPPY_2_DRIVES_ADD(apfimag_floppy_config)
672700MACHINE_DRIVER_END
673701

Previous 15994 Revisions Next


© 1998-2018 The MESS Team