Previous 15994 Revisions Next

r11337 Tuesday 26th April, 2011 at 14:25:07 UTC by Curt Coder
[ATOM] Modernized driver. (nw)
[src/mess/drivers]atom.c
[src/mess/includes]atom.h

src/mess/includes/atom.h
r11336r11337
33#ifndef __ATOM__
44#define __ATOM__
55
6#define ADDRESS_MAP_MODERN
7
68#include "emu.h"
9#include "cpu/m6502/m6502.h"
10#include "imagedev/cartslot.h"
11#include "imagedev/cassette.h"
12#include "imagedev/flopdrv.h"
13#include "machine/ram.h"
14#include "imagedev/snapquik.h"
15#include "formats/atom_atm.h"
16#include "formats/atom_tap.h"
17#include "formats/basicdsk.h"
18#include "formats/uef_cas.h"
19#include "machine/ctronics.h"
20#include "machine/6522via.h"
21#include "machine/i8255.h"
22#include "machine/i8271.h"
23#include "sound/speaker.h"
24#include "video/m6847.h"
725
826#define SY6502_TAG      "ic22"
927#define INS8255_TAG      "ic25"
r11336r11337
2341{
2442public:
2543   atom_state(running_machine &machine, const driver_device_config_base &config)
26      : driver_device(machine, config) { }
44      : driver_device(machine, config),
45        m_maincpu(*this, SY6502_TAG),
46        m_vdg(*this, MC6847_TAG),
47        m_cassette(*this, CASSETTE_TAG),
48        m_centronics(*this, CENTRONICS_TAG),
49        m_speaker(*this, SPEAKER_TAG)
50   { }
2751
52   required_device<cpu_device> m_maincpu;
53   required_device<device_t> m_vdg;
54   required_device<device_t> m_cassette;
55   required_device<device_t> m_centronics;
56   required_device<device_t> m_speaker;
57
58   virtual void machine_start();
59   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
60
61   void bankswitch();
62   
63   READ8_MEMBER( eprom_r );
64   WRITE8_MEMBER( eprom_w );
65   WRITE8_MEMBER( ppi_pa_w );
66   READ8_MEMBER( ppi_pb_r );
67   READ8_MEMBER( ppi_pc_r );
68   WRITE8_MEMBER( ppi_pc_w );
69   READ8_MEMBER( printer_busy );
70   WRITE8_MEMBER( printer_data );
71   READ8_MEMBER( vdg_videoram_r );
72
2873   /* eprom state */
2974   int m_eprom;
3075
r11336r11337
4085   int m_pc1;
4186
4287   /* devices */
43   device_t *m_mc6847;
44   device_t *m_cassette;
4588   int m_previous_i8271_int_state;
4689};
4790
91class atomeb_state : public atom_state
92{
93public:
94   atomeb_state(running_machine &machine, const driver_device_config_base &config)
95      : atom_state(machine, config)
96   { }
97
98   virtual void machine_start();
99};
100
48101#endif
src/mess/drivers/atom.c
r11336r11337
107107
108108*/
109109
110#include "emu.h"
111110#include "includes/atom.h"
112#include "cpu/m6502/m6502.h"
113#include "imagedev/cartslot.h"
114#include "imagedev/cassette.h"
115#include "imagedev/flopdrv.h"
116#include "machine/ram.h"
117#include "imagedev/snapquik.h"
118#include "formats/atom_atm.h"
119#include "formats/atom_tap.h"
120#include "formats/basicdsk.h"
121#include "formats/uef_cas.h"
122#include "machine/ctronics.h"
123#include "machine/6522via.h"
124#include "machine/i8255.h"
125#include "machine/i8271.h"
126#include "sound/speaker.h"
127#include "video/m6847.h"
128111
129112/***************************************************************************
130113    READ/WRITE HANDLERS
r11336r11337
134117    bankswitch - EPROM bankswitch
135118-------------------------------------------------*/
136119
137static void bankswitch(running_machine &machine)
120void atom_state::bankswitch()
138121{
139   atom_state *state = machine.driver_data<atom_state>();
140   address_space *program = machine.device(SY6502_TAG)->memory().space(AS_PROGRAM);
122   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
141123
142   UINT8 *eprom = machine.region("a000")->base() + (state->m_eprom << 12);
124   UINT8 *eprom = machine().region("a000")->base() + (m_eprom << 12);
143125
144126   program->install_rom(0xa000, 0xafff, eprom);
145127}
r11336r11337
148130     eprom_r - EPROM slot select read
149131-------------------------------------------------*/
150132
151static READ8_HANDLER( eprom_r )
133READ8_MEMBER( atom_state::eprom_r )
152134{
153   atom_state *state = space->machine().driver_data<atom_state>();
154
155   return state->m_eprom;
135   return m_eprom;
156136}
157137
158138/*-------------------------------------------------
159139     eprom_w - EPROM slot select write
160140-------------------------------------------------*/
161141
162static WRITE8_HANDLER( eprom_w )
142WRITE8_MEMBER( atom_state::eprom_w )
163143{
164144   /*
165145
r11336r11337
176156
177157    */
178158
179   atom_state *state = space->machine().driver_data<atom_state>();
180
181159   /* block A */
182   state->m_eprom = data & 0x0f;
160   m_eprom = data & 0x0f;
183161
184162   /* TODO block E */
185163
186   bankswitch(space->machine());
164   bankswitch();
187165}
188166
189167/***************************************************************************
r11336r11337
194172    ADDRESS_MAP( atom_mem )
195173-------------------------------------------------*/
196174
197static ADDRESS_MAP_START( atom_mem, AS_PROGRAM, 8 )
175static ADDRESS_MAP_START( atom_mem, AS_PROGRAM, 8, atom_state )
198176   AM_RANGE(0x0000, 0x09ff) AM_RAM
199   AM_RANGE(0x0a00, 0x0a03) AM_MIRROR(0x1f8) AM_DEVREADWRITE(I8271_TAG, i8271_r, i8271_w)
200   AM_RANGE(0x0a04, 0x0a04) AM_MIRROR(0x1f8) AM_DEVREADWRITE(I8271_TAG, i8271_data_r, i8271_data_w)
177   AM_RANGE(0x0a00, 0x0a03) AM_MIRROR(0x1f8) AM_DEVREADWRITE_LEGACY(I8271_TAG, i8271_r, i8271_w)
178   AM_RANGE(0x0a04, 0x0a04) AM_MIRROR(0x1f8) AM_DEVREADWRITE_LEGACY(I8271_TAG, i8271_data_r, i8271_data_w)
201179   AM_RANGE(0x0a05, 0x7fff) AM_RAM
202   AM_RANGE(0x8000, 0x97ff) AM_RAM AM_BASE_MEMBER(atom_state, m_video_ram)
180   AM_RANGE(0x8000, 0x97ff) AM_RAM AM_BASE(m_video_ram)
203181   AM_RANGE(0x9800, 0x9fff) AM_RAM
204182   AM_RANGE(0xa000, 0xafff) AM_ROM AM_REGION("a000", 0)
205   AM_RANGE(0xb000, 0xb003) AM_MIRROR(0x3fc) AM_DEVREADWRITE_MODERN(INS8255_TAG, i8255_device, read, write)
206//  AM_RANGE(0xb400, 0xb403) AM_DEVREADWRITE(MC6854_TAG, mc6854_r, mc6854_w)
183   AM_RANGE(0xb000, 0xb003) AM_MIRROR(0x3fc) AM_DEVREADWRITE(INS8255_TAG, i8255_device, read, write)
184//  AM_RANGE(0xb400, 0xb403) AM_DEVREADWRITE_LEGACY(MC6854_TAG, mc6854_r, mc6854_w)
207185//  AM_RANGE(0xb404, 0xb404) AM_READ_PORT("ECONET")
208   AM_RANGE(0xb800, 0xb80f) AM_MIRROR(0x3f0) AM_DEVREADWRITE_MODERN(R6522_TAG, via6522_device, read, write)
186   AM_RANGE(0xb800, 0xb80f) AM_MIRROR(0x3f0) AM_DEVREADWRITE(R6522_TAG, via6522_device, read, write)
209187   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION(SY6502_TAG, 0)
210188ADDRESS_MAP_END
211189
r11336r11337
213191    ADDRESS_MAP( atomeb_mem )
214192-------------------------------------------------*/
215193
216static ADDRESS_MAP_START( atomeb_mem, AS_PROGRAM, 8 )
194static ADDRESS_MAP_START( atomeb_mem, AS_PROGRAM, 8, atom_state )
217195   AM_IMPORT_FROM(atom_mem)
218196   AM_RANGE(0xbfff, 0xbfff) AM_READWRITE(eprom_r, eprom_w)
219197ADDRESS_MAP_END
r11336r11337
364342    SCREEN_UPDATE( atom )
365343-------------------------------------------------*/
366344
367static SCREEN_UPDATE( atom )
345bool atom_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
368346{
369   atom_state *state = screen->machine().driver_data<atom_state>();
370
371   return mc6847_update(state->m_mc6847, bitmap, cliprect);
347   return mc6847_update(m_vdg, &bitmap, &cliprect);
372348}
373349
374350/***************************************************************************
r11336r11337
379355    I8255_INTERFACE( ppi_intf )
380356-------------------------------------------------*/
381357
382static WRITE8_DEVICE_HANDLER( ppi_pa_w )
358WRITE8_MEMBER( atom_state::ppi_pa_w )
383359{
384360   /*
385361
r11336r11337
396372
397373    */
398374
399   atom_state *state = device->machine().driver_data<atom_state>();
400
401375   /* keyboard column */
402   state->m_keylatch = data & 0x0f;
376   m_keylatch = data & 0x0f;
403377
404378   /* MC6847 */
405   mc6847_ag_w(state->m_mc6847, BIT(data, 4));
406   mc6847_gm0_w(state->m_mc6847, BIT(data, 5));
407   mc6847_gm1_w(state->m_mc6847, BIT(data, 6));
408   mc6847_gm2_w(state->m_mc6847, BIT(data, 7));
379   mc6847_ag_w(m_vdg, BIT(data, 4));
380   mc6847_gm0_w(m_vdg, BIT(data, 5));
381   mc6847_gm1_w(m_vdg, BIT(data, 6));
382   mc6847_gm2_w(m_vdg, BIT(data, 7));
409383}
410384
411static READ8_DEVICE_HANDLER( ppi_pb_r )
385READ8_MEMBER( atom_state::ppi_pb_r )
412386{
413387   /*
414388
r11336r11337
425399
426400    */
427401
428   atom_state *state = device->machine().driver_data<atom_state>();
429402   UINT8 data = 0xff;
430403
431   switch (state->m_keylatch)
404   switch (m_keylatch)
432405   {
433   case 0: data &= input_port_read(device->machine(), "KEY0"); break;
434   case 1: data &= input_port_read(device->machine(), "KEY1"); break;
435   case 2: data &= input_port_read(device->machine(), "KEY2"); break;
436   case 3: data &= input_port_read(device->machine(), "KEY3"); break;
437   case 4: data &= input_port_read(device->machine(), "KEY4"); break;
438   case 5: data &= input_port_read(device->machine(), "KEY5"); break;
439   case 6: data &= input_port_read(device->machine(), "KEY6"); break;
440   case 7: data &= input_port_read(device->machine(), "KEY7"); break;
441   case 8: data &= input_port_read(device->machine(), "KEY8"); break;
442   case 9: data &= input_port_read(device->machine(), "KEY9"); break;
406   case 0: data &= input_port_read(machine(), "KEY0"); break;
407   case 1: data &= input_port_read(machine(), "KEY1"); break;
408   case 2: data &= input_port_read(machine(), "KEY2"); break;
409   case 3: data &= input_port_read(machine(), "KEY3"); break;
410   case 4: data &= input_port_read(machine(), "KEY4"); break;
411   case 5: data &= input_port_read(machine(), "KEY5"); break;
412   case 6: data &= input_port_read(machine(), "KEY6"); break;
413   case 7: data &= input_port_read(machine(), "KEY7"); break;
414   case 8: data &= input_port_read(machine(), "KEY8"); break;
415   case 9: data &= input_port_read(machine(), "KEY9"); break;
443416   }
444417
445   data &= input_port_read(device->machine(), "KEY10");
418   data &= input_port_read(machine(), "KEY10");
446419
447420   return data;
448421}
449422
450static READ8_DEVICE_HANDLER( ppi_pc_r )
423READ8_MEMBER( atom_state::ppi_pc_r )
451424{
452425   /*
453426
r11336r11337
464437
465438    */
466439
467   atom_state *state = device->machine().driver_data<atom_state>();
468
469440   UINT8 data = 0;
470441
471442   /* 2400 Hz input */
472   data |= state->m_hz2400 << 4;
443   data |= m_hz2400 << 4;
473444
474445   /* cassette input */
475   data |= (cassette_input(state->m_cassette) > 0.0) << 5;
446   data |= (cassette_input(m_cassette) > 0.0) << 5;
476447
477448   /* keyboard RPT */
478   data |= BIT(input_port_read(device->machine(), "RPT"), 0) << 6;
449   data |= BIT(input_port_read(machine(), "RPT"), 0) << 6;
479450
480451   /* MC6847 FS */
481   data |= mc6847_fs_r(state->m_mc6847) << 7;
452   data |= mc6847_fs_r(m_vdg) << 7;
482453
483454   return data;
484455}
485456
486static WRITE8_DEVICE_HANDLER( ppi_pc_w )
457WRITE8_MEMBER( atom_state::ppi_pc_w )
487458{
488459   /*
489460
r11336r11337
500471
501472    */
502473
503   atom_state *state = device->machine().driver_data<atom_state>();
504
505474   /* cassette output */
506   state->m_pc0 = BIT(data, 0);
507   state->m_pc1 = BIT(data, 1);
475   m_pc0 = BIT(data, 0);
476   m_pc1 = BIT(data, 1);
508477
509478   /* speaker output */
510   speaker_level_w(device, BIT(data, 2));
479   speaker_level_w(m_speaker, BIT(data, 2));
511480
512481   /* MC6847 CSS */
513   mc6847_css_w(state->m_mc6847, BIT(data, 3));
482   mc6847_css_w(m_vdg, BIT(data, 3));
514483}
515484
516485static I8255_INTERFACE( ppi_intf )
517486{
518487   DEVCB_NULL,
519   DEVCB_HANDLER(ppi_pa_w),
520   DEVCB_HANDLER(ppi_pb_r),
488   DEVCB_DRIVER_MEMBER(atom_state, ppi_pa_w),
489   DEVCB_DRIVER_MEMBER(atom_state, ppi_pb_r),
521490   DEVCB_NULL,
522   DEVCB_HANDLER(ppi_pc_r),
523   DEVCB_DEVICE_HANDLER(SPEAKER_TAG, ppi_pc_w)
491   DEVCB_DRIVER_MEMBER(atom_state, ppi_pc_r),
492   DEVCB_DRIVER_MEMBER(atom_state, ppi_pc_w)
524493};
525494
526495/*-------------------------------------------------
527496    via6522_interface via_intf
528497-------------------------------------------------*/
529498
530static READ8_DEVICE_HANDLER( atom_printer_busy )
499READ8_MEMBER( atom_state::printer_busy )
531500{
532   return centronics_busy_r(device) << 7;
501   return centronics_busy_r(m_centronics) << 7;
533502}
534503
535static WRITE8_DEVICE_HANDLER( atom_printer_data )
504WRITE8_MEMBER( atom_state::printer_data )
536505{
537   centronics_data_w(device, 0, data & 0x7f);
506   centronics_data_w(m_centronics, 0, data & 0x7f);
538507}
539508
540509static const via6522_interface via_intf =
541510{
542   DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, atom_printer_busy),
511   DEVCB_DRIVER_MEMBER(atom_state, printer_busy),
543512   DEVCB_NULL,
544513   DEVCB_NULL,
545514   DEVCB_NULL,
546515   DEVCB_NULL,
547516   DEVCB_NULL,
548   DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, atom_printer_data),
517   DEVCB_DRIVER_MEMBER(atom_state, printer_data),
549518   DEVCB_NULL,
550519   DEVCB_NULL,
551520   DEVCB_NULL,
r11336r11337
558527    i8271_interface fdc_intf
559528-------------------------------------------------*/
560529
561
562530static void atom_8271_interrupt_callback(device_t *device, int state)
563531{
564532   atom_state *drvstate = device->machine().driver_data<atom_state>();
r11336r11337
574542      {
575543         /* I'll pulse it because if I used hold-line I'm not sure
576544            it would clear - to be checked */
577         cputag_set_input_line(device->machine(), SY6502_TAG, INPUT_LINE_NMI, PULSE_LINE);
545         drvstate->m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
578546      }
579547   }
580548
r11336r11337
595563static const centronics_interface atom_centronics_config =
596564{
597565   FALSE,
598   DEVCB_DEVICE_LINE_MEMBER(R6522_TAG, via6522_device,write_ca1),
566   DEVCB_DEVICE_LINE_MEMBER(R6522_TAG, via6522_device, write_ca1),
599567   DEVCB_NULL,
600568   DEVCB_NULL
601569};
r11336r11337
626594   DEVCB_NULL,
627595   FLOPPY_STANDARD_5_25_SSDD_40,
628596   FLOPPY_OPTIONS_NAME(atom),
629   NULL
597   "floppy_5_25"
630598};
631599
632600/*-------------------------------------------------
r11336r11337
658626};
659627
660628/*-------------------------------------------------
661    mc6847_interface atom_mc6847_intf
629    mc6847_interface atom_vdg_intf
662630-------------------------------------------------*/
663631
664static READ8_DEVICE_HANDLER( atom_mc6847_videoram_r )
632READ8_MEMBER( atom_state::vdg_videoram_r )
665633{
666   atom_state *state = device->machine().driver_data<atom_state>();
634   mc6847_as_w(m_vdg, BIT(m_video_ram[offset], 6));
635   mc6847_intext_w(m_vdg, BIT(m_video_ram[offset], 6));
636   mc6847_inv_w(m_vdg, BIT(m_video_ram[offset], 7));
667637
668   mc6847_as_w(device, BIT(state->m_video_ram[offset], 6));
669   mc6847_intext_w(device, BIT(state->m_video_ram[offset], 6));
670   mc6847_inv_w(device, BIT(state->m_video_ram[offset], 7));
671
672   return state->m_video_ram[offset];
638   return m_video_ram[offset];
673639}
674640
675static const mc6847_interface atom_mc6847_intf =
641static const mc6847_interface atom_vdg_intf =
676642{
677   DEVCB_HANDLER(atom_mc6847_videoram_r),
643   DEVCB_DRIVER_MEMBER(atom_state, vdg_videoram_r),
678644   DEVCB_NULL,
679645   DEVCB_NULL,
680646   DEVCB_NULL,
r11336r11337
696662    MACHINE_START( atom )
697663-------------------------------------------------*/
698664
699static MACHINE_START( atom )
665void atom_state::machine_start()
700666{
701   atom_state *state = machine.driver_data<atom_state>();
702
703667   /* this is temporary */
704668   /* Kees van Oss mentions that address 8-b are used for the random number
705669    generator. I don't know if this is hardware, or random data because the
706670    ram chips are not cleared at start-up. So at this time, these numbers
707671    are poked into the memory to simulate it. When I have more details I will fix it */
708   machine.region(SY6502_TAG)->base()[0x08] = machine.rand() & 0x0ff;
709   machine.region(SY6502_TAG)->base()[0x09] = machine.rand() & 0x0ff;
710   machine.region(SY6502_TAG)->base()[0x0a] = machine.rand() & 0x0ff;
711   machine.region(SY6502_TAG)->base()[0x0b] = machine.rand() & 0x0ff;
712
713   /* find devices */
714   state->m_mc6847 = machine.device(MC6847_TAG);
715   state->m_cassette = machine.device(CASSETTE_TAG);
672   machine().region(SY6502_TAG)->base()[0x08] = machine().rand() & 0x0ff;
673   machine().region(SY6502_TAG)->base()[0x09] = machine().rand() & 0x0ff;
674   machine().region(SY6502_TAG)->base()[0x0a] = machine().rand() & 0x0ff;
675   machine().region(SY6502_TAG)->base()[0x0b] = machine().rand() & 0x0ff;
716676}
717677
718678/*-------------------------------------------------
719679    MACHINE_START( atomeb )
720680-------------------------------------------------*/
721681
722static MACHINE_START( atomeb )
682void atomeb_state::machine_start()
723683{
724   MACHINE_START_CALL(atom);
684   atom_state::machine_start();
725685
726   bankswitch(machine);
686   bankswitch();
727687}
728688
729689/***************************************************************************
r11336r11337
834794   MCFG_CPU_ADD(SY6502_TAG, M65C02, X2/4)
835795   MCFG_CPU_PROGRAM_MAP(atom_mem)
836796
837   MCFG_MACHINE_START( atom )
838
839797   /* video hardware */
840798   MCFG_SCREEN_ADD(SCREEN_TAG, RASTER)
841799   MCFG_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND)
842800   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
843801   MCFG_SCREEN_SIZE(320, 25+192+26)
844802   MCFG_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
845   MCFG_SCREEN_UPDATE(atom)
846803
847   MCFG_MC6847_ADD(MC6847_TAG, atom_mc6847_intf)
804   MCFG_MC6847_ADD(MC6847_TAG, atom_vdg_intf)
848805   MCFG_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL)
849806
850807   /* sound hardware */
r11336r11337
878835    MACHINE_DRIVER( atomeb )
879836-------------------------------------------------*/
880837
881static MACHINE_CONFIG_DERIVED( atomeb, atom )
838static MACHINE_CONFIG_DERIVED_CLASS( atomeb, atom, atomeb_state )
882839   MCFG_CPU_MODIFY(SY6502_TAG)
883840   MCFG_CPU_PROGRAM_MAP(atomeb_mem)
884841
885   MCFG_MACHINE_START(atomeb)
886
887842   /* cartridges */
888843   MCFG_DEVICE_REMOVE("cart")
889844   MCFG_ATOM_CARTSLOT_ADD("a0")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team