From: Fabio Priuli [mailto:doge.fabio@gmail.com]

Sent: Mon 9/29/2008 9:45 AM
To: submit@mamedev.org
Subject: Small SNES changes
Hi,  

enclosed please find a patch which changes a bit the way SNES 
carts (NSS & bootlegs) are loaded at init time. Currently, data 
are loaded once at start and then the read handlers perform various 
mirroring tricks. With the attached patch, the cart is loaded at 
init and mirrored as many times as it is necessary, while handlers 
simply read from the plain offset. Also, blocks of data are mirrored 
until they fill all the available banks. Implementing this behavior 
both simplifies the handlers code and is more faithful to the hardware 
(see mirroring note included in the DRIVER_INIT).

I also slightly changed some handlers to take into account the new 
mirroring system. OTOH sram_handlers haven't been updated (they will 
be eventually) because with carts as small as the ones in nss.c and 
snesb.c, they basically have no overlapping with the new mirroring 
approach... as soon as I come up with a satisfactory implementation 
that works in MESS (which has to deal with much larger carts), I will 
also submit the MAME side.

No regressions appear with the patch, as far as I could test.

Regards
   Fabio

--

From: Fabio Priuli [mailto:doge.fabio@gmail.com] 
Sent: Wednesday, October 01, 2008 12:01 AM
To: submit@mamedev.org
Subject: further snes changes

Hi,

enclosed please find a patch which rewrites memory handlers in 
machine/snes.c to take into account the additional cart/memory layouts 
(mode 22 & 25) which were available for the home console (almost no 
impact on nss.c & snesb.c, which only use mode 20 & 21). rather than 
only add a bunch of if(snes_cart.mode == XXXX), I preferred to slightly 
rewrite the handlers. main changes on the MAME side are:

* merged regions 0x700000 up to 0x7dffff in snes_map (this allows to 
make memory maps in nss.c and snesb.c identical: the zone previously 
NOPed in nss.c is now handled by snes_r_bank5, because it was not 
reserved for all cart types)
* split region 0x800000-0xbfffff from 0xc00000-0xffffff in snes_map. 
This simplifies a bit handlers used by MAME and it will be necessary 
when MESS supports special chips like SDD-1 (which dynamically changes 
the part of cart loaded in the latter region)
* slightly enlarged SRAM regions (in this case, it only affects what 
happens inside the handler, NOT snes_map) to support carts with 512kbits 
of SRAM (e.g. Thoroughbred Breeder III for MESS). I'm still not 100% 
satisfied with SRAM mirroring, but this is closer to the real thing 
than the previous way to handle it

No regressions are present, neither in MAME nor in MESS, as far as I 
could test (well, for MAME weren't expected, since most changes affected 
mode 22 & 25).

Regards,
     Fabio
This commit is contained in:
Aaron Giles 2008-10-02 05:09:37 +00:00
parent 96943508cd
commit 18c6cfb56a
4 changed files with 659 additions and 488 deletions

View File

@ -299,11 +299,11 @@ static ADDRESS_MAP_START( snes_map, ADDRESS_SPACE_PROGRAM, 8)
AM_RANGE(0x000000, 0x2fffff) AM_READWRITE(snes_r_bank1, snes_w_bank1) /* I/O and ROM (repeats for each bank) */
AM_RANGE(0x300000, 0x3fffff) AM_READWRITE(snes_r_bank2, snes_w_bank2) /* I/O and ROM (repeats for each bank) */
AM_RANGE(0x400000, 0x5fffff) AM_READWRITE(snes_r_bank3, SMH_ROM) /* ROM (and reserved in Mode 20) */
AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(snes_r_bank6, snes_w_bank6) /* used by Mode 20 DSP-1 */
AM_RANGE(0x700000, 0x77ffff) AM_READWRITE(snes_r_sram, snes_w_sram) /* 256KB Mode 20 save ram + reserved from 0x8000 - 0xffff */
AM_RANGE(0x780000, 0x7dffff) AM_NOP /* Reserved */
AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(snes_r_bank4, snes_w_bank4) /* used by Mode 20 DSP-1 */
AM_RANGE(0x700000, 0x7dffff) AM_READWRITE(snes_r_bank5, snes_w_bank5)
AM_RANGE(0x7e0000, 0x7fffff) AM_RAM /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */
AM_RANGE(0x800000, 0xffffff) AM_READWRITE(snes_r_bank4, snes_w_bank4) /* Mirror and ROM */
AM_RANGE(0x800000, 0xbfffff) AM_READWRITE(snes_r_bank6, snes_w_bank6) /* Mirror and ROM */
AM_RANGE(0xc00000, 0xffffff) AM_READWRITE(snes_r_bank7, snes_w_bank7) /* Mirror and ROM */
ADDRESS_MAP_END
static READ8_HANDLER( spc_ram_100_r )

