Commit Graph

86 Commits

Author SHA1 Message Date
Aaron Giles
eb025378a9 Fix tilemaps so they can be initialized at device start time. 2009-12-14 07:33:54 +00:00
Aaron Giles
64a35dfe95 Added tilemap_create_device() function which lets you create a tilemap
from within a device, and be passed that device in your callback.
2009-12-10 15:42:56 +00:00
Aaron Giles
c3b50fe048 Changed profiler to separate start/stop cases. [Christophe Jaillet] 2009-08-19 16:43:04 +00:00
Aaron Giles
9d033c98e7 > From: atari_ace@verizon.net
> To: submit@mamedev.org
> CC: atariace@hotmail.com
> Subject: [patch] Introduce tilemap_private to running_machine
> Date: Thu, 23 Jul 2009 18:49:08 -0700
> 
> Hi mamedev,
> 
> Tilemaps in MAME are currently globally tracked. If multiple machines
> with different tilemaps are ever to be supported, this needs to be
> changed, which this patchset does.
> 
> 0. This patch add tilemap_private to running_machine, adds machine to
> a few apis and adds two new apis to replace the convention that tmap =
> NULL => all tilemaps.
> 1. This patch mechanically converts all the uses of ALL_TILEMAPS to
> use the new apis.
> 2. This patch removes ALL_TILEMAPS and makes tilemap_private
> dynamically allocated per machine.
> 
> ~aa
2009-08-13 04:42:13 +00:00
Aaron Giles
0df8391ad7 > From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Wednesday, July 22, 2009 8:18 PM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] priority_bitmap global begone!
> 
> Hi mamedev,
> 
> This patch set migrates priority_bitmap from a global variable to the
> running_machine object.  The first patch adds it to the machine
> object, adjusting some routines to take a machine/screen object in
> preparation and others to use a local variable for the bitmap.  The
> second patch then converts all the global vars to (typically)
> machine->priority_bitmap, this patch was generated by the included
> script.  The last patch removes the global priority_bitmap.
> 
> ~aa
2009-08-02 18:30:00 +00:00
Aaron Giles
ad4910a8a8 Bulk change alert.
This update changes the way we handle memory allocation. Rather
than allocating in terms of bytes, allocations are now done in
terms of objects. This is done via new set of macros that replace
the malloc_or_die() macro:

  alloc_or_die(t) - allocate memory for an object of type 't'
  alloc_array_or_die(t,c) - allocate memory for an array of 'c' objects of type 't'
  alloc_clear_or_die(t) - same as alloc_or_die but memset's the memory to 0
  alloc_array_clear_or_die(t,c) - same as alloc_array_or_die but memset's the memory to 0

All original callers of malloc_or_die have been updated to call these
new macros. If you just need an array of bytes, you can use
alloc_array_or_die(UINT8, numbytes).

Made a similar change to the auto_* allocation macros. In addition,
added 'machine' as a required parameter to the auto-allocation macros,
as the resource pools will eventually be owned by the machine object.
The new macros are:

  auto_alloc(m,t) - allocate memory for an object of type 't'
  auto_alloc_array(m,t,c) - allocate memory for an array of 'c' objects of type 't'
  auto_alloc_clear(m,t) - allocate and memset
  auto_alloc_array_clear(m,t,c) - allocate and memset

All original calls or auto_malloc have been updated to use the new
macros. In addition, auto_realloc(), auto_strdup(), auto_astring_alloc(),
and auto_bitmap_alloc() have been updated to take a machine parameter.

Changed validity check allocations to not rely on auto_alloc* anymore
because they are not done in the context of a machine.

One final change that is included is the removal of SMH_BANKn macros.
Just use SMH_BANK(n) instead, which is what the previous macros mapped
to anyhow.
2009-04-26 23:54:37 +00:00
Aaron Giles
eb539cce9d Many casts added to the core files, and various other tweaks
to make them compile as either C or C++.
2009-03-12 07:43:03 +00:00
Aaron Giles
d848af288d From: Christophe Jaillet [christophe.jaillet@wanadoo.fr]
Sent: Monday, February 16, 2009 1:03 PM
To: submit@mamedev.org
Subject: Speed up 'src\mame\video\mcatadv.c'

Hi,

here is a patch against 'src\mame\video\mcatadv.c'

This patch moves a call to 'memory_region' outside of a hot loop in the 'draw_sprites' function.
This gives a fiew pourcents speed up in games such as 'nost'.

Hope this helps,
Best regards,
Christophe Jaillet

--

From: Christophe Jaillet [christophe.jaillet@wanadoo.fr]
Sent: Monday, February 16, 2009 1:53 PM
To: submit@mamedev.org
Subject: Another speed up in 'src\mame\video\mcatadv.c'

Hi,

here is a patch against 'src\mame\video\mcatadv.c'

This patch , by re-arranging the code, give a +/- 5% speed up in the emulation.

Before, we :
    - fetch a pixel,
    - make some computation for lower/higher part of it
    - check if we should render it
    - test for priority
    - update destination if necessary

