mirror of
https://github.com/holub/mame
synced 2025-05-18 19:49:35 +03:00
sega16sp: moved bootleg interfaces to the system 16 bootleg driver and added different interfaces to avoid drivers to directly access device private items. No whatsnew.
snes.c: moved some more elements to driver_data class and added skeleton support for the BS-X satellaview addon (which will be used by MESS, eventually). No whatsnew.
This commit is contained in:
parent
5424d5b9ac
commit
728e00bc44
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3186,6 +3186,7 @@ src/mame/machine/slapstic.c svneol=native#text/plain
|
||||
src/mame/machine/slikshot.c svneol=native#text/plain
|
||||
src/mame/machine/snes.c svneol=native#text/plain
|
||||
src/mame/machine/snes7110.c svneol=native#text/plain
|
||||
src/mame/machine/snesbsx.c svneol=native#text/plain
|
||||
src/mame/machine/snescx4.c svneol=native#text/plain
|
||||
src/mame/machine/snescx4.h svneol=native#text/plain
|
||||
src/mame/machine/snesdsp1.c svneol=native#text/plain
|
||||
|
@ -2083,6 +2083,16 @@ static MACHINE_DRIVER_START( system16_datsu_sound )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
|
||||
static const sega16sp_interface shinobld_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
117, // xoffs
|
||||
segaic16_sprites_16a_bootleg_shinobld_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( shinobib )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -2090,12 +2100,22 @@ static MACHINE_DRIVER_START( shinobib )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(shinobib_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_SHINOBI_BOOTLEG("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", shinobld_sega16sp_intf)
|
||||
|
||||
MDRV_VIDEO_START( s16a_bootleg_shinobi )
|
||||
MDRV_VIDEO_UPDATE( s16a_bootleg )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static const sega16sp_interface passshtb_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
117, // xoffs
|
||||
segaic16_sprites_16a_bootleg_passhtb_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( passshtb )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -2103,7 +2123,7 @@ static MACHINE_DRIVER_START( passshtb )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(passshtb_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_PASSINGSHOT_BOOTLEG("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", passshtb_sega16sp_intf)
|
||||
|
||||
MDRV_VIDEO_START( s16a_bootleg_passsht )
|
||||
MDRV_VIDEO_UPDATE( s16a_bootleg )
|
||||
@ -2118,12 +2138,22 @@ static MACHINE_DRIVER_START( passsht4b )
|
||||
MDRV_CPU_PROGRAM_MAP(passht4b_map)
|
||||
|
||||
// wrong
|
||||
MDRV_SEGA16SP_ADD_PASSINGSHOT_BOOTLEG("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", passshtb_sega16sp_intf)
|
||||
|
||||
MDRV_VIDEO_START( s16a_bootleg_passsht )
|
||||
MDRV_VIDEO_UPDATE( s16a_bootleg_passht4b )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static const sega16sp_interface wb3bbl_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
117, // xoffs
|
||||
segaic16_sprites_16a_bootleg_wb3bl_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( wb3bb )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -2131,13 +2161,23 @@ static MACHINE_DRIVER_START( wb3bb )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(wb3bbl_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_WONDERBOY3_BOOTLEG("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", wb3bbl_sega16sp_intf)
|
||||
|
||||
MDRV_VIDEO_START( s16a_bootleg_wb3bl )
|
||||
MDRV_VIDEO_UPDATE( s16a_bootleg )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
|
||||
static const sega16sp_interface s16bbl_x121_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
121, // xoffs
|
||||
segaic16_sprites_16b_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( goldnaxeb1 )
|
||||
|
||||
/* driver data */
|
||||
@ -2160,7 +2200,7 @@ static MACHINE_DRIVER_START( goldnaxeb1 )
|
||||
MDRV_GFXDECODE(sys16)
|
||||
MDRV_PALETTE_LENGTH(2048*SHADOW_COLORS_MULTIPLIER)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x121_sega16sp_intf)
|
||||
|
||||
MDRV_PALETTE_INIT( all_black )
|
||||
MDRV_VIDEO_START(system16)
|
||||
@ -2183,6 +2223,16 @@ static MACHINE_DRIVER_START( bayrouteb1 )
|
||||
MDRV_CPU_PROGRAM_MAP(bayrouteb1_map)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static const sega16sp_interface s16bbl_x107_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
107, // xoffs
|
||||
segaic16_sprites_16b_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( bayrouteb2 )
|
||||
/* basic machine hardware */
|
||||
MDRV_IMPORT_FROM(goldnaxeb1)
|
||||
@ -2190,6 +2240,9 @@ static MACHINE_DRIVER_START( bayrouteb2 )
|
||||
MDRV_CPU_PROGRAM_MAP(bayrouteb2_map)
|
||||
|
||||
MDRV_IMPORT_FROM(system16_datsu_sound)
|
||||
|
||||
MDRV_DEVICE_REMOVE("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x107_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( tturfbl )
|
||||
@ -2209,9 +2262,19 @@ static MACHINE_DRIVER_START( tturfbl )
|
||||
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80)
|
||||
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x107_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static const sega16sp_interface s16bbl_x112_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
112, // xoffs
|
||||
segaic16_sprites_16b_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( dduxbl )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -2219,9 +2282,19 @@ static MACHINE_DRIVER_START( dduxbl )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(dduxbl_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x112_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static const sega16sp_interface s16bbl_x124_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
124, // xoffs
|
||||
segaic16_sprites_16b_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( eswatbl )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -2229,7 +2302,7 @@ static MACHINE_DRIVER_START( eswatbl )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(eswatbl_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x124_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( fpointbl )
|
||||
@ -2242,7 +2315,7 @@ static MACHINE_DRIVER_START( fpointbl )
|
||||
MDRV_CPU_MODIFY("soundcpu")
|
||||
MDRV_CPU_PROGRAM_MAP(fpointbl_sound_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x107_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( tetrisbl )
|
||||
@ -2252,7 +2325,7 @@ static MACHINE_DRIVER_START( tetrisbl )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(tetrisbl_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x112_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
|
||||
@ -2263,7 +2336,7 @@ static MACHINE_DRIVER_START( beautyb )
|
||||
MDRV_CPU_MODIFY("maincpu")
|
||||
MDRV_CPU_PROGRAM_MAP(beautyb_map)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x112_sega16sp_intf)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
|
||||
@ -2295,7 +2368,7 @@ static MACHINE_DRIVER_START( system18 )
|
||||
MDRV_VIDEO_START(system18old)
|
||||
MDRV_VIDEO_UPDATE(system18old)
|
||||
|
||||
MDRV_SEGA16SP_ADD_16B("segaspr1")
|
||||
MDRV_SEGA16SP_ADD("segaspr1", s16bbl_x107_sega16sp_intf)
|
||||
|
||||
/* sound hardware */
|
||||
MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
|
||||
@ -3221,12 +3294,6 @@ static DRIVER_INIT( common )
|
||||
{
|
||||
segas1x_bootleg_state *state = (segas1x_bootleg_state *)machine->driver_data;
|
||||
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
sega16sp->xoffs = 107;
|
||||
|
||||
|
||||
state->bg1_trans = 0;
|
||||
state->splittab_bg_x = 0;
|
||||
state->splittab_bg_y = 0;
|
||||
@ -3238,8 +3305,6 @@ static DRIVER_INIT( common )
|
||||
state->fore_yscroll = 0;
|
||||
state->text_yscroll = 0;
|
||||
|
||||
|
||||
|
||||
state->sample_buffer = 0;
|
||||
state->sample_select = 0;
|
||||
|
||||
@ -3255,41 +3320,31 @@ static DRIVER_INIT( common )
|
||||
static DRIVER_INIT( shinobl )
|
||||
{
|
||||
segas1x_bootleg_state *state = (segas1x_bootleg_state *)machine->driver_data;
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
state->spritebank_type = 1;
|
||||
sega16sp->xoffs = 117;
|
||||
}
|
||||
|
||||
static DRIVER_INIT( passsht )
|
||||
{
|
||||
segas1x_bootleg_state *state = (segas1x_bootleg_state *)machine->driver_data;
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
state->spritebank_type = 1;
|
||||
state->back_yscroll = 3;
|
||||
sega16sp->xoffs = 117;
|
||||
}
|
||||
|
||||
static DRIVER_INIT( wb3bbl )
|
||||
{
|
||||
segas1x_bootleg_state *state = (segas1x_bootleg_state *)machine->driver_data;
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
state->spritebank_type = 1;
|
||||
state->back_yscroll = 2;
|
||||
state->fore_yscroll = 2;
|
||||
sega16sp->xoffs = 117;
|
||||
}
|
||||
|
||||
|
||||
@ -3302,8 +3357,6 @@ static DRIVER_INIT( goldnaxeb1 )
|
||||
UINT8 *KEY = memory_region(machine, "decryption");
|
||||
const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
||||
UINT8 data[0x1000];
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
// the decryption key is in a rom (part of an MSDOS executable...)
|
||||
for (i = 0; i < 0x800; i++)
|
||||
@ -3326,7 +3379,6 @@ static DRIVER_INIT( goldnaxeb1 )
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
state->spritebank_type = 1;
|
||||
sega16sp->xoffs = 121;
|
||||
}
|
||||
|
||||
|
||||
@ -3370,13 +3422,10 @@ static DRIVER_INIT( bayrouteb2 )
|
||||
static DRIVER_INIT( goldnaxeb2 )
|
||||
{
|
||||
segas1x_bootleg_state *state = (segas1x_bootleg_state *)machine->driver_data;
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
state->spritebank_type = 1;
|
||||
sega16sp->xoffs = 121;
|
||||
}
|
||||
|
||||
static DRIVER_INIT( tturfbl )
|
||||
@ -3390,25 +3439,17 @@ static DRIVER_INIT( tturfbl )
|
||||
|
||||
static DRIVER_INIT( dduxbl )
|
||||
{
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
sega16sp->xoffs = 112;
|
||||
}
|
||||
|
||||
static DRIVER_INIT( eswatbl )
|
||||
{
|
||||
segas1x_bootleg_state *state = (segas1x_bootleg_state *)machine->driver_data;
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
//state->splittab_fg_x = &sys16_textram[0x0f80];
|
||||
|
||||
state->spritebank_type = 1;
|
||||
sega16sp->xoffs = 124;
|
||||
}
|
||||
|
||||
static DRIVER_INIT( fpointbl )
|
||||
@ -3427,8 +3468,6 @@ static DRIVER_INIT( beautyb )
|
||||
{
|
||||
UINT16*rom = (UINT16*)memory_region( machine, "maincpu" );
|
||||
int x;
|
||||
running_device* device = devtag_get_device(machine, "segaspr1");
|
||||
sega16sp_state *sega16sp = (sega16sp_state *)device->token;
|
||||
|
||||
for (x = 0; x < 0x8000; x++)
|
||||
{
|
||||
@ -3439,8 +3478,6 @@ static DRIVER_INIT( beautyb )
|
||||
}
|
||||
|
||||
DRIVER_INIT_CALL(common);
|
||||
|
||||
sega16sp->xoffs = 112;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,10 +43,14 @@
|
||||
#define SNES_VTOTAL_PAL 312 /* Maximum number of lines for PAL systems */
|
||||
#define SNES_HTOTAL 341 /* Maximum number pixels per line (incl. hblank) */
|
||||
#define SNES_DMA_BASE 0x4300 /* Base DMA register address */
|
||||
#define SNES_MODE_20 0x1 /* Lo-ROM cart */
|
||||
#define SNES_MODE_21 0x2 /* Hi-ROM cart */
|
||||
#define SNES_MODE_22 0x4 /* Extended Lo-ROM cart - SDD-1 */
|
||||
#define SNES_MODE_25 0x8 /* Extended Hi-ROM cart */
|
||||
#define SNES_MODE_20 0x01 /* Lo-ROM cart */
|
||||
#define SNES_MODE_21 0x02 /* Hi-ROM cart */
|
||||
#define SNES_MODE_22 0x04 /* Extended Lo-ROM cart - SDD-1 */
|
||||
#define SNES_MODE_25 0x08 /* Extended Hi-ROM cart */
|
||||
#define SNES_MODE_BSX 0x10
|
||||
#define SNES_MODE_BSLO 0x20
|
||||
#define SNES_MODE_BSHI 0x40
|
||||
#define SNES_MODE_ST 0x80
|
||||
#define SNES_NTSC 0x00
|
||||
#define SNES_PAL 0x10
|
||||
#define SNES_VRAM_SIZE 0x20000 /* 128kb of video ram */
|
||||
@ -354,6 +358,15 @@
|
||||
#define DSP_FIR_C6 0x6F
|
||||
#define DSP_FIR_C7 0x7F
|
||||
|
||||
struct snes_cart_info
|
||||
{
|
||||
UINT8 mode; /* ROM memory mode */
|
||||
UINT32 sram; /* Amount of sram in cart */
|
||||
UINT32 sram_max; /* Maximum amount sram in cart (based on ROM mode) */
|
||||
int small_sram;
|
||||
int slot_in_use; /* this is needed by Sufami Turbo slots (to check if SRAM has to be saved) */
|
||||
};
|
||||
|
||||
struct snes_joypad
|
||||
{
|
||||
UINT16 buttons;
|
||||
@ -437,6 +450,11 @@ public:
|
||||
snes_io_read io_read;
|
||||
snes_oldjoy_read oldjoy1_read, oldjoy2_read;
|
||||
|
||||
/* cart related */
|
||||
UINT8 has_addon_chip;
|
||||
UINT32 cart_size;
|
||||
snes_cart_info cart[2]; // the second one is used by MESS for Sufami Turbo and, eventually, BS-X
|
||||
|
||||
/* devices */
|
||||
running_device *maincpu;
|
||||
running_device *soundcpu;
|
||||
@ -523,8 +541,6 @@ extern WRITE8_HANDLER( superfx_w_bank3 );
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( snes_extern_irq_w );
|
||||
|
||||
extern UINT8 snes_has_addon_chip;
|
||||
extern UINT32 snes_rom_size;
|
||||
|
||||
extern void snes_latch_counters(running_machine *machine);
|
||||
|
||||
@ -638,14 +654,6 @@ struct SNES_PPU_STRUCT /* once all the regs are saved in this structure, it woul
|
||||
UINT8 stat77_flags;
|
||||
};
|
||||
|
||||
struct snes_cart_info
|
||||
{
|
||||
UINT8 mode; /* ROM memory mode */
|
||||
UINT32 sram; /* Amount of sram in cart */
|
||||
UINT32 sram_max; /* Maximum amount sram in cart (based on ROM mode) */
|
||||
int small_sram;
|
||||
};
|
||||
|
||||
extern struct snes_cart_info snes_cart;
|
||||
|
||||
/*----------- defined in video/snes.c -----------*/
|
||||
|
@ -26,9 +26,6 @@
|
||||
/* -- Globals -- */
|
||||
UINT8 *snes_ram = NULL; /* 65816 ram */
|
||||
|
||||
UINT8 snes_has_addon_chip;
|
||||
UINT32 snes_rom_size;
|
||||
|
||||
static void snes_dma(const address_space *space, UINT8 channels);
|
||||
static void snes_hdma_init(const address_space *space);
|
||||
static void snes_hdma(const address_space *space);
|
||||
@ -49,6 +46,7 @@ struct snes_cart_info snes_cart;
|
||||
#include "machine/snessdd1.c"
|
||||
#include "machine/snes7110.c"
|
||||
#include "machine/snesst10.c"
|
||||
#include "machine/snesbsx.c"
|
||||
|
||||
/*************************************
|
||||
|
||||
@ -435,21 +433,21 @@ READ8_HANDLER( snes_r_io )
|
||||
return spc_port_out(state->spc700, offset & 0x3);
|
||||
}
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (offset >= 0x3000 && offset < 0x3300)
|
||||
{
|
||||
return superfx_mmio_read(state->superfx, offset);
|
||||
}
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_RTC)
|
||||
else if (state->has_addon_chip == HAS_RTC)
|
||||
{
|
||||
if (offset == 0x2800 || offset == 0x2801)
|
||||
{
|
||||
return srtc_read(space, offset);
|
||||
}
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_SDD1)
|
||||
else if (state->has_addon_chip == HAS_SDD1)
|
||||
{
|
||||
if (offset >= 0x4800 && offset < 0x4808)
|
||||
{
|
||||
@ -460,9 +458,9 @@ READ8_HANDLER( snes_r_io )
|
||||
offset += 0x4300;
|
||||
}
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
|
||||
else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
|
||||
{
|
||||
UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
|
||||
UINT16 limit = (state->has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
|
||||
if (offset >= 0x4800 && offset <= limit)
|
||||
{
|
||||
return spc7110_mmio_read(space, offset);
|
||||
@ -578,7 +576,7 @@ WRITE8_HANDLER( snes_w_io )
|
||||
return;
|
||||
}
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (offset >= 0x3000 && offset < 0x3300)
|
||||
{
|
||||
@ -586,7 +584,7 @@ WRITE8_HANDLER( snes_w_io )
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_RTC)
|
||||
else if (state->has_addon_chip == HAS_RTC)
|
||||
{
|
||||
if (offset == 0x2800 || offset == 0x2801)
|
||||
{
|
||||
@ -594,7 +592,7 @@ WRITE8_HANDLER( snes_w_io )
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_SDD1)
|
||||
else if (state->has_addon_chip == HAS_SDD1)
|
||||
{
|
||||
if ((offset >= 0x4300 && offset < 0x4380) ||
|
||||
(offset >= 0x4800 && offset < 0x4808))
|
||||
@ -607,9 +605,9 @@ WRITE8_HANDLER( snes_w_io )
|
||||
offset += 0x4300;
|
||||
}
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
|
||||
else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
|
||||
{
|
||||
UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
|
||||
UINT16 limit = (state->has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
|
||||
if (offset >= 0x4800 && offset <= limit)
|
||||
{
|
||||
spc7110_mmio_write(space->machine, (UINT32)offset, data);
|
||||
@ -918,23 +916,28 @@ READ8_HANDLER( snes_r_bank1 )
|
||||
if (address < 0x2000) /* Mirror of Low RAM */
|
||||
value = memory_read_byte(space, 0x7e0000 + address);
|
||||
else if (address < 0x6000) /* I/O */
|
||||
value = snes_r_io(space, address);
|
||||
{
|
||||
if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
|
||||
value = bsx_read(space, offset);
|
||||
else
|
||||
value = snes_r_io(space, address);
|
||||
}
|
||||
else if (address < 0x8000)
|
||||
{
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx !=NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (superfx_access_ram(state->superfx))
|
||||
value = snes_ram[0xf00000 + (offset & 0x1fff)]; // here it should be 0xe00000 but there are mirroring issues
|
||||
else
|
||||
value = snes_open_bus_r(space, 0);
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_OBC1)
|
||||
else if (state->has_addon_chip == HAS_OBC1)
|
||||
value = obc1_read(space, offset);
|
||||
else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000))
|
||||
value = (address < 0x7000) ? dsp1_get_dr() : dsp1_get_sr();
|
||||
else if (snes_has_addon_chip == HAS_CX4)
|
||||
else if (state->has_addon_chip == HAS_CX4)
|
||||
value = CX4_read(address - 0x6000);
|
||||
else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
|
||||
else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
|
||||
{
|
||||
if (offset < 0x10000)
|
||||
value = snes_ram[0x306000 + (offset & 0x1fff)];
|
||||
@ -945,11 +948,11 @@ READ8_HANDLER( snes_r_bank1 )
|
||||
value = snes_open_bus_r(space, 0); /* Reserved */
|
||||
}
|
||||
}
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
|
||||
else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
value = dsp3_read(address);
|
||||
else
|
||||
value = snes_ram[offset];
|
||||
@ -970,28 +973,33 @@ READ8_HANDLER( snes_r_bank2 )
|
||||
if (address < 0x2000) /* Mirror of Low RAM */
|
||||
value = memory_read_byte(space, 0x7e0000 + address);
|
||||
else if (address < 0x6000) /* I/O */
|
||||
value = snes_r_io(space, address);
|
||||
{
|
||||
if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
|
||||
value = bsx_read(space, 0x300000 + offset);
|
||||
else
|
||||
value = snes_r_io(space, address);
|
||||
}
|
||||
else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */
|
||||
{
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (superfx_access_ram(state->superfx))
|
||||
value = snes_ram[0xf00000 + (offset & 0x1fff)]; // here it should be 0xe00000 but there are mirroring issues
|
||||
else
|
||||
value = snes_open_bus_r(space, 0);
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_OBC1)
|
||||
else if (state->has_addon_chip == HAS_OBC1)
|
||||
value = obc1_read (space, offset);
|
||||
else if (snes_has_addon_chip == HAS_CX4)
|
||||
else if (state->has_addon_chip == HAS_CX4)
|
||||
value = CX4_read(address - 0x6000);
|
||||
else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
|
||||
else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
|
||||
{
|
||||
if (offset < 0x10000)
|
||||
value = snes_ram[0x306000 + (offset & 0x1fff)];
|
||||
}
|
||||
else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
|
||||
else if ((state->cart[0].mode == SNES_MODE_21) && (state->cart[0].sram > 0))
|
||||
{
|
||||
int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
value = snes_ram[0x300000 + (offset & mask)];
|
||||
}
|
||||
else
|
||||
@ -1001,13 +1009,13 @@ READ8_HANDLER( snes_r_bank2 )
|
||||
}
|
||||
}
|
||||
/* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1))
|
||||
value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2))
|
||||
value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
|
||||
else if (snes_has_addon_chip == HAS_DSP3)
|
||||
else if (state->has_addon_chip == HAS_DSP3)
|
||||
value = dsp3_read(address);
|
||||
else if (snes_has_addon_chip == HAS_DSP4)
|
||||
else if (state->has_addon_chip == HAS_DSP4)
|
||||
value = (address < 0xc000) ? dsp4_read() : 0x80;
|
||||
else
|
||||
value = snes_ram[0x300000 + offset];
|
||||
@ -1025,7 +1033,7 @@ READ8_HANDLER( snes_r_bank3 )
|
||||
UINT8 value = 0xff;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (superfx_access_rom(state->superfx))
|
||||
value = snes_ram[0x400000 + offset];
|
||||
@ -1038,14 +1046,14 @@ READ8_HANDLER( snes_r_bank3 )
|
||||
return sfx_data[offset & 0x0f];
|
||||
}
|
||||
}
|
||||
else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC))
|
||||
else if ((state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC))
|
||||
{
|
||||
if (offset >= 0x100000 && offset < 0x110000)
|
||||
value = spc7110_mmio_read(space, 0x4800);
|
||||
}
|
||||
else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */
|
||||
else if ((state->cart[0].mode & 5) && !(state->has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */
|
||||
{
|
||||
if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20))
|
||||
if ((address < 0x8000) && (state->cart[0].mode == SNES_MODE_20))
|
||||
value = snes_open_bus_r(space, 0); /* Reserved */
|
||||
else
|
||||
value = snes_ram[0x400000 + offset];
|
||||
@ -1066,21 +1074,21 @@ READ8_HANDLER( snes_r_bank4 )
|
||||
UINT8 value = 0xff;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (superfx_access_ram(state->superfx))
|
||||
value = snes_ram[0xe00000 + offset];
|
||||
else
|
||||
value = snes_open_bus_r(space, 0);
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
|
||||
else if (state->has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
|
||||
value = st010_read(address);
|
||||
else if (snes_cart.mode & 5) /* Mode 20 & 22 */
|
||||
else if (state->cart[0].mode & 5) /* Mode 20 & 22 */
|
||||
{
|
||||
if (address >= 0x8000)
|
||||
value = snes_ram[0x600000 + offset];
|
||||
/* some other dsp1 games use these banks 0x60 to 0x6f at address 0x0000 */
|
||||
else if (snes_has_addon_chip == HAS_DSP1)
|
||||
else if (state->has_addon_chip == HAS_DSP1)
|
||||
value = (address >= 0x4000) ? dsp1_get_sr() : dsp1_get_dr();
|
||||
else
|
||||
{
|
||||
@ -1088,7 +1096,7 @@ READ8_HANDLER( snes_r_bank4 )
|
||||
value = snes_open_bus_r(space, 0); /* Reserved */
|
||||
}
|
||||
}
|
||||
else if (snes_cart.mode & 0x0a) /* Mode 21 & 25 */
|
||||
else if (state->cart[0].mode & 0x0a) /* Mode 21 & 25 */
|
||||
value = snes_ram[0x600000 + offset];
|
||||
|
||||
if(!space->debugger_access)
|
||||
@ -1104,18 +1112,18 @@ READ8_HANDLER( snes_r_bank5 )
|
||||
UINT8 value;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (superfx_access_ram(state->superfx))
|
||||
value = snes_ram[0xf00000 + offset];
|
||||
else
|
||||
value = snes_open_bus_r(space, 0);
|
||||
}
|
||||
else if ((snes_cart.mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */
|
||||
else if ((state->cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */
|
||||
{
|
||||
if (snes_cart.sram > 0)
|
||||
if (state->cart[0].sram > 0)
|
||||
{
|
||||
int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
value = snes_ram[0x700000 + (offset & mask)];
|
||||
}
|
||||
else
|
||||
@ -1136,24 +1144,25 @@ READ8_HANDLER( snes_r_bank5 )
|
||||
/* 0x800000 - 0xbfffff */
|
||||
READ8_HANDLER( snes_r_bank6 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT8 value = 0;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
value = memory_read_byte(space, offset);
|
||||
else if (address < 0x8000)
|
||||
{
|
||||
if (snes_cart.mode != SNES_MODE_25)
|
||||
if (state->cart[0].mode != SNES_MODE_25)
|
||||
value = memory_read_byte(space, offset);
|
||||
else if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000))
|
||||
else if ((state->has_addon_chip == HAS_CX4) && (address >= 0x6000))
|
||||
value = CX4_read(address - 0x6000);
|
||||
else /* Mode 25 has SRAM not mirrored from lower banks */
|
||||
{
|
||||
if (address < 0x6000)
|
||||
value = memory_read_byte(space, offset);
|
||||
else if ((offset >= 0x300000) && (snes_cart.sram > 0))
|
||||
else if ((offset >= 0x300000) && (state->cart[0].sram > 0))
|
||||
{
|
||||
int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
value = snes_ram[0x800000 + (offset & mask)];
|
||||
}
|
||||
else /* Area 0x6000-0x8000 with offset < 0x300000 is reserved */
|
||||
@ -1163,13 +1172,13 @@ READ8_HANDLER( snes_r_bank6 )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
|
||||
else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
value = dsp3_read(address);
|
||||
else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
|
||||
else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
|
||||
value = (address < 0xc000) ? dsp4_read() : 0x80;
|
||||
else
|
||||
value = snes_ram[0x800000 + offset];
|
||||
@ -1187,7 +1196,7 @@ READ8_HANDLER( snes_r_bank7 )
|
||||
UINT8 value = 0;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
|
||||
{
|
||||
if (offset < 0x200000) // ROM
|
||||
{
|
||||
@ -1211,13 +1220,13 @@ READ8_HANDLER( snes_r_bank7 )
|
||||
value = snes_open_bus_r(space, 0);
|
||||
}
|
||||
}
|
||||
else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
|
||||
else if ((state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
|
||||
value = spc7110_bank7_read(space, offset);
|
||||
else if (snes_has_addon_chip == HAS_SDD1)
|
||||
else if (state->has_addon_chip == HAS_SDD1)
|
||||
value = sdd1_read(space->machine, offset);
|
||||
else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
|
||||
else if (state->has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
|
||||
value = st010_read(address);
|
||||
else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */
|
||||
else if ((state->cart[0].mode & 5) && !(state->has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */
|
||||
{
|
||||
if (address < 0x8000)
|
||||
value = memory_read_byte(space, 0x400000 + offset);
|
||||
@ -1237,23 +1246,29 @@ READ8_HANDLER( snes_r_bank7 )
|
||||
/* 0x000000 - 0x2fffff */
|
||||
WRITE8_HANDLER( snes_w_bank1 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (address < 0x2000) /* Mirror of Low RAM */
|
||||
memory_write_byte(space, 0x7e0000 + address, data);
|
||||
else if (address < 0x6000) /* I/O */
|
||||
snes_w_io(space, address, data);
|
||||
{
|
||||
if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
|
||||
bsx_write(space, offset, data);
|
||||
else
|
||||
snes_w_io(space, address, data);
|
||||
}
|
||||
else if (address < 0x8000)
|
||||
{
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues
|
||||
else if (snes_has_addon_chip == HAS_OBC1)
|
||||
else if (state->has_addon_chip == HAS_OBC1)
|
||||
obc1_write(space, offset, data);
|
||||
else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000))
|
||||
dsp1_set_dr(data);
|
||||
else if (snes_has_addon_chip == HAS_CX4)
|
||||
else if (state->has_addon_chip == HAS_CX4)
|
||||
CX4_write(space->machine, address - 0x6000, data);
|
||||
else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
|
||||
else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
|
||||
{
|
||||
if (offset < 0x10000)
|
||||
snes_ram[0x306000 + (offset & 0x1fff)] = data;
|
||||
@ -1261,16 +1276,16 @@ WRITE8_HANDLER( snes_w_bank1 )
|
||||
else
|
||||
logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data);
|
||||
}
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
dsp1_set_dr(data);
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
{
|
||||
if (address < 0xc000)
|
||||
dsp2_dr_write(data);
|
||||
else
|
||||
dsp2_sr_write(data);
|
||||
}
|
||||
else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
dsp3_write(address, data);
|
||||
else
|
||||
logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset );
|
||||
@ -1282,46 +1297,52 @@ WRITE8_HANDLER( snes_w_bank1 )
|
||||
/* 0x300000 - 0x3fffff */
|
||||
WRITE8_HANDLER( snes_w_bank2 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (address < 0x2000) /* Mirror of Low RAM */
|
||||
memory_write_byte(space, 0x7e0000 + address, data);
|
||||
else if (address < 0x6000) /* I/O */
|
||||
snes_w_io(space, address, data);
|
||||
{
|
||||
if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
|
||||
bsx_write(space, 0x300000 + offset, data);
|
||||
else
|
||||
snes_w_io(space, address, data);
|
||||
}
|
||||
else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */
|
||||
{
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues
|
||||
else if (snes_has_addon_chip == HAS_OBC1)
|
||||
else if (state->has_addon_chip == HAS_OBC1)
|
||||
obc1_write(space, offset, data);
|
||||
else if (snes_has_addon_chip == HAS_CX4)
|
||||
else if (state->has_addon_chip == HAS_CX4)
|
||||
CX4_write(space->machine, address - 0x6000, data);
|
||||
else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
|
||||
else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
|
||||
{
|
||||
if (offset < 0x10000)
|
||||
snes_ram[0x306000 + (offset & 0x1fff)] = data;
|
||||
}
|
||||
else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
|
||||
else if ((state->cart[0].mode == SNES_MODE_21) && (state->cart[0].sram > 0))
|
||||
{
|
||||
int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
snes_ram[0x300000 + (offset & mask)] = data;
|
||||
}
|
||||
else
|
||||
logerror("snes_w_bank2: Attempt to write to reserved address: %X = %02x\n", offset + 0x300000, data);
|
||||
}
|
||||
/* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1))
|
||||
dsp1_set_dr(data);
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2))
|
||||
{
|
||||
if (address < 0xc000)
|
||||
dsp2_dr_write(data);
|
||||
else
|
||||
dsp2_sr_write(data);
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_DSP3)
|
||||
else if (state->has_addon_chip == HAS_DSP3)
|
||||
dsp3_write(address, data);
|
||||
else if ((snes_has_addon_chip == HAS_DSP4) && (address < 0xc000))
|
||||
else if ((state->has_addon_chip == HAS_DSP4) && (address < 0xc000))
|
||||
dsp4_write(data);
|
||||
else
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000);
|
||||
@ -1333,22 +1354,23 @@ WRITE8_HANDLER( snes_w_bank2 )
|
||||
/* 0x600000 - 0x6fffff */
|
||||
WRITE8_HANDLER( snes_w_bank4 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
snes_ram[0xe00000 + offset] = data;
|
||||
else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
|
||||
else if (state->has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
|
||||
st010_write(address, data);
|
||||
else if (snes_cart.mode & 5) /* Mode 20 & 22 */
|
||||
else if (state->cart[0].mode & 5) /* Mode 20 & 22 */
|
||||
{
|
||||
if (address >= 0x8000)
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000);
|
||||
else if (snes_has_addon_chip == HAS_DSP1)
|
||||
else if (state->has_addon_chip == HAS_DSP1)
|
||||
dsp1_set_dr(data);
|
||||
else
|
||||
logerror("snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", offset + 0x600000, data);
|
||||
}
|
||||
else if (snes_cart.mode & 0x0a)
|
||||
else if (state->cart[0].mode & 0x0a)
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000);
|
||||
|
||||
if(!space->debugger_access)
|
||||
@ -1358,21 +1380,22 @@ WRITE8_HANDLER( snes_w_bank4 )
|
||||
/* 0x700000 - 0x7dffff */
|
||||
WRITE8_HANDLER( snes_w_bank5 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
snes_ram[0xf00000 + offset] = data;
|
||||
else if ((snes_cart.mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */
|
||||
else if ((state->cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */
|
||||
{
|
||||
if (snes_cart.sram > 0)
|
||||
if (state->cart[0].sram > 0)
|
||||
{
|
||||
int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
snes_ram[0x700000 + (offset & mask)] = data;
|
||||
}
|
||||
else
|
||||
logerror("snes_w_bank5: Attempt to write to reserved address: %X = %02x\n", offset + 0x700000, data);
|
||||
}
|
||||
else if (snes_cart.mode & 0x0a)
|
||||
else if (state->cart[0].mode & 0x0a)
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x700000);
|
||||
|
||||
if(!space->debugger_access)
|
||||
@ -1383,41 +1406,42 @@ WRITE8_HANDLER( snes_w_bank5 )
|
||||
/* 0x800000 - 0xbfffff */
|
||||
WRITE8_HANDLER( snes_w_bank6 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
memory_write_byte(space, offset, data);
|
||||
else if (address < 0x8000)
|
||||
{
|
||||
if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000))
|
||||
if ((state->has_addon_chip == HAS_CX4) && (address >= 0x6000))
|
||||
CX4_write(space->machine, address - 0x6000, data);
|
||||
else if (snes_cart.mode != SNES_MODE_25)
|
||||
else if (state->cart[0].mode != SNES_MODE_25)
|
||||
memory_write_byte(space, offset, data);
|
||||
else /* Mode 25 has SRAM not mirrored from lower banks */
|
||||
{
|
||||
if (address < 0x6000)
|
||||
memory_write_byte(space, offset, data);
|
||||
else if ((offset >= 0x300000) && (snes_cart.sram > 0))
|
||||
else if ((offset >= 0x300000) && (state->cart[0].sram > 0))
|
||||
{
|
||||
int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */
|
||||
snes_ram[0x800000 + (offset & mask)] = data;
|
||||
}
|
||||
else /* Area in 0x6000-0x8000 && offset < 0x300000 is Reserved! */
|
||||
logerror("snes_w_bank6: Attempt to write to reserved address: %X = %02x\n", offset + 0x800000, data);
|
||||
}
|
||||
}
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
|
||||
dsp1_set_dr(data);
|
||||
else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
|
||||
{
|
||||
if (address < 0xc000)
|
||||
dsp2_dr_write(data);
|
||||
else
|
||||
dsp2_sr_write(data);
|
||||
}
|
||||
else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
|
||||
dsp3_write(address, data);
|
||||
else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000))
|
||||
else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000))
|
||||
dsp4_write(data);
|
||||
else
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000);
|
||||
@ -1430,9 +1454,10 @@ WRITE8_HANDLER( snes_w_bank6 )
|
||||
/* 0xc00000 - 0xffffff */
|
||||
WRITE8_HANDLER( snes_w_bank7 )
|
||||
{
|
||||
snes_state *state = (snes_state *)space->machine->driver_data;
|
||||
UINT16 address = offset & 0xffff;
|
||||
|
||||
if (snes_has_addon_chip == HAS_SUPERFX)
|
||||
if (state->has_addon_chip == HAS_SUPERFX)
|
||||
{
|
||||
if (offset >= 0x200000)
|
||||
{
|
||||
@ -1442,9 +1467,9 @@ WRITE8_HANDLER( snes_w_bank7 )
|
||||
else
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000);
|
||||
}
|
||||
else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
|
||||
else if (state->has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
|
||||
st010_write(address, data);
|
||||
else if (snes_cart.mode & 5) /* Mode 20 & 22 */
|
||||
else if (state->cart[0].mode & 5) /* Mode 20 & 22 */
|
||||
{
|
||||
if (address < 0x8000)
|
||||
{
|
||||
@ -1458,7 +1483,7 @@ WRITE8_HANDLER( snes_w_bank7 )
|
||||
else
|
||||
logerror("(PC=%06x) snes_w_bank7: Attempt to write to ROM address: %X = %02x\n",cpu_get_pc(space->cpu),offset + 0xc00000, data);
|
||||
}
|
||||
else if (snes_cart.mode & 0x0a)
|
||||
else if (state->cart[0].mode & 0x0a)
|
||||
logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000);
|
||||
|
||||
if(!space->debugger_access)
|
||||
@ -1606,7 +1631,7 @@ static void snes_init_ram( running_machine *machine )
|
||||
snes_ram[WRIO] = 0xff;
|
||||
snes_ram[VMAIN] = 0x80;
|
||||
|
||||
switch (snes_has_addon_chip)
|
||||
switch (state->has_addon_chip)
|
||||
{
|
||||
case HAS_DSP1:
|
||||
dsp1_init(machine);
|
||||
@ -1683,7 +1708,7 @@ MACHINE_START( snes )
|
||||
snes_ram[WRDIVL] = 0xff;
|
||||
snes_ram[WRDIVH] = 0xff;
|
||||
|
||||
switch (snes_has_addon_chip)
|
||||
switch (state->has_addon_chip)
|
||||
{
|
||||
case HAS_SDD1:
|
||||
sdd1_init(machine);
|
||||
@ -1699,6 +1724,9 @@ MACHINE_START( snes )
|
||||
break;
|
||||
}
|
||||
|
||||
if (state->cart[0].mode == SNES_MODE_BSX)
|
||||
bsx_init(machine);
|
||||
|
||||
snes_init_timers(machine);
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
@ -1807,6 +1835,7 @@ MACHINE_RESET( snes )
|
||||
/* for mame we use an init, maybe we will need more for the different games */
|
||||
DRIVER_INIT( snes )
|
||||
{
|
||||
snes_state *state = (snes_state *)machine->driver_data;
|
||||
const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
||||
UINT16 total_blocks, read_blocks;
|
||||
UINT8 *rom;
|
||||
@ -1815,9 +1844,9 @@ DRIVER_INIT( snes )
|
||||
snes_ram = auto_alloc_array_clear(machine, UINT8, 0x1400000);
|
||||
|
||||
/* all NSS games seem to use MODE 20 */
|
||||
snes_cart.mode = SNES_MODE_20;
|
||||
snes_cart.sram_max = 0x40000;
|
||||
snes_has_addon_chip = HAS_NONE;
|
||||
state->cart[0].mode = SNES_MODE_20;
|
||||
state->cart[0].sram_max = 0x40000;
|
||||
state->has_addon_chip = HAS_NONE;
|
||||
|
||||
/* Find the number of blocks in this ROM */
|
||||
total_blocks = (memory_region_length(machine, "user3") / 0x8000);
|
||||
@ -1861,17 +1890,18 @@ DRIVER_INIT( snes )
|
||||
}
|
||||
|
||||
/* Find the amount of sram */
|
||||
snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
|
||||
if (snes_cart.sram > 0)
|
||||
state->cart[0].sram = snes_r_bank1(space, 0x00ffd8);
|
||||
if (state->cart[0].sram > 0)
|
||||
{
|
||||
snes_cart.sram = (1024 << snes_cart.sram);
|
||||
if (snes_cart.sram > snes_cart.sram_max)
|
||||
snes_cart.sram = snes_cart.sram_max;
|
||||
state->cart[0].sram = (1024 << state->cart[0].sram);
|
||||
if (state->cart[0].sram > state->cart[0].sram_max)
|
||||
state->cart[0].sram = state->cart[0].sram_max;
|
||||
}
|
||||
}
|
||||
|
||||
DRIVER_INIT( snes_hirom )
|
||||
{
|
||||
snes_state *state = (snes_state *)machine->driver_data;
|
||||
const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
||||
UINT16 total_blocks, read_blocks;
|
||||
UINT8 *rom;
|
||||
@ -1880,9 +1910,9 @@ DRIVER_INIT( snes_hirom )
|
||||
snes_ram = auto_alloc_array(machine, UINT8, 0x1400000);
|
||||
memset(snes_ram, 0, 0x1400000);
|
||||
|
||||
snes_cart.mode = SNES_MODE_21;
|
||||
snes_cart.sram_max = 0x40000;
|
||||
snes_has_addon_chip = HAS_NONE;
|
||||
state->cart[0].mode = SNES_MODE_21;
|
||||
state->cart[0].sram_max = 0x40000;
|
||||
state->has_addon_chip = HAS_NONE;
|
||||
|
||||
/* Find the number of blocks in this ROM */
|
||||
total_blocks = (memory_region_length(machine, "user3") / 0x10000);
|
||||
@ -1920,12 +1950,12 @@ DRIVER_INIT( snes_hirom )
|
||||
}
|
||||
|
||||
/* Find the amount of sram */
|
||||
snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
|
||||
if (snes_cart.sram > 0)
|
||||
state->cart[0].sram = snes_r_bank1(space, 0x00ffd8);
|
||||
if (state->cart[0].sram > 0)
|
||||
{
|
||||
snes_cart.sram = (1024 << snes_cart.sram);
|
||||
if (snes_cart.sram > snes_cart.sram_max)
|
||||
snes_cart.sram = snes_cart.sram_max;
|
||||
state->cart[0].sram = (1024 << state->cart[0].sram);
|
||||
if (state->cart[0].sram > state->cart[0].sram_max)
|
||||
state->cart[0].sram = state->cart[0].sram_max;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ static const UINT8 spc7110_mode2_context_table[32][2] =
|
||||
typedef struct
|
||||
{
|
||||
running_machine *machine;
|
||||
|
||||
|
||||
UINT32 decomp_mode;
|
||||
UINT32 decomp_offset;
|
||||
|
||||
@ -138,9 +138,11 @@ typedef struct
|
||||
|
||||
UINT32 morton16[2][256];
|
||||
UINT32 morton32[4][256];
|
||||
|
||||
UINT32 rom_size;
|
||||
} SPC7110Decomp;
|
||||
|
||||
static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine);
|
||||
static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine, UINT32 size);
|
||||
static void SPC7110Decomp_reset(SPC7110Decomp *thisptr);
|
||||
static void SPC7110Decomp_init(SPC7110Decomp *thisptr, running_machine *machine, UINT32 mode, UINT32 offset, UINT32 index);
|
||||
static UINT8 SPC7110Decomp_read(SPC7110Decomp *thisptr);
|
||||
@ -156,7 +158,7 @@ static UINT8 SPC7110Decomp_toggle_invert(SPC7110Decomp *thisptr, UINT32 n);
|
||||
static UINT32 SPC7110Decomp_morton_2x8(SPC7110Decomp *thisptr, UINT32 data);
|
||||
static UINT32 SPC7110Decomp_morton_4x8(SPC7110Decomp *thisptr, UINT32 data);
|
||||
|
||||
static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine)
|
||||
static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine, UINT32 size)
|
||||
{
|
||||
UINT32 i;
|
||||
SPC7110Decomp* newclass = (SPC7110Decomp*)auto_alloc_array(machine, UINT8, sizeof(SPC7110Decomp));
|
||||
@ -183,6 +185,8 @@ static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine)
|
||||
#undef map
|
||||
}
|
||||
|
||||
newclass->rom_size = size;
|
||||
|
||||
return newclass;
|
||||
}
|
||||
|
||||
@ -271,7 +275,7 @@ static void SPC7110Decomp_write(SPC7110Decomp *thisptr, UINT8 data)
|
||||
static UINT8 SPC7110Decomp_dataread(SPC7110Decomp *thisptr)
|
||||
{
|
||||
UINT8 *ROM = memory_region(thisptr->machine, "cart");
|
||||
UINT32 size = snes_rom_size - 0x100000;
|
||||
UINT32 size = thisptr->rom_size - 0x100000;
|
||||
while(thisptr->decomp_offset >= size)
|
||||
{
|
||||
thisptr->decomp_offset -= size;
|
||||
@ -863,12 +867,16 @@ typedef struct
|
||||
UINT64 rtc_offset;
|
||||
|
||||
UINT8 rtc_ram[16]; // 0-12 secs, min, hrs, etc.; 13-14-15 control registers
|
||||
|
||||
UINT32 size;
|
||||
} _snes_spc7110_t;
|
||||
|
||||
static _snes_spc7110_t snes_spc7110;
|
||||
|
||||
static void spc7110_init(running_machine* machine)
|
||||
{
|
||||
snes_state *state = (snes_state *)machine->driver_data;
|
||||
|
||||
snes_spc7110.r4801 = 0x00;
|
||||
snes_spc7110.r4802 = 0x00;
|
||||
snes_spc7110.r4803 = 0x00;
|
||||
@ -921,8 +929,10 @@ static void spc7110_init(running_machine* machine)
|
||||
snes_spc7110.r4840 = 0x00;
|
||||
snes_spc7110.r4841 = 0x00;
|
||||
snes_spc7110.r4842 = 0x00;
|
||||
|
||||
snes_spc7110.decomp = SPC7110Decomp_ctor(machine);
|
||||
|
||||
snes_spc7110.size = state->cart_size;
|
||||
|
||||
snes_spc7110.decomp = SPC7110Decomp_ctor(machine, snes_spc7110.size);
|
||||
}
|
||||
|
||||
static void spc7110rtc_init(running_machine* machine)
|
||||
@ -940,7 +950,7 @@ static void spc7110rtc_init(running_machine* machine)
|
||||
|
||||
static UINT32 spc7110_datarom_addr(UINT32 addr)
|
||||
{
|
||||
UINT32 size = snes_rom_size - 0x100000;
|
||||
UINT32 size = snes_spc7110.size - 0x100000;
|
||||
while(addr >= size)
|
||||
{
|
||||
addr -= size;
|
||||
|
252
src/mame/machine/snesbsx.c
Normal file
252
src/mame/machine/snesbsx.c
Normal file
@ -0,0 +1,252 @@
|
||||
/***************************************************************************
|
||||
|
||||
snesbsx.c
|
||||
|
||||
File to handle emulation of the SNES "BS-X Satellaview".
|
||||
|
||||
Based on byuu's research.
|
||||
|
||||
TODO: basically everything. The hardware can dynamically remap where
|
||||
the memory handlers read/write (this will probably require some more
|
||||
rethinking of the way we use snes_ram), see bsx_update_memory_map
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SNES_BSX_CARTROM = 0,
|
||||
SNES_BSX_PRAM,
|
||||
SNES_BSX_FLASH
|
||||
};
|
||||
|
||||
|
||||
struct _snes_bsx_state
|
||||
{
|
||||
// base regs
|
||||
// we don't emulate the base unit yet
|
||||
|
||||
// cart regs
|
||||
UINT8 cart_regs[16];
|
||||
|
||||
// flash regs
|
||||
UINT32 command;
|
||||
UINT8 write_old;
|
||||
UINT8 write_new;
|
||||
|
||||
int flash_enable;
|
||||
int read_enable;
|
||||
int write_enable;
|
||||
|
||||
UINT8 *pram;
|
||||
int ram_source;
|
||||
};
|
||||
|
||||
static struct _snes_bsx_state bsx_state;
|
||||
|
||||
|
||||
static void bsx_update_memory_map(void)
|
||||
{
|
||||
bsx_state.ram_source = BIT(bsx_state.cart_regs[0x01], 7) ? SNES_BSX_PRAM : SNES_BSX_FLASH;
|
||||
// UINT8 *RAM = (bsx_state.cart_regs[0x01] & 0x80) == 0x00 ? memory_region(space->machine, "flash") : bsx_state.pram;
|
||||
|
||||
logerror("BSX: updated memory map, current RAM: %d", bsx_state.ram_source);
|
||||
if (!BIT(bsx_state.cart_regs[0x02], 7))
|
||||
{
|
||||
//LoROM mapping
|
||||
// 0x00-0x7d:0x8000-0xfff -> RAM (either flash or pram)
|
||||
// 0x80-0xff:0x8000-0xfff -> RAM
|
||||
}
|
||||
else
|
||||
{
|
||||
//HiROM mapping
|
||||
// 0x00-0x3f:0x8000-0xfff -> RAM - 'shadowed'
|
||||
// 0x40-0x7d:0x0000-0xfff -> RAM
|
||||
// 0x80-0xbf:0x8000-0xfff -> RAM - 'shadowed'
|
||||
// 0xc0-0xff:0x0000-0xfff -> RAM
|
||||
}
|
||||
|
||||
if (BIT(bsx_state.cart_regs[0x03], 7))
|
||||
{
|
||||
// 0x60-0x6f:0x0000-0xffff -> PRAM
|
||||
}
|
||||
|
||||
if (!BIT(bsx_state.cart_regs[0x05], 7))
|
||||
{
|
||||
// 0x40-0x4f:0x0000-0xffff -> PRAM
|
||||
}
|
||||
|
||||
if (!BIT(bsx_state.cart_regs[0x06], 7))
|
||||
{
|
||||
// 0x50-0x5f:0x0000-0xffff -> PRAM
|
||||
}
|
||||
|
||||
if (BIT(bsx_state.cart_regs[0x07], 7))
|
||||
{
|
||||
// 0x00-0x1f:0x8000-0xffff -> CART
|
||||
}
|
||||
|
||||
if (BIT(bsx_state.cart_regs[0x08], 7))
|
||||
{
|
||||
// 0x80-0x9f:0x8000-0xffff -> CART
|
||||
}
|
||||
|
||||
// 0x20-0x3f:0x6000-0x7fff -> PRAM
|
||||
// 0x70-0x77:0x0000-0xffff -> PRAM
|
||||
}
|
||||
|
||||
static READ8_HANDLER( bsx_read )
|
||||
{
|
||||
if ((offset & 0xf0ffff) == 0x005000)
|
||||
{
|
||||
//$[00-0f]:5000 MMIO
|
||||
UINT8 n = (offset >> 16) & 0x0f;
|
||||
return bsx_state.cart_regs[n];
|
||||
}
|
||||
|
||||
if ((offset & 0xf8f000) == 0x105000)
|
||||
{
|
||||
//$[10-17]:[5000-5fff] SRAM
|
||||
return bsx_state.pram[((offset >> 16) & 7) * 0x1000 + (offset & 0xfff)];
|
||||
}
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
static WRITE8_HANDLER( bsx_write )
|
||||
{
|
||||
if ((offset & 0xf0ffff) == 0x005000)
|
||||
{
|
||||
//$[00-0f]:5000 MMIO
|
||||
UINT8 n = (offset >> 16) & 0x0f;
|
||||
bsx_state.cart_regs[n] = data;
|
||||
if ((n == 0x0e) && (data & 0x80))
|
||||
bsx_update_memory_map();
|
||||
}
|
||||
|
||||
if ((offset & 0xf8f000) == 0x105000)
|
||||
{
|
||||
//$[10-17]:[5000-5fff] SRAM
|
||||
bsx_state.pram[((offset >> 16) & 7) * 0x1000 + (offset & 0xfff)] = data;
|
||||
}
|
||||
}
|
||||
|
||||
static void bsx_init( running_machine *machine )
|
||||
{
|
||||
|
||||
memset(bsx_state.cart_regs, 0, ARRAY_LENGTH(bsx_state.cart_regs));
|
||||
|
||||
bsx_state.cart_regs[0x07] = 0x80;
|
||||
bsx_state.cart_regs[0x08] = 0x80;
|
||||
|
||||
bsx_state.pram = auto_alloc_array(machine, UINT8, 0x80000);
|
||||
|
||||
bsx_update_memory_map();
|
||||
// saves
|
||||
}
|
||||
|
||||
#ifdef UNUSED_FUNCTION
|
||||
static READ8_HANDLER( bsx_flash_read )
|
||||
{
|
||||
UINT8 *FLASH = memory_region(space->machine, "flash");
|
||||
|
||||
if (offset == 0x0002)
|
||||
{
|
||||
if (bsx_state.flash_enable)
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
if (offset == 0x5555)
|
||||
{
|
||||
if (bsx_state.flash_enable)
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
if (bsx_state.read_enable && offset >= 0xff00 && offset <= 0xff13)
|
||||
{
|
||||
//read flash cartridge vendor information
|
||||
switch(offset - 0xff00)
|
||||
{
|
||||
case 0x00: return 0x4d;
|
||||
case 0x01: return 0x00;
|
||||
case 0x02: return 0x50;
|
||||
case 0x03: return 0x00;
|
||||
case 0x04: return 0x00;
|
||||
case 0x05: return 0x00;
|
||||
case 0x06: return 0x2a; //0x2a = 8mbit, 0x2b = 16mbit (not known to exist, though BIOS recognizes ID)
|
||||
case 0x07: return 0x00;
|
||||
default: return 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
return FLASH[offset];
|
||||
}
|
||||
|
||||
static WRITE8_HANDLER( bsx_flash_write )
|
||||
{
|
||||
if ((offset & 0xff0000) == 0)
|
||||
{
|
||||
bsx_state.write_old = bsx_state.write_new;
|
||||
bsx_state.write_new = data;
|
||||
|
||||
if (bsx_state.write_enable && bsx_state.write_old == bsx_state.write_new)
|
||||
{
|
||||
// currently we have the flashcart loaded in a rom_region -> we cannot write yet
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bsx_state.write_enable)
|
||||
{
|
||||
// currently we have the flashcart loaded in a rom_region -> we cannot write yet
|
||||
}
|
||||
}
|
||||
|
||||
if (offset == 0x0000)
|
||||
{
|
||||
bsx_state.command <<= 8;
|
||||
bsx_state.command |= data;
|
||||
|
||||
if ((bsx_state.command & 0xffff) == 0x38d0)
|
||||
{
|
||||
bsx_state.flash_enable = 1;
|
||||
bsx_state.read_enable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset == 0x2aaa)
|
||||
{
|
||||
bsx_state.command <<= 8;
|
||||
bsx_state.command |= data;
|
||||
}
|
||||
|
||||
if (offset == 0x5555)
|
||||
{
|
||||
bsx_state.command <<= 8;
|
||||
bsx_state.command |= data;
|
||||
|
||||
if ((bsx_state.command & 0xffffff) == 0xaa5570)
|
||||
{
|
||||
bsx_state.write_enable = 0;
|
||||
}
|
||||
|
||||
if ((bsx_state.command & 0xffffff) == 0xaa55a0)
|
||||
{
|
||||
bsx_state.write_old = 0x00;
|
||||
bsx_state.write_new = 0x00;
|
||||
bsx_state.flash_enable = 1;
|
||||
bsx_state.write_enable = 1;
|
||||
}
|
||||
|
||||
if ((bsx_state.command & 0xffffff) == 0xaa55f0)
|
||||
{
|
||||
bsx_state.flash_enable = 0;
|
||||
bsx_state.read_enable = 0;
|
||||
bsx_state.write_enable = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1900,7 +1900,8 @@ $(MACHINE)/snes.o: $(MAMESRC)/machine/snesdsp1.c \
|
||||
$(MAMESRC)/machine/cx4data.c \
|
||||
$(MAMESRC)/machine/snesrtc.c \
|
||||
$(MAMESRC)/machine/snessdd1.c \
|
||||
$(MAMESRC)/machine/snesst10.c \
|
||||
$(MAMESRC)/machine/snes7110.c \
|
||||
$(MAMESRC)/machine/snesst10.c
|
||||
$(MAMESRC)/machine/snesbsx.c
|
||||
$(VIDEO)/model2.o: $(MAMESRC)/video/model2rd.c
|
||||
$(VIDEO)/model3.o: $(MAMESRC)/video/m3raster.c
|
||||
|
@ -290,38 +290,6 @@ static const sega16sp_interface xboard_sega16sp_intf =
|
||||
1, // use buffer
|
||||
};
|
||||
|
||||
static const sega16sp_interface shinobld_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
117, // xoffs
|
||||
segaic16_sprites_16a_bootleg_shinobld_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static const sega16sp_interface passshtb_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
117, // xoffs
|
||||
segaic16_sprites_16a_bootleg_passhtb_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
static const sega16sp_interface wb3bbl_sega16sp_intf =
|
||||
{
|
||||
0, // which spriteram
|
||||
1024, // colorbase
|
||||
0x800, // ramsize
|
||||
117, // xoffs
|
||||
segaic16_sprites_16a_bootleg_wb3bl_draw, // draw function
|
||||
0, // use buffer
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define MDRV_SEGA16SP_ADD(_tag, _interface) \
|
||||
@ -360,18 +328,6 @@ static const sega16sp_interface wb3bbl_sega16sp_intf =
|
||||
MDRV_DEVICE_ADD(_tag, SEGA16SP, 0) \
|
||||
MDRV_DEVICE_CONFIG(xboard_sega16sp_intf)
|
||||
|
||||
#define MDRV_SEGA16SP_ADD_SHINOBI_BOOTLEG(_tag) \
|
||||
MDRV_DEVICE_ADD(_tag, SEGA16SP, 0) \
|
||||
MDRV_DEVICE_CONFIG(shinobld_sega16sp_intf)
|
||||
|
||||
#define MDRV_SEGA16SP_ADD_PASSINGSHOT_BOOTLEG(_tag) \
|
||||
MDRV_DEVICE_ADD(_tag, SEGA16SP, 0) \
|
||||
MDRV_DEVICE_CONFIG(passshtb_sega16sp_intf)
|
||||
|
||||
#define MDRV_SEGA16SP_ADD_WONDERBOY3_BOOTLEG(_tag) \
|
||||
MDRV_DEVICE_ADD(_tag, SEGA16SP, 0) \
|
||||
MDRV_DEVICE_CONFIG(wb3bbl_sega16sp_intf)
|
||||
|
||||
|
||||
extern struct palette_info palette;
|
||||
extern struct rotate_info rotate[SEGAIC16_MAX_ROTATE];
|
||||
|
Loading…
Reference in New Issue
Block a user