cases, we can get rid of the postload function entirely and just
call directly to the target function. Drivers eventually should
just override device_postload() instead of registering for callbacks.
- non-device timer callbacks
- machine state changing callbacks
- configuration callbacks
- per-screen VBLANK callbacks
- DRC backend callbacks
For the timer case only, I added wrappers for the old-style functions.
Over time, drivers should switch to device timers instead, reducing the
number of timers that are directly allocated through the scheduler.
Remove redundant machine items from address_space and device_t.
Neither machine nor m_machine are directly accessible anymore.
Instead a new getter machine() is available which returns a
machine reference. So:
space->machine->xxx ==> space->machine().xxx
device->machine->yyy ==> device->machine().yyy
Globally changed all running_machine pointers to running_machine
references. Any function/method that takes a running_machine takes
it as a required parameter (1 or 2 exceptions). Being consistent
here gets rid of a lot of odd &machine or *machine, but it does
mean a very large bulk change across the project.
Structs which have a running_machine * now have that variable
renamed to m_machine, and now have a shiny new machine() method
that works like the space and device methods above. Since most of
these are things that should eventually be devices anyway, consider
this a step in that direction.
98% of the update was done with regex searches. The changes are
architected such that the compiler will catch the remaining
errors:
// find things that use an embedded machine directly and replace
// with a machine() getter call
S: ->machine->
R: ->machine\(\)\.
// do the same if via a reference
S: \.machine->
R: \.machine\(\)\.
// convert function parameters to running_machine &
S: running_machine \*machine([^;])
R: running_machine \&machine\1
// replace machine-> with machine.
S: machine->
R: machine\.
// replace &machine() with machine()
S: \&([()->a-z0-9_]+machine\(\))
R: \1
// sanity check: look for this used as a cast
(running_machine &)
// and change to this:
*(running_machine *)
are still intact. The new state_manager class has templatized methods
for saving the various types, and through template specialization can
save more complex system types cleanly (like bitmaps and attotimes).
Added new mechanism to detect proper state save types. This is much
more strict and there will likely be some games/devices that fatalerror
at startup until they are remedied. Spot checking has caught the more
common situations.
The new state_manager is embedded directly in the running_machine,
allowing objects to register state saving in their constructors now.
Added NAME() macro which is a generalization of FUNC() and can be
used to wrap variables that are registered when directly using the
new methods as opposed to the previous macros. For example:
machine->state().save_item(NAME(global_item))
Added methods in the device_t class that implicitly register state
against the current device, making for a cleaner interface.
Just a couple of required regexes for now:
state_save_register_postload( *)\(( *)([^,;]+), *
\3->state().register_postload\1\(\2
state_save_register_presave( *)\(( *)([^,;]+), *
\3->state().register_presave\1\(\2
create a stack class that started the profiler in the constructor
and stopped it in the destructor). Sadly, doing that causes gcc to
call out to hook up the unwind chain, and this tanks performance
quite badly, even when the profiler is off.
Since I had already class-ified profiler.c, I decided to keep the old
way of doing things but wrap it in the newer classes. So at least it
wasn't a complete waste of my time.
Search & replace:
profiler_mark_start -> g_profiler.start
profiler_mark_end -> g_profiler.end
running_machine definition and implementation.
Moved global machine-level operations and accessors into methods on the
running_machine class. For the most part, this doesn't affect drivers
except for a few occasional bits:
mame_get_phase() == machine->phase()
add_reset_callback() == machine->add_notifier(MACHINE_NOTIFY_RESET, ...)
add_exit_callback() == machine->add_notifier(MACHINE_NOTIFY_EXIT, ...)
mame_get_base_datetime() == machine->base_datetime()
mame_get_current_datetime() == machine->current_datetime()
Cleaned up the region_info class, removing most global region accessors
except for memory_region() and memory_region_length(). Again, this doesn't
generally affect drivers.
performance as a result of this change. Do not panic; report issues to the
list in the short term and I will look into them. There are probably also
some details I forgot to mention. Please ask questions if anything is not
clear.
NOTE: This is a major internal change to the way devices are handled in
MAME. There is a small impact on drivers, but the bulk of the changes are
to the devices themselves. Full documentation on the new device handling
is in progress at http://mamedev.org/devwiki/index.php/MAME_Device_Basics
Defined two new casting helpers: [Aaron Giles]
downcast<type>(value) should be used for safe and efficient downcasting
from a base class to a derived class. It wraps static_cast<> by adding
an assert that a matching dynamic_cast<> returns the same result in
debug builds.
crosscast<type>(value) should be used for safe casting from one type to
another in multiple inheritance scenarios. It compiles to a
dynamic_cast<> plus an assert on the result. Since it does not optimize
down to static_cast<>, you should prefer downcast<> over crosscast<>
when you can.
Redefined running_device to be a proper C++ class (now called device_t).
Same for device_config (still called device_config). All devices and
device_configs must now be derived from these base classes. This means
each device type now has a pair of its own unique classes that describe
the device. Drivers are encouraged to use the specific device types
instead of the generic running_device or device_t classes. Drivers that
have a state class defined in their header file are encouraged to use
initializers off the constructor to locate devices. [Aaron Giles]
Removed the following fields from the device and device configuration
classes as they never were necessary or provided any use: device class,
device family, source file, version, credits. [Aaron Giles]
Added templatized variant of machine->device() which performs a downcast
as part of the device fetch. Thus machine->device<timer_device>("timer")
will locate a device named "timer", downcast it to a timer_device, and
assert if the downcast fails. [Aaron Giles]
Removed most publically accessible members of running_device/device_t in
favor of inline accessor functions. The only remaining public member is
machine. Thus all references to device->type are now device->type(), etc.
[Aaron Giles]
Created a number of device interface classes which are designed to be mix-
ins for the device classes, providing specific extended functionality and
information. There are standard interface classes for sound, execution,
state, nvram, memory, and disassembly. Devices can opt into 0 or more of
these classes. [Aaron Giles]
Converted the classic CPU device to a standard device that uses the
execution, state, memory, and disassembly interfaces. Used this new class
(cpu_device) to implement the existing CPU device interface. In the future
it will be possible to convert each CPU core to its own device type, but
for now they are still all CPU devices with a cpu_type() that specifies
exactly which kind of CPU. [Aaron Giles]
Created a new header devlegcy.h which wraps the old device interface using
some special template classes. To use these with an existing device,
simply remove from the device header the DEVICE_GET_INFO() declaration and
the #define mapping the ALL_CAPS name to the DEVICE_GET_INFO. In their
place #include "devlegcy.h" and use the DECLARE_LEGACY_DEVICE() macro.
In addition, there is a DECLARE_LEGACY_SOUND_DEVICE() macro for wrapping
existing sound devices into new-style devices, and a
DECLARE_LEGACY_NVRAM_DEVICE() for wrapping NVRAM devices. Also moved the
token and inline_config members to the legacy device class, as these are
not used in modern devices. [Aaron Giles]
Converted the standard base devices (VIDEO_SCREEN, SPEAKER, and TIMER)
from legacy devices to the new C++ style. Also renamed VIDEO_SCREEN to
simply SCREEN. The various global functions that were previously used to
access information or modify the state of these devices are now replaced
by methods on the device classes. Specifically:
video_screen_configure() == screen->configure()
video_screen_set_visarea() == screen->set_visible_area()
video_screen_update_partial() == screen->update_partial()
video_screen_update_now() == screen->update_now()
video_screen_get_vpos() == screen->vpos()
video_screen_get_hpos() == screen->hpos()
video_screen_get_vblank() == screen->vblank()
video_screen_get_hblank() == screen->hblank()
video_screen_get_width() == screen->width()
video_screen_get_height() == screen->height()
video_screen_get_visible_area() == screen->visible_area()
video_screen_get_time_until_pos() == screen->time_until_pos()
video_screen_get_time_until_vblank_start() ==
screen->time_until_vblank_start()
video_screen_get_time_until_vblank_end() ==
screen->time_until_vblank_end()
video_screen_get_time_until_update() == screen->time_until_update()
video_screen_get_scan_period() == screen->scan_period()
video_screen_get_frame_period() == screen->frame_period()
video_screen_get_frame_number() == screen->frame_number()
timer_device_adjust_oneshot() == timer->adjust()
timer_device_adjust_periodic() == timer->adjust()
timer_device_reset() == timer->reset()
timer_device_enable() == timer->enable()
timer_device_enabled() == timer->enabled()
timer_device_get_param() == timer->param()
timer_device_set_param() == timer->set_param()
timer_device_get_ptr() == timer->get_ptr()
timer_device_set_ptr() == timer->set_ptr()
timer_device_timeelapsed() == timer->time_elapsed()
timer_device_timeleft() == timer->time_left()
timer_device_starttime() == timer->start_time()
timer_device_firetime() == timer->fire_time()
Updated all drivers that use the above functions to fetch the specific
device type (timer_device or screen_device) and call the appropriate
method. [Aaron Giles]
Changed machine->primary_screen and the 'screen' parameter to VIDEO_UPDATE
to specifically pass in a screen_device object. [Aaron Giles]
Defined a new custom interface for the Z80 daisy chain. This interface
behaves like the standard interfaces, and can be added to any device that
implements the Z80 daisy chain behavior. Converted all existing Z80 daisy
chain devices to new-style devices that inherit this interface.
[Aaron Giles]
Changed the way CPU state tables are built up. Previously, these were data
structures defined by a CPU core which described all the registers and how
to output them. This functionality is now part of the state interface and
is implemented via the device_state_entry class. Updated all CPU cores
which were using the old data structure to use the new form. The syntax is
currently awkward, but will be cleaner for CPUs that are native new
devices. [Aaron Giles]
Converted the okim6295 and eeprom devices to the new model. These were
necessary because they both require multiple interfaces to operate and it
didn't make sense to create legacy device templates for these single cases.
(okim6295 needs the sound interface and the memory interface, while eeprom
requires both the nvram and memory interfaces). [Aaron Giles]
Changed parameters in a few callback functions from pointers to references
in situations where they are guaranteed to never be NULL. [Aaron Giles]
Removed MDRV_CPU_FLAGS() which was only used for disabling a CPU. Changed
it to MDRV_DEVICE_DISABLE() instead. Updated drivers. [Aaron Giles]
Reorganized the token parsing for machine configurations. The core parsing
code knows how to create/replace/remove devices, but all device token
parsing is now handled in the device_config class, which in turn will make
use of any interface classes or device-specific token handling for custom
token processing. [Aaron Giles]
Moved many validity checks out of validity.c and into the device interface
classes. For example, address space validation is now part of the memory
interface class. [Aaron Giles]
Consolidated address space parameters (bus width, endianness, etc.) into
a single address_space_config class. Updated all code that queried for
address space parameters to use the new mechanism. [Aaron Giles]
is now separate from runtime device state. I have larger plans
for devices, so there is some temporary scaffolding to hold
everything together, but this first step does separate things
out.
There is a new class 'running_device' which represents the
state of a live device. A list of these running_devices sits
in machine->devicelist and is created when a running_machine
is instantiated.
To access the configuration state, use device->baseconfig()
which returns a reference to the configuration.
The list of running_devices in machine->devicelist has a 1:1
correspondance with the list of device configurations in
machine->config->devicelist, and most navigation options work
equally on either (scanning by class, type, etc.)
For the most part, drivers will now deal with running_device
objects instead of const device_config objects. In fact, in
order to do this patch, I did the following global search &
replace:
const device_config -> running_device
device->static_config -> device->baseconfig().static_config
device->inline_config -> device->baseconfig().inline_config
and then fixed up the compiler errors that fell out.
Some specifics:
Removed device_get_info_* functions and replaced them with
methods called get_config_*.
Added methods for get_runtime_* to access runtime state from
the running_device.
DEVICE_GET_INFO callbacks are only passed a device_config *.
This means they have no access to the token or runtime state
at all. For most cases this is fine.
Added new DEVICE_GET_RUNTIME_INFO callback that is passed
the running_device for accessing data that is live at runtime.
In the future this will go away to make room for a cleaner
mechanism.
Cleaned up the handoff of memory regions from the memory
subsystem to the devices.
- Created new central header "emu.h"; this should be included
by pretty much any driver or device as the first include. This
file in turn includes pretty much everything a driver or device
will need, minus any other devices it references. Note that
emu.h should *never* be included by another header file.
- Updated all files in the core (src/emu) to use emu.h.
- Removed a ton of redundant and poorly-tracked header includes
from within other header files.
- Temporarily changed driver.h to map to emu.h until we update
files outside of the core.
Added class wrapper around tagmap so it can be directly included
and accessed within objects that need it. Updated all users to
embed tagmap objects and changed them to call through the class.
Added nicer functions for finding devices, ports, and regions in
a machine:
machine->device("tag") -- return the named device, or NULL
machine->port("tag") -- return the named port, or NULL
machine->region("tag"[, &length[, &flags]]) -- return the
named region and optionally its length and flags
Made the device tag an astring. This required touching a lot of
code that printed the device to explicitly fetch the C-string
from it. (Thank you gcc for flagging that issue!)
osd_free(). They take the same parameters as malloc() and free().
Renamed mamecore.h -> emucore.h.
New C++-aware memory manager, implemented in emualloc.*. This is a
simple manager that allows you to add any type of object to a
resource pool. Most commonly, allocated objects are added, and so
a set of allocation macros is provided to allow you to manage
objects in a particular pool:
pool_alloc(p, t) = allocate object of type 't' and add to pool 'p'
pool_alloc_clear(p, t) = same as above, but clear the memory first
pool_alloc_array(p, t, c) = allocate an array of 'c' objects of type
't' and add to pool 'p'
pool_alloc_array_clear(p, t, c) = same, but with clearing
pool_free(p, v) = free object 'v' and remove it from the pool
Note that pool_alloc[_clear] is roughly equivalent to "new t" and
pool_alloc_array[_clear] is roughly equivalent to "new t[c]". Also
note that pool_free works for single objects and arrays.
There is a single global_resource_pool defined which should be used
for any global allocations. It has equivalent macros to the pool_*
macros above that automatically target the global pool.
In addition, the memory module defines global new/delete overrides
that access file and line number parameters so that allocations can
be tracked. Currently this tracking is only done if MAME_DEBUG is
enabled. In debug builds, any unfreed memory will be printed at
the end of the session.
emualloc.h also has #defines to disable malloc/free/realloc/calloc.
Since emualloc.h is included by emucore.h, this means pretty much
all code within the emulator is forced to use the new allocators.
Although straight new/delete do work, their use is discouraged, as
any allocations made with them will not be tracked.
Changed the familar auto_alloc_* macros to map to the resource pool
model described above. The running_machine is now a class and contains
a resource pool which is automatically destructed upon deletion. If
you are a driver writer, all your allocations should be done with
auto_alloc_*.
Changed all drivers and files in the core using malloc/realloc or the
old alloc_*_or_die macros to use (preferably) the auto_alloc_* macros
instead, or the global_alloc_* macros if necessary.
Added simple C++ wrappers for astring and bitmap_t, as these need
proper constructors/destructors to be used for auto_alloc_astring and
auto_alloc_bitmap.
Removed references to the winalloc prefix file. Most of its
functionality has moved into the core, save for the guard page
allocations, which are now implemented in osd_alloc and osd_free.
> 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
> 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
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.
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
- 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.
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
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
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.
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.
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.
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.
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
- 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
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.
- 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