Previous 15994 Revisions Next

r9514 Wednesday 3rd November, 2010 at 21:31:42 UTC by Curt Coder
[ABC800] Cleaned up video code with some C++ magic.
[src/mess/drivers]abc80x.c
[src/mess/includes]abc80x.h
[src/mess/video]abc800.c

src/mess/video/abc800.c
r9513r9514
88
99    TODO:
1010
11   - type in SAA5052 Swedish characters
12   - convert SAA5050 to C++ device and fix its memory interface
1113   - check compatibility with new MC6845
1214   - ABC800C video: http://www.qsl.net/zl1vfo/teletext.htm
1315
r9513r9514
5860//**************************************************************************
5961
6062//-------------------------------------------------
61//  PALETTE_INIT( abc800c )
62//-------------------------------------------------
63
64static PALETTE_INIT( abc800c )
65{
66   palette_set_color_rgb(machine, 0, 0x00, 0x00, 0x00); // black
67   palette_set_color_rgb(machine, 1, 0x00, 0x00, 0xff); // blue
68   palette_set_color_rgb(machine, 2, 0xff, 0x00, 0x00); // red
69   palette_set_color_rgb(machine, 3, 0xff, 0x00, 0xff); // magenta
70   palette_set_color_rgb(machine, 4, 0x00, 0xff, 0x00); // green
71   palette_set_color_rgb(machine, 5, 0x00, 0xff, 0xff); // cyan
72   palette_set_color_rgb(machine, 6, 0xff, 0xff, 0x00); // yellow
73   palette_set_color_rgb(machine, 7, 0xff, 0xff, 0xff); // white
74}
75
76
77//-------------------------------------------------
7863//  abc800m_hr_update - color high resolution
7964//   screen update
8065//-------------------------------------------------
8166
82static void abc800c_hr_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
67void abc800c_state::hr_update(bitmap_t *bitmap, const rectangle *cliprect)
8368{
84   abc800_state *state = machine->driver_data<abc800_state>();
85
8669   UINT16 addr = 0;
8770   int sx, y, dot;
8871
89   for (y = state->m_hrs; y < MIN(cliprect->max_y + 1, state->m_hrs + 240); y++)
72   for (y = m_hrs; y < MIN(cliprect->max_y + 1, m_hrs + 240); y++)
9073   {
9174      int x = 0;
9275
9376      for (sx = 0; sx < 64; sx++)
9477      {
95         UINT8 data = state->m_video_ram[addr++];
78         UINT8 data = m_video_ram[addr++];
9679
9780         for (dot = 0; dot < 4; dot++)
9881         {
99            UINT16 fgctl_addr = ((state->m_fgctl & 0x7f) << 2) | ((data >> 6) & 0x03);
100            int color = state->fgctl_prom[fgctl_addr] & 0x07;
82            UINT16 fgctl_addr = ((m_fgctl & 0x7f) << 2) | ((data >> 6) & 0x03);
83            int color = fgctl_prom[fgctl_addr] & 0x07;
10184
10285            *BITMAP_ADDR16(bitmap, y, x++) = color;
10386
r9513r9514
11295//  VIDEO_START( abc800c )
11396//-------------------------------------------------
11497
115static VIDEO_START( abc800c )
98void abc800_state::video_start()
11699{
117   abc800_state *state = machine->driver_data<abc800_state>();
118
119100   // find memory regions
120   state->m_char_rom = memory_region(machine, MC6845_TAG);
121   state->fgctl_prom = memory_region(machine, "hru2");
101   m_char_rom = memory_region(machine, MC6845_TAG);
102   fgctl_prom = memory_region(machine, "hru2");
122103
123104   // register for state saving
124   state_save_register_global(machine, state->m_hrs);
125   state_save_register_global(machine, state->m_fgctl);
105   state_save_register_global(machine, m_hrs);
106   state_save_register_global(machine, m_fgctl);
126107}
127108
128109
r9513r9514
130111//  VIDEO_UPDATE( abc800c )
131112//-------------------------------------------------
132113
133static VIDEO_UPDATE( abc800c )
114bool abc800c_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
134115{
135   abc800_state *state = screen->machine->driver_data<abc800_state>();
136
137116   // clear screen
138   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
117   bitmap_fill(&bitmap, &cliprect, get_black_pen(machine));
139118
140119   // draw HR graphics
141   abc800c_hr_update(screen->machine, bitmap, cliprect);
120   hr_update(&bitmap, &cliprect);
142121
143   if (!BIT(state->m_fgctl, 7))
122   if (!BIT(m_fgctl, 7))
144123   {
145124      // draw text
146      saa5050_update(state->m_trom, bitmap, cliprect);
125      saa5050_update(m_trom, &bitmap, &cliprect);
147126   }
148127
149128   return 0;
r9513r9514
158137{
159138   SCREEN_TAG,
160139   0,   // starting gfxnum
161   40, 24 - 1, 40,  // x, y, size
140   40, 24 - 1, 0x80,  // x, y, size
162141   0    // rev y order
163142};
164143
r9513r9514
176155   MDRV_SCREEN_SIZE(640, 400)
177156   MDRV_SCREEN_VISIBLE_AREA(0,640-1, 0, 400-1)
178157
179   MDRV_PALETTE_LENGTH(8)
180   MDRV_PALETTE_INIT(abc800c)
158   MDRV_PALETTE_LENGTH(128)
159   MDRV_PALETTE_INIT(saa5050)
181160
182   MDRV_VIDEO_START(abc800c)
183   MDRV_VIDEO_UPDATE(abc800c)
184
185161   MDRV_GFXDECODE(saa5050)
186162
187163   MDRV_SAA5050_ADD(SAA5052_TAG, trom_intf)
r9513r9514
209185//   screen update
210186//-------------------------------------------------
211187
212static void abc800m_hr_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
188void abc800m_state::hr_update(bitmap_t *bitmap, const rectangle *cliprect)
213189{
214   abc800_state *state = machine->driver_data<abc800_state>();
215
216190   UINT16 addr = 0;
217191   int sx, y, dot;
218192
219   for (y = state->m_hrs + VERTICAL_PORCH_HACK; y < MIN(cliprect->max_y + 1, state->m_hrs + VERTICAL_PORCH_HACK + 240); y++)
193   for (y = m_hrs + VERTICAL_PORCH_HACK; y < MIN(cliprect->max_y + 1, m_hrs + VERTICAL_PORCH_HACK + 240); y++)
220194   {
221195      int x = HORIZONTAL_PORCH_HACK;
222196
223197      for (sx = 0; sx < 64; sx++)
224198      {
225         UINT8 data = state->m_video_ram[addr++];
199         UINT8 data = m_video_ram[addr++];
226200
227201         for (dot = 0; dot < 4; dot++)
228202         {
229            UINT16 fgctl_addr = ((state->m_fgctl & 0x7f) << 2) | ((data >> 6) & 0x03);
230            int color = (state->fgctl_prom[fgctl_addr] & 0x07) ? 1 : 0;
203            UINT16 fgctl_addr = ((m_fgctl & 0x7f) << 2) | ((data >> 6) & 0x03);
204            int color = (fgctl_prom[fgctl_addr] & 0x07) ? 1 : 0;
231205
232206            *BITMAP_ADDR16(bitmap, y, x++) = color;
233207            *BITMAP_ADDR16(bitmap, y, x++) = color;
r9513r9514
245219
246220static MC6845_UPDATE_ROW( abc800m_update_row )
247221{
248   abc800_state *state = device->machine->driver_data<abc800_state>();
222   abc800m_state *state = device->machine->driver_data<abc800m_state>();
249223
250224   int column;
251225
r9513r9514
306280//  VIDEO_UPDATE( abc800m )
307281//-------------------------------------------------
308282
309static VIDEO_UPDATE( abc800m )
283bool abc800m_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
310284{
311   abc800_state *state = screen->machine->driver_data<abc800_state>();
312
313285   // HACK expand visible area to workaround MC6845
314   screen->set_visible_area(0, 767, 0, 311);
286   screen.set_visible_area(0, 767, 0, 311);
315287
316288   // clear screen
317   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
289   bitmap_fill(&bitmap, &cliprect, get_black_pen(machine));
318290
319291   // draw HR graphics
320   abc800m_hr_update(screen->machine, bitmap, cliprect);
292   hr_update(&bitmap, &cliprect);
321293
322   if (!BIT(state->m_fgctl, 7))
294   if (!BIT(m_fgctl, 7))
323295   {
324296      // draw text
325      mc6845_update(state->m_crtc, bitmap, cliprect);
297      mc6845_update(m_crtc, &bitmap, &cliprect);
326298   }
327299
328300   return 0;
r9513r9514
346318
347319   MDRV_PALETTE_LENGTH(2)
348320   MDRV_PALETTE_INIT(abc800m)
349
350   MDRV_VIDEO_START(abc800c)
351   MDRV_VIDEO_UPDATE(abc800m)
352321MACHINE_CONFIG_END
src/mess/includes/abc80x.h
r9513r9514
6262        m_ctc(*this, Z80CTC_TAG),
6363        m_dart(*this, Z80DART_TAG),
6464        m_sio(*this, Z80SIO_TAG),
65        m_crtc(*this, MC6845_TAG),
66        m_trom(*this, SAA5052_TAG),
6765        m_discrete(*this, "discrete"),
6866        m_ram(*this, "messram")
6967   { }
r9513r9514
7270   required_device<running_device> m_ctc;
7371   required_device<running_device> m_dart;
7472   required_device<running_device> m_sio;
75   optional_device<running_device> m_crtc;
76   optional_device<running_device> m_trom;
7773   required_device<running_device> m_discrete;
7874   required_device<running_device> m_ram;
7975
8076   virtual void machine_start();
8177   virtual void machine_reset();
82   
78
79   virtual void video_start();
80
8381   void bankswitch();
8482
8583   DECLARE_READ8_MEMBER( pling_r );
r9513r9514
116114   int m_sio_txcb;
117115};
118116
117class abc800m_state : public abc800_state
118{
119public:
120   abc800m_state(running_machine &machine, const driver_device_config_base &config)
121      : abc800_state(machine, config),
122        m_crtc(*this, MC6845_TAG)
123   { }
119124
125   required_device<running_device> m_crtc;
126
127   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
128
129   void hr_update(bitmap_t *bitmap, const rectangle *cliprect);
130};
131
132class abc800c_state : public abc800_state
133{
134public:
135   abc800c_state(running_machine &machine, const driver_device_config_base &config)
136      : abc800_state(machine, config),
137        m_trom(*this, SAA5052_TAG)
138   { }
139
140   required_device<running_device> m_trom;
141
142   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
143
144   void hr_update(bitmap_t *bitmap, const rectangle *cliprect);
145};
146
120147// ======================> abc802_state
121148
122149class abc802_state : public driver_device
src/mess/drivers/abc80x.c
r9513r9514
16241624//**************************************************************************
16251625
16261626//-------------------------------------------------
1627//  MACHINE_CONFIG( abc800 )
1627//  MACHINE_CONFIG( abc800c )
16281628//-------------------------------------------------
16291629
1630static MACHINE_CONFIG_START( abc800, abc800_state )
1630static MACHINE_CONFIG_START( abc800c, abc800c_state )
16311631   // basic machine hardware
16321632   MDRV_CPU_ADD(Z80_TAG, Z80, ABC800_X01/2/2)
16331633   MDRV_CPU_CONFIG(abc800_daisy_chain)
1634   MDRV_CPU_PROGRAM_MAP(abc800m_mem)
1635   MDRV_CPU_IO_MAP(abc800m_io)
1634   MDRV_CPU_PROGRAM_MAP(abc800c_mem)
1635   MDRV_CPU_IO_MAP(abc800c_io)
16361636
16371637   MDRV_CPU_ADD(I8048_TAG, I8048, XTAL_5_9904MHz)
16381638   MDRV_CPU_IO_MAP(abc800_keyboard_io)
16391639
1640   // video hardware
1641   MDRV_FRAGMENT_ADD(abc800c_video)
1642
16401643   // sound hardware
16411644   MDRV_SPEAKER_STANDARD_MONO("mono")
16421645   MDRV_SOUND_ADD("discrete", DISCRETE, 0)
r9513r9514
16671670//  MACHINE_CONFIG( abc800m )
16681671//-------------------------------------------------
16691672
1670static MACHINE_CONFIG_DERIVED( abc800m, abc800 )
1673static MACHINE_CONFIG_START( abc800m, abc800m_state )
1674   // basic machine hardware
1675   MDRV_CPU_ADD(Z80_TAG, Z80, ABC800_X01/2/2)
1676   MDRV_CPU_CONFIG(abc800_daisy_chain)
1677   MDRV_CPU_PROGRAM_MAP(abc800m_mem)
1678   MDRV_CPU_IO_MAP(abc800m_io)
1679   
1680   MDRV_CPU_ADD(I8048_TAG, I8048, XTAL_5_9904MHz)
1681   MDRV_CPU_IO_MAP(abc800_keyboard_io)
1682
16711683   // video hardware
16721684   MDRV_FRAGMENT_ADD(abc800m_video)
1673MACHINE_CONFIG_END
16741685
1686   // sound hardware
1687   MDRV_SPEAKER_STANDARD_MONO("mono")
1688   MDRV_SOUND_ADD("discrete", DISCRETE, 0)
1689   MDRV_SOUND_CONFIG_DISCRETE(abc800)
1690   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
16751691
1676//-------------------------------------------------
1677//  MACHINE_CONFIG( abc800c )
1678//-------------------------------------------------
1692   // peripheral hardware
1693   MDRV_Z80CTC_ADD(Z80CTC_TAG, ABC800_X01/2/2, ctc_intf)
1694   MDRV_TIMER_ADD_PERIODIC("ctc", ctc_tick, HZ(ABC800_X01/2/2/2))
1695   MDRV_Z80SIO2_ADD(Z80SIO_TAG, ABC800_X01/2/2, sio_intf)
1696   MDRV_Z80DART_ADD(Z80DART_TAG, ABC800_X01/2/2, abc800_dart_intf)
1697   MDRV_PRINTER_ADD("printer")
1698   MDRV_CASSETTE_ADD(CASSETTE_TAG, abc800_cassette_config)
1699   MDRV_TIMER_ADD_PERIODIC("keyboard_t1", keyboard_t1_tick, HZ(XTAL_5_9904MHz/(3*5)/20)) // TODO correct frequency?
16791700
1680static MACHINE_CONFIG_DERIVED( abc800c, abc800 )
1681   // basic machine hardware
1682   MDRV_CPU_MODIFY(Z80_TAG)
1683   MDRV_CPU_PROGRAM_MAP(abc800c_mem)
1684   MDRV_CPU_IO_MAP(abc800c_io)
1701   // ABC bus
1702   MDRV_ABCBUS_ADD(ABCBUS_TAG, abcbus_daisy, Z80_TAG)
1703   MDRV_ABC830_ADD("luxor_55_21046", ABCBUS_TAG, DRIVE_BASF_6106_08)
16851704
1686   // video hardware
1687   MDRV_FRAGMENT_ADD(abc800c_video)
1705   // internal ram
1706   MDRV_RAM_ADD("messram")
1707   MDRV_RAM_DEFAULT_SIZE("16K")
1708   MDRV_RAM_EXTRA_OPTIONS("32K")
16881709MACHINE_CONFIG_END
16891710
16901711

Previous 15994 Revisions Next


© 1998-2018 The MESS Team