Previous 199869 Revisions Next

r30886 Sunday 8th June, 2014 at 18:16:20 UTC by Sandro Ronco
segajw.c updates: [Sandro Ronco]
- Hooked up ACRTC
- Added inputs
- Added NVRAM support
[src/mame/drivers]segajw.c

trunk/src/mame/drivers/segajw.c
r30885r30886
2222#include "emu.h"
2323#include "cpu/m68000/m68000.h"
2424#include "cpu/z80/z80.h"
25//#include "video/hd63484.h"
25#include "machine/nvram.h"
26#include "video/h63484.h"
2627
2728class segajw_state : public driver_device
2829{
2930public:
3031   segajw_state(const machine_config &mconfig, device_type type, const char *tag)
3132      : driver_device(mconfig, type, tag),
32         m_maincpu(*this, "maincpu")
33         m_maincpu(*this, "maincpu"),
34         m_palette(*this, "palette")
3335   { }
3436
35   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
37   DECLARE_READ16_MEMBER(coin_counter_r);
38   DECLARE_WRITE16_MEMBER(coin_counter_w);
39   DECLARE_READ16_MEMBER(hopper_r);
40   DECLARE_WRITE16_MEMBER(hopper_w);
41   DECLARE_READ16_MEMBER(coinlockout_r);
42   DECLARE_WRITE16_MEMBER(coinlockout_w);
43   DECLARE_READ16_MEMBER(soundboard_r);
44   DECLARE_WRITE8_MEMBER(ramdac_io_w);
45   DECLARE_INPUT_CHANGED_MEMBER(coin_drop_start);
46   DECLARE_CUSTOM_INPUT_MEMBER(coin_sensors_r);
47   DECLARE_CUSTOM_INPUT_MEMBER(hopper_sensors_r);
3648
3749protected:
3850
3951   // devices
4052   required_device<cpu_device> m_maincpu;
53   required_device<palette_device> m_palette;
4154
4255   // driver_device overrides
4356   virtual void machine_start();
4457   virtual void machine_reset();
45   virtual void video_start();
58   struct { int r,g,b,offs,offs_internal; } m_pal;
59   UINT64      m_coin_start_cycles;
60   UINT64      m_hopper_start_cycles;
61   UINT8       m_coin_counter;
62   UINT16      m_coin_lockout;
63   UINT8       m_hopper_ctrl;
4664};
4765
4866
49void segajw_state::video_start()
67READ16_MEMBER(segajw_state::coin_counter_r)
5068{
69   return m_coin_counter ^ 0xff;
5170}
5271
53UINT32 segajw_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
72WRITE16_MEMBER(segajw_state::coin_counter_w)
5473{
55   return 0;
74   if(ACCESSING_BITS_0_7)
75      m_coin_counter = data;
5676}
5777
78READ16_MEMBER(segajw_state::hopper_r)
79{
80   return m_hopper_ctrl;
81}
5882
83WRITE16_MEMBER(segajw_state::hopper_w)
84{
85   if(ACCESSING_BITS_0_7)
86   {
87      m_hopper_start_cycles = data & 0x02 ? 0 : m_maincpu->total_cycles();
88      m_hopper_ctrl = data;
89   }
90}
91
92READ16_MEMBER(segajw_state::coinlockout_r)
93{
94   return m_coin_lockout;
95}
96
97WRITE16_MEMBER(segajw_state::coinlockout_w)
98{
99   coin_lockout_w(machine(), 0, data & 1);
100   m_coin_lockout = data;
101}
102
103
104READ16_MEMBER(segajw_state::soundboard_r)
105{
106   // TODO: to replace with proper sound emulation
107   return 0xfff0;  // value expected for pass the sound board test
108}
109
110WRITE8_MEMBER(segajw_state::ramdac_io_w)
111{
112   // copied from adp.c
113   switch(offset)
114   {
115      case 0:
116         m_pal.offs = data;
117         m_pal.offs_internal = 0;
118         break;
119      case 2:
120         //mask pen reg
121         break;
122      case 1:
123         switch(m_pal.offs_internal)
124         {
125            case 0:
126               m_pal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
127               m_pal.offs_internal++;
128               break;
129            case 1:
130               m_pal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
131               m_pal.offs_internal++;
132               break;
133            case 2:
134               m_pal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
135               m_palette->set_pen_color(m_pal.offs, rgb_t(m_pal.r, m_pal.g, m_pal.b));
136               m_pal.offs_internal = 0;
137               m_pal.offs++;
138               m_pal.offs&=0xff;
139               break;
140         }
141
142         break;
143   }
144}
145
146INPUT_CHANGED_MEMBER( segajw_state::coin_drop_start )
147{
148   if (newval && !m_coin_start_cycles)
149      m_coin_start_cycles = m_maincpu->total_cycles();
150}
151
152CUSTOM_INPUT_MEMBER( segajw_state::hopper_sensors_r )
153{
154   UINT8 data = 0;
155
156   // if the hopper is active simulate the coin-out sensor
157   if (m_hopper_start_cycles)
158   {
159      attotime diff = m_maincpu->cycles_to_attotime(m_maincpu->total_cycles() - m_hopper_start_cycles);
160
161      if (diff > attotime::from_msec(100))
162         data |= 0x01;
163
164      if (diff > attotime::from_msec(200))
165         m_hopper_start_cycles = m_maincpu->total_cycles();
166   }
167
168   return data;
169}
170
171CUSTOM_INPUT_MEMBER( segajw_state::coin_sensors_r )
172{
173   UINT8 data = 0;
174
175   // simulates the passage of coins through multiple sensors
176   if (m_coin_start_cycles)
177   {
178      attotime diff = m_maincpu->cycles_to_attotime(m_maincpu->total_cycles() - m_coin_start_cycles);
179
180      if (diff > attotime::from_msec(20) && diff < attotime::from_msec(100))
181         data |= 0x01;
182      if (diff > attotime::from_msec(80) && diff < attotime::from_msec(200))
183         data |= 0x02;
184      if (diff <= attotime::from_msec(100))
185         data |= 0x04;
186
187      if (diff > attotime::from_msec(200))
188         m_coin_start_cycles = 0;
189   }
190
191   return data;
192}
193
59194static ADDRESS_MAP_START( segajw_map, AS_PROGRAM, 16, segajw_state )
60195   AM_RANGE(0x000000, 0x03ffff) AM_ROM
61196
62//  AM_RANGE(0x080000, 0x080001) AM_DEVREADWRITE("hd63484", hd63484_device, status_r, address_w)
63//  AM_RANGE(0x080002, 0x080003) AM_DEVREADWRITE("hd63484", hd63484_device, data_r, data_w)
197   AM_RANGE(0x080000, 0x080001) AM_DEVREADWRITE("hd63484", h63484_device, status_r, address_w)
198   AM_RANGE(0x080002, 0x080003) AM_DEVREADWRITE("hd63484", h63484_device, data_r, data_w)
64199
200   AM_RANGE(0x180000, 0x180001) AM_READ_PORT("DSW0")
201   AM_RANGE(0x180004, 0x180005) AM_READ(soundboard_r)
202   AM_RANGE(0x180008, 0x180009) AM_READ_PORT("DSW1")
203   AM_RANGE(0x18000a, 0x18000b) AM_READ_PORT("DSW3")
204   AM_RANGE(0x18000c, 0x18000d) AM_READ_PORT("DSW2")
205
206   AM_RANGE(0x1a0000, 0x1a0001) AM_WRITE(coin_counter_w)
207   AM_RANGE(0x1a0006, 0x1a0007) AM_READWRITE(hopper_r, hopper_w)
208   AM_RANGE(0x1a000a, 0x1a000b) AM_READ(coin_counter_r)
209
65210   AM_RANGE(0x1a000e, 0x1a000f) AM_NOP
66   AM_RANGE(0xff0000, 0xffffff) AM_RAM
211
212   AM_RANGE(0x1c0000, 0x1c0001) AM_READ_PORT("IN0")
213   AM_RANGE(0x1c0002, 0x1c0003) AM_READ_PORT("IN1")
214   AM_RANGE(0x1c0004, 0x1c0005) AM_READ_PORT("IN2")
215   AM_RANGE(0x1c0006, 0x1c0007) AM_READ_PORT("IN3")
216   AM_RANGE(0x1c000c, 0x1c000d) AM_READWRITE(coinlockout_r, coinlockout_w)
217
218   AM_RANGE(0x280000, 0x280007) AM_WRITE8(ramdac_io_w, 0x00ff)
219
220   AM_RANGE(0xff0000, 0xffffff) AM_RAM AM_SHARE("nvram")
67221ADDRESS_MAP_END
68222
223static ADDRESS_MAP_START( segajw_audiocpu_map, AS_PROGRAM, 8, segajw_state )
224   AM_RANGE(0x0000, 0x7fff) AM_ROM
225   AM_RANGE(0xe000, 0xffff) AM_RAM
226ADDRESS_MAP_END
69227
228static ADDRESS_MAP_START( segajw_audiocpu_io_map, AS_IO, 8, segajw_state )
229   ADDRESS_MAP_GLOBAL_MASK(0xff)
230ADDRESS_MAP_END
231
232static ADDRESS_MAP_START( segajw_hd63484_map, AS_0, 16, segajw_state )
233   AM_RANGE(0x00000, 0x3ffff) AM_RAM
234   AM_RANGE(0x80000, 0xbffff) AM_ROM AM_REGION("gfx1", 0)
235ADDRESS_MAP_END
236
237
70238static INPUT_PORTS_START( segajw )
239   PORT_START("IN0")
240   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )
241   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
242   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_POKER_HOLD3 )
243   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_POKER_HOLD4 )
244   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_POKER_HOLD5 )
245   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_GAMBLE_BET )   PORT_NAME("1 Bet")
246   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 )      PORT_NAME("Max Bet")
247   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON1 )      PORT_NAME("Deal / Draw")
248
249   PORT_START("IN1")
250   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 )      PORT_NAME("Double")
251   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
252   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON4 )      PORT_NAME("Change")
253   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE )
254   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_OTHER )        PORT_NAME("Reset")     PORT_CODE(KEYCODE_R)
255   PORT_BIT( 0x000d, IP_ACTIVE_HIGH, IPT_UNUSED )
256
257   PORT_START("IN2")
258   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_GAMBLE_SERVICE ) PORT_NAME("Meter")
259   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_OTHER )          PORT_NAME("Last Game")   PORT_CODE(KEYCODE_T)
260   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_OTHER )          PORT_NAME("M-Door")
261   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_OTHER )          PORT_NAME("D-Door")
262   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_SPECIAL )       PORT_CUSTOM_MEMBER(DEVICE_SELF, segajw_state, hopper_sensors_r, NULL)
263   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_OTHER )          PORT_NAME("Hopper Full")
264   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_OTHER )          PORT_NAME("Hopper Fill")
265   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED )
266
267   PORT_START("IN3")
268   PORT_BIT( 0x0007, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, segajw_state, coin_sensors_r, NULL)
269   PORT_BIT( 0x00f8, IP_ACTIVE_HIGH, IPT_UNUSED )
270
271   PORT_START("COIN1") // start the coin drop sequence (see coin_sensors_r)
272   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )   PORT_CHANGED_MEMBER(DEVICE_SELF, segajw_state, coin_drop_start, NULL)
273
274   PORT_START("DSW0")
275   PORT_DIPNAME( 0x0001, 0x0000, "DSW0-1" )
276   PORT_DIPSETTING(    0x0001, DEF_STR( Off ) )
277   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
278   PORT_DIPNAME( 0x0002, 0x0000, "DSW0-2" )
279   PORT_DIPSETTING(    0x0002, DEF_STR( Off ) )
280   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
281   PORT_DIPNAME( 0x0004, 0x0000, "DSW0-3" )
282   PORT_DIPSETTING(    0x0004, DEF_STR( Off ) )
283   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
284   PORT_DIPNAME( 0x0008, 0x0000, "DSW0-4" )
285   PORT_DIPSETTING(    0x0008, DEF_STR( Off ) )
286   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
287   PORT_DIPNAME( 0x0010, 0x0000, "DSW0-5" )
288   PORT_DIPSETTING(    0x0010, DEF_STR( Off ) )
289   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
290   PORT_DIPNAME( 0x0020, 0x0000, "DSW0-6" )
291   PORT_DIPSETTING(    0x0020, DEF_STR( Off ) )
292   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
293   PORT_DIPNAME( 0x0040, 0x0000, "DSW0-7" )
294   PORT_DIPSETTING(    0x0040, DEF_STR( Off ) )
295   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
296   PORT_DIPNAME( 0x0080, 0x0000, "DSW0-8" )
297   PORT_DIPSETTING(    0x0080, DEF_STR( Off ) )
298   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
299
300   PORT_START("DSW1")
301   PORT_DIPNAME( 0x0001, 0x0000, "DSW1-1" )
302   PORT_DIPSETTING(    0x0001, DEF_STR( Off ) )
303   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
304   PORT_DIPNAME( 0x0002, 0x0000, "DSW1-2" )
305   PORT_DIPSETTING(    0x0002, DEF_STR( Off ) )
306   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
307   PORT_DIPNAME( 0x0004, 0x0000, "DSW1-3" )
308   PORT_DIPSETTING(    0x0004, DEF_STR( Off ) )
309   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
310   PORT_DIPNAME( 0x0008, 0x0000, "DSW1-4" )
311   PORT_DIPSETTING(    0x0008, DEF_STR( Off ) )
312   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
313   PORT_DIPNAME( 0x0010, 0x0000, "DSW1-5" )
314   PORT_DIPSETTING(    0x0010, DEF_STR( Off ) )
315   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
316   PORT_DIPNAME( 0x0020, 0x0000, "DSW1-6" )
317   PORT_DIPSETTING(    0x0020, DEF_STR( Off ) )
318   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
319   PORT_DIPNAME( 0x0040, 0x0000, "DSW1-7" )
320   PORT_DIPSETTING(    0x0040, DEF_STR( Off ) )
321   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
322   PORT_DIPNAME( 0x0080, 0x0000, "DSW1-8" )
323   PORT_DIPSETTING(    0x0080, DEF_STR( Off ) )
324   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
325
326   PORT_START("DSW2")
327   PORT_DIPNAME( 0x0001, 0x0000, "DSW2-1" )
328   PORT_DIPSETTING(    0x0001, DEF_STR( Off ) )
329   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
330   PORT_DIPNAME( 0x0002, 0x0000, "DSW2-2" )
331   PORT_DIPSETTING(    0x0002, DEF_STR( Off ) )
332   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
333   PORT_DIPNAME( 0x0004, 0x0000, "DSW2-3" )
334   PORT_DIPSETTING(    0x0004, DEF_STR( Off ) )
335   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
336   PORT_DIPNAME( 0x0008, 0x0000, "DSW2-4" )
337   PORT_DIPSETTING(    0x0008, DEF_STR( Off ) )
338   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
339   PORT_DIPNAME( 0x0010, 0x0000, "DSW2-5" )
340   PORT_DIPSETTING(    0x0010, DEF_STR( Off ) )
341   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
342   PORT_DIPNAME( 0x0020, 0x0000, "DSW2-6" )
343   PORT_DIPSETTING(    0x0020, DEF_STR( Off ) )
344   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
345   PORT_DIPNAME( 0x0040, 0x0000, "DSW2-7" )
346   PORT_DIPSETTING(    0x0040, DEF_STR( Off ) )
347   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
348   PORT_DIPNAME( 0x0080, 0x0000, "DSW2-8" )
349   PORT_DIPSETTING(    0x0080, DEF_STR( Off ) )
350   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
351
352   PORT_START("DSW3")
353   PORT_DIPNAME( 0x0001, 0x0001, "DSW3-1" )
354   PORT_DIPSETTING(    0x0001, DEF_STR( Off ) )
355   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
356   PORT_DIPNAME( 0x0002, 0x0002, "DSW3-2" )
357   PORT_DIPSETTING(    0x0002, DEF_STR( Off ) )
358   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
359   PORT_DIPNAME( 0x0004, 0x0004, "DSW3-3" )
360   PORT_DIPSETTING(    0x0004, DEF_STR( Off ) )
361   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
362   PORT_DIPNAME( 0x0008, 0x0000, "DSW3-4" )
363   PORT_DIPSETTING(    0x0008, DEF_STR( Off ) )
364   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
365   PORT_DIPNAME( 0x0010, 0x0000, "DSW3-5" )
366   PORT_DIPSETTING(    0x0010, DEF_STR( Off ) )
367   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
368   PORT_DIPNAME( 0x0020, 0x0000, "DSW3-6" )
369   PORT_DIPSETTING(    0x0020, DEF_STR( Off ) )
370   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
371   PORT_DIPNAME( 0x0040, 0x0000, "DSW3-7" )
372   PORT_DIPSETTING(    0x0040, DEF_STR( Off ) )
373   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
374   PORT_DIPNAME( 0x0080, 0x0000, "DSW3-8" )
375   PORT_DIPSETTING(    0x0080, DEF_STR( Off ) )
376   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
71377INPUT_PORTS_END
72378
73379
r30885r30886
78384
79385void segajw_state::machine_reset()
80386{
387   m_coin_start_cycles = 0;
388   m_hopper_start_cycles = 0;
389   m_coin_counter = 0xff;
390   m_coin_lockout = 0;
391   m_hopper_ctrl = 0;
81392}
82393
83394static MACHINE_CONFIG_START( segajw, segajw_state )
r30885r30886
85396   MCFG_CPU_ADD("maincpu",M68000,8000000) // unknown clock
86397   MCFG_CPU_PROGRAM_MAP(segajw_map)
87398   MCFG_CPU_VBLANK_INT_DRIVER("screen", segajw_state, irq4_line_hold)
399   MCFG_CPU_PERIODIC_INT_DRIVER(segajw_state, irq5_line_hold, 300)    // FIXME: unknown source, but vblank is too slow
88400
401   MCFG_CPU_ADD("audiocpu", Z80, 4000000) // unknown clock
402   MCFG_CPU_PROGRAM_MAP(segajw_audiocpu_map)
403   MCFG_CPU_IO_MAP(segajw_audiocpu_io_map)
404   MCFG_DEVICE_DISABLE()
405
406   MCFG_NVRAM_ADD_NO_FILL("nvram")
407
89408   /* video hardware */
90409   MCFG_SCREEN_ADD("screen", RASTER)
91410   MCFG_SCREEN_REFRESH_RATE(60)
92411   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
93   MCFG_SCREEN_UPDATE_DRIVER(segajw_state, screen_update)
94   MCFG_SCREEN_SIZE(32*8, 32*8)
95   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
412   MCFG_SCREEN_UPDATE_DEVICE("hd63484", h63484_device, update_screen)
413   MCFG_SCREEN_SIZE(720, 480)
414   MCFG_SCREEN_VISIBLE_AREA(0, 720-1, 0, 448-1)
96415   MCFG_SCREEN_PALETTE("palette")
97416
98417   MCFG_PALETTE_ADD("palette", 16)
99418
419   MCFG_H63484_ADD("hd63484", 8000000, segajw_hd63484_map) // unknown clock
420
100421   /* sound hardware */
101422   MCFG_SPEAKER_STANDARD_MONO("mono")
102423//  MCFG_SOUND_ADD("aysnd", AY8910, MAIN_CLOCK/4) /* guess */
r30885r30886
117438   ROM_REGION( 0x20000, "audiocpu", 0 )
118439   ROM_LOAD( "14587a.epr",   0x00000, 0x20000, CRC(66163b6c) SHA1(88e994bcad86c58dc730a93b48226e9296df7667) )
119440
120   ROM_REGION( 0x80000, "gfx1", 0 )
121   ROM_LOAD( "14586.epr",   0x00000, 0x80000, CRC(daeb0616) SHA1(17a8bb7137ad46a7c3ac07d22cbc4430e76e2f71) )
441   ROM_REGION16_BE( 0x80000, "gfx1", 0 )
442   ROM_LOAD16_WORD_SWAP( "14586.epr",   0x00000, 0x80000, CRC(daeb0616) SHA1(17a8bb7137ad46a7c3ac07d22cbc4430e76e2f71) )
122443ROM_END
123444
124445

Previous 199869 Revisions Next


© 1997-2024 The MAME Team