Commit Graph

86 Commits

Author SHA1 Message Date
Alex W. Jackson
7d528cc33a Make memarray word/dword/qword writers take a mem_mask, and update the tilemap device to use them [Alex Jackson] 2014-02-22 11:37:42 +00:00
Aaron Giles
57cfaa163e Switched rgb_t to a class, replacing macros with methods. Mappings are
as follows:

   MAKE_RGB(r,g,b)     == rgb_t(r,g,b)
   MAKE_ARGB(a,r,g,b)  == rgb_t(a,r,g,b)
   RGB_ALPHA(data)     == data.a()
   RGB_RED(data)       == data.r()
   RGB_GREEN(data)     == data.g()
   RGB_BLUE(data)      == data.b()
   RGB_BLACK           == rgb_t::black
   RGB_WHITE           == rgb_t::white

Implicit conversions to/from UINT32 are built in as well as simple
addition, subtraction, and scaling (with clamping).

As a result of being a class, some stricter typing was needed in
a few places but overall not too much.
2014-02-19 06:07:32 +00:00
Aaron Giles
3e2995cbba Converted palette_t and palette_client to classes. General palette.c
cleanup.
2014-02-18 08:05:44 +00:00
Miodrag Milanovic
7cde79cd9c Created gfxdecode_device instead of using machine fixed gfxdecode [Miodrag Milanovic]
Updated all devices and drivers for using it.

out of whatsnew:
Note that it is made to work same as before, in some cases it can be more
logic to move gfxdevice into subdevice itself then to keep it in main driver.
2014-02-16 17:32:10 +00:00
Alex W. Jackson
1f7a3bf649 Stop the flipping insanity [Alex Jackson]
Tilemap flipping is now calculated relative to the center of the visible area
rather than to the total screen size, and the generic flip screen functions
no longer reconfigure the actual screen.
These changes ensure that in most cases flipping should Just Work for drivers
that use MCFG_RAW_PARAMs, games that have a programmable CRTC, and games that
have raster effects, and should fix many longstanding flip/cocktail-related
regressions.

(nw)
Unfortunately, it also means that all the thankless work that Osso and hap
have been doing over the last few months fixing flipscreen regressions will
have to be reverted now. I've also undoubtedly caused new regressions in
drivers that handle flipscreen in unusual ways. But now we can share video
device implementations between drivers that have been updated to RAW_PARAMs
and drivers that haven't without kludges all over the place.
And now I can hook up the programmable CRTC in toaplan1.c without abandoning
all hope of flipscreen ever working again in that driver.

(also nw)
I also added savestate registration for the generic soundlatches, which seemed
like a good idea. Any particular reason why these weren't being saved?
2014-02-05 17:25:58 +00:00
Aaron Giles
5d0ce54f9e Bulk convert files that already had standard BSD license in my name
to new license tagged form.
2013-10-16 08:14:49 +00:00
Aaron Giles
2f1e78d892 Moved tilemap_memory into a generic memory_array class, since it is
more generally useful than just in tilemaps. Code is now in memarray.*

Converted the Atari RLE motion objects device from a half-assed
device into a full-assed device, leveraging the memory_array class.
2013-08-07 03:18:59 +00:00
Aaron Giles
ec07fb1022 Fix long-standing architectural wart: the priority bitmap is no longer owned
by the tilemap system, and no longer exists globally in the machine. Instead
it is allocated per-screen for all systems. This has several side-effects:

1. Previously, the pdrawgfx* functions were already changed to take the priority
bitmap as a parameter. Now all other hand-crafted functions that mess with
the priority bitmap generally must do so as well, and have been updated.

2. Calls to the tilemap system now need to provide a screen_device. This is not
just for the priority_bitmap, but also for screen flipping, which previously
always assumed the "primary screen" when doing flipping calculations.

