diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c index 8165ef49576..a1a2a3f9d05 100644 --- a/src/emu/drawgfx.c +++ b/src/emu/drawgfx.c @@ -163,21 +163,27 @@ static void calc_penusage(gfx_element *gfx, int num) void decodechar(gfx_element *gfx, int num, const UINT8 *src, const gfx_layout *gl) { + int israw = (gl->planeoffset[0] == GFX_RAW); + int planes = gl->planes; + UINT32 charincrement = gl->charincrement; + const UINT32 *poffset = gl->planeoffset; const UINT32 *xoffset = gl->extxoffs ? gl->extxoffs : gl->xoffset; const UINT32 *yoffset = gl->extyoffs ? gl->extyoffs : gl->yoffset; UINT8 *dp = gfx->gfxdata + num * gfx->char_modulo; int plane, x, y; + assert_always(!israw, "decodechar: raw layouts not supported"); + /* zap the data to 0 */ memset(dp, 0, gfx->char_modulo); /* packed case */ if (gfx->flags & GFX_ELEMENT_PACKED) { - for (plane = 0; plane < gl->planes; plane++) + for (plane = 0; plane < planes; plane++) { - int planebit = 1 << (gl->planes - 1 - plane); - int planeoffs = num * gl->charincrement + gl->planeoffset[plane]; + int planebit = 1 << (planes - 1 - plane); + int planeoffs = num * charincrement + poffset[plane]; for (y = 0; y < gfx->height; y++) { @@ -198,10 +204,10 @@ void decodechar(gfx_element *gfx, int num, const UINT8 *src, const gfx_layout *g /* unpacked case */ else { - for (plane = 0; plane < gl->planes; plane++) + for (plane = 0; plane < planes; plane++) { - int planebit = 1 << (gl->planes - 1 - plane); - int planeoffs = num * gl->charincrement + gl->planeoffset[plane]; + int planebit = 1 << (planes - 1 - plane); + int planeoffs = num * charincrement + poffset[plane]; for (y = 0; y < gfx->height; y++) { @@ -232,6 +238,11 @@ void decodechar(gfx_element *gfx, int num, const UINT8 *src, const gfx_layout *g gfx_element *allocgfx(const gfx_layout *gl) { + int israw = (gl->planeoffset[0] == GFX_RAW); + int planes = gl->planes; + UINT16 width = gl->width; + UINT16 height = gl->height; + UINT32 total = gl->total; gfx_element *gfx; /* allocate memory for the gfx_element structure */ @@ -254,17 +265,17 @@ gfx_element *allocgfx(const gfx_layout *gl) } /* fill in the rest */ - gfx->width = gl->width; - gfx->height = gl->height; - gfx->total_elements = gl->total; + gfx->width = width; + gfx->height = height; + gfx->total_elements = total; gfx->color_base = 0; - gfx->color_depth = 1 << gl->planes; - gfx->color_granularity = 1 << gl->planes; + gfx->color_depth = 1 << planes; + gfx->color_granularity = 1 << planes; if (gfx->color_depth <= 32) gfx->pen_usage = malloc_or_die(gfx->total_elements * sizeof(*gfx->pen_usage)); /* raw graphics case */ - if (gl->planeoffset[0] == GFX_RAW) + if (israw) { /* modulos are determined for us by the layout */ gfx->line_modulo = (gl->extyoffs ? gl->extyoffs[0] : gl->yoffset[0]) / 8; @@ -272,7 +283,7 @@ gfx_element *allocgfx(const gfx_layout *gl) /* don't free the data because we will get a pointer at decode time */ gfx->flags |= GFX_ELEMENT_DONT_FREE; - if (gl->planes <= 4) + if (planes <= 4) gfx->flags |= GFX_ELEMENT_PACKED; } diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h index 3c48350d893..d8608904f42 100644 --- a/src/emu/drawgfx.h +++ b/src/emu/drawgfx.h @@ -105,6 +105,10 @@ enum #define GFXDECODE_SCALE(region,offset,layout,start,colors,xscale,yscale) { region, offset, &layout, start, colors, xscale, yscale }, #define GFXDECODE_END { -1 } }; +/* these macros are used for declaring gfx_layout structures. */ +#define GFXLAYOUT_RAW( name, planes, width, height, linemod, charmod ) \ +const gfx_layout name = { width, height, RGN_FRAC(1,1), planes, { GFX_RAW }, { 0 }, { linemod }, charmod }; + /*************************************************************************** TYPE DEFINITIONS diff --git a/src/emu/validity.c b/src/emu/validity.c index cd10e56a3d9..e2c92000b6a 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -866,24 +866,34 @@ static int validate_gfx(int drivnum, const machine_config *drv, const UINT32 *re { const gfx_decode_entry *gfx = &drv->gfxdecodeinfo[gfxnum]; int region = gfx->memory_region; + int xscale = (drv->gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : drv->gfxdecodeinfo[gfxnum].xscale; + int yscale = (drv->gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : drv->gfxdecodeinfo[gfxnum].yscale; + const gfx_layout *gl = gfx->gfxlayout; + int israw = (gl->planeoffset[0] == GFX_RAW); + int planes = gl->planes; + UINT16 width = gl->width; + UINT16 height = gl->height; + UINT32 total = gl->total; /* if we have a valid region, and we're not using auto-sizing, check the decode against the region length */ - if (region && !IS_FRAC(gfx->gfxlayout->total)) + if (region && !IS_FRAC(total)) { int len, avail, plane, start; + UINT32 charincrement = gl->charincrement; + const UINT32 *poffset = gl->planeoffset; /* determine which plane is the largest */ start = 0; - for (plane = 0; plane < MAX_GFX_PLANES; plane++) - if (gfx->gfxlayout->planeoffset[plane] > start) - start = gfx->gfxlayout->planeoffset[plane]; - start &= ~(gfx->gfxlayout->charincrement - 1); + for (plane = 0; plane < planes; plane++) + if (poffset[plane] > start) + start = poffset[plane]; + start &= ~(charincrement - 1); /* determine the total length based on this info */ - len = gfx->gfxlayout->total * gfx->gfxlayout->charincrement; + len = total * charincrement; /* do we have enough space in the region to cover the whole decode? */ - avail = region_length[region] - (gfx->start & ~(gfx->gfxlayout->charincrement/8-1)); + avail = region_length[region] - (gfx->start & ~(charincrement/8-1)); /* if not, this is an error */ if ((start + len) / 8 > avail) @@ -892,6 +902,34 @@ static int validate_gfx(int drivnum, const machine_config *drv, const UINT32 *re error = TRUE; } } + if (israw) + { + if (total != RGN_FRAC(1,1)) + { + mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver->source_file, driver->name, gfxnum); + error = TRUE; + } + + if (xscale != 1 || yscale != 1) + { + mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver->source_file, driver->name, gfxnum); + error = TRUE; + } + } + else + { + if (planes > MAX_GFX_PLANES) + { + mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver->source_file, driver->name, gfxnum); + error = TRUE; + } + + if (xscale * width > MAX_ABS_GFX_SIZE || yscale * height > MAX_ABS_GFX_SIZE) + { + mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver->source_file, driver->name, gfxnum); + error = TRUE; + } + } } return error; diff --git a/src/emu/video.c b/src/emu/video.c index c504c0a2e60..4003d41c5ea 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -498,8 +498,15 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry * int region_length = 8 * memory_region_length(gfxdecodeinfo[i].memory_region); int xscale = (gfxdecodeinfo[i].xscale == 0) ? 1 : gfxdecodeinfo[i].xscale; int yscale = (gfxdecodeinfo[i].yscale == 0) ? 1 : gfxdecodeinfo[i].yscale; - UINT32 extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE]; + UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE]; gfx_layout glcopy; + const gfx_layout *gl = gfxdecodeinfo[i].gfxlayout; + int israw = (gl->planeoffset[0] == GFX_RAW); + int planes = gl->planes; + UINT16 width = gl->width; + UINT16 height = gl->height; + UINT32 total = gl->total; + UINT32 charincrement = gl->charincrement; int j; /* make a copy of the layout */ @@ -519,48 +526,50 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry * glcopy.extxoffs = extxoffs; glcopy.extyoffs = extyoffs; + extpoffs = glcopy.planeoffset; + /* expand X and Y by the scale factors */ if (xscale > 1) { - glcopy.width *= xscale; - for (j = glcopy.width - 1; j >= 0; j--) + width *= xscale; + for (j = width - 1; j >= 0; j--) extxoffs[j] = extxoffs[j / xscale]; } if (yscale > 1) { - glcopy.height *= yscale; - for (j = glcopy.height - 1; j >= 0; j--) + height *= yscale; + for (j = height - 1; j >= 0; j--) extyoffs[j] = extyoffs[j / yscale]; } /* if the character count is a region fraction, compute the effective total */ - if (IS_FRAC(glcopy.total)) + if (IS_FRAC(total)) { if (region_length == 0) continue; - glcopy.total = region_length / glcopy.charincrement * FRAC_NUM(glcopy.total) / FRAC_DEN(glcopy.total); + total = region_length / charincrement * FRAC_NUM(total) / FRAC_DEN(total); } /* for non-raw graphics, decode the X and Y offsets */ - if (glcopy.planeoffset[0] != GFX_RAW) + if (!israw) { /* loop over all the planes, converting fractions */ - for (j = 0; j < glcopy.planes; j++) + for (j = 0; j < planes; j++) { - UINT32 value = glcopy.planeoffset[j]; + UINT32 value = extpoffs[j]; if (IS_FRAC(value)) - glcopy.planeoffset[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value); + extpoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value); } /* loop over all the X/Y offsets, converting fractions */ - for (j = 0; j < glcopy.width; j++) + for (j = 0; j < width; j++) { UINT32 value = extxoffs[j]; if (IS_FRAC(value)) extxoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value); } - for (j = 0; j < glcopy.height; j++) + for (j = 0; j < height; j++) { UINT32 value = extyoffs[j]; if (IS_FRAC(value)) @@ -568,21 +577,27 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry * } } - /* otherwise, just use yoffset[0] as the line modulo */ + /* otherwise, just use the line modulo */ else { int base = gfxdecodeinfo[i].start; int end = region_length/8; + int linemod = gl->yoffset[0]; while (glcopy.total > 0) { - int elementbase = base + (glcopy.total - 1) * glcopy.charincrement / 8; - int lastpixelbase = elementbase + glcopy.height * glcopy.yoffset[0] / 8 - 1; + int elementbase = base + (total - 1) * charincrement / 8; + int lastpixelbase = elementbase + height * linemod / 8 - 1; if (lastpixelbase < end) break; - glcopy.total--; + total--; } } + /* update glcopy */ + glcopy.width = width; + glcopy.height = height; + glcopy.total = total; + /* allocate the graphics */ machine->gfx[i] = allocgfx(&glcopy); diff --git a/src/mame/drivers/bnstars.c b/src/mame/drivers/bnstars.c index 1bee526b5c0..b70c737b7f1 100644 --- a/src/mame/drivers/bnstars.c +++ b/src/mame/drivers/bnstars.c @@ -1175,39 +1175,9 @@ INPUT_PORTS_END /* sprites are contained in 256x256 "tiles" */ -static const gfx_layout spritelayout = -{ - 256,256, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 256*8 }, /* line modulo */ - 256*256*8 /* char modulo */ -}; - -static const gfx_layout bglayout = -{ - 16,16, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 16*8 }, /* line modulo */ - 16*16*8 /* char modulo */ -}; - - -static const gfx_layout txlayout = -{ - 8,8, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 8*8*8 /* char modulo */ -}; +static GFXLAYOUT_RAW( spritelayout, 8, 256, 256, 256*8, 256*256*8 ) +static GFXLAYOUT_RAW( bglayout, 8, 16, 16, 16*8, 16*16*8 ) +static GFXLAYOUT_RAW( txlayout, 8, 8, 8, 8*8, 8*8*8 ) static GFXDECODE_START( bnstars ) GFXDECODE_ENTRY( REGION_GFX1, 0, spritelayout, 0x0000, 0x10 ) diff --git a/src/mame/drivers/bogeyman.c b/src/mame/drivers/bogeyman.c index aa08ff6ba12..6df51dc059e 100644 --- a/src/mame/drivers/bogeyman.c +++ b/src/mame/drivers/bogeyman.c @@ -162,7 +162,7 @@ static const gfx_layout charlayout2 = 8, 8, 512, 3, - { 0x8000*8, 0+0x1000*8, 4+0x1000*8, 0 }, + { 0x8000*8, 0+0x1000*8, 4+0x1000*8 }, { 0x2000*8+3, 0x2000*8+2, 0x2000*8+1, 0x2000*8+0, 3, 2, 1, 0 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, 8*8 diff --git a/src/mame/drivers/cherrym.c b/src/mame/drivers/cherrym.c index 9186cba8fd6..42c14ca01ba 100644 --- a/src/mame/drivers/cherrym.c +++ b/src/mame/drivers/cherrym.c @@ -348,7 +348,7 @@ static const gfx_layout spritelayout = 12, 4, { 0, 0x2000*8, 0x4000*8, 0x6000*8 }, - { 0 }, + EXTENDED_XOFFS, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8, 16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8, 24*8, 25*8, 26*8, 27*8, 28*8, 29*8, 30*8, 31*8 diff --git a/src/mame/drivers/cherrym2.c b/src/mame/drivers/cherrym2.c index c434767b1f9..674144e9e2f 100644 --- a/src/mame/drivers/cherrym2.c +++ b/src/mame/drivers/cherrym2.c @@ -296,7 +296,8 @@ static const UINT32 spritelayout2_xoffset[80] = 3+6*64*8, 2+6*64*8, 1+6*64*8, 0+6*64*8, 3+7*64*8, 2+7*64*8, 1+7*64*8, 0+7*64*8, 3+8*64*8, 2+8*64*8, 1+8*64*8, 0+8*64*8, - 3+9*64*8, 2+9*64*8, 1+9*64*8, 0+9*64*8 + 3+9*64*8, 2+9*64*8, 1+9*64*8, 0+9*64*8, + STEP32(0,0), STEP8(0,0) }; static const UINT32 spritelayout2_yoffset[128] = diff --git a/src/mame/drivers/cps1.c b/src/mame/drivers/cps1.c index a6cf8099e1d..e946ee9c930 100644 --- a/src/mame/drivers/cps1.c +++ b/src/mame/drivers/cps1.c @@ -3427,27 +3427,8 @@ static const gfx_layout cps1_layout8x8_2 = 64*8 }; -static const gfx_layout cps1_layout16x16 = -{ - 16,16, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 128*8 /* char modulo */ -}; - -static const gfx_layout cps1_layout32x32 = -{ - 32,32, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 16*8 }, /* line modulo */ - 512*8 /* char modulo */ -}; +static GFXLAYOUT_RAW( cps1_layout16x16, 4, 16, 16, 8*8, 128*8 ) +static GFXLAYOUT_RAW( cps1_layout32x32, 4, 32, 32, 16*8, 512*8 ) GFXDECODE_START( cps1 ) GFXDECODE_ENTRY( REGION_GFX1, 0, cps1_layout8x8, 0, 0x100 ) diff --git a/src/mame/drivers/cps2.c b/src/mame/drivers/cps2.c index ddfe03e4894..e8f75e5ba39 100644 --- a/src/mame/drivers/cps2.c +++ b/src/mame/drivers/cps2.c @@ -1311,27 +1311,8 @@ static const gfx_layout cps1_layout8x8_2 = 64*8 }; -static const gfx_layout layout16x16 = -{ - 16,16, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 128*8 /* char modulo */ -}; - -static const gfx_layout layout32x32 = -{ - 32,32, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 16*8 }, /* line modulo */ - 512*8 /* char modulo */ -}; +static GFXLAYOUT_RAW( layout16x16, 4, 16, 16, 8*8, 128*8 ) +static GFXLAYOUT_RAW( layout32x32, 4, 32, 32, 16*8, 512*8 ) static GFXDECODE_START( cps2 ) GFXDECODE_ENTRY( REGION_GFX1, 0, cps1_layout8x8, 0, 0x100 ) diff --git a/src/mame/drivers/equites.c b/src/mame/drivers/equites.c index 8f1906c4997..2f9e53b5298 100644 --- a/src/mame/drivers/equites.c +++ b/src/mame/drivers/equites.c @@ -627,7 +627,7 @@ static const gfx_layout eq_spritelayout = 3, { 0, 0x4000*8, 0x4000*8+4 }, { STEP4(128*0+3,-1), STEP4(128*1+3,-1), STEP4(128*2+3,-1), STEP4(128*3+3,-1) }, - { STEP16(1*8,8) }, + { STEP8(1*8,8), STEP4(1*8+8*8,8), STEP2(1*8+12*8,8) }, 64*8 }; diff --git a/src/mame/drivers/funworld.c b/src/mame/drivers/funworld.c index cc56ce8bde7..60053daec50 100644 --- a/src/mame/drivers/funworld.c +++ b/src/mame/drivers/funworld.c @@ -1318,8 +1318,7 @@ INPUT_PORTS_END static const gfx_layout charlayout = { - 4, - 8, + 4,8, 0x1000, // RGN_FRAC(1,2), 4, @@ -1332,8 +1331,7 @@ static const gfx_layout charlayout = static const gfx_layout sn10_charlayout = { - 4, - 8, + 4,8, RGN_FRAC(1,2), 4, { RGN_FRAC(0,2), RGN_FRAC(0,2) + 4, RGN_FRAC(1,2), RGN_FRAC(1,2) + 4 }, diff --git a/src/mame/drivers/gamecstl.c b/src/mame/drivers/gamecstl.c index 19c1688c149..f4ede2edbf5 100644 --- a/src/mame/drivers/gamecstl.c +++ b/src/mame/drivers/gamecstl.c @@ -380,8 +380,6 @@ static const gfx_layout CGA_charlayout = { 0,1,2,3,4,5,6,7 }, /* y offsets */ { 0*8,1*8,2*8,3*8, - 4*8,5*8,6*8,7*8, - 0*8,1*8,2*8,3*8, 4*8,5*8,6*8,7*8 }, 8*8 /* every char takes 8 bytes */ }; diff --git a/src/mame/drivers/hyprduel.c b/src/mame/drivers/hyprduel.c index d692202c901..250c0e9d0d2 100644 --- a/src/mame/drivers/hyprduel.c +++ b/src/mame/drivers/hyprduel.c @@ -676,28 +676,10 @@ INPUT_PORTS_END ***************************************************************************/ /* 8x8x4 tiles */ -static const gfx_layout layout_8x8x4 = -{ - 8,8, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 4*8 }, /* line modulo */ - 32*8 /* char modulo */ -}; +static GFXLAYOUT_RAW( layout_8x8x4, 4, 8, 8, 4*8, 32*8 ) /* 8x8x8 tiles for later games */ -static const gfx_layout layout_8x8x8h = -{ - 8,8, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 32*8 /* char modulo (half char step) */ -}; +static GFXLAYOUT_RAW( layout_8x8x8h, 8, 8, 8, 8*8, 32*8 ) static GFXDECODE_START( 14220 ) GFXDECODE_ENTRY( REGION_GFX1, 0, layout_8x8x4, 0x0, 0x200 ) // [0] 4 Bit Tiles diff --git a/src/mame/drivers/igs_m027.c b/src/mame/drivers/igs_m027.c index 63507ecc08d..ec8a4d63603 100644 --- a/src/mame/drivers/igs_m027.c +++ b/src/mame/drivers/igs_m027.c @@ -338,16 +338,18 @@ static const gfx_layout gfxlayout_8x8x4 = 8*8*4 }; +#if 0 static const gfx_layout gfxlayout_16x16x16 = { 16,16, RGN_FRAC(1,1), 16, - { 0 }, + { STEP16(0,0) }, // >8planes not supported { STEP16(15,-1) }, { STEP16(0,16*1) }, 16*16*16 }; +#endif static GFXDECODE_START( igs_m027 ) GFXDECODE_ENTRY( REGION_GFX1, 0, gfxlayout_8x8x4, 0, 16 ) diff --git a/src/mame/drivers/liberate.c b/src/mame/drivers/liberate.c index c0fc3359168..3c4aad8a0f6 100644 --- a/src/mame/drivers/liberate.c +++ b/src/mame/drivers/liberate.c @@ -433,7 +433,7 @@ static const gfx_layout pro_tiles = 16,16, 16, 2, - { 0, 4, 1024*8, 1024*8+4 }, + { 0, 4 }, { 24,25,26,27, 16,17,18,19, 8,9,10,11, 0,1,2,3 }, diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c index 29ffef9ad7d..99976a71a7b 100644 --- a/src/mame/drivers/mediagx.c +++ b/src/mame/drivers/mediagx.c @@ -767,8 +767,6 @@ static const gfx_layout CGA_charlayout = { 0,1,2,3,4,5,6,7 }, /* y offsets */ { 0*8,1*8,2*8,3*8, - 4*8,5*8,6*8,7*8, - 0*8,1*8,2*8,3*8, 4*8,5*8,6*8,7*8 }, 8*8 /* every char takes 8 bytes */ }; diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c index 44e45fc88d3..a8281d7858f 100644 --- a/src/mame/drivers/metro.c +++ b/src/mame/drivers/metro.c @@ -3568,52 +3568,16 @@ INPUT_PORTS_END /* 8x8x4 tiles */ -static const gfx_layout layout_8x8x4 = -{ - 8,8, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 4*8 }, /* line modulo */ - 32*8 /* char modulo */ -}; +static GFXLAYOUT_RAW( layout_8x8x4, 4, 8, 8, 4*8, 32*8 ) /* 8x8x8 tiles for later games */ -static const gfx_layout layout_8x8x8h = -{ - 8,8, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 32*8 /* char modulo (half char step) */ -}; +static GFXLAYOUT_RAW( layout_8x8x8h, 8, 8, 8, 8*8, 32*8 ) /* 16x16x4 tiles for later games */ -static const gfx_layout layout_16x16x4q = -{ - 16,16, - RGN_FRAC(1,1), - 4, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 32*8 /* char modulo (quarter char step) */ -}; +static GFXLAYOUT_RAW( layout_16x16x4q, 4, 16, 16, 8*8, 32*8 ) /* 16x16x8 tiles for later games */ -static const gfx_layout layout_16x16x8o = -{ - 16,16, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 16*8 }, /* line modulo */ - 32*8 /* char modulo (1/8th char step) */ -}; +static GFXLAYOUT_RAW( layout_16x16x8o, 8, 16, 16, 16*8, 32*8 ) static const gfx_layout layout_053936 = { diff --git a/src/mame/drivers/ms32.c b/src/mame/drivers/ms32.c index c33329a5b25..ea6243b840f 100644 --- a/src/mame/drivers/ms32.c +++ b/src/mame/drivers/ms32.c @@ -1216,39 +1216,9 @@ INPUT_PORTS_END /********** GFX DECODE **********/ /* sprites are contained in 256x256 "tiles" */ -static const gfx_layout spritelayout = -{ - 256,256, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 256*8 }, /* line modulo */ - 256*256*8 /* char modulo */ -}; - -static const gfx_layout bglayout = -{ - 16,16, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 16*8 }, /* line modulo */ - 16*16*8 /* char modulo */ -}; - - -static const gfx_layout txlayout = -{ - 8,8, - RGN_FRAC(1,1), - 8, - { GFX_RAW }, - { 0 }, /* org displacement */ - { 8*8 }, /* line modulo */ - 8*8*8 /* char modulo */ -}; +static GFXLAYOUT_RAW( spritelayout, 8, 256, 256, 256*8, 256*256*8 ) +static GFXLAYOUT_RAW( bglayout, 8, 16, 16, 16*8, 16*16*8 ) +static GFXLAYOUT_RAW( txlayout, 8, 8, 8, 8*8, 8*8*8 ) static GFXDECODE_START( ms32 ) GFXDECODE_ENTRY( REGION_GFX1, 0, spritelayout, 0x0000, 0x10 ) diff --git a/src/mame/drivers/namcoic.c b/src/mame/drivers/namcoic.c index 61b481029aa..a5af7c46702 100644 --- a/src/mame/drivers/namcoic.c +++ b/src/mame/drivers/namcoic.c @@ -1522,17 +1522,14 @@ static int mbRoadNeedTransparent; static const gfx_layout RoadTileLayout = { - ROAD_TILE_SIZE, - ROAD_TILE_SIZE, + ROAD_TILE_SIZE, ROAD_TILE_SIZE, ROAD_TILE_COUNT_MAX, 2, - { #ifndef LSB_FIRST - 0,8 + { 0,8 }, #else - 8,0 + { 8,0 }, #endif - }, {/* x offset */ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17 diff --git a/src/mame/drivers/taitowlf.c b/src/mame/drivers/taitowlf.c index a05e7d3cc41..4f67cb836ed 100644 --- a/src/mame/drivers/taitowlf.c +++ b/src/mame/drivers/taitowlf.c @@ -345,8 +345,6 @@ static const gfx_layout CGA_charlayout = { 0,1,2,3,4,5,6,7 }, /* y offsets */ { 0*8,1*8,2*8,3*8, - 4*8,5*8,6*8,7*8, - 0*8,1*8,2*8,3*8, 4*8,5*8,6*8,7*8 }, 8*8 /* every char takes 8 bytes */ }; diff --git a/src/mame/video/atarisy1.c b/src/mame/video/atarisy1.c index 5fdca93d1c1..561dfe08d5e 100644 --- a/src/mame/video/atarisy1.c +++ b/src/mame/video/atarisy1.c @@ -64,8 +64,29 @@ static emu_timer *int3off_timer; static UINT8 bank_gfx[3][8]; static UINT8 bank_color_shift[MAX_GFX_ELEMENTS]; -/* basic form of a graphics bank */ -static gfx_layout objlayout = +static const gfx_layout objlayout_4bpp = +{ + 8,8, /* 8*8 sprites */ + 4096, /* 4096 of them */ + 4, /* 4 bits per pixel */ + { 3*8*0x10000, 2*8*0x10000, 1*8*0x10000, 0*8*0x10000 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, + 8*8 /* every sprite takes 8 consecutive bytes */ +}; + +static const gfx_layout objlayout_5bpp = +{ + 8,8, /* 8*8 sprites */ + 4096, /* 4096 of them */ + 5, /* 5 bits per pixel */ + { 4*8*0x10000, 3*8*0x10000, 2*8*0x10000, 1*8*0x10000, 0*8*0x10000 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, + 8*8 /* every sprite takes 8 consecutive bytes */ +}; + +static const gfx_layout objlayout_6bpp = { 8,8, /* 8*8 sprites */ 4096, /* 4096 of them */ @@ -607,7 +628,7 @@ static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *moloo static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp) { - int bank_index, i, gfx_index; + int bank_index, gfx_index; /* determine the bank index */ if ((prom1 & PROM1_BANK_1) == 0) @@ -644,13 +665,24 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp) break; assert(gfx_index != MAX_GFX_ELEMENTS); - /* tweak the structure for the number of bitplanes we have */ - objlayout.planes = bpp; - for (i = 0; i < bpp; i++) - objlayout.planeoffset[i] = (bpp - i - 1) * 0x10000 * 8; - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&objlayout); + switch (bpp) + { + case 4: + machine->gfx[gfx_index] = allocgfx(&objlayout_4bpp); + break; + + case 5: + machine->gfx[gfx_index] = allocgfx(&objlayout_5bpp); + break; + + case 6: + machine->gfx[gfx_index] = allocgfx(&objlayout_6bpp); + break; + + default: + fatalerror("Unsupported bpp"); + } decodegfx(machine->gfx[gfx_index], &memory_region(REGION_GFX2)[0x80000 * (bank_index - 1)], 0, machine->gfx[gfx_index]->total_elements); /* set the color information */ diff --git a/src/mame/video/konamiic.c b/src/mame/video/konamiic.c index 438db7e3cc8..4a4fdf613d5 100644 --- a/src/mame/video/konamiic.c +++ b/src/mame/video/konamiic.c @@ -1205,6 +1205,22 @@ void konami_rom_deinterleave_4(int mem_region) } +static void decode_gfx(running_machine *machine, int gfx_index, UINT8 *data, UINT32 total, const gfx_layout *layout, int bpp) +{ + gfx_layout gl; + + memcpy(&gl, layout, sizeof(gl)); + gl.total = total; + machine->gfx[gfx_index] = allocgfx(&gl); + decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements); + + /* set the color information */ + if (machine->drv->color_table_len) + machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / (1 << bpp); + else + machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / (1 << bpp); +} + @@ -1958,16 +1974,17 @@ static void K052109_tileflip_reset(void) } -void K052109_vh_start(running_machine *machine,int gfx_memory_region,int plane0,int plane1,int plane2,int plane3, +void K052109_vh_start(running_machine *machine,int gfx_memory_region,int plane_order, void (*callback)(int tmap,int bank,int *code,int *color,int *flags,int *priority)) { int gfx_index, i; - static gfx_layout charlayout = + UINT32 total; + static const gfx_layout charlayout = { 8,8, - 0, /* filled in later */ + 0, 4, - { 0, 0, 0, 0 }, /* filled in later */ + { 24, 16, 8, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, 32*8 @@ -1980,22 +1997,17 @@ void K052109_vh_start(running_machine *machine,int gfx_memory_region,int plane0, break; assert(gfx_index != MAX_GFX_ELEMENTS); - /* tweak the structure for the number of tiles we have */ - charlayout.total = memory_region_length(gfx_memory_region) / 32; - charlayout.planeoffset[0] = plane3 * 8; - charlayout.planeoffset[1] = plane2 * 8; - charlayout.planeoffset[2] = plane1 * 8; - charlayout.planeoffset[3] = plane0 * 8; - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + switch (plane_order) + { + case NORMAL_PLANE_ORDER: + total = memory_region_length(gfx_memory_region) / 32; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout, 4); + break; - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; + default: + fatalerror("Unsupported plane_order"); + } K052109_memory_region = gfx_memory_region; K052109_gfxnum = gfx_index; @@ -2420,23 +2432,35 @@ static int K051960_dx, K051960_dy; static int K051960_irq_enabled, K051960_nmi_enabled; -void K051960_vh_start(running_machine *machine,int gfx_memory_region,int plane0,int plane1,int plane2,int plane3, +void K051960_vh_start(running_machine *machine,int gfx_memory_region,int plane_order, void (*callback)(int *code,int *color,int *priority,int *shadow)) { int gfx_index,i; - static gfx_layout spritelayout = + UINT32 total; + static const gfx_layout spritelayout = { 16,16, - 0, /* filled in later */ + 0, 4, - { 0, 0, 0, 0 }, /* filled in later */ + { 0, 8, 16, 24 }, + { 0, 1, 2, 3, 4, 5, 6, 7, + 8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 }, + { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, + 16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 }, + 128*8 + }; + static const gfx_layout spritelayout_reverse = + { + 16,16, + 0, + 4, + { 24, 16, 8, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 }, { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 }, 128*8 }; - /* find first empty slot to decode gfx */ for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) @@ -2445,22 +2469,22 @@ void K051960_vh_start(running_machine *machine,int gfx_memory_region,int plane0, assert(gfx_index != MAX_GFX_ELEMENTS); - /* tweak the structure for the number of tiles we have */ - spritelayout.total = memory_region_length(gfx_memory_region) / 128; - spritelayout.planeoffset[0] = plane0 * 8; - spritelayout.planeoffset[1] = plane1 * 8; - spritelayout.planeoffset[2] = plane2 * 8; - spritelayout.planeoffset[3] = plane3 * 8; - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + switch (plane_order) + { + case NORMAL_PLANE_ORDER: + total = memory_region_length(gfx_memory_region) / 128; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &spritelayout, 4); + break; - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; + case REVERSE_PLANE_ORDER: + total = memory_region_length(gfx_memory_region) / 128; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &spritelayout_reverse, 4); + break; + + default: + fatalerror("Unknown plane_order"); + } if (VERBOSE && !(machine->drv->video_attributes & VIDEO_HAS_SHADOWS)) popmessage("driver should use VIDEO_HAS_SHADOWS"); @@ -2913,16 +2937,17 @@ static UINT16 *K053245_ram[MAX_K053245_CHIPS], *K053245_buffer[MAX_K053245_CHIPS static UINT8 K053244_regs[MAX_K053245_CHIPS][0x10]; static int K053245_dx[MAX_K053245_CHIPS], K053245_dy[MAX_K053245_CHIPS]; -void K053245_vh_start(running_machine *machine,int chip, int gfx_memory_region,int plane0,int plane1,int plane2,int plane3, +void K053245_vh_start(running_machine *machine,int chip, int gfx_memory_region,int plane_order, void (*callback)(int *code,int *color,int *priority)) { int gfx_index,i; - static gfx_layout spritelayout = + UINT32 total; + static const gfx_layout spritelayout = { 16,16, - 0, /* filled in later */ + 0, 4, - { 0, 0, 0, 0 }, /* filled in later */ + { 24, 16, 8, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 }, { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, @@ -2942,22 +2967,17 @@ void K053245_vh_start(running_machine *machine,int chip, int gfx_memory_region,i break; assert(gfx_index != MAX_GFX_ELEMENTS); - /* tweak the structure for the number of tiles we have */ - spritelayout.total = memory_region_length(gfx_memory_region) / 128; - spritelayout.planeoffset[0] = plane3 * 8; - spritelayout.planeoffset[1] = plane2 * 8; - spritelayout.planeoffset[2] = plane1 * 8; - spritelayout.planeoffset[3] = plane0 * 8; - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + switch (plane_order) + { + case NORMAL_PLANE_ORDER: + total = memory_region_length(gfx_memory_region) / 128; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &spritelayout, 4); + break; - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; + default: + fatalerror("Unsupported plane_order"); + } if (VERBOSE && !(machine->drv->video_attributes & VIDEO_HAS_SHADOWS)) popmessage("driver should use VIDEO_HAS_SHADOWS"); @@ -3664,16 +3684,17 @@ void K053247_wraparound_enable(int status) K053247_wraparound = status; } -void K053247_vh_start(running_machine *machine, int gfx_memory_region, int dx, int dy, int plane0,int plane1,int plane2,int plane3, +void K053247_vh_start(running_machine *machine, int gfx_memory_region, int dx, int dy, int plane_order, void (*callback)(int *code,int *color,int *priority)) { int gfx_index,i; - static gfx_layout spritelayout = + UINT32 total; + static const gfx_layout spritelayout = { 16,16, - 0, /* filled in later */ + 0, 4, - { 0, 0, 0, 0 }, /* filled in later */ + { 0, 1, 2, 3 }, { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4, 10*4, 11*4, 8*4, 9*4, 14*4, 15*4, 12*4, 13*4 }, { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, @@ -3688,22 +3709,17 @@ void K053247_vh_start(running_machine *machine, int gfx_memory_region, int dx, i break; assert(gfx_index != MAX_GFX_ELEMENTS); - /* tweak the structure for the number of tiles we have */ - spritelayout.total = memory_region_length(gfx_memory_region) / 128; - spritelayout.planeoffset[0] = plane0; - spritelayout.planeoffset[1] = plane1; - spritelayout.planeoffset[2] = plane2; - spritelayout.planeoffset[3] = plane3; - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + switch (plane_order) + { + case NORMAL_PLANE_ORDER: + total = memory_region_length(gfx_memory_region) / 128; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &spritelayout, 4); + break; - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; + default: + fatalerror("Unsupported plane_order"); + } if (VERBOSE) { @@ -3749,11 +3765,12 @@ void K053247_vh_start(running_machine *machine, int gfx_memory_region, int dx, i void K055673_vh_start(running_machine *machine, int gfx_memory_region, int layout, int dx, int dy, void (*callback)(int *code,int *color,int *priority)) { int gfx_index; + UINT32 total; - static gfx_layout spritelayout = /* System GX sprite layout */ + static const gfx_layout spritelayout = /* System GX sprite layout */ { 16,16, - 32768, /* filled in later */ + 0, 5, { 32, 24, 16, 8, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 40, 41, 42, 43, 44, 45, 46, 47 }, @@ -3761,20 +3778,20 @@ void K055673_vh_start(running_machine *machine, int gfx_memory_region, int layou 10*8*9, 10*8*10, 10*8*11, 10*8*12, 10*8*13, 10*8*14, 10*8*15 }, 16*16*5 }; - static gfx_layout spritelayout2 = /* Run and Gun sprite layout */ + static const gfx_layout spritelayout2 = /* Run and Gun sprite layout */ { 16,16, - 32768, /* filled in later */ + 0, 4, { 24, 16, 8, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 32, 33, 34, 35, 36, 37, 38, 39 }, { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 }, 16*16*4 }; - static gfx_layout spritelayout3 = /* Lethal Enforcers II sprite layout */ + static const gfx_layout spritelayout3 = /* Lethal Enforcers II sprite layout */ { 16,16, - 32768, /* filled in later */ + 0, 8, { 8*1,8*0,8*3,8*2,8*5,8*4,8*7,8*6 }, { 0,1,2,3,4,5,6,7,64+0,64+1,64+2,64+3,64+4,64+5,64+6,64+7 }, @@ -3782,10 +3799,10 @@ void K055673_vh_start(running_machine *machine, int gfx_memory_region, int layou 128*8, 128*9, 128*10, 128*11, 128*12, 128*13, 128*14, 128*15 }, 128*16 }; - static gfx_layout spritelayout4 = /* System GX 6bpp sprite layout */ + static const gfx_layout spritelayout4 = /* System GX 6bpp sprite layout */ { 16,16, - 32768, /* filled in later */ + 0, 6, { 40, 32, 24, 16, 8, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 48, 49, 50, 51, 52, 53, 54, 55 }, @@ -3796,6 +3813,7 @@ void K055673_vh_start(running_machine *machine, int gfx_memory_region, int layou UINT8 *s1, *s2, *d; long i, c; UINT16 *K055673_rom; + int size4; /* find first empty slot to decode gfx */ for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) @@ -3803,13 +3821,15 @@ void K055673_vh_start(running_machine *machine, int gfx_memory_region, int layou break; assert(gfx_index != MAX_GFX_ELEMENTS); - switch(layout) { - case K055673_LAYOUT_GX: + K055673_rom = (UINT16 *)memory_region(gfx_memory_region); + + /* decode the graphics */ + switch(layout) { - int size4 = (memory_region_length(gfx_memory_region)/(1024*1024))/5; + case K055673_LAYOUT_GX: + size4 = (memory_region_length(gfx_memory_region)/(1024*1024))/5; size4 *= 4*1024*1024; /* set the # of tiles based on the 4bpp section */ - spritelayout.total = size4 / 128; K055673_rom = auto_malloc(size4 * 5); d = (UINT8 *)K055673_rom; // now combine the graphics together to form 5bpp @@ -3823,45 +3843,30 @@ void K055673_vh_start(running_machine *machine, int gfx_memory_region, int layou *d++ = *s1++; *d++ = *s2++; } - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout); - decodegfx(machine->gfx[gfx_index], (UINT8 *)K055673_rom, 0, machine->gfx[gfx_index]->total_elements); + + total = size4 / 128; + decode_gfx(machine, gfx_index, (UINT8 *)K055673_rom, total, &spritelayout, 4); break; - } + case K055673_LAYOUT_RNG: - K055673_rom = (UINT16 *)memory_region(gfx_memory_region); - spritelayout2.total = memory_region_length(gfx_memory_region) / (16*16/2); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout2); - decodegfx(machine->gfx[gfx_index], (UINT8 *)K055673_rom, 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (16*16/2); + decode_gfx(machine, gfx_index, (UINT8 *)K055673_rom, total, &spritelayout2, 4); break; + case K055673_LAYOUT_LE2: - K055673_rom = (UINT16 *)memory_region(gfx_memory_region); - spritelayout3.total = memory_region_length(gfx_memory_region) / (16*16); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout3); - decodegfx(machine->gfx[gfx_index], (UINT8 *)K055673_rom, 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (16*16); + decode_gfx(machine, gfx_index, (UINT8 *)K055673_rom, total, &spritelayout3, 4); break; + case K055673_LAYOUT_GX6: - K055673_rom = (UINT16 *)memory_region(gfx_memory_region); - spritelayout4.total = memory_region_length(gfx_memory_region) / (16*16*6/8); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&spritelayout4); - decodegfx(machine->gfx[gfx_index], (UINT8 *)K055673_rom, 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (16*16*6/8); + decode_gfx(machine, gfx_index, (UINT8 *)K055673_rom, total, &spritelayout4, 4); break; + + default: + fatalerror("Unsupported layout"); } - assert(machine->gfx[gfx_index]); - - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; - if (VERBOSE && !(machine->drv->video_attributes & VIDEO_HAS_SHADOWS)) popmessage("driver should use VIDEO_HAS_SHADOWS"); @@ -4541,6 +4546,43 @@ static void K051316_vh_start(running_machine *machine,int chip, int gfx_memory_r void (*callback)(int *code,int *color,int *flags)) { int gfx_index; + UINT32 total; + static const gfx_layout charlayout4 = + { + 16,16, + 0, + 4, + { 0, 1, 2, 3 }, + { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, + 8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4 }, + { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, + 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, + 128*8 + }; + static const gfx_layout charlayout7 = + { + 16,16, + 0, + 7, + { 1,2,3,4,5,6,7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, + 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, + 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, + 256*8 + }; + static const gfx_layout charlayout8 = + { + 16,16, + 0, + 8, + { 0,1,2,3,4,5,6,7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, + 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, + 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, + 256*8 + }; static const tile_get_info_callback get_tile_info[3] = { K051316_get_tile_info0,K051316_get_tile_info1,K051316_get_tile_info2 }; /* find first empty slot to decode gfx */ @@ -4549,66 +4591,27 @@ static void K051316_vh_start(running_machine *machine,int chip, int gfx_memory_r break; assert(gfx_index != MAX_GFX_ELEMENTS); - assert((bpp == 4) || (bpp == 7) || (bpp == 8)); - - if (bpp == 4) + /* decode the graphics */ + switch (bpp) { - static gfx_layout charlayout = - { - 16,16, - 0, /* filled in later */ - 4, - { 0, 1, 2, 3 }, - { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4, - 8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4 }, - { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, - 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 }, - 128*8 - }; + case 4: + total = memory_region_length(gfx_memory_region) / 128; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout4, 4); + break; + case 7: + total = memory_region_length(gfx_memory_region) / 256; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout7, 7); + break; - /* tweak the structure for the number of tiles we have */ - charlayout.total = memory_region_length(gfx_memory_region) / 128; + case 8: + total = memory_region_length(gfx_memory_region) / 256; + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout8, 8); + break; - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + default: + fatalerror("Unsupported bpp"); } - else - { - static gfx_layout charlayout = - { - 16,16, - 0, /* filled in later */ - 0, /* filled in later */ - { 0 }, /* filled in later */ - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, - 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, - { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, - 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 }, - 256*8 - }; - int i; - - - /* tweak the structure for the number of tiles we have */ - charlayout.total = memory_region_length(gfx_memory_region) / 256; - charlayout.planes = bpp; - if (bpp == 7) for (i = 0;i < 7;i++) charlayout.planeoffset[i] = i+1; - else for (i = 0;i < 8;i++) charlayout.planeoffset[i] = i; - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); - } - - assert(machine->gfx[gfx_index]); - - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / (1 << bpp); - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / (1 << bpp); K051316_memory_region[chip] = gfx_memory_region; K051316_gfxnum[chip] = gfx_index; @@ -5538,17 +5541,18 @@ void K056832_vh_start(running_machine *machine, int gfx_memory_region, int bpp, tilemap *tmap; int gfx_index; int i; - gfx_layout charlayout8 = + UINT32 total; + static const gfx_layout charlayout8 = { 8, 8, - 0, /* filled in later */ + 0, 8, { 8*7,8*3,8*5,8*1,8*6,8*2,8*4,8*0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0, 8*8, 8*8*2, 8*8*3, 8*8*4, 8*8*5, 8*8*6, 8*8*7 }, 8*8*8 }; - gfx_layout charlayout8le = + static const gfx_layout charlayout8le = { 8, 8, 0, @@ -5559,27 +5563,27 @@ void K056832_vh_start(running_machine *machine, int gfx_memory_region, int bpp, { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 }, 8*8*4 }; - gfx_layout charlayout6 = + static const gfx_layout charlayout6 = { 8, 8, - 0, /* filled in later */ + 0, 6, { 40, 32, 24, 8, 16, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0, 6*8, 6*8*2, 6*8*3, 6*8*4, 6*8*5, 6*8*6, 6*8*7 }, 8*8*6 }; - gfx_layout charlayout5 = + static const gfx_layout charlayout5 = { 8, 8, - 0, /* filled in later */ + 0, 5, { 32, 24, 8, 16, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0, 5*8, 5*8*2, 5*8*3, 5*8*4, 5*8*5, 5*8*6, 5*8*7 }, 8*8*5 }; - gfx_layout charlayout4 = + static const gfx_layout charlayout4 = { 8, 8, 0, @@ -5589,10 +5593,10 @@ void K056832_vh_start(running_machine *machine, int gfx_memory_region, int bpp, { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 }, 8*8*4 }; - static gfx_layout charlayout4dj = + static const gfx_layout charlayout4dj = { 8, 8, - 0, /* filled in later */ + 0, 4, { 8*3,8*1,8*2,8*0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, @@ -5612,69 +5616,43 @@ void K056832_vh_start(running_machine *machine, int gfx_memory_region, int bpp, /* handle the various graphics formats */ i = (big) ? 8 : 16; + /* decode the graphics */ switch (bpp) { case K056832_BPP_4: - charlayout4.total = memory_region_length(gfx_memory_region) / (i*4); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout4); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (i*4); + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout4, 4); break; case K056832_BPP_5: - /* tweak the structure for the number of tiles we have */ - charlayout5.total = memory_region_length(gfx_memory_region) / (i*5); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout5); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (i*5); + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout5, 4); break; case K056832_BPP_6: - /* tweak the structure for the number of tiles we have */ - charlayout6.total = memory_region_length(gfx_memory_region) / (i*6); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout6); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (i*6); + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout6, 4); break; case K056832_BPP_8: - /* tweak the structure for the number of tiles we have */ - charlayout8.total = memory_region_length(gfx_memory_region) / (i*8); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout8); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (i*8); + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout8, 4); break; case K056832_BPP_8LE: - /* tweak the structure for the number of tiles we have */ - charlayout8le.total = memory_region_length(gfx_memory_region) / (i*8); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout8le); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (i*8); + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout8le, 4); break; case K056832_BPP_4dj: - charlayout4dj.total = memory_region_length(gfx_memory_region) / (i*4); - - /* decode the graphics */ - machine->gfx[gfx_index] = allocgfx(&charlayout4dj); - decodegfx(machine->gfx[gfx_index], memory_region(gfx_memory_region), 0, machine->gfx[gfx_index]->total_elements); + total = memory_region_length(gfx_memory_region) / (i*4); + decode_gfx(machine, gfx_index, memory_region(gfx_memory_region), total, &charlayout4dj, 4); break; + + default: + fatalerror("Unsupported bpp"); } - /* make sure the decode went OK */ - assert(machine->gfx[gfx_index]); - - /* set the color information */ - if (machine->drv->color_table_len) - machine->gfx[gfx_index]->total_colors = machine->drv->color_table_len / 16; - else - machine->gfx[gfx_index]->total_colors = machine->drv->total_colors / 16; machine->gfx[gfx_index]->color_granularity = 16; /* override */ K056832_memory_region = gfx_memory_region; diff --git a/src/mame/video/konamiic.h b/src/mame/video/konamiic.h index 56fc348649d..3805c4284b0 100644 --- a/src/mame/video/konamiic.h +++ b/src/mame/video/konamiic.h @@ -44,8 +44,8 @@ The konami_rom_deinterleave() function above will do the reorganization for you in most cases (but see tmnt.c for additional bit rotations or byte permutations which may be required). */ -#define NORMAL_PLANE_ORDER 0,1,2,3 -#define REVERSE_PLANE_ORDER 3,2,1,0 +#define NORMAL_PLANE_ORDER 0x0123 +#define REVERSE_PLANE_ORDER 0x3210 /* @@ -64,7 +64,7 @@ The callback must put: */ extern tilemap *K052109_tilemap[3]; -void K052109_vh_start(running_machine *machine,int gfx_memory_region,int plane0,int plane1,int plane2,int plane3, +void K052109_vh_start(running_machine *machine,int gfx_memory_region,int plane_order, void (*callback)(int layer,int bank,int *code,int *color,int *flags,int *priority)); /* plain 8-bit access */ READ8_HANDLER( K052109_r ); @@ -92,7 +92,7 @@ The callback must put: shadow is preloaded with color & 0x80 so it doesn't need to be changed unless the game has special treatment (Aliens) */ -void K051960_vh_start(running_machine *machine,int gfx_memory_region,int plane0,int plane1,int plane2,int plane3, +void K051960_vh_start(running_machine *machine,int gfx_memory_region,int plane_order, void (*callback)(int *code,int *color,int *priority,int *shadow)); READ8_HANDLER( K051960_r ); WRITE8_HANDLER( K051960_w ); @@ -112,7 +112,7 @@ READ8_HANDLER( K052109_051960_r ); WRITE8_HANDLER( K052109_051960_w ); -void K053245_vh_start(running_machine *machine,int chip, int gfx_memory_region,int plane0,int plane1,int plane2,int plane3, +void K053245_vh_start(running_machine *machine,int chip, int gfx_memory_region,int plane_order, void (*callback)(int *code,int *color,int *priority_mask)); READ16_HANDLER( K053245_word_r ); WRITE16_HANDLER( K053245_word_w ); @@ -152,7 +152,7 @@ Callback procedures for non-standard shadows: #define K053247_CUSTOMSHADOW 0x20000000 #define K053247_SHDSHIFT 20 -void K053247_vh_start(running_machine *machine, int gfx_memory_region,int dx,int dy,int plane0,int plane1,int plane2,int plane3, +void K053247_vh_start(running_machine *machine, int gfx_memory_region,int dx,int dy,int plane_order, void (*callback)(int *code,int *color,int *priority_mask)); READ8_HANDLER( K053247_r ); WRITE8_HANDLER( K053247_w ); diff --git a/src/mame/video/ppu2c0x.c b/src/mame/video/ppu2c0x.c index f263b8b7f05..618005383a3 100644 --- a/src/mame/video/ppu2c0x.c +++ b/src/mame/video/ppu2c0x.c @@ -237,10 +237,10 @@ void ppu2c0x_init_palette(running_machine *machine, int first_entry ) } /* the charlayout we use for the chargen */ -static gfx_layout ppu_charlayout = +static const gfx_layout ppu_charlayout = { 8,8, /* 8*8 characters */ - 512, /* 512 characters - modified at runtime */ + 0, 2, /* 2 bits per pixel */ { 8*8, 0 }, /* the two bitplanes are separated */ { 0, 1, 2, 3, 4, 5, 6, 7 }, @@ -256,6 +256,7 @@ static gfx_layout ppu_charlayout = void ppu2c0x_init(running_machine *machine, const ppu2c0x_interface *interface ) { int i; + UINT32 total; /* keep a local copy of the interface */ intf = auto_malloc(sizeof(*interface)); @@ -326,20 +327,24 @@ void ppu2c0x_init(running_machine *machine, const ppu2c0x_interface *interface ) chips[i].videorom_banks = memory_region_length( intf->vrom_region[i] ) / 0x2000; /* tweak the layout accordingly */ - ppu_charlayout.total = chips[i].videorom_banks * CHARGEN_NUM_CHARS; + total = chips[i].videorom_banks * CHARGEN_NUM_CHARS; } else { chips[i].has_videorom = chips[i].videorom_banks = 0; /* we need to reset this in case of mame running multisession */ - ppu_charlayout.total = CHARGEN_NUM_CHARS; + total = CHARGEN_NUM_CHARS; } /* now create the gfx region */ { + gfx_layout gl; UINT8 *src = chips[i].has_videorom ? memory_region( intf->vrom_region[i] ) : chips[i].videoram; - machine->gfx[intf->gfx_layout_number[i]] = allocgfx( &ppu_charlayout ); + + memcpy(&gl, &ppu_charlayout, sizeof(gl)); + gl.total = total; + machine->gfx[intf->gfx_layout_number[i]] = allocgfx( &gl ); decodegfx( machine->gfx[intf->gfx_layout_number[i]], src, 0, machine->gfx[intf->gfx_layout_number[i]]->total_elements ); machine->gfx[intf->gfx_layout_number[i]]->total_colors = 8; }