src/mess/drivers/jaguar.c
| r5493 | r5494 | |
| 78 | 78 | *************************************/ |
| 79 | 79 | |
| 80 | 80 | static UINT32 joystick_data; |
| 81 | | static UINT8 eeprom_enable; |
| 82 | | |
| 83 | 81 | static UINT32 *rom_base; |
| 84 | 82 | static size_t rom_size; |
| 85 | | |
| 86 | 83 | static UINT32 *cart_base; |
| 87 | 84 | static size_t cart_size; |
| 88 | | |
| 89 | 85 | static UINT8 eeprom_bit_count; |
| 90 | 86 | |
| 91 | 87 | |
| r5493 | r5494 | |
| 123 | 119 | memory_set_bankptr(machine, 12, jaguar_gpu_ram); |
| 124 | 120 | memory_set_bankptr(machine, 13, jaguar_dsp_ram); |
| 125 | 121 | memory_set_bankptr(machine, 14, jaguar_shared_ram); |
| 126 | | #endif |
| 127 | 122 | memory_set_bankptr(machine, 15, cart_base); |
| 128 | 123 | memory_set_bankptr(machine, 16, rom_base); |
| 129 | | // memory_set_bankptr(machine, 17, jaguar_gpu_ram); |
| 124 | memory_set_bankptr(machine, 17, jaguar_gpu_ram); |
| 125 | #endif |
| 130 | 126 | |
| 131 | 127 | /* clear any spinuntil stuff */ |
| 132 | 128 | jaguar_gpu_resume(machine); |
| r5493 | r5494 | |
| 155 | 151 | ********************************************************************/ |
| 156 | 152 | |
| 157 | 153 | |
| 154 | static mame_file *jaguar_nvram_fopen( running_machine *machine, UINT32 openflags) |
| 155 | { |
| 156 | const device_config *image = devtag_get_device(machine, "cart"); |
| 157 | astring *fname; |
| 158 | file_error filerr; |
| 159 | mame_file *file; |
| 160 | fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, image_basename_noext(image), ".nv"); |
| 161 | filerr = mame_fopen( SEARCHPATH_NVRAM, astring_c( fname), openflags, &file); |
| 162 | astring_free( fname); |
| 163 | return (filerr == FILERR_NONE) ? file : NULL; |
| 164 | } |
| 165 | |
| 166 | static void jaguar_nvram_load(running_machine *machine) |
| 167 | { |
| 168 | mame_file *nvram_file = NULL; |
| 169 | const device_config *device; |
| 170 | |
| 171 | if (machine->config->nvram_handler != NULL) |
| 172 | { |
| 173 | nvram_file = jaguar_nvram_fopen(machine, OPEN_FLAG_READ); |
| 174 | eeprom_load(nvram_file); |
| 175 | } |
| 176 | |
| 177 | for (device = machine->config->devicelist; device != NULL; device = device->next) |
| 178 | { |
| 179 | device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM); |
| 180 | if (nvram != NULL) |
| 181 | { |
| 182 | if (nvram_file == NULL) |
| 183 | nvram_file = nvram_fopen(machine, OPEN_FLAG_READ); |
| 184 | (*nvram)(device, nvram_file, 0); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | if (nvram_file != NULL) |
| 189 | mame_fclose(nvram_file); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | static void jaguar_nvram_save(running_machine *machine) |
| 194 | { |
| 195 | mame_file *nvram_file = NULL; |
| 196 | const device_config *device; |
| 197 | |
| 198 | if (machine->config->nvram_handler != NULL) |
| 199 | { |
| 200 | nvram_file = jaguar_nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); |
| 201 | eeprom_save(nvram_file); |
| 202 | } |
| 203 | |
| 204 | for (device = machine->config->devicelist; device != NULL; device = device->next) |
| 205 | { |
| 206 | device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM); |
| 207 | if (nvram != NULL) |
| 208 | { |
| 209 | if (nvram_file == NULL) |
| 210 | nvram_file = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); |
| 211 | (*nvram)(device, nvram_file, 1); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | if (nvram_file != NULL) |
| 216 | mame_fclose(nvram_file); |
| 217 | } |
| 218 | |
| 158 | 219 | static NVRAM_HANDLER( jaguar ) |
| 159 | 220 | { |
| 160 | 221 | if (read_or_write) |
| 161 | | eeprom_save(file); |
| 222 | jaguar_nvram_save(machine); |
| 162 | 223 | else |
| 163 | 224 | { |
| 164 | 225 | eeprom_init(machine, &eeprom_interface_93C46); |
| 165 | 226 | |
| 166 | 227 | if (file) |
| 167 | | eeprom_load(file); |
| 228 | jaguar_nvram_load(machine); |
| 168 | 229 | } |
| 169 | 230 | } |
| 170 | 231 | |
| r5493 | r5494 | |
| 347 | 408 | static ADDRESS_MAP_START( jaguar_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| 348 | 409 | ADDRESS_MAP_GLOBAL_MASK(0xffffff) |
| 349 | 410 | AM_RANGE(0x000000, 0x1fffff) AM_RAM AM_BASE(&jaguar_shared_ram) AM_MIRROR(0x200000) AM_SHARE(1) AM_REGION("maincpu", 0) |
| 350 | | AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_BASE(&cart_base) AM_SIZE(&cart_size) AM_REGION("maincpu", 0x800000) |
| 351 | | AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_BASE(&rom_base) AM_SIZE(&rom_size) AM_REGION("maincpu", 0xe00000) |
| 411 | AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_BASE(&cart_base) AM_SIZE(&cart_size) AM_SHARE(15) AM_REGION("maincpu", 0x800000) |
| 412 | AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_BASE(&rom_base) AM_SIZE(&rom_size) AM_SHARE(16) AM_REGION("maincpu", 0xe00000) |
| 352 | 413 | AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE(jaguar_tom_regs32_r, jaguar_tom_regs32_w) |
| 353 | 414 | AM_RANGE(0xf00400, 0xf007ff) AM_RAM AM_BASE(&jaguar_gpu_clut) AM_SHARE(2) |
| 354 | 415 | AM_RANGE(0xf02100, 0xf021ff) AM_MIRROR(0x008000) AM_READWRITE(gpuctrl_r, gpuctrl_w) |
| r5493 | r5494 | |
| 372 | 433 | |
| 373 | 434 | static ADDRESS_MAP_START( gpu_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| 374 | 435 | ADDRESS_MAP_GLOBAL_MASK(0xffffff) |
| 375 | | AM_RANGE(0x000000, 0x1fffff) AM_MIRROR(0x200000) AM_RAM AM_SHARE(1) |
| 376 | | AM_RANGE(0x800000, 0xdfffff) AM_ROMBANK(15) |
| 377 | | AM_RANGE(0xe00000, 0xe1ffff) AM_ROMBANK(16) |
| 436 | AM_RANGE(0x000000, 0x1fffff) AM_MIRROR(0x200000) AM_RAM AM_SHARE(1) AM_REGION("maincpu", 0) |
| 437 | AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_SHARE(15) AM_REGION("maincpu", 0x800000) |
| 438 | AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_SHARE(16) AM_REGION("maincpu", 0xe00000) |
| 378 | 439 | AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE(jaguar_tom_regs32_r, jaguar_tom_regs32_w) |
| 379 | 440 | AM_RANGE(0xf00400, 0xf007ff) AM_RAM AM_SHARE(2) |
| 380 | 441 | AM_RANGE(0xf02100, 0xf021ff) AM_MIRROR(0x008000) AM_READWRITE(gpuctrl_r, gpuctrl_w) |
| r5493 | r5494 | |
| 488 | 549 | PORT_BIT( 0xfffc, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 489 | 550 | |
| 490 | 551 | PORT_START("CONFIG") |
| 552 | // PORT_CONFNAME( 0x02, 0x02, "Show Logo") |
| 553 | // PORT_CONFSETTING( 0x00, "Yes") |
| 554 | // PORT_CONFSETTING( 0x02, "No") |
| 491 | 555 | PORT_CONFNAME( 0x04, 0x04, "TV System") |
| 492 | 556 | PORT_CONFSETTING( 0x00, "PAL") |
| 493 | 557 | PORT_CONFSETTING( 0x04, "NTSC") |
| r5493 | r5494 | |
| 590 | 654 | static DRIVER_INIT( jaguar ) |
| 591 | 655 | { |
| 592 | 656 | state_save_register_global(machine, joystick_data); |
| 593 | | state_save_register_global(machine, eeprom_enable); |
| 594 | | |
| 595 | | /* init the sound system and install DSP speedups */ |
| 596 | | // cojag_sound_init(machine); // rom makes this redundant |
| 597 | 657 | } |
| 598 | 658 | |
| 599 | 659 | static QUICKLOAD_LOAD( jaguar ) |
| r5493 | r5494 | |
| 639 | 699 | cart_base[i] = ((j & 0xff) << 24) | ((j & 0xff00) << 8) | ((j & 0xff0000) >> 8) | ((j & 0xff000000) >> 24); |
| 640 | 700 | } |
| 641 | 701 | |
| 642 | | /* Disable logo - breaks Doom */ |
| 643 | | rom_base[0x53c / 4] = 0x67000002; |
| 702 | /* Disable logo? - can't do this because of core fatal warning */ |
| 703 | //if (input_port_read(image->machine, "CONFIG") & 2) |
| 704 | rom_base[0x53c / 4] = 0x67000002; |
| 644 | 705 | |
| 645 | 706 | /* Transfer control to the bios */ |
| 646 | 707 | cpu_set_reg(cputag_get_cpu(image->machine, "maincpu"), REG_GENPC, rom_base[1]); |