3. All devices that implemented tilemap-like functionality have been updated
to follow the same pattern, since they largely tend to call through to the
core tilemap system at some point.
2013-07-26 08:15:05 +00:00
Miodrag Milanovic
14629cbcb4 Cleanups and version bump 2013-07-23 07:18:56 +00:00
Aaron Giles
da8170e0af Memory system: added endianness to the memory_share class.
Tilemap system: numerous changes:

 * Moved remaining legacy macros and typedefs to tilelgcy.h. This revealed
   a few drivers mixing and matching modern & legcy, which have now been 
   fixed.

 * Changed get info callback signature to no longer pass the user_data
   pointer, but instead pass a reference to the tilemap object itself.
   Updated those few drivers using user_data to pull it out of the
   tilemap object with the new user_data() getter method.
 
 * Changed get info and mapping callbacks to be device_delegates so that
   they can be described at config time.
 
 * Added tilemap_memory object that is used internally for reading/
   writing to memory that backs a tilemap. This object is used to track
   a memory pointer that backs tilemap memory, and also is designed to
   transparently handle all bus width and endianness associated with
   reading and writing data in a tilemap.
   
 * Incorporated two tilemap_memory objects (basemem and extmem) into the 
   tilemap object and added accessors to them, as well as read/write 
   handlers for reading/writing to entries stored in the memory. This
   means that tilemap get info callbacks can now easily read data out of
   the tilemap in a generic way.
 
 * Rejiggered the initialization sequence for tilemap objects so that
   the tilemap_manager is not required to be present at instantiation.  
 
 * Created a new tilemap_device, which can be used to declare a tilemap
   in the machine config, and which also is a tilemap object itself.
   The tilemap device will look for shared memory regions called
   "<tag>" and "<tag>_ext" and automatically plug them into the tilemap.
   The device also provides write handlers that can be used to write
   to the tilemap memory and mark tiles dirty, saving the need for each 
   driver to write their own.
   
Device system: moved required/optional device finders to a new header
devfind.h.

Atari drivers: removed all playfield and alpha memory and tilemap
variables, apart from those needed by atarivc-using games (this will
become a device in a future update). Updated all Atari 16-bit drivers to
use the new tilemap_device instead, which provides all the needed
functionality in a more generic way.
2013-07-20 21:46:00 +00:00
Miodrag Milanovic
0e19f641d3 Cleanups and version bump 2013-01-11 07:32:46 +00:00
Aaron Giles
a50849088e gfx_element is now a class. Accessors are provided for all
necessary elements. Updated some of the more, ah, creative
uses/abuses of the gfx_elements. [Aaron Giles]
2012-09-06 06:19:32 +00:00
Aaron Giles
104ae23dcb Replaced standard mappers with an enumeration that maps internally
to the original functions. The only change is to all-caps since
these are constants, e.g., tilemap_scan_rows -> TILEMAP_SCAN_ROWS.
2012-09-05 16:58:19 +00:00
Scott Stone
a4098e8a3a Some cleanup of some observed #include redundancy from source files which use emu.h (nw) 2012-02-06 01:30:22 +00:00
Aaron Giles
3d10a89945 Fix tilemap viewer. Tilemaps now use the bitmap's raw palette instead
of machine->pens to lookup RGB32 values if the palette is present (it
is on all screen bitmaps). Today these are identical, but it's part of
a long-term effort to move away from a global palette and allowing
each bitmap or screen to have their own if that is preferred.
2012-02-04 19:24:25 +00:00
Angelo Salese
505442d0a0 Clean-ups and version bump 2012-01-29 16:34:26 +00:00
Aaron Giles
81d3e50238 Remove support for 4bpp packed graphics. These only manifested
for drivers that used GFX_RAW support for 4bpp systems, and yet
we had a bunch of extra code to support it. Updated these drivers
to do without it and removed all the extra code for supporting 
it.
2012-01-17 06:16:20 +00:00
Aaron Giles
29ada3c938 Bulk converted most of the tilemap_* calls into method calls.
Only thing left is tilemap_create.
2012-01-17 00:25:05 +00:00
Aaron Giles
051af55fa9 Rewrote tilemap.c as a C++ class. For now kept the global
functions and just inline mapped them to the class. Will do
a pass soon to actually update drivers to use the C++
methods directly. Also, the tilemap callbacks are now
delegates which should make for cleaner integrating into
modern devices and drivers going forward.
2012-01-16 05:08:31 +00:00
Aaron Giles
db8e8824db Misc regression fixes (thanks, Tafoid) 2012-01-15 07:48:20 +00:00
Aaron Giles
d57d1f3273 Added new method screen_device::register_screen_bitmap which
allocates a given bitmap to match the screen size and resizes
it as appropriate when the screen size changes. Updated all
the obvious spots in the code where this could be leveraged.

Move allocate/resize methods in the bitmap classes down into
bitmap_t because they no longer have any dependency on the
bitmap format or type.

Ensured that the bitmap's palette remains set across a resize
call (it is lost doing an allocate).
2012-01-15 01:13:13 +00:00
Aaron Giles
e4238fb654 Major bitmap-related changes throughout the system. There are
almost certainly some regressions lurking. Let me know if
something seems busted.

Bitmaps are now strongly typed based on format. bitmap_t still
exists as an abstract base class, but it is almost never used.
Instead, format-specific bitmap classes are provided:

   bitmap_ind8 == 8bpp indexed
   bitmap_ind16 == 16bpp indexed
   bitmap_ind32 == 32bpp indexed
   bitmap_ind64 == 64bpp indexed
   bitmap_rgb32 == 32bpp RGB
   bitmap_argb32 == 32bpp ARGB
   bitmap_yuy16 == 16bpp YUY

