diff options
| author | 2008-06-05 08:40:22 +0000 | |
|---|---|---|
| committer | 2008-06-05 08:40:22 +0000 | |
| commit | 56279e278024dc354dfe145266cbd53ec58ad4b6 (patch) | |
| tree | a07dcf4bb87156b1806fd5157163ebee89a9e7a9 | |
| parent | 9073e622290222127a371722afeddbe01caefdd9 (diff) | |
From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] memory_region madness
The memory_region and memory_region_length functions are probably the
two most common functions in MAME that don't take a machine parameter
but probably should given the direction MAME has been going in
removing global variable references. Attached are massive patches to
accomplish this. I wish they could be smaller, but sadly, this is
butchery, not brain surgery.
The first patch makes some simplifications to help the second patch
along. It is a general improvement as well, and hopefully can be
applied even if the second patch is rejected. Specifically:
1. Introduced/updated some include files for files that export
functions whose apis will need to be changed (cps1.h, decocrpt.h,
ms32.h, pgm.h, fd1089.h, konami1.h). In the case of konami.c, I
renamed the file konami1.c and changed the api and callers to only
require one function export.
2. Pulled memory_region*() calls out of for loops and folded the
occasional duplicated call. The compiler can't likely infer that the
results are constant, so this should be a minor performance win as
well.
135 files changed, 745 insertions, 632 deletions
diff --git a/src/emu/sound/c352.c b/src/emu/sound/c352.c index 8cadcaaad7d..75458cac0da 100644 --- a/src/emu/sound/c352.c +++ b/src/emu/sound/c352.c @@ -114,7 +114,7 @@ static void c352_mix_one_channel(struct c352_info *info, unsigned long ch, long UINT16 noisecnt; INT32 frequency, delta, offset, cnt, flag; UINT32 bank; - UINT32 pos; + UINT32 pos, len; frequency = info->c352_ch[ch].pitch; delta=frequency; @@ -127,6 +127,7 @@ static void c352_mix_one_channel(struct c352_info *info, unsigned long ch, long noisecnt = info->c352_ch[ch].noisecnt; noisebuf = info->c352_ch[ch].noisebuf; + len = (UINT32)memory_region_length(info->c352_region); for(i = 0 ; (i < sample_count) && (flag & C352_FLG_BUSY) ; i++) { offset += delta; @@ -136,7 +137,7 @@ static void c352_mix_one_channel(struct c352_info *info, unsigned long ch, long offset &= 0xffff; } - if (pos > (UINT32)memory_region_length(info->c352_region)) + if (pos > len) { info->c352_ch[ch].flag &= ~C352_FLG_BUSY; return; diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 977e9fd0edc..48ae5e51c08 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -533,7 +533,7 @@ static void SCSP_Init(struct _SCSP *SCSP, const struct SCSPinterface *intf, int SCSP->SCSPRAM = memory_region(intf->region); SCSP->SCSPRAM_LENGTH = memory_region_length(intf->region); SCSP->DSP.SCSPRAM = (UINT16 *)SCSP->SCSPRAM; - SCSP->DSP.SCSPRAM_LENGTH = memory_region_length(intf->region)/2; + SCSP->DSP.SCSPRAM_LENGTH = SCSP->SCSPRAM_LENGTH/2; SCSP->SCSPRAM += intf->roffset; } } diff --git a/src/emu/sound/segapcm.c b/src/emu/sound/segapcm.c index bb046d2ea0e..ec484458824 100644 --- a/src/emu/sound/segapcm.c +++ b/src/emu/sound/segapcm.c @@ -79,7 +79,7 @@ static void SEGAPCM_update(void *param, stream_sample_t **inputs, stream_sample_ static void *segapcm_start(int sndindex, int clock, const void *config) { const struct SEGAPCMinterface *intf = config; - int mask, rom_mask; + int mask, rom_mask, len; struct segapcm *spcm; spcm = auto_malloc(sizeof(*spcm)); @@ -95,7 +95,8 @@ static void *segapcm_start(int sndindex, int clock, const void *config) if(!mask) mask = BANK_MASK7>>16; - for(rom_mask = 1; rom_mask < memory_region_length(intf->region); rom_mask *= 2); + len = memory_region_length(intf->region); + for(rom_mask = 1; rom_mask < len; rom_mask *= 2); rom_mask--; spcm->bankmask = mask & (rom_mask >> spcm->bankshift); diff --git a/src/mame/audio/atarijsa.c b/src/mame/audio/atarijsa.c index 437727de67d..8eb8091fe1b 100644 --- a/src/mame/audio/atarijsa.c +++ b/src/mame/audio/atarijsa.c @@ -107,6 +107,7 @@ static void init_save_state(void) void atarijsa_init(running_machine *machine, int testport, int testmask) { int i; + UINT8 *rgn; /* copy in the parameters */ cpu_num = mame_find_cpu_index(machine, "jsa"); @@ -115,8 +116,9 @@ void atarijsa_init(running_machine *machine, int testport, int testmask) test_mask = testmask; /* predetermine the bank base */ - bank_base = &memory_region(REGION_CPU1+cpu_num)[0x03000]; - bank_source_data = &memory_region(REGION_CPU1+cpu_num)[0x10000]; + rgn = memory_region(REGION_CPU1+cpu_num); + bank_base = &rgn[0x03000]; + bank_source_data = &rgn[0x10000]; /* determine which sound hardware is installed */ has_tms5220 = has_oki6295 = has_pokey = has_ym2151 = 0; diff --git a/src/mame/audio/cclimber.c b/src/mame/audio/cclimber.c index f36f01828e0..bca19484fd7 100644 --- a/src/mame/audio/cclimber.c +++ b/src/mame/audio/cclimber.c @@ -24,6 +24,7 @@ static void cclimber_sh_start(void) static void cclimber_play_sample(int start,int freq,int volume) { int len; + int romlen = memory_region_length(REGION_SOUND1); const UINT8 *rom = memory_region(REGION_SOUND1); @@ -31,7 +32,7 @@ static void cclimber_play_sample(int start,int freq,int volume) /* decode the rom samples */ len = 0; - while (start + len < memory_region_length(REGION_SOUND1) && rom[start+len] != 0x70) + while (start + len < romlen && rom[start+len] != 0x70) { int sample; diff --git a/src/mame/audio/fghtbskt.c b/src/mame/audio/fghtbskt.c index 5c4b06deb16..6e5a7549db0 100644 --- a/src/mame/audio/fghtbskt.c +++ b/src/mame/audio/fghtbskt.c @@ -17,11 +17,11 @@ WRITE8_HANDLER( fghtbskt_samples_w ) void fghtbskt_sh_start(void) { - int i; + int i, len = memory_region_length(REGION_SOUND1); UINT8 *ROM = memory_region(REGION_SOUND1); - samplebuf = auto_malloc(memory_region_length(REGION_SOUND1) * 2); + samplebuf = auto_malloc(len * 2); - for(i=0;i<memory_region_length(REGION_SOUND1);i++) + for(i=0;i<len;i++) samplebuf[i] = ((INT8)(ROM[i] ^ 0x80)) * 256; } diff --git a/src/mame/audio/seibu.c b/src/mame/audio/seibu.c index 6e30963e05f..15b1e185c1d 100644 --- a/src/mame/audio/seibu.c +++ b/src/mame/audio/seibu.c @@ -198,9 +198,10 @@ static void seibu_adpcm_stop(void *token) void seibu_adpcm_decrypt(int region) { UINT8 *ROM = memory_region(region); + int len = memory_region_length(region); int i; - for (i = 0; i < memory_region_length(region); i++) + for (i = 0; i < len; i++) { ROM[i] = BITSWAP8(ROM[i], 7, 5, 3, 1, 6, 4, 2, 0); } diff --git a/src/mame/audio/suna8.c b/src/mame/audio/suna8.c index b47a9d43abc..604066a30fa 100644 --- a/src/mame/audio/suna8.c +++ b/src/mame/audio/suna8.c @@ -35,11 +35,11 @@ WRITE8_HANDLER( suna8_samples_number_w ) void suna8_sh_start(void) { - int i; + int i, len = memory_region_length(REGION_SOUND1); UINT8 *ROM = memory_region(REGION_SOUND1); - samplebuf = auto_malloc(memory_region_length(REGION_SOUND1) * sizeof(samplebuf[0])); + samplebuf = auto_malloc(len * sizeof(samplebuf[0])); - for(i=0;i<memory_region_length(REGION_SOUND1);i++) + for(i=0;i<len;i++) samplebuf[i] = (INT8)(ROM[i] ^ 0x80) * 256; } diff --git a/src/mame/drivers/20pacgal.c b/src/mame/drivers/20pacgal.c index 6549747a7bc..ec8aff2aef6 100644 --- a/src/mame/drivers/20pacgal.c +++ b/src/mame/drivers/20pacgal.c @@ -165,7 +165,10 @@ static WRITE8_HANDLER( rom_bank_select_w ) state->game_selected = data & 1; if (state->game_selected == 0) - memcpy(memory_region(REGION_CPU1)+0x48000, memory_region(REGION_CPU1)+0x8000, 0x2000); + { + UINT8 *rom = memory_region(REGION_CPU1); + memcpy(rom+0x48000, rom+0x8000, 0x2000); + } } diff --git a/src/mame/drivers/2mindril.c b/src/mame/drivers/2mindril.c index afe3834d743..0268a4e1174 100644 --- a/src/mame/drivers/2mindril.c +++ b/src/mame/drivers/2mindril.c @@ -238,8 +238,9 @@ ROM_END static DRIVER_INIT( drill ) { // rearrange gfx roms to something we can decode, two of the roms form 4bpp of the graphics, the third forms another 2bpp but is in a different format - UINT32 *src = (UINT32*)memory_region ( REGION_GFX2 ); - UINT32 *dst = (UINT32*)memory_region ( REGION_GFX1 );// + 0x400000; + UINT32 *src = (UINT32*)memory_region( REGION_GFX2 ); + UINT32 *dst = (UINT32*)memory_region( REGION_GFX1 );// + 0x400000; + UINT8 *rom = memory_region( REGION_CPU1 ); int i; for (i=0; i< 0x400000/4; i++) @@ -250,10 +251,10 @@ static DRIVER_INIT( drill ) } //enable some kind of debug mode (ignore errors) - memory_region( REGION_CPU1)[0x7fffb]=0; - memory_region( REGION_CPU1)[0x7fffc]=0; - memory_region( REGION_CPU1)[0x7fffd]=0; - memory_region( REGION_CPU1)[0x7fffe]=0; + rom[0x7fffb]=0; + rom[0x7fffc]=0; + rom[0x7fffd]=0; + rom[0x7fffe]=0; } GAME( 1993, 2mindril, 0, drill, drill, drill, ROT0, "Taito", "Two Minute Drill", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS ) diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c index 1d74d506bdc..f6506ea5113 100644 --- a/src/mame/drivers/atarisy2.c +++ b/src/mame/drivers/atarisy2.c @@ -3034,6 +3034,7 @@ static DRIVER_INIT( paperboy ) 0x0000 }; int i; + UINT8 *cpu1 = memory_region(REGION_CPU1); atarigen_eeprom_default = compressed_default_eeprom; slapstic_init(105); @@ -3041,9 +3042,9 @@ static DRIVER_INIT( paperboy ) /* expand the 16k program ROMs into full 64k chunks */ for (i = 0x10000; i < 0x90000; i += 0x20000) { - memcpy(&memory_region(REGION_CPU1)[i + 0x08000], &memory_region(REGION_CPU1)[i], 0x8000); - memcpy(&memory_region(REGION_CPU1)[i + 0x10000], &memory_region(REGION_CPU1)[i], 0x8000); - memcpy(&memory_region(REGION_CPU1)[i + 0x18000], &memory_region(REGION_CPU1)[i], 0x8000); + memcpy(&cpu1[i + 0x08000], &cpu1[i], 0x8000); + memcpy(&cpu1[i + 0x10000], &cpu1[i], 0x8000); + memcpy(&cpu1[i + 0x18000], &cpu1[i], 0x8000); } pedal_count = 0; @@ -3090,16 +3091,17 @@ static DRIVER_INIT( 720 ) } -static void ssprint_init_common(const UINT16 *default_eeprom) +static void ssprint_init_common(running_machine *machine, const UINT16 *default_eeprom) { int i; + UINT8 *cpu1 = memory_region(REGION_CPU1); atarigen_eeprom_default = default_eeprom; slapstic_init(108); /* expand the 32k program ROMs into full 64k chunks */ for (i = 0x10000; i < 0x90000; i += 0x20000) - memcpy(&memory_region(REGION_CPU1)[i + 0x10000], &memory_region(REGION_CPU1)[i], 0x10000); + memcpy(&cpu1[i + 0x10000], &cpu1[i], 0x10000); pedal_count = 3; has_tms5220 = 0; @@ -3134,7 +3136,7 @@ static DRIVER_INIT( ssprint ) 0x01D0,0x0125,0x0186,0x0102,0x01C6,0x011D,0x011F,0xFF00, 0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0x0800,0x0000 }; - ssprint_init_common(compressed_default_eeprom); + ssprint_init_common(machine, compressed_default_eeprom); } static DRIVER_INIT( ssprint1 ) @@ -3179,7 +3181,7 @@ static DRIVER_INIT( ssprint1 ) 0x012c,0x0132,0x0102,0x01d0,0x0125,0x0186,0x0102,0x01c6, 0x011d,0x011f,0x0200,0x0000 }; - ssprint_init_common(compressed_default_eeprom); + ssprint_init_common(machine, compressed_default_eeprom); } @@ -3216,13 +3218,14 @@ static DRIVER_INIT( csprint ) 0x0186,0x0100,0x011B,0x01BC,0x011D,0x011F,0x0000 }; int i; + UINT8 *cpu1 = memory_region(REGION_CPU1); atarigen_eeprom_default = compressed_default_eeprom; slapstic_init(109); /* expand the 32k program ROMs into full 64k chunks */ for (i = 0x10000; i < 0x90000; i += 0x20000) - memcpy(&memory_region(REGION_CPU1)[i + 0x10000], &memory_region(REGION_CPU1)[i], 0x10000); + memcpy(&cpu1[i + 0x10000], &cpu1[i], 0x10000); pedal_count = 2; has_tms5220 = 0; diff --git a/src/mame/drivers/backfire.c b/src/mame/drivers/backfire.c index ba3abe648fc..d770130dd1a 100644 --- a/src/mame/drivers/backfire.c +++ b/src/mame/drivers/backfire.c @@ -11,8 +11,6 @@ */ #define DE156CPU ARM -extern void decrypt156(void); - #include "driver.h" #include "decocrpt.h" #include "deco32.h" @@ -685,7 +683,7 @@ static DRIVER_INIT( backfire ) { deco56_decrypt(REGION_GFX1); /* 141 */ deco56_decrypt(REGION_GFX2); /* 141 */ - decrypt156(); + deco156_decrypt(); cpunum_set_clockscale(machine, 0, 4.0f); /* core timings aren't accurate */ descramble_sound(); memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0170018, 0x017001b, 0, 0, backfire_speedup_r ); diff --git a/src/mame/drivers/balsente.c b/src/mame/drivers/balsente.c index d56ffb74bd2..9e602f6e531 100644 --- a/src/mame/drivers/balsente.c +++ b/src/mame/drivers/balsente.c @@ -1862,9 +1862,10 @@ static void expand_roms(UINT8 cd_rom_mask) UINT8 *temp = malloc_or_die(0x20000); { UINT8 *rom = memory_region(REGION_CPU1); + UINT32 len = memory_region_length(REGION_CPU1); UINT32 base; - for (base = 0x10000; base < memory_region_length(REGION_CPU1); base += 0x30000) + for (base = 0x10000; base < len; base += 0x30000) { UINT8 *ab_base = &temp[0x00000]; UINT8 *cd_base = &temp[0x10000]; @@ -1928,8 +1929,9 @@ static DRIVER_INIT( stocker ) { expand_roms(EXPAND_ALL); balsente_shooter = 0; static DRIVER_INIT( triviag1 ) { expand_roms(EXPAND_ALL); balsente_shooter = 0; /* noanalog */ } static DRIVER_INIT( triviag2 ) { - memcpy(&memory_region(REGION_CPU1)[0x20000], &memory_region(REGION_CPU1)[0x28000], 0x4000); - memcpy(&memory_region(REGION_CPU1)[0x24000], &memory_region(REGION_CPU1)[0x28000], 0x4000); + UINT8 *rom = memory_region(REGION_CPU1); + memcpy(&rom[0x20000], &rom[0x28000], 0x4000); + memcpy(&rom[0x24000], &rom[0x28000], 0x4000); expand_roms(EXPAND_NONE); balsente_shooter = 0; /* noanalog */ } static DRIVER_INIT( triviaes ) diff --git a/src/mame/drivers/bloodbro.c b/src/mame/drivers/bloodbro.c index 3f684759e80..f927aeb3b49 100644 --- a/src/mame/drivers/bloodbro.c +++ b/src/mame/drivers/bloodbro.c @@ -633,10 +633,11 @@ ROM_END static DRIVER_INIT( weststry ) { UINT8 *gfx = memory_region(REGION_GFX3); + int len = memory_region_length(REGION_GFX3); int i; // invert sprite data - for (i = 0; i < memory_region_length(REGION_GFX3); i++) + for (i = 0; i < len; i++) gfx[i] = ~gfx[i]; } diff --git a/src/mame/drivers/bnstars.c b/src/mame/drivers/bnstars.c index 42a5c730701..db4f9fba195 100644 --- a/src/mame/drivers/bnstars.c +++ b/src/mame/drivers/bnstars.c @@ -90,11 +90,10 @@ ROMs : MR96004-10.1 [125661cd] (IC5 - Samples) #include "deprecat.h" #include "sound/ymf271.h" #include "rendlay.h" +#include "includes/ms32.h" -/* drivers/ms32/c */ -extern void ms32_rearrange_sprites(int region); -extern void decrypt_ms32_tx(int addr_xor,int data_xor, int region); -extern void decrypt_ms32_bg(int addr_xor,int data_xor, int region); +#define ms32_roz_ctrl bnstars_roz_ctrl +#define ms32_spram bnstars_spram static tilemap *ms32_tx_tilemap[2]; static tilemap *ms32_bg_tilemap[2]; diff --git a/src/mame/drivers/boogwing.c b/src/mame/drivers/boogwing.c index 32fa6b16736..77fc414bceb 100644 --- a/src/mame/drivers/boogwing.c +++ b/src/mame/drivers/boogwing.c @@ -83,7 +83,6 @@ #include "sound/2151intf.h" #include "sound/okim6295.h" -extern void deco102_decrypt(int region, int address_xor, int data_select_xor, int opcode_select_xor); VIDEO_START(boogwing); VIDEO_UPDATE(boogwing); diff --git a/src/mame/drivers/carpolo.c b/src/mame/drivers/carpolo.c index e915a192335..b28f29a9c24 100644 --- a/src/mame/drivers/carpolo.c +++ b/src/mame/drivers/carpolo.c @@ -311,13 +311,14 @@ ROM_END static DRIVER_INIT( carpolo ) { - size_t i; + size_t i, len; UINT8 *ROM; /* invert gfx PROM since the bits are active LO */ ROM = memory_region(REGION_GFX2); - for (i = 0;i < memory_region_length(REGION_GFX2); i++) + len = memory_region_length(REGION_GFX2); + for (i = 0;i < len; i++) ROM[i] ^= 0x0f; } diff --git a/src/mame/drivers/cave.c b/src/mame/drivers/cave.c index 86b511ecb5c..3c7cec45e33 100644 --- a/src/mame/drivers/cave.c +++ b/src/mame/drivers/cave.c @@ -2621,8 +2621,9 @@ static void ddonpach_unpack_sprites(void) const int region = REGION_GFX1; // sprites const UINT32 len = memory_region_length(region); - UINT8 *src = memory_region(region) + len / 2 - 1; - UINT8 *dst = memory_region(region) + len - 1; + UINT8 *rgn = memory_region(region); + UINT8 *src = rgn + len / 2 - 1; + UINT8 *dst = rgn + len - 1; while(dst > src) { @@ -2646,7 +2647,7 @@ static void esprade_unpack_sprites(void) const int region = REGION_GFX1; // sprites UINT8 *src = memory_region(region); - UINT8 *dst = memory_region(region) + memory_region_length(region); + UINT8 *dst = src + memory_region_length(region); while(src < dst) { @@ -4047,8 +4048,10 @@ ROM_END Expand the 2 bit part into a 4 bit layout, so we can decode it */ static void sailormn_unpack_tiles( const int region ) { - UINT8 *src = memory_region(region) + (memory_region_length(region)/4)*3 - 1; - UINT8 *dst = memory_region(region) + (memory_region_length(region)/4)*4 - 2; + const UINT32 len = memory_region_length(region); + UINT8 *rgn = memory_region(region); + UINT8 *src = rgn + (len/4)*3 - 1; + UINT8 *dst = rgn + (len/4)*4 - 2; while(src <= dst) { diff --git a/src/mame/drivers/cbasebal.c b/src/mame/drivers/cbasebal.c index b1fd3a204b5..1cf316c6cfb 100644 --- a/src/mame/drivers/cbasebal.c +++ b/src/mame/drivers/cbasebal.c @@ -13,15 +13,12 @@ TODO: ***************************************************************************/ #include "driver.h" +#include "includes/cps1.h" #include "machine/eeprom.h" #include "sound/okim6295.h" #include "sound/2413intf.h" -/* in machine/kabuki.c */ -void pang_decode(void); - - VIDEO_START( cbasebal ); WRITE8_HANDLER( cbasebal_textram_w ); READ8_HANDLER( cbasebal_textram_r ); diff --git a/src/mame/drivers/circusc.c b/src/mame/drivers/circusc.c index c7b7bb8f863..0e8fe311619 100644 --- a/src/mame/drivers/circusc.c +++ b/src/mame/drivers/circusc.c @@ -14,13 +14,12 @@ To enter service mode, keep 1&2 pressed on reset ***************************************************************************/ #include "driver.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "sound/dac.h" #include "sound/sn76496.h" #include "sound/discrete.h" -void konami1_decode(void); - extern UINT8 *circusc_spritebank; extern UINT8 *circusc_scroll; extern UINT8 *circusc_videoram,*circusc_colorram; @@ -525,7 +524,7 @@ ROM_END static DRIVER_INIT( circusc ) { - konami1_decode(); + konami1_decode(0); } diff --git a/src/mame/drivers/cischeat.c b/src/mame/drivers/cischeat.c index 910ccfab947..52823884c02 100644 --- a/src/mame/drivers/cischeat.c +++ b/src/mame/drivers/cischeat.c @@ -1974,7 +1974,7 @@ MACHINE_DRIVER_END static void cischeat_untangle_sprites(int region) { UINT8 *src = memory_region(region); - const UINT8 *end = memory_region(region) + memory_region_length(region); + const UINT8 *end = src + memory_region_length(region); while (src < end) { diff --git a/src/mame/drivers/cojag.c b/src/mame/drivers/cojag.c index 427c11bb1d5..3849bf07a58 100644 --- a/src/mame/drivers/cojag.c +++ b/src/mame/drivers/cojag.c @@ -219,25 +219,27 @@ static UINT32 *rom_base; static MACHINE_RESET( cojag ) { + UINT8 *rom = memory_region(REGION_USER2); + /* 68020 only: copy the interrupt vectors into RAM */ if (!cojag_is_r3000) memcpy(jaguar_shared_ram, rom_base, 0x10); /* configure banks for gfx/sound ROMs */ - if (memory_region(REGION_USER2)) + if (rom) { /* graphics banks */ if (cojag_is_r3000) { - memory_configure_bank(1, 0, 2, memory_region(REGION_USER2) + 0x800000, 0x400000); + memory_configure_bank(1, 0, 2, rom + 0x800000, 0x400000); memory_set_bank(1, 0); } - memory_configure_bank(8, 0, 2, memory_region(REGION_USER2) + 0x800000, 0x400000); + memory_configure_bank(8, 0, 2, rom + 0x800000, 0x400000); memory_set_bank(8, 0); /* sound banks */ - memory_configure_bank(2, 0, 8, memory_region(REGION_USER2) + 0x000000, 0x200000); - memory_configure_bank(9, 0, 8, memory_region(REGION_USER2) + 0x000000, 0x200000); + memory_configure_bank(2, 0, 8, rom + 0x000000, 0x200000); + memory_configure_bank(9, 0, 8, rom + 0x000000, 0x200000); memory_set_bank(2, 0); memory_set_bank(9, 0); } diff --git a/src/mame/drivers/coolpool.c b/src/mame/drivers/coolpool.c index ed6d62c04ba..1aad9c8c976 100644 --- a/src/mame/drivers/coolpool.c +++ b/src/mame/drivers/coolpool.c @@ -940,12 +940,13 @@ static DRIVER_INIT( coolpool ) static DRIVER_INIT( 9ballsht ) { - int a; + int a, len; UINT16 *rom; /* decrypt the main program ROMs */ rom = (UINT16 *)memory_region(REGION_USER1); - for (a = 0;a < memory_region_length(REGION_USER1)/2;a++) + len = memory_region_length(REGION_USER1); + for (a = 0;a < len/2;a++) { int hi,lo,nhi,nlo; @@ -968,7 +969,8 @@ static DRIVER_INIT( 9ballsht ) /* decrypt the sub data ROMs */ rom = (UINT16 *)memory_region(REGION_USER2); - for (a = 1;a < memory_region_length(REGION_USER2)/2;a+=4) + len = memory_region_length(REGION_USER2); + for (a = 1;a < len/2;a+=4) { /* just swap bits 1 and 2 of the address */ UINT16 tmp = rom[a]; diff --git a/src/mame/drivers/cosmic.c b/src/mame/drivers/cosmic.c index f6d3c627ac4..8f12c14eb2a 100644 --- a/src/mame/drivers/cosmic.c +++ b/src/mame/drivers/cosmic.c @@ -1460,18 +1460,21 @@ static DRIVER_INIT( cosmicg ) { /* Program ROMs have data pins connected different from normal */ - offs_t offs; + offs_t offs, len; + UINT8 *rom; - for (offs =0; offs < memory_region_length(REGION_CPU1); offs++) - { - UINT8 scrambled = memory_region(REGION_CPU1)[offs]; + len = memory_region_length(REGION_CPU1); + rom = memory_region(REGION_CPU1); + for (offs =0; offs < len; offs++) + { + UINT8 scrambled = rom[offs]; UINT8 normal = (scrambled >> 3 & 0x11) | (scrambled >> 1 & 0x22) | (scrambled << 1 & 0x44) | (scrambled << 3 & 0x88); - memory_region(REGION_CPU1)[offs] = normal; + rom[offs] = normal; } } diff --git a/src/mame/drivers/cps3.c b/src/mame/drivers/cps3.c index 4d97f1c5eee..32bce13e18b 100644 --- a/src/mame/drivers/cps3.c +++ b/src/mame/drivers/cps3.c @@ -2515,11 +2515,11 @@ static void precopy_to_flash(void) /* precopy gfx roms, good, tests pass */ { - UINT32 thebase; + UINT32 thebase, len = memory_region_length(REGION_USER5); int flashnum = 8; UINT32* romdata = (UINT32*)memory_region(REGION_USER5); - for (thebase = 0;thebase < memory_region_length(REGION_USER5)/2; thebase+=0x200000) + for (thebase = 0;thebase < len/2; thebase+=0x200000) { // printf("flashnums %d. %d\n",flashnum, flashnum+1); @@ -2587,12 +2587,12 @@ static void copy_from_nvram(void) /* copy gfx from loaded flashroms to user reigon 5, where it's used */ { - UINT32 thebase; + UINT32 thebase, len = memory_region_length(REGION_USER5); int flashnum = 8; UINT32* romdata = (UINT32*)memory_region(REGION_USER5); int countoffset = 0; - for (thebase = 0;thebase < memory_region_length(REGION_USER5)/2; thebase+=0x200000) + for (thebase = 0;thebase < len/2; thebase+=0x200000) { // printf("flashnums %d. %d\n",flashnum, flashnum+1); diff --git a/src/mame/drivers/cvs.c b/src/mame/drivers/cvs.c index b7f79a81117..dd80b919869 100644 --- a/src/mame/drivers/cvs.c +++ b/src/mame/drivers/cvs.c @@ -1535,19 +1535,21 @@ ROM_END static DRIVER_INIT( huncholy ) { + UINT8 *ROM = memory_region(REGION_CPU1); + /* patch out protection */ - memory_region(REGION_CPU1)[0x0082] = 0xc0; - memory_region(REGION_CPU1)[0x0083] = 0xc0; - memory_region(REGION_CPU1)[0x0084] = 0xc0; - memory_region(REGION_CPU1)[0x00b7] = 0xc0; - memory_region(REGION_CPU1)[0x00b8] = 0xc0; - memory_region(REGION_CPU1)[0x00b9] = 0xc0; - memory_region(REGION_CPU1)[0x00d9] = 0xc0; - memory_region(REGION_CPU1)[0x00da] = 0xc0; - memory_region(REGION_CPU1)[0x00db] = 0xc0; - memory_region(REGION_CPU1)[0x4456] = 0xc0; - memory_region(REGION_CPU1)[0x4457] = 0xc0; - memory_region(REGION_CPU1)[0x4458] = 0xc0; + ROM[0x0082] = 0xc0; + ROM[0x0083] = 0xc0; + ROM[0x0084] = 0xc0; + ROM[0x00b7] = 0xc0; + ROM[0x00b8] = 0xc0; + ROM[0x00b9] = 0xc0; + ROM[0x00d9] = 0xc0; + ROM[0x00da] = 0xc0; + ROM[0x00db] = 0xc0; + ROM[0x4456] = 0xc0; + ROM[0x4457] = 0xc0; + ROM[0x4458] = 0xc0; } @@ -1565,47 +1567,51 @@ static DRIVER_INIT( hunchbka ) static DRIVER_INIT( superbik ) { + UINT8 *ROM = memory_region(REGION_CPU1); + /* patch out protection */ - memory_region(REGION_CPU1)[0x0079] = 0xc0; - memory_region(REGION_CPU1)[0x007a] = 0xc0; - memory_region(REGION_CPU1)[0x007b] = 0xc0; - memory_region(REGION_CPU1)[0x0081] = 0xc0; - memory_region(REGION_CPU1)[0x0082] = 0xc0; - memory_region(REGION_CPU1)[0x0083] = 0xc0; - memory_region(REGION_CPU1)[0x00b6] = 0xc0; - memory_region(REGION_CPU1)[0x00b7] = 0xc0; - memory_region(REGION_CPU1)[0x00b8] = 0xc0; - memory_region(REGION_CPU1)[0x0168] = 0xc0; - memory_region(REGION_CPU1)[0x0169] = 0xc0; - memory_region(REGION_CPU1)[0x016a] = 0xc0; + ROM[0x0079] = 0xc0; + ROM[0x007a] = 0xc0; + ROM[0x007b] = 0xc0; + ROM[0x0081] = 0xc0; + ROM[0x0082] = 0xc0; + ROM[0x0083] = 0xc0; + ROM[0x00b6] = 0xc0; + ROM[0x00b7] = 0xc0; + ROM[0x00b8] = 0xc0; + ROM[0x0168] = 0xc0; + ROM[0x0169] = 0xc0; + ROM[0x016a] = 0xc0; /* and speed up the protection check */ - memory_region(REGION_CPU1)[0x0099] = 0xc0; - memory_region(REGION_CPU1)[0x009a] = 0xc0; - memory_region(REGION_CPU1)[0x009b] = 0xc0; - memory_region(REGION_CPU1)[0x00bb] = 0xc0; - memory_region(REGION_CPU1)[0x00bc] = 0xc0; - memory_region(REGION_CPU1)[0x00bd] = 0xc0; + ROM[0x0099] = 0xc0; + ROM[0x009a] = 0xc0; + ROM[0x009b] = 0xc0; + ROM[0x00bb] = 0xc0; + ROM[0x00bc] = 0xc0; + ROM[0x00bd] = 0xc0; } static DRIVER_INIT( hero ) { + UINT8 *ROM = memory_region(REGION_CPU1); + /* patch out protection */ - memory_region(REGION_CPU1)[0x0087] = 0xc0; - memory_region(REGION_CPU1)[0x0088] = 0xc0; - memory_region(REGION_CPU1)[0x0aa1] = 0xc0; - memory_region(REGION_CPU1)[0x0aa2] = 0xc0; - memory_region(REGION_CPU1)[0x0aa3] = 0xc0; - memory_region(REGION_CPU1)[0x0aaf] = 0xc0; - memory_region(REGION_CPU1)[0x0ab0] = 0xc0; - memory_region(REGION_CPU1)[0x0ab1] = 0xc0; - memory_region(REGION_CPU1)[0x0abd] = 0xc0; - memory_region(REGION_CPU1)[0x0abe] = 0xc0; - memory_region(REGION_CPU1)[0x0abf] = 0xc0; - memory_region(REGION_CPU1)[0x4de0] = 0xc0; - memory_region(REGION_CPU1)[0x4de1] = 0xc0; - memory_region(REGION_CPU1)[0x4de2] = 0xc0; + ROM[0x0087] = 0xc0; + ROM[0x0088] = 0xc0; + ROM[0x0aa1] = 0xc0; + ROM[0x0aa2] = 0xc0; + ROM[0x0aa3] = 0xc0; + ROM[0x0aaf] = 0xc0; + ROM[0x0ab0] = 0xc0; + ROM[0x0ab1] = 0xc0; + ROM[0x0abd] = 0xc0; + ROM[0x0abe] = 0xc0; + ROM[0x0abf] = 0xc0; + ROM[0x4de0] = 0xc0; + ROM[0x4de1] = 0xc0; + ROM[0x4de2] = 0xc0; } @@ -1620,9 +1626,9 @@ static DRIVER_INIT( raiders ) ROM[offs] = BITSWAP8(ROM[offs],7,1,5,4,3,2,6,0); /* patch out protection */ - memory_region(REGION_CPU1)[0x010a] = 0xc0; - memory_region(REGION_CPU1)[0x010b] = 0xc0; - memory_region(REGION_CPU1)[0x010c] = 0xc0; + ROM[0x010a] = 0xc0; + ROM[0x010b] = 0xc0; + ROM[0x010c] = 0xc0; } diff --git a/src/mame/drivers/dambustr.c b/src/mame/drivers/dambustr.c index b1a65cb8050..aa8f386b1d8 100644 --- a/src/mame/drivers/dambustr.c +++ b/src/mame/drivers/dambustr.c @@ -147,38 +147,37 @@ static DRIVER_INIT(dambustr) { int i, j, tmp; int tmpram[16]; + UINT8 *rom = memory_region(REGION_CPU1); + UINT8 *usr = memory_region(REGION_USER1); + UINT8 *gfx = memory_region(REGION_GFX1); // Bit swap addresses for(i=0; i<4096*4; i++) { - memory_region(REGION_CPU1)[i] = - memory_region(REGION_USER1)[BITSWAP16(i,15,14,13,12, 4,10,9,8,7,6,5,3,11,2,1,0)]; + rom[i] = usr[BITSWAP16(i,15,14,13,12, 4,10,9,8,7,6,5,3,11,2,1,0)]; }; // Swap program ROMs for(i=0; i<0x1000; i++) { - tmp = memory_region(REGION_CPU1)[0x5000+i]; - memory_region(REGION_CPU1)[0x5000+i] = memory_region(REGION_CPU1)[0x6000+i]; - memory_region(REGION_CPU1)[0x6000+i] = memory_region(REGION_CPU1)[0x1000+i]; - memory_region(REGION_CPU1)[0x1000+i] = tmp; + tmp = rom[0x5000+i]; + rom[0x5000+i] = rom[0x6000+i]; + rom[0x6000+i] = rom[0x1000+i]; + rom[0x1000+i] = tmp; }; // Bit swap in $1000-$1fff and $4000-$5fff for(i=0; i<0x1000; i++) { - memory_region(REGION_CPU1)[0x1000+i] = - BITSWAP8(memory_region(REGION_CPU1)[0x1000+i],7,6,5,1,3,2,4,0); - memory_region(REGION_CPU1)[0x4000+i] = - BITSWAP8(memory_region(REGION_CPU1)[0x4000+i],7,6,5,1,3,2,4,0); - memory_region(REGION_CPU1)[0x5000+i] = - BITSWAP8(memory_region(REGION_CPU1)[0x5000+i],7,6,5,1,3,2,4,0); + rom[0x1000+i] = BITSWAP8(rom[0x1000+i],7,6,5,1,3,2,4,0); + rom[0x4000+i] = BITSWAP8(rom[0x4000+i],7,6,5,1,3,2,4,0); + rom[0x5000+i] = BITSWAP8(rom[0x5000+i],7,6,5,1,3,2,4,0); }; // Swap graphics ROMs for(i=0;i<0x4000;i+=16) { for(j=0; j<16; j++) - tmpram[j] = memory_region(REGION_GFX1)[i+j]; + tmpram[j] = gfx[i+j]; for(j=0; j<8; j++) { - memory_region(REGION_GFX1)[i+j] = tmpram[j*2]; - memory_region(REGION_GFX1)[i+j+8] = tmpram[j*2+1]; + gfx[i+j] = tmpram[j*2]; + gfx[i+j+8] = tmpram[j*2+1]; }; }; } diff --git a/src/mame/drivers/darkmist.c b/src/mame/drivers/darkmist.c index 1290e78653b..db206313988 100644 --- a/src/mame/drivers/darkmist.c +++ b/src/mame/drivers/darkmist.c @@ -422,7 +422,7 @@ static void decrypt_snd(void) static DRIVER_INIT(darkmist) { - int i; + int i, len; UINT8 *ROM = memory_region(REGION_CPU1); UINT8 *buffer = malloc_or_die(0x10000); UINT8 *decrypt = auto_malloc(0x8000); @@ -460,30 +460,34 @@ static DRIVER_INIT(darkmist) /* adr line swaps */ ROM = memory_region(REGION_USER1); - memcpy( buffer, ROM, memory_region_length(REGION_USER1) ); + len = memory_region_length(REGION_USER1); + memcpy( buffer, ROM, len ); - for(i=0;i<memory_region_length(REGION_USER1);i++) + for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = memory_region(REGION_USER2); - memcpy( buffer, ROM, memory_region_length(REGION_USER2) ); - for(i=0;i<memory_region_length(REGION_USER2);i++) + len = memory_region_length(REGION_USER2); + memcpy( buffer, ROM, len ); + for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,6,5,4,3,2,14,13,12,11,8,7,1,0,10,9)]; } ROM = memory_region(REGION_USER3); - memcpy( buffer, ROM, memory_region_length(REGION_USER3) ); - for(i=0;i<memory_region_length(REGION_USER3);i++) + len = memory_region_length(REGION_USER3); + memcpy( buffer, ROM, len ); + for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } ROM = memory_region(REGION_USER4); - memcpy( buffer, ROM, memory_region_length(REGION_USER4) ); - for(i=0;i<memory_region_length(REGION_USER4);i++) + len = memory_region_length(REGION_USER4); + memcpy( buffer, ROM, len ); + for(i=0;i<len;i++) { ROM[i]=buffer[BITSWAP24(i,23,22,21,20,19,18,17,16,15,14 ,5,4,3,2,11,10,9,8,13,12,1,0,7,6)]; } diff --git a/src/mame/drivers/dblewing.c b/src/mame/drivers/dblewing.c index 3eaeb3c2b27..5081ee6b6d2 100644 --- a/src/mame/drivers/dblewing.c +++ b/src/mame/drivers/dblewing.c @@ -16,8 +16,6 @@ the most protected of the DE102 games? #include "sound/2151intf.h" #include "sound/okim6295.h" -extern void deco102_decrypt(int region, int address_xor, int data_select_xor, int opcode_select_xor); - /* offs +0 diff --git a/src/mame/drivers/deco156.c b/src/mame/drivers/deco156.c index d45cd5360ef..65be253838b 100644 --- a/src/mame/drivers/deco156.c +++ b/src/mame/drivers/deco156.c @@ -13,8 +13,6 @@ */ #define DE156CPU ARM -extern void decrypt156(void); - #include "driver.h" #include "decocrpt.h" #include "deco32.h" @@ -690,14 +688,14 @@ static void descramble_sound( int region ) static DRIVER_INIT( hvysmsh ) { deco56_decrypt(REGION_GFX1); /* 141 */ - decrypt156(); + deco156_decrypt(); descramble_sound(REGION_SOUND2); } static DRIVER_INIT( wcvol95 ) { deco56_decrypt(REGION_GFX1); /* 141 */ - decrypt156(); + deco156_decrypt(); descramble_sound(REGION_SOUND1); } diff --git a/src/mame/drivers/deco32.c b/src/mame/drivers/deco32.c index d527c1e38b8..b8071f6ae2f 100644 --- a/src/mame/drivers/deco32.c +++ b/src/mame/drivers/deco32.c @@ -241,8 +241,6 @@ static int raster_enable; static emu_timer *raster_irq_timer; static UINT8 nslasher_sound_irq; -extern void decrypt156(void); - /**********************************************************************************/ static TIMER_CALLBACK( interrupt_gen ) @@ -3277,7 +3275,7 @@ static DRIVER_INIT( nslasher ) deco56_decrypt(REGION_GFX1); /* 141 */ deco74_decrypt(REGION_GFX2); - decrypt156(); + deco156_decrypt(); soundlatch_setclearedvalue(0xff); diff --git a/src/mame/drivers/deco_mlc.c b/src/mame/drivers/deco_mlc.c index cc62ca9d8db..33345fb5446 100644 --- a/src/mame/drivers/deco_mlc.c +++ b/src/mame/drivers/deco_mlc.c @@ -96,13 +96,12 @@ ***************************************************************************/ #include "driver.h" +#include "includes/decocrpt.h" #include "machine/eeprom.h" #include "sound/ymz280b.h" #include "decoprot.h" #include "cpu/arm/arm.h" -extern void decrypt156(void); - VIDEO_START( mlc ); VIDEO_UPDATE( mlc ); VIDEO_EOF( mlc ); @@ -735,7 +734,7 @@ static DRIVER_INIT( mlc ) Skull Fung where there probably shouldn't be. */ cpunum_set_clockscale(machine, 0, 2.0f); mainCpuIsArm=1; - decrypt156(); + deco156_decrypt(); descramble_sound(); } diff --git a/src/mame/drivers/dietgo.c b/src/mame/drivers/dietgo.c index 55c6b41afc1..88b162d3a4d 100644 --- a/src/mame/drivers/dietgo.c +++ b/src/mame/drivers/dietgo.c @@ -16,8 +16,6 @@ VIDEO_START( dietgo ); READ16_HANDLER( dietgo_104_prot_r ); WRITE16_HANDLER( dietgo_104_prot_w ); -extern void deco102_decrypt(int region, int address_xor, int data_select_xor, int opcode_select_xor); - static ADDRESS_MAP_START( dietgo_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM diff --git a/src/mame/drivers/dreamwld.c b/src/mame/drivers/dreamwld.c index a5fbfdb8825..49d690dc309 100644 --- a/src/mame/drivers/dreamwld.c +++ b/src/mame/drivers/dreamwld.c @@ -239,7 +239,7 @@ static void dreamwld_oki_setbank( UINT8 chip, UINT8 bank ) { /* 0x30000-0x3ffff is banked. banks are at 0x30000,0x40000,0x50000 and 0x60000 in rom */ - UINT8 *sound = chip?memory_region(REGION_SOUND1):memory_region(REGION_SOUND2); + UINT8 *sound = memory_region(chip ? REGION_SOUND1 : REGION_SOUND2); logerror("OKI%d: set bank %02x\n",chip,bank); memcpy(sound+0x30000, sound+0xb0000+0x10000*bank, 0x10000); } diff --git a/src/mame/drivers/dwarfd.c b/src/mame/drivers/dwarfd.c index bc3f5165ac7..282bfbd19b5 100644 --- a/src/mame/drivers/dwarfd.c +++ b/src/mame/drivers/dwarfd.c @@ -743,13 +743,13 @@ ROM_END static DRIVER_INIT(dwarfd) { int i; + UINT8 *src, *dst; /* expand gfx roms */ + src = memory_region ( REGION_GFX1 ); + dst = memory_region ( REGION_GFX2 ); for (i=0;i<0x4000;i++) { - UINT8 *src = memory_region ( REGION_GFX1 ); - UINT8 *dst = memory_region ( REGION_GFX2 ); - UINT8 dat; dat = (src[i]&0xf0)>>0; dst[i*2] = dat; @@ -759,9 +759,9 @@ static DRIVER_INIT(dwarfd) } /* use low bit as 'interpolation' bit */ + src = memory_region ( REGION_GFX2 ); for (i=0;i<0x8000;i++) { - UINT8 *src = memory_region ( REGION_GFX2 ); if (src[i]&0x10) { src[i] = src[i]&0xe0; diff --git a/src/mame/drivers/dynadice.c b/src/mame/drivers/dynadice.c index e667ebc6689..bb9b5c4fb8e 100644 --- a/src/mame/drivers/dynadice.c +++ b/src/mame/drivers/dynadice.c @@ -250,12 +250,17 @@ ROM_END static DRIVER_INIT( dynadice ) { int i,j; - memory_region(REGION_CPU2)[0x0b]=0x23; /* bug in game code Dec HL -> Inc HL*/ + UINT8 *usr1 = memory_region(REGION_USER1); + UINT8 *cpu2 = memory_region(REGION_CPU2); + UINT8 *gfx1 = memory_region(REGION_GFX1); + UINT8 *gfx2 = memory_region(REGION_GFX2); + + cpu2[0x0b]=0x23; /* bug in game code Dec HL -> Inc HL*/ /* 1bpp tiles -> 3bpp tiles (dy_5.bin contains bg/fg color data for each tile line) */ for(i=0;i<0x800;i++) for(j=0;j<8;j++) - memory_region(REGION_GFX2)[(i<<3)+j]=(memory_region(REGION_GFX1)[i]&(0x80>>j))?(memory_region(REGION_USER1)[i]&7):(memory_region(REGION_USER1)[i]>>4); + gfx2[(i<<3)+j]=(gfx1[i]&(0x80>>j))?(usr1[i]&7):(usr1[i]>>4); } diff --git a/src/mame/drivers/enigma2.c b/src/mame/drivers/enigma2.c index 46ae89e3be6..dcfb140cc0e 100644 --- a/src/mame/drivers/enigma2.c +++ b/src/mame/drivers/enigma2.c @@ -170,8 +170,9 @@ static VIDEO_UPDATE( enigma2 ) pen_t pens[NUM_PENS]; const rectangle *visarea = video_screen_get_visible_area(screen); - UINT8 *color_map_base = engima2_flip_screen ? &memory_region(REGION_PROMS)[0x0400] : memory_region(REGION_PROMS); - UINT8 *star_map_base = (blink_count & 0x08) ? &memory_region(REGION_PROMS)[0x0c00] : &memory_region(REGION_PROMS)[0x0800]; + UINT8 *prom = memory_region(REGION_PROMS); + UINT8 *color_map_base = engima2_flip_screen ? &prom[0x0400] : &prom[0x0000]; + UINT8 *star_map_base = (blink_count & 0x08) ? &prom[0x0c00] : &prom[0x0800]; UINT8 x = 0; UINT16 bitmap_y = visarea->min_y; @@ -655,10 +656,11 @@ ROM_END static DRIVER_INIT(enigma2) { offs_t i; + UINT8 *rom = memory_region(REGION_CPU2); for(i = 0; i < 0x2000; i++) { - memory_region(REGION_CPU2)[i] = BITSWAP8(memory_region(REGION_CPU2)[i],4,5,6,0,7,1,3,2); + rom[i] = BITSWAP8(rom[i],4,5,6,0,7,1,3,2); } } diff --git a/src/mame/drivers/exidy440.c b/src/mame/drivers/exidy440.c index ae0e76f5d68..cff1c1f449d 100644 --- a/src/mame/drivers/exidy440.c +++ b/src/mame/drivers/exidy440.c @@ -241,15 +241,16 @@ static READ8_HANDLER( showdown_bank0_r ); static NVRAM_HANDLER( exidy440 ) { + UINT8 *rom = memory_region(REGION_CPU1); if (read_or_write) /* the EEROM lives in the uppermost 8k of the top bank */ - mame_fwrite(file, &memory_region(REGION_CPU1)[0x10000 + 15 * 0x4000 + 0x2000], 0x2000); + mame_fwrite(file, &rom[0x10000 + 15 * 0x4000 + 0x2000], 0x2000); else { if (file) - mame_fread(file, &memory_region(REGION_CPU1)[0x10000 + 15 * 0x4000 + 0x2000], 0x2000); + mame_fread(file, &rom[0x10000 + 15 * 0x4000 + 0x2000], 0x2000); else - memset(&memory_region(REGION_CPU1)[0x10000 + 15 * 0x4000 + 0x2000], 0, 0x2000); + memset(&rom[0x10000 + 15 * 0x4000 + 0x2000], 0, 0x2000); } } diff --git a/src/mame/drivers/finalizr.c b/src/mame/drivers/finalizr.c index 07ef03f8087..43d0b1780c7 100644 --- a/src/mame/drivers/finalizr.c +++ b/src/mame/drivers/finalizr.c @@ -8,14 +8,13 @@ driver by Nicola Salmoria #include "driver.h" #include "deprecat.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "cpu/i8039/i8039.h" #include "sound/sn76496.h" #include "sound/dac.h" -void konami1_decode(void); - extern UINT8 *finalizr_scroll; extern UINT8 *finalizr_videoram2,*finalizr_colorram2; static UINT8 *finalizr_interrupt_enable; @@ -500,7 +499,7 @@ ROM_END static DRIVER_INIT( finalizr ) { - konami1_decode(); + konami1_decode(0); } diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c index 6652f9a01bd..4860a6f721c 100644 --- a/src/mame/drivers/galaga.c +++ b/src/mame/drivers/galaga.c @@ -3050,9 +3050,9 @@ static DRIVER_INIT (galaga) { /* swap bytes for flipped character so we can decode them together with normal characters */ UINT8 *rom = memory_region(REGION_GFX1); - int i; + int i, len = memory_region_length(REGION_GFX1); - for (i = 0;i < memory_region_length(REGION_GFX1);i++) + for (i = 0;i < len;i++) { if ((i & 0x0808) == 0x0800) { diff --git a/src/mame/drivers/gauntlet.c b/src/mame/drivers/gauntlet.c index 1fa9c5785e6..3f0bd2b48e7 100644 --- a/src/mame/drivers/gauntlet.c +++ b/src/mame/drivers/gauntlet.c @@ -1633,15 +1633,16 @@ ROM_END static void gauntlet_common_init(int slapstic, int vindctr2) { + UINT8 *rom = memory_region(REGION_CPU1); atarigen_eeprom_default = NULL; atarigen_slapstic_init(0, 0x038000, 0, slapstic); /* swap the top and bottom halves of the main CPU ROM images */ - atarigen_swap_mem(memory_region(REGION_CPU1) + 0x000000, memory_region(REGION_CPU1) + 0x008000, 0x8000); - atarigen_swap_mem(memory_region(REGION_CPU1) + 0x040000, memory_region(REGION_CPU1) + 0x048000, 0x8000); - atarigen_swap_mem(memory_region(REGION_CPU1) + 0x050000, memory_region(REGION_CPU1) + 0x058000, 0x8000); - atarigen_swap_mem(memory_region(REGION_CPU1) + 0x060000, memory_region(REGION_CPU1) + 0x068000, 0x8000); - atarigen_swap_mem(memory_region(REGION_CPU1) + 0x070000, memory_region(REGION_CPU1) + 0x078000, 0x8000); + atarigen_swap_mem(rom + 0x000000, rom + 0x008000, 0x8000); + atarigen_swap_mem(rom + 0x040000, rom + 0x048000, 0x8000); + atarigen_swap_mem(rom + 0x050000, rom + 0x058000, 0x8000); + atarigen_swap_mem(rom + 0x060000, rom + 0x068000, 0x8000); + atarigen_swap_mem(rom + 0x070000, rom + 0x078000, 0x8000); /* indicate whether or not we are vindicators 2 */ vindctr2_screen_refresh = vindctr2; diff --git a/src/mame/drivers/gyruss.c b/src/mame/drivers/gyruss.c index 88dcdb9e490..02ac25cd3b7 100644 --- a/src/mame/drivers/gyruss.c +++ b/src/mame/drivers/gyruss.c @@ -56,6 +56,7 @@ and 1 SFX channel controlled by an 8039: ***************************************************************************/ #include "driver.h" +#include "machine/konami1.h" #include "cpu/i8039/i8039.h" #include "sound/ay8910.h" #include "sound/discrete.h" @@ -65,7 +66,6 @@ extern UINT8 *gyruss_colorram; extern UINT8 *gyruss_spriteram; extern UINT8 *gyruss_flipscreen; -void konami1_decode_cpu2(void); WRITE8_HANDLER( gyruss_spriteram_w ); READ8_HANDLER( gyruss_scanline_r ); VIDEO_START( gyruss ); @@ -701,7 +701,7 @@ ROM_END static DRIVER_INIT( gyruss ) { - konami1_decode_cpu2(); + konami1_decode(1); } diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c index 6feaaf2d6ac..b97f07e4209 100644 --- a/src/mame/drivers/hornet.c +++ b/src/mame/drivers/hornet.c @@ -742,11 +742,12 @@ static WRITE32_HANDLER( comm1_w ) static WRITE32_HANDLER( comm_rombank_w ) { int bank = data >> 24; - if (memory_region(REGION_USER3)) + UINT8 *usr3 = memory_region(REGION_USER3); + if (usr3) if( bank != comm_rombank ) { printf("rombank %02X\n", bank); comm_rombank = bank & 0x7f; - memory_set_bankptr(1, memory_region(REGION_USER3) + (comm_rombank * 0x10000)); + memory_set_bankptr(1, usr3 + (comm_rombank * 0x10000)); } } @@ -974,12 +975,14 @@ static MACHINE_START( hornet ) static MACHINE_RESET( hornet ) { - if (memory_region(REGION_USER3)) - memory_set_bankptr(1, memory_region(REGION_USER3)); + UINT8 *usr3 = memory_region(REGION_USER3); + UINT8 *usr5 = memory_region(REGION_USER5); + if (usr3) + memory_set_bankptr(1, usr3); cpunum_set_input_line(machine, 2, INPUT_LINE_RESET, ASSERT_LINE); - if (memory_region(REGION_USER5)) - memory_set_bankptr(5, memory_region(REGION_USER5)); + if (usr5) + memory_set_bankptr(5, usr5); } static MACHINE_DRIVER_START( hornet ) @@ -1025,13 +1028,16 @@ MACHINE_DRIVER_END static MACHINE_RESET( hornet_2board ) { - if (memory_region(REGION_USER3)) - memory_set_bankptr(1, memory_region(REGION_USER3)); + UINT8 *usr3 = memory_region(REGION_USER3); + UINT8 *usr5 = memory_region(REGION_USER5); + + if (usr3) + memory_set_bankptr(1, usr3); cpunum_set_input_line(machine, 2, INPUT_LINE_RESET, ASSERT_LINE); cpunum_set_input_line(machine, 3, INPUT_LINE_RESET, ASSERT_LINE); - if (memory_region(REGION_USER5)) - memory_set_bankptr(5, memory_region(REGION_USER5)); + if (usr5) + memory_set_bankptr(5, usr5); } static MACHINE_DRIVER_START( hornet_2board ) diff --git a/src/mame/drivers/hyperspt.c b/src/mame/drivers/hyperspt.c index edea39f0c6e..801212901e2 100644 --- a/src/mame/drivers/hyperspt.c +++ b/src/mame/drivers/hyperspt.c @@ -5,13 +5,12 @@ Based on drivers from Juno First emulator by Chris Hardy (chrish@kcbbs.gen.nz) ***************************************************************************/ #include "driver.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "sound/vlm5030.h" #include "sound/dac.h" -extern void konami1_decode(void); - extern UINT8 *hyperspt_scroll; extern WRITE8_HANDLER( hyperspt_videoram_w ); @@ -592,7 +591,7 @@ ROM_END static DRIVER_INIT( hyperspt ) { - konami1_decode(); + konami1_decode(0); } diff --git a/src/mame/drivers/hyprduel.c b/src/mame/drivers/hyprduel.c index 039fe6bdbfd..da493ce55e6 100644 --- a/src/mame/drivers/hyprduel.c +++ b/src/mame/drivers/hyprduel.c @@ -802,7 +802,7 @@ MACHINE_DRIVER_END static DRIVER_INIT( hyprduel ) { - int i; + int i, len = memory_region_length(REGION_GFX1); UINT8 *ROM = memory_region(REGION_GFX1); /* @@ -811,7 +811,7 @@ static DRIVER_INIT( hyprduel ) tilemap.c handle that, we invert gfx data so the transparent pen becomes 0 for both tile depths. */ - for (i = 0;i < memory_region_length(REGION_GFX1);i++) + for (i = 0;i < len;i++) ROM[i] ^= 0xff; // ROM[(0x174b9*0x20)+0x1f] |= 0x0e; /* I */ diff --git a/src/mame/drivers/jailbrek.c b/src/mame/drivers/jailbrek.c index 89229038793..9488845d4ce 100644 --- a/src/mame/drivers/jailbrek.c +++ b/src/mame/drivers/jailbrek.c @@ -21,13 +21,12 @@ ernesto@imagina.com #include "driver.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "sound/sn76496.h" #include "sound/vlm5030.h" -void konami1_decode(void); - extern UINT8 *jailbrek_scroll_x; extern UINT8 *jailbrek_scroll_dir; @@ -413,7 +412,7 @@ static DRIVER_INIT( jailbrek ) } } - konami1_decode(); + konami1_decode(0); } GAME( 1986, jailbrek, 0, jailbrek, jailbrek, jailbrek, ROT0, "Konami", "Jail Break", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/junofrst.c b/src/mame/drivers/junofrst.c index cf247e90d3c..8b591805d26 100644 --- a/src/mame/drivers/junofrst.c +++ b/src/mame/drivers/junofrst.c @@ -79,6 +79,7 @@ Blitter source graphics #include "driver.h" #include "tutankhm.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "cpu/i8039/i8039.h" #include "cpu/z80/z80.h" @@ -87,8 +88,6 @@ Blitter source graphics #include "sound/flt_rc.h" -void konami1_decode(void); - static int i8039_status; WRITE8_HANDLER( tutankhm_sh_irqtrigger_w ); @@ -435,12 +434,10 @@ ROM_END static DRIVER_INIT( junofrst ) { - extern UINT8 *konami1_decrypted; - - konami1_decode(); + UINT8 *decrypt = konami1_decode(0); memory_configure_bank(1, 0, 16, memory_region(REGION_CPU1) + 0x10000, 0x1000); - memory_configure_bank_decrypted(1, 0, 16, konami1_decrypted + 0x10000, 0x1000); + memory_configure_bank_decrypted(1, 0, 16, decrypt + 0x10000, 0x1000); } diff --git a/src/mame/drivers/kinstb.c b/src/mame/drivers/kinstb.c index de436077c96..612813d2346 100644 --- a/src/mame/drivers/kinstb.c +++ b/src/mame/drivers/kinstb.c @@ -240,9 +240,11 @@ MACHINE_DRIVER_END static DRIVER_INIT(kinstb) { INT32 i; + UINT8 *rom = memory_region(REGION_USER3); + for(i=0;i<0x400000;i++) { - memory_region(REGION_USER3)[i]=BITSWAP8(memory_region(REGION_USER3)[i],5,0,6,1,7,4,3,2 ); + rom[i]=BITSWAP8(rom[i],5,0,6,1,7,4,3,2); } DRIVER_INIT_CALL(snes_hirom); } diff --git a/src/mame/drivers/ltcasino.c b/src/mame/drivers/ltcasino.c index 0881aaaf425..29faa81f1e6 100644 --- a/src/mame/drivers/ltcasino.c +++ b/src/mame/drivers/ltcasino.c @@ -716,8 +716,9 @@ ROM_END static DRIVER_INIT(mv4in1) { int i; + UINT8 *rom = memory_region(REGION_CPU1); for(i=0;i<0x10000;i++) - memory_region(REGION_CPU1)[i]=BITSWAP8(memory_region(REGION_CPU1)[i],7,6,5,4,3,1,2,0); + rom[i]=BITSWAP8(rom[i],7,6,5,4,3,1,2,0); } diff --git a/src/mame/drivers/maxaflex.c b/src/mame/drivers/maxaflex.c index c5f4b303865..1095791390e 100644 --- a/src/mame/drivers/maxaflex.c +++ b/src/mame/drivers/maxaflex.c @@ -531,7 +531,8 @@ ROM_END static DRIVER_INIT( a600xl ) { - memcpy( memory_region(REGION_CPU1) + 0x5000, memory_region(REGION_CPU1) + 0xd000, 0x800 ); + UINT8 *rom = memory_region(REGION_CPU1); + memcpy( rom + 0x5000, rom + 0xd000, 0x800 ); } GAME( 1984, maxaflex, 0, maxaflex, a600xl, a600xl, ROT0, "Exidy", "Max-A-Flex", GAME_IS_BIOS_ROOT ) diff --git a/src/mame/drivers/mazerbla.c b/src/mame/drivers/mazerbla.c index ee5ca2d2469..251041c84cc 100644 --- a/src/mame/drivers/mazerbla.c +++ b/src/mame/drivers/mazerbla.c @@ -1452,6 +1452,7 @@ static MACHINE_RESET( mazerbla ) static MACHINE_RESET( greatgun ) { + UINT8 *rom = memory_region(REGION_CPU3); game_id = GREATGUN; zpu_int_vector = 0xff; cpunum_set_irq_callback(0, irq_callback); @@ -1459,11 +1460,11 @@ static MACHINE_RESET( greatgun ) //patch VCU test //VCU test starts at PC=0x56f - memory_region(REGION_CPU3)[0x05b6] = 0; - memory_region(REGION_CPU3)[0x05b7] = 0; + rom[0x05b6] = 0; + rom[0x05b7] = 0; //so we also need to patch ROM checksum test - memory_region(REGION_CPU3)[0x037f] = 0; - memory_region(REGION_CPU3)[0x0380] = 0; + rom[0x037f] = 0; + rom[0x0380] = 0; } diff --git a/src/mame/drivers/meadows.c b/src/mame/drivers/meadows.c index 6c6b1e7daf8..90ac83d5714 100644 --- a/src/mame/drivers/meadows.c +++ b/src/mame/drivers/meadows.c @@ -791,13 +791,19 @@ static DRIVER_INIT( gypsyjug ) 0x01,0x80, 0x03,0xc0, 0x03,0xc0, 0x01,0x80 }; int i; + UINT8 *gfx2 = memory_region(REGION_GFX2); + UINT8 *gfx3 = memory_region(REGION_GFX3); + UINT8 *gfx4 = memory_region(REGION_GFX4); + UINT8 *gfx5 = memory_region(REGION_GFX5); + int len3 = memory_region_length(REGION_GFX3); + int len4 = memory_region_length(REGION_GFX4); - memcpy(memory_region(REGION_GFX3),memory_region(REGION_GFX2),memory_region_length(REGION_GFX3)); + memcpy(gfx3,gfx2,len3); - for (i = 0; i < memory_region_length(REGION_GFX4); i += 16*2) + for (i = 0; i < len4; i += 16*2) { - memcpy(memory_region(REGION_GFX4) + i, ball, sizeof(ball)); - memcpy(memory_region(REGION_GFX5) + i, ball, sizeof(ball)); + memcpy(gfx4 + i, ball, sizeof(ball)); + memcpy(gfx5 + i, ball, sizeof(ball)); } } diff --git a/src/mame/drivers/megazone.c b/src/mame/drivers/megazone.c index 5bdff22a9b7..ba20f401bab 100644 --- a/src/mame/drivers/megazone.c +++ b/src/mame/drivers/megazone.c @@ -7,6 +7,7 @@ To enter service mode, keep 1&2 pressed on reset ***************************************************************************/ #include "driver.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "cpu/i8039/i8039.h" #include "cpu/z80/z80.h" @@ -15,8 +16,6 @@ To enter service mode, keep 1&2 pressed on reset #include "sound/flt_rc.h" -void konami1_decode(void); - extern UINT8 *megazone_scrollx; extern UINT8 *megazone_scrolly; @@ -588,7 +587,7 @@ ROM_END static DRIVER_INIT( megazone ) { - konami1_decode(); + konami1_decode(0); } /* these just display a Konami copyright, no logo */ diff --git a/src/mame/drivers/mitchell.c b/src/mame/drivers/mitchell.c index 5cacd296589..2f7b885740f 100644 --- a/src/mame/drivers/mitchell.c +++ b/src/mame/drivers/mitchell.c @@ -80,24 +80,12 @@ mw-9.rom = ST M27C1001 / GFX #include "driver.h" #include "deprecat.h" #include "machine/eeprom.h" +#include "includes/cps1.h" #include "sound/okim6295.h" #include "sound/3812intf.h" #include "sound/2413intf.h" #include "sound/msm5205.h" -/* in machine/kabuki.c */ -void mgakuen2_decode(void); -void pang_decode(void); -void cworld_decode(void); -void hatena_decode(void); -void spang_decode(void); -void spangj_decode(void); -void sbbros_decode(void); -void marukin_decode(void); -void qtono1_decode(void); -void qsangoku_decode(void); -void block_decode(void); - VIDEO_START( pang ); VIDEO_UPDATE( pang ); @@ -2360,7 +2348,8 @@ static DRIVER_INIT( blockbl ) static DRIVER_INIT( mstworld ) { /* descramble the program rom .. */ - UINT8* source = malloc_or_die(memory_region_length(REGION_CPU1)); + int len = memory_region_length(REGION_CPU1); + UINT8* source = malloc_or_die(len); UINT8* dst = memory_region(REGION_CPU1) ; int x; @@ -2388,7 +2377,7 @@ static DRIVER_INIT( mstworld ) /* bank f */12, 12, }; - memcpy(source, dst, memory_region_length(REGION_CPU1)); + memcpy(source, dst, len); for (x=0;x<40;x+=2) { if (tablebank[x]!=-1) diff --git a/src/mame/drivers/mlanding.c b/src/mame/drivers/mlanding.c index 7c6f459c47b..d695d7c689c 100644 --- a/src/mame/drivers/mlanding.c +++ b/src/mame/drivers/mlanding.c @@ -436,8 +436,9 @@ ROM_END static DRIVER_INIT(mlanding) { - memory_region(REGION_CPU3)[0x88b]=0x4e; - memory_region(REGION_CPU3)[0x88a]=0x71; + UINT8 *rom = memory_region(REGION_CPU3); + rom[0x88b]=0x4e; + rom[0x88a]=0x71; } GAME( 1990, mlanding, 0, mlanding, mlanding, mlanding, ROT0, "Taito Corporation", "Midnight Landing", GAME_NOT_WORKING|GAME_NO_SOUND ) diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c index 81c1b7e251d..a74fe7ada0d 100644 --- a/src/mame/drivers/model2.c +++ b/src/mame/drivers/model2.c @@ -1662,15 +1662,16 @@ static WRITE16_HANDLER( model2snd_ctrl ) // handle sample banking if (memory_region_length(REGION_SOUND1) > 0x800000) { + UINT8 *snd = memory_region(REGION_SOUND1); if (data & 0x20) { - memory_set_bankptr(4, memory_region(REGION_SOUND1) + 0x200000); - memory_set_bankptr(5, memory_region(REGION_SOUND1) + 0x600000); + memory_set_bankptr(4, snd + 0x200000); + memory_set_bankptr(5, snd + 0x600000); } else { - memory_set_bankptr(4, memory_region(REGION_SOUND1) + 0x800000); - memory_set_bankptr(5, memory_region(REGION_SOUND1) + 0xa00000); + memory_set_bankptr(4, snd + 0x800000); + memory_set_bankptr(5, snd + 0xa00000); } } } diff --git a/src/mame/drivers/model3.c b/src/mame/drivers/model3.c index 7aab404c588..7f98ec4434b 100644 --- a/src/mame/drivers/model3.c +++ b/src/mame/drivers/model3.c @@ -4006,15 +4006,16 @@ static WRITE16_HANDLER( model3snd_ctrl ) // handle sample banking if (memory_region_length(REGION_SOUND1) > 0x800000) { + UINT8 *snd = memory_region(REGION_SOUND1); if (data & 0x20) { - memory_set_bankptr(4, memory_region(REGION_SOUND1) + 0x200000); - memory_set_bankptr(5, memory_region(REGION_SOUND1) + 0x600000); + memory_set_bankptr(4, snd + 0x200000); + memory_set_bankptr(5, snd + 0x600000); } else { - memory_set_bankptr(4, memory_region(REGION_SOUND1) + 0x800000); - memory_set_bankptr(5, memory_region(REGION_SOUND1) + 0xa00000); + memory_set_bankptr(4, snd + 0x800000); + memory_set_bankptr(5, snd + 0xa00000); } } } diff --git a/src/mame/drivers/mpu4drvr.c b/src/mame/drivers/mpu4drvr.c index 4e93fd7cfc7..c04daec6fe2 100644 --- a/src/mame/drivers/mpu4drvr.c +++ b/src/mame/drivers/mpu4drvr.c @@ -1567,7 +1567,7 @@ static UINT8 *dealem_videoram; static PALETTE_INIT( dealem ) { - int i; + int i, len; static const int resistances_rg[3] = { 1000, 470, 220 }; static const int resistances_b [2] = { 470, 220 }; double weights_r[3], weights_g[3], weights_b[2]; @@ -1577,7 +1577,8 @@ static PALETTE_INIT( dealem ) 3, resistances_rg, weights_g, 1000, 0, 2, resistances_b, weights_b, 1000, 0); - for (i = 0; i < memory_region_length(REGION_PROMS); i++) + len = memory_region_length(REGION_PROMS); + for (i = 0; i < len; i++) { int bit0,bit1,bit2,r,g,b; diff --git a/src/mame/drivers/ms32.c b/src/mame/drivers/ms32.c index cb8318eb436..05aca687a7e 100644 --- a/src/mame/drivers/ms32.c +++ b/src/mame/drivers/ms32.c @@ -170,37 +170,7 @@ Games marked * need dumping / redumping #include "driver.h" #include "deprecat.h" #include "sound/ymf271.h" - -extern UINT32 *ms32_fce00000; -extern UINT32 *ms32_roz_ctrl; -extern UINT32 *ms32_tx_scroll; -extern UINT32 *ms32_bg_scroll; -extern UINT32 *ms32_priram; -extern UINT32 *ms32_palram; -extern UINT32 *ms32_bgram; -extern UINT32 *ms32_rozram; -extern UINT32 *ms32_lineram; -extern UINT32 *ms32_spram; -extern UINT32 *ms32_txram; -extern UINT32 *ms32_mainram; - -WRITE32_HANDLER( ms32_brightness_w ); -WRITE32_HANDLER( ms32_palram_w ); -READ32_HANDLER( ms32_txram_r ); -WRITE32_HANDLER( ms32_txram_w ); -READ32_HANDLER( ms32_rozram_r ); -WRITE32_HANDLER( ms32_rozram_w ); -READ32_HANDLER( ms32_lineram_r ); -WRITE32_HANDLER( ms32_lineram_w ); -READ32_HANDLER( ms32_bgram_r ); -WRITE32_HANDLER( ms32_bgram_w ); -READ32_HANDLER( ms32_spram_r ); -WRITE32_HANDLER( ms32_spram_w ); -READ32_HANDLER( ms32_priram_r ); -WRITE32_HANDLER( ms32_priram_w ); -WRITE32_HANDLER( ms32_gfxctrl_w ); -VIDEO_START( ms32 ); -VIDEO_UPDATE( ms32 ); +#include "includes/ms32.h" static UINT32 *ms32_fc000000; diff --git a/src/mame/drivers/multigam.c b/src/mame/drivers/multigam.c index be97aafdf38..67443799738 100644 --- a/src/mame/drivers/multigam.c +++ b/src/mame/drivers/multigam.c @@ -232,6 +232,7 @@ static WRITE8_HANDLER( multigam3_mmc3_rom_switch_w ) if ( multigam3_mmc3_last_bank != ( data & 0xc0 ) ) { int bank; + UINT8 *prg = memory_region( REGION_CPU1 ); /* reset the banks */ if ( multigam3_mmc3_command & 0x40 ) @@ -239,21 +240,21 @@ static WRITE8_HANDLER( multigam3_mmc3_rom_switch_w ) /* high bank */ bank = multigam3_mmc3_banks[0] * 0x2000 + 0xa0000; - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_USER1 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_USER1 )[0xa0000 + 0x3c000], 0x2000 ); + memcpy( &prg[0x0c000], &prg[bank], 0x2000 ); + memcpy( &prg[0x08000], &prg[0xa0000 + 0x3c000], 0x2000 ); } else { /* low bank */ bank = multigam3_mmc3_banks[0] * 0x2000 + 0xa0000; - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_USER1 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_USER1 )[0xa0000 + 0x3c000], 0x2000 ); + memcpy( &prg[0x08000], &prg[bank], 0x2000 ); + memcpy( &prg[0x0c000], &prg[0xa0000 + 0x3c000], 0x2000 ); } /* mid bank */ bank = multigam3_mmc3_banks[1] * 0x2000 + 0xa0000; - memcpy( &memory_region( REGION_CPU1 )[0x0a000], &memory_region( REGION_USER1 )[bank], 0x2000 ); + memcpy( &prg[0x0a000], &prg[bank], 0x2000 ); multigam3_mmc3_last_bank = data & 0xc0; } @@ -283,14 +284,16 @@ static WRITE8_HANDLER( multigam3_mmc3_rom_switch_w ) break; case 6: /* program banking */ + { + UINT8 *prg = memory_region( REGION_CPU1 ); if ( multigam3_mmc3_command & 0x40 ) { /* high bank */ multigam3_mmc3_banks[0] = data & 0x1f; bank = ( multigam3_mmc3_banks[0] ) * 0x2000 + 0xa0000; - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_USER1 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_USER1 )[0xa0000 + 0x3c000], 0x2000 ); + memcpy( &prg[0x0c000], &prg[bank], 0x2000 ); + memcpy( &prg[0x08000], &prg[0xa0000 + 0x3c000], 0x2000 ); } else { @@ -298,18 +301,20 @@ static WRITE8_HANDLER( multigam3_mmc3_rom_switch_w ) multigam3_mmc3_banks[0] = data & 0x1f; bank = ( multigam3_mmc3_banks[0] ) * 0x2000 + 0xa0000; - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_USER1 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_USER1 )[0xa0000 + 0x3c000], 0x2000 ); + memcpy( &prg[0x08000], &prg[bank], 0x2000 ); + memcpy( &prg[0x0c000], &prg[0xa0000 + 0x3c000], 0x2000 ); } + } break; case 7: /* program banking */ { /* mid bank */ + UINT8 *prg = memory_region( REGION_CPU1 ); multigam3_mmc3_banks[1] = data & 0x1f; bank = multigam3_mmc3_banks[1] * 0x2000 + 0xa0000; - memcpy( &memory_region( REGION_CPU1 )[0x0a000], &memory_region( REGION_USER1 )[bank], 0x2000 ); + memcpy( &prg[0x0a000], &prg[bank], 0x2000 ); } break; } diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index 726256402e6..93295d043e9 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -647,14 +647,14 @@ void neogeo_set_main_cpu_bank_address(UINT32 bank_address) static WRITE16_HANDLER( main_cpu_bank_select_w ) { UINT32 bank_address; - - if ((memory_region_length(NEOGEO_REGION_MAIN_CPU_CARTRIDGE) <= 0x100000) && (data & 0x07)) + UINT32 len = memory_region_length(NEOGEO_REGION_MAIN_CPU_CARTRIDGE); + if ((len <= 0x100000) && (data & 0x07)) logerror("PC %06x: warning: bankswitch to %02x but no banks available\n", activecpu_get_pc(), data); else { bank_address = ((data & 0x07) + 1) * 0x100000; - if (bank_address >= memory_region_length(NEOGEO_REGION_MAIN_CPU_CARTRIDGE)) + if (bank_address >= len) { logerror("PC %06x: warning: bankswitch to empty bank %02x\n", activecpu_get_pc(), data); bank_address = 0x100000; diff --git a/src/mame/drivers/nmk16.c b/src/mame/drivers/nmk16.c index ca0f8738b52..c576f1e91bc 100644 --- a/src/mame/drivers/nmk16.c +++ b/src/mame/drivers/nmk16.c @@ -4596,7 +4596,7 @@ static void decode_gfx(void) { /* GFX are scrambled. We decode them here. (BIG Thanks to Antiriad for descrambling info) */ UINT8 *rom; - int A; + int A, len; static const UINT8 decode_data_bg[8][8] = { @@ -4626,14 +4626,16 @@ static void decode_gfx(void) /* background */ rom = memory_region(REGION_GFX2); - for (A = 0;A < memory_region_length(REGION_GFX2);A++) + len = memory_region_length(REGION_GFX2); + for (A = 0;A < len;A++) { rom[A] = decode_byte( rom[A], decode_data_bg[bjtwin_address_map_bg0(A)]); } /* sprites */ rom = memory_region(REGION_GFX3); - for (A = 0;A < memory_region_length(REGION_GFX3);A += 2) + len = memory_region_length(REGION_GFX3); + for (A = 0;A < len;A += 2) { UINT16 tmp = decode_word( rom[A+1]*256 + rom[A], decode_data_sprite[bjtwin_address_map_sprites(A)]); rom[A+1] = tmp >> 8; @@ -4647,7 +4649,7 @@ static void decode_tdragonb(void) going Open Source, best of luck in future development. */ UINT8 *rom; - int A; + int A, len; /* The Main 68k Program of the Bootleg is Bitswapped */ static const UINT8 decode_data_tdragonb[1][16] = @@ -4662,7 +4664,8 @@ static void decode_tdragonb(void) }; rom = memory_region(REGION_CPU1); - for (A = 0;A < memory_region_length(REGION_CPU1);A += 2) + len = memory_region_length(REGION_CPU1); + for (A = 0;A < len;A += 2) { #ifdef LSB_FIRST UINT16 tmp = decode_word( rom[A+1]*256 + rom[A], decode_data_tdragonb[0]); @@ -4676,13 +4679,15 @@ static void decode_tdragonb(void) } rom = memory_region(REGION_GFX2); - for (A = 0;A < memory_region_length(REGION_GFX2);A++) + len = memory_region_length(REGION_GFX2); + for (A = 0;A < len;A++) { rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); } rom = memory_region(REGION_GFX3); - for (A = 0;A < memory_region_length(REGION_GFX3);A++) + len = memory_region_length(REGION_GFX3); + for (A = 0;A < len;A++) { rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); } @@ -4692,7 +4697,7 @@ static void decode_ssmissin(void) { /* Like Thunder Dragon Bootleg without the Program Rom Swapping */ UINT8 *rom; - int A; + int A, len; /* Graphic Roms Could Also Do With Rearranging to make things simpler */ static const UINT8 decode_data_tdragonbgfx[1][8] = @@ -4701,13 +4706,15 @@ static void decode_ssmissin(void) }; rom = memory_region(REGION_GFX2); - for (A = 0;A < memory_region_length(REGION_GFX2);A++) + len = memory_region_length(REGION_GFX2); + for (A = 0;A < len;A++) { rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); } rom = memory_region(REGION_GFX3); - for (A = 0;A < memory_region_length(REGION_GFX3);A++) + len = memory_region_length(REGION_GFX3); + for (A = 0;A < len;A++) { rom[A] = decode_byte( rom[A], decode_data_tdragonbgfx[0]); } diff --git a/src/mame/drivers/nycaptor.c b/src/mame/drivers/nycaptor.c index a75c54514ab..dca9b7cdbc6 100644 --- a/src/mame/drivers/nycaptor.c +++ b/src/mame/drivers/nycaptor.c @@ -1316,16 +1316,18 @@ ROM_END static DRIVER_INIT(bronx) { int i; + UINT8 *rom = memory_region(REGION_CPU1); for(i=0;i<0x20000;i++) - memory_region(REGION_CPU1)[i]=BITSWAP8(memory_region(REGION_CPU1)[i],0,1,2,3,4,5,6,7); + rom[i]=BITSWAP8(rom[i],0,1,2,3,4,5,6,7); nyc_gametype=1; } static DRIVER_INIT(colt) { int i; + UINT8 *rom = memory_region(REGION_CPU1); for(i=0;i<0x20000;i++) - memory_region(REGION_CPU1)[i]=BITSWAP8(memory_region(REGION_CPU1)[i],0,1,2,3,4,5,6,7); + rom[i]=BITSWAP8(rom[i],0,1,2,3,4,5,6,7); nyc_gametype=2; } diff --git a/src/mame/drivers/omegrace.c b/src/mame/drivers/omegrace.c index 0222159b9bf..bb179f6ae8a 100644 --- a/src/mame/drivers/omegrace.c +++ b/src/mame/drivers/omegrace.c @@ -568,7 +568,7 @@ ROM_END static DRIVER_INIT( omegrace ) { - int i; + int i, len = memory_region_length(REGION_USER1); UINT8 *prom = memory_region(REGION_USER1); /* Omega Race has two pairs of the state PROM output @@ -576,7 +576,7 @@ static DRIVER_INIT( omegrace ) * Since all other avg/dvg games connect the PROM * in a consistent way to the decoder, we swap the bits * here. */ - for (i=0; i<memory_region_length(REGION_USER1); i++) + for (i=0; i<len; i++) prom[i] = BITSWAP8(prom[i],7,6,5,4,1,0,3,2); } diff --git a/src/mame/drivers/pacman.c b/src/mame/drivers/pacman.c index 9d336255bac..86de6aa2ed5 100644 --- a/src/mame/drivers/pacman.c +++ b/src/mame/drivers/pacman.c @@ -5216,7 +5216,7 @@ static void eyes_decode(UINT8 *data) static DRIVER_INIT( eyes ) { - int i; + int i, len; UINT8 *RAM; /* CPU ROMs */ @@ -5233,20 +5233,22 @@ static DRIVER_INIT( eyes ) /* Data lines D4 and D6 and address lines A0 and A2 are swapped */ RAM = memory_region(REGION_GFX1); - for (i = 0;i < memory_region_length(REGION_GFX1);i += 8) + len = memory_region_length(REGION_GFX1); + for (i = 0;i < len;i += 8) eyes_decode(&RAM[i]); } static DRIVER_INIT( woodpek ) { - int i; + int i, len; UINT8 *RAM; /* Graphics ROMs */ /* Data lines D4 and D6 and address lines A0 and A2 are swapped */ RAM = memory_region(REGION_GFX1); - for (i = 0;i < memory_region_length(REGION_GFX1);i += 8) + len = memory_region_length(REGION_GFX1); + for (i = 0;i < len;i += 8) eyes_decode(&RAM[i]); } diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c index f8f8b8825ec..fac1c3e5fbe 100644 --- a/src/mame/drivers/pgm.c +++ b/src/mame/drivers/pgm.c @@ -284,37 +284,13 @@ Notes: #include "deprecat.h" #include "sound/ics2115.h" #include "cpu/arm7/arm7core.h" +#include "includes/pgm.h" UINT16 *pgm_mainram, *pgm_bg_videoram, *pgm_tx_videoram, *pgm_videoregs, *pgm_rowscrollram; static UINT8 *z80_mainram; static UINT32 *arm7_shareram; static UINT32 arm7_latch; -WRITE16_HANDLER( pgm_tx_videoram_w ); -WRITE16_HANDLER( pgm_bg_videoram_w ); -VIDEO_START( pgm ); -VIDEO_EOF( pgm ); -VIDEO_UPDATE( pgm ); -void pgm_kov_decrypt(void); -void pgm_kovsh_decrypt(void); -void pgm_kov2_decrypt(void); -void pgm_mm_decrypt(void); -void pgm_dw2_decrypt(void); -void pgm_djlzz_decrypt(void); -void pgm_dw3_decrypt(void); -void pgm_killbld_decrypt(void); -void pgm_pstar_decrypt(void); -void pgm_puzzli2_decrypt(void); - -READ16_HANDLER( pgm_asic3_r ); -WRITE16_HANDLER( pgm_asic3_w ); -WRITE16_HANDLER( pgm_asic3_reg_w ); - -READ16_HANDLER (sango_protram_r); -READ16_HANDLER (ASIC28_r16); -WRITE16_HANDLER (ASIC28_w16); - -READ16_HANDLER (dw2_d80000_r ); static READ16_HANDLER ( z80_ram_r ) diff --git a/src/mame/drivers/pktgaldx.c b/src/mame/drivers/pktgaldx.c index de80fd4ced4..b6efb3bc5ce 100644 --- a/src/mame/drivers/pktgaldx.c +++ b/src/mame/drivers/pktgaldx.c @@ -64,8 +64,6 @@ VIDEO_UPDATE(pktgaldx); VIDEO_START(pktgaldb); VIDEO_UPDATE(pktgaldb); -extern void deco102_decrypt(int region, int address_xor, int data_select_xor, int opcode_select_xor); - extern UINT16* pcktgaldb_fgram; extern UINT16* pcktgaldb_sprites; diff --git a/src/mame/drivers/raiden2.c b/src/mame/drivers/raiden2.c index 469d6c40738..2ddab76ecae 100644 --- a/src/mame/drivers/raiden2.c +++ b/src/mame/drivers/raiden2.c @@ -2167,20 +2167,21 @@ MACHINE_DRIVER_END static DRIVER_INIT(rdx_v33) { - memory_set_bankptr(1,&memory_region(REGION_CPU1)[0x020000]); - memory_set_bankptr(2,&memory_region(REGION_CPU1)[0x030000]); - memory_set_bankptr(3,&memory_region(REGION_CPU1)[0x040000]); - memory_set_bankptr(4,&memory_region(REGION_CPU1)[0x050000]); - memory_set_bankptr(5,&memory_region(REGION_CPU1)[0x060000]); - memory_set_bankptr(6,&memory_region(REGION_CPU1)[0x070000]); - memory_set_bankptr(7,&memory_region(REGION_CPU1)[0x080000]); - memory_set_bankptr(8,&memory_region(REGION_CPU1)[0x090000]); - memory_set_bankptr(9,&memory_region(REGION_CPU1)[0x0a0000]); - memory_set_bankptr(10,&memory_region(REGION_CPU1)[0x0b0000]); - memory_set_bankptr(11,&memory_region(REGION_CPU1)[0x0c0000]); - memory_set_bankptr(12,&memory_region(REGION_CPU1)[0x0d0000]); - memory_set_bankptr(13,&memory_region(REGION_CPU1)[0x0e0000]); - memory_set_bankptr(14,&memory_region(REGION_CPU1)[0x0f0000]); + UINT8 *prg = memory_region(REGION_CPU1); + memory_set_bankptr(1,&prg[0x020000]); + memory_set_bankptr(2,&prg[0x030000]); + memory_set_bankptr(3,&prg[0x040000]); + memory_set_bankptr(4,&prg[0x050000]); + memory_set_bankptr(5,&prg[0x060000]); + memory_set_bankptr(6,&prg[0x070000]); + memory_set_bankptr(7,&prg[0x080000]); + memory_set_bankptr(8,&prg[0x090000]); + memory_set_bankptr(9,&prg[0x0a0000]); + memory_set_bankptr(10,&prg[0x0b0000]); + memory_set_bankptr(11,&prg[0x0c0000]); + memory_set_bankptr(12,&prg[0x0d0000]); + memory_set_bankptr(13,&prg[0x0e0000]); + memory_set_bankptr(14,&prg[0x0f0000]); raiden2_decrypt_sprites(); } diff --git a/src/mame/drivers/rainbow.c b/src/mame/drivers/rainbow.c index 24e8c62ac88..df375051f91 100644 --- a/src/mame/drivers/rainbow.c +++ b/src/mame/drivers/rainbow.c @@ -809,12 +809,13 @@ static DRIVER_INIT( rainbowe ) static DRIVER_INIT( jumping ) { - int i; + int i, len = memory_region_length(REGION_GFX2); + UINT8 *rom = memory_region(REGION_GFX2); /* Sprite colour map is reversed - switch to normal */ - for (i = 0;i < memory_region_length(REGION_GFX2);i++) - memory_region(REGION_GFX2)[i] ^= 0xff; + for (i = 0;i < len;i++) + rom[i] ^= 0xff; state_save_register_global(jumping_latch); } diff --git a/src/mame/drivers/rampart.c b/src/mame/drivers/rampart.c index e6e515f9fb8..c797c59dc78 100644 --- a/src/mame/drivers/rampart.c +++ b/src/mame/drivers/rampart.c @@ -532,9 +532,10 @@ static DRIVER_INIT( rampart ) 0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00, 0x0000 }; + UINT8 *rom = memory_region(REGION_CPU1); atarigen_eeprom_default = compressed_default_eeprom; - memcpy(&memory_region(REGION_CPU1)[0x140000], &memory_region(REGION_CPU1)[0x40000], 0x8000); + memcpy(&rom[0x140000], &rom[0x40000], 0x8000); atarigen_slapstic_init(0, 0x140000, 0x438000, 118); } diff --git a/src/mame/drivers/redclash.c b/src/mame/drivers/redclash.c index 910eff19e15..e4cf41bb6c2 100644 --- a/src/mame/drivers/redclash.c +++ b/src/mame/drivers/redclash.c @@ -507,12 +507,15 @@ ROM_END static DRIVER_INIT( redclash ) { int i,j; + const UINT8 *src = memory_region(REGION_GFX2); + UINT8 *dst = memory_region(REGION_GFX3); + int len = memory_region_length(REGION_GFX3); /* rearrange the sprite graphics */ - for (i = 0;i < memory_region_length(REGION_GFX3);i++) + for (i = 0;i < len;i++) { j = (i & ~0x003e) | ((i & 0x0e) << 2) | ((i & 0x30) >> 3); - memory_region(REGION_GFX3)[i] = memory_region(REGION_GFX2)[j]; + dst[i] = src[j]; } } diff --git a/src/mame/drivers/rocnrope.c b/src/mame/drivers/rocnrope.c index ea1b7191657..4942c813fcd 100644 --- a/src/mame/drivers/rocnrope.c +++ b/src/mame/drivers/rocnrope.c @@ -6,11 +6,10 @@ Based on drivers from Juno First emulator by Chris Hardy (chrish@kcbbs.gen.nz) #include "driver.h" #include "cpu/m6809/m6809.h" +#include "machine/konami1.h" #include "audio/timeplt.h" -extern void konami1_decode(void); - extern WRITE8_HANDLER( rocnrope_videoram_w ); extern WRITE8_HANDLER( rocnrope_colorram_w ); extern WRITE8_HANDLER( rocnrope_flipscreen_w ); @@ -310,16 +309,14 @@ ROM_END static DRIVER_INIT( rocnrope ) { - extern UINT8 *konami1_decrypted; - - konami1_decode(); + UINT8 *decrypted = konami1_decode(0); - konami1_decrypted[0x703d] = 0x98; /* fix one instruction */ + decrypted[0x703d] = 0x98; /* fix one instruction */ } static DRIVER_INIT( rocnropk ) { - konami1_decode(); + konami1_decode(0); } diff --git a/src/mame/drivers/royalmah.c b/src/mame/drivers/royalmah.c index bf0934046b2..f6b90c2ca34 100644 --- a/src/mame/drivers/royalmah.c +++ b/src/mame/drivers/royalmah.c @@ -98,12 +98,14 @@ static int palette_base; static PALETTE_INIT( royalmah ) { offs_t i; + const UINT8 *prom = memory_region(REGION_PROMS); + int len = memory_region_length(REGION_PROMS); - for (i = 0; i < memory_region_length(REGION_PROMS); i++) + for (i = 0; i < len; i++) { UINT8 bit0, bit1, bit2, r, g, b; - UINT8 data = memory_region(REGION_PROMS)[i]; + UINT8 data = prom[i]; /* red component */ bit0 = (data >> 0) & 0x01; @@ -131,10 +133,12 @@ static PALETTE_INIT( royalmah ) static PALETTE_INIT( mjderngr ) { offs_t i; + const UINT8 *prom = memory_region(REGION_PROMS); + int len = memory_region_length(REGION_PROMS); - for (i = 0; i < memory_region_length(REGION_PROMS) / 2; i++) + for (i = 0; i < len / 2; i++) { - UINT16 data = (memory_region(REGION_PROMS)[i] << 8) | memory_region(REGION_PROMS)[i + 0x200]; + UINT16 data = (prom[i] << 8) | prom[i + 0x200]; /* the bits are in reverse order */ UINT8 r = BITSWAP8((data >> 0) & 0x1f,7,6,5,0,1,2,3,4 ); diff --git a/src/mame/drivers/rpunch.c b/src/mame/drivers/rpunch.c index 538a60c641d..008ab1e3da4 100644 --- a/src/mame/drivers/rpunch.c +++ b/src/mame/drivers/rpunch.c @@ -151,7 +151,8 @@ static void ym2151_irq_gen(running_machine *machine, int state) static MACHINE_RESET( rpunch ) { - memcpy(memory_region(REGION_SOUND1), memory_region(REGION_SOUND1) + 0x20000, 0x20000); + UINT8 *snd = memory_region(REGION_SOUND1); + memcpy(snd, snd + 0x20000, 0x20000); } @@ -215,8 +216,9 @@ static WRITE8_HANDLER( upd_control_w ) { if ((data & 1) != upd_rom_bank) { + UINT8 *snd = memory_region(REGION_SOUND1); upd_rom_bank = data & 1; - memcpy(memory_region(REGION_SOUND1), memory_region(REGION_SOUND1) + 0x20000 * (upd_rom_bank + 1), 0x20000); + memcpy(snd, snd + 0x20000 * (upd_rom_bank + 1), 0x20000); } upd7759_reset_w(0, data >> 7); } diff --git a/src/mame/drivers/sbasketb.c b/src/mame/drivers/sbasketb.c index cee4145f293..b07bd2b8097 100644 --- a/src/mame/drivers/sbasketb.c +++ b/src/mame/drivers/sbasketb.c @@ -16,6 +16,7 @@ MAIN BOARD: ***************************************************************************/ #include "driver.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "sound/vlm5030.h" #include "sound/dac.h" @@ -25,8 +26,6 @@ extern UINT8 *sbasketb_scroll; extern UINT8 *sbasketb_palettebank; extern UINT8 *sbasketb_spriteram_select; -void konami1_decode(void); - WRITE8_HANDLER( sbasketb_videoram_w ); WRITE8_HANDLER( sbasketb_colorram_w ); WRITE8_HANDLER( sbasketb_flipscreen_w ); @@ -382,7 +381,7 @@ ROM_END static DRIVER_INIT( sbasketb ) { - konami1_decode(); + konami1_decode(0); } diff --git a/src/mame/drivers/segahang.c b/src/mame/drivers/segahang.c index bba270cd667..a3196c5bd9f 100644 --- a/src/mame/drivers/segahang.c +++ b/src/mame/drivers/segahang.c @@ -17,6 +17,7 @@ #include "deprecat.h" #include "system16.h" #include "machine/segaic16.h" +#include "machine/fd1089.h" #include "machine/8255ppi.h" #include "cpu/m68000/m68000.h" #include "sound/2203intf.h" @@ -1710,7 +1711,6 @@ static DRIVER_INIT( sharrier ) static DRIVER_INIT( enduror ) { - void fd1089_decrypt_0013A(void); hangon_generic_init(); fd1089_decrypt_0013A(); } diff --git a/src/mame/drivers/segaorun.c b/src/mame/drivers/segaorun.c index 410388d5a71..680aa3af1a1 100644 --- a/src/mame/drivers/segaorun.c +++ b/src/mame/drivers/segaorun.c @@ -16,6 +16,7 @@ #include "driver.h" #include "deprecat.h" #include "system16.h" +#include "machine/fd1089.h" #include "machine/segaic16.h" #include "machine/8255ppi.h" #include "cpu/m68000/m68000.h" @@ -1735,7 +1736,6 @@ static DRIVER_INIT( shangon ) static DRIVER_INIT( shangon3 ) { - extern void fd1089_decrypt_0034(void); outrun_generic_init(machine); fd1089_decrypt_0034(); custom_io_r = shangon_custom_io_r; diff --git a/src/mame/drivers/segas16a.c b/src/mame/drivers/segas16a.c index a3fcc5575f6..c6a1a2cbb1f 100644 --- a/src/mame/drivers/segas16a.c +++ b/src/mame/drivers/segas16a.c @@ -146,6 +146,7 @@ Tetris - - - - EPR12169 EPR12170 - #include "driver.h" #include "system16.h" #include "machine/8255ppi.h" +#include "machine/fd1089.h" #include "cpu/i8039/i8039.h" #include "sound/dac.h" #include "sound/2151intf.h" @@ -3068,7 +3069,6 @@ static DRIVER_INIT( aceattaa ) static DRIVER_INIT( afighter ) { - void fd1089_decrypt_0018(void); system16a_generic_init(machine); fd1089_decrypt_0018(); } @@ -3076,7 +3076,6 @@ static DRIVER_INIT( afighter ) static DRIVER_INIT( alexkid1 ) { - void fd1089_decrypt_alexkidd(void); system16a_generic_init(machine); fd1089_decrypt_alexkidd(); } @@ -3084,14 +3083,12 @@ static DRIVER_INIT( alexkid1 ) static DRIVER_INIT( aliensy1 ) { - void fd1089_decrypt_0033(void); system16a_generic_init(machine); fd1089_decrypt_0033(); } static DRIVER_INIT( aliensy5 ) { - void fd1089_decrypt_0037(void); system16a_generic_init(machine); fd1089_decrypt_0037(); } @@ -3124,7 +3121,6 @@ static DRIVER_INIT( quartet ) static DRIVER_INIT( sdi ) { - void fd1089_decrypt_0027(void); system16a_generic_init(machine); fd1089_decrypt_0027(); custom_io_r = sdi_custom_io_r; @@ -3133,7 +3129,6 @@ static DRIVER_INIT( sdi ) static DRIVER_INIT( sjryukoa ) { - void fd1089_decrypt_5021(void); system16a_generic_init(machine); fd1089_decrypt_5021(); custom_io_r = sjryuko_custom_io_r; @@ -3143,7 +3138,6 @@ static DRIVER_INIT( sjryukoa ) static DRIVER_INIT( timesca1 ) { - void fd1089_decrypt_0024(void); system16a_generic_init(machine); fd1089_decrypt_0024(); } diff --git a/src/mame/drivers/segas16b.c b/src/mame/drivers/segas16b.c index 64a4a56a266..e75d70c372d 100644 --- a/src/mame/drivers/segas16b.c +++ b/src/mame/drivers/segas16b.c @@ -871,6 +871,7 @@ CPU - 317-0092 |-------------------------------------------------------------- #include "deprecat.h" #include "system16.h" #include "machine/segaic16.h" +#include "machine/fd1089.h" #include "machine/fd1094.h" #include "machine/mc8123.h" #include "sound/2151intf.h" @@ -6127,7 +6128,6 @@ static DRIVER_INIT( generic_5797 ) static DRIVER_INIT( aliensy3_5358 ) { - void fd1089_decrypt_0033(void); DRIVER_INIT_CALL(generic_5358); fd1089_decrypt_0033(); } @@ -6163,7 +6163,6 @@ static DRIVER_INIT( altbeas4_5521 ) static DRIVER_INIT( aurail1_5704 ) { - void fd1089_decrypt_0168(void); DRIVER_INIT_CALL(generic_5704); fd1089_decrypt_0168(); } @@ -6171,7 +6170,6 @@ static DRIVER_INIT( aurail1_5704 ) static DRIVER_INIT( aurailj_5704 ) { - void fd1089_decrypt_0167(void); DRIVER_INIT_CALL(generic_5704); fd1089_decrypt_0167(); } @@ -6186,7 +6184,6 @@ static DRIVER_INIT( ddux_5704 ) static DRIVER_INIT( dunkshot_5358 ) { - void fd1089_decrypt_0022(void); DRIVER_INIT_CALL(generic_5358); fd1089_decrypt_0022(); custom_io_r = dunkshot_custom_io_r; @@ -6232,7 +6229,6 @@ static DRIVER_INIT( sdi_5358 ) static DRIVER_INIT( defense_5358 ) { - void fd1089_decrypt_0028(void); DRIVER_INIT_CALL(generic_5358); fd1089_decrypt_0028(); custom_io_r = sdi_custom_io_r; @@ -6255,7 +6251,6 @@ static DRIVER_INIT( shinobi3_5358 ) static DRIVER_INIT( sjryuko_5358 ) { - void fd1089_decrypt_5021(void); DRIVER_INIT_CALL(generic_5358); fd1089_decrypt_5021(); custom_io_r = sjryuko_custom_io_r; diff --git a/src/mame/drivers/segas24.c b/src/mame/drivers/segas24.c index 6c6e2d3c0a9..ecb1e5a8c8f 100644 --- a/src/mame/drivers/segas24.c +++ b/src/mame/drivers/segas24.c @@ -1257,10 +1257,11 @@ static NVRAM_HANDLER(system24) static MACHINE_START( system24 ) { - if (memory_region(REGION_USER1)) + UINT8 *usr1 = memory_region(REGION_USER1); + if (usr1) { - memory_configure_bank(1, 0, 16, memory_region(REGION_USER1), 0x40000); - memory_configure_bank(2, 0, 16, memory_region(REGION_USER1), 0x40000); + memory_configure_bank(1, 0, 16, usr1, 0x40000); + memory_configure_bank(2, 0, 16, usr1, 0x40000); } } diff --git a/src/mame/drivers/simpl156.c b/src/mame/drivers/simpl156.c index e523fab1ed8..c7a6ce06ee4 100644 --- a/src/mame/drivers/simpl156.c +++ b/src/mame/drivers/simpl156.c @@ -88,8 +88,6 @@ Are the OKI M6295 clocks from Heavy Smash are correct at least for the Mitchell */ -extern void decrypt156(void); - #include "driver.h" #include "decocrpt.h" #include "deco32.h" @@ -578,7 +576,7 @@ static DRIVER_INIT(simpl156) free (buf1); deco56_decrypt(REGION_GFX1); - decrypt156(); + deco156_decrypt(); simpl156_default_eeprom = NULL; } diff --git a/src/mame/drivers/sliver.c b/src/mame/drivers/sliver.c index 63a8a7ef186..be5243cbe94 100644 --- a/src/mame/drivers/sliver.c +++ b/src/mame/drivers/sliver.c @@ -256,6 +256,8 @@ static WRITE16_HANDLER( fifo_data_w ) static void blit_gfx(void) { int tmpptr=0; + const UINT8 *rom = memory_region(REGION_USER1); + while(tmpptr<fptr) { int x,y,romdata; @@ -271,7 +273,7 @@ static void blit_gfx(void) { for (x=0;x<w;x++) { - romdata = memory_region(REGION_USER1)[romoffs&0x1fffff]; + romdata = rom[romoffs&0x1fffff]; if(romdata) { plot_pixel_pal(fifo[tmpptr+5]+fifo[tmpptr+3]-x, fifo[tmpptr+6]+fifo[tmpptr+4]-y, romdata); @@ -306,16 +308,19 @@ static void render_jpeg(void) { int x,y; int addr=jpeg_addr; + UINT8 *rom; + fillbitmap(sliver_bitmap_bg, 0,0); if(jpeg_addr<0) { return; } + rom = memory_region(REGION_USER3); for (y=0;y<jpeg_h;y++) { for (x=0;x<jpeg_w;x++) { - plot_pixel_rgb(x-x_offset+jpeg_x,jpeg_h-y-y_offset-jpeg_y,memory_region(REGION_USER3)[addr],memory_region(REGION_USER3)[addr+1],memory_region(REGION_USER3)[addr+2]); + plot_pixel_rgb(x-x_offset+jpeg_x,jpeg_h-y-y_offset-jpeg_y,rom[addr],rom[addr+1],rom[addr+2]); addr+=3; } } diff --git a/src/mame/drivers/snowbros.c b/src/mame/drivers/snowbros.c index e53d8cb4b18..d0a218a3acd 100644 --- a/src/mame/drivers/snowbros.c +++ b/src/mame/drivers/snowbros.c @@ -411,31 +411,27 @@ static READ16_HANDLER( sb3_sound_r ) static void sb3_play_music(int data) { + UINT8 *snd; + /* sample is actually played in interrupt function so it loops */ sb3_music = data; switch (data) { case 0x23: - memcpy(memory_region(REGION_SOUND1)+0x20000, memory_region(REGION_SOUND1)+0x80000, 0x20000); + case 0x26: + snd = memory_region(REGION_SOUND1); + memcpy(snd+0x20000, snd+0x80000+0x00000, 0x20000); sb3_music_is_playing = 1; break; case 0x24: - memcpy(memory_region(REGION_SOUND1)+0x20000, memory_region(REGION_SOUND1)+0x80000+0x20000, 0x20000); + snd = memory_region(REGION_SOUND1); + memcpy(snd+0x20000, snd+0x80000+0x20000, 0x20000); sb3_music_is_playing = 1; break; case 0x25: - memcpy(memory_region(REGION_SOUND1)+0x20000, memory_region(REGION_SOUND1)+0x80000+0x40000, 0x20000); - sb3_music_is_playing = 1; - break; - - case 0x26: - memcpy(memory_region(REGION_SOUND1)+0x20000, memory_region(REGION_SOUND1)+0x80000, 0x20000); - sb3_music_is_playing = 1; - break; - case 0x27: case 0x28: case 0x29: @@ -443,7 +439,8 @@ static void sb3_play_music(int data) case 0x2b: case 0x2c: case 0x2d: - memcpy(memory_region(REGION_SOUND1)+0x20000, memory_region(REGION_SOUND1)+0x80000+0x40000, 0x20000); + snd = memory_region(REGION_SOUND1); + memcpy(snd+0x20000, snd+0x80000+0x40000, 0x20000); sb3_music_is_playing = 1; break; diff --git a/src/mame/drivers/srmp5.c b/src/mame/drivers/srmp5.c index dfecdc385a9..1ede7f487e1 100644 --- a/src/mame/drivers/srmp5.c +++ b/src/mame/drivers/srmp5.c @@ -157,8 +157,9 @@ static WRITE32_HANDLER(spr_w) static READ32_HANDLER(data_r) { UINT32 data; + const UINT8 *usr = memory_region(REGION_USER2); data=((databank>>4)&0xf)*0x100000; //guess - data=memory_region(REGION_USER2)[data+offset*2]+memory_region(REGION_USER2)[data+offset*2+1]*256; + data=usr[data+offset*2]+usr[data+offset*2+1]*256; return data|(data<<16); } diff --git a/src/mame/drivers/srmp6.c b/src/mame/drivers/srmp6.c index 4f60bc5a6f9..94701ac28f6 100644 --- a/src/mame/drivers/srmp6.c +++ b/src/mame/drivers/srmp6.c @@ -455,6 +455,7 @@ static WRITE16_HANDLER(srmp6_dma_w) COMBINE_DATA(&dmaram[offset]); if(offset==13 && dmaram[offset]==0x40) { + const UINT8 *rom = memory_region(REGION_USER2); UINT32 srctab=2*((((UINT32)dmaram[5])<<16)|dmaram[4]); UINT32 srcdata=2*((((UINT32)dmaram[11])<<16)|dmaram[10]); UINT32 len=4*(((((UINT32)dmaram[7]&3)<<16)|dmaram[6])+1); //??? WRONG! @@ -485,19 +486,19 @@ static WRITE16_HANDLER(srmp6_dma_w) while(1) { int i; - UINT8 ctrl=memory_region(REGION_USER2)[srcdata]; + UINT8 ctrl=rom[srcdata]; ++srcdata; for(i=0;i<8;++i) { - UINT8 p=memory_region(REGION_USER2)[srcdata]; + UINT8 p=rom[srcdata]; if(ctrl&0x80) { UINT8 real_byte; - real_byte = memory_region(REGION_USER2)[srctab+p*2]; + real_byte = rom[srctab+p*2]; tempidx+=process(real_byte,tempidx); - real_byte = memory_region(REGION_USER2)[srctab+p*2+1];//px[DMA_XOR((current_table_address+p*2+1))]; + real_byte = rom[srctab+p*2+1];//px[DMA_XOR((current_table_address+p*2+1))]; tempidx+=process(real_byte,tempidx); } else diff --git a/src/mame/drivers/sstrangr.c b/src/mame/drivers/sstrangr.c index d9908e135e3..b4ea3bb2e13 100644 --- a/src/mame/drivers/sstrangr.c +++ b/src/mame/drivers/sstrangr.c @@ -80,7 +80,7 @@ static VIDEO_UPDATE( sstrngr2 ) get_pens(pens); - color_map_base = sstrngr_flip_screen ? memory_region(REGION_PROMS) : &memory_region(REGION_PROMS)[0x0200]; + color_map_base = &memory_region(REGION_PROMS)[sstrngr_flip_screen ? 0x0000 : 0x0200]; for (offs = 0; offs < sstrngr_ram_size; offs++) { diff --git a/src/mame/drivers/superqix.c b/src/mame/drivers/superqix.c index f08fd5761e8..5a2dcabc3cd 100644 --- a/src/mame/drivers/superqix.c +++ b/src/mame/drivers/superqix.c @@ -136,11 +136,11 @@ static INT16 *samplebuf; static void pbillian_sh_start(void) { UINT8 *src = memory_region(REGION_SOUND1); - int i; + int i, len = memory_region_length(REGION_SOUND1); /* convert 8-bit unsigned samples to 8-bit signed */ - samplebuf = auto_malloc(memory_region_length(REGION_SOUND1) * 2); - for (i = 0;i < memory_region_length(REGION_SOUND1);i++) + samplebuf = auto_malloc(len * 2); + for (i = 0;i < len;i++) samplebuf[i] = (INT8)(src[i] ^ 0x80) * 256; } diff --git a/src/mame/drivers/supertnk.c b/src/mame/drivers/supertnk.c index 663aa6535c1..683d3d2f383 100644 --- a/src/mame/drivers/supertnk.c +++ b/src/mame/drivers/supertnk.c @@ -218,10 +218,11 @@ static WRITE8_HANDLER( supertnk_bitplane_select_1_w ) static void get_pens(pen_t *pens) { offs_t i; + const UINT8 *prom = memory_region(REGION_PROMS); for (i = 0; i < NUM_PENS; i++) { - UINT8 data = memory_region(REGION_PROMS)[i]; + UINT8 data = prom[i]; pens[i] = MAKE_RGB(pal1bit(data >> 2), pal1bit(data >> 5), pal1bit(data >> 6)); } @@ -475,10 +476,12 @@ static DRIVER_INIT( supertnk ) { /* decode the TMS9980 ROMs */ offs_t offs; + UINT8 *rom = memory_region(REGION_CPU1); + size_t len = memory_region_length(REGION_CPU1); - for (offs = 0; offs < memory_region_length(REGION_CPU1); offs++) + for (offs = 0; offs < len; offs++) { - memory_region(REGION_CPU1)[offs] = BITSWAP8(memory_region(REGION_CPU1)[offs],0,1,2,3,4,5,6,7); + rom[offs] = BITSWAP8(rom[offs],0,1,2,3,4,5,6,7); }; } diff --git a/src/mame/drivers/taito_f2.c b/src/mame/drivers/taito_f2.c index 6b405c05335..f3101722759 100644 --- a/src/mame/drivers/taito_f2.c +++ b/src/mame/drivers/taito_f2.c @@ -5888,12 +5888,12 @@ static DRIVER_INIT( finalb ) static DRIVER_INIT( mjnquest ) { - int i; + int i, len = memory_region_length(REGION_GFX2); UINT8 *gfx = memory_region(REGION_GFX2); /* the bytes in each longword are in reversed order, put them in the order used by the other games. */ - for (i = 0;i < memory_region_length(REGION_GFX2);i += 2) + for (i = 0;i < len;i += 2) { int t; diff --git a/src/mame/drivers/tatsumi.c b/src/mame/drivers/tatsumi.c index 17667fe442c..d397c6ff8c5 100644 --- a/src/mame/drivers/tatsumi.c +++ b/src/mame/drivers/tatsumi.c @@ -1241,9 +1241,11 @@ static DRIVER_INIT( cyclwarr ) { UINT8 *dst = memory_region(REGION_GFX1); UINT8 *src1 = memory_region(REGION_GFX2); + int len1 = memory_region_length(REGION_GFX2); UINT8 *src2 = memory_region(REGION_GFX3); + int len2 = memory_region_length(REGION_GFX3); int i; - for (i=0; i<memory_region_length(REGION_GFX2); i+=32) { + for (i=0; i<len2; i+=32) { memcpy(dst,src1,32); src1+=32; dst+=32; @@ -1254,17 +1256,17 @@ static DRIVER_INIT( cyclwarr ) dst = memory_region(REGION_CPU1); memcpy(cyclwarr_cpua_ram,dst,8); - memory_set_bankptr(1, memory_region(REGION_CPU1)); + memory_set_bankptr(1, dst); dst = memory_region(REGION_CPU2); memcpy(cyclwarr_cpub_ram,dst,8); - memory_set_bankptr(2, memory_region(REGION_CPU2)); + memory_set_bankptr(2, dst); // Copy sprite & palette data out of GFX rom area - tatsumi_rom_sprite_lookup1 = memory_region(REGION_GFX2); - tatsumi_rom_sprite_lookup2 = memory_region(REGION_GFX3); - tatsumi_rom_clut0 = memory_region(REGION_GFX2)+ memory_region_length(REGION_GFX2) - 0x1000; - tatsumi_rom_clut1 = memory_region(REGION_GFX3)+ memory_region_length(REGION_GFX3) - 0x1000; + tatsumi_rom_sprite_lookup1 = src1; + tatsumi_rom_sprite_lookup2 = src2; + tatsumi_rom_clut0 = src1 + len1 - 0x1000; + tatsumi_rom_clut1 = src2 + len2 - 0x1000; tatsumi_reset(); } diff --git a/src/mame/drivers/tcl.c b/src/mame/drivers/tcl.c index b441f5f469b..e1a463d7622 100644 --- a/src/mame/drivers/tcl.c +++ b/src/mame/drivers/tcl.c @@ -179,10 +179,11 @@ static DRIVER_INIT(tcl) /* only the first part is decrypted (and verified)*/ UINT8 *dest = memory_region(REGION_CPU1); - UINT8 *src = malloc_or_die(memory_region_length(REGION_CPU1)); + int len = memory_region_length(REGION_CPU1); + UINT8 *src = malloc_or_die(len); int i,idx=0; - memcpy(src, dest, memory_region_length(REGION_CPU1)); + memcpy(src, dest, len); for(i=0;i<64*1024;i+=4) { if(i&0x8000) diff --git a/src/mame/drivers/tetriunk.c b/src/mame/drivers/tetriunk.c index a8c15ae7d24..4f8082392ee 100644 --- a/src/mame/drivers/tetriunk.c +++ b/src/mame/drivers/tetriunk.c @@ -221,6 +221,8 @@ static DRIVER_INIT (tetriunk) int i,j,k; int index=0; UINT8 *region = memory_region(REGION_USER1); + UINT8 *gfx = memory_region(REGION_GFX2); + for(i=0;i<0x20000;i++) { //8 pixels/byte @@ -230,7 +232,7 @@ static DRIVER_INIT (tetriunk) int pixel=0; for(k=0;k<4;k++) { - if(memory_region(REGION_GFX2)[k*0x20000+i]&mask) + if(gfx[k*0x20000+i]&mask) { pixel|=(1<<k); } diff --git a/src/mame/drivers/thedeep.c b/src/mame/drivers/thedeep.c index 9b64356313f..e7e2363af5e 100644 --- a/src/mame/drivers/thedeep.c +++ b/src/mame/drivers/thedeep.c @@ -83,13 +83,15 @@ static WRITE8_HANDLER( thedeep_protection_w ) case 0x32: case 0x33: { + UINT8 *rom; int new_rombank = protection_command & 3; if (rombank == new_rombank) break; rombank = new_rombank; - memory_set_bankptr(1, memory_region(REGION_CPU1) + 0x10000 + rombank * 0x4000); + rom = memory_region(REGION_CPU1); + memory_set_bankptr(1, rom + 0x10000 + rombank * 0x4000); /* there's code which falls through from the fixed ROM to bank #1, I have to */ /* copy it there otherwise the CPU bank switching support will not catch it. */ - memcpy(memory_region(REGION_CPU1) + 0x08000,memory_region(REGION_CPU1) + 0x10000 + rombank * 0x4000, 0x4000); + memcpy(rom + 0x08000, rom + 0x10000 + rombank * 0x4000, 0x4000); } break; diff --git a/src/mame/drivers/tmaster.c b/src/mame/drivers/tmaster.c index 6f2e33fdaf3..563a6a864c7 100644 --- a/src/mame/drivers/tmaster.c +++ b/src/mame/drivers/tmaster.c @@ -1253,12 +1253,13 @@ Protection starts: static DRIVER_INIT( galgames ) { + UINT8 *ROM = memory_region(REGION_CPU1); // configure memory banks - memory_configure_bank(1, 0, 2, memory_region(REGION_CPU1)+0x1c0000, 0x40000); - memory_configure_bank(3, 0, 2, memory_region(REGION_CPU1)+0x1c0000, 0x40000); + memory_configure_bank(1, 0, 2, ROM+0x1c0000, 0x40000); + memory_configure_bank(3, 0, 2, ROM+0x1c0000, 0x40000); - memory_configure_bank(2, 0, 1, memory_region(REGION_CPU1)+0x200000, 0x40000); - memory_configure_bank(4, 0, 1, memory_region(REGION_CPU1)+0x200000, 0x40000); + memory_configure_bank(2, 0, 1, ROM+0x200000, 0x40000); + memory_configure_bank(4, 0, 1, ROM+0x200000, 0x40000); } GAME( 1996, tm, 0, tm, tm, 0, ROT0, "Midway", "Touchmaster (v3.00 Euro)", 0 ) diff --git a/src/mame/drivers/toki.c b/src/mame/drivers/toki.c index 4708ca31e48..4fcc761901d 100644 --- a/src/mame/drivers/toki.c +++ b/src/mame/drivers/toki.c @@ -750,16 +750,21 @@ static DRIVER_INIT( toki ) static DRIVER_INIT( tokib ) { UINT8 *temp = malloc_or_die(65536 * 2); - int i, offs; + int i, offs, len; + UINT8 *rom; /* invert the sprite data in the ROMs */ - for (i = 0; i < memory_region_length(REGION_GFX2); i++) - memory_region(REGION_GFX2)[i] ^= 0xff; + len = memory_region_length(REGION_GFX2); + rom = memory_region(REGION_GFX2); + for (i = 0; i < len; i++) + rom[i] ^= 0xff; /* merge background tile graphics together */ - for (offs = 0; offs < memory_region_length(REGION_GFX3); offs += 0x20000) + len = memory_region_length(REGION_GFX3); + rom = memory_region(REGION_GFX3); + for (offs = 0; offs < len; offs += 0x20000) { - UINT8 *base = &memory_region(REGION_GFX3)[offs]; + UINT8 *base = &rom[offs]; memcpy (temp, base, 65536 * 2); for (i = 0; i < 16; i++) { @@ -769,9 +774,11 @@ static DRIVER_INIT( tokib ) memcpy (&base[0x18000 + i * 0x800], &temp[0x1800 + i * 0x2000], 0x800); } } - for (offs = 0; offs < memory_region_length(REGION_GFX4); offs += 0x20000) + len = memory_region_length(REGION_GFX4); + rom = memory_region(REGION_GFX4); + for (offs = 0; offs < len; offs += 0x20000) { - UINT8 *base = &memory_region(REGION_GFX4)[offs]; + UINT8 *base = &rom[offs]; memcpy (temp, base, 65536 * 2); for (i = 0; i < 16; i++) { diff --git a/src/mame/drivers/trackfld.c b/src/mame/drivers/trackfld.c index d2bff966b65..6662434c317 100644 --- a/src/mame/drivers/trackfld.c +++ b/src/mame/drivers/trackfld.c @@ -18,6 +18,7 @@ MAIN BOARD: ***************************************************************************/ #include "driver.h" +#include "machine/konami1.h" #include "cpu/m6809/m6809.h" #include "sound/sn76496.h" #include "sound/vlm5030.h" @@ -25,10 +26,6 @@ MAIN BOARD: #include "sound/msm5205.h" -void konami1_decode(void); -UINT8 konami1_decodebyte( UINT8 opcode, UINT16 address ); - - extern UINT8 *trackfld_scroll; extern UINT8 *trackfld_scroll2; @@ -1251,25 +1248,23 @@ ROM_END static DRIVER_INIT( trackfld ) { - konami1_decode(); + konami1_decode(0); } static DRIVER_INIT( atlantol ) { UINT8 *rom = memory_region(REGION_CPU1); - int size = memory_region_length(REGION_CPU1); - UINT8 *decrypt = auto_malloc(size); + UINT8 *decrypt; int A; - memory_set_decrypted_region(0, 0x0000, 0xffff, decrypt); + /* "konami1" encrypted opcodes */ + decrypt = konami1_decode(0); /* not encrypted opcodes */ for (A = 0;A < 0x6000;A++) decrypt[A] = rom[A]; - /* "konami1" encrypted opcodes */ - for (A = 0x6000;A < size;A++) - decrypt[A] = konami1_decodebyte(rom[A],A); + memory_set_decrypted_region(0, 0x0000, 0xffff, decrypt); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1000, 0, 0, SMH_NOP ); } diff --git a/src/mame/drivers/tumbleb.c b/src/mame/drivers/tumbleb.c index 549841e2cdd..70dd7a3ca7a 100644 --- a/src/mame/drivers/tumbleb.c +++ b/src/mame/drivers/tumbleb.c @@ -2169,9 +2169,9 @@ static MACHINE_RESET (htchctch) /* copy protection data every reset */ UINT16 *PROTDATA = (UINT16*)memory_region(REGION_USER1); - int i; + int i, len = memory_region_length(REGION_USER1); - for (i = 0;i < memory_region_length( REGION_USER1 )/2;i++) + for (i = 0;i < len/2;i++) tumblepb_mainram[0x000/2 + i] = PROTDATA[i]; } @@ -3375,7 +3375,7 @@ static DRIVER_INIT( htchctch ) // UINT16 *HCROM = (UINT16*)memory_region(REGION_CPU1); UINT16 *PROTDATA = (UINT16*)memory_region(REGION_USER1); - int i; + int i, len = memory_region_length(REGION_USER1); /* simulate RAM initialization done by the protection MCU */ /* verified on real hardware */ // static UINT16 htchctch_mcu68k[] = @@ -3387,7 +3387,7 @@ static DRIVER_INIT( htchctch ) // for (i = 0;i < sizeof(htchctch_mcu68k)/sizeof(htchctch_mcu68k[0]);i++) // tumblepb_mainram[0x000/2 + i] = htchctch_mcu68k[i]; - for (i = 0;i < memory_region_length( REGION_USER1 )/2;i++) + for (i = 0;i < len/2;i++) tumblepb_mainram[0x000/2 + i] = PROTDATA[i]; diff --git a/src/mame/drivers/wecleman.c b/src/mame/drivers/wecleman.c index a563f6fbccb..682f7e4650f 100644 --- a/src/mame/drivers/wecleman.c +++ b/src/mame/drivers/wecleman.c @@ -1296,7 +1296,7 @@ static void bitswap(UINT8 *src,size_t len,int _14,int _13,int _12,int _11,int _1 /* Unpack sprites data and do some patching */ static DRIVER_INIT( wecleman ) { - int i; + int i, len; UINT8 *RAM; // UINT16 *RAM1 = (UINT16 *) memory_region(REGION_CPU1); /* Main CPU patches */ // RAM1[0x08c2/2] = 0x601e; // faster self test @@ -1309,7 +1309,8 @@ static DRIVER_INIT( wecleman ) /* let's swap even and odd *pixels* of the sprites */ RAM = memory_region(REGION_GFX1); - for (i = 0; i < memory_region_length(REGION_GFX1); i ++) + len = memory_region_length(REGION_GFX1); + for (i = 0; i < len; i ++) { /* TODO: could be wrong, colors have to be fixed. */ /* The only certain thing is that 87 must convert to f0 */ diff --git a/src/mame/drivers/wldarrow.c b/src/mame/drivers/wldarrow.c index e674bd96317..0c979aaaf18 100644 --- a/src/mame/drivers/wldarrow.c +++ b/src/mame/drivers/wldarrow.c @@ -453,9 +453,10 @@ ROM_END static DRIVER_INIT( wldarrow ) { offs_t i; + UINT8 *rom = memory_region(REGION_CPU1); for (i = 0; i < 0x3000; i++) - memory_region(REGION_CPU1)[i] ^= 0xff; + rom[i] ^= 0xff; } diff --git a/src/mame/includes/cps1.h b/src/mame/includes/cps1.h index 9ade22919a2..bb6c2be72d0 100644 --- a/src/mame/includes/cps1.h +++ b/src/mame/includes/cps1.h @@ -32,6 +32,18 @@ DRIVER_INIT( cps2crpt ); /*----------- defined in machine/kabuki.c -----------*/ +void mgakuen2_decode(void); +void pang_decode(void); +void cworld_decode(void); +void hatena_decode(void); +void spang_decode(void); +void spangj_decode(void); +void sbbros_decode(void); +void marukin_decode(void); +void qtono1_decode(void); +void qsangoku_decode(void); +void block_decode(void); + void wof_decode(void); void dino_decode(void); void punisher_decode(void); diff --git a/src/mame/includes/decocrpt.h b/src/mame/includes/decocrpt.h index 96f15a4c3c0..48614ed5642 100644 --- a/src/mame/includes/decocrpt.h +++ b/src/mame/includes/decocrpt.h @@ -3,3 +3,13 @@ void deco56_decrypt(int region); void deco74_decrypt(int region); void deco56_remap(int region); + + +/*----------- defined in machine/deco102.c -----------*/ + +void deco102_decrypt(int region, int address_xor, int data_select_xor, int opcode_select_xor); + + +/*----------- defined in machine/deco156.c -----------*/ + +void deco156_decrypt(void); diff --git a/src/mame/machine/deco102.c b/src/mame/machine/deco102.c index 1c85dafd908..b9af2811e21 100644 --- a/src/mame/machine/deco102.c +++ b/src/mame/machine/deco102.c @@ -9,8 +9,7 @@ #include "driver.h" #include "cpu/m68000/m68000.h" - -extern void deco102_decrypt(int region, int address_xor, int data_select_xor, int opcode_select_xor); +#include "decocrpt.h" static UINT16 decrypt(UINT16 data, int address, int select_xor) { diff --git a/src/mame/machine/deco156.c b/src/mame/machine/deco156.c index 5aedf0e002e..d589638c7fb 100644 --- a/src/mame/machine/deco156.c +++ b/src/mame/machine/deco156.c @@ -121,7 +121,7 @@ static void decrypt(UINT32 *src, UINT32 *dst, int length) } -void decrypt156(void) +void deco156_decrypt(void) { UINT32 *rom = (UINT32 *)memory_region(REGION_CPU1); int length = memory_region_length(REGION_CPU1); diff --git a/src/mame/machine/fd1089.c b/src/mame/machine/fd1089.c index fa9c829eaf3..76f8888be1b 100644 --- a/src/mame/machine/fd1089.c +++ b/src/mame/machine/fd1089.c @@ -70,6 +70,7 @@ FD1089B ***************************************************************************/ #include "driver.h" +#include "fd1089.h" /* 317-0013A FD1089B */ diff --git a/src/mame/machine/galaxold.c b/src/mame/machine/galaxold.c index 0e2a304f793..59e43cc01ba 100644 --- a/src/mame/machine/galaxold.c +++ b/src/mame/machine/galaxold.c @@ -381,11 +381,11 @@ DRIVER_INIT( mooncrsu ) DRIVER_INIT( mooncrst ) { - offs_t i; + offs_t i, len = memory_region_length(REGION_CPU1); UINT8 *rom = memory_region(REGION_CPU1); - for (i = 0;i < memory_region_length(REGION_CPU1);i++) + for (i = 0;i < len;i++) rom[i] = decode_mooncrst(rom[i],i); DRIVER_INIT_CALL(mooncrsu); @@ -457,11 +457,11 @@ Pin layout is such that links can replace the PAL if encryption is not used. { 1,4,1,4 } }; - offs_t i; + offs_t i, len = memory_region_length(REGION_CPU1); UINT8 *rom = memory_region(REGION_CPU1); - for (i = 0; i < memory_region_length(REGION_CPU1); i++) + for (i = 0; i < len; i++) { UINT8 data_xor; int line = i & 0x07; @@ -483,11 +483,11 @@ DRIVER_INIT( azurian ) DRIVER_INIT( 4in1 ) { - offs_t i; + offs_t i, len = memory_region_length(REGION_CPU1); UINT8 *RAM = memory_region(REGION_CPU1); /* Decrypt Program Roms */ - for (i = 0; i < memory_region_length(REGION_CPU1); i++) + for (i = 0; i < len; i++) RAM[i] = RAM[i] ^ (i & 0xff); /* games are banked at 0x0000 - 0x3fff */ diff --git a/src/mame/machine/midwunit.c b/src/mame/machine/midwunit.c index ab6515b2c08..28b16ba5438 100644 --- a/src/mame/machine/midwunit.c +++ b/src/mame/machine/midwunit.c @@ -370,14 +370,15 @@ WRITE16_HANDLER( midxunit_uart_w ) static void init_wunit_generic(void) { UINT8 *base; - int i, j; + int i, j, len; /* register for state saving */ register_state_saving(); /* load the graphics ROMs -- quadruples */ midyunit_gfx_rom = base = memory_region(REGION_GFX1); - for (i = 0; i < memory_region_length(REGION_GFX1) / 0x400000; i++) + len = memory_region_length(REGION_GFX1); + for (i = 0; i < len / 0x400000; i++) { memcpy(midwunit_decode_memory, base, 0x400000); for (j = 0; j < 0x100000; j++) @@ -575,14 +576,15 @@ DRIVER_INIT( rmpgwt ) DRIVER_INIT( revx ) { UINT8 *base; - int i, j; + int i, j, len; /* register for state saving */ register_state_saving(); /* load the graphics ROMs -- quadruples */ midyunit_gfx_rom = base = memory_region(REGION_GFX1); - for (i = 0; i < memory_region_length(REGION_GFX1) / 0x200000; i++) + len = memory_region_length(REGION_GFX1); + for (i = 0; i < len / 0x200000; i++) { memcpy(midwunit_decode_memory, base, 0x200000); for (j = 0; j < 0x80000; j++) diff --git a/src/mame/machine/pgmcrypt.c b/src/mame/machine/pgmcrypt.c index f3b5a3223c2..dff9b729fa3 100644 --- a/src/mame/machine/pgmcrypt.c +++ b/src/mame/machine/pgmcrypt.c @@ -1,6 +1,8 @@ /* IGS PGM System Encryptions */ #include "driver.h" +#include "includes/pgm.h" + static const UINT8 kov_tab[256] = { 0x17, 0x1c, 0xe3, 0x02, 0x62, 0x59, 0x97, 0x4a, 0x67, 0x4d, 0x1f, 0x11, 0x76, 0x64, 0xc1, 0xe1, diff --git a/src/mame/machine/pgmprot.c b/src/mame/machine/pgmprot.c index 7d7a4206c61..56bb79d68e9 100644 --- a/src/mame/machine/pgmprot.c +++ b/src/mame/machine/pgmprot.c @@ -1,6 +1,5 @@ #include "driver.h" - -extern UINT16 *pgm_mainram; +#include "includes/pgm.h" /*** ASIC27a (Puzzle Star) -- ARM but with no external rom? behaves a bit like KOV ***/ @@ -539,7 +538,6 @@ READ16_HANDLER (ASIC28_r16) case 0x21: // PhotoY2k spritenum conversion 3/4 if(!ASIC28RCNT) { - extern const UINT32 pgmy2ks[]; photoy2k_trf[2] = val & 0xffff; logerror("ASIC28: PhotoY2K spr3 %04x %06x (%06x)\n", val & 0xffff, photoy2k_trf[1], activecpu_get_pc()); if(photoy2k_trf[0] < 0x3c00) diff --git a/src/mame/machine/pgmy2ks.c b/src/mame/machine/pgmy2ks.c index 8e9c9b3126b..00f0ef69b22 100644 --- a/src/mame/machine/pgmy2ks.c +++ b/src/mame/machine/pgmy2ks.c @@ -18,6 +18,7 @@ // The actual decryption algorithm is unknown. #include "driver.h" +#include "includes/pgm.h" const UINT32 pgmy2ks[0x3c00] = { 0x000000, 0x00007c, 0x0000f8, 0x000174, 0x0001f0, 0x00026c, 0x0002e8, 0x000364, diff --git a/src/mame/machine/playch10.c b/src/mame/machine/playch10.c index bca40fef274..4341ada17d3 100644 --- a/src/mame/machine/playch10.c +++ b/src/mame/machine/playch10.c @@ -397,11 +397,12 @@ static WRITE8_HANDLER( mmc1_rom_switch_w ) case 3: /* program banking */ { int bank = ( mmc1_shiftreg & mmc1_rom_mask ) * 0x4000; + UINT8 *prg = memory_region( REGION_CPU2 ); if ( !size16k ) { /* switch 32k */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x010000+bank], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x010000+bank], 0x8000 ); } else { @@ -409,12 +410,12 @@ static WRITE8_HANDLER( mmc1_rom_switch_w ) if ( switchlow ) { /* low */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x010000+bank], 0x4000 ); + memcpy( &prg[0x08000], &prg[0x010000+bank], 0x4000 ); } else { /* high */ - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[0x010000+bank], 0x4000 ); + memcpy( &prg[0x0c000], &prg[0x010000+bank], 0x4000 ); } } } @@ -451,15 +452,18 @@ DRIVER_INIT( pcaboard ) static WRITE8_HANDLER( bboard_rom_switch_w ) { int bankoffset = 0x10000 + ( ( data & 7 ) * 0x4000 ); + UINT8 *prg = memory_region( REGION_CPU2 ); - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[bankoffset], 0x4000 ); + memcpy( &prg[0x08000], &prg[bankoffset], 0x4000 ); } DRIVER_INIT( pcbboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x28000], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x28000], 0x8000 ); /* Roms are banked at $8000 to $bfff */ memory_install_write8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, bboard_rom_switch_w ); @@ -495,9 +499,11 @@ DRIVER_INIT( pccboard ) DRIVER_INIT( pcdboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x28000], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x28000], 0x8000 ); mmc1_rom_mask = 0x07; @@ -557,7 +563,8 @@ static WRITE8_HANDLER( eboard_rom_switch_w ) case 0x2000: /* code bank switching */ { int bankoffset = 0x10000 + ( data & 0x0f ) * 0x2000; - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[bankoffset], 0x2000 ); + UINT8 *prg = memory_region( REGION_CPU2 ); + memcpy( &prg[0x08000], &prg[bankoffset], 0x2000 ); } break; @@ -594,9 +601,11 @@ static WRITE8_HANDLER( eboard_rom_switch_w ) DRIVER_INIT( pceboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x28000], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x28000], 0x8000 ); /* basically a mapper 9 on a nes */ memory_install_write8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, eboard_rom_switch_w ); @@ -618,9 +627,11 @@ DRIVER_INIT( pceboard ) DRIVER_INIT( pcfboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x28000], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x28000], 0x8000 ); mmc1_rom_mask = 0x07; @@ -678,6 +689,7 @@ static WRITE8_HANDLER( gboard_rom_switch_w ) if ( gboard_last_bank != ( data & 0xc0 ) ) { int bank; + UINT8 *prg = memory_region( REGION_CPU2 ); /* reset the banks */ if ( gboard_command & 0x40 ) @@ -685,21 +697,21 @@ static WRITE8_HANDLER( gboard_rom_switch_w ) /* high bank */ bank = gboard_banks[0] * 0x2000 + 0x10000; - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x4c000], 0x2000 ); + memcpy( &prg[0x0c000], &prg[bank], 0x2000 ); + memcpy( &prg[0x08000], &prg[0x4c000], 0x2000 ); } else { /* low bank */ bank = gboard_banks[0] * 0x2000 + 0x10000; - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[0x4c000], 0x2000 ); + memcpy( &prg[0x08000], &prg[bank], 0x2000 ); + memcpy( &prg[0x0c000], &prg[0x4c000], 0x2000 ); } /* mid bank */ bank = gboard_banks[1] * 0x2000 + 0x10000; - memcpy( &memory_region( REGION_CPU2 )[0x0a000], &memory_region( REGION_CPU2 )[bank], 0x2000 ); + memcpy( &prg[0x0a000], &prg[bank], 0x2000 ); gboard_last_bank = data & 0xc0; } @@ -729,14 +741,16 @@ static WRITE8_HANDLER( gboard_rom_switch_w ) break; case 6: /* program banking */ + { + UINT8 *prg = memory_region( REGION_CPU2 ); if ( gboard_command & 0x40 ) { /* high bank */ gboard_banks[0] = data & 0x1f; bank = ( gboard_banks[0] ) * 0x2000 + 0x10000; - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x4c000], 0x2000 ); + memcpy( &prg[0x0c000], &prg[bank], 0x2000 ); + memcpy( &prg[0x08000], &prg[0x4c000], 0x2000 ); } else { @@ -744,18 +758,20 @@ static WRITE8_HANDLER( gboard_rom_switch_w ) gboard_banks[0] = data & 0x1f; bank = ( gboard_banks[0] ) * 0x2000 + 0x10000; - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[bank], 0x2000 ); - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[0x4c000], 0x2000 ); + memcpy( &prg[0x08000], &prg[bank], 0x2000 ); + memcpy( &prg[0x0c000], &prg[0x4c000], 0x2000 ); } + } break; case 7: /* program banking */ { /* mid bank */ + UINT8 *prg = memory_region( REGION_CPU2 ); gboard_banks[1] = data & 0x1f; bank = gboard_banks[1] * 0x2000 + 0x10000; - memcpy( &memory_region( REGION_CPU2 )[0x0a000], &memory_region( REGION_CPU2 )[bank], 0x2000 ); + memcpy( &prg[0x0a000], &prg[bank], 0x2000 ); } break; } @@ -796,10 +812,12 @@ static WRITE8_HANDLER( gboard_rom_switch_w ) DRIVER_INIT( pcgboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x4c000], 0x4000 ); - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[0x4c000], 0x4000 ); + memcpy( &prg[0x08000], &prg[0x4c000], 0x4000 ); + memcpy( &prg[0x0c000], &prg[0x4c000], 0x4000 ); /* MMC3 mapper at writes to $8000-$ffff */ memory_install_write8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, gboard_rom_switch_w ); @@ -834,20 +852,23 @@ DRIVER_INIT( pcgboard_type2 ) static WRITE8_HANDLER( iboard_rom_switch_w ) { int bank = data & 7; + UINT8 *prg = memory_region( REGION_CPU2 ); if ( data & 0x10 ) ppu2c0x_set_mirroring( 0, PPU_MIRROR_HIGH ); else ppu2c0x_set_mirroring( 0, PPU_MIRROR_LOW ); - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[bank * 0x8000 + 0x10000], 0x8000 ); + memcpy( &prg[0x08000], &prg[bank * 0x8000 + 0x10000], 0x8000 ); } DRIVER_INIT( pciboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x10000], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x10000], 0x8000 ); /* Roms are banked at $8000 to $bfff */ memory_install_write8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, iboard_rom_switch_w ); @@ -908,8 +929,9 @@ static WRITE8_HANDLER( hboard_rom_switch_w ) DRIVER_INIT( pchboard ) { - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x4c000], 0x4000 ); - memcpy( &memory_region( REGION_CPU2 )[0x0c000], &memory_region( REGION_CPU2 )[0x4c000], 0x4000 ); + UINT8 *prg = memory_region( REGION_CPU2 ); + memcpy( &prg[0x08000], &prg[0x4c000], 0x4000 ); + memcpy( &prg[0x0c000], &prg[0x4c000], 0x4000 ); /* Roms are banked at $8000 to $bfff */ memory_install_write8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, hboard_rom_switch_w ); @@ -933,9 +955,11 @@ DRIVER_INIT( pchboard ) DRIVER_INIT( pckboard ) { + UINT8 *prg = memory_region( REGION_CPU2 ); + /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU2 )[0x08000], &memory_region( REGION_CPU2 )[0x48000], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x48000], 0x8000 ); mmc1_rom_mask = 0x0f; diff --git a/src/mame/machine/scramble.c b/src/mame/machine/scramble.c index c48c38b4dda..d40a618af49 100644 --- a/src/mame/machine/scramble.c +++ b/src/mame/machine/scramble.c @@ -590,7 +590,7 @@ static int bit(int i,int n) DRIVER_INIT( anteater ) { - offs_t i; + offs_t i, len; UINT8 *RAM; UINT8 *scratch; @@ -603,12 +603,13 @@ DRIVER_INIT( anteater ) */ RAM = memory_region(REGION_GFX1); + len = memory_region_length(REGION_GFX1); - scratch = malloc_or_die(memory_region_length(REGION_GFX1)); + scratch = malloc_or_die(len); - memcpy(scratch, RAM, memory_region_length(REGION_GFX1)); + memcpy(scratch, RAM, len); - for (i = 0; i < memory_region_length(REGION_GFX1); i++) + for (i = 0; i < len; i++) { int j; @@ -626,7 +627,7 @@ DRIVER_INIT( anteater ) DRIVER_INIT( rescue ) { - offs_t i; + offs_t i, len; UINT8 *RAM; UINT8 *scratch; @@ -639,12 +640,13 @@ DRIVER_INIT( rescue ) */ RAM = memory_region(REGION_GFX1); + len = memory_region_length(REGION_GFX1); - scratch = malloc_or_die(memory_region_length(REGION_GFX1)); + scratch = malloc_or_die(len); - memcpy(scratch, RAM, memory_region_length(REGION_GFX1)); + memcpy(scratch, RAM, len); - for (i = 0; i < memory_region_length(REGION_GFX1); i++) + for (i = 0; i < len; i++) { int j; @@ -662,7 +664,7 @@ DRIVER_INIT( rescue ) DRIVER_INIT( minefld ) { - offs_t i; + offs_t i, len; UINT8 *RAM; UINT8 *scratch; @@ -674,12 +676,13 @@ DRIVER_INIT( minefld ) */ RAM = memory_region(REGION_GFX1); + len = memory_region_length(REGION_GFX1); - scratch = malloc_or_die(memory_region_length(REGION_GFX1)); + scratch = malloc_or_die(len); - memcpy(scratch, RAM, memory_region_length(REGION_GFX1)); + memcpy(scratch, RAM, len); - for (i = 0; i < memory_region_length(REGION_GFX1); i++) + for (i = 0; i < len; i++) { int j; @@ -698,7 +701,7 @@ DRIVER_INIT( minefld ) DRIVER_INIT( losttomb ) { - offs_t i; + offs_t i, len; UINT8 *RAM; UINT8 *scratch; @@ -711,12 +714,13 @@ DRIVER_INIT( losttomb ) */ RAM = memory_region(REGION_GFX1); + len = memory_region_length(REGION_GFX1); - scratch = malloc_or_die(memory_region_length(REGION_GFX1)); + scratch = malloc_or_die(len); - memcpy(scratch, RAM, memory_region_length(REGION_GFX1)); + memcpy(scratch, RAM, len); - for (i = 0; i < memory_region_length(REGION_GFX1); i++) + for (i = 0; i < len; i++) { int j; @@ -866,11 +870,10 @@ DRIVER_INIT( mrkougb ) DRIVER_INIT( ad2083 ) { UINT8 c; - int i; - + int i, len = memory_region_length(REGION_CPU1); UINT8 *ROM = memory_region(REGION_CPU1); - for (i=0; i<memory_region_length(REGION_CPU1); i++) + for (i=0; i<len; i++) { c = ROM[i] ^ 0x35; c = BITSWAP8(c, 6,2,5,1,7,3,4,0); /* also swapped inside of the bigger module */ diff --git a/src/mame/machine/vsnes.c b/src/mame/machine/vsnes.c index b5178ac4e4a..230379ae211 100644 --- a/src/mame/machine/vsnes.c +++ b/src/mame/machine/vsnes.c @@ -405,15 +405,12 @@ static WRITE8_HANDLER( goonies_rom_banking ) switch( reg ) { case 0: /* code bank 0 */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[bankoffset], 0x2000 ); - break; - case 2: /* code bank 1 */ - memcpy( &memory_region( REGION_CPU1 )[0x0a000], &memory_region( REGION_CPU1 )[bankoffset], 0x2000 ); - break; - case 4: /* code bank 2 */ - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_CPU1 )[bankoffset], 0x2000 ); + { + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000 + reg*0x1000], &prg[bankoffset], 0x2000 ); + } break; case 6: /* vrom bank 0 */ @@ -430,7 +427,8 @@ DRIVER_INIT( goonies ) { /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x18000], 0x8000 ); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x18000], 0x8000 ); /* banking is done with writes to the $8000-$ffff area */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, goonies_rom_banking ); @@ -446,7 +444,8 @@ DRIVER_INIT( vsgradus ) { /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x18000], 0x8000 ); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x18000], 0x8000 ); /* banking is done with writes to the $8000-$ffff area */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, goonies_rom_banking ); @@ -504,9 +503,10 @@ static WRITE8_HANDLER( vsgshoe_gun_in0_w ) int addr; if((data & 0x04) != old_bank) { + UINT8 *prg = memory_region( REGION_CPU1 ); old_bank = data & 0x04; addr = old_bank ? 0x12000: 0x10000; - memcpy (&memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[addr], 0x2000); + memcpy (&prg[0x08000], &prg[addr], 0x2000); } gun_in0_w(machine, offset, data); @@ -515,7 +515,8 @@ static WRITE8_HANDLER( vsgshoe_gun_in0_w ) DRIVER_INIT( vsgshoe ) { /* set up the default bank */ - memcpy (&memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x12000], 0x2000); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy (&prg[0x08000], &prg[0x12000], 0x2000); /* Protection */ memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2002, 0x2002, 0, 0, vsgshoe_security_r ); @@ -620,11 +621,12 @@ static WRITE8_HANDLER( drmario_rom_banking ) case 3: /* program banking */ { int bank = ( drmario_shiftreg & 0x03 ) * 0x4000; + UINT8 *prg = memory_region( REGION_CPU1 ); if ( !size16k ) { /* switch 32k */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x010000+bank], 0x8000 ); + memcpy( &prg[0x08000], &prg[0x010000+bank], 0x8000 ); } else { @@ -632,12 +634,12 @@ static WRITE8_HANDLER( drmario_rom_banking ) if ( switchlow ) { /* low */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x010000+bank], 0x4000 ); + memcpy( &prg[0x08000], &prg[0x010000+bank], 0x4000 ); } else { /* high */ - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_CPU1 )[0x010000+bank], 0x4000 ); + memcpy( &prg[0x0c000], &prg[0x010000+bank], 0x4000 ); } } } @@ -652,8 +654,9 @@ DRIVER_INIT( drmario ) { /* We do manual banking, in case the code falls through */ /* Copy the initial banks */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x10000], 0x4000 ); - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_CPU1 )[0x1c000], 0x4000 ); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x10000], 0x4000 ); + memcpy( &prg[0x0c000], &prg[0x1c000], 0x4000 ); /* MMC1 mapper at writes to $8000-$ffff */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, drmario_rom_banking ); @@ -741,14 +744,16 @@ DRIVER_INIT( vsslalom ) static WRITE8_HANDLER( castlevania_rom_banking ) { int rombank = 0x10000 + ( data & 7 ) * 0x4000; + UINT8 *prg = memory_region( REGION_CPU1 ); - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[rombank], 0x4000 ); + memcpy( &prg[0x08000], &prg[rombank], 0x4000 ); } DRIVER_INIT( cstlevna ) { /* when starting the game, the 1st 16k and the last 16k are loaded into the 2 banks */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x28000], 0x8000 ); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x28000], 0x8000 ); /* banking is done with writes to the $8000-$ffff area */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, castlevania_rom_banking ); @@ -775,7 +780,8 @@ static READ8_HANDLER( topgun_security_r ) DRIVER_INIT( topgun ) { /* when starting the game, the 1st 16k and the last 16k are loaded into the 2 banks */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x28000], 0x8000 ); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x28000], 0x8000 ); /* banking is done with writes to the $8000-$ffff area */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, castlevania_rom_banking ); @@ -797,20 +803,21 @@ static int IRQ_enable, IRQ_count, IRQ_count_latch; static void mapper4_set_prg (void) { + UINT8 *prg = memory_region( REGION_CPU1 ); MMC3_prg0 &= MMC3_prg_mask; MMC3_prg1 &= MMC3_prg_mask; if (MMC3_cmd & 0x40) { - memcpy( &memory_region( REGION_CPU1 )[0x8000], &memory_region( REGION_CPU1 )[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0xc000], &memory_region( REGION_CPU1 )[0x2000 * (MMC3_prg0) + 0x10000], 0x2000 ); + memcpy( &prg[0x8000], &prg[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); + memcpy( &prg[0xc000], &prg[0x2000 * (MMC3_prg0) + 0x10000], 0x2000 ); } else { - memcpy( &memory_region( REGION_CPU1 )[0x8000], &memory_region( REGION_CPU1 )[0x2000 * (MMC3_prg0) + 0x10000], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0xc000], &memory_region( REGION_CPU1 )[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); + memcpy( &prg[0x8000], &prg[0x2000 * (MMC3_prg0) + 0x10000], 0x2000 ); + memcpy( &prg[0xc000], &prg[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); } - memcpy( &memory_region( REGION_CPU1 )[0xa000], &memory_region( REGION_CPU1 )[0x2000 * (MMC3_prg1) + 0x10000], 0x2000 ); + memcpy( &prg[0xa000], &prg[0x2000 * (MMC3_prg1) + 0x10000], 0x2000 ); } static void mapper4_set_chr (void) @@ -945,6 +952,7 @@ static WRITE8_HANDLER( mapper4_w ) DRIVER_INIT( MMC3 ) { + UINT8 *prg = memory_region( REGION_CPU1 ); IRQ_enable = IRQ_count = IRQ_count_latch = 0; MMC3_prg0 = 0xfe; MMC3_prg1 = 0xff; @@ -954,10 +962,10 @@ DRIVER_INIT( MMC3 ) MMC3_prg_mask = ((MMC3_prg_chunks << 1) - 1); - memcpy( &memory_region( REGION_CPU1 )[0x8000], &memory_region( REGION_CPU1 )[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0xa000], &memory_region( REGION_CPU1 )[(MMC3_prg_chunks-1) * 0x4000 + 0x12000], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0xc000], &memory_region( REGION_CPU1 )[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); - memcpy( &memory_region( REGION_CPU1 )[0xe000], &memory_region( REGION_CPU1 )[(MMC3_prg_chunks-1) * 0x4000 + 0x12000], 0x2000 ); + memcpy( &prg[0x8000], &prg[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); + memcpy( &prg[0xa000], &prg[(MMC3_prg_chunks-1) * 0x4000 + 0x12000], 0x2000 ); + memcpy( &prg[0xc000], &prg[(MMC3_prg_chunks-1) * 0x4000 + 0x10000], 0x2000 ); + memcpy( &prg[0xe000], &prg[(MMC3_prg_chunks-1) * 0x4000 + 0x12000], 0x2000 ); /* MMC3 mapper at writes to $8000-$ffff */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, mapper4_w ); @@ -1140,7 +1148,10 @@ static WRITE8_HANDLER( mapper68_rom_banking ){ break; case 0x7000: - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x10000 +data*0x4000], 0x4000 ); + { + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x10000 +data*0x4000], 0x4000 ); + } break; } @@ -1153,8 +1164,9 @@ DRIVER_INIT( platoon ) /* when starting a mapper 68 game the first 16K ROM bank in the cart is loaded into $8000 the LAST 16K ROM bank is loaded into $C000. The last 16K of ROM cannot be swapped. */ - memcpy( &memory_region( REGION_CPU1 )[0x08000], &memory_region( REGION_CPU1 )[0x10000], 0x4000 ); - memcpy( &memory_region( REGION_CPU1 )[0x0c000], &memory_region( REGION_CPU1 )[0x2c000], 0x4000 ); + UINT8 *prg = memory_region( REGION_CPU1 ); + memcpy( &prg[0x08000], &prg[0x10000], 0x4000 ); + memcpy( &prg[0x0c000], &prg[0x2c000], 0x4000 ); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, mapper68_rom_banking ); @@ -1268,6 +1280,8 @@ static WRITE8_HANDLER( vstennis_vrom_banking ) DRIVER_INIT( vstennis ) { + UINT8 *prg = memory_region( REGION_CPU1 ); + /* vrom switching is enabled with bit 2 of $4016 */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4016, 0x4016, 0, 0, vstennis_vrom_banking ); memory_install_write8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x4016, 0x4016, 0, 0, vstennis_vrom_banking ); @@ -1276,7 +1290,7 @@ DRIVER_INIT( vstennis ) memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, SMH_BANK1, SMH_BANK1 ); memory_install_readwrite8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, SMH_BANK1, SMH_BANK1 ); - memory_set_bankptr(1, &memory_region(REGION_CPU1)[0x6000]); + memory_set_bankptr(1, &prg[0x6000]); } /**********************************************************************/ diff --git a/src/mame/mame.mak b/src/mame/mame.mak index a8d38ef8e71..e15b171dc74 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -899,7 +899,7 @@ $(MAMEOBJ)/konami.a: \ $(DRIVERS)/timeplt.o $(AUDIO)/timeplt.o $(VIDEO)/timeplt.o \ $(DRIVERS)/tmnt.o $(VIDEO)/tmnt.o \ $(DRIVERS)/tp84.o $(VIDEO)/tp84.o \ - $(DRIVERS)/trackfld.o $(MACHINE)/konami.o $(AUDIO)/trackfld.o $(VIDEO)/trackfld.o \ + $(DRIVERS)/trackfld.o $(MACHINE)/konami1.o $(AUDIO)/trackfld.o $(VIDEO)/trackfld.o \ $(DRIVERS)/tutankhm.o $(VIDEO)/tutankhm.o \ $(DRIVERS)/twin16.o $(VIDEO)/twin16.o \ $(DRIVERS)/ultrsprt.o \ diff --git a/src/mame/video/8080bw.c b/src/mame/video/8080bw.c index 71293ee3482..016944d4517 100644 --- a/src/mame/video/8080bw.c +++ b/src/mame/video/8080bw.c @@ -130,11 +130,13 @@ VIDEO_UPDATE( invadpt2 ) { pen_t pens[NUM_PENS]; offs_t offs; + UINT8 *prom; UINT8 *color_map_base; invadpt2_get_pens(pens); - color_map_base = color_map ? &memory_region(REGION_PROMS)[0x0400] : memory_region(REGION_PROMS); + prom = memory_region(REGION_PROMS); + color_map_base = color_map ? &prom[0x0400] : &prom[0x0000]; for (offs = 0; offs < mw8080bw_ram_size; offs++) { @@ -160,10 +162,12 @@ VIDEO_UPDATE( ballbomb ) pen_t pens[NUM_PENS]; offs_t offs; UINT8 *color_map_base; + UINT8 *prom; invadpt2_get_pens(pens); - color_map_base = color_map ? &memory_region(REGION_PROMS)[0x0400] : memory_region(REGION_PROMS); + prom = memory_region(REGION_PROMS); + color_map_base = color_map ? &prom[0x0400] : &prom[0x0000]; for (offs = 0; offs < mw8080bw_ram_size; offs++) { @@ -400,10 +404,12 @@ VIDEO_UPDATE( indianbt ) pen_t pens[NUM_PENS]; offs_t offs; UINT8 *color_map_base; + UINT8 *prom; cosmo_get_pens(pens); - color_map_base = color_map ? &memory_region(REGION_PROMS)[0x0400] : memory_region(REGION_PROMS); + prom = memory_region(REGION_PROMS); + color_map_base = color_map ? &prom[0x0400] : &prom[0x0000]; for (offs = 0; offs < mw8080bw_ram_size; offs++) { diff --git a/src/mame/video/epos.c b/src/mame/video/epos.c index bfbfe84a677..44c36cc03bb 100644 --- a/src/mame/video/epos.c +++ b/src/mame/video/epos.c @@ -29,12 +29,14 @@ static UINT8 palette; static void get_pens(pen_t *pens) { offs_t i; + const UINT8 *prom = memory_region(REGION_PROMS); + int len = memory_region_length(REGION_PROMS); - for (i = 0; i < memory_region_length(REGION_PROMS); i++) + for (i = 0; i < len; i++) { int bit0, bit1, bit2, r, g, b; - UINT8 data = memory_region(REGION_PROMS)[i]; + UINT8 data = prom[i]; bit0 = (data >> 7) & 0x01; bit1 = (data >> 6) & 0x01; diff --git a/src/mame/video/galaxian.c b/src/mame/video/galaxian.c index 279469e4b03..e69c2c6cb90 100644 --- a/src/mame/video/galaxian.c +++ b/src/mame/video/galaxian.c @@ -308,7 +308,7 @@ PALETTE_INIT( galaxian ) { static const int rgb_resistances[3] = { 1000, 470, 220 }; double rweights[3], gweights[3], bweights[2]; - int i, minval, midval, maxval; + int i, minval, midval, maxval, len; UINT8 starmap[4]; /* @@ -343,7 +343,8 @@ PALETTE_INIT( galaxian ) 2, &rgb_resistances[1], bweights, 470, 0); /* decode the palette first */ - for (i = 0; i < memory_region_length(REGION_PROMS); i++) + len = memory_region_length(REGION_PROMS); + for (i = 0; i < len; i++) { UINT8 bit0, bit1, bit2, r, g, b; diff --git a/src/mame/video/galaxold.c b/src/mame/video/galaxold.c index d0e08f676f9..1303305f6a5 100644 --- a/src/mame/video/galaxold.c +++ b/src/mame/video/galaxold.c @@ -166,12 +166,12 @@ static bitmap_t *dambustr_tmpbitmap; ***************************************************************************/ PALETTE_INIT( galaxold ) { - int i; + int i, len; /* first, the character/sprite palette */ - - for (i = 0;i < memory_region_length(REGION_PROMS);i++) + len = memory_region_length(REGION_PROMS); + for (i = 0;i < len;i++) { int bit0,bit1,bit2,r,g,b; @@ -247,12 +247,12 @@ PALETTE_INIT( stratgyx ) PALETTE_INIT( rockclim ) { - int i; + int i, len; /* first, the character/sprite palette */ - - for (i = 0;i < memory_region_length(REGION_PROMS);i++) + len = memory_region_length(REGION_PROMS); + for (i = 0;i < len;i++) { int bit0,bit1,bit2,r,g,b; diff --git a/src/mame/video/ginganin.c b/src/mame/video/ginganin.c index 77f366cd6f7..997de5f1fa2 100644 --- a/src/mame/video/ginganin.c +++ b/src/mame/video/ginganin.c @@ -84,7 +84,8 @@ UINT16 *ginganin_fgram16, *ginganin_txtram16, *ginganin_vregs16; static TILE_GET_INFO( get_bg_tile_info ) { - int code = memory_region(REGION_GFX5)[2*tile_index + 0] * 256 + memory_region(REGION_GFX5)[2*tile_index + 1]; + UINT8 *gfx = memory_region(REGION_GFX5); + int code = gfx[2*tile_index + 0] * 256 + gfx[2*tile_index + 1]; SET_TILE_INFO( BG_GFX, code, diff --git a/src/mame/video/hyhoo.c b/src/mame/video/hyhoo.c index 1a25248e5ee..992789d3c56 100644 --- a/src/mame/video/hyhoo.c +++ b/src/mame/video/hyhoo.c @@ -52,16 +52,17 @@ WRITE8_HANDLER( hyhoo_blitter_w ) WRITE8_HANDLER( hyhoo_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); hyhoo_gfxrom = (((data & 0xc0) >> 4) + (data & 0x03)); hyhoo_highcolorflag = data; nb1413m3_gfxrombank_w(machine, 0, data); - if ((0x20000 * hyhoo_gfxrom) > (memory_region_length(REGION_GFX1) - 1)) + if ((0x20000 * hyhoo_gfxrom) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - hyhoo_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + hyhoo_gfxrom &= (gfxlen / 0x20000 - 1); } } @@ -81,7 +82,7 @@ void hyhoo_gfxdraw(void) int sizex, sizey; int skipx, skipy; int ctrx, ctry; - int gfxaddr; + int gfxaddr, gfxlen; UINT8 color, color1, color2; int r, g, b; pen_t pen; @@ -115,13 +116,14 @@ void hyhoo_gfxdraw(void) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = (hyhoo_gfxrom << 17) + (blitter_src_addr << 1); for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDRESS OVER!!"); diff --git a/src/mame/video/ms32.c b/src/mame/video/ms32.c index c0d813d1afc..124d9e27f7a 100644 --- a/src/mame/video/ms32.c +++ b/src/mame/video/ms32.c @@ -14,6 +14,8 @@ priority should be given to #include "driver.h" #include "deprecat.h" +#include "includes/ms32.h" + //UINT32 *ms32_fce00000; UINT32 *ms32_roz_ctrl; diff --git a/src/mame/video/mystwarr.c b/src/mame/video/mystwarr.c index a4ba270046c..be8f4e032f3 100644 --- a/src/mame/video/mystwarr.c +++ b/src/mame/video/mystwarr.c @@ -21,10 +21,11 @@ static char *orig_roms; static void mystwarr_save_orig_tiles(void) { UINT8 *s = memory_region(REGION_GFX1); - UINT8 *pFinish = s+memory_region_length(REGION_GFX1)-3; + int len = memory_region_length(REGION_GFX1); + UINT8 *pFinish = s+len-3; - orig_roms = malloc_or_die(memory_region_length(REGION_GFX1)); - memcpy(orig_roms, s, memory_region_length(REGION_GFX1)); + orig_roms = malloc_or_die(len); + memcpy(orig_roms, s, len); // now convert the data into a drawable format so we can decode it while (s < pFinish) @@ -54,9 +55,10 @@ static void mystwarr_save_orig_tiles(void) static void mystwarr_rest_orig_tiles(void) { UINT8 *s = memory_region(REGION_GFX1); + int len = memory_region_length(REGION_GFX1); // restore the original data so the ROM test can pass - memcpy(s, orig_roms, memory_region_length(REGION_GFX1)); + memcpy(s, orig_roms, len); free(orig_roms); } diff --git a/src/mame/video/nbmj8688.c b/src/mame/video/nbmj8688.c index ea673d329f1..df0fc80747e 100644 --- a/src/mame/video/nbmj8688.c +++ b/src/mame/video/nbmj8688.c @@ -184,56 +184,60 @@ WRITE8_HANDLER( mjsikaku_scrolly_w ) WRITE8_HANDLER( mjsikaku_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); mjsikaku_gfxrom = (data & 0x0f); - if ((mjsikaku_gfxrom << 17) > (memory_region_length(REGION_GFX1) - 1)) + if ((mjsikaku_gfxrom << 17) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - mjsikaku_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + mjsikaku_gfxrom &= (gfxlen / 0x20000 - 1); } } WRITE8_HANDLER( secolove_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); mjsikaku_gfxrom = ((data & 0xc0) >> 4) + (data & 0x03); mjsikaku_gfxflag2_w(machine, 0, data); - if ((mjsikaku_gfxrom << 17) > (memory_region_length(REGION_GFX1) - 1)) + if ((mjsikaku_gfxrom << 17) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - mjsikaku_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + mjsikaku_gfxrom &= (gfxlen / 0x20000 - 1); } } WRITE8_HANDLER( crystalg_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); mjsikaku_gfxrom = (data & 0x03); mjsikaku_gfxflag2_w(machine, 0, data); - if ((mjsikaku_gfxrom << 17) > (memory_region_length(REGION_GFX1) - 1)) + if ((mjsikaku_gfxrom << 17) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - mjsikaku_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + mjsikaku_gfxrom &= (gfxlen / 0x20000 - 1); } } WRITE8_HANDLER( seiha_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); mjsikaku_gfxrom = (data & 0x1f); mjsikaku_gfxflag3_w(machine, 0, data); - if ((mjsikaku_gfxrom << 17) > (memory_region_length(REGION_GFX1) - 1)) + if ((mjsikaku_gfxrom << 17) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - mjsikaku_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + mjsikaku_gfxrom &= (gfxlen / 0x20000 - 1); } } @@ -300,7 +304,7 @@ static void mbmj8688_gfxdraw(int gfxtype) int sizex, sizey; int skipx, skipy; int ctrx, ctry; - int gfxaddr; + int gfxaddr, gfxlen; UINT16 color, color1, color2; if (gfxtype == GFXTYPE_PURE_12BIT) @@ -335,6 +339,7 @@ static void mbmj8688_gfxdraw(int gfxtype) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = (mjsikaku_gfxrom << 17) + (blitter_src_addr << 1); //popmessage("ADDR:%08X DX:%03d DY:%03d SX:%03d SY:%03d", gfxaddr, startx, starty, sizex, sizey); //if (blitter_direction_x|blitter_direction_y) popmessage("ADDR:%08X FX:%01d FY:%01d", gfxaddr, blitter_direction_x, blitter_direction_y); @@ -343,7 +348,7 @@ static void mbmj8688_gfxdraw(int gfxtype) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDRESS OVER!!"); diff --git a/src/mame/video/nbmj8891.c b/src/mame/video/nbmj8891.c index e569983ca71..c5d0c6dc017 100644 --- a/src/mame/video/nbmj8891.c +++ b/src/mame/video/nbmj8891.c @@ -273,14 +273,15 @@ WRITE8_HANDLER( nbmj8891_vramsel_w ) WRITE8_HANDLER( nbmj8891_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); nbmj8891_gfxrom = (data & 0x0f); - if ((0x20000 * nbmj8891_gfxrom) > (memory_region_length(REGION_GFX1) - 1)) + if ((0x20000 * nbmj8891_gfxrom) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - nbmj8891_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + nbmj8891_gfxrom &= (gfxlen / 0x20000 - 1); } } @@ -347,7 +348,7 @@ static void nbmj8891_gfxdraw(void) int skipx, skipy; int ctrx, ctry; UINT8 color, color1, color2; - int gfxaddr; + int gfxaddr, gfxlen; nb1413m3_busyctr = 0; @@ -376,18 +377,19 @@ static void nbmj8891_gfxdraw(void) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = (nbmj8891_gfxrom << 17) + (blitter_src_addr << 1); for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDRESS OVER!!"); #endif - gfxaddr &= (memory_region_length(REGION_GFX1) - 1); + gfxaddr &= (gfxlen - 1); } color = GFX[gfxaddr++]; diff --git a/src/mame/video/nbmj8991.c b/src/mame/video/nbmj8991.c index 91f799e2c00..d3db594db52 100644 --- a/src/mame/video/nbmj8991.c +++ b/src/mame/video/nbmj8991.c @@ -94,6 +94,8 @@ WRITE8_HANDLER( nbmj8991_palette_type3_w ) ******************************************************************************/ WRITE8_HANDLER( nbmj8991_blitter_w ) { + int gfxlen = memory_region_length(REGION_GFX1); + switch (offset) { case 0x00: blitter_src_addr = (blitter_src_addr & 0xff00) | data; break; @@ -125,12 +127,12 @@ WRITE8_HANDLER( nbmj8991_blitter_w ) case 0x70: nbmj8991_clutsel = data; break; } - if ((0x20000 * nbmj8991_gfxrom) > (memory_region_length(REGION_GFX1) - 1)) + if ((0x20000 * nbmj8991_gfxrom) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - nbmj8991_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + nbmj8991_gfxrom &= (gfxlen / 0x20000 - 1); } } @@ -202,7 +204,7 @@ static void nbmj8991_gfxdraw(void) int skipx, skipy; int ctrx, ctry; UINT8 color, color1, color2; - int gfxaddr; + int gfxaddr, gfxlen; nb1413m3_busyctr = 0; @@ -232,18 +234,19 @@ static void nbmj8991_gfxdraw(void) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = (nbmj8991_gfxrom << 17) + (blitter_src_addr << 1); for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDRESS OVER!!"); #endif - gfxaddr &= (memory_region_length(REGION_GFX1) - 1); + gfxaddr &= (gfxlen - 1); } color = GFX[gfxaddr++]; diff --git a/src/mame/video/nbmj9195.c b/src/mame/video/nbmj9195.c index 32f40850556..ce7032cd055 100644 --- a/src/mame/video/nbmj9195.c +++ b/src/mame/video/nbmj9195.c @@ -242,7 +242,7 @@ static void nbmj9195_gfxdraw(int vram) int skipx, skipy; int ctrx, ctry; UINT16 color, color1, color2; - int gfxaddr; + int gfxaddr, gfxlen; nb19010_busyctr = 0; @@ -279,19 +279,20 @@ static void nbmj9195_gfxdraw(int vram) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = ((blitter_src_addr[vram] + 2) & 0x00ffffff); for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDR OVER:%08X DX,%d,DY:%d,SX:%d,SY:%d", gfxaddr, startx, starty, sizex,sizey); logerror("GFXROM ADDR OVER:%08X DX,%d,DY:%d,SX:%d,SY:%d\n", gfxaddr, startx, starty, sizex,sizey); #endif - gfxaddr &= (memory_region_length(REGION_GFX1) - 1); + gfxaddr &= (gfxlen - 1); } color = GFX[gfxaddr++]; diff --git a/src/mame/video/neogeo.c b/src/mame/video/neogeo.c index 0f648a38d79..34cd641bf2c 100644 --- a/src/mame/video/neogeo.c +++ b/src/mame/video/neogeo.c @@ -693,6 +693,7 @@ static void optimize_sprite_data(void) /* convert the sprite graphics data into a format that allows faster blitting */ int i; + int len; UINT8 *src; UINT8 *dest; UINT32 bit; @@ -713,9 +714,10 @@ static void optimize_sprite_data(void) memset(sprite_gfx, 0, sprite_gfx_address_mask + 1); src = memory_region(NEOGEO_REGION_SPRITES); + len = memory_region_length(NEOGEO_REGION_SPRITES); dest = sprite_gfx; - for (i = 0; i < memory_region_length(NEOGEO_REGION_SPRITES); i += 0x80, src += 0x80) + for (i = 0; i < len; i += 0x80, src += 0x80) { int y; diff --git a/src/mame/video/niyanpai.c b/src/mame/video/niyanpai.c index 1b373185c07..c98fa8d9add 100644 --- a/src/mame/video/niyanpai.c +++ b/src/mame/video/niyanpai.c @@ -207,7 +207,7 @@ static void niyanpai_gfxdraw(int vram) int skipx, skipy; int ctrx, ctry; UINT16 color, color1, color2; - int gfxaddr; + int gfxaddr, gfxlen; nb19010_busyctr = 0; @@ -244,19 +244,20 @@ static void niyanpai_gfxdraw(int vram) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = ((blitter_src_addr[vram] + 2) & 0x00ffffff); for (y = starty, ctry = sizey; ctry >= 0; y += skipy, ctry--) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDR OVER:%08X DX,%d,DY:%d,SX:%d,SY:%d", gfxaddr, startx, starty, sizex,sizey); logerror("GFXROM ADDR OVER:%08X DX,%d,DY:%d,SX:%d,SY:%d\n", gfxaddr, startx, starty, sizex,sizey); #endif - gfxaddr &= (memory_region_length(REGION_GFX1) - 1); + gfxaddr &= (gfxlen - 1); } color = GFX[gfxaddr++]; diff --git a/src/mame/video/pastelg.c b/src/mame/video/pastelg.c index 8f30e573d0c..cbd8bc5fafb 100644 --- a/src/mame/video/pastelg.c +++ b/src/mame/video/pastelg.c @@ -98,16 +98,17 @@ WRITE8_HANDLER( pastelg_blitter_w ) WRITE8_HANDLER( pastelg_romsel_w ) { + int gfxlen = memory_region_length(REGION_GFX1); pastelg_gfxrom = ((data & 0xc0) >> 6); pastelg_palbank = ((data & 0x10) >> 4); nb1413m3_sndrombank1_w(machine, 0, data); - if ((pastelg_gfxrom << 16) > (memory_region_length(REGION_GFX1) - 1)) + if ((pastelg_gfxrom << 16) > (gfxlen - 1)) { #ifdef MAME_DEBUG popmessage("GFXROM BANK OVER!!"); #endif - pastelg_gfxrom &= (memory_region_length(REGION_GFX1) / 0x20000 - 1); + pastelg_gfxrom &= (gfxlen / 0x20000 - 1); } } @@ -156,7 +157,7 @@ static void pastelg_gfxdraw(void) int skipx, skipy; int ctrx, ctry; int readflag; - int gfxaddr; + int gfxaddr, gfxlen; UINT8 color; nb1413m3_busyctr = 0; @@ -186,6 +187,7 @@ static void pastelg_gfxdraw(void) skipy = -1; } + gfxlen = memory_region_length(REGION_GFX1); gfxaddr = (pastelg_gfxrom << 16) + blitter_src_addr; readflag = 0; @@ -194,7 +196,7 @@ static void pastelg_gfxdraw(void) { for (x = startx, ctrx = sizex; ctrx >= 0; x += skipx, ctrx--) { - if ((gfxaddr > (memory_region_length(REGION_GFX1) - 1))) + if ((gfxaddr > (gfxlen - 1))) { #ifdef MAME_DEBUG popmessage("GFXROM ADDRESS OVER!!"); diff --git a/src/mame/video/pgm.c b/src/mame/video/pgm.c index 488fd3ba8dc..5599683e8d7 100644 --- a/src/mame/video/pgm.c +++ b/src/mame/video/pgm.c @@ -2,15 +2,12 @@ /* see drivers/pgm.c for notes on where improvements can be made */ #include "driver.h" +#include "includes/pgm.h" -extern UINT16 *pgm_mainram, *pgm_bg_videoram, *pgm_tx_videoram, *pgm_videoregs, *pgm_rowscrollram; static tilemap *pgm_tx_tilemap, *pgm_bg_tilemap; static UINT16 *pgm_spritebufferram; // buffered spriteram static UINT16 *sprite_temp_render; -extern UINT8 *pgm_sprite_a_region; /* = memory_region ( REGION_GFX4 ); */ -extern size_t pgm_sprite_a_region_allocate; - /* Sprites - These are a pain! */ /* this decodes one of the funky sprites to a bitmap so we can draw it more easily -- slow but easier to use*/ diff --git a/src/mame/video/segaic16.c b/src/mame/video/segaic16.c index b59f5c4ab8d..03df5b1863c 100644 --- a/src/mame/video/segaic16.c +++ b/src/mame/video/segaic16.c @@ -1991,10 +1991,10 @@ static void segaic16_sprites_16b_draw(struct sprite_info *info, bitmap_t *bitmap const UINT16 *spritebase; UINT16 *data; - if (!memory_region(REGION_GFX2)) + spritebase = (const UINT16 *)memory_region(REGION_GFX2); + if (!spritebase) return; - spritebase = (const UINT16 *)memory_region(REGION_GFX2); numbanks = memory_region_length(REGION_GFX2) / 0x20000; /* first scan forward to find the end of the list */ @@ -2895,6 +2895,8 @@ WRITE16_HANDLER( segaic16_sprites_draw_1_w ) static void segaic16_road_hangon_decode(struct road_info *info) { int x, y; + const UINT8 *gfx = memory_region(REGION_GFX3); + int len = memory_region_length(REGION_GFX3); /* allocate memory for the unpacked road data */ info->gfx = auto_malloc(256 * 512); @@ -2902,7 +2904,7 @@ static void segaic16_road_hangon_decode(struct road_info *info) /* loop over rows */ for (y = 0; y < 256; y++) { - UINT8 *src = memory_region(REGION_GFX3) + ((y & 0xff) * 0x40) % memory_region_length(REGION_GFX3); + const UINT8 *src = gfx + ((y & 0xff) * 0x40) % len; UINT8 *dst = info->gfx + y * 512; /* loop over columns */ @@ -3154,6 +3156,8 @@ static void segaic16_road_hangon_draw(struct road_info *info, bitmap_t *bitmap, static void segaic16_road_outrun_decode(struct road_info *info) { int x, y; + const UINT8 *gfx = memory_region(REGION_GFX3); + int len = memory_region_length(REGION_GFX3); /* allocate memory for the unpacked road data */ info->gfx = auto_malloc((256 * 2 + 1) * 512); @@ -3161,7 +3165,7 @@ static void segaic16_road_outrun_decode(struct road_info *info) /* loop over rows */ for (y = 0; y < 256 * 2; y++) { - UINT8 *src = memory_region(REGION_GFX3) + ((y & 0xff) * 0x40 + (y >> 8) * 0x8000) % memory_region_length(REGION_GFX3); + const UINT8 *src = gfx + ((y & 0xff) * 0x40 + (y >> 8) * 0x8000) % len; UINT8 *dst = info->gfx + y * 512; /* loop over columns */ diff --git a/src/mame/video/st0016.c b/src/mame/video/st0016.c index 3fd7e26d62b..fb675f58ff4 100644 --- a/src/mame/video/st0016.c +++ b/src/mame/video/st0016.c @@ -190,9 +190,10 @@ WRITE8_HANDLER(st0016_vregs_w) UINT32 srcadr=(st0016_vregs[0xa0]|(st0016_vregs[0xa1]<<8)|(st0016_vregs[0xa2]<<16))<<1; UINT32 dstadr=(st0016_vregs[0xa3]|(st0016_vregs[0xa4]<<8)|(st0016_vregs[0xa5]<<16))<<1; UINT32 length=((st0016_vregs[0xa6]|(st0016_vregs[0xa7]<<8)|((st0016_vregs[0xa8]&0x1f)<<16))+1)<<1; + UINT32 srclen = (memory_region_length(REGION_CPU1)-0x10000); while(length>0) { - if( srcadr < (memory_region_length(REGION_CPU1)-0x10000) && (dstadr < ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE)) + if( srcadr < srclen && (dstadr < ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE)) { st0016_char_bank=dstadr>>5; st0016_character_ram_w(machine,dstadr&0x1f,memory_region(REGION_CPU1)[0x10000+srcadr]); diff --git a/src/mame/video/suprnova.c b/src/mame/video/suprnova.c index b4914a33a1b..13d6d29d53b 100644 --- a/src/mame/video/suprnova.c +++ b/src/mame/video/suprnova.c @@ -451,7 +451,7 @@ void skns_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectang int disabled = skns_spc_regs[0x04/4] & 0x08; // RWR1 int xsize,ysize, size, xpos=0,ypos=0, pri=0, romoffset, colour=0, xflip,yflip, joint; int sx,sy; - int endromoffs=0; + int endromoffs=0, gfxlen; UINT16 zoomx, zoomy; @@ -503,6 +503,7 @@ void skns_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectang sprite_y_scroll += sprite_kludge_y; + gfxlen = memory_region_length (REGION_GFX1); while( source<finish ) { xflip = (source[0] & 0x00000200) >> 9; @@ -590,7 +591,7 @@ void skns_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectang zoomx = source[2] >> 16; zoomy = source[3] >> 16; - romoffset &= memory_region_length (REGION_GFX1)-1; + romoffset &= gfxlen-1; endromoffs = skns_rle_decode ( romoffset, size ); diff --git a/src/mame/video/tmnt.c b/src/mame/video/tmnt.c index 802f5cfb7d2..ed81585b471 100644 --- a/src/mame/video/tmnt.c +++ b/src/mame/video/tmnt.c @@ -424,8 +424,11 @@ READ16_HANDLER( glfgreat_rom_r ) if (glfgreat_roz_rom_mode) return memory_region(REGION_GFX3)[glfgreat_roz_char_bank * 0x80000 + offset]; else if (offset < 0x40000) - return memory_region(REGION_USER1)[offset + 0x80000 + glfgreat_roz_rom_bank * 0x40000] + - 256 * memory_region(REGION_USER1)[offset + glfgreat_roz_rom_bank * 0x40000]; + { + UINT8 *usr = memory_region(REGION_USER1); + return usr[offset + 0x80000 + glfgreat_roz_rom_bank * 0x40000] + + 256 * usr[offset + glfgreat_roz_rom_bank * 0x40000]; + } else return memory_region(REGION_USER1)[((offset & 0x3ffff) >> 2) + 0x100000 + glfgreat_roz_rom_bank * 0x10000]; } @@ -525,7 +528,10 @@ READ16_HANDLER( prmrsocr_rom_r ) if(glfgreat_roz_char_bank) return memory_region(REGION_GFX3)[offset]; else - return 256 * memory_region(REGION_USER1)[offset] + memory_region(REGION_USER1)[offset + 0x020000]; + { + UINT8 *usr = memory_region(REGION_USER1); + return 256 * usr[offset] + usr[offset + 0x020000]; + } } WRITE16_HANDLER( tmnt_priority_w ) diff --git a/src/mame/video/tubep.c b/src/mame/video/tubep.c index 0afc481a211..499b2d5b894 100644 --- a/src/mame/video/tubep.c +++ b/src/mame/video/tubep.c @@ -436,9 +436,9 @@ static void draw_sprite(void) UINT32 XDOT; UINT32 YDOT; UINT8 * romCxx = memory_region(REGION_USER2)+0x00000; - UINT8 * romD10 = memory_region(REGION_USER2)+0x10000; - UINT8 * romEF13 = memory_region(REGION_USER2)+0x12000; - UINT8 * romHI2 = memory_region(REGION_USER2)+0x14000; + UINT8 * romD10 = romCxx+0x10000; + UINT8 * romEF13 = romCxx+0x12000; + UINT8 * romHI2 = romCxx+0x14000; for (YDOT=0; (YDOT^YSize) != 0x00; YDOT++) @@ -739,8 +739,8 @@ VIDEO_UPDATE( rjammer ) UINT32 v; UINT8 *text_gfx_base = memory_region(REGION_GFX1); UINT8 *rom13D = memory_region(REGION_USER1); - UINT8 *rom11BD = memory_region(REGION_USER1)+0x1000; - UINT8 *rom19C = memory_region(REGION_USER1)+0x5000; + UINT8 *rom11BD = rom13D+0x1000; + UINT8 *rom19C = rom13D+0x5000; /* this can be optimized further by extracting constants out of the loop */ /* especially read from ROM19C can be done once per 8 pixels*/ diff --git a/src/mame/video/xevious.c b/src/mame/video/xevious.c index df823e72c77..c254958bcd6 100644 --- a/src/mame/video/xevious.c +++ b/src/mame/video/xevious.c @@ -329,8 +329,8 @@ WRITE8_HANDLER( xevious_bs_w ) READ8_HANDLER( xevious_bb_r ) { UINT8 *rom2a = memory_region(REGION_GFX4); - UINT8 *rom2b = memory_region(REGION_GFX4)+0x1000; - UINT8 *rom2c = memory_region(REGION_GFX4)+0x3000; + UINT8 *rom2b = rom2a+0x1000; + UINT8 *rom2c = rom2a+0x3000; int adr_2b,adr_2c; int dat1,dat2; |
