Previous 199869 Revisions Next

r22022 Friday 22nd March, 2013 at 08:28:41 UTC by Fabio Priuli
another global variable removed + cleanup. nw.
[src/mame/machine]megacd.c megacd.h

trunk/src/mame/machine/megacd.c
r22021r22022
44#include "sound/rf5c68.h"
55
66
7// not in the state because the IRQ_CALLBACK needs it, and that can't be a member function?
8UINT16 a12000_halt_reset_reg = 0x0000;
9
107/* Callback when the genesis enters interrupt code */
11// needs to be a member
128IRQ_CALLBACK_MEMBER(sega_segacd_device::segacd_sub_int_callback)
139{
1410   if (irqline==2)
1511   {
1612      // clear this bit
17      a12000_halt_reset_reg &= ~0x0100;
18      device.machine().device(":segacd:segacd_68k")->execute().set_input_line(2, CLEAR_LINE);
13      m_a12000_halt_reset_reg &= ~0x0100;
14      m_scdcpu->set_input_line(2, CLEAR_LINE);
1915   }
2016
2117   return (0x60+irqline*4)/4; // vector address
2218}
2319
2420
25
26
2721const device_type SEGA_SEGACD_US = &device_creator<sega_segacd_us_device>;
2822const device_type SEGA_SEGACD_JAPAN = &device_creator<sega_segacd_japan_device>;
2923const device_type SEGA_SEGACD_EUROPE = &device_creator<sega_segacd_europe_device>;
3024
3125sega_segacd_device::sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type)
32   : device_t(mconfig, type, "sega_segacd_device", tag, owner, clock)
26   : device_t(mconfig, type, "sega_segacd_device", tag, owner, clock),
27      m_scdcpu(*this, "segacd_68k")
3328{
3429}
3530
r22021r22022
137132   MCFG_TIMER_DRIVER_ADD("scd_dma_timer", sega_segacd_device, scd_dma_timer_callback)
138133
139134
140
141135   MCFG_DEFAULT_LAYOUT( layout_megacd )
142136
143137
144
145138   MCFG_RF5C68_ADD("rfsnd", SEGACD_CLOCK) // RF5C164!
146139   MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 )
147140   MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 )
r22021r22022
165158
166159
167160
168
169
170
171
172161inline void sega_segacd_device::write_pixel(running_machine& machine, UINT8 pix, int pixeloffset )
173162{
174163   int shift = 12-(4*(pixeloffset&0x3));
r22021r22022
292281
293282WRITE16_MEMBER( sega_segacd_device::scd_a12000_halt_reset_w )
294283{
295   UINT16 old_halt = a12000_halt_reset_reg;
284   UINT16 old_halt = m_a12000_halt_reset_reg;
296285
297   COMBINE_DATA(&a12000_halt_reset_reg);
286   COMBINE_DATA(&m_a12000_halt_reset_reg);
298287
299288   if (ACCESSING_BITS_0_7)
300289   {
301290      // reset line
302      if (a12000_halt_reset_reg&0x0001)
291      if (m_a12000_halt_reset_reg & 0x0001)
303292      {
304         space.machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
293         m_scdcpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
305294         if (!(old_halt&0x0001)) printf("clear reset slave\n");
306295      }
307296      else
308297      {
309         space.machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
298         m_scdcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
310299         if ((old_halt&0x0001)) printf("assert reset slave\n");
311300      }
312301
313302      // request BUS
314      if (a12000_halt_reset_reg&0x0002)
303      if (m_a12000_halt_reset_reg & 0x0002)
315304      {
316         space.machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
305         m_scdcpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
317306         if (!(old_halt&0x0002)) printf("halt slave\n");
318307      }
319308      else
320309      {
321         space.machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
310         m_scdcpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
322311         if ((old_halt&0x0002)) printf("resume slave\n");
323312      }
324313   }
325314
326315   if (ACCESSING_BITS_8_15)
327316   {
328      if (a12000_halt_reset_reg&0x0100)
317      if (m_a12000_halt_reset_reg & 0x0100)
329318      {
330319         running_machine& machine = space.machine();
331320         CHECK_SCD_LV2_INTERRUPT
332321      }
333322
334      if (a12000_halt_reset_reg&0x8000)
323      if (m_a12000_halt_reset_reg & 0x8000)
335324      {
336325         // not writable.. but can read irq mask here?
337         //printf("a12000_halt_reset_reg & 0x8000 set\n"); // irq2 mask?
326         //printf("m_a12000_halt_reset_reg & 0x8000 set\n"); // irq2 mask?
338327      }
339328
340329
r22021r22022
343332
344333READ16_MEMBER( sega_segacd_device::scd_a12000_halt_reset_r )
345334{
346   return a12000_halt_reset_reg;
335   return m_a12000_halt_reset_reg;
347336}
348337
349338
r22021r22022
15621551
15631552void sega_segacd_device::device_start()
15641553{
1565   _segacd_68k_cpu = machine().device<cpu_device>(":segacd:segacd_68k");
1566
15671554   segacd_gfx_conversion_timer = machine().device<timer_device>(":segacd:stamp_timer");
15681555   segacd_irq3_timer = machine().device<timer_device>(":segacd:irq3_timer");
15691556   scd_dma_timer = machine().device<timer_device>(":segacd:scd_dma_timer");
r22021r22022
16031590
16041591
16051592
1606   machine().device(":segacd:segacd_68k")->execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(sega_segacd_device::segacd_sub_int_callback),this));
1593   m_scdcpu->set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(sega_segacd_device::segacd_sub_int_callback),this));
16071594
16081595   space.install_read_handler (0x0000070, 0x0000073, read16_delegate(FUNC(sega_segacd_device::scd_hint_vector_r),this) );
16091596
r22021r22022
16501637
16511638void sega_segacd_device::device_reset()
16521639{
1653   _segacd_68k_cpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
1654   _segacd_68k_cpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
1640   m_scdcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
1641   m_scdcpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
16551642
16561643   segacd_hint_register = 0xffff; // -1
16571644
1645   m_a12000_halt_reset_reg = 0x0000;
16581646
1659
16601647   scd_rammode = 0;
16611648   scd_mode_dmna_ret_flags = 0x5421;
16621649
r22021r22022
16751662   // time.  Changing the CDHock timer to 50hz from 75hz also stops the hang, but then the video is
16761663   // too slow and has bad sound.  -- Investigate!
16771664
1678   _segacd_68k_cpu->set_clock_scale(1.5000f);
1665   m_scdcpu->set_clock_scale(1.5000f);
16791666
16801667
16811668   // initialize some stuff on reset
trunk/src/mame/machine/megacd.h
r22021r22022
193193   _32x32_SEQUENCE_1_FLIP
194194_32x32_END
195195
196extern UINT16 a12000_halt_reset_reg;
197196
198197
199
200
201
202
203
204198class sega_segacd_device : public device_t
205199{
206200public:
207201   sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type);
208202
209   cpu_device *_segacd_68k_cpu;
203   required_device<cpu_device> m_scdcpu;
210204   lc89510_temp_device *lc89510_temp;
211205
212206   UINT16 *segacd_backupram;
r22021r22022
265259   DECLARE_WRITE16_MEMBER( segacd_dmaaddr_w );
266260   UINT16 m_dmaaddr;
267261
262   UINT16 m_a12000_halt_reset_reg;
268263
269
270264   void segacd_mark_tiles_dirty(running_machine& machine, int offset);
271265   int segacd_get_active_stampmap_tilemap(void);
272266

Previous 199869 Revisions Next


© 1997-2024 The MAME Team