Previous 15994 Revisions Next

r12840 Wednesday 14th September, 2011 at 02:32:48 UTC by Barry Rodewald
x68k: added basic expansion slot, and support for the Neptune-X NIC as
a slot device. [Barry Rodewald]
[src/mess]mess.mak
[src/mess/drivers]x68k.c
[src/mess/machine]x68k_neptunex.c* x68k_neptunex.h* x68kexp.c* x68kexp.h*

src/mess/machine/x68kexp.c
r0r12840
1/*
2 * x68kexp.c
3 */
4
5#include "emu.h"
6#include "emuopts.h"
7#include "machine/x68kexp.h"
8
9//**************************************************************************
10//  GLOBAL VARIABLES
11//**************************************************************************
12
13const device_type X68K_EXPANSION_SLOT = &device_creator<x68k_expansion_slot_device>;
14
15
16//**************************************************************************
17//  DEVICE CPC_EXPANSION CARD INTERFACE
18//**************************************************************************
19
20
21device_x68k_expansion_card_interface::device_x68k_expansion_card_interface(const machine_config &mconfig, device_t &device)
22   : device_interface(device)
23{
24}
25
26
27device_x68k_expansion_card_interface::~device_x68k_expansion_card_interface()
28{
29}
30
31//**************************************************************************
32//  LIVE DEVICE
33//**************************************************************************
34
35x68k_expansion_slot_device::x68k_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
36        device_t(mconfig, X68K_EXPANSION_SLOT, "Sharp X680x0 expansion slot", tag, owner, clock),
37      device_slot_interface(mconfig, *this)
38{
39}
40
41x68k_expansion_slot_device::~x68k_expansion_slot_device()
42{
43}
44
45//-------------------------------------------------
46//  device_config_complete - perform any
47//  operations now that the configuration is
48//  complete
49//-------------------------------------------------
50
51void x68k_expansion_slot_device::device_config_complete()
52{
53   // inherit a copy of the static data
54   const x68k_expansion_slot_interface *intf = reinterpret_cast<const x68k_expansion_slot_interface *>(static_config());
55   if (intf != NULL)
56   {
57      *static_cast<x68k_expansion_slot_interface *>(this) = *intf;
58   }
59
60   // or initialize to defaults if none provided
61   else
62   {
63       memset(&m_out_irq2_cb, 0, sizeof(m_out_irq2_cb));
64       memset(&m_out_irq4_cb, 0, sizeof(m_out_irq4_cb));
65       memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb));
66       memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
67   }
68}
69
70//-------------------------------------------------
71//  device_start - device-specific startup
72//-------------------------------------------------
73
74void x68k_expansion_slot_device::device_start()
75{
76   m_card = dynamic_cast<device_x68k_expansion_card_interface *>(get_card_device());
77
78   // resolve callbacks
79   m_out_irq2_func.resolve(m_out_irq2_cb, *this);
80   m_out_irq4_func.resolve(m_out_irq4_cb, *this);
81   m_out_nmi_func.resolve(m_out_nmi_cb, *this);
82   m_out_reset_func.resolve(m_out_reset_cb, *this);
83}
84
85
86//-------------------------------------------------
87//  device_reset - device-specific reset
88//-------------------------------------------------
89
90void x68k_expansion_slot_device::device_reset()
91{
92}
93
94
95WRITE_LINE_MEMBER( x68k_expansion_slot_device::irq2_w ) { m_out_irq2_func(state); }
96WRITE_LINE_MEMBER( x68k_expansion_slot_device::irq4_w ) { m_out_irq4_func(state); }
97WRITE_LINE_MEMBER( x68k_expansion_slot_device::nmi_w ) { m_out_nmi_func(state); }
98WRITE_LINE_MEMBER( x68k_expansion_slot_device::reset_w ) { m_out_reset_func(state); }
src/mess/machine/x68kexp.h
r0r12840
1/*
2 * x68kexp.h
3 *
4 * Expansion slots for the X680x0 series
5 *
6 * Pinout: (from http://www.amy.hi-ho.ne.jp/shimada/neptune/x68k.html)
7                +-----+
8   GND       B1  |[] []| A1      GND
9   10MHz   B2  |[] []| A2      20MHz
10   #10MHz  B3  |[] []| A3      GND
11   E       B4  |[] []| A4      DB0
12   AB1     B5  |[] []| A5      DB1
13   AB2     B6  |[] []| A6      DB2
14   AB3     B7  |[] []| A7      DB3
15   AB4     B8  |[] []| A8      DB4
16   AB5     B9  |[] []| A9      DB5
17   AB6     B10 |[] []| A10      DB6
18   GND     B11 |[] []| A11      GND
19   AB7     B12 |[] []| A12      DB7
20   AB8     B13 |[] []| A13      DB8
21   AB9     B14 |[] []| A14      DB9
22   AB10    B15 |[] []| A15      DB10
23   AB11    B16 |[] []| A16      DB11
24   AB12    B17 |[] []| A17      DB12
25   AB13    B18 |[] []| A18      DB13
26   AB14    B19 |[] []| A19      DB14
27   AB15    B20 |[] []| A20      DB15
28   GND     B21 |[] []| A21      GND
29   AB16    B22 |[] []| A22      +12V
30   AB17    B23 |[] []| A23      +12V
31   AB18    B24 |[] []| A24      FC0
32   AB19    B25 |[] []| A25      FC1
33   AB20    B26 |[] []| A26      FC2
34   AB21    B27 |[] []| A27      #AS
35   AB22    B28 |[] []| A28      #LDS
36   AB23    B29 |[] []| A29      #UDS
37   IDDIR   B30 |[] []| A30      R/#W
38   N.C.    B31 |[] []| A31      N.C.
39   HSYNC   B32 |[] []| A32      -12V
40   VSYNC   B33 |[] []| A33      -12V
41   #DONE   B34 |[] []| A34      #VMA
42   #DTC    B35 |[] []| A35      #EXVPA
43   #EXREQ  B36 |[] []| A36      #DTACK
44   #EXACK  B37 |[] []| A37      #EXRESET
45   #EXPCL  B38 |[] []| A38      #HALT
46   #EXOWN  B39 |[] []| A39      #EXBERR
47   #EXNMI  B40 |[] []| A40      #EXPWON
48   GND     B41 |[] []| A41      GND
49   #IRQ2   B42 |[] []| A42      Vcc2
50   #IRQ4   B43 |[] []| A43      Vcc2
51   #IACK2  B44 |[] []| A44      SELEN
52   #IACK4  B45 |[] []| A45      CASRDEN
53   #BR     B46 |[] []| A46      CASWRL
54   #BG     B47 |[] []| A47      CASWRU
55   #BGACK  B48 |[] []| A48      INH2
56   Vcc1    B49 |[] []| A49      Vcc1
57   Vcc1    B50 |[] []| A50      Vcc1
58                +-----+
59 *
60 */
61
62#ifndef X68KEXP_H_
63#define X68KEXP_H_
64
65#include "emu.h"
66
67//**************************************************************************
68//  CONSTANTS
69//**************************************************************************
70
71#define X68K_EXP_SLOT_TAG      "x68kexp"
72
73//**************************************************************************
74//  INTERFACE CONFIGURATION MACROS
75//**************************************************************************
76
77#define X68K_EXPANSION_INTERFACE(_name) \
78   const x68k_expansion_slot_interface (_name) =
79
80
81#define MCFG_X68K_EXPANSION_SLOT_ADD(_tag, _config, _slot_intf, _def_slot, _def_inp) \
82    MCFG_DEVICE_ADD(_tag, X68K_EXPANSION_SLOT, 0) \
83    MCFG_DEVICE_CONFIG(_config) \
84   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
85
86//**************************************************************************
87//  TYPE DEFINITIONS
88//**************************************************************************
89
90// expansion slot interface
91
92struct x68k_expansion_slot_interface
93{
94    devcb_write_line   m_out_irq2_cb;
95    devcb_write_line   m_out_irq4_cb;
96    devcb_write_line   m_out_nmi_cb;
97    devcb_write_line   m_out_reset_cb;
98};
99
100// ======================> device_x68k_expansion_card_interface
101
102// class representing interface-specific live x68k_expansion card
103class device_x68k_expansion_card_interface : public device_interface
104{
105public:
106   // construction/destruction
107   device_x68k_expansion_card_interface(const machine_config &mconfig, device_t &device);
108   virtual ~device_x68k_expansion_card_interface();
109
110   // reset
111   virtual void x68k_reset_w() { };
112};
113
114
115// ======================> x68k_expansion_slot_device
116
117class x68k_expansion_slot_device : public device_t,
118                          public x68k_expansion_slot_interface,
119                          public device_slot_interface
120{
121public:
122   // construction/destruction
123   x68k_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
124   virtual ~x68k_expansion_slot_device();
125
126   DECLARE_WRITE_LINE_MEMBER( irq2_w );
127   DECLARE_WRITE_LINE_MEMBER( irq4_w );
128   DECLARE_WRITE_LINE_MEMBER( nmi_w );
129   DECLARE_WRITE_LINE_MEMBER( reset_w );
130
131protected:
132   // device-level overrides
133   virtual void device_start();
134   virtual void device_reset();
135   virtual void device_config_complete();
136
137   devcb_resolved_write_line   m_out_irq2_func;
138   devcb_resolved_write_line   m_out_irq4_func;
139   devcb_resolved_write_line   m_out_nmi_func;
140   devcb_resolved_write_line   m_out_reset_func;
141
142   device_x68k_expansion_card_interface *m_card;
143};
144
145
146// device type definition
147extern const device_type X68K_EXPANSION_SLOT;
148
149#endif /* X68KEXP_H_ */
src/mess/machine/x68k_neptunex.c
r0r12840
1/*
2 * x68k_neptunex.c
3 */
4
5#include "emu.h"
6#include "machine/dp8390.h"
7#include "machine/x68k_neptunex.h"
8
9
10//**************************************************************************
11//  DEVICE DEFINITIONS
12//**************************************************************************
13
14const device_type X68K_NEPTUNEX = &device_creator<x68k_neptune_device>;
15
16static const dp8390_interface neptune_dp8390_interface = {
17   DEVCB_LINE_MEMBER(x68k_neptune_device, x68k_neptune_irq_w),
18   DEVCB_NULL,
19   DEVCB_MEMBER(x68k_neptune_device, x68k_neptune_mem_read),
20   DEVCB_MEMBER(x68k_neptune_device, x68k_neptune_mem_write)
21};
22
23
24// device machine config
25static MACHINE_CONFIG_FRAGMENT( x68k_neptunex )
26   MCFG_DP8390D_ADD("dp8390d", neptune_dp8390_interface)
27MACHINE_CONFIG_END
28
29machine_config_constructor x68k_neptune_device::device_mconfig_additions() const
30{
31   return MACHINE_CONFIG_NAME( x68k_neptunex );
32}
33
34x68k_neptune_device::x68k_neptune_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
35        : device_t(mconfig, X68K_NEPTUNEX, "Neptune-X", tag, owner, clock),
36      device_x68k_expansion_card_interface(mconfig, *this),
37      device_slot_card_interface(mconfig, *this),
38      m_dp8390(*this, "dp8390d")
39{
40}
41
42//-------------------------------------------------
43//  device_start - device-specific startup
44//-------------------------------------------------
45
46void x68k_neptune_device::device_start()
47{
48   device_t* cpu = machine().device("maincpu");
49   char mac[7];
50   UINT32 num = rand();
51   address_space* space = cpu->memory().space(AS_PROGRAM);
52   m_slot = dynamic_cast<x68k_expansion_slot_device *>(owner());
53   m_dp8390->set_interface(0); // XXX make user configurable
54   memset(m_prom, 0x57, 16);
55   sprintf(mac+2, "\x1b%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff);
56   mac[0] = 0; mac[1] = 0;  // avoid gcc warning
57   memcpy(m_prom, mac, 6);
58   space->install_readwrite_handler(0xece000,0xece3ff,read16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_r),this),write16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_w),this),0);
59}
60
61READ16_MEMBER(x68k_neptune_device::x68k_neptune_port_r)
62{
63   UINT16 data;
64   if(offset >= 32)
65      return 0xffff;
66   if(offset < 16)
67   {
68      m_dp8390->dp8390_cs(CLEAR_LINE);
69      return (m_dp8390->dp8390_r(space, offset, 0xff) << 8)|
70            m_dp8390->dp8390_r(space, offset+1, 0xff);
71   }
72   //if(mem_mask == 0x00ff) offset++;
73   switch(offset)
74   {
75   case 16:
76      m_dp8390->dp8390_cs(ASSERT_LINE);
77      data = m_dp8390->dp8390_r(space, offset, mem_mask);
78      data = ((data & 0x00ff) << 8) | ((data & 0xff00) >> 8);
79      return data;
80   case 31:
81      m_dp8390->dp8390_reset(CLEAR_LINE);
82      return 0;
83   default:
84      logerror("ne2000: invalid register read %02X\n", offset);
85   }
86   return 0;
87}
88
89WRITE16_MEMBER(x68k_neptune_device::x68k_neptune_port_w)
90{
91   if(offset >= 32)
92      return;
93   if(offset < 16)
94   {
95      m_dp8390->dp8390_cs(CLEAR_LINE);
96      if(mem_mask == 0x00ff)
97      {
98         data <<= 8;
99         offset++;
100      }
101      m_dp8390->dp8390_w(space, offset, data>>8, 0xff);
102      if(mem_mask == 0xffff) m_dp8390->dp8390_w(space, offset+1, data & 0xff, 0xff);
103      return;
104   }
105   //if(mem_mask == 0x00ff) offset++;
106   switch(offset)
107   {
108   case 16:
109      m_dp8390->dp8390_cs(ASSERT_LINE);
110      data = ((data & 0x00ff) << 8) | ((data & 0xff00) >> 8);
111      m_dp8390->dp8390_w(space, offset, data, mem_mask);
112      return;
113   case 31:
114      m_dp8390->dp8390_reset(ASSERT_LINE);
115      return;
116   default:
117      logerror("ne2000: invalid register write %02X\n", offset);
118   }
119   return;
120}
121
122READ8_MEMBER(x68k_neptune_device::x68k_neptune_mem_read)
123{
124   if(offset < 32) return m_prom[offset>>1];
125   if((offset < (16*1024)) || (offset >= (32*1024)))
126   {
127      logerror("ne2000: invalid memory read %04X\n", offset);
128      return 0xff;
129   }
130   return m_board_ram[offset - (16*1024)];
131}
132
133WRITE8_MEMBER(x68k_neptune_device::x68k_neptune_mem_write)
134{
135   if((offset < (16*1024)) || (offset >= (32*1024)))
136   {
137      logerror("ne2000: invalid memory write %04X\n", offset);
138      return;
139   }
140   m_board_ram[offset - (16*1024)] = data;
141}
142
143WRITE_LINE_MEMBER(x68k_neptune_device::x68k_neptune_irq_w)
144{
145   device_set_input_line_vector(machine().device("maincpu"),2, NEPTUNE_IRQ_VECTOR);
146   m_slot->irq2_w(state);
147   logerror("Neptune: IRQ2 set to %i\n",state);
148}
149
src/mess/machine/x68k_neptunex.h
r0r12840
1/*
2 * x68k_neptunex.h
3 *
4 * Neptune-X NE2000-based ethernet board for the X68000
5 *
6 * Map:
7 * 0xECE000-0xECE3FF: "Y0"
8 * 0xECE400-0xECE7FF: "Y1"
9 */
10
11#ifndef X68K_NEPTUNEX_H_
12#define X68K_NEPTUNEX_H_
13
14#include "emu.h"
15#include "machine/dp8390.h"
16#include "machine/x68kexp.h"
17
18#define NEPTUNE_IRQ_VECTOR 0xf9
19
20class x68k_neptune_device : public device_t,
21                     public device_x68k_expansion_card_interface,
22                     public device_slot_card_interface
23{
24public:
25   // construction/destruction
26   x68k_neptune_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
27
28   // optional information overrides
29   virtual machine_config_constructor device_mconfig_additions() const;
30
31   void x68k_neptune_irq_w(int state);
32   DECLARE_READ8_MEMBER(x68k_neptune_mem_read);
33   DECLARE_WRITE8_MEMBER(x68k_neptune_mem_write);
34   DECLARE_READ16_MEMBER(x68k_neptune_port_r);
35   DECLARE_WRITE16_MEMBER(x68k_neptune_port_w);
36
37protected:
38   // device-level overrides
39   virtual void device_start();
40   virtual void device_reset() {};
41    virtual void device_config_complete() { m_shortname = "x68k_neptunex"; }
42
43private:
44   x68k_expansion_slot_device *m_slot;
45
46   required_device<dp8390d_device> m_dp8390;
47   UINT8 m_board_ram[16*1024];
48   UINT8 m_prom[16];
49};
50
51// device type definition
52extern const device_type X68K_NEPTUNEX;
53
54#endif /* X68K_NEPTUNEX_H_ */
src/mess/mess.mak
r12839r12840
14301430   $(MESS_MACHINE)/mz700.o      \
14311431   $(MESS_DRIVERS)/x68k.o      \
14321432   $(MESS_VIDEO)/x68k.o      \
1433   $(MESS_MACHINE)/x68kexp.o   \
1434   $(MESS_MACHINE)/x68k_neptunex.o   \
14331435   $(MESS_MACHINE)/x68k_hdc.o   \
14341436   $(MESS_MACHINE)/mb89352.o   \
14351437   $(MESS_DRIVERS)/mz80.o      \
src/mess/drivers/x68k.c
r12839r12840
138138#include "includes/x68k.h"
139139#include "machine/ram.h"
140140#include "machine/nvram.h"
141#include "machine/x68kexp.h"
142#include "machine/x68k_neptunex.h"
141143#include "x68000.lh"
142144
143145
r12839r12840
19861988   AM_RANGE(0xeafa80, 0xeafa89) AM_READWRITE(x68k_areaset_r, x68k_enh_areaset_w)
19871989   AM_RANGE(0xeb0000, 0xeb7fff) AM_READWRITE(x68k_spritereg_r, x68k_spritereg_w)
19881990   AM_RANGE(0xeb8000, 0xebffff) AM_READWRITE(x68k_spriteram_r, x68k_spriteram_w)
1989   AM_RANGE(0xec0000, 0xecffff) AM_NOP  // User I/O
1991   AM_RANGE(0xece000, 0xece3ff) AM_READWRITE(x68k_exp_r, x68k_exp_w)  // User I/O
19901992//  AM_RANGE(0xed0000, 0xed3fff) AM_READWRITE(sram_r, sram_w) AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
19911993   AM_RANGE(0xed0000, 0xed3fff) AM_RAMBANK("bank4") AM_SHARE("nvram")
19921994   AM_RANGE(0xed4000, 0xefffff) AM_NOP
r12839r12840
20242026   AM_RANGE(0xeafa80, 0xeafa89) AM_READWRITE(x68k_areaset_r, x68k_enh_areaset_w)
20252027   AM_RANGE(0xeb0000, 0xeb7fff) AM_READWRITE(x68k_spritereg_r, x68k_spritereg_w)
20262028   AM_RANGE(0xeb8000, 0xebffff) AM_READWRITE(x68k_spriteram_r, x68k_spriteram_w)
2027   AM_RANGE(0xec0000, 0xecffff) AM_NOP  // User I/O
2029   AM_RANGE(0xece000, 0xece3ff) AM_READWRITE(x68k_exp_r, x68k_exp_w)  // User I/O
20282030//  AM_RANGE(0xed0000, 0xed3fff) AM_READWRITE(sram_r, sram_w) AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
20292031   AM_RANGE(0xed0000, 0xed3fff) AM_RAMBANK("bank4") AM_SHARE("nvram")
20302032   AM_RANGE(0xed4000, 0xefffff) AM_NOP
r12839r12840
20622064   AM_RANGE(0xeafa80, 0xeafa8b) AM_READWRITE16(x68k_areaset_r, x68k_enh_areaset_w,0xffffffff)
20632065   AM_RANGE(0xeb0000, 0xeb7fff) AM_READWRITE16(x68k_spritereg_r, x68k_spritereg_w,0xffffffff)
20642066   AM_RANGE(0xeb8000, 0xebffff) AM_READWRITE16(x68k_spriteram_r, x68k_spriteram_w,0xffffffff)
2065   AM_RANGE(0xec0000, 0xecffff) AM_NOP  // User I/O
2067   AM_RANGE(0xece000, 0xece3ff) AM_READWRITE16(x68k_exp_r, x68k_exp_w,0xffffffff)  // User I/O
20662068//  AM_RANGE(0xed0000, 0xed3fff) AM_READWRITE(sram_r, sram_w) AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
20672069   AM_RANGE(0xed0000, 0xed3fff) AM_RAMBANK("bank4") AM_SHARE("nvram")
20682070   AM_RANGE(0xed4000, 0xefffff) AM_NOP
r12839r12840
24802482   state->m_fdc.disk_inserted[floppy_get_drive(&image.device())] = 0;
24812483}
24822484
2485static void x68k_irq2_line(device_t* device,int state)
2486{
2487   x68k_state *tstate = device->machine().driver_data<x68k_state>();
2488   if(state==ASSERT_LINE)
2489   {
2490      tstate->m_current_vector[2] = 0xf9;
2491      tstate->m_current_irq_line = 2;
2492      cputag_set_input_line_and_vector(device->machine(), "maincpu",2,ASSERT_LINE,tstate->m_current_vector[2]);  // Disk insert/eject interrupt
2493   }
2494   logerror("EXP: IRQ2 set to %i\n",state);
2495
2496}
2497
24832498static LEGACY_FLOPPY_OPTIONS_START( x68k )
24842499   LEGACY_FLOPPY_OPTION( img2d, "xdf,hdm,2hd", "XDF disk image", basicdsk_identify_default, basicdsk_construct_default, NULL,
24852500      HEADS([2])
r12839r12840
25252540   DEVCB_LINE(x68k_scsi_drq)
25262541};
25272542
2543static X68K_EXPANSION_INTERFACE(x68k_exp_intf)
2544{
2545   DEVCB_LINE(x68k_irq2_line),
2546   DEVCB_CPU_INPUT_LINE("maincpu", M68K_IRQ_4),
2547   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI),
2548   DEVCB_NULL  // RESET
2549};
2550
2551static SLOT_INTERFACE_START(x68000_exp_cards)
2552   SLOT_INTERFACE("neptunex",X68K_NEPTUNEX)
2553SLOT_INTERFACE_END
2554
25282555static MACHINE_RESET( x68000 )
25292556{
25302557   x68k_state *state = machine.driver_data<x68k_state>();
r12839r12840
27742801   MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(x68k_floppy_interface)
27752802   MCFG_SOFTWARE_LIST_ADD("flop_list","x68k_flop")
27762803
2804   MCFG_X68K_EXPANSION_SLOT_ADD("exp",x68k_exp_intf,x68000_exp_cards,NULL,NULL)
2805
27772806   /* internal ram */
27782807   MCFG_RAM_ADD(RAM_TAG)
27792808   MCFG_RAM_DEFAULT_SIZE("4M")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team