Previous 199869 Revisions Next

r29216 Thursday 3rd April, 2014 at 10:05:07 UTC by Fabio Priuli
(MESS) saturn: modernized nvram. nw.
[src/mess/drivers]saturn.c

trunk/src/mess/drivers/saturn.c
r29215r29216
4343#include "sound/scsp.h"
4444#include "sound/cdda.h"
4545#include "machine/smpc.h"
46#include "machine/nvram.h"
4647#include "includes/stv.h"
4748#include "imagedev/chd_cd.h"
4849#include "coreutil.h"
r29215r29216
5253#include "bus/saturn/dram.h"
5354#include "bus/saturn/bram.h"
5455
55#include "mcfglgcy.h"
5656
57
5857class sat_console_state : public saturn_state
5958{
6059public:
6160   sat_console_state(const machine_config &mconfig, device_type type, const char *tag)
6261            : saturn_state(mconfig, type, tag)
6362            , m_exp(*this, "exp")
63            , m_nvram(*this, "nvram")
64            , m_smpc_nv(*this, "smpc_nv")
6465   { }
6566
6667   DECLARE_INPUT_CHANGED_MEMBER(key_stroke);
r29215r29216
8283   DECLARE_DRIVER_INIT(saturneu);
8384   DECLARE_DRIVER_INIT(saturnjp);
8485
86   void nvram_init(nvram_device &nvram, void *data, size_t size);
87
8588   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
8691};
8792
8893
89/* TODO: if you change the driver configuration then NVRAM contents gets screwed, needs mods in MAME framework */
90static 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
13594READ8_MEMBER(sat_console_state::saturn_cart_type_r)
13695{
13796   if (m_exp)
r29215r29216
585544   PORT_CONFSETTING(0x01,"One Shot (Hack)")
586545INPUT_PORTS_END
587546
547
548/* TODO: if you change the driver configuration then NVRAM contents gets screwed, needs mods in MAME framework */
549void 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
588562static const sh2_cpu_core sh2_conf_master = { 0, NULL };
589563static const sh2_cpu_core sh2_conf_slave  = { 1, NULL };
590564
591565
592MACHINE_START_MEMBER(sat_console_state,saturn)
566MACHINE_START_MEMBER(sat_console_state, saturn)
593567{
594568   system_time systime;
595569   machine().base_datetime(systime);
r29215r29216
602576   m_maincpu->space(AS_PROGRAM).nop_readwrite(0x04000000, 0x047fffff);
603577   m_slave->space(AS_PROGRAM).nop_readwrite(0x04000000, 0x047fffff);
604578
579   m_nvram->set_base(m_backupram, 0x8000);
580   m_smpc_nv->set_base(&m_smpc.SMEM, 4);
581
605582   if (m_exp)
606583   {
607584      switch (m_exp->get_cart_type())
r29215r29216
708685   m_NMI_reset = 0;
709686   m_smpc.slave_on = 0;
710687
711
712688   //memset(stv_m_workram_l, 0, 0x100000);
713689   //memset(stv_m_workram_h, 0, 0x100000);
714690
r29215r29216
765741   MCFG_MACHINE_START_OVERRIDE(sat_console_state,saturn)
766742   MCFG_MACHINE_RESET_OVERRIDE(sat_console_state,saturn)
767743
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)
769746
770747   MCFG_TIMER_DRIVER_ADD("sector_timer", sat_console_state, stv_sector_cb)
771748   MCFG_TIMER_DRIVER_ADD("sh1_cmd", sat_console_state, stv_sh1_sim)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team