Commit Graph

276 Commits

Author SHA1 Message Date
Olivier Galibert
a860700bbf memory: Make the proxy manage a list of handlers instead of a unique one. [O. Galibert] 2011-05-31 19:18:36 +00:00
Olivier Galibert
a511ce2d19 memory: Split the map_range function into a fixed entry mapping one and a dynamically allocating entry one. [O. Galibert] 2011-05-31 19:18:29 +00:00
Olivier Galibert
fb374c78fc memory: Tuck the unitmask into the proxy. [O. Galibert] 2011-05-31 19:18:23 +00:00
Olivier Galibert
afe9864d99 memory: Proxy the handler entry access when adding handlers. [O. Galibert] 2011-05-31 19:18:16 +00:00
Olivier Galibert
e5fb48ffdc memory: Combine the map_range and handler_read/write() operations into one. [O. Galibert] 2011-05-31 19:18:10 +00:00
Olivier Galibert
9d7efea985 memory: Add utility methods to clean up colliding subunit masks and testing if any are remaining. [O. Galibert] 2011-05-31 19:18:03 +00:00
Olivier Galibert
b1940a2cca memory: Make the memdump file include a description of every subunit. [O. Galibert] 2011-05-31 19:17:56 +00:00
Olivier Galibert
a8db172be1 memory: Split the subaccesses delegation information per-slot. [O. Galibert] 2011-05-31 19:17:48 +00:00
Olivier Galibert
8e73d99610 memory: Separate delegates for the main access and the subaccesses. [O. Galibert] 2011-05-31 19:17:37 +00:00
Olivier Galibert
587f1db003 memory: Build a structure with all possible delegate sizes [O. Galibert] 2011-05-31 19:17:30 +00:00
Olivier Galibert
617ca7a08a memory: Merge width-conversion functions together from the same source width. [O. Galibert] 2011-05-31 19:17:21 +00:00
Olivier Galibert
7d9f24728b memory: Pass the legacy object/handler as a set_delegate parameter. [O. Galibert] 2011-05-31 19:17:12 +00:00
Olivier Galibert
2740bad7dc memory: Store legacy object and handler together in the same structure. [O. Galibert] 2011-05-31 19:17:03 +00:00
Aaron Giles
fda7ea574d Readd type checking to late-binding delegates. This is generally used in
a limited capacity (e.g., for devices), but the existing copy-and-rebind
code would just cast the bound object without verifying the pointer was
of the correct type or pointing to the correct class in the hierarchy.
Objects that are late-bound must be derived from the delegate_late_bind 
class at some point so that a dynamic_cast from delegate_late_bind to the
appropriate type succeeds.

Updated the address map and custom NVRAM handlers to do the right thing
with their re-binding.
2011-05-11 16:46:18 +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
Miodrag Milanovic
b734d88389 - Removed difference between handling driver and device address maps
- Updated modern macros to propagate device so it is possible to make modern maps for devices too
- Updated bsmt2000.c and mie.c as examples of modern address map devices
2011-05-08 18:07:36 +00:00
smf-
5a49af2303 fixed building non debug with visual studio 2010, it wants a virtual destructor if there are any virtual methods. 2011-05-07 07:04: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
5e964d09ce Latest delegate changes removed the need for bindable_object, so
get rid of it across the board.
2011-04-29 20:45:40 +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
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
fecfc465df Switch from m_machine to machine() everywhere. In some cases this
meant adding a machine() accessor but it's worth it for consistency.
This will allow future changes from reference to pointer to happen
transparently for devices. [Aaron Giles]

