Previous 199869 Revisions Next

r20244 Sunday 13th January, 2013 at 13:36:12 UTC by Wilbert Pol
(MESS)sms.c: Keep RAM working normally when no scope is attached. (nw)
[src/mess/drivers]sms.c
[src/mess/includes]sms.h
[src/mess/machine]sms.c

trunk/src/mess/machine/sms.c
r20243r20244
868868
869869READ8_MEMBER(sms_state::sms_sscope_r)
870870{
871   return m_sscope_state;
871   int sscope = machine().root_device().ioport("SEGASCOPE")->read_safe(0x00);
872
873   if ( sscope )
874   {
875      // Scope is attached
876      return m_sscope_state;
877   }
878
879   return m_mainram[0x1FF8 + offset];
872880}
873881
874882
875883WRITE8_MEMBER(sms_state::sms_sscope_w)
876884{
877   screen_device *screen = machine().first_screen();
885   m_mainram[0x1FF8 + offset] = data;
878886
879   m_sscope_state = data;
887   int sscope = machine().root_device().ioport("SEGASCOPE")->read_safe(0x00);
880888
881   // There are occurrences when Sega Scope's state changes after VBLANK, or at
882   // active screen. Most cases are solid-color frames of scene transitions, but
883   // one exception is the first frame of Zaxxon 3-D's title screen. In that
884   // case, this method is enough for setting the intended state for the frame.
885   // No information found about a minimum time need for switch open/closed lens.
886   if (screen->vpos() < (screen->height() >> 1))
887      m_frame_sscope_state = m_sscope_state;
889   if ( sscope )
890   {
891      // Scope is attached
892      screen_device *screen = machine().first_screen();
893
894      m_sscope_state = data;
895
896      // There are occurrences when Sega Scope's state changes after VBLANK, or at
897      // active screen. Most cases are solid-color frames of scene transitions, but
898      // one exception is the first frame of Zaxxon 3-D's title screen. In that
899      // case, this method is enough for setting the intended state for the frame.
900      // No information found about a minimum time need for switch open/closed lens.
901      if (screen->vpos() < (screen->height() >> 1))
902      {
903         m_frame_sscope_state = m_sscope_state;
904      }
905   }
888906}
889907
890908
891909READ8_MEMBER(sms_state::sms_mapper_r)
892910{
893   return m_mapper[offset];
911   return m_mainram[0x1FFC + offset];
894912}
895913
896914/* Terebi Oekaki */
r20243r20244
960978   offset &= 3;
961979
962980   m_mapper[offset] = data;
963   m_mapper_ram[offset] = data;
981   m_mainram[0x1FFC + offset] = data;
964982
965983   if (m_bios_port & IO_BIOS_ROM || (m_is_gamegear && m_BIOS == NULL))
966984   {
r20243r20244
19411959   // in Japan region (including KR), until confirmed on other consoles.
19421960   if (m_is_region_japan)
19431961   {
1944      memset((UINT8*)m_space->get_write_ptr(0xc000), 0xf0, 0x1FF0);
1962      memset((UINT8*)m_space->get_write_ptr(0xc000), 0xf0, 0x1FFF);
19451963   }
19461964}
19471965
r20243r20244
19531971   if (m_has_fm)
19541972      m_fm_detect = 0x01;
19551973
1956   m_mapper_ram = (UINT8*)space.get_write_ptr(0xdffc);
1957
19581974   m_bios_port = 0;
19591975
19601976   if ( m_cartridge[m_current_cartridge].features & CF_CODEMASTERS_MAPPER )
trunk/src/mess/includes/sms.h
r20243r20244
2626
2727public:
2828   sms_state(const machine_config &mconfig, device_type type, const char *tag)
29   : driver_device(mconfig, type, tag) { }
29      : driver_device(mconfig, type, tag)
30      , m_mainram(*this, "mainram")
31   {
32   }
3033
3134   // device_ts
3235   device_t *m_main_cpu;
r20243r20244
4548   int m_paused;
4649   UINT8 m_bios_port;
4750   UINT8 *m_BIOS;
48   UINT8 *m_mapper_ram;
4951   UINT8 m_mapper[4];
5052   // we are going to use 1-6, same as bank numbers. Notice, though, that most mappers
5153   // only work on 16K banks and, hence, banks 4-6 are not always directly set
r20243r20244
195197   DECLARE_WRITE_LINE_MEMBER(sms_int_callback);
196198   DECLARE_WRITE_LINE_MEMBER(sms_pause_callback);
197199   DECLARE_WRITE_LINE_MEMBER(sms_store_int_callback);
200
201protected:
202   required_shared_ptr<UINT8> m_mainram;
198203};
199204
200205
trunk/src/mess/drivers/sms.c
r20243r20244
7474
7575
7676static ADDRESS_MAP_START( sms1_mem, AS_PROGRAM, 8, sms_state )
77   AM_RANGE(0x0000, 0x03ff) AM_ROMBANK("bank1")                    /* First 0x0400 part always points to first page */
78   AM_RANGE(0x0400, 0x1fff) AM_ROMBANK("bank2")                    /* switchable rom bank */
79   AM_RANGE(0x2000, 0x3fff) AM_ROMBANK("bank7")                    /* switchable rom bank */
80   AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank3")                    /* switchable rom bank */
81   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank4")                    /* switchable rom bank */
77   AM_RANGE(0x0000, 0x03ff) AM_ROMBANK("bank1")                            /* First 0x0400 part always points to first page */
78   AM_RANGE(0x0400, 0x1fff) AM_ROMBANK("bank2")                            /* switchable rom bank */
79   AM_RANGE(0x2000, 0x3fff) AM_ROMBANK("bank7")                            /* switchable rom bank */
80   AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank3")                            /* switchable rom bank */
81   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank4")                            /* switchable rom bank */
8282   AM_RANGE(0x8000, 0x9fff) AM_READ_BANK("bank5") AM_WRITE(sms_cartram_w)  /* ROM bank / on-cart RAM */
8383   AM_RANGE(0xa000, 0xbfff) AM_READ_BANK("bank6") AM_WRITE(sms_cartram2_w) /* ROM bank / on-cart RAM */
84   AM_RANGE(0xc000, 0xdff7) AM_MIRROR(0x2000) AM_RAM           /* RAM (mirror at 0xE000) */
85   AM_RANGE(0xdff8, 0xdfff) AM_RAM                     /* RAM "underneath" frame registers */
86   AM_RANGE(0xfff8, 0xfffb) AM_READWRITE(sms_sscope_r, sms_sscope_w)   /* 3-D glasses */
87   AM_RANGE(0xfffc, 0xffff) AM_READWRITE(sms_mapper_r, sms_mapper_w)   /* Bankswitch control */
84   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_SHARE("mainram")                     /* RAM */
85   AM_RANGE(0xe000, 0xfff7) AM_RAM AM_SHARE("mainram")                     /* RAM (mirror) */
86   AM_RANGE(0xfff8, 0xfffb) AM_READWRITE(sms_sscope_r, sms_sscope_w)       /* 3-D glasses */
87   AM_RANGE(0xfffc, 0xffff) AM_READWRITE(sms_mapper_r, sms_mapper_w)       /* Bankswitch control */
8888ADDRESS_MAP_END
8989
9090static ADDRESS_MAP_START( sms_mem, AS_PROGRAM, 8, sms_state )
91   AM_RANGE(0x0000, 0x03ff) AM_ROMBANK("bank1")                    /* First 0x0400 part always points to first page */
92   AM_RANGE(0x0400, 0x1fff) AM_ROMBANK("bank2")                    /* switchable rom bank */
93   AM_RANGE(0x2000, 0x3fff) AM_ROMBANK("bank7")                    /* switchable rom bank */
94   AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank3")                    /* switchable rom bank */
95   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank4")                    /* switchable rom bank */
91   AM_RANGE(0x0000, 0x03ff) AM_ROMBANK("bank1")                            /* First 0x0400 part always points to first page */
92   AM_RANGE(0x0400, 0x1fff) AM_ROMBANK("bank2")                            /* switchable rom bank */
93   AM_RANGE(0x2000, 0x3fff) AM_ROMBANK("bank7")                            /* switchable rom bank */
94   AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank3")                            /* switchable rom bank */
95   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank4")                            /* switchable rom bank */
9696   AM_RANGE(0x8000, 0x9fff) AM_READ_BANK("bank5") AM_WRITE(sms_cartram_w)  /* ROM bank / on-cart RAM */
9797   AM_RANGE(0xa000, 0xbfff) AM_READ_BANK("bank6") AM_WRITE(sms_cartram2_w) /* ROM bank / on-cart RAM */
98   AM_RANGE(0xc000, 0xdffb) AM_MIRROR(0x2000) AM_RAM           /* RAM (mirror at 0xE000) */
99   AM_RANGE(0xdffc, 0xdfff) AM_RAM                     /* RAM "underneath" frame registers */
100   AM_RANGE(0xfffc, 0xffff) AM_READWRITE(sms_mapper_r, sms_mapper_w)   /* Bankswitch control */
98   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_SHARE("mainram")                     /* RAM */
99   AM_RANGE(0xe000, 0xfffb) AM_RAM AM_SHARE("mainram")                     /* RAM (mirror) */
100   AM_RANGE(0xfffc, 0xffff) AM_READWRITE(sms_mapper_r, sms_mapper_w)       /* Bankswitch control */
101101ADDRESS_MAP_END
102102
103103static ADDRESS_MAP_START( sms_store_mem, AS_PROGRAM, 8, sms_state )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team