trunk/src/mess/drivers/saturn.c
| r29215 | r29216 | |
| 43 | 43 | #include "sound/scsp.h" |
| 44 | 44 | #include "sound/cdda.h" |
| 45 | 45 | #include "machine/smpc.h" |
| 46 | #include "machine/nvram.h" |
| 46 | 47 | #include "includes/stv.h" |
| 47 | 48 | #include "imagedev/chd_cd.h" |
| 48 | 49 | #include "coreutil.h" |
| r29215 | r29216 | |
| 52 | 53 | #include "bus/saturn/dram.h" |
| 53 | 54 | #include "bus/saturn/bram.h" |
| 54 | 55 | |
| 55 | | #include "mcfglgcy.h" |
| 56 | 56 | |
| 57 | | |
| 58 | 57 | class sat_console_state : public saturn_state |
| 59 | 58 | { |
| 60 | 59 | public: |
| 61 | 60 | sat_console_state(const machine_config &mconfig, device_type type, const char *tag) |
| 62 | 61 | : saturn_state(mconfig, type, tag) |
| 63 | 62 | , m_exp(*this, "exp") |
| 63 | , m_nvram(*this, "nvram") |
| 64 | , m_smpc_nv(*this, "smpc_nv") |
| 64 | 65 | { } |
| 65 | 66 | |
| 66 | 67 | DECLARE_INPUT_CHANGED_MEMBER(key_stroke); |
| r29215 | r29216 | |
| 82 | 83 | DECLARE_DRIVER_INIT(saturneu); |
| 83 | 84 | DECLARE_DRIVER_INIT(saturnjp); |
| 84 | 85 | |
| 86 | void nvram_init(nvram_device &nvram, void *data, size_t size); |
| 87 | |
| 85 | 88 | required_device<sat_cart_slot_device> m_exp; |
| 89 | required_device<nvram_device> m_nvram; |
| 90 | required_device<nvram_device> m_smpc_nv; // TODO: move this in the base class saturn_state and add it to stv in MAME |
| 86 | 91 | }; |
| 87 | 92 | |
| 88 | 93 | |
| 89 | | /* TODO: if you change the driver configuration then NVRAM contents gets screwed, needs mods in MAME framework */ |
| 90 | | static NVRAM_HANDLER(saturn) |
| 91 | | { |
| 92 | | sat_console_state *state = machine.driver_data<sat_console_state>(); |
| 93 | | static const UINT32 BUP_SIZE = 32*1024; |
| 94 | | UINT8 backup_file[(BUP_SIZE)+4]; |
| 95 | | static const UINT8 init[16] = |
| 96 | | { |
| 97 | | 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't' |
| 98 | | }; |
| 99 | | UINT32 i; |
| 100 | | |
| 101 | | if (read_or_write) |
| 102 | | { |
| 103 | | for(i=0;i<BUP_SIZE;i++) |
| 104 | | backup_file[i] = state->m_backupram[i]; |
| 105 | | for(i=0;i<4;i++) |
| 106 | | backup_file[i+(BUP_SIZE)] = state->m_smpc.SMEM[i]; |
| 107 | | |
| 108 | | file->write(backup_file, (BUP_SIZE)+4); |
| 109 | | } |
| 110 | | else |
| 111 | | { |
| 112 | | if (file) |
| 113 | | { |
| 114 | | file->read(backup_file, (BUP_SIZE)+4); |
| 115 | | |
| 116 | | for(i=0;i<BUP_SIZE;i++) |
| 117 | | state->m_backupram[i] = backup_file[i]; |
| 118 | | for(i=0;i<4;i++) |
| 119 | | state->m_smpc.SMEM[i] = backup_file[i+BUP_SIZE]; |
| 120 | | } |
| 121 | | else |
| 122 | | { |
| 123 | | UINT8 j; |
| 124 | | memset(state->m_backupram, 0, BUP_SIZE); |
| 125 | | for (i = 0; i < 4; i++) |
| 126 | | { |
| 127 | | for(j=0;j<16;j++) |
| 128 | | state->m_backupram[i*16+j] = init[j]; |
| 129 | | } |
| 130 | | memset(state->m_smpc.SMEM, 0, 4); // TODO: default for each region |
| 131 | | } |
| 132 | | } |
| 133 | | } |
| 134 | | |
| 135 | 94 | READ8_MEMBER(sat_console_state::saturn_cart_type_r) |
| 136 | 95 | { |
| 137 | 96 | if (m_exp) |
| r29215 | r29216 | |
| 585 | 544 | PORT_CONFSETTING(0x01,"One Shot (Hack)") |
| 586 | 545 | INPUT_PORTS_END |
| 587 | 546 | |
| 547 | |
| 548 | /* TODO: if you change the driver configuration then NVRAM contents gets screwed, needs mods in MAME framework */ |
| 549 | void sat_console_state::nvram_init(nvram_device &nvram, void *data, size_t size) |
| 550 | { |
| 551 | static const UINT8 init[64] = { |
| 552 | 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't', |
| 553 | 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't', |
| 554 | 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't', |
| 555 | 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't', }; |
| 556 | |
| 557 | memset(data, 0x00, size); |
| 558 | memcpy(data, init, sizeof(init)); |
| 559 | } |
| 560 | |
| 561 | |
| 588 | 562 | static const sh2_cpu_core sh2_conf_master = { 0, NULL }; |
| 589 | 563 | static const sh2_cpu_core sh2_conf_slave = { 1, NULL }; |
| 590 | 564 | |
| 591 | 565 | |
| 592 | | MACHINE_START_MEMBER(sat_console_state,saturn) |
| 566 | MACHINE_START_MEMBER(sat_console_state, saturn) |
| 593 | 567 | { |
| 594 | 568 | system_time systime; |
| 595 | 569 | machine().base_datetime(systime); |
| r29215 | r29216 | |
| 602 | 576 | m_maincpu->space(AS_PROGRAM).nop_readwrite(0x04000000, 0x047fffff); |
| 603 | 577 | m_slave->space(AS_PROGRAM).nop_readwrite(0x04000000, 0x047fffff); |
| 604 | 578 | |
| 579 | m_nvram->set_base(m_backupram, 0x8000); |
| 580 | m_smpc_nv->set_base(&m_smpc.SMEM, 4); |
| 581 | |
| 605 | 582 | if (m_exp) |
| 606 | 583 | { |
| 607 | 584 | switch (m_exp->get_cart_type()) |
| r29215 | r29216 | |
| 708 | 685 | m_NMI_reset = 0; |
| 709 | 686 | m_smpc.slave_on = 0; |
| 710 | 687 | |
| 711 | | |
| 712 | 688 | //memset(stv_m_workram_l, 0, 0x100000); |
| 713 | 689 | //memset(stv_m_workram_h, 0, 0x100000); |
| 714 | 690 | |
| r29215 | r29216 | |
| 765 | 741 | MCFG_MACHINE_START_OVERRIDE(sat_console_state,saturn) |
| 766 | 742 | MCFG_MACHINE_RESET_OVERRIDE(sat_console_state,saturn) |
| 767 | 743 | |
| 768 | | MCFG_NVRAM_HANDLER(saturn) |
| 744 | MCFG_NVRAM_ADD_CUSTOM_DRIVER("nvram", sat_console_state, nvram_init) |
| 745 | MCFG_NVRAM_ADD_0FILL("smpc_nv") // TODO: default for each region (+ move it inside SMPC when converted to device) |
| 769 | 746 | |
| 770 | 747 | MCFG_TIMER_DRIVER_ADD("sector_timer", sat_console_state, stv_sector_cb) |
| 771 | 748 | MCFG_TIMER_DRIVER_ADD("sh1_cmd", sat_console_state, stv_sh1_sim) |