Commit Graph

134 Commits

Author SHA1 Message Date
Angelo Salese
a23c194ed5 Port from MESS, nw 2011-06-28 14:23:18 +00:00
Miodrag Milanovic
2e199e3e83 Fixed PORT_CONDITION to look relative to device (no whatsnew) 2011-06-22 12:54:34 +00:00
R. Belmont
1a23f8659b More GCC 4.6 fixes (no whatsnew) 2011-05-30 02:19:30 +00:00
Aaron Giles
d5af6b6a9b Switch input ports to use function-based constructors instead of tokens.
Remove the old tokenizing helpers. Add basic classes for ports, fields,
settings, and dip locations as a first step. These will be fully cleaned
up later. Added machine() method to field to hide all the necessary
indirection. Changed custom/changed handlers into generic read/write
handlers, and added wrappers to convert them to device read/write
lines. [Aaron Giles]
2011-05-10 22:20:27 +00:00
Aaron Giles
ff1db593b7 Attach gamedrv's input ports to the driver_device, so that there's
no longer anything special about how they are processed. Removed
logic that handled the game inputs as a special case.
2011-05-05 07:02:28 +00:00
Aaron Giles
919913f118 Collapsed device_config and device_t into one class. Updated all
existing modern devices and the legacy wrappers to work in this
environment. This in general greatly simplifies writing a modern
device. [Aaron Giles]

General notes:
 * some more cleanup probably needs to happen behind this change,
   but I needed to get it in before the next device modernization 
   or import from MESS  :)

 * new template function device_creator which automatically defines
   the static function that creates the device; use this instead of
   creating a static_alloc_device_config function

 * added device_stop() method which is called at around the time
   the previous device_t's destructor was called; if you auto_free
   anything, do it here because the machine is gone when the 
   destructor is called

 * changed the static_set_* calls to pass a device_t & instead of
   a device_config *

 * for many devices, the static config structure member names over-
   lapped the device's names for devcb_* functions; in these cases
   the members in the interface were renamed to have a _cb suffix

 * changed the driver_enumerator to only cache 100 machine_configs
   because caching them all took a ton of memory; fortunately this
   implementation detail is completely hidden behind the 
   driver_enumerator interface

 * got rid of the macros for creating derived classes; doing it
   manually is now clean enough that it isn't worth hiding the
   details in a macro
2011-04-27 05:11:18 +00:00
Aaron Giles
00d745ca77 (Big tangle of changes that all happened as I was looking into the ROM
loader rewrite, which is still in progress....)

Replaced mamedriv.c with a new driver list mechanism that is generated
by the build tools. The emulator core now expects the presence of a
file called src/$(TARGET)/$(SUBTARGET).lst which is just a raw list of
driver names, one per line. C and C++ comments are still permitted.
This file is parsed by a new build tool makelist which extracts the
driver names, sorts them, and generates a file called drivlist.c, which
is consumed by the core. [Aaron Giles]

Added new osdcore function osd_malloc_array() which is identical to
osd_malloc() but obviously hints that the underlying allocation is for
an array. Updated all callers to use the appropriate form. Modified the
Windows allocator to only use guard pages for array-style allocations,
allowing us to enable them once again in debug builds. [Aaron Giles]

Created new static class driver_list to wrap accesses to the list of
available drivers. Improved speed of driver lookups by relying on the
presorting done by makelist. [Aaron Giles]

Created helper class driver_enumerator as a helper for iterating through 
the list of drivers. This class supports basic filtering and iteration,
and also serves as a temporary cache of machine_configs. [Aaron Giles]

Created cli_frontend object to wrap all the CLI handling code in
clifront.c. Updated/simplified all the code to take advantage of the
driver_enumerator. [Aaron Giles]

Created media_auditor object to wrap all the auditing functions in
audit.c. Updated all users to the new interface. Note that the new
auditing mechanism is slightly out of sync with the romload code in
terms of finding ROMs owned by devices, so it may mis-report some
issues until the new ROM loading code is in. [Aaron Giles]

Added concept of a per-device searchpath. For most devices, their 
searchpath is just the short name of the device. For driver_devices, the
searchpath is driver[;parent[;bios]]. This searchpath will eventually be
used by the rom loader to find ROMs. For now it is used by the media
auditor only. [Aaron Giles]

