Previous 199869 Revisions Next

r19374 Friday 7th December, 2012 at 08:47:13 UTC by David Haywood
neocd, misc improvements / notes (nw)
[src/mame/drivers]neogeo.c
[src/mame/includes]neogeo.h
[src/mess/drivers]ng_aes.c

trunk/src/mess/drivers/ng_aes.c
r19373r19374
5454//UINT8* NeoTextROM;
5555UINT8* YM2610ADPCMAROM;
5656UINT8* NeoZ80ROMActive;
57UINT8 NeoSystem = 6;
57
58// was it actually released in eu / asia?
59#define NEOCD_REGION_ASIA 3 // IronClad runs with a darkened screen (MVS has the same issue)
60#define NEOCD_REGION_EUROPE 2 // ^
61#define NEOCD_REGION_US 1
62#define NEOCD_REGION_JAPAN 0
63
64
65UINT8 NeoSystem = NEOCD_REGION_JAPAN;
5866INT32 nNeoCDZ80ProgWriteWordCancelHack = 0;
5967
6068
r19373r19374
6371
6472
6573
66static void MapVectorTable(bool bMapBoardROM)
67{
68   /*
69    if (!bMapBoardROM && Neo68KROMActive) {
70        SekMapMemory(Neo68KFix, 0x000000, 0x0003FF, SM_ROM);
71    } else {
72        SekMapMemory(NeoVectorActive, 0x000000, 0x0003FF, SM_ROM);
73    }
74    */
75}
7674
7775
7876class ng_aes_state : public neogeo_state
r19373r19374
9997   void set_DMA_regs(int offset, UINT16 wordValue);
10098
10199   UINT8 *m_memcard_data;
102   DECLARE_WRITE8_MEMBER(audio_cpu_clear_nmi_w);
103   DECLARE_WRITE16_MEMBER(io_control_w);
104100   DECLARE_WRITE16_MEMBER(save_ram_w);
105101   DECLARE_READ16_MEMBER(memcard_r);
106102   DECLARE_WRITE16_MEMBER(memcard_w);
107103   DECLARE_READ16_MEMBER(neocd_memcard_r);
108104   DECLARE_WRITE16_MEMBER(neocd_memcard_w);
109   DECLARE_WRITE16_MEMBER(main_cpu_bank_select_w);
110105   DECLARE_READ16_MEMBER(neocd_control_r);
111106   DECLARE_WRITE16_MEMBER(neocd_control_w);
112107   DECLARE_READ16_MEMBER(neocd_transfer_r);
r19373r19374
124119
125120   // neoCD
126121
127   UINT16 neogeoReadWordCDROM(UINT32 sekAddress);
128   void neogeoWriteWordCDROM(UINT32 sekAddress, UINT16 wordValue);
129122   UINT8 neogeoReadTransfer(UINT32 sekAddress, int is_byte_transfer);
130123   void neogeoWriteTransfer(UINT32 sekAddress, UINT8 byteValue, int is_byte_transfer);
131124
r19373r19374
197190
198191
199192
200WRITE8_MEMBER(ng_aes_state::audio_cpu_clear_nmi_w)
201{
202   m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
203}
204193
205194
206195
207/*************************************
208 *
209 *  Input ports / Controllers
210 *
211 *************************************/
212196
213static void select_controller( running_machine &machine, UINT8 data )
214{
215   neogeo_state *state = machine.driver_data<neogeo_state>();
216   state->m_controller_select = data;
217}
218197
219198
220WRITE16_MEMBER(ng_aes_state::io_control_w)
221{
222   switch (offset)
223   {
224   case 0x00: select_controller(machine(), data & 0x00ff); break;
225//  case 0x18: set_output_latch(machine(), data & 0x00ff); break;
226//  case 0x20: set_output_data(machine(), data & 0x00ff); break;
227   case 0x28: upd4990a_control_16_w(m_upd4990a, space, 0, data, mem_mask); break;
228//  case 0x30: break; // coin counters
229//  case 0x31: break; // coin counters
230//  case 0x32: break; // coin lockout
231//  case 0x33: break; // coui lockout
232
233   default:
234      logerror("PC: %x  Unmapped I/O control write.  Offset: %x  Data: %x\n", space.device().safe_pc(), offset, data);
235      break;
236   }
237}
238
239
240static CUSTOM_INPUT( get_calendar_status )
241{
242   neogeo_state *state = field.machine().driver_data<neogeo_state>();
243   return (upd4990a_databit_r(state->m_upd4990a, state->generic_space(), 0) << 1) | upd4990a_testbit_r(state->m_upd4990a, state->generic_space(), 0);
244}
245
246
247199/*************************************
248200 *
249201 *  Memory card
r19373r19374
319271   }
320272}
321273
322/*************************************
323 *
324 *  Main CPU banking
325 *
326 *************************************/
327274
328WRITE16_MEMBER(ng_aes_state::main_cpu_bank_select_w)
329{
330   UINT32 bank_address;
331   UINT32 len = memregion("maincpu")->bytes();
332275
333   if ((len <= 0x100000) && (data & 0x07))
334      logerror("PC %06x: warning: bankswitch to %02x but no banks available\n", space.device().safe_pc(), data);
335   else
336   {
337      bank_address = ((data & 0x07) + 1) * 0x100000;
338276
339      if (bank_address >= len)
340      {
341         logerror("PC %06x: warning: bankswitch to empty bank %02x\n", space.device().safe_pc(), data);
342         bank_address = 0x100000;
343      }
344277
345      neogeo_set_main_cpu_bank_address(space, bank_address);
346   }
347}
348278
349
350static void main_cpu_banking_init( running_machine &machine )
351{
352   ng_aes_state *state = machine.driver_data<ng_aes_state>();
353   address_space &mainspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
354
355   /* create vector banks */
356   state->membank(NEOGEO_BANK_VECTORS)->configure_entry(0, machine.root_device().memregion("mainbios")->base());
357   state->membank(NEOGEO_BANK_VECTORS)->configure_entry(1, machine.root_device().memregion("maincpu")->base());
358
359   /* set initial main CPU bank */
360   if (machine.root_device().memregion("maincpu")->bytes() > 0x100000)
361      neogeo_set_main_cpu_bank_address(mainspace, 0x100000);
362   else
363      neogeo_set_main_cpu_bank_address(mainspace, 0x000000);
364}
365
366
367
368
369
370
371279/*************************************
372280 *
373281 *  System control register
r19373r19374
450358
451359
452360
453UINT16 ng_aes_state::neogeoReadWordCDROM(UINT32 sekAddress)
454{
455//  bprintf(PRINT_NORMAL, _T("  - CDROM: 0x%06X read (word, PC: 0x%06X)\n"), sekAddress, SekGetPC(-1));
456361
457362
363
364READ16_MEMBER(ng_aes_state::neocd_control_r)
365{
366   UINT32 sekAddress = 0xff0000+ (offset*2);
367
458368   switch (sekAddress & 0xFFFF) {
459369
460370      case 0x0016:
r19373r19374
481391}
482392
483393
484void ng_aes_state::neogeoWriteWordCDROM(UINT32 sekAddress, UINT16 wordValue)
394WRITE16_MEMBER(ng_aes_state::neocd_control_w)
485395{
396
397   UINT32 sekAddress = 0xff0000+ (offset*2);
398   UINT16 wordValue = data;
399
486400//  bprintf(PRINT_NORMAL, _T("  - NGCD port 0x%06X -> 0x%04X (PC: 0x%06X)\n"), sekAddress, wordValue, SekGetPC(-1));
487401   int byteValue = wordValue & 0xff;
488402
r19373r19374
588502
589503      case 0x016c:
590504//          bprintf(PRINT_ERROR, _T("  - NGCD port 0x%06X -> 0x%02X (PC: 0x%06X)\n"), sekAddress, byteValue, SekGetPC(-1));
505         //MapVectorTable(!(byteValue == 0xFF));
506         if (ACCESSING_BITS_0_7)
507         {
508            // even like this doubledr ends up mapping vectors in, then erasing them causing the loading to crash??
509            // is there some way to enable write protection on the RAM vector area or is it some IRQ masking issue?
510            // the games still write to the normal address for this too?
511            // writes 00 / 01 / ff
512            printf("MapVectorTable? %04x %04x\n",data,mem_mask);
591513
592         MapVectorTable(!(byteValue == 0xFF));
514            if (!data) neogeo_set_main_cpu_vector_table_source(machine(), 0); // bios vectors
515            else neogeo_set_main_cpu_vector_table_source(machine(), 1); // ram (aka cart) vectors
593516
517         }
518
594519//extern INT32 bRunPause;
595520//bRunPause = 1;
596521         break;
r19373r19374
634559
635560
636561
637READ16_MEMBER(ng_aes_state::neocd_control_r)
638{
639   return neogeoReadWordCDROM(0xff0000+ (offset*2));
640}
641562
642
643WRITE16_MEMBER(ng_aes_state::neocd_control_w)
644{
645   neogeoWriteWordCDROM(0xff0000+ (offset*2), data);
646}
647
648
649
650
651563/*
652564 *  Handling NeoCD banked RAM
653565 *  When the Z80 space is banked in to 0xe00000, only the low byte of each word is used
r19373r19374
11601072   state->membank(NEOGEO_BANK_BIOS)->set_base(state->memregion("mainbios")->base());
11611073
11621074   /* set the initial main CPU bank */
1163   main_cpu_banking_init(machine);
1075   neogeo_main_cpu_banking_init(machine);
11641076
11651077   /* set the initial audio CPU ROM banks */
11661078   neogeo_audio_cpu_banking_init(machine);
r19373r19374
12151127
12161128MACHINE_START_MEMBER(ng_aes_state,neocd)
12171129{
1218   UINT8* ROM = machine().root_device().memregion("mainbios")->base();
1219   UINT8* RAM = machine().root_device().memregion("maincpu")->base();
1130//   UINT8* ROM = machine().root_device().memregion("mainbios")->base();
1131//   UINT8* RAM = machine().root_device().memregion("maincpu")->base();
12201132//   UINT8* Z80bios = machine().root_device().memregion("audiobios")->base();
12211133//   int x;
12221134   m_has_audio_banking = false;
1135   m_is_cartsys = false;
12231136
12241137   common_machine_start(machine());
12251138   m_is_mvs = false;
r19373r19374
12351148   save_pointer(NAME(m_memcard_data), 0x2000);
12361149
12371150   // copy initial 68k vectors into RAM
1238   memcpy(RAM,ROM,0x80);
1151   // memcpy(RAM,ROM,0x80);
12391152
12401153
12411154
r19373r19374
12431156   // for custom vectors
12441157   machine().device("maincpu")->execute().set_irq_acknowledge_callback(neocd_int_callback);
12451158
1159   neogeo_set_main_cpu_vector_table_source(machine(), 0); // default to the BIOS vectors
1160
12461161   m_tempcdc->reset_cd();
12471162   
12481163}
r19373r19374
13391254
13401255
13411256
1257
13421258static ADDRESS_MAP_START( neocd_main_map, AS_PROGRAM, 16, ng_aes_state )
1343   AM_RANGE(0x000000, 0x00007f) AM_RAMBANK(NEOGEO_BANK_VECTORS)
1344   AM_RANGE(0x000080, 0x1fffff) AM_RAM AM_SHARE("neocd_work_ram")
1345   /* some games have protection devices in the 0x200000 region, it appears to map to cart space, not surprising, the ROM is read here too */
1346   AM_RANGE(0x200000, 0x2fffff) AM_ROMBANK(NEOGEO_BANK_CARTRIDGE)
1347   AM_RANGE(0x2ffff0, 0x2fffff) AM_WRITE(main_cpu_bank_select_w)
1259   AM_RANGE(0x000000, 0x00007f) AM_READ_BANK(NEOGEO_BANK_VECTORS) // writes will fall through to area below
1260   AM_RANGE(0x000000, 0x1fffff) AM_RAM AM_REGION("maincpu", 0x00000)
1261
13481262   AM_RANGE(0x300000, 0x300001) AM_MIRROR(0x01ff7e) AM_READ(aes_in0_r)
13491263   AM_RANGE(0x300080, 0x300081) AM_MIRROR(0x01ff7e) AM_READ_PORT("IN4")
13501264   AM_RANGE(0x300000, 0x300001) AM_MIRROR(0x01ffe0) AM_READ(neogeo_unmapped_r) AM_WRITENOP   // AES has no watchdog
r19373r19374
14241338   AM_RANGE(0x0b, 0x0b) AM_MIRROR(0xfff0) AM_MASK(0xfff0) AM_READ(audio_cpu_bank_select_8000_bfff_r)
14251339   AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xff00) AM_WRITE(audio_result_w)
14261340   AM_RANGE(0x18, 0x18) AM_MIRROR(0xff00) /* write - NMI disable? (the data written doesn't matter) */
1341
1342   // ??
1343   AM_RANGE(0x80, 0x80) AM_MIRROR(0xff00) AM_WRITENOP
1344   AM_RANGE(0xc0, 0xc0) AM_MIRROR(0xff00) AM_WRITENOP
1345   AM_RANGE(0xc1, 0xc1) AM_MIRROR(0xff00) AM_WRITENOP
14271346ADDRESS_MAP_END
14281347
14291348
r19373r19374
14901409   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* having this ACTIVE_HIGH causes you to start with 2 credits using USA bios roms */   \
14911410   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* having this ACTIVE_HIGH causes you to start with 2 credits using USA bios roms */   \
14921411   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SPECIAL ) /* what is this? */                        \
1493   PORT_BIT( 0x00c0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(get_calendar_status, NULL)         \
1412   PORT_BIT( 0x00c0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, neogeo_state,get_calendar_status, NULL)         \
14941413   PORT_BIT( 0xff00, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, neogeo_state,get_audio_result, NULL) \
14951414
14961415#define STANDARD_IN4                                                         \
trunk/src/mame/includes/neogeo.h
r19373r19374
4141   {
4242      m_has_audio_banking = true;
4343      m_is_mvs = true;
44      m_is_cartsys = true;
4445   }
4546
4647   /* memory pointers */
r19373r19374
227228   TIMER_CALLBACK_MEMBER(auto_animation_timer_callback);
228229   TIMER_CALLBACK_MEMBER(sprite_line_timer_callback);
229230
230   bool m_has_audio_banking;
231   bool m_is_mvs;
231   bool m_has_audio_banking; // does the system use Audio Banking (the NeoCD doesn't?)
232   bool m_is_mvs; // is the system an MVS (watchdog, SRAM etc.)
233   bool m_is_cartsys; // does the system use Cartridges? (MVS and AES)
232234};
233235
234236
r19373r19374
242244DEVICE_IMAGE_LOAD( neo_cartridge );
243245void neogeo_postload(running_machine &machine);
244246void neogeo_audio_cpu_banking_init( running_machine &machine );
247void neogeo_main_cpu_banking_init( running_machine &machine );
248void neogeo_set_main_cpu_vector_table_source( running_machine &machine, UINT8 data );
245249
246250/*----------- defined in machine/neocrypt.c -----------*/
247251
trunk/src/mame/drivers/neogeo.c
r19373r19374
420420   switch (offset)
421421   {
422422   case 0x00: select_controller(machine(), data & 0x00ff); break;
423   case 0x18: set_output_latch(machine(), data & 0x00ff); break;
424   case 0x20: set_output_data(machine(), data & 0x00ff); break;
423   case 0x18: if (m_is_mvs) set_output_latch(machine(), data & 0x00ff); break;
424   case 0x20: if (m_is_mvs) set_output_data(machine(), data & 0x00ff); break;
425425   case 0x28: upd4990a_control_16_w(m_upd4990a, space, 0, data, mem_mask); break;
426426//  case 0x30: break; // coin counters
427427//  case 0x31: break; // coin counters
r19373r19374
435435}
436436
437437
438
439438/*************************************
440439 *
441440 *  Unmapped memory access
r19373r19374
477476
478477
479478
479
480480/*************************************
481481 *
482482 *  NVRAM (Save RAM)
r19373r19374
633633
634634
635635
636static void set_main_cpu_vector_table_source( running_machine &machine, UINT8 data )
636void neogeo_set_main_cpu_vector_table_source( running_machine &machine, UINT8 data )
637637{
638638   neogeo_state *state = machine.driver_data<neogeo_state>();
639639   state->m_main_cpu_vector_table_source = data;
r19373r19374
645645static void _set_main_cpu_bank_address( running_machine &machine )
646646{
647647   neogeo_state *state = machine.driver_data<neogeo_state>();
648   if (!state->m_is_cartsys) return;
649
648650   state->membank(NEOGEO_BANK_CARTRIDGE)->set_base(&state->memregion("maincpu")->base()[state->m_main_cpu_bank_address]);
649651}
650652
r19373r19374
684686}
685687
686688
687static void main_cpu_banking_init( running_machine &machine )
689
690
691void neogeo_main_cpu_banking_init( running_machine &machine )
688692{
693   neogeo_state *state = machine.driver_data<neogeo_state>();
689694   address_space &mainspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
690695
691696   /* create vector banks */
692   machine.root_device().membank(NEOGEO_BANK_VECTORS)->configure_entry(0, machine.root_device().memregion("mainbios")->base());
693   machine.root_device().membank(NEOGEO_BANK_VECTORS)->configure_entry(1, machine.root_device().memregion("maincpu")->base());
697   state->membank(NEOGEO_BANK_VECTORS)->configure_entry(0, machine.root_device().memregion("mainbios")->base());
698   state->membank(NEOGEO_BANK_VECTORS)->configure_entry(1, machine.root_device().memregion("maincpu")->base());
699   
700   if (state->m_is_cartsys)
701   {
694702
695   /* set initial main CPU bank */
696   if (machine.root_device().memregion("maincpu")->bytes() > 0x100000)
697      neogeo_set_main_cpu_bank_address(mainspace, 0x100000);
698   else
699      neogeo_set_main_cpu_bank_address(mainspace, 0x000000);
703      /* set initial main CPU bank */
704      if (machine.root_device().memregion("maincpu")->bytes() > 0x100000)
705         neogeo_set_main_cpu_bank_address(mainspace, 0x100000);
706      else
707         neogeo_set_main_cpu_bank_address(mainspace, 0x000000);
708   }
700709}
701710
702711
703
704712/*************************************
705713 *
706714 *  Audio CPU banking
r19373r19374
865873      {
866874      default:
867875      case 0x00: neogeo_set_screen_dark(machine(), bit); break;
868      case 0x01: set_main_cpu_vector_table_source(machine(), bit);
869               set_audio_cpu_rom_source(space, bit); /* this is a guess */
870               break;
876      case 0x01:
877               if (m_is_cartsys)
878               {
879                  neogeo_set_main_cpu_vector_table_source(machine(), bit); // NeoCD maps the vector swap elsewhere
880               }
881               else
882               {
883#if 0
884                  if (bit)
885                  {
886                     if (m_main_cpu_vector_table_source)
887                        neogeo_set_main_cpu_vector_table_source(machine(), 0);
888                     else
889                        neogeo_set_main_cpu_vector_table_source(machine(), 1);
890                  }
891#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?
893               }
894               if (m_has_audio_banking) set_audio_cpu_rom_source(space, bit); /* this is a guess */
895               break;
871896      case 0x05: neogeo_set_fixed_layer_source(machine(), bit); break;
872897      case 0x06: if (m_is_mvs) set_save_ram_unlock(machine(), bit); break;
873898      case 0x07: neogeo_set_palette_bank(machine(), bit); break;
r19373r19374
10201045   membank(NEOGEO_BANK_BIOS)->set_base(memregion("mainbios")->base());
10211046
10221047   /* set the initial main CPU bank */
1023   main_cpu_banking_init(machine());
1048   neogeo_main_cpu_banking_init(machine());
10241049
10251050   /* set the initial audio CPU ROM banks */
10261051   neogeo_audio_cpu_banking_init(machine());

Previous 199869 Revisions Next


© 1997-2024 The MAME Team