Simple S&R:
m_machine( *[^ (!=;])
machine()\1
2011-04-18 20:06:43 +00:00
Aaron Giles
55866daab8 Delegates 2.0 implementation. Resdesigned how delegates work to make
them more flexible and simpler to use. Got rid of the proto_delegates
altogether in favor of supporting delegates that are bound to NULL
objects. Added a front-end template that supports "natural" syntax
favored by libraries like boost. Added support for static functions
that take reference parameters instead of pointer parameters for the
object type. Updated all delegate users in the system to the new
syntax. [Aaron Giles]

Changed the DIRECT_UPDATE_HANDLER to take a machine reference like 
everything else in the system. Updated all users. [Aaron Giles]

Changed the FUNC() macro to automatically put an & in front of the
item passed. In general this works transparently, however it does have
the nice side-effect of catching situations where a variable is passed
instead of a function name. Fixed those cases to push the naming
upstream so that the name is now provided properly. Also added a
FUNC_NULL macro since FUNC(NULL) no longer works. [Aaron Giles]
2011-04-16 23:02:16 +00:00
Aaron Giles
68958f72db Cleanups and version bump. 2011-04-03 05:49:24 +00:00
Aaron Giles
17e077da3a Remove redundant item cpu from address_space, in favor of
space->device().

S: space->cpu->
R: space->device\(\)\.

S: space->cpu
R: \&space->device\(\)
2011-03-29 16:31:32 +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
af071893a6 Cleanup of machine.h. Shuffled some fields around, and moved several
to private member variables with accessors:

machine->m_respool     ==> machine->respool()
machine->config        ==> machine->config()
machine->gamedrv       ==> machine->system()
machine->m_regionlist  ==> machine->first_region()
machine->sample_rate   ==> machine->sample_rate()

Also converted internal lists to use simple_list.
2011-03-28 09:10:17 +00:00
Aaron Giles
a80dcb629b Deprecate the old memory_install_* macros. Dynamic installation is now handled
directly by calling methods on the address_space, which have been expanded with
aliases to cover all previous situations. In addition, variants with no mirror
or mask value are provided to cover the common cases:

memory_install_read*_handler(space, begin, end, mirror, mask, handler) ==>
    space->install_legacy_read_handler(begin, end [, mirror, mask], FUNC(handler))

memory_install_write*_handler(space, begin, end, mirror, mask, handler) ==>
    space->install_legacy_write_handler(begin, end [, mirror, mask], FUNC(handler))

memory_install_readwrite*_handler(space, begin, end, mirror, mask, rhandler, whandler) ==>
    space->install_legacy_readwrite_handler(begin, end [, mirror, mask], FUNC(rhandler), FUNC(whandler))

memory_install_read*_device_handler(space, device, begin, end, mirror, mask, handler) ==>
    space->install_legacy_read_handler(*device, begin, end [, mirror, mask], FUNC(handler))

memory_install_write*_device_handler(space, device, begin, end, mirror, mask, handler) ==>
    space->install_legacy_write_handler(*device, begin, end [, mirror, mask], FUNC(handler))

memory_install_readwrite*_device_handler(space, device, begin, end, mirror, mask, rhandler, whandler) ==>
    space->install_legacy_readwrite_handler(*device, begin, end [, mirror, mask], FUNC(rhandler), FUNC(whandler))

memory_install_read_port(space, begin, end, mirror, mask, port) ==>
    space->install_read_port(begin, end [, mirror, mask], port)

memory_install_read_bank(space, begin, end, mirror, mask, bank) ==>
    space->install_read_bank(begin, end [, mirror, mask], bank)

memory_install_rom(space, begin, end, mirror, mask, ptr) ==>
    space->install_rom(begin, end [, mirror, mask], ptr)

memory_install_ram(space, begin, end, mirror, mask, ptr) ==>
    space->install_ram(begin, end [, mirror, mask], ptr)

memory_unmap_read(space, begin, end, mirror, mask) ==>
    space->unmap_read(begin, end [, mirror, mask])

memory_nop_read(space, begin, end, mirror, mask) ==>
    space->nop_read(begin, end [, mirror, mask])


Below are the bulk search & replace regex'es used for this

memory_install_read([0-9]+)_handler( *)\(( *)([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ )]+)( *)\)
\4->install_legacy_read_handler\2\(\3\5FUNC\(\6\)\7\)

memory_install_read([0-9]+)_handler( *)\(( *)([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ )]+)( *)\)
\4->install_legacy_read_handler\2\(\3\5FUNC\(\6\)\7\)

memory_install_write([0-9]+)_handler( *)\(( *)([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ )]+)( *)\)
\4->install_legacy_write_handler\2\(\3\5FUNC\(\6\)\7\)

memory_install_write([0-9]+)_handler( *)\(( *)([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ )]+)( *)\)
\4->install_legacy_write_handler\2\(\3\5FUNC\(\6\)\7\)

memory_install_readwrite([0-9]+)_handler( *)\(( *)([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ ,]+)( *, *)([^ )]+)( *)\)
\4->install_legacy_readwrite_handler\2\(\3\5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite([0-9]+)_handler( *)\(( *)([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ ,]+)( *, *)([^ )]+)( *)\)
\4->install_legacy_readwrite_handler\2\(\3\5FUNC\(\6\)\7FUNC\(\8\)\9\)



memory_install_read([0-9]+)_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ )]+)( *)\)
\4->install_legacy_read_handler\2\(\3\*\5, \6FUNC\(\7\)\8\)

memory_install_read([0-9]+)_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ )]+)( *)\)
\4->install_legacy_read_handler\2\(\3\*\5, \6FUNC\(\7\)\8\)

memory_install_write([0-9]+)_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ )]+)( *)\)
\4->install_legacy_write_handler\2\(\3\*\5, \6FUNC\(\7\)\8\)

memory_install_write([0-9]+)_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ )]+)( *)\)
\4->install_legacy_write_handler\2\(\3\*\5, \6FUNC\(\7\)\8\)

memory_install_readwrite8_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite8_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite16_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite16_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite32_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite32_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite64_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+, *)0 *, *0 *, *([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)

memory_install_readwrite64_device_handler( *)\(( *)([^,]+), *([^,]+), *([^,]+,[^,]+,[^,]+,[^,]+, *)([^ ,]+)( *, *)([^ )]+)( *)\)
\3->install_legacy_readwrite_handler\1\(\2\*\4, \5FUNC\(\6\)\7FUNC\(\8\)\9\)