Created info_xml_creator object to wrap all the info generation functions
in info.c. Converted the file to C++ and cleaned up the input processing
code. [Aaron Giles]

(not for whatsnew ... Known issues: auditing of CHDs appears busted, and 
debug builds report unfreed memory if you use the built-in game picker)
2011-04-13 20:31:00 +00:00
Aaron Giles
28fdb61512 Move overridable device->rom_region(), device->machine_config_additions(), and
device->input_ports() to protected methods. Added non-virtual wrappers around
them.
2011-03-30 06:27:49 +00:00
Aaron Giles
fe71058aa2 Don't pass both a machine_config and an emu_options, since the options
are now available via the config.
2011-03-11 06:01:58 +00:00
Aaron Giles
04c9a546b5 Attached emu_options to the machine_config, and the running_machine
inherits it now.
2011-03-10 10:17:30 +00:00
Aaron Giles
06ee6804dd Converted core_options to a class. Removed a bunch of marginal
functionality in favor of alternate mechanisms. Errors are
now reported via an astring rather than via callbacks. Every
option must now specify a type (command, integer, float, string,
boolean, etc). Command behavior has changed so that only one
command is permitted. [Aaron Giles]

Changed fileio system to accept just a raw searchpath instead of
an options/option name combination. [Aaron Giles]

Created emu_options class dervied from core_options which wraps
core emulator options. Added mechanisms to cleanly change the
system name and add/remove system-specific options, versus the
old way using callbacks. Also added read accessors for all the
options, to ensure consistency in how parameters are handled.
Changed most core systems to access emu_options instead of
core_options. Also changed machine->options() to return emu_options.
[Aaron Giles]
 
Created cli_options class derived from emu_options which adds the
command-line specific options. Updated clifront code to leverage
the new class and the new core behaviors. cli_execute() now accepts
a cli_options object when called. [Aaron Giles]

Updated both SDL and Windows to have their own options classes,
derived from cli_options, which add the OSD-specific options on
top of everything else. Added accessors for all the options so
that queries are strongly typed and simplified. [Aaron Giles]

Out of whatsnew: I've surely screwed up some stuff, though I have
smoke tested a bunch of things. Let me know if you hit anything odd.
Also I know this change will impact the WINUI stuff, please let me 
know if there are issues. All the functionality necessary should 
still be present. If it's not obvious, please talk to me before 
adding stuff to the core_options class.
2011-03-03 17:05:24 +00:00
Aaron Giles
5e4df8c772 Hash generation and general cleanup. New class hash_collection holds
and manages a collection of hashes, and can be built from an internal
format string which is stored with each ROM. All core instances are
cleaned up to use the new interfaces, but it's likely that hashfile
code in MESS will need an update.

Also compacted the form of the hash strings used for ROMs, and fixed
verification/hashing of non-ZIPped files.
2011-02-14 08:41:08 +00:00
Miodrag Milanovic
569f818281 Input ports can now be added to device, names are formed as sub tags from parent device tag. [Miodrag Milanovic] 2011-02-13 17:45:31 +00:00
Aaron Giles
1b54456be5 mame_file is now emu_file and is a class. It is required
to pass a core_options object to the constructor, along with
a search path. This required pushing either a running_machine
or a core_options through some code that wasn't previously
ready to handle it. emu_files can be reused over multiple 
open/close sessions, and a lot of core code cleaned up
nicely as things were converted to them.

Also created a file_enumerator class for iterating over files
in a searchpath. This replaces the old mame_openpath functions.

Changed machine->options() to return a reference.

Removed public nvram_open() and fixed jchan/kaneko16 to
stop directly saving NVRAM.

Removed most of the mame_options() calls; this will soon go 
away entirely, so don't add any more.

Added core_options to device_validity_check() so they can be
used to validate things.
2011-02-12 03:47:37 +00:00
Miodrag Milanovic
a9dc2227c9 Display all warnings during validate of devices shortname (no whatsnew) 2011-02-10 20:25:27 +00:00
Miodrag Milanovic
601056b130 - Added shortname to devices in order to make ROM loading per device possible. [Miodrag Milanovic]
- Updated all devices containing ROM regions to have short names and all modern devices too
- Created new validation to check existence of short name if device contain ROM region defined
2011-02-10 19:08:37 +00:00
Aaron Giles
57ef3a5ed6 Split the screen device into a separate module.
Converted global video routines into a video_manager.
Moved video manager initialization earlier in startup.
2010-12-02 17:26:38 +00:00
Aaron Giles
e4d8baf401 Changed driver_device to expose the game_driver's ROMs through the
device interface. This means all ROMs are now exposed via devices,
and thus the process of enumerating ROMs gets simpler.