With this patch, we check priority first in order to avoid useless processing and testing on pixel that can't be displayed due to priority reason. So in the best case, it is faster, in the worse case execution time should be more or less the same because :
       if ((drawxpos >= cliprect->min_x) && (drawxpos <= cliprect->max_x) &&
pix)
is likely to be true (IMO). So the same tests are performed, only the order is different.


Hope this helps,
Best regards,
Christophe Jaillet

--

From: Christophe Jaillet [christophe.jaillet@wanadoo.fr]
Sent: Monday, February 16, 2009 1:09 PM
To: submit@mamedev.org
Subject: Clean up of 'src\emu\tilemap.c' (with the patch...)

Hi,

here is a patch against 'src\emu\tilemap.c'

This patch removes a variable called 'original_cliprect' from the top of 'tilemap_get_tile_flags'.
This variable is useless because all cases that need it, already make the same copy in a variable with the same name, shodawing the former one.

Hope this helps,
Best regards,
Christophe Jaillet
2009-02-26 08:48:51 +00:00
Aaron Giles
7f2e4e19be Cleanups and version bump. 2009-01-15 08:33:24 +00:00
Aaron Giles
ac0abd1706 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.
2009-01-12 11:05:15 +00:00
Aaron Giles
ba92f06dd7 Minor tweaks to please valgrind. 2009-01-02 10:50:40 +00:00
Aaron Giles
9830575ad0 From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Saturday, December 13, 2008 1:34 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Add machine parameter to tilemap_create()

Hi mamdev,

This set of patches eliminates the #include "deprecat.h" from
tilemap.c.  The main change is to require callers of tilemap_create to
provide a machine pointer.  This pointer is then attached to the
tilemap and used when needed inside tilemap.c.

The first patch simply adds running_machine *machine to some driver
functions that will soon need them.  The second patch makes the needed
changes to tilemap.[ch].  The (large) third patch adds machine to all
the tilemap_create calls, and was generated entirely by the attached
script.

~aa
2008-12-14 08:34:41 +00:00
Aaron Giles
b24198a1cd Hi mamedev,
This is a reworked/expanded version of the patch I sent yesterday.
This one is split into three parts:

1.  This introduces function macros for SAMPLES_START,
CUSTOM_{START,STOP,RESET}, and ANTIC_RENDERER.
2.  This introduces running_machine *machine throughout MAME.
Principally it adds running_machine *machine = Machine to the top of
functions, but in some static functions the parameter is added
directly.  Some similar changes in 99xxcore.h, v9938.c, v9938mod.c,
galaxold.c, psx.c, taito_l.c are also made to eliminate Machine
params.  No global API is changed.
3.  This changes the APIs introduced in the first part to pass device
or space as appropriate.  A few similar changes in some other global
apis are made as well.

The net result of this sequence of patches is to remove 40% of the
Machine references and 27 deprecat.h includes.

~aa
2008-12-08 06:53:40 +00:00
Aaron Giles
3c6eacc96f Changed save state system to accept machine parameters where
appropriate, and to keep all global variables hanging off the
machine structure. Once again, this means all state registration
call sites have been touched:

  - state_save_register_global* now takes a machine parameter
  - state_save_register_item* now takes a machine parameter
  - added new state_save_register_device_item* which now uses
     the device name and tag to generate the base name

Extended the fake sound devices to have more populated fields.
Modified sound cores to use tags from the devices and simplified
the start function.

Renumbered CPU and sound get/set info constants to align with
the device constants, and shared values where they were perfectly
aligned.

Set the type field in the fake device_configs for CPU and sound
chips to a get_info stub which calls through to the CPU and sound
specific get_info functions. This means the device_get_info()
functions work for CPU and sound cores, even in their fake state.

Changed device information getters from device_info() to
device_get_info() to match the CPU and sound macros.
2008-12-05 08:00:13 +00:00
Aaron Giles
a5bf427929 Added "tag" parameter to state_save_register_item_* calls. Removed
state_save_combine_module_and_tag() function in favor of passing
the tag when registering. Revisited all save state item registrations
and changed them to use the tag where appropriate.
2008-11-17 06:21:26 +00:00
Nicola Salmoria
9ff6c5bb96 added pen_mask tile attribute to the tilemap system.
implemented dynamic tile & sprite bit depth in the Taito F3 driver.
02024: pbobble3, pbobble4, ringrage and clones: Color Regression
2008-09-27 17:30:17 +00:00
Nicola Salmoria
4ecbf842e9 Added new function tilemap_set_pen_data_offset().
While this isn't 'free' as tilemap_set_palette_offset() is (when the offset changes, the pixmap cache needs to be invalidated), it helps removing some redundant code from drivers.

Updated snk.c and snk68.c to take advantage of the new function.
2008-08-26 18:40:12 +00:00
Nicola Salmoria
8ea2d9e334 optimised tilemap_draw rowscroll case to avoid overhead when used with clip rects smaller than the tilemap. This reduces by an order of magnitude the time taken to render the bg in Gunnail stage 5. 2008-06-05 08:04:46 +00:00
Aaron Giles
dbb98c5473 Reduced the number of save state callback types from 3 to 1. The
only remaining form is the one that takes a pointer parameter.