View File

@ -130,10 +130,11 @@ static ADDRESS_MAP_START( snesb_map, ADDRESS_SPACE_PROGRAM, 8)
AM_RANGE(0x000000, 0x2fffff) AM_READWRITE(snes_r_bank1, snes_w_bank1) /* I/O and ROM (repeats for each bank) */
AM_RANGE(0x300000, 0x3fffff) AM_READWRITE(snes_r_bank2, snes_w_bank2) /* I/O and ROM (repeats for each bank) */
AM_RANGE(0x400000, 0x5fffff) AM_READWRITE(snes_r_bank3, SMH_ROM) /* ROM (and reserved in Mode 20) */
AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(snes_r_bank6, snes_w_bank6) /* used by Mode 20 DSP-1 */
AM_RANGE(0x700000, 0x77ffff) AM_READWRITE(snes_r_sram, snes_w_sram) /* 256KB Mode 20 save ram + reserved from 0x8000 - 0xffff */
AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(snes_r_bank4, snes_w_bank4) /* used by Mode 20 DSP-1 */
AM_RANGE(0x700000, 0x7dffff) AM_READWRITE(snes_r_bank5, snes_w_bank5)
AM_RANGE(0x7e0000, 0x7fffff) AM_RAM /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */
AM_RANGE(0x800000, 0xffffff) AM_READWRITE(snes_r_bank4, snes_w_bank4) /* Mirror and ROM */
AM_RANGE(0x800000, 0xbfffff) AM_READWRITE(snes_r_bank6, snes_w_bank6) /* Mirror and ROM */
AM_RANGE(0xc00000, 0xffffff) AM_READWRITE(snes_r_bank7, snes_w_bank7) /* Mirror and ROM */
ADDRESS_MAP_END
static READ8_HANDLER( spc_ram_100_r )

View File

@ -359,19 +359,25 @@ extern DRIVER_INIT( snes_hirom );
extern MACHINE_START( snes );
extern MACHINE_RESET( snes );
extern READ8_HANDLER( snes_r_io );
extern WRITE8_HANDLER( snes_w_io );
extern READ8_HANDLER( snes_r_bank1 );
extern READ8_HANDLER( snes_r_bank2 );
extern READ8_HANDLER( snes_r_bank3 );
extern READ8_HANDLER( snes_r_bank4 );
extern READ8_HANDLER( snes_r_bank5 );
extern READ8_HANDLER( snes_r_bank6 );
extern READ8_HANDLER( snes_r_io );
extern READ8_HANDLER( snes_r_sram );
extern READ8_HANDLER( snes_r_bank7 );
extern WRITE8_HANDLER( snes_w_bank1 );
extern WRITE8_HANDLER( snes_w_bank2 );
extern WRITE8_HANDLER( snes_w_bank3 );
extern WRITE8_HANDLER( snes_w_bank4 );
extern WRITE8_HANDLER( snes_w_bank5 );
extern WRITE8_HANDLER( snes_w_bank6 );
extern WRITE8_HANDLER( snes_w_io );
extern WRITE8_HANDLER( snes_w_sram );
extern WRITE8_HANDLER( snes_w_bank7 );
extern void snes_gdma( UINT8 channels );
extern void snes_hdma_init(void);

File diff suppressed because it is too large Load Diff