summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-01-12 11:05:15 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-01-12 11:05:15 +0000
commitac0abd17066f0b9c95a64430be86c451c6ae6f32 (patch)
tree4e30749b6d6d98a9a7f6621b2b809f231b1bf96c /src
parentfa224bfe854958489065c8e5f7bfcd4590c40721 (diff)
Major drawgfx cleanup, global removal, and feature enhancements:
- Added built-in dirty tile tracking to the gfx_element. This removes the need for all drivers that had dynamically populated graphics to do their own dirty tracking. Tiles are marked dirty via the new function gfx_element_mark_dirty(). Any driver that needs access to the decoded data must call gfx_element_get_data() in order to ensure that the referenced tile is clean before proceeding. - In order to support dirty tracking, the gfx_element was enhanced to keep track of the original source pointer, so that it can go back and regenerate tiles on demand. For systems that set NULL for the region in the gfxdecode, they must use gfx_element_set_source() to specify a pointer to the raw data before drawing anything. - Changed allocgfx() to gfx_element_alloc(), and added parameters to specify the source data pointer, base color index, and total colors. Many drivers had to whack these values in after the fact, so this allowed for some minor additional cleanup. - Added a dirtyseq member to the gfx_element struct. This is incremented on each tile dirty, and can be used to sniff if something has changed. - Added logic in the tilemap engine to track which gfx_elements are used for a given tilemap, and automatically detect changes to the tiles so that drivers no longer have to explicitly invalidate the tilemap when tiles change. In the future, this may grow smarter to only invalidate the affected tiles, but for now it invalidates the entire tilemap. - Updated a number of drivers to remove their own dirty handling and leverage the new internal dirty marking. - Because the source data must always be present, updated the atarigen zwackery and mystwarr graphics handing code to support this. - Thanks to the dirty tracking, this actually allows all gfx decoding to happen on the fly instead of all at once up front. Since there was some concern that this would cause undesirable behavior due to decoding lots of tiles on the fly, it is controlled with a compile- time constant in mame.h (PREDECODE_GFX). Set this to 1 to get the old behavior back. - Moved decodechar() and decodegfx() to deprecat.h. All drivers in MAME have been updated to simply mark tiles dirty and let the rendering system decode them as needed, so these functions may go away in the future. - Rewrote entirely the rendering code in drawgfx. This code previously used extensive recursive #includes and tricks to build, and was very difficult to understand. The new code is based off of a set of macros defined in drawgfxm.h. These new macros separate the core rendering logic from the per-pixel operation, allowing the operation to be easily "plugged" into any of the renderers. These macros are also available to any driver that wants custom rendering behavior that is similar to existing core behavior, without needing to populate the core with esoteric one-off rendering behaviors. - Added a set of new functions for [p]drawgfx[zoom], one for each transparency type. The old [p]drawgfx[zoom] functions are still present, but now switch off the transparency type and call through to one of these new transparency-specific functions. The old functions are also now reduced to only supporting TRANSPARENCY_NONE, TRANSPARENCY_PEN, and TRANSPARENCY_PENS. All other rendering types must use the new functions. - All new rendering functions have extensive asserts to catch improper clipping rectangles and other common errors. - All new rendering functions automatically downgrade to optimized versions where appropriate. For example, calling drawgfx_transpen with an out-of-range pen automatically falls back to drawgfx_opaque. And drawgfxzoom_* with xscale=yscale=1.0 automatically falls back to drawgfx_*. And many other examples. In general, this relieves drivers from needing to make these sorts of decisions. - All new rendering functions have a consistent parameter order that is a bit different from the existing functions. The cliprect parameter is now specified immediately after the destination bitmap, to match the convention used throughout the rest of the system. The core parameters are followed by the scale parameters (for the zoom functions), and then followed by the priority parameters (for the pdrawgfx* functions), finally followed by any PIXEL_OP*-specific parameters (such as transparent pen, alpha, drawing tables, etc.) - Removed drawgfx_alpha_cache, alpha_set_level(), and the inline functions alpha_blend16() and alpha_blend32(). To render graphics with alpha, use the new [p]drawgfx[zoom]_alpha functions, which take an explicit alpha value. To render tilemaps with alpha, the TILEMAP_DRAW_ALPHA option now takes an explicit alpha parameter. And to do you own alpha blending, use the alpha_blend_r16() and alpha_blend_r32() functions, which take an explicit alpha. - Updated a number of drivers as a result of removing the implicit alpha in the drawgfx_alpha_cache. - Removed drawgfx_pen_table and TRANSPARENCY_PEN_TABLE. To achieve the same effect, build your own table and pass it to [p]drawgfx[zoom]_transtable, along with a pointer to the machine->shadow_table to use for shadows. Eventually machine->shadow_table is likely to go away, and drivers will need to fetch the shadow table from the palette directly. - Updated a number of drivers to remove use of drawgfx_pen_table. - Removed TRANSPARENCY_ALPHARANGE; it was only used by the psikyosh driver, so it is now moved locally into that driver and built using the macros in drawgfxm.h. - Removed TRANSPARENCY_PEN_RAW; to achieve the same effect, call the new [p]drawgfx[zoom]_transpen_raw() functions. Updated drivers to make this change. - Removed the unused mdrawgfx* functions entirely. - Added new function gfx_element_set_source_clip() to specify a source clipping rectangle for any element. This replaces the nasty hacks that were being used in bnstars, ms32, namcos86, and namcos1 to achieve similar behaviors. - Simplified the copyrozbitmap() functions to match the copybitmap() functions in having separate opaque and transparent versions. Also removed the 'priority' parameter which was only used by one driver, and moved that logic into a custom renderer built using macros in drawgfxm.h. Updated copyrozbitmap* to use the destbitmap, cliprect parameter ordering convention as well. - Simplified the draw_scanline*() functions to always render opaque. Only one driver was doing otherwise, and it now does its work internally (draw_scanline is dead-simple ever since we moved rotation to the OSD code; I almost just removed it entirely). Other changes: - Added a cliprect to the bitmap_t type, which describes the full bitmap. - Removed tilemap_set_pen_data_offset; unfortunately, this adds a random tile offset behind the scenes and goes against the dirty tile detection and invalidation. Updated the mainsnk, snk, and snk68 drivers to use old fashioned tile banking. (Sorry Nicola.) - Changed zac2650 gfxdecode to use scale factors. - Added function video_assert_out_of_range_pixels() to help find the source of invalid pixels (generally out-of-range palette entries due to invalid data or sloppy calculations). Place this after each step in your rendering in a debug build to discover which code is generating improper pixels.
Diffstat (limited to 'src')
-rw-r--r--src/emu/deprecat.h19
-rw-r--r--src/emu/drawgfx.c4784
-rw-r--r--src/emu/drawgfx.h333
-rw-r--r--src/emu/drawgfxm.h1395
-rw-r--r--src/emu/emupal.h6
-rw-r--r--src/emu/mame.c4
-rw-r--r--src/emu/mame.h4
-rw-r--r--src/emu/tilemap.c151
-rw-r--r--src/emu/tilemap.h25
-rw-r--r--src/emu/uigfx.c4
-rw-r--r--src/emu/video.c85
-rw-r--r--src/emu/video.h7
-rw-r--r--src/lib/util/bitmap.c15
-rw-r--r--src/lib/util/bitmap.h1
-rw-r--r--src/lib/util/palette.c12
-rw-r--r--src/lib/util/palette.h3
-rw-r--r--src/mame/drivers/2mindril.c15
-rw-r--r--src/mame/drivers/ace.c35
-rw-r--r--src/mame/drivers/acefruit.c6
-rw-r--r--src/mame/drivers/atarig1.c10
-rw-r--r--src/mame/drivers/bnstars.c9
-rw-r--r--src/mame/drivers/btime.c31
-rw-r--r--src/mame/drivers/cps3.c83
-rw-r--r--src/mame/drivers/cvs.c23
-rw-r--r--src/mame/drivers/fastfred.c9
-rw-r--r--src/mame/drivers/gamecstl.c4
-rw-r--r--src/mame/drivers/gticlub.c3
-rw-r--r--src/mame/drivers/hng64.c1
-rw-r--r--src/mame/drivers/hornet.c44
-rw-r--r--src/mame/drivers/igs017.c2
-rw-r--r--src/mame/drivers/limenko.c6
-rw-r--r--src/mame/drivers/madalien.c4
-rw-r--r--src/mame/drivers/mastboy.c3
-rw-r--r--src/mame/drivers/mediagx.c4
-rw-r--r--src/mame/drivers/mlanding.c24
-rw-r--r--src/mame/drivers/mogura.c5
-rw-r--r--src/mame/drivers/mpu4drvr.c34
-rw-r--r--src/mame/drivers/namcoic.c89
-rw-r--r--src/mame/drivers/namcos23.c8
-rw-r--r--src/mame/drivers/nemesis.c2
-rw-r--r--src/mame/drivers/nwk-tr.c69
-rw-r--r--src/mame/drivers/polyplay.c1
-rw-r--r--src/mame/drivers/relief.c55
-rw-r--r--src/mame/drivers/srmp6.c62
-rw-r--r--src/mame/drivers/ssv.c19
-rw-r--r--src/mame/drivers/stv.c8
-rw-r--r--src/mame/drivers/suprnova.c10
-rw-r--r--src/mame/drivers/taito_l.c46
-rw-r--r--src/mame/drivers/taitowlf.c4
-rw-r--r--src/mame/drivers/tiamc1.c26
-rw-r--r--src/mame/drivers/trvmadns.c6
-rw-r--r--src/mame/drivers/zac2650.c54
-rw-r--r--src/mame/drivers/zr107.c4
-rw-r--r--src/mame/includes/deco16ic.h2
-rw-r--r--src/mame/includes/madalien.h3
-rw-r--r--src/mame/includes/polyplay.h1
-rw-r--r--src/mame/includes/tiamc1.h7
-rw-r--r--src/mame/machine/atarigen.c39
-rw-r--r--src/mame/machine/konamigx.c46
-rw-r--r--src/mame/machine/konamigx.h4
-rw-r--r--src/mame/video/88games.c8
-rw-r--r--src/mame/video/ajax.c2
-rw-r--r--src/mame/video/aliens.c2
-rw-r--r--src/mame/video/arabian.c4
-rw-r--r--src/mame/video/asterix.c5
-rw-r--r--src/mame/video/atari.c2
-rw-r--r--src/mame/video/atarimo.c4
-rw-r--r--src/mame/video/atarisy1.c11
-rw-r--r--src/mame/video/balsente.c2
-rw-r--r--src/mame/video/battlera.c45
-rw-r--r--src/mame/video/bbusters.c5
-rw-r--r--src/mame/video/beathead.c2
-rw-r--r--src/mame/video/blockhl.c2
-rw-r--r--src/mame/video/boogwing.c12
-rw-r--r--src/mame/video/bottom9.c6
-rw-r--r--src/mame/video/btime.c54
-rw-r--r--src/mame/video/buggychl.c20
-rw-r--r--src/mame/video/bwing.c28
-rw-r--r--src/mame/video/chqflag.c4
-rw-r--r--src/mame/video/circus.c4
-rw-r--r--src/mame/video/cischeat.c23
-rw-r--r--src/mame/video/cninja.c11
-rw-r--r--src/mame/video/crimfght.c6
-rw-r--r--src/mame/video/cvs.c15
-rw-r--r--src/mame/video/dassault.c8
-rw-r--r--src/mame/video/deco16ic.c10
-rw-r--r--src/mame/video/deco32.c64
-rw-r--r--src/mame/video/deco_mlc.c34
-rw-r--r--src/mame/video/decocass.c99
-rw-r--r--src/mame/video/equites.c2
-rw-r--r--src/mame/video/exerion.c2
-rw-r--r--src/mame/video/exidy440.c2
-rw-r--r--src/mame/video/f1gp.c61
-rw-r--r--src/mame/video/gaelco2.c2
-rw-r--r--src/mame/video/gaiden.c27
-rw-r--r--src/mame/video/gbusters.c12
-rw-r--r--src/mame/video/gottlieb.c5
-rw-r--r--src/mame/video/gradius3.c32
-rw-r--r--src/mame/video/grchamp.c4
-rw-r--r--src/mame/video/gridlee.c4
-rw-r--r--src/mame/video/gticlub.c2
-rw-r--r--src/mame/video/hyprduel.c3
-rw-r--r--src/mame/video/irobot.c2
-rw-r--r--src/mame/video/itech32.c4
-rw-r--r--src/mame/video/jalblend.c6
-rw-r--r--src/mame/video/kaneko16.c4
-rw-r--r--src/mame/video/konamiic.c165
-rw-r--r--src/mame/video/konamiic.h10
-rw-r--r--src/mame/video/lemmings.c18
-rw-r--r--src/mame/video/lethal.c9
-rw-r--r--src/mame/video/m10.c14
-rw-r--r--src/mame/video/m58.c1
-rw-r--r--src/mame/video/macrossp.c12
-rw-r--r--src/mame/video/madalien.c21
-rw-r--r--src/mame/video/magmax.c4
-rw-r--r--src/mame/video/mainevt.c4
-rw-r--r--src/mame/video/mainsnk.c10
-rw-r--r--src/mame/video/mcr.c4
-rw-r--r--src/mame/video/mcr68.c34
-rw-r--r--src/mame/video/metro.c3
-rw-r--r--src/mame/video/model1.c1
-rw-r--r--src/mame/video/model2.c1
-rw-r--r--src/mame/video/moo.c2
-rw-r--r--src/mame/video/ms32.c9
-rw-r--r--src/mame/video/mystwarr.c64
-rw-r--r--src/mame/video/namcona1.c83
-rw-r--r--src/mame/video/namcos1.c39
-rw-r--r--src/mame/video/namcos2.c11
-rw-r--r--src/mame/video/namcos22.c48
-rw-r--r--src/mame/video/namcos86.c9
-rw-r--r--src/mame/video/nemesis.c97
-rw-r--r--src/mame/video/parodius.c2
-rw-r--r--src/mame/video/plygonet.c5
-rw-r--r--src/mame/video/polepos.c6
-rw-r--r--src/mame/video/policetr.c2
-rw-r--r--src/mame/video/polyplay.c15
-rw-r--r--src/mame/video/ppu2c0x.c65
-rw-r--r--src/mame/video/psikyosh.c213
-rw-r--r--src/mame/video/psx.c4
-rw-r--r--src/mame/video/qix.c6
-rw-r--r--src/mame/video/rallyx.c105
-rw-r--r--src/mame/video/realbrk.c16
-rw-r--r--src/mame/video/relief.c6
-rw-r--r--src/mame/video/rockola.c10
-rw-r--r--src/mame/video/rohga.c20
-rw-r--r--src/mame/video/rollerg.c2
-rw-r--r--src/mame/video/rungun.c5
-rw-r--r--src/mame/video/segag80r.c14
-rw-r--r--src/mame/video/segaic24.c39
-rw-r--r--src/mame/video/segaic24.h1
-rw-r--r--src/mame/video/segas24.c2
-rw-r--r--src/mame/video/segasyse.c7
-rw-r--r--src/mame/video/seibuspi.c4
-rw-r--r--src/mame/video/shangha3.c26
-rw-r--r--src/mame/video/skyraid.c6
-rw-r--r--src/mame/video/snes.c31
-rw-r--r--src/mame/video/snk.c90
-rw-r--r--src/mame/video/snk68.c10
-rw-r--r--src/mame/video/spbactn.c16
-rw-r--r--src/mame/video/spy.c2
-rw-r--r--src/mame/video/ssv.c56
-rw-r--r--src/mame/video/st0016.c40
-rw-r--r--src/mame/video/stvvdp2.c198
-rw-r--r--src/mame/video/suprnova.c59
-rw-r--r--src/mame/video/surpratk.c2
-rw-r--r--src/mame/video/tail2nos.c29
-rw-r--r--src/mame/video/taito_b.c10
-rw-r--r--src/mame/video/taito_f2.c4
-rw-r--r--src/mame/video/taito_f3.c55
-rw-r--r--src/mame/video/taito_l.c44
-rw-r--r--src/mame/video/taitoic.c216
-rw-r--r--src/mame/video/taitojc.c32
-rw-r--r--src/mame/video/taitosj.c69
-rw-r--r--src/mame/video/tatsumi.c10
-rw-r--r--src/mame/video/tceptor.c22
-rw-r--r--src/mame/video/tecmo16.c30
-rw-r--r--src/mame/video/thunderx.c2
-rw-r--r--src/mame/video/tiamc1.c51
-rw-r--r--src/mame/video/tmnt.c16
-rw-r--r--src/mame/video/toaplan1.c4
-rw-r--r--src/mame/video/toaplan2.c16
-rw-r--r--src/mame/video/toypop.c5
-rw-r--r--src/mame/video/tryout.c5
-rw-r--r--src/mame/video/tunhunt.c8
-rw-r--r--src/mame/video/ultraman.c4
-rw-r--r--src/mame/video/usgames.c6
-rw-r--r--src/mame/video/victory.c5
-rw-r--r--src/mame/video/wecleman.c18
-rw-r--r--src/mame/video/wrally.c2
-rw-r--r--src/mame/video/xexex.c2
-rw-r--r--src/mame/video/xmen.c6
-rw-r--r--src/mame/video/ygv608.c11
-rw-r--r--src/mame/video/zac2650.c16
193 files changed, 4816 insertions, 6074 deletions
diff --git a/src/emu/deprecat.h b/src/emu/deprecat.h
index 175a32b4454..1f1059f31de 100644
--- a/src/emu/deprecat.h
+++ b/src/emu/deprecat.h
@@ -54,4 +54,23 @@
int cpu_getiloops(const device_config *device);
+
+/*************************************
+ *
+ * Graphics decoding. Drivers should
+ * use the new gfx_element_mark_dirty()
+ * to explicitly mark tiles dirty, and
+ * gfx_element_get_data() to fetch a
+ * pointer to the data (and undirty
+ * the tile)
+ *
+ *************************************/
+
+/* decode a series of tiles from a particular gfx_element */
+void decodegfx(gfx_element *gfx, UINT32 first, UINT32 count);
+
+void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src);
+
+
+
#endif /* __DEPRECAT_H__ */
diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c
index 66b3bf0b94f..bafeff0886f 100644
--- a/src/emu/drawgfx.c
+++ b/src/emu/drawgfx.c
@@ -9,38 +9,24 @@
*********************************************************************/
-#ifndef DECLAREG
-
#include "driver.h"
-#include "profiler.h"
+#include "drawgfxm.h"
/***************************************************************************
- CONSTANTS
+ GLOBAL VARIABLES
***************************************************************************/
-#ifdef LSB_FIRST
-#define SHIFT0 0
-#define SHIFT1 8
-#define SHIFT2 16
-#define SHIFT3 24
-#else
-#define SHIFT3 0
-#define SHIFT2 8
-#define SHIFT1 16
-#define SHIFT0 24
-#endif
+/* if this line errors during compile, the size of NO_PRIORITY is wrong and I need to use something else */
+UINT8 no_priority_size_is_wrong[2 * (sizeof(NO_PRIORITY) == 3) - 1];
/***************************************************************************
- GLOBAL VARIABLES
+ FUNCTION PROTOTYPES
***************************************************************************/
-UINT8 gfx_drawmode_table[256];
-UINT8 gfx_alpharange_table[256];
-
-alpha_cache drawgfx_alpha_cache;
+void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src);
@@ -49,33 +35,6 @@ alpha_cache drawgfx_alpha_cache;
***************************************************************************/
/*-------------------------------------------------
- write_dword - safely write an unaligned DWORD
--------------------------------------------------*/
-
-#ifdef ALIGN_INTS /* GSL 980108 read/write nonaligned dword routine for ARM processor etc */
-
-INLINE void write_dword(void *address, UINT32 data)
-{
- if ((FPTR)address & 3)
- {
- *((UINT8 *)address) = (data>>SHIFT0);
- *((UINT8 *)address+1) = (data>>SHIFT1);
- *((UINT8 *)address+2) = (data>>SHIFT2);
- *((UINT8 *)address+3) = (data>>SHIFT3);
- return;
- }
- else
- *(UINT32 *)address = data;
-}
-
-#else
-
-#define write_dword(address,data) *(int *)address=data
-
-#endif
-
-
-/*-------------------------------------------------
readbit - read a single bit from a base
offset
-------------------------------------------------*/
@@ -86,141 +45,41 @@ INLINE int readbit(const UINT8 *src, unsigned int bitnum)
}
-
-/***************************************************************************
- INITIALIZATION
-***************************************************************************/
-
-void drawgfx_init(running_machine *machine)
-{
- /* initialize the alpha drawing table */
- alpha_set_level(255);
-}
-
-
-
-/***************************************************************************
- GRAPHICS DECODING
-***************************************************************************/
-
/*-------------------------------------------------
- calc_penusage - calculate the pen usage for
- a given graphics tile
+ normalize_xscroll - normalize an X scroll
+ value for a bitmap to be positive and less
+ than the width
-------------------------------------------------*/
-static void calc_penusage(gfx_element *gfx, int num)
+INLINE INT32 normalize_xscroll(bitmap_t *bitmap, INT32 xscroll)
{
- const UINT8 *dp = gfx->gfxdata + num * gfx->char_modulo;
- UINT32 usage = 0;
- int x, y;
-
- /* if nothing allocated, don't do it */
- if (!gfx->pen_usage)
- return;
-
- /* packed case */
- if (gfx->flags & GFX_ELEMENT_PACKED)
- for (y = 0; y < gfx->height; y++)
- {
- for (x = 0; x < gfx->width/2; x++)
- usage |= (1 << (dp[x] & 0x0f)) | (1 << (dp[x] >> 4));
-
- dp += gfx->line_modulo;
- }
-
- /* unpacked case */
- else
- for (y = 0; y < gfx->height; y++)
- {
- for (x = 0; x < gfx->width; x++)
- usage |= 1 << dp[x];
-
- dp += gfx->line_modulo;
- }
-
- /* store the final result */
- gfx->pen_usage[num] = usage;
+ return (xscroll >= 0) ? xscroll % bitmap->width : (bitmap->width - (-xscroll) % bitmap->width);
}
/*-------------------------------------------------
- decodechar - decode a single character based
- on a specified layout
+ normalize_yscroll - normalize a Y scroll
+ value for a bitmap to be positive and less
+ than the height
-------------------------------------------------*/
-void decodechar(gfx_element *gfx, int num, const UINT8 *src)
+INLINE INT32 normalize_yscroll(bitmap_t *bitmap, INT32 yscroll)
{
- const gfx_layout *gl = &gfx->layout;
- 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 < planes; plane++)
- {
- int planebit = 1 << (planes - 1 - plane);
- int planeoffs = num * charincrement + poffset[plane];
-
- for (y = 0; y < gfx->height; y++)
- {
- int yoffs = planeoffs + yoffset[y];
-
- dp = gfx->gfxdata + num * gfx->char_modulo + y * gfx->line_modulo;
- for (x = 0; x < gfx->width; x += 2)
- {
- if (readbit(src, yoffs + xoffset[x+0]))
- dp[x+0] |= planebit;
- if (readbit(src, yoffs + xoffset[x+1]))
- dp[x+1] |= planebit;
- }
- }
- }
-
- /* unpacked case */
- else
- for (plane = 0; plane < planes; plane++)
- {
- int planebit = 1 << (planes - 1 - plane);
- int planeoffs = num * charincrement + poffset[plane];
-
- for (y = 0; y < gfx->height; y++)
- {
- int yoffs = planeoffs + yoffset[y];
-
- dp = gfx->gfxdata + num * gfx->char_modulo + y * gfx->line_modulo;
- for (x = 0; x < gfx->width; x++)
- if (readbit(src, yoffs + xoffset[x]))
- dp[x] |= planebit;
- }
- }
-
- /* compute pen usage */
- calc_penusage(gfx, num);
+ return (yscroll >= 0) ? yscroll % bitmap->height : (bitmap->height - (-yscroll) % bitmap->height);
}
/***************************************************************************
- GRAPHICS SETS
+ GRAPHICS ELEMENTS
***************************************************************************/
/*-------------------------------------------------
- allocgfx - allocate a gfx_element structure
+ gfx_element_alloc - allocate a gfx_element structure
based on a given layout
-------------------------------------------------*/
-gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl)
+gfx_element *gfx_element_alloc(running_machine *machine, const gfx_layout *gl, const UINT8 *srcdata, UINT32 total_colors, UINT32 color_base)
{
int israw = (gl->planeoffset[0] == GFX_RAW);
int planes = gl->planes;
@@ -233,33 +92,61 @@ gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl)
gfx = malloc_or_die(sizeof(*gfx));
memset(gfx, 0, sizeof(*gfx));
+ /* fill in the data */
+ gfx->width = width;
+ gfx->height = height;
+
+ gfx->origwidth = width;
+ gfx->origheight = height;
+ gfx->total_elements = total;
+
+ gfx->color_base = color_base;
+ gfx->color_depth = 1 << planes;
+ gfx->color_granularity = 1 << planes;
+ gfx->total_colors = total_colors;
+
+ gfx->srcdata = srcdata;
gfx->machine = machine;
/* copy the layout */
gfx->layout = *gl;
- if (gl->extxoffs != NULL)
+ if (gfx->layout.extxoffs != NULL)
{
- UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gl->width);
- memcpy(buffer, gl->extxoffs, sizeof(gfx->layout.extxoffs[0]) * gl->width);
- gfx->layout.extxoffs = buffer;
+ if (gfx->layout.width < ARRAY_LENGTH(gfx->layout.xoffset))
+ {
+ memcpy(gfx->layout.xoffset, gfx->layout.extxoffs, sizeof(gfx->layout.xoffset[0]) * gfx->layout.width);
+ gfx->layout.extxoffs = NULL;
+ }
+ else
+ {
+ UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gfx->layout.width);
+ memcpy(buffer, gfx->layout.extxoffs, sizeof(gfx->layout.extxoffs[0]) * gfx->layout.width);
+ gfx->layout.extxoffs = buffer;
+ }
}
- if (gl->extyoffs != NULL)
+ if (gfx->layout.extyoffs != NULL)
{
- UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gl->height);
- memcpy(buffer, gl->extyoffs, sizeof(gfx->layout.extyoffs[0]) * gl->height);
- gfx->layout.extyoffs = buffer;
+ if (gfx->layout.height < ARRAY_LENGTH(gfx->layout.yoffset))
+ {
+ memcpy(gfx->layout.yoffset, gfx->layout.extyoffs, sizeof(gfx->layout.yoffset[0]) * gfx->layout.height);
+ gfx->layout.extyoffs = NULL;
+ }
+ else
+ {
+ UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gfx->layout.height);
+ memcpy(buffer, gfx->layout.extyoffs, sizeof(gfx->layout.extyoffs[0]) * gfx->layout.height);
+ gfx->layout.extyoffs = buffer;
+ }
}
- /* fill in the rest */
- gfx->width = width;
- gfx->height = height;
- gfx->total_elements = total;
- gfx->color_base = 0;
- gfx->color_depth = 1 << planes;
- gfx->color_granularity = 1 << planes;
+ /* allocate a pen usage array for entries with 32 pens or less */
if (gfx->color_depth <= 32)
gfx->pen_usage = malloc_or_die(gfx->total_elements * sizeof(*gfx->pen_usage));
+
+ /* allocate a dirty array */
+ gfx->dirty = malloc_or_die(gfx->total_elements * sizeof(*gfx->dirty));
+ memset(gfx->dirty, 1, gfx->total_elements * sizeof(*gfx->dirty));
/* raw graphics case */
if (israw)
@@ -272,17 +159,20 @@ gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl)
gfx->flags |= GFX_ELEMENT_DONT_FREE;
if (planes <= 4)
gfx->flags |= GFX_ELEMENT_PACKED;
+
+ /* RAW graphics must have a pointer up front */
+ gfx->gfxdata = (UINT8 *)gfx->srcdata;
}
/* decoded graphics case */
else
{
/* we get to pick our own modulos */
- gfx->line_modulo = gfx->width;
- gfx->char_modulo = gfx->line_modulo * gfx->height;
+ gfx->line_modulo = gfx->origwidth;
+ gfx->char_modulo = gfx->line_modulo * gfx->origheight;
/* allocate memory for the data */
- gfx->gfxdata = malloc_or_die(gfx->total_elements * gfx->char_modulo * sizeof(UINT8));
+ gfx->gfxdata = malloc_or_die(gfx->total_elements * gfx->char_modulo);
}
return gfx;
@@ -290,55 +180,35 @@ gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl)
/*-------------------------------------------------
- decodegfx - decode a series of tiles from
- a particular gfx_element
+ gfx_element_decode - update a single code in
+ a gfx_element
-------------------------------------------------*/
-void decodegfx(gfx_element *gfx, const UINT8 *src, UINT32 first, UINT32 count)
+void gfx_element_decode(const gfx_element *gfx, UINT32 code)
{
- int last = first + count - 1;
- int c;
-
- assert(gfx);
- assert(first < gfx->total_elements);
- assert(last < gfx->total_elements);
-
- /* if this is raw graphics data, just set the pointer and compute pen usage */
- if (gfx->flags & GFX_ELEMENT_DONT_FREE)
- {
- /* if we got a pointer, set it */
- if (first == 0 && src)
- gfx->gfxdata = (UINT8 *)src;
-
- /* compute pen usage for everything */
- for (c = first; c <= last; c++)
- calc_penusage(gfx, c);
- }
-
- /* otherwise, we get to manually decode */
- else
- for (c = first; c <= last; c++)
- decodechar(gfx, c, src);
+ decodechar(gfx, code, gfx->srcdata);
}
/*-------------------------------------------------
- freegfx - free a gfx_element
+ gfx_element_free - free a gfx_element
-------------------------------------------------*/
-void freegfx(gfx_element *gfx)
+void gfx_element_free(gfx_element *gfx)
{
/* ignore NULL frees */
if (gfx == NULL)
return;
/* free our data */
- if (gfx->layout.extyoffs)
+ if (gfx->layout.extyoffs != NULL)
free((void *)gfx->layout.extyoffs);
- if (gfx->layout.extxoffs)
+ if (gfx->layout.extxoffs != NULL)
free((void *)gfx->layout.extxoffs);
- if (gfx->pen_usage)
+ if (gfx->pen_usage != NULL)
free(gfx->pen_usage);
+ if (gfx->dirty != NULL)
+ free(gfx->dirty);
if (!(gfx->flags & GFX_ELEMENT_DONT_FREE))
free(gfx->gfxdata);
free(gfx);
@@ -346,3457 +216,1779 @@ void freegfx(gfx_element *gfx)
-/***************************************************************************
- BLOCKMOVE PRIMITIVES
-***************************************************************************/
+/*-------------------------------------------------
+ calc_penusage - calculate the pen usage for
+ a given graphics tile
+-------------------------------------------------*/
-INLINE void blockmove_NtoN_transpen_noremap16(
- const UINT16 *srcdata,int srcwidth,int srcheight,int srcmodulo,
- UINT16 *dstdata,int dstmodulo,
- int transpen)
+static void calc_penusage(const gfx_element *gfx, UINT32 code)
{
- UINT16 *end;
+ const UINT8 *dp = gfx->gfxdata + code * gfx->char_modulo;
+ UINT32 usage = 0;
+ int x, y;
- srcmodulo -= srcwidth;
- dstmodulo -= srcwidth;
+ /* if nothing allocated, don't do it */
+ if (gfx->pen_usage == NULL)
+ return;
- while (srcheight)
- {
- end = dstdata + srcwidth;
- while (dstdata < end)
+ /* packed case */
+ if (gfx->flags & GFX_ELEMENT_PACKED)
+ for (y = 0; y < gfx->origheight; y++)
+ {
+ for (x = 0; x < gfx->origwidth/2; x++)
+ usage |= (1 << (dp[x] & 0x0f)) | (1 << (dp[x] >> 4));
+
+ dp += gfx->line_modulo;
+ }
+
+ /* unpacked case */
+ else
+ for (y = 0; y < gfx->origheight; y++)
{
- int col;
+ for (x = 0; x < gfx->origwidth; x++)
+ usage |= 1 << dp[x];
- col = *(srcdata++);
- if (col != transpen) *dstdata = col;
- dstdata++;
+ dp += gfx->line_modulo;
}
- srcdata += srcmodulo;
- dstdata += dstmodulo;
- srcheight--;
- }
+ /* store the final result */
+ gfx->pen_usage[code] = usage;
}
-INLINE void blockmove_NtoN_transpen_noremap_flipx16(
- const UINT16 *srcdata,int srcwidth,int srcheight,int srcmodulo,
- UINT16 *dstdata,int dstmodulo,
- int transpen)
-{
- UINT16 *end;
- srcmodulo += srcwidth;
- dstmodulo -= srcwidth;
+/*-------------------------------------------------
+ decodechar - decode a single character based
+ on a specified layout
+-------------------------------------------------*/
- while (srcheight)
+void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src)
+{
+ const gfx_layout *gl = &gfx->layout;
+ 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 + code * gfx->char_modulo;
+ int plane, x, y;
+
+ if (!israw)
{
- end = dstdata + srcwidth;
- while (dstdata < end)
- {
- int col;
-
- col = *(srcdata--);
- if (col != transpen) *dstdata = col;
- dstdata++;
- }
+ /* zap the data to 0 */
+ memset(dp, 0, gfx->char_modulo);
- srcdata += srcmodulo;
- dstdata += dstmodulo;
- srcheight--;
- }
-}
+ /* packed case */
+ if (gfx->flags & GFX_ELEMENT_PACKED)
+ for (plane = 0; plane < planes; plane++)
+ {
+ int planebit = 1 << (planes - 1 - plane);
+ int planeoffs = code * charincrement + poffset[plane];
-INLINE void blockmove_NtoN_transpen_noremap32(
- const UINT32 *srcdata,int srcwidth,int srcheight,int srcmodulo,
- UINT32 *dstdata,int dstmodulo,
- int transpen)
-{
- UINT32 *end;
+ for (y = 0; y < gfx->origheight; y++)
+ {
+ int yoffs = planeoffs + yoffset[y];
- srcmodulo -= srcwidth;
- dstmodulo -= srcwidth;
+ dp = gfx->gfxdata + code * gfx->char_modulo + y * gfx->line_modulo;
+ for (x = 0; x < gfx->origwidth; x += 2)
+ {
+ if (readbit(src, yoffs + xoffset[x+0]))
+ dp[x+0] |= planebit;
+ if (readbit(src, yoffs + xoffset[x+1]))
+ dp[x+1] |= planebit;
+ }
+ }
+ }
- while (srcheight)
- {
- end = dstdata + srcwidth;
- while (dstdata < end)
- {
- int col;
+ /* unpacked case */
+ else
+ for (plane = 0; plane < planes; plane++)
+ {
+ int planebit = 1 << (planes - 1 - plane);
+ int planeoffs = code * charincrement + poffset[plane];
- col = *(srcdata++);
- if (col != transpen) *dstdata = col;
- dstdata++;
- }
+ for (y = 0; y < gfx->origheight; y++)
+ {
+ int yoffs = planeoffs + yoffset[y];
- srcdata += srcmodulo;
- dstdata += dstmodulo;
- srcheight--;
+ dp = gfx->gfxdata + code * gfx->char_modulo + y * gfx->line_modulo;
+ for (x = 0; x < gfx->origwidth; x++)
+ if (readbit(src, yoffs + xoffset[x]))
+ dp[x] |= planebit;
+ }
+ }
}
+
+ /* compute pen usage */
+ calc_penusage(gfx, code);
+
+ /* no longer dirty */
+ gfx->dirty[code] = 0;
}
-INLINE void blockmove_NtoN_transpen_noremap_flipx32(
- const UINT32 *srcdata,int srcwidth,int srcheight,int srcmodulo,
- UINT32 *dstdata,int dstmodulo,
- int transpen)
+
+/*-------------------------------------------------
+ decodegfx - decode a series of tiles from
+ a particular gfx_element
+-------------------------------------------------*/
+
+void decodegfx(gfx_element *gfx, UINT32 first, UINT32 count)
{
- UINT32 *end;
+ int last = first + count - 1;
+ int c;
- srcmodulo += srcwidth;
- dstmodulo -= srcwidth;
+ assert(gfx != NULL);
+ assert(gfx->srcdata != NULL);
+ assert(first < gfx->total_elements);
+ assert(last < gfx->total_elements);
- while (srcheight)
+ /* if this is raw graphics data, just set the pointer and compute pen usage */
+ if (gfx->flags & GFX_ELEMENT_DONT_FREE)
{
- end = dstdata + srcwidth;
- while (dstdata < end)
- {
- int col;
-
- col = *(srcdata--);
- if (col != transpen) *dstdata = col;
- dstdata++;
- }
+ /* if we got a pointer, set it */
+ gfx->gfxdata = (UINT8 *)gfx->srcdata;
- srcdata += srcmodulo;
- dstdata += dstmodulo;
- srcheight--;
+ /* compute pen usage for everything */
+ for (c = first; c <= last; c++)
+ calc_penusage(gfx, c);
}
-}
-
-
-static int afterdrawmask = 31;
-int pdrawgfx_shadow_lowpri = 0;
-
-/* 8-bit version (only used to generate the draw_scanline family of functions) */
-#define DATA_TYPE UINT8
-#define DEPTH 8
-#define DECLAREG(function,args,body) void function##8 args body
-#include "drawgfx.c"
-#undef DECLAREG
-#undef DEPTH
-#undef DATA_TYPE
-
-/* 16-bit version */
-#define DATA_TYPE UINT16
-#define DEPTH 16
-#define alpha_blend_r alpha_blend_r16
-#define alpha_blend alpha_blend16
-
-#define DECLARE(function,args,body)
-#define DECLAREG(function,args,body)
-
-#define HMODULO 1
-#define VMODULO dstmodulo
-#define COMMON_ARGS \
- pen_t *palette_shadow_table, \
- const UINT8 *srcdata,int srcwidth,int srcheight,int srcmodulo, \
- int leftskip,int topskip,int flipx,int flipy, \
- DATA_TYPE *dstdata,int dstwidth,int dstheight,int dstmodulo
-
-#define RAW 1
-#define COLOR_ARG int color,UINT8 *pridata,UINT32 pmask
-#define INCREMENT_DST(n) {dstdata+=(n);pridata += (n);}
-#define LOOKUP(n) (color + (n))
-#define SETPIXELCOLOR(dest,n) { if (((1 << (pridata[dest] & 0x1f)) & pmask) == 0) { if (pridata[dest] & 0x80) { dstdata[dest] = palette_shadow_table[n];} else { dstdata[dest] = (n);} } pridata[dest] = (pridata[dest] & 0x7f) | afterdrawmask; }
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw_pri16 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef SETPIXELCOLOR
-#undef RAW
-
-#define RAW 0
-#define COLOR_ARG int colorbase,const pen_t *paldata,UINT8 *pridata,UINT32 pmask
-#define LOOKUP(n) (paldata[n])
-//#define LOOKUP(n) (colorbase + (n))
-#define SETPIXELCOLOR(dest,n) { if (((1 << (pridata[dest] & 0x1f)) & pmask) == 0) { if (pridata[dest] & 0x80) { dstdata[dest] = palette_shadow_table[n];} else { dstdata[dest] = (n);} } pridata[dest] = (pridata[dest] & 0x7f) | afterdrawmask; }
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_pri16 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef INCREMENT_DST
-#undef SETPIXELCOLOR
-#undef RAW
-
-#define RAW 1
-#define COLOR_ARG int color
-#define INCREMENT_DST(n) {dstdata+=(n);}
-#define LOOKUP(n) (color + (n))
-#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw16 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef SETPIXELCOLOR
-#undef RAW
-
-#define RAW 0
-#define COLOR_ARG int colorbase, const pen_t *paldata
-#define LOOKUP(n) (paldata[n])
-//#define LOOKUP(n) (colorbase + (n))
-#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##16 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef INCREMENT_DST
-#undef SETPIXELCOLOR
-
-#undef HMODULO
-#undef VMODULO
-#undef COMMON_ARGS
-#undef DECLARE
-#undef DECLAREG
-
-#define DECLARE(function,args,body) static void function##16 args body
-#define DECLAREG(function,args,body) void function##16 args body
-#define DECLARE_SWAP_RAW_PRI(function,args,body)
-#define BLOCKMOVE(function,flipx,args) \
- if (flipx) blockmove_##function##_flipx##16 args ; \
- else blockmove_##function##16 args
-#define BLOCKMOVELU(function,args) \
- blockmove_##function##16 args
-#define BLOCKMOVERAW(function,args) \
- blockmove_##function##_raw##16 args
-#define BLOCKMOVEPRI(function,args) \
- blockmove_##function##_pri##16 args
-#define BLOCKMOVERAWPRI(function,args) \
- blockmove_##function##_raw_pri##16 args
-#include "drawgfx.c"
-#undef DECLARE
-#undef DECLARE_SWAP_RAW_PRI
-#undef DECLAREG
-#undef BLOCKMOVE
-#undef BLOCKMOVELU
-#undef BLOCKMOVERAW
-#undef BLOCKMOVEPRI
-#undef BLOCKMOVERAWPRI
-
-#undef RAW
-#undef DEPTH
-#undef DATA_TYPE
-#undef alpha_blend_r
-#undef alpha_blend
-
-/* 32-bit version */
-INLINE UINT32 SHADOW32(pen_t *shadow_table, UINT32 c)
-{
- return shadow_table[((c >> 9) & 0x7c00) | ((c >> 6) & 0x03e0) | ((c >> 3) & 0x001f)];
+ /* otherwise, we get to manually decode */
+ else
+ for (c = first; c <= last; c++)
+ decodechar(gfx, c, gfx->srcdata);
}
-#define DATA_TYPE UINT32
-#define DEPTH 32
-#define alpha_blend_r alpha_blend_r32
-#define alpha_blend alpha_blend32
-
-#define DECLARE(function,args,body)
-#define DECLAREG(function,args,body)
-
-#define HMODULO 1
-#define VMODULO dstmodulo
-#define COMMON_ARGS \
- pen_t *palette_shadow_table, \
- const UINT8 *srcdata,int srcwidth,int srcheight,int srcmodulo, \
- int leftskip,int topskip,int flipx,int flipy, \
- DATA_TYPE *dstdata,int dstwidth,int dstheight,int dstmodulo
-
-#define RAW 1
-#define COLOR_ARG int color,UINT8 *pridata,UINT32 pmask
-#define INCREMENT_DST(n) {dstdata+=(n);pridata += (n);}
-#define LOOKUP(n) (color + (n))
-#define SETPIXELCOLOR(dest,n) { UINT8 r8=pridata[dest]; if(!(1<<(r8&0x1f)&pmask)){ if(afterdrawmask){ r8&=0x7f; r8|=0x1f; dstdata[dest]=(n); pridata[dest]=r8; } else if(!(r8&0x80)){ dstdata[dest]=SHADOW32(palette_shadow_table,n); pridata[dest]|=0x80; } } }
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw_pri32 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef SETPIXELCOLOR
-#undef RAW
-
-#define RAW 0
-#define COLOR_ARG int colorbase,const pen_t *paldata,UINT8 *pridata,UINT32 pmask
-#define LOOKUP(n) (paldata[n])
-//#define LOOKUP(n) (colorbase + (n))
-#define SETPIXELCOLOR(dest,n) { UINT8 r8=pridata[dest]; if(!(1<<(r8&0x1f)&pmask)){ if(afterdrawmask){ r8&=0x7f; r8|=0x1f; dstdata[dest]=(n); pridata[dest]=r8; } else if(!(r8&0x80)){ dstdata[dest]=SHADOW32(palette_shadow_table,n); pridata[dest]|=0x80; } } }
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_pri32 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef INCREMENT_DST
-#undef SETPIXELCOLOR
-#undef RAW
-
-#define RAW 1
-#define COLOR_ARG int color
-#define INCREMENT_DST(n) {dstdata+=(n);}
-#define LOOKUP(n) (color + (n))
-#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw32 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef SETPIXELCOLOR
-#undef RAW
-
-#define RAW 0
-#define COLOR_ARG int colorbase, const pen_t *paldata
-#define LOOKUP(n) (paldata[n])
-//#define LOOKUP(n) (colorbase + (n))
-#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
-#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##32 args body
-#include "drawgfx.c"
-#undef DECLARE_SWAP_RAW_PRI
-#undef COLOR_ARG
-#undef LOOKUP
-#undef INCREMENT_DST
-#undef SETPIXELCOLOR
-
-#undef HMODULO
-#undef VMODULO
-#undef COMMON_ARGS
-#undef DECLARE
-#undef DECLAREG
-
-#define DECLARE(function,args,body) static void function##32 args body
-#define DECLAREG(function,args,body) void function##32 args body
-#define DECLARE_SWAP_RAW_PRI(function,args,body)
-#define BLOCKMOVE(function,flipx,args) \
- if (flipx) blockmove_##function##_flipx##32 args ; \
- else blockmove_##function##32 args
-#define BLOCKMOVELU(function,args) \
- blockmove_##function##32 args
-#define BLOCKMOVERAW(function,args) \
- blockmove_##function##_raw##32 args
-#define BLOCKMOVEPRI(function,args) \
- blockmove_##function##_pri##32 args
-#define BLOCKMOVERAWPRI(function,args) \
- blockmove_##function##_raw_pri##32 args
-#include "drawgfx.c"
-#undef DECLARE
-#undef DECLARE_SWAP_RAW_PRI
-#undef DECLAREG
-#undef BLOCKMOVE
-#undef BLOCKMOVELU
-#undef BLOCKMOVERAW
-#undef BLOCKMOVEPRI
-#undef BLOCKMOVERAWPRI
-
-#undef RAW
-#undef DEPTH
-#undef DATA_TYPE
-#undef alpha_blend_r
-#undef alpha_blend
/***************************************************************************
+ DRAWGFX IMPLEMENTATIONS
+***************************************************************************/
- Draw graphic elements in the specified bitmap.
+/*-------------------------------------------------
+ drawgfx - generic drawgfx with legacy
+ interface
+-------------------------------------------------*/
- transparency == TRANSPARENCY_NONE - no transparency.
- transparency == TRANSPARENCY_PEN - bits whose _original_ value is == transparent_color
- are transparent. This is the most common kind of
- transparency.
- transparency == TRANSPARENCY_PENS - as above, but transparent_color is a mask of
- transparent pens.
- transparency == TRANSPARENCY_PEN_TABLE - the transparency condition is same as TRANSPARENCY_PEN
- A special drawing is done according to gfx_drawmode_table[source pixel].
- DRAWMODE_NONE transparent
- DRAWMODE_SOURCE normal, draw source pixel.
- DRAWMODE_SHADOW destination is changed through palette_shadow_table[]
+void drawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
+ INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color)
+{
+ switch (transparency)
+ {
+ case TRANSPARENCY_NONE:
+ drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy);
+ break;
+
+ case TRANSPARENCY_PEN:
+ drawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, transparent_color);
+ break;
+
+ case TRANSPARENCY_PENS:
+ drawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, transparent_color);
+ break;
+
+ default:
+ fatalerror("Invalid transparency specified for drawgfx (%d)", transparency);
+ break;
+ }
+}
-***************************************************************************/
-INLINE void common_drawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
- bitmap_t *pri_buffer,UINT32 pri_mask)
+/*-------------------------------------------------
+ drawgfx_opaque - render a gfx element with
+ no transparency
+-------------------------------------------------*/
+
+void drawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty)
{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
+
assert(dest != NULL);
- assert((dest->bpp == 16) || (dest->bpp == 32));
+ assert(dest->bpp == 16 || dest->bpp == 32);
assert(gfx != NULL);
+ /* get final code and color, and grab lookup tables */
code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+}
- if (transparency != TRANSPARENCY_PEN_RAW)
- color %= gfx->total_colors;
- if ((dest->format == BITMAP_FORMAT_INDEXED16 || dest->format == BITMAP_FORMAT_INDEXED32) &&
- (transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHARANGE))
- {
- transparency = TRANSPARENCY_PEN;
- transparent_color &= 0xff;
- }
+/*-------------------------------------------------
+ drawgfx_transpen - render a gfx element with
+ a single transparent pen
+-------------------------------------------------*/
- if (gfx->pen_usage && (transparency == TRANSPARENCY_PEN || transparency == TRANSPARENCY_PENS))
+void drawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 transpen)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
+
+ /* special case invalid pens to opaque */
+ if (transpen > 0xff)
{
- int transmask = 0;
+ drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
+ return;
+ }
- if (transparency == TRANSPARENCY_PEN)
- transmask = 1 << (transparent_color & 0xff);
- else /* transparency == TRANSPARENCY_PENS */
- transmask = transparent_color;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- if ((gfx->pen_usage[code] & ~transmask) == 0)
- /* character is totally transparent, no need to draw */
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
+ {
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~(1 << transpen)) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & (1 << transpen)) == 0)
+ {
+ drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
return;
- else if ((gfx->pen_usage[code] & transmask) == 0)
- /* character is totally opaque, can disable transparency */
- transparency = TRANSPARENCY_NONE;
+ }
}
+ /* render based on dest bitmap depth */
if (dest->bpp == 16)
- drawgfx_core16(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,pri_buffer,pri_mask);
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
else
- drawgfx_core32(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,pri_buffer,pri_mask);
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
}
-void drawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color)
-{
- profiler_mark(PROFILER_DRAWGFX);
- common_drawgfx(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,NULL,0);
- profiler_mark(PROFILER_END);
-}
-void pdrawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,UINT32 priority_mask)
-{
- profiler_mark(PROFILER_DRAWGFX);
- common_drawgfx(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,priority_bitmap,priority_mask | (1<<31));
- profiler_mark(PROFILER_END);
-}
+/*-------------------------------------------------
+ drawgfx_transpen_raw - render a gfx element
+ with a single transparent pen and no color
+ lookups
+-------------------------------------------------*/
-void mdrawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,UINT32 priority_mask)
+void drawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 transpen)
{
- profiler_mark(PROFILER_DRAWGFX);
- common_drawgfx(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,priority_bitmap,priority_mask);
- profiler_mark(PROFILER_END);
-}
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
-
-/***************************************************************************
-
- Use copybitmap() to copy a bitmap onto another at the given position.
-
-***************************************************************************/
-static void copybitmap_common(bitmap_t *dest,bitmap_t *src,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color)
-{
assert(dest != NULL);
- assert(src != NULL);
- assert((dest->bpp == 16) || (dest->bpp == 32));
- assert(dest->bpp == src->bpp);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- profiler_mark(PROFILER_COPYBITMAP);
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
+ /* render based on dest bitmap depth */
if (dest->bpp == 16)
- copybitmap_core16(dest,src,flipx,flipy,sx,sy,clip,transparency,transparent_color);
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
else
- copybitmap_core32(dest,src,flipx,flipy,sx,sy,clip,transparency,transparent_color);
-
- profiler_mark(PROFILER_END);
-}
-
-void copybitmap(bitmap_t *dest, bitmap_t *src, int flipx, int flipy,
- int sx, int sy, const rectangle *clip)
-{
- copybitmap_common(dest,src,flipx,flipy,sx,sy,clip,TRANSPARENCY_NONE,0);
-}
-
-void copybitmap_trans(bitmap_t *dest, bitmap_t *src, int flipx, int flipy,
- int sx, int sy, const rectangle *clip, pen_t transparent_pen)
-{
- copybitmap_common(dest,src,flipx,flipy,sx,sy,clip,TRANSPARENCY_PEN,transparent_pen);
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
}
+/*-------------------------------------------------
+ drawgfx_transmask - render a gfx element
+ with a multiple transparent pens provided as
+ a mask
+-------------------------------------------------*/
-/***************************************************************************
-
- Copy a bitmap onto another with scroll and wraparound.
- This function supports multiple independently scrolling rows/columns.
- "rows" is the number of indepentently scrolling rows. "rowscroll" is an
- array of integers telling how much to scroll each row. Same thing for
- "cols" and "colscroll".
- If the bitmap cannot scroll in one direction, set rows or columns to 0.
- If the bitmap scrolls as a whole, set rows and/or cols to 1.
- Bidirectional scrolling is, of course, supported only if the bitmap
- scrolls as a whole in at least one direction.
-
-***************************************************************************/
-static void copyscrollbitmap_common(bitmap_t *dest,bitmap_t *src,
- int rows,const int *rowscroll,int cols,const int *colscroll,
- const rectangle *clip,int transparency,int transparent_color)
+void drawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 transmask)
{
- int srcwidth,srcheight,destwidth,destheight;
- rectangle orig_clip;
-
- assert(dest != NULL);
- assert(src != NULL);
- assert((dest->bpp == 16) || (dest->bpp == 32));
- assert(dest->bpp == src->bpp);
- assert((rows != 0) || (rowscroll == NULL));
- assert((rows == 0) || (rowscroll != NULL));
- assert((cols != 0) || (colscroll == NULL));
- assert((cols == 0) || (colscroll != NULL));
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
- if (clip)
+ /* special case 0 mask to opaque */
+ if (transmask == 0)
{
- orig_clip.min_x = clip->min_x;
- orig_clip.max_x = clip->max_x;
- orig_clip.min_y = clip->min_y;
- orig_clip.max_y = clip->max_y;
- }
- else
- {
- orig_clip.min_x = 0;
- orig_clip.max_x = dest->width-1;
- orig_clip.min_y = 0;
- orig_clip.max_y = dest->height-1;
- }
- clip = &orig_clip;
-
- if (rows == 0 && cols == 0)
- {
- copybitmap_common(dest,src,0,0,0,0,clip,transparency,transparent_color);
+ drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
return;
}
- srcwidth = src->width;
- srcheight = src->height;
- destwidth = dest->width;
- destheight = dest->height;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- if (rows == 0)
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
{
- /* scrolling columns */
- int col,colwidth;
- rectangle myclip;
-
- colwidth = srcwidth / cols;
-
- myclip.min_y = clip->min_y;
- myclip.max_y = clip->max_y;
-
- col = 0;
- while (col < cols)
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~transmask) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & transmask) == 0)
{
- int cons,scroll;
-
- /* count consecutive columns scrolled by the same amount */
- scroll = colscroll[col];
- cons = 1;
- while (col + cons < cols && colscroll[col + cons] == scroll)
- cons++;
-
- if (scroll < 0)
- scroll = srcheight - (-scroll) % srcheight;
- else
- scroll %= srcheight;
-
- myclip.min_x = col * colwidth;
- if (myclip.min_x < clip->min_x) myclip.min_x = clip->min_x;
- myclip.max_x = (col + cons) * colwidth - 1;
- if (myclip.max_x > clip->max_x) myclip.max_x = clip->max_x;
-
- copybitmap_common(dest,src,0,0,0,scroll,&myclip,transparency,transparent_color);
- copybitmap_common(dest,src,0,0,0,scroll - srcheight,&myclip,transparency,transparent_color);
-
- col += cons;
+ drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
+ return;
}
}
- else if (cols == 0)
- {
- /* scrolling rows */
- int row,rowheight;
- rectangle myclip;
- rowheight = srcheight / rows;
-
- myclip.min_x = clip->min_x;
- myclip.max_x = clip->max_x;
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
+}
- row = 0;
- while (row < rows)
- {
- int cons,scroll;
- /* count consecutive rows scrolled by the same amount */
- scroll = rowscroll[row];
- cons = 1;
- while (row + cons < rows && rowscroll[row + cons] == scroll)
- cons++;
-
- if (scroll < 0)
- scroll = srcwidth - (-scroll) % srcwidth;
- else
- scroll %= srcwidth;
+/*-------------------------------------------------
+ drawgfx_transtable - render a gfx element
+ using a table to look up which pens are
+ transparent, opaque, or shadowing
+-------------------------------------------------*/
- myclip.min_y = row * rowheight;
- if (myclip.min_y < clip->min_y) myclip.min_y = clip->min_y;
- myclip.max_y = (row + cons) * rowheight - 1;
- if (myclip.max_y > clip->max_y) myclip.max_y = clip->max_y;
+void drawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ const UINT8 *pentable, const pen_t *shadowtable)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
- copybitmap_common(dest,src,0,0,scroll,0,&myclip,transparency,transparent_color);
- copybitmap_common(dest,src,0,0,scroll - srcwidth,0,&myclip,transparency,transparent_color);
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
+ assert(pentable != NULL);
- row += cons;
- }
- }
- else if (rows == 1 && cols == 1)
- {
- /* XY scrolling playfield */
- int scrollx,scrolly,sx,sy;
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16, NO_PRIORITY);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY);
+}
- if (rowscroll[0] < 0)
- scrollx = srcwidth - (-rowscroll[0]) % srcwidth;
- else
- scrollx = rowscroll[0] % srcwidth;
- if (colscroll[0] < 0)
- scrolly = srcheight - (-colscroll[0]) % srcheight;
- else
- scrolly = colscroll[0] % srcheight;
+/*-------------------------------------------------
+ drawgfx_alpha - render a gfx element with
+ a single transparent pen, alpha blending the
+ remaining pixels with a fixed alpha value
+-------------------------------------------------*/
- for (sx = scrollx - srcwidth;sx < destwidth;sx += srcwidth)
- for (sy = scrolly - srcheight;sy < destheight;sy += srcheight)
- copybitmap_common(dest,src,0,0,sx,sy,clip,transparency,transparent_color);
- }
- else if (rows == 1)
+void drawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 transpen, UINT8 alpha)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
+
+ /* special case alpha = 0xff */
+ if (alpha == 0xff)
{
- /* scrolling columns + horizontal scroll */
- int col,colwidth;
- int scrollx;
- rectangle myclip;
+ drawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen);
+ return;
+ }
- if (rowscroll[0] < 0)
- scrollx = srcwidth - (-rowscroll[0]) % srcwidth;
- else
- scrollx = rowscroll[0] % srcwidth;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- colwidth = srcwidth / cols;
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
- myclip.min_y = clip->min_y;
- myclip.max_y = clip->max_y;
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16, NO_PRIORITY);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY);
+}
- col = 0;
- while (col < cols)
- {
- int cons,scroll;
- /* count consecutive columns scrolled by the same amount */
- scroll = colscroll[col];
- cons = 1;
- while (col + cons < cols && colscroll[col + cons] == scroll)
- cons++;
- if (scroll < 0)
- scroll = srcheight - (-scroll) % srcheight;
- else
- scroll %= srcheight;
+/***************************************************************************
+ DRAWGFXZOOM IMPLEMENTATIONS
+***************************************************************************/
- myclip.min_x = col * colwidth + scrollx;
- if (myclip.min_x < clip->min_x) myclip.min_x = clip->min_x;
- myclip.max_x = (col + cons) * colwidth - 1 + scrollx;
- if (myclip.max_x > clip->max_x) myclip.max_x = clip->max_x;
+/*-------------------------------------------------
+ drawgfxzoom - generic drawgfxzoom with legacy
+ interface
+-------------------------------------------------*/
- copybitmap_common(dest,src,0,0,scrollx,scroll,&myclip,transparency,transparent_color);
- copybitmap_common(dest,src,0,0,scrollx,scroll - srcheight,&myclip,transparency,transparent_color);
+void drawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
+ INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color,
+ UINT32 scalex, UINT32 scaley)
+{
+ switch (transparency)
+ {
+ case TRANSPARENCY_NONE:
+ drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley);
+ break;
+
+ case TRANSPARENCY_PEN:
+ drawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, transparent_color);
+ break;
+
+ case TRANSPARENCY_PENS:
+ drawgfxzoom_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, transparent_color);
+ break;
+
+ default:
+ fatalerror("Invalid transparency specified for drawgfxzoom (%d)", transparency);
+ break;
+ }
+}
- myclip.min_x = col * colwidth + scrollx - srcwidth;
- if (myclip.min_x < clip->min_x) myclip.min_x = clip->min_x;
- myclip.max_x = (col + cons) * colwidth - 1 + scrollx - srcwidth;
- if (myclip.max_x > clip->max_x) myclip.max_x = clip->max_x;
- copybitmap_common(dest,src,0,0,scrollx - srcwidth,scroll,&myclip,transparency,transparent_color);
- copybitmap_common(dest,src,0,0,scrollx - srcwidth,scroll - srcheight,&myclip,transparency,transparent_color);
+/*-------------------------------------------------
+ drawgfxzoom_opaque - render a scaled gfx
+ element with no transparency
+-------------------------------------------------*/
- col += cons;
- }
- }
- else if (cols == 1)
+void drawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
+
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
{
- /* scrolling rows + vertical scroll */
- int row,rowheight;
- int scrolly;
- rectangle myclip;
-
- if (colscroll[0] < 0)
- scrolly = srcheight - (-colscroll[0]) % srcheight;
- else
- scrolly = colscroll[0] % srcheight;
-
- rowheight = srcheight / rows;
+ drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
+ return;
+ }
- myclip.min_x = clip->min_x;
- myclip.max_x = clip->max_x;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- row = 0;
- while (row < rows)
- {
- int cons,scroll;
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+}
- /* count consecutive rows scrolled by the same amount */
- scroll = rowscroll[row];
- cons = 1;
- while (row + cons < rows && rowscroll[row + cons] == scroll)
- cons++;
- if (scroll < 0)
- scroll = srcwidth - (-scroll) % srcwidth;
- else
- scroll %= srcwidth;
+/*-------------------------------------------------
+ drawgfxzoom_transpen - render a scaled gfx
+ element with a single transparent pen
+-------------------------------------------------*/
- myclip.min_y = row * rowheight + scrolly;
- if (myclip.min_y < clip->min_y) myclip.min_y = clip->min_y;
- myclip.max_y = (row + cons) * rowheight - 1 + scrolly;
- if (myclip.max_y > clip->max_y) myclip.max_y = clip->max_y;
+void drawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, UINT32 transpen)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
- copybitmap_common(dest,src,0,0,scroll,scrolly,&myclip,transparency,transparent_color);
- copybitmap_common(dest,src,0,0,scroll - srcwidth,scrolly,&myclip,transparency,transparent_color);
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
+ {
+ drawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen);
+ return;
+ }
- myclip.min_y = row * rowheight + scrolly - srcheight;
- if (myclip.min_y < clip->min_y) myclip.min_y = clip->min_y;
- myclip.max_y = (row + cons) * rowheight - 1 + scrolly - srcheight;
- if (myclip.max_y > clip->max_y) myclip.max_y = clip->max_y;
+ /* special case invalid pens to opaque */
+ if (transpen > 0xff)
+ {
+ drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
+ return;
+ }
- copybitmap_common(dest,src,0,0,scroll,scrolly - srcheight,&myclip,transparency,transparent_color);
- copybitmap_common(dest,src,0,0,scroll - srcwidth,scrolly - srcheight,&myclip,transparency,transparent_color);
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- row += cons;
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
+ {
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~(1 << transpen)) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & (1 << transpen)) == 0)
+ {
+ drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
+ return;
}
}
-}
-
-void copyscrollbitmap(bitmap_t *dest, bitmap_t *src,
- int rows, const int *rowscroll, int cols, const int *colscroll,
- const rectangle *clip)
-{
- copyscrollbitmap_common(dest,src,rows,rowscroll,cols,colscroll,clip,TRANSPARENCY_NONE,0);
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
}
-void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src,
- int rows, const int *rowscroll, int cols, const int *colscroll,
- const rectangle *clip, pen_t transparent_pen)
-{
- copyscrollbitmap_common(dest,src,rows,rowscroll,cols,colscroll,clip,TRANSPARENCY_PEN,transparent_pen);
-}
+/*-------------------------------------------------
+ drawgfxzoom_transpen_raw - render a scaled gfx
+ element with a single transparent pen and no
+ color lookups
+-------------------------------------------------*/
-/* notes:
- - startx and starty MUST be UINT32 for calculations to work correctly
- - srcbitmap->width and height are assumed to be a power of 2 to speed up wraparound
- */
-void copyrozbitmap(bitmap_t *dest,bitmap_t *src,
- UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound,
- const rectangle *clip,int transparency,int transparent_color,UINT32 priority)
+void drawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, UINT32 transpen)
{
- assert(dest != NULL);
- assert(src != NULL);
- assert((dest->bpp == 16) || (dest->bpp == 32));
- assert(dest->bpp == src->bpp);
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
- profiler_mark(PROFILER_COPYBITMAP);
-
- /* cheat, the core doesn't support TRANSPARENCY_NONE yet */
- if (transparency == TRANSPARENCY_NONE)
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
{
- transparency = TRANSPARENCY_PEN;
- transparent_color = -1;
+ drawgfx_transpen_raw(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen);
+ return;
}
- if (transparency != TRANSPARENCY_PEN)
- {
- popmessage("copyrozbitmap unsupported trans %02x",transparency);
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
+
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
return;
- }
+ /* render based on dest bitmap depth */
if (dest->bpp == 16)
- copyrozbitmap_core16(dest,src,startx,starty,incxx,incxy,incyx,incyy,wraparound,clip,transparency,transparent_color,priority);
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
else
- copyrozbitmap_core32(dest,src,startx,starty,incxx,incxy,incyx,incyy,wraparound,clip,transparency,transparent_color,priority);
-
- profiler_mark(PROFILER_END);
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
}
+/*-------------------------------------------------
+ drawgfxzoom_transmask - render a scaled gfx
+ element with a multiple transparent pens
+ provided as a mask
+-------------------------------------------------*/
-INLINE void common_drawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
- int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask)
+void drawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, UINT32 transmask)
{
- /* verify arguments */
- assert(dest_bmp != NULL);
- assert((dest_bmp->bpp == 16) || (dest_bmp->bpp == 32));
- assert(gfx != NULL);
-
- if ((scalex == 0) || (scaley == 0)) return;
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
+ /* non-zoom case */
if (scalex == 0x10000 && scaley == 0x10000)
{
- common_drawgfx(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,pri_buffer,pri_mask);
+ drawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transmask);
return;
}
- if ((dest_bmp->format == BITMAP_FORMAT_INDEXED16 || dest_bmp->format == BITMAP_FORMAT_INDEXED32) &&
- (transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHARANGE))
+ /* special case 0 mask to opaque */
+ if (transmask == 0)
{
- transparency = TRANSPARENCY_PEN;
- transparent_color &= 0xff;
+ drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
+ return;
}
- /*
- scalex and scaley are 16.16 fixed point numbers
- 1<<15 : shrink to 50%
- 1<<16 : uniform scale
- 1<<17 : double to 200%
- */
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- /* force clip to bitmap boundary */
- if (clip)
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
{
- rectangle myclip;
-
- myclip.min_x = clip->min_x;
- myclip.max_x = clip->max_x;
- myclip.min_y = clip->min_y;
- myclip.max_y = clip->max_y;
-
- if (myclip.min_x < 0) myclip.min_x = 0;
- if (myclip.max_x >= dest_bmp->width) myclip.max_x = dest_bmp->width-1;
- if (myclip.min_y < 0) myclip.min_y = 0;
- if (myclip.max_y >= dest_bmp->height) myclip.max_y = dest_bmp->height-1;
-
- clip = &myclip;
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~transmask) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & transmask) == 0)
+ {
+ drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
+ return;
+ }
}
- /* 16-bit destination bitmap */
- if (dest_bmp->bpp == 16)
- {
- int colorbase = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
- const pen_t *pal = &gfx->machine->pens[colorbase];
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
-
- int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
- int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
+}
- if (sprite_screen_width && sprite_screen_height)
- {
- /* compute sprite increment per screen pixel */
- int dx = (gfx->width<<16)/sprite_screen_width;
- int dy = (gfx->height<<16)/sprite_screen_height;
- int ex = sx+sprite_screen_width;
- int ey = sy+sprite_screen_height;
+/*-------------------------------------------------
+ drawgfxzoom_transtable - render a scaled gfx
+ element using a table to look up which pens
+ are transparent, opaque, or shadowing
+-------------------------------------------------*/
- int x_index_base;
- int y_index;
+void drawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, const UINT8 *pentable, const pen_t *shadowtable)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
- if (flipx)
- {
- x_index_base = (sprite_screen_width-1)*dx;
- dx = -dx;
- }
- else
- x_index_base = 0;
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
+ {
+ drawgfx_transtable(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, pentable, shadowtable);
+ return;
+ }
- if (flipy)
- {
- y_index = (sprite_screen_height-1)*dy;
- dy = -dy;
- }
- else
- y_index = 0;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
+ assert(pentable != NULL);
- if (clip)
- {
- if (sx < clip->min_x)
- { /* clip left */
- int pixels = clip->min_x-sx;
- sx += pixels;
- x_index_base += pixels*dx;
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16, NO_PRIORITY);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY);
+}
- if (sy < clip->min_y)
- { /* clip top */
- int pixels = clip->min_y-sy;
- sy += pixels;
- y_index += pixels*dy;
- }
- if (ex > clip->max_x + 1)
- { /* clip right */
- int pixels = ex-clip->max_x-1;
- ex -= pixels;
- }
+/*-------------------------------------------------
+ drawgfxzoom_alpha - render a scaled gfx element
+ with a single transparent pen, alpha blending
+ the remaining pixels with a fixed alpha value
+-------------------------------------------------*/
- if (ey > clip->max_y + 1)
- { /* clip bottom */
- int pixels = ey-clip->max_y-1;
- ey -= pixels;
- }
- }
+void drawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, UINT32 transpen, UINT8 alpha)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+ const pen_t *paldata;
+
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
+ {
+ drawgfx_alpha(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen, alpha);
+ return;
+ }
- if (ex > sx)
- { /* skip if inner loop doesn't draw anything */
- int y;
+ /* special case alpha = 0xff */
+ if (alpha == 0xff)
+ {
+ drawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, transpen);
+ return;
+ }
- /* case 0: TRANSPARENCY_NONE */
- if (transparency == TRANSPARENCY_NONE)
- {
- if (pri_buffer)
- {
- if (gfx->flags & GFX_ELEMENT_PACKED)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[(source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f];
-// dest[x] = colorbase + ((source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f);
- pri[x] = 31;
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[source[x_index>>16]];
-// dest[x] = colorbase + source[x_index>>16];
- pri[x] = 31;
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- else
- {
- if (gfx->flags & GFX_ELEMENT_PACKED)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- dest[x] = pal[(source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f];
-// dest[x] = colorbase + ((source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f);
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- dest[x] = pal[source[x_index>>16]];
-// dest[x] = colorbase + source[x_index>>16];
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- }
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- /* case 1: TRANSPARENCY_PEN */
- if (transparency == TRANSPARENCY_PEN)
- {
- if (pri_buffer)
- {
- if (gfx->flags & GFX_ELEMENT_PACKED)
- for(y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = (source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f;
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for(y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- else
- {
- if (gfx->flags & GFX_ELEMENT_PACKED)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = (source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f;
- if( c != transparent_color ) dest[x] = pal[c];
-// if (c != transparent_color) dest[x] = colorbase + c;
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if( c != transparent_color ) dest[x] = pal[c];
-// if (c != transparent_color) dest[x] = colorbase + c;
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
- /* case 1b: TRANSPARENCY_PEN_RAW */
- if (transparency == TRANSPARENCY_PEN_RAW)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = color + c;
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color) dest[x] = color + c;
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16, NO_PRIORITY);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY);
+}
- /* case 2: TRANSPARENCY_PENS */
- if (transparency == TRANSPARENCY_PENS)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (((1 << c) & transparent_color) == 0)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (((1 << c) & transparent_color) == 0)
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- /* case 3: TRANSPARENCY_PEN_TABLE */
- if (transparency == TRANSPARENCY_PEN_TABLE)
- {
- pen_t *palette_shadow_table = gfx->machine->shadow_table;
- if (pri_buffer)
- {
- UINT8 al = (pdrawgfx_shadow_lowpri) ? 0 : 0x80;
-
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- UINT8 ah;
-
- switch(gfx_drawmode_table[c])
- {
- case DRAWMODE_SOURCE:
- ah = pri[x];
- if (((1 << (ah & 0x1f)) & pri_mask) == 0)
- {
- if (ah & 0x80)
- dest[x] = palette_shadow_table[pal[c]];
-// dest[x] = palette_shadow_table[colorbase + c];
- else
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- }
- pri[x] = (ah & 0x7f) | 31;
- break;
- case DRAWMODE_SHADOW:
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = palette_shadow_table[dest[x]];
- pri[x] |= al;
- break;
- }
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- else
- {
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- switch(gfx_drawmode_table[c])
- {
- case DRAWMODE_SOURCE:
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- break;
- case DRAWMODE_SHADOW:
- dest[x] = palette_shadow_table[dest[x]];
- break;
- }
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- }
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = alpha_blend16(dest[x], pal[c]);
-// dest[x] = alpha_blend16(dest[x], colorbase + c);
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if( c != transparent_color ) dest[x] = alpha_blend16(dest[x], pal[c]);
-// if (c != transparent_color) dest[x] = alpha_blend16(dest[x], colorbase + c);
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
+/***************************************************************************
+ PDRAWGFX IMPLEMENTATIONS
+***************************************************************************/
- /* case 7: TRANSPARENCY_ALPHARANGE */
- if (transparency == TRANSPARENCY_ALPHARANGE)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- {
- if (gfx_alpharange_table[c] == 0xff)
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- else
- dest[x] = alpha_blend_r16(dest[x], pal[c], gfx_alpharange_table[c]);
-// dest[x] = alpha_blend_r16(dest[x], colorbase + c, gfx_alpharange_table[c]);
- }
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (gfx_alpharange_table[c] == 0xff)
- dest[x] = pal[c];
-// dest[x] = colorbase + c;
- else
- dest[x] = alpha_blend_r16(dest[x], pal[c], gfx_alpharange_table[c]);
-// dest[x] = alpha_blend_r16(dest[x], colorbase + c, gfx_alpharange_table[c]);
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- }
- }
- }
+/*-------------------------------------------------
+ pdrawgfx - generic pdrawgfx with legacy
+ interface
+-------------------------------------------------*/
- /* 32-bit destination bitmap */
- else
+void pdrawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
+ INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color,
+ UINT32 priority_mask)
+{
+ switch (transparency)
{
- const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
-
- int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
- int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
+ case TRANSPARENCY_NONE:
+ pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, priority_bitmap, priority_mask);
+ break;
+
+ case TRANSPARENCY_PEN:
+ pdrawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, priority_bitmap, priority_mask, transparent_color);
+ break;
+
+ case TRANSPARENCY_PENS:
+ pdrawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, priority_bitmap, priority_mask, transparent_color);
+ break;
+
+ default:
+ fatalerror("Invalid transparency specified for pdrawgfx (%d)", transparency);
+ break;
+ }
+}
- if (sprite_screen_width && sprite_screen_height)
- {
- /* compute sprite increment per screen pixel */
- int dx = (gfx->width<<16)/sprite_screen_width;
- int dy = (gfx->height<<16)/sprite_screen_height;
- int ex = sx+sprite_screen_width;
- int ey = sy+sprite_screen_height;
+/*-------------------------------------------------
+ pdrawgfx_opaque - render a gfx element with
+ no transparency, checking against the priority
+ bitmap
+-------------------------------------------------*/
- int x_index_base;
- int y_index;
+void pdrawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ bitmap_t *priority, UINT32 pmask)
+{
+ const pen_t *paldata;
- if (flipx)
- {
- x_index_base = (sprite_screen_width-1)*dx;
- dx = -dx;
- }
- else
- {
- x_index_base = 0;
- }
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- if (flipy)
- {
- y_index = (sprite_screen_height-1)*dy;
- dy = -dy;
- }
- else
- {
- y_index = 0;
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
+}
- if (clip)
- {
- if (sx < clip->min_x)
- { /* clip left */
- int pixels = clip->min_x-sx;
- sx += pixels;
- x_index_base += pixels*dx;
- }
- if (sy < clip->min_y)
- { /* clip top */
- int pixels = clip->min_y-sy;
- sy += pixels;
- y_index += pixels*dy;
- }
+/*-------------------------------------------------
+ pdrawgfx_transpen - render a gfx element with
+ a single transparent pen, checking against the
+ priority bitmap
+-------------------------------------------------*/
- if (ex > clip->max_x + 1)
- { /* clip right */
- int pixels = ex-clip->max_x-1;
- ex -= pixels;
- }
+void pdrawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ bitmap_t *priority, UINT32 pmask, UINT32 transpen)
+{
+ const pen_t *paldata;
- if (ey > clip->max_y + 1)
- { /* clip bottom */
- int pixels = ey-clip->max_y-1;
- ey -= pixels;
- }
- }
+ /* special case invalid pens to opaque */
+ if (transpen > 0xff)
+ {
+ pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
+ return;
+ }
- if (ex > sx)
- { /* skip if inner loop doesn't draw anything */
- int y;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- /* case 0: TRANSPARENCY_NONE */
- if (transparency == TRANSPARENCY_NONE)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[source[x_index>>16]];
- pri[x] = 31;
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- dest[x] = pal[source[x_index>>16]];
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
+ {
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~(1 << transpen)) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & (1 << transpen)) == 0)
+ {
+ pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
+ return;
+ }
+ }
- /* case 1: TRANSPARENCY_PEN */
- if (transparency == TRANSPARENCY_PEN)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color) dest[x] = pal[c];
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
+}
- /* case 1b: TRANSPARENCY_PEN_RAW */
- if (transparency == TRANSPARENCY_PEN_RAW)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = color + c;
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color) dest[x] = color + c;
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- /* case 2: TRANSPARENCY_PENS */
- if (transparency == TRANSPARENCY_PENS)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (((1 << c) & transparent_color) == 0)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (((1 << c) & transparent_color) == 0)
- dest[x] = pal[c];
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
+/*-------------------------------------------------
+ pdrawgfx_transpen_raw - render a gfx element
+ with a single transparent pen and no color
+ lookups, checking against the priority bitmap
+-------------------------------------------------*/
- /* case 3: TRANSPARENCY_PEN_TABLE */
- if (transparency == TRANSPARENCY_PEN_TABLE)
- {
- pen_t *palette_shadow_table = gfx->machine->shadow_table;
- UINT8 *source;
- UINT8 *pri;
- UINT32 *dest;
- int c, x, x_index;
- UINT8 al, ah;
-
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- source = source_base + (y_index>>16) * gfx->line_modulo;
- y_index += dy;
- dest = BITMAP_ADDR32(dest_bmp, y, 0);
- pri = BITMAP_ADDR8(pri_buffer, y, 0);
- x_index = x_index_base;
-
- for (x = sx; x < ex; x++)
- {
- int ebx = x_index;
- x_index += dx;
- ebx >>= 16;
- al = pri[x];
- c = source[ebx];
- ah = al;
- al &= 0x1f;
-
- if (gfx_drawmode_table[c] == DRAWMODE_NONE) continue;
-
- if (!(1<<al & pri_mask))
- {
- if (gfx_drawmode_table[c] == DRAWMODE_SOURCE)
- {
- ah &= 0x7f;
- ebx = pal[c];
- ah |= 0x1f;
- dest[x] = ebx;
- pri[x] = ah;
- }
- else if (!(ah & 0x80))
- {
- ebx = SHADOW32(palette_shadow_table,dest[x]);
- pri[x] |= 0x80;
- dest[x] = ebx;
- }
- }
- }
- }
- else
- for (y = sy; y < ey; y++)
- {
- source = source_base + (y_index>>16) * gfx->line_modulo;
- y_index += dy;
- dest = BITMAP_ADDR32(dest_bmp, y, 0);
- x_index = x_index_base;
-
- for (x = sx; x < ex; x++)
- {
- c = source[x_index>>16];
- x_index += dx;
-
- if (gfx_drawmode_table[c] == DRAWMODE_NONE) continue;
- if (gfx_drawmode_table[c] == DRAWMODE_SOURCE)
- dest[x] = pal[c];
- else
- dest[x] = SHADOW32(palette_shadow_table,dest[x]);
- }
- }
- }
+void pdrawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ bitmap_t *priority, UINT32 pmask, UINT32 transpen)
+{
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = alpha_blend32(dest[x], pal[c]);
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color) dest[x] = alpha_blend32(dest[x], pal[c]);
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
- /* case 7: TRANSPARENCY_ALPHARANGE */
- if (transparency == TRANSPARENCY_ALPHARANGE)
- {
- if (pri_buffer)
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
- UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (((1 << pri[x]) & pri_mask) == 0)
- {
- if (gfx_alpharange_table[c] == 0xff)
- dest[x] = pal[c];
- else
- dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
- }
- pri[x] = 31;
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- else
- for (y = sy; y < ey; y++)
- {
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
-
- int x, x_index = x_index_base;
- for (x = sx; x < ex; x++)
- {
- int c = source[x_index>>16];
- if (c != transparent_color)
- {
- if (gfx_alpharange_table[c] == 0xff)
- dest[x] = pal[c];
- else
- dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
- }
- x_index += dx;
- }
-
- y_index += dy;
- }
- }
- }
- }
- }
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
}
-void drawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley)
-{
- profiler_mark(PROFILER_DRAWGFX);
- common_drawgfxzoom(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,
- clip,transparency,transparent_color,scalex,scaley,NULL,0);
- profiler_mark(PROFILER_END);
-}
-void pdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley,
- UINT32 priority_mask)
-{
- profiler_mark(PROFILER_DRAWGFX);
- common_drawgfxzoom(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,
- clip,transparency,transparent_color,scalex,scaley,priority_bitmap,priority_mask | (1<<31));
- profiler_mark(PROFILER_END);
-}
+/*-------------------------------------------------
+ pdrawgfx_transmask - render a gfx element
+ with a multiple transparent pens provided as
+ a mask, checking against the priority bitmap
+-------------------------------------------------*/
-void mdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley,
- UINT32 priority_mask)
+void pdrawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ bitmap_t *priority, UINT32 pmask, UINT32 transmask)
{
- profiler_mark(PROFILER_DRAWGFX);
- common_drawgfxzoom(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,
- clip,transparency,transparent_color,scalex,scaley,priority_bitmap,priority_mask);
- profiler_mark(PROFILER_END);
-}
-
+ const pen_t *paldata;
-#else /* DECLAREG */
-
-#if (DEPTH != 8)
-/* -------------------- included inline section --------------------- */
-#define ADJUST_8 \
- int ydir; \
- if (flipy) \
- { \
- INCREMENT_DST(VMODULO * (dstheight-1)) \
- srcdata += (srcheight - dstheight - topskip) * srcmodulo; \
- ydir = -1; \
- } \
- else \
- { \
- srcdata += topskip * srcmodulo; \
- ydir = 1; \
- } \
- if (flipx) \
- { \
- INCREMENT_DST(HMODULO * (dstwidth-1)) \
- srcdata += (srcwidth - dstwidth - leftskip); \
- } \
- else \
- srcdata += leftskip; \
- srcmodulo -= dstwidth;
-
-
-#define ADJUST_4 \
- int ydir; \
- if (flipy) \
- { \
- INCREMENT_DST(VMODULO * (dstheight-1)) \
- srcdata += (srcheight - dstheight - topskip) * srcmodulo; \
- ydir = -1; \
- } \
- else \
- { \
- srcdata += topskip * srcmodulo; \
- ydir = 1; \
- } \
- if (flipx) \
- { \
- INCREMENT_DST(HMODULO * (dstwidth-1)) \
- srcdata += (srcwidth - dstwidth - leftskip)/2; \
- leftskip = (srcwidth - dstwidth - leftskip) & 1; \
- } \
- else \
- { \
- srcdata += leftskip/2; \
- leftskip &= 1; \
- } \
- srcmodulo -= (dstwidth+leftskip)/2;
-
-
-
-#if (RAW == 0)
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_opaque,(COMMON_ARGS, COLOR_ARG),
-{
- ADJUST_8
+ /* special case 0 mask to opaque */
+ if (transmask == 0)
+ {
+ pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
+ return;
+ }
- (void)palette_shadow_table;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- if (flipx)
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
{
- DATA_TYPE *end;
-
- while (dstheight)
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~transmask) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & transmask) == 0)
{
- end = dstdata - dstwidth*HMODULO;
- while (dstdata >= end + 8*HMODULO)
- {
- INCREMENT_DST(-8*HMODULO)
- SETPIXELCOLOR(8*HMODULO,LOOKUP(srcdata[0]))
- SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[1]))
- SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[2]))
- SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[3]))
- SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[4]))
- SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[5]))
- SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[6]))
- SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[7]))
- srcdata += 8;
- }
- while (dstdata > end)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata))
- srcdata++;
- INCREMENT_DST(-HMODULO)
- }
-
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
- dstheight--;
+ pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
+ return;
}
}
+
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
else
- {
- DATA_TYPE *end;
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
+}
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (dstdata <= end - 8*HMODULO)
- {
- SETPIXELCOLOR(0*HMODULO,LOOKUP(srcdata[0]))
- SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[1]))
- SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[2]))
- SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[3]))
- SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[4]))
- SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[5]))
- SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[6]))
- SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[7]))
- srcdata += 8;
- INCREMENT_DST(8*HMODULO)
- }
- while (dstdata < end)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata))
- srcdata++;
- INCREMENT_DST(HMODULO)
- }
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
- dstheight--;
- }
- }
-})
-#endif
+/*-------------------------------------------------
+ pdrawgfx_transtable - render a gfx element
+ using a table to look up which pens are
+ transparent, opaque, or shadowing, checking
+ against the priority bitmap
+-------------------------------------------------*/
-#if (RAW == 0)
-DECLARE_SWAP_RAW_PRI(blockmove_4toN_opaque,(COMMON_ARGS, COLOR_ARG),
+void pdrawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ bitmap_t *priority, UINT32 pmask, const UINT8 *pentable, const pen_t *shadowtable)
{
- ADJUST_4
+ const pen_t *paldata;
- (void)palette_shadow_table;
-
- if (flipx)
- {
- DATA_TYPE *end;
-
- while (dstheight)
- {
- end = dstdata - dstwidth*HMODULO;
- if (leftskip)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
- srcdata++;
- INCREMENT_DST(-HMODULO)
- }
- while (dstdata >= end + 8*HMODULO)
- {
- INCREMENT_DST(-8*HMODULO)
- SETPIXELCOLOR(8*HMODULO,LOOKUP(srcdata[0]&0x0f))
- SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[0]>>4))
- SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[1]&0x0f))
- SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[1]>>4))
- SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[2]&0x0f))
- SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[2]>>4))
- SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[3]&0x0f))
- SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[3]>>4))
- srcdata += 4;
- }
- while (dstdata > end)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata&0x0f))
- INCREMENT_DST(-HMODULO)
- if (dstdata > end)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
- srcdata++;
- INCREMENT_DST(-HMODULO)
- }
- }
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
+ assert(pentable != NULL);
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
- dstheight--;
- }
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16_PRIORITY, UINT8);
else
- {
- DATA_TYPE *end;
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, UINT8);
+}
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- if (leftskip)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
- srcdata++;
- INCREMENT_DST(HMODULO)
- }
- while (dstdata <= end - 8*HMODULO)
- {
- SETPIXELCOLOR(0*HMODULO,LOOKUP(srcdata[0]&0x0f))
- SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[0]>>4))
- SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[1]&0x0f))
- SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[1]>>4))
- SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[2]&0x0f))
- SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[2]>>4))
- SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[3]&0x0f))
- SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[3]>>4))
- srcdata += 4;
- INCREMENT_DST(8*HMODULO)
- }
- while (dstdata < end)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata&0x0f))
- INCREMENT_DST(HMODULO)
- if (dstdata < end)
- {
- SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
- srcdata++;
- INCREMENT_DST(HMODULO)
- }
- }
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
- dstheight--;
- }
- }
-})
-#endif
+/*-------------------------------------------------
+ pdrawgfx_alpha - render a gfx element with
+ a single transparent pen, alpha blending the
+ remaining pixels with a fixed alpha value,
+ checking against the priority bitmap
+-------------------------------------------------*/
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_transpen,(COMMON_ARGS, COLOR_ARG, int transpen),
+void pdrawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ bitmap_t *priority, UINT32 pmask, UINT32 transpen, UINT8 alpha)
{
- ADJUST_8
+ const pen_t *paldata;
- (void)palette_shadow_table;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- if (flipx)
+ /* special case alpha = 0xff */
+ if (alpha == 0xff)
{
- DATA_TYPE *end;
- int trans4;
- UINT32 *sd4;
+ pdrawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen);
+ return;
+ }
- trans4 = transpen * 0x01010101;
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
- while (dstheight)
- {
- end = dstdata - dstwidth*HMODULO;
- while (((FPTR)srcdata & 3) && dstdata > end) /* longword align */
- {
- int col;
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16_PRIORITY, UINT8);
+ else
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, UINT8);
+}
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- }
- sd4 = (UINT32 *)srcdata;
- while (dstdata >= end + 4*HMODULO)
- {
- UINT32 col4;
- INCREMENT_DST(-4*HMODULO)
- if ((col4 = *(sd4++)) != trans4)
- {
- UINT32 xod4;
- xod4 = col4 ^ trans4;
- if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(4*HMODULO,LOOKUP((col4>>SHIFT0) & 0xff))
- if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(3*HMODULO,LOOKUP((col4>>SHIFT1) & 0xff))
- if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,LOOKUP((col4>>SHIFT2) & 0xff))
- if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(1*HMODULO,LOOKUP((col4>>SHIFT3) & 0xff))
- }
- }
- srcdata = (UINT8 *)sd4;
- while (dstdata > end)
- {
- int col;
+/***************************************************************************
+ PDRAWGFXZOOM IMPLEMENTATIONS
+***************************************************************************/
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- }
+/*-------------------------------------------------
+ pdrawgfxzoom - generic pdrawgfxzoom with
+ legacy interface
+-------------------------------------------------*/
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO);
- dstheight--;
- }
- }
- else
+void pdrawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
+ INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color,
+ UINT32 scalex, UINT32 scaley, UINT32 priority_mask)
+{
+ switch (transparency)
{
- DATA_TYPE *end;
- int trans4;
- UINT32 *sd4;
+ case TRANSPARENCY_NONE:
+ pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, priority_bitmap, priority_mask);
+ break;
+
+ case TRANSPARENCY_PEN:
+ pdrawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, priority_bitmap, priority_mask, transparent_color);
+ break;
+
+ case TRANSPARENCY_PENS:
+ pdrawgfxzoom_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, priority_bitmap, priority_mask, transparent_color);
+ break;
+
+ default:
+ fatalerror("Invalid transparency specified for pdrawgfxzoom (%d)", transparency);
+ break;
+ }
+}
- trans4 = transpen * 0x01010101;
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (((FPTR)srcdata & 3) && dstdata < end) /* longword align */
- {
- int col;
+/*-------------------------------------------------
+ pdrawgfxzoom_opaque - render a scaled gfx
+ element with no transparency, checking against
+ the priority bitmap
+-------------------------------------------------*/
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- }
- sd4 = (UINT32 *)srcdata;
- while (dstdata <= end - 4*HMODULO)
- {
- UINT32 col4;
+void pdrawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask)
+{
+ const pen_t *paldata;
- if ((col4 = *(sd4++)) != trans4)
- {
- UINT32 xod4;
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
+ {
+ pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
+ return;
+ }
- xod4 = col4 ^ trans4;
- if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(0*HMODULO,LOOKUP((col4>>SHIFT0) & 0xff))
- if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(1*HMODULO,LOOKUP((col4>>SHIFT1) & 0xff))
- if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,LOOKUP((col4>>SHIFT2) & 0xff))
- if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(3*HMODULO,LOOKUP((col4>>SHIFT3) & 0xff))
- }
- INCREMENT_DST(4*HMODULO)
- }
- srcdata = (UINT8 *)sd4;
- while (dstdata < end)
- {
- int col;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
+}
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO);
- dstheight--;
- }
- }
-})
-DECLARE_SWAP_RAW_PRI(blockmove_4toN_transpen,(COMMON_ARGS, COLOR_ARG, int transpen),
-{
- ADJUST_4
+/*-------------------------------------------------
+ pdrawgfxzoom_transpen - render a scaled gfx
+ element with a single transparent pen,
+ checking against the priority bitmap
+-------------------------------------------------*/
- (void)palette_shadow_table;
+void pdrawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
+ UINT32 transpen)
+{
+ const pen_t *paldata;
- if (flipx)
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
{
- DATA_TYPE *end;
+ pdrawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen);
+ return;
+ }
- while (dstheight)
- {
- int col;
+ /* special case invalid pens to opaque */
+ if (transpen > 0xff)
+ {
+ pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
+ return;
+ }
- end = dstdata - dstwidth*HMODULO;
- if (leftskip)
- {
- col = *(srcdata++)>>4;
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- }
- while (dstdata > end)
- {
- col = *(srcdata)&0x0f;
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- if (dstdata > end)
- {
- col = *(srcdata++)>>4;
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- }
- }
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
- dstheight--;
- }
- }
- else
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
{
- DATA_TYPE *end;
-
- while (dstheight)
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~(1 << transpen)) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & (1 << transpen)) == 0)
{
- int col;
-
- end = dstdata + dstwidth*HMODULO;
- if (leftskip)
- {
- col = *(srcdata++)>>4;
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- }
- while (dstdata < end)
- {
- col = *(srcdata)&0x0f;
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- if (dstdata < end)
- {
- col = *(srcdata++)>>4;
- if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- }
- }
-
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
- dstheight--;
+ pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
+ return;
}
}
-})
-#if (RAW == 0)
-#define PEN_IS_OPAQUE ((1<<col)&transmask) == 0
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
+}
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_transmask,(COMMON_ARGS, COLOR_ARG, int transmask),
-{
- ADJUST_8
- (void)palette_shadow_table;
+/*-------------------------------------------------
+ pdrawgfxzoom_transpen_raw - render a scaled gfx
+ element with a single transparent pen and no
+ color lookups, checking against the priority
+ bitmap
+-------------------------------------------------*/
- if (flipx)
+void pdrawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
+ UINT32 transpen)
+{
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
{
- DATA_TYPE *end;
- UINT32 *sd4;
-
- while (dstheight)
- {
- end = dstdata - dstwidth*HMODULO;
- while (((FPTR)srcdata & 3) && dstdata > end) /* longword align */
- {
- int col;
+ pdrawgfx_transpen_raw(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen);
+ return;
+ }
- col = *(srcdata++);
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- }
- sd4 = (UINT32 *)srcdata;
- while (dstdata >= end + 4*HMODULO)
- {
- int col;
- UINT32 col4;
-
- INCREMENT_DST(-4*HMODULO)
- col4 = *(sd4++);
- col = (col4 >> SHIFT0) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(4*HMODULO,LOOKUP(col))
- col = (col4 >> SHIFT1) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(3*HMODULO,LOOKUP(col))
- col = (col4 >> SHIFT2) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(2*HMODULO,LOOKUP(col))
- col = (col4 >> SHIFT3) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(1*HMODULO,LOOKUP(col))
- }
- srcdata = (UINT8 *)sd4;
- while (dstdata > end)
- {
- int col;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- col = *(srcdata++);
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(-HMODULO)
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
- dstheight--;
- }
- }
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
else
- {
- DATA_TYPE *end;
- UINT32 *sd4;
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
+}
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (((FPTR)srcdata & 3) && dstdata < end) /* longword align */
- {
- int col;
- col = *(srcdata++);
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- }
- sd4 = (UINT32 *)srcdata;
- while (dstdata <= end - 4*HMODULO)
- {
- int col;
- UINT32 col4;
-
- col4 = *(sd4++);
- col = (col4 >> SHIFT0) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(0*HMODULO,LOOKUP(col))
- col = (col4 >> SHIFT1) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(1*HMODULO,LOOKUP(col))
- col = (col4 >> SHIFT2) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(2*HMODULO,LOOKUP(col))
- col = (col4 >> SHIFT3) & 0xff;
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(3*HMODULO,LOOKUP(col))
- INCREMENT_DST(4*HMODULO)
- }
- srcdata = (UINT8 *)sd4;
- while (dstdata < end)
- {
- int col;
+/*-------------------------------------------------
+ pdrawgfxzoom_transmask - render a scaled gfx
+ element with a multiple transparent pens
+ provided as a mask, checking against the
+ priority bitmap
+-------------------------------------------------*/
- col = *(srcdata++);
- if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
- INCREMENT_DST(HMODULO)
- }
+void pdrawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
+ UINT32 transmask)
+{
+ const pen_t *paldata;
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
- dstheight--;
- }
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
+ {
+ pdrawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transmask);
+ return;
}
-})
-#endif
-#if (RAW == 0)
-#if (DEPTH == 32)
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_pen_table,(COMMON_ARGS, COLOR_ARG, int transcolor),
-{
- ADJUST_8
+ /* special case 0 mask to opaque */
+ if (transmask == 0)
+ {
+ pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
+ return;
+ }
- (void)palette_shadow_table;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- if (flipx)
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* use pen usage to optimize */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code])
{
- DATA_TYPE *end;
-
- while (dstheight)
+ UINT32 usage = gfx->pen_usage[code];
+
+ /* fully transparent; do nothing */
+ if ((usage & ~transmask) == 0)
+ return;
+
+ /* fully opaque; draw as such */
+ if ((usage & transmask) == 0)
{
- end = dstdata - dstwidth*HMODULO;
- while (dstdata > end)
- {
- int col;
-
- col = *(srcdata++);
- if (col != transcolor)
- {
- switch(gfx_drawmode_table[col])
- {
- case DRAWMODE_SOURCE:
- SETPIXELCOLOR(0,LOOKUP(col))
- break;
- case DRAWMODE_SHADOW:
- afterdrawmask = 0;
- SETPIXELCOLOR(0,*dstdata)
- afterdrawmask = 31;
- break;
- }
- }
- INCREMENT_DST(-HMODULO)
- }
-
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
- dstheight--;
+ pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
+ return;
}
}
+
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
else
- {
- DATA_TYPE *end;
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
+}
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (dstdata < end)
- {
- int col;
- col = *(srcdata++);
- if (col != transcolor)
- {
- switch(gfx_drawmode_table[col])
- {
- case DRAWMODE_SOURCE:
- SETPIXELCOLOR(0,LOOKUP(col))
- break;
- case DRAWMODE_SHADOW:
- afterdrawmask = 0;
- SETPIXELCOLOR(0,*dstdata)
- afterdrawmask = 31;
- break;
- }
- }
- INCREMENT_DST(HMODULO)
- }
+/*-------------------------------------------------
+ pdrawgfxzoom_transtable - render a scaled gfx
+ element using a table to look up which pens
+ are transparent, opaque, or shadowing,
+ checking against the priority bitmap
+-------------------------------------------------*/
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
- dstheight--;
- }
- }
-})
-#else
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_pen_table,(COMMON_ARGS, COLOR_ARG, int transcolor),
+void pdrawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
+ const UINT8 *pentable, const pen_t *shadowtable)
{
- int eax = (pdrawgfx_shadow_lowpri) ? 0 : 0x80;
+ const pen_t *paldata;
- ADJUST_8
-
- (void)palette_shadow_table;
-
- if (flipx)
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
{
- DATA_TYPE *end;
-
- while (dstheight)
- {
- end = dstdata - dstwidth*HMODULO;
- while (dstdata > end)
- {
- int col;
+ pdrawgfx_transtable(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, pentable, shadowtable);
+ return;
+ }
- col = *(srcdata++);
- if (col != transcolor)
- {
- switch(gfx_drawmode_table[col])
- {
- case DRAWMODE_SOURCE:
- SETPIXELCOLOR(0,LOOKUP(col))
- break;
- case DRAWMODE_SHADOW:
- afterdrawmask = eax;
- SETPIXELCOLOR(0,palette_shadow_table[*dstdata])
- afterdrawmask = 31;
- break;
- }
- }
- INCREMENT_DST(-HMODULO)
- }
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
+ assert(pentable != NULL);
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
- dstheight--;
- }
- }
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16_PRIORITY, UINT8);
else
- {
- DATA_TYPE *end;
-
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (dstdata < end)
- {
- int col;
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, UINT8);
+}
- col = *(srcdata++);
- if (col != transcolor)
- {
- switch(gfx_drawmode_table[col])
- {
- case DRAWMODE_SOURCE:
- SETPIXELCOLOR(0,LOOKUP(col))
- break;
- case DRAWMODE_SHADOW:
- afterdrawmask = eax;
- SETPIXELCOLOR(0,palette_shadow_table[*dstdata])
- afterdrawmask = 31;
- break;
- }
- }
- INCREMENT_DST(HMODULO)
- }
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
- dstheight--;
- }
- }
-})
-#endif
-#endif
+/*-------------------------------------------------
+ pdrawgfxzoom_alpha - render a scaled gfx
+ element with a single transparent pen, alpha
+ blending the remaining pixels with a fixed
+ alpha value, checking against the priority
+ bitmap
+-------------------------------------------------*/
-#if (RAW == 0)
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_alpha,(COMMON_ARGS, COLOR_ARG, int transpen),
+void pdrawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
+ UINT32 transpen, UINT8 alpha)
{
- ADJUST_8
+ const pen_t *paldata;
- (void)palette_shadow_table;
+ /* non-zoom case */
+ if (scalex == 0x10000 && scaley == 0x10000)
+ {
+ pdrawgfx_alpha(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen, alpha);
+ return;
+ }
- if (flipx)
+ /* special case alpha = 0xff */
+ if (alpha == 0xff)
{
- DATA_TYPE *end;
- int trans4;
- UINT32 *sd4;
+ pdrawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask, transpen);
+ return;
+ }
- trans4 = transpen * 0x01010101;
+ assert(dest != NULL);
+ assert(dest->bpp == 16 || dest->bpp == 32);
+ assert(gfx != NULL);
- while (dstheight)
- {
- end = dstdata - dstwidth*HMODULO;
- while (((FPTR)srcdata & 3) && dstdata > end) /* longword align */
- {
- int col;
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
+ return;
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
- INCREMENT_DST(-HMODULO);
- }
- sd4 = (UINT32 *)srcdata;
- while (dstdata >= end + 4*HMODULO)
- {
- UINT32 col4;
+ /* high bit of the mask is implicitly on */
+ pmask |= 1 << 31;
+
+ /* render based on dest bitmap depth */
+ if (dest->bpp == 16)
+ DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16_PRIORITY, UINT8);
+ else
+ DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, UINT8);
+}
- INCREMENT_DST(-4*HMODULO);
- if ((col4 = *(sd4++)) != trans4)
- {
- UINT32 xod4;
- xod4 = col4 ^ trans4;
- if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(4*HMODULO,alpha_blend(dstdata[4*HMODULO], LOOKUP((col4>>SHIFT0) & 0xff)));
- if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(3*HMODULO,alpha_blend(dstdata[3*HMODULO], LOOKUP((col4>>SHIFT1) & 0xff)));
- if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,alpha_blend(dstdata[2*HMODULO], LOOKUP((col4>>SHIFT2) & 0xff)));
- if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(1*HMODULO,alpha_blend(dstdata[1*HMODULO], LOOKUP((col4>>SHIFT3) & 0xff)));
- }
- }
- srcdata = (UINT8 *)sd4;
- while (dstdata > end)
- {
- int col;
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
- INCREMENT_DST(-HMODULO);
- }
+/***************************************************************************
+ DRAW_SCANLINE IMPLEMENTATIONS
+***************************************************************************/
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO);
- dstheight--;
- }
+/*-------------------------------------------------
+ draw_scanline8 - copy pixels from an 8bpp
+ buffer to a single scanline of a bitmap
+-------------------------------------------------*/
+
+void draw_scanline8(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT8 *srcptr, const pen_t *paldata)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+
+ assert(bitmap != NULL);
+ assert(bitmap->bpp == 16 || bitmap->bpp == 32);
+
+ /* palette lookup case */
+ if (paldata != NULL)
+ {
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+ else
+ DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
}
+
+ /* raw copy case */
else
{
- DATA_TYPE *end;
- int trans4;
- UINT32 *sd4;
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ DRAWSCANLINE_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ else
+ DRAWSCANLINE_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ }
+}
- trans4 = transpen * 0x01010101;
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (((FPTR)srcdata & 3) && dstdata < end) /* longword align */
- {
- int col;
+/*-------------------------------------------------
+ draw_scanline16 - copy pixels from a 16bpp
+ buffer to a single scanline of a bitmap
+-------------------------------------------------*/
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
- INCREMENT_DST(HMODULO);
- }
- sd4 = (UINT32 *)srcdata;
- while (dstdata <= end - 4*HMODULO)
- {
- UINT32 col4;
+void draw_scanline16(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT16 *srcptr, const pen_t *paldata)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
- if ((col4 = *(sd4++)) != trans4)
- {
- UINT32 xod4;
+ assert(bitmap != NULL);
+ assert(bitmap->bpp == 16 || bitmap->bpp == 32);
- xod4 = col4 ^ trans4;
- if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(0*HMODULO,alpha_blend(dstdata[0*HMODULO], LOOKUP((col4>>SHIFT0) & 0xff)));
- if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(1*HMODULO,alpha_blend(dstdata[1*HMODULO], LOOKUP((col4>>SHIFT1) & 0xff)));
- if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,alpha_blend(dstdata[2*HMODULO], LOOKUP((col4>>SHIFT2) & 0xff)));
- if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(3*HMODULO,alpha_blend(dstdata[3*HMODULO], LOOKUP((col4>>SHIFT3) & 0xff)));
- }
- INCREMENT_DST(4*HMODULO);
- }
- srcdata = (UINT8 *)sd4;
- while (dstdata < end)
- {
- int col;
+ /* palette lookup case */
+ if (paldata != NULL)
+ {
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+ else
+ DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+ }
+
+ /* raw copy case */
+ else
+ {
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ DRAWSCANLINE_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ else
+ DRAWSCANLINE_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ }
+}
- col = *(srcdata++);
- if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
- INCREMENT_DST(HMODULO);
- }
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO);
- dstheight--;
- }
- }
-})
+/*-------------------------------------------------
+ draw_scanline32 - copy pixels from a 32bpp
+ buffer to a single scanline of a bitmap
+-------------------------------------------------*/
-/* pjp 02/06/02 */
-DECLARE_SWAP_RAW_PRI(blockmove_8toN_alpharange,(COMMON_ARGS, COLOR_ARG, int transpen),
+void draw_scanline32(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, const pen_t *paldata)
{
- ADJUST_8
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
- (void)palette_shadow_table;
+ assert(bitmap != NULL);
+ assert(bitmap->bpp == 16 || bitmap->bpp == 32);
- if (flipx)
+ /* palette lookup case */
+ if (paldata != NULL)
{
- DATA_TYPE *end;
-
- while (dstheight)
- {
- end = dstdata - dstwidth*HMODULO;
- while (dstdata > end) /* Note that I'm missing the optimisations present in the other alpha functions */
- {
- int col;
-
- col = *(srcdata++);
- if (col != transpen)
- {
- if (gfx_alpharange_table[col] == 0xff)
- SETPIXELCOLOR(0,LOOKUP(col))
- else
- SETPIXELCOLOR(0,alpha_blend_r(*dstdata,LOOKUP(col),gfx_alpharange_table[col]))
- }
- INCREMENT_DST(-HMODULO);
- }
-
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO);
- dstheight--;
- }
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
+ else
+ DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
}
+
+ /* raw copy case */
else
{
- DATA_TYPE *end;
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ DRAWSCANLINE_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ else
+ DRAWSCANLINE_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ }
+}
- while (dstheight)
- {
- end = dstdata + dstwidth*HMODULO;
- while (dstdata < end)
- {
- int col;
- col = *(srcdata++);
- if (col != transpen)
- {
- if (gfx_alpharange_table[col] == 0xff)
- SETPIXELCOLOR(0,LOOKUP(col))
- else
- SETPIXELCOLOR(0,alpha_blend_r(*dstdata,LOOKUP(col),gfx_alpharange_table[col]))
- }
- INCREMENT_DST(HMODULO);
- }
- srcdata += srcmodulo;
- INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO);
- dstheight--;
- }
- }
-})
-#endif
+/***************************************************************************
+ EXTRACT_SCANLINE IMPLEMENTATIONS
+***************************************************************************/
-DECLARE(blockmove_NtoN_opaque_noremap,(
- const DATA_TYPE *srcdata,int srcwidth,int srcheight,int srcmodulo,
- DATA_TYPE *dstdata,int dstmodulo),
-{
- while (srcheight)
- {
- memcpy(dstdata,srcdata,srcwidth * sizeof(DATA_TYPE));
- srcdata += srcmodulo;
- dstdata += dstmodulo;
- srcheight--;
- }
-})
+/*-------------------------------------------------
+ extract_scanline8 - copy pixels from a single
+ scanline of a bitmap to an 8bpp buffer
+-------------------------------------------------*/
-DECLARE(blockmove_NtoN_opaque_noremap_flipx,(
- const DATA_TYPE *srcdata,int srcwidth,int srcheight,int srcmodulo,
- DATA_TYPE *dstdata,int dstmodulo),
+void extract_scanline8(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT8 *destptr)
{
- DATA_TYPE *end;
-
- srcmodulo += srcwidth;
- dstmodulo -= srcwidth;
+ assert(bitmap != NULL);
+ assert(bitmap->bpp == 16 || bitmap->bpp == 32);
- while (srcheight)
- {
- end = dstdata + srcwidth;
- while (dstdata <= end - 8)
- {
- srcdata -= 8;
- dstdata[0] = srcdata[8];
- dstdata[1] = srcdata[7];
- dstdata[2] = srcdata[6];
- dstdata[3] = srcdata[5];
- dstdata[4] = srcdata[4];
- dstdata[5] = srcdata[3];
- dstdata[6] = srcdata[2];
- dstdata[7] = srcdata[1];
- dstdata += 8;
- }
- while (dstdata < end)
- *(dstdata++) = *(srcdata--);
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ EXTRACTSCANLINE_CORE(UINT16);
+ else
+ EXTRACTSCANLINE_CORE(UINT32);
+}
- srcdata += srcmodulo;
- dstdata += dstmodulo;
- srcheight--;
- }
-})
+/*-------------------------------------------------
+ extract_scanline16 - copy pixels from a single
+ scanline of a bitmap to a 16bpp buffer
+-------------------------------------------------*/
-DECLARE(drawgfx_core,(
- bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
- bitmap_t *pri_buffer,UINT32 pri_mask),
+void extract_scanline16(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT16 *destptr)
{
- int ox;
- int oy;
- int ex;
- int ey;
-
- /* check bounds */
- ox = sx;
- oy = sy;
-
- ex = sx + gfx->width-1;
- if (sx < 0) sx = 0;
- if (clip && sx < clip->min_x) sx = clip->min_x;
- if (ex >= dest->width) ex = dest->width-1;
- if (clip && ex > clip->max_x) ex = clip->max_x;
- if (sx > ex) return;
-
- ey = sy + gfx->height-1;
- if (sy < 0) sy = 0;
- if (clip && sy < clip->min_y) sy = clip->min_y;
- if (ey >= dest->height) ey = dest->height-1;
- if (clip && ey > clip->max_y) ey = clip->max_y;
- if (sy > ey) return;
+ assert(bitmap != NULL);
+ assert(bitmap->bpp == 16 || bitmap->bpp == 32);
- {
- pen_t *st = gfx->machine->shadow_table;
- UINT8 *sd = gfx->gfxdata + code * gfx->char_modulo; /* source data */
- int sw = gfx->width; /* source width */
- int sh = gfx->height; /* source height */
- int sm = gfx->line_modulo; /* source modulo */
- int ls = sx-ox; /* left skip */
- int ts = sy-oy; /* top skip */
- DATA_TYPE *dd = BITMAP_ADDR(dest, DATA_TYPE, sy, sx); /* dest data */
- int dw = ex-sx+1; /* dest width */
- int dh = ey-sy+1; /* dest height */
- int dm = dest->rowpixels; /* dest modulo */
- int colorbase = gfx->color_base + gfx->color_granularity * color;
- const pen_t *paldata = &gfx->machine->pens[colorbase];
- UINT8 *pribuf = (pri_buffer) ? BITMAP_ADDR8(pri_buffer, sy, sx) : NULL;
-
- switch (transparency)
- {
- case TRANSPARENCY_NONE:
- if (gfx->flags & GFX_ELEMENT_PACKED)
- {
- if (pribuf)
- BLOCKMOVEPRI(4toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask));
- else
- BLOCKMOVELU(4toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata));
- }
- else
- {
- if (pribuf)
- BLOCKMOVEPRI(8toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask));
- else
- BLOCKMOVELU(8toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata));
- }
- break;
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ EXTRACTSCANLINE_CORE(UINT16);
+ else
+ EXTRACTSCANLINE_CORE(UINT32);
+}
- case TRANSPARENCY_PEN:
- if (gfx->flags & GFX_ELEMENT_PACKED)
- {
- if (pribuf)
- BLOCKMOVEPRI(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVELU(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
- }
- else
- {
- if (pribuf)
- BLOCKMOVEPRI(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVELU(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
- }
- break;
- case TRANSPARENCY_PEN_RAW:
- if (gfx->flags & GFX_ELEMENT_PACKED)
- {
- if (pribuf)
- BLOCKMOVERAWPRI(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVERAW(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,transparent_color));
- }
- else
- {
- if (pribuf)
- BLOCKMOVERAWPRI(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVERAW(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,transparent_color));
- }
- break;
-
- case TRANSPARENCY_PENS:
- if (pribuf)
- BLOCKMOVEPRI(8toN_transmask,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVELU(8toN_transmask,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
- break;
-
- case TRANSPARENCY_PEN_TABLE:
- if (pribuf)
- BLOCKMOVEPRI(8toN_pen_table,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVELU(8toN_pen_table,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
- break;
-
- case TRANSPARENCY_ALPHA:
- if (pribuf)
- BLOCKMOVEPRI(8toN_alpha,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVELU(8toN_alpha,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
- break;
-
- case TRANSPARENCY_ALPHARANGE:
- if (pribuf)
- BLOCKMOVEPRI(8toN_alpharange,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
- else
- BLOCKMOVELU(8toN_alpharange,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
- break;
-
- default:
- if (pribuf)
- popmessage("pdrawgfx pen mode not supported");
- else
- popmessage("drawgfx pen mode not supported");
- break;
- }
- }
-})
+/*-------------------------------------------------
+ extract_scanline32 - copy pixels from a single
+ scanline of a bitmap to a 32bpp buffer
+-------------------------------------------------*/
-DECLARE(copybitmap_core,(
- bitmap_t *dest,bitmap_t *src,
- int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color),
+void extract_scanline32(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT32 *destptr)
{
- int ox;
- int oy;
- int ex;
- int ey;
-
- /* check bounds */
- ox = sx;
- oy = sy;
-
- ex = sx + src->width-1;
- if (sx < 0) sx = 0;
- if (clip && sx < clip->min_x) sx = clip->min_x;
- if (ex >= dest->width) ex = dest->width-1;
- if (clip && ex > clip->max_x) ex = clip->max_x;
- if (sx > ex) return;
-
- ey = sy + src->height-1;
- if (sy < 0) sy = 0;
- if (clip && sy < clip->min_y) sy = clip->min_y;
- if (ey >= dest->height) ey = dest->height-1;
- if (clip && ey > clip->max_y) ey = clip->max_y;
- if (sy > ey) return;
+ assert(bitmap != NULL);
+ assert(bitmap->bpp == 16 || bitmap->bpp == 32);
- {
- DATA_TYPE *sd = (DATA_TYPE *)src->base; /* source data */
- int sw = ex-sx+1; /* source width */
- int sh = ey-sy+1; /* source height */
- int sm = src->rowpixels; /* source modulo */
- DATA_TYPE *dd = BITMAP_ADDR(dest, DATA_TYPE, sy, sx); /* dest data */
- int dm = dest->rowpixels; /* dest modulo */
-
- if (flipx)
- sd += src->width -1 -(sx-ox);
- else
- sd += (sx-ox);
+ /* 16bpp case */
+ if (bitmap->bpp == 16)
+ EXTRACTSCANLINE_CORE(UINT16);
+ else
+ EXTRACTSCANLINE_CORE(UINT32);
+}
- if (flipy)
- {
- sd += sm * (src->height -1 -(sy-oy));
- sm = -sm;
- }
- else
- sd += sm * (sy-oy);
- switch (transparency)
- {
- case TRANSPARENCY_NONE:
- BLOCKMOVE(NtoN_opaque_noremap,flipx,(sd,sw,sh,sm,dd,dm));
- break;
- case TRANSPARENCY_PEN:
- BLOCKMOVE(NtoN_transpen_noremap,flipx,(sd,sw,sh,sm,dd,dm,transparent_color));
- break;
+/***************************************************************************
+ COPYBITMAP IMPLEMENTATIONS
+***************************************************************************/
- default:
- popmessage("copybitmap pen mode not supported");
- break;
- }
- }
-})
+/*-------------------------------------------------
+ copybitmap - copy from one bitmap to another,
+ copying all unclipped pixels
+-------------------------------------------------*/
-DECLARE(copyrozbitmap_core,(bitmap_t *bitmap,bitmap_t *srcbitmap,
- UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound,
- const rectangle *clip,int transparency,int transparent_color,UINT32 priority),
+void copybitmap(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect)
{
- UINT32 cx;
- UINT32 cy;
- int x;
- int sx;
- int sy;
- int ex;
- int ey;
- const int xmask = srcbitmap->width-1;
- const int ymask = srcbitmap->height-1;
- const int widthshifted = srcbitmap->width << 16;
- const int heightshifted = srcbitmap->height << 16;
- DATA_TYPE *dest;
-
- if (clip)
- {
- startx += clip->min_x * incxx + clip->min_y * incyx;
- starty += clip->min_x * incxy + clip->min_y * incyy;
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
- sx = clip->min_x;
- sy = clip->min_y;
- ex = clip->max_x;
- ey = clip->max_y;
- }
- else
- {
- sx = 0;
- sy = 0;
- ex = bitmap->width-1;
- ey = bitmap->height-1;
- }
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
+ assert(src->bpp == dest->bpp);
+ if (dest->bpp == 8)
+ COPYBITMAP_CORE(UINT8, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ else if (dest->bpp == 16)
+ COPYBITMAP_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ else
+ COPYBITMAP_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+}
- if (incxy == 0 && incyx == 0 && !wraparound)
- {
- /* optimized loop for the not rotated case */
- if (incxx == 0x10000)
- {
- /* optimized loop for the not zoomed case */
+/*-------------------------------------------------
+ copybitmap_trans - copy from one bitmap to
+ another, copying all unclipped pixels except
+ those that match transpen
+-------------------------------------------------*/
- /* startx is unsigned */
- startx = ((INT32)startx) >> 16;
+void copybitmap_trans(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, UINT32 transpen)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
- if (startx >= srcbitmap->width)
- {
- sx += -startx;
- startx = 0;
- }
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
+ assert(src->bpp == dest->bpp);
- if (sx <= ex)
- {
- while (sy <= ey)
- {
- if (starty < heightshifted)
- {
- x = sx;
- cx = startx;
- cy = starty >> 16;
- dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, sx);
- if (priority)
- {
- UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
- DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
-
- while (x <= ex && cx < srcbitmap->width)
- {
- int c = src[cx];
-
- if (c != transparent_color)
- {
- *dest = c;
- *pri |= priority;
- }
-
- cx++;
- x++;
- dest++;
- pri++;
- }
- }
- else
- {
- DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
-
- while (x <= ex && cx < srcbitmap->width)
- {
- int c = src[cx];
-
- if (c != transparent_color)
- *dest = c;
-
- cx++;
- x++;
- dest++;
- }
- }
- }
- starty += incyy;
- sy++;
- }
- }
- }
+ if (dest->bpp == 8)
+ {
+ if (transpen > 0xff)
+ copybitmap(dest, src, flipx, flipy, destx, desty, cliprect);
else
- {
- while (startx >= widthshifted && sx <= ex)
- {
- startx += incxx;
- sx++;
- }
-
- if (sx <= ex)
- {
- while (sy <= ey)
- {
- if (starty < heightshifted)
- {
- x = sx;
- cx = startx;
- cy = starty >> 16;
- dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, sx);
- if (priority)
- {
- UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
- DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
-
- while (x <= ex && cx < widthshifted)
- {
- int c = src[cx >> 16];
-
- if (c != transparent_color)
- {
- *dest = c;
- *pri |= priority;
- }
-
- cx += incxx;
- x++;
- dest++;
- pri++;
- }
- }
- else
- {
- DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
-
- while (x <= ex && cx < widthshifted)
- {
- int c = src[cx >> 16];
-
- if (c != transparent_color)
- *dest = c;
-
- cx += incxx;
- x++;
- dest++;
- }
- }
- }
- starty += incyy;
- sy++;
- }
- }
- }
+ COPYBITMAP_CORE(UINT8, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
+ }
+ else if (dest->bpp == 16)
+ {
+ if (transpen > 0xffff)
+ copybitmap(dest, src, flipx, flipy, destx, desty, cliprect);
+ else
+ COPYBITMAP_CORE(UINT16, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
}
else
{
- if (wraparound)
- {
- /* plot with wraparound */
- while (sy <= ey)
- {
- x = sx;
- cx = startx;
- cy = starty;
- dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, sx);
- if (priority)
- {
- UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
+ if (transpen == 0xffffffff)
+ copybitmap(dest, src, flipx, flipy, destx, desty, cliprect);
+ else
+ COPYBITMAP_CORE(UINT32, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
+ }
+}
- while (x <= ex)
- {
- int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, (cy >> 16) & ymask, (cx >> 16) & xmask);
-
- if (c != transparent_color)
- {
- *dest = c;
- *pri |= priority;
- }
-
- cx += incxx;
- cy += incxy;
- x++;
- dest++;
- pri++;
- }
- }
- else
- {
- while (x <= ex)
- {
- int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, (cy >> 16) & ymask, (cx >> 16) & xmask);
- if (c != transparent_color)
- *dest = c;
- cx += incxx;
- cy += incxy;
- x++;
- dest++;
- }
- }
- startx += incyx;
- starty += incyy;
- sy++;
- }
- }
- else
- {
- while (sy <= ey)
- {
- x = sx;
- cx = startx;
- cy = starty;
- if (priority)
- {
- UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
-
- while (x <= ex)
- {
- if (cx < widthshifted && cy < heightshifted)
- {
- int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, cy >> 16, cx >> 16);
-
- if (c != transparent_color)
- {
- dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, x);
- *dest = c;
- *pri |= priority;
- }
- }
-
- cx += incxx;
- cy += incxy;
- x++;
- pri++;
- }
- }
- else
- {
- while (x <= ex)
- {
- if (cx < widthshifted && cy < heightshifted)
- {
- int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, cy >> 16, cx >> 16);
-
- if (c != transparent_color)
- {
- dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, x);
- *dest = c;
- }
- }
-
- cx += incxx;
- cy += incxy;
- x++;
- }
- }
- startx += incyx;
- starty += incyy;
- sy++;
- }
- }
- }
-})
+/***************************************************************************
+ COPYSCROLLBITMAP IMPLEMENTATIONS
+***************************************************************************/
-#endif /* (DEPTH != 8) */
+/*-------------------------------------------------
+ copyscrollbitmap - copy from one bitmap to
+ another, copying all unclipped pixels, and
+ applying scrolling to one or more rows/colums
+-------------------------------------------------*/
-DECLAREG(draw_scanline, (
- bitmap_t *bitmap,int x,int y,int length,
- const DATA_TYPE *src,const pen_t *pens,int transparent_pen),
+void copyscrollbitmap(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect)
{
- assert(bitmap != NULL);
- assert((bitmap->bpp == 16) || (bitmap->bpp == 32));
- assert(src != NULL);
- assert(length > 0);
- assert(x >= 0);
- assert(y >= 0);
+ /* just call through to the transparent case as the underlying copybitmap will
+ optimize for pen == 0xffffffff */
+ copyscrollbitmap_trans(dest, src, numrows, rowscroll, numcols, colscroll, cliprect, 0xffffffff);
+}
- /* 16bpp destination */
- if (bitmap->bpp == 16)
- {
- UINT16 *dst = BITMAP_ADDR16(bitmap, y, x);
- int xadv = 1;
- /* with pen lookups */
- if (pens)
- {
- if (transparent_pen == -1)
- while (length--)
- {
- *dst = pens[*src++];
- dst += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- *dst = pens[spixel];
- dst += xadv;
- }
- }
+/*-------------------------------------------------
+ copyscrollbitmap_trans - copy from one bitmap
+ to another, copying all unclipped pixels
+ except those that match transpen, and applying
+ scrolling to one or more rows/colums
+-------------------------------------------------*/
- /* without pen lookups */
- else
- {
- if (transparent_pen == -1)
- while (length--)
- {
- *dst = *src++;
- dst += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- *dst = spixel;
- dst += xadv;
- }
- }
+void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect, UINT32 transpen)
+{
+ /* no rowscroll and no colscroll means no scroll */
+ if (numrows == 0 && numcols == 0)
+ {
+ copybitmap_trans(dest, src, 0, 0, 0, 0, cliprect, transpen);
+ return;
}
- /* 32bpp destination */
- else
- {
- UINT32 *dst = BITMAP_ADDR32(bitmap, y, x);
- int xadv = 1;
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
+ assert(dest->bpp == src->bpp);
+ assert(numrows != 0 || rowscroll == NULL);
+ assert(numrows == 0 || rowscroll != NULL);
+ assert(numcols != 0 || colscroll == NULL);
+ assert(numcols == 0 || colscroll != NULL);
- /* with pen lookups */
- if (pens)
- {
- if (transparent_pen == -1)
- while (length--)
- {
- *dst = pens[*src++];
- dst += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- *dst = pens[spixel];
- dst += xadv;
- }
- }
+ /* NULL clip means use the full bitmap */
+ if (cliprect == NULL)
+ cliprect = &dest->cliprect;
- /* without pen lookups */
- else
- {
- if (transparent_pen == -1)
- while (length--)
- {
- *dst = *src++;
- dst += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- *dst = spixel;
- dst += xadv;
- }
- }
+ /* fully scrolling X,Y playfield */
+ if (numrows <= 1 && numcols <= 1)
+ {
+ INT32 xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]);
+ INT32 yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]);
+ INT32 sx, sy;
+
+ /* iterate over all portions of the scroll that overlap the destination */
+ for (sx = xscroll - src->width; sx < dest->width; sx += src->width)
+ for (sy = yscroll - src->height; sy < dest->height; sy += src->height)
+ copybitmap_trans(dest, src, 0, 0, sx, sy, cliprect, transpen);
}
-})
-DECLAREG(pdraw_scanline, (
- bitmap_t *bitmap,int x,int y,int length,
- const DATA_TYPE *src,const pen_t *pens,int transparent_pen,int pri),
-{
- assert(bitmap != NULL);
- assert((bitmap->bpp == 16) || (bitmap->bpp == 32));
- assert(length > 0);
- assert(x >= 0);
- assert(y >= 0);
-
- /* 16bpp destination */
- if (bitmap->bpp == 16)
+ /* scrolling columns plus horizontal scroll */
+ else if (numrows <= 1)
{
- UINT16 *dsti = BITMAP_ADDR16(bitmap, y, x);
- UINT8 *dstp = BITMAP_ADDR8(priority_bitmap, y, x);
- int xadv = 1;
+ INT32 xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]);
+ rectangle subclip = *cliprect;
+ int col, colwidth, groupcols;
- /* with pen lookups */
- if (pens)
- {
- if (transparent_pen == -1)
- while (length--)
- {
- *dsti = pens[*src++];
- *dstp = pri;
- dsti += xadv;
- dstp += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- {
- *dsti = pens[spixel];
- *dstp = pri;
- }
- dsti += xadv;
- dstp += xadv;
- }
- }
+ /* determine width of each column */
+ colwidth = src->width / numcols;
+ assert(src->width % colwidth == 0);
- /* without pen lookups */
- else
+ /* iterate over each column */
+ for (col = 0; col < numcols; col += groupcols)
{
- if (transparent_pen == -1)
- while (length--)
- {
- *dsti = *src++;
- *dstp = pri;
- dsti += xadv;
- dstp += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- {
- *dsti = spixel;
- *dstp = pri;
- }
- dsti += xadv;
- dstp += xadv;
- }
+ INT32 yscroll = colscroll[col];
+ INT32 sx, sy;
+
+ /* count consecutive columns scrolled by the same amount */
+ for (groupcols = 1; col + groupcols < numcols; groupcols++)
+ if (colscroll[col + groupcols] != yscroll)
+ break;
+
+ /* compute the cliprect for this group */
+ subclip.min_x = col * colwidth;
+ subclip.max_x = (col + groupcols) * colwidth - 1;
+ sect_rect(&subclip, cliprect);
+
+ /* iterate over all portions of the scroll that overlap the destination */
+ for (sy = normalize_yscroll(src, yscroll) - src->height; sy < dest->height; sy += src->height)
+ for (sx = xscroll - src->width; sx < dest->width; sx += src->width)
+ copybitmap_trans(dest, src, 0, 0, sx, sy, &subclip, transpen);
}
}
- /* 32bpp destination */
- else
+ /* scrolling rows plus vertical scroll */
+ else if (numcols <= 1)
{
- UINT32 *dsti = BITMAP_ADDR32(bitmap, y, x);
- UINT8 *dstp = BITMAP_ADDR8(priority_bitmap, y, x);
- int xadv = 1;
+ INT32 yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]);
+ rectangle subclip = *cliprect;
+ int row, rowheight, grouprows;
- /* with pen lookups */
- if (pens)
- {
- if (transparent_pen == -1)
- while (length--)
- {
- *dsti = pens[*src++];
- *dstp = pri;
- dsti += xadv;
- dstp += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- {
- *dsti = pens[spixel];
- *dstp = pri;
- }
- dsti += xadv;
- dstp += xadv;
- }
- }
+ /* determine width of each rows */
+ rowheight = src->height / numrows;
+ assert(src->height % rowheight == 0);
- /* without pen lookups */
- else
+ /* iterate over each row */
+ for (row = 0; row < numrows; row += grouprows)
{
- if (transparent_pen == -1)
- while (length--)
- {
- *dsti = *src++;
- *dstp = pri;
- dsti += xadv;
- dstp += xadv;
- }
- else
- while (length--)
- {
- UINT32 spixel = *src++;
- if (spixel != transparent_pen)
- {
- *dsti = spixel;
- *dstp = pri;
- }
- dsti += xadv;
- dstp += xadv;
- }
+ INT32 xscroll = rowscroll[row];
+ INT32 sx, sy;
+
+ /* count consecutive rows scrolled by the same amount */
+ for (grouprows = 1; row + grouprows < numrows; grouprows++)
+ if (rowscroll[row + grouprows] != xscroll)
+ break;
+
+ /* compute the cliprect for this group */
+ subclip.min_y = row * rowheight;
+ subclip.max_y = (row + grouprows) * rowheight - 1;
+ sect_rect(&subclip, cliprect);
+
+ /* iterate over all portions of the scroll that overlap the destination */
+ for (sx = normalize_xscroll(src, xscroll) - src->width; sx < dest->width; sx += src->width)
+ for (sy = yscroll - src->height; sy < dest->height; sy += src->height)
+ copybitmap_trans(dest, src, 0, 0, sx, sy, &subclip, transpen);
}
}
}
-)
-DECLAREG(extract_scanline, (
- bitmap_t *bitmap,int x,int y,int length,
- DATA_TYPE *dst),
-{
- assert(bitmap != NULL);
- assert((bitmap->bpp == 16) || (bitmap->bpp == 32));
- assert(dst != NULL);
- assert(length > 0);
- assert(x >= 0);
- assert(y >= 0);
- /* 16bpp destination */
- if (bitmap->bpp == 16)
- {
- UINT16 *src = BITMAP_ADDR16(bitmap, y, x);
- int xadv = 1;
- while (length--)
- {
- *dst++ = *src;
- src += xadv;
- }
- }
+/***************************************************************************
+ COPYROZBITMAP IMPLEMENTATIONS
+***************************************************************************/
+
+/*-------------------------------------------------
+ copyrozbitmap - copy from one bitmap to another,
+ with zoom and rotation, copying all unclipped
+ pixels
+-------------------------------------------------*/
+
+void copyrozbitmap(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
- /* 32bpp destination */
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
+ assert(src->bpp == dest->bpp);
+
+ if (dest->bpp == 8)
+ COPYROZBITMAP_CORE(UINT8, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+ else if (dest->bpp == 16)
+ COPYROZBITMAP_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
else
- {
- UINT32 *src = BITMAP_ADDR32(bitmap, y, x);
- int xadv = 1;
+ COPYROZBITMAP_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
+}
- while (length--)
- {
- *dst++ = *src;
- src += xadv;
- }
- }
-})
-#endif /* DECLAREG */
+/*-------------------------------------------------
+ copyrozbitmap_trans - copy from one bitmap to
+ another, with zoom and rotation, copying all
+ unclipped pixels whose values do not match
+ transpen
+-------------------------------------------------*/
+
+void copyrozbitmap_trans(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound, UINT32 transpen)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+
+ assert(dest != NULL);
+ assert(src != NULL);
+ assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
+ assert(src->bpp == dest->bpp);
+
+ if (dest->bpp == 8)
+ COPYROZBITMAP_CORE(UINT8, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
+ else if (dest->bpp == 16)
+ COPYROZBITMAP_CORE(UINT16, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
+ else
+ COPYROZBITMAP_CORE(UINT32, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
+}
diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h
index 96249a9d85d..4e8c2ee4b20 100644
--- a/src/emu/drawgfx.h
+++ b/src/emu/drawgfx.h
@@ -50,11 +50,7 @@ enum
{
TRANSPARENCY_NONE, /* opaque with remapping */
TRANSPARENCY_PEN, /* single pen transparency with remapping */
- TRANSPARENCY_PEN_RAW, /* single pen transparency with no remapping */
TRANSPARENCY_PENS, /* multiple pen transparency with remapping */
- TRANSPARENCY_PEN_TABLE, /* special pen remapping modes (see DRAWMODE_xxx below) with remapping */
- TRANSPARENCY_ALPHA, /* single pen transparency, other pens alpha */
- TRANSPARENCY_ALPHARANGE, /* single pen transparency, multiple pens alpha depending on array, see psikyosh.c */
TRANSPARENCY_MODES /* total number of modes; must be last */
};
@@ -99,6 +95,7 @@ enum
const gfx_layout name = { width, height, RGN_FRAC(1,1), planes, { GFX_RAW }, { 0 }, { linemod }, charmod };
+
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
@@ -122,8 +119,13 @@ struct _gfx_layout
/* In mamecore.h: typedef struct _gfx_element gfx_element; */
struct _gfx_element
{
- UINT16 width; /* pixel width of each element */
- UINT16 height; /* pixel height of each element */
+ UINT16 width; /* current pixel width of each element (changeble with source clipping) */
+ UINT16 height; /* current pixel height of each element (changeble with source clipping) */
+ UINT16 startx; /* current source clip X offset */
+ UINT16 starty; /* current source clip Y offset */
+
+ UINT16 origwidth; /* starting pixel width of each element */
+ UINT16 origheight; /* staring pixel height of each element */
UINT8 flags; /* one of the GFX_ELEMENT_* flags above */
UINT32 total_elements; /* total number of decoded elements */
@@ -131,13 +133,17 @@ struct _gfx_element
UINT16 color_depth; /* number of colors each pixel can represent */
UINT16 color_granularity; /* number of colors for each color code */
UINT32 total_colors; /* number of color codes */
-
+
UINT32 * pen_usage; /* bitmask of pens that are used (pens 0-31 only) */
UINT8 * gfxdata; /* pixel data, 8bpp or 4bpp (if GFX_ELEMENT_PACKED) */
UINT32 line_modulo; /* bytes between each row of data */
UINT32 char_modulo; /* bytes between each element */
- running_machine * machine; /* pointer to the owning machine */
+ const UINT8 * srcdata; /* pointer to the source data for decoding */
+ UINT8 * dirty; /* dirty array for detecting tiles that need decoding */
+ UINT32 dirtyseq; /* sequence number; incremented each time a tile is dirtied */
+
+ running_machine *machine; /* pointer to the owning machine */
gfx_layout layout; /* copy of the original layout */
};
@@ -155,127 +161,171 @@ struct _gfx_decode_entry
};
-typedef struct _alpha_cache alpha_cache;
-struct _alpha_cache
-{
- int alphas;
- int alphad;
-};
-
-
/***************************************************************************
- GLOBAL VARIABLES
+ FUNCTION PROTOTYPES
***************************************************************************/
-/* drawing mode case TRANSPARENCY_ALPHARANGE */
-extern UINT8 gfx_alpharange_table[256];
-/* drawing mode case TRANSPARENCY_PEN_TABLE */
-extern UINT8 gfx_drawmode_table[256];
+/* ----- graphics elements ----- */
-/* By default, when drawing sprites with pdrawgfx, shadows affect the sprites below them. */
-/* Set this flag to 1 to make shadows only affect the background, leaving sprites at full brightness. */
-extern int pdrawgfx_shadow_lowpri;
+/* allocate a gfx_element structure based on a given layout */
+gfx_element *gfx_element_alloc(running_machine *machine, const gfx_layout *gl, const UINT8 *srcdata, UINT32 total_colors, UINT32 color_base);
+/* update a single code in a gfx_element */
+void gfx_element_decode(const gfx_element *gfx, UINT32 code);
+/* free a gfx_element */
+void gfx_element_free(gfx_element *gfx);
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-void drawgfx_init(running_machine *machine);
+/* ----- core graphics drawing ----- */
+
+/* generic drawgfx with legacy interface */
+void drawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color);
+
+/* specific drawgfx implementations for each transparency type */
+void drawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty);
+void drawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen);
+void drawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen);
+void drawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transmask);
+void drawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const UINT8 *pentable, const pen_t *shadowtable);
+void drawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen, UINT8 alpha);
+
+
+
+/* ----- zoomed graphics drawing ----- */
+
+/* generic drawgfxzoom with legacy interface */
+void drawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color, UINT32 scalex, UINT32 scaley);
+
+/* specific drawgfxzoom implementations for each transparency type */
+void drawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley);
+void drawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen);
+void drawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen);
+void drawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transmask);
+void drawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, const UINT8 *pentable, const pen_t *shadowtable);
+void drawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen, UINT8 alpha);
+
+
+
+/* ----- priority masked graphics drawing ----- */
+
+/* generic pdrawgfx with legacy interface */
+void pdrawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color, UINT32 pmask);
+
+/* specific pdrawgfx implementations for each transparency type */
+void pdrawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask);
+void pdrawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
+void pdrawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
+void pdrawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transmask);
+void pdrawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, const UINT8 *pentable, const pen_t *shadowtable);
+void pdrawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transpen, UINT8 alpha);
-void decodechar(gfx_element *gfx,int num,const unsigned char *src);
-gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl);
-void decodegfx(gfx_element *gfx, const UINT8 *src, UINT32 first, UINT32 count);
-void freegfx(gfx_element *gfx);
-void drawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color);
-void pdrawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
- UINT32 priority_mask);
-void mdrawgfx(bitmap_t *dest,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
- UINT32 priority_mask);
+/* ----- priority masked zoomed graphics drawing ----- */
+/* generic pdrawgfxzoom with legacy interface */
+void pdrawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color, UINT32 scalex, UINT32 scaley, UINT32 pmask);
-void drawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley);
-void pdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley,
- UINT32 priority_mask);
-void mdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
- unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley,
- UINT32 priority_mask);
+/* specific pdrawgfxzoom implementations for each transparency type */
+void pdrawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask);
+void pdrawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
+void pdrawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
+void pdrawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transmask);
+void pdrawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, const UINT8 *pentable, const pen_t *shadowtable);
+void pdrawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transpen, UINT8 alpha);
-void draw_scanline8(bitmap_t *bitmap,int x,int y,int length,const UINT8 *src,const pen_t *pens,int transparent_pen);
-void draw_scanline16(bitmap_t *bitmap,int x,int y,int length,const UINT16 *src,const pen_t *pens,int transparent_pen);
-void draw_scanline32(bitmap_t *bitmap,int x,int y,int length,const UINT32 *src,const pen_t *pens,int transparent_pen);
-void pdraw_scanline8(bitmap_t *bitmap,int x,int y,int length,const UINT8 *src,const pen_t *pens,int transparent_pen,int pri);
-void pdraw_scanline16(bitmap_t *bitmap,int x,int y,int length,const UINT16 *src,const pen_t *pens,int transparent_pen,int pri);
-void pdraw_scanline32(bitmap_t *bitmap,int x,int y,int length,const UINT32 *src,const pen_t *pens,int transparent_pen,int pri);
-void extract_scanline8(bitmap_t *bitmap,int x,int y,int length,UINT8 *dst);
-void extract_scanline16(bitmap_t *bitmap,int x,int y,int length,UINT16 *dst);
-void extract_scanline32(bitmap_t *bitmap,int x,int y,int length,UINT32 *dst);
+/* ----- scanline copying ----- */
-void copybitmap(bitmap_t *dest,bitmap_t *src,int flipx,int flipy,
- int sx,int sy,const rectangle *clip);
+/* copy pixels from an 8bpp buffer to a single scanline of a bitmap */
+void draw_scanline8(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT8 *srcptr, const pen_t *paldata);
-void copybitmap_trans(bitmap_t *dest,bitmap_t *src,int flipx,int flipy,
- int sx,int sy,const rectangle *clip,pen_t transparent_pen);
+/* copy pixels from a 16bpp buffer to a single scanline of a bitmap */
+void draw_scanline16(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT16 *srcptr, const pen_t *paldata);
-void copyscrollbitmap(bitmap_t *dest,bitmap_t *src,
- int rows,const int *rowscroll,int cols,const int *colscroll,
- const rectangle *clip);
+/* copy pixels from a 32bpp buffer to a single scanline of a bitmap */
+void draw_scanline32(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, const pen_t *paldata);
-void copyscrollbitmap_trans(bitmap_t *dest,bitmap_t *src,
- int rows,const int *rowscroll,int cols,const int *colscroll,
- const rectangle *clip,pen_t transparent_pen);
+/* ----- scanline extraction ----- */
+
+/* copy pixels from a single scanline of a bitmap to an 8bpp buffer */
+void extract_scanline8(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT8 *destptr);
+
+/* copy pixels from a single scanline of a bitmap to a 16bpp buffer */
+void extract_scanline16(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT16 *destptr);
+
+/* copy pixels from a single scanline of a bitmap to a 32bpp buffer */
+void extract_scanline32(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT32 *destptr);
+
+
+
+/* ----- bitmap copying ----- */
+
+/* copy from one bitmap to another, copying all unclipped pixels */
+void copybitmap(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect);
+
+/* copy from one bitmap to another, copying all unclipped pixels except those that match transpen */
+void copybitmap_trans(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, UINT32 transpen);
+
+/*
+ Copy a bitmap onto another with scroll and wraparound.
+ These functions support multiple independently scrolling rows/columns.
+ "rows" is the number of indepentently scrolling rows. "rowscroll" is an
+ array of integers telling how much to scroll each row. Same thing for
+ "numcols" and "colscroll".
+ If the bitmap cannot scroll in one direction, set numrows or columns to 0.
+ If the bitmap scrolls as a whole, set numrows and/or numcols to 1.
+ Bidirectional scrolling is, of course, supported only if the bitmap
+ scrolls as a whole in at least one direction.
+*/
+
+/* copy from one bitmap to another, copying all unclipped pixels, and applying scrolling to one or more rows/colums */
+void copyscrollbitmap(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect);
+
+/* copy from one bitmap to another, copying all unclipped pixels except those that match transpen, and applying scrolling to one or more rows/colums */
+void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect, UINT32 transpen);
+
/*
- Copy a bitmap applying rotation, zooming, and arbitrary distortion.
- This function works in a way that mimics some real hardware like the Konami
- 051316, so it requires little or no further processing on the caller side.
-
- Two 16.16 fixed point counters are used to keep track of the position on
- the source bitmap. startx and starty are the initial values of those counters,
- indicating the source pixel that will be drawn at coordinates (0,0) in the
- destination bitmap. The destination bitmap is scanned left to right, top to
- bottom; every time the cursor moves one pixel to the right, incxx is added
- to startx and incxy is added to starty. Every time the cursor moves to the
- next line, incyx is added to startx and incyy is added to startyy.
-
- What this means is that if incxy and incyx are both 0, the bitmap will be
- copied with only zoom and no rotation. If e.g. incxx and incyy are both 0x8000,
- the source bitmap will be doubled.
-
- Rotation is performed this way:
- incxx = 0x10000 * cos(theta)
- incxy = 0x10000 * -sin(theta)
- incyx = 0x10000 * sin(theta)
- incyy = 0x10000 * cos(theta)
- this will perform a rotation around (0,0), you'll have to adjust startx and
- starty to move the center of rotation elsewhere.
-
- Optionally the bitmap can be tiled across the screen instead of doing a single
- copy. This is obtained by setting the wraparound parameter to true.
- */
-void copyrozbitmap(bitmap_t *dest,bitmap_t *src,
- UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound,
- const rectangle *clip,int transparency,int transparent_color,UINT32 priority);
+ Copy a bitmap applying rotation, zooming, and arbitrary distortion.
+ This function works in a way that mimics some real hardware like the Konami
+ 051316, so it requires little or no further processing on the caller side.
+
+ Two 16.16 fixed point counters are used to keep track of the position on
+ the source bitmap. startx and starty are the initial values of those counters,
+ indicating the source pixel that will be drawn at coordinates (0,0) in the
+ destination bitmap. The destination bitmap is scanned left to right, top to
+ bottom; every time the cursor moves one pixel to the right, incxx is added
+ to startx and incxy is added to starty. Every time the cursor moves to the
+ next line, incyx is added to startx and incyy is added to startyy.
+
+ What this means is that if incxy and incyx are both 0, the bitmap will be
+ copied with only zoom and no rotation. If e.g. incxx and incyy are both 0x8000,
+ the source bitmap will be doubled.
+
+ Rotation is performed this way:
+ incxx = 0x10000 * cos(theta)
+ incxy = 0x10000 * -sin(theta)
+ incyx = 0x10000 * sin(theta)
+ incyy = 0x10000 * cos(theta)
+ this will perform a rotation around (0,0), you'll have to adjust startx and
+ starty to move the center of rotation elsewhere.
+
+ Optionally the bitmap can be tiled across the screen instead of doing a single
+ copy. This is obtained by setting the wraparound parameter to true.
+*/
+
+/* copy from one bitmap to another, with zoom and rotation, copying all unclipped pixels */
+void copyrozbitmap(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound);
+
+/* copy from one bitmap to another, with zoom and rotation, copying all unclipped pixels whose values do not match transpen */
+void copyrozbitmap_trans(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound, UINT32 transparent_color);
@@ -283,34 +333,72 @@ void copyrozbitmap(bitmap_t *dest,bitmap_t *src,
INLINE FUNCTIONS
***************************************************************************/
-/* Alpha blending functions */
-INLINE void alpha_set_level(int level)
+/*-------------------------------------------------
+ gfx_element_set_source - set a pointer to
+ the source of a gfx_element
+-------------------------------------------------*/
+
+INLINE void gfx_element_set_source(gfx_element *gfx, const UINT8 *source)
{
- extern struct _alpha_cache drawgfx_alpha_cache;
- assert(level >= 0 && level <= 256);
- drawgfx_alpha_cache.alphas = level;
- drawgfx_alpha_cache.alphad = 256 - level;
+ gfx->srcdata = source;
+ memset(gfx->dirty, 1, gfx->total_elements);
}
-INLINE UINT32 alpha_blend16(UINT32 d, UINT32 s)
+/*-------------------------------------------------
+ gfx_element_get_data - return a pointer to
+ the base of the given code within a
+ gfx_element, decoding it if it is dirty
+-------------------------------------------------*/
+
+INLINE const UINT8 *gfx_element_get_data(const gfx_element *gfx, UINT32 code)
{
- extern struct _alpha_cache drawgfx_alpha_cache;
- return ((((s & 0x001f) * drawgfx_alpha_cache.alphas + (d & 0x001f) * drawgfx_alpha_cache.alphad) >> 8)) |
- ((((s & 0x03e0) * drawgfx_alpha_cache.alphas + (d & 0x03e0) * drawgfx_alpha_cache.alphad) >> 8) & 0x03e0) |
- ((((s & 0x7c00) * drawgfx_alpha_cache.alphas + (d & 0x7c00) * drawgfx_alpha_cache.alphad) >> 8) & 0x7c00);
+ assert(code < gfx->total_elements);
+ if (gfx->dirty[code])
+ gfx_element_decode(gfx, code);
+ return gfx->gfxdata + code * gfx->char_modulo + gfx->starty * gfx->line_modulo + gfx->startx;
}
-INLINE UINT32 alpha_blend32(UINT32 d, UINT32 s)
+/*-------------------------------------------------
+ gfx_element_mark_dirty - mark a code of a
+ gfx_element dirty
+-------------------------------------------------*/
+
+INLINE void gfx_element_mark_dirty(gfx_element *gfx, UINT32 code)
{
- extern struct _alpha_cache drawgfx_alpha_cache;
- return ((((s & 0x0000ff) * drawgfx_alpha_cache.alphas + (d & 0x0000ff) * drawgfx_alpha_cache.alphad) >> 8)) |
- ((((s & 0x00ff00) * drawgfx_alpha_cache.alphas + (d & 0x00ff00) * drawgfx_alpha_cache.alphad) >> 8) & 0x00ff00) |
- ((((s & 0xff0000) * drawgfx_alpha_cache.alphas + (d & 0xff0000) * drawgfx_alpha_cache.alphad) >> 8) & 0xff0000);
+ if (code < gfx->total_elements)
+ {
+ gfx->dirty[code] = 1;
+ gfx->dirtyseq++;
+ }
}
+/*-------------------------------------------------
+ gfx_element_set_source_clip - set a source
+ clipping area to apply to subsequent renders
+-------------------------------------------------*/
+
+INLINE void gfx_element_set_source_clip(gfx_element *gfx, UINT32 xoffs, UINT32 width, UINT32 yoffs, UINT32 height)
+{
+ assert(xoffs < gfx->origwidth);
+ assert(yoffs < gfx->origheight);
+ assert(xoffs + width <= gfx->origwidth);
+ assert(yoffs + height <= gfx->origheight);
+
+ gfx->width = width;
+ gfx->height = height;
+ gfx->startx = xoffs;
+ gfx->starty = yoffs;
+}
+
+
+/*-------------------------------------------------
+ alpha_blend_r16 - alpha blend two 16-bit
+ 5-5-5 RGB pixels
+-------------------------------------------------*/
+
INLINE UINT32 alpha_blend_r16(UINT32 d, UINT32 s, UINT8 level)
{
int alphad = 256 - level;
@@ -320,7 +408,12 @@ INLINE UINT32 alpha_blend_r16(UINT32 d, UINT32 s, UINT8 level)
}
-INLINE UINT32 alpha_blend_r32( UINT32 d, UINT32 s, UINT8 level )
+/*-------------------------------------------------
+ alpha_blend_r32 - alpha blend two 32-bit
+ 8-8-8 RGB pixels
+-------------------------------------------------*/
+
+INLINE UINT32 alpha_blend_r32(UINT32 d, UINT32 s, UINT8 level)
{
int alphad = 256 - level;
return ((((s & 0x0000ff) * level + (d & 0x0000ff) * alphad) >> 8)) |
diff --git a/src/emu/drawgfxm.h b/src/emu/drawgfxm.h
new file mode 100644
index 00000000000..8204ad28535
--- /dev/null
+++ b/src/emu/drawgfxm.h
@@ -0,0 +1,1395 @@
+/*********************************************************************
+
+ drawgfxm.h
+
+ Macros implementing drawgfx core operations. Drivers can use
+ these if they need custom behavior not provided by the existing
+ drawgfx functions.
+
+ Copyright Nicola Salmoria and the MAME Team.
+ Visit http://mamedev.org for licensing and usage restrictions.
+
+**********************************************************************
+
+ How to use these macros:
+
+ There are two sets of macros. The PIXEL_OP* macros are simple
+ per-pixel operations, designed to take a SOURCE pixel and
+ copy it to the DEST, perhaps updating the PRIORITY pixel as
+ well. On their own, they are not particularly useful.
+
+ The second set of macros represents the core gfx/bitmap walking
+ and rendering code. These macros generally take the target pixel
+ type (UINT8, UINT16, UINT32), one of the PIXEL_OP* macros,
+ and a priority bitmap pixel type (UINT8, UINT16, UINT32, or the
+ special type NO_PRIORITY).
+
+ Although the code may look inefficient at first, the compiler is
+ able to easily optimize out unused cases due to the way the
+ macros are written, leaving behind just the cases we are
+ interested in.
+
+ The general approach for using these macros is:
+
+ my_drawing_function(params)
+ {
+ // ensure that all the required parameters for the mega
+ // macro are defined (if they are not needed, just declare
+ // the variables and set them equal to a known constant
+ // value to help the compiler)
+
+ // set up any additional variables needed by the PIXEL_OP*
+ // macro you want to use (each macro has its own
+ // requirements)
+
+ MEGA_MACRO(BITMAP_TYPE, PIXEL_OP, PRIORITY_TYPE);
+ }
+
+*********************************************************************/
+
+#pragma once
+
+#ifndef __DRAWGFXM_H__
+#define __DRAWGFXM_H__
+
+#include "profiler.h"
+
+
+/* special priority type meaning "none" */
+typedef struct { char dummy[3]; } NO_PRIORITY;
+
+
+/* macros for using the optional priority */
+#define PRIORITY_VALID(x) (sizeof(x) != sizeof(NO_PRIORITY))
+#define PRIORITY_ADDR(p,t,y,x) (PRIORITY_VALID(t) ? BITMAP_ADDR(p, t, y, x) : NULL)
+#define PRIORITY_ADVANCE(t,p,i) do { if (PRIORITY_VALID(t)) (p) += (i); } while (0)
+
+
+/***************************************************************************
+ PIXEL OPERATIONS
+***************************************************************************/
+
+/*-------------------------------------------------
+ PIXEL_OP_COPY_OPAQUE - render all pixels
+ regardless of pen, copying directly
+-------------------------------------------------*/
+
+#define PIXEL_OP_COPY_OPAQUE(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ (DEST) = SOURCE; \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_COPY_TRANSPEN - render all pixels
+ except those matching 'transpen', copying
+ directly
+-------------------------------------------------*/
+
+#define PIXEL_OP_COPY_TRANSPEN(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ (DEST) = SOURCE; \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_REMAP_OPAQUE - render all pixels
+ regardless of pen, mapping the pen via the
+ 'paldata' array
+-------------------------------------------------*/
+
+#define PIXEL_OP_REMAP_OPAQUE(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ (DEST) = paldata[SOURCE]; \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_OPAQUE_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \
+ (DEST) = paldata[SOURCE]; \
+ (PRIORITY) = 31; \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_REMAP_TRANSPEN - render all pixels
+ except those matching 'transpen', mapping the
+ pen via the 'paldata' array
+-------------------------------------------------*/
+
+#define PIXEL_OP_REMAP_TRANSPEN(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ (DEST) = paldata[srcdata]; \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSPEN_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ { \
+ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \
+ (DEST) = paldata[srcdata]; \
+ (PRIORITY) = 31; \
+ } \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_REBASE_TRANSPEN - render all pixels
+ except those matching 'transpen', adding
+ 'color' to the pen value
+-------------------------------------------------*/
+
+#define PIXEL_OP_REBASE_TRANSPEN(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ (DEST) = color + srcdata; \
+} \
+while (0) \
+
+#define PIXEL_OP_REBASE_TRANSPEN_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ { \
+ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \
+ (DEST) = color + srcdata; \
+ (PRIORITY) = 31; \
+ } \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_REMAP_TRANSMASK - render all pixels
+ except those matching 'transmask', mapping the
+ pen via the 'paldata' array
+-------------------------------------------------*/
+
+#define PIXEL_OP_REMAP_TRANSMASK(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (((transmask >> srcdata) & 1) == 0) \
+ (DEST) = paldata[srcdata]; \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSMASK_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (((transmask >> srcdata) & 1) == 0) \
+ { \
+ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \
+ (DEST) = paldata[srcdata]; \
+ (PRIORITY) = 31; \
+ } \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_REMAP_TRANSTABLE - look up each pen in
+ 'pentable'; if the entry is DRAWMODE_NONE,
+ don't draw it; if the entry is DRAWMODE_SOURCE,
+ look up the pen via the 'paldata' array; if the
+ entry is DRAWMODE_SHADOW, generate a shadow of
+ the destination pixel using 'shadowtable'
+-------------------------------------------------*/
+
+#define PIXEL_OP_REMAP_TRANSTABLE16(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ UINT32 entry = pentable[srcdata]; \
+ if (entry != DRAWMODE_NONE) \
+ { \
+ if (entry == DRAWMODE_SOURCE) \
+ (DEST) = paldata[srcdata]; \
+ else \
+ (DEST) = shadowtable[DEST]; \
+ } \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSTABLE32(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ UINT32 entry = pentable[srcdata]; \
+ if (entry != DRAWMODE_NONE) \
+ { \
+ if (entry == DRAWMODE_SOURCE) \
+ (DEST) = paldata[srcdata]; \
+ else \
+ (DEST) = shadowtable[rgb_to_rgb15(DEST)]; \
+ } \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSTABLE16_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ UINT32 entry = pentable[srcdata]; \
+ if (entry != DRAWMODE_NONE) \
+ { \
+ UINT8 pridata = (PRIORITY); \
+ if (((1 << (pridata & 0x1f)) & pmask) == 0) \
+ { \
+ if (entry == DRAWMODE_SOURCE) \
+ { \
+ (DEST) = paldata[srcdata]; \
+ (PRIORITY) = 31; \
+ } \
+ else if ((pridata & 0x80) == 0) \
+ { \
+ (DEST) = shadowtable[DEST]; \
+ (PRIORITY) = pridata | 0x80; \
+ } \
+ } \
+ } \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ UINT32 entry = pentable[srcdata]; \
+ if (entry != DRAWMODE_NONE) \
+ { \
+ UINT8 pridata = (PRIORITY); \
+ if (((1 << (pridata & 0x1f)) & pmask) == 0) \
+ { \
+ if (entry == DRAWMODE_SOURCE) \
+ { \
+ (DEST) = paldata[srcdata]; \
+ (PRIORITY) = 31; \
+ } \
+ else if ((pridata & 0x80) == 0) \
+ { \
+ (DEST) = shadowtable[rgb_to_rgb15(DEST)]; \
+ (PRIORITY) = pridata | 0x80; \
+ } \
+ } \
+ } \
+} \
+while (0) \
+
+
+/*-------------------------------------------------
+ PIXEL_OP_REMAP_TRANSPEN_ALPHA - render all
+ pixels except those matching 'transpen',
+ mapping the pen to via the 'paldata' array;
+ the resulting color is RGB alpha blended
+ against the destination using 'alpha'
+-------------------------------------------------*/
+
+#define PIXEL_OP_REMAP_TRANSPEN_ALPHA16(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ (DEST) = alpha_blend_r16((DEST), paldata[srcdata], alpha); \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSPEN_ALPHA32(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alpha); \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSPEN_ALPHA16_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ { \
+ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \
+ (DEST) = alpha_blend_r16((DEST), paldata[srcdata], alpha); \
+ (PRIORITY) = 31; \
+ } \
+} \
+while (0) \
+
+#define PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != transpen) \
+ { \
+ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \
+ (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alpha); \
+ (PRIORITY) = 31; \
+ } \
+} \
+while (0) \
+
+
+
+/***************************************************************************
+ BASIC DRAWGFX CORE
+***************************************************************************/
+
+/*
+ Assumed input parameters or local variables:
+
+ bitmap_t *dest - the bitmap to render to
+ const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
+ const gfx_element *gfx - pointer to the gfx_element to render
+ UINT32 code - index of the entry within gfx_element
+ UINT32 color - index of the color within gfx_element
+ int flipx - non-zero means render right-to-left instead of left-to-right
+ int flipy - non-zero means render bottom-to-top instead of top-to-bottom
+ INT32 destx - the top-left X coordinate to render to
+ INT32 desty - the top-left Y coordinate to render to
+ bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
+*/
+
+
+#define DRAWGFX_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
+do { \
+ profiler_mark(PROFILER_DRAWGFX); \
+ do { \
+ const UINT8 *srcdata; \
+ INT32 destendx, destendy; \
+ INT32 srcx, srcy; \
+ INT32 curx, cury; \
+ INT32 dy; \
+ \
+ assert(dest != NULL); \
+ assert(gfx != NULL); \
+ assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL); \
+ assert(cliprect == NULL || cliprect->min_x >= 0); \
+ assert(cliprect == NULL || cliprect->max_x < dest->width); \
+ assert(cliprect == NULL || cliprect->min_y >= 0); \
+ assert(cliprect == NULL || cliprect->max_y < dest->height); \
+ \
+ /* NULL clip means use the full bitmap */ \
+ if (cliprect == NULL) \
+ cliprect = &dest->cliprect; \
+ \
+ /* ignore empty/invalid cliprects */ \
+ if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y) \
+ break; \
+ \
+ /* compute final pixel in X and exit if we are entirely clipped */ \
+ destendx = destx + gfx->width - 1; \
+ if (destx > cliprect->max_x || destendx < cliprect->min_x) \
+ break; \
+ \
+ /* apply left clip */ \
+ srcx = 0; \
+ if (destx < cliprect->min_x) \
+ { \
+ srcx = cliprect->min_x - destx; \
+ destx = cliprect->min_x; \
+ } \
+ \
+ /* apply right clip */ \
+ if (destendx > cliprect->max_x) \
+ destendx = cliprect->max_x; \
+ \
+ /* compute final pixel in Y and exit if we are entirely clipped */ \
+ destendy = desty + gfx->height - 1; \
+ if (desty > cliprect->max_y || destendy < cliprect->min_y) \
+ break; \
+ \
+ /* apply top clip */ \
+ srcy = 0; \
+ if (desty < cliprect->min_y) \
+ { \
+ srcy = cliprect->min_y - desty; \
+ desty = cliprect->min_y; \
+ } \
+ \
+ /* apply bottom clip */ \
+ if (destendy > cliprect->max_y) \
+ destendy = cliprect->max_y; \
+ \
+ /* apply X flipping */ \
+ if (flipx) \
+ srcx = gfx->width - 1 - srcx; \
+ \
+ /* apply Y flipping */ \
+ dy = gfx->line_modulo; \
+ if (flipy) \
+ { \
+ srcy = gfx->height - 1 - srcy; \
+ dy = -dy; \
+ } \
+ \
+ /* fetch the source data */ \
+ srcdata = gfx_element_get_data(gfx, code); \
+ \
+ /* draw normal 8bpp source data */ \
+ if (!(gfx->flags & GFX_ELEMENT_PACKED)) \
+ { \
+ /* compute how many blocks of 4 pixels we have */ \
+ UINT32 numblocks = (destendx + 1 - destx) / 4; \
+ UINT32 leftovers = (destendx + 1 - destx) - 4 * numblocks; \
+ \
+ /* adjust srcdata to point to the first source pixel of the row */ \
+ srcdata += srcy * gfx->line_modulo + srcx; \
+ \
+ /* non-flipped 8bpp case */ \
+ if (!flipx) \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const UINT8 *srcptr = srcdata; \
+ srcdata += dy; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[1]); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[2]); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[3]); \
+ \
+ srcptr += 4; \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcptr++; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ \
+ /* flipped 8bpp case */ \
+ else \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const UINT8 *srcptr = srcdata; \
+ srcdata += dy; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[ 0]); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[-1]); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[-2]); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[-3]); \
+ \
+ srcptr -= 4; \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcptr--; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ } \
+ \
+ /* draw packed 4bpp source data */ \
+ else \
+ { \
+ /* adjust srcdata to point to the first source pixel of the row */ \
+ srcdata += srcy * gfx->line_modulo + srcx / 2; \
+ \
+ /* non-flipped 4bpp case */ \
+ if (!flipx) \
+ { \
+ /* compute how many blocks of 2 pixels we have */ \
+ UINT32 oddstart = srcx & 1; \
+ UINT32 numblocks = (destendx + 1 - destx - oddstart) / 2; \
+ UINT32 leftovers = (destendx + 1 - destx - oddstart) - 2 * numblocks; \
+ \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const UINT8 *srcptr = srcdata; \
+ srcdata += dy; \
+ \
+ /* odd starting pixel */ \
+ if (oddstart) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0] >> 4); \
+ srcptr++; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ \
+ /* iterate over unrolled blocks of 2 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ UINT8 srcbyte = *srcptr++; \
+ PIXEL_OP(destptr[0], priptr[0], srcbyte & 15); \
+ PIXEL_OP(destptr[1], priptr[1], srcbyte >> 4); \
+ destptr += 2; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 2); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ if (leftovers > 0) \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0] & 15); \
+ } \
+ } \
+ \
+ /* flipped 4bpp case */ \
+ else \
+ { \
+ /* compute how many blocks of 2 pixels we have */ \
+ UINT32 oddstart = ~srcx & 1; \
+ UINT32 numblocks = (destendx + 1 - destx - oddstart) / 2; \
+ UINT32 leftovers = (destendx + 1 - destx - oddstart) - 2 * numblocks; \
+ \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const UINT8 *srcptr = srcdata; \
+ srcdata += dy; \
+ \
+ /* odd right pixel */ \
+ if (oddstart) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0] & 15); \
+ srcptr--; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ \
+ /* middle pixels */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ UINT8 srcbyte = *srcptr--; \
+ PIXEL_OP(destptr[0], priptr[0], srcbyte >> 4); \
+ PIXEL_OP(destptr[1], priptr[1], srcbyte & 15); \
+ destptr += 2; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 2); \
+ } \
+ \
+ /* odd left pixel */ \
+ if (leftovers > 0) \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0] >> 4); \
+ } \
+ } \
+ } \
+ } while (0); \
+ profiler_mark(PROFILER_END); \
+} while (0)
+
+
+
+/***************************************************************************
+ BASIC DRAWGFXZOOM CORE
+***************************************************************************/
+
+/*
+ Assumed input parameters or local variables:
+
+ bitmap_t *dest - the bitmap to render to
+ const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
+ const gfx_element *gfx - pointer to the gfx_element to render
+ UINT32 code - index of the entry within gfx_element
+ UINT32 color - index of the color within gfx_element
+ int flipx - non-zero means render right-to-left instead of left-to-right
+ int flipy - non-zero means render bottom-to-top instead of top-to-bottom
+ INT32 destx - the top-left X coordinate to render to
+ INT32 desty - the top-left Y coordinate to render to
+ UINT32 scalex - the 16.16 scale factor in the X dimension
+ UINT32 scaley - the 16.16 scale factor in the Y dimension
+ bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
+*/
+
+
+#define DRAWGFXZOOM_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
+do { \
+ profiler_mark(PROFILER_DRAWGFX); \
+ do { \
+ const UINT8 *srcdata; \
+ UINT32 dstwidth, dstheight; \
+ INT32 destendx, destendy; \
+ INT32 srcx, srcy; \
+ INT32 curx, cury; \
+ INT32 dx, dy; \
+ \
+ assert(dest != NULL); \
+ assert(gfx != NULL); \
+ assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL); \
+ assert(cliprect == NULL || cliprect->min_x >= 0); \
+ assert(cliprect == NULL || cliprect->max_x < dest->width); \
+ assert(cliprect == NULL || cliprect->min_y >= 0); \
+ assert(cliprect == NULL || cliprect->max_y < dest->height); \
+ \
+ /* NULL clip means use the full bitmap */ \
+ if (cliprect == NULL) \
+ cliprect = &dest->cliprect; \
+ \
+ /* ignore empty/invalid cliprects */ \
+ if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y) \
+ break; \
+ \
+ /* compute scaled size */ \
+ dstwidth = (scalex * gfx->width + 0x8000) >> 16; \
+ dstheight = (scaley * gfx->height + 0x8000) >> 16; \
+ if (dstwidth < 1 || dstheight < 1) \
+ break; \
+ \
+ /* compute 16.16 source steps in dx and dy */ \
+ dx = (gfx->width << 16) / dstwidth; \
+ dy = (gfx->height << 16) / dstheight; \
+ \
+ /* compute final pixel in X and exit if we are entirely clipped */ \
+ destendx = destx + dstwidth - 1; \
+ if (destx > cliprect->max_x || destendx < cliprect->min_x) \
+ break; \
+ \
+ /* apply left clip */ \
+ srcx = 0; \
+ if (destx < cliprect->min_x) \
+ { \
+ srcx = (cliprect->min_x - destx) * dx; \
+ destx = cliprect->min_x; \
+ } \
+ \
+ /* apply right clip */ \
+ if (destendx > cliprect->max_x) \
+ destendx = cliprect->max_x; \
+ \
+ /* compute final pixel in Y and exit if we are entirely clipped */ \
+ destendy = desty + dstheight - 1; \
+ if (desty > cliprect->max_y || destendy < cliprect->min_y) \
+ return; \
+ \
+ /* apply top clip */ \
+ srcy = 0; \
+ if (desty < cliprect->min_y) \
+ { \
+ srcy = (cliprect->min_y - desty) * dy; \
+ desty = cliprect->min_y; \
+ } \
+ \
+ /* apply bottom clip */ \
+ if (destendy > cliprect->max_y) \
+ destendy = cliprect->max_y; \
+ \
+ /* apply X flipping */ \
+ if (flipx) \
+ { \
+ srcx = (dstwidth - 1) * dx - srcx; \
+ dx = -dx; \
+ } \
+ \
+ /* apply Y flipping */ \
+ if (flipy) \
+ { \
+ srcy = (dstheight - 1) * dy - srcy; \
+ dy = -dy; \
+ } \
+ \
+ /* fetch the source data */ \
+ srcdata = gfx_element_get_data(gfx, code); \
+ \
+ /* draw normal */ \
+ if (!(gfx->flags & GFX_ELEMENT_PACKED)) \
+ { \
+ /* compute how many blocks of 4 pixels we have */ \
+ UINT32 numblocks = (destendx + 1 - destx) / 4; \
+ UINT32 leftovers = (destendx + 1 - destx) - 4 * numblocks; \
+ \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const UINT8 *srcptr = srcdata + (srcy >> 16) * gfx->line_modulo; \
+ INT32 cursrcx = srcx; \
+ srcy += dy; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[cursrcx >> 16]); \
+ cursrcx += dx; \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[cursrcx >> 16]); \
+ cursrcx += dx; \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[cursrcx >> 16]); \
+ cursrcx += dx; \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[cursrcx >> 16]); \
+ cursrcx += dx; \
+ \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[cursrcx >> 16]); \
+ cursrcx += dx; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ \
+ /* draw packed */ \
+ else \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const UINT8 *srcptr = srcdata + (srcy >> 16) * gfx->line_modulo; \
+ INT32 cursrcx = srcx; \
+ srcy += dy; \
+ \
+ /* iterate over pixels in X */ \
+ for (curx = destx; curx <= destendx; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], (srcptr[cursrcx >> 17] >> ((cursrcx >> 14) & 4)) & 15); \
+ cursrcx += dx; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ } while (0); \
+ profiler_mark(PROFILER_END); \
+} while (0)
+
+
+
+/***************************************************************************
+ BASIC COPYBITMAP CORE
+***************************************************************************/
+
+/*
+ Assumed input parameters or local variables:
+
+ bitmap_t *dest - the bitmap to copy to
+ bitmap_t *src - the bitmap to copy from (must be same bpp as dest)
+ const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
+ int flipx - non-zero means render right-to-left instead of left-to-right
+ int flipy - non-zero means render bottom-to-top instead of top-to-bottom
+ INT32 destx - the top-left X coordinate to copy to
+ INT32 desty - the top-left Y coordinate to copy to
+ bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
+*/
+
+#define COPYBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
+do { \
+ profiler_mark(PROFILER_COPYBITMAP); \
+ do { \
+ const PIXEL_TYPE *srcdata; \
+ UINT32 numblocks, leftovers; \
+ INT32 destendx, destendy; \
+ INT32 srcx, srcy; \
+ INT32 curx, cury; \
+ INT32 dx, dy; \
+ \
+ assert(dest != NULL); \
+ assert(src != NULL); \
+ assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL); \
+ assert(cliprect == NULL || cliprect->min_x >= 0); \
+ assert(cliprect == NULL || cliprect->max_x < dest->width); \
+ assert(cliprect == NULL || cliprect->min_y >= 0); \
+ assert(cliprect == NULL || cliprect->max_y < dest->height); \
+ \
+ /* NULL clip means use the full bitmap */ \
+ if (cliprect == NULL) \
+ cliprect = &dest->cliprect; \
+ \
+ /* ignore empty/invalid cliprects */ \
+ if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y) \
+ break; \
+ \
+ /* standard setup; dx counts bytes in X, dy counts pixels in Y */ \
+ dx = 1; \
+ dy = src->rowpixels; \
+ \
+ /* compute final pixel in X and exit if we are entirely clipped */ \
+ destendx = destx + src->width - 1; \
+ if (destx > cliprect->max_x || destendx < cliprect->min_x) \
+ break; \
+ \
+ /* apply left clip */ \
+ srcx = 0; \
+ if (destx < cliprect->min_x) \
+ { \
+ srcx = cliprect->min_x - destx; \
+ destx = cliprect->min_x; \
+ } \
+ \
+ /* apply right clip */ \
+ if (destendx > cliprect->max_x) \
+ destendx = cliprect->max_x; \
+ \
+ /* compute final pixel in Y and exit if we are entirely clipped */ \
+ destendy = desty + src->height - 1; \
+ if (desty > cliprect->max_y || destendy < cliprect->min_y) \
+ break; \
+ \
+ /* apply top clip */ \
+ srcy = 0; \
+ if (desty < cliprect->min_y) \
+ { \
+ srcy = cliprect->min_y - desty; \
+ desty = cliprect->min_y; \
+ } \
+ \
+ /* apply bottom clip */ \
+ if (destendy > cliprect->max_y) \
+ destendy = cliprect->max_y; \
+ \
+ /* apply X flipping */ \
+ if (flipx) \
+ { \
+ srcx = src->width - 1 - srcx; \
+ dx = -dx; \
+ } \
+ \
+ /* apply Y flipping */ \
+ if (flipy) \
+ { \
+ srcy = src->height - 1 - srcy; \
+ dy = -dy; \
+ } \
+ \
+ /* compute how many blocks of 4 pixels we have */ \
+ numblocks = (destendx + 1 - destx) / 4; \
+ leftovers = (destendx + 1 - destx) - 4 * numblocks; \
+ \
+ /* compute the address of the first source pixel of the first row */ \
+ srcdata = BITMAP_ADDR(src, PIXEL_TYPE, srcy, srcx); \
+ \
+ /* non-flipped case */ \
+ if (!flipx) \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const PIXEL_TYPE *srcptr = srcdata; \
+ srcdata += dy; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[1]); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[2]); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[3]); \
+ \
+ srcptr += 4; \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcptr++; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ \
+ /* flipped case */ \
+ else \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = desty; cury <= destendy; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx); \
+ const PIXEL_TYPE *srcptr = srcdata; \
+ srcdata += dy; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[ 0]); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[-1]); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[-2]); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[-3]); \
+ \
+ srcptr -= 4; \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcptr--; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ } while (0); \
+ profiler_mark(PROFILER_END); \
+} while (0)
+
+
+
+/***************************************************************************
+ BASIC COPYROZBITMAP CORE
+***************************************************************************/
+
+/*
+ Assumed input parameters or local variables:
+
+ bitmap_t *dest - the bitmap to copy to
+ bitmap_t *src - the bitmap to copy from (must be same bpp as dest)
+ const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
+ INT32 destx - the 16.16 source X position at destination pixel (0,0)
+ INT32 desty - the 16.16 source Y position at destination pixel (0,0)
+ INT32 incxx - the 16.16 amount to increment in source X for each destination X pixel
+ INT32 incyx - the 16.16 amount to increment in source Y for each destination X pixel
+ INT32 incxy - the 16.16 amount to increment in source X for each destination Y pixel
+ INT32 incyy - the 16.16 amount to increment in source Y for each destination Y pixel
+ int wraparound - non-zero means wrap when hitting the edges of the source
+ bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
+*/
+
+#define COPYROZBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
+do { \
+ UINT32 srcfixwidth, srcfixheight; \
+ UINT32 numblocks, leftovers; \
+ INT32 curx, cury; \
+ \
+ profiler_mark(PROFILER_COPYBITMAP); \
+ \
+ assert(dest != NULL); \
+ assert(src != NULL); \
+ assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL); \
+ assert(cliprect == NULL || cliprect->min_x >= 0); \
+ assert(cliprect == NULL || cliprect->max_x < dest->width); \
+ assert(cliprect == NULL || cliprect->min_y >= 0); \
+ assert(cliprect == NULL || cliprect->max_y < dest->height); \
+ assert(!wraparound || (src->width & (src->width - 1)) == 0); \
+ assert(!wraparound || (src->height & (src->height - 1)) == 0); \
+ \
+ /* NULL clip means use the full bitmap */ \
+ if (cliprect == NULL) \
+ cliprect = &dest->cliprect; \
+ \
+ /* ignore empty/invalid cliprects */ \
+ if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y) \
+ break; \
+ \
+ /* compute fixed-point 16.16 size of the source bitmap */ \
+ srcfixwidth = src->width << 16; \
+ srcfixheight = src->height << 16; \
+ \
+ /* advance the starting coordinates to the top-left of the cliprect */ \
+ startx += cliprect->min_x * incxx + cliprect->min_y * incyx; \
+ starty += cliprect->min_x * incxy + cliprect->min_y * incyy; \
+ \
+ /* compute how many blocks of 4 pixels we have */ \
+ numblocks = (cliprect->max_x + 1 - cliprect->min_x) / 4; \
+ leftovers = (cliprect->max_x + 1 - cliprect->min_x) - 4 * numblocks; \
+ \
+ /* if incxy and incyx are 0, then we aren't rotating, just zooming */ \
+ if (incxy == 0 && incyx == 0) \
+ { \
+ /* zoom-only, non-wraparound case */ \
+ if (!wraparound) \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
+ const PIXEL_TYPE *srcptr; \
+ INT32 srcx = startx; \
+ INT32 srcy = starty; \
+ \
+ starty += incyy; \
+ \
+ /* check srcy for the whole row at once */ \
+ if ((UINT32)srcy < srcfixheight) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, 0); \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ if ((UINT32)srcx < srcfixwidth) \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]); \
+ srcx += incxx; \
+ \
+ if ((UINT32)srcx < srcfixwidth) \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[srcx >> 16]); \
+ srcx += incxx; \
+ \
+ if ((UINT32)srcx < srcfixwidth) \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[srcx >> 16]); \
+ srcx += incxx; \
+ \
+ if ((UINT32)srcx < srcfixwidth) \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[srcx >> 16]); \
+ srcx += incxx; \
+ \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ if ((UINT32)srcx < srcfixwidth) \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]); \
+ srcx += incxx; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ } \
+ \
+ /* zoom-only, wraparound case */ \
+ else \
+ { \
+ /* convert srcfixwidth/height into a mask and apply */ \
+ srcfixwidth--; \
+ srcfixheight--; \
+ startx &= srcfixwidth; \
+ starty &= srcfixheight; \
+ \
+ /* iterate over pixels in Y */ \
+ for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
+ const PIXEL_TYPE *srcptr = BITMAP_ADDR(src, PIXEL_TYPE, starty >> 16, 0); \
+ INT32 srcx = startx; \
+ \
+ starty = (starty + incyy) & srcfixheight; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[srcx >> 16]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[srcx >> 16]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[srcx >> 16]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ } \
+ \
+ /* full rotation case */ \
+ else \
+ { \
+ /* full rotation, non-wraparound case */ \
+ if (!wraparound) \
+ { \
+ /* iterate over pixels in Y */ \
+ for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
+ const PIXEL_TYPE *srcptr; \
+ INT32 srcx = startx; \
+ INT32 srcy = starty; \
+ \
+ startx += incyx; \
+ starty += incyy; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ } \
+ srcx += incxx; \
+ srcy += incxy; \
+ \
+ if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[0]); \
+ } \
+ srcx += incxx; \
+ srcy += incxy; \
+ \
+ if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[0]); \
+ } \
+ srcx += incxx; \
+ srcy += incxy; \
+ \
+ if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[0]); \
+ } \
+ srcx += incxx; \
+ srcy += incxy; \
+ \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ } \
+ srcx += incxx; \
+ srcy += incxy; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ \
+ /* zoom-only, wraparound case */ \
+ else \
+ { \
+ /* convert srcfixwidth/height into a mask and apply */ \
+ srcfixwidth--; \
+ srcfixheight--; \
+ startx &= srcfixwidth; \
+ starty &= srcfixheight; \
+ \
+ /* iterate over pixels in Y */ \
+ for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++) \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
+ const PIXEL_TYPE *srcptr; \
+ INT32 srcx = startx; \
+ INT32 srcy = starty; \
+ \
+ startx = (startx + incyx) & srcfixwidth; \
+ starty = (starty + incyy) & srcfixheight; \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ for (curx = 0; curx < numblocks; curx++) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ srcy = (srcy + incxy) & srcfixheight; \
+ \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[0]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ srcy = (srcy + incxy) & srcfixheight; \
+ \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[0]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ srcy = (srcy + incxy) & srcfixheight; \
+ \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[0]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ srcy = (srcy + incxy) & srcfixheight; \
+ \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ for (curx = 0; curx < leftovers; curx++) \
+ { \
+ srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcx = (srcx + incxx) & srcfixwidth; \
+ srcy = (srcy + incxy) & srcfixheight; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+ } \
+ } \
+ profiler_mark(PROFILER_END); \
+} while (0)
+
+
+
+/***************************************************************************
+ BASIC DRAWSCANLINE CORE
+***************************************************************************/
+
+/*
+ Assumed input parameters or local variables:
+
+ bitmap_t *bitmap - the bitmap to copy to
+ INT32 destx - the X coordinate to copy to
+ INT32 desty - the Y coordinate to copy to
+ INT32 length - the total number of pixels to copy
+ const UINTx *srcptr - pointer to memory containing the source pixels
+ bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
+*/
+
+#define DRAWSCANLINE_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
+do { \
+ assert(bitmap != NULL); \
+ assert(destx >= 0); \
+ assert(destx + length <= bitmap->width); \
+ assert(desty >= 0); \
+ assert(desty < bitmap->height); \
+ assert(srcptr != NULL); \
+ assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL); \
+ \
+ { \
+ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, desty, destx); \
+ PIXEL_TYPE *destptr = BITMAP_ADDR(bitmap, PIXEL_TYPE, desty, destx); \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ while (length >= 4) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ PIXEL_OP(destptr[1], priptr[1], srcptr[1]); \
+ PIXEL_OP(destptr[2], priptr[2], srcptr[2]); \
+ PIXEL_OP(destptr[3], priptr[3], srcptr[3]); \
+ \
+ length -= 4; \
+ srcptr += 4; \
+ destptr += 4; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ while (length-- > 0) \
+ { \
+ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \
+ srcptr++; \
+ destptr++; \
+ PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \
+ } \
+ } \
+} while (0)
+
+
+
+/***************************************************************************
+ BASIC EXTRACTSCANLINE CORE
+***************************************************************************/
+
+/*
+ Assumed input parameters:
+
+ bitmap_t *bitmap - the bitmap to extract from
+ INT32 srcx - the X coordinate to begin extraction
+ INT32 srcy - the Y coordinate to begin extraction
+ INT32 length - the total number of pixels to extract
+ UINTx *destptr - pointer to memory to receive the extracted pixels
+*/
+
+#define EXTRACTSCANLINE_CORE(PIXEL_TYPE) \
+do { \
+ assert(bitmap != NULL); \
+ assert(srcx >= 0); \
+ assert(srcx + length <= bitmap->width); \
+ assert(srcy >= 0); \
+ assert(srcy < bitmap->height); \
+ assert(destptr != NULL); \
+ \
+ { \
+ const PIXEL_TYPE *srcptr = BITMAP_ADDR(bitmap, PIXEL_TYPE, srcy, srcx); \
+ \
+ /* iterate over unrolled blocks of 4 */ \
+ while (length >= 4) \
+ { \
+ destptr[0] = srcptr[0]; \
+ destptr[1] = srcptr[1]; \
+ destptr[2] = srcptr[2]; \
+ destptr[3] = srcptr[3]; \
+ length -= 4; \
+ srcptr += 4; \
+ destptr += 4; \
+ } \
+ \
+ /* iterate over leftover pixels */ \
+ while (length > 0) \
+ { \
+ destptr[0] = srcptr[0]; \
+ length--; \
+ srcptr++; \
+ destptr++; \
+ } \
+ } \
+} while (0)
+
+
+#endif /* __DRAWGFXM_H__ */
diff --git a/src/emu/emupal.h b/src/emu/emupal.h
index 9e00c7c8a2f..de843b4933c 100644
--- a/src/emu/emupal.h
+++ b/src/emu/emupal.h
@@ -74,7 +74,7 @@
1) declare MDRV_VIDEO_ATTRIBUTES( ... VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS ... )
- 2) set gfx_drawmode_table[0-n] to DRAWMODE_NONE, DRAWMODE_SOURCE or DRAWMODE_SHADOW
+ 2) make a pen table fill with DRAWMODE_NONE, DRAWMODE_SOURCE or DRAWMODE_SHADOW
3) (optional) set shadow darkness or highlight brightness by
palette_set_shadow_factor(0.0-1.0) or
@@ -84,8 +84,8 @@
palette_set_shadow_mode(0) to arm shadows or
palette_set_shadow_mode(1) to arm highlights
- 5) call drawgfx with the TRANSPARENCY_PEN_TABLE flag
- drawgfx( ..., cliprect, TRANSPARENCY_PEN_TABLE, transparent_color )
+ 5) call drawgfx_transtable
+ drawgfx_transtable( ..., pentable )
******************************************************************************/
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 86a8969a1d4..18a15de9157 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -32,7 +32,6 @@
- calls output_init() [output.c] to initialize the output system
- calls state_init() [state.c] to initialize save state system
- calls state_save_allow_registration() [state.c] to allow registrations
- - calls drawgfx_init() [drawgfx.c] to initialize rendering globals
- calls palette_init() [palette.c] to initialize palette system
- calls render_init() [render.c] to initialize the rendering system
- calls ui_init() [ui.c] to initialize the user interface
@@ -1478,7 +1477,6 @@ static void init_machine(running_machine *machine)
output_init(machine);
state_init(machine);
state_save_allow_registration(machine, TRUE);
- drawgfx_init(machine);
palette_init(machine);
render_init(machine);
ui_init(machine);
@@ -1559,7 +1557,7 @@ static void init_machine(running_machine *machine)
/* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */
/* but not if the debugger is enabled (so we can look at the data) */
- if (!options_get_bool(mame_options(), OPTION_DEBUG))
+ if (PREDECODE_GFX && !options_get_bool(mame_options(), OPTION_DEBUG))
for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = nextrgntag)
{
nextrgntag = memory_region_next(machine, rgntag);
diff --git a/src/emu/mame.h b/src/emu/mame.h
index 61aaa5ab2fd..fd258527923 100644
--- a/src/emu/mame.h
+++ b/src/emu/mame.h
@@ -27,6 +27,10 @@
#endif /* MESS */
+// temporary: set this to 1 to pre-decode graphics like we used to
+#define PREDECODE_GFX (0)
+
+
/***************************************************************************
CONSTANTS
diff --git a/src/emu/tilemap.c b/src/emu/tilemap.c
index b36938d820f..1762ca9f3d0 100644
--- a/src/emu/tilemap.c
+++ b/src/emu/tilemap.c
@@ -46,8 +46,8 @@ typedef enum
/* internal blitting callbacks */
-typedef void (*blitmask_func)(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-typedef void (*blitopaque_func)(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
+typedef void (*blitmask_func)(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+typedef void (*blitopaque_func)(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
/* blitting parameters for rendering */
@@ -61,6 +61,7 @@ struct _blit_parameters
UINT32 tilemap_priority_code;
UINT8 mask;
UINT8 value;
+ UINT8 alpha;
};
@@ -97,6 +98,8 @@ struct _tilemap
UINT8 all_tiles_clean; /* true if all tiles are clean */
UINT32 palette_offset; /* palette offset */
UINT32 pen_data_offset; /* pen data offset */
+ UINT32 gfx_used; /* bitmask of gfx items used */
+ UINT32 gfx_dirtyseq[MAX_GFX_ELEMENTS]; /* dirtyseq values from last check */
/* scroll information */
UINT32 scrollrows; /* number of independently scrolled rows */
@@ -157,18 +160,18 @@ static void tilemap_draw_roz_core(tilemap *tmap, const blit_parameters *blit,
UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound);
/* scanline rasterizers for drawing to the pixmap */
-static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_opaque_ind16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_masked_ind16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_opaque_rgb16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_masked_rgb16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_opaque_rgb16_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_masked_rgb16_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_opaque_rgb32(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_masked_rgb32(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_opaque_rgb32_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
-static void scanline_draw_masked_rgb32_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
+static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_opaque_ind16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_masked_ind16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_opaque_rgb16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_masked_rgb16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_opaque_rgb16_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_masked_rgb16_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_opaque_rgb32(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_masked_rgb32(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_opaque_rgb32_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
+static void scanline_draw_masked_rgb32_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
@@ -251,6 +254,30 @@ INLINE tilemap *indexed_tilemap(int index)
}
+/*-------------------------------------------------
+ gfx_tiles_changed - return TRUE if any
+ gfx_elements used by this tilemap have
+ changed
+-------------------------------------------------*/
+
+INLINE int gfx_elements_changed(tilemap *tmap)
+{
+ UINT32 usedmask = tmap->gfx_used;
+ int isdirty = FALSE;
+ int gfxnum;
+
+ /* iterate over all used gfx types and set the dirty flag if any of them have changed */
+ for (gfxnum = 0; usedmask != 0; usedmask >>= 1, gfxnum++)
+ if ((usedmask & 1) != 0)
+ if (tmap->gfx_dirtyseq[gfxnum] != tmap->machine->gfx[gfxnum]->dirtyseq)
+ {
+ tmap->gfx_dirtyseq[gfxnum] = tmap->machine->gfx[gfxnum]->dirtyseq;
+ isdirty = TRUE;
+ }
+
+ return isdirty;
+}
+
/***************************************************************************
SYSTEM-WIDE MANAGEMENT
@@ -318,6 +345,7 @@ tilemap *tilemap_create(running_machine *machine, tile_get_info_func tile_get_in
/* set up the default pen mask */
tmap->tileinfo.pen_mask = 0xff;
+ tmap->tileinfo.gfxnum = 0xff;
/* initialize global states */
tmap->enable = TRUE;
@@ -391,21 +419,6 @@ void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset)
/*-------------------------------------------------
- tilemap_set_pen_data_offset - specify an offset
- to be added to pen_data while rendering tiles
--------------------------------------------------*/
-
-void tilemap_set_pen_data_offset(tilemap *tmap, UINT32 offset)
-{
- if (tmap->pen_data_offset != offset)
- {
- tmap->pen_data_offset = offset;
- tilemap_mark_all_tiles_dirty(tmap);
- }
-}
-
-
-/*-------------------------------------------------
tilemap_set_enable - set an enable flag for
the tilemap; if 0, requests to draw the
tilemap are ignored
@@ -776,10 +789,11 @@ profiler_mark(PROFILER_TILEMAP_DRAW);
original_cliprect = blit.cliprect;
/* if the whole map is dirty, mark it as such */
- if (tmap->all_tiles_dirty)
+ if (tmap->all_tiles_dirty || gfx_elements_changed(tmap))
{
memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
tmap->all_tiles_dirty = FALSE;
+ tmap->gfx_used = 0;
}
width = video_screen_get_width(tmap->machine->primary_screen);
@@ -975,10 +989,11 @@ void tilemap_draw_by_index(bitmap_t *dest, int number, UINT32 scrollx, UINT32 sc
scrolly = tmap->height - scrolly % tmap->height;
/* if the whole map is dirty, mark it as such */
- if (tmap->all_tiles_dirty)
+ if (tmap->all_tiles_dirty || gfx_elements_changed(tmap))
{
memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
tmap->all_tiles_dirty = FALSE;
+ tmap->gfx_used = 0;
}
/* iterate to handle wraparound */
@@ -1205,7 +1220,11 @@ static void pixmap_update(tilemap *tmap, const rectangle *cliprect)
{
int mincol, maxcol, minrow, maxrow;
int row, col;
-
+
+ /* if the graphics changed, we need to mark everything dirty */
+ if (gfx_elements_changed(tmap))
+ tilemap_mark_all_tiles_dirty(tmap);
+
/* if everything is clean, do nothing */
if (tmap->all_tiles_clean)
return;
@@ -1232,6 +1251,7 @@ profiler_mark(PROFILER_TILEMAP_DRAW);
{
memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
tmap->all_tiles_dirty = FALSE;
+ tmap->gfx_used = 0;
}
/* iterate over rows */
@@ -1281,6 +1301,13 @@ profiler_mark(PROFILER_TILEMAP_UPDATE);
if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && tmap->tileinfo.mask_data != NULL)
tmap->tileflags[logindex] = tile_apply_bitmask(tmap, tmap->tileinfo.mask_data, x0, y0, tmap->tileinfo.category, flags);
+ /* track which gfx have been used for this tilemap */
+ if (tmap->tileinfo.gfxnum != 0xff && (tmap->gfx_used & (1 << tmap->tileinfo.gfxnum)) == 0)
+ {
+ tmap->gfx_used |= 1 << tmap->tileinfo.gfxnum;
+ tmap->gfx_dirtyseq[tmap->tileinfo.gfxnum] = tmap->machine->gfx[tmap->tileinfo.gfxnum]->dirtyseq;
+ }
+
profiler_mark(PROFILER_END);
}
@@ -1470,8 +1497,9 @@ static void configure_blit_parameters(blit_parameters *blit, tilemap *tmap, bitm
blit->cliprect.max_y = dest->height - 1;
}
- /* set the priority code */
+ /* set the priority code and alpha */
blit->tilemap_priority_code = priority | (priority_mask << 8) | (tmap->palette_offset << 16);
+ blit->alpha = (flags & TILEMAP_DRAW_ALPHA_FLAG) ? (flags >> 24) : 0xff;
/* if no destination, just render priority */
if (dest == NULL)
@@ -1486,13 +1514,13 @@ static void configure_blit_parameters(blit_parameters *blit, tilemap *tmap, bitm
switch (dest->format)
{
case BITMAP_FORMAT_RGB32:
- blit->draw_masked = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_masked_rgb32_alpha : scanline_draw_masked_rgb32;
- blit->draw_opaque = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_opaque_rgb32_alpha : scanline_draw_opaque_rgb32;
+ blit->draw_masked = (blit->alpha < 0xff) ? scanline_draw_masked_rgb32_alpha : scanline_draw_masked_rgb32;
+ blit->draw_opaque = (blit->alpha < 0xff) ? scanline_draw_opaque_rgb32_alpha : scanline_draw_opaque_rgb32;
break;
case BITMAP_FORMAT_RGB15:
- blit->draw_masked = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_masked_rgb16_alpha : scanline_draw_masked_rgb16;
- blit->draw_opaque = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_opaque_rgb16_alpha : scanline_draw_opaque_rgb16;
+ blit->draw_masked = (blit->alpha < 0xff) ? scanline_draw_masked_rgb16_alpha : scanline_draw_masked_rgb16;
+ blit->draw_opaque = (blit->alpha < 0xff) ? scanline_draw_opaque_rgb16_alpha : scanline_draw_opaque_rgb16;
break;
case BITMAP_FORMAT_INDEXED16:
@@ -1650,7 +1678,7 @@ static void tilemap_draw_instance(tilemap *tmap, const blit_parameters *blit, in
{
for (cury = y; cury < nexty; cury++)
{
- (*blit->draw_opaque)(dest0, source0, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code);
+ (*blit->draw_opaque)(dest0, source0, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code, blit->alpha);
dest0 = (UINT8 *)dest0 + dest_line_pitch_bytes;
source0 += tmap->pixmap->rowpixels;
@@ -1664,7 +1692,7 @@ static void tilemap_draw_instance(tilemap *tmap, const blit_parameters *blit, in
const UINT8 *mask0 = mask_baseaddr + x_start;
for (cury = y; cury < nexty; cury++)
{
- (*blit->draw_masked)(dest0, source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code);
+ (*blit->draw_masked)(dest0, source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code, blit->alpha);
dest0 = (UINT8 *)dest0 + dest_line_pitch_bytes;
source0 += tmap->pixmap->rowpixels;
@@ -1712,9 +1740,9 @@ do { \
else if (blit->draw_masked == scanline_draw_masked_rgb16) \
*(UINT16 *)dest = clut[INPUT_VAL]; \
else if (blit->draw_masked == scanline_draw_masked_rgb32_alpha) \
- *(UINT32 *)dest = alpha_blend32(*(UINT32 *)dest, clut[INPUT_VAL]); \
+ *(UINT32 *)dest = alpha_blend_r32(*(UINT32 *)dest, clut[INPUT_VAL], alpha); \
else if (blit->draw_masked == scanline_draw_masked_rgb16_alpha) \
- *(UINT16 *)dest = alpha_blend16(*(UINT16 *)dest, clut[INPUT_VAL]); \
+ *(UINT16 *)dest = alpha_blend_r16(*(UINT16 *)dest, clut[INPUT_VAL], alpha); \
} while (0)
static void tilemap_draw_roz_core(tilemap *tmap, const blit_parameters *blit,
@@ -1731,6 +1759,7 @@ static void tilemap_draw_roz_core(tilemap *tmap, const blit_parameters *blit,
UINT32 priority = blit->tilemap_priority_code;
UINT8 mask = blit->mask;
UINT8 value = blit->value;
+ UINT8 alpha = blit->alpha;
UINT32 cx;
UINT32 cy;
int x;
@@ -1902,7 +1931,7 @@ static void tilemap_draw_roz_core(tilemap *tmap, const blit_parameters *blit,
bitmap, setting priority only
-------------------------------------------------*/
-static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
int i;
@@ -1920,7 +1949,7 @@ static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int coun
bitmap using a mask, setting priority only
-------------------------------------------------*/
-static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
int i;
@@ -1940,7 +1969,7 @@ static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UI
indexed bitmap
-------------------------------------------------*/
-static void scanline_draw_opaque_ind16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_opaque_ind16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
UINT16 *dest = _dest;
int pal = pcode >> 16;
@@ -1983,7 +2012,7 @@ static void scanline_draw_opaque_ind16(void *_dest, const UINT16 *source, int co
indexed bitmap using a mask
-------------------------------------------------*/
-static void scanline_draw_masked_ind16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_masked_ind16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
UINT16 *dest = _dest;
int pal = pcode >> 16;
@@ -2016,7 +2045,7 @@ static void scanline_draw_masked_ind16(void *_dest, const UINT16 *source, const
RGB bitmap
-------------------------------------------------*/
-static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT16 *dest = _dest;
@@ -2046,7 +2075,7 @@ static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int co
RGB bitmap using a mask
-------------------------------------------------*/
-static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT16 *dest = _dest;
@@ -2078,7 +2107,7 @@ static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const
16bpp RGB bitmap with alpha blending
-------------------------------------------------*/
-static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT16 *dest = _dest;
@@ -2089,7 +2118,7 @@ static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source,
{
for (i = 0; i < count; i++)
{
- dest[i] = alpha_blend16(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
pri[i] = (pri[i] & (pcode >> 8)) | pcode;
}
}
@@ -2098,7 +2127,7 @@ static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source,
else
{
for (i = 0; i < count; i++)
- dest[i] = alpha_blend16(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
}
}
@@ -2109,7 +2138,7 @@ static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source,
blending
-------------------------------------------------*/
-static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT16 *dest = _dest;
@@ -2121,7 +2150,7 @@ static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source,
for (i = 0; i < count; i++)
if ((maskptr[i] & mask) == value)
{
- dest[i] = alpha_blend16(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
pri[i] = (pri[i] & (pcode >> 8)) | pcode;
}
}
@@ -2131,7 +2160,7 @@ static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source,
{
for (i = 0; i < count; i++)
if ((maskptr[i] & mask) == value)
- dest[i] = alpha_blend16(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
}
}
@@ -2141,7 +2170,7 @@ static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source,
RGB bitmap
-------------------------------------------------*/
-static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT32 *dest = _dest;
@@ -2171,7 +2200,7 @@ static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int co
RGB bitmap using a mask
-------------------------------------------------*/
-static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT32 *dest = _dest;
@@ -2203,7 +2232,7 @@ static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const
32bpp RGB bitmap with alpha blending
-------------------------------------------------*/
-static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT32 *dest = _dest;
@@ -2214,7 +2243,7 @@ static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source,
{
for (i = 0; i < count; i++)
{
- dest[i] = alpha_blend32(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
pri[i] = (pri[i] & (pcode >> 8)) | pcode;
}
}
@@ -2223,7 +2252,7 @@ static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source,
else
{
for (i = 0; i < count; i++)
- dest[i] = alpha_blend32(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
}
}
@@ -2234,7 +2263,7 @@ static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source,
blending
-------------------------------------------------*/
-static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
+static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
{
const pen_t *clut = &pens[pcode >> 16];
UINT32 *dest = _dest;
@@ -2246,7 +2275,7 @@ static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source,
for (i = 0; i < count; i++)
if ((maskptr[i] & mask) == value)
{
- dest[i] = alpha_blend32(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
pri[i] = (pri[i] & (pcode >> 8)) | pcode;
}
}
@@ -2256,6 +2285,6 @@ static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source,
{
for (i = 0; i < count; i++)
if ((maskptr[i] & mask) == value)
- dest[i] = alpha_blend32(dest[i], clut[source[i]]);
+ dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
}
}
diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h
index 681236ce6d5..ca1e6a65372 100644
--- a/src/emu/tilemap.h
+++ b/src/emu/tilemap.h
@@ -131,9 +131,6 @@
* setting a global palette offset via
tilemap_set_palette_offset()
- * setting a global pen data offset via
- tilemap_set_pen_data_offset()
-
3. In your memory write handlers for the tile memory, anytime tile
data is modified, you need to mark the tile dirty so that it is
re-rendered with the new data the next time the tilemap is drawn.
@@ -282,8 +279,7 @@
TILEMAP_DRAW_LAYER0 is assumed.
* If you want to render with alpha blending, you can call
- tilemap_draw() with the TILEMAP_DRAW_ALPHA flag. To configure the
- amount of alpha blending, call alpha_set_level() ahead of time.
+ tilemap_draw() with the TILEMAP_DRAW_ALPHA flag.
* To configure more complex pen-to-layer mapping, use the
tilemap_map_pens_to_layer() call. This call takes a group number
@@ -302,6 +298,7 @@
#define __TILEMAP_H__
#include "mamecore.h"
+#include "drawgfx.h"
/***************************************************************************
@@ -323,7 +320,8 @@
#define TILEMAP_DRAW_LAYER1 0x20 /* draw layer 1 */
#define TILEMAP_DRAW_LAYER2 0x40 /* draw layer 2 */
#define TILEMAP_DRAW_OPAQUE 0x80 /* draw everything, even transparent stuff */
-#define TILEMAP_DRAW_ALPHA 0x100 /* draw with alpha blending */
+#define TILEMAP_DRAW_ALPHA_FLAG 0x100 /* draw with alpha blending (in the upper 8 bits) */
+#define TILEMAP_DRAW_ALPHA(x) (TILEMAP_DRAW_ALPHA_FLAG | (rgb_clamp(x) << 24))
#define TILEMAP_DRAW_ALL_CATEGORIES 0x200 /* draw all categories */
@@ -390,13 +388,14 @@ typedef struct _tilemap tilemap;
typedef struct _tile_data tile_data;
struct _tile_data
{
- const UINT8* pen_data; /* required */
- const UINT8* mask_data; /* required */
+ const UINT8 * pen_data; /* required */
+ const UINT8 * mask_data; /* required */
pen_t palette_base; /* defaults to 0 */
UINT8 category; /* defaults to 0; range from 0..15 */
UINT8 group; /* defaults to 0; range from 0..TILEMAP_NUM_GROUPS */
UINT8 flags; /* defaults to 0; one or more of TILE_* flags above */
UINT8 pen_mask; /* defaults to 0xff; mask to apply to pen_data while rendering the tile */
+ UINT8 gfxnum; /* defaults to 0xff; specify index of machine->gfx for auto-invalidation on dirty */
};
@@ -442,11 +441,6 @@ void tilemap_set_user_data(tilemap *tmap, void *user_data);
*/
void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset);
-/* specify an offset to be added to pen_data while rendering tiles.
- * This will automatically mark all tiles dirty if the offset changes.
- */
-void tilemap_set_pen_data_offset(tilemap *tmap, UINT32 offset);
-
/* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */
void tilemap_set_enable(tilemap *tmap, int enable);
@@ -570,13 +564,14 @@ TILEMAP_MAPPER( tilemap_scan_cols_flip_xy );
INLINE void tileinfo_set(running_machine *machine, tile_data *tileinfo, int gfxnum, int rawcode, int rawcolor, int flags)
{
- const gfx_element * gfx = machine->gfx[gfxnum];
+ const gfx_element *gfx = machine->gfx[gfxnum];
int code = rawcode % gfx->total_elements;
- tileinfo->pen_data = gfx->gfxdata + code * gfx->char_modulo;
+ tileinfo->pen_data = gfx_element_get_data(gfx, code);
tileinfo->palette_base = gfx->color_base + gfx->color_granularity * rawcolor;
tileinfo->flags = flags;
if (gfx->flags & GFX_ELEMENT_PACKED)
tileinfo->flags |= TILE_4BPP;
+ tileinfo->gfxnum = gfxnum;
}
diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c
index 72ab6c4db55..d9be2dca061 100644
--- a/src/emu/uigfx.c
+++ b/src/emu/uigfx.c
@@ -787,14 +787,14 @@ static void gfxset_draw_item(running_machine *machine, const gfx_element *gfx, i
for (y = 0; y < height; y++)
{
UINT32 *dest = (UINT32 *)bitmap->base + (dsty + y) * rowpixels + dstx;
- UINT8 *src = gfx->gfxdata + index * gfx->char_modulo;
+ const UINT8 *src = gfx_element_get_data(gfx, index);
/* loop over columns in the cell */
for (x = 0; x < width; x++)
{
int effx = x, effy = y;
rgb_t pixel;
- UINT8 *s;
+ const UINT8 *s;
/* compute effective x,y values after rotation */
if (!(rotate & ORIENTATION_SWAP_XY))
diff --git a/src/emu/video.c b/src/emu/video.c
index baec345afe5..ab670c23652 100644
--- a/src/emu/video.c
+++ b/src/emu/video.c
@@ -16,6 +16,7 @@
#include "rendutil.h"
#include "ui.h"
#include "aviio.h"
+#include "deprecat.h"
#include "snap.lh"
@@ -340,12 +341,9 @@ void video_init(running_machine *machine)
(*machine->config->init_palette)(machine, memory_region(machine, "proms"));
/* actually decode the graphics */
- if (machine->config->gfxdecodeinfo != NULL)
+ if (PREDECODE_GFX && machine->config->gfxdecodeinfo != NULL)
decode_graphics(machine, machine->config->gfxdecodeinfo);
- /* reset video statics and get out of here */
- pdrawgfx_shadow_lowpri = 0;
-
/* create a render target for snapshots */
viewname = options_get_string(mame_options(), OPTION_SNAPVIEW);
global.snap_native = (machine->primary_screen != NULL && (viewname[0] == 0 || strcmp(viewname, "native") == 0));
@@ -407,7 +405,7 @@ static void video_exit(running_machine *machine)
/* free all the graphics elements */
for (i = 0; i < MAX_GFX_ELEMENTS; i++)
- freegfx(machine->gfx[i]);
+ gfx_element_free(machine->gfx[i]);
/* free the snapshot target */
if (global.snap_target != NULL)
@@ -471,27 +469,29 @@ static void init_buffered_spriteram(running_machine *machine)
static void allocate_graphics(running_machine *machine, const gfx_decode_entry *gfxdecodeinfo)
{
- int i;
+ int curgfx;
/* loop over all elements */
- for (i = 0; i < MAX_GFX_ELEMENTS && gfxdecodeinfo[i].gfxlayout != NULL; i++)
+ for (curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++)
{
- int region_length = 8 * memory_region_length(machine, gfxdecodeinfo[i].memory_region);
- int xscale = (gfxdecodeinfo[i].xscale == 0) ? 1 : gfxdecodeinfo[i].xscale;
- int yscale = (gfxdecodeinfo[i].yscale == 0) ? 1 : gfxdecodeinfo[i].yscale;
+ const gfx_decode_entry *gfxdecode = &gfxdecodeinfo[curgfx];
+ UINT32 region_length = 8 * memory_region_length(machine, gfxdecode->memory_region);
+ const UINT8 *region_base = memory_region(machine, gfxdecode->memory_region);
+ UINT32 xscale = (gfxdecode->xscale == 0) ? 1 : gfxdecode->xscale;
+ UINT32 yscale = (gfxdecode->yscale == 0) ? 1 : gfxdecode->yscale;
UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE];
- gfx_layout glcopy;
- const gfx_layout *gl = gfxdecodeinfo[i].gfxlayout;
+ const gfx_layout *gl = gfxdecode->gfxlayout;
int israw = (gl->planeoffset[0] == GFX_RAW);
int planes = gl->planes;
- UINT16 width = gl->width;
- UINT16 height = gl->height;
+ UINT32 width = gl->width;
+ UINT32 height = gl->height;
UINT32 total = gl->total;
UINT32 charincrement = gl->charincrement;
+ gfx_layout glcopy;
int j;
/* make a copy of the layout */
- glcopy = *gfxdecodeinfo[i].gfxlayout;
+ glcopy = *gfxdecode->gfxlayout;
/* copy the X and Y offsets into temporary arrays */
memcpy(extxoffs, glcopy.xoffset, sizeof(glcopy.xoffset));
@@ -526,8 +526,7 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry *
/* if the character count is a region fraction, compute the effective total */
if (IS_FRAC(total))
{
- if (region_length == 0)
- continue;
+ assert(region_length != 0);
total = region_length / charincrement * FRAC_NUM(total) / FRAC_DEN(total);
}
@@ -539,7 +538,10 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry *
{
UINT32 value = extpoffs[j];
if (IS_FRAC(value))
+ {
+ assert(region_length != 0);
extpoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
+ }
}
/* loop over all the X/Y offsets, converting fractions */
@@ -547,21 +549,27 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry *
{
UINT32 value = extxoffs[j];
if (IS_FRAC(value))
+ {
+ assert(region_length != 0);
extxoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
+ }
}
for (j = 0; j < height; j++)
{
UINT32 value = extyoffs[j];
if (IS_FRAC(value))
+ {
+ assert(region_length != 0);
extyoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
+ }
}
}
/* otherwise, just use the line modulo */
else
{
- int base = gfxdecodeinfo[i].start;
+ int base = gfxdecode->start;
int end = region_length/8;
int linemod = gl->yoffset[0];
while (total > 0)
@@ -580,11 +588,7 @@ static void allocate_graphics(running_machine *machine, const gfx_decode_entry *
glcopy.total = total;
/* allocate the graphics */
- machine->gfx[i] = allocgfx(machine, &glcopy);
-
- /* if we have a remapped colortable, point our local colortable to it */
- machine->gfx[i]->total_colors = gfxdecodeinfo[i].total_color_codes;
- machine->gfx[i]->color_base = machine->config->gfxdecodeinfo[i].color_codes_start;
+ machine->gfx[curgfx] = gfx_element_alloc(machine, &glcopy, (region_base != NULL) ? region_base + gfxdecode->start : NULL, gfxdecode->total_color_codes, gfxdecode->color_codes_start);
}
}
@@ -610,7 +614,6 @@ static void decode_graphics(running_machine *machine, const gfx_decode_entry *gf
/* if we have a valid region, decode it now */
if (gfxdecodeinfo[i].memory_region != NULL)
{
- UINT8 *region_base = memory_region(machine, gfxdecodeinfo[i].memory_region);
gfx_element *gfx = machine->gfx[i];
int j;
@@ -619,7 +622,7 @@ static void decode_graphics(running_machine *machine, const gfx_decode_entry *gf
{
char buffer[200];
int num_to_decode = (j + 1024 < gfx->total_elements) ? 1024 : (gfx->total_elements - j);
- decodegfx(gfx, region_base + gfxdecodeinfo[i].start, j, num_to_decode);
+ decodegfx(gfx, j, num_to_decode);
curgfx += num_to_decode;
/* display some startup text */
@@ -2727,6 +2730,38 @@ int video_get_view_for_target(running_machine *machine, render_target *target, c
/***************************************************************************
+ DEBUGGING HELPERS
+***************************************************************************/
+
+/*-------------------------------------------------
+ video_assert_out_of_range_pixels - assert if
+ any pixels in the given bitmap contain an
+ invalid palette index
+-------------------------------------------------*/
+
+void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap)
+{
+#ifdef MAME_DEBUG
+ int maxindex = palette_get_max_index(machine->palette);
+ int x, y;
+
+ /* this only applies to indexed16 bitmaps */
+ if (bitmap->format != BITMAP_FORMAT_INDEXED16)
+ return;
+
+ /* iterate over rows */
+ for (y = 0; y < bitmap->height; y++)
+ {
+ UINT16 *rowbase = BITMAP_ADDR16(bitmap, y, 0);
+ for (x = 0; x < bitmap->width; x++)
+ assert(rowbase[x] < maxindex);
+ }
+#endif
+}
+
+
+
+/***************************************************************************
SOFTWARE RENDERING
***************************************************************************/
diff --git a/src/emu/video.h b/src/emu/video.h
index 0595e62c9b0..41ec2992715 100644
--- a/src/emu/video.h
+++ b/src/emu/video.h
@@ -278,4 +278,11 @@ void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsa
/* select a view for a given target */
int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets);
+
+/* ----- debugging helpers ----- */
+
+/* assert if any pixels in the given bitmap contain an invalid palette index */
+void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap);
+
+
#endif /* __VIDEO_H__ */
diff --git a/src/lib/util/bitmap.c b/src/lib/util/bitmap.c
index efbb6d09e71..26af203b702 100644
--- a/src/lib/util/bitmap.c
+++ b/src/lib/util/bitmap.c
@@ -72,6 +72,10 @@ bitmap_t *bitmap_alloc_slop(int width, int height, int xslop, int yslop, bitmap_
bitmap->bpp = bpp;
bitmap->rowpixels = rowpixels;
bitmap->base = (UINT8 *)bitmap->alloc + (rowpixels * yslop + xslop) * (bpp / 8);
+ bitmap->cliprect.min_x = 0;
+ bitmap->cliprect.max_x = width - 1;
+ bitmap->cliprect.min_y = 0;
+ bitmap->cliprect.max_y = height - 1;
return bitmap;
}
@@ -104,6 +108,10 @@ bitmap_t *bitmap_wrap(void *base, int width, int height, int rowpixels, bitmap_f
bitmap->bpp = bpp;
bitmap->rowpixels = rowpixels;
bitmap->base = base;
+ bitmap->cliprect.min_x = 0;
+ bitmap->cliprect.max_x = width - 1;
+ bitmap->cliprect.min_y = 0;
+ bitmap->cliprect.max_y = height - 1;
return bitmap;
}
@@ -164,14 +172,9 @@ void bitmap_free(bitmap_t *bitmap)
void bitmap_fill(bitmap_t *dest, const rectangle *cliprect, UINT32 color)
{
- rectangle fill;
+ rectangle fill = dest->cliprect;
int x, y;
- /* default to the whole bitmap */
- fill.min_x = fill.min_y = 0;
- fill.max_x = dest->width - 1;
- fill.max_y = dest->height - 1;
-
/* if we have a cliprect, intersect with that */
if (cliprect != NULL)
sect_rect(&fill, cliprect);
diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h
index ab484a010ff..95c4e4476ef 100644
--- a/src/lib/util/bitmap.h
+++ b/src/lib/util/bitmap.h
@@ -61,6 +61,7 @@ struct _bitmap_t
bitmap_format format; /* format of the bitmap */
int bpp; /* bits per pixel */
palette_t * palette; /* optional palette */
+ rectangle cliprect; /* a clipping rectangle covering the full bitmap */
};
diff --git a/src/lib/util/palette.c b/src/lib/util/palette.c
index c343808f67e..e659f152830 100644
--- a/src/lib/util/palette.c
+++ b/src/lib/util/palette.c
@@ -230,6 +230,18 @@ int palette_get_num_groups(palette_t *palette)
/*-------------------------------------------------
+ palette_get_max_index - return the maximum
+ allowed index (i.e., length of arrays returned
+ by palette_entry_list*)
+-------------------------------------------------*/
+
+int palette_get_max_index(palette_t *palette)
+{
+ return palette->numcolors * palette->numgroups + 2;
+}
+
+
+/*-------------------------------------------------
palette_get_black_entry - return the index of
the black entry
-------------------------------------------------*/
diff --git a/src/lib/util/palette.h b/src/lib/util/palette.h
index 6b3e3a546f4..3ae0147f96f 100644
--- a/src/lib/util/palette.h
+++ b/src/lib/util/palette.h
@@ -81,6 +81,9 @@ int palette_get_num_colors(palette_t *palette);
/* return the number of groups managed by the palette */
int palette_get_num_groups(palette_t *palette);
+/* return the maximum allowed index (i.e., length of arrays returned by palette_entry_list*) */
+int palette_get_max_index(palette_t *palette);
+
/* return the index of the black entry */
UINT32 palette_get_black_entry(palette_t *palette);
diff --git a/src/mame/drivers/2mindril.c b/src/mame/drivers/2mindril.c
index db8c154993b..82a001605c9 100644
--- a/src/mame/drivers/2mindril.c
+++ b/src/mame/drivers/2mindril.c
@@ -81,14 +81,8 @@ static UINT16 *textram;
static VIDEO_UPDATE( drill )
{
- int i;
bitmap_fill(bitmap,NULL,0);
- for (i=0; i<256; i++)
- {
- decodechar(screen->machine->gfx[1],i,(UINT8*)&charram[0]);
- }
-
DRAW_MAP(map1ram,0)
DRAW_MAP(map2ram,1)
DRAW_MAP(map3ram,2)
@@ -117,6 +111,7 @@ static VIDEO_UPDATE( drill )
static VIDEO_START( drill )
{
machine->gfx[0]->color_granularity=16;
+ gfx_element_set_source(machine->gfx[1], (UINT8 *)charram);
}
static UINT16 *iodata;
@@ -220,6 +215,12 @@ static WRITE16_HANDLER( sensors_w )
}
}
+static WRITE16_HANDLER( charram_w )
+{
+ COMBINE_DATA(&charram[offset]);
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/16);
+}
+
static ADDRESS_MAP_START( drill_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x07ffff) AM_ROM
AM_RANGE(0x200000, 0x20ffff) AM_RAM
@@ -229,7 +230,7 @@ static ADDRESS_MAP_START( drill_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x414000, 0x415fff) AM_RAM AM_BASE(&map3ram)
AM_RANGE(0x416000, 0x417fff) AM_RAM AM_BASE(&map4ram)
AM_RANGE(0x41c000, 0x41dfff) AM_RAM AM_BASE(&textram)
- AM_RANGE(0x41e000, 0x41ffff) AM_RAM AM_BASE(&charram)
+ AM_RANGE(0x41e000, 0x41ffff) AM_RAM_WRITE(charram_w) AM_BASE(&charram)
AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE(&unkram)// video stuff, 460000 - video regs ?
AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE(&paletteram16)
AM_RANGE(0x502000, 0x503fff) AM_RAM
diff --git a/src/mame/drivers/ace.c b/src/mame/drivers/ace.c
index af13c7fa89a..8fd4d46c7ac 100644
--- a/src/mame/drivers/ace.c
+++ b/src/mame/drivers/ace.c
@@ -61,19 +61,18 @@ static READ8_HANDLER( ace_objpos_r )
}
#endif
+static VIDEO_START( ace )
+{
+ gfx_element_set_source(machine->gfx[1], ace_characterram);
+ gfx_element_set_source(machine->gfx[2], ace_characterram);
+ gfx_element_set_source(machine->gfx[3], ace_characterram);
+ gfx_element_set_source(machine->gfx[4], ace_scoreram);
+}
+
static VIDEO_UPDATE( ace )
{
int offs;
- decodechar(screen->machine->gfx[1], 0, ace_characterram);
- decodechar(screen->machine->gfx[2], 0, ace_characterram);
- decodechar(screen->machine->gfx[3], 0, ace_characterram);
-
- for (offs = 0; offs < 8; offs++)
- {
- decodechar(screen->machine->gfx[4], offs, ace_scoreram);
- }
-
/* first of all, fill the screen with the background color */
bitmap_fill(bitmap, cliprect, 0);
@@ -119,11 +118,6 @@ static PALETTE_INIT( ace )
}
-static READ8_HANDLER( ace_characterram_r )
-{
- return ace_characterram[offset];
-}
-
static WRITE8_HANDLER( ace_characterram_w )
{
if (ace_characterram[offset] != data)
@@ -134,9 +128,17 @@ static WRITE8_HANDLER( ace_characterram_w )
popmessage("write to %04x data=%02x\n", 0x8000+offset, data);
}
ace_characterram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[1], 0);
+ gfx_element_mark_dirty(space->machine->gfx[2], 0);
+ gfx_element_mark_dirty(space->machine->gfx[3], 0);
}
}
+static WRITE8_HANDLER( ace_scoreram_w )
+{
+ ace_scoreram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[4], offset / 32);
+}
static READ8_HANDLER( unk_r )
{
@@ -152,9 +154,9 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x09ff) AM_ROM
- AM_RANGE(0x2000, 0x20ff) AM_RAM AM_BASE(&ace_scoreram) /* 2x2101 */
+ AM_RANGE(0x2000, 0x20ff) AM_RAM_WRITE(ace_scoreram_w) AM_BASE(&ace_scoreram) /* 2x2101 */
AM_RANGE(0x8300, 0x83ff) AM_RAM AM_BASE(&ace_ram2) /* 2x2101 */
- AM_RANGE(0x8000, 0x80ff) AM_READWRITE(ace_characterram_r, ace_characterram_w) AM_BASE(&ace_characterram) /* 3x3101 (3bits: 0, 1, 2) */
+ AM_RANGE(0x8000, 0x80ff) AM_RAM_WRITE(ace_characterram_w) AM_BASE(&ace_characterram) /* 3x3101 (3bits: 0, 1, 2) */
AM_RANGE(0xc000, 0xc005) AM_WRITE(ace_objpos_w)
@@ -326,6 +328,7 @@ static MACHINE_DRIVER_START( ace )
MDRV_PALETTE_LENGTH(2)
MDRV_PALETTE_INIT(ace)
+ MDRV_VIDEO_START(ace)
MDRV_VIDEO_UPDATE(ace)
/* sound hardware */
diff --git a/src/mame/drivers/acefruit.c b/src/mame/drivers/acefruit.c
index 11251aaaa34..7182ba6c9f9 100644
--- a/src/mame/drivers/acefruit.c
+++ b/src/mame/drivers/acefruit.c
@@ -90,11 +90,13 @@ static VIDEO_UPDATE( acefruit )
for( x = 0; x < 16; x++ )
{
+ int sprite = ( spriteram[ ( spriteindex / 64 ) % 6 ] & 0xf ) ^ 0xf;
+ const UINT8 *gfxdata = gfx_element_get_data(gfx, sprite);
+
for( y = 0; y < 8; y++ )
{
UINT16 *dst = BITMAP_ADDR16( bitmap, y + ( row * 8 ), x + ( col * 16 ) );
- int sprite = ( spriteram[ ( spriteindex / 64 ) % 6 ] & 0xf ) ^ 0xf;
- *( dst ) = *( gfx->gfxdata + ( sprite * gfx->char_modulo ) + ( ( spriterow + y ) * gfx->line_modulo ) + ( ( spriteindex % 64 ) >> 1 ) );
+ *( dst ) = *( gfxdata + ( ( spriterow + y ) * gfx->line_modulo ) + ( ( spriteindex % 64 ) >> 1 ) );
}
spriteindex += spritesize;
diff --git a/src/mame/drivers/atarig1.c b/src/mame/drivers/atarig1.c
index 9640aa9102f..a71d8f6814b 100644
--- a/src/mame/drivers/atarig1.c
+++ b/src/mame/drivers/atarig1.c
@@ -370,7 +370,7 @@ static const gfx_layout pflayout =
5,
{ 0, 0, 1, 2, 3 },
{ RGN_FRAC(2,5)+0, RGN_FRAC(2,5)+4, 0, 4, RGN_FRAC(2,5)+8, RGN_FRAC(2,5)+12, 8, 12 },
- { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
+ { STEP8(0,16) },
16*8
};
@@ -381,7 +381,7 @@ static const gfx_layout pftoplayout =
5,
{ RGN_FRAC(4,5), RGN_FRAC(4,5), RGN_FRAC(4,5), RGN_FRAC(4,5), RGN_FRAC(4,5) },
{ 0, 1, 2, 3, 4, 5, 6, 7 },
- { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
+ { STEP8(0,8) },
8*8
};
@@ -390,9 +390,9 @@ static const gfx_layout anlayout =
8,8,
RGN_FRAC(1,1),
4,
- { 0, 1, 2, 3 },
- { 0, 4, 8, 12, 16, 20, 24, 28 },
- { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
+ { STEP4(0,1) },
+ { STEP8(0,4) },
+ { STEP8(0,32) },
32*8
};
diff --git a/src/mame/drivers/bnstars.c b/src/mame/drivers/bnstars.c
index 56dc854658e..b39b6e9aaac 100644
--- a/src/mame/drivers/bnstars.c
+++ b/src/mame/drivers/bnstars.c
@@ -370,7 +370,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int xsize, ysize, xzoom, yzoom;
int code, attr, color, size, pri, pri_mask, trans;
gfx_element *gfx = machine->gfx[region];
- gfx_element mygfx = *gfx;
UINT32 *source = sprram_top;
const UINT32 *finish = sprram_top + (sprram_size - 0x10) / 4;
@@ -433,11 +432,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
flipy = !flipy;
}
- /* change GfxElement parameters to draw only the needed part of the 256x256 tile */
- mygfx.width = xsize;
- mygfx.height = ysize;
- mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
-
/* TODO: priority handling is completely wrong, but better than nothing */
if (pri == 0x0)
pri_mask = 0x00;
@@ -448,7 +442,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
else
pri_mask = 0xfe;
- pdrawgfxzoom(bitmap, &mygfx,
+ gfx_element_set_source_clip(gfx, tx, xsize, ty, ysize);
+ pdrawgfxzoom(bitmap, gfx,
code,
color,
flipx, flipy,
diff --git a/src/mame/drivers/btime.c b/src/mame/drivers/btime.c
index 36440277ee4..5b06b19f30c 100644
--- a/src/mame/drivers/btime.c
+++ b/src/mame/drivers/btime.c
@@ -1155,6 +1155,16 @@ static const gfx_layout tile8layout =
8*8
};
+static const gfx_layout disco_tile8layout =
+{
+ 8,8,
+ 0x6000/3/8,
+ 3,
+ { 0x4000*8, 0x2000*8, 0x0000*8 },
+ { STEP8(0,1) },
+ { STEP8(0,8) },
+ 8*8
+};
static const gfx_layout tile16layout =
@@ -1168,7 +1178,16 @@ static const gfx_layout tile16layout =
32*8
};
-
+static const gfx_layout disco_tile16layout =
+{
+ 16,16,
+ 0x6000/3/32,
+ 3,
+ { 0x4000*8, 0x2000*8, 0x0000*8 },
+ { STEP8(16*8,1), STEP8(0,1) },
+ { STEP16(0,8) },
+ 32*8
+};
static const gfx_layout bnj_tile16layout =
{
@@ -1211,8 +1230,8 @@ static GFXDECODE_START( zoar )
GFXDECODE_END
static GFXDECODE_START( disco )
- GFXDECODE_ENTRY( "gfx1", 0, tile8layout, 0, 4 ) /* char set #1 */
- GFXDECODE_ENTRY( "gfx1", 0, tile16layout, 0, 4 ) /* sprites */
+ GFXDECODE_ENTRY( NULL, 0, disco_tile8layout, 0, 4 ) /* char set #1 */
+ GFXDECODE_ENTRY( NULL, 0, disco_tile16layout, 0, 4 ) /* sprites */
GFXDECODE_END
@@ -1736,9 +1755,6 @@ ROM_START( disco )
ROM_REGION( 0x10000, "audio", 0 )
ROM_LOAD( "disco.w6", 0xf000, 0x1000, CRC(d81e781e) SHA1(bde510bfed06a13bd56bf7ddbf220e7cf82f79b6) )
- ROM_REGION( 0x6000, "gfx1", ROMREGION_ERASE00 )
- /* dynamically allocated */
-
ROM_REGION( 0x0020, "proms", 0 )
ROM_LOAD( "disco.clr", 0x0000, 0x0020, CRC(a393f913) SHA1(42dce159283427064b3f5ce3a6e2189744ecd943) )
ROM_END
@@ -1755,9 +1771,6 @@ ROM_START( discof )
ROM_REGION( 0x10000, "audio", 0 )
ROM_LOAD( "disco.w6", 0xf000, 0x1000, CRC(d81e781e) SHA1(bde510bfed06a13bd56bf7ddbf220e7cf82f79b6) )
- ROM_REGION( 0x6000, "gfx1", ROMREGION_ERASE00 )
- /* dynamically allocated */
-
ROM_REGION( 0x0020, "proms", 0 )
ROM_LOAD( "disco.clr", 0x0000, 0x0020, CRC(a393f913) SHA1(42dce159283427064b3f5ce3a6e2189744ecd943) )
ROM_END
diff --git a/src/mame/drivers/cps3.c b/src/mame/drivers/cps3.c
index 37592e96dd7..28e93b71aaf 100644
--- a/src/mame/drivers/cps3.c
+++ b/src/mame/drivers/cps3.c
@@ -428,7 +428,7 @@ INLINE void cps3_drawgfxzoom(running_machine *machine, bitmap_t *dest_bmp,const
// const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)];
UINT32 palbase = (gfx->color_granularity * color) & 0x1ffff;
const pen_t *pal = &cps3_mame_colours[palbase];
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
@@ -501,7 +501,7 @@ INLINE void cps3_drawgfxzoom(running_machine *machine, bitmap_t *dest_bmp,const
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -520,7 +520,7 @@ INLINE void cps3_drawgfxzoom(running_machine *machine, bitmap_t *dest_bmp,const
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -540,7 +540,7 @@ INLINE void cps3_drawgfxzoom(running_machine *machine, bitmap_t *dest_bmp,const
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -560,7 +560,7 @@ INLINE void cps3_drawgfxzoom(running_machine *machine, bitmap_t *dest_bmp,const
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -797,11 +797,6 @@ static const gfx_layout cps3_tiles8x8_layout =
};
static UINT32* cps3_ss_ram;
-static UINT8* cps3_ss_ram_dirty;
-static int cps3_ss_ram_is_dirty;
-
-static UINT8* cps3_char_ram_dirty;
-static int cps3_char_ram_is_dirty;
static void cps3_set_mame_colours(running_machine *machine, int colournum, UINT16 data, UINT32 fadeval )
{
@@ -845,29 +840,21 @@ static void cps3_set_mame_colours(running_machine *machine, int colournum, UINT1
static VIDEO_START(cps3)
{
cps3_ss_ram = auto_malloc(0x10000);
- cps3_ss_ram_dirty = auto_malloc(0x400);
- cps3_ss_ram_is_dirty = 1;
memset(cps3_ss_ram, 0x00, 0x10000);
- memset(cps3_ss_ram_dirty, 1, 0x400);
state_save_register_global_pointer(machine, cps3_ss_ram, 0x10000/4);
cps3_char_ram = auto_malloc(0x800000);
- cps3_char_ram_dirty = auto_malloc(0x800000/256);
- cps3_char_ram_is_dirty = 1;
memset(cps3_char_ram, 0x00, 0x800000);
- memset(cps3_char_ram_dirty, 1, 0x8000);
state_save_register_global_pointer(machine, cps3_char_ram, 0x800000 /4);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[0] = allocgfx(machine, &cps3_tiles8x8_layout);
- machine->gfx[0]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[0] = gfx_element_alloc(machine, &cps3_tiles8x8_layout, (UINT8 *)cps3_ss_ram, machine->config->total_colors / 16, 0);
//decode_ssram();
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[1] = allocgfx(machine, &cps3_tiles16x16_layout);
- machine->gfx[1]->total_colors = machine->config->total_colors / 64;
- machine->gfx[1]->color_granularity=64;
+ machine->gfx[1] = gfx_element_alloc(machine, &cps3_tiles16x16_layout, (UINT8 *)cps3_char_ram, machine->config->total_colors / 64, 0);
+ machine->gfx[1]->color_granularity = 64;
//decode_charram();
@@ -968,13 +955,7 @@ static void cps3_draw_tilemapsprite_line(running_machine *machine, int tmnum, in
if (!bpp) machine->gfx[1]->color_granularity=256;
else machine->gfx[1]->color_granularity=64;
- if (cps3_char_ram_dirty[tileno])
- {
- decodechar(machine->gfx[1], tileno, (UINT8*)cps3_char_ram);
- cps3_char_ram_dirty[tileno] = 0;
- }
cps3_drawgfxzoom(machine, bitmap, machine->gfx[1],tileno,colour,xflip,yflip,(x*16)-scrollx%16,drawline-tilesubline,&clip,CPS3_TRANSPARENCY_PEN_INDEX,0, 0x10000, 0x10000, NULL, 0);
-
}
}
}
@@ -1215,12 +1196,6 @@ static VIDEO_UPDATE(cps3)
{
int realtileno = tileno+count;
- if (cps3_char_ram_dirty[realtileno])
- {
- decodechar(screen->machine->gfx[1], realtileno, (UINT8*)cps3_char_ram);
- cps3_char_ram_dirty[realtileno] = 0;
- }
-
if (global_alpha || alpha)
{
cps3_drawgfxzoom(screen->machine, renderbuffer_bitmap, screen->machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,&renderbuffer_clip,CPS3_TRANSPARENCY_PEN_INDEX_BLEND,0,xinc,yinc, NULL, 0);
@@ -1293,13 +1268,6 @@ static VIDEO_UPDATE(cps3)
pal += cps3_ss_pal_base << 5;
tile+=0x200;
-
- if (cps3_ss_ram_dirty[tile])
- {
- decodechar(screen->machine->gfx[0], tile, (UINT8*)cps3_ss_ram);
- cps3_ss_ram_dirty[tile] = 0;
- }
-
cps3_drawgfxzoom(screen->machine, bitmap, screen->machine->gfx[0],tile,pal,flipx,flipy,x*8,y*8,cliprect,CPS3_TRANSPARENCY_PEN,0,0x10000,0x10000,NULL,0);
count++;
}
@@ -1323,9 +1291,7 @@ static WRITE32_HANDLER( cps3_ssram_w )
// we only want to endian-flip the character data, the tilemap info is fine
data = LITTLE_ENDIANIZE_INT32(data);
mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask);
-
- cps3_ss_ram_dirty[offset/16] = 1;
- cps3_ss_ram_is_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
}
COMBINE_DATA(&cps3_ss_ram[offset]);
@@ -1419,8 +1385,7 @@ static WRITE32_HANDLER( cram_data_w )
mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask);
data = LITTLE_ENDIANIZE_INT32(data);
COMBINE_DATA(&cps3_char_ram[fulloffset]);
- cps3_char_ram_dirty[fulloffset/0x40] = 1;
- cps3_char_ram_is_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[1], fulloffset/0x40);
}
/* FLASH ROM ACCESS */
@@ -1904,7 +1869,7 @@ static int cps3_rle_length = 0;
static int last_normal_byte = 0;
-static UINT32 process_byte( UINT8 real_byte, UINT32 destination, int max_length )
+static UINT32 process_byte( running_machine *machine, UINT8 real_byte, UINT32 destination, int max_length )
{
UINT8* dest = (UINT8*)cps3_char_ram;
@@ -1924,8 +1889,7 @@ static UINT32 process_byte( UINT8 real_byte, UINT32 destination, int max_length
while (cps3_rle_length)
{
dest[((destination+tranfercount)&0x7fffff)^3] = (last_normal_byte&0x3f);
- cps3_char_ram_dirty[((destination+tranfercount)&0x7fffff)/0x100] = 1;
- cps3_char_ram_is_dirty = 1;
+ gfx_element_mark_dirty(machine->gfx[1], ((destination+tranfercount)&0x7fffff)/0x100);
//printf("RLE WRite Byte %08x, %02x\n", destination+tranfercount, real_byte);
tranfercount++;
@@ -1944,8 +1908,7 @@ static UINT32 process_byte( UINT8 real_byte, UINT32 destination, int max_length
//printf("Write Normal Data\n");
dest[(destination&0x7fffff)^3] = real_byte;
last_normal_byte = real_byte;
- cps3_char_ram_dirty[(destination&0x7fffff)/0x100] = 1;
- cps3_char_ram_is_dirty = 1;
+ gfx_element_mark_dirty(machine->gfx[1], (destination&0x7fffff)/0x100);
return 1;
}
}
@@ -1973,7 +1936,7 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT
real_byte = sourcedata[DMA_XOR((current_table_address+current_byte*2+0))];
//if (real_byte&0x80) return;
- length_processed = process_byte( real_byte, real_destination, length_remaining );
+ length_processed = process_byte( machine, real_byte, real_destination, length_remaining );
length_remaining-=length_processed; // subtract the number of bytes the operation has taken
real_destination+=length_processed; // add it onto the destination
if (real_destination>0x7fffff) return;
@@ -1981,7 +1944,7 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT
real_byte = sourcedata[DMA_XOR((current_table_address+current_byte*2+1))];
//if (real_byte&0x80) return;
- length_processed = process_byte( real_byte, real_destination, length_remaining );
+ length_processed = process_byte( machine, real_byte, real_destination, length_remaining );
length_remaining-=length_processed; // subtract the number of bytes the operation has taken
real_destination+=length_processed; // add it onto the destination
if (real_destination>0x7fffff) return;
@@ -1990,7 +1953,7 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT
else
{
UINT32 length_processed;
- length_processed = process_byte( current_byte, real_destination, length_remaining );
+ length_processed = process_byte( machine, current_byte, real_destination, length_remaining );
length_remaining-=length_processed; // subtract the number of bytes the operation has taken
real_destination+=length_processed; // add it onto the destination
if (real_destination>0x7fffff) return;
@@ -2003,7 +1966,7 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT
static unsigned short lastb;
static unsigned short lastb2;
-static UINT32 ProcessByte8(UINT8 b,UINT32 dst_offset)
+static UINT32 ProcessByte8(running_machine *machine,UINT8 b,UINT32 dst_offset)
{
UINT8* destRAM = (UINT8*)cps3_char_ram;
int l=0;
@@ -2016,8 +1979,7 @@ static UINT32 ProcessByte8(UINT8 b,UINT32 dst_offset)
for(i=0;i<rle;++i)
{
destRAM[(dst_offset&0x7fffff)^3] = lastb;
- cps3_char_ram_dirty[(dst_offset&0x7fffff)/0x100] = 1;
- cps3_char_ram_is_dirty = 1;
+ gfx_element_mark_dirty(machine->gfx[1], (dst_offset&0x7fffff)/0x100);
dst_offset++;
++l;
@@ -2031,8 +1993,7 @@ static UINT32 ProcessByte8(UINT8 b,UINT32 dst_offset)
lastb2=lastb;
lastb=b;
destRAM[(dst_offset&0x7fffff)^3] = b;
- cps3_char_ram_dirty[(dst_offset&0x7fffff)/0x100] = 1;
- cps3_char_ram_is_dirty = 1;
+ gfx_element_mark_dirty(machine->gfx[1], (dst_offset&0x7fffff)/0x100);
return 1;
}
}
@@ -2061,13 +2022,13 @@ static void cps3_do_alt_char_dma( running_machine *machine, UINT32 src, UINT32 r
UINT8 real_byte;
p&=0x7f;
real_byte = px[DMA_XOR((current_table_address+p*2+0))];
- ds+=ProcessByte8(real_byte,ds);
+ ds+=ProcessByte8(machine,real_byte,ds);
real_byte = px[DMA_XOR((current_table_address+p*2+1))];
- ds+=ProcessByte8(real_byte,ds);
+ ds+=ProcessByte8(machine,real_byte,ds);
}
else
{
- ds+=ProcessByte8(p,ds);
+ ds+=ProcessByte8(machine,p,ds);
}
++src;
ctrl<<=1;
diff --git a/src/mame/drivers/cvs.c b/src/mame/drivers/cvs.c
index af20d9091f3..d9a85903a6e 100644
--- a/src/mame/drivers/cvs.c
+++ b/src/mame/drivers/cvs.c
@@ -195,7 +195,11 @@ READ8_HANDLER( cvs_s2636_0_or_character_ram_r )
WRITE8_HANDLER( cvs_s2636_0_or_character_ram_w )
{
if (cpu_get_reg(space->cpu, S2650_FO))
- cvs_character_ram[(0 * 0x800) | 0x400 | character_ram_page_start | offset] = data;
+ {
+ offset |= (0 * 0x800) | 0x400 | character_ram_page_start;
+ cvs_character_ram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
+ }
else
cvs_s2636_0_ram[offset] = data;
}
@@ -212,7 +216,11 @@ READ8_HANDLER( cvs_s2636_1_or_character_ram_r )
WRITE8_HANDLER( cvs_s2636_1_or_character_ram_w )
{
if (cpu_get_reg(space->cpu, S2650_FO))
- cvs_character_ram[(1 * 0x800) | 0x400 | character_ram_page_start | offset] = data;
+ {
+ offset |= (1 * 0x800) | 0x400 | character_ram_page_start;
+ cvs_character_ram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
+ }
else
cvs_s2636_1_ram[offset] = data;
}
@@ -229,7 +237,11 @@ READ8_HANDLER( cvs_s2636_2_or_character_ram_r )
WRITE8_HANDLER( cvs_s2636_2_or_character_ram_w )
{
if (cpu_get_reg(space->cpu, S2650_FO))
- cvs_character_ram[(2 * 0x800) | 0x400 | character_ram_page_start | offset] = data;
+ {
+ offset |= (2 * 0x800) | 0x400 | character_ram_page_start;
+ cvs_character_ram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
+ }
else
cvs_s2636_2_ram[offset] = data;
}
@@ -497,6 +509,10 @@ MACHINE_START( cvs )
cvs_character_ram = auto_malloc(3 * 0x800); /* only half is used, but
by allocating twice the amount,
we can use the same gfx_layout */
+
+ if (machine->gfx[1] != NULL)
+ gfx_element_set_source(machine->gfx[1], cvs_character_ram);
+
start_393hz_timer(machine);
/* register state save */
@@ -996,6 +1012,7 @@ static const gfx_layout charlayout =
static GFXDECODE_START( cvs )
GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout, 0, 256+4 )
+ GFXDECODE_ENTRY( NULL, 0x0000, charlayout, 0, 256+4 )
GFXDECODE_END
diff --git a/src/mame/drivers/fastfred.c b/src/mame/drivers/fastfred.c
index 9b34d141f52..22fdcda13ef 100644
--- a/src/mame/drivers/fastfred.c
+++ b/src/mame/drivers/fastfred.c
@@ -118,6 +118,11 @@ static UINT8 imago_sprites[0x800*3];
static UINT16 imago_sprites_address;
static UINT8 imago_sprites_bank = 0;
+static MACHINE_START( imago )
+{
+ gfx_element_set_source(machine->gfx[1], imago_sprites);
+}
+
static WRITE8_HANDLER( imago_dma_irq_w )
{
cpu_set_input_line(space->machine->cpu[0], 0, data & 1 ? ASSERT_LINE : CLEAR_LINE);
@@ -142,7 +147,7 @@ static WRITE8_HANDLER( imago_sprites_dma_w )
sprites_data = rom[imago_sprites_address + 0x2000*2 + imago_sprites_bank * 0x1000];
imago_sprites[offset + 0x800*2] = sprites_data;
- decodechar(space->machine->gfx[1], offset/32, imago_sprites);
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/32);
}
static READ8_HANDLER( imago_sprites_offset_r )
@@ -665,6 +670,8 @@ static MACHINE_DRIVER_START( imago )
MDRV_IMPORT_FROM(fastfred)
MDRV_CPU_MODIFY("main")
MDRV_CPU_PROGRAM_MAP(imago_map,0)
+
+ MDRV_MACHINE_START(imago)
/* video hardware */
MDRV_PALETTE_LENGTH(256+64+2) /* 256 for characters, 64 for the stars and 2 for the web */
diff --git a/src/mame/drivers/gamecstl.c b/src/mame/drivers/gamecstl.c
index 53a22f8696a..59df94e0c44 100644
--- a/src/mame/drivers/gamecstl.c
+++ b/src/mame/drivers/gamecstl.c
@@ -105,9 +105,9 @@ static VIDEO_START(gamecstl)
static void draw_char(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y)
{
int i,j;
- UINT8 *dp;
+ const UINT8 *dp;
int index = 0;
- dp = gfx->gfxdata + ch * gfx->char_modulo;
+ dp = gfx_element_get_data(gfx, ch);
for (j=y; j < y+8; j++)
{
diff --git a/src/mame/drivers/gticlub.c b/src/mame/drivers/gticlub.c
index ec6a50120e5..5a1f2086684 100644
--- a/src/mame/drivers/gticlub.c
+++ b/src/mame/drivers/gticlub.c
@@ -236,7 +236,6 @@ UINT8 gticlub_led_reg0;
UINT8 gticlub_led_reg1;
int K001604_vh_start(running_machine *machine, int chip);
-void K001604_tile_update(running_machine *machine, int chip);
void K001604_draw_front_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
READ32_HANDLER(K001604_tile_r);
@@ -280,7 +279,6 @@ static VIDEO_UPDATE( hangplt )
{
const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo0");
- K001604_tile_update(screen->machine, 0);
// K001604_draw_back_layer(bitmap, cliprect);
voodoo_update(voodoo, bitmap, cliprect);
@@ -291,7 +289,6 @@ static VIDEO_UPDATE( hangplt )
{
const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo1");
- K001604_tile_update(screen->machine, 1);
// K001604_draw_back_layer(bitmap, cliprect);
voodoo_update(voodoo, bitmap, cliprect);
diff --git a/src/mame/drivers/hng64.c b/src/mame/drivers/hng64.c
index 87f63a05bc9..472072e3115 100644
--- a/src/mame/drivers/hng64.c
+++ b/src/mame/drivers/hng64.c
@@ -622,7 +622,6 @@ static WRITE32_HANDLER( hng64_pal_w )
a = ((paletteram32[offset] & 0xff000000) >>24);
// a sure ain't alpha.
- // alpha_set_level(mame_rand(space->machine)) ;
// mame_printf_debug("Alpha : %d %d %d %d\n", a, b, g, r) ;
//if (a != 0)
diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c
index ee2cbeed416..48ba1f31e7c 100644
--- a/src/mame/drivers/hornet.c
+++ b/src/mame/drivers/hornet.c
@@ -332,8 +332,7 @@ static UINT32 jvs_sdata_ptr = 0;
static UINT32 *K037122_tile_ram[MAX_K037122_CHIPS];
static UINT32 *K037122_char_ram[MAX_K037122_CHIPS];
-static UINT8 *K037122_dirty_map[MAX_K037122_CHIPS];
-static int K037122_gfx_index[MAX_K037122_CHIPS], K037122_char_dirty[MAX_K037122_CHIPS];
+static int K037122_gfx_index[MAX_K037122_CHIPS];
static tilemap *K037122_layer[MAX_K037122_CHIPS][2];
static UINT32 *K037122_reg[MAX_K037122_CHIPS];
@@ -410,13 +409,6 @@ static TILE_GET_INFO( K037122_1_tile_info_layer1 )
SET_TILE_INFO(K037122_gfx_index[1], tile, color, flags);
}
-static STATE_POSTLOAD( K037122_postload )
-{
- int chip = (FPTR)param;
- K037122_char_dirty[chip] = 1;
- memset(K037122_dirty_map[chip], 1, K037122_NUM_TILES);
-}
-
static int K037122_vh_start(running_machine *machine, int chip)
{
for(K037122_gfx_index[chip] = 0; K037122_gfx_index[chip] < MAX_GFX_ELEMENTS; K037122_gfx_index[chip]++)
@@ -429,8 +421,6 @@ static int K037122_vh_start(running_machine *machine, int chip)
K037122_tile_ram[chip] = auto_malloc(0x20000);
- K037122_dirty_map[chip] = auto_malloc(K037122_NUM_TILES);
-
K037122_reg[chip] = auto_malloc(0x400);
if (chip == 0)
@@ -449,41 +439,17 @@ static int K037122_vh_start(running_machine *machine, int chip)
memset(K037122_char_ram[chip], 0, 0x200000);
memset(K037122_tile_ram[chip], 0, 0x20000);
- memset(K037122_dirty_map[chip], 0, K037122_NUM_TILES);
memset(K037122_reg[chip], 0, 0x400);
- machine->gfx[K037122_gfx_index[chip]] = allocgfx(machine, &K037122_char_layout);
- decodegfx(machine->gfx[K037122_gfx_index[chip]], (UINT8*)K037122_char_ram[chip], 0, machine->gfx[K037122_gfx_index[chip]]->total_elements);
-
- machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[K037122_gfx_index[chip]] = gfx_element_alloc(machine, &K037122_char_layout, (UINT8*)K037122_char_ram[chip], machine->config->total_colors / 16, 0);
state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_reg[chip], 0x400/sizeof(K037122_reg[chip][0]));
state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_char_ram[chip], 0x200000/sizeof(K037122_char_ram[chip][0]));
state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_tile_ram[chip], 0x20000/sizeof(K037122_tile_ram[chip][0]));
- state_save_register_postload(machine, K037122_postload, (void *)(FPTR)chip);
return 0;
}
-static void K037122_tile_update(running_machine *machine, int chip)
-{
- if (K037122_char_dirty[chip])
- {
- int i;
- for (i=0; i < K037122_NUM_TILES; i++)
- {
- if (K037122_dirty_map[chip][i])
- {
- K037122_dirty_map[chip][i] = 0;
- decodechar(machine->gfx[K037122_gfx_index[chip]], i, (UINT8 *)K037122_char_ram[chip]);
- }
- }
- tilemap_mark_all_tiles_dirty(K037122_layer[chip][0]);
- tilemap_mark_all_tiles_dirty(K037122_layer[chip][1]);
- K037122_char_dirty[chip] = 0;
- }
-}
-
static void K037122_tile_draw(running_machine *machine, int chip, bitmap_t *bitmap, const rectangle *cliprect)
{
const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
@@ -576,8 +542,7 @@ static WRITE32_HANDLER(K037122_char_w)
addr = offset + (bank * (0x40000/4));
COMBINE_DATA(K037122_char_ram[chip] + addr);
- K037122_dirty_map[chip][addr / 32] = 1;
- K037122_char_dirty[chip] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[K037122_gfx_index[chip]], addr / 32);
}
static READ32_HANDLER(K037122_reg_r)
@@ -629,7 +594,6 @@ static VIDEO_UPDATE( hornet )
voodoo_update(voodoo, bitmap, cliprect);
- K037122_tile_update(screen->machine, 0);
K037122_tile_draw(screen->machine, 0, bitmap, cliprect);
draw_7segment_led(bitmap, 3, 3, led_reg0);
@@ -645,7 +609,6 @@ static VIDEO_UPDATE( hornet_2board )
voodoo_update(voodoo, bitmap, cliprect);
/* TODO: tilemaps per screen */
- K037122_tile_update(screen->machine, 0);
K037122_tile_draw(screen->machine, 0, bitmap, cliprect);
}
else if (strcmp(screen->tag, "right") == 0)
@@ -654,7 +617,6 @@ static VIDEO_UPDATE( hornet_2board )
voodoo_update(voodoo, bitmap, cliprect);
/* TODO: tilemaps per screen */
- K037122_tile_update(screen->machine, 1);
K037122_tile_draw(screen->machine, 1, bitmap, cliprect);
}
diff --git a/src/mame/drivers/igs017.c b/src/mame/drivers/igs017.c
index daef5370309..57e6fdb3a56 100644
--- a/src/mame/drivers/igs017.c
+++ b/src/mame/drivers/igs017.c
@@ -173,6 +173,7 @@ static void draw_sprite(running_machine *machine, bitmap_t *bitmap,const rectang
{
// prepare GfxElement on the fly
gfx_element gfx;
+ UINT8 dirty = 0;
gfx.machine = machine;
gfx.width = dimx;
@@ -184,6 +185,7 @@ static void draw_sprite(running_machine *machine, bitmap_t *bitmap,const rectang
gfx.total_colors = 8;
gfx.pen_usage = NULL;
gfx.gfxdata = sprites_gfx + addr;
+ gfx.dirty = &dirty;
gfx.line_modulo = dimx;
gfx.char_modulo = 0; // doesn't matter
gfx.flags = 0;
diff --git a/src/mame/drivers/limenko.c b/src/mame/drivers/limenko.c
index d338e2ef761..24ab3b1abd0 100644
--- a/src/mame/drivers/limenko.c
+++ b/src/mame/drivers/limenko.c
@@ -246,7 +246,7 @@ static void draw_single_sprite(bitmap_t *dest_bmp,const gfx_element *gfx,
const rectangle *clip,int priority)
{
int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
@@ -316,7 +316,7 @@ static void draw_single_sprite(bitmap_t *dest_bmp,const gfx_element *gfx,
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(sprites_bitmap_pri, y, 0);
@@ -355,6 +355,7 @@ static void draw_sprites(running_machine *machine, UINT32 *sprites, const rectan
for(i = 0; i <= count*2; i += 2)
{
int x, width, flipx, y, height, flipy, code, color, pri;
+ UINT8 dirty = 0;
if(~sprites[i] & 0x80000000) continue;
@@ -394,6 +395,7 @@ static void draw_sprites(running_machine *machine, UINT32 *sprites, const rectan
gfx.line_modulo = width;
gfx.char_modulo = 0; /* doesn't matter */
gfx.flags = 0;
+ gfx.dirty = &dirty;
/* Bounds checking */
if ( (gfxdata + width * height - 1) >= gfx_max )
diff --git a/src/mame/drivers/madalien.c b/src/mame/drivers/madalien.c
index 0b3a88166ed..080f5fd7172 100644
--- a/src/mame/drivers/madalien.c
+++ b/src/mame/drivers/madalien.c
@@ -83,9 +83,9 @@ static WRITE8_HANDLER( madalien_portB_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x03ff) AM_RAM
- AM_RANGE(0x6000, 0x63ff) AM_RAM AM_BASE(&madalien_videoram)
+ AM_RANGE(0x6000, 0x63ff) AM_RAM_WRITE(madalien_videoram_w) AM_BASE(&madalien_videoram)
AM_RANGE(0x6400, 0x67ff) AM_RAM
- AM_RANGE(0x6800, 0x7fff) AM_RAM AM_BASE(&madalien_charram)
+ AM_RANGE(0x6800, 0x7fff) AM_RAM_WRITE(madalien_charram_w) AM_BASE(&madalien_charram)
AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x0ff0) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
AM_RANGE(0x8001, 0x8001) AM_MIRROR(0x0ff0) AM_DEVREADWRITE(MC6845, "crtc", mc6845_register_r, mc6845_register_w)
diff --git a/src/mame/drivers/mastboy.c b/src/mame/drivers/mastboy.c
index 6afd9cab155..53c61039137 100644
--- a/src/mame/drivers/mastboy.c
+++ b/src/mame/drivers/mastboy.c
@@ -460,6 +460,7 @@ static int mastboy_m5205_sambit0, mastboy_m5205_sambit1;
static VIDEO_START(mastboy)
{
+ gfx_element_set_source(machine->gfx[0], mastboy_vram);
}
static VIDEO_UPDATE(mastboy)
@@ -563,7 +564,7 @@ static WRITE8_HANDLER( banked_ram_w )
mastboy_vram[offs] = data^0xff;
/* Decode the new tile */
- decodechar(space->machine->gfx[0], offs/32, mastboy_vram);
+ gfx_element_mark_dirty(space->machine->gfx[0], offs/32);
}
}
else
diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c
index 15267624593..def24d3bfec 100644
--- a/src/mame/drivers/mediagx.c
+++ b/src/mame/drivers/mediagx.c
@@ -181,9 +181,9 @@ static VIDEO_START(mediagx)
static void draw_char(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y)
{
int i,j;
- UINT8 *dp;
+ const UINT8 *dp;
int index = 0;
- dp = gfx->gfxdata + ch * gfx->char_modulo;
+ dp = gfx_element_get_data(gfx, ch);
for (j=y; j < y+8; j++)
{
diff --git a/src/mame/drivers/mlanding.c b/src/mame/drivers/mlanding.c
index e2852ecf784..f47dcb082bd 100644
--- a/src/mame/drivers/mlanding.c
+++ b/src/mame/drivers/mlanding.c
@@ -17,7 +17,6 @@ static UINT16 * ml_spriteram;
static UINT16 * ml_unk;
static bitmap_t *ml_bitmap[8];
#define ML_CHARS 0x2000
-static UINT8 dirtychar[ML_CHARS];
static int status_bit;
static int adpcm_pos;
static int adpcm_data;
@@ -35,23 +34,10 @@ static const gfx_layout tiles8x8_layout =
32*8
};
-static void updateChars(running_machine *machine)
-{
- int i;
- for(i=0;i<ML_CHARS;i++)
- {
- if(dirtychar[i])
- {
- dirtychar[i]=0;
- decodechar(machine->gfx[0], i,(UINT8 *) ml_tileram);
- }
- }
-}
-
static WRITE16_HANDLER(ml_tileram_w)
{
COMBINE_DATA(&ml_tileram[offset]);
- dirtychar[offset>>4]=1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset>>4);
}
static READ16_HANDLER(ml_tileram_r)
@@ -200,10 +186,8 @@ ADDRESS_MAP_END
static VIDEO_START(mlanding)
{
int i;
- for(i=0;i<ML_CHARS;i++)
- {
- dirtychar[i]=0;
- }
+
+ gfx_element_set_source(machine->gfx[0], (UINT8 *) ml_tileram);
for (i=0;i<8;i++)
ml_bitmap[i] = video_screen_auto_bitmap_alloc(machine->primary_screen);
@@ -213,8 +197,6 @@ static VIDEO_UPDATE(mlanding)
{
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
- updateChars(screen->machine);
-
{
int i,dx,dy,j,k,num;
for(i=0;i<0x1000;i+=4)
diff --git a/src/mame/drivers/mogura.c b/src/mame/drivers/mogura.c
index 64445426cdd..ba25e30dd61 100644
--- a/src/mame/drivers/mogura.c
+++ b/src/mame/drivers/mogura.c
@@ -55,6 +55,7 @@ static TILE_GET_INFO( get_mogura_tile_info )
static VIDEO_START( mogura )
{
+ gfx_element_set_source(machine->gfx[0], mogura_gfxram);
mogura_tilemap = tilemap_create(machine, get_mogura_tile_info,tilemap_scan_rows,8,8,64, 32);
}
@@ -110,9 +111,7 @@ static WRITE8_HANDLER ( mogura_gfxram_w )
{
mogura_gfxram[offset] = data ;
- decodechar(space->machine->gfx[0], offset/16, mogura_gfxram);
-
- tilemap_mark_all_tiles_dirty(mogura_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
}
diff --git a/src/mame/drivers/mpu4drvr.c b/src/mame/drivers/mpu4drvr.c
index 03ddee96b35..84626b2fafd 100644
--- a/src/mame/drivers/mpu4drvr.c
+++ b/src/mame/drivers/mpu4drvr.c
@@ -212,7 +212,6 @@ static UINT8 m6809_acia_dcd;
/* SCN2674 AVDC stuff */
static int mpu4_gfx_index;
static UINT16 * mpu4_vid_vidram;
-static UINT8 * mpu4_vid_vidram_is_dirty;
static UINT16 * mpu4_vid_mainram;
static UINT8 scn2674_IR[16];
@@ -452,18 +451,6 @@ static VIDEO_UPDATE( mpu4_vid )
bitmap_fill(bitmap,cliprect,0);
- for (i = 0; i < 0x1000; i++)
- {
- if (mpu4_vid_vidram_is_dirty[i]==1)
- {
- decodechar(screen->machine->gfx[mpu4_gfx_index+0], i, (UINT8 *)mpu4_vid_vidram);
- decodechar(screen->machine->gfx[mpu4_gfx_index+1], i, (UINT8 *)mpu4_vid_vidram);
- decodechar(screen->machine->gfx[mpu4_gfx_index+2], i, (UINT8 *)mpu4_vid_vidram);
- decodechar(screen->machine->gfx[mpu4_gfx_index+3], i, (UINT8 *)mpu4_vid_vidram);
- mpu4_vid_vidram_is_dirty[i]=0;
- }
- }
-
/* this is in main ram.. i think it must transfer it out of here??? */
/* count = 0x0018b6/2; - crmaze count = 0x004950/2; - turnover */
@@ -517,7 +504,10 @@ static WRITE16_HANDLER( mpu4_vid_vidram_w )
{
COMBINE_DATA(&mpu4_vid_vidram[offset]);
offset <<= 1;
- mpu4_vid_vidram_is_dirty[offset/0x20]=1;
+ gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+0], offset/0x20);
+ gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+1], offset/0x20);
+ gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+2], offset/0x20);
+ gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+3], offset/0x20);
}
@@ -983,9 +973,7 @@ static VIDEO_START( mpu4_vid )
maybe we will anyway, but for now we don't need to */
mpu4_vid_vidram = auto_malloc (0x20000);
- mpu4_vid_vidram_is_dirty = auto_malloc(0x1000);
- memset(mpu4_vid_vidram_is_dirty,1,0x1000);
memset(mpu4_vid_vidram,0,0x20000);
/* find first empty slot to decode gfx */
@@ -996,16 +984,10 @@ static VIDEO_START( mpu4_vid )
assert(mpu4_gfx_index != MAX_GFX_ELEMENTS);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[mpu4_gfx_index+0] = allocgfx(machine, &mpu4_vid_char_8x8_layout);
- machine->gfx[mpu4_gfx_index+1] = allocgfx(machine, &mpu4_vid_char_8x16_layout);
- machine->gfx[mpu4_gfx_index+2] = allocgfx(machine, &mpu4_vid_char_16x8_layout);
- machine->gfx[mpu4_gfx_index+3] = allocgfx(machine, &mpu4_vid_char_16x16_layout);
-
- /* set the color information */
- machine->gfx[mpu4_gfx_index+0]->total_colors = machine->config->total_colors / 16;
- machine->gfx[mpu4_gfx_index+1]->total_colors = machine->config->total_colors / 16;
- machine->gfx[mpu4_gfx_index+2]->total_colors = machine->config->total_colors / 16;
- machine->gfx[mpu4_gfx_index+3]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[mpu4_gfx_index+0] = gfx_element_alloc(machine, &mpu4_vid_char_8x8_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
+ machine->gfx[mpu4_gfx_index+1] = gfx_element_alloc(machine, &mpu4_vid_char_8x16_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
+ machine->gfx[mpu4_gfx_index+2] = gfx_element_alloc(machine, &mpu4_vid_char_16x8_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
+ machine->gfx[mpu4_gfx_index+3] = gfx_element_alloc(machine, &mpu4_vid_char_16x16_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
scn2675_IR_pointer = 0;
}
diff --git a/src/mame/drivers/namcoic.c b/src/mame/drivers/namcoic.c
index c6d1de6ef56..5cbc4162a27 100644
--- a/src/mame/drivers/namcoic.c
+++ b/src/mame/drivers/namcoic.c
@@ -278,7 +278,7 @@ static void zdrawgfxzoom(running_machine *machine,
{
int shadow_offset = (machine->config->video_attributes&VIDEO_HAS_SHADOWS)?machine->config->total_colors:0;
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
if (sprite_screen_width && sprite_screen_height)
@@ -348,7 +348,7 @@ static void zdrawgfxzoom(running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
int x, x_index = x_index_base;
@@ -470,25 +470,23 @@ namcos2_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle
int scaley = (sizey<<16)/((word0&0x0200)?0x20:0x10);
if(scalex && scaley)
{
- gfx_element gfx = *machine->gfx[rgn];
+ gfx_element *gfx = machine->gfx[rgn];
+
if( (word0&0x0200)==0 )
- {
- gfx.width = 16;
- gfx.height = 16;
- if( word1&0x0001 ) gfx.gfxdata += 16;
- if( word1&0x0002 ) gfx.gfxdata += 16*gfx.line_modulo;
- }
+ gfx_element_set_source_clip(gfx, (word1&0x0001) ? 16 : 0, 16, (word1&0x0002) ? 16 : 0, 16);
+ else
+ gfx_element_set_source_clip(gfx, 0, 32, 0, 32);
+
zdrawgfxzoom(
machine,
bitmap,
- &gfx,
+ gfx,
sprn,
color,
flipx,flipy,
xpos,ypos,
cliprect,
TRANSPARENCY_PEN,0xff,
- //(color==0x0f ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN),0xff,
scalex,scaley,
loop );
}
@@ -1508,8 +1506,6 @@ WRITE32_HANDLER( namco_rozvideoram32_le_w )
* 0x1fffd always 0xffff 0xffff?
*/
static UINT16 *mpRoadRAM; /* at 0x880000 in Final Lap; at 0xa00000 in Lucky&Wild */
-static UINT8 *mpRoadDirty;
-static int mbRoadSomethingIsDirty;
static int mRoadGfxBank;
static tilemap *mpRoadTilemap;
static pen_t mRoadTransparentColor;
@@ -1572,70 +1568,29 @@ WRITE16_HANDLER( namco_road16_w )
else
{
offset -= 0x10000/2;
- if( offset<ROAD_TILE_COUNT_MAX*WORDS_PER_ROAD_TILE )
- {
- mpRoadDirty[offset/WORDS_PER_ROAD_TILE] = 1;
- mbRoadSomethingIsDirty = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[mRoadGfxBank], offset/WORDS_PER_ROAD_TILE);
}
}
-static void
-UpdateRoad(running_machine *machine)
-{
- int i;
- if( mbRoadSomethingIsDirty )
- {
- for( i=0; i<ROAD_TILE_COUNT_MAX; i++ )
- {
- if( mpRoadDirty[i] )
- {
- decodechar(
- machine->gfx[mRoadGfxBank],
- i,
- 0x10000+(UINT8 *)mpRoadRAM);
- mpRoadDirty[i] = 0;
- }
- }
- tilemap_mark_all_tiles_dirty( mpRoadTilemap );
- mbRoadSomethingIsDirty = 0;
- }
-}
-
-static STATE_POSTLOAD( RoadMarkAllDirty )
-{
- memset( mpRoadDirty,0x01,ROAD_TILE_COUNT_MAX );
- mbRoadSomethingIsDirty = 1;
-}
-
void
namco_road_init(running_machine *machine, int gfxbank )
{
+ gfx_element *pGfx;
+
mbRoadNeedTransparent = 0;
mRoadGfxBank = gfxbank;
- mpRoadDirty = auto_malloc(ROAD_TILE_COUNT_MAX);
- {
- memset( mpRoadDirty,0x00,ROAD_TILE_COUNT_MAX );
- mbRoadSomethingIsDirty = 0;
- mpRoadRAM = auto_malloc(0x20000);
- {
- gfx_element *pGfx = allocgfx( machine, &RoadTileLayout );
- decodegfx(pGfx, 0x10000+(UINT8 *)mpRoadRAM, 0, pGfx->total_elements);
- pGfx->color_base = 0xf00;
- pGfx->total_colors = 0x3f;
- machine->gfx[gfxbank] = pGfx;
- mpRoadTilemap = tilemap_create(machine,
- get_road_info,tilemap_scan_rows,
- ROAD_TILE_SIZE,ROAD_TILE_SIZE,
- ROAD_COLS,ROAD_ROWS);
+ mpRoadRAM = auto_malloc(0x20000);
- state_save_register_global_pointer(machine, mpRoadDirty, ROAD_TILE_COUNT_MAX);
- state_save_register_global_pointer(machine, mpRoadRAM, 0x20000 / 2);
- state_save_register_postload(machine, RoadMarkAllDirty, NULL);
+ pGfx = gfx_element_alloc( machine, &RoadTileLayout, 0x10000+(UINT8 *)mpRoadRAM, 0x3f, 0xf00);
- }
- }
+ machine->gfx[gfxbank] = pGfx;
+ mpRoadTilemap = tilemap_create(machine,
+ get_road_info,tilemap_scan_rows,
+ ROAD_TILE_SIZE,ROAD_TILE_SIZE,
+ ROAD_COLS,ROAD_ROWS);
+
+ state_save_register_global_pointer(machine, mpRoadRAM, 0x20000 / 2);
} /* namco_road_init */
void
@@ -1653,8 +1608,6 @@ namco_road_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cli
unsigned yscroll;
int i;
- UpdateRoad(machine);
-
pSourceBitmap = tilemap_get_pixmap(mpRoadTilemap);
yscroll = mpRoadRAM[0x1fdfe/2];
diff --git a/src/mame/drivers/namcos23.c b/src/mame/drivers/namcos23.c
index 437c11507bb..25b7477bc1a 100644
--- a/src/mame/drivers/namcos23.c
+++ b/src/mame/drivers/namcos23.c
@@ -775,6 +775,7 @@ static WRITE32_HANDLER( namcos23_textram_w )
static VIDEO_START( ss23 )
{
+ gfx_element_set_source(machine->gfx[0], (UINT8 *)namcos23_charram);
bgtilemap = tilemap_create(machine, TextTilemapGetInfo, tilemap_scan_rows, 16, 16, 64, 64);
tilemap_set_transparent_pen(bgtilemap, 0xf);
}
@@ -936,11 +937,8 @@ static VIDEO_UPDATE( gorgon )
static WRITE32_HANDLER( s23_txtchar_w )
{
- COMBINE_DATA(&namcos23_charram[offset] );
-
- decodechar( space->machine->gfx[0],offset/32,(UINT8 *)namcos23_charram );
-
- tilemap_mark_all_tiles_dirty(bgtilemap);
+ COMBINE_DATA(&namcos23_charram[offset]);
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/32);
}
static READ32_HANDLER( ss23_vstat_r )
diff --git a/src/mame/drivers/nemesis.c b/src/mame/drivers/nemesis.c
index 74030937950..497cbafbe8e 100644
--- a/src/mame/drivers/nemesis.c
+++ b/src/mame/drivers/nemesis.c
@@ -1918,7 +1918,7 @@ INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8, /* 8*8 characters */
- 2048+1, /* 2048 characters (+ blank one) */
+ 2048, /* 2048 characters (+ blank one) */
4, /* 4 bits per pixel */
{ 0, 1, 2, 3 }, /* the two bitplanes are merged in the same nibble */
{ XOR(0*4), XOR(1*4), XOR(2*4), XOR(3*4), XOR(4*4), XOR(5*4), XOR(6*4), XOR(7*4) },
diff --git a/src/mame/drivers/nwk-tr.c b/src/mame/drivers/nwk-tr.c
index 369717897fb..78b21f3de3a 100644
--- a/src/mame/drivers/nwk-tr.c
+++ b/src/mame/drivers/nwk-tr.c
@@ -243,8 +243,7 @@ static WRITE32_HANDLER( paletteram32_w )
static UINT32 *K001604_tile_ram[MAX_K001604_CHIPS];
static UINT32 *K001604_char_ram[MAX_K001604_CHIPS];
-static UINT8 *K001604_dirty_map[MAX_K001604_CHIPS][2];
-static int K001604_gfx_index[MAX_K001604_CHIPS][2], K001604_char_dirty[MAX_K001604_CHIPS][2];
+static int K001604_gfx_index[MAX_K001604_CHIPS][2];
static tilemap *K001604_layer_8x8[MAX_K001604_CHIPS][2];
static int K001604_tilemap_offset;
static tilemap *K001604_layer_roz[MAX_K001604_CHIPS][2];
@@ -422,9 +421,6 @@ int K001604_vh_start(running_machine *machine, int chip)
K001604_tile_ram[chip] = auto_malloc(0x20000);
- K001604_dirty_map[chip][0] = auto_malloc(K001604_NUM_TILES_LAYER0);
- K001604_dirty_map[chip][1] = auto_malloc(K001604_NUM_TILES_LAYER1);
-
K001604_reg[chip] = auto_malloc(0x400);
if (chip == 0)
@@ -453,66 +449,15 @@ int K001604_vh_start(running_machine *machine, int chip)
memset(K001604_char_ram[chip], 0, 0x200000);
memset(K001604_tile_ram[chip], 0, 0x10000);
- memset(K001604_dirty_map[chip][0], 0, K001604_NUM_TILES_LAYER0);
- memset(K001604_dirty_map[chip][1], 0, K001604_NUM_TILES_LAYER1);
memset(K001604_reg[chip], 0, 0x400);
- machine->gfx[K001604_gfx_index[chip][0]] = allocgfx(machine, &K001604_char_layout_layer_8x8);
- decodegfx(machine->gfx[K001604_gfx_index[chip][0]], (UINT8*)&K001604_char_ram[chip][0], 0, machine->gfx[K001604_gfx_index[chip][0]]->total_elements);
- machine->gfx[K001604_gfx_index[chip][1]] = allocgfx(machine, &K001604_char_layout_layer_16x16);
- decodegfx(machine->gfx[K001604_gfx_index[chip][1]], (UINT8*)&K001604_char_ram[chip][0], 0, machine->gfx[K001604_gfx_index[chip][1]]->total_elements);
-
- machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->config->total_colors / 16;
- machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[K001604_gfx_index[chip][0]] = gfx_element_alloc(machine, &K001604_char_layout_layer_8x8, (UINT8*)&K001604_char_ram[chip][0], machine->config->total_colors / 16, 0);
+ machine->gfx[K001604_gfx_index[chip][1]] = gfx_element_alloc(machine, &K001604_char_layout_layer_16x16, (UINT8*)&K001604_char_ram[chip][0], machine->config->total_colors / 16, 0);
return 0;
}
-void K001604_tile_update(running_machine *machine, int chip)
-{
- if(K001604_char_dirty[chip][0])
- {
- int i;
- for (i=0; i < K001604_NUM_TILES_LAYER0; i++)
- {
- if(K001604_dirty_map[chip][0][i])
- {
- K001604_dirty_map[chip][0][i] = 0;
- decodechar(machine->gfx[K001604_gfx_index[chip][0]], i, (UINT8*)&K001604_char_ram[chip][0]);
- }
- }
- tilemap_mark_all_tiles_dirty(K001604_layer_8x8[chip][0]);
- tilemap_mark_all_tiles_dirty(K001604_layer_8x8[chip][1]);
-
- if (K001604_roz_size[chip] == 0)
- {
- tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][0]);
- tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][1]);
- }
- K001604_char_dirty[chip][0] = 0;
- }
- if(K001604_char_dirty[chip][1])
- {
- int i;
- for (i=0; i < K001604_NUM_TILES_LAYER1; i++)
- {
- if(K001604_dirty_map[chip][1][i])
- {
- K001604_dirty_map[chip][1][i] = 0;
- decodechar(machine->gfx[K001604_gfx_index[chip][1]], i, (UINT8*)&K001604_char_ram[chip][0]);
- }
- }
-
- if (K001604_roz_size[chip] == 1)
- {
- tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][0]);
- tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][1]);
- }
- K001604_char_dirty[chip][1] = 0;
- }
-}
-
void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect)
{
int layer;
@@ -659,11 +604,8 @@ WRITE32_HANDLER(K001604_char_w)
COMBINE_DATA(K001604_char_ram[chip] + addr);
- K001604_dirty_map[chip][0][addr / 32] = 1;
- K001604_char_dirty[chip][0] = 1;
-
- K001604_dirty_map[chip][1][addr / 128] = 1;
- K001604_char_dirty[chip][1] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[K001604_gfx_index[chip][0]], addr / 32);
+ gfx_element_mark_dirty(space->machine->gfx[K001604_gfx_index[chip][1]], addr / 128);
}
@@ -724,7 +666,6 @@ static VIDEO_UPDATE( nwktr )
voodoo_update(voodoo, bitmap, cliprect);
- K001604_tile_update(screen->machine, 0);
K001604_draw_front_layer(0, bitmap, cliprect);
draw_7segment_led(bitmap, 3, 3, led_reg0);
diff --git a/src/mame/drivers/polyplay.c b/src/mame/drivers/polyplay.c
index c8609f52c95..9137e6d3d06 100644
--- a/src/mame/drivers/polyplay.c
+++ b/src/mame/drivers/polyplay.c
@@ -298,6 +298,7 @@ static MACHINE_DRIVER_START( polyplay )
MDRV_PALETTE_LENGTH(10)
MDRV_PALETTE_INIT(polyplay)
+ MDRV_VIDEO_START(polyplay)
MDRV_VIDEO_UPDATE(polyplay)
/* sound hardware */
diff --git a/src/mame/drivers/relief.c b/src/mame/drivers/relief.c
index 8627ba4c006..f10d7c32513 100644
--- a/src/mame/drivers/relief.c
+++ b/src/mame/drivers/relief.c
@@ -294,34 +294,33 @@ INPUT_PORTS_END
*
*************************************/
-static const gfx_layout pfmolayout =
+static const gfx_layout pflayout =
{
8,8,
- RGN_FRAC(1,4),
+ RGN_FRAC(1,5),
4,
- { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4), RGN_FRAC(0,4) },
- { 0, 1, 2, 3, 4, 5, 6, 7 },
- { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
+ { RGN_FRAC(3,5), RGN_FRAC(2,5), RGN_FRAC(1,5), RGN_FRAC(0,5) },
+ { STEP8(0,1) },
+ { STEP8(0,16) },
16*8
};
-static const gfx_layout moexlayout =
+static const gfx_layout molayout =
{
8,8,
- RGN_FRAC(1,1),
+ RGN_FRAC(1,5),
5,
- { 0, 0, 0, 0, 0 },
- { 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
+ { RGN_FRAC(4,5), RGN_FRAC(3,5), RGN_FRAC(2,5), RGN_FRAC(1,5), RGN_FRAC(0,5) },
+ { STEP8(0,1) },
+ { STEP8(0,16) },
+ 16*8
};
static GFXDECODE_START( relief )
- GFXDECODE_ENTRY( "gfx1", 0, pfmolayout, 0, 64 ) /* alpha & playfield */
- GFXDECODE_ENTRY( "gfx1", 1, pfmolayout, 256, 16 ) /* sprites */
- GFXDECODE_ENTRY( "gfx2", 0, moexlayout, 256, 16 ) /* extra sprite bit */
+ GFXDECODE_ENTRY( "gfx1", 0, pflayout, 0, 64 ) /* alpha & playfield */
+ GFXDECODE_ENTRY( "gfx1", 1, molayout, 256, 16 ) /* sprites */
GFXDECODE_END
@@ -381,14 +380,12 @@ ROM_START( relief )
ROM_LOAD16_BYTE( "136093-0013.17e", 0x40000, 0x20000, CRC(1e1e82e5) SHA1(d33c84ae950db9775f9db9bf953aa63188d3f2f9) )
ROM_LOAD16_BYTE( "136093-0014.17j", 0x40001, 0x20000, CRC(19e5decd) SHA1(8d93d93f966df46d59cf9f4cdaa689e4dcd2689a) )
- ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
- ROM_LOAD( "136093-0025a.14s", 0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
- ROM_LOAD( "136093-0026a.8d", 0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
- ROM_LOAD( "136093-0027a.18s", 0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
- ROM_LOAD( "136093-0028a.10d", 0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
-
- ROM_REGION( 0x040000, "gfx2", ROMREGION_DISPOSE | ROMREGION_INVERT )
- ROM_LOAD( "136093-0029a.4d", 0x000000, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
+ ROM_REGION( 0x280000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
+ ROM_LOAD( "136093-0025a.14s", 0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
+ ROM_LOAD( "136093-0026a.8d", 0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
+ ROM_LOAD( "136093-0027a.18s", 0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
+ ROM_LOAD( "136093-0028a.10d", 0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
+ ROM_LOAD16_BYTE( "136093-0029a.4d", 0x200001, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
ROM_REGION( 0x200000, "oki", 0 ) /* 2MB for ADPCM data */
ROM_LOAD( "136093-0030a.9b", 0x100000, 0x80000, CRC(f4c567f5) SHA1(7e8c1d54d918b0b41625eacbaf6dcb5bd99d1949) )
@@ -412,14 +409,12 @@ ROM_START( relief2 )
ROM_LOAD16_BYTE( "136093-0013.17e", 0x40000, 0x20000, CRC(1e1e82e5) SHA1(d33c84ae950db9775f9db9bf953aa63188d3f2f9) )
ROM_LOAD16_BYTE( "136093-0014.17j", 0x40001, 0x20000, CRC(19e5decd) SHA1(8d93d93f966df46d59cf9f4cdaa689e4dcd2689a) )
- ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
- ROM_LOAD( "136093-0025a.14s", 0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
- ROM_LOAD( "136093-0026a.8d", 0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
- ROM_LOAD( "136093-0027a.18s", 0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
- ROM_LOAD( "136093-0028a.10d", 0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
-
- ROM_REGION( 0x040000, "gfx2", ROMREGION_DISPOSE | ROMREGION_INVERT )
- ROM_LOAD( "136093-0029.4d", 0x000000, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
+ ROM_REGION( 0x280000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
+ ROM_LOAD( "136093-0025a.14s", 0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
+ ROM_LOAD( "136093-0026a.8d", 0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
+ ROM_LOAD( "136093-0027a.18s", 0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
+ ROM_LOAD( "136093-0028a.10d", 0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
+ ROM_LOAD16_BYTE( "136093-0029.4d", 0x200001, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
ROM_REGION( 0x200000, "oki", 0 ) /* 2MB for ADPCM data */
ROM_LOAD( "136093-0030a.9b", 0x100000, 0x80000, CRC(f4c567f5) SHA1(7e8c1d54d918b0b41625eacbaf6dcb5bd99d1949) )
diff --git a/src/mame/drivers/srmp6.c b/src/mame/drivers/srmp6.c
index 5aad047feb4..483a37f246f 100644
--- a/src/mame/drivers/srmp6.c
+++ b/src/mame/drivers/srmp6.c
@@ -72,7 +72,6 @@ Dumped 06/15/2000
#include "sound/nile.h"
static UINT16* tileram;
-static UINT8* dirty_tileram;
static UINT16* dmaram;
static UINT16 *sprram, *sprram_old;
@@ -127,40 +126,20 @@ static void update_palette(running_machine *machine)
static VIDEO_START(srmp6)
{
- /* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[0] = allocgfx(machine, &tiles8x8_layout);
- machine->gfx[0]->total_colors = machine->config->total_colors / 256;
- machine->gfx[0]->color_granularity=256;
-
tileram = auto_malloc(0x100000*16);
- dirty_tileram = auto_malloc((0x100000*16)/0x40); // every 8x8x8 tile is 0x40 bytes
-
memset(tileram,0x00,(0x100000*16));
- memset(dirty_tileram,1,(0x100000*16)/0x40);
dmaram = auto_malloc(0x100);
sprram_old = auto_malloc(0x80000);
memset(sprram_old, 0, 0x80000);
- brightness = 0x60;
-}
+ /* create the char set (gfx will then be updated dynamically from RAM) */
+ machine->gfx[0] = gfx_element_alloc(machine, &tiles8x8_layout, (UINT8*)tileram, machine->config->total_colors / 256, 0);
+ machine->gfx[0]->color_granularity=256;
-/* Debug code */
-#ifdef UNUSED_FUNCTION
-static void srmp6_decode_charram(running_machine *machine)
-{
- if(input_code_pressed_once(KEYCODE_Z))
- {
- int i;
- for (i=0;i<(0x100000*16)/0x40;i++)
- {
- decodechar(machine->gfx[0], i, (UINT8*)tileram);
- dirty_tileram[i] = 0;
- }
- }
+ brightness = 0x60;
}
-#endif
#if 0
static int xixi=0;
@@ -168,7 +147,7 @@ static int xixi=0;
static VIDEO_UPDATE(srmp6)
{
- int trans = TRANSPARENCY_PEN;
+ int alpha;
int x,y,tileno,height,width,xw,yw,sprite,xb,yb;
UINT16 *sprite_list=sprram_old;
UINT16 mainlist_offset = 0;
@@ -183,11 +162,6 @@ static VIDEO_UPDATE(srmp6)
#if 0
/* debug */
- srmp6_decode_charram(screen->machine);
-
-
-
- /* debug */
if(input_code_pressed_once(KEYCODE_Q))
{
++xixi;
@@ -226,13 +200,11 @@ static VIDEO_UPDATE(srmp6)
if((sprite_list[mainlist_offset+5] & 0x700) == 0x700)
{
- trans = TRANSPARENCY_ALPHA;
- alpha_set_level((sprite_list[mainlist_offset+5] & 0x1F) << 3);
+ alpha = (sprite_list[mainlist_offset+5] & 0x1F) << 3;
}
else
{
- trans = TRANSPARENCY_PEN;
- alpha_set_level(255);
+ alpha = 255;
}
// printf("%x %x \n",sprite_list[mainlist_offset+1],sublist_length);
@@ -273,13 +245,7 @@ static VIDEO_UPDATE(srmp6)
else
yb=y+(height-yw-1)*8+global_y;
- if (dirty_tileram[tileno])
- {
- decodechar(screen->machine->gfx[0], tileno, (UINT8*)tileram);
- dirty_tileram[tileno] = 0;
- }
-
- drawgfx(bitmap,screen->machine->gfx[0],tileno,global_pal,flip_x,flip_y,xb,yb,cliprect,trans,0);
+ drawgfx_alpha(bitmap,cliprect,screen->machine->gfx[0],tileno,global_pal,flip_x,flip_y,xb,yb,0,alpha);
tileno++;
}
}
@@ -384,7 +350,7 @@ static unsigned short lastb;
static unsigned short lastb2;
static int destl;
-static UINT32 process(UINT8 b,UINT32 dst_offset)
+static UINT32 process(running_machine *machine,UINT8 b,UINT32 dst_offset)
{
int l=0;
@@ -399,7 +365,7 @@ static UINT32 process(UINT8 b,UINT32 dst_offset)
for(i=0;i<rle;++i)
{
tram[dst_offset+destl] = lastb;
- dirty_tileram[(dst_offset+destl)/0x40] = 1;
+ gfx_element_mark_dirty(machine->gfx[0], (dst_offset+destl)/0x40);
dst_offset++;
++l;
@@ -413,7 +379,7 @@ static UINT32 process(UINT8 b,UINT32 dst_offset)
lastb2=lastb;
lastb=b;
tram[dst_offset+destl] = b;
- dirty_tileram[(dst_offset+destl)/0x40] = 1;
+ gfx_element_mark_dirty(machine->gfx[0], (dst_offset+destl)/0x40);
return 1;
}
@@ -467,13 +433,13 @@ static WRITE16_HANDLER(srmp6_dma_w)
{
UINT8 real_byte;
real_byte = rom[srctab+p*2];
- tempidx+=process(real_byte,tempidx);
+ tempidx+=process(space->machine,real_byte,tempidx);
real_byte = rom[srctab+p*2+1];//px[DMA_XOR((current_table_address+p*2+1))];
- tempidx+=process(real_byte,tempidx);
+ tempidx+=process(space->machine,real_byte,tempidx);
}
else
{
- tempidx+=process(p,tempidx);
+ tempidx+=process(space->machine,p,tempidx);
}
ctrl<<=1;
diff --git a/src/mame/drivers/ssv.c b/src/mame/drivers/ssv.c
index e5875e35e02..1f3ef26188c 100644
--- a/src/mame/drivers/ssv.c
+++ b/src/mame/drivers/ssv.c
@@ -536,9 +536,7 @@ static WRITE16_HANDLER( gdfs_gfxram_w )
{
offset += gdfs_gfxram_bank * 0x100000/2;
COMBINE_DATA(&eaglshot_gfxram[offset]);
-
- eaglshot_dirty = 1;
- eaglshot_dirty_tile[offset / (16*8/2)] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[2], offset / (16*8/2));
}
static READ16_HANDLER( gdfs_blitram_r )
@@ -588,14 +586,17 @@ static WRITE16_HANDLER( gdfs_blitram_w )
if ( (src+len <= size) && (dst+len <= 4 * 0x100000) )
{
- eaglshot_dirty = 1;
-
memcpy( &eaglshot_gfxram[dst/2], &rom[src], len );
if (len % (16*8)) len = len / (16*8) + 1;
else len = len / (16*8);
- memset( &eaglshot_dirty_tile[dst / (16*8)], 1, len );
+ dst /= 16*8;
+ while (len--)
+ {
+ gfx_element_mark_dirty(space->machine->gfx[2], dst);
+ dst++;
+ }
}
else
{
@@ -1101,9 +1102,8 @@ static WRITE16_HANDLER( eaglshot_gfxram_w )
{
offset += (ssv_scroll[0x76/2] & 0xf) * 0x40000/2;
COMBINE_DATA(&eaglshot_gfxram[offset]);
-
- eaglshot_dirty = 1;
- eaglshot_dirty_tile[offset / (16*8/2)] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset / (16*8/2));
+ gfx_element_mark_dirty(space->machine->gfx[1], offset / (16*8/2));
}
@@ -2716,7 +2716,6 @@ static void init_ssv(void)
ssv_enable_video(1);
ssv_special = 0;
interrupt_ultrax = 0;
- eaglshot_dirty = 0;
}
static void init_ssv_hypreac2(void)
diff --git a/src/mame/drivers/stv.c b/src/mame/drivers/stv.c
index 7117bd2e95d..469a91cd3a9 100644
--- a/src/mame/drivers/stv.c
+++ b/src/mame/drivers/stv.c
@@ -2426,18 +2426,18 @@ static const gfx_layout tiles16x16x4_layout =
static const gfx_layout tiles8x8x8_layout =
{
8,8,
- 0x100000/(64*8/8),
+ 0x100000/(32*8/8),
8,
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0, 8, 16, 24, 32, 40, 48, 56 },
{ 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 },
- 64*8
+ 32*8 /* really 64*8, but granularity is 32 bytes */
};
static const gfx_layout tiles16x16x8_layout =
{
16,16,
- 0x100000/(128*16/8),
+ 0x100000/(64*16/8),
8,
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0, 8, 16, 24, 32, 40, 48, 56,
@@ -2447,7 +2447,7 @@ static const gfx_layout tiles16x16x8_layout =
{ 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
64*16, 64*17, 64*18, 64*19, 64*20, 64*21, 64*22, 64*23
},
- 128*16
+ 64*16 /* really 128*16, but granularity is 32 bytes */
};
diff --git a/src/mame/drivers/suprnova.c b/src/mame/drivers/suprnova.c
index 1ac9476c097..9d1d00c3326 100644
--- a/src/mame/drivers/suprnova.c
+++ b/src/mame/drivers/suprnova.c
@@ -195,10 +195,6 @@ UINT32 *skns_tilemapA_ram, *skns_tilemapB_ram, *skns_v3slc_ram;
UINT32 *skns_palette_ram;
UINT32 *skns_pal_regs, *skns_v3_regs, *skns_spc_regs;
-UINT32 skns_v3t_dirty[0x4000]; // allocate this elsewhere?
-UINT32 skns_v3t_4bppdirty[0x8000]; // allocate this elsewhere?
-int skns_v3t_somedirty,skns_v3t_4bpp_somedirty;
-
static UINT32 *skns_v3t_ram, *skns_main_ram, *skns_cache_ram;
/* hit.c */
@@ -755,10 +751,8 @@ static WRITE32_HANDLER( skns_v3t_w )
COMBINE_DATA(&skns_v3t_ram[offset]);
- skns_v3t_dirty[offset/0x40] = 1;
- skns_v3t_somedirty = 1;
- skns_v3t_4bppdirty[offset/0x20] = 1;
- skns_v3t_4bpp_somedirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/0x40);
+ gfx_element_mark_dirty(space->machine->gfx[3], offset/0x20);
data = skns_v3t_ram[offset];
// i think we need to swap around to decode .. endian issues?
diff --git a/src/mame/drivers/taito_l.c b/src/mame/drivers/taito_l.c
index 54cb27e2b50..ad1665ebbb4 100644
--- a/src/mame/drivers/taito_l.c
+++ b/src/mame/drivers/taito_l.c
@@ -60,22 +60,26 @@ puzznici note
#include "includes/taito_l.h"
-static void (*const rambank_modify_notifiers[12])(running_machine *, int) =
-{
- taitol_chardef14_m, // 14
- taitol_chardef15_m, // 15
- taitol_chardef16_m, // 16
- taitol_chardef17_m, // 17
-
- taitol_bg18_m, // 18
- taitol_bg19_m, // 19
- taitol_char1a_m, // 1a
- taitol_obj1b_m, // 1b
-
- taitol_chardef1c_m, // 1c
- taitol_chardef1d_m, // 1d
- taitol_chardef1e_m, // 1e
- taitol_chardef1f_m, // 1f
+static const struct
+{
+ void (*notifier)(running_machine *, int);
+ UINT32 offset;
+} rambank_modify_notifiers[12] =
+{
+ { taitol_chardef14_m, 0x0000 }, // 14
+ { taitol_chardef15_m, 0x1000 }, // 15
+ { taitol_chardef16_m, 0x2000 }, // 16
+ { taitol_chardef17_m, 0x3000 }, // 17
+
+ { taitol_bg18_m, 0x8000 }, // 18
+ { taitol_bg19_m, 0x9000 }, // 19
+ { taitol_char1a_m, 0xa000 }, // 1a
+ { taitol_obj1b_m, 0xb000 }, // 1b
+
+ { taitol_chardef1c_m, 0x4000 }, // 1c
+ { taitol_chardef1d_m, 0x5000 }, // 1d
+ { taitol_chardef1e_m, 0x6000 }, // 1e
+ { taitol_chardef1f_m, 0x7000 }, // 1f
};
static void (*current_notifier[4])(running_machine *, int);
@@ -152,11 +156,7 @@ static void machine_init(running_machine *machine)
cur_rombank = cur_rombank2 = 0;
memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x10000);
- for(i=0;i<512;i++)
- {
- decodechar(machine->gfx[2], i, taitol_rambanks);
- decodechar(machine->gfx[2], i+512, taitol_rambanks + 0x4000);
- }
+ gfx_element_set_source(machine->gfx[2], taitol_rambanks);
adpcm_pos = 0;
adpcm_data = -1;
@@ -377,8 +377,8 @@ static WRITE8_HANDLER( rambankswitch_w )
if(data>=0x14 && data<=0x1f)
{
data -= 0x14;
- current_notifier[offset] = rambank_modify_notifiers[data];
- current_base[offset] = taitol_rambanks+0x1000*data;
+ current_notifier[offset] = rambank_modify_notifiers[data].notifier;
+ current_base[offset] = taitol_rambanks+rambank_modify_notifiers[data].offset;
}
else if (data == 0x80)
{
diff --git a/src/mame/drivers/taitowlf.c b/src/mame/drivers/taitowlf.c
index d1b84183175..d00f2ab651a 100644
--- a/src/mame/drivers/taitowlf.c
+++ b/src/mame/drivers/taitowlf.c
@@ -51,9 +51,9 @@ static VIDEO_START(taitowlf)
static void draw_char(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y)
{
int i,j;
- UINT8 *dp;
+ const UINT8 *dp;
int index = 0;
- dp = gfx->gfxdata + ch * gfx->char_modulo;
+ dp = gfx_element_get_data(gfx, ch);
for (j=y; j < y+8; j++)
{
diff --git a/src/mame/drivers/tiamc1.c b/src/mame/drivers/tiamc1.c
index 25e0163305a..7f4a240cd7a 100644
--- a/src/mame/drivers/tiamc1.c
+++ b/src/mame/drivers/tiamc1.c
@@ -118,30 +118,10 @@
#include "cpu/i8085/i8085.h"
#include "includes/tiamc1.h"
-static UINT8 *video_ram;
-
-static DRIVER_INIT( tiamc1 )
-{
- video_ram = auto_malloc(0x3040);
-}
-
static MACHINE_RESET( tiamc1 )
{
const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
-
- memset(video_ram, 0, 0x3040);
-
- tiamc1_charram = video_ram + 0x0800; /* Ram is banked */
- tiamc1_tileram = video_ram + 0x0000;
-
- tiamc1_spriteram_y = video_ram + 0x3000;
- tiamc1_spriteram_x = video_ram + 0x3010;
- tiamc1_spriteram_n = video_ram + 0x3020;
- tiamc1_spriteram_a = video_ram + 0x3030;
-
tiamc1_bankswitch_w(space, 0, 0);
-
- state_save_register_global_pointer(machine, video_ram, 0x3040);
}
static WRITE8_HANDLER( tiamc1_control_w )
@@ -342,7 +322,7 @@ ROM_START( koroleva )
ROM_END
-GAME( 1988, konek, 0, tiamc1, tiamc1, tiamc1, ROT0, "Terminal", "Konek-Gorbunok", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
-GAME( 1988, sosterm, 0, tiamc1, tiamc1, tiamc1, ROT0, "Terminal", "S.O.S.", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
-GAME( 1988, koroleva, 0, tiamc1, tiamc1, tiamc1, ROT0, "Terminal", "Snezhnaja Koroleva", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
+GAME( 1988, konek, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Konek-Gorbunok", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
+GAME( 1988, sosterm, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "S.O.S.", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
+GAME( 1988, koroleva, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Snezhnaja Koroleva", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
diff --git a/src/mame/drivers/trvmadns.c b/src/mame/drivers/trvmadns.c
index 33a588cf7ba..590592b42fc 100644
--- a/src/mame/drivers/trvmadns.c
+++ b/src/mame/drivers/trvmadns.c
@@ -143,9 +143,7 @@ static WRITE8_HANDLER( trvmadns_banking_w )
static WRITE8_HANDLER( trvmadns_gfxram_w )
{
trvmadns_gfxram[offset] = data;
- decodechar(space->machine->gfx[0], offset/16, trvmadns_gfxram);
-
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
}
#ifdef UNUSED_FUNCTION
@@ -268,6 +266,8 @@ static VIDEO_START( trvmadns )
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(bg_tilemap,1);
+
+ gfx_element_set_source(machine->gfx[0], trvmadns_gfxram);
}
static VIDEO_UPDATE( trvmadns )
diff --git a/src/mame/drivers/zac2650.c b/src/mame/drivers/zac2650.c
index 9e0078a976a..9023224606a 100644
--- a/src/mame/drivers/zac2650.c
+++ b/src/mame/drivers/zac2650.c
@@ -18,6 +18,7 @@ extern UINT8 *zac2650_s2636_0_ram;
WRITE8_HANDLER( tinvader_videoram_w );
static WRITE8_HANDLER( tinvader_sound_w );
READ8_HANDLER( zac_s2636_r );
+WRITE8_HANDLER( zac_s2636_w );
READ8_HANDLER( tinvader_port_0_r );
VIDEO_START( tinvader );
@@ -33,7 +34,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1e82, 0x1e82) AM_READ_PORT("1E82")
AM_RANGE(0x1e85, 0x1e85) AM_READ_PORT("1E85") /* Dodgem Only */
AM_RANGE(0x1e86, 0x1e86) AM_READ_PORT("1E86") AM_WRITENOP /* Dodgem Only */
- AM_RANGE(0x1f00, 0x1fff) AM_READWRITE(zac_s2636_r, SMH_RAM) AM_BASE(&zac2650_s2636_0_ram)
+ AM_RANGE(0x1f00, 0x1fff) AM_READWRITE(zac_s2636_r, zac_s2636_w) AM_BASE(&zac2650_s2636_0_ram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( port_map, ADDRESS_SPACE_IO, 8 )
@@ -210,62 +211,31 @@ static PALETTE_INIT( zac2650 )
static const gfx_layout tinvader_character =
{
- 24,24,
+ 8,8,
128,
1,
{ 0 },
- { 0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7 },
- { 0*8, 0*8, 0*8, 1*8, 1*8, 1*8, 2*8, 2*8, 2*8, 3*8, 3*8, 3*8, 4*8, 4*8, 4*8,
- 5*8, 5*8, 5*8, 6*8, 6*8, 6*8, 7*8, 7*8, 7*8 },
+ { STEP8(0,1) },
+ { STEP8(0,8) },
8*8
};
-static const gfx_layout s2636_character8 =
+static const gfx_layout s2636_character =
{
- 32,30,
+ 8,10,
16,
1,
{ 0 },
- { 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7 },
- { 0*8, 0*8, 0*8, 1*8, 1*8, 1*8, 2*8, 2*8, 2*8, 3*8, 3*8, 3*8,
- 4*8, 4*8, 4*8, 5*8, 5*8, 5*8, 6*8, 6*8, 6*8, 7*8, 7*8, 7*8,
- 8*8, 8*8, 8*8, 9*8, 9*8, 9*8 } ,
+ { STEP8(0,1) },
+ { STEP8(0,8), STEP2(8*8,8) },
8*8
};
-static const UINT32 s2636_character16_xoffset[64] =
-{
- 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,
- 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7
-};
-
-static const UINT32 s2636_character16_yoffset[60] =
-{
- 0*8, 0*8, 0*8, 0*8, 0*8, 0*8, 1*8, 1*8, 1*8, 1*8, 1*8, 1*8,
- 2*8, 2*8, 2*8, 2*8, 2*8, 2*8, 3*8, 3*8, 3*8, 3*8, 3*8, 3*8,
- 4*8, 4*8, 4*8, 4*8, 4*8, 4*8, 5*8, 5*8, 5*8, 5*8, 5*8, 5*8,
- 6*8, 6*8, 6*8, 6*8, 6*8, 6*8, 7*8, 7*8, 7*8, 7*8, 7*8, 7*8,
- 8*8, 8*8, 8*8, 8*8, 8*8, 8*8, 9*8, 9*8, 9*8, 9*8, 9*8, 9*8
-};
-
-static const gfx_layout s2636_character16 =
-{
- 64,60,
- 16,
- 1,
- { 0 },
- EXTENDED_XOFFS,
- EXTENDED_YOFFS,
- 8*8,
- s2636_character16_xoffset,
- s2636_character16_yoffset
-};
-
static GFXDECODE_START( tinvader )
- GFXDECODE_ENTRY( "gfx1", 0, tinvader_character, 0, 2 )
- GFXDECODE_ENTRY( NULL, 0x1F00, s2636_character8, 0, 2 ) /* dynamic */
- GFXDECODE_ENTRY( NULL, 0x1F00, s2636_character16, 0, 2 ) /* dynamic */
+ GFXDECODE_SCALE( "gfx1", 0, tinvader_character, 0, 2, 3, 3 )
+ GFXDECODE_SCALE( NULL, 0x1F00, s2636_character, 0, 2, 4, 3 ) /* dynamic */
+ GFXDECODE_SCALE( NULL, 0x1F00, s2636_character, 0, 2, 8, 6 ) /* dynamic */
GFXDECODE_END
static MACHINE_DRIVER_START( tinvader )
diff --git a/src/mame/drivers/zr107.c b/src/mame/drivers/zr107.c
index abe5fe41b02..d5a09cf8063 100644
--- a/src/mame/drivers/zr107.c
+++ b/src/mame/drivers/zr107.c
@@ -199,7 +199,6 @@ extern WRITE32_HANDLER(lanc_ram_w);
// defined in drivers/nwk-tr.c
int K001604_vh_start(running_machine *machine, int chip);
-void K001604_tile_update(running_machine *machine, int chip);
void K001604_draw_front_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
READ32_HANDLER(K001604_tile_r);
@@ -224,7 +223,6 @@ static VIDEO_UPDATE( jetwave )
{
bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
- K001604_tile_update(screen->machine, 0);
K001005_draw(bitmap, cliprect);
K001604_draw_front_layer(0, bitmap, cliprect);
@@ -505,7 +503,7 @@ static ADDRESS_MAP_START( jetwave_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x780c0000, 0x780c0007) AM_MIRROR(0x80000000) AM_READWRITE(cgboard_dsp_comm_r_ppc, cgboard_dsp_comm_w_ppc)
AM_RANGE(0x7e000000, 0x7e003fff) AM_MIRROR(0x80000000) AM_READWRITE8(sysreg_r, sysreg_w, 0xffffffff)
AM_RANGE(0x7e008000, 0x7e009fff) AM_MIRROR(0x80000000) AM_READWRITE8(K056230_r, K056230_w, 0xffffffff) /* LANC registers */
- AM_RANGE(0x7e00a000, 0x7e00bfff) AM_MIRROR(0x80000000) AM_READWRITE(lanc_ram_r, lanc_ram_w) /* LANC Buffer RAM (27E) */
+ AM_RANGE(0x7e00a000, 0x7e00bfff) AM_MIRROR(0x80000000) AM_READWRITE(lanc_ram_r, lanc_ram_w) AM_BASE(&lanc_ram) /* LANC Buffer RAM (27E) */
AM_RANGE(0x7e00c000, 0x7e00c007) AM_MIRROR(0x80000000) AM_WRITE(K056800_host_w)
AM_RANGE(0x7e00c008, 0x7e00c00f) AM_MIRROR(0x80000000) AM_READ(K056800_host_r)
AM_RANGE(0x7f000000, 0x7f3fffff) AM_MIRROR(0x80000000) AM_ROM AM_REGION("user2", 0)
diff --git a/src/mame/includes/deco16ic.h b/src/mame/includes/deco16ic.h
index 23281dfa603..65b615eca13 100644
--- a/src/mame/includes/deco16ic.h
+++ b/src/mame/includes/deco16ic.h
@@ -40,7 +40,7 @@ void deco16_clear_sprite_priority_bitmap(void);
void deco16_pdrawgfx(running_machine *machine,
bitmap_t *dest,const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri);
+ const rectangle *clip,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha);
tilemap *deco16_get_tilemap(int pf, int size);
diff --git a/src/mame/includes/madalien.h b/src/mame/includes/madalien.h
index 01a5d4010f3..d4e838f72b4 100644
--- a/src/mame/includes/madalien.h
+++ b/src/mame/includes/madalien.h
@@ -26,6 +26,9 @@ extern UINT8 *madalien_headlight_pos;
MACHINE_DRIVER_EXTERN( madalien_video );
+WRITE8_HANDLER( madalien_videoram_w );
+WRITE8_HANDLER( madalien_charram_w );
+
/*----------- defined in audio/madalien.c -----------*/
diff --git a/src/mame/includes/polyplay.h b/src/mame/includes/polyplay.h
index 1cf88daf763..7618c28fb2f 100644
--- a/src/mame/includes/polyplay.h
+++ b/src/mame/includes/polyplay.h
@@ -14,5 +14,6 @@ SAMPLES_START( polyplay_sh_start );
extern UINT8 *polyplay_characterram;
PALETTE_INIT( polyplay );
+VIDEO_START( polyplay );
VIDEO_UPDATE( polyplay );
WRITE8_HANDLER( polyplay_characterram_w );
diff --git a/src/mame/includes/tiamc1.h b/src/mame/includes/tiamc1.h
index cc34f004f71..6cd5b77d8c1 100644
--- a/src/mame/includes/tiamc1.h
+++ b/src/mame/includes/tiamc1.h
@@ -10,13 +10,6 @@ WRITE8_HANDLER( tiamc1_timer1_gate_w );
/*----------- defined in video/tiamc1.c -----------*/
-extern UINT8 *tiamc1_charram;
-extern UINT8 *tiamc1_tileram;
-extern UINT8 *tiamc1_spriteram_x;
-extern UINT8 *tiamc1_spriteram_y;
-extern UINT8 *tiamc1_spriteram_n;
-extern UINT8 *tiamc1_spriteram_a;
-
PALETTE_INIT( tiamc1 );
VIDEO_START( tiamc1 );
VIDEO_UPDATE( tiamc1 );
diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c
index 952a23dd0e1..d43501ab52b 100644
--- a/src/mame/machine/atarigen.c
+++ b/src/mame/machine/atarigen.c
@@ -1605,35 +1605,48 @@ void atarigen_blend_gfx(running_machine *machine, int gfx0, int gfx1, int mask0,
{
gfx_element *gx0 = machine->gfx[gfx0];
gfx_element *gx1 = machine->gfx[gfx1];
+ UINT8 *srcdata, *dest;
int c, x, y;
-
+
+ /* allocate memory for the assembled data */
+ srcdata = auto_malloc(gx0->total_elements * gx0->width * gx0->height);
+
/* loop over elements */
+ dest = srcdata;
for (c = 0; c < gx0->total_elements; c++)
{
- UINT8 *c0base = gx0->gfxdata + gx0->char_modulo * c;
- UINT8 *c1base = gx1->gfxdata + gx1->char_modulo * c;
- UINT32 usage = 0;
+ const UINT8 *c0base = gfx_element_get_data(gx0, c);
+ const UINT8 *c1base = gfx_element_get_data(gx1, c);
/* loop over height */
for (y = 0; y < gx0->height; y++)
{
- UINT8 *c0 = c0base, *c1 = c1base;
+ const UINT8 *c0 = c0base;
+ const UINT8 *c1 = c1base;
- for (x = 0; x < gx0->width; x++, c0++, c1++)
- {
- *c0 = (*c0 & mask0) | (*c1 & mask1);
- usage |= 1 << *c0;
- }
+ for (x = 0; x < gx0->width; x++)
+ *dest++ = (*c0++ & mask0) | (*c1++ & mask1);
c0base += gx0->line_modulo;
c1base += gx1->line_modulo;
- if (gx0->pen_usage)
- gx0->pen_usage[c] = usage;
}
}
/* free the second graphics element */
- freegfx(gx1);
+ gfx_element_free(gx1);
machine->gfx[gfx1] = NULL;
+
+ /* create a simple target layout */
+ gx0->layout.planes = 8;
+ for (x = 0; x < 8; x++)
+ gx0->layout.planeoffset[x] = x;
+ for (x = 0; x < gx0->width; x++)
+ gx0->layout.xoffset[x] = 8 * x;
+ for (y = 0; y < gx0->height; y++)
+ gx0->layout.yoffset[y] = 8 * y * gx0->width;
+ gx0->layout.charincrement = 8 * gx0->width * gx0->height;
+
+ /* make the assembled data our new source data */
+ gfx_element_set_source(gx0, srcdata);
}
diff --git a/src/mame/machine/konamigx.c b/src/mame/machine/konamigx.c
index da6da7ab583..48496ad41cd 100644
--- a/src/mame/machine/konamigx.c
+++ b/src/mame/machine/konamigx.c
@@ -211,7 +211,7 @@ INLINE void K053936GP_copyroz32clip( running_machine *machine,
bitmap_t *dst_bitmap, bitmap_t *src_bitmap,
const rectangle *dst_cliprect, const rectangle *src_cliprect,
UINT32 _startx,UINT32 _starty,int _incxx,int _incxy,int _incyx,int _incyy,
- int tilebpp, int blend, int clip )
+ int tilebpp, int blend, int alpha, int clip )
{
static const int colormask[8]={1,3,7,0xf,0x1f,0x3f,0x7f,0xff};
@@ -288,7 +288,7 @@ INLINE void K053936GP_copyroz32clip( running_machine *machine,
if (!(pixel & cmask))
continue;
- dst_ptr[ecx] = alpha_blend32(pal_base[pixel], dst_ptr[ecx]);
+ dst_ptr[ecx] = alpha_blend_r32(pal_base[pixel], dst_ptr[ecx], alpha);
}
while (++ecx);
@@ -361,7 +361,7 @@ INLINE void K053936GP_copyroz32clip( running_machine *machine,
static void K053936GP_zoom_draw(running_machine *machine,
int chip, UINT16 *ctrl, UINT16 *linectrl,
bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap,
- int tilebpp, int blend)
+ int tilebpp, int blend, int alpha)
{
bitmap_t *src_bitmap;
rectangle *src_cliprect;
@@ -401,7 +401,7 @@ static void K053936GP_zoom_draw(running_machine *machine,
K053936GP_copyroz32clip(machine,
bitmap, src_bitmap, &my_clip, src_cliprect,
startx<<5, starty<<5, incxx<<5, incxy<<5, 0, 0,
- tilebpp, blend, clip);
+ tilebpp, blend, alpha, clip);
y++;
}
}
@@ -426,20 +426,20 @@ static void K053936GP_zoom_draw(running_machine *machine,
K053936GP_copyroz32clip(machine,
bitmap, src_bitmap, cliprect, src_cliprect,
startx<<5, starty<<5, incxx<<5, incxy<<5, incyx<<5, incyy<<5,
- tilebpp, blend, clip);
+ tilebpp, blend, alpha, clip);
}
}
void K053936GP_0_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
- tilemap *tmap, int tilebpp, int blend)
+ tilemap *tmap, int tilebpp, int blend, int alpha)
{
- K053936GP_zoom_draw(machine, 0,K053936_0_ctrl,K053936_0_linectrl,bitmap,cliprect,tmap,tilebpp,blend);
+ K053936GP_zoom_draw(machine, 0,K053936_0_ctrl,K053936_0_linectrl,bitmap,cliprect,tmap,tilebpp,blend,alpha);
}
void K053936GP_1_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
- tilemap *tmap, int tilebpp, int blend)
+ tilemap *tmap, int tilebpp, int blend, int alpha)
{
- K053936GP_zoom_draw(machine, 1,K053936_1_ctrl,K053936_1_linectrl,bitmap,cliprect,tmap,tilebpp,blend);
+ K053936GP_zoom_draw(machine, 1,K053936_1_ctrl,K053936_1_linectrl,bitmap,cliprect,tmap,tilebpp,blend,alpha);
}
@@ -471,7 +471,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
#define FPENT 0
// inner loop
- UINT8 *src_ptr;
+ const UINT8 *src_ptr;
int src_x;
int eax, ecx;
int src_fx, src_fdx;
@@ -485,7 +485,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
// outter loop
int src_fby, src_fdy, src_fbx;
- UINT8 *src_base;
+ const UINT8 *src_base;
int dst_w, dst_h;
// one-time
@@ -524,7 +524,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
src_pitch = 16;
src_fw = 16;
src_fh = 16;
- src_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ src_base = gfx_element_get_data(gfx, code % gfx->total_elements);
pal_base = machine->pens + gfx->color_base + (color % gfx->total_colors) * granularity;
shd_base = machine->shadow_table;
@@ -691,7 +691,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
if (!eax || ozbuf_ptr[ecx] < z8) continue;
ozbuf_ptr[ecx] = z8;
- dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
+ dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
}
while (++ecx);
@@ -717,7 +717,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
if (!eax || eax >= shdpen || ozbuf_ptr[ecx] < z8) continue;
ozbuf_ptr[ecx] = z8;
- dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
+ dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
}
while (++ecx);
@@ -838,7 +838,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
if (!eax || ozbuf_ptr[ecx] < z8) continue;
ozbuf_ptr[ecx] = z8;
- dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
+ dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
}
while (++ecx);
@@ -858,7 +858,7 @@ INLINE void zdrawgfxzoom32GP( running_machine *machine,
if (!eax || eax >= shdpen || ozbuf_ptr[ecx] < z8) continue;
ozbuf_ptr[ecx] = z8;
- dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
+ dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
}
while (++ecx);
@@ -1603,10 +1603,10 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
temp4 = K054338_set_alpha_level(temp2);
if (temp4 <= 0) continue;
- if (temp4 < 255) k = TILEMAP_DRAW_ALPHA;
+ if (temp4 < 255) k = TILEMAP_DRAW_ALPHA(temp4);
}
- if (mixerflags & 1<<(code+12)) k |= TILE_LINE_DISABLED;
+ if (mixerflags & 1<<(code+12)) k |= K056382_DRAW_FLAG_FORCE_XYSCROLL;
K056832_tilemap_draw(machine, bitmap, cliprect, code, k, 0);
}
@@ -1615,6 +1615,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
case -4:
if (disp & K55_INP_SUB1)
{
+ int alpha = 255;
if (j == GXMIX_BLEND_NONE) { temp1 = 0xff; temp2 = temp3 = 0; } else
if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>24; temp3 = 3; }
else
@@ -1626,7 +1627,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
if (temp1!=0xff && temp2 /*&& temp3==3*/)
{
- temp4 = K054338_set_alpha_level(temp2);
+ alpha = temp4 = K054338_set_alpha_level(temp2);
if (temp4 <= 0) continue;
if (temp4 < 255) k = (j == GXMIX_BLEND_FAST) ? ~parity : 1;
@@ -1635,7 +1636,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
l = sub1flags & 0xf;
if (offs == -2)
- K053936GP_0_zoom_draw(machine, bitmap, cliprect, sub1, l, k);
+ K053936GP_0_zoom_draw(machine, bitmap, cliprect, sub1, l, k, alpha);
else
K053250_draw(machine, bitmap, cliprect, 0, vcblk[4]<<l, 0, 0);
}
@@ -1644,6 +1645,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
case -5:
if (disp & K55_INP_SUB2)
{
+ int alpha = 255;
if (j == GXMIX_BLEND_NONE) { temp1 = 0xff; temp2 = temp3 = 0; } else
if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>26; temp3 = 3; }
else
@@ -1655,7 +1657,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
if (temp1!=0xff && temp2 /*&& temp3==3*/)
{
- temp4 = K054338_set_alpha_level(temp2);
+ alpha = temp4 = K054338_set_alpha_level(temp2);
if (temp4 <= 0) continue;
if (temp4 < 255) k = (j == GXMIX_BLEND_FAST) ? ~parity : 1;
@@ -1664,7 +1666,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
l = sub2flags & 0xf;
if (offs == -3)
- K053936GP_1_zoom_draw(machine, bitmap, cliprect, sub2, l, k);
+ K053936GP_1_zoom_draw(machine, bitmap, cliprect, sub2, l, k, alpha);
else
K053250_draw(machine, bitmap, cliprect, 1, vcblk[5]<<l, 0, 0);
}
diff --git a/src/mame/machine/konamigx.h b/src/mame/machine/konamigx.h
index 49c3351b107..a49eeb448ff 100644
--- a/src/mame/machine/konamigx.h
+++ b/src/mame/machine/konamigx.h
@@ -21,8 +21,8 @@ void K053247GP_set_SpriteOffset(int offsx, int offsy);
void K053936GP_set_offset(int chip, int xoffs, int yoffs);
void K053936GP_clip_enable(int chip, int status);
void K053936GP_set_cliprect(int chip, int minx, int maxx, int miny, int maxy);
-void K053936GP_0_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend);
-void K053936GP_1_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend);
+void K053936GP_0_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend, int alpha);
+void K053936GP_1_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend, int alpha);
diff --git a/src/mame/video/88games.c b/src/mame/video/88games.c
index 0c53123184f..e81bd87a0ca 100644
--- a/src/mame/video/88games.c
+++ b/src/mame/video/88games.c
@@ -86,19 +86,19 @@ VIDEO_UPDATE( 88games )
if (k88games_priority)
{
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],TILEMAP_DRAW_OPAQUE,0);
- K051960_sprites_draw(bitmap,cliprect,1,1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
K051316_zoom_draw_0(bitmap,cliprect,0,0);
}
else
{
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
K051316_zoom_draw_0(bitmap,cliprect,0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
- K051960_sprites_draw(bitmap,cliprect,1,1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
}
return 0;
diff --git a/src/mame/video/ajax.c b/src/mame/video/ajax.c
index 7923eab6304..19b50cad488 100644
--- a/src/mame/video/ajax.c
+++ b/src/mame/video/ajax.c
@@ -112,6 +112,6 @@ VIDEO_UPDATE( ajax )
}
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,8);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
diff --git a/src/mame/video/aliens.c b/src/mame/video/aliens.c
index ae31cfd5e3d..48ef3ad208e 100644
--- a/src/mame/video/aliens.c
+++ b/src/mame/video/aliens.c
@@ -81,6 +81,6 @@ VIDEO_UPDATE( aliens )
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
diff --git a/src/mame/video/arabian.c b/src/mame/video/arabian.c
index f3be32dfe85..a90be49488c 100644
--- a/src/mame/video/arabian.c
+++ b/src/mame/video/arabian.c
@@ -386,7 +386,7 @@ VIDEO_UPDATE( arabian )
{
/* non-flipped case */
if (!arabian_flip_screen)
- draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &main_bitmap[y * BITMAP_WIDTH], pens, -1);
+ draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &main_bitmap[y * BITMAP_WIDTH], pens);
/* flipped case */
else
@@ -395,7 +395,7 @@ VIDEO_UPDATE( arabian )
int x;
for (x = 0; x < BITMAP_WIDTH; x++)
scanline[BITMAP_WIDTH - 1 - x] = main_bitmap[y * BITMAP_WIDTH + x];
- draw_scanline8(bitmap, 0, BITMAP_HEIGHT - 1 - y, BITMAP_WIDTH, scanline, pens, -1);
+ draw_scanline8(bitmap, 0, BITMAP_HEIGHT - 1 - y, BITMAP_WIDTH, scanline, pens);
}
}
return 0;
diff --git a/src/mame/video/asterix.c b/src/mame/video/asterix.c
index 4cf91ee8f38..df3d54af5a8 100644
--- a/src/mame/video/asterix.c
+++ b/src/mame/video/asterix.c
@@ -123,8 +123,9 @@ VIDEO_UPDATE( asterix )
K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[1], 0, 2);
K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[2], 0, 4);
- pdrawgfx_shadow_lowpri = 1; /* fix shadows in front of feet */
- K053245_sprites_draw(0, bitmap, cliprect);
+/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
+ pdrawgfx_shadow_lowpri = 1; fix shadows in front of feet */
+ K053245_sprites_draw(screen->machine, 0, bitmap, cliprect);
K056832_tilemap_draw(screen->machine, bitmap, cliprect, 2, 0, 0);
return 0;
diff --git a/src/mame/video/atari.c b/src/mame/video/atari.c
index 04b66d1e588..5ad7ea3af4c 100644
--- a/src/mame/video/atari.c
+++ b/src/mame/video/atari.c
@@ -1051,7 +1051,7 @@ static void antic_linerefresh(running_machine *machine)
dst[2] = antic.color_lookup[PBK] | antic.color_lookup[PBK] << 16;
dst[3] = antic.color_lookup[PBK] | antic.color_lookup[PBK] << 16;
- draw_scanline8(tmpbitmap, 12, y, sizeof(scanline), (const UINT8 *) scanline, NULL, -1);
+ draw_scanline8(tmpbitmap, 12, y, MIN(tmpbitmap->width - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL);
}
static int cycle(running_machine *machine)
diff --git a/src/mame/video/atarimo.c b/src/mame/video/atarimo.c
index 209d9cde16b..79e6eba1933 100644
--- a/src/mame/video/atarimo.c
+++ b/src/mame/video/atarimo.c
@@ -862,7 +862,7 @@ if ((temp & 0xff00) == 0xc800)
continue;
/* draw the sprite */
- drawgfx(bitmap, gfx, code, color, hflip, vflip, sx, sy, cliprect, TRANSPARENCY_PEN_RAW, mo->transpen);
+ drawgfx_transpen_raw(bitmap, cliprect, gfx, code, color, hflip, vflip, sx, sy, mo->transpen);
rendered = 1;
/* mark the grid dirty */
@@ -899,7 +899,7 @@ if ((temp & 0xff00) == 0xc800)
continue;
/* draw the sprite */
- drawgfx(bitmap, gfx, code, color, hflip, vflip, sx, sy, cliprect, TRANSPARENCY_PEN_RAW, mo->transpen);
+ drawgfx_transpen_raw(bitmap, cliprect, gfx, code, color, hflip, vflip, sx, sy, mo->transpen);
rendered = 1;
/* mark the grid dirty */
diff --git a/src/mame/video/atarisy1.c b/src/mame/video/atarisy1.c
index f5683a2afbc..e794925eb00 100644
--- a/src/mame/video/atarisy1.c
+++ b/src/mame/video/atarisy1.c
@@ -630,6 +630,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)
{
+ const UINT8 *srcdata;
int bank_index, gfx_index;
/* determine the bank index */
@@ -668,29 +669,27 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp)
assert(gfx_index != MAX_GFX_ELEMENTS);
/* decode the graphics */
+ srcdata = &memory_region(machine, "tiles")[0x80000 * (bank_index - 1)];
switch (bpp)
{
case 4:
- machine->gfx[gfx_index] = allocgfx(machine, &objlayout_4bpp);
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &objlayout_4bpp, srcdata, 0x40, 256);
break;
case 5:
- machine->gfx[gfx_index] = allocgfx(machine, &objlayout_5bpp);
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &objlayout_5bpp, srcdata, 0x40, 256);
break;
case 6:
- machine->gfx[gfx_index] = allocgfx(machine, &objlayout_6bpp);
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &objlayout_6bpp, srcdata, 0x40, 256);
break;
default:
fatalerror("Unsupported bpp");
}
- decodegfx(machine->gfx[gfx_index], &memory_region(machine, "tiles")[0x80000 * (bank_index - 1)], 0, machine->gfx[gfx_index]->total_elements);
/* set the color information */
- machine->gfx[gfx_index]->color_base = 256;
machine->gfx[gfx_index]->color_granularity = 8;
- machine->gfx[gfx_index]->total_colors = 0x40;
bank_color_shift[gfx_index] = bpp - 3;
/* set the entry and return it */
diff --git a/src/mame/video/balsente.c b/src/mame/video/balsente.c
index 6ea15e33254..4b0bbe56521 100644
--- a/src/mame/video/balsente.c
+++ b/src/mame/video/balsente.c
@@ -227,7 +227,7 @@ VIDEO_UPDATE( balsente )
/* draw scanlines from the VRAM directly */
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
- draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens, -1);
+ draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens);
/* draw the sprite images */
for (i = 0; i < 40; i++)
diff --git a/src/mame/video/battlera.c b/src/mame/video/battlera.c
index 64e4a0508fd..e05d40ad496 100644
--- a/src/mame/video/battlera.c
+++ b/src/mame/video/battlera.c
@@ -13,12 +13,14 @@
static int HuC6270_registers[20];
static int VDC_register,vram_ptr;
-static UINT8 *HuC6270_vram,*tile_dirty,*sprite_dirty,*vram_dirty;
+static UINT8 *HuC6270_vram,*vram_dirty;
static bitmap_t *tile_bitmap,*front_bitmap;
+static UINT32 tile_dirtyseq;
static int current_scanline,inc_value;
static int irq_enable,rcr_enable,sb_enable,bb_enable,bldwolf_vblank;
+static UINT8 blank_tile[32];
/******************************************************************************/
@@ -26,13 +28,9 @@ static int irq_enable,rcr_enable,sb_enable,bb_enable,bldwolf_vblank;
VIDEO_START( battlera )
{
HuC6270_vram=auto_malloc(0x20000);
- tile_dirty=auto_malloc(0x1000);
- sprite_dirty=auto_malloc(0x400);
vram_dirty=auto_malloc(0x1000);
memset(HuC6270_vram,0,0x20000);
- memset(tile_dirty,1,0x1000);
- memset(sprite_dirty,1,0x400);
memset(vram_dirty,1,0x1000);
tile_bitmap=auto_bitmap_alloc(512,512,video_screen_get_format(machine->primary_screen));
@@ -42,6 +40,10 @@ VIDEO_START( battlera )
inc_value=1;
current_scanline=0;
irq_enable=rcr_enable=sb_enable=bb_enable=0;
+
+ gfx_element_set_source(machine->gfx[0], HuC6270_vram);
+ gfx_element_set_source(machine->gfx[1], HuC6270_vram);
+ gfx_element_set_source(machine->gfx[2], blank_tile);
}
/******************************************************************************/
@@ -133,8 +135,8 @@ WRITE8_HANDLER( HuC6270_data_w )
case 2: /* VRAM */
if (HuC6270_vram[(HuC6270_registers[0]<<1)|1]!=data) {
HuC6270_vram[(HuC6270_registers[0]<<1)|1]=data;
- tile_dirty[HuC6270_registers[0]>>4]=1;
- sprite_dirty[HuC6270_registers[0]>>6]=1;
+ gfx_element_mark_dirty(space->machine->gfx[0], HuC6270_registers[0]>>4);
+ gfx_element_mark_dirty(space->machine->gfx[1], HuC6270_registers[0]>>6);
}
if (HuC6270_registers[0]<0x1000) vram_dirty[HuC6270_registers[0]]=1;
return;
@@ -193,8 +195,8 @@ WRITE8_HANDLER( HuC6270_data_w )
case 2: /* VWR - VRAM */
if (HuC6270_vram[(HuC6270_registers[0]<<1)|0]!=data) {
HuC6270_vram[(HuC6270_registers[0]<<1)|0]=data;
- tile_dirty[HuC6270_registers[0]>>4]=1;
- sprite_dirty[HuC6270_registers[0]>>6]=1;
+ gfx_element_mark_dirty(space->machine->gfx[0], HuC6270_registers[0]>>4);
+ gfx_element_mark_dirty(space->machine->gfx[1], HuC6270_registers[0]>>6);
if (HuC6270_registers[0]<0x1000) vram_dirty[HuC6270_registers[0]]=1;
}
HuC6270_registers[0]+=inc_value;
@@ -313,17 +315,12 @@ VIDEO_UPDATE( battlera )
{
int offs,code,scrollx,scrolly,mx,my;
- /* Dynamically decode chars if dirty */
- for (code = 0x0000;code < 0x1000;code++)
- if (tile_dirty[code])
- decodechar(screen->machine->gfx[0],code,HuC6270_vram);
-
- /* Dynamically decode sprites if dirty */
- for (code = 0x0000;code < 0x400;code++)
- if (sprite_dirty[code])
- decodechar(screen->machine->gfx[1],code,HuC6270_vram);
-
- /* NB: If first 0x1000 byte is always tilemap, no need to decode the first batch of tiles/sprites */
+ /* if any tiles changed, redraw the VRAM */
+ if (screen->machine->gfx[0]->dirtyseq != tile_dirtyseq)
+ {
+ tile_dirtyseq = screen->machine->gfx[0]->dirtyseq;
+ memset(vram_dirty, 1, 0x1000);
+ }
mx=-1;
my=0;
@@ -334,7 +331,7 @@ VIDEO_UPDATE( battlera )
code=HuC6270_vram[offs+1] + ((HuC6270_vram[offs] & 0x0f) << 8);
/* If this tile was changed OR tilemap was changed, redraw */
- if (tile_dirty[code] || vram_dirty[offs/2]) {
+ if (vram_dirty[offs/2]) {
vram_dirty[offs/2]=0;
drawgfx(tile_bitmap,screen->machine->gfx[0],
code,
@@ -357,12 +354,6 @@ VIDEO_UPDATE( battlera )
}
}
- /* Nothing dirty after a screen refresh */
- for (code = 0x0000;code < 0x1000;code++)
- tile_dirty[code]=0;
- for (code = 0x0000;code < 0x400;code++)
- sprite_dirty[code]=0;
-
/* Render bitmap */
scrollx=-HuC6270_registers[7];
scrolly=-HuC6270_registers[8]+cliprect->min_y-1;
diff --git a/src/mame/video/bbusters.c b/src/mame/video/bbusters.c
index 1b43d76b560..f33e30e299c 100644
--- a/src/mame/video/bbusters.c
+++ b/src/mame/video/bbusters.c
@@ -108,7 +108,7 @@ VIDEO_START( mechatt )
INLINE const UINT8 *get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block)
{
- int source_base,code=0;
+ int code=0;
/* Get a tile index from the x,y position in the block */
switch (block)
@@ -141,8 +141,7 @@ INLINE const UINT8 *get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int
break;
}
- source_base=((sprite+code) % gfx->total_elements) * 16;
- return gfx->gfxdata + ((source_base+(dy%16)) * gfx->line_modulo);
+ return gfx_element_get_data(gfx, (sprite+code) % gfx->total_elements) + ((dy%16) * gfx->line_modulo);
}
static void bbusters_draw_block(running_machine *machine, bitmap_t *dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block)
diff --git a/src/mame/video/beathead.c b/src/mame/video/beathead.c
index dcc3657e5a5..e6a9009c47c 100644
--- a/src/mame/video/beathead.c
+++ b/src/mame/video/beathead.c
@@ -206,7 +206,7 @@ VIDEO_UPDATE( beathead )
}
/* then draw it */
- draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1);
+ draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL);
}
return 0;
}
diff --git a/src/mame/video/blockhl.c b/src/mame/video/blockhl.c
index 8789b26c3bd..027becd9c5f 100644
--- a/src/mame/video/blockhl.c
+++ b/src/mame/video/blockhl.c
@@ -62,6 +62,6 @@ VIDEO_UPDATE( blockhl )
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,1);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,2);
- K051960_sprites_draw(bitmap,cliprect,0,-1); // draw sprites with pdrawgfx
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,-1); // draw sprites with pdrawgfx
return 0;
}
diff --git a/src/mame/video/boogwing.c b/src/mame/video/boogwing.c
index 8fc81192005..a29e6be4015 100644
--- a/src/mame/video/boogwing.c
+++ b/src/mame/video/boogwing.c
@@ -9,7 +9,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
for (offs = 0x400-4;offs >= 0;offs -= 4)
{
int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0,spri=0;
- int trans=TRANSPARENCY_PEN;
+ int alpha = 0xff;
sprite = spriteram_base[offs+1];
if (!sprite) continue;
@@ -38,13 +38,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
// Transparency
if (spriteram_base[offs+2]&0x2000)
- trans=TRANSPARENCY_ALPHA;
+ alpha = 0x80;
if (deco16_priority==0x2)
{
// Additional sprite alpha in this mode
if (spriteram_base[offs+2]&0x8000)
- trans=TRANSPARENCY_ALPHA;
+ alpha = 0x80;
// Sprite vs playfield
if ((spriteram_base[offs+2]&0xc000)==0xc000)
@@ -123,7 +123,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
colour,
fx,fy,
x,y + mult * multi,
- cliprect,trans, 0, pri, spri, 0);
+ cliprect, 0, pri, spri, 0, alpha);
multi--;
}
@@ -152,8 +152,6 @@ VIDEO_START(boogwing)
deco16_set_tilemap_bank_callback(3,boogwing_bank_callback2);
deco16_set_tilemap_colour_base(1,0);
deco16_set_tilemap_transparency_mask(1, 0x1f); // 5bpp graphics
-
- alpha_set_level(0x80);
}
VIDEO_UPDATE(boogwing)
@@ -187,7 +185,7 @@ VIDEO_UPDATE(boogwing)
// This mode uses playfield 3 to shadow sprites & playfield 2 (instead of
// regular alpha-blending, the destination is inverted). Not yet implemented.
-// deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA,32);
+// deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA(0x80),32);
}
else
{
diff --git a/src/mame/video/bottom9.c b/src/mame/video/bottom9.c
index ff9257c1fe7..92f2372f42d 100644
--- a/src/mame/video/bottom9.c
+++ b/src/mame/video/bottom9.c
@@ -84,13 +84,13 @@ VIDEO_UPDATE( bottom9 )
bitmap_fill(bitmap,cliprect,layer_colorbase[1]);
// if (bottom9_video_enable)
{
- K051960_sprites_draw(bitmap,cliprect,1,1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
K051316_zoom_draw_0(bitmap,cliprect,0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
/* note that priority 3 is opposite to the basic layer priority! */
/* (it IS used, but hopefully has no effect) */
- K051960_sprites_draw(bitmap,cliprect,2,3);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,2,3);
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
}
return 0;
diff --git a/src/mame/video/btime.c b/src/mame/video/btime.c
index 97e445c7bc2..3a780848545 100644
--- a/src/mame/video/btime.c
+++ b/src/mame/video/btime.c
@@ -26,8 +26,6 @@ static UINT8 bnj_scroll1 = 0;
static UINT8 bnj_scroll2 = 0;
static bitmap_t *background_bitmap;
-static UINT8 *sprite_dirty, *char_dirty;
-
/***************************************************************************
Burger Time doesn't have a color PROM. It uses RAM to dynamically
@@ -141,11 +139,10 @@ VIDEO_START( btime )
bnj_scroll2 = 0;
btime_palette = 0;
- sprite_dirty = auto_malloc(256 * sizeof(*sprite_dirty));
- memset(sprite_dirty, 1, 256 * sizeof(*sprite_dirty));
-
- char_dirty = auto_malloc(1024 * sizeof(*char_dirty));
- memset(char_dirty, 1, 1024 * sizeof(*char_dirty));
+ if (machine->gfx[0]->srcdata == NULL)
+ gfx_element_set_source(machine->gfx[0], deco_charram);
+ if (machine->gfx[1]->srcdata == NULL)
+ gfx_element_set_source(machine->gfx[1], deco_charram);
}
@@ -242,10 +239,10 @@ WRITE8_HANDLER( deco_charram_w )
offset &= 0x1fff;
/* dirty sprite */
- sprite_dirty[offset >> 5] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[1], offset >> 5);
/* diry char */
- char_dirty [offset >> 3] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset >> 3);
}
WRITE8_HANDLER( bnj_background_w )
@@ -431,43 +428,6 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re
}
-static void decode_modified(running_machine *machine, UINT8 *sprite_ram, int interleave)
-{
- int i,offs;
-
-
- /* decode dirty characters */
- for (offs = btime_videoram_size - 1;offs >= 0;offs--)
- {
- int code;
-
- code = btime_videoram[offs] + 256 * (btime_colorram[offs] & 3);
-
- if (char_dirty[code])
- {
- decodechar(machine->gfx[0],code,deco_charram);
-
- char_dirty[code] = 0;
- }
- }
-
- /* decode dirty sprites */
- for (i = 0, offs = 0;i < 8; i++, offs += 4*interleave)
- {
- int code;
-
- code = sprite_ram[offs + interleave];
-
- if (sprite_dirty[code])
- {
- decodechar(machine->gfx[1],code,deco_charram);
-
- sprite_dirty[code] = 0;
- }
- }
-}
-
-
VIDEO_UPDATE( btime )
{
if (bnj_scroll1 & 0x10)
@@ -620,7 +580,6 @@ VIDEO_UPDATE( cookrace )
VIDEO_UPDATE( disco )
{
- decode_modified(screen->machine, spriteram, 1);
draw_chars(screen->machine, bitmap, cliprect, TRANSPARENCY_NONE, btime_palette, -1);
draw_sprites(screen->machine, bitmap, cliprect, btime_palette, 0, 0, spriteram, 1);
@@ -630,7 +589,6 @@ VIDEO_UPDATE( disco )
VIDEO_UPDATE( progolf )
{
- decode_modified(screen->machine, spriteram, 1);
draw_chars(screen->machine, bitmap, cliprect, TRANSPARENCY_NONE, /*btime_palette*/0, -1);
// draw_sprites(screen->machine, bitmap, cliprect, 0/*btime_palette*/, 0, 0, spriteram, 1);
diff --git a/src/mame/video/buggychl.c b/src/mame/video/buggychl.c
index 41969e841d2..cd78b49a921 100644
--- a/src/mame/video/buggychl.c
+++ b/src/mame/video/buggychl.c
@@ -8,8 +8,6 @@ UINT8 *buggychl_scrollv,*buggychl_scrollh;
static UINT8 buggychl_sprite_lookup[0x2000];
UINT8 *buggychl_character_ram;
-static int *dirtychar;
-
static bitmap_t *tmpbitmap1,*tmpbitmap2;
static int sl_bank,bg_on,sky_on,sprite_color_base,bg_scrollx;
@@ -29,11 +27,10 @@ PALETTE_INIT( buggychl )
VIDEO_START( buggychl )
{
- dirtychar = auto_malloc(256 * sizeof(*dirtychar));
tmpbitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen);
tmpbitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen);
- memset(dirtychar,0xff,256 * sizeof(*dirtychar));
+ gfx_element_set_source(machine->gfx[0], buggychl_character_ram);
}
@@ -43,8 +40,7 @@ WRITE8_HANDLER( buggychl_chargen_w )
if (buggychl_character_ram[offset] != data)
{
buggychl_character_ram[offset] = data;
-
- dirtychar[(offset / 8) & 0xff] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
}
}
@@ -210,7 +206,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
code = 8 * (lookup[pos] | ((lookup[pos+1] & 0x07) << 8));
realflipy = (lookup[pos+1] & 0x80) ? !flipy : flipy;
code += (realflipy ? (charline ^ 7) : charline);
- pendata = machine->gfx[1]->gfxdata + code*16;
+ pendata = gfx_element_get_data(machine->gfx[1], code);
for (x = 0;x < 16;x++)
{
@@ -239,19 +235,11 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( buggychl )
{
- int code;
-
-
if (sky_on)
draw_sky(bitmap, cliprect);
else
bitmap_fill(bitmap,cliprect,0);
- /* decode modified characters */
- for (code = 0;code < 256;code++)
- if (dirtychar[code])
- decodechar(screen->machine->gfx[0],code,buggychl_character_ram);
-
if (bg_on)
draw_bg(screen->machine, bitmap, cliprect);
@@ -259,7 +247,5 @@ VIDEO_UPDATE( buggychl )
draw_fg(screen->machine, bitmap, cliprect);
- for (code = 0;code < 256;code++)
- dirtychar[code] = 0;
return 0;
}
diff --git a/src/mame/video/bwing.c b/src/mame/video/bwing.c
index 40b8245bcd0..5cccd28937f 100644
--- a/src/mame/video/bwing.c
+++ b/src/mame/video/bwing.c
@@ -81,6 +81,13 @@ WRITE8_HANDLER( bwing_scrollram_w )
tilemap_mark_tile_dirty(scrollmap[offset>>12], offset & 0xfff);
}
+ else
+ {
+ if (offset < 0x1000)
+ gfx_element_mark_dirty(fgfx, offset/32);
+ else
+ gfx_element_mark_dirty(bgfx, offset/32);
+ }
(srbase[srbank])[offset] = data;
}
@@ -88,10 +95,6 @@ WRITE8_HANDLER( bwing_scrollram_w )
WRITE8_HANDLER( bwing_scrollreg_w )
{
- static unsigned bp_ready=0;
- unsigned i;
- UINT8 *src;
-
sreg[offset] = data;
switch (offset)
@@ -103,19 +106,6 @@ WRITE8_HANDLER( bwing_scrollreg_w )
mapmask = data;
srbank = data >> 6;
- if (srbank) bp_ready |= 1<<(srbank-1) & 7;
-
- if (bp_ready == 7 && !srbank)
- {
- src = srbase[1];
- for (i=0; i<BW_NTILES; i++) decodechar(fgfx, i, src);
-
- src += 0x1000;
- for (i=0; i<BW_NTILES; i++) decodechar(bgfx, i, src);
-
- bp_ready = 0;
- }
-
#if BW_DEBUG
logerror("(%s)%04x: w=%02x a=%04x f=%d\n", space->cpu->tag, cpu_get_pc(space->cpu),data,0x1b00+offset,video_screen_get_frame_number(space->machine->primary_screen));
#endif
@@ -164,7 +154,7 @@ WRITE8_HANDLER( bwing_paletteram_w )
// Initializations
#define BW_SET_TILE_INFO(GFX, CODE, COLOR) { \
- tileinfo->pen_data = GFX->gfxdata + (CODE) * GFX->char_modulo; \
+ tileinfo->pen_data = gfx_element_get_data(GFX, CODE); \
tileinfo->palette_base = GFX->color_base + ((COLOR) << 3); \
}
@@ -215,7 +205,9 @@ VIDEO_START( bwing )
for (i=0; i<8; i++) sreg[i] = 0;
fgfx = machine->gfx[2];
+ gfx_element_set_source(fgfx, srbase[1]);
bgfx = machine->gfx[3];
+ gfx_element_set_source(bgfx, srbase[1] + 0x1000);
dwptr = fgfx->pen_usage;
if (dwptr)
diff --git a/src/mame/video/chqflag.c b/src/mame/video/chqflag.c
index 5914e4d4049..ca6540b107d 100644
--- a/src/mame/video/chqflag.c
+++ b/src/mame/video/chqflag.c
@@ -79,9 +79,9 @@ VIDEO_UPDATE( chqflag )
bitmap_fill(bitmap,cliprect,0);
K051316_zoom_draw_1(bitmap,cliprect,TILEMAP_DRAW_LAYER1,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
K051316_zoom_draw_1(bitmap,cliprect,TILEMAP_DRAW_LAYER0,0);
- K051960_sprites_draw(bitmap,cliprect,1,1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
K051316_zoom_draw_0(bitmap,cliprect,0,0);
return 0;
}
diff --git a/src/mame/video/circus.c b/src/mame/video/circus.c
index 96166e94a75..bc61587260f 100644
--- a/src/mame/video/circus.c
+++ b/src/mame/video/circus.c
@@ -198,7 +198,7 @@ VIDEO_UPDATE( crash )
static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
const gfx_element *gfx;
- UINT8 *src_lineptr, *src_pixptr;
+ const UINT8 *src_lineptr, *src_pixptr;
UINT16 *dst_lineptr, *dst_lineend;
UINT32 code;
int sx, sy;
@@ -216,7 +216,7 @@ static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, co
edx = 1;
gfx = machine->gfx[1];
- src_lineptr = gfx->gfxdata + code * gfx->char_modulo;
+ src_lineptr = gfx_element_get_data(gfx, code);
src_pitch = gfx->line_modulo;
dst_pitch = bitmap->rowpixels;
diff --git a/src/mame/video/cischeat.c b/src/mame/video/cischeat.c
index dbcd365624c..0a5d5fbe9a1 100644
--- a/src/mame/video/cischeat.c
+++ b/src/mame/video/cischeat.c
@@ -60,6 +60,7 @@ Note: if MAME_DEBUG is defined, pressing Z or X with:
static int cischeat_ip_select;
static int shift_ret = 1;
+static UINT8 drawmode_table[16];
#ifdef MAME_DEBUG
static int debugsprites; // For debug purposes
@@ -129,10 +130,10 @@ static void prepare_shadows(void)
{
int i;
for (i = 0;i < 16;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
+ drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[ 0] = DRAWMODE_SHADOW;
- gfx_drawmode_table[15] = DRAWMODE_NONE;
+ drawmode_table[ 0] = DRAWMODE_SHADOW;
+ drawmode_table[15] = DRAWMODE_NONE;
}
/**************************************************************************
@@ -923,18 +924,18 @@ if ( (debugsprites) && ( ((attr & 0x0300)>>8) != (debugsprites-1) ) ) { continu
if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; }
else { ystart = 0; yend = ynum; yinc = +1; }
+ drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+
for (y = ystart; y != yend; y += yinc)
{
for (x = xstart; x != xend; x += xinc)
{
- drawgfxzoom(bitmap,machine->gfx[3],
+ drawgfxzoom_transtable(bitmap,cliprect,machine->gfx[3],
code++,
color,
flipx,flipy,
(sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000,
- cliprect,
- shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
- xscale, yscale );
+ xscale, yscale, drawmode_table, machine->shadow_table);
}
}
#ifdef MAME_DEBUG
@@ -1077,18 +1078,18 @@ if ( (debugsprites) && ( ((attr & 0x0300)>>8) != (debugsprites-1) ) ) { continu
if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; }
else { ystart = 0; yend = ynum; yinc = +1; }
+ drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+
for (y = ystart; y != yend; y += yinc)
{
for (x = xstart; x != xend; x += xinc)
{
- drawgfxzoom(bitmap,machine->gfx[3],
+ drawgfxzoom_transtable(bitmap,cliprect,machine->gfx[3],
code++,
color,
flipx,flipy,
(sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000,
- cliprect,
- shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
- xscale, yscale );
+ xscale, yscale, drawmode_table, machine->shadow_table);
}
}
#ifdef MAME_DEBUG
diff --git a/src/mame/video/cninja.c b/src/mame/video/cninja.c
index 34f5191866c..85fb807d699 100644
--- a/src/mame/video/cninja.c
+++ b/src/mame/video/cninja.c
@@ -93,8 +93,6 @@ VIDEO_START( mutantf )
deco16_set_tilemap_colour_base(1,0x30);
deco16_set_tilemap_colour_base(2,0x20);
deco16_set_tilemap_colour_base(3,0x40);
-
- alpha_set_level(0x80);
}
/******************************************************************************/
@@ -325,7 +323,7 @@ static void mutantf_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
while (offs!=end)
{
int x,y,sprite,colour,fx,fy,w,h,sx,sy,x_mult,y_mult;
- int trans=TRANSPARENCY_PEN;
+ int alpha=0xff;
sprite = spriteptr[offs+3];
if (!sprite) {
@@ -347,7 +345,7 @@ static void mutantf_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
colour = (spriteptr[offs+2] >>0) & 0x1f;
if (gfxbank==4) { /* Seems to be always alpha'd */
- trans=TRANSPARENCY_ALPHA;
+ alpha=0x80;
colour&=0xf;
}
@@ -380,12 +378,13 @@ static void mutantf_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
for (x=0; x<w; x++) {
for (y=0; y<h; y++) {
- pdrawgfx(bitmap,machine->gfx[gfxbank],
+ pdrawgfx_alpha(bitmap,cliprect,machine->gfx[gfxbank],
sprite + y + h * x,
colour,
fx,fy,
sx + x_mult * (w-x),sy + y_mult * (h-y),
- cliprect,trans,0,0);
+ priority_bitmap,0,
+ 0,alpha);
}
}
diff --git a/src/mame/video/crimfght.c b/src/mame/video/crimfght.c
index 63efbe4cd72..f690911fd61 100644
--- a/src/mame/video/crimfght.c
+++ b/src/mame/video/crimfght.c
@@ -77,10 +77,10 @@ VIDEO_UPDATE( crimfght )
K052109_tilemap_update();
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
- K051960_sprites_draw(bitmap,cliprect,2,2);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
- K051960_sprites_draw(bitmap,cliprect,1,1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
return 0;
}
diff --git a/src/mame/video/cvs.c b/src/mame/video/cvs.c
index 44c74ebb70f..aa3a8a08296 100644
--- a/src/mame/video/cvs.c
+++ b/src/mame/video/cvs.c
@@ -208,7 +208,6 @@ void cvs_scroll_stars(void)
VIDEO_UPDATE( cvs )
{
static const int ram_based_char_start_indices[] = { 0xe0, 0xc0, 0x100, 0x80 };
- int code;
offs_t offs;
int scroll[8];
UINT8 character_banking_mode;
@@ -223,14 +222,6 @@ VIDEO_UPDATE( cvs )
character_banking_mode = cvs_get_character_banking_mode();
- /* ROM based tiles first */
- for (code = 0; code < ram_based_char_start_indices[character_banking_mode]; code++)
- decodechar(screen->machine->gfx[0], code, memory_region(screen->machine, "gfx1"));
-
- /* now the RAM based ones */
- for (; code < 0x100; code++)
- decodechar(screen->machine->gfx[0], code, cvs_character_ram);
-
/* draw the background */
for (offs = 0; offs < 0x0400; offs++)
{
@@ -242,7 +233,9 @@ VIDEO_UPDATE( cvs )
UINT8 x = offs << 3;
UINT8 y = offs >> 5 << 3;
- drawgfx(background_bitmap, screen->machine->gfx[0],
+ int gfxnum = (code < ram_based_char_start_indices[character_banking_mode]) ? 0 : 1;
+
+ drawgfx(background_bitmap, screen->machine->gfx[gfxnum],
code, color,
0, 0,
x, y,
@@ -259,7 +252,7 @@ VIDEO_UPDATE( cvs )
collision_color = 0x102;
}
- drawgfx(cvs_collision_background, screen->machine->gfx[0],
+ drawgfx(cvs_collision_background, screen->machine->gfx[gfxnum],
code, collision_color,
0, 0,
x, y,
diff --git a/src/mame/video/dassault.c b/src/mame/video/dassault.c
index 046f403e6e1..f1ca1c2a923 100644
--- a/src/mame/video/dassault.c
+++ b/src/mame/video/dassault.c
@@ -20,7 +20,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
{
for (offs = 0x800-4;offs >= 0; offs -= 4)
{
- int trans=TRANSPARENCY_PEN, pmask=0;
+ int alpha=0xff, pmask=0;
/* Draw the main spritebank after the other one */
if (bank==0)
@@ -41,7 +41,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
/* Alpha on chip 2 only */
if (bank==1 && x&0xc000)
- trans=TRANSPARENCY_ALPHA;
+ alpha=0x80;
y = spritebase[offs];
flash=y&0x1000;
@@ -134,7 +134,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
colour,
fx,fy,
x,y + mult * multi,
- cliprect,trans,0,pmask,1<<bank, 1);
+ cliprect,0,pmask,1<<bank, 1, alpha);
multi--;
}
@@ -157,8 +157,6 @@ VIDEO_START( dassault )
deco16_set_tilemap_bank_callback(1,dassault_bank_callback);
deco16_set_tilemap_bank_callback(2,dassault_bank_callback);
deco16_set_tilemap_bank_callback(3,dassault_bank_callback);
-
- alpha_set_level(0x80);
}
/******************************************************************************/
diff --git a/src/mame/video/deco16ic.c b/src/mame/video/deco16ic.c
index 4ce1794e6f1..51b029e09e3 100644
--- a/src/mame/video/deco16ic.c
+++ b/src/mame/video/deco16ic.c
@@ -838,13 +838,13 @@ void deco16_clear_sprite_priority_bitmap(void)
void deco16_pdrawgfx(running_machine *machine,
bitmap_t *dest,const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri)
+ const rectangle *clip,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha)
{
int ox,oy,cx,cy;
int x_index,y_index,x,y;
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- int source_base = (code % gfx->total_elements) * gfx->height;
+ const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
/* check bounds */
ox = sx;
@@ -864,7 +864,7 @@ void deco16_pdrawgfx(running_machine *machine,
for( y=0; y<16-cy; y++ )
{
- UINT8 *source = gfx->gfxdata + ((source_base+y_index) * gfx->line_modulo);
+ const UINT8 *source = code_base + (y_index * gfx->line_modulo);
UINT32 *destb = BITMAP_ADDR32(dest, sy, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
UINT8 *spri = BITMAP_ADDR8(sprite_priority_bitmap, sy, 0);
@@ -879,8 +879,8 @@ void deco16_pdrawgfx(running_machine *machine,
if( c != transparent_color && x >= 0 && x < 320 )
{
if (pri_mask>pri[x] && sprite_mask>spri[x]) {
- if (transparency == TRANSPARENCY_ALPHA)
- destb[x] = alpha_blend32(destb[x], pal[c]);
+ if (alpha != 0xff)
+ destb[x] = alpha_blend_r32(destb[x], pal[c], alpha);
else
destb[x] = pal[c];
if (write_pri)
diff --git a/src/mame/video/deco32.c b/src/mame/video/deco32.c
index 23af89ccfe5..598d59199ce 100644
--- a/src/mame/video/deco32.c
+++ b/src/mame/video/deco32.c
@@ -284,7 +284,7 @@ static void fghthist_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
for (offs = 0x400 - 4; offs >= 0; offs -=4)
{
int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0;
- int trans;
+ int alpha = 0xff;
sprite = spritedata[offs+1] & 0xffff;
@@ -292,7 +292,6 @@ static void fghthist_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
flash=y&0x1000;
if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
- trans=TRANSPARENCY_PEN;
x = spritedata[offs+2];
colour = (x >>9) & colourmask;
@@ -332,7 +331,7 @@ static void fghthist_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
colour,
fx,fy,
x,y + mult * multi,
- cliprect,trans,0,pri,1<<gfxbank, 1);
+ cliprect,0,pri,1<<gfxbank, 1, alpha);
multi--;
}
@@ -348,11 +347,10 @@ static void deco32_draw_sprite(bitmap_t *dest,const gfx_element *gfx,
UINT32 code,UINT32 priority,int flipx,int flipy,int sx,int sy,
const rectangle *clip)
{
+ const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int ox,oy,cx,cy;
int x_index,y_index,x,y;
- int source_base = (code % gfx->total_elements) * gfx->height;
-
/* check bounds */
ox = sx;
oy = sy;
@@ -371,7 +369,7 @@ static void deco32_draw_sprite(bitmap_t *dest,const gfx_element *gfx,
for( y=0; y<16-cy; y++ )
{
- UINT8 *source = gfx->gfxdata + ((source_base+y_index) * gfx->line_modulo);
+ const UINT8 *source = code_base + y_index * gfx->line_modulo;
UINT16 *destb = BITMAP_ADDR16(dest, sy, 0);
if (flipx) { source+=15-(sx-ox); x_index=-1; } else { x_index=1; source+=(sx-ox); }
@@ -458,8 +456,8 @@ static void nslasher_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
INLINE void dragngun_drawgfxzoom( running_machine *machine,
bitmap_t *dest_bmp,const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
- int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int sprite_screen_height )
+ const rectangle *clip,int transparent_color,
+ int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int sprite_screen_height, UINT8 alpha )
{
rectangle myclip;
@@ -492,7 +490,7 @@ INLINE void dragngun_drawgfxzoom( running_machine *machine,
if( gfx )
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- int source_base = (code % gfx->total_elements) * gfx->height;
+ const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
if (sprite_screen_width && sprite_screen_height)
{
@@ -558,13 +556,13 @@ INLINE void dragngun_drawgfxzoom( running_machine *machine,
int y;
/* case 1: TRANSPARENCY_PEN */
- if (transparency == TRANSPARENCY_PEN)
+ if (alpha == 0xff)
{
if (pri_buffer)
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
@@ -588,7 +586,7 @@ INLINE void dragngun_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -604,14 +602,14 @@ INLINE void dragngun_drawgfxzoom( running_machine *machine,
}
}
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
+ /* alpha-blended */
+ else
{
if (pri_buffer)
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
@@ -622,7 +620,7 @@ INLINE void dragngun_drawgfxzoom( running_machine *machine,
if( c != transparent_color )
{
if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = alpha_blend32(dest[x], pal[c]);
+ dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
pri[x] = 31;
}
x_index += dx;
@@ -635,14 +633,14 @@ INLINE void dragngun_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>16];
- if( c != transparent_color ) dest[x] = alpha_blend32(dest[x], pal[c]);
+ if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
x_index += dx;
}
@@ -713,7 +711,7 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
for (offs = 0;offs < 0x800;offs += 8)
{
- int sx,sy,colour,fx,fy,w,h,x,y,bx,by,trans,scalex,scaley;
+ int sx,sy,colour,fx,fy,w,h,x,y,bx,by,alpha,scalex,scaley;
int zoomx,zoomy;
int xpos,ypos;
@@ -743,9 +741,9 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
colour = spritedata[offs+6]&0x1f;
if (spritedata[offs+6]&0x80)
- trans=TRANSPARENCY_ALPHA;
+ alpha=0x80;
else
- trans=TRANSPARENCY_PEN;
+ alpha=0xff;
fx = spritedata[offs+4]&0x8000;
fy = spritedata[offs+5]&0x8000;
@@ -808,15 +806,15 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co
colour,
fx,fy,
xpos>>16,ypos>>16,
- cliprect,trans,15,zoomx,zoomy,NULL,0,
- ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16) );
+ cliprect,15,zoomx,zoomy,NULL,0,
+ ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha );
else
- drawgfx(bitmap,machine->gfx[bank],
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[bank],
sprite,
colour,
fx,fy,
xpos>>16,ypos>>16,
- cliprect,trans,15);
+ 15,alpha);
if (fx)
xpos-=zoomx<<4;
@@ -1006,7 +1004,6 @@ VIDEO_START( dragngun )
deco32_pf2_colourbank=deco32_pf4_colourbank=0;
- alpha_set_level(0x80);
state_save_register_global(machine, dragngun_sprite_ctrl);
has_ace_ram=0;
}
@@ -1030,7 +1027,6 @@ VIDEO_START( lockload )
deco32_pf2_colourbank=deco32_pf4_colourbank=0;
- alpha_set_level(0x80);
state_save_register_global(machine, dragngun_sprite_ctrl);
has_ace_ram=0;
}
@@ -1061,7 +1057,6 @@ VIDEO_START( nslasher )
deco32_pf2_colourbank=16;
deco32_pf4_colourbank=16;
state_save_register_global(machine, deco32_pri);
- alpha_set_level(0x80);
has_ace_ram=1;
}
@@ -1483,13 +1478,11 @@ static void mixDualAlphaSprites(running_machine* machine, bitmap_t *bitmap, cons
Pri 2 -
Pri 3 -
*/
- alpha_set_level(0x80);
/* Alpha values are tied to ACE ram... */
//int alpha=((deco32_ace_ram[0x0 + (((priColAlphaPal1&0xf0)>>4)/2)]) * 8)-1;
//if (alpha<0)
// alpha=0;
- //alpha_set_level(255-alpha);
/* I don't really understand how object ACE ram is really hooked up,
the only obvious place in Night Slashers is the stagecoach in level 2 */
@@ -1497,14 +1490,14 @@ static void mixDualAlphaSprites(running_machine* machine, bitmap_t *bitmap, cons
if (pri1==0 && (((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2))))
{
if ((deco32_pri&1)==0 || ((deco32_pri&1)==1 && tilemapPri[x]<4) || ((deco32_pri&1)==1 && mixAlphaTilemap))
- destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
+ destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
}
else if (pri1==1 && ((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2)))
- destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
+ destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
else if (pri1==2)// TOdo
- destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
+ destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
else if (pri1==3)// TOdo
- destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
+ destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
}
else
{
@@ -1538,9 +1531,8 @@ static void mixDualAlphaSprites(running_machine* machine, bitmap_t *bitmap, cons
int alpha=((deco32_ace_ram[0x17 + (((p&0xf0)>>4)/2)]) * 8)-1;
if (alpha<0)
alpha=0;
- alpha_set_level(255-alpha);
- destLine[x]=alpha_blend32(destLine[x], pal2[p]);
+ destLine[x]=alpha_blend_r32(destLine[x], pal2[p], 255-alpha);
}
}
}
diff --git a/src/mame/video/deco_mlc.c b/src/mame/video/deco_mlc.c
index 0ff4213c947..ab698aa974e 100644
--- a/src/mame/video/deco_mlc.c
+++ b/src/mame/video/deco_mlc.c
@@ -20,8 +20,6 @@ UINT32 *mlc_vram, *mlc_clip_ram;
VIDEO_START( mlc )
{
- alpha_set_level(0x80);
-
if (machine->gfx[0]->color_granularity==16)
colour_mask=0x7f;
else if (machine->gfx[0]->color_granularity==32)
@@ -65,8 +63,8 @@ static void blitRaster(bitmap_t *bitmap, int rasterMode)
static void mlc_drawgfxzoom(running_machine *machine,
bitmap_t *dest_bmp,const gfx_element *gfx,
UINT32 code1,UINT32 code2, UINT32 color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,int use8bpp,
- int scalex, int scaley)
+ const rectangle *clip,int transparent_color,int use8bpp,
+ int scalex, int scaley,int alpha)
{
rectangle myclip;
@@ -99,8 +97,8 @@ static void mlc_drawgfxzoom(running_machine *machine,
if( gfx )
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- int source_base1 = (code1 % gfx->total_elements) * gfx->height;
- int source_base2 = (code2 % gfx->total_elements) * gfx->height;
+ const UINT8 *code_base1 = gfx_element_get_data(gfx, code1 % gfx->total_elements);
+ const UINT8 *code_base2 = gfx_element_get_data(gfx, code2 % gfx->total_elements);
int sprite_screen_height = (scaley*gfx->height+(sy&0xffff))>>16;
int sprite_screen_width = (scalex*gfx->width+(sx&0xffff))>>16;
@@ -172,13 +170,13 @@ static void mlc_drawgfxzoom(running_machine *machine,
int y;
/* case 1: TRANSPARENCY_PEN */
- if (transparency == TRANSPARENCY_PEN)
+ if (alpha == 0xff)
{
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source1 = gfx->gfxdata + (source_base1+(y_index>>16)) * gfx->line_modulo;
- UINT8 *source2 = gfx->gfxdata + (source_base2+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source1 = code_base1 + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source2 = code_base2 + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -199,20 +197,20 @@ static void mlc_drawgfxzoom(running_machine *machine,
}
}
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
+ /* case 6: alpha blended */
+ else
{
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base1+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source = code_base1 + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x, x_index = x_index_base;
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>16];
- if( c != transparent_color ) dest[x] = alpha_blend32(dest[x], 0); //pal[c]);
+ if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], 0, alpha); //pal[c]);
x_index += dx;
}
@@ -237,7 +235,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan
int sprite2=0,indx2=0,use8bppMode=0;
int yscale,xscale;
int ybase,yinc;
- int trans;
+ int alpha;
int useIndicesInRom=0;
int hibits=0;
int tileFormat=0;
@@ -325,9 +323,9 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan
/* Any colours out of range (for the bpp value) trigger 'shadow' mode */
if (color & (colour_mask+1))
- trans=TRANSPARENCY_ALPHA;
+ alpha=0x80;
else
- trans=TRANSPARENCY_PEN;
+ alpha=0xff;
color&=colour_mask;
/* If this bit is set, combine this block with the next one */
@@ -491,8 +489,8 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan
/*rasterMode ? temp_bitmap : */bitmap,machine->gfx[0],
tile,tile2,
color + colorOffset,fx,fy,xbase,ybase,
- &user_clip,trans,0,
- use8bppMode,(xscale<<8),(yscale<<8));
+ &user_clip,0,
+ use8bppMode,(xscale<<8),(yscale<<8),alpha);
sprite++;
sprite2++;
diff --git a/src/mame/video/decocass.c b/src/mame/video/decocass.c
index 127aaeb80e1..779a1ae7732 100644
--- a/src/mame/video/decocass.c
+++ b/src/mame/video/decocass.c
@@ -35,11 +35,6 @@ size_t decocass_objectram_size;
static tilemap *fg_tilemap, *bg_tilemap_l, *bg_tilemap_r;
-static char *sprite_dirty;
-static char *char_dirty;
-static char *tile_dirty;
-static char object_dirty;
-
static rectangle bg_tilemap_l_clip;
static rectangle bg_tilemap_r_clip;
@@ -215,9 +210,9 @@ WRITE8_HANDLER( decocass_charram_w )
{
decocass_charram[offset] = data;
/* dirty sprite */
- sprite_dirty[(offset >> 5) & 255] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[1], (offset >> 5) & 255);
/* dirty char */
- char_dirty[(offset >> 3) & 1023] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset >> 3) & 1023);
}
@@ -245,7 +240,7 @@ WRITE8_HANDLER( decocass_tileram_w )
{
decocass_tileram[offset] = data;
/* dirty tile (64 bytes per tile) */
- tile_dirty[(offset / 64) & 15] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[2], (offset / 64) & 15);
/* first 1KB of tile RAM is shared with tilemap RAM */
if (offset < decocass_bgvideoram_size)
mark_bg_tile_dirty( offset );
@@ -255,7 +250,8 @@ WRITE8_HANDLER( decocass_objectram_w )
{
decocass_objectram[offset] = data;
/* dirty the object */
- object_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[3], 0);
+ gfx_element_mark_dirty(space->machine->gfx[3], 1);
}
WRITE8_HANDLER( decocass_bgvideoram_w )
@@ -497,84 +493,8 @@ static void draw_missiles(running_machine *machine,bitmap_t *bitmap, const recta
}
-static void decode_modified(running_machine* machine, UINT8 *sprite_ram, int interleave)
-{
- int i,offs;
-
- /* decode dirty characters */
- for (offs = decocass_fgvideoram_size - 1;offs >= 0;offs--)
- {
- int code;
-
- code = decocass_fgvideoram[offs] + 256 * (decocass_colorram[offs] & 3);
-
- switch (char_dirty[code])
- {
- case 1:
- decodechar(machine->gfx[0],code,decocass_charram);
- char_dirty[code] = 2;
- /* fall through */
- case 2:
- tilemap_mark_tile_dirty(fg_tilemap, offs);
- break;
- default:
- break;
- }
- }
-
- for (i = 0; i < 1024; i++)
- {
- if (char_dirty[i] == 2)
- char_dirty[i] = 0;
- }
-
- /* decode dirty sprites */
- for (i = 0, offs = 0;i < 8; i++, offs += 4*interleave)
- {
- int code;
-
- code = sprite_ram[offs + interleave];
- if (sprite_dirty[code])
- {
- sprite_dirty[code] = 0;
-
- decodechar(machine->gfx[1],code,decocass_charram);
- }
- }
-
- /* decode dirty tiles */
- for (offs = 0; offs < decocass_bgvideoram_size; offs++)
- {
- int code = (decocass_tileram[offs] >> 4) & 15;
-
- if (tile_dirty[code])
- {
- tile_dirty[code] = 0;
-
- decodechar(machine->gfx[2],code,decocass_tileram);
-
- /* mark all visible tiles dirty */
- for (i = offs; i < decocass_bgvideoram_size; i++)
- if (code == ((decocass_tileram[i] >> 4) & 15))
- mark_bg_tile_dirty(i);
- }
- }
-
- /* decode object if it is dirty */
- if (object_dirty)
- {
- decodechar(machine->gfx[3], 0, decocass_objectram);
- decodechar(machine->gfx[3], 1, decocass_objectram);
- object_dirty = 0;
- }
-}
-
VIDEO_START( decocass )
{
- sprite_dirty = auto_malloc(256);
- char_dirty = auto_malloc(1024);
- tile_dirty = auto_malloc(16);
-
bg_tilemap_l = tilemap_create( machine, get_bg_l_tile_info, bgvideoram_scan_cols, 16, 16, 32, 32 );
bg_tilemap_r = tilemap_create( machine, get_bg_r_tile_info, bgvideoram_scan_cols, 16, 16, 32, 32 );
fg_tilemap = tilemap_create( machine, get_fg_tile_info, fgvideoram_scan_cols, 8, 8, 32, 32 );
@@ -584,7 +504,7 @@ VIDEO_START( decocass )
tilemap_set_transparent_pen( fg_tilemap, 0 );
bg_tilemap_l_clip = *video_screen_get_visible_area(machine->primary_screen);
- bg_tilemap_l_clip.max_y = 256 / 2;
+ bg_tilemap_l_clip.max_y = 256 / 2 - 1;
bg_tilemap_r_clip = *video_screen_get_visible_area(machine->primary_screen);
bg_tilemap_r_clip.min_y = 256 / 2;
@@ -592,6 +512,11 @@ VIDEO_START( decocass )
/* background videroam bits D0-D3 are shared with the tileram */
decocass_bgvideoram = decocass_tileram;
decocass_bgvideoram_size = 0x0400; /* d000-d3ff */
+
+ gfx_element_set_source(machine->gfx[0], decocass_charram);
+ gfx_element_set_source(machine->gfx[1], decocass_charram);
+ gfx_element_set_source(machine->gfx[2], decocass_tileram);
+ gfx_element_set_source(machine->gfx[3], decocass_objectram);
}
VIDEO_UPDATE( decocass )
@@ -629,8 +554,6 @@ VIDEO_UPDATE( decocass )
bitmap_fill( bitmap, cliprect , 0);
- decode_modified(screen->machine, decocass_fgvideoram, 0x20 );
-
scrolly_l = back_vl_shift;
scrolly_r = 256 - back_vr_shift;
diff --git a/src/mame/video/equites.c b/src/mame/video/equites.c
index 552aaacd0bf..a7116562d46 100644
--- a/src/mame/video/equites.c
+++ b/src/mame/video/equites.c
@@ -351,7 +351,7 @@ static void splndrbt_draw_sprites(running_machine *machine, bitmap_t *bitmap, co
// const UINT8 * const xromline = xrom + (scalex << 4);
const UINT8 * const yromline = yrom + (scaley << 4) + (15 - scaley);
- const UINT8* const srcgfx = gfx->gfxdata + tile * gfx->char_modulo;
+ const UINT8* const srcgfx = gfx_element_get_data(gfx, tile);
const pen_t *paldata = &machine->pens[gfx->color_base + gfx->color_granularity * color];
int x,yy;
diff --git a/src/mame/video/exerion.c b/src/mame/video/exerion.c
index 195a2359a8b..a9ee00bc3a1 100644
--- a/src/mame/video/exerion.c
+++ b/src/mame/video/exerion.c
@@ -343,7 +343,7 @@ static void draw_background(bitmap_t *bitmap, const rectangle *cliprect)
}
/* draw the scanline */
- draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1);
+ draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL);
}
}
diff --git a/src/mame/video/exidy440.c b/src/mame/video/exidy440.c
index 841b131435d..beb722d83cc 100644
--- a/src/mame/video/exidy440.c
+++ b/src/mame/video/exidy440.c
@@ -420,7 +420,7 @@ static void update_screen(const device_config *screen, bitmap_t *bitmap, const r
sy -= (VBSTART - VBEND);
/* draw line */
- draw_scanline8(bitmap, 0, y, (HBSTART - HBEND), &local_videoram[sy * 512], NULL, -1);
+ draw_scanline8(bitmap, 0, y, (HBSTART - HBEND), &local_videoram[sy * 512], NULL);
}
/* draw the sprites */
diff --git a/src/mame/video/f1gp.c b/src/mame/video/f1gp.c
index e802d88ff9e..eb5ba9db54a 100644
--- a/src/mame/video/f1gp.c
+++ b/src/mame/video/f1gp.c
@@ -10,8 +10,7 @@ UINT16 *f1gpb_rozregs, *f1gpb_fgregs;
size_t f1gp_spr1cgram_size,f1gp_spr2cgram_size;
static UINT16 *zoomdata;
-static int dirtygfx,flipscreen,gfxctrl;
-static UINT8 *dirtychar;
+static int flipscreen,gfxctrl;
#define TOTAL_CHARS 0x800
@@ -63,10 +62,8 @@ VIDEO_START( f1gp )
tilemap_set_transparent_pen(fg_tilemap,0xff);
- dirtychar = auto_malloc(TOTAL_CHARS);
- memset(dirtychar,1,TOTAL_CHARS);
-
zoomdata = (UINT16 *)memory_region(machine, "gfx4");
+ gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata);
}
VIDEO_START( f1gpb )
@@ -76,10 +73,8 @@ VIDEO_START( f1gpb )
tilemap_set_transparent_pen(fg_tilemap,0xff);
- dirtychar = auto_malloc(TOTAL_CHARS);
- memset(dirtychar,1,TOTAL_CHARS);
-
zoomdata = (UINT16 *)memory_region(machine, "gfx4");
+ gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata);
}
VIDEO_START( f1gp2 )
@@ -95,11 +90,6 @@ VIDEO_START( f1gp2 )
tilemap_set_scrolldx(fg_tilemap,-80,0);
tilemap_set_scrolldy(fg_tilemap,-26,0);
-
- dirtychar = auto_malloc(TOTAL_CHARS);
- memset(dirtychar,1,TOTAL_CHARS);
-
- zoomdata = (UINT16 *)memory_region(machine, "gfx4");
}
@@ -116,13 +106,8 @@ READ16_HANDLER( f1gp_zoomdata_r )
WRITE16_HANDLER( f1gp_zoomdata_w )
{
- int oldword = zoomdata[offset];
COMBINE_DATA(&zoomdata[offset]);
- if (oldword != zoomdata[offset])
- {
- dirtygfx = 1;
- dirtychar[offset / 64] = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[3], offset / 64);
}
READ16_HANDLER( f1gp_rozvideoram_r )
@@ -330,26 +315,6 @@ static void f1gpb_draw_sprites(running_machine *machine, bitmap_t *bitmap,const
VIDEO_UPDATE( f1gp )
{
- if (dirtygfx)
- {
- int i;
-
- dirtygfx = 0;
-
- for (i = 0;i < TOTAL_CHARS;i++)
- {
- if (dirtychar[i])
- {
- dirtychar[i] = 0;
- decodechar(screen->machine->gfx[3],i,(UINT8 *)zoomdata);
- }
- }
-
- tilemap_mark_all_tiles_dirty(roz_tilemap);
- }
-
-
-
bitmap_fill(priority_bitmap, cliprect, 0);
K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,0);
@@ -375,24 +340,6 @@ VIDEO_UPDATE( f1gpb )
UINT32 startx,starty;
int incxx,incxy,incyx,incyy;
- if (dirtygfx)
- {
- int i;
-
- dirtygfx = 0;
-
- for (i = 0;i < TOTAL_CHARS;i++)
- {
- if (dirtychar[i])
- {
- dirtychar[i] = 0;
- decodechar(screen->machine->gfx[3],i,(UINT8 *)zoomdata);
- }
- }
-
- tilemap_mark_all_tiles_dirty(roz_tilemap);
- }
-
incxy = (INT16)f1gpb_rozregs[1];
incyx = -incxy;
incxx = incyy = (INT16)f1gpb_rozregs[3];
diff --git a/src/mame/video/gaelco2.c b/src/mame/video/gaelco2.c
index c9c3b4ecff8..62bc690eac4 100644
--- a/src/mame/video/gaelco2.c
+++ b/src/mame/video/gaelco2.c
@@ -392,7 +392,7 @@ static void draw_sprites(const device_config *screen, bitmap_t *bitmap, const re
} else { /* last palette entry is reserved for shadows and highlights */
/* get a pointer to the current sprite's gfx data */
- UINT8 *gfx_src = gfx->gfxdata + (number % gfx->total_elements)*gfx->char_modulo;
+ const UINT8 *gfx_src = gfx_element_get_data(gfx, number % gfx->total_elements);
for (py = 0; py < gfx->height; py++){
/* get a pointer to the current line in the screen bitmap */
diff --git a/src/mame/video/gaiden.c b/src/mame/video/gaiden.c
index 1b05af24ccc..b3c5fe5cb9a 100644
--- a/src/mame/video/gaiden.c
+++ b/src/mame/video/gaiden.c
@@ -361,13 +361,12 @@ static void gaiden_draw_sprites(running_machine *machine, bitmap_t *bitmap, cons
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
- pdrawgfx(bitmap, gfx,
+ pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
number + layout[row][col],
gfx->color_base + color * gfx->color_granularity,
flipx, flipy,
sx, sy,
- cliprect, TRANSPARENCY_PEN_RAW, 0,
- priority_mask);
+ priority_bitmap, priority_mask, 0);
}
}
}
@@ -462,13 +461,12 @@ static void raiga_draw_sprites(running_machine *machine, bitmap_t *bitmap_bg, bi
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
- pdrawgfx(bitmap_sp, gfx,
+ pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx,
number + layout[row][col],
gfx->color_base + color * gfx->color_granularity,
flipx, flipy,
sx, sy,
- cliprect, TRANSPARENCY_PEN_RAW, 0,
- priority_mask);
+ priority_bitmap, priority_mask, 0);
}
}
}
@@ -483,13 +481,12 @@ static void raiga_draw_sprites(running_machine *machine, bitmap_t *bitmap_bg, bi
int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
- pdrawgfx(bitmap, gfx,
+ pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
number + layout[row][col],
gfx->color_base + color * gfx->color_granularity,
flipx, flipy,
sx, sy,
- cliprect, TRANSPARENCY_PEN_RAW, 0,
- priority_mask);
+ priority_bitmap, priority_mask, 0);
}
}
}
@@ -541,22 +538,18 @@ static void drgnbowl_draw_sprites(running_machine *machine, bitmap_t *bitmap, co
else
priority_mask = 0;
- pdrawgfx(bitmap,machine->gfx[3],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[3],
code,
machine->gfx[3]->color_base + color * machine->gfx[3]->color_granularity,
flipx,flipy,x,y,
- cliprect,
- TRANSPARENCY_PEN_RAW,15,
- priority_mask);
+ priority_bitmap, priority_mask,15);
/* wrap x*/
- pdrawgfx(bitmap,machine->gfx[3],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[3],
code,
machine->gfx[3]->color_base + color * machine->gfx[3]->color_granularity,
flipx,flipy,x-512,y,
- cliprect,
- TRANSPARENCY_PEN_RAW,15,
- priority_mask);
+ priority_bitmap, priority_mask,15);
}
}
diff --git a/src/mame/video/gbusters.c b/src/mame/video/gbusters.c
index 5e9ecd135ae..0286f0b6656 100644
--- a/src/mame/video/gbusters.c
+++ b/src/mame/video/gbusters.c
@@ -57,20 +57,20 @@ VIDEO_UPDATE( gbusters )
/* sprite priority 3 = disable */
if (gbusters_priority)
{
-// K051960_sprites_draw(bitmap,cliprect,1,1); /* are these used? */
+// K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1); /* are these used? */
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
- K051960_sprites_draw(bitmap,cliprect,2,2);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
}
else
{
-// K051960_sprites_draw(bitmap,cliprect,1,1); /* are these used? */
+// K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1); /* are these used? */
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
- K051960_sprites_draw(bitmap,cliprect,2,2);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
}
return 0;
diff --git a/src/mame/video/gottlieb.c b/src/mame/video/gottlieb.c
index 069fe6b2a93..6c31f78e155 100644
--- a/src/mame/video/gottlieb.c
+++ b/src/mame/video/gottlieb.c
@@ -122,8 +122,7 @@ WRITE8_HANDLER( gottlieb_charram_w )
if (gottlieb_charram[offset] != data)
{
gottlieb_charram[offset] = data;
- decodechar(space->machine->gfx[0], offset / 32, gottlieb_charram);
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[0], offset / 32);
}
}
@@ -163,6 +162,8 @@ VIDEO_START( gottlieb )
tilemap_set_transparent_pen(bg_tilemap, 0);
tilemap_set_scrolldx(bg_tilemap, 0, 318 - 256);
+ gfx_element_set_source(machine->gfx[0], gottlieb_charram);
+
/* save some state */
state_save_register_global(machine, background_priority);
state_save_register_global(machine, spritebank);
diff --git a/src/mame/video/gradius3.c b/src/mame/video/gradius3.c
index 0a89411c4fe..5bda96bd62c 100644
--- a/src/mame/video/gradius3.c
+++ b/src/mame/video/gradius3.c
@@ -8,8 +8,6 @@
UINT16 *gradius3_gfxram;
int gradius3_priority;
static int layer_colorbase[3],sprite_colorbase;
-static int dirtygfx;
-static UINT8 *dirtychar;
@@ -77,10 +75,9 @@ VIDEO_START( gradius3 )
/* re-decode the sprites because the ROMs are connected to the custom IC differently
from how they are connected to the CPU. */
for (i = 0;i < TOTAL_SPRITES;i++)
- decodechar(machine->gfx[1],i,memory_region(machine, "gfx2"));
+ gfx_element_mark_dirty(machine->gfx[1],i);
- dirtychar = auto_malloc(TOTAL_CHARS);
- memset(dirtychar,1,TOTAL_CHARS);
+ gfx_element_set_source(machine->gfx[0], (UINT8 *)gradius3_gfxram);
}
@@ -103,10 +100,7 @@ WRITE16_HANDLER( gradius3_gfxram_w )
int oldword = gradius3_gfxram[offset];
COMBINE_DATA(&gradius3_gfxram[offset]);
if (oldword != gradius3_gfxram[offset])
- {
- dirtygfx = 1;
- dirtychar[offset / 16] = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[0], offset / 16);
}
@@ -125,24 +119,6 @@ VIDEO_UPDATE( gradius3 )
K052109_w(space,0x1d80,0x10);
K052109_w(space,0x1f00,0x32);
- if (dirtygfx)
- {
- int i;
-
- dirtygfx = 0;
-
- for (i = 0;i < TOTAL_CHARS;i++)
- {
- if (dirtychar[i])
- {
- dirtychar[i] = 0;
- decodechar(screen->machine->gfx[0],i,(UINT8 *)gradius3_gfxram);
- }
- }
-
- tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
- }
-
K052109_tilemap_update();
bitmap_fill(priority_bitmap,cliprect,0);
@@ -159,6 +135,6 @@ VIDEO_UPDATE( gradius3 )
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4);
}
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
diff --git a/src/mame/video/grchamp.c b/src/mame/video/grchamp.c
index 375690e16e2..1309caba86b 100644
--- a/src/mame/video/grchamp.c
+++ b/src/mame/video/grchamp.c
@@ -283,7 +283,7 @@ static void draw_objects(running_machine *machine, grchamp_state *state, int y,
int code = (codeflip & 0x3f) + (change >> 2);
int yflip = (codeflip & 0x80) ? 0x0f : 0x00;
int xflip = (codeflip & 0x40) ? 0x0f : 0x00;
- const UINT8 *src = gfx->gfxdata + code * gfx->char_modulo + ((dy ^ yflip) & 15) * gfx->line_modulo;
+ const UINT8 *src = gfx_element_get_data(gfx, code) + ((dy ^ yflip) & 15) * gfx->line_modulo;
/* the third byte is: color in bits 0-2 */
int color = (state->spriteram[0x42 + (dataoffs & ~0x20)] & 0x07) << 2;
@@ -327,7 +327,7 @@ static void draw_objects(running_machine *machine, grchamp_state *state, int y,
int dy = sy + ~y;
int color = (state->spriteram[0x01 + dataoffs] & 0x07) << 2;
int code = state->videoram[hprime | ((dy & 0xf8) << 2)] + change;
- const UINT8 *src = gfx->gfxdata + code * gfx->char_modulo + (dy & 7) * gfx->line_modulo;
+ const UINT8 *src = gfx_element_get_data(gfx, code) + (dy & 7) * gfx->line_modulo;
int x;
/* draw 8 pixels */
diff --git a/src/mame/video/gridlee.c b/src/mame/video/gridlee.c
index bb79ada1dad..06aa143ef63 100644
--- a/src/mame/video/gridlee.c
+++ b/src/mame/video/gridlee.c
@@ -160,7 +160,7 @@ VIDEO_UPDATE( gridlee )
{
/* non-flipped: draw directly from the bitmap */
if (!gridlee_cocktail_flip)
- draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens + 16, -1);
+ draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens + 16);
/* flipped: x-flip the scanline into a temp buffer and draw that */
else
@@ -171,7 +171,7 @@ VIDEO_UPDATE( gridlee )
for (xx = 0; xx < 256; xx++)
temp[xx] = local_videoram[srcy * 256 + 255 - xx];
- draw_scanline8(bitmap, 0, y, 256, temp, pens + 16, -1);
+ draw_scanline8(bitmap, 0, y, 256, temp, pens + 16);
}
}
diff --git a/src/mame/video/gticlub.c b/src/mame/video/gticlub.c
index 4dc12e26c1e..4ac18850542 100644
--- a/src/mame/video/gticlub.c
+++ b/src/mame/video/gticlub.c
@@ -19,7 +19,6 @@ struct _poly_extra_data
// defined in drivers/nwk-tr.c
int K001604_vh_start(running_machine *machine, int chip);
-void K001604_tile_update(running_machine *machine, int chip);
void K001604_draw_front_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
@@ -989,7 +988,6 @@ VIDEO_START( gticlub )
VIDEO_UPDATE( gticlub )
{
- K001604_tile_update(screen->machine, 0);
K001604_draw_back_layer(0, bitmap, cliprect);
K001005_draw(bitmap, cliprect);
diff --git a/src/mame/video/hyprduel.c b/src/mame/video/hyprduel.c
index 799662b8730..c29474ad82c 100644
--- a/src/mame/video/hyprduel.c
+++ b/src/mame/video/hyprduel.c
@@ -408,6 +408,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int i, pri;
static const int primask[4] = { 0x0000, 0xff00, 0xff00|0xf0f0, 0xff00|0xf0f0|0xcccc };
+ UINT8 dirty = 0;
for (i=0; i<0x20; i++)
{
@@ -483,6 +484,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
gfx.line_modulo = width;
gfx.char_modulo = 0; /* doesn't matter */
gfx.flags = 0;
+ gfx.dirty = &dirty;
gfx.machine = machine;
/* Bounds checking */
@@ -515,6 +517,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
gfx.line_modulo = width/2;
gfx.char_modulo = 0; /* doesn't matter */
gfx.flags = GFX_ELEMENT_PACKED;
+ gfx.dirty = &dirty;
gfx.machine = machine;
/* Bounds checking */
diff --git a/src/mame/video/irobot.c b/src/mame/video/irobot.c
index d35b92c4b7b..44b18f97d36 100644
--- a/src/mame/video/irobot.c
+++ b/src/mame/video/irobot.c
@@ -353,7 +353,7 @@ VIDEO_UPDATE( irobot )
/* copy the polygon bitmap */
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
- draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &bitmap_base[y * BITMAP_WIDTH], NULL, -1);
+ draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &bitmap_base[y * BITMAP_WIDTH], NULL);
/* redraw the non-zero characters in the alpha layer */
for (y = offs = 0; y < 32; y++)
diff --git a/src/mame/video/itech32.c b/src/mame/video/itech32.c
index ee5272b8a56..1116818a73a 100644
--- a/src/mame/video/itech32.c
+++ b/src/mame/video/itech32.c
@@ -1475,12 +1475,12 @@ VIDEO_UPDATE( itech32 )
}
/* draw from the buffer */
- draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1);
+ draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL);
}
/* otherwise, draw directly from VRAM */
else
- draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &src1[cliprect->min_x], NULL, -1);
+ draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &src1[cliprect->min_x], NULL);
}
return 0;
}
diff --git a/src/mame/video/jalblend.c b/src/mame/video/jalblend.c
index 818be8bdbaf..309b8caa28f 100644
--- a/src/mame/video/jalblend.c
+++ b/src/mame/video/jalblend.c
@@ -75,7 +75,7 @@ void jal_blend_drawgfx(running_machine *machine,bitmap_t *dest_bmp,const gfx_ele
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)];
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int x_index_base, y_index, sx, sy, ex, ey;
int xinc, yinc;
@@ -128,7 +128,7 @@ void jal_blend_drawgfx(running_machine *machine,bitmap_t *dest_bmp,const gfx_ele
/* taken from case 7: TRANSPARENCY_ALPHARANGE */
for (y = sy; y < ey; y++)
{
- UINT8 *source = source_base + y_index*gfx->line_modulo;
+ const UINT8 *source = source_base + y_index*gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
int x_index = x_index_base;
for (x = sx; x < ex; x++)
@@ -159,7 +159,7 @@ void jal_blend_drawgfx(running_machine *machine,bitmap_t *dest_bmp,const gfx_ele
/* taken from case 7: TRANSPARENCY_ALPHARANGE */
for (y = sy; y < ey; y++)
{
- UINT8 *source = source_base + y_index*gfx->line_modulo;
+ const UINT8 *source = source_base + y_index*gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x_index = x_index_base;
for (x = sx; x < ex; x++)
diff --git a/src/mame/video/kaneko16.c b/src/mame/video/kaneko16.c
index 2ad0492d823..2c6905003f4 100644
--- a/src/mame/video/kaneko16.c
+++ b/src/mame/video/kaneko16.c
@@ -437,7 +437,7 @@ static void kaneko16_draw_sprites_custom(running_machine *machine, bitmap_t *des
const rectangle *clip,int priority)
{
pen_t pen_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
@@ -507,7 +507,7 @@ static void kaneko16_draw_sprites_custom(running_machine *machine, bitmap_t *des
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
diff --git a/src/mame/video/konamiic.c b/src/mame/video/konamiic.c
index 0f20c09e03a..7f23949373f 100644
--- a/src/mame/video/konamiic.c
+++ b/src/mame/video/konamiic.c
@@ -1212,11 +1212,7 @@ static void decode_gfx(running_machine *machine, int gfx_index, UINT8 *data, UIN
memcpy(&gl, layout, sizeof(gl));
gl.total = total;
- machine->gfx[gfx_index] = allocgfx(machine, &gl);
- decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements);
-
- /* set the color information */
- machine->gfx[gfx_index]->total_colors = machine->config->total_colors / (1 << bpp);
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &gl, data, machine->config->total_colors >> bpp, 0);
}
@@ -2477,7 +2473,7 @@ static int K051960_irq_enabled, K051960_nmi_enabled;
void K051960_vh_start(running_machine *machine,const char *gfx_memory_region,int plane_order,
void (*callback)(int *code,int *color,int *priority,int *shadow))
{
- int gfx_index,i;
+ int gfx_index;
UINT32 total;
static const gfx_layout spritelayout =
{
@@ -2548,12 +2544,6 @@ void K051960_vh_start(running_machine *machine,const char *gfx_memory_region,int
if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
popmessage("driver should use VIDEO_HAS_SHADOWS");
- /* prepare shadow draw table */
- gfx_drawmode_table[0] = DRAWMODE_NONE;
- for (i = 1;i < 15;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[15] = DRAWMODE_SHADOW;
-
K051960_dx = K051960_dy = 0;
K051960_memory_region = gfx_memory_region;
@@ -2730,11 +2720,15 @@ WRITE16_HANDLER( K051937_word_w )
* Note that Aliens also uses the shadow bit to select the second sprite bank.
*/
-void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority)
+void K051960_sprites_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority)
{
#define NUM_SPRITES 128
int offs,pri_code;
int sortedlist[NUM_SPRITES];
+ UINT8 drawmode_table[256];
+
+ memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
+ drawmode_table[0] = DRAWMODE_NONE;
for (offs = 0;offs < NUM_SPRITES;offs++)
sortedlist[offs] = -1;
@@ -2812,6 +2806,8 @@ void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_pri
flipy = !flipy;
}
+ drawmode_table[K051960_gfx->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+
if (zoomx == 0x10000 && zoomy == 0x10000)
{
int sx,sy;
@@ -2831,19 +2827,20 @@ void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_pri
else c += yoffset[y];
if (max_priority == -1)
- pdrawgfx(bitmap,K051960_gfx,
+ pdrawgfx_transtable(bitmap,cliprect,K051960_gfx,
c,
color,
flipx,flipy,
sx & 0x1ff,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,pri);
+ priority_bitmap,pri,
+ drawmode_table,machine->shadow_table);
else
- drawgfx(bitmap,K051960_gfx,
+ drawgfx_transtable(bitmap,cliprect,K051960_gfx,
c,
color,
flipx,flipy,
sx & 0x1ff,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0);
+ drawmode_table,machine->shadow_table);
}
}
}
@@ -2868,21 +2865,22 @@ void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_pri
else c += yoffset[y];
if (max_priority == -1)
- pdrawgfxzoom(bitmap,K051960_gfx,
+ pdrawgfxzoom_transtable(bitmap,cliprect,K051960_gfx,
c,
color,
flipx,flipy,
sx & 0x1ff,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
- (zw << 16) / 16,(zh << 16) / 16,pri);
+ (zw << 16) / 16,(zh << 16) / 16,
+ priority_bitmap,pri,
+ drawmode_table,machine->shadow_table);
else
- drawgfxzoom(bitmap,K051960_gfx,
+ drawgfxzoom_transtable(bitmap,cliprect,K051960_gfx,
c,
color,
flipx,flipy,
sx & 0x1ff,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
- (zw << 16) / 16,(zh << 16) / 16);
+ (zw << 16) / 16,(zh << 16) / 16,
+ drawmode_table,machine->shadow_table);
}
}
}
@@ -2999,7 +2997,7 @@ static int K053245_dx[MAX_K053245_CHIPS], K053245_dy[MAX_K053245_CHIPS];
void K053245_vh_start(running_machine *machine,int chip, const char *gfx_memory_region,int plane_order,
void (*callback)(int *code,int *color,int *priority))
{
- int gfx_index,i;
+ int gfx_index;
UINT32 total;
static const gfx_layout spritelayout =
{
@@ -3042,11 +3040,6 @@ void K053245_vh_start(running_machine *machine,int chip, const char *gfx_memory_
popmessage("driver should use VIDEO_HAS_SHADOWS");
- /* prepare shadow draw table */
- gfx_drawmode_table[0] = DRAWMODE_NONE;
- for (i = 1;i < 15;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[15] = DRAWMODE_SHADOW;
K05324x_z_rejection = -1;
K053245_memory_region[chip] = gfx_memory_region;
K053245_gfx[chip] = machine->gfx[gfx_index];
@@ -3244,12 +3237,16 @@ void K053244_bankselect(int chip, int bank)
* The rest of the sprite remains normal.
*/
-void K053245_sprites_draw(int chip, bitmap_t *bitmap,const rectangle *cliprect) //*
+void K053245_sprites_draw(running_machine *machine, int chip, bitmap_t *bitmap,const rectangle *cliprect) //*
{
#define NUM_SPRITES 128
int offs,pri_code,i;
int sortedlist[NUM_SPRITES];
int flipscreenX, flipscreenY, spriteoffsX, spriteoffsY;
+ UINT8 drawmode_table[256];
+
+ memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
+ drawmode_table[0] = DRAWMODE_NONE;
flipscreenX = K053244_regs[chip][5] & 0x01;
flipscreenY = K053244_regs[chip][5] & 0x02;
@@ -3372,6 +3369,8 @@ void K053245_sprites_draw(int chip, bitmap_t *bitmap,const rectangle *cliprect)
ox -= (zoomx * w) >> 13;
oy -= (zoomy * h) >> 13;
+ drawmode_table[K053245_gfx[chip]->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+
for (y = 0;y < h;y++)
{
int sx,sy,zw,zh;
@@ -3434,22 +3433,24 @@ void K053245_sprites_draw(int chip, bitmap_t *bitmap,const rectangle *cliprect)
if (zoomx == 0x10000 && zoomy == 0x10000)
{
- pdrawgfx(bitmap,K053245_gfx[chip],
+ pdrawgfx_transtable(bitmap,cliprect,K053245_gfx[chip],
c,
color,
fx,fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,pri);
+ priority_bitmap,pri,
+ drawmode_table,machine->shadow_table);
}
else
{
- pdrawgfxzoom(bitmap,K053245_gfx[chip],
+ pdrawgfxzoom_transtable(bitmap,cliprect,K053245_gfx[chip],
c,
color,
fx,fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
- (zw << 16) / 16,(zh << 16) / 16,pri);
+ (zw << 16) / 16,(zh << 16) / 16,
+ priority_bitmap,pri,
+ drawmode_table,machine->shadow_table);
}
}
@@ -3479,6 +3480,10 @@ void K053245_sprites_draw_lethal(running_machine *machine,int chip, bitmap_t *bi
int offs,pri_code,i;
int sortedlist[NUM_SPRITES];
int flipscreenX, flipscreenY, spriteoffsX, spriteoffsY;
+ UINT8 drawmode_table[256];
+
+ memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
+ drawmode_table[0] = DRAWMODE_NONE;
flipscreenX = K053244_regs[chip][5] & 0x01;
flipscreenY = K053244_regs[chip][5] & 0x02;
@@ -3601,6 +3606,8 @@ void K053245_sprites_draw_lethal(running_machine *machine,int chip, bitmap_t *bi
ox -= (zoomx * w) >> 13;
oy -= (zoomy * h) >> 13;
+ drawmode_table[machine->gfx[0]->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+
for (y = 0;y < h;y++)
{
int sx,sy,zw,zh;
@@ -3663,22 +3670,24 @@ void K053245_sprites_draw_lethal(running_machine *machine,int chip, bitmap_t *bi
if (zoomx == 0x10000 && zoomy == 0x10000)
{
- pdrawgfx(bitmap,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
+ pdrawgfx_transtable(bitmap,cliprect,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
c,
color,
fx,fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,pri);
+ priority_bitmap,pri,
+ drawmode_table,machine->shadow_table);
}
else
{
- pdrawgfxzoom(bitmap,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
+ pdrawgfxzoom_transtable(bitmap,cliprect,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
c,
color,
fx,fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
- (zw << 16) / 16,(zh << 16) / 16,pri);
+ (zw << 16) / 16,(zh << 16) / 16,
+ priority_bitmap,pri,
+ drawmode_table,machine->shadow_table);
}
}
@@ -3747,7 +3756,7 @@ void K053247_wraparound_enable(int status)
void K053247_vh_start(running_machine *machine, const char *gfx_memory_region, int dx, int dy, int plane_order,
void (*callback)(int *code,int *color,int *priority))
{
- int gfx_index,i;
+ int gfx_index;
UINT32 total;
static const gfx_layout spritelayout =
{
@@ -3795,12 +3804,6 @@ void K053247_vh_start(running_machine *machine, const char *gfx_memory_region, i
}
}
- /* prepare shadow draw table */
- gfx_drawmode_table[0] = DRAWMODE_NONE;
- for (i = 1;i < 15;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[15] = DRAWMODE_SHADOW;
-
K053247_dx = dx;
K053247_dy = dy;
K053247_wraparound = 1;
@@ -3871,7 +3874,7 @@ void K055673_vh_start(running_machine *machine, const char *gfx_memory_region, i
16*16*6
};
UINT8 *s1, *s2, *d;
- long i, c;
+ long i;
UINT16 *K055673_rom;
int size4;
@@ -3930,13 +3933,6 @@ void K055673_vh_start(running_machine *machine, const char *gfx_memory_region, i
if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
popmessage("driver should use VIDEO_HAS_SHADOWS");
- /* prepare shadow draw table */
- c = machine->gfx[gfx_index]->color_granularity-1;
- gfx_drawmode_table[0] = DRAWMODE_NONE;
- for (i = 1;i < c;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[c] = DRAWMODE_SHADOW;
-
K053247_dx = dx;
K053247_dy = dy;
K053247_wraparound = 1;
@@ -4221,8 +4217,15 @@ void K053247_sprites_draw(running_machine *machine, bitmap_t *bitmap,const recta
int offx = (short)((K053246_regs[0] << 8) | K053246_regs[1]);
int offy = (short)((K053246_regs[2] << 8) | K053246_regs[3]);
- int solidpens = K053247_gfx->color_granularity - 1;
int screen_width = video_screen_get_width(machine->primary_screen);
+ UINT8 drawmode_table[256];
+ UINT8 shadowmode_table[256];
+ UINT8 *whichtable;
+
+ memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
+ drawmode_table[0] = DRAWMODE_NONE;
+ memset(shadowmode_table, DRAWMODE_SHADOW, sizeof(shadowmode_table));
+ shadowmode_table[0] = DRAWMODE_NONE;
/*
safeguard older drivers missing any of the following video attributes:
@@ -4393,13 +4396,14 @@ void K053247_sprites_draw(running_machine *machine, bitmap_t *bitmap,const recta
if (mirrorx) flipx = 0; // documented and confirmed
mirrory = shadow & 0x8000;
+ whichtable = drawmode_table;
if (color == -1)
{
// drop the entire sprite to shadow unconditionally
if (shdmask < 0) continue;
color = 0;
shadow = -1;
- for (temp=1; temp<solidpens; temp++) gfx_drawmode_table[temp] = DRAWMODE_SHADOW;
+ whichtable = shadowmode_table;
palette_set_shadow_mode(machine, 0);
}
else
@@ -4448,6 +4452,8 @@ void K053247_sprites_draw(running_machine *machine, bitmap_t *bitmap,const recta
ox -= (zoomx * w) >> 13;
oy -= (zoomy * h) >> 13;
+ drawmode_table[K053247_gfx->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+
for (y = 0;y < h;y++)
{
int sx,sy,zw,zh;
@@ -4505,52 +4511,53 @@ void K053247_sprites_draw(running_machine *machine, bitmap_t *bitmap,const recta
if (nozoom)
{
- pdrawgfx(bitmap,K053247_gfx,
+ pdrawgfx_transtable(bitmap,cliprect,K053247_gfx,
c,
color,
fx,fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,primask);
+ priority_bitmap,primask,
+ whichtable,machine->shadow_table);
}
else
{
- pdrawgfxzoom(bitmap,K053247_gfx,
+ pdrawgfxzoom_transtable(bitmap,cliprect,K053247_gfx,
c,
color,
fx,fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
- (zw << 16) >> 4,(zh << 16) >> 4,primask);
+ (zw << 16) >> 4,(zh << 16) >> 4,
+ priority_bitmap,primask,
+ whichtable,machine->shadow_table);
}
if (mirrory && h == 1) /* Simpsons shadows */
{
if (nozoom)
{
- pdrawgfx(bitmap,K053247_gfx,
+ pdrawgfx_transtable(bitmap,cliprect,K053247_gfx,
c,
color,
fx,!fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,primask);
+ priority_bitmap,primask,
+ whichtable,machine->shadow_table);
}
else
{
- pdrawgfxzoom(bitmap,K053247_gfx,
+ pdrawgfxzoom_transtable(bitmap,cliprect,K053247_gfx,
c,
color,
fx,!fy,
sx,sy,
- cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
- (zw << 16) >> 4,(zh << 16) >> 4,primask);
+ (zw << 16) >> 4,(zh << 16) >> 4,
+ priority_bitmap,primask,
+ whichtable,machine->shadow_table);
}
}
} // end of X loop
} // end of Y loop
- // reset drawmode_table
- if (shadow == -1) for (temp=1; temp<solidpens; temp++) gfx_drawmode_table[temp] = DRAWMODE_SOURCE;
-
} // end of sprite-list loop
#undef NUM_SPRITES
}
@@ -6488,7 +6495,7 @@ static int K056832_update_linemap(running_machine *machine, bitmap_t *bitmap, in
UINT8 code_transparent, code_opaque;
const pen_t *pal_ptr;
- const UINT8 *src_base, *src_ptr;
+ const UINT8 *src_ptr;
UINT8 *xpr_ptr;
UINT16 *dst_ptr;
UINT16 pen, basepen;
@@ -6509,7 +6516,6 @@ static int K056832_update_linemap(running_machine *machine, bitmap_t *bitmap, in
pixmap = K056832_pixmap[page];
pal_ptr = machine->pens;
src_gfx = machine->gfx[K056832_gfxnum];
- src_base = src_gfx->gfxdata;
src_pitch = src_gfx->line_modulo;
src_modulo = src_gfx->char_modulo;
dst_pitch = pixmap->rowpixels;
@@ -6561,7 +6567,7 @@ static int K056832_update_linemap(running_machine *machine, bitmap_t *bitmap, in
return(0);
}
-void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority)
+void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority)
{
static int last_colorbase[K056832_PAGE_COUNT];
@@ -6620,10 +6626,10 @@ void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rect
} else corr = 0;
corr -= K056832_LayerOffset[layer][0];
- if (scrollmode == 0 && (flags & TILE_LINE_DISABLED))
+ if (scrollmode == 0 && (flags & K056382_DRAW_FLAG_FORCE_XYSCROLL))
{
scrollmode = 3;
- flags &= ~TILE_LINE_DISABLED;
+ flags &= ~K056382_DRAW_FLAG_FORCE_XYSCROLL;
}
switch( scrollmode )
@@ -6844,7 +6850,7 @@ void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rect
} // end of function
-void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority) //*
+void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority) //*
{
static int last_colorbase[K056832_PAGE_COUNT];
@@ -6899,10 +6905,10 @@ void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const r
} else corr = 0;
corr -= K056832_LayerOffset[layer][0];
- if (scrollmode == 0 && (flags & TILE_LINE_DISABLED))
+ if (scrollmode == 0 && (flags & K056382_DRAW_FLAG_FORCE_XYSCROLL))
{
scrollmode = 3;
- flags &= ~TILE_LINE_DISABLED;
+ flags &= ~K056382_DRAW_FLAG_FORCE_XYSCROLL;
}
switch( scrollmode )
@@ -7409,7 +7415,6 @@ int K054338_set_alpha_level(int pblend)
if (pblend <= 0 || pblend > 3)
{
- alpha_set_level(255);
return(255);
}
@@ -7424,7 +7429,6 @@ int K054338_set_alpha_level(int pblend)
if (!(mixset & 0x20))
{
mixlv = mixlv<<3 | mixlv>>2;
- alpha_set_level(mixlv); // source x alpha/255 + target x (255-alpha)/255
}
else
{
@@ -7440,7 +7444,6 @@ int K054338_set_alpha_level(int pblend)
// DUMMY
if (mixlv && mixlv<0x1f) mixlv = 0x10;
mixlv = mixlv<<3 | mixlv>>2;
- alpha_set_level(mixlv);
if (VERBOSE)
popmessage("MIXSET%1d %s addition mode: %02x",pblend,(mixpri)?"dst":"src",mixset&0x1f);
diff --git a/src/mame/video/konamiic.h b/src/mame/video/konamiic.h
index 844fcca0e51..d71f46738ee 100644
--- a/src/mame/video/konamiic.h
+++ b/src/mame/video/konamiic.h
@@ -104,7 +104,7 @@ READ8_HANDLER( K051937_r );
WRITE8_HANDLER( K051937_w );
READ16_HANDLER( K051937_word_r );
WRITE16_HANDLER( K051937_word_w );
-void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority);
+void K051960_sprites_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority);
int K051960_is_IRQ_enabled(void);
int K051960_is_NMI_enabled(void);
void K051960_set_sprite_offsets(int dx, int dy);
@@ -129,7 +129,7 @@ WRITE16_HANDLER( K053244_lsb_w );
READ16_HANDLER( K053244_word_r );
WRITE16_HANDLER( K053244_word_w );
void K053244_bankselect(int chip, int bank); /* used by TMNT2, Asterix and Premier Soccer for ROM testing */
-void K053245_sprites_draw(int chip, bitmap_t *bitmap,const rectangle *cliprect);
+void K053245_sprites_draw(running_machine *machine, int chip, bitmap_t *bitmap,const rectangle *cliprect);
void K053245_sprites_draw_lethal(running_machine *machine, int chip, bitmap_t *bitmap,const rectangle *cliprect); /* for lethal enforcers */
void K053245_clear_buffer(int chip);
void K053245_set_SpriteOffset(int chip,int offsx, int offsy);
@@ -254,6 +254,8 @@ READ8_HANDLER( K051733_r );
void K056832_SetExtLinescroll(void); /* Lethal Enforcers */
+#define K056382_DRAW_FLAG_FORCE_XYSCROLL 0x00800000
+
void K056832_vh_start(running_machine *machine, const char *gfx_memory_region, int bpp, int big,
int (*scrolld)[4][2],
void (*callback)(int layer, int *code, int *color, int *flags),
@@ -284,8 +286,8 @@ WRITE8_HANDLER( K056832_w );
WRITE8_HANDLER( K056832_b_w );
void K056832_mark_plane_dirty(int num);
void K056832_MarkAllTilemapsDirty(void);
-void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int num, int flags, UINT32 priority);
-void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority);
+void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int num, UINT32 flags, UINT32 priority);
+void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority);
void K056832_set_LayerAssociation(int status);
int K056832_get_LayerAssociation(void);
void K056832_set_LayerOffset(int layer, int offsx, int offsy);
diff --git a/src/mame/video/lemmings.c b/src/mame/video/lemmings.c
index b4e9959f7d6..faf14a2e761 100644
--- a/src/mame/video/lemmings.c
+++ b/src/mame/video/lemmings.c
@@ -17,7 +17,7 @@
UINT16 *lemmings_pixel_0_data,*lemmings_pixel_1_data,*lemmings_vram_data,*lemmings_control_data;
static UINT16 *sprite_triple_buffer_0,*sprite_triple_buffer_1;
-static UINT8 *vram_buffer, *vram_dirty;
+static UINT8 *vram_buffer;
static bitmap_t *bitmap0;
static tilemap *vram_tilemap;
@@ -97,12 +97,13 @@ VIDEO_START( lemmings )
vram_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_cols,8,8,64,32);
vram_buffer = (UINT8*)auto_malloc(2048*64); /* 64 bytes per VRAM character */
- vram_dirty = (UINT8*)auto_malloc(2048);
sprite_triple_buffer_0 = (UINT16*)auto_malloc(0x800);
sprite_triple_buffer_1 = (UINT16*)auto_malloc(0x800);
tilemap_set_transparent_pen(vram_tilemap,0);
bitmap_fill(bitmap0,0,0x100);
+
+ gfx_element_set_source(machine->gfx[2], vram_buffer);
}
VIDEO_EOF( lemmings )
@@ -148,7 +149,7 @@ WRITE16_HANDLER( lemmings_pixel_1_w )
/* Copy pixel to buffer for easier decoding later */
tile=((sx/8)*32)+(sy/8);
- vram_dirty[tile]=1;
+ gfx_element_mark_dirty(space->machine->gfx[2], tile);
vram_buffer[(tile*64) + ((sx&7)) + ((sy&7)*8)]=(src>>8)&0xf;
sx+=1; /* Update both pixels in the word */
@@ -163,20 +164,11 @@ WRITE16_HANDLER( lemmings_vram_w )
VIDEO_UPDATE( lemmings )
{
- int x1=-lemmings_control_data[0],x0=-lemmings_control_data[2],i,y=0;
+ int x1=-lemmings_control_data[0],x0=-lemmings_control_data[2],y=0;
rectangle rect;
rect.max_y=cliprect->max_y;
rect.min_y=cliprect->min_y;
- /* Decode any characters that have changed in vram */
- for (i=0; i<2048; i++) {
- if (vram_dirty[i]) {
- decodechar(screen->machine->gfx[2],i,vram_buffer);
- tilemap_mark_tile_dirty(vram_tilemap,i);
- vram_dirty[i]=0;
- }
- }
-
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
draw_sprites(screen->machine,bitmap,cliprect,sprite_triple_buffer_1,1,0x0000);
diff --git a/src/mame/video/lethal.c b/src/mame/video/lethal.c
index d711e122e29..2f12f701f36 100644
--- a/src/mame/video/lethal.c
+++ b/src/mame/video/lethal.c
@@ -45,21 +45,12 @@ static void lethalen_tile_callback(int layer, int *code, int *color, int *flags)
VIDEO_START(lethalen)
{
- int i;
-
K053251_vh_start(machine);
K056832_vh_start(machine, "gfx1", K056832_BPP_8LE, 1, NULL, lethalen_tile_callback, 0);
K053245_vh_start(machine, 0, "gfx3",NORMAL_PLANE_ORDER, lethalen_sprite_callback);
- /* the default drawmode table is no good for 6bpp, create a new one */
- gfx_drawmode_table[0] = DRAWMODE_NONE;
- for (i = 1;i < 64;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
-
- gfx_drawmode_table[63] = DRAWMODE_SHADOW;
-
// this game uses external linescroll RAM
K056832_SetExtLinescroll();
diff --git a/src/mame/video/m10.c b/src/mame/video/m10.c
index aeb9915c6e2..2e10f5d6848 100644
--- a/src/mame/video/m10.c
+++ b/src/mame/video/m10.c
@@ -69,8 +69,7 @@ WRITE8_HANDLER( m15_chargen_w )
if (state->chargen[offset] != data)
{
state->chargen[offset] = data;
- /* not very effective ... dirty would be better */
- decodechar(space->machine->gfx[0],offset >> 3,state->chargen);
+ gfx_element_mark_dirty(space->machine->gfx[0],offset >> 3);
}
}
@@ -88,7 +87,7 @@ INLINE void plot_pixel_m10(running_machine *machine, bitmap_t *bm, int x, int y,
VIDEO_START( m10 )
{
- //m10_state *state = machine->driver_data;
+ m10_state *state = machine->driver_data;
int i;
for (i=0;i<32*8;i++)
@@ -99,8 +98,7 @@ VIDEO_START( m10 )
tilemap_set_scrolldx(tx_tilemap, 0, 62);
tilemap_set_scrolldy(tx_tilemap, 0, 0);
- back_gfx = allocgfx(machine, &backlayout);
- back_gfx->total_colors = 8;
+ back_gfx = gfx_element_alloc(machine, &backlayout, state->chargen, 8, 0);
machine->gfx[1] = back_gfx;
return ;
@@ -110,10 +108,7 @@ VIDEO_START( m15 )
{
m10_state *state = machine->driver_data;
- machine->gfx[0] = allocgfx(machine, &charlayout);
- machine->gfx[0]->total_colors = 8;
-
- decodegfx(machine->gfx[0], state->chargen,0,256);
+ machine->gfx[0] = gfx_element_alloc(machine, &charlayout, state->chargen, 8, 0);
tx_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan,8,8,32,32);
tilemap_set_scrolldx(tx_tilemap, 0, 116);
@@ -137,7 +132,6 @@ VIDEO_UPDATE( m10 )
bitmap_fill(bitmap,cliprect,0);
- decodegfx(back_gfx, state->chargen,0,4);
for (i=0;i<4;i++)
if (state->flip)
drawgfx(bitmap, back_gfx, i, color[i], 1, 1, 31*8 - xpos[i], 6, cliprect, 0, 0);
diff --git a/src/mame/video/m58.c b/src/mame/video/m58.c
index 566aa64a9a6..91438459278 100644
--- a/src/mame/video/m58.c
+++ b/src/mame/video/m58.c
@@ -293,6 +293,7 @@ static void draw_panel( running_machine *machine, bitmap_t *bitmap, const rectan
clip.min_y += visarea->min_y + yoffs;
clip.max_y += visarea->max_y + yoffs;
+ sect_rect(&clip, cliprect);
copybitmap(bitmap, scroll_panel_bitmap, flip_screen_get(machine), flip_screen_get(machine),
sx, visarea->min_y + yoffs, &clip);
diff --git a/src/mame/video/macrossp.c b/src/mame/video/macrossp.c
index 64a4e9be228..e9f4ebbab1d 100644
--- a/src/mame/video/macrossp.c
+++ b/src/mame/video/macrossp.c
@@ -166,8 +166,6 @@ VIDEO_START(macrossp)
machine->gfx[1]->color_granularity=64;
machine->gfx[2]->color_granularity=64;
machine->gfx[3]->color_granularity=64;
-
- alpha_set_level(0x80); /* guess */
}
@@ -209,7 +207,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int flipx = (source[2] & 0x40000000) >> 30;
int flipy = (source[2] & 0x80000000) >> 31;
- int trans = (source[2] & 0x20000000)?TRANSPARENCY_ALPHA:TRANSPARENCY_PEN; /* alpha blending enable? */
+ int alpha = (source[2] & 0x20000000)?0x80:0xff; /* alpha blending enable? */
int loopno = 0;
@@ -245,7 +243,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
for (ycnt = 0; ycnt <= high; ycnt++) {
xoffset = 0;
for (xcnt = 0; xcnt <= wide; xcnt++) {
- drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
+ drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
xoffset += ((xzoom*16 + (1<<7)) >> 8);
loopno++;
@@ -257,7 +255,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
for (ycnt = high; ycnt >= 0; ycnt--) {
xoffset = 0;
for (xcnt = 0; xcnt <= wide; xcnt++) {
- drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
+ drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
xoffset += ((xzoom*16 + (1<<7)) >> 8);
loopno++;
@@ -271,7 +269,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
for (ycnt = 0; ycnt <= high; ycnt++) {
xoffset = ((wide*xzoom*16) >> 8);
for (xcnt = wide; xcnt >= 0; xcnt--) {
- drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
+ drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
xoffset -= ((xzoom*16 + (1<<7)) >> 8);
loopno++;
@@ -283,7 +281,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
for (ycnt = high; ycnt >= 0; ycnt--) {
xoffset = ((wide*xzoom*16) >> 8);
for (xcnt = wide; xcnt >=0 ; xcnt--) {
- drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
+ drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
xoffset -= ((xzoom*16 + (1<<7)) >> 8);
loopno++;
diff --git a/src/mame/video/madalien.c b/src/mame/video/madalien.c
index d47545b3642..159a04b08dc 100644
--- a/src/mame/video/madalien.c
+++ b/src/mame/video/madalien.c
@@ -127,6 +127,12 @@ static TILE_GET_INFO( get_tile_info_FG )
SET_TILE_INFO(0, madalien_videoram[tile_index], 0, 0);
}
+WRITE8_HANDLER( madalien_videoram_w )
+{
+ madalien_videoram[offset] = data;
+ tilemap_mark_tile_dirty(tilemap_fg, offset);
+}
+
static VIDEO_START( madalien )
{
@@ -160,6 +166,8 @@ static VIDEO_START( madalien )
headlight_bitmap = auto_bitmap_alloc(128, 128, BITMAP_FORMAT_INDEXED16);
+ gfx_element_set_source(machine->gfx[0], madalien_charram);
+
drawgfx(headlight_bitmap, machine->gfx[2], 0, 0, 0, 0, 0x00, 0x00, NULL, TRANSPARENCY_NONE, 0);
drawgfx(headlight_bitmap, machine->gfx[2], 0, 0, 0, 1, 0x00, 0x40, NULL, TRANSPARENCY_NONE, 0);
}
@@ -240,17 +248,18 @@ static void draw_headlight(bitmap_t *bitmap, const rectangle *cliprect, int flip
static void draw_foreground(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int flip)
{
- int i;
-
- for (i = 0; i < 256; i++)
- decodechar(machine->gfx[0], i, madalien_charram);
-
- tilemap_mark_all_tiles_dirty(tilemap_fg);
tilemap_set_flip(tilemap_fg, flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
tilemap_draw(bitmap, cliprect, tilemap_fg, 0, 0);
}
+WRITE8_HANDLER( madalien_charram_w )
+{
+ madalien_charram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset/8) & 0xff);
+}
+
+
static VIDEO_UPDATE( madalien )
{
int flip = BIT(input_port_read(screen->machine, "DSW"), 6) && BIT(*madalien_video_control, 0);
diff --git a/src/mame/video/magmax.c b/src/mame/video/magmax.c
index cae90d683a3..88d6e787121 100644
--- a/src/mame/video/magmax.c
+++ b/src/mame/video/magmax.c
@@ -167,10 +167,10 @@ VIDEO_UPDATE( magmax )
UINT16 line_data_flip_x[256];
for (i=0; i<256; i++)
line_data_flip_x[i] = line_data[255-i];
- draw_scanline16(bitmap, 0, 255-v, 256, line_data_flip_x, NULL , -1);
+ draw_scanline16(bitmap, 0, 255-v, 256, line_data_flip_x, NULL);
}
else
- draw_scanline16(bitmap, 0, v, 256, line_data, NULL, -1);
+ draw_scanline16(bitmap, 0, v, 256, line_data, NULL);
}
}
diff --git a/src/mame/video/mainevt.c b/src/mame/video/mainevt.c
index 394b9dc9b4f..163da591da5 100644
--- a/src/mame/video/mainevt.c
+++ b/src/mame/video/mainevt.c
@@ -99,7 +99,7 @@ VIDEO_UPDATE( mainevt )
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4); /* high priority part of layer */
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,8);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
@@ -109,7 +109,7 @@ VIDEO_UPDATE( dv )
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
return 0;
}
diff --git a/src/mame/video/mainsnk.c b/src/mame/video/mainsnk.c
index ce08a4111a6..a51e6b4e0c1 100644
--- a/src/mame/video/mainsnk.c
+++ b/src/mame/video/mainsnk.c
@@ -6,6 +6,8 @@ UINT8 *mainsnk_fgram;
UINT8 *mainsnk_bgram;
+static UINT32 bg_tile_offset;
+
static TILEMAP_MAPPER( marvins_tx_scan_cols )
{
@@ -33,7 +35,7 @@ static TILE_GET_INFO( get_bg_tile_info )
SET_TILE_INFO(
0,
- code,
+ bg_tile_offset + code,
0,
0);
}
@@ -67,7 +69,11 @@ WRITE8_HANDLER(mainsnk_c600_w)
else if (space->machine->gfx[0]->total_elements == 0x800) // canvas
bank = ((data & 0x40) >> 6) | ((data & 0x30) >> 3);
- tilemap_set_pen_data_offset(bg_tilemap, (bank << 8) * space->machine->gfx[0]->char_modulo);
+ if (bg_tile_offset != (bank << 8))
+ {
+ bg_tile_offset = bank << 8;
+ tilemap_mark_all_tiles_dirty(bg_tilemap);
+ }
}
WRITE8_HANDLER( mainsnk_fgram_w )
diff --git a/src/mame/video/mcr.c b/src/mame/video/mcr.c
index 9115aeb6bcb..11cbb44e325 100644
--- a/src/mame/video/mcr.c
+++ b/src/mame/video/mcr.c
@@ -275,7 +275,7 @@ static void render_sprites_91399(running_machine *machine, bitmap_t *bitmap, con
for (y = 0; y < 32; y++, sy = (sy + 1) & 0x1ff)
if (sy >= cliprect->min_y && sy <= cliprect->max_y)
{
- UINT8 *src = gfx->gfxdata + gfx->char_modulo * code + gfx->line_modulo * (y ^ vflip);
+ const UINT8 *src = gfx_element_get_data(gfx, code) + gfx->line_modulo * (y ^ vflip);
UINT16 *dst = BITMAP_ADDR16(bitmap, sy, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
@@ -345,7 +345,7 @@ static void render_sprites_91464(running_machine *machine, bitmap_t *bitmap, con
for (y = 0; y < 32; y++, sy = (sy + 1) & 0x1ff)
if (sy >= 2 && sy >= cliprect->min_y && sy <= cliprect->max_y)
{
- UINT8 *src = gfx->gfxdata + gfx->char_modulo * code + gfx->line_modulo * (y ^ vflip);
+ const UINT8 *src = gfx_element_get_data(gfx, code) + gfx->line_modulo * (y ^ vflip);
UINT16 *dst = BITMAP_ADDR16(bitmap, sy, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
diff --git a/src/mame/video/mcr68.c b/src/mame/video/mcr68.c
index bf32819081e..621aaa7a57f 100644
--- a/src/mame/video/mcr68.c
+++ b/src/mame/video/mcr68.c
@@ -73,6 +73,8 @@ VIDEO_START( zwackery )
const UINT8 *colordatabase = (const UINT8 *)memory_region(machine, "gfx3");
gfx_element *gfx0 = machine->gfx[0];
gfx_element *gfx2 = machine->gfx[2];
+ UINT8 *srcdata0, *dest0;
+ UINT8 *srcdata2, *dest2;
int code, y, x;
/* initialize the background tilemap */
@@ -82,18 +84,24 @@ VIDEO_START( zwackery )
fg_tilemap = tilemap_create(machine, zwackery_get_fg_tile_info, tilemap_scan_rows, 16,16, 32,32);
tilemap_set_transparent_pen(fg_tilemap, 0);
+ /* allocate memory for the assembled gfx data */
+ srcdata0 = auto_malloc(gfx0->total_elements * gfx0->width * gfx0->height);
+ srcdata2 = auto_malloc(gfx2->total_elements * gfx2->width * gfx2->height);
+
/* "colorize" each code */
+ dest0 = srcdata0;
+ dest2 = srcdata2;
for (code = 0; code < gfx0->total_elements; code++)
{
const UINT8 *coldata = colordatabase + code * 32;
- UINT8 *gfxdata0 = gfx0->gfxdata + code * gfx0->char_modulo;
- UINT8 *gfxdata2 = gfx2->gfxdata + code * gfx2->char_modulo;
+ const UINT8 *gfxdata0 = gfx_element_get_data(gfx0, code);
+ const UINT8 *gfxdata2 = gfx_element_get_data(gfx2, code);
/* assume 16 rows */
for (y = 0; y < 16; y++)
{
- UINT8 *gd0 = gfxdata0;
- UINT8 *gd2 = gfxdata2;
+ const UINT8 *gd0 = gfxdata0;
+ const UINT8 *gd2 = gfxdata2;
/* 16 columns */
for (x = 0; x < 16; x++, gd0++, gd2++)
@@ -104,12 +112,12 @@ VIDEO_START( zwackery )
int tp0, tp1;
/* every 4 pixels gets its own foreground/background colors */
- *gd0 = *gd0 ? pen1 : pen0;
+ *dest0++ = *gd0 ? pen1 : pen0;
/* for gfx 2, we convert all low-priority pens to 0 */
tp0 = (pen0 & 0x80) ? pen0 : 0;
tp1 = (pen1 & 0x80) ? pen1 : 0;
- *gd2 = *gd2 ? tp1 : tp0;
+ *dest2++ = *gd2 ? tp1 : tp0;
}
/* advance */
@@ -117,6 +125,20 @@ VIDEO_START( zwackery )
gfxdata2 += gfx2->line_modulo;
}
}
+
+ /* create a simple target layout */
+ gfx0->layout.planes = gfx2->layout.planes = 8;
+ for (x = 0; x < 8; x++)
+ gfx0->layout.planeoffset[x] = gfx2->layout.planeoffset[x] = x;
+ for (x = 0; x < gfx0->width; x++)
+ gfx0->layout.xoffset[x] = gfx2->layout.xoffset[x] = 8 * x;
+ for (y = 0; y < gfx0->height; y++)
+ gfx0->layout.yoffset[y] = gfx2->layout.yoffset[y] = 8 * y * gfx0->width;
+ gfx0->layout.charincrement = gfx2->layout.charincrement = 8 * gfx0->width * gfx0->height;
+
+ /* make the assembled data our new source data */
+ gfx_element_set_source(gfx0, srcdata0);
+ gfx_element_set_source(gfx2, srcdata2);
}
diff --git a/src/mame/video/metro.c b/src/mame/video/metro.c
index 3c489581519..52853b0bad1 100644
--- a/src/mame/video/metro.c
+++ b/src/mame/video/metro.c
@@ -615,6 +615,7 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan
UINT16 *src;
int inc;
+ UINT8 dirty = 0;
if (sprites == 0)
return;
@@ -704,6 +705,7 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan
gfx.line_modulo = width;
gfx.char_modulo = 0; /* doesn't matter */
gfx.flags = 0;
+ gfx.dirty = &dirty;
gfx.machine = machine;
/* Bounds checking */
@@ -736,6 +738,7 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan
gfx.line_modulo = width/2;
gfx.char_modulo = 0; /* doesn't matter */
gfx.flags = GFX_ELEMENT_PACKED;
+ gfx.dirty = &dirty;
gfx.machine = machine;
/* Bounds checking */
diff --git a/src/mame/video/model1.c b/src/mame/video/model1.c
index 2ed46846253..e3595af5dba 100644
--- a/src/mame/video/model1.c
+++ b/src/mame/video/model1.c
@@ -1460,7 +1460,6 @@ VIDEO_START(model1)
VIDEO_UPDATE(model1)
{
- sys24_tile_update(screen->machine);
#if 0
{
int mod = 0;
diff --git a/src/mame/video/model2.c b/src/mame/video/model2.c
index 2aa4581e765..1b839bf514f 100644
--- a/src/mame/video/model2.c
+++ b/src/mame/video/model2.c
@@ -2734,7 +2734,6 @@ VIDEO_UPDATE(model2)
{
logerror("--- frame ---\n");
- sys24_tile_update(screen->machine);
bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
bitmap_fill(sys24_bitmap, cliprect, 0);
diff --git a/src/mame/video/moo.c b/src/mame/video/moo.c
index fc163c66f95..70485f19fb1 100644
--- a/src/mame/video/moo.c
+++ b/src/mame/video/moo.c
@@ -160,7 +160,7 @@ VIDEO_UPDATE(moo)
alpha = (alpha_enabled) ? K054338_set_alpha_level(1) : 255;
if (alpha > 0)
- K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[2], (alpha >= 255) ? 0 : TILEMAP_DRAW_ALPHA, 4);
+ K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4);
K053247_sprites_draw(screen->machine, bitmap,cliprect);
diff --git a/src/mame/video/ms32.c b/src/mame/video/ms32.c
index 3936bc076df..3d534d59961 100644
--- a/src/mame/video/ms32.c
+++ b/src/mame/video/ms32.c
@@ -283,7 +283,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int xsize, ysize, xzoom, yzoom;
int code, attr, color, size, pri, pri_mask, trans;
gfx_element *gfx = machine->gfx[0];
- gfx_element mygfx = *gfx;
UINT32 *source = sprram_top;
const UINT32 *finish = sprram_top + (sprram_size - 0x20) / 4;
@@ -346,11 +345,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
flipy = !flipy;
}
- /* change GfxElement parameters to draw only the needed part of the 256x256 tile */
- mygfx.width = xsize;
- mygfx.height = ysize;
- mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
-
#if 0
if (input_code_pressed(KEYCODE_A) && (pri & 8)) color = rand();
if (input_code_pressed(KEYCODE_S) && (pri & 4)) color = rand();
@@ -368,7 +362,8 @@ if (input_code_pressed(KEYCODE_F) && (pri & 1)) color = rand();
else
pri_mask = 0xfe;
- pdrawgfxzoom(bitmap, &mygfx,
+ gfx_element_set_source_clip(gfx, tx, xsize, ty, ysize);
+ pdrawgfxzoom(bitmap, gfx,
code,
color,
flipx, flipy,
diff --git a/src/mame/video/mystwarr.c b/src/mame/video/mystwarr.c
index 48d5f5a5f64..9addd41ca6f 100644
--- a/src/mame/video/mystwarr.c
+++ b/src/mame/video/mystwarr.c
@@ -14,18 +14,24 @@ static int oinprion, cbparam;
static int sprite_colorbase, sub1_colorbase, last_psac_colorbase, gametype;
static int roz_enable, roz_rombank;
static tilemap *ult_936_tilemap;
-static char *orig_roms;
-// do some trickery since we know the graphics decode doesn't touch the source data again
-// and we want the original data
-static void mystwarr_save_orig_tiles(running_machine *machine)
+// create a decoding buffer to hold decodable tiles so that the ROM test will pass by
+// reading the original raw data
+static void mystwarr_decode_tiles(running_machine *machine)
{
UINT8 *s = memory_region(machine, "gfx1");
int len = memory_region_length(machine, "gfx1");
UINT8 *pFinish = s+len-3;
+ UINT8 *d, *decoded;
+ int gfxnum;
+
+ for (gfxnum = 0; gfxnum < ARRAY_LENGTH(machine->gfx); gfxnum++)
+ if (machine->gfx[gfxnum] != NULL && machine->gfx[gfxnum]->srcdata == s)
+ break;
+ assert(gfxnum != ARRAY_LENGTH(machine->gfx));
- orig_roms = malloc_or_die(len);
- memcpy(orig_roms, s, len);
+ decoded = auto_malloc(len);
+ d = decoded;
// now convert the data into a drawable format so we can decode it
while (s < pFinish)
@@ -43,23 +49,17 @@ static void mystwarr_save_orig_tiles(running_machine *machine)
int d3 = ((s[0]&0x10)<<3)|((s[0]&0x01)<<6)|((s[1]&0x10)<<1)|((s[1]&0x01)<<4)|
((s[2]&0x10)>>1)|((s[2]&0x01)<<2)|((s[3]&0x10)>>3)|((s[3]&0x01) );
- s[0] = d3;
- s[1] = d1;
- s[2] = d2;
- s[3] = d0;
+ d[0] = d3;
+ d[1] = d1;
+ d[2] = d2;
+ d[3] = d0;
+ d[4] = s[4];
s += 5;
+ d += 5;
}
-}
-
-static void mystwarr_rest_orig_tiles(running_machine *machine)
-{
- UINT8 *s = memory_region(machine, "gfx1");
- int len = memory_region_length(machine, "gfx1");
-
- // restore the original data so the ROM test can pass
- memcpy(s, orig_roms, len);
- free(orig_roms);
+
+ gfx_element_set_source(machine->gfx[gfxnum], decoded);
}
@@ -164,11 +164,9 @@ VIDEO_START(gaiapols)
gametype = 0;
- mystwarr_save_orig_tiles(machine);
-
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
- mystwarr_rest_orig_tiles(machine);
+ mystwarr_decode_tiles(machine);
K055673_vh_start(machine, "gfx2", 1, -61, -22, gaiapols_sprite_callback); // stage2 brick walls
@@ -206,11 +204,9 @@ VIDEO_START(dadandrn)
gametype = 1;
- mystwarr_save_orig_tiles(machine);
-
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game5bpp_tile_callback, 0);
- mystwarr_rest_orig_tiles(machine);
+ mystwarr_decode_tiles(machine);
K055673_vh_start(machine, "gfx2", 0, -42, -22, gaiapols_sprite_callback);
@@ -237,11 +233,9 @@ VIDEO_START(mystwarr)
gametype = 0;
- mystwarr_save_orig_tiles(machine);
-
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, mystwarr_tile_callback, 0);
- mystwarr_rest_orig_tiles(machine);
+ mystwarr_decode_tiles(machine);
K055673_vh_start(machine, "gfx2", 0, -48, -24, mystwarr_sprite_callback);
@@ -265,11 +259,9 @@ VIDEO_START(metamrph)
K054338_vh_start(machine);
K053250_vh_start(machine, 1, &rgn_250);
- mystwarr_save_orig_tiles(machine);
-
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
- mystwarr_rest_orig_tiles(machine);
+ mystwarr_decode_tiles(machine);
K055673_vh_start(machine, "gfx2", 1, -51, -22, metamrph_sprite_callback);
@@ -291,11 +283,9 @@ VIDEO_START(viostorm)
K055555_vh_start(machine);
K054338_vh_start(machine);
- mystwarr_save_orig_tiles(machine);
-
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
- mystwarr_rest_orig_tiles(machine);
+ mystwarr_decode_tiles(machine);
K055673_vh_start(machine, "gfx2", 1, -62, -23, metamrph_sprite_callback);
@@ -314,11 +304,9 @@ VIDEO_START(martchmp)
K055555_vh_start(machine);
K054338_vh_start(machine);
- mystwarr_save_orig_tiles(machine);
-
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game5bpp_tile_callback, 0);
- mystwarr_rest_orig_tiles(machine);
+ mystwarr_decode_tiles(machine);
K055673_vh_start(machine, "gfx2", 0, -58, -23, martchmp_sprite_callback);
diff --git a/src/mame/video/namcona1.c b/src/mame/video/namcona1.c
index 94e7653b287..04bd2b39dd9 100644
--- a/src/mame/video/namcona1.c
+++ b/src/mame/video/namcona1.c
@@ -19,13 +19,10 @@ UINT16 *namcona1_workram;
//UINT16 *namcona1_pixmap;
/* private variables */
-static char *dirtychar;
-static char dirtygfx;
static UINT16 *shaperam;
static UINT16 *cgram;
static tilemap *roz_tilemap;
static int roz_palette;
-static int roz_dirty;
static tilemap *bg_tilemap[NAMCONA1_NUM_TILEMAPS];
static int tilemap_palette_bank[NAMCONA1_NUM_TILEMAPS];
static int palette_is_dirty;
@@ -139,7 +136,7 @@ WRITE16_HANDLER( namcona1_videoram_w )
}
else if( offset<0xa000/2 )
{
- roz_dirty = 1;
+ tilemap_mark_all_tiles_dirty( roz_tilemap );
}
} /* namcona1_videoram_w */
@@ -262,10 +259,7 @@ WRITE16_HANDLER( namcona1_gfxram_w )
old_word = shaperam[offset];
COMBINE_DATA( &shaperam[offset] );
if( shaperam[offset]!=old_word )
- {
- dirtygfx = 1;
- dirtychar[offset/4] = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[2], offset/4);
}
}
else if( type == 0x02 )
@@ -274,59 +268,20 @@ WRITE16_HANDLER( namcona1_gfxram_w )
COMBINE_DATA( &cgram[offset] );
if( cgram[offset]!=old_word )
{
- dirtygfx = 1;
- dirtychar[offset/0x20] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/0x20);
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/0x20);
}
}
} /* namcona1_gfxram_w */
static void UpdateGfx(running_machine *machine)
{
- const UINT16 *pSource = videoram16;
- int page;
- int i;
-
- if( dirtygfx )
- {
- for( page = 0; page<NAMCONA1_NUM_TILEMAPS; page++ )
- {
- for( i=0; i<0x1000; i++ )
- {
- if( dirtychar[*pSource++ & 0xfff] )
- {
- tilemap_mark_tile_dirty( bg_tilemap[page], i );
- }
- }
- }
-
- for( i=0; i<0x1000; i++ )
- {
- if( dirtychar[*pSource++ & 0xfff] )
- {
- roz_dirty = 1;
- break;
- }
- }
-
- for( i = 0;i <0x1000; i++ )
- {
- if( dirtychar[i] )
- {
- dirtychar[i] = 0;
- decodechar(machine->gfx[0],i,(UINT8 *)cgram);
- decodechar(machine->gfx[1],i,(UINT8 *)cgram);
- decodechar(machine->gfx[2],i,(UINT8 *)shaperam);
- }
- }
- dirtygfx = 0;
- }
} /* UpdateGfx */
VIDEO_START( namcona1 )
{
static const tile_get_info_func get_info[4] = { tilemap_get_info0, tilemap_get_info1, tilemap_get_info2, tilemap_get_info3 };
int i;
- gfx_element *gfx0,*gfx1,*gfx2;
roz_tilemap = tilemap_create( machine, roz_get_info, tilemap_scan_rows, 8,8,64,64 );
roz_palette = -1;
@@ -339,19 +294,11 @@ VIDEO_START( namcona1 )
shaperam = auto_malloc( 0x2000*4 );
cgram = auto_malloc( 0x1000*0x40 );
- dirtychar = auto_malloc( 0x1000 );
-
- gfx0 = allocgfx( machine, &cg_layout_8bpp );
- gfx0->total_colors = machine->config->total_colors/256;
- machine->gfx[0] = gfx0;
- gfx1 = allocgfx( machine, &cg_layout_4bpp );
- gfx1->total_colors = machine->config->total_colors/16;
- machine->gfx[1] = gfx1;
+ machine->gfx[0] = gfx_element_alloc( machine, &cg_layout_8bpp, (UINT8 *)cgram, machine->config->total_colors/256, 0 );
+ machine->gfx[1] = gfx_element_alloc( machine, &cg_layout_4bpp, (UINT8 *)cgram, machine->config->total_colors/16, 0 );
+ machine->gfx[2] = gfx_element_alloc( machine, &shape_layout, (UINT8 *)shaperam, machine->config->total_colors/2, 0 );
- gfx2 = allocgfx( machine, &shape_layout );
- gfx2->total_colors = machine->config->total_colors/2;
- machine->gfx[2] = gfx2;
} /* namcona1_vh_start */
/*************************************************************************/
@@ -372,8 +319,8 @@ static void pdraw_tile(running_machine *machine,
const gfx_element *mask = machine->gfx[2];
int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
- UINT8 *mask_base = mask->gfxdata + (code % mask->total_elements) * mask->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, (code % gfx->total_elements));
+ const UINT8 *mask_base = gfx_element_get_data(mask, (code % mask->total_elements));
int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
@@ -443,8 +390,8 @@ static void pdraw_tile(running_machine *machine,
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
- UINT8 *mask_addr = mask_base + (y_index>>16) * mask->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *mask_addr = mask_base + (y_index>>16) * mask->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
@@ -714,17 +661,11 @@ VIDEO_UPDATE( namcona1 )
int color = namcona1_vreg[0xba/2]&0xf;
if( color != roz_palette )
{
- roz_dirty = 1;
+ tilemap_mark_all_tiles_dirty( roz_tilemap );
roz_palette = color;
}
}
- if( roz_dirty )
- {
- tilemap_mark_all_tiles_dirty( roz_tilemap );
- roz_dirty = 0;
- }
-
bitmap_fill( priority_bitmap,cliprect ,0);
bitmap_fill( bitmap, cliprect , 0xff); /* background color? */
diff --git a/src/mame/video/namcos1.c b/src/mame/video/namcos1.c
index 841cf159952..6d82c3cb4e9 100644
--- a/src/mame/video/namcos1.c
+++ b/src/mame/video/namcos1.c
@@ -52,6 +52,8 @@ static tilemap *bg_tilemap[6];
static UINT8 *tilemap_maskdata;
static int copy_sprites;
+static UINT8 drawmode_table[16];
+
@@ -126,8 +128,9 @@ VIDEO_START( namcos1 )
state_save_register_global_array(machine, namcos1_playfield_control);
/* set table for sprite color == 0x7f */
- for (i = 0;i <= 15;i++)
- gfx_drawmode_table[i] = DRAWMODE_SHADOW;
+ for (i = 0;i < 15;i++)
+ drawmode_table[i] = DRAWMODE_SHADOW;
+ drawmode_table[15] = DRAWMODE_NONE;
/* clear paletteram */
memset(namcos1_paletteram, 0, 0x8000);
@@ -278,7 +281,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
const UINT8 *source = &spriteram[0x0800-0x20]; /* the last is NOT a sprite */
const UINT8 *finish = &spriteram[0];
gfx_element *gfx = machine->gfx[1];
- gfx_element mygfx = *gfx;
int sprite_xoffs = spriteram[0x07f5] + ((spriteram[0x07f4] & 1) << 8);
int sprite_yoffs = spriteram[0x07f7];
@@ -318,18 +320,25 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
sy++; /* sprites are buffered and delayed by one scanline */
- /* change GfxElement parameters to draw only the needed part of the 32x32 tile */
- mygfx.width = sizex;
- mygfx.height = sizey;
- mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
-
- pdrawgfx( bitmap, &mygfx,
- sprite,
- color,
- flipx,flipy,
- sx & 0x1ff,
- ((sy + 16) & 0xff) - 16,
- cliprect,(color != 0x7f) ? TRANSPARENCY_PEN : TRANSPARENCY_PEN_TABLE,0xf, pri_mask);
+ gfx_element_set_source_clip(gfx, tx, sizex, ty, sizey);
+ if (color != 0x7f)
+ pdrawgfx_transpen( bitmap, cliprect, gfx,
+ sprite,
+ color,
+ flipx,flipy,
+ sx & 0x1ff,
+ ((sy + 16) & 0xff) - 16,
+ priority_bitmap, pri_mask,
+ 0xf);
+ else
+ pdrawgfx_transtable( bitmap, cliprect, gfx,
+ sprite,
+ color,
+ flipx,flipy,
+ sx & 0x1ff,
+ ((sy + 16) & 0xff) - 16,
+ priority_bitmap, pri_mask,
+ drawmode_table, machine->shadow_table);
source -= 0x10;
}
diff --git a/src/mame/video/namcos2.c b/src/mame/video/namcos2.c
index 54feb5ea62e..7bf19f4334c 100644
--- a/src/mame/video/namcos2.c
+++ b/src/mame/video/namcos2.c
@@ -294,12 +294,6 @@ DrawSpriteInit( running_machine *machine )
{
int i;
/* set table for sprite color == 0x0f */
- for(i = 0;i <= 253;i++)
- {
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- }
- gfx_drawmode_table[254] = DRAWMODE_SHADOW;
- gfx_drawmode_table[255] = DRAWMODE_NONE;
for( i = 0; i<16*256; i++ )
{
machine->shadow_table[i] = i+0x2000;
@@ -334,10 +328,7 @@ ApplyClip( rectangle *clip, const rectangle *cliprect )
clip->min_y = GetPaletteRegister(2) - 0x21;
clip->max_y = GetPaletteRegister(3) - 0x21 - 1;
/* intersect with master clip rectangle */
- if( clip->min_x < cliprect->min_x ){ clip->min_x = cliprect->min_x; }
- if( clip->min_y < cliprect->min_y ){ clip->min_y = cliprect->min_y; }
- if( clip->max_x > cliprect->max_x ){ clip->max_x = cliprect->max_x; }
- if( clip->max_y > cliprect->max_y ){ clip->max_y = cliprect->max_y; }
+ sect_rect(clip, cliprect);
} /* ApplyClip */
VIDEO_UPDATE( namcos2_default )
diff --git a/src/mame/video/namcos22.c b/src/mame/video/namcos22.c
index 27171d6252a..c9b9cfebce9 100644
--- a/src/mame/video/namcos22.c
+++ b/src/mame/video/namcos22.c
@@ -558,7 +558,7 @@ static void
mydrawgfxzoom(
bitmap_t *dest_bmp,const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
- const rectangle *clip,int transparency,int transparent_color,
+ const rectangle *clip,
int scalex, int scaley, int z, int prioverchar, int alpha )
{
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
@@ -597,7 +597,7 @@ mydrawgfxzoom(
extra->prioverchar = prioverchar;
extra->line_modulo = gfx->line_modulo;
extra->pens = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- extra->source = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ extra->source = gfx_element_get_data(gfx, code % gfx->total_elements);
#ifdef RENDER_AS_QUADS
poly_render_quad_fan(poly, dest_bmp, clip, renderscanline_sprite, 2, 4, &vert[0]);
#else
@@ -671,7 +671,6 @@ poly3d_Draw3dSprite( bitmap_t *bitmap, gfx_element *gfx, int tileNumber, int col
flipx, flipy,
sx, sy,
&clip,
- TRANSPARENCY_ALPHA, 0xff,
(width<<16)/32,
(height<<16)/32,
zc, pri, 0xff - translucency );
@@ -1063,8 +1062,6 @@ UINT32 *namcos22_czattr;
UINT32 *namcos22_tilemapattr;
-static int cgsomethingisdirty;
-static UINT8 *cgdirty;
static UINT8 *dirtypal;
READ32_HANDLER( namcos22_czram_r )
@@ -1538,13 +1535,12 @@ WRITE32_HANDLER( namcos22_textram_w )
static void
DrawTranslucentCharacters( bitmap_t *bitmap, const rectangle *cliprect )
{
- alpha_set_level( 0xff-mixer.text_translucency ); /* ? */
- tilemap_draw( bitmap, cliprect, bgtilemap, TILEMAP_DRAW_ALPHA|1, 0 );
+ UINT8 alpha = 0xff-mixer.text_translucency; /* ? */
+ tilemap_draw( bitmap, cliprect, bgtilemap, TILEMAP_DRAW_ALPHA(alpha)|1, 0 );
}
static void DrawCharacterLayer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
- unsigned i;
INT32 dx = namcos22_tilemapattr[0]>>16;
INT32 dy = namcos22_tilemapattr[0]&0xffff;
/**
@@ -1552,32 +1548,6 @@ static void DrawCharacterLayer(running_machine *machine, bitmap_t *bitmap, const
* namcos22_tilemapattr[0x8/4] == 0x01ff0000
* namcos22_tilemapattr[0xe/4] == ?
*/
- if( cgsomethingisdirty )
- {
- for( i=0; i<64*64; i+=2 )
- {
- UINT32 data = namcos22_textram[i/2];
- if( cgdirty[(data>>16)&0x3ff] )
- {
- tilemap_mark_tile_dirty( bgtilemap,i );
- }
- if( cgdirty[data&0x3ff] )
- {
- tilemap_mark_tile_dirty( bgtilemap,i+1 );
- }
- }
-
- for( i=0; i<NUM_CG_CHARS; i++ )
- {
- if( cgdirty[i] )
- {
- decodechar( machine->gfx[GFX_CHAR],i,(UINT8 *)namcos22_cgram );
- cgdirty[i] = 0;
- }
- }
- cgsomethingisdirty = 0;
- }
-
bitmap_fill(priority_bitmap,cliprect,0);
tilemap_set_scrollx( bgtilemap,0, (dx-0x35c)&0x3ff );
tilemap_set_scrolly( bgtilemap,0, dy&0x3ff );
@@ -2192,8 +2162,7 @@ READ32_HANDLER( namcos22_cgram_r )
WRITE32_HANDLER( namcos22_cgram_w )
{
COMBINE_DATA( &namcos22_cgram[offset] );
- cgdirty[offset/32] = 1;
- cgsomethingisdirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[GFX_CHAR],offset/32);
}
READ32_HANDLER( namcos22_gamma_r )
@@ -2230,15 +2199,18 @@ static void namcos22_exit(running_machine *machine)
static VIDEO_START( common )
{
+ int code;
+
bgtilemap = tilemap_create( machine, TextTilemapGetInfo,tilemap_scan_rows,16,16,64,64 );
tilemap_set_transparent_pen( bgtilemap, 0xf );
mbDSPisActive = 0;
memset( namcos22_polygonram, 0xcc, 0x20000 );
+ for (code = 0; code < machine->gfx[GFX_TEXTURE_TILE]->total_elements; code++)
+ gfx_element_decode(machine->gfx[GFX_TEXTURE_TILE], code);
Prepare3dTexture(memory_region(machine, "textilemap"), machine->gfx[GFX_TEXTURE_TILE]->gfxdata );
dirtypal = auto_malloc(NAMCOS22_PALETTE_SIZE/4);
- cgdirty = auto_malloc( 0x400 );
mPtRomSize = memory_region_length(machine, "pointrom")/3;
mpPolyL = memory_region(machine, "pointrom");
mpPolyM = mpPolyL + mPtRomSize;
@@ -2251,6 +2223,8 @@ static VIDEO_START( common )
#endif
add_reset_callback(machine, namcos22_reset);
add_exit_callback(machine, namcos22_exit);
+
+ gfx_element_set_source(machine->gfx[GFX_CHAR], (UINT8 *)namcos22_cgram);
}
VIDEO_START( namcos22 )
diff --git a/src/mame/video/namcos86.c b/src/mame/video/namcos86.c
index d8eb7d8b81f..09a18cc5ec3 100644
--- a/src/mame/video/namcos86.c
+++ b/src/mame/video/namcos86.c
@@ -267,7 +267,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
const UINT8 *source = &spriteram[0x0800-0x20]; /* the last is NOT a sprite */
const UINT8 *finish = &spriteram[0];
gfx_element *gfx = machine->gfx[2];
- gfx_element mygfx = *gfx;
int sprite_xoffs = spriteram[0x07f5] + ((spriteram[0x07f4] & 1) << 8);
int sprite_yoffs = spriteram[0x07f7];
@@ -310,12 +309,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
sy++; /* sprites are buffered and delayed by one scanline */
- /* change GfxElement parameters to draw only the needed part of the 32x32 tile */
- mygfx.width = sizex;
- mygfx.height = sizey;
- mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
-
- pdrawgfx( bitmap, &mygfx,
+ gfx_element_set_source_clip(gfx, tx, sizex, ty, sizey);
+ pdrawgfx( bitmap, gfx,
sprite,
color,
flipx,flipy,
diff --git a/src/mame/video/nemesis.c b/src/mame/video/nemesis.c
index ccf56587acf..4223b65a818 100644
--- a/src/mame/video/nemesis.c
+++ b/src/mame/video/nemesis.c
@@ -24,14 +24,6 @@ static int flipscreen;
static tilemap *background, *foreground;
-static UINT8 *blank_characterdata; /* pseudo character */
-
-/* gfxram dirty flags */
-
-/* we should be able to draw sprite gfx directly without caching to GfxElements */
-
-static UINT8 *sprite_dirty[8];
-
static const struct
{
UINT8 width;
@@ -44,6 +36,8 @@ sprite_data[8] =
{ 8, 8, 0 }, { 16, 8, 6 }, { 8, 16, 3 }, { 16, 16, 1 }
};
+static UINT8 blank_tile[8*8];
+
static TILE_GET_INFO( get_bg_tile_info )
{
int code,color,flags;
@@ -57,7 +51,8 @@ static TILE_GET_INFO( get_bg_tile_info )
if (code & 0xf800) {
SET_TILE_INFO( 0, code&0x7ff, color&0x7f, flags );
} else {
- SET_TILE_INFO( 0, 0x800, 0x00, 0 );
+ SET_TILE_INFO( 0, 0, 0x00, 0 );
+ tileinfo->pen_data = blank_tile;
}
tileinfo->category = (code & 0x1000)>>12;
}
@@ -75,7 +70,8 @@ static TILE_GET_INFO( get_fg_tile_info )
if (code & 0xf800) {
SET_TILE_INFO( 0, code&0x7ff, color&0x7f, flags );
} else {
- SET_TILE_INFO( 0, 0x800, 0x00, 0 );
+ SET_TILE_INFO( 0, 0, 0x00, 0 );
+ tileinfo->pen_data = blank_tile;
}
tileinfo->category = (code & 0x1000)>>12;
}
@@ -199,7 +195,7 @@ WRITE16_HANDLER( nemesis_characterram_word_w )
{
int w = sprite_data[i].width;
int h = sprite_data[i].height;
- sprite_dirty[i][offset * 4 / (w * h)] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[sprite_data[i].char_type], offset * 4 / (w * h));
}
}
}
@@ -208,7 +204,6 @@ WRITE16_HANDLER( nemesis_characterram_word_w )
/* claim a palette dirty array */
VIDEO_START( nemesis )
{
- int i;
spriteram_words = spriteram_size / 2;
background = tilemap_create(machine,
@@ -222,21 +217,16 @@ VIDEO_START( nemesis )
tilemap_set_scroll_rows( background, 256 );
tilemap_set_scroll_rows( foreground, 256 );
- for (i=0; i<8; i++)
- {
- int w = sprite_data[i].width;
- int h = sprite_data[i].height;
- int size = 0x20000 / (w * h);
- sprite_dirty[i] = auto_malloc(size);
- memset(sprite_dirty[i], 1, size);
- }
-
memset(nemesis_characterram,0,nemesis_characterram_size);
-
- blank_characterdata = auto_malloc(32*8/8*(2048+1));
- memset(blank_characterdata,0x00,32*8/8*(2048+1));
- decodechar(machine->gfx[0],0x800,(UINT8 *)blank_characterdata);
+ gfx_element_set_source(machine->gfx[0], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[1], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[2], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[3], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[4], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[5], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[6], (UINT8 *)nemesis_characterram);
+ gfx_element_set_source(machine->gfx[7], (UINT8 *)nemesis_characterram);
flipscreen = 0;
tilemap_flip = 0;
@@ -329,65 +319,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
/******************************************************************************/
-static void update_gfx(running_machine *machine)
-{
- int offs,code;
- int bAnyDirty;
-
- bAnyDirty = 0;
- for (offs = spriteram_words - 1;offs >= 0;offs --)
- {
- if (sprite_dirty[4][offs])
- {
- decodechar(machine->gfx[0],offs,(UINT8 *)nemesis_characterram);
- bAnyDirty = 1;
- sprite_dirty[4][offs] = 0;
- }
- }
- if( bAnyDirty )
- {
- tilemap_mark_all_tiles_dirty( background );
- tilemap_mark_all_tiles_dirty( foreground );
- }
-
- for (offs = 0;offs < spriteram_words;offs += 8)
- {
- int char_type;
- int zoom;
-
- zoom = spriteram16[offs+2] & 0xff;
- if (!(spriteram16[offs+2] & 0xff00) && ((spriteram16[offs+3] & 0xff00) != 0xff00))
- code = spriteram16[offs+3] + ((spriteram16[offs+4] & 0xc0) << 2);
- else
- code = (spriteram16[offs+3] & 0xff) + ((spriteram16[offs+4] & 0xc0) << 2);
-
- if (zoom != 0xFF || code!=0)
- {
- int size = spriteram16[offs+1];
- int idx = (size >> 3) & 7;
- int w, h;
-
- w = sprite_data[idx].width;
- h = sprite_data[idx].height;
- code = code * 8 * 16 / (w * h);
- char_type = sprite_data[idx].char_type;
- if (sprite_dirty[idx][code] == 1)
- {
- decodechar(machine->gfx[char_type],code,(UINT8 *)nemesis_characterram);
- sprite_dirty[idx][code] = 0;
- }
- }
- }
-}
-
-/******************************************************************************/
-
VIDEO_UPDATE( nemesis )
{
int offs;
- update_gfx(screen->machine);
-
bitmap_fill(priority_bitmap,cliprect,0);
bitmap_fill(bitmap,cliprect,0);
@@ -415,8 +350,6 @@ VIDEO_UPDATE( salamand )
int offs;
rectangle clip;
- update_gfx(screen->machine);
-
bitmap_fill(priority_bitmap,cliprect,0);
bitmap_fill(bitmap,cliprect,0);
diff --git a/src/mame/video/parodius.c b/src/mame/video/parodius.c
index ddc0c1d8b9a..765e4510c7a 100644
--- a/src/mame/video/parodius.c
+++ b/src/mame/video/parodius.c
@@ -93,6 +93,6 @@ VIDEO_UPDATE( parodius )
tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
- K053245_sprites_draw(0,bitmap,cliprect);
+ K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
return 0;
}
diff --git a/src/mame/video/plygonet.c b/src/mame/video/plygonet.c
index a77500be732..3db9a70174e 100644
--- a/src/mame/video/plygonet.c
+++ b/src/mame/video/plygonet.c
@@ -72,10 +72,7 @@ VIDEO_START( polygonet )
assert(ttl_gfx_index != MAX_GFX_ELEMENTS);
// decode the ttl layer's gfx
- machine->gfx[ttl_gfx_index] = allocgfx(machine, &charlayout);
- decodegfx(machine->gfx[ttl_gfx_index], memory_region(machine, "gfx1"), 0, machine->gfx[ttl_gfx_index]->total_elements);
-
- machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[ttl_gfx_index] = gfx_element_alloc(machine, &charlayout, memory_region(machine, "gfx1"), machine->config->total_colors / 16, 0);
// create the tilemap
ttl_tilemap = tilemap_create(machine, ttl_get_tile_info, plygonet_scan, 8, 8, 64, 32);
diff --git a/src/mame/video/polepos.c b/src/mame/video/polepos.c
index 2fb015f5fa6..6de4382978c 100644
--- a/src/mame/video/polepos.c
+++ b/src/mame/video/polepos.c
@@ -423,7 +423,7 @@ static void draw_road(running_machine *machine, bitmap_t *bitmap)
}
/* draw the scanline */
- draw_scanline16(bitmap, 0, y, 256, &scanline[xscroll], NULL, -1);
+ draw_scanline16(bitmap, 0, y, 256, &scanline[xscroll], NULL);
}
}
@@ -432,7 +432,7 @@ static void zoom_sprite(running_machine *machine, bitmap_t *bitmap,int big,
int sizex,int sizey)
{
const gfx_element *gfx = machine->gfx[big ? 3 : 2];
- UINT8 *gfxdata = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *gfxdata = gfx_element_get_data(gfx, code % gfx->total_elements);
UINT8 *scaling_rom = memory_region(machine, "gfx6");
UINT32 transmask = colortable_get_transpen_mask(machine->colortable, gfx, color, 0x1f);
int coloroffs = gfx->color_base + color * gfx->color_granularity;
@@ -451,7 +451,7 @@ static void zoom_sprite(running_machine *machine, bitmap_t *bitmap,int big,
int xx = sx & 0x3ff;
int siz = 0;
int offs = 0;
- UINT8 *src;
+ const UINT8 *src;
if (!big) dy >>= 1;
src = gfxdata + dy * gfx->line_modulo;
diff --git a/src/mame/video/policetr.c b/src/mame/video/policetr.c
index 0dbe9f3bc31..52bce56563a 100644
--- a/src/mame/video/policetr.c
+++ b/src/mame/video/policetr.c
@@ -366,7 +366,7 @@ VIDEO_UPDATE( policetr )
/* render all the scanlines from the dstbitmap to MAME's bitmap */
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
- draw_scanline8(bitmap, cliprect->min_x, y, width, &dstbitmap[DSTBITMAP_WIDTH * y + cliprect->min_x], NULL, -1);
+ draw_scanline8(bitmap, cliprect->min_x, y, width, &dstbitmap[DSTBITMAP_WIDTH * y + cliprect->min_x], NULL);
return 0;
}
diff --git a/src/mame/video/polyplay.c b/src/mame/video/polyplay.c
index e53320f22db..861aef4940e 100644
--- a/src/mame/video/polyplay.c
+++ b/src/mame/video/polyplay.c
@@ -14,7 +14,6 @@
UINT8 *polyplay_characterram;
-static UINT8 dirtycharacter[256];
@@ -38,12 +37,17 @@ WRITE8_HANDLER( polyplay_characterram_w )
{
if (polyplay_characterram[offset] != data)
{
- dirtycharacter[((offset >> 3) & 0x7f) | 0x80] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[1], ((offset >> 3) & 0x7f) | 0x80);
polyplay_characterram[offset] = data;
}
}
+VIDEO_START( polyplay )
+{
+ gfx_element_set_source(machine->gfx[1], polyplay_characterram);
+}
+
VIDEO_UPDATE( polyplay )
{
@@ -56,13 +60,6 @@ VIDEO_UPDATE( polyplay )
int sy = offs >> 6 << 3;
UINT8 code = videoram[offs];
- if (dirtycharacter[code])
- {
- decodechar(screen->machine->gfx[1], code & 0x7f, polyplay_characterram);
-
- dirtycharacter[code] = 0;
- }
-
drawgfx(bitmap,screen->machine->gfx[(code >> 7) & 0x01],
code, 0, 0, 0, sx, sy,
cliprect, TRANSPARENCY_NONE, 0);
diff --git a/src/mame/video/ppu2c0x.c b/src/mame/video/ppu2c0x.c
index 4b82974021a..d71d62d38f0 100644
--- a/src/mame/video/ppu2c0x.c
+++ b/src/mame/video/ppu2c0x.c
@@ -72,8 +72,6 @@ typedef struct {
UINT8 *spriteram; /* sprite ram */
pen_t *colortable; /* color table modified at run time */
pen_t *colortable_mono; /* monochromatic color table modified at run time */
- UINT8 *dirtychar; /* an array flagging dirty characters */
- int chars_are_dirty; /* master flag to check if theres any dirty character */
emu_timer *scanline_timer; /* scanline timer */
emu_timer *hblank_timer; /* hblank period at end of each scanline */
emu_timer *nmi_timer; /* NMI timer */
@@ -310,7 +308,6 @@ void ppu2c0x_init(running_machine *machine, const ppu2c0x_interface *interface )
chips[i].videomem = auto_malloc( VIDEOMEM_SIZE );
chips[i].videoram = auto_malloc( VIDEOMEM_SIZE );
chips[i].spriteram = auto_malloc( SPRITERAM_SIZE );
- chips[i].dirtychar = auto_malloc( CHARGEN_NUM_CHARS );
chips[i].colortable = auto_malloc( sizeof( default_colortable ) );
chips[i].colortable_mono = auto_malloc( sizeof( default_colortable_mono ) );
@@ -320,9 +317,6 @@ void ppu2c0x_init(running_machine *machine, const ppu2c0x_interface *interface )
memset( chips[i].spriteram, 0, SPRITERAM_SIZE );
memset( chips[i].videoram_banks_indices, 0xff, sizeof(chips[i].videoram_banks_indices) );
- /* set all characters dirty */
- memset( chips[i].dirtychar, 1, CHARGEN_NUM_CHARS );
-
if ( intf->vram_enabled[i] )
{
chips[i].has_videoram = 1;
@@ -362,9 +356,7 @@ void ppu2c0x_init(running_machine *machine, const ppu2c0x_interface *interface )
memcpy(&gl, &ppu_charlayout, sizeof(gl));
gl.total = total;
- machine->gfx[intf->gfx_layout_number[i]] = allocgfx( machine, &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;
+ machine->gfx[intf->gfx_layout_number[i]] = gfx_element_alloc( machine, &gl, src, 8, 0 );
}
/* setup our videomem handlers based on mirroring */
@@ -412,9 +404,7 @@ static void draw_background(running_machine *machine, int num, UINT8 *line_prior
const int total_elements = chips[num].machine->gfx[gfx_bank]->total_elements;
const int *nes_vram = &chips[num].nes_vram[0];
const int tile_page = chips[num].tile_page;
- const int char_modulo = chips[num].machine->gfx[gfx_bank]->char_modulo;
const int line_modulo = chips[num].machine->gfx[gfx_bank]->line_modulo;
- UINT8 *gfx_data = chips[num].machine->gfx[gfx_bank]->gfxdata;
UINT8 **ppu_page = chips[num].ppu_page;
int start_x = ( chips[num].x_fine ^ 0x07 ) - 7;
UINT16 back_pen;
@@ -493,8 +483,8 @@ static void draw_background(running_machine *machine, int num, UINT8 *line_prior
if(start_x < VISIBLE_SCREEN_WIDTH )
{
paldata = &color_table[ 4 * ( ( ( color_byte >> color_bits ) & 0x03 ) ) ];
- start = ( index2 % total_elements ) * char_modulo + scroll_y_fine * line_modulo;
- sd = &gfx_data[start];
+ start = scroll_y_fine * line_modulo;
+ sd = gfx_element_get_data(chips[num].machine->gfx[gfx_bank], index2 % total_elements) + start;
/* render the pixel */
for( i = 0; i < 8; i++ )
@@ -548,11 +538,9 @@ static void draw_sprites(running_machine *machine, int num, UINT8 *line_priority
const int gfx_bank = intf->gfx_layout_number[num];
const int total_elements = chips[num].machine->gfx[gfx_bank]->total_elements;
const int sprite_page = chips[num].sprite_page;
- const int char_modulo = chips[num].machine->gfx[gfx_bank]->char_modulo;
const int line_modulo = chips[num].machine->gfx[gfx_bank]->line_modulo;
const UINT8 *sprite_ram = chips[num].spriteram;
pen_t *color_table = chips[num].colortable;
- UINT8 *gfx_data = chips[num].machine->gfx[gfx_bank]->gfxdata;
int *ppu_regs = &chips[num].regs[0];
int spriteXPos, spriteYPos, spriteIndex;
@@ -637,8 +625,10 @@ static void draw_sprites(running_machine *machine, int num, UINT8 *line_priority
sprite_line = ( size - 1 ) - sprite_line;
paldata = &color_table[4 * color];
- start = ( index1 % total_elements ) * char_modulo + sprite_line * line_modulo;
- sd = &gfx_data[start];
+ start = sprite_line * line_modulo;
+ sd = gfx_element_get_data(chips[num].machine->gfx[gfx_bank], index1 % total_elements) + start;
+ if (size > 8)
+ gfx_element_get_data(chips[num].machine->gfx[gfx_bank], (index1 + 1) % total_elements);
if ( pri )
{
@@ -859,7 +849,6 @@ static TIMER_CALLBACK( scanline_callback )
int num = param;
ppu2c0x_chip* this_ppu = &chips[num];
int *ppu_regs = &chips[num].regs[0];
- int i;
int blanked = ( ppu_regs[PPU_CONTROL1] & ( PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES ) ) == 0;
int vblank = ((this_ppu->scanline >= PPU_VBLANK_FIRST_SCANLINE-1) && (this_ppu->scanline < this_ppu->scanlines_per_frame-1)) ? 1 : 0;
int next_scanline;
@@ -894,29 +883,6 @@ logerror("vlbank starting\n");
}
}
- /* decode any dirty chars if we're using vram */
-
- /* first, check the master dirty char flag */
- if ( (!this_ppu->has_videorom || this_ppu->has_videoram) && this_ppu->chars_are_dirty )
- {
- /* cache some values */
- UINT8 *dirtyarray = this_ppu->dirtychar;
- UINT8 *vram = this_ppu->videomem;
- gfx_element *gfx = chips[num].machine->gfx[intf->gfx_layout_number[num]];
-
- /* then iterate and decode */
- for( i = 0; i < CHARGEN_NUM_CHARS; i++ )
- {
- if ( dirtyarray[i] )
- {
- decodechar( gfx, i, vram );
- dirtyarray[i] = 0;
- }
- }
-
- this_ppu->chars_are_dirty = 0;
- }
-
if ( this_ppu->scanline == this_ppu->scanlines_per_frame - 1 )
{
logerror("vlbank ending\n");
@@ -996,7 +962,6 @@ void ppu2c0x_reset(running_machine *machine, int num, int scan_scale)
chips[num].tile_page = 0;
chips[num].sprite_page = 0;
chips[num].back_color = 0;
- chips[num].chars_are_dirty = 1;
/* initialize the color tables */
{
@@ -1244,11 +1209,8 @@ void ppu2c0x_w( const address_space *space, offs_t offset, UINT8 data, int num )
/* store the data */
this_ppu->videomem[tempAddr] = data;
- /* setup the master dirty switch */
- this_ppu->chars_are_dirty = 1;
-
/* mark the char dirty */
- this_ppu->dirtychar[tempAddr >> 4] = 1;
+ gfx_element_mark_dirty(this_ppu->machine->gfx[intf->gfx_layout_number[num]], tempAddr >> 4);
}
}
@@ -1397,14 +1359,16 @@ void ppu2c0x_set_videorom_bank( int num, int start_page, int num_pages, int bank
{
for ( i = start_page; i < start_page + num_pages; i++ )
{
+ int elemnum;
+
if ( chips[num].videoram_banks_indices[i] != -1 )
{
memcpy( &chips[num].videoram[chips[num].videoram_banks_indices[i]*0x400], &chips[num].videomem[i*0x400], 0x400);
}
chips[num].videoram_banks_indices[i] = -1;
- memset( &chips[num].dirtychar[start_page*0x400 >> 4], 1, (num_pages*0x400 >> 4));
+ for (elemnum = 0; elemnum < (num_pages*0x400 >> 4); elemnum++)
+ gfx_element_mark_dirty(chips[num].machine->gfx[intf->gfx_layout_number[num]], (start_page*0x400 >> 4) + elemnum);
}
- chips[num].chars_are_dirty = 1;
}
else
{
@@ -1447,14 +1411,15 @@ void ppu2c0x_set_videoram_bank( int num, int start_page, int num_pages, int bank
for ( i = start_page; i < start_page + num_pages; i++ )
{
+ int elemnum;
if ( chips[num].videoram_banks_indices[i] != -1 )
{
memcpy( &chips[num].videoram[chips[num].videoram_banks_indices[i]*0x400], &chips[num].videomem[i*0x400], 0x400);
}
chips[num].videoram_banks_indices[i] = (bank * bank_size * 16)/0x400 + (i - start_page);
- memset( &chips[num].dirtychar[start_page*0x400 >> 4], 1, (num_pages*0x400 >> 4));
+ for (elemnum = 0; elemnum < (num_pages*0x400 >> 4); elemnum++)
+ gfx_element_mark_dirty(chips[num].machine->gfx[intf->gfx_layout_number[num]], (start_page*0x400 >> 4) + elemnum);
}
- chips[num].chars_are_dirty = 1;
{
int vram_start = start_page * 0x400;
diff --git a/src/mame/video/psikyosh.c b/src/mame/video/psikyosh.c
index 9d5f7e410ec..a8c2604ff16 100644
--- a/src/mame/video/psikyosh.c
+++ b/src/mame/video/psikyosh.c
@@ -92,19 +92,64 @@ sol divide doesn't seem to make much use of tilemaps at all, it uses them to fad
#include "driver.h"
#include "profiler.h"
#include "psikyosh.h"
+#include "drawgfxm.h"
/* Needed for psikyosh_drawgfxzoom */
static bitmap_t *zoom_bitmap, *z_bitmap;
+static UINT8 alphatable[256];
/* Psikyo PS6406B */
/* --- BACKGROUNDS --- */
+#define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != 0) \
+ (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alphatable[srcdata]); \
+} \
+while (0) \
+
+void drawgfx_alphatable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
+ UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
+ int fixedalpha)
+{
+ bitmap_t *priority = NULL; /* dummy, no priority in this case */
+
+ const pen_t *paldata;
+
+ /* if we have a fixed alpha, call the standard drawgfx_alpha */
+ if (fixedalpha >= 0)
+ {
+ drawgfx_alpha(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, 0, fixedalpha);
+ return;
+ }
+
+ assert(dest != NULL);
+ assert(dest->bpp == 32);
+ assert(gfx != NULL);
+ assert(alphatable != NULL);
+
+ /* get final code and color, and grab lookup tables */
+ code %= gfx->total_elements;
+ color %= gfx->total_colors;
+ paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
+
+ /* early out if completely transparent */
+ if (gfx->pen_usage != NULL && (gfx->pen_usage[code] & ~(1 << 0)) == 0)
+ return;
+
+ /* render based on dest bitmap depth */
+ DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANS0_ALPHATABLE32, NO_PRIORITY);
+}
+
+
/* 'Normal' layers, no line/columnscroll. No per-line effects */
static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
{
gfx_element *gfx;
int offs=0, sx, sy;
- int scrollx, scrolly, bank, alpha, alphamap, trans, size, width;
+ int scrollx, scrolly, bank, alpha, alphamap, size, width;
if ( BG_TYPE(layer) == BG_NORMAL_ALT )
{
@@ -130,13 +175,9 @@ static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap,
width = BG_LARGE(layer) ? 0x200 : 0x100;
if(alphamap) { /* alpha values are per-pen */
- trans = TRANSPARENCY_ALPHARANGE;
- } else if(alpha) {
- trans = TRANSPARENCY_ALPHA;
- alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
- alpha_set_level(alpha);
+ alpha = -1;
} else {
- trans = TRANSPARENCY_PEN;
+ alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
}
if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
@@ -150,13 +191,13 @@ static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap,
tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
if(scrollx)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
if(scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
if(scrollx && scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
offs++;
}
@@ -170,7 +211,7 @@ static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitm
{
gfx_element *gfx;
int offs, sx, sy;
- int scrollx, scrolly, bank, size, width, scrollbank,trans,alpha,alphamap;
+ int scrollx, scrolly, bank, size, width, scrollbank,alpha,alphamap;
scrollbank = BG_TYPE(layer); /* Scroll bank appears to be same as layer type */
@@ -186,13 +227,9 @@ static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitm
scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x03ff0000) >> 16;
if(alphamap) { /* alpha values are per-pen */
- trans = TRANSPARENCY_ALPHARANGE;
- } else if(alpha) {
- trans = TRANSPARENCY_ALPHA;
- alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
- alpha_set_level(alpha);
+ alpha = -1;
} else {
- trans = TRANSPARENCY_PEN;
+ alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
}
@@ -205,13 +242,13 @@ static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitm
tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
if(scrollx)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
if(scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
if(scrollx && scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
offs++;
}}}
@@ -224,13 +261,9 @@ static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitm
scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4 + 0x20/4] & 0x03ff0000) >> 16;
if(alphamap) { /* alpha values are per-pen */
- trans = TRANSPARENCY_ALPHARANGE;
- } else if(alpha) {
- trans = TRANSPARENCY_ALPHA;
- alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
- alpha_set_level(alpha);
+ alpha = -1;
} else {
- trans = TRANSPARENCY_PEN;
+ alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
}
if((bank>=0x0c) && (bank<=0x1f)) { /* shouldn't happen, 20 banks of 0x800 bytes */
@@ -242,13 +275,13 @@ static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitm
tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
if(scrollx)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
if(scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
if(scrollx && scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
offs++;
}}}
@@ -260,7 +293,7 @@ static void draw_bglayerscroll(running_machine *machine, int layer, bitmap_t *bi
{
gfx_element *gfx;
int offs, sx, sy;
- int scrollx, scrolly, bank, alpha, alphamap, trans, size, width, scrollbank;
+ int scrollx, scrolly, bank, alpha, alphamap, size, width, scrollbank;
scrollbank = BG_TYPE(layer); /* Scroll bank appears to be same as layer type */
@@ -280,13 +313,9 @@ static void draw_bglayerscroll(running_machine *machine, int layer, bitmap_t *bi
width = BG_LARGE(layer) ? 0x200 : 0x100;
if(alphamap) { /* alpha values are per-pen */
- trans = TRANSPARENCY_ALPHARANGE;
- } else if(alpha) {
- trans = TRANSPARENCY_ALPHA;
- alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
- alpha_set_level(alpha);
+ alpha = -1;
} else {
- trans = TRANSPARENCY_PEN;
+ alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
}
if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
@@ -315,13 +344,13 @@ static void draw_bglayerscroll(running_machine *machine, int layer, bitmap_t *bi
// drawgfx(zoom_bitmap,gfx,tileno,colour,0,0,(16*sx)&0x1ff,((16*sy)&(width-1)),NULL,TRANSPARENCY_PEN,0);
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
if(scrollx)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
if(scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
if(scrollx && scrolly)
- drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
+ drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
offs++;
}
@@ -395,7 +424,7 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re
static void psikyosh_drawgfxzoom( running_machine *machine,
bitmap_t *dest_bmp,const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
- const rectangle *clip,int transparency,int transparent_color,
+ const rectangle *clip,int alpha,
int zoomx, int zoomy, int wide, int high, UINT32 z)
{
rectangle myclip; /* Clip to screen boundaries */
@@ -406,7 +435,6 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
profiler_mark(PROFILER_DRAWGFX);
- assert(transparency == TRANSPARENCY_PEN || transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHARANGE);
assert(dest_bmp->bpp == 32);
/* KW 991012 -- Added code to force clip to bitmap boundary */
@@ -444,7 +472,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for (xtile = xstart; xtile != xend; xtile += xinc )
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height;
+ const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements);
int x_index_base, y_index, sx, sy, ex, ey;
@@ -494,11 +522,11 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
int y;
/* case 1: TRANSPARENCY_PEN */
- if (transparency == TRANSPARENCY_PEN)
+ if (alpha == 0xff)
{
if( z > 0 )
{
- UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
+ const UINT8 *source = code_base + (y_index)*gfx->line_modulo + x_index_base;
UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
@@ -512,7 +540,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if(z >= *pri)
{
int c = *source;
- if( c != transparent_color )
+ if( c != 0 )
{
*dest = pal[c];
*pri = z;
@@ -529,7 +557,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
else
{
- UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
+ const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
int dst_modulo = dest_bmp->rowpixels - (ex-sx);
@@ -540,7 +568,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for( x=sx; x<ex; x++ )
{
int c = *source;
- if( c != transparent_color ) *dest = pal[c];
+ if( c != 0 ) *dest = pal[c];
dest++;
source += xinc;
@@ -551,12 +579,12 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
}
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
+ /* case 6: alpha-blended */
+ else if (alpha >= 0)
{
if ( z > 0 )
{
- UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
+ const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
@@ -570,9 +598,9 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if(z >= *pri)
{
int c = *source;
- if( c != transparent_color )
+ if( c != 0 )
{
- *dest = alpha_blend32(*dest, pal[c]);
+ *dest = alpha_blend_r32(*dest, pal[c], alpha);
*pri = z;
}
}
@@ -587,7 +615,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
else
{
- UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
+ const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
int dst_modulo = dest_bmp->rowpixels - (ex-sx);
@@ -598,7 +626,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for( x=sx; x<ex; x++ )
{
int c = *source;
- if( c != transparent_color ) *dest = alpha_blend32(*dest, pal[c]);
+ if( c != 0 ) *dest = alpha_blend_r32(*dest, pal[c], alpha);
dest++;
source += xinc;
@@ -611,11 +639,11 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
/* pjp 31/5/02 */
/* case 7: TRANSPARENCY_ALPHARANGE */
- if (transparency == TRANSPARENCY_ALPHARANGE)
+ else
{
if ( z > 0 )
{
- UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
+ const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
@@ -629,12 +657,12 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if(z >= *pri)
{
int c = *source;
- if( c != transparent_color )
+ if( c != 0 )
{
- if( gfx_alpharange_table[c] == 0xff )
+ if( alphatable[c] == 0xff )
*dest = pal[c];
else
- *dest = alpha_blend_r32(*dest, pal[c], gfx_alpharange_table[c]);
+ *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]);
*pri = z;
}
@@ -650,7 +678,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
else
{
- UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
+ const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
int dst_modulo = dest_bmp->rowpixels - (ex-sx);
@@ -661,12 +689,12 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for( x=sx; x<ex; x++ )
{
int c = *source;
- if( c != transparent_color )
+ if( c != 0 )
{
- if( gfx_alpharange_table[c] == 0xff )
+ if( alphatable[c] == 0xff )
*dest = pal[c];
else
- *dest = alpha_blend_r32(*dest, pal[c], gfx_alpharange_table[c]);
+ *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]);
}
dest++;
source += xinc;
@@ -690,10 +718,10 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
{
for(xtile=0; xtile<wide; xtile++)
{
- int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height;
+ const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements);
for( ypixel=0; ypixel<gfx->height; ypixel++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+ypixel) * gfx->line_modulo;
+ const UINT8 *source = code_base + ypixel * gfx->line_modulo;
UINT8 *dest = BITMAP_ADDR8(zoom_bitmap, ypixel + ytile*gfx->height, 0);
for( xpixel=0; xpixel<gfx->width; xpixel++ )
@@ -766,7 +794,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
/* case 1: TRANSPARENCY_PEN */
/* Note: adjusted to >>10 and draws from zoom_bitmap not gfx */
- if (transparency == TRANSPARENCY_PEN)
+ if (alpha == 0xff)
{
if( z > 0 )
{
@@ -782,7 +810,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if(z >= pri[x])
{
int c = source[x_index>>10];
- if( c != transparent_color )
+ if( c != 0 )
{
dest[x] = pal[c];
pri[x] = z;
@@ -805,7 +833,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>10];
- if( c != transparent_color ) dest[x] = pal[c];
+ if( c != 0 ) dest[x] = pal[c];
x_index += dx;
}
@@ -814,8 +842,8 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
}
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
+ /* case 6: alpha-blended */
+ else if (alpha >= 0)
{
if( z > 0 )
{
@@ -831,9 +859,9 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if(z >= pri[x])
{
int c = source[x_index>>10];
- if( c != transparent_color )
+ if( c != 0 )
{
- dest[x] = alpha_blend32(dest[x], pal[c]);
+ dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
pri[x] = z;
}
}
@@ -854,7 +882,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>10];
- if( c != transparent_color ) dest[x] = alpha_blend32(dest[x], pal[c]);
+ if( c != 0 ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
x_index += dx;
}
@@ -864,7 +892,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
/* case 7: TRANSPARENCY_ALPHARANGE */
- if (transparency == TRANSPARENCY_ALPHARANGE)
+ else
{
if( z > 0 )
{
@@ -880,12 +908,12 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if(z >= pri[x])
{
int c = source[x_index>>10];
- if( c != transparent_color )
+ if( c != 0 )
{
- if( gfx_alpharange_table[c] == 0xff )
+ if( alphatable[c] == 0xff )
dest[x] = pal[c];
else
- dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
+ dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]);
pri[x] = z;
}
@@ -907,12 +935,12 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>10];
- if( c != transparent_color )
+ if( c != 0 )
{
- if( gfx_alpharange_table[c] == 0xff )
+ if( alphatable[c] == 0xff )
dest[x] = pal[c];
else
- dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
+ dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]);
}
x_index += dx;
}
@@ -972,7 +1000,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
while( listcntr < listlen )
{
UINT32 listdat, sprnum, xpos, ypos, high, wide, flpx, flpy, zoomx, zoomy, tnum, colr, dpth;
- UINT32 pri, alpha, alphamap, trans;
+ UINT32 pri, alphamap;
+ int alpha;
listdat = list[BYTE_XOR_BE(listcntr)];
sprnum = (listdat & 0x03ff) * 4;
@@ -1009,19 +1038,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
gfx = dpth ? machine->gfx[1] : machine->gfx[0];
if(alphamap) { /* alpha values are per-pen */
- trans = TRANSPARENCY_ALPHARANGE;
- } else if(alpha) {
- alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
- trans = TRANSPARENCY_ALPHA;
- alpha_set_level(alpha);
+ alpha = -1;
} else {
- trans = TRANSPARENCY_PEN;
+ alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
}
/* start drawing */
if( zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)] ) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */
{
- psikyosh_drawgfxzoom(machine, bitmap,gfx,tnum,colr,flpx,flpy,xpos,ypos,cliprect,trans,0,
+ psikyosh_drawgfxzoom(machine, bitmap,gfx,tnum,colr,flpx,flpy,xpos,ypos,cliprect,alpha,
(UINT32)zoom_table[BYTE_XOR_BE(zoomx)], (UINT32)zoom_table[BYTE_XOR_BE(zoomy)], wide, high, listcntr);
#if 0
@@ -1066,10 +1091,10 @@ VIDEO_START( psikyosh )
{ /* Pens 0xc0-0xff have a gradient of alpha values associated with them */
int i;
for (i=0; i<0xc0; i++)
- gfx_alpharange_table[i] = 0xff;
+ alphatable[i] = 0xff;
for (i=0; i<0x40; i++) {
int alpha = ((0x3f-i)*0xff)/0x3f;
- gfx_alpharange_table[i+0xc0] = alpha;
+ alphatable[i+0xc0] = alpha;
}
}
diff --git a/src/mame/video/psx.c b/src/mame/video/psx.c
index 84a96e2b1c3..1690e684b4a 100644
--- a/src/mame/video/psx.c
+++ b/src/mame/video/psx.c
@@ -537,7 +537,7 @@ static int DebugTextureDisplay( running_machine *machine, bitmap_t *bitmap )
}
p_n_interleave[ n_x ] = m_p_p_vram[ n_yi ][ n_xi ];
}
- draw_scanline16( bitmap, 0, n_y, width, p_n_interleave, machine->pens, -1 );
+ draw_scanline16( bitmap, 0, n_y, width, p_n_interleave, machine->pens );
}
}
return m_debug.b_texture;
@@ -922,7 +922,7 @@ VIDEO_UPDATE( psx )
n_line = n_lines;
while( n_line > 0 )
{
- draw_scanline16( bitmap, n_x + n_left, n_y + n_top, n_columns, m_p_p_vram[ n_y + m_n_displaystarty ] + n_x + n_displaystartx, NULL, -1 );
+ draw_scanline16( bitmap, n_x + n_left, n_y + n_top, n_columns, m_p_p_vram[ n_y + m_n_displaystarty ] + n_x + n_displaystartx, NULL );
n_y++;
n_line--;
}
diff --git a/src/mame/video/qix.c b/src/mame/video/qix.c
index 242173a6d31..9c099113612 100644
--- a/src/mame/video/qix.c
+++ b/src/mame/video/qix.c
@@ -327,8 +327,8 @@ static MC6845_BEGIN_UPDATE( begin_update )
static MC6845_UPDATE_ROW( update_row )
{
qix_state *state = device->machine->driver_data;
+ UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
UINT16 x;
- UINT8 scanline[256];
pen_t *pens = (pen_t *)param;
@@ -337,9 +337,7 @@ static MC6845_UPDATE_ROW( update_row )
offs_t offs_xor = state->flip ? 0xffff : 0;
for (x = 0; x < x_count * 8; x++)
- scanline[x] = state->videoram[(offs + x) ^ offs_xor];
-
- draw_scanline8(bitmap, 0, y, x_count * 8, scanline, pens, -1);
+ dest[x] = pens[state->videoram[(offs + x) ^ offs_xor]];
}
diff --git a/src/mame/video/rallyx.c b/src/mame/video/rallyx.c
index 772fccb5dba..a719d75a809 100644
--- a/src/mame/video/rallyx.c
+++ b/src/mame/video/rallyx.c
@@ -16,8 +16,8 @@ When there is a sprite under the bullet, the palette bank is changed, but the
palette entry number is NOT changed; therefore, the sprite pixels that are
covered by the bullet just change bank. This is emulated by first drawing the
bullets normally, then drawing the sprites (with pdrawgfx so they are not
-drawn over high priority tiles), then drawing the pullets again in
-TRANSPARENCY_PEN_TABLE mode, so that bullets not covered by sprites remain
+drawn over high priority tiles), then drawing the pullets again with
+drawgfx_transtable mode, so that bullets not covered by sprites remain
the same while the others alter the sprite color.
@@ -50,6 +50,7 @@ struct star
};
static struct star stars[MAX_STARS];
static int total_stars;
+static UINT8 drawmode_table[4];
/***************************************************************************
@@ -356,9 +357,9 @@ VIDEO_START( rallyx )
machine->shadow_table[i] = i;
for (i = 0;i < 3;i++)
- gfx_drawmode_table[i] = DRAWMODE_SHADOW;
+ drawmode_table[i] = DRAWMODE_SHADOW;
- gfx_drawmode_table[3] = DRAWMODE_NONE;
+ drawmode_table[3] = DRAWMODE_NONE;
}
@@ -383,9 +384,9 @@ VIDEO_START( jungler )
machine->shadow_table[i] = i;
for (i = 0;i < 3;i++)
- gfx_drawmode_table[i] = DRAWMODE_SHADOW;
+ drawmode_table[i] = DRAWMODE_SHADOW;
- gfx_drawmode_table[3] = DRAWMODE_NONE;
+ drawmode_table[3] = DRAWMODE_NONE;
calculate_star_field();
}
@@ -419,9 +420,9 @@ VIDEO_START( locomotn )
machine->shadow_table[i] = i;
for (i = 0;i < 3;i++)
- gfx_drawmode_table[i] = DRAWMODE_SHADOW;
+ drawmode_table[i] = DRAWMODE_SHADOW;
- gfx_drawmode_table[3] = DRAWMODE_NONE;
+ drawmode_table[3] = DRAWMODE_NONE;
calculate_star_field();
}
@@ -456,9 +457,9 @@ VIDEO_START( commsega )
machine->shadow_table[i] = i;
for (i = 0;i < 3;i++)
- gfx_drawmode_table[i] = DRAWMODE_SHADOW;
+ drawmode_table[i] = DRAWMODE_SHADOW;
- gfx_drawmode_table[3] = DRAWMODE_NONE;
+ drawmode_table[3] = DRAWMODE_NONE;
calculate_star_field();
}
@@ -575,7 +576,7 @@ static void locomotn_draw_sprites(running_machine *machine, bitmap_t *bitmap, co
}
}
-static void rallyx_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transparency )
+static void rallyx_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transpen )
{
int offs;
@@ -587,16 +588,24 @@ static void rallyx_draw_bullets(running_machine *machine, bitmap_t *bitmap, cons
y = 253 - rallyx_radary[offs];
if (flip_screen_get(machine)) x -= 3;
- drawgfx(bitmap,machine->gfx[2],
- ((rallyx_radarattr[offs & 0x0f] & 0x0e) >> 1) ^ 0x07,
- 0,
- 0,0,
- x,y,
- cliprect,transparency,3);
+ if (transpen)
+ drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
+ ((rallyx_radarattr[offs & 0x0f] & 0x0e) >> 1) ^ 0x07,
+ 0,
+ 0,0,
+ x,y,
+ 3);
+ else
+ drawgfx_transtable(bitmap,cliprect,machine->gfx[2],
+ ((rallyx_radarattr[offs & 0x0f] & 0x0e) >> 1) ^ 0x07,
+ 0,
+ 0,0,
+ x,y,
+ drawmode_table,machine->shadow_table);
}
}
-static void jungler_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transparency )
+static void jungler_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transpen )
{
int offs;
@@ -607,16 +616,24 @@ static void jungler_draw_bullets(running_machine *machine, bitmap_t *bitmap, con
x = rallyx_radarx[offs] + ((~rallyx_radarattr[offs & 0x0f] & 0x08) << 5);
y = 253 - rallyx_radary[offs];
- drawgfx(bitmap,machine->gfx[2],
- (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
- 0,
- 0,0,
- x,y,
- cliprect,transparency,3);
+ if (transpen)
+ drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
+ (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
+ 0,
+ 0,0,
+ x,y,
+ 3);
+ else
+ drawgfx_transtable(bitmap,cliprect,machine->gfx[2],
+ (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
+ 0,
+ 0,0,
+ x,y,
+ drawmode_table,machine->shadow_table);
}
}
-static void locomotn_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transparency )
+static void locomotn_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transpen )
{
int offs;
@@ -635,12 +652,20 @@ static void locomotn_draw_bullets(running_machine *machine, bitmap_t *bitmap, co
x = rallyx_radarx[offs] + ((~rallyx_radarattr[offs & 0x0f] & 0x08) << 5);
y = 252 - rallyx_radary[offs];
- drawgfx(bitmap,machine->gfx[2],
- (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
- 0,
- 0,0,
- x,y,
- cliprect,transparency,3);
+ if (transpen)
+ drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
+ (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
+ 0,
+ 0,0,
+ x,y,
+ 3);
+ else
+ drawgfx_transtable(bitmap,cliprect,machine->gfx[2],
+ (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
+ 0,
+ 0,0,
+ x,y,
+ drawmode_table,machine->shadow_table);
}
}
@@ -669,9 +694,9 @@ VIDEO_UPDATE( rallyx )
tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,1);
tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,1);
- rallyx_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN);
- rallyx_draw_sprites(screen->machine, bitmap,cliprect,1);
- rallyx_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN_TABLE);
+ rallyx_draw_bullets(screen->machine,bitmap,cliprect,TRUE);
+ rallyx_draw_sprites(screen->machine,bitmap,cliprect,1);
+ rallyx_draw_bullets(screen->machine,bitmap,cliprect,FALSE);
return 0;
}
@@ -702,9 +727,9 @@ VIDEO_UPDATE( jungler )
tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,0);
tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,0);
- jungler_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN);
- rallyx_draw_sprites(screen->machine, bitmap,cliprect,0);
- jungler_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN_TABLE);
+ jungler_draw_bullets(screen->machine,bitmap,cliprect,TRUE);
+ rallyx_draw_sprites(screen->machine,bitmap,cliprect,0);
+ jungler_draw_bullets(screen->machine,bitmap,cliprect,FALSE);
if (stars_enable)
draw_stars(screen->machine, bitmap, cliprect);
@@ -746,9 +771,9 @@ VIDEO_UPDATE( locomotn )
tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,1);
tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,1);
- locomotn_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN);
- locomotn_draw_sprites(screen->machine, bitmap,cliprect,0);
- locomotn_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN_TABLE);
+ locomotn_draw_bullets(screen->machine,bitmap,cliprect,TRUE);
+ locomotn_draw_sprites(screen->machine,bitmap,cliprect,0);
+ locomotn_draw_bullets(screen->machine,bitmap,cliprect,FALSE);
if (stars_enable)
draw_stars(screen->machine, bitmap, cliprect);
diff --git a/src/mame/video/realbrk.c b/src/mame/video/realbrk.c
index 12611b1c177..bce6b36b446 100644
--- a/src/mame/video/realbrk.c
+++ b/src/mame/video/realbrk.c
@@ -222,8 +222,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
rectangle spritetile_clip;
spritetile_clip.min_x = 0;
spritetile_clip.min_y = 0;
- spritetile_clip.max_x = 32;
- spritetile_clip.max_y = 32;
+ spritetile_clip.max_x = 31;
+ spritetile_clip.max_y = 31;
for ( offs = 0x3000/2; offs < 0x3600/2; offs += 2/2 )
{
@@ -314,14 +314,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
switch( rot )
{
case 0x10: // rot 90
- copyrozbitmap( tmpbitmap1, tmpbitmap0,
+ copyrozbitmap_trans( tmpbitmap1, NULL, tmpbitmap0,
(UINT32)0<<16,
(UINT32)16<<16,
0 << 16,
-1 << 16,
1 << 16,
0 << 16,
- 0, cliprect, TRANSPARENCY_PEN, 0, 0 );
+ 0, 0 );
currx = (sx - (y+1) * ydim) / 0x10000;
curry = (sy + x * xdim) / 0x10000;
@@ -330,14 +330,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
break;
case 0x20: // rot 180
- copyrozbitmap( tmpbitmap1, tmpbitmap0,
+ copyrozbitmap_trans( tmpbitmap1, NULL, tmpbitmap0,
(UINT32)16<<16,
(UINT32)16<<16,
-1 << 16,
0 << 16,
0 << 16,
-1 << 16,
- 0, cliprect, TRANSPARENCY_PEN, 0, 0 );
+ 0, 0 );
currx = (sx - (x+1) * xdim) / 0x10000;
curry = (sy - (y+1) * ydim) / 0x10000;
@@ -346,14 +346,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
break;
case 0x30: // rot 270
- copyrozbitmap( tmpbitmap1, tmpbitmap0,
+ copyrozbitmap_trans( tmpbitmap1, NULL, tmpbitmap0,
(UINT32)16<<16,
(UINT32)0<<16,
0 << 16,
1 << 16,
-1 << 16,
0 << 16,
- 0, cliprect, TRANSPARENCY_PEN, 0, 0 );
+ 0, 0 );
currx = (sx + y * ydim) / 0x10000;
curry = (sy - (x+1) * xdim) / 0x10000;
diff --git a/src/mame/video/relief.c b/src/mame/video/relief.c
index 2574347c52d..1ea77515786 100644
--- a/src/mame/video/relief.c
+++ b/src/mame/video/relief.c
@@ -81,9 +81,9 @@ VIDEO_START( relief )
0, /* resulting value to indicate "special" */
0 /* callback routine for special entries */
};
-
- /* blend the MO graphics */
- atarigen_blend_gfx(machine, 1, 2, 0x0f, 0x10);
+
+ /* MOs are 5bpp but with a 4-bit color granularity */
+ machine->gfx[1]->color_granularity = 16;
/* initialize the playfield */
atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols, 8,8, 64,64);
diff --git a/src/mame/video/rockola.c b/src/mame/video/rockola.c
index 4295e7bad2f..afa57fead5c 100644
--- a/src/mame/video/rockola.c
+++ b/src/mame/video/rockola.c
@@ -107,7 +107,7 @@ WRITE8_HANDLER( rockola_charram_w )
if (rockola_charram[offset] != data)
{
rockola_charram[offset] = data;
- tilemap_mark_all_tiles_dirty(fg_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset/8) % 256);
}
}
@@ -171,8 +171,6 @@ static TILE_GET_INFO( get_fg_tile_info )
int code = rockola_videoram2[tile_index];
int color = colorram[tile_index] & 0x07;
- decodechar(machine->gfx[0], code, rockola_charram);
-
SET_TILE_INFO(0, code, color, 0);
}
@@ -182,6 +180,8 @@ VIDEO_START( rockola )
fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
+
+ gfx_element_set_source(machine->gfx[0], rockola_charram);
}
VIDEO_UPDATE( rockola )
@@ -291,8 +291,6 @@ static TILE_GET_INFO( satansat_get_fg_tile_info )
int code = rockola_videoram2[tile_index];
int color = colorram[tile_index] & 0x03;
- decodechar(machine->gfx[0], code, rockola_charram);
-
SET_TILE_INFO(0, code, color, 0);
}
@@ -302,4 +300,6 @@ VIDEO_START( satansat )
fg_tilemap = tilemap_create(machine, satansat_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
+
+ gfx_element_set_source(machine->gfx[0], rockola_charram);
}
diff --git a/src/mame/video/rohga.c b/src/mame/video/rohga.c
index 668344a401a..12aea1a6f57 100644
--- a/src/mame/video/rohga.c
+++ b/src/mame/video/rohga.c
@@ -46,8 +46,6 @@ VIDEO_START( wizdfire )
deco16_set_tilemap_bank_callback(3,wizdfire_bank_callback);
deco16_pf1_rowscroll=deco16_pf2_rowscroll=0;
-
- alpha_set_level(0x80);
}
VIDEO_START( nitrobal )
@@ -63,8 +61,6 @@ VIDEO_START( nitrobal )
deco16_set_tilemap_colour_mask(2,0);
deco16_set_tilemap_colour_base(3,0);
deco16_set_tilemap_colour_mask(3,0);
-
- alpha_set_level(0x80);
}
/******************************************************************************/
@@ -153,7 +149,7 @@ static void wizdfire_draw_sprites(running_machine *machine, bitmap_t *bitmap, co
for (offs = 0;offs < 0x400;offs += 4)
{
int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
- int trans=TRANSPARENCY_PEN;
+ int alpha=0xff;
sprite = spriteptr[offs+1];
if (!sprite) continue;
@@ -194,7 +190,7 @@ static void wizdfire_draw_sprites(running_machine *machine, bitmap_t *bitmap, co
colour = (x >> 9) &0x1f;
if (bank==4 && colour&0x10) {
- trans=TRANSPARENCY_ALPHA;
+ alpha=0x80;
colour&=0xf;
}
@@ -231,12 +227,12 @@ static void wizdfire_draw_sprites(running_machine *machine, bitmap_t *bitmap, co
while (multi >= 0)
{
- drawgfx(bitmap,machine->gfx[bank],
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[bank],
sprite - multi * inc,
colour,
fx,fy,
x,y + mult * multi,
- cliprect,trans,0);
+ 0,alpha);
multi--;
}
@@ -283,7 +279,7 @@ Sprites 2:
while (offs!=end)
{
int x,y,sprite,colour,fx,fy,w,h,sx,sy,x_mult,y_mult,tilemap_pri,sprite_pri;
- int trans=TRANSPARENCY_PEN;
+ int alpha=0xff;
sprite = spriteptr[offs+3];
if (!sprite) {
@@ -387,7 +383,7 @@ sprite 2:
}
if (gfxbank==4 && colour&0x10) {
- trans=TRANSPARENCY_ALPHA;
+ alpha=0x80;
colour&=0xf;
}
@@ -426,7 +422,7 @@ sprite 2:
colour,
fx,fy,
sx + x_mult * (w-x),sy + y_mult * (h-y),
- cliprect,trans,0,tilemap_pri,sprite_pri,1);
+ cliprect,0,tilemap_pri,sprite_pri,1,alpha);
}
}
@@ -509,7 +505,7 @@ VIDEO_UPDATE( wizdfire )
wizdfire_draw_sprites(screen->machine,bitmap,cliprect,buffered_spriteram16,3,3);
if ((deco16_priority&0x1f)==0x1f) /* Wizdfire has bit 0x40 always set, Dark Seal 2 doesn't?! */
- deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA,0);
+ deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA(0x80),0);
else
deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
diff --git a/src/mame/video/rollerg.c b/src/mame/video/rollerg.c
index 2b70e5752fa..1ba3f744de7 100644
--- a/src/mame/video/rollerg.c
+++ b/src/mame/video/rollerg.c
@@ -71,6 +71,6 @@ VIDEO_UPDATE( rollerg )
bitmap_fill(priority_bitmap,cliprect,0);
bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
K051316_zoom_draw_0(bitmap,cliprect,0,1);
- K053245_sprites_draw(0,bitmap,cliprect);
+ K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
return 0;
}
diff --git a/src/mame/video/rungun.c b/src/mame/video/rungun.c
index 8e701622ae9..5dbd0a8d2ad 100644
--- a/src/mame/video/rungun.c
+++ b/src/mame/video/rungun.c
@@ -97,10 +97,7 @@ VIDEO_START(rng)
assert(ttl_gfx_index != MAX_GFX_ELEMENTS);
// decode the ttl layer's gfx
- machine->gfx[ttl_gfx_index] = allocgfx(machine, &charlayout);
- decodegfx(machine->gfx[ttl_gfx_index], memory_region(machine, "gfx3"), 0, machine->gfx[ttl_gfx_index]->total_elements);
-
- machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[ttl_gfx_index] = gfx_element_alloc(machine, &charlayout, memory_region(machine, "gfx3"), machine->config->total_colors / 16, 0);
// create the tilemap
ttl_tilemap = tilemap_create(machine, ttl_get_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
diff --git a/src/mame/video/segag80r.c b/src/mame/video/segag80r.c
index 9861664cd5e..786a2755602 100644
--- a/src/mame/video/segag80r.c
+++ b/src/mame/video/segag80r.c
@@ -13,7 +13,6 @@ UINT8 segag80r_background_pcb;
static double rweights[3], gweights[3], bweights[2];
-static UINT8 *dirtychar;
static UINT8 video_control;
static UINT8 video_flip;
static UINT8 vblank_latch;
@@ -209,9 +208,7 @@ VIDEO_START( segag80r )
3, rg_resistances, gweights, 220, 0,
2, b_resistances, bweights, 220, 0);
- /* allocate paletteram */
- dirtychar = auto_malloc(256);
- memset(dirtychar, 1, 256);
+ gfx_element_set_source(machine->gfx[0], &videoram[0x800]);
/* allocate paletteram */
paletteram = auto_malloc(0x80);
@@ -288,7 +285,7 @@ WRITE8_HANDLER( segag80r_videoram_w )
/* track which characters are dirty */
if (offset & 0x800)
- dirtychar[(offset & 0x7ff) / 8] = TRUE;
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset & 0x7ff) / 8);
}
@@ -658,13 +655,6 @@ static void draw_videoram(running_machine *machine, bitmap_t *bitmap, const rect
int offs = effy * 32 + (x ^ flipmask);
UINT8 tile = videoram[offs];
- /* if the tile is dirty, decode it */
- if (dirtychar[tile])
- {
- decodechar(machine->gfx[0], tile, &videoram[0x800]);
- dirtychar[tile] = 0;
- }
-
/* draw the tile */
drawgfx(bitmap, machine->gfx[0], tile, tile >> 4, video_flip, video_flip, x*8, y*8, cliprect, TRANSPARENCY_PENS, transparent_pens[tile >> 4]);
}
diff --git a/src/mame/video/segaic24.c b/src/mame/video/segaic24.c
index 2d8df0852c7..f3455090e71 100644
--- a/src/mame/video/segaic24.c
+++ b/src/mame/video/segaic24.c
@@ -81,8 +81,7 @@ enum {SYS24_TILES = 0x4000};
static UINT16 *sys24_char_ram, *sys24_tile_ram;
static UINT16 sys24_tile_mask;
-static UINT8 *sys24_char_dirtymap;
-static int sys24_char_dirty, sys24_char_gfx_index;
+static int sys24_char_gfx_index;
static tilemap *sys24_tile_layer[4];
#ifdef LSB_FIRST
@@ -135,12 +134,6 @@ static TILE_GET_INFO( sys24_tile_info_1w )
SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
}
-static STATE_POSTLOAD( sys24_tile_dirtyall )
-{
- memset(sys24_char_dirtymap, 1, SYS24_TILES);
- sys24_char_dirty = 1;
-}
-
void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask)
{
sys24_tile_mask = tile_mask;
@@ -154,8 +147,6 @@ void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask)
sys24_tile_ram = auto_malloc(0x10000);
- sys24_char_dirtymap = auto_malloc(SYS24_TILES);
-
sys24_tile_layer[0] = tilemap_create(machine, sys24_tile_info_0s, tilemap_scan_rows, 8, 8, 64, 64);
sys24_tile_layer[1] = tilemap_create(machine, sys24_tile_info_0w, tilemap_scan_rows, 8, 8, 64, 64);
sys24_tile_layer[2] = tilemap_create(machine, sys24_tile_info_1s, tilemap_scan_rows, 8, 8, 64, 64);
@@ -168,34 +159,11 @@ void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask)
memset(sys24_char_ram, 0, 0x80000);
memset(sys24_tile_ram, 0, 0x10000);
- memset(sys24_char_dirtymap, 1, SYS24_TILES);
- sys24_char_dirty = 1;
-
- machine->gfx[sys24_char_gfx_index] = allocgfx(machine, &sys24_char_layout);
- machine->gfx[sys24_char_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[sys24_char_gfx_index] = gfx_element_alloc(machine, &sys24_char_layout, (UINT8 *)sys24_char_ram, machine->config->total_colors / 16, 0);
state_save_register_global_pointer(machine, sys24_tile_ram, 0x10000/2);
state_save_register_global_pointer(machine, sys24_char_ram, 0x80000/2);
- state_save_register_postload(machine, sys24_tile_dirtyall, NULL);
-}
-
-void sys24_tile_update(running_machine *machine)
-{
- if(sys24_char_dirty) {
- int i;
- for(i=0; i<SYS24_TILES; i++) {
- if(sys24_char_dirtymap[i]) {
- sys24_char_dirtymap[i] = 0;
- decodechar(machine->gfx[sys24_char_gfx_index], i, (UINT8 *)sys24_char_ram);
- }
- }
- tilemap_mark_all_tiles_dirty(sys24_tile_layer[0]);
- tilemap_mark_all_tiles_dirty(sys24_tile_layer[1]);
- tilemap_mark_all_tiles_dirty(sys24_tile_layer[2]);
- tilemap_mark_all_tiles_dirty(sys24_tile_layer[3]);
- sys24_char_dirty = 0;
- }
}
static void sys24_tile_draw_rect(running_machine *machine, bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
@@ -604,8 +572,7 @@ WRITE16_HANDLER(sys24_char_w)
UINT16 old = sys24_char_ram[offset];
COMBINE_DATA(sys24_char_ram + offset);
if(old != sys24_char_ram[offset]) {
- sys24_char_dirtymap[offset / 16] = 1;
- sys24_char_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[sys24_char_gfx_index], offset / 16);
}
}
diff --git a/src/mame/video/segaic24.h b/src/mame/video/segaic24.h
index e3993687494..22e26b1db5a 100644
--- a/src/mame/video/segaic24.h
+++ b/src/mame/video/segaic24.h
@@ -12,7 +12,6 @@ WRITE16_HANDLER (system24temp_sys16_paletteram1_w);
// Tilemaps
// System24
void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask);
-void sys24_tile_update(running_machine *machine);
void sys24_tile_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int pri, int flags);
READ16_HANDLER(sys24_tile_r);
diff --git a/src/mame/video/segas24.c b/src/mame/video/segas24.c
index c838bd0ee85..61f0de481c6 100644
--- a/src/mame/video/segas24.c
+++ b/src/mame/video/segas24.c
@@ -31,8 +31,6 @@ VIDEO_UPDATE(system24)
return 0;
}
- sys24_tile_update(screen->machine);
-
bitmap_fill(priority_bitmap, 0, 0);
bitmap_fill(bitmap, cliprect, 0);
diff --git a/src/mame/video/segasyse.c b/src/mame/video/segasyse.c
index da0891f610d..45e1b583de9 100644
--- a/src/mame/video/segasyse.c
+++ b/src/mame/video/segasyse.c
@@ -74,7 +74,12 @@ VIDEO_UPDATE( megaplay_normal )
segae_drawscanline(screen->machine, i-16,0,0);
for (i = miny;i <= maxy;i++)
- draw_scanline8(bitmap,32,i,256,&cache_bitmap[(i-16) * (16+256+16) +24],&screen->machine->pens[palette_base],0);
+ {
+ UINT16 *dest = BITMAP_ADDR16(bitmap, i, 32);
+ int x;
+ for (x = 0; x < 256; x++)
+ dest[x] = screen->machine->pens[palette_base + cache_bitmap[(i-16) * (16+256+16) + 24 + x]];
+ }
return 0;
}
diff --git a/src/mame/video/seibuspi.c b/src/mame/video/seibuspi.c
index f805831ba38..d37a9bd69ae 100644
--- a/src/mame/video/seibuspi.c
+++ b/src/mame/video/seibuspi.c
@@ -235,7 +235,7 @@ WRITE32_HANDLER( video_dma_address_w )
static void draw_blend_gfx(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy)
{
const pen_t *pens = &machine->pens[gfx->color_base];
- UINT8 *dp;
+ const UINT8 *dp;
int i, j;
int x1, x2;
int y1, y2;
@@ -314,7 +314,7 @@ static void draw_blend_gfx(running_machine *machine, bitmap_t *bitmap, const rec
code &= 0xffff;
}
- dp = gfx->gfxdata + code * gfx->char_modulo;
+ dp = gfx_element_get_data(gfx, code);
// draw
for (j=y1; j <= y2; j++)
diff --git a/src/mame/video/shangha3.c b/src/mame/video/shangha3.c
index a8c16e08b50..7738a52960e 100644
--- a/src/mame/video/shangha3.c
+++ b/src/mame/video/shangha3.c
@@ -70,20 +70,23 @@ int shangha3_do_shadows;
static UINT16 gfxlist_addr;
static bitmap_t *rawbitmap;
+static UINT8 drawmode_table[16];
VIDEO_START( shangha3 )
{
+ int i;
+
rawbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
+ for (i = 0;i < 14;i++)
+ drawmode_table[i] = DRAWMODE_SOURCE;
+ drawmode_table[14] = shangha3_do_shadows ? DRAWMODE_SHADOW : DRAWMODE_NONE;
+ drawmode_table[15] = DRAWMODE_NONE;
+
if (shangha3_do_shadows)
{
- int i;
-
/* Prepare the shadow table */
- for (i = 0;i < 14;i++)
- gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[14] = DRAWMODE_SHADOW;
for (i = 0;i < 128;i++)
machine->shadow_table[i] = i+128;
}
@@ -154,6 +157,7 @@ WRITE16_HANDLER( shangha3_blitter_go_w )
myclip.max_x = sx + sizex;
myclip.min_y = sy;
myclip.max_y = sy + sizey;
+ sect_rect(&myclip, &rawbitmap->cliprect);
if (shangha3_ram[offs+4] & 0x08) /* tilemap */
{
@@ -225,26 +229,26 @@ WRITE16_HANDLER( shangha3_blitter_go_w )
int w;
if (zoomx <= 1 && zoomy <= 1)
- drawgfxzoom(rawbitmap,space->machine->gfx[0],
+ drawgfxzoom_transtable(rawbitmap,&myclip,space->machine->gfx[0],
code,
color,
flipx,flipy,
sx,sy,
- &myclip,shangha3_do_shadows ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
- 0x1000000,0x1000000);
+ 0x1000000,0x1000000,
+ drawmode_table,space->machine->shadow_table);
else
{
w = (sizex+15)/16;
for (x = 0;x < w;x++)
{
- drawgfxzoom(rawbitmap,space->machine->gfx[0],
+ drawgfxzoom_transtable(rawbitmap,&myclip,space->machine->gfx[0],
code,
color,
flipx,flipy,
sx + 16*x,sy,
- &myclip,shangha3_do_shadows ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
- (0x200-zoomx)*0x100,(0x200-zoomy)*0x100);
+ (0x200-zoomx)*0x100,(0x200-zoomy)*0x100,
+ drawmode_table,space->machine->shadow_table);
if ((code & 0x000f) == 0x0f)
code = (code + 0x100) & 0xfff0;
diff --git a/src/mame/video/skyraid.c b/src/mame/video/skyraid.c
index 52575dd5b6a..093c4ec061b 100644
--- a/src/mame/video/skyraid.c
+++ b/src/mame/video/skyraid.c
@@ -143,9 +143,9 @@ VIDEO_UPDATE( skyraid )
{
bitmap_fill(bitmap, cliprect, 0);
- draw_terrain(screen->machine, helper, cliprect);
- draw_sprites(screen->machine, helper, cliprect);
- draw_missiles(screen->machine, helper, cliprect);
+ draw_terrain(screen->machine, helper, NULL);
+ draw_sprites(screen->machine, helper, NULL);
+ draw_missiles(screen->machine, helper, NULL);
draw_trapezoid(screen->machine, bitmap, helper);
draw_text(screen->machine, bitmap, cliprect);
return 0;
diff --git a/src/mame/video/snes.c b/src/mame/video/snes.c
index c1ec2e196f8..8519bb40045 100644
--- a/src/mame/video/snes.c
+++ b/src/mame/video/snes.c
@@ -1941,6 +1941,8 @@ static void snes_dbg_draw_all_tiles(bitmap_t *bitmap, UINT32 tileaddr, UINT8 bpl
addr = tileaddr + (jj * bpl * 16 * 32);
for( kk = 0; kk < 8; kk++ )
{
+ UINT32 *destline = BITMAP_ADDR32(bitmap, jj * 8 + kk, 0);
+
/* Clear buffers */
memset( scanlines[MAINSCREEN].buffer, 0, SNES_SCR_WIDTH * 2 );
memset( scanlines[MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2 );
@@ -1960,7 +1962,12 @@ static void snes_dbg_draw_all_tiles(bitmap_t *bitmap, UINT32 tileaddr, UINT8 bpl
}
addr += (bpl * 16);
}
- draw_scanline16( bitmap, 0, jj * 8 + kk, SNES_SCR_WIDTH * 2, scanlines[MAINSCREEN].buffer, machine->pens, 200 );
+ for (ii = 0; ii < SNES_SCR_WIDTH * 2; ii++)
+ {
+ int pixdata = scanlines[MAINSCREEN].buffer[ii];
+ if (pixdata != 200)
+ destline[ii] = machine->pens[pixdata];
+ }
addr -= (32 * (bpl * 16)) - 2;
}
}
@@ -2142,6 +2149,7 @@ static UINT8 snes_dbg_video(bitmap_t *bitmap, UINT16 curline )
{
static UINT32 tmaddr = 0;
static INT8 tmbg = 0;
+ UINT32 *destline = BITMAP_ADDR32(bitmap, curline, 0);
if( curline == 0 )
{
if( adjust & 0x1 ) tmaddr += 2;
@@ -2159,21 +2167,26 @@ static UINT8 snes_dbg_video(bitmap_t *bitmap, UINT16 curline )
for( ii = 0; ii < SNES_SCR_WIDTH; ii++ )
scanlines[MAINSCREEN].buffer[ii] = machine->pens[0];
snes_dbg_draw_maps(bitmap, tmaddr, dm, curline, tmbg );
- draw_scanline16( bitmap, 0, curline, SNES_SCR_WIDTH, scanlines[MAINSCREEN].buffer, machine->pens, 200 );
+ for (ii = 0; ii < SNES_SCR_WIDTH; ii++)
+ {
+ int pixdata = scanlines[MAINSCREEN].buffer[ii];
+ if (pixdata != 200)
+ destline[ii] = machine->pens[pixdata];
+ }
return 1;
}
}
/* Draw some useful information about the back/fixed colours and current bg mode etc. */
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 26) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0xc0) >> 6]];
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 24) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0x30) >> 4]];
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 22) = machine->pens[dbg_mode_colours[snes_ram[BGMODE] & 0x7]];
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 12) = machine->pens[32767];
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 2 ) = machine->pens[32767];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 26) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0xc0) >> 6]];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 24) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0x30) >> 4]];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 22) = machine->pens[dbg_mode_colours[snes_ram[BGMODE] & 0x7]];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 12) = machine->pens[32767];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 2 ) = machine->pens[32767];
for( ii = 0; ii < 5; ii++ )
{
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = snes_cgram[0];
- *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 9 + ii) = snes_cgram[FIXED_COLOUR];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = snes_cgram[0];
+ *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 9 + ii) = snes_cgram[FIXED_COLOUR];
}
/* Draw window positions */
scanlines[MAINSCREEN].buffer[snes_ram[WH0]] = machine->pens[dbg_mode_colours[0]];
diff --git a/src/mame/video/snk.c b/src/mame/video/snk.c
index 03383fafb32..d1929e8d6d8 100644
--- a/src/mame/video/snk.c
+++ b/src/mame/video/snk.c
@@ -33,8 +33,11 @@ static int fg_scrollx, fg_scrolly, bg_scrollx, bg_scrolly;
static int sp16_scrollx, sp16_scrolly, sp32_scrollx, sp32_scrolly;
static UINT8 sprite_split_point;
static int num_sprites, yscroll_mask;
+static UINT32 bg_tile_offset;
+static UINT32 tx_tile_offset;
static UINT8 empty_tile[16*16];
+static UINT8 drawmode_table[16];
/**************************************************************************************/
@@ -87,7 +90,7 @@ static TILE_GET_INFO( marvins_get_tx_tile_info )
int code = snk_tx_videoram[tile_index];
int color = code >> 5;
SET_TILE_INFO(0,
- code,
+ tx_tile_offset + code,
color,
tile_index & 0x400 ? TILE_FORCE_LAYER0 : 0);
}
@@ -96,7 +99,7 @@ static TILE_GET_INFO( ikari_get_tx_tile_info )
{
int code = snk_tx_videoram[tile_index];
SET_TILE_INFO(0,
- code,
+ tx_tile_offset + code,
0,
tile_index & 0x400 ? TILE_FORCE_LAYER0 : 0);
}
@@ -105,7 +108,7 @@ static TILE_GET_INFO( gwar_get_tx_tile_info )
{
int code = snk_tx_videoram[tile_index];
SET_TILE_INFO(0,
- code,
+ tx_tile_offset + code,
0,
0);
}
@@ -134,7 +137,7 @@ static TILE_GET_INFO( aso_get_bg_tile_info )
{
int code = snk_bg_videoram[tile_index];
SET_TILE_INFO(1,
- code,
+ bg_tile_offset + code,
0,
0);
}
@@ -189,9 +192,9 @@ static VIDEO_START( snk_3bpp_shadow )
fatalerror("driver should use VIDEO_HAS_SHADOWS");
/* prepare shadow draw table */
- for(i = 0; i <= 5; i++) gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[6] = DRAWMODE_SHADOW;
- gfx_drawmode_table[7] = DRAWMODE_NONE;
+ for(i = 0; i <= 5; i++) drawmode_table[i] = DRAWMODE_SOURCE;
+ drawmode_table[6] = (machine->config->video_attributes & VIDEO_HAS_SHADOWS) ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+ drawmode_table[7] = DRAWMODE_NONE;
for (i = 0x000;i < 0x400;i++)
machine->shadow_table[i] = i | 0x200;
@@ -205,9 +208,9 @@ static VIDEO_START( snk_4bpp_shadow )
fatalerror("driver should use VIDEO_HAS_SHADOWS");
/* prepare shadow draw table */
- for(i = 0; i <= 13; i++) gfx_drawmode_table[i] = DRAWMODE_SOURCE;
- gfx_drawmode_table[14] = DRAWMODE_SHADOW;
- gfx_drawmode_table[15] = DRAWMODE_NONE;
+ for(i = 0; i <= 13; i++) drawmode_table[i] = DRAWMODE_SOURCE;
+ drawmode_table[14] = (machine->config->video_attributes & VIDEO_HAS_SHADOWS) ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
+ drawmode_table[15] = DRAWMODE_NONE;
/* all palette entries are not affected by shadow sprites... */
for (i = 0x000;i < 0x400;i++)
@@ -235,6 +238,8 @@ VIDEO_START( marvins )
tilemap_set_scrolldx(bg_tilemap, 15, 31);
tilemap_set_scrolldy(bg_tilemap, 8, -32);
+
+ tx_tile_offset = 0;
}
VIDEO_START( jcross )
@@ -252,6 +257,8 @@ VIDEO_START( jcross )
num_sprites = 25;
yscroll_mask = 0x1ff;
+ bg_tile_offset = 0;
+ tx_tile_offset = 0;
}
VIDEO_START( sgladiat )
@@ -269,6 +276,8 @@ VIDEO_START( sgladiat )
num_sprites = 25;
yscroll_mask = 0x0ff;
+ bg_tile_offset = 0;
+ tx_tile_offset = 0;
}
VIDEO_START( hal21 )
@@ -307,6 +316,7 @@ VIDEO_START( tnk3 )
num_sprites = 50;
yscroll_mask = 0x1ff;
+ tx_tile_offset = 0;
}
VIDEO_START( ikari )
@@ -321,10 +331,18 @@ VIDEO_START( ikari )
tilemap_set_scrolldx(bg_tilemap, 15, 24);
tilemap_set_scrolldy(bg_tilemap, 8, -32);
+
+ tx_tile_offset = 0;
}
VIDEO_START( gwar )
{
+ int i;
+
+ /* prepare drawmode table */
+ for(i = 0; i <= 14; i++) drawmode_table[i] = DRAWMODE_SOURCE;
+ drawmode_table[15] = DRAWMODE_NONE;
+
memset(empty_tile,0xf,sizeof(empty_tile));
tx_tilemap = tilemap_create(machine, gwar_get_tx_tile_info, tilemap_scan_cols, 8, 8, 50, 32);
@@ -334,6 +352,8 @@ VIDEO_START( gwar )
tilemap_set_scrolldx(bg_tilemap, 16, 143);
tilemap_set_scrolldy(bg_tilemap, 0, -32);
+
+ tx_tile_offset = 0;
}
VIDEO_START( tdfever )
@@ -443,7 +463,11 @@ WRITE8_HANDLER( hal21_flipscreen_w )
flip_screen_set(space->machine, data & 0x80);
tilemap_set_palette_offset(bg_tilemap, ((data & 0xf) ^ 8) << 4);
- tilemap_set_pen_data_offset(bg_tilemap, ((data & 0x20) << 3) * space->machine->gfx[1]->char_modulo);
+ if (bg_tile_offset != ((data & 0x20) << 3))
+ {
+ bg_tile_offset = (data & 0x20) << 3;
+ tilemap_mark_all_tiles_dirty(bg_tilemap);
+ }
// other bits unknown
}
@@ -507,7 +531,11 @@ WRITE8_HANDLER( tnk3_videoattrs_w )
flip_screen_set(space->machine, data & 0x80);
- tilemap_set_pen_data_offset(tx_tilemap, ((data & 0x40) << 2) * space->machine->gfx[0]->char_modulo);
+ if (tx_tile_offset != ((data & 0x40) << 2))
+ {
+ tx_tile_offset = (data & 0x40) << 2;
+ tilemap_mark_all_tiles_dirty(tx_tilemap);
+ }
bg_scrolly = (bg_scrolly & 0xff) | ((data & 0x10) << 4);
sp16_scrolly = (sp16_scrolly & 0xff) | ((data & 0x08) << 5);
@@ -518,7 +546,11 @@ WRITE8_HANDLER( tnk3_videoattrs_w )
WRITE8_HANDLER( aso_bg_bank_w )
{
tilemap_set_palette_offset(bg_tilemap, ((data & 0xf) ^ 8) << 4);
- tilemap_set_pen_data_offset(bg_tilemap, ((data & 0x30) << 4) * space->machine->gfx[1]->char_modulo);
+ if (bg_tile_offset != ((data & 0x30) << 4))
+ {
+ bg_tile_offset = (data & 0x30) << 4;
+ tilemap_mark_all_tiles_dirty(bg_tilemap);
+ }
}
WRITE8_HANDLER( ikari_bg_scroll_msb_w )
@@ -549,13 +581,21 @@ if (data != 0x20 && // normal
popmessage("attrs %02x contact MAMEDEV", data);
tilemap_set_palette_offset(tx_tilemap, (data & 0x01) << 4);
- tilemap_set_pen_data_offset(tx_tilemap, ((data & 0x10) << 4) * space->machine->gfx[0]->char_modulo);
+ if (tx_tile_offset != ((data & 0x10) << 4))
+ {
+ tx_tile_offset = (data & 0x10) << 4;
+ tilemap_mark_all_tiles_dirty(tx_tilemap);
+ }
}
WRITE8_HANDLER( gwar_tx_bank_w )
{
tilemap_set_palette_offset(tx_tilemap, (data & 0xf) << 4);
- tilemap_set_pen_data_offset(tx_tilemap, ((data & 0x30) << 4) * space->machine->gfx[0]->char_modulo);
+ if (tx_tile_offset != ((data & 0x30) << 4))
+ {
+ tx_tile_offset = (data & 0x30) << 4;
+ tilemap_mark_all_tiles_dirty(tx_tilemap);
+ }
}
WRITE8_HANDLER( gwar_videoattrs_w )
@@ -640,12 +680,12 @@ static void marvins_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
if (sx > 512-16) sx -= 512;
if (sy > 256-16) sy -= 256;
- drawgfx( bitmap,gfx,
+ drawgfx_transtable(bitmap,cliprect,gfx,
tile_number,
color,
flipx, flipy,
sx, sy,
- cliprect,TRANSPARENCY_PEN_TABLE,7);
+ drawmode_table, machine->shadow_table);
source+=4;
}
@@ -705,12 +745,12 @@ static void tnk3_draw_sprites(running_machine *machine, bitmap_t *bitmap, const
if (sx > 512-size) sx -= 512;
if (sy > (yscroll_mask+1)-size) sy -= (yscroll_mask+1);
- drawgfx(bitmap,gfx,
+ drawgfx_transtable(bitmap,cliprect,gfx,
tile_number,
color,
xflip,yflip,
sx,sy,
- cliprect,TRANSPARENCY_PEN_TABLE,7);
+ drawmode_table, machine->shadow_table);
}
}
@@ -751,12 +791,12 @@ static void ikari_draw_sprites(running_machine *machine, bitmap_t *bitmap, const
if (sx > 512-size) sx -= 512;
if (sy > 512-size) sy -= 512;
- drawgfx(bitmap,gfx,
+ drawgfx_transtable(bitmap,cliprect,gfx,
tile_number,
color,
0,0,
sx,sy,
- cliprect,TRANSPARENCY_PEN_TABLE,7);
+ drawmode_table, machine->shadow_table);
}
}
@@ -791,12 +831,10 @@ static void tdfever_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
{
const gfx_element *gfx = machine->gfx[gfxnum];
const int size = gfx->width;
- int tile_number, attributes, sx, sy, color, pen_mode;
+ int tile_number, attributes, sx, sy, color;
int which;
int flipx, flipy;
- pen_mode = (machine->config->video_attributes & VIDEO_HAS_SHADOWS) ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN;
-
for(which = from*4; which < to*4; which+=4)
{
tile_number = source[which+1];
@@ -838,12 +876,12 @@ static void tdfever_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
if (sx > 512-size) sx -= 512;
if (sy > 512-size) sy -= 512;
- drawgfx(bitmap,gfx,
+ drawgfx_transtable(bitmap,cliprect,gfx,
tile_number,
color,
flipx,flipy,
sx,sy,
- cliprect,pen_mode,15);
+ drawmode_table, machine->shadow_table);
}
}
diff --git a/src/mame/video/snk68.c b/src/mame/video/snk68.c
index 1617a21926b..75013c5f922 100644
--- a/src/mame/video/snk68.c
+++ b/src/mame/video/snk68.c
@@ -19,6 +19,7 @@ UINT16* pow_fg_videoram;
static int sprite_flip_axis;
static tilemap *fg_tilemap;
static int flipscreen;
+static UINT32 fg_tile_offset;
/***************************************************************************
@@ -28,7 +29,7 @@ static int flipscreen;
static TILE_GET_INFO( get_pow_tile_info )
{
- int tile = (pow_fg_videoram[2*tile_index] & 0xff);
+ int tile = fg_tile_offset + (pow_fg_videoram[2*tile_index] & 0xff);
int color = pow_fg_videoram[2*tile_index+1] & 0x07;
SET_TILE_INFO(0, tile, color, 0);
@@ -63,6 +64,7 @@ static void common_video_start(running_machine *machine)
VIDEO_START( pow )
{
fg_tilemap = tilemap_create(machine, get_pow_tile_info,tilemap_scan_cols,8,8,32,32);
+ fg_tile_offset = 0;
common_video_start(machine);
}
@@ -139,7 +141,11 @@ WRITE16_HANDLER( pow_flipscreen16_w )
sprite_flip_axis = data & 0x04; // for streetsm? though might not be present on this board
- tilemap_set_pen_data_offset(fg_tilemap, ((data & 0x70) << 4) * space->machine->gfx[0]->char_modulo);
+ if (fg_tile_offset != ((data & 0x70) << 4))
+ {
+ fg_tile_offset = (data & 0x70) << 4;
+ tilemap_mark_all_tiles_dirty(fg_tilemap);
+ }
}
}
diff --git a/src/mame/video/spbactn.c b/src/mame/video/spbactn.c
index fdd8151bce2..55c8de92cea 100644
--- a/src/mame/video/spbactn.c
+++ b/src/mame/video/spbactn.c
@@ -90,12 +90,12 @@ static int draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
- drawgfx(bitmap, machine->gfx[2],
+ drawgfx_transpen_raw(bitmap, cliprect, machine->gfx[2],
code + layout[row][col],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx, flipy,
x, y,
- cliprect, TRANSPARENCY_PEN_RAW, 0);
+ 0);
}
}
@@ -133,12 +133,12 @@ VIDEO_UPDATE( spbactn )
color = ((attr & 0x00f0) >> 4) | 0x80;
- drawgfx(tile_bitmap_bg, screen->machine->gfx[1],
+ drawgfx_transpen_raw(tile_bitmap_bg, cliprect, screen->machine->gfx[1],
code,
screen->machine->gfx[1]->color_base + color * screen->machine->gfx[1]->color_granularity,
0, 0,
16 * sx, 8 * sy,
- cliprect, TRANSPARENCY_PEN_RAW, -1);
+ -1);
sx++;
if (sx > 63)
@@ -160,12 +160,12 @@ VIDEO_UPDATE( spbactn )
color = ((attr & 0x00f0) >> 4) | 0x80;
- drawgfx(tile_bitmap_bg, screen->machine->gfx[1],
+ drawgfx_transpen_raw(tile_bitmap_bg, cliprect, screen->machine->gfx[1],
code,
screen->machine->gfx[1]->color_base + color * screen->machine->gfx[1]->color_granularity,
0, 0,
16 * sx, 8 * sy,
- cliprect, TRANSPARENCY_PEN_RAW, 0);
+ 0);
sx++;
if (sx > 63)
@@ -194,12 +194,12 @@ VIDEO_UPDATE( spbactn )
else
color |= 0x0080;
- drawgfx(tile_bitmap_fg, screen->machine->gfx[0],
+ drawgfx_transpen_raw(tile_bitmap_fg, cliprect, screen->machine->gfx[0],
code,
screen->machine->gfx[0]->color_base + color * screen->machine->gfx[0]->color_granularity,
0, 0,
16 * sx, 8 * sy,
- cliprect, TRANSPARENCY_PEN_RAW, 0);
+ 0);
sx++;
if (sx > 63)
diff --git a/src/mame/video/spy.c b/src/mame/video/spy.c
index ab484914fa9..f8c66ccf29c 100644
--- a/src/mame/video/spy.c
+++ b/src/mame/video/spy.c
@@ -76,7 +76,7 @@ VIDEO_UPDATE( spy )
{
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,1);
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
}
diff --git a/src/mame/video/ssv.c b/src/mame/video/ssv.c
index 232f2ddd38f..4baf3d2c8ab 100644
--- a/src/mame/video/ssv.c
+++ b/src/mame/video/ssv.c
@@ -147,12 +147,13 @@ static void ssv_drawgfx( bitmap_t *bitmap, const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int x0,int y0,
const rectangle *cliprect, int shadow )
{
- UINT8 *source, *addr, pen;
+ const UINT8 *addr, *source;
+ UINT8 pen;
UINT16 *dest;
int sx, x1, dx;
int sy, y1, dy;
- addr = (code % gfx->total_elements) * gfx->char_modulo + gfx->gfxdata;
+ addr = gfx_element_get_data(gfx, code % gfx->total_elements);
color = gfx->color_granularity * (color % gfx->total_colors);
if ( flipx ) { x1 = x0-1; x0 += gfx->width-1; dx = -1; }
@@ -202,7 +203,9 @@ VIDEO_START( eaglshot )
VIDEO_START_CALL(ssv);
eaglshot_gfxram = (UINT16*)auto_malloc(16 * 0x40000);
- eaglshot_dirty_tile = (char*)auto_malloc(16 * 0x40000 / (16*8));
+
+ gfx_element_set_source(machine->gfx[0], (UINT8 *)eaglshot_gfxram);
+ gfx_element_set_source(machine->gfx[1], (UINT8 *)eaglshot_gfxram);
}
static tilemap *gdfs_tmap;
@@ -223,10 +226,10 @@ VIDEO_START( gdfs )
{
VIDEO_START_CALL(ssv);
- machine->gfx[2]->color_granularity = 64; /* 256 colour sprites with palette selectable on 64 colour boundaries */
-
eaglshot_gfxram = (UINT16*)auto_malloc(4 * 0x100000);
- eaglshot_dirty_tile = (char*)auto_malloc(4 * 0x100000 / (16*8));
+
+ machine->gfx[2]->color_granularity = 64; /* 256 colour sprites with palette selectable on 64 colour boundaries */
+ gfx_element_set_source(machine->gfx[2], (UINT8 *)eaglshot_gfxram);
gdfs_tmap = tilemap_create( machine, get_tile_info_0, tilemap_scan_rows,
16,16, 0x100,0x100 );
@@ -245,7 +248,6 @@ int ssv_sprites_offsx, ssv_sprites_offsy;
int ssv_tilemap_offsx, ssv_tilemap_offsy;
UINT16 *eaglshot_gfxram, *gdfs_tmapram, *gdfs_tmapscroll;
-char eaglshot_dirty, *eaglshot_dirty_tile;
/***************************************************************************
@@ -917,27 +919,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( eaglshot )
{
- int tile;
-
- // Decode tiles from ram
- if (eaglshot_dirty)
- {
- eaglshot_dirty = 0;
-
- for (tile = 0; tile < (16 * 0x40000 / (16*8)); tile++)
- {
- if (eaglshot_dirty_tile[tile])
- {
- eaglshot_dirty_tile[tile] = 0;
-
- decodechar(screen->machine->gfx[0], tile, (UINT8 *)eaglshot_gfxram);
- decodechar(screen->machine->gfx[1], tile, (UINT8 *)eaglshot_gfxram);
- }
- }
- }
-
- VIDEO_UPDATE_CALL(ssv);
- return 0;
+ return VIDEO_UPDATE_CALL(ssv);
}
/*
@@ -1105,26 +1087,10 @@ static void gdfs_draw_zooming_sprites(running_machine *machine, bitmap_t *bitmap
VIDEO_UPDATE( gdfs )
{
- int tile, pri;
+ int pri;
VIDEO_UPDATE_CALL(ssv);
- // Decode zooming sprites tiles from ram
- if (eaglshot_dirty)
- {
- eaglshot_dirty = 0;
-
- for (tile = 0; tile < (4 * 0x100000 / (16*8)); tile++)
- {
- if (eaglshot_dirty_tile[tile])
- {
- eaglshot_dirty_tile[tile] = 0;
-
- decodechar(screen->machine->gfx[2], tile, (UINT8 *)eaglshot_gfxram);
- }
- }
- }
-
for (pri = 0; pri <= 0xf; pri++)
gdfs_draw_zooming_sprites(screen->machine, bitmap, cliprect, pri);
diff --git a/src/mame/video/st0016.c b/src/mame/video/st0016.c
index 5e907aa6b47..23bb5fc4c4c 100644
--- a/src/mame/video/st0016.c
+++ b/src/mame/video/st0016.c
@@ -14,7 +14,6 @@ UINT32 st0016_game;
static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank;
static int spr_dx,spr_dy;
-static UINT8 *chardirty;
static UINT8 st0016_vregs[0xc0];
static int st0016_ramgfx;
@@ -115,7 +114,7 @@ READ8_HANDLER(st0016_character_ram_r)
WRITE8_HANDLER(st0016_character_ram_w)
{
st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data;
- chardirty[st0016_char_bank] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[st0016_ramgfx], st0016_char_bank);
}
READ8_HANDLER(st0016_vregs_r)
@@ -353,20 +352,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int yloop,xloop;
int ypos, xpos;
int tileno;
- UINT8 *srcgfx;
+ const UINT8 *srcgfx;
int gfxoffs;
ypos = sy+y0*8+spr_dy;
xpos = sx+x0*8+spr_dx;
tileno = (code+i0++)&ST0016_CHAR_BANK_MASK ;
- if (chardirty[tileno])
- {
- chardirty[tileno] = 0;
- decodechar(gfx, tileno, (UINT8 *) st0016_charram);
- }
-
gfxoffs = 0;
- srcgfx= gfx->gfxdata+(64*tileno);
+ srcgfx= gfx_element_get_data(gfx, tileno);
for (yloop=0; yloop<8; yloop++)
{
@@ -424,14 +417,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
}
}
-static STATE_POSTLOAD( st0016_postload )
-{
- const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
-
- st0016_rom_bank_w(space,0,st0016_rom_bank);
- memset(chardirty, 1, ST0016_MAX_CHAR_BANK);
-}
-
void st0016_save_init(running_machine *machine)
{
@@ -444,7 +429,6 @@ void st0016_save_init(running_machine *machine)
state_save_register_global_pointer(machine, st0016_charram, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
state_save_register_global_pointer(machine, st0016_paletteram, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
state_save_register_global_pointer(machine, st0016_spriteram, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
- state_save_register_postload(machine, st0016_postload, NULL);
}
@@ -463,13 +447,7 @@ VIDEO_START( st0016 )
assert(gfx_index != MAX_GFX_ELEMENTS);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[gfx_index] = allocgfx(machine, &charlayout);
- chardirty = auto_malloc(ST0016_MAX_CHAR_BANK);
- memset(chardirty, 1, ST0016_MAX_CHAR_BANK);
-
- /* set the color information */
- machine->gfx[gfx_index]->color_base = 0;
- machine->gfx[gfx_index]->total_colors = 0x40;
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &charlayout, (UINT8 *) st0016_charram, 0x40, 0);
st0016_ramgfx = gfx_index;
spr_dx=0;
@@ -531,12 +509,6 @@ static void draw_bgmap(running_machine *machine, bitmap_t *bitmap,const rectangl
flipx=st0016_spriteram[i+3]&0x80;
flipy=st0016_spriteram[i+3]&0x40;
- if (chardirty[code])
- {
- chardirty[code] = 0;
- decodechar(gfx, code, (UINT8 *) st0016_charram);
- }
-
if(priority)
{
drawgfx(bitmap,gfx,
@@ -551,12 +523,12 @@ static void draw_bgmap(running_machine *machine, bitmap_t *bitmap,const rectangl
UINT16 *destline;
int yloop,xloop;
int ypos, xpos;
- UINT8 *srcgfx;
+ const UINT8 *srcgfx;
int gfxoffs;
ypos = y*8+spr_dy;//+((st0016_vregs[j+2]==0xaf)?0x50:0);//hack for mayjinsen title screen
xpos = x*8+spr_dx;
gfxoffs = 0;
- srcgfx= gfx->gfxdata+(gfx->char_modulo*code);
+ srcgfx= gfx_element_get_data(gfx, code);
for (yloop=0; yloop<8; yloop++)
{
diff --git a/src/mame/video/stvvdp2.c b/src/mame/video/stvvdp2.c
index c833e958c24..4ce7b9a3303 100644
--- a/src/mame/video/stvvdp2.c
+++ b/src/mame/video/stvvdp2.c
@@ -108,9 +108,6 @@ In other words,the first three types uses the offset and not the color allocated
UINT32* stv_vdp2_regs;
UINT32* stv_vdp2_vram;
-/* this won't be used in the end .. */
-static UINT8* stv_vdp2_vram_dirty_8x8x4;
-static UINT8* stv_vdp2_vram_dirty_8x8x8;
static UINT8* stv_vdp2_gfx_decode;
@@ -138,8 +135,8 @@ enum
{
STV_TRANSPARENCY_NONE = TRANSPARENCY_NONE,
STV_TRANSPARENCY_PEN = TRANSPARENCY_PEN,
- STV_TRANSPARENCY_ALPHA = TRANSPARENCY_ALPHA,
- STV_TRANSPARENCY_ADD_BLEND = TRANSPARENCY_MODES
+ STV_TRANSPARENCY_ADD_BLEND = TRANSPARENCY_MODES,
+ STV_TRANSPARENCY_ALPHA = TRANSPARENCY_MODES + 1
};
#if DEBUG_MODE
@@ -2072,6 +2069,7 @@ static struct stv_vdp2_tilemap_capabilities
UINT8 transparency;
UINT8 colour_calculation_enabled;
UINT8 colour_depth;
+ UINT8 alpha;
UINT8 tile_size;
UINT8 bitmap_enable;
UINT8 bitmap_size;
@@ -2398,7 +2396,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
bitmap_t *dest_bmp,const gfx_element *gfx,
UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley,
- int sprite_screen_width, int sprite_screen_height)
+ int sprite_screen_width, int sprite_screen_height, int alpha)
{
rectangle myclip;
@@ -2452,7 +2450,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
if( gfx )
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
//int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
//int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
@@ -2529,7 +2527,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -2546,7 +2544,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -2568,7 +2566,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -2586,7 +2584,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -2602,19 +2600,19 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
}
}
- /* case 6: TRANSPARENCY_ALPHA */
- if (transparency == TRANSPARENCY_ALPHA)
+ /* case 6: STV_TRANSPARENCY_ALPHA */
+ if (transparency == STV_TRANSPARENCY_ALPHA)
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>16];
- if( c != transparent_color ) dest[x] = alpha_blend16(dest[x], pal[c]);
+ if( c != transparent_color ) dest[x] = alpha_blend_r16(dest[x], pal[c], alpha);
x_index += dx;
}
@@ -2629,7 +2627,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -2647,7 +2645,7 @@ static void stv_vdp2_drawgfxzoom( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
int x, x_index = x_index_base;
@@ -2729,7 +2727,7 @@ static void stv_vdp2_compute_color_offset_RGB555_UINT16(UINT16 *rgb, int cor)
}
static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, UINT32 code, int flipx, int flipy,
- int sx, int sy, const rectangle *clip, int transparency)
+ int sx, int sy, const rectangle *clip, int transparency, int alpha)
{
rectangle myclip;
UINT8* gfxdata;
@@ -2817,7 +2815,7 @@ static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, UINT32 code, int flipx,
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfxdata + (y_index>>16)*16;
+ const UINT8 *source = gfxdata + (y_index>>16)*16;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT16 data;
@@ -2836,8 +2834,8 @@ static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, UINT32 code, int flipx,
if(stv2_current_tilemap.fade_control & 1)
stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2);
- if ( transparency == TRANSPARENCY_ALPHA )
- dest[x] = alpha_blend16( dest[x], b | g << 5 | r << 10 );
+ if ( transparency == STV_TRANSPARENCY_ALPHA )
+ dest[x] = alpha_blend_r16( dest[x], b | g << 5 | r << 10, alpha );
else
dest[x] = b | g << 5 | r << 10;
}
@@ -2937,7 +2935,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
*BITMAP_ADDR16(bitmap, ycnt, xcnt+1) = machine->pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
else
- *BITMAP_ADDR16(bitmap, ycnt, xcnt+1) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt+1), machine->pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
+ *BITMAP_ADDR16(bitmap, ycnt, xcnt+1) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt+1), machine->pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
}
}
tw = stv_vdp2_window_process(xcnt,ycnt);
@@ -2950,7 +2948,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
*BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
else
- *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
+ *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
}
}
gfxdata++;
@@ -2982,7 +2980,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
*BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
else
- *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
+ *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
}
}
if ( (gfxdata + xs) >= gfxdatahigh )
@@ -3025,7 +3023,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
*BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
else
- *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
+ *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
}
}
@@ -3050,7 +3048,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
*BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset];
else
- *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset]);
+ *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset], stv2_current_tilemap.alpha);
}
}
@@ -3094,7 +3092,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
destline[xcnt] = b | g << 5 | r << 10;
else
- destline[xcnt] = alpha_blend16( destline[xcnt], b | g << 5 | r << 10 );
+ destline[xcnt] = alpha_blend_r16( destline[xcnt], b | g << 5 | r << 10, stv2_current_tilemap.alpha );
}
if ( (gfxdata + 2*xs) >= gfxdatahigh ) gfxdata = gfxdatalow;
@@ -3134,7 +3132,7 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma
if(t_pen)
{
if ( stv2_current_tilemap.colour_calculation_enabled == 1 )
- destline[xcnt] = alpha_blend16( destline[xcnt], b | g << 5 | r << 10 );
+ destline[xcnt] = alpha_blend_r16( destline[xcnt], b | g << 5 | r << 10, stv2_current_tilemap.alpha );
else
destline[xcnt] = b | g << 5 | r << 10;
}
@@ -3397,7 +3395,7 @@ static void stv_vdp2_draw_basic_tilemap(running_machine *machine, bitmap_t *bitm
}
else
{
- stv2_current_tilemap.transparency = TRANSPARENCY_ALPHA;
+ stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
}
}
@@ -3606,6 +3604,7 @@ static void stv_vdp2_draw_basic_tilemap(running_machine *machine, bitmap_t *bitm
for (x = 0; x<mptiles_x; x++) {
int xpageoffs;
+ int tilecodespacing = 1;
if ( x == 0 )
{
@@ -3686,44 +3685,17 @@ static void stv_vdp2_draw_basic_tilemap(running_machine *machine, bitmap_t *bitm
if (stv2_current_tilemap.colour_depth == 1)
{
- UINT8 gfx_mem_offset = (tilecode & 0x1) ? 0x20 : 0x0;
-
- tilecode = tilecode >> 1;
gfx = 2;
pal = pal >>4;
-
- /* do a bit of tile decoding */
- tilecode &=0x3fff;
- if (stv2_current_tilemap.tile_size==1)
- { /* we're treating 16x16 tiles as 4 8x8's atm */
- if (stv_vdp2_vram_dirty_8x8x8[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode] = 0; decodechar(machine->gfx[2], tilecode, stv_vdp2_gfx_decode + gfx_mem_offset); };
- if (stv_vdp2_vram_dirty_8x8x8[tilecode+1] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode+1] = 0; decodechar(machine->gfx[2], tilecode+1, stv_vdp2_gfx_decode + gfx_mem_offset); };
- if (stv_vdp2_vram_dirty_8x8x8[tilecode+2] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode+2] = 0; decodechar(machine->gfx[2], tilecode+2, stv_vdp2_gfx_decode + gfx_mem_offset); };
- if (stv_vdp2_vram_dirty_8x8x8[tilecode+3] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode+3] = 0; decodechar(machine->gfx[2], tilecode+3, stv_vdp2_gfx_decode + gfx_mem_offset); };
- }
- else
- {
- if (stv_vdp2_vram_dirty_8x8x8[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode] = 0; decodechar(machine->gfx[2], tilecode, stv_vdp2_gfx_decode + gfx_mem_offset); };
- }
-
+ tilecode &=0x7fff;
+ if (tilecode == 0x7fff) tilecode--; /* prevents crash but unsure what should happen; wrapping? */
+ tilecodespacing = 2;
}
else if (stv2_current_tilemap.colour_depth == 0)
{
gfx = 0;
-
- /* do a bit of tile decoding */
tilecode &=0x7fff;
- if (stv2_current_tilemap.tile_size==1)
- { /* we're treating 16x16 tiles as 4 8x8's atm */
- if (stv_vdp2_vram_dirty_8x8x4[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode] = 0; decodechar(machine->gfx[0], tilecode, stv_vdp2_gfx_decode); };
- if (stv_vdp2_vram_dirty_8x8x4[tilecode+1] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode+1] = 0; decodechar(machine->gfx[0], tilecode+1, stv_vdp2_gfx_decode); };
- if (stv_vdp2_vram_dirty_8x8x4[tilecode+2] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode+2] = 0; decodechar(machine->gfx[0], tilecode+2, stv_vdp2_gfx_decode); };
- if (stv_vdp2_vram_dirty_8x8x4[tilecode+3] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode+3] = 0; decodechar(machine->gfx[0], tilecode+3, stv_vdp2_gfx_decode); };
- }
- else
- {
- if (stv_vdp2_vram_dirty_8x8x4[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode] = 0; decodechar(machine->gfx[0], tilecode, stv_vdp2_gfx_decode); };
- }
+ tilecodespacing = 1;
}
/* TILES ARE NOW DECODED */
@@ -3739,15 +3711,15 @@ static void stv_vdp2_draw_basic_tilemap(running_machine *machine, bitmap_t *bitm
if (stv2_current_tilemap.tile_size==1)
{
/* normal */
- stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+0+(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y);
- stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+1-(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y);
- stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+2+(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey));
- stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+3-(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey));
+ stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y,stv2_current_tilemap.alpha);
+ stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y,stv2_current_tilemap.alpha);
+ stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha);
+ stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha);
}
else
{
- stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y);
+ stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y,stv2_current_tilemap.alpha);
}
}
else
@@ -3760,19 +3732,28 @@ static void stv_vdp2_draw_basic_tilemap(running_machine *machine, bitmap_t *bitm
if ( stv2_current_tilemap.colour_depth == 3 )
{
/* normal */
- stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency);
- stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency);
- stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency);
- stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency);
+ stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
+ stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
+ stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
+ stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
+
+ }
+ else if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA)
+ {
+ /* alpha */
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos, drawypos,0,stv2_current_tilemap.alpha);
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,0,stv2_current_tilemap.alpha);
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,0,stv2_current_tilemap.alpha);
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,0,stv2_current_tilemap.alpha);
}
else
{
/* normal */
- drawgfx(bitmap,machine->gfx[gfx],tilecode+0+(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
- drawgfx(bitmap,machine->gfx[gfx],tilecode+1-(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency,0);
- drawgfx(bitmap,machine->gfx[gfx],tilecode+2+(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
- drawgfx(bitmap,machine->gfx[gfx],tilecode+3-(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
+ drawgfx(bitmap,machine->gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
+ drawgfx(bitmap,machine->gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency,0);
+ drawgfx(bitmap,machine->gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
+ drawgfx(bitmap,machine->gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
}
}
@@ -3780,11 +3761,14 @@ static void stv_vdp2_draw_basic_tilemap(running_machine *machine, bitmap_t *bitm
{
if ( stv2_current_tilemap.colour_depth == 3 )
{
- stv_vdp2_drawgfx_rgb555(bitmap,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,cliprect,stv2_current_tilemap.transparency);
+ stv_vdp2_drawgfx_rgb555(bitmap,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
}
else
{
- drawgfx(bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
+ if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA)
+ drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos, drawypos,0,stv2_current_tilemap.alpha);
+ else
+ drawgfx(bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
}
}
drawxpos = olddrawxpos;
@@ -4142,7 +4126,7 @@ static void stv_vdp2_copy_roz_bitmap(bitmap_t *bitmap,
}
else
{
- stv2_current_tilemap.transparency = TRANSPARENCY_ALPHA;
+ stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
}
}
@@ -4287,8 +4271,8 @@ static void stv_vdp2_copy_roz_bitmap(bitmap_t *bitmap,
case TRANSPARENCY_NONE:
line[hcnt] = pix;
break;
- case TRANSPARENCY_ALPHA:
- if ( pix != 0x000 ) line[hcnt] = alpha_blend16( line[hcnt], pix );
+ case STV_TRANSPARENCY_ALPHA:
+ if ( pix != 0x000 ) line[hcnt] = alpha_blend_r16( line[hcnt], pix, stv2_current_tilemap.alpha );
break;
case STV_TRANSPARENCY_ADD_BLEND:
if ( pix != 0x0000 ) line[hcnt] = stv_add_blend( line[hcnt], pix );
@@ -4379,8 +4363,8 @@ static void stv_vdp2_copy_roz_bitmap(bitmap_t *bitmap,
case TRANSPARENCY_NONE:
line[hcnt] = pix;
break;
- case TRANSPARENCY_ALPHA:
- if ( pix != 0x000 ) line[hcnt] = alpha_blend16( line[hcnt], pix );
+ case STV_TRANSPARENCY_ALPHA:
+ if ( pix != 0x000 ) line[hcnt] = alpha_blend_r16( line[hcnt], pix, stv2_current_tilemap.alpha );
break;
case STV_TRANSPARENCY_ADD_BLEND:
if ( pix != 0x0000 ) line[hcnt] = stv_add_blend( line[hcnt], pix );
@@ -4415,7 +4399,7 @@ static void stv_vdp2_draw_NBG0(running_machine *machine, bitmap_t *bitmap, const
if ( STV_VDP2_N0CCEN )
{
stv2_current_tilemap.colour_calculation_enabled = 1;
- alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N0CCRT)*0xff)/0x1f);
+ stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N0CCRT)*0xff)/0x1f;
}
else
{
@@ -4505,7 +4489,7 @@ static void stv_vdp2_draw_NBG1(running_machine *machine, bitmap_t *bitmap, const
if ( STV_VDP2_N1CCEN )
{
stv2_current_tilemap.colour_calculation_enabled = 1;
- alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N1CCRT)*0xff)/0x1f);
+ stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N1CCRT)*0xff)/0x1f;
}
else
{
@@ -4602,7 +4586,7 @@ static void stv_vdp2_draw_NBG2(running_machine *machine, bitmap_t *bitmap, const
if ( STV_VDP2_N2CCEN )
{
stv2_current_tilemap.colour_calculation_enabled = 1;
- alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N2CCRT)*0xff)/0x1f);
+ stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N2CCRT)*0xff)/0x1f;
}
else
{
@@ -4702,7 +4686,7 @@ static void stv_vdp2_draw_NBG3(running_machine *machine, bitmap_t *bitmap, const
if ( STV_VDP2_N3CCEN )
{
stv2_current_tilemap.colour_calculation_enabled = 1;
- alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N3CCRT)*0xff)/0x1f);
+ stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N3CCRT)*0xff)/0x1f;
}
else
{
@@ -4932,7 +4916,7 @@ static void stv_vdp2_draw_rotation_screen(running_machine *machine, bitmap_t *bi
stv2_current_tilemap.colour_calculation_enabled = colour_calculation_enabled;
if ( colour_calculation_enabled )
{
- stv2_current_tilemap.transparency = TRANSPARENCY_ALPHA;
+ stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
}
mycliprect.min_x = cliprect->min_x;
@@ -4980,7 +4964,7 @@ static void stv_vdp2_draw_RBG0(running_machine *machine, bitmap_t *bitmap, const
if ( STV_VDP2_R0CCEN )
{
stv2_current_tilemap.colour_calculation_enabled = 1;
- alpha_set_level( ((UINT16)(0x1f-STV_VDP2_R0CCRT)*0xff)/0x1f);
+ stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_R0CCRT)*0xff)/0x1f;
}
else
{
@@ -5111,8 +5095,17 @@ WRITE32_HANDLER ( stv_vdp2_vram_w )
stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8;
stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0;
- stv_vdp2_vram_dirty_8x8x4[offset/8] = 1;
- stv_vdp2_vram_dirty_8x8x8[offset/16] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
+ gfx_element_mark_dirty(space->machine->gfx[2], offset/8);
+ gfx_element_mark_dirty(space->machine->gfx[3], offset/8);
+
+ /* 8-bit tiles overlap, so this affects the previous one as well */
+ if (offset/8 != 0)
+ {
+ gfx_element_mark_dirty(space->machine->gfx[2], offset/8 - 1);
+ gfx_element_mark_dirty(space->machine->gfx[3], offset/8 - 1);
+ }
if ( stv_rbg_cache_data.watch_vdp2_vram_writes )
{
@@ -5379,9 +5372,6 @@ static STATE_POSTLOAD( stv_vdp2_state_save_postload )
stv_vdp2_vram_decode[offset*4+1] = (data & 0x00ff0000) >> 16;
stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8;
stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0;
-
- stv_vdp2_vram_dirty_8x8x4[offset/8] = 1;
- stv_vdp2_vram_dirty_8x8x8[offset/16] = 1;
}
memset( &stv_rbg_cache_data, 0, sizeof(stv_rbg_cache_data));
@@ -5397,8 +5387,6 @@ static int stv_vdp2_start (running_machine *machine)
stv_vdp2_vram = auto_malloc ( 0x100000 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart.
stv_vdp2_cram = auto_malloc ( 0x080000 );
stv_vdp2_gfx_decode = auto_malloc ( 0x100000 );
- stv_vdp2_vram_dirty_8x8x4 = auto_malloc ( 0x100000 );
- stv_vdp2_vram_dirty_8x8x8 = auto_malloc ( 0x100000 );
memset(stv_vdp2_regs, 0, 0x040000);
memset(stv_vdp2_vram, 0, 0x100000);
@@ -5429,6 +5417,14 @@ VIDEO_START( stv_vdp2 )
debug.l_en = 0xff;
debug.error = 0xffffffff;
debug.roz = 0;
+ gfx_element_set_source(machine->gfx[0], stv_vdp2_gfx_decode);
+ gfx_element_set_source(machine->gfx[1], stv_vdp2_gfx_decode);
+ gfx_element_set_source(machine->gfx[2], stv_vdp2_gfx_decode);
+ gfx_element_set_source(machine->gfx[3], stv_vdp2_gfx_decode);
+ gfx_element_set_source(machine->gfx[4], stv_vdp1_gfx_decode);
+ gfx_element_set_source(machine->gfx[5], stv_vdp1_gfx_decode);
+ gfx_element_set_source(machine->gfx[6], stv_vdp1_gfx_decode);
+ gfx_element_set_source(machine->gfx[7], stv_vdp1_gfx_decode);
}
/*TODO: frame_period should be different for every kind of resolution (needs tests on actual boards)*/
@@ -6295,41 +6291,41 @@ VIDEO_UPDATE( stv_vdp2 )
for (tilecode = 0;tilecode<0x8000;tilecode++)
{
- decodechar(screen->machine->gfx[0], tilecode, stv_vdp2_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[0], tilecode);
}
for (tilecode = 0;tilecode<0x2000;tilecode++)
{
- decodechar(screen->machine->gfx[1], tilecode, stv_vdp2_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[1], tilecode);
}
for (tilecode = 0;tilecode<0x4000;tilecode++)
{
- decodechar(screen->machine->gfx[2], tilecode, stv_vdp2_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[2], tilecode);
}
for (tilecode = 0;tilecode<0x1000;tilecode++)
{
- decodechar(screen->machine->gfx[3], tilecode, stv_vdp2_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[3], tilecode);
}
/* vdp 1 ... doesn't have to be tile based */
for (tilecode = 0;tilecode<0x8000;tilecode++)
{
- decodechar(screen->machine->gfx[4], tilecode, stv_vdp1_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[4], tilecode);
}
for (tilecode = 0;tilecode<0x2000;tilecode++)
{
- decodechar(screen->machine->gfx[5], tilecode, stv_vdp1_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[5], tilecode);
}
for (tilecode = 0;tilecode<0x4000;tilecode++)
{
- decodechar(screen->machine->gfx[6], tilecode, stv_vdp1_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[6], tilecode);
}
for (tilecode = 0;tilecode<0x1000;tilecode++)
{
- decodechar(screen->machine->gfx[7], tilecode, stv_vdp1_gfx_decode);
+ gfx_element_mark_dirty(screen->machine->gfx[7], tilecode);
}
}
diff --git a/src/mame/video/suprnova.c b/src/mame/video/suprnova.c
index 46c3e734782..bddac0a0657 100644
--- a/src/mame/video/suprnova.c
+++ b/src/mame/video/suprnova.c
@@ -991,67 +991,8 @@ static void supernova_draw_b( bitmap_t *bitmap, bitmap_t* bitmap_flags, const re
VIDEO_UPDATE(skns)
{
- int i, offset;
-
- UINT8 *btiles;
-
-
palette_update(screen->machine);
- btiles = memory_region (screen->machine, "gfx3");
-
-// if (!(skns_v3_regs[0x0c/4] & 0x0100)); // if tilemap b is in 8bpp mode
- {
- if (skns_v3t_somedirty)
- {
- skns_v3t_somedirty = 0;
-
- /* check if & where that tile is used in the tilemap */
- for (offset=0;offset<0x4000/4;offset++)
- {
- int code = ((skns_tilemapB_ram[offset] & 0x001fffff) >> 0 );
- if (skns_v3t_dirty[code&0x3ff])
- tilemap_mark_tile_dirty(skns_tilemap_B,offset);
- }
-
- for (i = 0; i < 0x0400; i++)
- {
- if (skns_v3t_dirty[i] == 1)
- {
- decodechar(screen->machine->gfx[1], i, (UINT8*)btiles);
-
- skns_v3t_dirty[i] = 0;
- }
- }
- }
- }
-
-// if (skns_v3_regs[0x0c/4] & 0x0100); // if tilemap b is in 4bpp mode
- {
- if (skns_v3t_4bpp_somedirty)
- {
- skns_v3t_4bpp_somedirty = 0;
-
- /* check if & where that tile is used in the tilemap */
- for (offset=0;offset<0x4000/4;offset++)
- {
- int code = ((skns_tilemapB_ram[offset] & 0x001fffff) >> 0 );
- if (skns_v3t_4bppdirty[code&0x7ff])
- tilemap_mark_tile_dirty(skns_tilemap_B,offset);
- }
-
- for (i = 0; i < 0x0800; i++)
- {
- if (skns_v3t_4bppdirty[i] == 1)
- {
- decodechar(screen->machine->gfx[3], i, (UINT8*)btiles);
-
- skns_v3t_4bppdirty[i] = 0;
- }
- }
- }
- }
-
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
bitmap_fill(tilemap_bitmap_lower, NULL, 0);
bitmap_fill(tilemap_bitmapflags_lower, NULL, 0);
diff --git a/src/mame/video/surpratk.c b/src/mame/video/surpratk.c
index b0f3bcb1bc1..ef6161ebc18 100644
--- a/src/mame/video/surpratk.c
+++ b/src/mame/video/surpratk.c
@@ -94,6 +94,6 @@ VIDEO_UPDATE( surpratk )
tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
- K053245_sprites_draw(0,bitmap,cliprect);
+ K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
return 0;
}
diff --git a/src/mame/video/tail2nos.c b/src/mame/video/tail2nos.c
index e59b09f05c7..ec92b6f8a6a 100644
--- a/src/mame/video/tail2nos.c
+++ b/src/mame/video/tail2nos.c
@@ -9,8 +9,6 @@ static tilemap *bg_tilemap;
static int charbank,charpalette,video_enable;
static UINT16 *zoomdata;
-static int dirtygfx;
-static UINT8 *dirtychar;
#define TOTAL_CHARS 0x400
@@ -56,9 +54,6 @@ VIDEO_START( tail2nos )
K051316_vh_start_0(machine,"gfx3",-4,TRUE,0,zoom_callback);
- dirtychar = auto_malloc(TOTAL_CHARS);
- memset(dirtychar,1,TOTAL_CHARS);
-
tilemap_set_transparent_pen(bg_tilemap,15);
K051316_wraparound_enable(0,1);
@@ -90,10 +85,7 @@ WRITE16_HANDLER( tail2nos_zoomdata_w )
int oldword = zoomdata[offset];
COMBINE_DATA(&zoomdata[offset]);
if (oldword != zoomdata[offset])
- {
- dirtygfx = 1;
- dirtychar[offset / 64] = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[2], offset / 64);
}
WRITE16_HANDLER( tail2nos_gfxbank_w )
@@ -164,25 +156,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( tail2nos )
{
- if (dirtygfx)
- {
- int i;
-
- dirtygfx = 0;
-
- for (i = 0;i < TOTAL_CHARS;i++)
- {
- if (dirtychar[i])
- {
- dirtychar[i] = 0;
- decodechar(screen->machine->gfx[2],i,(UINT8 *)zoomdata);
- }
- }
-
- tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
- }
-
-
if (video_enable)
{
K051316_zoom_draw_0(bitmap,cliprect,0,0);
diff --git a/src/mame/video/taito_b.c b/src/mame/video/taito_b.c
index becb11767d7..17cab772641 100644
--- a/src/mame/video/taito_b.c
+++ b/src/mame/video/taito_b.c
@@ -430,23 +430,21 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
if ( zoomx || zoomy )
{
- drawgfxzoom (bitmap,machine->gfx[1],
+ drawgfxzoom_transpen_raw (bitmap,cliprect,machine->gfx[1],
code,
color,
flipx,flipy,
x,y,
- cliprect,
- TRANSPARENCY_PEN_RAW,0,(zx << 16) / 16,(zy << 16) / 16);
+ (zx << 16) / 16,(zy << 16) / 16,0);
}
else
{
- drawgfx (bitmap,machine->gfx[1],
+ drawgfx_transpen_raw (bitmap,cliprect,machine->gfx[1],
code,
color,
flipx,flipy,
x,y,
- cliprect,
- TRANSPARENCY_PEN_RAW,0);
+ 0);
}
}
}
diff --git a/src/mame/video/taito_f2.c b/src/mame/video/taito_f2.c
index 3e6a9f4ac7a..70d98b24082 100644
--- a/src/mame/video/taito_f2.c
+++ b/src/mame/video/taito_f2.c
@@ -372,7 +372,7 @@ static void taito_f2_tc360_spritemixdraw( bitmap_t *dest_bmp,const gfx_element *
const rectangle *clip,int scalex, int scaley)
{
int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
@@ -445,7 +445,7 @@ static void taito_f2_tc360_spritemixdraw( bitmap_t *dest_bmp,const gfx_element *
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
diff --git a/src/mame/video/taito_f3.c b/src/mame/video/taito_f3.c
index c7640dd7adb..4be4402e95f 100644
--- a/src/mame/video/taito_f3.c
+++ b/src/mame/video/taito_f3.c
@@ -215,16 +215,12 @@ Playfield tile info:
static tilemap *pf1_tilemap,*pf2_tilemap,*pf3_tilemap,*pf4_tilemap;
static tilemap *pixel_layer,*vram_layer;
static UINT32 *spriteram32_buffered;
-static int vram_dirty[256];
-static int pivot_changed,vram_changed;
static UINT32 f3_control_0[8];
static UINT32 f3_control_1[8];
static int flipscreen;
static UINT8 sprite_extra_planes;
static UINT8 sprite_pen_mask;
-static UINT8 *pivot_dirty;
-
static UINT32 *f3_pf_data_1,*f3_pf_data_2,*f3_pf_data_3,*f3_pf_data_4;
UINT32 *f3_vram,*f3_line_ram;
@@ -599,7 +595,7 @@ VIDEO_EOF( f3 )
VIDEO_START( f3 )
{
const struct F3config *pCFG=&f3_config_table[0];
- int tile, width, height, i;
+ int width, height, i;
f3_alpha_level_2as=127;
f3_alpha_level_2ad=127;
@@ -622,7 +618,6 @@ VIDEO_START( f3 )
spritelist=0;
spriteram32_buffered=0;
- pivot_dirty=0;
pf_line_inf=0;
pri_alp_bitmap=0;
tile_opaque_sp=0;
@@ -674,7 +669,6 @@ VIDEO_START( f3 )
sprite_end = spritelist;
vram_layer = tilemap_create(machine, get_tile_info_vram,tilemap_scan_rows,8,8,64,64);
pixel_layer = tilemap_create(machine, get_tile_info_pixel,tilemap_scan_cols,8,8,64,32);
- pivot_dirty = (UINT8 *)auto_malloc(2048);
pf_line_inf = auto_malloc(5 * sizeof(struct f3_playfield_line_inf));
sa_line_inf = auto_malloc(1 * sizeof(struct f3_spritealpha_line_inf));
width = video_screen_get_width(machine->primary_screen);
@@ -703,10 +697,8 @@ VIDEO_START( f3 )
state_save_register_global_array(machine, f3_control_0);
state_save_register_global_array(machine, f3_control_1);
- for (tile = 0;tile < 256;tile++)
- vram_dirty[tile]=1;
- for (tile = 0;tile < 2048;tile++)
- pivot_dirty[tile]=1;
+ gfx_element_set_source(machine->gfx[0], (UINT8 *)f3_vram);
+ gfx_element_set_source(machine->gfx[3], (UINT8 *)f3_pivot_ram);
f3_skip_this_frame=0;
@@ -722,7 +714,7 @@ VIDEO_START( f3 )
{
int x,y;
int chk_trans_or_opa=0;
- UINT8 *dp = sprite_gfx->gfxdata + c * sprite_gfx->char_modulo;
+ const UINT8 *dp = gfx_element_get_data(sprite_gfx, c);
for (y = 0;y < sprite_gfx->height;y++)
{
for (x = 0;x < sprite_gfx->width;x++)
@@ -751,7 +743,7 @@ VIDEO_START( f3 )
{
int chk_trans_or_opa=0;
UINT8 extra_mask = ((extra_planes << 4) | 0x0f);
- UINT8 *dp = pf_gfx->gfxdata + c * pf_gfx->char_modulo;
+ const UINT8 *dp = gfx_element_get_data(pf_gfx, c);
for (y = 0;y < pf_gfx->height;y++)
{
@@ -819,15 +811,13 @@ WRITE32_HANDLER( f3_videoram_w )
WRITE32_HANDLER( f3_vram_w )
{
COMBINE_DATA(&f3_vram[offset]);
- vram_dirty[offset/8]=1;
- vram_changed=1;
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
}
WRITE32_HANDLER( f3_pivot_w )
{
COMBINE_DATA(&f3_pivot_ram[offset]);
- pivot_dirty[offset/8]=1;
- pivot_changed=1;
+ gfx_element_mark_dirty(space->machine->gfx[3], offset/8);
}
WRITE32_HANDLER( f3_lineram_w )
@@ -2668,7 +2658,7 @@ INLINE void f3_drawgfx( running_machine *machine,
if( gfx )
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- int source_base = (code % gfx->total_elements) * 16;
+ const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
{
/* compute sprite increment per screen pixel */
@@ -2734,14 +2724,14 @@ INLINE void f3_drawgfx( running_machine *machine,
{
int y=ey-sy;
int x=(ex-sx-1)|(tile_opaque_sp[code % gfx->total_elements]<<4);
- UINT8 *source0 = gfx->gfxdata + (source_base+y_index) * 16 + x_index_base;
+ const UINT8 *source0 = code_base + y_index * 16 + x_index_base;
UINT32 *dest0 = BITMAP_ADDR32(dest_bmp, sy, sx);
UINT8 *pri0 = BITMAP_ADDR8(pri_alp_bitmap, sy, sx);
int yadv = dest_bmp->rowpixels;
dy=dy*16;
while(1)
{
- UINT8 *source = source0;
+ const UINT8 *source = source0;
UINT32 *dest = dest0;
UINT8 *pri = pri0;
@@ -2833,7 +2823,7 @@ INLINE void f3_drawgfxzoom(running_machine *machine,
if( gfx )
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
- int source_base = (code % gfx->total_elements) * 16;
+ const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
{
/* compute sprite increment per screen pixel */
@@ -2900,7 +2890,7 @@ INLINE void f3_drawgfxzoom(running_machine *machine,
int y;
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * 16;
+ const UINT8 *source = code_base + (y_index>>16) * 16;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(pri_alp_bitmap, y, 0);
@@ -3248,31 +3238,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( f3 )
{
UINT32 sy_fix[5],sx_fix[5];
- int tile;
f3_skip_this_frame=0;
tilemap_set_flip(ALL_TILEMAPS,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
- /* Dynamically decode VRAM chars if dirty */
- if (vram_changed)
- for (tile = 0;tile < 256;tile++)
- if (vram_dirty[tile]) {
- decodechar(screen->machine->gfx[0],tile,(UINT8 *)f3_vram);
- tilemap_mark_all_tiles_dirty(vram_layer); // TODO
- //tilemap_mark_tile_dirty(vram_layer,tile);
- vram_dirty[tile]=0;
- }
-
- /* Decode chars & mark tilemap dirty */
- if (pivot_changed)
- for (tile = 0;tile < 2048;tile++)
- if (pivot_dirty[tile]) {
- decodechar(screen->machine->gfx[3],tile,(UINT8 *)f3_pivot_ram);
- tilemap_mark_tile_dirty(pixel_layer,tile);
- pivot_dirty[tile]=0;
- }
- pivot_changed=vram_changed=0;
-
/* Setup scroll */
sy_fix[0]=((f3_control_0[2]&0xffff0000)>> 7) + (1<<16);
sy_fix[1]=((f3_control_0[2]&0x0000ffff)<< 9) + (1<<16);
diff --git a/src/mame/video/taito_l.c b/src/mame/video/taito_l.c
index 55be6dc8410..fe2c2d94726 100644
--- a/src/mame/video/taito_l.c
+++ b/src/mame/video/taito_l.c
@@ -24,8 +24,8 @@ static UINT8 buff_spriteram[SPRITERAM_SIZE];
static TILE_GET_INFO( get_bg18_tile_info )
{
- int attr = taitol_rambanks[2*tile_index+0x4000+1];
- int code = taitol_rambanks[2*tile_index+0x4000]
+ int attr = taitol_rambanks[2*tile_index+0x8000+1];
+ int code = taitol_rambanks[2*tile_index+0x8000]
| ((attr & 0x03) << 8)
| ((bankc[(attr & 0xc) >> 2]) << 10)
| (horshoes_gfxbank << 12);
@@ -39,8 +39,8 @@ static TILE_GET_INFO( get_bg18_tile_info )
static TILE_GET_INFO( get_bg19_tile_info )
{
- int attr = taitol_rambanks[2*tile_index+0x5000+1];
- int code = taitol_rambanks[2*tile_index+0x5000]
+ int attr = taitol_rambanks[2*tile_index+0x9000+1];
+ int code = taitol_rambanks[2*tile_index+0x9000]
| ((attr & 0x03) << 8)
| ((bankc[(attr & 0xc) >> 2]) << 10)
| (horshoes_gfxbank << 12);
@@ -54,8 +54,8 @@ static TILE_GET_INFO( get_bg19_tile_info )
static TILE_GET_INFO( get_ch1a_tile_info )
{
- int attr = taitol_rambanks[2*tile_index+0x6000+1];
- int code = taitol_rambanks[2*tile_index+0x6000]|((attr&0x01)<<8)|((attr&0x04)<<7);
+ int attr = taitol_rambanks[2*tile_index+0xa000+1];
+ int code = taitol_rambanks[2*tile_index+0xa000]|((attr&0x01)<<8)|((attr&0x04)<<7);
SET_TILE_INFO(
2,
@@ -158,50 +158,44 @@ READ8_HANDLER( taitol_control_r )
return cur_ctrl;
}
-INLINE void taitol_chardef(running_machine *machine, int num, int offset)
-{
- decodechar(machine->gfx[2], num, taitol_rambanks + offset);
- tilemap_mark_all_tiles_dirty(ch1a_tilemap);
-}
-
void taitol_chardef14_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32, 0);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 0);
}
void taitol_chardef15_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32 + 128, 0);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 128);
}
void taitol_chardef16_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32+256, 0);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 256);
}
void taitol_chardef17_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32+384, 0);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 384);
}
void taitol_chardef1c_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32+512, 0x4000);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 512);
}
void taitol_chardef1d_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32+640, 0x4000);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 640);
}
void taitol_chardef1e_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32+768, 0x4000);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 768);
}
void taitol_chardef1f_m(running_machine *machine, int offset)
{
- taitol_chardef(machine, offset/32+896, 0x4000);
+ gfx_element_mark_dirty(machine->gfx[2], offset/32 + 896);
}
void taitol_bg18_m(running_machine *machine, int offset)
@@ -299,17 +293,17 @@ VIDEO_UPDATE( taitol )
int dx,dy;
- dx = taitol_rambanks[0x73f4]|(taitol_rambanks[0x73f5]<<8);
+ dx = taitol_rambanks[0xb3f4]|(taitol_rambanks[0xb3f5]<<8);
if (flipscreen)
dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf;
- dy = taitol_rambanks[0x73f6];
+ dy = taitol_rambanks[0xb3f6];
tilemap_set_scrollx(bg18_tilemap,0,-dx);
tilemap_set_scrolly(bg18_tilemap,0,-dy);
- dx = taitol_rambanks[0x73fc]|(taitol_rambanks[0x73fd]<<8);
+ dx = taitol_rambanks[0xb3fc]|(taitol_rambanks[0xb3fd]<<8);
if (flipscreen)
dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf;
- dy = taitol_rambanks[0x73fe];
+ dy = taitol_rambanks[0xb3fe];
tilemap_set_scrollx(bg19_tilemap,0,-dx);
tilemap_set_scrolly(bg19_tilemap,0,-dy);
@@ -337,7 +331,7 @@ VIDEO_UPDATE( taitol )
VIDEO_EOF( taitol )
{
- UINT8 *spriteram = taitol_rambanks + 0x7000;
+ UINT8 *spriteram = taitol_rambanks + 0xb000;
memcpy(buff_spriteram,spriteram,SPRITERAM_SIZE);
}
diff --git a/src/mame/video/taitoic.c b/src/mame/video/taitoic.c
index 6e076127245..5de19954fec 100644
--- a/src/mame/video/taitoic.c
+++ b/src/mame/video/taitoic.c
@@ -533,6 +533,7 @@ Newer version of the I/O chip ?
***************************************************************************/
#include "driver.h"
+#include "drawgfxm.h"
#include "taitoic.h"
#define TOPSPEED_ROAD_COLORS
@@ -1344,8 +1345,6 @@ static UINT16 TC0080VCO_bg0_scrollx,TC0080VCO_bg0_scrolly,
static tilemap *TC0080VCO_tilemap[3];
-static UINT8 *TC0080VCO_char_dirty;
-static int TC0080VCO_chars_dirty;
static int TC0080VCO_bg_gfx,TC0080VCO_tx_gfx;
static int TC0080VCO_bg_xoffs,TC0080VCO_bg_yoffs;
static int TC0080VCO_bg_flip_yoffs;
@@ -1479,12 +1478,6 @@ static void TC0080VCO_set_layer_ptrs(void)
TC0080VCO_scroll_ram = TC0080VCO_ram + 0x20800/2;
}
-static void TC0080VCO_dirty_chars(void)
-{
- memset(TC0080VCO_char_dirty,1,TC0080VCO_TOTAL_CHARS);
- TC0080VCO_chars_dirty = 1;
-}
-
static void TC0080VCO_restore_scroll(void)
{
TC0080VCO_flipscreen = TC0080VCO_scroll_ram[0] & 0x0c00;
@@ -1503,7 +1496,6 @@ static void TC0080VCO_restore_scroll(void)
static STATE_POSTLOAD( TC0080VCO_postload )
{
TC0080VCO_set_layer_ptrs();
- TC0080VCO_dirty_chars();
TC0080VCO_restore_scroll();
}
@@ -1540,9 +1532,6 @@ void TC0080VCO_vh_start(running_machine *machine, int gfxnum,int has_fg0,int bg_
/* Perform extra initialisations for text layer */
{
TC0080VCO_tilemap[2] = tilemap_create(machine, TC0080VCO_get_tx_tile_info,tilemap_scan_rows,8,8,64,64);
- TC0080VCO_char_dirty = auto_malloc(TC0080VCO_TOTAL_CHARS);
-
- TC0080VCO_dirty_chars();
/* find first empty slot to decode gfx */
for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++)
@@ -1551,10 +1540,7 @@ void TC0080VCO_vh_start(running_machine *machine, int gfxnum,int has_fg0,int bg_
assert(gfx_index != MAX_GFX_ELEMENTS);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[gfx_index] = allocgfx(machine, &TC0080VCO_charlayout);
-
- /* set the color information */
- machine->gfx[gfx_index]->total_colors = 64; // is this correct ?
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &TC0080VCO_charlayout, (UINT8 *)TC0080VCO_char_ram, 64, 0);
TC0080VCO_tx_gfx = gfx_index;
tilemap_set_scrolldx(TC0080VCO_tilemap[2],0,0);
@@ -1612,8 +1598,7 @@ WRITE16_HANDLER( TC0080VCO_word_w )
if (offset < 0x1000/2)
{
- TC0080VCO_char_dirty[offset / 8] = 1;
- TC0080VCO_chars_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[TC0080VCO_tx_gfx], offset / 8);
#if 0
if (!TC0080VCO_has_tx)
{
@@ -1644,8 +1629,7 @@ WRITE16_HANDLER( TC0080VCO_word_w )
else if (offset < 0x11000/2)
{
- TC0080VCO_char_dirty[(offset - 0x10000/2) / 8] = 1;
- TC0080VCO_chars_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[TC0080VCO_tx_gfx], (offset - 0x10000/2) / 8);
#if 0
if (!TC0080VCO_has_tx)
{
@@ -1700,40 +1684,6 @@ void TC0080VCO_tilemap_update(running_machine *machine)
tilemap_set_scrolly(TC0080VCO_tilemap[1],0, TC0080VCO_bg1_scrolly);
tilemap_set_scrollx(TC0080VCO_tilemap[2],0,0); /* no scroll (maybe) */
tilemap_set_scrolly(TC0080VCO_tilemap[2],0,0);
-
- /* Decode any characters that have changed */
-
- if (TC0080VCO_chars_dirty)
- {
- int tile_index;
-
- for (tile_index = 0;tile_index < 64*64;tile_index++)
- {
- int attr = TC0080VCO_tx_ram_0[tile_index >> 1];
-
- /* should this be reversed in flipscreen ?? */
- if (tile_index & 1) /* each word has 2 chars */
- {
- attr = (attr &0xff);
- }
- else
- {
- attr = (attr &0xff00) >> 8;
- }
-
- if (TC0080VCO_char_dirty[attr])
- tilemap_mark_tile_dirty(TC0080VCO_tilemap[2],tile_index);
- }
-
- for (j = 0;j < TC0080VCO_TOTAL_CHARS;j++)
- {
- if (TC0080VCO_char_dirty[j])
- decodechar(machine->gfx[TC0080VCO_tx_gfx],j,
- (UINT8 *)TC0080VCO_char_ram);
- TC0080VCO_char_dirty[j] = 0;
- }
- TC0080VCO_chars_dirty = 0;
- }
}
@@ -1893,6 +1843,18 @@ static void TC0080VCO_bg0_tilemap_draw(bitmap_t *bitmap,const rectangle *cliprec
}
+#define PIXEL_OP_COPY_TRANS0_SET_PRIORITY(DEST, PRIORITY, SOURCE) \
+do \
+{ \
+ UINT32 srcdata = (SOURCE); \
+ if (srcdata != 0) \
+ { \
+ (DEST) = SOURCE; \
+ (PRIORITY) = privalue; \
+ } \
+} \
+while (0) \
+
static void TC0080VCO_bg1_tilemap_draw(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int flags,UINT32 priority)
{
UINT8 layer=1;
@@ -1959,12 +1921,24 @@ static void TC0080VCO_bg1_tilemap_draw(running_machine *machine, bitmap_t *bitma
- (max_y + min_y) * (zy-0x10000);
}
- copyrozbitmap(bitmap,srcbitmap,
- sx, sy,
- zx, 0, 0, zy,
- 0, /* why no wraparound ?? */
- cliprect,
- TRANSPARENCY_PEN, 0, priority);
+ {
+ bitmap_t *dest = bitmap;
+ bitmap_t *src = srcbitmap;
+ INT32 startx = sx;
+ INT32 starty = sy;
+ INT32 incxx = zx;
+ INT32 incxy = 0;
+ INT32 incyx = 0;
+ INT32 incyy = zy;
+ int wraparound = 0;
+ UINT32 privalue = priority;
+ bitmap_t *priority = priority_bitmap;
+
+ if (dest->bpp == 16)
+ COPYROZBITMAP_CORE(UINT16, PIXEL_OP_COPY_TRANS0_SET_PRIORITY, UINT8);
+ else
+ COPYROZBITMAP_CORE(UINT32, PIXEL_OP_COPY_TRANS0_SET_PRIORITY, UINT8);
+ }
}
}
@@ -2025,8 +1999,6 @@ static int TC0100SCN_bgscrollx[TC0100SCN_MAX_CHIPS],TC0100SCN_bgscrolly[TC0100SC
static tilemap *TC0100SCN_tilemap[TC0100SCN_MAX_CHIPS][3][2];
static rectangle TC0100SCN_cliprect[TC0100SCN_MAX_CHIPS];
-static char *TC0100SCN_char_dirty[TC0100SCN_MAX_CHIPS];
-static int TC0100SCN_chars_dirty[TC0100SCN_MAX_CHIPS];
static int TC0100SCN_bg_gfx[TC0100SCN_MAX_CHIPS],TC0100SCN_tx_gfx[TC0100SCN_MAX_CHIPS];
static int TC0100SCN_bg_col_mult,TC0100SCN_bg_tilemask,TC0100SCN_tx_col_mult;
static INT32 TC0100SCN_gfxbank,TC0100SCN_chip_colbank[3],TC0100SCN_colbank[3];
@@ -2226,12 +2198,6 @@ static void TC0100SCN_dirty_tilemaps(int chip)
tilemap_mark_all_tiles_dirty(TC0100SCN_tilemap[chip][2][TC0100SCN_dblwidth[chip]]);
}
-static void TC0100SCN_dirty_chars(int chip)
-{
- memset(TC0100SCN_char_dirty[chip],1,TC0100SCN_TOTAL_CHARS);
- TC0100SCN_chars_dirty[chip] = 1;
-}
-
static void TC0100SCN_restore_scroll(int chip)
{
int flip;
@@ -2261,7 +2227,6 @@ static STATE_POSTLOAD( TC0100SCN_postload )
int chip = (FPTR)param;
TC0100SCN_set_layer_ptrs(chip);
- TC0100SCN_dirty_chars(chip);
TC0100SCN_restore_scroll(chip);
}
@@ -2304,10 +2269,8 @@ void TC0100SCN_vh_start(running_machine *machine, int chips,int gfxnum,int x_off
TC0100SCN_cliprect[i] = myclip;
TC0100SCN_ram[i] = auto_malloc(TC0100SCN_RAM_SIZE);
- TC0100SCN_char_dirty[i] = auto_malloc(TC0100SCN_TOTAL_CHARS);
TC0100SCN_set_layer_ptrs(i);
- TC0100SCN_dirty_chars(i);
memset(TC0100SCN_ram[i],0,TC0100SCN_RAM_SIZE);
{
@@ -2325,11 +2288,7 @@ void TC0100SCN_vh_start(running_machine *machine, int chips,int gfxnum,int x_off
assert(gfx_index != MAX_GFX_ELEMENTS);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[gfx_index] = allocgfx(machine, &TC0100SCN_charlayout);
-
- /* set the color information */
- machine->gfx[gfx_index]->total_colors = 64;
-
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &TC0100SCN_charlayout, (UINT8 *)TC0100SCN_char_ram[i], 64, 0);
TC0100SCN_tx_gfx[i] = gfx_index;
/* use the given gfx set for bg tiles; 2nd/3rd chips will
@@ -2431,7 +2390,7 @@ READ16_HANDLER( TC0100SCN_word_2_r )
return TC0100SCN_ram[2][offset];
}
-static void TC0100SCN_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
+static void TC0100SCN_word_w(const address_space *space,int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
{
COMBINE_DATA(&TC0100SCN_ram[chip][offset]);
if (!TC0100SCN_dblwidth[chip])
@@ -2441,10 +2400,7 @@ static void TC0100SCN_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
else if (offset < 0x3000)
tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][2][0],(offset & 0x0fff));
else if (offset < 0x3800)
- {
- TC0100SCN_char_dirty[chip][(offset - 0x3000) / 8] = 1;
- TC0100SCN_chars_dirty[chip] = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[TC0100SCN_tx_gfx[chip]], (offset - 0x3000) / 8);
else if (offset >= 0x4000 && offset < 0x6000)
tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][1][0],(offset & 0x1fff) / 2);
}
@@ -2455,10 +2411,7 @@ static void TC0100SCN_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
else if (offset >= 0x4000 && offset < 0x8000)
tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][1][1],(offset & 0x3fff) / 2);
else if (offset >= 0x8800 && offset < 0x9000)
- {
- TC0100SCN_char_dirty[chip][(offset - 0x8800) / 8] = 1;
- TC0100SCN_chars_dirty[chip] = 1;
- }
+ gfx_element_mark_dirty(space->machine->gfx[TC0100SCN_tx_gfx[chip]], (offset - 0x8800) / 8);
else if (offset >= 0x9000)
tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][2][1],(offset & 0x0fff));
}
@@ -2466,17 +2419,17 @@ static void TC0100SCN_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
WRITE16_HANDLER( TC0100SCN_word_0_w )
{
- TC0100SCN_word_w(0,offset,data,mem_mask);
+ TC0100SCN_word_w(space,0,offset,data,mem_mask);
}
WRITE16_HANDLER( TC0100SCN_word_1_w )
{
- TC0100SCN_word_w(1,offset,data,mem_mask);
+ TC0100SCN_word_w(space,1,offset,data,mem_mask);
}
WRITE16_HANDLER( TC0100SCN_word_2_w )
{
- TC0100SCN_word_w(2,offset,data,mem_mask);
+ TC0100SCN_word_w(space,2,offset,data,mem_mask);
}
WRITE16_HANDLER( TC0100SCN_dual_screen_w )
@@ -2509,7 +2462,7 @@ READ16_HANDLER( TC0100SCN_ctrl_word_2_r )
}
-static void TC0100SCN_ctrl_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
+static void TC0100SCN_ctrl_word_w(const address_space *space,int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
{
COMBINE_DATA(&TC0100SCN_ctrl[chip][offset]);
@@ -2555,6 +2508,9 @@ static void TC0100SCN_ctrl_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_
/* and ensure full redraw of the tilemaps */
TC0100SCN_dirty_tilemaps(chip);
+
+ /* reset the pointer to the text characters (and dirty them all) */
+ gfx_element_set_source(space->machine->gfx[TC0100SCN_tx_gfx[chip]], (UINT8 *)TC0100SCN_char_ram[chip]);
}
break;
@@ -2578,17 +2534,17 @@ static void TC0100SCN_ctrl_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_
WRITE16_HANDLER( TC0100SCN_ctrl_word_0_w )
{
- TC0100SCN_ctrl_word_w(0,offset,data,mem_mask);
+ TC0100SCN_ctrl_word_w(space,0,offset,data,mem_mask);
}
WRITE16_HANDLER( TC0100SCN_ctrl_word_1_w )
{
- TC0100SCN_ctrl_word_w(1,offset,data,mem_mask);
+ TC0100SCN_ctrl_word_w(space,1,offset,data,mem_mask);
}
WRITE16_HANDLER( TC0100SCN_ctrl_word_2_w )
{
- TC0100SCN_ctrl_word_w(2,offset,data,mem_mask);
+ TC0100SCN_ctrl_word_w(space,2,offset,data,mem_mask);
}
@@ -2599,8 +2555,8 @@ READ32_HANDLER( TC0100SCN_ctrl_long_r )
WRITE32_HANDLER( TC0100SCN_ctrl_long_w )
{
- if (ACCESSING_BITS_16_31) TC0100SCN_ctrl_word_w(0,offset*2,data>>16,mem_mask>>16);
- if (ACCESSING_BITS_0_15) TC0100SCN_ctrl_word_w(0,(offset*2)+1,data&0xffff,mem_mask&0xffff);
+ if (ACCESSING_BITS_16_31) TC0100SCN_ctrl_word_w(space,0,offset*2,data>>16,mem_mask>>16);
+ if (ACCESSING_BITS_0_15) TC0100SCN_ctrl_word_w(space,0,(offset*2)+1,data&0xffff,mem_mask&0xffff);
}
READ32_HANDLER( TC0100SCN_long_r )
@@ -2650,29 +2606,6 @@ void TC0100SCN_tilemap_update(running_machine *machine)
tilemap_set_scrollx(TC0100SCN_tilemap[chip][1][TC0100SCN_dblwidth[chip]],
(j + TC0100SCN_fgscrolly[chip]) & 0x1ff,
TC0100SCN_fgscrollx[chip] - TC0100SCN_fgscroll_ram[chip][j]);
-
- /* Decode any characters that have changed */
- if (TC0100SCN_chars_dirty[chip])
- {
- int tile_index;
-
-
- for (tile_index = 0;tile_index < 64*64;tile_index++)
- {
- int attr = TC0100SCN_tx_ram[chip][tile_index];
- if (TC0100SCN_char_dirty[chip][attr & 0xff])
- tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][2][TC0100SCN_dblwidth[chip]],tile_index);
- }
-
- for (j = 0;j < TC0100SCN_TOTAL_CHARS;j++)
- {
- if (TC0100SCN_char_dirty[chip][j])
- decodechar(machine->gfx[TC0100SCN_tx_gfx[chip]],j,
- (UINT8 *)TC0100SCN_char_ram[chip]);
- TC0100SCN_char_dirty[chip][j] = 0;
- }
- TC0100SCN_chars_dirty[chip] = 0;
- }
}
}
@@ -2947,8 +2880,6 @@ int TC0480SCP_pri_reg;
/* We keep two tilemaps for each of the 5 actual tilemaps: one at standard width, one double */
static tilemap *TC0480SCP_tilemap[5][2];
-static char *TC0480SCP_char_dirty;
-static int TC0480SCP_chars_dirty;
static int TC0480SCP_bg_gfx,TC0480SCP_tx_gfx;
static INT32 TC0480SCP_tile_colbase,TC0480SCP_dblwidth;
static int TC0480SCP_x_offs,TC0480SCP_y_offs;
@@ -3072,12 +3003,6 @@ static void TC0480SCP_dirty_tilemaps(void)
tilemap_mark_all_tiles_dirty(TC0480SCP_tilemap[4][TC0480SCP_dblwidth]);
}
-static void TC0480SCP_dirty_chars(void)
-{
- memset(TC0480SCP_char_dirty,1,TC0480SCP_TOTAL_CHARS);
- TC0480SCP_chars_dirty = 1;
-}
-
static void TC0480SCP_restore_scroll(void)
{
int reg;
@@ -3144,7 +3069,6 @@ static void TC0480SCP_restore_scroll(void)
static STATE_POSTLOAD( TC0480SCP_postload )
{
TC0480SCP_set_layer_ptrs();
- TC0480SCP_dirty_chars();
TC0480SCP_restore_scroll();
}
@@ -3176,10 +3100,8 @@ void TC0480SCP_vh_start(running_machine *machine, int gfxnum,int pixels,int x_of
TC0480SCP_tilemap[4][1] = tilemap_create(machine, tc480_get_tile_info[4],tilemap_scan_rows,8,8,64,64);
TC0480SCP_ram = auto_malloc(TC0480SCP_RAM_SIZE);
- TC0480SCP_char_dirty = auto_malloc(TC0480SCP_TOTAL_CHARS);
TC0480SCP_set_layer_ptrs();
- TC0480SCP_dirty_chars();
memset(TC0480SCP_ram,0,TC0480SCP_RAM_SIZE);
state_save_register_global_pointer(machine, TC0480SCP_ram, TC0480SCP_RAM_SIZE/2);
@@ -3194,11 +3116,7 @@ void TC0480SCP_vh_start(running_machine *machine, int gfxnum,int pixels,int x_of
assert(gfx_index != MAX_GFX_ELEMENTS);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[gfx_index] = allocgfx(machine, &TC0480SCP_charlayout);
-
- /* set the color information */
- machine->gfx[gfx_index]->total_colors = 64;
-
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &TC0480SCP_charlayout, (UINT8 *)TC0480SCP_char_ram, 64, 0);
TC0480SCP_tx_gfx = gfx_index;
/* use the given gfx set for bg tiles */
@@ -3308,7 +3226,7 @@ READ16_HANDLER( TC0480SCP_word_r )
return TC0480SCP_ram[offset];
}
-static void TC0480SCP_word_write(offs_t offset,UINT16 data,UINT32 mem_mask)
+static void TC0480SCP_word_write(const address_space *space,offs_t offset,UINT16 data,UINT32 mem_mask)
{
COMBINE_DATA(&TC0480SCP_ram[offset]);
@@ -3329,8 +3247,7 @@ static void TC0480SCP_word_write(offs_t offset,UINT16 data,UINT32 mem_mask)
}
else if (offset <= 0x7fff)
{
- TC0480SCP_char_dirty[(offset - 0x7000) / 16] = 1;
- TC0480SCP_chars_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[TC0480SCP_tx_gfx], (offset - 0x7000) / 16);
}
}
else
@@ -3350,15 +3267,14 @@ static void TC0480SCP_word_write(offs_t offset,UINT16 data,UINT32 mem_mask)
}
else if (offset <= 0x7fff)
{
- TC0480SCP_char_dirty[(offset - 0x7000) / 16] = 1;
- TC0480SCP_chars_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[TC0480SCP_tx_gfx], (offset - 0x7000) / 16);
}
}
}
WRITE16_HANDLER( TC0480SCP_word_w )
{
- TC0480SCP_word_write(offset,data,mem_mask);
+ TC0480SCP_word_write(space,offset,data,mem_mask);
}
READ16_HANDLER( TC0480SCP_ctrl_word_r )
@@ -3523,28 +3439,6 @@ void TC0480SCP_tilemap_update(running_machine *machine)
}
}
}
-
- /* Decode any characters that have changed */
- if (TC0480SCP_chars_dirty)
- {
- int tile_index;
-
- for (tile_index = 0;tile_index < 64*64;tile_index++)
- {
- int attr = TC0480SCP_tx_ram[tile_index];
- if (TC0480SCP_char_dirty[attr & 0xff])
- tilemap_mark_tile_dirty(TC0480SCP_tilemap[4][TC0480SCP_dblwidth],tile_index);
- }
-
- for (j = 0;j < TC0480SCP_TOTAL_CHARS;j++)
- {
- if (TC0480SCP_char_dirty[j])
- decodechar(machine->gfx[TC0480SCP_tx_gfx],j,
- (UINT8 *)TC0480SCP_char_ram);
- TC0480SCP_char_dirty[j] = 0;
- }
- TC0480SCP_chars_dirty = 0;
- }
}
diff --git a/src/mame/video/taitojc.c b/src/mame/video/taitojc.c
index d568de64522..7e66b920379 100644
--- a/src/mame/video/taitojc.c
+++ b/src/mame/video/taitojc.c
@@ -22,10 +22,8 @@ struct _poly_extra_data
static int taitojc_gfx_index;
-static UINT8 *taitojc_dirty_map;
static UINT32 *taitojc_char_ram;
static UINT32 *taitojc_tile_ram;
-static int taitojc_char_dirty;
static tilemap *taitojc_tilemap;
static poly_manager *poly;
@@ -51,24 +49,6 @@ static TILE_GET_INFO( taitojc_tile_info )
SET_TILE_INFO(taitojc_gfx_index, tile, color, 0);
}
-static void taitojc_tile_update(running_machine *machine)
-{
- int i;
- if (taitojc_char_dirty)
- {
- for (i=0; i < TAITOJC_NUM_TILES; i++)
- {
- if (taitojc_dirty_map[i])
- {
- taitojc_dirty_map[i] = 0;
- decodechar(machine->gfx[taitojc_gfx_index], i, (UINT8 *)taitojc_char_ram);
- }
- }
- tilemap_mark_all_tiles_dirty(taitojc_tilemap);
- taitojc_char_dirty = 0;
- }
-}
-
READ32_HANDLER(taitojc_tile_r)
{
return taitojc_tile_ram[offset];
@@ -88,8 +68,7 @@ WRITE32_HANDLER(taitojc_tile_w)
WRITE32_HANDLER(taitojc_char_w)
{
COMBINE_DATA(taitojc_char_ram + offset);
- taitojc_dirty_map[offset/32] = 1;
- taitojc_char_dirty = 1;
+ gfx_element_mark_dirty(space->machine->gfx[taitojc_gfx_index], offset/32);
}
// Object data format:
@@ -196,8 +175,6 @@ VIDEO_START( taitojc )
{
int width, height;
- taitojc_char_dirty = 1;
-
poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
add_exit_callback(machine, taitojc_exit);
@@ -209,7 +186,6 @@ VIDEO_START( taitojc )
assert(taitojc_gfx_index != MAX_GFX_ELEMENTS);
taitojc_tilemap = tilemap_create(machine, taitojc_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
- taitojc_dirty_map = auto_malloc(TAITOJC_NUM_TILES);
tilemap_set_transparent_pen(taitojc_tilemap, 0);
@@ -220,10 +196,7 @@ VIDEO_START( taitojc )
memset(taitojc_tile_ram, 0, 0x4000);
/* create the char set (gfx will then be updated dynamically from RAM) */
- machine->gfx[taitojc_gfx_index] = allocgfx(machine, &taitojc_char_layout);
-
- /* set the color information */
- machine->gfx[taitojc_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[taitojc_gfx_index] = gfx_element_alloc(machine, &taitojc_char_layout, (UINT8 *)taitojc_char_ram, machine->config->total_colors / 16, 0);
taitojc_texture = auto_malloc(0x400000);
@@ -280,7 +253,6 @@ VIDEO_UPDATE( taitojc )
}
}
- taitojc_tile_update(screen->machine);
tilemap_draw(bitmap, cliprect, taitojc_tilemap, 0,0);
#if 0
diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c
index 294b44c208c..5158ba191bb 100644
--- a/src/mame/video/taitosj.c
+++ b/src/mame/video/taitosj.c
@@ -36,8 +36,6 @@ static bitmap_t *taitosj_layer_bitmap[3];
static bitmap_t *sprite_sprite_collbitmap1,*sprite_sprite_collbitmap2;
static bitmap_t *sprite_layer_collbitmap1;
static bitmap_t *sprite_layer_collbitmap2[3];
-static UINT8 dirtycharacter1[256],dirtycharacter2[256];
-static UINT8 dirtysprite1[64],dirtysprite2[64];
static const int layer_enable_mask[3] = { 0x10, 0x20, 0x40 };
@@ -154,15 +152,6 @@ static void set_pens(running_machine *machine)
}
}
-
-static STATE_POSTLOAD( taitosj_postload )
-{
- memset(dirtycharacter1, 1, sizeof(dirtycharacter1));
- memset(dirtycharacter2, 1, sizeof(dirtycharacter2));
- memset(dirtysprite1, 1, sizeof(dirtysprite1));
- memset(dirtysprite2, 1, sizeof(dirtysprite2));
-}
-
/***************************************************************************
Start the video hardware emulation.
@@ -214,14 +203,12 @@ VIDEO_START( taitosj )
sprite_sprite_collbitmap1 = auto_bitmap_alloc(32,32,video_screen_get_format(machine->primary_screen));
sprite_sprite_collbitmap2 = auto_bitmap_alloc(32,32,video_screen_get_format(machine->primary_screen));
- memset(dirtycharacter1, 1, sizeof(dirtycharacter1));
- memset(dirtycharacter2, 1, sizeof(dirtycharacter2));
- memset(dirtysprite1, 1, sizeof(dirtysprite1));
- memset(dirtysprite2, 1, sizeof(dirtysprite2));
+ gfx_element_set_source(machine->gfx[0], taitosj_characterram);
+ gfx_element_set_source(machine->gfx[1], taitosj_characterram);
+ gfx_element_set_source(machine->gfx[2], taitosj_characterram + 0x1800);
+ gfx_element_set_source(machine->gfx[3], taitosj_characterram + 0x1800);
compute_draw_order(machine);
-
- state_save_register_postload(machine, taitosj_postload, NULL);
}
@@ -253,13 +240,13 @@ WRITE8_HANDLER( taitosj_characterram_w )
{
if (offset < 0x1800)
{
- dirtycharacter1[(offset / 8) & 0xff] = 1;
- dirtysprite1[(offset / 32) & 0x3f] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
+ gfx_element_mark_dirty(space->machine->gfx[1], (offset / 32) & 0x3f);
}
else
{
- dirtycharacter2[(offset / 8) & 0xff] = 1;
- dirtysprite2[(offset / 32) & 0x3f] = 1;
+ gfx_element_mark_dirty(space->machine->gfx[2], (offset / 8) & 0xff);
+ gfx_element_mark_dirty(space->machine->gfx[3], (offset / 32) & 0x3f);
}
taitosj_characterram[offset] = data;
@@ -537,44 +524,6 @@ static void check_sprite_layer_collision(running_machine *machine, int *sprites_
}
-static void decode_modified(running_machine *machine)
-{
- offs_t offs;
-
- /* decode modified characters */
- for (offs = 0;offs < 256;offs++)
- {
- if (dirtycharacter1[offs] == 1)
- {
- decodechar(machine->gfx[0], offs, taitosj_characterram);
- dirtycharacter1[offs] = 0;
- }
-
- if (dirtycharacter2[offs] == 1)
- {
- decodechar(machine->gfx[2], offs, taitosj_characterram + 0x1800);
- dirtycharacter2[offs] = 0;
- }
- }
-
- /* decode modified sprites */
- for (offs = 0;offs < 64;offs++)
- {
- if (dirtysprite1[offs] == 1)
- {
- decodechar(machine->gfx[1], offs, taitosj_characterram);
- dirtysprite1[offs] = 0;
- }
-
- if (dirtysprite2[offs] == 1)
- {
- decodechar(machine->gfx[3], offs, taitosj_characterram + 0x1800);
- dirtysprite2[offs] = 0;
- }
- }
-}
-
-
static void draw_layers(running_machine *machine)
{
offs_t offs;
@@ -802,8 +751,6 @@ static int video_update_common(running_machine *machine, bitmap_t *bitmap,
set_pens(machine);
- decode_modified(machine);
-
draw_layers(machine);
calculate_sprite_areas(machine, sprites_on, sprite_areas);
diff --git a/src/mame/video/tatsumi.c b/src/mame/video/tatsumi.c
index dfc5346a6ae..688c915d5fa 100644
--- a/src/mame/video/tatsumi.c
+++ b/src/mame/video/tatsumi.c
@@ -48,7 +48,7 @@ WRITE16_HANDLER(roundup5_vram_w)
offset=offset%0xc000;
- decodechar(space->machine->gfx[1],offset/0x10,(UINT8 *)roundup5_vram);
+ gfx_element_mark_dirty(space->machine->gfx[1],offset/0x10);
}
@@ -207,6 +207,8 @@ VIDEO_START( roundup5 )
memset(shadow_pen_array, 0, 8192);
tilemap_set_transparent_pen(tx_layer,0);
+
+ gfx_element_set_source(machine->gfx[1], (UINT8 *)roundup5_vram);
}
VIDEO_START( cyclwarr )
@@ -271,7 +273,7 @@ INLINE void roundupt_drawgfxzoomrotate( running_machine *machine,
{
const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
const UINT8 *shadow_pens = shadow_pen_array + (gfx->color_granularity * (color % gfx->total_colors));
- int source_base = (code % gfx->total_elements) * gfx->height;
+ const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int block_size = 8 * scalex;
int sprite_screen_height = ((ssy&0xffff)+block_size)>>16;
@@ -397,7 +399,7 @@ INLINE void roundupt_drawgfxzoomrotate( running_machine *machine,
int x, x_index = x_index_base;
for( x=sx; x<ex; x++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+((cy>>16))) * gfx->line_modulo;
+ const UINT8 *source = code_base + (cy>>16) * gfx->line_modulo;
int c = source[(cx >> 16)];
if( c != transparent_color )
{
@@ -421,7 +423,7 @@ INLINE void roundupt_drawgfxzoomrotate( running_machine *machine,
{
for( y=sy; y<ey; y++ )
{
- UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
+ const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
UINT8 *priority_dest = BITMAP_ADDR8(dest_bmp, y, 0);
diff --git a/src/mame/video/tceptor.c b/src/mame/video/tceptor.c
index e6b10db560e..f4bd6efaa51 100644
--- a/src/mame/video/tceptor.c
+++ b/src/mame/video/tceptor.c
@@ -276,23 +276,13 @@ static void decode_bg(running_machine *machine, const char * region)
free(buffer);
/* decode the graphics */
- machine->gfx[gfx_index] = allocgfx(machine, &bg_layout);
- decodegfx(machine->gfx[gfx_index], memory_region(machine, region), 0, machine->gfx[gfx_index]->total_elements);
-
- /* set the color information */
- machine->gfx[gfx_index]->color_base = 2048;
- machine->gfx[gfx_index]->total_colors = 64;
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, &bg_layout, memory_region(machine, region), 64, 2048);
}
static void decode_sprite(running_machine *machine, int gfx_index, const gfx_layout *layout, const void *data)
{
/* decode the graphics */
- machine->gfx[gfx_index] = allocgfx(machine, layout);
- decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements);
-
- /* set the color information */
- machine->gfx[gfx_index]->color_base = 1024;
- machine->gfx[gfx_index]->total_colors = 64;
+ machine->gfx[gfx_index] = gfx_element_alloc(machine, layout, data, 64, 1024);
}
// fix sprite order
@@ -320,7 +310,7 @@ static void decode_sprite16(running_machine *machine, const char * region)
UINT8 *dst;
int i, y;
- dst = malloc_or_die(len);
+ dst = auto_malloc(len);
for (i = 0; i < len / (4*4*16); i++)
for (y = 0; y < 16; y++)
@@ -340,8 +330,6 @@ static void decode_sprite16(running_machine *machine, const char * region)
}
decode_sprite(machine, sprite16, &spr16_layout, dst);
-
- free(dst);
}
// fix sprite order
@@ -375,7 +363,7 @@ static void decode_sprite32(running_machine *machine, const char * region)
UINT8 *dst;
int i;
- dst = malloc_or_die(len);
+ dst = auto_malloc(len);
memset(dst, 0, len);
@@ -391,8 +379,6 @@ static void decode_sprite32(running_machine *machine, const char * region)
}
decode_sprite(machine, sprite32, &spr32_layout, dst);
-
- free(dst);
}
VIDEO_START( tceptor )
diff --git a/src/mame/video/tecmo16.c b/src/mame/video/tecmo16.c
index dc3398f0d35..1dc68bcb2ab 100644
--- a/src/mame/video/tecmo16.c
+++ b/src/mame/video/tecmo16.c
@@ -411,31 +411,28 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap_bg, bitmap_t
sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8);
sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8);
}
- pdrawgfx(bitmap,machine->gfx[2],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
code + layout[y][x],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx,flipy,
sx,sy,
- cliprect,TRANSPARENCY_PEN_RAW,0,
- priority_mask);
+ priority_bitmap, priority_mask,0);
/* wrap around x */
- pdrawgfx(bitmap,machine->gfx[2],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
code + layout[y][x],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx,flipy,
sx-512,sy,
- cliprect,TRANSPARENCY_PEN_RAW,0,
- priority_mask);
+ priority_bitmap, priority_mask,0);
/* wrap around x */
- pdrawgfx(bitmap,machine->gfx[2],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
code + layout[y][x],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx,flipy,
sx+512,sy,
- cliprect,TRANSPARENCY_PEN_RAW,0,
- priority_mask);
+ priority_bitmap, priority_mask,0);
}
}
}
@@ -457,31 +454,28 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap_bg, bitmap_t
sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8);
sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8);
}
- pdrawgfx(bitmap,machine->gfx[2],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
code + layout[y][x],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx,flipy,
sx,sy,
- cliprect,TRANSPARENCY_PEN_RAW,0,
- priority_mask);
+ priority_bitmap, priority_mask,0);
/* wrap around x */
- pdrawgfx(bitmap,machine->gfx[2],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
code + layout[y][x],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx,flipy,
sx-512,sy,
- cliprect,TRANSPARENCY_PEN_RAW,0,
- priority_mask);
+ priority_bitmap, priority_mask,0);
/* wrap around x */
- pdrawgfx(bitmap,machine->gfx[2],
+ pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
code + layout[y][x],
machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
flipx,flipy,
sx+512,sy,
- cliprect,TRANSPARENCY_PEN_RAW,0,
- priority_mask);
+ priority_bitmap, priority_mask,0);
}
}
}
diff --git a/src/mame/video/thunderx.c b/src/mame/video/thunderx.c
index bb55e70fcc2..690fd403a5a 100644
--- a/src/mame/video/thunderx.c
+++ b/src/mame/video/thunderx.c
@@ -86,6 +86,6 @@ VIDEO_UPDATE( scontra )
}
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
diff --git a/src/mame/video/tiamc1.c b/src/mame/video/tiamc1.c
index 0b5efc58eff..edfa35c5b0c 100644
--- a/src/mame/video/tiamc1.c
+++ b/src/mame/video/tiamc1.c
@@ -11,12 +11,12 @@
#include "includes/tiamc1.h"
-UINT8 *tiamc1_tileram;
-UINT8 *tiamc1_charram;
-UINT8 *tiamc1_spriteram_x;
-UINT8 *tiamc1_spriteram_y;
-UINT8 *tiamc1_spriteram_a;
-UINT8 *tiamc1_spriteram_n;
+static UINT8 *tiamc1_tileram;
+static UINT8 *tiamc1_charram;
+static UINT8 *tiamc1_spriteram_x;
+static UINT8 *tiamc1_spriteram_y;
+static UINT8 *tiamc1_spriteram_a;
+static UINT8 *tiamc1_spriteram_n;
static UINT8 tiamc1_layers_ctrl;
static UINT8 tiamc1_bg_vshift;
static UINT8 tiamc1_bg_hshift;
@@ -35,15 +35,15 @@ WRITE8_HANDLER( tiamc1_videoram_w )
if(!(tiamc1_layers_ctrl & 16))
tiamc1_charram[offset + 0x1800] = data;
- if((tiamc1_layers_ctrl & 30) ^ 0xff)
- tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
+ if ((tiamc1_layers_ctrl & (16|8|4|2)) != (16|8|4|2))
+ gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
if(!(tiamc1_layers_ctrl & 1)) {
tiamc1_tileram[offset] = data;
- if (offset >= 1024)
- tilemap_mark_tile_dirty(bg_tilemap1, offset);
+ if (offset < 1024)
+ tilemap_mark_tile_dirty(bg_tilemap1, offset & 0x3ff);
else
- tilemap_mark_tile_dirty(bg_tilemap2, offset);
+ tilemap_mark_tile_dirty(bg_tilemap2, offset & 0x3ff);
}
}
@@ -122,24 +122,31 @@ PALETTE_INIT( tiamc1 )
static TILE_GET_INFO( get_bg1_tile_info )
{
- int code = tiamc1_tileram[tile_index];
-
- decodechar(machine->gfx[0], code, tiamc1_charram);
-
- SET_TILE_INFO(0, code, 0, 0);
+ SET_TILE_INFO(0, tiamc1_tileram[tile_index], 0, 0);
}
static TILE_GET_INFO( get_bg2_tile_info )
{
- int code = tiamc1_tileram[tile_index + 1024];
-
- decodechar(machine->gfx[0], code, tiamc1_charram);
-
- SET_TILE_INFO(0, code, 0, 0);
+ SET_TILE_INFO(0, tiamc1_tileram[tile_index + 1024], 0, 0);
}
VIDEO_START( tiamc1 )
{
+ UINT8 *video_ram;
+
+ video_ram = auto_malloc(0x3040);
+ memset(video_ram, 0, 0x3040);
+
+ tiamc1_charram = video_ram + 0x0800; /* Ram is banked */
+ tiamc1_tileram = video_ram + 0x0000;
+
+ tiamc1_spriteram_y = video_ram + 0x3000;
+ tiamc1_spriteram_x = video_ram + 0x3010;
+ tiamc1_spriteram_n = video_ram + 0x3020;
+ tiamc1_spriteram_a = video_ram + 0x3030;
+
+ state_save_register_global_pointer(machine, video_ram, 0x3040);
+
bg_tilemap1 = tilemap_create(machine, get_bg1_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
@@ -152,6 +159,8 @@ VIDEO_START( tiamc1 )
state_save_register_global(machine, tiamc1_layers_ctrl);
state_save_register_global(machine, tiamc1_bg_vshift);
state_save_register_global(machine, tiamc1_bg_hshift);
+
+ gfx_element_set_source(machine->gfx[0], tiamc1_charram);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
diff --git a/src/mame/video/tmnt.c b/src/mame/video/tmnt.c
index ac0bf01032d..950cbd3a42b 100644
--- a/src/mame/video/tmnt.c
+++ b/src/mame/video/tmnt.c
@@ -590,9 +590,9 @@ VIDEO_UPDATE( mia )
K052109_tilemap_update();
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
- if ((priorityflag & 1) == 1) K051960_sprites_draw(bitmap,cliprect,0,0);
+ if ((priorityflag & 1) == 1) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
- if ((priorityflag & 1) == 0) K051960_sprites_draw(bitmap,cliprect,0,0);
+ if ((priorityflag & 1) == 0) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
return 0;
}
@@ -602,9 +602,9 @@ VIDEO_UPDATE( tmnt )
K052109_tilemap_update();
tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
- if ((priorityflag & 1) == 1) K051960_sprites_draw(bitmap,cliprect,0,0);
+ if ((priorityflag & 1) == 1) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
- if ((priorityflag & 1) == 0) K051960_sprites_draw(bitmap,cliprect,0,0);
+ if ((priorityflag & 1) == 0) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
return 0;
}
@@ -634,7 +634,7 @@ VIDEO_UPDATE( punkshot )
tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
@@ -664,7 +664,7 @@ VIDEO_UPDATE( lgtnfght )
tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
- K053245_sprites_draw(0, bitmap,cliprect);
+ K053245_sprites_draw(screen->machine, 0, bitmap,cliprect);
return 0;
}
@@ -724,7 +724,7 @@ VIDEO_UPDATE( glfgreat )
glfgreat_pixel = *BITMAP_ADDR16(bitmap,0x80,0x105);
}
- K053245_sprites_draw(0, bitmap,cliprect);
+ K053245_sprites_draw(screen->machine, 0, bitmap,cliprect);
return 0;
}
@@ -804,7 +804,7 @@ VIDEO_UPDATE( thndrx2 )
tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
- K051960_sprites_draw(bitmap,cliprect,-1,-1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
return 0;
}
diff --git a/src/mame/video/toaplan1.c b/src/mame/video/toaplan1.c
index 7201df40cac..15b9ff315aa 100644
--- a/src/mame/video/toaplan1.c
+++ b/src/mame/video/toaplan1.c
@@ -948,7 +948,7 @@ static void toaplan1_draw_sprite_custom(bitmap_t *dest_bmp,const gfx_element *gf
const rectangle *clip,int priority)
{
int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
- UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
+ const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
@@ -1018,7 +1018,7 @@ static void toaplan1_draw_sprite_custom(bitmap_t *dest_bmp,const gfx_element *gf
for( y=sy; y<ey; y++ )
{
- UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
+ const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
diff --git a/src/mame/video/toaplan2.c b/src/mame/video/toaplan2.c
index 22acbc43bfc..a4ece96fd6c 100644
--- a/src/mame/video/toaplan2.c
+++ b/src/mame/video/toaplan2.c
@@ -558,6 +558,9 @@ VIDEO_START( truxton2_0 )
toaplan2_vram_alloc(0);
truxton2_create_tilemaps_0(machine);
+ if (machine->gfx[2]->srcdata == NULL)
+ gfx_element_set_source(machine->gfx[2], (UINT8 *)toaplan2_tx_gfxram16);
+
if(!strcmp(machine->gamedrv->name,"fixeighb"))
{
xoffset[0]=-26;
@@ -594,6 +597,8 @@ VIDEO_START( batrider_0 )
raizing_tx_gfxram16 = auto_malloc(RAIZING_TX_GFXRAM_SIZE);
memset(raizing_tx_gfxram16,0,RAIZING_TX_GFXRAM_SIZE);
state_save_register_global_pointer(machine, raizing_tx_gfxram16, RAIZING_TX_GFXRAM_SIZE/2);
+
+ gfx_element_set_source(machine->gfx[2], (UINT8 *)raizing_tx_gfxram16);
toaplan2_vram_alloc(0);
spriteram16_n[0] = spriteram16_new[0];
@@ -702,15 +707,12 @@ WRITE16_HANDLER( toaplan2_tx_gfxram16_w )
/*** Dynamic GFX decoding for Truxton 2 / FixEight ***/
UINT16 oldword = toaplan2_tx_gfxram16[offset];
- UINT8 *toaplan2_tx_gfxram = (UINT8 *)(toaplan2_tx_gfxram16);
if (oldword != data)
{
int code = offset/32;
COMBINE_DATA(&toaplan2_tx_gfxram16[offset]);
- decodechar(space->machine->gfx[2], code, toaplan2_tx_gfxram);
-
- tilemap_mark_all_tiles_dirty(tx_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[2], code);
}
}
@@ -738,7 +740,6 @@ WRITE16_HANDLER( batrider_textdata_decode )
/*** Only done once during start-up ***/
int code;
- UINT8 *raizing_tx_gfxram = (UINT8 *)raizing_tx_gfxram16;
UINT16 *dest = (UINT16 *)raizing_tx_gfxram16;
memcpy(dest, toaplan2_txvideoram16, toaplan2_tx_vram_size);
@@ -749,10 +750,9 @@ WRITE16_HANDLER( batrider_textdata_decode )
dest += (toaplan2_tx_offs_vram_size/2);
memcpy(dest, toaplan2_txscrollram16, toaplan2_tx_scroll_vram_size);
- /* Decode text characters */
+ /* Decode text characters; force them to update immediately */
for (code = 0; code < 1024; code++)
- decodechar (space->machine->gfx[2], code, raizing_tx_gfxram);
- tilemap_mark_all_tiles_dirty(tx_tilemap);
+ gfx_element_decode(space->machine->gfx[2], code);
}
WRITE16_HANDLER( batrider_objectbank_w )
diff --git a/src/mame/video/toypop.c b/src/mame/video/toypop.c
index 1b39748dbaf..3aadf6cb0ac 100644
--- a/src/mame/video/toypop.c
+++ b/src/mame/video/toypop.c
@@ -175,7 +175,6 @@ WRITE16_HANDLER( toypop_merged_background_w )
static void draw_background(bitmap_t *bitmap)
{
int offs, x, y;
- UINT16 scanline[288];
pen_t pen_base = 0x300 + 0x10*palettebank;
// copy the background image from RAM (0x190200-0x19FDFF) to bitmap
@@ -184,6 +183,7 @@ static void draw_background(bitmap_t *bitmap)
offs = 0xFDFE/2;
for (y = 0; y < 224; y++)
{
+ UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0);
for (x = 0; x < 288; x+=2)
{
UINT16 data = toypop_bg_image[offs];
@@ -191,7 +191,6 @@ static void draw_background(bitmap_t *bitmap)
scanline[x+1] = pen_base | (data >> 8);
offs--;
}
- draw_scanline16(bitmap, 0, y, 288, scanline, NULL, -1);
}
}
else
@@ -199,6 +198,7 @@ static void draw_background(bitmap_t *bitmap)
offs = 0x200/2;
for (y = 0; y < 224; y++)
{
+ UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0);
for (x = 0; x < 288; x+=2)
{
UINT16 data = toypop_bg_image[offs];
@@ -206,7 +206,6 @@ static void draw_background(bitmap_t *bitmap)
scanline[x+1] = pen_base | (data & 0x0f);
offs++;
}
- draw_scanline16(bitmap, 0, y, 288, scanline, NULL, -1);
}
}
}
diff --git a/src/mame/video/tryout.c b/src/mame/video/tryout.c
index e11814f2b08..ec32afafb05 100644
--- a/src/mame/video/tryout.c
+++ b/src/mame/video/tryout.c
@@ -140,8 +140,7 @@ WRITE8_HANDLER( tryout_vram_w )
break;
}
- decodechar(space->machine->gfx[2],(offset-0x400/64)&0x7f,tryout_vram_gfx);
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[2], (offset-0x400/64)&0x7f);
}
WRITE8_HANDLER( tryout_vram_bankswitch_w )
@@ -179,6 +178,8 @@ VIDEO_START( tryout )
tryout_vram=auto_malloc(8 * 0x800);
tryout_vram_gfx=auto_malloc(0x6000);
+ gfx_element_set_source(machine->gfx[2], tryout_vram_gfx);
+
tilemap_set_transparent_pen(fg_tilemap,0);
}
diff --git a/src/mame/video/tunhunt.c b/src/mame/video/tunhunt.c
index 56e64964ff3..5874ee12b02 100644
--- a/src/mame/video/tunhunt.c
+++ b/src/mame/video/tunhunt.c
@@ -251,17 +251,15 @@ static void draw_motion_object(bitmap_t *bitmap, const rectangle *cliprect)
}
scalex = (1<<16);
- copyrozbitmap(
- bitmap,tmpbitmap,
+ copyrozbitmap_trans(
+ bitmap,cliprect,tmpbitmap,
-x0*scalex,/* startx */
-y0*scaley,/* starty */
scalex,/* incxx */
0,0,/* incxy,incyx */
scaley,/* incyy */
0, /* no wraparound */
- cliprect,
- TRANSPARENCY_PEN,0,
- 0 /* priority */
+ 0
);
}
diff --git a/src/mame/video/ultraman.c b/src/mame/video/ultraman.c
index a5877b1e462..2f2f9a58190 100644
--- a/src/mame/video/ultraman.c
+++ b/src/mame/video/ultraman.c
@@ -128,8 +128,8 @@ VIDEO_UPDATE( ultraman )
{
K051316_zoom_draw_2(bitmap,cliprect,0,0);
K051316_zoom_draw_1(bitmap,cliprect,0,0);
- K051960_sprites_draw(bitmap,cliprect,0,0);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
K051316_zoom_draw_0(bitmap,cliprect,0,0);
- K051960_sprites_draw(bitmap,cliprect,1,1);
+ K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
return 0;
}
diff --git a/src/mame/video/usgames.c b/src/mame/video/usgames.c
index 313179814e8..7f03e145262 100644
--- a/src/mame/video/usgames.c
+++ b/src/mame/video/usgames.c
@@ -49,6 +49,7 @@ static TILE_GET_INFO( get_usgames_tile_info )
VIDEO_START(usgames)
{
usgames_tilemap = tilemap_create(machine, get_usgames_tile_info,tilemap_scan_rows, 8, 8,64,32);
+ gfx_element_set_source(machine->gfx[0], usgames_charram);
}
@@ -61,10 +62,7 @@ WRITE8_HANDLER( usgames_videoram_w )
WRITE8_HANDLER( usgames_charram_w )
{
usgames_charram[offset] = data;
-
- decodechar(space->machine->gfx[0], offset/8, usgames_charram);
-
- tilemap_mark_all_tiles_dirty(usgames_tilemap);
+ gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
}
diff --git a/src/mame/video/victory.c b/src/mame/video/victory.c
index 57db8026caa..705ee9cbc01 100644
--- a/src/mame/video/victory.c
+++ b/src/mame/video/victory.c
@@ -1113,10 +1113,10 @@ VIDEO_UPDATE( victory )
/* blend the bitmaps and do collision detection */
for (y = 0; y < 256; y++)
{
+ UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0);
UINT8 sy = scrolly + y;
UINT8 *fg = &fgbitmap[y * 256];
UINT8 *bg = &bgbitmap[sy * 256];
- UINT8 scanline[256];
/* do the blending */
for (x = 0; x < 256; x++)
@@ -1127,9 +1127,6 @@ VIDEO_UPDATE( victory )
if (fpix && (bpix & bgcollmask) && count++ < 128)
timer_set(screen->machine, video_screen_get_time_until_pos(screen, y, x), NULL, x | (y << 8), bgcoll_irq_callback);
}
-
- /* draw the scanline */
- draw_scanline8(bitmap, 0, y, 256, scanline, NULL, -1);
}
return 0;
diff --git a/src/mame/video/wecleman.c b/src/mame/video/wecleman.c
index 7297cb0f889..4cb72827d96 100644
--- a/src/mame/video/wecleman.c
+++ b/src/mame/video/wecleman.c
@@ -585,7 +585,7 @@ static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const
};
- UINT8 *src_ptr;
+ const UINT8 *src_ptr;
const pen_t *pal_ptr, *rgb_ptr;
int scrollx, sy, sx;
@@ -614,7 +614,6 @@ static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const
else if (priority == 0x04)
{
// draw road
- UINT8 *src_base = machine->gfx[1]->gfxdata;
pen_t road_rgb[48];
for (i=0; i<48; i++)
@@ -633,7 +632,14 @@ static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const
if ((road>>8) != 0x04) continue;
road &= YMASK;
- src_ptr = src_base + (road << 9);
+ src_ptr = gfx_element_get_data(machine->gfx[1], (road << 3));
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 1);
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 2);
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 3);
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 4);
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 5);
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 6);
+ gfx_element_get_data(machine->gfx[1], (road << 3) + 7);
mdy = ((road * MIDCURB_DY) >> 8) * bitmap->rowpixels;
tdy = ((road * TOPCURB_DY) >> 8) * bitmap->rowpixels;
@@ -680,7 +686,7 @@ static void draw_cloud(running_machine *machine, bitmap_t *bitmap,
int tmw_l2, int tmh_l2, // tilemap width and height in log(2)
int alpha, int pal_offset ) // alpha(0-3f), # of color codes to shift
{
- UINT8 *src_base, *src_ptr;
+ const UINT8 *src_ptr;
UINT16 *tmap_ptr;
UINT32 *dst_base, *dst_ptr;
const pen_t *pal_base, *pal_ptr;
@@ -706,8 +712,6 @@ static void draw_cloud(running_machine *machine, bitmap_t *bitmap,
tmskipy = scrolly / tileh;
dy = -(scrolly & (tileh-1));
- src_base = gfx->gfxdata;
-
dst_base = BITMAP_ADDR32(bitmap, y0+dy, x0+dx);
pal_base = machine->pens + pal_offset * gfx->color_granularity;
@@ -730,7 +734,7 @@ static void draw_cloud(running_machine *machine, bitmap_t *bitmap,
// Wec Le Mans specific: decodes tile color in EAX
UINT16 tile_color = ((tiledata >> 5) & 0x78) + (tiledata >> 12);
- src_ptr = src_base + tile_index * gfx->char_modulo;
+ src_ptr = gfx_element_get_data(gfx, tile_index);
pal_ptr = pal_base + tile_color * gfx->color_granularity;
dst_ptr = dst_base + j * tilew;
diff --git a/src/mame/video/wrally.c b/src/mame/video/wrally.c
index 3742b9462b9..45454911797 100644
--- a/src/mame/video/wrally.c
+++ b/src/mame/video/wrally.c
@@ -137,7 +137,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
cliprect,TRANSPARENCY_PEN,0);
} else {
/* get a pointer to the current sprite's gfx data */
- UINT8 *gfx_src = gfx->gfxdata + (number % gfx->total_elements)*gfx->char_modulo;
+ const UINT8 *gfx_src = gfx_element_get_data(gfx, number % gfx->total_elements);
for (py = 0; py < gfx->height; py++){
/* get a pointer to the current line in the screen bitmap */
diff --git a/src/mame/video/xexex.c b/src/mame/video/xexex.c
index 9cd38d96f02..dcee10df95b 100644
--- a/src/mame/video/xexex.c
+++ b/src/mame/video/xexex.c
@@ -134,7 +134,7 @@ VIDEO_UPDATE( xexex )
if (alpha > 0)
{
- K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, (alpha >= 255) ? 0 : TILEMAP_DRAW_ALPHA, 0);
+ K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, TILEMAP_DRAW_ALPHA(alpha), 0);
}
}
diff --git a/src/mame/video/xmen.c b/src/mame/video/xmen.c
index 422dc5acd90..acd0e96ea80 100644
--- a/src/mame/video/xmen.c
+++ b/src/mame/video/xmen.c
@@ -124,7 +124,8 @@ VIDEO_UPDATE( xmen )
tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
- pdrawgfx_shadow_lowpri = 1; /* fix shadows of boulders in front of feet */
+/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
+ pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
K053247_sprites_draw(screen->machine, bitmap,cliprect);
return 0;
}
@@ -250,7 +251,8 @@ VIDEO_EOF( xmen6p )
tilemap_draw(renderbitmap,&cliprect,K052109_tilemap[layer[1]],0,2);
tilemap_draw(renderbitmap,&cliprect,K052109_tilemap[layer[2]],0,4);
- pdrawgfx_shadow_lowpri = 1; /* fix shadows of boulders in front of feet */
+/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
+ pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
K053247_sprites_draw(machine, renderbitmap,&cliprect);
}
diff --git a/src/mame/video/ygv608.c b/src/mame/video/ygv608.c
index f0ffc353407..c877c4079c9 100644
--- a/src/mame/video/ygv608.c
+++ b/src/mame/video/ygv608.c
@@ -882,16 +882,14 @@ VIDEO_UPDATE( ygv608 )
cos_theta = (double)ygv608.dx / (double)0x10000;
if( ygv608.regs.s.zron )
- copyrozbitmap( bitmap, work_bitmap,
+ copyrozbitmap( bitmap, cliprect, work_bitmap,
( visarea->min_x << 16 ) +
ygv608.ax + 0x10000 * r *
( -sin( alpha ) * cos_theta + cos( alpha ) * sin_theta ),
( visarea->min_y << 16 ) +
ygv608.ay + 0x10000 * r *
( cos( alpha ) * cos_theta + sin( alpha ) * sin_theta ),
- ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0,
- cliprect,
- TRANSPARENCY_NONE, 0, 0 );
+ ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0);
else
#endif
copybitmap( bitmap, work_bitmap, 0, 0, 0, 0, cliprect);
@@ -909,12 +907,11 @@ VIDEO_UPDATE( ygv608 )
#ifdef _ENABLE_ROTATE_ZOOM
if( ygv608.regs.s.zron )
- copyrozbitmap( bitmap, work_bitmap,
+ copyrozbitmap_trans( bitmap, cliprect, work_bitmap,
ygv608.ax, // + ( visarea->min_x << 16 ),
ygv608.ay, // + ( visarea->min_y << 16 ),
ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0,
- cliprect,
- TRANSPARENCY_PEN, 0, 0 );
+ 0 );
else
#endif
copybitmap_trans( bitmap, work_bitmap, 0, 0, 0, 0, cliprect, 0 );
diff --git a/src/mame/video/zac2650.c b/src/mame/video/zac2650.c
index 7c3eb92afc2..c0cf786a931 100644
--- a/src/mame/video/zac2650.c
+++ b/src/mame/video/zac2650.c
@@ -35,6 +35,13 @@ READ8_HANDLER( zac_s2636_r )
else return CollisionSprite;
}
+WRITE8_HANDLER( zac_s2636_w )
+{
+ zac2650_s2636_0_ram[offset] = data;
+ gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
+ gfx_element_mark_dirty(space->machine->gfx[2], offset/8);
+}
+
READ8_HANDLER( tinvader_port_0_r )
{
return input_port_read(space->machine, "1E80") - CollisionBackground;
@@ -137,6 +144,9 @@ VIDEO_START( tinvader )
spritebitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
+
+ gfx_element_set_source(machine->gfx[1], zac2650_s2636_0_ram);
+ gfx_element_set_source(machine->gfx[2], zac2650_s2636_0_ram);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
@@ -170,12 +180,6 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
int by = (zac2650_s2636_0_ram[offs+12] * 3) + 3;
int x,y;
- /* 16x8 version */
- decodechar(machine->gfx[1],spriteno,zac2650_s2636_0_ram);
-
- /* 16x16 version */
- decodechar(machine->gfx[2],spriteno,zac2650_s2636_0_ram);
-
/* Sprite->Background collision detection */
drawgfx(bitmap,machine->gfx[expand],
spriteno,