Previous 199869 Revisions Next

r19376 Friday 7th December, 2012 at 09:33:53 UTC by David Haywood
more Ncd notes etc. (nw)
[src/mame/drivers]neogeo.c
[src/mame/includes]neogeo.h
[src/mess/drivers]ng_aes.c

trunk/src/mame/includes/neogeo.h
r19375r19376
236236
237237/*----------- defined in drivers/neogeo.c -----------*/
238238
239MACHINE_CONFIG_EXTERN( neogeo_base );
239240void neogeo_set_display_position_interrupt_control(running_machine &machine, UINT16 data);
240241void neogeo_set_display_counter_msb(address_space &space, UINT16 data);
241242void neogeo_set_display_counter_lsb(address_space &space, UINT16 data);
trunk/src/mame/drivers/neogeo.c
r19375r19376
889889                        neogeo_set_main_cpu_vector_table_source(machine(), 1);
890890                  }
891891#endif
892                  printf("NeoCD: write to regular address? %d\n", bit); // what IS going on with "neocdz doubledr" and why do games write here if it's hooked up to nothing?
892                  printf("NeoCD: write to regular vector change address? %d\n", bit); // what IS going on with "neocdz doubledr" and why do games write here if it's hooked up to nothing?
893893               }
894894               if (m_has_audio_banking) set_audio_cpu_rom_source(space, bit); /* this is a guess */
895895               break;
r19375r19376
11611161
11621162
11631163
1164
11641165/*************************************
11651166 *
11661167 *  Audio CPU memory handlers
r19375r19376
14081409 *
14091410 *************************************/
14101411
1411static MACHINE_CONFIG_START( neogeo, neogeo_state )
1412MACHINE_CONFIG_START( neogeo_base, neogeo_state )
14121413
14131414   /* basic machine hardware */
14141415   MCFG_CPU_ADD("maincpu", M68000, NEOGEO_MAIN_CPU_CLOCK)
r19375r19376
14171418   MCFG_CPU_ADD("audiocpu", Z80, NEOGEO_AUDIO_CPU_CLOCK)
14181419   MCFG_CPU_PROGRAM_MAP(audio_map)
14191420   MCFG_CPU_IO_MAP(audio_io_map)
1420
1421   MCFG_WATCHDOG_TIME_INIT(attotime::from_usec(128762))
1422
1423   MCFG_NVRAM_ADD_0FILL("saveram")
1424   MCFG_MEMCARD_HANDLER(neogeo)
1425
1421   
14261422   /* video hardware */
14271423   MCFG_DEFAULT_LAYOUT(layout_neogeo)
14281424
r19375r19376
14441440   MCFG_UPD4990A_ADD("upd4990a")
14451441MACHINE_CONFIG_END
14461442
1447static MACHINE_CONFIG_DERIVED( mvs, neogeo )
1443static MACHINE_CONFIG_DERIVED( neogeo, neogeo_base )
1444   MCFG_WATCHDOG_TIME_INIT(attotime::from_usec(128762))
14481445
1446   MCFG_NVRAM_ADD_0FILL("saveram")
14491447   MCFG_MEMCARD_HANDLER(neogeo)
1448MACHINE_CONFIG_END
14501449
1450static MACHINE_CONFIG_DERIVED( mvs, neogeo )
14511451    MCFG_CARTSLOT_ADD("cart")
14521452   MCFG_CARTSLOT_LOAD(neo_cartridge)
14531453   MCFG_CARTSLOT_INTERFACE("neo_cart")
trunk/src/mess/drivers/ng_aes.c
r19375r19376
2121
2222    Current status:
2323        - Cartridges run.
24      - Riding Hero runs in slow-mo (probably related to comms HW / IO port handling)
2425
2526    ToDo :
2627        - Change input code to allow selection of the mahjong panel in PORT_CATEGORY.
2728        - Clean up code, to reduce duplication of MAME source
2829
30
31    Neo-Geo CD hardware
32
33   Thanks to:
34       * The FBA team (Barry Harris) for much of the CDC / CDD code and system details.
35        ( http://www.barryharris.me.uk/ )
36      * Mirko Buffoni for a commented disassembly of the NeoCD bios rom.
37
38    Current status:
39      - NeoCDZ runs, the original NeoCD does not
40         - Might think the tray is open? (check)
41      - CDDA doesn't play
42      - Some unknown / unhandled CD commands, code is still a bit messy
43      - Games using Raster Effects are broken, even non-IRQ based ones like mosyougi
44         - Are we overloading the CPU with interrupts from the CDC, incorrect masking? or something else?
45      - Double Dragon doesn't load, it erases the IRQ table
46         - might need better handling of the Vector Table Mapping, or better interrupts (see point above)
47      - Softlist are based on an old Tosec set and should be updated to the TruRip set once we can convert CCD
48        without throwing away gap data etc.
49      - Backup RAM isn't saved?
50
2951****************************************************************************/
3052
3153#include "emu.h"
r19375r19376
93115   
94116
95117
96   void NeoCDDoDMA();
118   void NeoCDDoDMA(address_space& curr_space);
97119   void set_DMA_regs(int offset, UINT16 wordValue);
98120
99121   UINT8 *m_memcard_data;
r19375r19376
131153   INT32 NeoCDDMAValue2;
132154   INT32 NeoCDDMACount;
133155   INT32 NeoCDDMAMode;
134   void SekWriteWord(UINT32 a, UINT16 d);
135   void SekWriteByte(UINT32 a, UINT8 d);
136   UINT32 SekReadByte(UINT32 a);
137   UINT32 SekReadWord(UINT32 a);
138156
139157   UINT8 nTransferWriteEnable;
140158
141159   address_space* curr_space;
142
143
144160};
145161
146162
147#define LOG_VIDEO_SYSTEM      (0)
148#define LOG_CPU_COMM         (0)
149#define LOG_MAIN_CPU_BANKING   (1)
150#define LOG_AUDIO_CPU_BANKING   (1)
151
152#define NEOCD_AREA_SPR    0
153#define NEOCD_AREA_PCM    1
154#define NEOCD_AREA_AUDIO  4
155#define NEOCD_AREA_FIX    5
156
157163/*************************************
158164 *
159165 *  Global variables
r19375r19376
175181
176182
177183
178/*************************************
179 *
180 *  Audio CPU interrupt generation
181 *
182 *************************************/
183184
184static void audio_cpu_irq(device_t *device, int assert)
185{
186   neogeo_state *state = device->machine().driver_data<neogeo_state>();
187   state->m_audiocpu->set_input_line(0, assert ? ASSERT_LINE : CLEAR_LINE);
188}
189185
190186
191
192
193
194
195
196
197
198
199187/*************************************
200188 *
201189 *  Memory card
r19375r19376
251239   }
252240}
253241
254static MEMCARD_HANDLER( neogeo )
242static MEMCARD_HANDLER( neogeo_aes )
255243{
256244   ng_aes_state *state = machine.driver_data<ng_aes_state>();
257245   switch (action)
r19375r19376
372360
373361      // LC8951 registers
374362      case 0x0100:
375         return m_tempcdc->segacd_cdc_mode_address_r(*curr_space, 0, 0xffff);
363         return m_tempcdc->segacd_cdc_mode_address_r(space, 0, 0xffff);
376364      case 0x0102:
377365         return m_tempcdc->CDC_Reg_r();
378366
r19375r19376
418406         // DMA controller
419407      case 0x0060:
420408         if (byteValue & 0x40) {
421            NeoCDDoDMA();
409            NeoCDDoDMA(space);
422410         }
423411         break;
424412
r19375r19376
449437
450438      // LC8951 registers
451439      case 0x0100:
452         m_tempcdc->segacd_cdc_mode_address_w(*curr_space, 0, byteValue, 0xffff);
440         m_tempcdc->segacd_cdc_mode_address_w(space, 0, byteValue, 0xffff);
453441         break;
454442      case 0x0102:
455443         m_tempcdc->CDC_Reg_w(byteValue);
r19375r19376
468456         break;
469457      case 0x0126:
470458//          bprintf(PRINT_NORMAL, _T("  - NGCD Z80 BUSREQ -> 1 (PC: 0x%06X)\n"), SekGetPC(-1));
471         curr_space->machine().scheduler().synchronize();
459         space.machine().scheduler().synchronize();
472460         m_audiocpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
473461         break;
474462      case 0x0128:
r19375r19376
484472         break;
485473      case 0x0146:
486474//          bprintf(PRINT_NORMAL, _T("  - NGCD Z80 BUSREQ -> 0 (PC: 0x%06X)\n"), SekGetPC(-1));
487         curr_space->machine().scheduler().synchronize();
475         space.machine().scheduler().synchronize();
488476         m_audiocpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
489477         break;
490478      case 0x0148:
r19375r19376
654642
655643
656644
657void ng_aes_state::SekWriteWord(UINT32 a, UINT16 d)
658{
659//  printf("write word %08x %04x\n", a, d);
660   curr_space->write_word(a,d);
661}
662645
663void ng_aes_state::SekWriteByte(UINT32 a, UINT8 d)
664{
665//  printf("write byte %08x %02x\n", a, d);
666   curr_space->write_byte(a,d);
667}
668646
669UINT32 ng_aes_state::SekReadByte(UINT32 a)
670{
671//  printf("read byte %08x\n", a);
672   return curr_space->read_byte(a);
673}
674
675
676UINT32 ng_aes_state::SekReadWord(UINT32 a)
677{
678//  printf("read WORD %08x\n", a);
679   return curr_space->read_word(a);
680}
681
682
683
684647static INT32 SekIdle(INT32 nCycles)
685648{
686649   return nCycles;
r19375r19376
734697 */
735698
736699
737void ng_aes_state::NeoCDDoDMA()
700void ng_aes_state::NeoCDDoDMA(address_space& curr_space)
738701{
739702
740703   // The LC8953 chip has a programmable DMA controller, which is not properly emulated.
r19375r19376
765728         SekIdle(NeoCDDMACount * 4);
766729
767730         while (NeoCDDMACount--) {
768            SekWriteWord(NeoCDDMAAddress1 + 0, NeoCDDMAAddress1 >> 24);
769            SekWriteWord(NeoCDDMAAddress1 + 2, NeoCDDMAAddress1 >> 16);
770            SekWriteWord(NeoCDDMAAddress1 + 4, NeoCDDMAAddress1 >>  8);
771            SekWriteWord(NeoCDDMAAddress1 + 6, NeoCDDMAAddress1 >>  0);
731            curr_space.write_word(NeoCDDMAAddress1 + 0, NeoCDDMAAddress1 >> 24);
732            curr_space.write_word(NeoCDDMAAddress1 + 2, NeoCDDMAAddress1 >> 16);
733            curr_space.write_word(NeoCDDMAAddress1 + 4, NeoCDDMAAddress1 >>  8);
734            curr_space.write_word(NeoCDDMAAddress1 + 6, NeoCDDMAAddress1 >>  0);
772735            NeoCDDMAAddress1 += 8;
773736         }
774737
r19375r19376
791754         SekIdle(NeoCDDMACount * 1);
792755
793756         while (NeoCDDMACount--) {
794            SekWriteWord(NeoCDDMAAddress2 + 0, SekReadByte(NeoCDDMAAddress1 + 0));
795            SekWriteWord(NeoCDDMAAddress2 + 2, SekReadByte(NeoCDDMAAddress1 + 1));
757            curr_space.write_word(NeoCDDMAAddress2 + 0, curr_space.read_byte(NeoCDDMAAddress1 + 0));
758            curr_space.write_word(NeoCDDMAAddress2 + 2, curr_space.read_byte(NeoCDDMAAddress1 + 1));
796759            NeoCDDMAAddress1 += 2;
797760            NeoCDDMAAddress2 += 4;
798761         }
r19375r19376
821784         SekIdle(NeoCDDMACount * 4);
822785
823786         while (NeoCDDMACount--) {
824            SekWriteByte(NeoCDDMAAddress1 + 0, data[0]);
825            SekWriteByte(NeoCDDMAAddress1 + 2, data[1]);
787            curr_space.write_byte(NeoCDDMAAddress1 + 0, data[0]);
788            curr_space.write_byte(NeoCDDMAAddress1 + 2, data[1]);
826789            NeoCDDMAAddress1 += 4;
827790            data += 2;
828791         }
r19375r19376
860823         SekIdle(NeoCDDMACount * 1);
861824
862825         while (NeoCDDMACount--) {
863            SekWriteWord(NeoCDDMAAddress2, SekReadWord(NeoCDDMAAddress1));
826            curr_space.write_word(NeoCDDMAAddress2, curr_space.read_word(NeoCDDMAAddress1));
864827            NeoCDDMAAddress1 += 2;
865828            NeoCDDMAAddress2 += 2;
866829         }
r19375r19376
890853         SekIdle(NeoCDDMACount * 2);
891854
892855         while (NeoCDDMACount--) {
893            SekWriteWord(NeoCDDMAAddress1 + 0, NeoCDDMAAddress1 >> 16);
894            SekWriteWord(NeoCDDMAAddress1 + 2, NeoCDDMAAddress1 >>  0);
856            curr_space.write_word(NeoCDDMAAddress1 + 0, NeoCDDMAAddress1 >> 16);
857            curr_space.write_word(NeoCDDMAAddress1 + 2, NeoCDDMAAddress1 >>  0);
895858            NeoCDDMAAddress1 += 4;
896859         }
897860
r19375r19376
919882         SekIdle(NeoCDDMACount * 4);
920883
921884         while (NeoCDDMACount--) {
922            SekWriteByte(NeoCDDMAAddress1 + 0, data[0]);
923            SekWriteByte(NeoCDDMAAddress1 + 1, data[1]);
885            curr_space.write_byte(NeoCDDMAAddress1 + 0, data[0]);
886            curr_space.write_byte(NeoCDDMAAddress1 + 1, data[1]);
924887            NeoCDDMAAddress1 += 2;
925888            data += 2;
926889         }
r19375r19376
958921         SekIdle(NeoCDDMACount * 1);
959922
960923         while (NeoCDDMACount--) {
961            SekWriteWord(NeoCDDMAAddress1, NeoCDDMAValue1);
924            curr_space.write_word(NeoCDDMAAddress1, NeoCDDMAValue1);
962925            NeoCDDMAAddress1 += 2;
963926         }
964927
r19375r19376
12041167   YM2610ADPCMAROM = memregion("ymsnd")->base();
12051168   NeoZ80ROMActive = memregion("audiocpu")->base();
12061169   NeoTextRAM = memregion("fixed")->base();
1207   curr_space = &machine().device("maincpu")->memory().space(AS_PROGRAM);
12081170}
12091171
12101172MACHINE_RESET_MEMBER(ng_aes_state,neocd)
r19375r19376
12261188 *
12271189 *************************************/
12281190
1229static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, ng_aes_state )
1191static ADDRESS_MAP_START( aes_main_map, AS_PROGRAM, 16, ng_aes_state )
12301192   AM_RANGE(0x000000, 0x00007f) AM_ROMBANK(NEOGEO_BANK_VECTORS)
12311193   AM_RANGE(0x000080, 0x0fffff) AM_ROM
12321194   AM_RANGE(0x100000, 0x10ffff) AM_MIRROR(0x0f0000) AM_RAM
r19375r19376
12821244ADDRESS_MAP_END
12831245
12841246
1285/*************************************
1286 *
1287 *  Audio CPU memory handlers
1288 *
1289 *************************************/
12901247
1291static ADDRESS_MAP_START( audio_map, AS_PROGRAM, 8, ng_aes_state )
1292   AM_RANGE(0x0000, 0x7fff) AM_ROMBANK(NEOGEO_BANK_AUDIO_CPU_MAIN_BANK)
1293   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(NEOGEO_BANK_AUDIO_CPU_CART_BANK3)
1294   AM_RANGE(0xc000, 0xdfff) AM_ROMBANK(NEOGEO_BANK_AUDIO_CPU_CART_BANK2)
1295   AM_RANGE(0xe000, 0xefff) AM_ROMBANK(NEOGEO_BANK_AUDIO_CPU_CART_BANK1)
1296   AM_RANGE(0xf000, 0xf7ff) AM_ROMBANK(NEOGEO_BANK_AUDIO_CPU_CART_BANK0)
1297   AM_RANGE(0xf800, 0xffff) AM_RAM
1298ADDRESS_MAP_END
12991248
13001249
1301
13021250/*************************************
13031251 *
13041252 *  Audio CPU port handlers
13051253 *
13061254 *************************************/
13071255
1308static ADDRESS_MAP_START( audio_io_map, AS_IO, 8, ng_aes_state )
1309  /*AM_RANGE(0x00, 0x00) AM_MIRROR(0xff00) AM_READWRITE(audio_command_r, audio_cpu_clear_nmi_w);*/  /* may not and NMI clear */
1310   AM_RANGE(0x00, 0x00) AM_MIRROR(0xff00) AM_READ(audio_command_r)
1311   AM_RANGE(0x04, 0x07) AM_MIRROR(0xff00) AM_DEVREADWRITE_LEGACY("ymsnd", ym2610_r, ym2610_w)
1312   AM_RANGE(0x08, 0x08) AM_MIRROR(0xff00) /* write - NMI enable / acknowledge? (the data written doesn't matter) */
1313   AM_RANGE(0x08, 0x08) AM_MIRROR(0xfff0) AM_MASK(0xfff0) AM_READ(audio_cpu_bank_select_f000_f7ff_r)
1314   AM_RANGE(0x09, 0x09) AM_MIRROR(0xfff0) AM_MASK(0xfff0) AM_READ(audio_cpu_bank_select_e000_efff_r)
1315   AM_RANGE(0x0a, 0x0a) AM_MIRROR(0xfff0) AM_MASK(0xfff0) AM_READ(audio_cpu_bank_select_c000_dfff_r)
1316   AM_RANGE(0x0b, 0x0b) AM_MIRROR(0xfff0) AM_MASK(0xfff0) AM_READ(audio_cpu_bank_select_8000_bfff_r)
1317   AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xff00) AM_WRITE(audio_result_w)
1318   AM_RANGE(0x18, 0x18) AM_MIRROR(0xff00) /* write - NMI disable? (the data written doesn't matter) */
1319ADDRESS_MAP_END
13201256
1321
1322
1323
13241257static ADDRESS_MAP_START( neocd_audio_map, AS_PROGRAM, 8, ng_aes_state )
13251258   AM_RANGE(0x0000, 0xffff) AM_RAM AM_REGION("audiocpu", 0x00000)
13261259ADDRESS_MAP_END
r19375r19376
13481281
13491282/*************************************
13501283 *
1351 *  Audio interface
1352 *
1353 *************************************/
1354
1355static const ym2610_interface ym2610_config =
1356{
1357   audio_cpu_irq
1358};
1359
1360
1361
1362/*************************************
1363 *
13641284 *  Standard Neo-Geo DIPs and
13651285 *  input port definition
13661286 *
r19375r19376
15991519 *
16001520 *************************************/
16011521
1602static MACHINE_CONFIG_START( neogeo, ng_aes_state )
16031522
1604   /* basic machine hardware */
1605   MCFG_CPU_ADD("maincpu", M68000, NEOGEO_MAIN_CPU_CLOCK)
1606   MCFG_CPU_PROGRAM_MAP(main_map)
1523static MACHINE_CONFIG_DERIVED_CLASS( aes, neogeo_base, ng_aes_state )
1524   MCFG_CPU_MODIFY("maincpu")
1525   MCFG_CPU_PROGRAM_MAP(aes_main_map) // some different input handling, probably also responsible for Riding Hero not running properly
1526   
1527   MCFG_MEMCARD_HANDLER(neogeo_aes)
16071528
1608   MCFG_CPU_ADD("audiocpu", Z80, NEOGEO_AUDIO_CPU_CLOCK)
1609   MCFG_CPU_PROGRAM_MAP(audio_map)
1610   MCFG_CPU_IO_MAP(audio_io_map)
1611
16121529   MCFG_MACHINE_START_OVERRIDE(ng_aes_state, neogeo)
16131530   MCFG_MACHINE_RESET_OVERRIDE(ng_aes_state, neogeo)
16141531
1615   // temporary until things are cleaned up
1616   MCFG_DEVICE_ADD("tempcdc", LC89510_TEMP, 0) // cd controller
1617   MCFG_SEGACD_HACK_SET_NEOCD
1618
1619   /* video hardware */
1620   MCFG_DEFAULT_LAYOUT(layout_neogeo)
1621
1622   MCFG_SCREEN_ADD("screen", RASTER)
1623   MCFG_SCREEN_RAW_PARAMS(NEOGEO_PIXEL_CLOCK, NEOGEO_HTOTAL, NEOGEO_HBEND, NEOGEO_HBSTART, NEOGEO_VTOTAL, NEOGEO_VBEND, NEOGEO_VBSTART)
1624   MCFG_SCREEN_UPDATE_DRIVER(ng_aes_state, screen_update_neogeo)
1625
1626   /* audio hardware */
1627   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
1628
1629   MCFG_SOUND_ADD("ymsnd", YM2610, NEOGEO_YM2610_CLOCK)
1630   MCFG_SOUND_CONFIG(ym2610_config)
1631   MCFG_SOUND_ROUTE(0, "lspeaker",  0.60)
1632   MCFG_SOUND_ROUTE(0, "rspeaker", 0.60)
1633   MCFG_SOUND_ROUTE(1, "lspeaker",  1.0)
1634   MCFG_SOUND_ROUTE(2, "rspeaker", 1.0)
1635
1636   /* NEC uPD4990A RTC */
1637   MCFG_UPD4990A_ADD("upd4990a")
1638MACHINE_CONFIG_END
1639
1640static MACHINE_CONFIG_DERIVED( aes, neogeo )
1641
1642   MCFG_MEMCARD_HANDLER(neogeo)
1643
16441532   MCFG_CARTSLOT_ADD("cart")
16451533   MCFG_CARTSLOT_LOAD(neo_cartridge)
16461534   MCFG_CARTSLOT_INTERFACE("neo_cart")
r19375r19376
16511539MACHINE_CONFIG_END
16521540
16531541
1654
16551542/* NeoCD uses custom vectors on IRQ4 to handle various events from the CDC */
16561543
16571544static IRQ_CALLBACK(neocd_int_callback)
r19375r19376
16771564   NULL
16781565};
16791566
1680static MACHINE_CONFIG_DERIVED( neocd, neogeo )
1567static MACHINE_CONFIG_DERIVED_CLASS( neocd, neogeo_base, ng_aes_state )
16811568
16821569   MCFG_CPU_MODIFY("maincpu")
16831570   MCFG_CPU_PROGRAM_MAP(neocd_main_map)
r19375r19376
16861573   MCFG_CPU_PROGRAM_MAP(neocd_audio_map)
16871574   MCFG_CPU_IO_MAP(neocd_audio_io_map)
16881575
1576   // temporary until things are cleaned up
1577   MCFG_DEVICE_ADD("tempcdc", LC89510_TEMP, 0) // cd controller
1578   MCFG_SEGACD_HACK_SET_NEOCD
16891579
1580   MCFG_MEMCARD_HANDLER(neogeo_aes)
1581
16901582   MCFG_MACHINE_START_OVERRIDE(ng_aes_state,neocd)
16911583   MCFG_MACHINE_RESET_OVERRIDE(ng_aes_state,neocd)
16921584

Previous 199869 Revisions Next


© 1997-2024 The MAME Team