memory_install_read_port( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_read_port\1\(\2\4,

memory_install_read_port( *)\(( *)([^,]+), *
\3->install_read_port\1\(\2

memory_install_write_port( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_write_port\1\(\2\4,

memory_install_write_port( *)\(( *)([^,]+), *
\3->install_write_port\1\(\2

memory_install_readwrite_port( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_readwrite_port\1\(\2\4,

memory_install_readwrite_port( *)\(( *)([^,]+), *
\3->install_readwrite_port\1\(\2



memory_install_read_bank( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_read_bank\1\(\2\4,

memory_install_read_bank( *)\(( *)([^,]+), *
\3->install_read_bank\1\(\2

memory_install_write_bank( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_write_bank\1\(\2\4,

memory_install_write_bank( *)\(( *)([^,]+), *
\3->install_write_bank\1\(\2

memory_install_readwrite_bank( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_readwrite_bank\1\(\2\4,

memory_install_readwrite_bank( *)\(( *)([^,]+), *
\3->install_readwrite_bank\1\(\2



memory_install_rom( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_rom\1\(\2\4,

memory_install_rom( *)\(( *)([^,]+), *
\3->install_rom\1\(\2

memory_install_ram( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_ram\1\(\2\4,

memory_install_ram( *)\(( *)([^,]+), *
\3->install_ram\1\(\2

memory_install_writeonly( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *,
\3->install_writeonly\1\(\2\4,

memory_install_writeonly( *)\(( *)([^,]+), *
\3->install_writeonly\1\(\2



memory_unmap_read( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *\)
\3->unmap_read\1\(\2\4\)

memory_unmap_read( *)\(( *)([^,]+), *
\3->unmap_read\1\(\2

memory_unmap_write( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *\)
\3->unmap_write\1\(\2\4\)

memory_unmap_write( *)\(( *)([^,]+), *
\3->unmap_write\1\(\2

memory_unmap_readwrite( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *\)
\3->unmap_readwrite\1\(\2\4\)

memory_unmap_readwrite( *)\(( *)([^,]+), *
\3->unmap_readwrite\1\(\2



memory_nop_read( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *\)
\3->nop_read\1\(\2\4\)

memory_nop_read( *)\(( *)([^,]+), *
\3->nop_read\1\(\2

memory_nop_write( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *\)
\3->nop_write\1\(\2\4\)

memory_nop_write( *)\(( *)([^,]+), *
\3->nop_write\1\(\2

memory_nop_readwrite( *)\(( *)([^,]+), *([^,]+,[^,]+), *0 *, *0 *\)
\3->nop_readwrite\1\(\2\4\)

memory_nop_readwrite( *)\(( *)([^,]+), *
\3->nop_readwrite\1\(\2
2011-03-27 17:34:05 +00:00
Aaron Giles
202d7680a4 Created new enum type address_spacenum for specifying an address
space by index. Update functions and methods that accepted an
address space index to take an address_spacenum instead. Note that
this means you can't use a raw integer in ADDRESS_SPACE macros, so
instead of 0 use the enumerated AS_0.

Standardized the project on the shortened constants AS_* over the
older ADDRESS_SPACE_*. Removed the latter to prevent confusion.
Also centralized the location of these definitions to memory.h.
2011-03-27 07:37:24 +00:00
Aaron Giles
4b3aa02618 Added device_t::memory() to fetch a reference to the memory interface,
or assert if not present.

Split address_space::install_[legacy_]handler into 
install_[legacy_]read_handler, install_[legacy_]write_handler,
and install_[legacy_]readwrite_handler.

Added variants of address_space handler installers which don't take
mirror or mask parameters, since this is by far the most common case.

Deprecated API cleanup. Simple search & replace:
cpu_suspend                          ==> device_suspend
cpu_resume                           ==> device_resume
cpu_yield                            ==> device_yield
cpu_spin                             ==> device_spin
cpu_spinuntil_trigger                ==> device_spin_until_trigger
cpu_spinuntil_time                   ==> device_spin_until_time
cpu_spinuntil_int                    ==> device_spin_until_interrupt
cpu_eat_cycles                       ==> device_eat_cycles
cpu_adjust_icount                    ==> device_adjust_icount
cpu_triggerint                       ==> device_triggerint
cpu_set_input_line                   ==> device_set_input_line
cpu_set_input_line_vector            ==> device_set_input_line_vector
cpu_set_input_line_and_vector        ==> device_set_input_line_and_vector
cpu_set_irq_callback                 ==> device_set_irq_callback

More complex changes:
device_memory(device)                ==>  device->memory()
device_get_space(device, spacenum)   ==>  device->memory().space(spacenum)
cpu_get_address_space(cpu, spacenum) ==> cpu->memory().space(spacenum)
cputag_get_address_space(mach, tag, spacenum) ==> mach->device("tag")->memory().space(spacenum)
cputag_get_clock(mach, tag)          ==> mach->device("tag")->unscaled_clock()
cputag_set_clock(mach, tag, hz)      ==> mach->device("tag")->set_unscaled_clock(hz)

Some regex'es for the more prevalent cases above:
S: cpu_get_address_space( *)\(( *)([^,]+)( *), *
R: \3->memory().space\1\(\2
S: cputag_get_address_space( *)\(( *)([^,]+)( *),( *)([^,]+)( *), *
R: \3->device\1\(\2\6\7\)->memory().space\1\(\2
S: cputag_get_clock( *)\(( *)([^,]+)( *),( *)([^ )]+) *\)
R: \3->device\1\(\2\6\7\)->unscaled_clock\(\)
2011-03-27 01:19:26 +00:00
Aaron Giles
2b47d0d5a4 Remove unused static handler entries. Also ensure that subsequent mapping/
unmapping of static memory types does not change the memory parameters.
This fixes the case where dynamically unmapping memory could lead to
incorrectly reported offsets. [Aaron Giles]
2011-03-17 07:23:21 +00:00
R. Belmont
d877507952 Fix reads for 32-bit handlers on 64-bit CPUs too. [R. Belmont] 2011-02-19 23:09:29 +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
3aa8b7d041 Fix RB's bug 2011-02-09 04:33:20 +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
feb6e77be3 As promised, the bulk update of timer calls:
timer_adjust_oneshot(t,...)  => t->adjust(...)
timer_adjust_periodic(t,...) => t->adjust(...)
timer_reset(t,...)           => t->reset(...)
timer_enable(t,...)          => t->enable(...)
timer_enabled(t)             => t->enabled()
timer_get_param(t)           => t->param()
timer_get_ptr(t)             => t->ptr()
timer_set_param(t,...)       => t->set_param(...)
timer_set_ptr(t)             => t->set_ptr(...)
timer_timeelapsed(t)         => t->elapsed()
timer_timeleft(t)            => t->remaining()
timer_starttime(t)           => t->start()
timer_firetime(t)            => t->expire()

Also remove some stray legacy cpuexec* macros that were 
lurking in schedule.h):

cpuexec_describe_context(m)     => m->describe_context()
cpuexec_boost_interleave(m,...) => m->scheduler().boot_interleave(...)
cpuexec_trigger(m,...)          => m->scheduler().trigger(...)
cpuexec_triggertime(m,...)      => m->scheduler().trigger(...)

Specific regex'es used:

timer_adjust_oneshot( *)\(( *)([^,;]+), *
\3->adjust\1\(\2

timer_adjust_periodic( *)\(( *)([^,;]+), *
\3->adjust\1\(\2

(->adjust.*), *0( *)\)
\1\2\)

timer_reset( *)\(( *)([^,;]+), *
\3->reset\1\(\2

(->reset *\(.*)attotime::never
\1

timer_enable( *)\(( *)([^,;]+), *
\3->enable\1\(\2

timer_enabled( *)\(( *)([^,;)]+)\)
\3->enabled\1\(\2\)

timer_get_param( *)\(( *)([^,;)]+)\)
\3->param\1\(\2\)

timer_get_ptr( *)\(( *)([^,;)]+)\)
\3->ptr\1\(\2\)

timer_timeelapsed( *)\(( *)([^,;)]+)\)
\3->elapsed\1\(\2\)

timer_timeleft( *)\(( *)([^,;)]+)\)
\3->remaining\1\(\2\)

timer_starttime( *)\(( *)([^,;)]+)\)
\3->start\1\(\2\)

timer_firetime( *)\(( *)([^,;)]+)\)
\3->expire\1\(\2\)

timer_set_param( *)\(( *)([^,;]+), *
\3->set_param\1\(\2

timer_set_ptr( *)\(( *)([^,;]+), *
\3->set_ptr\1\(\2

cpuexec_describe_context( *)\(( *)([^,;)]+)\)
\3->describe_context\1\(\2\)

\&m_machine->describe_context
m_machine.describe_context

cpuexec_boost_interleave( *)\(( *)([^,;]+), *
\3->scheduler().boost_interleave\1\(\2

cpuexec_trigger( *)\(( *)([^,;]+), *
\3->scheduler().trigger\1\(\2

cpuexec_triggertime( *)\(( *)([^,;]+), *
\3->scheduler().trigger\1\(\2
2011-02-06 21:23:00 +00:00
Aaron Giles
5db7b9e8a3 Ok, last major rename for this round:
memory_region()        == machine->region()->base()
memory_region_length() == machine->region()->bytes()

region_info -> memory_region

Regex searches:

S: memory_region( *)\(( *)([^,&]+), *([^)]+)\)
R: \3->region\1\(\2\4\)->base\(\)

S: memory_region_length( *)\(( *)([^,&]+), *([^)]+)\)
R: \3->region\1\(\2\4\)->bytes\(\)
2011-01-01 00:41:25 +00:00
Aaron Giles
3fc2f94628 Fix 20pacgal. 2010-12-08 06:46:08 +00:00
Aaron Giles
3e621b169b Cleanups and version bump. 2010-10-14 07:04:16 +00:00
Aaron Giles
9b7a65c490 Changed memory width stubs to fill unpopulated regions with the appropriate
portion of the unmap value.

Changed X2212 device to return unmapped bits for the upper 4 bits.
2010-09-21 13:26:27 +00:00
Aaron Giles
7a4744d31d Cleanups and version bump. 2010-09-19 05:09:00 +00:00
Aaron Giles
c181febddc Fix 04034: All sets in viper.c: [debug] Assert in Debug build 2010-09-16 13:54:38 +00:00
Aaron Giles
f529af1f43 Align large memory blocks to 4k boundaries. 2010-09-10 16:33:35 +00:00
Aaron Giles
5b6c078aeb Added templates required_shared_ptr<> and optional_shared_ptr<> which
work just like required_device<> and optional_device<> for retrieving a
pointer by tag from an address space that specifies AM_SHARE("tag").
Also added templates required_shared_size<> and optional_shared_size<>
for retrieving the size of the AM_SHARE region.

Created a new generic NVRAM device. It can be configured to default to
0-fill, 1-fill, random-fill, or custom fill. In all cases, a same-named
memory region overrides the default fill. The address range where the
NVRAM can be found is now identified by an AM_SHARE() region of the
same tag as the NVRAM device. Drivers can also explicitly configure a
separately-allocated NVRAM region via nvram_device::set_base().

Replaced all instances of MDRV_NVRAM_HANDLER(generic_*) with
MDRV_NVRAM_ADD_*("nvram"). Replaced all AM_BASE_GENERIC/AM_SIZE_GENERIC(nvram)
with AM_SHARE("nvram"). For all remaining drivers that referenced the
generic.nvram directly, changed them to hold a required_shared_ptr<UINTx>
to the NVRAM in their driver state, and use that instead. Removed
nvram and nvram_size from the generic_ptrs.
2010-09-04 17:01:46 +00:00
Aaron Giles
8ac0be666e Change shared memory regions to track their size. Added memory_get_shared()
functions to retrieve a pointer to a shared region and optionally the size.
2010-09-04 02:26:32 +00:00
Aaron Giles
066e54b69f Changed driver_data objects to be devices. Replaced the driver_data_t
class with a new driver_device class, which is the base class for all 
driver_data objects now. The new driver devices are added as the
first device in the device list, with a tag of "root"; all other
devices are now owned by the driver device.

Moved core callbacks (machine_start/_reset, sound_start/_reset, 
video_start/_reset/_eof/_update, and palette_init) into device 
configuration parameters on these new devices. The driver_device
base class overrides device_start(), ensures all other devices have
been started, and then calls, in order, the following overridable 
methods:

  find_devices() - new, used to locate devices prior to DRIVER_INIT
  DRIVER_INIT function from the game driver
  palette_init() - by default calls the MDRV_PALETTE_INIT function
  driver_start() - new
  machine_start() - by default calls the MDRV_MACHINE_START function
  sound_start() - by default calls the MDRV_SOUND_START function
  video_start() - by default calls the MDRV_VIDEO_START function

Similarly, the driver_device class overrides device_reset() and then
calls these methods in order:

  driver_reset() - new
  machine_reset() - by default calls the MDRV_MACHINE_RESET function
  sound_reset() - by default calls the MDRV_SOUND_RESET function
  video_reset() - by default calls the MDRV_VIDEO_RESET function

To accommodate these changes, initialization order is slightly
altered from before. The tilemap, video, sound, and debug systems 
are now initialized prior to the devices' start. And the user
callbacks for DRIVER_INIT, PALETTE_INIT, MACHINE_START, SOUND_START, 
and VIDEO_START are all called back-to-back. The net effect should 
be similar, however.

Added methods (optional_device and required_device) to the new 
driver_device class to find devices, intended to be used from the 
find_devices() callback. See harddriv.h and beathead.h for examples 
of usage.

Changed device_t::subtag to only prepend a prefix if the device is
not the 'root' device, in order to keep compatibility with existing
tag searching.

Changed device startup to actively reorder devices when they report
missing dependencies. This ensures that the reset functions get
called in the same order that the start functions did.

Bulk updated drivers as follows:

First removed the old static alloc function from the driver_data_t:
S: [ \t]*static driver_device \*alloc *\( *running_machine *\&machine *\) *\{ *return auto_alloc_clear *\( *\&machine *, *[a-zA-Z0-9_]+_state *\( *machine *\) *\); *\}[\r\n]*
R: 

Then switched from driver_data_t to driver_device:
S: driver_data_t
R: driver_device

Then changed the constructors to pass the correct parameters:
S: ([a-zA-Z0-9_]+)_state *\( *running_machine *\&machine *\)([\r\n\t ]+): *driver_device *\( *machine *\)
R: \1_state\(running_machine \&machine, const driver_device_config_base \&config\)\2: driver_device\(machine, config\)
2010-09-02 07:57:50 +00:00
Aaron Giles
0e672ba6eb Cleanups and version bump. 2010-08-30 15:20:58 +00:00
Angelo Salese
a9ebee2119 Fixed broken error.log offsets 2010-08-26 21:06:30 +00:00
Aaron Giles
be32426a9d Ok, I think the old logic did work, but I renamed the methods so that
it makes sense to me and updated the comment.
2010-08-25 15:33:14 +00:00
Phil Bennett
2d7e4565f0 memory.c: Fixed numerous games broken with 'memory_set_decrypted_region found straddled region' fatalerror (no whatsnew)
Note: partially_covers() wouldn't work independently of fully_covers()...
2010-08-25 14:25:34 +00:00
Aaron Giles
b3a650c9ee Last watchpoint fix was not complete. 2010-08-24 19:45:08 +00:00
Aaron Giles
0a38a62d17 Fix watchpoints for >8-bit address spaces. 2010-08-23 14:14:06 +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
e8d644d285 Fix logic to re-use exact-matching ranges to force a remap.
Fixed almost all regressions reported.
2010-08-21 21:02:19 +00:00
Aaron Giles
e38adf825e Added mask-free versions of read_word/read_dword/read_qword to
address_space. Also added unaligned variants that can read
unaligned values. Rewrote the core handler as a template that
handles all cases, along with a simple unit test to verify that
everything is correct.

Updated 68k, v60, i86, and nec cores to use unaligned read/
write instead of their own stubs for handling misalinged reads.

Fixed memory management of ga2 decryption.
2010-08-21 18:40:01 +00:00
Angelo Salese
843e4de54a Fixed unmap writes in core, not worth mentioning, just do any stylistical change if you want it. 2010-08-21 15:53:43 +00:00
Aaron Giles
3598b772bc Replace "const address_space" with "address_space" throughout the system.
The purpose of making it const before was to discourage direct tampering,
but private/protected does a better job of that now anyhow, and it is
annoying now.

    s/const[ \t]+address_space\b/address_space/g;

Is basically what I did.
2010-08-19 07:26:14 +00:00
Aaron Giles
dd19e512c0 Massive memory system change. This is another step along the path toward
supporting cleaner implementations of drivers in the explicitly OO world.
Expect a follow-on of several more changes to clean up from this one, which
deliberately tried to avoid touching much driver code.

Converted address_space to a class, and moved most members behind accessor
methods, apart from space->machine and space->cpu. Removed external references
to 8le/8be/16le/16be/32le/32be/64le/64be. All external access is now done via
virtual functions read_byte()/read_word()/etc. Moved differentiation between
the endianness and the bus width internal to memory.c, and also added a new
axis to support small/large address spaces, which allows for faster lookups
on spaces smaller than 18 bits. 

Provided methods for most global memory operations within the new address_space 
class. These will be bulk converted in a future update, but for now there are
inline wrappers to hide this change from existing callers.

Created new module delegate.h which implements C++ delegates in a form that 
works for MAME. Details are in the opening comment. Delegates allow member 
functions of certain classes to be used as callbacks, which will hopefully 
be the beginning of the end of fetching the driver_data field in most 
callbacks. All classes that host delegates must derive from bindable_object.
Today, all devices and driver_data do implicitly via their base class.

Defined delegates for read/write handlers. The new delegates are always
passed an address_space reference, along with offset, data, and mask. Delegates
can refer to methods either in the driver_data class or in a device class.
To specify a callback in an address map, just use AM_READ_MEMBER(class, member).
In fact, all existing AM_ macros that take read/write handlers can now accept
delegates in their place. Delegates that are specified in an address map are
proto-delegates which have no object; they are bound to their object when
the corresponding address_space is created.

Added machine->m_nonspecific_space which can be passed as the required
address_space parameter to the new read/write methods in legacy situations 
where the space is not provided. Eventually this can go away but we will
need it for a while yet.

Added methods to the new address_space class to dynamically install delegates
just like you can dynamically install handlers today. Delegates installed this
way must be pre-bound to their object.

Moved beathead's read/write handlers into members of beathead_state as an
example of using the new delegates. This provides examples of both static (via
an address_map) and dynamic (via install_handler calls) mapping using delegates.

Added read/write member functions to okim6295_device as an example of using
delegates to call devices. Updated audio/williams.c as a single example of
calling the device via its member function callbacks. These will be bulk
updated in a future update, and the old global callbacks removed.

Changed the DIRECT_UPDATE_CALLBACKs into delegates as well. Updated all users
to the new function format. Added methods on direct_read_data for configuring the
parameters in a standard way to make the implementation clearer.

Created a simple_list template container class for managing the common
singly-linked lists we use all over in the project.

Many other internal changes in memory.c, mostly involving restructuring the code
into proper classes.
2010-08-19 06:57:51 +00:00
Aaron Giles
ab18e234b0 Cleanups and version bump. 2010-08-12 04:24:53 +00:00
Aaron Giles
c85c035c5d (Wow, I had no idea quite so many drivers were using driver_data!)
Defined new class driver_data_t, which all driver_data classes must
derive from. Updated all class definitions to inherit from the new
class, and to call it in the constructor. Also changed the alloc()
signature to return a driver_data_t pointer instead of a void *.

Renamed and hid machine->driver_data as machine->m_driver_data.
Added a new templatized method machine->driver_data<class> which returns
a properly downcast'ed version of the driver data. Updated all code
which looked like this:

  mydriver_state *state = (mydriver_state *)machine->driver_data;

to this:

  mydriver_state *state = machine->driver_data<mydriver_state>();

The new function does a downcast<> which in debug builds dynamically
verifies that you're actually casting to the right type.

Changed atarigen_state to be a base class from which all the related
Atari drivers derive their state from.

For MESS: this was mostly a bulk search/replace, in 4 steps in
src/mame:

1. Add ": public driver_data_t" to each driver state class definition:

Search:  (class [a-z0-9_]+_state)$
Replace: \1 : public driver_data_t

2. Change the static alloc function to return a driver_data_t *:

Search:  static void \*alloc\(
Replace: static driver_data_t \*alloc\(

3. Change the constructor to initialize driver_data_t:

Search:  ([a-z0-9_]+_state\(running_machine \&machine\)) { }
Replace: \1\r\n\t\t: driver_data_t(machine) { }

4. Replace the state fetchers to use the new templatized function:

Search:  \(([a-z0-9_]+_state) \*\)(.*)machine->driver_data
Replace: \2machine->driver_data<\1>()
2010-08-04 15:37:08 +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
30662dcdef Cleanups and version bump. 2010-07-06 17:30:28 +00:00
Aaron Giles
5d21c672af Moved debugging structure away from CPUs only and attached to all
devices. Debugger now creates one for each device. C++-ified most
debugger operations to hang off the debugging class, and updated
most callers. This still needs a little cleanup, but it fixes most
issues introduced when the CPUs were moved to their own devices.

Got rid of cpu_count, cpu_first, cpu_next, etc. as they were badly 
broken. Also removed cpu_is_executing, cpu_is_suspended,
cpu_get_local_time, and cpu_abort_timeslice.

Some minor name changes:
  state_value() -> state()
  state_set_value() -> set_state()
2010-07-06 00:52:36 +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
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
R. Belmont
bda9211496 Infinite PPC OS X compile fixes (no whatsnew) 2010-06-17 00:38:07 +00:00
Aaron Giles
34152cd57f Minor memory cleanup. 2010-06-08 16:18: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
Scott Stone
838b4fc801 Added some missing static qualifiers to MAME. Also, renamed some generically named exports from segaic16.c. [Atari Ace] 2010-05-28 01:13:40 +00:00
Curt Coder
e2eefc1333 Removed unnecessary warning. (no whatsnew) 2010-04-23 19:48:03 +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
Dirk Best
7d94ce8dec Fixed debugger memdump command [Robbbert] 2010-03-08 13:27:38 +00:00
Aaron Giles
fe3d7c4af4 Cleanups and version bump. 2010-01-28 08:03:44 +00:00
Aaron Giles
771a8b4ecc Whoops, typo. 2010-01-21 06:21:26 +00:00
Aaron Giles
1a2c20441f Remove some aliases between CPUINFO_ and DEVINFO_ to help clarify
usage.

Also converted a few more places to use the new accessors.
2010-01-21 06:05:57 +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
409add88bb Convrted the rest of devintrf to classes and moved management
functions into methods of those classes. The most wide-ranging
change was converting device_reset() to device->reset(). Apart
from that it was mostly internal shuffling in the core.
2010-01-19 15:08:18 +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
470f843262 Within src/emu, basic conversions:
devtag_get_device ... machine->device()
  memory_find_address_space ... device->space()
2010-01-12 06:54:57 +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
f43747b221 Some misc cleanups:
- added warning messages for auto_malloc, timer, and save state
    allocations done after init time. These should be fixed when
    detected, as I would eventually like to disallow them entirely.
 - changed state registration functions to pass through the caller's
    file and line number to facilitate fixing the above warnings
 - converted Taito F3 sound to a separate machine driver which is
    imported into games that use it
 - converted the balsente driver to driver_data structure
 - converted harddriv timers into devices
 - fixed crash in cps2 games due to not configuring the qsound bank
 - cleaned up initialization in taito_l to allocate at init time
    instead of reset time
2009-12-15 02:37:46 +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
Aaron Giles
fd34a32091 Added new functions:
memory_install_ram() to assign a un-named bank to a region and specify
    a pointer to where the RAM lives. If this is called in the DRIVER_INIT
    function or MACHINE/SOUND/VIDEO_START functions, then it is permissible
    to specify NULL, in which case the memory system will allocate memory
    and register it for save states.

  memory_install_rom() is like the above except that it only installs a
    read handler.

  memory_install_writeonly() is like the above except that it only installs
    a write handler.

Updated several instances in the code that were assigning banks to these
sorts of static RAM regions and simplified the code.

Also fixed several regressions reported by Tafoid.
2009-12-07 08:32:02 +00:00
R. Belmont
c165519e07 Fix 64-bit issue noted by Juergen. 2009-12-06 17:30:10 +00:00
Aaron Giles
98484d44b0 Internal memory system shuffling. Address maps initialized internally
now call the same installation handlers that drivers do for dynamic
installation. Cleaned up some parameter ordering and error detection.
2009-12-06 08:18:34 +00:00
Aaron Giles
0fd8c755ff Memory shares are now specified by tag instead of index.
The AM_SHARE() macro now takes a tag parameter. All existing
shares have been bulk renamed to "share##". However, the name
does not matter, so please use descriptive tags going forward.

Also added tag validation for bank and share tags.

Added flag to tagmap_add functions that optionally will
replace existing objects if a duplicate is found.
2009-12-05 20:19:04 +00:00
Aaron Giles
ee315fe99d Renamed functions:
memory_install_read/write_port_handler -> 
        memory_install_read/write_port

   memory_install_read/write_bank_handler -> 
        memory_install_read/write_bank
2009-12-05 07:59:31 +00:00
Aaron Giles
9eda9e163e More memory system cleanup. Removed SMH_* macros entirely. In
their place are a series of expanded macros and new memory
installation helpers. Some mappings below (not all are new):

   AM_READ(SMH_RAM)                       -> AM_READONLY
   AM_WRITE(SMH_RAM)                      -> AM_WRITEONLY
   AM_READWRITE(SMH_RAM, SMH_RAM)         -> AM_RAM
   AM_READ(rhandler) AM_WRITE(SMH_RAM)    -> AM_RAM_READ(rhandler)
   AM_READ(SMH_RAM) AM_WRITE(whandler)    -> AM_RAM_WRITE(whandler)
   AM_DEVREAD(tag, rhandler) AM_WRITE(SMH_RAM) 
                                  -> AM_RAM_DEVREAD(tag, rhandler)
   AM_READ(SMH_RAM) AM_DEVWRITE(tag, whandler) 
                                  -> AM_RAM_DEVWRITE(tag, whandler)

   AM_READ(SMH_ROM)                       -> AM_ROM
   AM_WRITE(SMH_ROM)                      -> (was a no-op)

   AM_READ(SMH_NOP)                       -> AM_READNOP
   AM_WRITE(SMH_NOP)                      -> AM_WRITENOP
   AM_READWRITE(SMH_NOP, SMH_NOP)         -> AM_NOP

For dynamic memory handler installation of the various types,
use the new functions:

   memory_unmap_read()
   memory_unmap_write()
   memory_unmap_readwrite() -- unmaps a section of address space

   memory_nop_read()
   memory_nop_write()
   memory_nop_readwrite() -- nops a section of address space

Cleaned up the internals of the address_map_entry structure, and
also normalized the way the address map macros work to remove a
lot of redundancy.
2009-12-05 07:54:11 +00:00
Aaron Giles
0069237f20 Memory banks are now referenced by tag rather than index.
Changed all memory_bank_* functions to specify a tag.
Bulk-converted existing banks to be tagged "bank##" in
order to ensure consistency. However, going forward, the
tags don't matter, so please name them something useful.

Added AM_BANK_READ/AM_BANK_WRITE macros to let you specify
bank tags. Also changed AM_ROMBANK and AM_RAMBANK macros to
accept tags as well.

Added new functions memory_install_read_bank_handler and
memory_install_write_bank_handler to install banks by tag
name, similar to input ports.

Changed internals of memory system to dynamically allocate
all banks. The first time a bank with an unknown tag is
installed, a new bank object is created and tracked 
internally. Removed all SMH_BANK(n) references outside of
the main code; these should never, ever be useful anymore.
2009-12-03 08:16:38 +00:00
R. Belmont
8bc10109ca One more Clang warning fix.
Anyone who's ever been confused by the meaning of a given GCC or MSVC error diagnostic will enjoy this (it's color-coded in real life for added "wow"):

src/emu/memory.c:2148:5: error: comparison of distinct pointer types ('genf *' and 'void *')                                                           
                                check_entry_handler(write);                                                                                            
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                             
src/emu/memory.c:2052:63: note: instantiated from:                                                                                                     
        if (entry->handler.generic != NULL && entry->handler.generic != SMH_RAM) \                                                                     
                                              ~~~~~~~~~~~~~~~~~~~~~~ ^
2009-12-02 03:51:45 +00:00
Aaron Giles
6bfe172c78 Removed global videoram, colorram, paletteram, and spriteram.
Added equivalent pointers to machine->generic. Updated all
references.

Now that accessing these is more awkward, it is probably best
to put these pointers in the driver data structures instead
of using the generic pointers. The main reason to continue
using generic pointers is to allow use of paletteram shortcuts
and buffered spriteram handling.
2009-11-28 03:06:46 +00:00