Previous 199869 Revisions Next

r32974 Sunday 26th October, 2014 at 11:48:02 UTC by Fabio Priuli
(MESS) spc1000: converted the expansion bus EXT1 to be a
slot device, moved FDD expansion to be a slot card, added
emulation of the VDP expansion as another slot card. This
makes Gun Fright, TwinBee and Zanac playable if you launch
them with "-ext1 vdp" option. If you want to emulate a
SPC-1000 with floppy drive, you have to add "-ext1 fdd"
instead. [Fabio Priuli]

out of whatsnew: disk emulation still does not work (unless we use
Meeso Kim's patched BIOS), but emulation is now closer to the real
functionality and we needed the changes for the VDP unit emulation.
[hash]spc1000_cass.xml
[src/emu/bus]bus.mak
[src/emu/bus/spc1000]exp.c* exp.h* fdd.c* fdd.h* vdp.c* vdp.h*
[src/mess]mess.mak
[src/mess/drivers]spc1000.c

trunk/hash/spc1000_cass.xml
r241485r241486
506506      </part>
507507   </software>
508508
509   <software name="gunfrigh">
510      <description>Gun Fright</description>
511      <year>1986</year>
512      <publisher>Sammi Computer</publisher>
513      <info name="usage" value="Requires VDP unit in -ext1 expansion" />
514      <part name="cass" interface="spc1000_cass">
515         <dataarea name="cass" size="614352">
516            <rom name="gunfright.tap" size="614352" crc="73cc58ef" sha1="ab09466a1cf2fc12faa2e18252e348b9cc56a7ff" offset="0" />
517         </dataarea>
518      </part>
519   </software>
520
509521   <software name="headon">
510522      <description>Head-On</description>
511523      <year>198?</year>
r241485r241486
10001012      </part>
10011013   </software>
10021014
1015   <software name="twinbee">
1016      <description>TwinBee</description>
1017      <year>1986</year>
1018      <publisher>Static Soft</publisher>
1019      <info name="usage" value="Requires VDP unit in -ext1 expansion" />
1020      <part name="cass" interface="spc1000_cass">
1021         <dataarea name="cass" size="55619">
1022            <rom name="vdp+twinbee.cas" size="55619" crc="b1882952" sha1="cee9e0e060ce3f17b0bcc1fa1ba5d86590cae4c3" offset="0" />
1023         </dataarea>
1024      </part>
1025   </software>
1026
10031027   <software name="vela">
10041028      <description>Vela</description>
10051029      <year>198?</year>
r241485r241486
10701094      </part>
10711095   </software>
10721096
1073   <software name="zexas">
1074      <description>Zexas</description>
1075      <year>198?</year>
1076      <publisher>Aloe?</publisher>
1077      <part name="cass" interface="spc1000_cass">
1078         <dataarea name="cass" size="702072">
1079            <rom name="zexas-5461-mayhouse.tap" size="702072" crc="9367b51e" sha1="d6da8e4ae2275dbd3ba1b9c7137944f5674daf26" offset="0" />
1080         </dataarea>
1081      </part>
1082   </software>
1083
1084
1085<!-- Requires VDP Unit emulation -->
1086   <software name="twinbee" supported="no">
1087      <description>TwinBee</description>
1088      <year>198?</year>
1089      <publisher>&lt;unknown&gt;</publisher>
1090      <part name="cass" interface="spc1000_cass">
1091         <dataarea name="cass" size="55619">
1092            <rom name="vdp+twinbee.cas" size="55619" crc="b1882952" sha1="cee9e0e060ce3f17b0bcc1fa1ba5d86590cae4c3" offset="0" />
1093         </dataarea>
1094      </part>
1095   </software>
1096
1097<!-- Requires VDP Unit emulation -->
1098   <software name="zanac" supported="no">
1097   <software name="zanac">
10991098      <description>Zanac</description>
11001099      <year>198?</year>
1101      <publisher>&lt;unknown&gt;</publisher>
1100      <publisher>A.I.</publisher>
1101      <info name="usage" value="Requires VDP unit in -ext1 expansion" />
11021102      <part name="cass" interface="spc1000_cass">
11031103         <dataarea name="cass" size="774330">
11041104            <rom name="vdp-zanac-mayhouse.tap" size="774330" crc="c4b6ea48" sha1="c6d85f1e43285d42b00d47cf69d14629520595c7" offset="0" />
r241485r241486
11061106      </part>
11071107   </software>
11081108
1109<!-- Requires VDP Unit emulation -->
1110   <software name="gunfrigh" supported="no">
1111      <description>Gun Fright</description>
1109   <software name="zexas">
1110      <description>Zexas</description>
11121111      <year>198?</year>
1113      <publisher>&lt;unknown&gt;</publisher>
1112      <publisher>Aloe?</publisher>
11141113      <part name="cass" interface="spc1000_cass">
1115         <dataarea name="cass" size="614352">
1116            <rom name="gunfright.tap" size="614352" crc="73cc58ef" sha1="ab09466a1cf2fc12faa2e18252e348b9cc56a7ff" offset="0" />
1114         <dataarea name="cass" size="702072">
1115            <rom name="zexas-5461-mayhouse.tap" size="702072" crc="9367b51e" sha1="d6da8e4ae2275dbd3ba1b9c7137944f5674daf26" offset="0" />
11171116         </dataarea>
11181117      </part>
11191118   </software>
trunk/src/emu/bus/bus.mak
r241485r241486
684684
685685#-------------------------------------------------
686686#
687#@src/emu/bus/spc1000/exp.h,BUSES += SPC1000
688#-------------------------------------------------
689
690ifneq ($(filter SPC1000,$(BUSES)),)
691OBJDIRS += $(BUSOBJ)/spc1000
692BUSOBJS += $(BUSOBJ)/spc1000/exp.o
693BUSOBJS += $(BUSOBJ)/spc1000/fdd.o
694BUSOBJS += $(BUSOBJ)/spc1000/vdp.o
695endif
696
697
698#-------------------------------------------------
699#
687700#@src/emu/bus/tvc/tvc.h,BUSES += TVC
688701#-------------------------------------------------
689702
trunk/src/emu/bus/spc1000/exp.c
r0r241486
1/***********************************************************************************************************
2
3    Samsung SPC-1000 Expansion port
4
5 ***********************************************************************************************************/
6
7
8#include "emu.h"
9#include "exp.h"
10
11//**************************************************************************
12//  GLOBAL VARIABLES
13//**************************************************************************
14
15const device_type SPC1000_EXP_SLOT = &device_creator<spc1000_exp_device>;
16
17
18device_spc1000_card_interface::device_spc1000_card_interface(const machine_config &mconfig, device_t &device)
19   : device_slot_card_interface(mconfig, device)
20{
21}
22
23
24device_spc1000_card_interface::~device_spc1000_card_interface()
25{
26}
27
28
29//**************************************************************************
30//  LIVE DEVICE
31//**************************************************************************
32
33//-------------------------------------------------
34//  spc1000_exp_device - constructor
35//-------------------------------------------------
36spc1000_exp_device::spc1000_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
37                  device_t(mconfig, SPC1000_EXP_SLOT, "Samsung SPC-1000 expansion", tag, owner, clock, "spc1000_exp", __FILE__),
38                  device_slot_interface(mconfig, *this)
39{
40}
41
42
43//-------------------------------------------------
44//  spc1000_exp_device - destructor
45//-------------------------------------------------
46
47spc1000_exp_device::~spc1000_exp_device()
48{
49}
50
51//-------------------------------------------------
52//  device_start - device-specific startup
53//-------------------------------------------------
54
55void spc1000_exp_device::device_start()
56{
57   m_card = dynamic_cast<device_spc1000_card_interface *>(get_card_device());
58}
59
60/*-------------------------------------------------
61 read
62 -------------------------------------------------*/
63
64READ8_MEMBER(spc1000_exp_device::read)
65{
66   if (m_card)
67      return m_card->read(space, offset);
68   else
69      return 0xff;
70}
71
72/*-------------------------------------------------
73 write
74 -------------------------------------------------*/
75
76WRITE8_MEMBER(spc1000_exp_device::write)
77{
78   if (m_card)
79      m_card->write(space, offset, data);
80}
trunk/src/emu/bus/spc1000/exp.h
r0r241486
1#ifndef __SCP1000_SLOT_H
2#define __SCP1000_SLOT_H
3
4// ======================> device_spc1000_card_interface
5
6class device_spc1000_card_interface : public device_slot_card_interface
7{
8public:
9   // construction/destruction
10   device_spc1000_card_interface(const machine_config &mconfig, device_t &device);
11   virtual ~device_spc1000_card_interface();
12
13   // reading and writing
14   virtual DECLARE_READ8_MEMBER(read) { return 0xff; }
15   virtual DECLARE_WRITE8_MEMBER(write) {}
16
17protected:
18};
19
20
21// ======================> spc1000_exp_device
22
23class spc1000_exp_device : public device_t,
24                        public device_slot_interface
25{
26public:
27   // construction/destruction
28   spc1000_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
29   virtual ~spc1000_exp_device();
30
31   // device-level overrides
32   virtual void device_start();
33
34   // reading and writing
35   virtual DECLARE_READ8_MEMBER(read);
36   virtual DECLARE_WRITE8_MEMBER(write);
37
38protected:
39
40   device_spc1000_card_interface*       m_card;
41};
42
43
44
45// device type definition
46extern const device_type SPC1000_EXP_SLOT;
47
48#endif
trunk/src/emu/bus/spc1000/fdd.c
r0r241486
1/***************************************************************************
2
3    SPC-1000 FDD unit
4
5***************************************************************************/
6
7#include "emu.h"
8#include "fdd.h"
9
10
11/***************************************************************************
12    IMPLEMENTATION
13***************************************************************************/
14
15READ8_MEMBER(spc1000_fdd_exp_device::i8255_c_r)
16{
17   return m_i8255_0_pc >> 4;
18}
19
20WRITE8_MEMBER(spc1000_fdd_exp_device::i8255_b_w)
21{
22   m_i8255_portb = data;
23}
24
25WRITE8_MEMBER(spc1000_fdd_exp_device::i8255_c_w)
26{
27   m_i8255_1_pc = data;
28}
29
30//-------------------------------------------------
31//  fdc interrupt
32//-------------------------------------------------
33
34READ8_MEMBER( spc1000_fdd_exp_device::tc_r )
35{
36   logerror("%s: tc_r\n", space.machine().describe_context());
37   
38   // toggle tc on read
39   m_fdc->tc_w(true);
40   m_timer_tc->adjust(attotime::zero);
41   
42   return 0xff;
43}
44
45WRITE8_MEMBER( spc1000_fdd_exp_device::control_w )
46{
47   logerror("%s: control_w(%02x)\n", space.machine().describe_context(), data);
48   
49   // bit 0, motor on signal
50   if (m_fd0)
51      m_fd0->mon_w(!BIT(data, 0));
52   if (m_fd1)
53      m_fd1->mon_w(!BIT(data, 0));
54}
55
56static ADDRESS_MAP_START( sd725_mem, AS_PROGRAM, 8, spc1000_fdd_exp_device )
57   ADDRESS_MAP_UNMAP_HIGH
58   AM_RANGE(0x0000, 0x1fff) AM_ROM
59   AM_RANGE(0x2000, 0xffff) AM_RAM
60ADDRESS_MAP_END
61
62static ADDRESS_MAP_START( sd725_io, AS_IO, 8, spc1000_fdd_exp_device )
63   ADDRESS_MAP_UNMAP_HIGH
64   ADDRESS_MAP_GLOBAL_MASK(0xff)
65   AM_RANGE(0xf8, 0xf8) AM_READWRITE(tc_r, control_w) // (R) Terminal Count Port (W) Motor Control Port
66   AM_RANGE(0xfa, 0xfb) AM_DEVICE("upd765", upd765a_device, map)
67   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE("d8255_master", i8255_device, read, write)
68ADDRESS_MAP_END
69
70static SLOT_INTERFACE_START( sd725_floppies )
71   SLOT_INTERFACE("sd320", EPSON_SD_320)
72SLOT_INTERFACE_END
73
74static MACHINE_CONFIG_FRAGMENT(spc1000_fdd)
75
76   /* sub CPU(5 inch floppy drive) */
77   MCFG_CPU_ADD("fdccpu", Z80, XTAL_4MHz)       /* 4 MHz */
78   MCFG_CPU_PROGRAM_MAP(sd725_mem)
79   MCFG_CPU_IO_MAP(sd725_io)
80
81   MCFG_DEVICE_ADD("d8255_master", I8255, 0)
82   MCFG_I8255_IN_PORTA_CB(DEVREAD8("d8255_master", i8255_device, pb_r))
83   MCFG_I8255_IN_PORTB_CB(DEVREAD8("d8255_master", i8255_device, pa_r))
84   MCFG_I8255_OUT_PORTB_CB(WRITE8(spc1000_fdd_exp_device, i8255_b_w))
85   MCFG_I8255_IN_PORTC_CB(READ8(spc1000_fdd_exp_device, i8255_c_r))
86   MCFG_I8255_OUT_PORTC_CB(WRITE8(spc1000_fdd_exp_device, i8255_c_w))
87
88   // floppy disk controller
89   MCFG_UPD765A_ADD("upd765", true, true)
90   MCFG_UPD765_INTRQ_CALLBACK(INPUTLINE("fdccpu", INPUT_LINE_IRQ0))
91
92   // floppy drives
93   MCFG_FLOPPY_DRIVE_ADD("upd765:0", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats)
94   MCFG_FLOPPY_DRIVE_ADD("upd765:1", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats)
95MACHINE_CONFIG_END
96
97//-------------------------------------------------
98//  device_mconfig_additions
99//-------------------------------------------------
100
101machine_config_constructor spc1000_fdd_exp_device::device_mconfig_additions() const
102{
103   return MACHINE_CONFIG_NAME( spc1000_fdd );
104}
105
106ROM_START( spc1000_fdd )
107   ROM_REGION(0x10000, "fdccpu", 0)
108   ROM_LOAD("sd725a.bin", 0x0000, 0x1000, CRC(96ac2eb8) SHA1(8e9d8f63a7fb87af417e95603e71cf537a6e83f1))
109ROM_END
110
111//-------------------------------------------------
112//  device_rom_region
113//-------------------------------------------------
114
115const rom_entry *spc1000_fdd_exp_device::device_rom_region() const
116{
117   return ROM_NAME( spc1000_fdd );
118}
119
120
121//**************************************************************************
122//  GLOBAL VARIABLES
123//**************************************************************************
124
125const device_type SPC1000_FDD_EXP = &device_creator<spc1000_fdd_exp_device>;
126
127//**************************************************************************
128//  LIVE DEVICE
129//**************************************************************************
130
131//-------------------------------------------------
132//  spc1000_fdd_exp_device - constructor
133//-------------------------------------------------
134
135spc1000_fdd_exp_device::spc1000_fdd_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
136      : device_t(mconfig, SPC1000_FDD_EXP, "SPC1000 FDD expansion", tag, owner, clock, "spc1000_fdd_exp", __FILE__),
137      device_spc1000_card_interface(mconfig, *this),
138      m_cpu(*this, "fdccpu"),
139      m_fdc(*this, "upd765"),
140      m_pio(*this, "d8255_master")
141{
142}
143
144
145//-------------------------------------------------
146//  device_start - device-specific startup
147//-------------------------------------------------
148
149void spc1000_fdd_exp_device::device_start()
150{
151   m_timer_tc = timer_alloc(TIMER_TC);
152   m_timer_tc->adjust(attotime::never);
153   
154   m_fd0 = subdevice<floppy_connector>("upd765:0")->get_device();
155   m_fd1 = subdevice<floppy_connector>("upd765:1")->get_device();
156}
157
158//-------------------------------------------------
159//  device_reset - device-specific reset
160//-------------------------------------------------
161
162void spc1000_fdd_exp_device::device_reset()
163{
164   m_cpu->set_input_line_vector(0, 0);
165
166   // enable rom (is this really needed? it does not seem necessary for FDD to work)
167   m_cpu->space(AS_PROGRAM).install_rom(0x0000, 0x0fff, 0, 0x2000, device().machine().root_device().memregion("fdccpu")->base());
168}
169
170void spc1000_fdd_exp_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
171{
172   switch (id)
173   {
174      case TIMER_TC:
175         m_fdc->tc_w(false);
176         break;
177   }
178}
179
180/*-------------------------------------------------
181    read
182-------------------------------------------------*/
183
184READ8_MEMBER(spc1000_fdd_exp_device::read)
185{
186   // this should be m_pio->read on the whole 0x00-0x03 range?
187   if (offset >= 3)
188      return 0xff;
189   else
190   {
191      UINT8 data = 0;
192      switch (offset)
193      {
194         case 1:
195            data = m_i8255_portb;
196            break;
197         case 2:
198            data = m_i8255_1_pc >> 4;
199            break;
200      }
201      return data;
202   }
203}
204
205//-------------------------------------------------
206//  write
207//-------------------------------------------------
208
209WRITE8_MEMBER(spc1000_fdd_exp_device::write)
210{
211   // this should be m_pio->write on the whole 0x00-0x03 range?
212   if (offset < 3)
213   {
214      switch (offset)
215      {
216         case 0:
217            m_pio->write(space, 1, data);
218            break;
219         case 2:
220            m_i8255_0_pc = data;
221            break;
222      }
223   }
224}
trunk/src/emu/bus/spc1000/fdd.h
r0r241486
1#ifndef __SPC1000_FDD_H__
2#define __SPC1000_FDD_H__
3
4#include "exp.h"
5#include "cpu/z80/z80.h"
6#include "machine/i8255.h"
7#include "machine/upd765.h"
8
9//**************************************************************************
10//  TYPE DEFINITIONS
11//**************************************************************************
12
13// ======================> spc1000_fdd_exp_device
14
15class spc1000_fdd_exp_device : public device_t,
16                  public device_spc1000_card_interface
17{
18public:
19   // construction/destruction
20   spc1000_fdd_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
21
22   // optional information overrides
23   virtual machine_config_constructor device_mconfig_additions() const;
24   virtual const rom_entry *device_rom_region() const;
25
26public:
27   // device-level overrides
28   virtual void device_start();
29   virtual void device_reset();
30
31   virtual DECLARE_READ8_MEMBER(read);
32   virtual DECLARE_WRITE8_MEMBER(write);
33
34   DECLARE_READ8_MEMBER(tc_r);
35   DECLARE_WRITE8_MEMBER(control_w);
36   DECLARE_WRITE8_MEMBER(i8255_b_w);
37   DECLARE_READ8_MEMBER(i8255_c_r);
38   DECLARE_WRITE8_MEMBER(i8255_c_w);
39   
40private:
41   // internal state
42   required_device<z80_device> m_cpu;
43   required_device<upd765a_device> m_fdc;
44   required_device<i8255_device> m_pio;
45
46   floppy_image_device *m_fd0;
47   floppy_image_device *m_fd1;
48
49   emu_timer *m_timer_tc;
50   
51   UINT8 m_i8255_0_pc;
52   UINT8 m_i8255_1_pc;
53   UINT8 m_i8255_portb;
54   
55   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
56   static const device_timer_id TIMER_TC = 0;
57};
58
59
60// device type definition
61extern const device_type SPC1000_FDD_EXP;
62
63#endif  /* __SPC1000_FDD_H__ */
trunk/src/emu/bus/spc1000/vdp.c
r0r241486
1/***************************************************************************
2
3    SPC-1000 VDP expansion unit
4
5***************************************************************************/
6
7#include "emu.h"
8#include "vdp.h"
9
10
11/***************************************************************************
12    IMPLEMENTATION
13***************************************************************************/
14
15WRITE_LINE_MEMBER(spc1000_vdp_exp_device::vdp_interrupt)
16{
17   // nothing here?
18}
19
20static MACHINE_CONFIG_FRAGMENT(scp1000_vdp)
21
22   MCFG_DEVICE_ADD("tms", TMS9928A, XTAL_10_738635MHz / 2)   // TODO: which clock?
23   MCFG_TMS9928A_VRAM_SIZE(0x4000)
24   MCFG_TMS9928A_OUT_INT_LINE_CB(WRITELINE(spc1000_vdp_exp_device, vdp_interrupt))
25   MCFG_TMS9928A_SCREEN_ADD_NTSC("tms_screen")
26   MCFG_SCREEN_UPDATE_DEVICE("tms", tms9928a_device, screen_update)
27MACHINE_CONFIG_END
28
29//-------------------------------------------------
30//  device_mconfig_additions
31//-------------------------------------------------
32
33machine_config_constructor spc1000_vdp_exp_device::device_mconfig_additions() const
34{
35   return MACHINE_CONFIG_NAME( scp1000_vdp );
36}
37
38
39//**************************************************************************
40//  GLOBAL VARIABLES
41//**************************************************************************
42
43const device_type SPC1000_VDP_EXP = &device_creator<spc1000_vdp_exp_device>;
44
45//**************************************************************************
46//  LIVE DEVICE
47//**************************************************************************
48
49//-------------------------------------------------
50//  spc1000_vdp_exp_device - constructor
51//-------------------------------------------------
52
53spc1000_vdp_exp_device::spc1000_vdp_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
54      : device_t(mconfig, SPC1000_VDP_EXP, "SPC1000 VDP expansion", tag, owner, clock, "spc1000_vdp_exp", __FILE__),
55         device_spc1000_card_interface(mconfig, *this),
56         m_vdp(*this, "tms")
57{
58}
59
60
61//-------------------------------------------------
62//  device_start - device-specific startup
63//-------------------------------------------------
64
65void spc1000_vdp_exp_device::device_start()
66{
67}
68
69//-------------------------------------------------
70//  device_reset - device-specific reset
71//-------------------------------------------------
72
73void spc1000_vdp_exp_device::device_reset()
74{
75}
76
77/*-------------------------------------------------
78    read
79-------------------------------------------------*/
80READ8_MEMBER(spc1000_vdp_exp_device::read)
81{
82   if (!(offset & 0x800))
83      return 0xff;
84
85   if (offset & 1)
86      return m_vdp->register_read(space, offset);
87   else
88      return m_vdp->vram_read(space, offset);
89}
90
91//-------------------------------------------------
92//  write
93//-------------------------------------------------
94
95WRITE8_MEMBER(spc1000_vdp_exp_device::write)
96{
97   if (offset & 0x800)
98   {
99      if (offset & 1)
100         m_vdp->register_write(space, offset, data);
101      else
102         m_vdp->vram_write(space, offset, data);
103   }
104}
trunk/src/emu/bus/spc1000/vdp.h
r0r241486
1#ifndef __SPC1000_VDP_H__
2#define __SPC1000_VDP_H__
3
4#include "exp.h"
5#include "video/tms9928a.h"
6
7
8//**************************************************************************
9//  TYPE DEFINITIONS
10//**************************************************************************
11
12// ======================> spc1000_vdp_exp_device
13
14class spc1000_vdp_exp_device : public device_t,
15                  public device_spc1000_card_interface
16{
17public:
18   // construction/destruction
19   spc1000_vdp_exp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
20
21   // optional information overrides
22   virtual machine_config_constructor device_mconfig_additions() const;
23
24public:
25   // device-level overrides
26   virtual void device_start();
27   virtual void device_reset();
28
29   virtual DECLARE_READ8_MEMBER(read);
30   virtual DECLARE_WRITE8_MEMBER(write);
31
32   DECLARE_WRITE_LINE_MEMBER(vdp_interrupt);
33   
34private:
35   // internal state
36   required_device<tms9928a_device>   m_vdp;
37};
38
39
40// device type definition
41extern const device_type SPC1000_VDP_EXP;
42
43#endif  /* __SPC1000_VDP_H__ */
trunk/src/mess/drivers/spc1000.c
r241485r241486
2929
3030#include "emu.h"
3131#include "cpu/z80/z80.h"
32#include "video/mc6847.h"
32#include "machine/ram.h"
3333#include "sound/ay8910.h"
3434#include "sound/wave.h"
35#include "video/mc6847.h"
3536#include "imagedev/cassette.h"
36#include "machine/ram.h"
3737#include "formats/spc1000_cas.h"
38#include "machine/i8255.h"
39#include "machine/upd765.h"
4038
39#include "bus/spc1000/exp.h"
40#include "bus/spc1000/fdd.h"
41#include "bus/spc1000/vdp.h"
4142
43
4244class spc1000_state : public driver_device
4345{
4446public:
4547   spc1000_state(const machine_config &mconfig, device_type type, const char *tag)
4648      : driver_device(mconfig, type, tag)
47      , m_p_videoram(*this, "videoram")
48      , m_vdg(*this, "mc6847")
4949      , m_maincpu(*this, "maincpu")
50      , m_fdccpu(*this, "fdccpu")
51      , m_fdc(*this, "upd765")
52      , m_pio(*this, "d8255_master")
53      , m_ram(*this, RAM_TAG)
50      , m_vdg(*this, "mc6847")
5451      , m_cass(*this, "cassette")
52      , m_ram(*this, RAM_TAG)
53      , m_p_videoram(*this, "videoram")
5554      , m_io_kb(*this, "LINE")
5655      , m_io_joy(*this, "JOY")
5756   {}
r241485r241486
6463   DECLARE_READ8_MEMBER(porta_r);
6564   DECLARE_READ8_MEMBER(mc6847_videoram_r);
6665   DECLARE_WRITE8_MEMBER(cass_w);
67   DECLARE_WRITE8_MEMBER(sd725_w);
68   DECLARE_READ8_MEMBER(sd725_r);
69   DECLARE_WRITE8_MEMBER(fdc_8255_b_w);
70   DECLARE_READ8_MEMBER(fdc_8255_c_r);
71   DECLARE_WRITE8_MEMBER(fdc_8255_c_w);
72   DECLARE_READ8_MEMBER(upd765_tc_r);
73   DECLARE_WRITE8_MEMBER(fdc_control_w);
7466   DECLARE_READ8_MEMBER(keyboard_r);
7567   MC6847_GET_CHARROM_MEMBER(get_char_rom)
7668   {
7769      return m_p_videoram[0x1000 + (ch & 0x7f) * 16 + line];
7870   }
7971
80   required_shared_ptr<UINT8> m_p_videoram;
8172private:
8273   UINT8 m_IPLK;
8374   UINT8 m_GMODE;
r241485r241486
8576   UINT8 *m_work_ram;
8677   virtual void machine_start();
8778   virtual void machine_reset();
79   required_device<z80_device> m_maincpu;
8880   required_device<mc6847_base_device> m_vdg;
89   required_device<cpu_device> m_maincpu;
90   required_device<cpu_device> m_fdccpu;
91   required_device<upd765a_device> m_fdc;
92   required_device<i8255_device> m_pio;
93   required_device<ram_device> m_ram;
9481   required_device<cassette_image_device> m_cass;
82   required_device<ram_device> m_ram;
83   required_shared_ptr<UINT8> m_p_videoram;
9584   required_ioport_array<10> m_io_kb;
9685   required_ioport m_io_joy;
97
98   floppy_image_device *m_fd0;
99   floppy_image_device *m_fd1;
100
101   emu_timer *m_timer_tc;
102
103   UINT8 m_i8255_0_pc;
104   UINT8 m_i8255_1_pc;
105   UINT8 m_i8255_portb;
106
107   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
10886};
10987
110void spc1000_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
111{
112   m_fdc->tc_w(false);
113}
114
11588static ADDRESS_MAP_START(spc1000_mem, AS_PROGRAM, 8, spc1000_state )
11689   ADDRESS_MAP_UNMAP_HIGH
11790   AM_RANGE(0x0000, 0x7fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank2")
r241485r241486
157130   return m_GMODE;
158131}
159132
160READ8_MEMBER(spc1000_state::sd725_r)
161{
162   UINT8 data = 0;
163   switch (offset)
164   {
165      case 1:
166         data = m_i8255_portb;
167         break;
168      case 2:
169         data = m_i8255_1_pc >> 4;
170         break;
171   }
172   return data;
173}
174
175WRITE8_MEMBER(spc1000_state::sd725_w)
176{
177   switch (offset)
178   {
179      case 0:
180         m_pio->write(space, offset+1, data);
181         break;
182      case 2:
183         m_i8255_0_pc = data;
184         break;
185   }
186}
187
188READ8_MEMBER(spc1000_state::fdc_8255_c_r)
189{
190   return m_i8255_0_pc >> 4;
191}
192
193WRITE8_MEMBER(spc1000_state::fdc_8255_b_w)
194{
195   m_i8255_portb = data;
196}
197
198WRITE8_MEMBER(spc1000_state::fdc_8255_c_w)
199{
200   m_i8255_1_pc = data;
201}
202
203//-------------------------------------------------
204//  fdc interrupt
205//-------------------------------------------------
206
207READ8_MEMBER( spc1000_state::upd765_tc_r )
208{
209   logerror("%s: upd765_tc_r\n", space.machine().describe_context());
210
211   // toggle tc on read
212   m_fdc->tc_w(true);
213   m_timer_tc->adjust(attotime::zero);
214
215   return 0xff;
216}
217
218WRITE8_MEMBER( spc1000_state::fdc_control_w )
219{
220   logerror("%s: sd725_fdc_control_w(%02x)\n", space.machine().describe_context(), data);
221
222   // bit 0, motor on signal
223   if (m_fd0)
224      m_fd0->mon_w(!BIT(data, 0));
225   if (m_fd1)
226      m_fd1->mon_w(!BIT(data, 0));
227}
228
229133READ8_MEMBER( spc1000_state::keyboard_r )
230134{
231135   // most games just read kb in $8000-$8009 but a few of them
r241485r241486
248152   AM_RANGE(0x6000, 0x6000) AM_WRITE(cass_w)
249153   AM_RANGE(0x8000, 0x9fff) AM_READ(keyboard_r)
250154   AM_RANGE(0xa000, 0xa000) AM_READWRITE(iplk_r, iplk_w)
251   AM_RANGE(0xc000, 0xc002) AM_READWRITE(sd725_r, sd725_w)
252//  AM_RANGE(0xc000, 0xc003) AM_DEVREADWRITE("d8255_master", i8255_device, read, write)
155   AM_RANGE(0xc000, 0xdfff) AM_DEVREADWRITE("ext1", spc1000_exp_device, read, write)
253156ADDRESS_MAP_END
254157
255158/* Input ports */
r241485r241486
385288
386289void spc1000_state::machine_reset()
387290{
388
389291   m_work_ram = auto_alloc_array_clear(machine(), UINT8, 0x10000);
390   m_fdccpu->set_input_line_vector(0, 0);
391
392   m_fd0 = machine().device<floppy_connector>("upd765:0")->get_device();
393   m_fd1 = machine().device<floppy_connector>("upd765:1")->get_device();
394
395   m_timer_tc = timer_alloc(1, NULL);
396   m_timer_tc->adjust(attotime::never);
397
398   // enable rom
399   m_fdccpu->space(AS_PROGRAM).install_rom(0x0000, 0xfff, 0, 0x2000, memregion("rom")->base());
400
401292   m_IPLK = 1;
402293}
403294
404295READ8_MEMBER(spc1000_state::mc6847_videoram_r)
405296{
406   if (offset == ~0) return 0xff;
297   if (offset == ~0)
298      return 0xff;
407299
408300   // m_GMODE layout: CSS|NA|PS2|PS1|~A/G|GM0|GM1|NA
409   if ( !BIT(m_GMODE, 3) )
301   if (!BIT(m_GMODE, 3))
410302   {   // text mode (~A/G set to A)
411      UINT8 data = m_p_videoram[offset+m_page+0x800];
303      UINT8 data = m_p_videoram[offset + m_page + 0x800];
412304      m_vdg->inv_w(BIT(data, 0));
413305      m_vdg->css_w(BIT(data, 1));
414306      m_vdg->as_w (BIT(data, 2));
415307      m_vdg->intext_w(BIT(data, 3));
416      return m_p_videoram[offset+m_page];
308      return m_p_videoram[offset + m_page];
417309   }
418310   else
419311   {    // graphics mode: uses full 6KB of VRAM
r241485r241486
437329   m_maincpu->set_input_line(0, state ? CLEAR_LINE : HOLD_LINE);
438330}
439331
440static SLOT_INTERFACE_START( sd725_floppies )
441   SLOT_INTERFACE( "sd320", EPSON_SD_320 )
442SLOT_INTERFACE_END
443
444332//-------------------------------------------------
445333//  address maps
446334//-------------------------------------------------
447335
448static ADDRESS_MAP_START( sd725_mem, AS_PROGRAM, 8, spc1000_state )
449   ADDRESS_MAP_UNMAP_HIGH
450   AM_RANGE(0x0000, 0x1fff) AM_ROM
451   AM_RANGE(0x2000, 0xffff) AM_RAM
452ADDRESS_MAP_END
336extern SLOT_INTERFACE_START(spc1000_exp)
337   SLOT_INTERFACE("fdd", SPC1000_FDD_EXP)
338   SLOT_INTERFACE("vdp", SPC1000_VDP_EXP)
339SLOT_INTERFACE_END
453340
454static ADDRESS_MAP_START( sd725_io, AS_IO, 8, spc1000_state )
455   ADDRESS_MAP_UNMAP_HIGH
456   ADDRESS_MAP_GLOBAL_MASK(0xff)
457   AM_RANGE(0xf8, 0xf8) AM_READWRITE(upd765_tc_r,fdc_control_w) // (R) Terminal Count Port (W) Motor Control Port
458   AM_RANGE(0xfa, 0xfb) AM_DEVICE("upd765", upd765a_device, map )
459   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE("d8255_master", i8255_device, read, write)
460ADDRESS_MAP_END
461
462341static MACHINE_CONFIG_START( spc1000, spc1000_state )
463342   /* basic machine hardware */
464343   MCFG_CPU_ADD("maincpu",Z80, XTAL_4MHz)
465344   MCFG_CPU_PROGRAM_MAP(spc1000_mem)
466345   MCFG_CPU_IO_MAP(spc1000_io)
467346
468   /* sub CPU(5 inch floppy drive) */
469   MCFG_CPU_ADD("fdccpu", Z80, XTAL_4MHz)       /* 4 MHz */
470   MCFG_CPU_PROGRAM_MAP(sd725_mem)
471   MCFG_CPU_IO_MAP(sd725_io)
472
473   MCFG_DEVICE_ADD("d8255_master", I8255, 0)
474   MCFG_I8255_IN_PORTA_CB(DEVREAD8("d8255_master", i8255_device, pb_r))
475   MCFG_I8255_IN_PORTB_CB(DEVREAD8("d8255_master", i8255_device, pa_r))
476   MCFG_I8255_OUT_PORTB_CB(WRITE8(spc1000_state, fdc_8255_b_w))
477   MCFG_I8255_IN_PORTC_CB(READ8(spc1000_state, fdc_8255_c_r))
478   MCFG_I8255_OUT_PORTC_CB(WRITE8(spc1000_state, fdc_8255_c_w))
479
480   // floppy disk controller
481   MCFG_UPD765A_ADD("upd765", true, true)
482   MCFG_UPD765_INTRQ_CALLBACK(INPUTLINE("fdccpu", INPUT_LINE_IRQ0))
483
484   // floppy drives
485   MCFG_FLOPPY_DRIVE_ADD("upd765:0", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats)
486   MCFG_FLOPPY_DRIVE_ADD("upd765:1", sd725_floppies, "sd320", floppy_image_device::default_floppy_formats)
487   //CFG_SOFTWARE_LIST_ADD("disk_list","spc1000_flop")
488
489347   /* video hardware */
490348   MCFG_SCREEN_MC6847_NTSC_ADD("screen", "mc6847")
491349
r241485r241486
504362   MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette")
505363   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
506364
507   MCFG_CASSETTE_ADD( "cassette" )
365   MCFG_DEVICE_ADD("ext1", SPC1000_EXP_SLOT, 0)
366   MCFG_DEVICE_SLOT_INTERFACE(spc1000_exp, NULL, false)
367
368   MCFG_CASSETTE_ADD("cassette")
508369   MCFG_CASSETTE_FORMATS(spc1000_cassette_formats)
509370   MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED | CASSETTE_MOTOR_ENABLED)
510371
r241485r241486
517378
518379/* ROM definition */
519380ROM_START( spc1000 )
520   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
521   ROM_LOAD( "spcall.rom", 0x0000, 0x8000, CRC(19638fc9) SHA1(489f1baa7aebf3c8c660325fb1fd790d84203284))
522
523   ROM_REGION( 0x10000, "fdccpu", 0)
524   ROM_LOAD("sd725a.bin", 0x0000, 0x1000, CRC(96ac2eb8) SHA1(8e9d8f63a7fb87af417e95603e71cf537a6e83f1))
381   ROM_REGION(0x10000, "maincpu", ROMREGION_ERASEFF)
382   ROM_LOAD("spcall.rom", 0x0000, 0x8000, CRC(19638fc9) SHA1(489f1baa7aebf3c8c660325fb1fd790d84203284))
525383ROM_END
526384
527385#if 0
528386ROM_START( spc1000 )
529   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
530   ROM_LOAD( "spcall.rom", 0x0000, 0x8000, CRC(2FBB6ECA) SHA1(cc9a076b0f00d54b2aec31f1f558b10f43ef61c8))
387   ROM_REGION(0x10000, "maincpu", ROMREGION_ERASEFF)
388   ROM_LOAD("spcall.rom", 0x0000, 0x8000, CRC(2FBB6ECA) SHA1(cc9a076b0f00d54b2aec31f1f558b10f43ef61c8))
531389   /// more roms to come...
532390ROM_END
533391#endif
trunk/src/mess/mess.mak
r241485r241486
625625BUSES += SMS_CTRL
626626BUSES += SMS_EXP
627627BUSES += SNES
628BUSES += SPC1000
628629BUSES += TI99PEB
629630BUSES += TVC
630631BUSES += VBOY


Previous 199869 Revisions Next


© 1997-2024 The MAME Team