Previous 199869 Revisions Next

r17952 Sunday 16th September, 2012 at 21:57:13 UTC by Tafoid
In preparation for future work (basic device structure).  Should have no functional change at this point.  From Haze (nw)
[src/mame]mame.mak
[src/mame/includes]megadriv.h
[src/mame/machine]megacd.c megacd.h* megadriv.c

trunk/src/mame/machine/megadriv.c
r17951r17952
3737#include "cpu/sh2/sh2comn.h"
3838#include "cpu/z80/z80.h"
3939#include "sound/2612intf.h"
40#include "sound/cdda.h"
40
4141#include "sound/dac.h"
42#include "sound/rf5c68.h"
42
4343#include "sound/sn76496.h"
4444#include "imagedev/chd_cd.h"
4545#include "includes/megadriv.h"
4646#include "machine/nvram.h"
4747#include "cpu/ssp1601/ssp1601.h"
48#include "megacd.lh"
4948
5049#include "machine/megavdp.h"
5150
r17951r17952
13021301
13031302
13041303MACHINE_CONFIG_DERIVED( genesis_scd, megadriv )
1305   MCFG_NVRAM_HANDLER_CLEAR()
1306   MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
1307   MCFG_CPU_PROGRAM_MAP(segacd_map)
1308
1309   MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer
1310
1311   MCFG_DEFAULT_LAYOUT( layout_megacd )
1312
1313   MCFG_NVRAM_ADD_0FILL("backupram")
1314
1315   MCFG_SOUND_ADD( "cdda", CDDA, 0 )
1316   MCFG_SOUND_ROUTE( 0, "lspeaker", 0.50 ) // TODO: accurate volume balance
1317   MCFG_SOUND_ROUTE( 1, "rspeaker", 0.50 )
1318
1319   MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164!
1320   MCFG_SOUND_ROUTE( 0, "lspeaker", 0.50 )
1321   MCFG_SOUND_ROUTE( 1, "rspeaker", 0.50 )
1322
1323   MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback)
1324
1325   MCFG_QUANTUM_PERFECT_CPU("segacd_68k") // perfect sync to the fastest cpu
1304   MCFG_DEVICE_ADD("segacd", SEGA_SEGACD_US, 0)
13261305MACHINE_CONFIG_END
13271306
13281307struct cdrom_interface scd_cdrom =
r17951r17952
13491328
13501329MACHINE_CONFIG_DERIVED( genesis_32x_scd, genesis_32x )
13511330
1352   MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
1353   MCFG_CPU_PROGRAM_MAP(segacd_map)
1354
1355   MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer
1356   MCFG_NVRAM_ADD_0FILL("backupram")
1357   MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback)
1358
1359   MCFG_DEFAULT_LAYOUT( layout_megacd )
1360
1361   MCFG_SOUND_ADD( "cdda", CDDA, 0 )
1362   MCFG_SOUND_ROUTE( 0, "lspeaker", 0.50 )
1363   MCFG_SOUND_ROUTE( 1, "rspeaker", 0.50 )
1364
1365   MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164
1366   MCFG_SOUND_ROUTE( 0, "lspeaker", 0.25 )
1367   MCFG_SOUND_ROUTE( 1, "rspeaker", 0.25 )
1368
1369   MCFG_CDROM_ADD( "cdrom", scd_cdrom)
1370   MCFG_SOFTWARE_LIST_ADD("cd_list","segacd")
1371
1331   MCFG_DEVICE_ADD("segacd", SEGA_SEGACD_US, 0)
13721332   //MCFG_QUANTUM_PERFECT_CPU("32x_master_sh2")
13731333MACHINE_CONFIG_END
13741334
r17951r17952
14101370
14111371   sega_cd_connected = 0;
14121372   segacd_wordram_mapped = 0;
1413   _segacd_68k_cpu = machine.device<cpu_device>("segacd_68k");
1373   _segacd_68k_cpu = machine.device<cpu_device>(":segacd:segacd_68k");
14141374   if (_segacd_68k_cpu != NULL)
14151375   {
14161376      printf("Sega CD secondary 68k cpu found '%s'\n", _segacd_68k_cpu->tag() );
14171377      sega_cd_connected = 1;
14181378      segacd_init_main_cpu(machine);
1419      scd_dma_timer = machine.device<timer_device>("scd_dma_timer");
1379      scd_dma_timer = machine.device<timer_device>(":segacd:scd_dma_timer");
14201380
14211381   }
14221382
trunk/src/mame/machine/megacd.c
r17951r17952
11
22#include "includes/megadriv.h"
3#include "megacd.lh"
4#include "sound/cdda.h"
5#include "sound/rf5c68.h"
36
47// the main MD emulation needs to know the state of these because it appears in the MD regs / affect DMA operations
58int sega_cd_connected = 0x00;
69int segacd_wordram_mapped = 0;
710
811
12
13
14
15const device_type SEGA_SEGACD_US = &device_creator<sega_segacd_us_device>;
16const device_type SEGA_SEGACD_JAPAN = &device_creator<sega_segacd_japan_device>;
17const device_type SEGA_SEGACD_EUROPE = &device_creator<sega_segacd_europe_device>;
18
19sega_segacd_device::sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type)
20   : device_t(mconfig, type, "sega_segacd_device", tag, owner, clock)
21{
22   
23}
24
25sega_segacd_us_device::sega_segacd_us_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
26   : sega_segacd_device(mconfig, tag, owner, clock, SEGA_SEGACD_US)
27{
28   
29}
30
31sega_segacd_japan_device::sega_segacd_japan_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
32   : sega_segacd_device(mconfig, tag, owner, clock, SEGA_SEGACD_JAPAN)
33{
34   
35}
36
37sega_segacd_europe_device::sega_segacd_europe_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
38   : sega_segacd_device(mconfig, tag, owner, clock, SEGA_SEGACD_EUROPE)
39{
40   
41}
42
43
44static MACHINE_CONFIG_FRAGMENT( segacd_fragment )
45
46   MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
47   MCFG_CPU_PROGRAM_MAP(segacd_map)
48
49   MCFG_TIMER_ADD("sw_timer", NULL) //stopwatch timer
50
51   MCFG_DEFAULT_LAYOUT( layout_megacd )
52
53   MCFG_SOUND_ADD( "cdda", CDDA, 0 )
54   MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 ) // TODO: accurate volume balance
55   MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 )
56
57   MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164!
58   MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 )
59   MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 )
60
61   MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback)
62
63   MCFG_NVRAM_HANDLER_CLEAR()
64   MCFG_NVRAM_ADD_0FILL("backupram")
65
66   MCFG_QUANTUM_PERFECT_CPU("segacd_68k") // perfect sync to the fastest cpu
67MACHINE_CONFIG_END
68
69
70
71machine_config_constructor sega_segacd_device::device_mconfig_additions() const
72{
73   return MACHINE_CONFIG_NAME( segacd_fragment );
74}
75
76
977/* Sega CD stuff */
1078cpu_device *_segacd_68k_cpu;
1179
r17951r17952
153221#define CHECK_SCD_LV5_INTERRUPT \
154222   if (segacd_irq_mask & 0x20) \
155223   { \
156      machine.device("segacd_68k")->execute().set_input_line(5, HOLD_LINE); \
224      machine.device(":segacd:segacd_68k")->execute().set_input_line(5, HOLD_LINE); \
157225   } \
158226
159227#define CHECK_SCD_LV4_INTERRUPT \
160228   if (segacd_irq_mask & 0x10) \
161229   { \
162      machine.device("segacd_68k")->execute().set_input_line(4, HOLD_LINE); \
230      machine.device(":segacd:segacd_68k")->execute().set_input_line(4, HOLD_LINE); \
163231   } \
164232
165233#define CHECK_SCD_LV3_INTERRUPT \
166234   if (segacd_irq_mask & 0x08) \
167235   { \
168      machine.device("segacd_68k")->execute().set_input_line(3, HOLD_LINE); \
236      machine.device(":segacd:segacd_68k")->execute().set_input_line(3, HOLD_LINE); \
169237   } \
170238
171239#define CHECK_SCD_LV2_INTERRUPT \
172240   if (segacd_irq_mask & 0x04) \
173241   { \
174      machine.device("segacd_68k")->execute().set_input_line(2, HOLD_LINE); \
242      machine.device(":segacd:segacd_68k")->execute().set_input_line(2, HOLD_LINE); \
175243   } \
176244
177245#define CHECK_SCD_LV1_INTERRUPT \
178246   if (segacd_irq_mask & 0x02) \
179247   { \
180      machine.device("segacd_68k")->execute().set_input_line(1, HOLD_LINE); \
248      machine.device(":segacd:segacd_68k")->execute().set_input_line(1, HOLD_LINE); \
181249   } \
182250
183251#define CURRENT_TRACK_IS_DATA \
r17951r17952
542610   SCD_STATUS = CDD_STOPPED;
543611   CDD_STATUS = 0x0000;
544612   SET_CDD_DATA_MODE
545   cdda_stop_audio( machine.device( "cdda" ) ); //stop any pending CD-DA
613   cdda_stop_audio( machine.device( ":segacd:cdda" ) ); //stop any pending CD-DA
546614}
547615
548616
r17951r17952
672740   printf("%d Track played\n",SCD_CURTRK);
673741   CDD_MIN = to_bcd(SCD_CURTRK, false);
674742   if(!(CURRENT_TRACK_IS_DATA))
675      cdda_start_audio( machine.device( "cdda" ), SCD_CURLBA, end_msf - SCD_CURLBA );
743      cdda_start_audio( machine.device( ":segacd:cdda" ), SCD_CURLBA, end_msf - SCD_CURLBA );
676744   SET_CDC_READ
677745}
678746
r17951r17952
699767   CDD_STATUS = SCD_STATUS;
700768   SET_CDD_DATA_MODE
701769
702   //segacd.current_frame = cdda_get_audio_lba( machine.device( "cdda" ) );
770   //segacd.current_frame = cdda_get_audio_lba( machine.device( ":segacd:cdda" ) );
703771   //if(!(CURRENT_TRACK_IS_DATA))
704   cdda_pause_audio( machine.device( "cdda" ), 1 );
772   cdda_pause_audio( machine.device( ":segacd:cdda" ), 1 );
705773}
706774
707775void CDD_Resume(running_machine &machine)
r17951r17952
715783   CDD_MIN = to_bcd (SCD_CURTRK, false);
716784   SET_CDC_READ
717785   //if(!(CURRENT_TRACK_IS_DATA))
718   cdda_pause_audio( machine.device( "cdda" ), 0 );
786   cdda_pause_audio( machine.device( ":segacd:cdda" ), 0 );
719787}
720788
721789
r17951r17952
816884
817885void CDC_Do_DMA(running_machine& machine, int rate)
818886{
819   address_space* space = machine.device("segacd_68k")->memory().space(AS_PROGRAM);
887   address_space* space = machine.device(":segacd:segacd_68k")->memory().space(AS_PROGRAM);
820888
821889   UINT32 dstoffset, length;
822890   UINT8 *dest;
r17951r17952
11741242      // reset line
11751243      if (a12000_halt_reset_reg&0x0001)
11761244      {
1177         space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
1245         space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
11781246         if (!(old_halt&0x0001)) printf("clear reset slave\n");
11791247      }
11801248      else
11811249      {
1182         space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
1250         space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
11831251         if ((old_halt&0x0001)) printf("assert reset slave\n");
11841252      }
11851253
11861254      // request BUS
11871255      if (a12000_halt_reset_reg&0x0002)
11881256      {
1189         space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
1257         space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
11901258         if (!(old_halt&0x0002)) printf("halt slave\n");
11911259      }
11921260      else
11931261      {
1194         space->machine().device("segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
1262         space->machine().device(":segacd:segacd_68k")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
11951263         if ((old_halt&0x0002)) printf("resume slave\n");
11961264      }
11971265   }
r17951r17952
14801548   {
14811549      // clear this bit
14821550      a12000_halt_reset_reg &= ~0x0100;
1483      device->machine().device("segacd_68k")->execute().set_input_line(2, CLEAR_LINE);
1551      device->machine().device(":segacd:segacd_68k")->execute().set_input_line(2, CLEAR_LINE);
14841552   }
14851553
14861554   return (0x60+irqline*4)/4; // vector address
r17951r17952
22362304{
22372305   address_space* space = machine.device("maincpu")->memory().space(AS_PROGRAM);
22382306   
2239   segacd_font_bits = reinterpret_cast<UINT16 *>(machine.root_device().memshare("segacd_font")->ptr());
2240   segacd_backupram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("backupram")->ptr());
2241   segacd_dataram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("dataram")->ptr());
2242   segacd_dataram2 = reinterpret_cast<UINT16 *>(machine.root_device().memshare("dataram2")->ptr());
2243   segacd_4meg_prgram = reinterpret_cast<UINT16 *>(machine.root_device().memshare("segacd_program")->ptr());
2307   segacd_font_bits = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:segacd_font")->ptr());
2308   segacd_backupram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:backupram")->ptr());
2309   segacd_dataram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:dataram")->ptr());
2310   segacd_dataram2 = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:dataram2")->ptr());
2311   segacd_4meg_prgram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:segacd_program")->ptr());
22442312   
22452313   segacd_4meg_prgbank = 0;
22462314
r17951r17952
22722340
22732341
22742342
2275   machine.device("segacd_68k")->execute().set_irq_acknowledge_callback(segacd_sub_int_callback);
2343   machine.device(":segacd:segacd_68k")->execute().set_irq_acknowledge_callback(segacd_sub_int_callback);
22762344
22772345   space->install_legacy_read_handler (0x0000070, 0x0000073, FUNC(scd_hint_vector_r) );
22782346
r17951r17952
23542422         if ( segacd.cd )
23552423         {
23562424            segacd.toc = cdrom_get_toc( segacd.cd );
2357            cdda_set_cdrom( machine.device("cdda"), segacd.cd );
2358            cdda_stop_audio( machine.device( "cdda" ) ); //stop any pending CD-DA
2425            cdda_set_cdrom( machine.device(":segacd:cdda"), segacd.cd );
2426            cdda_stop_audio( machine.device( ":segacd:cdda" ) ); //stop any pending CD-DA
23592427         }
23602428      }
23612429   }
r17951r17952
23692437
23702438
23712439   hock_cmd = 0;
2372   stopwatch_timer = machine.device<timer_device>("sw_timer");
2440   stopwatch_timer = machine.device<timer_device>(":segacd:sw_timer");
23732441
23742442   scd_dma_timer->adjust(attotime::zero);
23752443
r17951r17952
29623030
29633031   //printf("%f\n",cdfader_vol);
29643032
2965   cdda_set_volume(space->machine().device("cdda"), cdfader_vol);
3033   cdda_set_volume(space->machine().device(":segacd:cdda"), cdfader_vol);
29663034}
29673035
29683036READ16_HANDLER( segacd_backupram_r )
r17951r17952
30623130ADDRESS_MAP_END
30633131
30643132
3133
3134
3135void sega_segacd_device::device_start()
3136{
3137
3138}
3139
3140void sega_segacd_device::device_reset()
3141{
3142
3143}
3144
3145
trunk/src/mame/machine/megacd.h
r0r17952
1/* Sega CD / Mega CD */
2
3
4
5class sega_segacd_device : public device_t
6{
7public:
8   sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type);
9
10   emu_timer *m_segacd_pwm_timer;
11protected:
12   virtual void device_start();
13   virtual void device_reset();
14
15   // optional information overrides
16//   virtual const rom_entry *device_rom_region() const;
17   virtual machine_config_constructor device_mconfig_additions() const;
18private:
19//   virtual void device_config_complete();
20
21};
22
23
24class sega_segacd_us_device : public sega_segacd_device
25{
26   public:
27      sega_segacd_us_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
28   protected:
29
30};
31
32class sega_segacd_japan_device : public sega_segacd_device
33{
34   public:
35      sega_segacd_japan_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
36   protected:
37//      virtual machine_config_constructor device_mconfig_additions() const;
38};
39
40class sega_segacd_europe_device : public sega_segacd_device
41{
42   public:
43      sega_segacd_europe_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
44   protected:
45//      virtual machine_config_constructor device_mconfig_additions() const;
46};
47
48
49extern const device_type SEGA_SEGACD_US;
50extern const device_type SEGA_SEGACD_JAPAN;
51extern const device_type SEGA_SEGACD_EUROPE;
trunk/src/mame/includes/megadriv.h
r17951r17952
1616
1717#include "machine/megavdp.h"
1818#include "machine/mega32x.h"
19#include "machine/megacd.h"
1920#include "video/315_5124.h"
2021
2122#define MASTER_CLOCK_NTSC 53693175
trunk/src/mame/mame.mak
r17951r17952
22682268
22692269$(DRIVERS)/peyper.o:    $(LAYOUT)/peyper.lh
22702270
2271$(MACHINE)/megadriv.o:  $(LAYOUT)/megacd.lh
2271$(MACHINE)/megacd.o:  $(LAYOUT)/megacd.lh
22722272
2273
22742273#-------------------------------------------------
22752274# misc dependencies
22762275#-------------------------------------------------

Previous 199869 Revisions Next


© 1997-2024 The MAME Team