Changed all instances of temporarily allocating machine_config objects 
to just put them on the stack for simplicity, letting the destructor 
handle the cleanup work automatically.

Changed machine_config constructor to take a game_driver, from which
the machine_config constructor is obtained. This also means the
resulting machine_config holds a reference to the game_driver.

Changed running_machine constructor to no longer take a game_driver,
since the game_driver is now obtainable via the machine_config.
2010-09-03 05:21:46 +00:00
Aaron Giles
0e672ba6eb Cleanups and version bump. 2010-08-30 15:20:58 +00:00
Aaron Giles
d5d2cd0bb9 Haha, recent change to astrings also revealed that validity checks
were busted for ROM_FILL/ROM_COPY (we didn't detect regions populated
this way were non-empty).
2010-08-21 19:37:32 +00:00
Aaron Giles
4d1fc8fafa Swap: (astring.len() != 0) -> astring
Swap: (astring.len() == 0) -> !astring
2010-08-21 19:27:14 +00:00
Aaron Giles
f5a217442a Fix crasher caused by new astring operators (original code
was buggy, but didn't crash before).
2010-08-19 19:59:16 +00:00
Aaron Giles
ab18e234b0 Cleanups and version bump. 2010-08-12 04:24:53 +00:00
Aaron Giles
fe47da274e Return to type safety. Changed address maps back into functions that build
up the definition, rather than the whole tokenizing system, which lost type
checking. Added a new module addrmap.c which implements the address map
classes, and changed the macros to call methods on the address_map and
address_map_entry classes which are strongly typed.

Fixed a few incorrectly specified memory map entries along the way. Please
double-check to make sure the behavior is expected in: twincobr.c, lordgun.c,
galaxold.c.

This change also means that since the address_maps are now constructor
functions, they are detected when not used, so a number of #ifdef UNUSED_CODE
were added around dangling address map definitions.

Also included with this change:
- removed cputag_clocks_to_attotime() and cputag_attotime_to_clocks() in
   favor of just expanding the class
- same for cputag_suspend() and cputag_resume()
2010-08-01 21:04:03 +00:00
Aaron Giles
41b9dbb9ac Made the machine_config a proper object. Added detokenize method to
this object which can be called multiple times to append new devices
after the initial machine configuration is set up. Updated member
variables to match new naming convention.

Changed the running_machine to take a constructed machine_config
object in the constructor, instead of creating one itself, for
consistency. Also added machine->total_colors() as a shortcut to 
machine->config->m_total_colors.
2010-06-28 06:40:44 +00:00
Aaron Giles
861db1eb49 Cleanups and version bump. 2010-06-17 06:55:54 +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
Aaron Giles
ec586731b9 Made device->tag and devconfig->tag into private member variables (m_tag).
Added inline tag() function to return a const char * version. Updated
callers to use this instead of directly accessing tag.cstr() which
was awkward.
2010-03-08 17:06:27 +00:00
Aaron Giles
cfa887f3de Changed all driver_data structs into classes with a simple
constructor and a static allocation function.

Changed MDRV_DRIVER_DATA to reference driver_data::alloc
instead of just providing a size. This function is called
to allocate the driver data. This allows objects to be
embedded in the state data and be properly initialized.

Ideally, new driver_data constructors should perform
initialization actions in the constructor, but for now
most just use auto_alloc_clear() to blast everything to
zero.

Moved driver data allocation after device list construction
so that devices can be found when the driver data is
constructed.
2010-02-25 06:28:03 +00:00
Aaron Giles
6b663f66a7 Cleanups and version bump. 2010-02-14 16:59:22 +00:00
Miodrag Milanovic
0a6b13608d - Moved natural keyboard support from MESS to MAME
- Moved OSD file functions and clipboard access functions into OSD core
2010-02-12 15:40:11 +00:00
Miodrag Milanovic
ce85c7f748 Removed GAME_SHARE_ROMS flag and commented old check for duplicate ROM entries 2010-02-11 13:54:55 +00:00
Miodrag Milanovic
f058d3f6e0 Renamed GAME_CAN_SHARE_ROMS to GAME_SHARE_ROMS (sounds more logical) 2010-02-11 10:25:14 +00:00
Miodrag Milanovic
a8aedb92b0 - Renamed GAME_COMPUTER_MODIFIED to GAME_UNOFFICIAL to mark unofficial hardware modifications
- Removed GAME_COMPUTER it is distinct by IPT_KEYBOARD
- Added GAME_NO_SOUND_HW (to mark that there is no sound hardware) and marked drivers in dotrikun.c, minivadr.c and tgtpanic.c as such
- Added GAME_CAN_SHARE_ROMS - to mark that there can be other driver using same ROM as this one but with different hardware (common in computer/console world)
2010-02-11 09:44:23 +00:00
Miodrag Milanovic
312b80701c - Moved compatibility validation into MAME core from MESS.
- Made GAME_COMPUTER type visible for all, and removed ifdefs for it.
- Made GAME_NO_SOUND check done on MESS too.
2010-02-09 14:23:13 +00:00
Aaron Giles
a5668c2eb9 Made direct accessors for device configuration state. Currently they
just call through to the get info function. Removed old macros that
wrapped calls.
2010-01-21 03:56:53 +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
d061ced592 Created new template class tagged_list which manages a simple list
along with a tagmap. Changed memory regions, input ports, and devices
to use this class. For devices, converted typenext and classnext
fields into methods which dynamically search for the next item.
Changed a number of macros to use the features of the class, removing
the need for a bunch of helper functions.
2010-01-17 09:26:29 +00:00
Aaron Giles
aebc07a897 Cleanups and version bump. 2010-01-16 04:12:04 +00:00
Aaron Giles
a9c5a5a27e Fixed memory freeing so that is it released in the opposite order
it was originally allocated.

Changed machine->region() to return a pointer to the now-public
region_info class.

Added new member function space() to the device_config, along with
shorter constants to be used (AS_PROGRAM, AS_DATA, AS_IO). With no 
parameters, space() returns the first address space, which is 
commonly the only space present. Updated a few devices that referenced 
the old space[] array to call the new function instead.

Added #define to emualloc to ensure delete can't be freely used.
2010-01-11 18:02:38 +00:00
Aaron Giles
317da101d8 Try using type_traits for detection of valid save types. 2010-01-11 09:53:25 +00:00
Aaron Giles
51e6cbf6cd Fixed bogus empty ROM region warnings. 2010-01-11 08:42:05 +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
a92de5930c Extended the astring class wrapper into something useful, and
useable as a stack object. Also designed the interfaces to allow
for chaining operations. And added a casting operator to const
char * for seamless use in most functions that take plain old C
strings.

Changed all uses of astring to use the object directly on the
stack or embedded in objects instead of explicitly allocating 
and deallocating it. Removed a lot of annoying memory management
code as a result.

Changed interfaces that accepted/returned an astring * to
use an astring & instead.

Removed auto_alloc_astring(machine). Use 
auto_alloc(machine, astring) instead.
2010-01-08 17:18:54 +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
5be4dc8d54 Added some missing header declarations and static qualifiers. Added validity.h to the core for consistency as well as an explicit foo.h in each foo.c. [Atari Ace]
---------- Forwarded message ----------
From: Atari Ace <atari_ace@verizon.net>

Date: Sat, Dec 26, 2009 at 5:01 PM
Subject: [patch] Header/static cleanups
To: submit@mamedev.org
Cc: atariace@hotmail.com

- Hide quoted text -
Hi mamedev,

This patch add some missing header declarations and static qualifiers,
and adjusts a few names.  In the core, it adds validity.h for
consistency as well as an explicit foo.h in each foo.c.

~aa
2010-01-06 21:09:25 +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
40bcc29e8a Cleanups and version bump. 2009-12-11 06:19:46 +00:00
Aaron Giles
8ba04b825a Apply mirrors and global masks at address map detokenizing time rather
than later. Also added disabled code to detect address maps with
overlapping regions for future analysis.
2009-12-10 15:32:44 +00:00