Previous 15994 Revisions Next

r9244 Monday 27th September, 2010 at 22:49:24 UTC by Angelo Salese
[Megadrive] changed way the z80 window into 68k space works so that it automatically can handle things like the 32x. This improves 32x Tempo and allows correct sound samples to be played in 32x Pitfall [David Haywood]
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r9243r9244
619619
620620static UINT16 vdp_get_word_from_68k_mem_default(running_machine *machine, UINT32 source)
621621{
622   // should we limit the valid areas here?
623   // how does this behave with the segacd etc?
624   // with the 32x it seems to see the raw cart? - using 68k space causes the character to vanish
625   // svp uses it's own function elsewhere...
626
622627   if (( source >= 0x000000 ) && ( source <= 0x3fffff ))
623628   {
624629      UINT16 *rom = (UINT16*)memory_region(machine, "maincpu");
r9243r9244
636641      return mame_rand(machine);
637642   }
638643
644
639645}
640646
641647/*  Table from Charles Macdonald
r9243r9244
21002106   timer_set( space->machine, attotime_zero, NULL, 0, megadriv_z80_run_state );
21012107}
21022108
2109
2110// just directly access the 68k space, this makes it easier to deal with
2111// add-on hardware which changes the cpu mapping like the 32x and SegaCD.
2112// - we might need to add exceptions for example, z80 reading / writing the
2113//   z80 area of the 68k if games misbehave
21032114static READ8_HANDLER( z80_read_68k_banked_data )
21042115{
2105   // genz80.z80_bank_addr contains the address to read
2116   address_space *space68k = space->machine->device<legacy_cpu_device>("maincpu")->space();
2117   UINT8 ret = space68k->read_byte(genz80.z80_bank_addr+offset);
2118   return ret;
2119}
21062120
2107   if ((genz80.z80_bank_addr >= 0x000000) && (genz80.z80_bank_addr <= 0x3fffff)) // ROM Addresses
2108   {
2109      UINT32 fulladdress;
2110      fulladdress = genz80.z80_bank_addr + offset;
2111
2112      return memory_region(space->machine, "maincpu")[fulladdress^1]; // ^1? better..
2113
2114
2115   }
2116   else
2117   {
2118      if (_32x_is_connected)
2119      {
2120         if ((genz80.z80_bank_addr >= 0x880000) && (genz80.z80_bank_addr <= 0x900000)) // 'fixed' 512kb 32x rom
2121         {
2122            UINT32 fulladdress;
2123            fulladdress = (genz80.z80_bank_addr + offset)&0x3ffff;
2124
2125            return memory_region(space->machine, "gamecart")[fulladdress^1]; // ^1? better..
2126
2127
2128         }
2129         else if ((genz80.z80_bank_addr >= 0x900000) && (genz80.z80_bank_addr <= 0x9fffff)) // 'banked' 1mb 32x rom
2130         {
2131            UINT32 fulladdress;
2132            fulladdress = (genz80.z80_bank_addr + offset)&0x7ffff;
2133
2134            fulladdress |= (_32x_68k_a15104_reg&0x3)*0x80000;
2135
2136            return memory_region(space->machine, "gamecart")[fulladdress^1]; // ^1? better..
2137
2138         }
2139      }
2140
2141      printf("unhandled z80 bank read, gen.z80_bank_addr %08x\n",genz80.z80_bank_addr);
2142      return 0x0000;
2143   }
2144
2121static WRITE8_HANDLER( z80_write_68k_banked_data )
2122{
2123   address_space *space68k = space->machine->device<legacy_cpu_device>("maincpu")->space();
2124   space68k->write_byte(genz80.z80_bank_addr+offset,data);
21452125}
21462126
21472127
r9243r9244
21622142
21632143}
21642144
2165static WRITE8_HANDLER( z80_write_68k_banked_data )
2166{
2167   UINT32 fulladdress;
2168   fulladdress = genz80.z80_bank_addr + offset;
21692145
21702146
2171//  mame_printf_debug("z80_write_68k_banked_data %04x %02x\n",offset,data);
2172   if ((fulladdress >= 0x000000) && (fulladdress <= 0x3fffff)) // ROM Addresses
2173   {
2174
2175      //mame_printf_debug("z80 write to 68k rom??\n");
2176   }
2177   else if ((fulladdress >= 0xe00000) && (fulladdress <= 0xffffff)) // ROM Addresses
2178   {
2179      fulladdress &=0xffff;
2180      /* Cheese Cat-Astrophe Starring Speedy Gonzales (E) (M4) [!] has no sound without this */
2181      if (fulladdress&1) megadrive_ram[fulladdress>>1] = (megadrive_ram[fulladdress>>1]&0xff00) | (data);
2182      else  megadrive_ram[fulladdress>>1] = (megadrive_ram[fulladdress>>1]&0x00ff) | (data <<8);
2183   }
2184   else if (fulladdress == 0xc00011)
2185   {
2186      /* quite a few early games write here, most of the later ones don't */
2187      sn76496_w(space->machine->device("snsnd"), 0, data);
2188   }
2189   else
2190   {
2191
2192      //printf("z80 write to 68k address %06x\n",fulladdress);
2193   }
2194
2195}
2196
21972147static READ8_HANDLER( megadriv_z80_vdp_read )
21982148{
21992149   mame_printf_debug("megadriv_z80_vdp_read %02x\n",offset);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team