summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-06-23 08:17:42 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-06-23 08:17:42 +0000
commitb3743812df365ec03c4af5985ba7499fdc48fb3a (patch)
treef5bcb8b9bb5281f5795d231222465f0d86c5d0ef
parentec54e3911de8d8566ca1a5befa6f7b062f1490c3 (diff)
From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] memory_region madness reloaded Hi mamedev, 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 should given the syntax of the related apis memory_region_type and memory_region_flags. Clearly they didn't get the parameter because of the sheer number of changes needed to change the apis. This pair of patches makes the change, and deals with the consequences. The first patch makes some changes to help the second patch along, as well as moves some uses of the memory_region apis within for loops outside the loops.
-rw-r--r--src/emu/sound/aica.c2
-rw-r--r--src/emu/sound/x1_010.c5
-rw-r--r--src/mame/drivers/astinvad.c3
-rw-r--r--src/mame/drivers/astrof.c6
-rw-r--r--src/mame/drivers/atetris.c5
-rw-r--r--src/mame/drivers/cave.c5
-rw-r--r--src/mame/drivers/cps3.c16
-rw-r--r--src/mame/drivers/ddenlovr.c10
-rw-r--r--src/mame/drivers/epos.c5
-rw-r--r--src/mame/drivers/galaga.c7
-rw-r--r--src/mame/drivers/harddriv.c26
-rw-r--r--src/mame/drivers/hng64.c3
-rw-r--r--src/mame/drivers/kaneko16.c3
-rw-r--r--src/mame/drivers/lazercmd.c15
-rw-r--r--src/mame/drivers/megadriv.c3
-rw-r--r--src/mame/drivers/metro.c2
-rw-r--r--src/mame/drivers/missb2.c6
-rw-r--r--src/mame/drivers/namcos11.c4
-rw-r--r--src/mame/drivers/neogeo.c4
-rw-r--r--src/mame/drivers/pasha2.c13
-rw-r--r--src/mame/drivers/pgm.c10
-rw-r--r--src/mame/drivers/segaorun.c3
-rw-r--r--src/mame/drivers/segas16a.c3
-rw-r--r--src/mame/drivers/segas16b.c3
-rw-r--r--src/mame/drivers/segas18.c3
-rw-r--r--src/mame/drivers/segaxbd.c11
-rw-r--r--src/mame/drivers/ssingles.c9
-rw-r--r--src/mame/drivers/starwars.c10
-rw-r--r--src/mame/drivers/tmnt.c3
-rw-r--r--src/mame/drivers/tnzs.c2
-rw-r--r--src/mame/drivers/wheelfir.c11
-rw-r--r--src/mame/includes/system16.h6
-rw-r--r--src/mame/machine/jackal.c18
-rw-r--r--src/mame/machine/s16fd.c1
-rw-r--r--src/mame/machine/scramble.c8
-rw-r--r--src/mame/machine/segaic16.c6
-rw-r--r--src/mame/machine/segas32.c5
-rw-r--r--src/mame/video/btime.c4
-rw-r--r--src/mame/video/bublbobl.c6
-rw-r--r--src/mame/video/buggychl.c6
-rw-r--r--src/mame/video/crgolf.c3
-rw-r--r--src/mame/video/deniam.c4
-rw-r--r--src/mame/video/exerion.c4
-rw-r--r--src/mame/video/gridlee.c4
-rw-r--r--src/mame/video/jedi.c3
-rw-r--r--src/mame/video/ksayakyu.c5
-rw-r--r--src/mame/video/m107.c2
-rw-r--r--src/mame/video/n8080.c3
-rw-r--r--src/mame/video/namcos22.c4
-rw-r--r--src/mame/video/neogeo.c4
-rw-r--r--src/mame/video/polepos.c4
-rw-r--r--src/mame/video/redalert.c3
-rw-r--r--src/mame/video/rollrace.c5
-rw-r--r--src/mame/video/spacefb.c4
-rw-r--r--src/mame/video/st0016.c3
-rw-r--r--src/mame/video/strnskil.c3
-rw-r--r--src/mame/video/suprloco.c4
-rw-r--r--src/mame/video/taitosj.c3
58 files changed, 184 insertions, 152 deletions
diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c
index 574162c9477..d4cc0263482 100644
--- a/src/emu/sound/aica.c
+++ b/src/emu/sound/aica.c
@@ -544,7 +544,7 @@ static void AICA_Init(struct _AICA *AICA, const struct AICAinterface *intf, int
AICA->RAM_MASK = AICA->AICARAM_LENGTH-1;
AICA->RAM_MASK16 = AICA->RAM_MASK & 0x7ffffe;
AICA->DSP.AICARAM = (UINT16 *)AICA->AICARAM;
- AICA->DSP.AICARAM_LENGTH = memory_region_length(intf->region)/2;
+ AICA->DSP.AICARAM_LENGTH = AICA->AICARAM_LENGTH/2;
}
}
diff --git a/src/emu/sound/x1_010.c b/src/emu/sound/x1_010.c
index 43e7afb0385..9b22fde45cc 100644
--- a/src/emu/sound/x1_010.c
+++ b/src/emu/sound/x1_010.c
@@ -113,6 +113,7 @@ static void seta_update( void *param, stream_sample_t **inputs, stream_sample_t
register INT8 *start, *end, data;
register UINT8 *env;
register UINT32 smp_offs, smp_step, env_offs, env_step, delta;
+ UINT8 *snd1 = memory_region(REGION_SOUND1);
// mixer buffer zero clear
memset( buffer[0], 0, length*sizeof(*buffer[0]) );
@@ -126,8 +127,8 @@ static void seta_update( void *param, stream_sample_t **inputs, stream_sample_t
stream_sample_t *bufL = buffer[0];
stream_sample_t *bufR = buffer[1];
if( (reg->status&2) == 0 ) { // PCM sampling
- start = (INT8 *)(reg->start *0x1000+memory_region(REGION_SOUND1));
- end = (INT8 *)((0x100-reg->end)*0x1000+memory_region(REGION_SOUND1));
+ start = (INT8 *)(reg->start *0x1000+snd1);
+ end = (INT8 *)((0x100-reg->end)*0x1000+snd1);
volL = ((reg->volume>>4)&0xf)*VOL_BASE;
volR = ((reg->volume>>0)&0xf)*VOL_BASE;
smp_offs = info->smp_offset[ch];
diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c
index 1b6f7717e40..b6a209d1590 100644
--- a/src/mame/drivers/astinvad.c
+++ b/src/mame/drivers/astinvad.c
@@ -156,6 +156,7 @@ static VIDEO_UPDATE( astinvad )
static VIDEO_UPDATE( spaceint )
{
+ const UINT8 *color_prom = memory_region(REGION_PROMS);
int offs;
for (offs = 0; offs < videoram_size; offs++)
@@ -168,7 +169,7 @@ static VIDEO_UPDATE( spaceint )
/* this is almost certainly wrong */
offs_t n = ((offs >> 5) & 0xf0) | color;
- color = memory_region(REGION_PROMS)[n] & 0x07;
+ color = color_prom[n] & 0x07;
plot_byte(bitmap, y, x, data, color);
}
diff --git a/src/mame/drivers/astrof.c b/src/mame/drivers/astrof.c
index fac780c08d5..f683b421a1c 100644
--- a/src/mame/drivers/astrof.c
+++ b/src/mame/drivers/astrof.c
@@ -201,10 +201,11 @@ static rgb_t make_pen(UINT8 data)
static void astrof_get_pens(pen_t *pens)
{
offs_t i;
+ UINT8 *prom = memory_region(REGION_PROMS);
for (i = 0; i < ASTROF_NUM_PENS; i++)
{
- UINT8 data = memory_region(REGION_PROMS)[(astrof_palette_bank ? 0x10 : 0x00) | i];
+ UINT8 data = prom[(astrof_palette_bank ? 0x10 : 0x00) | i];
pens[i] = make_pen(data);
}
@@ -214,10 +215,11 @@ static void astrof_get_pens(pen_t *pens)
static void tomahawk_get_pens(pen_t *pens)
{
offs_t i;
+ UINT8 *prom = memory_region(REGION_PROMS);
for (i = 0; i < TOMAHAWK_NUM_PENS; i++)
{
- UINT8 data = memory_region(REGION_PROMS)[i];
+ UINT8 data = prom[i];
pens[i] = make_pen(data);
}
diff --git a/src/mame/drivers/atetris.c b/src/mame/drivers/atetris.c
index 80ebbdc86d1..c4d9b48b035 100644
--- a/src/mame/drivers/atetris.c
+++ b/src/mame/drivers/atetris.c
@@ -493,9 +493,10 @@ ROM_END
static DRIVER_INIT( atetris )
{
+ UINT8 *rgn = memory_region(REGION_CPU1);
slapstic_init(machine, 101);
- slapstic_source = &memory_region(REGION_CPU1)[0x10000];
- slapstic_base = &memory_region(REGION_CPU1)[0x04000];
+ slapstic_source = &rgn[0x10000];
+ slapstic_base = &rgn[0x04000];
}
diff --git a/src/mame/drivers/cave.c b/src/mame/drivers/cave.c
index 7a465381308..7dad95ca320 100644
--- a/src/mame/drivers/cave.c
+++ b/src/mame/drivers/cave.c
@@ -2603,8 +2603,9 @@ static void 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)
{
diff --git a/src/mame/drivers/cps3.c b/src/mame/drivers/cps3.c
index 68d3e655fde..15ddb451bfa 100644
--- a/src/mame/drivers/cps3.c
+++ b/src/mame/drivers/cps3.c
@@ -1951,11 +1951,11 @@ static WRITE32_HANDLER( cps3_palettedma_w )
if (data & 0x0002)
{
int i;
+ UINT16* src = (UINT16*)memory_region(REGION_USER5);
// if(DEBUG_PRINTF) printf("CPS3 pal dma start %08x (real: %08x) dest %08x fade %08x other2 %08x (length %04x)\n", paldma_source, paldma_realsource, paldma_dest, paldma_fade, paldma_other2, paldma_length);
for (i=0;i<paldma_length;i++)
{
- UINT16* src = (UINT16*)memory_region(REGION_USER5);
UINT16 coldata = src[BYTE_XOR_BE(((paldma_realsource>>1)+i))];
//if (paldma_fade!=0) printf("%08x\n",paldma_fade);
@@ -2477,11 +2477,11 @@ static MACHINE_RESET( cps3 )
static void precopy_to_flash(void)
{
+ UINT32* romdata = (UINT32*)memory_region(REGION_USER4);
int i;
/* precopy program roms, ok, sfiii2 tests pass, others fail because of how the decryption affects testing */
for (i=0;i<0x800000;i+=4)
{
- UINT32* romdata = (UINT32*)memory_region(REGION_USER4);
UINT32 data;
UINT8* ptr1 = intelflash_getmemptr(0);
UINT8* ptr2 = intelflash_getmemptr(1);
@@ -2498,7 +2498,6 @@ static void precopy_to_flash(void)
for (i=0;i<0x800000;i+=4)
{
- UINT32* romdata = (UINT32*)memory_region(REGION_USER4);
UINT32 data;
UINT8* ptr1 = intelflash_getmemptr(4);
UINT8* ptr2 = intelflash_getmemptr(5);
@@ -2517,8 +2516,8 @@ static void precopy_to_flash(void)
{
UINT32 thebase, len = memory_region_length(REGION_USER5);
int flashnum = 8;
- UINT32* romdata = (UINT32*)memory_region(REGION_USER5);
+ romdata = (UINT32*)memory_region(REGION_USER5);
for (thebase = 0;thebase < len/2; thebase+=0x200000)
{
// printf("flashnums %d. %d\n",flashnum, flashnum+1);
@@ -2544,13 +2543,12 @@ static void precopy_to_flash(void)
// make a copy in the regions we execute code / draw gfx from
static void copy_from_nvram(void)
{
-
+ UINT32* romdata = (UINT32*)memory_region(REGION_USER4);
+ UINT32* romdata2 = (UINT32*)decrypted_gamerom;
int i;
/* copy + decrypt program roms which have been loaded from flashroms/nvram */
for (i=0;i<0x800000;i+=4)
{
- UINT32* romdata = (UINT32*)memory_region(REGION_USER4);
- UINT32* romdata2 = (UINT32*)decrypted_gamerom;
UINT32 data;
UINT8* ptr1 = intelflash_getmemptr(0);
UINT8* ptr2 = intelflash_getmemptr(1);
@@ -2567,8 +2565,6 @@ static void copy_from_nvram(void)
for (i=0;i<0x800000;i+=4)
{
- UINT32* romdata = (UINT32*)memory_region(REGION_USER4);
- UINT32* romdata2 = (UINT32*)decrypted_gamerom;
UINT32 data;
UINT8* ptr1 = intelflash_getmemptr(4);
UINT8* ptr2 = intelflash_getmemptr(5);
@@ -2589,9 +2585,9 @@ static void copy_from_nvram(void)
{
UINT32 thebase, len = memory_region_length(REGION_USER5);
int flashnum = 8;
- UINT32* romdata = (UINT32*)memory_region(REGION_USER5);
int countoffset = 0;
+ romdata = (UINT32*)memory_region(REGION_USER5);
for (thebase = 0;thebase < len/2; thebase+=0x200000)
{
// printf("flashnums %d. %d\n",flashnum, flashnum+1);
diff --git a/src/mame/drivers/ddenlovr.c b/src/mame/drivers/ddenlovr.c
index 8e86881a2f1..4fda5268a3b 100644
--- a/src/mame/drivers/ddenlovr.c
+++ b/src/mame/drivers/ddenlovr.c
@@ -1217,7 +1217,7 @@ VIDEO_UPDATE(ddenlovr)
#if 0
static int base = 0x0;
-
+ const UINT8 *gfx = memory_region(REGION_GFX1);
int next;
memset(ddenlovr_pixmap[0],0,512*512);
memset(ddenlovr_pixmap[1],0,512*512);
@@ -1232,10 +1232,10 @@ VIDEO_UPDATE(ddenlovr)
popmessage("GFX %06x",base);
if (input_code_pressed(KEYCODE_S)) base = next;
if (input_code_pressed_once(KEYCODE_X)) base = next;
- if (input_code_pressed(KEYCODE_C)) { base--; while ((memory_region(REGION_GFX1)[base] & 0xf0) != 0x30) base--; }
- if (input_code_pressed(KEYCODE_V)) { base++; while ((memory_region(REGION_GFX1)[base] & 0xf0) != 0x30) base++; }
- if (input_code_pressed_once(KEYCODE_D)) { base--; while ((memory_region(REGION_GFX1)[base] & 0xf0) != 0x30) base--; }
- if (input_code_pressed_once(KEYCODE_F)) { base++; while ((memory_region(REGION_GFX1)[base] & 0xf0) != 0x30) base++; }
+ if (input_code_pressed(KEYCODE_C)) { base--; while ((gfx[base] & 0xf0) != 0x30) base--; }
+ if (input_code_pressed(KEYCODE_V)) { base++; while ((gfx[base] & 0xf0) != 0x30) base++; }
+ if (input_code_pressed_once(KEYCODE_D)) { base--; while ((gfx[base] & 0xf0) != 0x30) base--; }
+ if (input_code_pressed_once(KEYCODE_F)) { base++; while ((gfx[base] & 0xf0) != 0x30) base++; }
#endif
fillbitmap(bitmap,ddenlovr_bgcolor,cliprect);
diff --git a/src/mame/drivers/epos.c b/src/mame/drivers/epos.c
index 6dc089a3e9d..ed302de2a2f 100644
--- a/src/mame/drivers/epos.c
+++ b/src/mame/drivers/epos.c
@@ -571,9 +571,10 @@ ROM_END
static MACHINE_RESET( dealer )
{
+ UINT8 *rom = memory_region(REGION_CPU1);
counter = 0;
- memory_set_bankptr(1, memory_region(REGION_CPU1));
- memory_set_bankptr(2, ((UINT8*)memory_region(REGION_CPU1)) + 0x6000);
+ memory_set_bankptr(1, rom);
+ memory_set_bankptr(2, rom + 0x6000);
}
static DRIVER_INIT( dealer )
diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c
index 4860a6f721c..64d8daac383 100644
--- a/src/mame/drivers/galaga.c
+++ b/src/mame/drivers/galaga.c
@@ -3085,21 +3085,20 @@ static DRIVER_INIT( xevious )
static DRIVER_INIT( xevios )
{
int A;
+ UINT8 *rom;
/* convert one of the sprite ROMs to the format used by Xevious */
+ rom = memory_region(REGION_GFX3);
for (A = 0x5000;A < 0x7000;A++)
{
- UINT8 *rom = memory_region(REGION_GFX3);
-
rom[A] = BITSWAP8(rom[A],1,3,5,7,0,2,4,6);
}
/* convert one of tile map ROMs to the format used by Xevious */
+ rom = memory_region(REGION_GFX4);
for (A = 0x0000;A < 0x1000;A++)
{
- UINT8 *rom = memory_region(REGION_GFX4);
-
rom[A] = BITSWAP8(rom[A],3,7,5,1,2,6,4,0);
}
diff --git a/src/mame/drivers/harddriv.c b/src/mame/drivers/harddriv.c
index 461987faebf..c4e7dba50ad 100644
--- a/src/mame/drivers/harddriv.c
+++ b/src/mame/drivers/harddriv.c
@@ -3420,11 +3420,15 @@ static void init_ds3(running_machine *machine)
/* if we have a sound DSP, boot it */
if (hdcpu_sound != -1 && machine->config->cpu[hdcpu_sound].type == CPU_ADSP2105)
- adsp2105_load_boot_data((UINT8 *)(memory_region(REGION_CPU1 + hdcpu_sound) + 0x10000),
- (UINT32 *)(memory_region(REGION_CPU1 + hdcpu_sound)));
+ {
+ UINT8 *snd = memory_region(REGION_CPU1 + hdcpu_sound);
+ adsp2105_load_boot_data((UINT8 *)(snd + 0x10000), (UINT32 *)(snd));
+ }
if (hdcpu_sounddsp != -1 && machine->config->cpu[hdcpu_sounddsp].type == CPU_ADSP2105)
- adsp2105_load_boot_data((UINT8 *)(memory_region(REGION_CPU1 + hdcpu_sounddsp) + 0x10000),
- (UINT32 *)(memory_region(REGION_CPU1 + hdcpu_sounddsp)));
+ {
+ UINT8 *dsp = memory_region(REGION_CPU1 + hdcpu_sounddsp);
+ adsp2105_load_boot_data((UINT8 *)(dsp + 0x10000), (UINT32 *)(dsp));
+ }
/*
@@ -3498,6 +3502,8 @@ static void init_ds3(running_machine *machine)
/* COMMON INIT: initialize the DSK add-on board */
static void init_dsk(running_machine *machine)
{
+ UINT8 *usr3 = memory_region(REGION_USER3);
+
/* install ASIC61 */
memory_install_readwrite16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x85c000, 0x85c7ff, 0, 0, hd68k_dsk_dsp32_r, hd68k_dsk_dsp32_w);
@@ -3506,11 +3512,11 @@ static void init_dsk(running_machine *machine)
/* install extra RAM */
memory_install_readwrite16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x900000, 0x90ffff, 0, 0, hd68k_dsk_ram_r, hd68k_dsk_ram_w);
- hddsk_ram = (UINT16 *)(memory_region(REGION_USER3) + 0x40000);
+ hddsk_ram = (UINT16 *)(usr3 + 0x40000);
/* install extra ZRAM */
memory_install_readwrite16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x910000, 0x910fff, 0, 0, hd68k_dsk_zram_r, hd68k_dsk_zram_w);
- hddsk_zram = (UINT16 *)(memory_region(REGION_USER3) + 0x50000);
+ hddsk_zram = (UINT16 *)(usr3 + 0x50000);
/* install ASIC65 */
memory_install_write16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x914000, 0x917fff, 0, 0, asic65_data_w);
@@ -3519,7 +3525,7 @@ static void init_dsk(running_machine *machine)
/* install extra ROM */
memory_install_read16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x940000, 0x9fffff, 0, 0, hd68k_dsk_small_rom_r);
- hddsk_rom = (UINT16 *)(memory_region(REGION_USER3) + 0x00000);
+ hddsk_rom = (UINT16 *)(usr3 + 0x00000);
/* set up the ASIC65 */
asic65_config(machine, ASIC65_STANDARD);
@@ -3529,6 +3535,8 @@ static void init_dsk(running_machine *machine)
/* COMMON INIT: initialize the DSK II add-on board */
static void init_dsk2(running_machine *machine)
{
+ UINT8 *usr3 = memory_region(REGION_USER3);
+
/* install ASIC65 */
memory_install_write16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x824000, 0x824003, 0, 0, asic65_data_w);
memory_install_read16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x824000, 0x824003, 0, 0, asic65_r);
@@ -3542,11 +3550,11 @@ static void init_dsk2(running_machine *machine)
/* install extra RAM */
memory_install_readwrite16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x880000, 0x8bffff, 0, 0, hd68k_dsk_ram_r, hd68k_dsk_ram_w);
- hddsk_ram = (UINT16 *)(memory_region(REGION_USER3) + 0x100000);
+ hddsk_ram = (UINT16 *)(usr3 + 0x100000);
/* install extra ROM */
memory_install_read16_handler(machine, hdcpu_main, ADDRESS_SPACE_PROGRAM, 0x900000, 0x9fffff, 0, 0, hd68k_dsk_rom_r);
- hddsk_rom = (UINT16 *)(memory_region(REGION_USER3) + 0x000000);
+ hddsk_rom = (UINT16 *)(usr3 + 0x000000);
/* set up the ASIC65 */
asic65_config(machine, ASIC65_STANDARD);
diff --git a/src/mame/drivers/hng64.c b/src/mame/drivers/hng64.c
index 75a770231dd..68387d4f485 100644
--- a/src/mame/drivers/hng64.c
+++ b/src/mame/drivers/hng64.c
@@ -1458,6 +1458,7 @@ static INTERRUPT_GEN( irq_start )
static MACHINE_RESET(hyperneo)
{
int i ;
+ const UINT8 *rom = memory_region(REGION_USER2);
/* Sound CPU */
UINT8 *RAM = (UINT8*)hng64_soundram;
@@ -1476,7 +1477,7 @@ static MACHINE_RESET(hyperneo)
/* Fill up virtual memory with ROM */
for (i = 0x0; i < 0x100000; i++)
- hng64_com_virtual_mem[i] = memory_region(REGION_USER2)[i] ;
+ hng64_com_virtual_mem[i] = rom[i] ;
KL5C80_virtual_mem_sync();
memory_set_opbase_handler(2, KL5C80_opbase_handler);
diff --git a/src/mame/drivers/kaneko16.c b/src/mame/drivers/kaneko16.c
index bb4a32db387..5b95d9c4f3d 100644
--- a/src/mame/drivers/kaneko16.c
+++ b/src/mame/drivers/kaneko16.c
@@ -2069,14 +2069,15 @@ static void kaneko16_expand_sample_banks(int region)
possible combinations of these and swap between them.
*/
int bank;
+ UINT8 *src0;
if (memory_region_length(region) < 0x40000 * 16)
fatalerror("gtmr SOUND1 region too small");
/* bank 0 maps to itself, so we just leave it alone */
+ src0 = memory_region(region);
for (bank = 15; bank > 0; bank--)
{
- UINT8 *src0 = memory_region(region);
UINT8 *srcn = src0 + 0x10000 * (bank < 3 ? 3 : bank);
UINT8 *dst = src0 + 0x40000 * bank;
diff --git a/src/mame/drivers/lazercmd.c b/src/mame/drivers/lazercmd.c
index 6ca9464c3e7..303724eb1dc 100644
--- a/src/mame/drivers/lazercmd.c
+++ b/src/mame/drivers/lazercmd.c
@@ -767,6 +767,7 @@ ROM_END
static DRIVER_INIT( lazercmd )
{
int i, y;
+UINT8 *gfx = memory_region(REGION_GFX1);
/******************************************************************
* To show the maze bit #6 and #7 of the video ram are used.
@@ -778,8 +779,8 @@ int i, y;
******************************************************************/
for (i = 0; i < 0x40; i++)
{
-UINT8 *d = &memory_region(REGION_GFX1)[0 * 64 * 10 + i * VERT_CHR];
-UINT8 *s = &memory_region(REGION_GFX1)[4 * 64 * 10 + i * VERT_FNT];
+ UINT8 *d = &gfx[0 * 64 * 10 + i * VERT_CHR];
+ UINT8 *s = &gfx[4 * 64 * 10 + i * VERT_FNT];
for (y = 0; y < VERT_CHR; y++)
{
@@ -795,6 +796,7 @@ UINT8 *s = &memory_region(REGION_GFX1)[4 * 64 * 10 + i * VERT_FNT];
static DRIVER_INIT( medlanes )
{
int i, y;
+UINT8 *gfx = memory_region(REGION_GFX1);
/******************************************************************
* To show the maze bit #6 and #7 of the video ram are used.
@@ -806,8 +808,8 @@ int i, y;
******************************************************************/
for (i = 0; i < 0x40; i++)
{
-UINT8 *d = &memory_region(REGION_GFX1)[0 * 64 * 10 + i * VERT_CHR];
-UINT8 *s = &memory_region(REGION_GFX1)[4 * 64 * 10 + i * VERT_FNT];
+ UINT8 *d = &gfx[0 * 64 * 10 + i * VERT_CHR];
+ UINT8 *s = &gfx[4 * 64 * 10 + i * VERT_FNT];
for (y = 0; y < VERT_CHR; y++)
{
@@ -823,6 +825,7 @@ UINT8 *s = &memory_region(REGION_GFX1)[4 * 64 * 10 + i * VERT_FNT];
static DRIVER_INIT( bbonk )
{
int i, y;
+UINT8 *gfx = memory_region(REGION_GFX1);
/******************************************************************
* To show the maze bit #6 and #7 of the video ram are used.
@@ -834,8 +837,8 @@ int i, y;
******************************************************************/
for (i = 0; i < 0x40; i++)
{
-UINT8 *d = &memory_region(REGION_GFX1)[0 * 64 * 10 + i * VERT_CHR];
-UINT8 *s = &memory_region(REGION_GFX1)[4 * 64 * 10 + i * VERT_FNT];
+ UINT8 *d = &gfx[0 * 64 * 10 + i * VERT_CHR];
+ UINT8 *s = &gfx[4 * 64 * 10 + i * VERT_FNT];
for (y = 0; y < VERT_CHR; y++)
{
diff --git a/src/mame/drivers/megadriv.c b/src/mame/drivers/megadriv.c
index ebcb7cb755a..1e4517423f7 100644
--- a/src/mame/drivers/megadriv.c
+++ b/src/mame/drivers/megadriv.c
@@ -5142,10 +5142,11 @@ static void megadriv_init_common(running_machine *machine)
some games specify a single address, (start 200001, end 200001)
this usually means there is serial eeprom instead */
int i;
+ UINT16 *rom = (UINT16*)memory_region(REGION_CPU1);
+
mame_printf_debug("DEBUG:: Header: Backup RAM string (ignore for games without)\n");
for (i=0;i<12;i++)
{
- UINT16 *rom = (UINT16*)memory_region(REGION_CPU1);
if (i==2) mame_printf_debug("\nstart: ");
if (i==4) mame_printf_debug("\nend : ");
if (i==6) mame_printf_debug("\n");
diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c
index 5cb5980bc2e..b39959719f7 100644
--- a/src/mame/drivers/metro.c
+++ b/src/mame/drivers/metro.c
@@ -4784,7 +4784,7 @@ static DRIVER_INIT( balcube )
const size_t len = memory_region_length(region);
UINT8 *src = memory_region(region);
- UINT8 *end = memory_region(region) + len;
+ UINT8 *end = src + len;
while(src < end)
{
diff --git a/src/mame/drivers/missb2.c b/src/mame/drivers/missb2.c
index 4689cdd4880..7aee66fc7b9 100644
--- a/src/mame/drivers/missb2.c
+++ b/src/mame/drivers/missb2.c
@@ -27,6 +27,7 @@ static VIDEO_UPDATE( missb2 )
int offs;
int sx,sy,xc,yc;
int gfx_num,gfx_attr,gfx_offs;
+ const UINT8 *prom;
const UINT8 *prom_line;
UINT16 bg_offs;
@@ -53,8 +54,9 @@ static VIDEO_UPDATE( missb2 )
sx = 0;
+ prom = memory_region(REGION_PROMS);
for (offs = 0;offs < bublbobl_objectram_size;offs += 4)
- {
+ {
/* skip empty sprites */
/* this is dword aligned so the UINT32 * cast shouldn't give problems */
/* on any architecture */
@@ -63,7 +65,7 @@ static VIDEO_UPDATE( missb2 )
gfx_num = bublbobl_objectram[offs + 1];
gfx_attr = bublbobl_objectram[offs + 3];
- prom_line = memory_region(REGION_PROMS) + 0x80 + ((gfx_num & 0xe0) >> 1);
+ prom_line = prom + 0x80 + ((gfx_num & 0xe0) >> 1);
gfx_offs = ((gfx_num & 0x1f) * 0x80);
if ((gfx_num & 0xa0) == 0xa0)
diff --git a/src/mame/drivers/namcos11.c b/src/mame/drivers/namcos11.c
index c5088c7da55..a3cf5f5dc8e 100644
--- a/src/mame/drivers/namcos11.c
+++ b/src/mame/drivers/namcos11.c
@@ -816,6 +816,8 @@ static DRIVER_INIT( namcos11 )
if( namcos11_config_table[ n_game ].n_daughterboard != 0 )
{
int bank;
+ UINT32 len = memory_region_length( REGION_USER2 );
+ UINT8 *rgn = memory_region( REGION_USER2 );
memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1f000000, 0x1f0fffff, 0, 0, SMH_BANK1 );
memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1f100000, 0x1f1fffff, 0, 0, SMH_BANK2 );
@@ -828,7 +830,7 @@ static DRIVER_INIT( namcos11 )
for( bank = 0; bank < 8; bank++ )
{
- memory_configure_bank( bank + 1, 0, memory_region_length( REGION_USER2 ) / ( 1024 * 1024 ), memory_region( REGION_USER2 ), 1024 * 1024 );
+ memory_configure_bank( bank + 1, 0, len / ( 1024 * 1024 ), rgn, 1024 * 1024 );
memory_set_bank( bank + 1, 0 );
}
diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c
index 7f088a68934..846c1ecc8c7 100644
--- a/src/mame/drivers/neogeo.c
+++ b/src/mame/drivers/neogeo.c
@@ -767,6 +767,7 @@ static void audio_cpu_banking_init(running_machine *machine)
{
int region;
int bank;
+ UINT8 *rgn;
UINT32 address_mask;
/* audio bios/cartridge selection */
@@ -777,12 +778,13 @@ static void audio_cpu_banking_init(running_machine *machine)
/* audio banking */
address_mask = memory_region_length(NEOGEO_REGION_AUDIO_CPU_CARTRIDGE) - 0x10000 - 1;
+ rgn = memory_region(NEOGEO_REGION_AUDIO_CPU_CARTRIDGE);
for (region = 0; region < 4; region++)
{
for (bank = 0; bank < 0x100; bank++)
{
UINT32 bank_address = 0x10000 + (((bank << (11 + region)) & 0x3ffff) & address_mask);
- memory_configure_bank(NEOGEO_BANK_AUDIO_CPU_CART_BANK + region, bank, 1, &memory_region(NEOGEO_REGION_AUDIO_CPU_CARTRIDGE)[bank_address], 0);
+ memory_configure_bank(NEOGEO_BANK_AUDIO_CPU_CART_BANK + region, bank, 1, &rgn[bank_address], 0);
}
}
diff --git a/src/mame/drivers/pasha2.c b/src/mame/drivers/pasha2.c
index 63808dd769d..1df056108ac 100644
--- a/src/mame/drivers/pasha2.c
+++ b/src/mame/drivers/pasha2.c
@@ -93,12 +93,13 @@ static WRITE16_HANDLER( pasha2_misc_w )
switch(bank)
{
- case 0x8000: memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400000 * 0); break;
- case 0x9000: memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400000 * 1); break;
- case 0xa000: memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400000 * 2); break;
- case 0xb000: memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400000 * 3); break;
- case 0xc000: memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400000 * 4); break;
- case 0xd000: memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400000 * 5); break;
+ case 0x8000:
+ case 0x9000:
+ case 0xa000:
+ case 0xb000:
+ case 0xc000:
+ case 0xd000:
+ memory_set_bankptr(1, memory_region(REGION_USER2) + 0x400 * (bank - 0x8000)); break;
}
}
}
diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c
index fe122518772..e735618a987 100644
--- a/src/mame/drivers/pgm.c
+++ b/src/mame/drivers/pgm.c
@@ -1935,9 +1935,9 @@ static WRITE16_HANDLER( killbld_prot_w )
/* for now, cheat -- the scramble isn't understood, it might
be state based */
int x;
+ UINT16 *RAMDUMP = (UINT16*)memory_region(REGION_USER2);
for (x=0;x<size;x++)
{
- UINT16 *RAMDUMP = (UINT16*)memory_region(REGION_USER2);
UINT16 dat;
dat = RAMDUMP[dst+x];
@@ -1948,10 +1948,10 @@ static WRITE16_HANDLER( killbld_prot_w )
{
/* mode 5 seems to be a straight copy */
int x;
+ UINT16 *RAMDUMP = (UINT16*)memory_region(REGION_USER2);
+ UINT16 *PROTROM = (UINT16*)memory_region(REGION_USER1);
for (x=0;x<size;x++)
{
- UINT16 *RAMDUMP = (UINT16*)memory_region(REGION_USER2);
- UINT16 *PROTROM = (UINT16*)memory_region(REGION_USER1);
UINT16 dat;
dat = PROTROM[src+x];
@@ -1965,10 +1965,10 @@ static WRITE16_HANDLER( killbld_prot_w )
{
/* mode 6 seems to swap bytes and nibbles */
int x;
+ UINT16 *RAMDUMP = (UINT16*)memory_region(REGION_USER2);
+ UINT16 *PROTROM = (UINT16*)memory_region(REGION_USER1);
for (x=0;x<size;x++)
{
- UINT16 *RAMDUMP = (UINT16*)memory_region(REGION_USER2);
- UINT16 *PROTROM = (UINT16*)memory_region(REGION_USER1);
UINT16 dat;
dat = PROTROM[src+x];
diff --git a/src/mame/drivers/segaorun.c b/src/mame/drivers/segaorun.c
index 9314bbdf8bf..6e05bb3c644 100644
--- a/src/mame/drivers/segaorun.c
+++ b/src/mame/drivers/segaorun.c
@@ -57,9 +57,6 @@ static const UINT8 *custom_map;
*
*************************************/
-extern void fd1094_machine_init(void);
-extern void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(UINT8 *));
-
static READ16_HANDLER( misc_io_r );
static WRITE16_HANDLER( misc_io_w );
diff --git a/src/mame/drivers/segas16a.c b/src/mame/drivers/segas16a.c
index 0d8be7e5da0..f146678b0b6 100644
--- a/src/mame/drivers/segas16a.c
+++ b/src/mame/drivers/segas16a.c
@@ -179,9 +179,6 @@ static UINT32 n7751_rom_address;
*
*************************************/
-extern void fd1094_machine_init(void);
-extern void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(UINT8 *));
-
static READ16_HANDLER( misc_io_r );
static WRITE16_HANDLER( misc_io_w );
diff --git a/src/mame/drivers/segas16b.c b/src/mame/drivers/segas16b.c
index ba63d74c179..a5dbded1407 100644
--- a/src/mame/drivers/segas16b.c
+++ b/src/mame/drivers/segas16b.c
@@ -929,9 +929,6 @@ static const UINT8 *i8751_initial_config;
*
*************************************/
-extern void fd1094_machine_init(void);
-extern void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(UINT8 *));
-
static READ16_HANDLER( misc_io_r );
static WRITE16_HANDLER( misc_io_w );
static WRITE16_HANDLER( rom_5704_bank_w );
diff --git a/src/mame/drivers/segas18.c b/src/mame/drivers/segas18.c
index e9a4f63ec6f..7978a2bebea 100644
--- a/src/mame/drivers/segas18.c
+++ b/src/mame/drivers/segas18.c
@@ -75,9 +75,6 @@ static UINT8 lghost_value, lghost_select;
*
*************************************/
-extern void fd1094_machine_init(void);
-extern void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(UINT8 *));
-
static READ16_HANDLER( misc_io_r );
static WRITE16_HANDLER( misc_io_w );
static WRITE16_HANDLER( rom_5987_bank_w );
diff --git a/src/mame/drivers/segaxbd.c b/src/mame/drivers/segaxbd.c
index d13e2b17910..b212e6ccb2e 100644
--- a/src/mame/drivers/segaxbd.c
+++ b/src/mame/drivers/segaxbd.c
@@ -56,17 +56,6 @@ static UINT16 *backupram1, *backupram2;
/*************************************
*
- * Prototypes
- *
- *************************************/
-
-extern void fd1094_machine_init(void);
-extern void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(UINT8 *));
-
-
-
-/*************************************
- *
* Configuration
*
*************************************/
diff --git a/src/mame/drivers/ssingles.c b/src/mame/drivers/ssingles.c
index bd06183c235..78e8954fb49 100644
--- a/src/mame/drivers/ssingles.c
+++ b/src/mame/drivers/ssingles.c
@@ -52,6 +52,7 @@ static MC6845_UPDATE_ROW( update_row )
UINT32 tile_address;
UINT16 cell,palette;
UINT8 b0,b1;
+ const UINT8 *gfx = memory_region(REGION_GFX1);
for(cx=0;cx<x_count;++cx)
{
@@ -64,13 +65,13 @@ static MC6845_UPDATE_ROW( update_row )
if(cx&1)
{
- b0=memory_region(REGION_GFX1)[tile_address+0x0000]; /* 9.bin */
- b1=memory_region(REGION_GFX1)[tile_address+0x8000]; /* 11.bin */
+ b0=gfx[tile_address+0x0000]; /* 9.bin */
+ b1=gfx[tile_address+0x8000]; /* 11.bin */
}
else
{
- b0=memory_region(REGION_GFX1)[tile_address+0x4000]; /* 10.bin */
- b1=memory_region(REGION_GFX1)[tile_address+0xc000]; /* 12.bin */
+ b0=gfx[tile_address+0x4000]; /* 10.bin */
+ b1=gfx[tile_address+0xc000]; /* 12.bin */
}
for(x=7;x>=0;--x)
diff --git a/src/mame/drivers/starwars.c b/src/mame/drivers/starwars.c
index 69e844e90ab..d642d0bac41 100644
--- a/src/mame/drivers/starwars.c
+++ b/src/mame/drivers/starwars.c
@@ -566,13 +566,15 @@ static DRIVER_INIT( starwars )
static DRIVER_INIT( esb )
{
+ UINT8 *rom = memory_region(REGION_CPU1);
+
/* X2212 nvram */
generic_nvram = auto_malloc(generic_nvram_size);
/* init the slapstic */
slapstic_init(machine, 101);
- slapstic_source = &memory_region(REGION_CPU1)[0x14000];
- slapstic_base = &memory_region(REGION_CPU1)[0x08000];
+ slapstic_source = &rom[0x14000];
+ slapstic_base = &rom[0x08000];
/* install an opcode base handler */
memory_set_opbase_handler(0, esb_setopbase);
@@ -588,9 +590,9 @@ static DRIVER_INIT( esb )
starwars_mproc_init();
/* initialize banking */
- memory_configure_bank(1, 0, 2, memory_region(REGION_CPU1) + 0x6000, 0x10000 - 0x6000);
+ memory_configure_bank(1, 0, 2, rom + 0x6000, 0x10000 - 0x6000);
memory_set_bank(1, 0);
- memory_configure_bank(2, 0, 2, memory_region(REGION_CPU1) + 0xa000, 0x1c000 - 0xa000);
+ memory_configure_bank(2, 0, 2, rom + 0xa000, 0x1c000 - 0xa000);
memory_set_bank(2, 0);
/* additional globals for state saving */
diff --git a/src/mame/drivers/tmnt.c b/src/mame/drivers/tmnt.c
index 22342318a25..d3fc747326b 100644
--- a/src/mame/drivers/tmnt.c
+++ b/src/mame/drivers/tmnt.c
@@ -4037,6 +4037,7 @@ static DRIVER_INIT( mia )
static DRIVER_INIT( tmnt )
{
UINT8 *gfxdata;
+ const UINT8 *code_conv_table;
int len;
int i,j,k,A,B,entry;
int bits[32];
@@ -4089,9 +4090,9 @@ static DRIVER_INIT( tmnt )
temp = malloc_or_die(len);
memcpy(temp,gfxdata,len);
+ code_conv_table = &memory_region(REGION_PROMS)[0x0000];
for (A = 0;A < len/4;A++)
{
- UINT8 *code_conv_table = &memory_region(REGION_PROMS)[0x0000];
#define CA0 0
#define CA1 1
#define CA2 2
diff --git a/src/mame/drivers/tnzs.c b/src/mame/drivers/tnzs.c
index a6edb60d8fe..394f6b13bb8 100644
--- a/src/mame/drivers/tnzs.c
+++ b/src/mame/drivers/tnzs.c
@@ -270,9 +270,9 @@ static void kageki_init_samples(void)
int start, size;
int i, n;
+ src = memory_region(REGION_SOUND1) + 0x0090;
for (i = 0; i < MAX_SAMPLES; i++)
{
- src = memory_region(REGION_SOUND1) + 0x0090;
start = (src[(i * 2) + 1] * 256) + src[(i * 2)];
scan = &src[start];
size = 0;
diff --git a/src/mame/drivers/wheelfir.c b/src/mame/drivers/wheelfir.c
index 74d3dc9cac9..0939a790ba3 100644
--- a/src/mame/drivers/wheelfir.c
+++ b/src/mame/drivers/wheelfir.c
@@ -290,7 +290,7 @@ static int wheelfir_palpos = 0;
/* Press R to show a page of gfx, Q / E to move between pages, and W to clear the framebuffer */
static VIDEO_UPDATE(wheelfir)
{
- /*
+#if 0
int x,y;
static int base = 0;
@@ -310,6 +310,7 @@ static VIDEO_UPDATE(wheelfir)
if ( input_code_pressed(KEYCODE_R) )
{
+ const UINT8 *gfx = memory_region(REGION_GFX1);
for (y=0;y<128;y++)
{
for (x=0;x<512;x++)
@@ -319,13 +320,13 @@ static VIDEO_UPDATE(wheelfir)
romoffs = base+y*512+x;
- romdata = memory_region(REGION_GFX1)[romoffs];
+ romdata = gfx[romoffs];
*BITMAP_ADDR16(bitmap, y, x) = romdata;
}
}
}
- */
+#endif
copybitmap(bitmap, render_bitmap, 0, 0, 0, 0, cliprect);
copybitmap_trans(bitmap, wheelfir_tmp_bitmap[0], 0, 0, 0, 0, cliprect, 0);
@@ -343,7 +344,7 @@ static VIDEO_UPDATE(wheelfir)
palette_set_color(screen->machine,x/3,MAKE_RGB(r,g,b));
}
}
-/*
+#if 0
{
FILE* fp;
fp=fopen("wheelfir_pal.dmp", "w+b");
@@ -353,7 +354,7 @@ static VIDEO_UPDATE(wheelfir)
fclose(fp);
}
}
-*/
+#endif
return 0;
}
diff --git a/src/mame/includes/system16.h b/src/mame/includes/system16.h
index 42390459099..49d0036ca32 100644
--- a/src/mame/includes/system16.h
+++ b/src/mame/includes/system16.h
@@ -81,6 +81,12 @@ extern int sys16_sprite_quartet2( struct sys16_sprite_attributes *sprite, const
#define NumOfShadowColors 32
#define ShadowColorsMultiplier 2
+/*----------- defined in machine/s16fd.c -----------*/
+
+void *fd1094_get_decrypted_base(void);
+void fd1094_machine_init(void);
+void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(UINT8 *));
+
/*----------- defined in machine/system16.c -----------*/
extern UINT16 *sys16_workingram;
diff --git a/src/mame/machine/jackal.c b/src/mame/machine/jackal.c
index 2eb15de4272..76e0f3a3e88 100644
--- a/src/mame/machine/jackal.c
+++ b/src/mame/machine/jackal.c
@@ -19,13 +19,15 @@ static UINT8 *jackal_spritebank = 0;
MACHINE_RESET( jackal )
{
+ UINT8 *rgn = memory_region(REGION_CPU1);
+
// HACK: running at the nominal clock rate, music stops working
// at the beginning of the game. This fixes it.
cpunum_set_clockscale(machine, 1, 1.2f);
- memory_set_bankptr(1,&((memory_region(REGION_CPU1))[0x4000]));
- jackal_rambank = &((memory_region(REGION_CPU1))[0]);
- jackal_spritebank = &((memory_region(REGION_CPU1))[0]);
+ memory_set_bankptr(1,&rgn[0x4000]);
+ jackal_rambank = rgn;
+ jackal_spritebank = rgn;
}
@@ -50,12 +52,14 @@ READ8_HANDLER( jackal_spriteram_r )
WRITE8_HANDLER( jackal_rambank_w )
{
-if (data & 0x04) popmessage("jackal_rambank_w %02x",data);
+ UINT8 *rgn = memory_region(REGION_CPU1);
+
+ if (data & 0x04) popmessage("jackal_rambank_w %02x",data);
coin_counter_w(0,data & 0x01);
coin_counter_w(1,data & 0x02);
- jackal_spritebank = &((memory_region(REGION_CPU1))[((data & 0x08) << 13)]);
- jackal_rambank = &((memory_region(REGION_CPU1))[((data & 0x10) << 12)]);
- memory_set_bankptr(1,&((memory_region(REGION_CPU1))[((data & 0x20) << 11) + 0x4000]));
+ jackal_spritebank = &rgn[((data & 0x08) << 13)];
+ jackal_rambank = &rgn[((data & 0x10) << 12)];
+ memory_set_bankptr(1,&rgn[((data & 0x20) << 11) + 0x4000]);
}
diff --git a/src/mame/machine/s16fd.c b/src/mame/machine/s16fd.c
index 81c2991f519..343f4c60194 100644
--- a/src/mame/machine/s16fd.c
+++ b/src/mame/machine/s16fd.c
@@ -12,6 +12,7 @@ make more configurable (select caches per game?)
#include "cpu/m68000/m68000.h"
#include "machine/fd1094.h"
+#include "includes/system16.h"
#define CACHE_ENTRIES 8
diff --git a/src/mame/machine/scramble.c b/src/mame/machine/scramble.c
index a14bd6eff76..8b0d7f17dda 100644
--- a/src/mame/machine/scramble.c
+++ b/src/mame/machine/scramble.c
@@ -695,6 +695,7 @@ DRIVER_INIT( losttomb )
DRIVER_INIT( hustler )
{
offs_t A;
+ UINT8 *rom = memory_region(REGION_CPU1);
for (A = 0;A < 0x4000;A++)
@@ -702,7 +703,6 @@ DRIVER_INIT( hustler )
UINT8 xormask;
int bits[8];
int i;
- UINT8 *rom = memory_region(REGION_CPU1);
for (i = 0;i < 8;i++)
@@ -723,7 +723,7 @@ DRIVER_INIT( hustler )
/* the first ROM of the second CPU has data lines D0 and D1 swapped. Decode it. */
{
- UINT8 *rom = memory_region(REGION_CPU2);
+ rom = memory_region(REGION_CPU2);
for (A = 0;A < 0x0800;A++)
@@ -734,6 +734,7 @@ DRIVER_INIT( hustler )
DRIVER_INIT( billiard )
{
offs_t A;
+ UINT8 *rom = memory_region(REGION_CPU1);
for (A = 0;A < 0x4000;A++)
@@ -741,7 +742,6 @@ DRIVER_INIT( billiard )
UINT8 xormask;
int bits[8];
int i;
- UINT8 *rom = memory_region(REGION_CPU1);
for (i = 0;i < 8;i++)
@@ -764,7 +764,7 @@ DRIVER_INIT( billiard )
/* the first ROM of the second CPU has data lines D0 and D1 swapped. Decode it. */
{
- UINT8 *rom = memory_region(REGION_CPU2);
+ rom = memory_region(REGION_CPU2);
for (A = 0;A < 0x0800;A++)
diff --git a/src/mame/machine/segaic16.c b/src/mame/machine/segaic16.c
index 587d09907b6..6afa95ea83b 100644
--- a/src/mame/machine/segaic16.c
+++ b/src/mame/machine/segaic16.c
@@ -7,10 +7,8 @@
#include "driver.h"
#include "segaic16.h"
#include "video/resnet.h"
-
-extern void *fd1089_get_decrypted_base(void);
-extern void fd1094_machine_init(void);
-extern void *fd1094_get_decrypted_base(void);
+#include "machine/fd1089.h"
+#include "includes/system16.h"
/*************************************
diff --git a/src/mame/machine/segas32.c b/src/mame/machine/segas32.c
index 4c9f62e101d..8a1bbc51fd3 100644
--- a/src/mame/machine/segas32.c
+++ b/src/mame/machine/segas32.c
@@ -133,8 +133,9 @@ WRITE16_HANDLER(sonic_level_load_protection)
}
else
{
- level = *((memory_region(REGION_CPU1) + LEVEL_ORDER_ARRAY) + (system32_workram[CLEARED_LEVELS / 2] * 2) - 1);
- level |= *((memory_region(REGION_CPU1) + LEVEL_ORDER_ARRAY) + (system32_workram[CLEARED_LEVELS / 2] * 2) - 2) << 8;
+ const UINT8 *ROM = memory_region(REGION_CPU1);
+ level = *((ROM + LEVEL_ORDER_ARRAY) + (system32_workram[CLEARED_LEVELS / 2] * 2) - 1);
+ level |= *((ROM + LEVEL_ORDER_ARRAY) + (system32_workram[CLEARED_LEVELS / 2] * 2) - 2) << 8;
}
system32_workram[CURRENT_LEVEL / 2] = level;
diff --git a/src/mame/video/btime.c b/src/mame/video/btime.c
index c67bb16c4e1..08ac0b453af 100644
--- a/src/mame/video/btime.c
+++ b/src/mame/video/btime.c
@@ -408,7 +408,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8* tmap, UINT8 color)
{
int i;
-
+ const UINT8 *gfx = memory_region(REGION_GFX3);
int scroll = -(bnj_scroll2 | ((bnj_scroll1 & 0x03) << 8));
// One extra iteration for wrap around
@@ -433,7 +433,7 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re
}
drawgfx(bitmap, machine->gfx[2],
- memory_region(REGION_GFX3)[tileoffset + offs],
+ gfx[tileoffset + offs],
color,
flip_screen_get(),flip_screen_get(),
x,y,
diff --git a/src/mame/video/bublbobl.c b/src/mame/video/bublbobl.c
index 3b7cfc63fcc..22fd6e9b6b5 100644
--- a/src/mame/video/bublbobl.c
+++ b/src/mame/video/bublbobl.c
@@ -21,6 +21,7 @@ VIDEO_UPDATE( bublbobl )
int offs;
int sx,sy,xc,yc;
int gfx_num,gfx_attr,gfx_offs;
+ const UINT8 *prom;
const UINT8 *prom_line;
@@ -35,8 +36,9 @@ VIDEO_UPDATE( bublbobl )
sx = 0;
+ prom = memory_region(REGION_PROMS);
for (offs = 0;offs < bublbobl_objectram_size;offs += 4)
- {
+ {
/* skip empty sprites */
/* this is dword aligned so the UINT32 * cast shouldn't give problems */
/* on any architecture */
@@ -45,7 +47,7 @@ VIDEO_UPDATE( bublbobl )
gfx_num = bublbobl_objectram[offs + 1];
gfx_attr = bublbobl_objectram[offs + 3];
- prom_line = memory_region(REGION_PROMS) + 0x80 + ((gfx_num & 0xe0) >> 1);
+ prom_line = prom + 0x80 + ((gfx_num & 0xe0) >> 1);
gfx_offs = ((gfx_num & 0x1f) * 0x80);
if ((gfx_num & 0xa0) == 0xa0)
diff --git a/src/mame/video/buggychl.c b/src/mame/video/buggychl.c
index 18eb56399fc..7847de93ce6 100644
--- a/src/mame/video/buggychl.c
+++ b/src/mame/video/buggychl.c
@@ -167,9 +167,11 @@ static void draw_fg(running_machine *machine, bitmap_t *bitmap, const rectangle
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
int offs;
+ const UINT8 *gfx;
profiler_mark(PROFILER_USER1);
+ gfx = memory_region(REGION_GFX2);
for (offs = 0;offs < spriteram_size;offs += 4)
{
int sx,sy,flipy,zoom,ch,x,px,y;
@@ -181,8 +183,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
sy = 256-64 - spriteram[offs] + ((spriteram[offs+1] & 0x80) << 1);
flipy = spriteram[offs+1] & 0x40;
zoom = spriteram[offs+1] & 0x3f;
- zoomy_rom = memory_region(REGION_GFX2) + (zoom << 6);
- zoomx_rom = memory_region(REGION_GFX2) + 0x2000 + (zoom << 3);
+ zoomy_rom = gfx + (zoom << 6);
+ zoomx_rom = gfx + 0x2000 + (zoom << 3);
lookup = buggychl_sprite_lookup + ((spriteram[offs+2] & 0x7f) << 6);
diff --git a/src/mame/video/crgolf.c b/src/mame/video/crgolf.c
index 1efa343d2c8..2fd9edf906d 100644
--- a/src/mame/video/crgolf.c
+++ b/src/mame/video/crgolf.c
@@ -64,12 +64,13 @@ READ8_HANDLER( crgolf_videoram_r )
static void get_pens(pen_t *pens)
{
offs_t offs;
+ const UINT8 *prom = memory_region(REGION_PROMS);
for (offs = 0; offs < NUM_PENS; offs++)
{
int bit0, bit1, bit2, r, g, b;
- UINT8 data = memory_region(REGION_PROMS)[offs];
+ UINT8 data = prom[offs];
/* red component */
bit0 = (data >> 0) & 0x01;
diff --git a/src/mame/video/deniam.c b/src/mame/video/deniam.c
index e0cd65560b7..a8acf4b9c9a 100644
--- a/src/mame/video/deniam.c
+++ b/src/mame/video/deniam.c
@@ -204,12 +204,12 @@ WRITE16_HANDLER( deniam_coinctrl_w )
static void draw_sprites(bitmap_t *bitmap, const rectangle *cliprect)
{
int offs;
+ UINT8 *gfx = memory_region(REGION_GFX2);
for (offs = spriteram_size/2-8;offs >= 0;offs -= 8)
{
int sx,starty,endy,x,y,start,color,width,flipx,primask;
- UINT8 *rom = memory_region(REGION_GFX2);
-
+ UINT8 *rom = gfx;
sx = (spriteram16[offs+1] & 0x01ff) + 16*8 - 1;
if (sx >= 512) sx -= 512;
diff --git a/src/mame/video/exerion.c b/src/mame/video/exerion.c
index 7b8897a98c6..65d78711e1c 100644
--- a/src/mame/video/exerion.c
+++ b/src/mame/video/exerion.c
@@ -117,6 +117,7 @@ PALETTE_INIT( exerion )
VIDEO_START( exerion )
{
int i;
+ UINT8 *gfx;
/* get pointers to the mixing and lookup PROMs */
background_mixer = memory_region(REGION_PROMS) + 0x320;
@@ -142,11 +143,12 @@ VIDEO_START( exerion )
* Where AA,BB,CC,DD are the 2bpp data for the pixel,and a,b,c,d are the OR
* of these two bits together.
*/
+ gfx = memory_region(REGION_GFX3);
for (i = 0; i < 4; i++)
{
int y;
- UINT8 *src = memory_region(REGION_GFX3) + i * 0x2000;
+ UINT8 *src = gfx + i * 0x2000;
UINT16 *dst = background_gfx[i];
for (y = 0; y < 0x100; y++)
diff --git a/src/mame/video/gridlee.c b/src/mame/video/gridlee.c
index 870a9bd49af..c363151b8cd 100644
--- a/src/mame/video/gridlee.c
+++ b/src/mame/video/gridlee.c
@@ -129,6 +129,7 @@ WRITE8_HANDLER( gridlee_palette_select_w )
VIDEO_UPDATE( gridlee )
{
const pen_t *pens = &screen->machine->pens[palettebank_vis * 32];
+ UINT8 *gfx;
int x, y, i;
/* draw scanlines from the VRAM directly */
@@ -152,6 +153,7 @@ VIDEO_UPDATE( gridlee )
}
/* draw the sprite images */
+ gfx = memory_region(REGION_GFX1);
for (i = 0; i < 32; i++)
{
UINT8 *sprite = spriteram + i * 4;
@@ -161,7 +163,7 @@ VIDEO_UPDATE( gridlee )
int xpos = sprite[3];
/* get a pointer to the source image */
- src = &memory_region(REGION_GFX1)[64 * image];
+ src = &gfx[64 * image];
/* loop over y */
for (y = 0; y < 16; y++, ypos = (ypos + 1) & 255)
diff --git a/src/mame/video/jedi.c b/src/mame/video/jedi.c
index 8675142dc45..122ee38f120 100644
--- a/src/mame/video/jedi.c
+++ b/src/mame/video/jedi.c
@@ -236,6 +236,7 @@ static void draw_sprites(jedi_state *state, bitmap_t *bitmap, const rectangle *c
{
offs_t offs;
UINT8 *spriteram = state->spriteram;
+ UINT8 *gfx3 = memory_region(REGION_GFX3);
for (offs = 0x00; offs < 0x30; offs++)
{
@@ -265,7 +266,7 @@ static void draw_sprites(jedi_state *state, bitmap_t *bitmap, const rectangle *c
else
y_size = 0x10;
- gfx = &memory_region(REGION_GFX3)[code << 5];
+ gfx = &gfx3[code << 5];
if (flip_y)
y = y + y_size - 1;
diff --git a/src/mame/video/ksayakyu.c b/src/mame/video/ksayakyu.c
index 2da94f2ae78..59198addb26 100644
--- a/src/mame/video/ksayakyu.c
+++ b/src/mame/video/ksayakyu.c
@@ -33,11 +33,12 @@ WRITE8_HANDLER(ksayakyu_videoctrl_w)
PALETTE_INIT( ksayakyu )
{
int i,j,b1,b2;
+ const UINT8 *prom = memory_region(REGION_PROMS);
for(j=0;j<16;j++)
for(i=0;i<8;i++)
{
- b1=memory_region(REGION_PROMS)[j*16+i];
- b2=memory_region(REGION_PROMS)[j*16+i+8];
+ b1=prom[j*16+i];
+ b2=prom[j*16+i+8];
b1=b2|(b1<<8);
palette_set_color_rgb(machine,j*8+i,pal5bit(b1 >> 10),pal5bit(b1 >> 0),pal5bit(b1 >> 5));
diff --git a/src/mame/video/m107.c b/src/mame/video/m107.c
index cfb304d4727..800c3edc0c6 100644
--- a/src/mame/video/m107.c
+++ b/src/mame/video/m107.c
@@ -156,6 +156,7 @@ VIDEO_START( m107 )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
{
int offs;
+ UINT8 *rom = memory_region(REGION_USER1);
for (offs = 0x800-4;offs >= 0;offs -= 4)
{
@@ -201,7 +202,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
}
else
{
- UINT8 *rom = memory_region(REGION_USER1);
int rom_offs = sprite*8;
if (rom[rom_offs+1] || rom[rom_offs+3] || rom[rom_offs+5] || rom[rom_offs+7])
diff --git a/src/mame/video/n8080.c b/src/mame/video/n8080.c
index 3e62f6fd24b..2f7792dd825 100644
--- a/src/mame/video/n8080.c
+++ b/src/mame/video/n8080.c
@@ -157,6 +157,7 @@ VIDEO_UPDATE( spacefev )
int y;
const UINT8* pRAM = videoram;
+ const UINT8* pPROM = memory_region(REGION_PROMS);
for (y = 0; y < 256; y++)
{
@@ -174,7 +175,7 @@ VIDEO_UPDATE( spacefev )
}
else
{
- UINT8 val = memory_region(REGION_PROMS)[x >> 3];
+ UINT8 val = pPROM[x >> 3];
if ((x >> 3) == 0x06)
{
diff --git a/src/mame/video/namcos22.c b/src/mame/video/namcos22.c
index ba7f9ab6d2e..6c1b29c6cc4 100644
--- a/src/mame/video/namcos22.c
+++ b/src/mame/video/namcos22.c
@@ -636,8 +636,8 @@ ApplyGamma( bitmap_t *bitmap )
else
{ /* system 22 */
const UINT8 *rlut = 0x000+(const UINT8 *)memory_region(REGION_USER1);
- const UINT8 *glut = 0x100+(const UINT8 *)memory_region(REGION_USER1);
- const UINT8 *blut = 0x200+(const UINT8 *)memory_region(REGION_USER1);
+ const UINT8 *glut = 0x100+rlut;
+ const UINT8 *blut = 0x200+rlut;
for( y=0; y<bitmap->height; y++ )
{
UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
diff --git a/src/mame/video/neogeo.c b/src/mame/video/neogeo.c
index ac648201904..65eade6ea28 100644
--- a/src/mame/video/neogeo.c
+++ b/src/mame/video/neogeo.c
@@ -702,9 +702,10 @@ static void optimize_sprite_data(void)
power of 2 */
sprite_gfx_address_mask = 0xffffffff;
+ len = memory_region_length(NEOGEO_REGION_SPRITES);
for (bit = 0x80000000; bit != 0; bit >>= 1)
{
- if (((memory_region_length(NEOGEO_REGION_SPRITES) * 2) - 1) & bit)
+ if (((len * 2) - 1) & bit)
break;
sprite_gfx_address_mask >>= 1;
@@ -714,7 +715,6 @@ 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 < len; i += 0x80, src += 0x80)
diff --git a/src/mame/video/polepos.c b/src/mame/video/polepos.c
index aede53bc9d0..71a6e8903e6 100644
--- a/src/mame/video/polepos.c
+++ b/src/mame/video/polepos.c
@@ -355,8 +355,8 @@ WRITE8_HANDLER( polepos_alpha_w )
static void draw_road(bitmap_t *bitmap)
{
const UINT8 *road_control = memory_region(REGION_GFX5);
- const UINT8 *road_bits1 = memory_region(REGION_GFX5) + 0x2000;
- const UINT8 *road_bits2 = memory_region(REGION_GFX5) + 0x4000;
+ const UINT8 *road_bits1 = road_control + 0x2000;
+ const UINT8 *road_bits2 = road_control + 0x4000;
int x, y, i;
/* loop over the lower half of the screen */
diff --git a/src/mame/video/redalert.c b/src/mame/video/redalert.c
index 22a9116fe87..bd88867f7bf 100644
--- a/src/mame/video/redalert.c
+++ b/src/mame/video/redalert.c
@@ -76,6 +76,7 @@ static void get_pens(pen_t *pens)
double charmap_b_weights[2];
double back_r_weight[1];
double back_gb_weight[1];
+ const UINT8 *prom = memory_region(REGION_PROMS);
scaler = compute_resistor_weights(0, 0xff, -1,
1, resistances_bitmap, bitmap_weight, 470, 0,
@@ -90,7 +91,7 @@ static void get_pens(pen_t *pens)
/* the character layer colors come from the PROM */
for (offs = 0; offs < NUM_CHARMAP_PENS; offs++)
{
- UINT8 data = memory_region(REGION_PROMS)[offs];
+ UINT8 data = prom[offs];
/* very strange mapping */
UINT8 r0_bit = (data >> 2) & 0x01;
diff --git a/src/mame/video/rollrace.c b/src/mame/video/rollrace.c
index 6afb50b8ab5..51ab94e175a 100644
--- a/src/mame/video/rollrace.c
+++ b/src/mame/video/rollrace.c
@@ -64,6 +64,7 @@ VIDEO_UPDATE( rollrace )
int sx, sy;
int scroll;
int col;
+ const UINT8 *mem = memory_region(REGION_USER1);
/* fill in background colour*/
fillbitmap(bitmap,ra_bkgpen,cliprect);
@@ -88,8 +89,8 @@ VIDEO_UPDATE( rollrace )
drawgfx(bitmap,
screen->machine->gfx[RA_BGCHAR_BASE],
- memory_region(REGION_USER1)[offs + ( ra_bkgpage * 1024 )] \
- + ((( memory_region(REGION_USER1)[offs + 0x4000 + ( ra_bkgpage * 1024 )] & 0xc0 ) >> 6 ) * 256 ) ,
+ mem[offs + ( ra_bkgpage * 1024 )] \
+ + ((( mem[offs + 0x4000 + ( ra_bkgpage * 1024 )] & 0xc0 ) >> 6 ) * 256 ) ,
ra_bkgcol,
ra_flipx,(ra_bkgflip^ra_flipy),
sx*8,sy*8,
diff --git a/src/mame/video/spacefb.c b/src/mame/video/spacefb.c
index 18bb120e6cf..dbe750e7907 100644
--- a/src/mame/video/spacefb.c
+++ b/src/mame/video/spacefb.c
@@ -218,12 +218,12 @@ static void draw_starfield(const device_config *screen, bitmap_t *bitmap, const
static void get_sprite_pens(pen_t *pens)
{
static const double fade_weights[] = { 1.0, 1.5, 2.5, 4.0 };
-
+ const UINT8 *prom = memory_region(REGION_PROMS);
int i;
for (i = 0; i < NUM_SPRITE_PENS; i++)
{
- UINT8 data = memory_region(REGION_PROMS)[((port_0 & 0x40) >> 2) | (i & 0x0f)];
+ UINT8 data = prom[((port_0 & 0x40) >> 2) | (i & 0x0f)];
UINT8 r0 = (data >> 0) & 0x01;
UINT8 r1 = (data >> 1) & 0x01;
diff --git a/src/mame/video/st0016.c b/src/mame/video/st0016.c
index fb675f58ff4..a7016604049 100644
--- a/src/mame/video/st0016.c
+++ b/src/mame/video/st0016.c
@@ -191,12 +191,13 @@ WRITE8_HANDLER(st0016_vregs_w)
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);
+ UINT8 *mem = memory_region(REGION_CPU1);
while(length>0)
{
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]);
+ st0016_character_ram_w(machine,dstadr&0x1f,mem[0x10000+srcadr]);
srcadr++;
dstadr++;
length--;
diff --git a/src/mame/video/strnskil.c b/src/mame/video/strnskil.c
index 70a5d1bee60..0cc4e421bb4 100644
--- a/src/mame/video/strnskil.c
+++ b/src/mame/video/strnskil.c
@@ -124,12 +124,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( strnskil )
{
int row;
+ const UINT8 *usr1 = memory_region(REGION_USER1);
for (row = 0; row < 32; row++)
{
if (strnskil_scrl_ctrl != 0x07)
{
- switch (memory_region(REGION_USER1)[strnskil_scrl_ctrl * 32 + row])
+ switch (usr1[strnskil_scrl_ctrl * 32 + row])
{
case 2:
tilemap_set_scrollx(bg_tilemap, row, -~strnskil_xscroll[1]);
diff --git a/src/mame/video/suprloco.c b/src/mame/video/suprloco.c
index a7a47e8e7df..e7cafe7d119 100644
--- a/src/mame/video/suprloco.c
+++ b/src/mame/video/suprloco.c
@@ -180,6 +180,7 @@ static void draw_sprite(bitmap_t *bitmap,const rectangle *cliprect,int spr_numbe
{
int sx,sy,col,row,height,src,adjy,dy;
UINT8 *spr_reg;
+ UINT8 *gfx2;
pen_t pen_base;
short skip; /* bytes to skip before drawing each row (can be negative) */
@@ -205,6 +206,7 @@ static void draw_sprite(bitmap_t *bitmap,const rectangle *cliprect,int spr_numbe
dy = -1;
}
+ gfx2 = memory_region(REGION_GFX2);
for (row = 0;row < height;row++,adjy+=dy)
{
int color1,color2,flipx;
@@ -216,7 +218,7 @@ static void draw_sprite(bitmap_t *bitmap,const rectangle *cliprect,int spr_numbe
col = 0;
/* get pointer to packed sprite data */
- gfx = &(memory_region(REGION_GFX2)[src & 0x7fff]);
+ gfx = &(gfx2[src & 0x7fff]);
flipx = src & 0x8000; /* flip x */
while (1)
diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c
index e31703b44c0..f53ddf8221a 100644
--- a/src/mame/video/taitosj.c
+++ b/src/mame/video/taitosj.c
@@ -172,6 +172,7 @@ static STATE_POSTLOAD( taitosj_postload )
static void compute_draw_order(void)
{
int i;
+ UINT8 *color_prom = memory_region(REGION_PROMS);
/* do a simple conversion of the PROM into layer priority order. Note that */
/* this is a simplification, which assumes the PROM encodes a sensible priority */
@@ -183,8 +184,6 @@ static void compute_draw_order(void)
/* priority one in the first loop */
for (j = 3; j >= 0; j--)
{
- UINT8 *color_prom = memory_region(REGION_PROMS);
-
int data = color_prom[0x10 * (i & 0x0f) + mask] & 0x0f;
if (i & 0x10)