Added macros for STATE_PRESAVE and STATE_POSTLOAD to define common
functions. Added machine parameter to these functions.

Updated all drivers and CPU/sound cores  to use the new macros 
and consolidate on the single function type. As a result pushed
the machine parameter through a few initialization stacks.

Removed unnecessary postload callbacks which only marked all tiles
dirty, since this is done automatically by the tilemap engine.
2008-04-11 05:41:46 +00:00
Couriersud
0d10d0df2c 00761: finalapr: Heavy performance hit.
Actually remove tilemap invalidating from tilemap_set_palette_offset (tilemap.c)
Following recommendation from Aaron added a comment to tilemap.h
2008-04-04 19:43:20 +00:00
Nicola Salmoria
a284b2fd9e fix tilemap viewer to draw the whole tilemap when categories are used 2008-04-01 16:01:34 +00:00
Aaron Giles
9d3f7f8680 From: Mariusz Wojcieszek
Attached is update for Merit hardware based on V9938 (CRT-250 and CRT-260 - meritm.c).

New playable games:

Pit Boss II
Super Pit Boss
Pit Boss Megastar
Megatouch IV
Megatouch IV Tournament Edition
Megatouch 6
2008-03-13 15:04:33 +00:00
Zsolt Vasvari
77a58d253c - First batch of machine->screen[] access has been removed
- Added video_screen_auto_bitmap_alloc(screen) -- it is just a shorthand for 
  auto_bitmap_alloc(video_screen_get_width(screen), video_screen_get_height(screen), video_screen_get_format(screen))
  which is a common operation
- The Dynax/Don Den Lover games now do their updating in VIDEO_UPDATE instead of VIDEO_EOF.  This semmed to
  have fixed the palette problems
- Went through some of these drivers and changed Machine to machine
2008-03-11 08:37:05 +00:00
Aaron Giles
e31f9a6313 Normalized function pointer typedefs: they are now all
suffixed with _func. Did this throughout the core and
drivers I was familiar with.

Fixed gcc compiler error with recent render.c changes.
gcc does not like explicit (int) casts on float or
double functions. This is fracking annoying and stupid,
but there you have it.
2008-03-03 01:51:31 +00:00
Zsolt Vasvari
f8cbcafd5e Replaces mame_bitmap with bitmap_t
Removes mame_bitmap
2008-02-29 04:01:09 +00:00
Zsolt Vasvari
2b1192dec8 - Backs out BITMAP8 removal from most places.
- I still left drawgfx.c as is, the only piece of code that used any of the functions in drawgfx
  was s2636.c -- everything else uses 8-bit bitmaps as a replacement for a two dimensional array
2008-02-24 23:24:29 +00:00
Zsolt Vasvari
803ece9d96 Removes 8-bit bitmap support and converts all previously 8-bit bitmaps to 16-bit 2008-02-24 13:30:08 +00:00
Aaron Giles
aad4c81ac4 Pulled remaining vestiges of old-style colortables:
* PALETTE_INIT no longer has a colortable parameter
 * removed game_colortable and remapped_colortable from machine_config
 * updated a few stragglers that still referenced these fields
 * removed tile_draw_colortable from tilemap.c

(From Zsolt): Added support for the new colortable object in the palette viewer

Changed the input port tokens to use a union instead of casting everything to FPTR.
In the future, C99-enabled compilers will be able to achieve type safety with
designated initializers.
2008-02-19 17:52:21 +00:00
Zsolt Vasvari
79605aa3da Removed 'type' parameter from tilemap_create 2008-02-05 08:20:52 +00:00
Zsolt Vasvari
662f44ede3 Removed TILEMAP_TRANSPARENT_COLOR tilemap type. The tilemap type is no longer used for anything. 2008-02-05 05:31:23 +00:00
Aaron Giles
662dea1a21 Cleanups/version bump. 2008-02-03 05:23:32 +00:00
Aaron Giles
839029d302 From: Dirk Best
the latest changes in MAME 0.122u7 broke the screenless systems in
MESS. The attached patch fixes this.
2008-01-29 16:37:58 +00:00
Zsolt Vasvari
4930b2dbfd - Added deprecat.h that contains some deprecated/discouraged contructs (see below)
The idea is to create extra work if a driver wants to use these and hopefully
  gives an incentive to look for an alternate solution
- Added #include of deprecat.h that rely on these contructs
- Removed a bunch of unneccassary #include's from these files
2008-01-25 09:30:43 +00:00
Nicola Salmoria
e5b2e1f8ee added tilemap_get_scrollx / tilemap_get_scrolly 2008-01-19 15:02:18 +00:00
Aaron Giles
ee9f88963c Copyright cleanup:
- removed years from copyright notices
 - removed redundant (c) from copyright notices
 - updated "the MAME Team" to be "Nicola Salmoria and the MAME Team"
2008-01-06 00:47:40 +00:00
Aaron Giles
7b77f12186 Initial checkin of MAME 0.121. 2007-12-17 15:19:59 +00:00