For each format, a generic pix() method is provided which
references pixels of the correct type. The old pix8/pix16/pix32/
pix64 methods still exist in the short term, but the only one
available is the one that matches the bitmap's pixel size. Note
also that the old RGB15 format bitmaps are no longer supported
at all.

Converted model1, megadriv, and stv drivers away from the RGB15
format bitmaps.

New auto_bitmap_<type>_alloc() macros are provided for allocating
the appropriate type of bitmap.

Screen update functions now must specify the correct bitmap type
as their input parameters. For static update functions the
SCREEN_UPDATE macro is now replaced with SCREEN_UPDATE_RGB32 and
SCREEN_UPDATE_IND16 macros. All existing drivers have been 
updated to use the correct macros. 

Screen update functions are now required for all screens; there
is no longer any default behavior of copying a "default" bitmap
to the screen (in fact the default bitmap has been deprecated).
Use one of the following to specify your screen_update callback:

   MCFG_SCREEN_UPDATE_STATIC(name) - static functions
   MCFG_SCREEN_UPDATE_DRIVER(class, func) - driver members
   MCFG_SCREEN_UPDATE_DEVICE(tag, class, func) - device members

Because the target bitmap format can now be deduced from the
screen update function itself, the MCFG_SCREEN_FORMAT macro is
no longer necessary, and has been removed. If you specify a
screen update callback that takes a bitmap_ind16, then the screen
will be configured to use a 16bpp indexed bitmap, and if you
specify a callback that takes a bitmap_rgb32, then a 32bpp RGB
bitmap will be provided.

Extended the bitmap classes to support wrapping a subregion of
another bitmap, and cleaner allocation/resetting. The preferred
use of bitmaps now is to define them directly in drivers/devices
and use allocate() or wrap() to set them up, rather than 
allocating them via auto_bitmap_*_alloc().

Several common devices needed overhauls or changes as a result
of the above changes:

 * Reorganized the laserdisc base driver and all the laserdisc 
    drivers as modern C++ devices, cleaning the code up 
    considerably. Merged ldsound device into the laserdsc
    device since modern devices are flexible enough to handle
    it.

 * Reorganized the v9938 device as a modern C++ device. Removed
    v9938mod.c in favor of template functions in v9938.c directly.

 * Added independent ind16 and rgb32 callbacks for TMS340x0 devices.

 * All video devices are now hard-coded to either ind16 or rgb32
    bitmaps. The most notable is the mc6845 which is rgb32, and
    required changes to a number of consumers.

 * Added screen_update methods to most video devices so they can be
    directly called via MCFG_SCREEN_UPDATE_DEVICE instead of creating
    tons of stub functions.
2012-01-12 21:19:49 +00:00
Angelo Salese
fbd35ee85a Cleanups and version bump 2012-01-08 14:41:35 +00:00
Aaron Giles
70a40085eb Removed machine.generic.tmpbitmap, VIDEO_START(generic_bitmapped),
and SCREEN_UPDATE(generic_bitmapped). In their place, each screen_device
now maintains a default bitmap which is automatically copied to the
screen on each update if no SCREEN_UPDATE function is provided and if
no driver_device::video_update override is present. This bitmap can be
found by querying the screen's new default_bitmap() method. [Aaron Giles]
2012-01-02 07:37:22 +00:00
Aaron Giles
80cd316a2a Bulk conversion of bitmap_t * to bitmap_t & . With this change the
parameters for the global SCREEN_UPDATE callback match the parameters
for the driver_device version. Added allocate() and deallocate()
methods to bitmap_t to permit cleaner handling of bitmaps in drivers
and modern devices. [Aaron Giles]
2012-01-02 04:59:11 +00:00
Aaron Giles
fcc81b7c6d Bulk converted cliprect * to cliprect & across the system. This makes
cliprects mandatory everywhere. In general, cliprects were being
correctly passed through the video side of most drivers already, so
it is mostly a semantic change. Note that with my previous change,
bitmaps have cliprects, so if you just want to clip to the bitmap's
boundaries, pass bitmap->cliprect() instead of NULL (which is no 
longer permitted). [Aaron Giles]
2011-12-31 21:48:36 +00:00
Aaron Giles
9cae38e0d8 Converted bitmap_t and rectangle into proper classes. Replaced BITMAP_ADDR*
macros with bitmap->pix* functions, and moved bitmap_fill() to bitmap->fill()
among other similar changes. Bitmap fields now only available via accessors.
Replaced sect_rect with &= and union_rect with |= operators for rectangle
classes. Some general cleanup as a result of these changes. [Aaron Giles]
2011-12-31 07:52:26 +00:00
R. Belmont
6ca8f8a8c3 Fixes for variable shadowing [Oliver Stöneberg] 2011-07-21 13:19:08 +00:00
Aaron Giles
2465eb7e4e Converted presave/postload functions to delegates. In a lot of
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.
2011-04-30 05:12:28 +00:00
Aaron Giles
af94c692bb Switch to using delegates for some 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.
2011-04-27 20:34:45 +00:00
Aaron Giles
543fa08fd0 Rename state_manager -> save_manager since the term "state" is overloaded. 2011-04-20 15:14:54 +00:00
Aaron Giles
d971ce8f36 Privatized most of the m_machine pointers in the system to prevent
direct use.
2011-04-19 06:02:01 +00:00
Aaron Giles
2ad5072023 BIG update.
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 *)
2011-03-29 15:50:04 +00:00
Aaron Giles
a38c67f27b Get rid of state_save_register_device_* macros in favor of direct
calls on the device object.

Regex used:

state_save_register_device_item( *)\(( *)([^,]+), *([^,]+),( *)([^ )]+)( *)\)
\3->save_item\1\(\2NAME\(\6\),\5\4\7\)

state_save_register_device_item_array( *)\(( *)([^,]+), *([^,]+),( *)([^ )]+)( *)\)
\3->save_item\1\(\2NAME\(\6\),\5\4\7\)

state_save_register_device_item_2d_array( *)\(( *)([^,]+), *([^,]+),( *)([^ )]+)( *)\)
\3->save_item\1\(\2NAME\(\6\),\5\4\7\)

state_save_register_device_item_bitmap( *)\(( *)([^,]+), *([^,]+),( *)([^ )]+)( *)\)
\3->save_item\1\(\2NAME\(\*\6\),\5\4\7\)

state_save_register_device_item_pointer( *)\(( *)([^,]+), *([^,]+),( *)([^,]+), *([^ )]+)( *)\)
\3->save_pointer\1\(\2NAME\(\6\),\5\7,\5\4\8\)

this->save_
save_

(save_item[^;]+), *0( *)\);
\1\2\);

(save_pointer[^;]+), *0( *)\);
\1\2\);
2011-02-09 05:51:04 +00:00
Aaron Giles
4f7efb1ca4 Moved the state saving system to C++. For now the registration macros
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
2011-02-08 06:48:39 +00:00
Aaron Giles
a2f7346d90 I had originally wanted to convert the profiler to use scopes (e.g.,
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
2010-08-21 22:25:58 +00:00
Aaron Giles
733b797a3d Split mame.c into mame.c and machine.c, the latter containing the
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.
2010-06-30 03:46:21 +00:00
Aaron Giles
100564d412 WARNING: There are likely to be regressions in both functionality and
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]
2010-06-08 06:09:57 +00:00
Angelo Salese
cd5f1f4011 First step in refactoring the video system in metro.c driver [David Haywood] 2010-03-19 18:01:59 +00:00
Aaron Giles
e738b79785 Correct a long-standing design flaw: device configuration state
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.
2010-01-18 09:34:43 +00:00
Aaron Giles
4498faacd9 First round of an attempted cleanup of header files in the system.
- 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!)
2010-01-10 00:29:26 +00:00
Aaron Giles
91a1b8d634 NOTE: This change requires two new osd functions: osd_malloc() and
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.
2010-01-08 06:05:29 +00:00
Phil Bennett
6f4011f247 Corrected a couple of typos in tilemap.c (not whatsnew worthy) 2009-12-31 00:33:55 +00:00
Aaron Giles
bd24fb23c1 Results of running the latest srcclean. 2009-12-28 09:04:00 +00:00
Aaron Giles
f20a2e6b17 Fixes so we can compile as C++ again. 2009-12-28 07:34:17 +00:00
Aaron Giles
4e9be151f7 Renamed tilemap -> tilemap_t, as the name 'tilemap' is too commonly
used for statics and structure members, and some compilers (esp. C++
compilers) don't allow that.
2009-12-28 05:45:20 +00:00
Aaron Giles
c285eb9bcd Cleanups and version bump. 2009-12-23 18:10:25 +00:00
Phil Bennett
b1293d18ac Fix crash in tilemap viewer when driver has no tilemaps (no whatsnew) 2009-12-19 14:28:22 +00:00
Phil Bennett
123f4decc7 Fixed NULL pointer dereference in tilemap_set_flip_all() when game has no tilemaps (no whatsnew) 2009-12-19 14:04:10 +00:00
Aaron Giles
c1c28e486b Fix crash on exit for systems with no tilemaps. 2009-12-15 00:28:30 +00:00