Commit Graph

276 Commits

Author SHA1 Message Date
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
Aaron Giles
cdd9d7c757 Introduced a generic_pointers structure within machine that is
designed to hold generic pointers that are commonly used. For
now, only generic_nvram has moved there. Added AM_BASE_GENERIC
and AM_SIZE_GENERIC macros for initializing generic pointers
in memory maps. Also added AM_BASE_SIZE_GENERIC to set both
base and size in one step.

Moved global variables out of machine/generic and into a private
data structure hanging off of the running_machine. Added newly-
needed machine parameters to coin_counter_w, coin_lockout_w, and
coin_lockout_global_w. Also added machine parameter to 
set_led_state.

Added interface functions to get the number of dispensed tickets
and to increment the count, to remove the need for direct access
to these global variables. Also added functions to get the
current count on a particular coin counter and to determine the
lockout state.

Future checkins will move the remaining generic pointers (for
paletteram, videoram, spriteram, colorram, etc.) into the new
generic_pointers structure.
2009-11-26 23:43:19 +00:00
smf-
8836834f08 added memory_install_write_port_handler & memory_install_readwrite_port_handler to be consistent with installing handlers. 2009-11-25 09:48:44 +00:00
Aaron Giles
9072c7f911 Added new module tagmap which is a simple hashed string map.
Updated device and input port lists to use the tagmap for
tag searches. Also removed the whole "quark" thing from the
validity checker in favor of using the tagmaps.
2009-11-23 04:55:26 +00:00
smf-
dd1d8777a9 added device support to the input system. internally this replaces PORT_CUSTOM/PORT_CHANGED, backward compatibility is achieved with an internal dummy device.
added output lines (IPT_OUTPUT), which can be written using new input_port_write* functions or directly from a memory map using AM_WRITE_PORT
converted adc083x to use io lines.
adc08x chips are all hooked up using input/output ports
reversed racing force steering wheel input and gas pedal, which is enough to get the game to boot.
reversed steering wheel input on winding heat, the usa cabinets are however hooked up the other way.
renamed adc0831_interface to adc083x_interface.
fixed adc083x gnd input
removed stray call logerror from adc083x.c
fixed default adc083x sars value
adc083x reset only affects outputs
2009-11-20 22:36:52 +00:00
Aaron Giles
bd11e46b0c Minor comment cleanup. 2009-11-15 15:47:37 +00:00
Phil Bennett
8eeb31a04c Fixed a couple of source typos [Christophe Jaillet]
> -----Original Message-----
> From: Christophe Jaillet [mailto:christophe.jaillet@wanadoo.fr]
> Sent: Saturday, October 17, 2009 9:03 AM
> To: submit@mamedev.org
> Subject: Patch against 2 typo in comments
>
> Hi,
>
> all is said in the object of the mail. Catch while going thrue the
> code.
>
> Hope this help.
> Best regards,
>
> CJ
2009-10-21 10:18:15 +00:00
Aaron Giles
3bfae5cdec Fixed up RAM bank names to prevent crashes with memdump.
Extended explicit banks to 96.
2009-09-28 07:01:06 +00:00
Aaron Giles
fcf9e90cd5 Now allow for banks to take up half of the available slots.
Explicit banks now work up to bank 64.
2009-09-21 15:58:25 +00:00
Aaron Giles
8eeb0f1d20 Fixed up some error logging messages to output the correct number of characters
for addresses and data, using the new core_i64_hex_format function.
2009-09-10 08:24:15 +00:00
Aaron Giles
c3b50fe048 Changed profiler to separate start/stop cases. [Christophe Jaillet] 2009-08-19 16:43:04 +00:00
Aaron Giles
62c9a9d8cb Cleanups and version bump. 2009-07-10 03:10:17 +00:00
Aaron Giles
5201d52344 Expanded address maps from 3 to 4. Moved ADDRESS_SPACE_PROGRAM/DATA/IO
constants to cpuintrf, as those names are really only applicable to 
CPUs. Added new ADDRESS_MAP_0/1/2/3 constants to identify address maps 
more generically. 

Updated memory system to be more general about address map handling.
Added the concept of default address maps (in addition to the already
existing internal memory maps). The difference between internal and
default memory maps is that internal memory maps always override
everything (including user-specified maps), but default memory maps
simply provide a default that can be overridden.

Converted the okim6295 sound driver to use address maps for access.
By default, it defines a ROM address map that overlays its full
region. As a result, the validity checks require all okim6295 regions
to be at least 256k, unless you provide your own address map. Updated
all regions to meet this requirement.

Updated the atarijsa code to use a custom address space for its
okim6295 accesses (which are banked on the first half and static on
the second half), as an example of configuring a device with a
custom address space.

For now, attempts to use okim6295_set_bank_base() will still work,
though banking for the okim chips should be moved to custom address
maps in the drivers eventually. The first time okim6295_set_bank_base()
is called, it will install a banked memory handler over the region
and use memory_set_bankptr() to change the base on subsequent bank
switches.

Moved address map validity checks to be run for each device instead of
just each CPU.
2009-07-09 07:10:40 +00:00
Aaron Giles
2577a0b22d Another step. Moved the address-space related get_info constants
to devintrf (including endianness). Removed space array from the
CPU class header. Made the memory system much more device-neutral.
Various other cleanups along the way.
2009-07-08 16:20:01 +00:00
Aaron Giles
7b28233e47 Move address_map array from cpu_config to device_config. Added
MDRV macros in the device for specifying address maps. Changed
the memory system to fetch the maps from the new location.

This is just a small step toward the end goal of getting address
maps into arbitrary devices.
2009-07-08 14:47:35 +00:00
Aaron Giles
8125878cfa Fixed misaligned table. 2009-05-13 02:58:21 +00:00
Aaron Giles
09d58a6c7f Removed address_map2 items from the CPU config, etc. 2009-05-09 05:30:43 +00:00
Aaron Giles
ad4910a8a8 Bulk change alert.
This update changes the way we handle memory allocation. Rather
than allocating in terms of bytes, allocations are now done in
terms of objects. This is done via new set of macros that replace
the malloc_or_die() macro:

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

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

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

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

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

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

One final change that is included is the removal of SMH_BANKn macros.
Just use SMH_BANK(n) instead, which is what the previous macros mapped
to anyhow.
2009-04-26 23:54:37 +00:00
Aaron Giles
eb539cce9d Many casts added to the core files, and various other tweaks
to make them compile as either C or C++.
2009-03-12 07:43:03 +00:00
Aaron Giles
99d297a6fd Cleanups and version bump. 2009-03-05 09:38:53 +00:00
Aaron Giles
1dcd75d039 Removed device types from device queries that use tags, under the
assumption that all device tags are unique. Specifically, the
following no longer need to provide a device type:

   AM_DEVREAD/WRITE
   DEVCB_DEVICE_HANDLER
   devtag_get_device
   devtag_reset
   device_list_find_by_tag

as well as several device interfaces that referenced other devices.

Also fixed assertion due to overflow in the recent sound fix.
2009-03-02 10:59:37 +00:00
Aaron Giles
4ad8ec54f8 Converted the following drivers to the new device-based 6821 PIA:
- qix
 - mcr/williams
 - coinmstr
 - funworld
 - goldnpkr
 - jokrwild
 - nyny
 - r2dtank
 - spiders
 - tugboat

Added new function memory_install_read_port_handler() to more
easily allow you to install read handlers for ports based on tag.

Removed input_port_read_handler8/16/32/64 functions, since they
were really only used for getting a memory handler for a port by
tag, and this is no longer necessary.

Moved input port handlers to internal code in the memory system.

Added port names to the taito8741 device pending its proper
devicification.

Removed all remaining uses of input_port_n_r() functions, and
purged them from src/emu/machine/generic.
2009-03-02 09:31:05 +00:00
Aaron Giles
864560d4af From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Monday, February 16, 2009 7:10 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Add some missing static qualifiers

Hi mamedev,

This patch mostly adds missing static qualifiers, plus a few related header/name adjustments.  In particular, I tackled m68kmake.c and tmsmake.c which exposed a fair amount of dead code.

~aa
2009-02-26 08:52:27 +00:00
Aaron Giles
c4126c1034 bytemask should not mask low bits. Fixes disassembler for CPUs with address
bus shifts. Hopefully doesn't impact anything else.
2009-02-06 13:26:24 +00:00
smf-
8ac4f3cb33 Changed memory_set_direct_region to pass the address returned from the DIRECT_UPDATE_HANDLER back to the memory read function. 2009-01-31 16:57:16 +00:00
Aaron Giles
cc14b2aaa7 Opcode accesses are now marked debugger_access. This is important with the recent
changes to automatically call the read handler if the opcode base cannot be
found.

Changed logging for non-RAM opcode bases so that it does not output in the case
of debugger_access being set.

Fixed logic for deriving direct ranges so that it uses the non-watchpoint-
infected tables for its lookups.
2009-01-30 18:11:46 +00:00
Aaron Giles
eff9223966 Removed some stray ADDR2BYTE/BYTE2ADDR macros that have been replaced by
inline functions.
2009-01-17 23:11:07 +00:00
Aaron Giles
7f2e4e19be Cleanups and version bump. 2009-01-15 08:33:24 +00:00
Aaron Giles
0b6ec32822 Made direct (opcode) access more robust. Direct access now crawls the
memory table to find its ranges, and caches them for fast access in
the future. It invalidates intersecting regions when new ones are
installed, and now properly handles mirrored ranges.

Also changed the disassembly view to call the decrypted read routines
for each opcode byte/word instead of fetching from a pointer, which
prevented opcodes that crossed range boundaries from working correctly,
even though they would execute correctly.
2009-01-13 15:32:36 +00:00
Aaron Giles
a70fdf00a1 CPU interface organization shuffle. The file cpuintrf.h now merely
describes the interface, but does not contain any implementation.
All remaining bits of implementation have been migrated either to
cpuexec.c or to debugcpu.c. Specifically, cpu_dasm() is now
debug_cpu_disassemble(), and cpu_set_dasm_override() is now
debug_cpu_set_dasm_override(). Also moved memory_address_physical()
to debug_cpu_translate(), since it was only ever used for
debugging.

Changed all CPU and sound cores to use memory_find_address_space()
instead of cpu_get_address_space(). The former is reliable even
during early initialization when the CPU cores generally need it.

Removed the dummy CPU core and cpuintrf.c.

Changed the core execution loop to directly call the execute
function instead of using the inline helper (which has been removed).
2008-12-22 17:35:27 +00:00
Aaron Giles
5630547540 More device normalization:
cpu_get_info_* -> device_get_info_*
  cpu_set_info_* -> device_set_info_*
  cpu_reset      -> device_reset

Removed the cputype_get_* macros as they are not necessary.

Removed cpuintrf_init() which is no longer necessary.
2008-12-16 16:30:28 +00:00
Aaron Giles
98c40f06db Made CPUs into proper devices. CPUs are now added in the
machine configuration just as any other device, and the
standard CPU configuration is performed via the inline
configuration macros.

Change cpu_type from an enumeration into a pointer to the
CPU's get_info function, very similar to device behavior.
For now all CPUs are declared in cpuintrf.h, but 
eventually they should be declared in the CPU's header
file, and the driver should #include that header.

Added function cpu_get_type() to return the CPU type.

Changed several cpu_* functions into macros that call
through to the equivalent device_* function.

The device system now maintains a parallel list of devices
based on type, for faster iteration through all devices
of a given type.

Cleaned up code that looped over CPUs via the machine->cpu
array to now loop using the type-based device list.

Removed start/stop/reset/nvram functions from the 
device_config in favor of grabbing them as needed.

Cleaned up the generic interrupt_enable code to work with
CPU devices instead of numbers.

Mapped the devtag_* functions to device_* functions via
macros instead of parallel implementations.
2008-12-16 15:02:15 +00:00
Aaron Giles
d92a2e0c4e Cleanups/version bump/added missing drivers. 2008-12-06 17:54:42 +00:00
Aaron Giles
e2c9b10241 Fixed some memory view-related issues:
* select correct memory region by default when created
   (should be first address space of visible CPU)
* when created, default bytes/chunk is correct
* when changing width, cursor no longer moves around
* memory regions display more than all 0xff now

Also fixed:

* qword big-endian memory reads no longer call little-endian handlers
* memory regions are tracked in creation order (show up in order
   in the menu now)
* ROMREGION_DISPOSE memory regions are not disposed if the debugger
   is enabled
2008-12-05 16:02:22 +00:00
Aaron Giles
3c6eacc96f Changed save state system to accept machine parameters where
appropriate, and to keep all global variables hanging off the
machine structure. Once again, this means all state registration
call sites have been touched:

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

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

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

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

Changed device information getters from device_info() to
device_get_info() to match the CPU and sound macros.
2008-12-05 08:00:13 +00:00
Aaron Giles
85b961f5af CPU_IS_LE -> ENDIANNESS_LITTLE
CPU_IS_BE -> ENDIANNESS_BIG

Also fixed help for step over/in to specify correct keys.
2008-12-04 06:08:32 +00:00
Aaron Giles
d924407859 Big debugger cleanup.
Important note for OSD ports: the get/set property functions have 
been retired for debug_views. Instead, there are specific functions
to perform each get/set operation. In addition, the format of the
update callback has changed to pass the osd private data in, and
the update callback/osd private data must be passed in at view
allocation time. And osd_wait_for_debugger() now gets a CPU object
instead of the machine.

Removed extra debugger tracking for address spaces and added some
of the useful data to the address_space structure. Updated all
debugger commands and views to use CPU and address space objects
where appropriate.

Added new memory functions for converting between bytes and
addresses, and for performing translations for a given address
space. Removed debugger macros that did similar things in favor
of calling these functions.

Rewrote most of the memory view handling. Disasm and register views
still need some additional tweaking.
2008-12-03 06:35:34 +00:00
Aaron Giles
1d05ea6089 Cleanups and version bump for 0.128u4. 2008-11-24 04:10:18 +00:00
Aaron Giles
5e980fa67b Removed memory context switch. Let the fun begin. 2008-11-24 00:00:18 +00:00
Aaron Giles
ba6a03d734 Memory banking now requires a machine object. This makes the memory
system fully global-free, apart from the "active_address_space"
which will eventually go away.

Also fixed compiler errors from last checkin.
2008-11-20 11:14:38 +00:00
Aaron Giles
371cd0a56d Another big one.
Moved memory global state into a struct hanging off of the machine.
Updated almost all memory APIs to take an address_space * where
appropriate, and updated all callers. Changed memory internals to
use address spaces where appropriate. Changed accessors to point
to the memory_* functions instead of the address space-specific
functions. Improved internal handling of watchpoints.

Added cputag_* functions: cputag_reset(), cputag_get_index(),
cputag_get_address_space(). These just expand via macros to an
initial fetch of the CPU via cputag_get_cpu() followed by the
standard CPU call.

Added debugger_interrupt_hook() and debugger_exception_hook() calls
which intelligently look at the debugger flags before calling.

Did minimal cleanup of debugger, mainly moving CPU-specific data
to hang off of the CPU classdata for more direct access.
2008-11-20 09:50:31 +00:00
Aaron Giles
0801d1254c Converted change_pc() into a no-op. Changed memory_set_direct_region() to
return a boolean indicating whether the given address was successfully
located in a bank. Change raw/decrypted access to look at this result, and
if the given address is not in a bank, calls through to the standard read
handlers.

In theory, this should prevent crashes when accessing opcodes. It does in
fact prevent mp_col3 from crashing.

Fixed address space mapping handlers to invalidate direct access regions
if a change is made to the mapping. This is needed to prevent the Sega
dynamic memory mapping chips from falling over.
2008-11-19 06:36:01 +00:00
Aaron Giles
e7c418ef0f Generalized the concept of opbase access into "direct" access.
Removed opbase globals to the address_space structure.
Cleaned up names of pointers (decrypted and raw versus rom and ram).
Added inline functions to read/write data via any address space.
Added macros for existing functions to point them to the new functions.
Other related cleanups.
2008-11-17 18:33:10 +00:00
Aaron Giles
a5bf427929 Added "tag" parameter to state_save_register_item_* calls. Removed
state_save_combine_module_and_tag() function in favor of passing
the tag when registering. Revisited all save state item registrations
and changed them to use the tag where appropriate.
2008-11-17 06:21:26 +00:00
Aaron Giles
1794cfa5a1 Terminology cleanup. "Machine" handlers are now "space" handlers. 2008-11-15 21:36:21 +00:00
Aaron Giles
41b8e37e3d Added generic read/write callbacks. 2008-11-15 21:04:15 +00:00
Aaron Giles
d10a7cccd5 God forbid, neogeo doesn't work.... 2008-11-15 20:02:40 +00:00
Aaron Giles
537c9becf6 WARNING: this compiles, but not fully cleanly, and a number of drivers
are broken.

Changed READ/WRITE handlers to accept an address_space * instead of a
machine *. The address_space object was enhanced to contain a machine
and a pointer to the relevant CPU object.

Fixed a number of errors found by the compiler, mostly in the core and
CPU/sound handlers, but there is a lot remaining to fix.

Added new function cpu_get_address_space() to fetch the address space
for calling in manually to these functions. In some instances, code
which should eventually be converted to a device is hard-coding fetching
the program space of CPU #0 in order to have something valid to pass.
2008-11-14 16:43:46 +00:00
Aaron Giles
63d10ee9bf Massive API cleanup/change. The primary goal is that all CPU-
related APIs now take a device pointer instead of an index.
All functions that take a CPU device are prefixed with cpu_*
All functions that are globally related to cpu execution
are prefixed with cpuexec_*. Below is a list of some of the 
mappings:

  cpu_boost_interleave     -> cpuexec_boost_interleave
  cpunum_suspend           -> cpu_suspend
  cpunum_resume            -> cpu_resume
  cpunum_is_suspended      -> cpu_is_suspended
  cpunum_get_clock         -> cpu_get_clock
  cpunum_set_clock         -> cpu_set_clock
  cpunum_get_clockscale    -> cpu_get_clockscale
  cpunum_set_clockscale    -> cpu_set_clockscale
  cpunum_get_localtime     -> cpu_get_local_time
  cpunum_gettotalcycles    -> cpu_get_total_cycles
  activecpu_eat_cycles     -> cpu_eat_cycles
  activecpu_adjust_icount  -> cpu_adjust_icount
  cpu_trigger              -> cpuexec_trigger
  cpu_triggertime          -> cpuexec_triggertime
  cpunum_set_input_line    -> cpu_set_input_line
  cpunum_set_irq_callback  -> cpu_set_irq_callback

In addition, a number of functions retain the same name but
now require a specific CPU parameter to be passed in:

  cpu_yield
  cpu_spin
  cpu_spinuntil_time
  cpu_spinuntil_int
  cpu_spinuntil_trigger
  cpu_triggerint

Merged cpuint.c into cpuexec.c. One side-effect of this
change is that driver reset callbacks are called AFTER the
CPUs and devices are reset. This means that if you make
changes to the CPU state and expect the reset vectors to
recognize the changes in your reset routine, you will need
to manually reset the CPU after making the change (since it
has already been reset).

Added a number of inline helper functions to cpuintrf.h for
managing addresses

Removed cpu_gettotalcpu(). This information is rarely needed
outside of the core and can be obtained by looking at the
machine->cpu[] array.

Changed CPU interrupt acknowledge callbacks to pass a CPU 
device instead of machine/cpunum pair.

Changed VBLANK and periodic timer callbacks to pass a CPU
device instead of machine/cpunum pair.

Renamed all information getters from cpu_* to cpu_get_* and
from cputype_* to cputype_get_*.
2008-11-13 06:59:57 +00:00
Aaron Giles
92f3053105 Major cpuintrf changes:
* added a set of cpu_* calls which accept a CPU device object;
  these are now the preferred means of manipulating a CPU

* removed the cpunum_* calls; added an array of cpu[] to the
  running_machine object; converted all existing cpunum_* calls
  to cpu_* calls, pulling the CPU device object from the new
  array in the running_machine

* removed the activecpu_* calls; added an activecpu member to
  the running_machine object; converted all existing activecpu_*
  calls to cpu_* calls, pulling the active CPU device object
  from the running_machine

* changed cpuintrf_push_context() to cpu_push_context(), taking
  a CPU object pointer; changed cpuintrf_pop_context() to
  cpu_pop_context(); eventually these will go away

* many other similar changes moving toward a model where all CPU
  references are done by the CPU object and not by index
2008-11-10 07:42:09 +00:00
Aaron Giles
099373081e Added new functions for building device-relative tags. Changed machine
configuration builder to use these functions. Also changed the laserdisc
player devices to use them. Updated Z80 CTC/SIO code to assume that the
CPU provided for the clock is relative to the device that the CTC/SIO
belong to. Updated memory code to assume that regions and devices
referenced by the memory map are relative to the device the associated
CPU belongs to.
2008-10-03 16:29:33 +00:00
Aaron Giles
db3e968a6d CPU-internal regions now have priority again. Fixed mario by
installing a handler in the SOUND_START function.

02249: All Sets in zn.c: Game Hangs 
02248: All sets in m58.c: No sound in game 
02241: kncljoe, kncljoea: Missing AY-3-8910A sound effects. 
02240: All Sets in namcos12.c: Game Freeze 
02239: stunrun: No OKI6295 sound.
2008-09-18 15:54:25 +00:00
Aaron Giles
fc453dc652 Fixed crash when hitting watchpoints on static handlers. 2008-09-13 06:36:29 +00:00
Aaron Giles
3d1dbafcc2 From: Oliver Stoeneberg [mailto:oliverst@online.de]
Subject: Machine -> machine

This is a big patch adding running_machine* parameters and using 
"machine" where available.
2008-09-11 15:57:52 +00:00
Aaron Giles
2398d51941 Fixed memory handling of internal banks. They should be LOWER priority than
the driver's memory maps.

Reverted recent changes to MCS-48 core that were very hacky and which crashed
many games. You can now properly override the internal memory map and do
your own banking.

Also fixed 02204: masao: Memory bank error.
2008-09-11 14:33:52 +00:00
Aaron Giles
cffe201094 From Oliver Stoeneberg [oliverst@online.de]
This contains three different patches:

20080829.patch
Introducing the running_machine* parameter in a few more places. Next 
step would be to make the execute_* function aware of it, if that's 
OK. Also used the machine parameter in memory.c were it's available.

20080829_1.patch
The already discussed and probably being rejected removal of 
dreprecat.h from debugger.h. I think this is a low-risk patch (we had 
worse cleanups) and it lowers the risk of new code using deprecated 
function beign introduced in MAME/MESS, because there is no invisible 
inclusion of deprecat.h anymore (I think one driver - kofball.c - got 
it with deprecated code).

20080829_2.patch
The last Machine -> machine conversion I had sitting in my local 
tree. I know the proper way is to turn them into devices, but I still 
haven't looked into that.
2008-09-04 08:55:01 +00:00
Nathan Woods
15969c0428 Readded generic calls to install memory handlers that were in long before
0.126u5 - these are useful on the MESS side for things like the PC driver
2008-08-19 11:13:43 +00:00
Aaron Giles
8b8585328c From: Christophe Jaillet [mailto:christophe.jaillet@wanadoo.fr]
Subject: Profiler related
Hi,

here is a smalll patch that :
   - remove include "profiler.h" to files that do not use profiling function
        * emu/machine/laserdsc.c
        * osd/windows/video.c

    - use PROFILER_USER2 instead of PROFILER_USER1 in mame/video/tx1.c
      USER1 was used twice, USER3 once. I guess that USER1 should be used
only once and USER2 used in the 2nd place

   - remove unused MACRO in emu/memory.c

Best regards,
Christophe JAILLET
2008-08-19 06:13:26 +00:00
smf-
e334a63782 reverted unit mask changes and removed the unused & unsafe memory_install functions. 2008-08-18 12:08:08 +00:00
smf-
5c5337424a Added unit mask to all memory installs that override the bus width. You couldn't install a handler with a different width before, as it complained about the lack of the unit mask. So I've assumed it's safe for all current calls to be changed to the one that picks up the cpu bus width. 2008-08-17 10:15:22 +00:00
Aaron Giles
2d165fe1c3 Fixed I/O watchpoints. 2008-08-06 05:04:05 +00:00
Aaron Giles
57bd1856b5 Cleanups/version bump. 2008-07-31 09:00:13 +00:00
Aaron Giles
e70d4b0a85 (Modified to allow for overwrites of RAM ranges only.)
From: Atari Ace [mailto:atari_ace@verizon.net] 
Subject: [patch] Stricter ADDRESS_MAP checks

Hi mamedev,

The current implementation of address maps is lacking some useful
checks of the initial tokens.  In particular, it doesn't validate that
a particular entry doesn't try to define the same handler multiple
times.

The attached patch adds this and some other validations as fatalerrors
in address_map_detokenize, and fixes the affected maps.  The errors
generally fall into the following categories.

1.  AM_RAM AM_WRITE(...).  Should have been AM_RAM_WRITE(...)
2.  AM_RAM AM_READWRITE(...).  The AM_RAM is a NOP.
3.  AM_RAM AM_RAMBANK(...).  The AM_RAM is a NOP.
4.  AM_ROM AM_ROMBANK(...).  The AM_ROM is a NOP.
5.  AM_ROM AM_READ(...).  The AM_ROM is a NOP.

One peculiar error was in equites.c, where there were two AM_BASE
entries.

~aa
2008-07-29 17:08:43 +00:00
Aaron Giles
4a6fc8d5e5 Region classes go bye-bye. 2008-07-28 16:22:20 +00:00
Aaron Giles
27fed1ec97 Changed the way memory regions are referenced. Instead of a single
integer value, regions are now referred to by a region class and
a region tag. The class specifies the type of region (one of CPU,
gfx, sound, user, disk, prom, pld) while the tag uniquely specifies
the region. This change required updating all the ROM region
definitions in the project to specify the class/tag instead of
region number.

Updated the core memory_region_* functions to accept a class/tag
pair. Added new memory_region_next() function to allow for iteration
over all memory regions of a given class. Added new function
memory_region_class_name() to return the name for a given CPU
memory region class.

Changed the auto-binding behavior of CPU regions. Previously, the
first CPU would auto-bind to REGION_CPU1 (that is, any ROM references
would automatically assume that they lived in the corresponding
region). Now, each CPU automatically binds to the RGNCLASS_CPU region
with the same tag as the CPU itself. This behavior required ensuring
that all previous REGION_CPU* regions were changed to RGNCLASS_CPU
with the same tag as the CPU.

Introduced a new auto-binding mechanism for sound cores. This works
similarly to the CPU binding. Each sound core that requires a memory
region now auto-binds to the RGNCLASS_SOUND with the same tag as the
sound core. In almost all cases, this allowed for the removal of the
explicit region item in the sound configuration, which in turn 
allowed for many sound configurations to removed altogether.

Updated the expression engine's memory reference behavior. A recent
update expanded the scope of memory references to allow for referencing
data in non-active CPU spaces, in memory regions, and in EEPROMs.
However, this previous update required an index, which is no longer
appropriate for regions and will become increasingly less appropriate
for CPUs over time. Instead, a new syntax is supported, of the form:
"[tag.][space]size@addr", where 'tag' is an optional tag for the CPU
or memory region you wish to access, followed by a period as a 
separator; 'space' is the memory address space or region class you
wish to access (p/d/i for program/data/I/O spaces; o for opcode space;
r for direct RAM; c/u/g/s for CPU/user/gfx/sound regions; e for 
EEPROMs); and 'size' is the usual b/w/d/q for byte/word/dword/qword.

Cleaned up ROM definition flags and removed some ugly hacks that had
existed previously. Expanded to support up to 256 BIOSes. Updated
ROM_COPY to support specifying class/tag for the source region.

Updated the address map AM_REGION macro to support specifying a
class/tag for the region.

Updated debugger windows to display the CPU and region tags where
appropriate.

Updated -listxml to output region class and tag for each ROM entry.
2008-07-28 09:35:36 +00:00
Aaron Giles
e376a53661 Cleanups and version bump. 2008-07-03 15:50:46 +00:00
Aaron Giles
7d1d630f91 Fixed some save state problems in the DCS driver. Still comes out garbled
on a load, however. Extended memory.c to support up to 4096 banks.
2008-06-30 16:03:49 +00:00
Aaron Giles
64048d74f7 Oops, forgot to shift addresses for 16,32,64-bit watchpoint stubs. 2008-06-28 17:55:58 +00:00
Aaron Giles
75d18b3a33 Changed how watchpoints work so that supporting them adds 0 overhead
unless some are actually live.

Changed a few call sites from using memory_set_context() to cpuintrf_push_context().
2008-06-28 07:21:54 +00:00
Aaron Giles
68f3a9ab9e Removed DEBUGGER flag from makefile and ENABLE_DEBUGGER
macro from the source code. All MAME builds now include
the debugger, and it is enabled/disabled exclusively by
the runtime command-line/ini settings. This is a minor 
speed hit for now, but will be further optimized going 
forward.

Changed the 'd' suffix in the makefile to apply to DEBUG
builds (versus DEBUGGER builds as it did before).

Changed machine->debug_mode to machine->debug_flags.
These flags now indicate several things, such as whether
debugging is enabled, whether CPU cores should call the
debugger on each instruction, and whether there are live
watchpoints on each address space.

Redesigned a significant portion of debugcpu.c around
the concept of maintaining these flags globally and a
similar, more complete set of flags internally for each
CPU. All previous functionality should work as designed
but should be more robust and faster to work with.

Added new debugger hooks for starting/stopping CPU
execution. This allows the debugger to decide whether
or not a given CPU needs to call the debugger on each
instruction during the coming timeslice.

Added new debugger hook for reporting exceptions.
Proper exception breakpoints are not yet implemented.

Added new module debugger.c which is where global
debugger functions live.
2008-06-26 14:51:23 +00:00
Aaron Giles
57c35a0efc From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] memory_region madness reloaded
Hi mamedev,

The memory_region and memory_region_length functions are probably the
two most common functions in MAME that don't take a machine parameter
but should given the syntax of the related apis memory_region_type and
memory_region_flags.  Clearly they didn't get the parameter because of
the sheer number of changes needed to change the apis.  This pair of
patches makes the change, and deals with the consequences.

The second patch then changes the api for memory_region and
memory_region_length, and fixes the fallout.  It generally plumbs
through machine parameters where needed, except for the case of sound
apis which I deferred doing so till later.  This increased the number
of deprecat.h includes by ~50.  Given it is a massive patch, there are
bound to be a few mistakes in it (I had to make ~20% of the changes by
hand), but I exercised care and reviewed the patch several times to
minimize the problems.
2008-06-23 08:32:42 +00:00
Aaron Giles
ed6ad8b4f9 PowerPC dynamic recompiler: [Aaron Giles]
- rewrote PowerPC implementation as a dynamic recompiler on top
    of the universal recompiler engine
 - wrote a front-end to analyze PowerPC code paths and register usage
 - wrote a common shared module with C implementations of tricky
    CPU behaviors
 - added separate CPU types for the variants supported, instead of
    relying on a hidden model enum
 - rewrote the serial port emulation for the 4xx series to be more
    accurate and not rely on separate DMA handlers
 - rewrote the MMU handling to implement a software TLB that faults
    in pages and handles changed bits appropriately
 - implemented emulation of the PowerPC 603's software TLB, which
    allows the model 3 games to run without a hack to disable the MMU

Updated the PowerPC disassembler to share constants with the rest of
the core, and to more aggressively use simplified mnemonics, especially
for branches. [Aaron Giles]

Universal recompiler:
 - fixed frontend to handle opcode widths different from bus width
 - added several new opcodes:
    * (D)GETFLGS - copies the UML flags to a destination operand
    * FDRNDS - rounds a double precision value to single precision
 - renamed several opcodes:
    * SETC   -> CARRY
    * XTRACT -> ROLAND
    * INSERT -> ROLINS
 - consolidated the following opcodes:
    * LOAD?U -> LOAD
    * LOAD?S -> LOADS
    * STORE? -> STORE
    * READ?U -> READ
    * READ?M -> READM
    * WRITE? -> WRITE
    * WRITM? -> WRITEM
    * SEXT?  -> SEXT
    * FTOI?? -> FTOINT
    * FFRI?  -> FFRINT
    * FFRF?  -> FFRFLT
 - removed some opcodes:
    * FLAGS - can be done with GETFLGS/LOAD4/ROLINS
    * ZEXT - can be achieved with AND
    * READ?S - can be achieved with READ/SEXT
 - updated C, x86, and x64 back-ends to support these opcode changes
 - updated disassembler to support these opcode changes
 
MIPS3 dynamic recompiler:
 - updated to use new/changed opcode forms
 - changed context switch so that it only swaps a single pointer

Konami Hornet changes: [Aaron Giles]
 - updated to new PowerPC configurations
 - updated some memory handlers to be native 8-bit handlers
 - cleaned up JVS implementation to work with new serial code
 - added fast RAM for the work RAM to give a small speed boost

Konami GTI Club changes: [Aaron Giles]
 - updated to new PowerPC configurations
 - updated some memory handlers to be native 8-bit handlers

Konami Viper/ZR107 changes: [Aaron Giles]
 - updated to new PowerPC configurations

Sega Model 3 changes: [Aaron Giles]
 - updated to new PowerPC configurations
 - reimplemented/centralized interrupt handling
 - these games are broken for the moment

Fixed crasher due to some Konami games using 8 layers in
the K056832 implementation, even though it was only written
for 4. [Aaron Giles]

Added fisttp opcode to i386 disassembler. [Aaron Giles]
2008-06-05 08:34:13 +00:00
Aaron Giles
d5ff8c002a Cleanups and version bump. 2008-05-22 05:19:16 +00:00
Aaron Giles
defcc8895b From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] Missed Machine->machine changes

Hi mamedev,

A short incremental to my last deprecat.h patches.  This one is the
result of a slightly improved fixup script, which finds more cases
where Machine can be replaced with machine.  Six more files lose
deprecat.h.

~aa
2008-05-22 03:24:45 +00:00
Aaron Giles
096331c856 Restructured input port internals and cleaned up inptport.c:
* Input ports are now maintained hierarchically. At the top
level are input ports, which contain a list of fields. Each
field represents one or more bits of the port. Certain fields
such as DIP switches and configuration switches contain a
list of settings, which can be selected. DIP switch fields
can also contain a list of DIP switch locations.

* Normalized behavior of port overrides (via PORT_INCLUDE or
by defining multiple overlapping bits). All fields within a
port are kept in strict increasing bit order, so altered DIP
switches are now kept in the appropriate order. This addresses
MAMETesters bug 01671.

* Live port state is now fully separate from configured 
state. This is manifested in a similar way to devices, where
a const list of ports can be managed either offline or live.
Each port has a pointer to an opaque set of live state which
is NULL when offline or valid when live. Each port also has
a running_machine * which is also NULL when offline.

* Because of this new arrangement, the conversion from tokens
to a list of ports now requires reasonably complex memory
allocation, so these port lists must be explicitly allocated
and freed (they are not mantained by automatic resource
allocation).

* Custom and changed callbacks now take a pointer to a field
config instead of a running machine. This provides more
information about what field triggered the change notification.
The machine can be found by referenced field->port->machine.

* The inptport.c module has been cleaned up and many 
ambiguities resolved. Most of this is internal, though it did
result in osd_customize_inputport_list() being changed to
osd_customize_input_type_list(). The parameter to this function
is now a linked list instead of an array, and the structures
referenced have been reorganized somewhat.

* Updated config.c to pass machine parameters to its callbacks.

* Updated validity checks, XML output, and UI system to handle
the new structures.

* Moved large table of default input settings to a separate
include file inpttype.h.

* Removed gross hacks in trackfld and hyperspt NVRAM. These
may be broken as a result.
2008-05-15 16:25:03 +00:00
Aaron Giles
44fbeff9bf From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] Remove opbase globals from the public interface

Hi mamedev,

There are several variables associated with opbase handling which are
global and documented in memory.h and thus their use is not well
controlled.  This patch attempts to remedy this.  Because they are
used in various inline memory functions, they can't yet be made local
to memory.c, but by rescoping their declaration they can be hidden,
much like we hide totalcpu.

Most of the uses are in OPBASE_HANDLER() macros, so by encapsulating
the opbase state into a struct and adding that to the handler
interface those can be converted to local variable manipulation. There
is one use in missile.c in a MACHINE_START that I simply removed, it
shouldn't be needed.

One side effect of this patch is that the various unsafe memory macros
can't be used directly, they will be a compiler error now.  That is
probably for the best.

~aa
2008-05-15 08:22:17 +00:00
Aaron Giles
e91eb4007c Flipped the damn mem_mask. It is no longer inverted when passed to
read/write handlers. Updated all drivers accordingly. Hope I didn't
miss anything important!

Blame OG and smf for goading me into it. :)
2008-04-20 02:38:35 +00:00
Aaron Giles
9dd3f691ba Expanded the set of memory accessor functions. In addition to
direct byte, word, dword, and qword accessors for all bus sizes,
there are now masked word, dword, and qword accessors for all
bus sizes.

IMPORTANT: masks that are passed to the _masked_* functions are
NOT inverted. Although inverted masks are still passed to callback
functions, when you request a masked read or write the masks should
represent the bits you want.

Updated the various MIPS cores that use these functions to invert
their masks.
2008-04-19 19:09:24 +00:00
Aaron Giles
b35c15fef5 Cleanups and version bump to 0.124u3. 2008-04-17 05:26:05 +00:00
Aaron Giles
ffc326f8be Converted the IDE controller to a device. Updated all drivers
accordingly.

Added new functions for dynamically installing device memory 
read/write handlers.

Updated install_memory_XXX_handler() functions to take a machine
parameter. Updated all drivers accordingly.

Merged installation of read and write handlers where appropriate.

Simplified memory.c code for dynamic installation so that a single
function handles all the work; a NULL read or write handler 
indicates not to install anything for reads or writes.
2008-04-15 16:49:50 +00:00
Aaron Giles
71ca9ecec2 Switched subhandlers to using masks instead of shifts. Reduced the number
of stub handlers required as a result. Updated all drivers accordingly.
2008-04-15 06:39:34 +00:00
Aaron Giles
7b97535eae Added support for using smaller-sized memory handlers directly in
memory maps. To do so, you either need to specify a shift amount 
(mapping to a particular subset of the bus) or SHIFT_PACKED, which
maps a single larger sized read/write down to multiple reads or
writes at the smaller size.

Removed word-sized handlers from 6821pia.c. Updated drivers that
needed them to use these new interfaces instead.

Updated gaelco3d.c and itech8.c to remove the need for memconv.h
by using this new feature.

Re-removed input_port_set_digital_value().
2008-04-14 16:47:02 +00:00
Aaron Giles
439dbe872a Cleanups and version bump to 0.124u2. 2008-04-12 05:16:26 +00:00
smf-
22df06f724 fixed sign extension when inverting mem_mask. 2008-04-11 18:01:14 +00:00
Aaron Giles
dbb98c5473 Reduced the number of save state callback types from 3 to 1. The
only remaining form is the one that takes a pointer parameter.

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

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

Removed unnecessary postload callbacks which only marked all tiles
dirty, since this is done automatically by the tilemap engine.
2008-04-11 05:41:46 +00:00
Aaron Giles
4867aa38b9 Take two of the previous changes. I think this is a little simpler,
using masks instead of the generic byte/word/dword read functions.
2008-04-09 14:48:22 +00:00
Aaron Giles
eeee1cb437 Rewrote core memory handlers as inline functions. These should be easier to
trace through in a debug build, yet should operate the same as before.

Created a complete set of functions for all databus sizes (8,16,32,64) and
all endiannesses. A few functions are redundant, but it is now very clear
which functions to use in which scenarios. It is also now possible to rely
on being able to access values of 8, 16, 32 or 64 bits via the built-in
accessors without fear of crashing.

Updated all cores using 8-bit handlers to explicitly call the 8-bit handlers
with the appropriate endianness.

Fixed a few games which were calling n-bit handlers directly to use the
generic forms. In the future, this is all the access drivers will have.
2008-04-09 07:31:47 +00:00
Aaron Giles
31336e491e Cleanups and version bump to 0.124u1. 2008-04-03 07:57:25 +00:00
Aaron Giles
984380354e Added fatal error if AM_READ_PORT() references a non-existent port. 2008-03-28 00:03:25 +00:00
smf-
5ed703d6d5 fixed another bug in new debug hook code, data wasn't shifted properly in all cases. 2008-03-27 21:04:02 +00:00
smf-
07459e6491 Passes mem_mask to the read and write debug hooks. This allows the address & size of the memory access to be correctly calculated when using a memory call that takes a mem_mask. Unexpected results will occur if you pass in a mem_mask that has a gap in. For example 0x00ff00ff is treated as a 3 byte operation, a watchpoint for the gap will still trigger. To simplify the mem_mask decoding it is inverted before passing to the debugger. 2008-03-27 20:23:36 +00:00
smf-
7d38bf085f reverted, I misunderstood something and it's broken. I'm on it. 2008-03-27 19:56:24 +00:00
smf-
8b7582a477 Passes mem_mask to the read and write debug hooks. This allows the address & size of the memory access to be correctly calculated when using a memory call that takes a mem_mask. While testing I found that the address had already had it's lower bits masked out, so watch points were broken already. Unexpected results will occur if you pass in a mem_mask that has a gap in. For example 0x00ff00ff is treated as a 3 byte operation, a watchpoint for the gap will still trigger. To simplify the mem_mask decoding it is inverted before passing to the debugger. 2008-03-27 19:22:20 +00:00
Aaron Giles
9476c50ee6 Cleanups for 0.124. Marked Mermaid as working per checkin comment. 2008-03-24 04:07:46 +00:00
Aaron Giles
b28f2c2504 Explicitly fixed unmapped handler masks so that we don't report
all unmapped addresses as 0.
2008-03-20 14:16:00 +00:00
Aaron Giles
a6b4a6ad50 Cleanups and version bump to 0.123u5. 2008-03-13 16:21:46 +00:00
Aaron Giles
9d3f7f8680 From: Mariusz Wojcieszek
Attached is update for Merit hardware based on V9938 (CRT-250 and CRT-260 - meritm.c).

New playable games:

Pit Boss II
Super Pit Boss
Pit Boss Megastar
Megatouch IV
Megatouch IV Tournament Edition
Megatouch 6
2008-03-13 15:04:33 +00:00
Aaron Giles
d5561a8e75 Removed cpu_scalebyfcount().
Changed input ports to register a frame callback, which is
called immediately after throttling and updating. This is the
proper "sync point" between emulated time and real time. Moved
all analog and digital port processing into a central place
here. Added tracking of time since the previous frame update
and use that as an estimate for the time of the current frame.
This is used to scale analog ports without the use of
cpu_scalebyfcount(). This is not perfect in the case where
frame rates are dynamic (vector games), but works well for
other cases.

Further cleanup of memory header and code.
2008-03-12 05:13:03 +00:00
Aaron Giles
c4cfa7bde4 Compilation fixes for my last checkin (sorry). 2008-03-10 16:22:01 +00:00
Aaron Giles
8006568b87 More WIP cleanup of memory.*
Made address versus byte offsets explicit throughout.
Removed some unused parameters.
Consolidated initialization process.
Removed maximum memory block count.
Centralized bank management.
Added masked handlers and change_pc to the accessors.
Added memory_get_accessors() to return a pointer to the accessors
   for a given address space/databus width/endian configuration.

More to come.
2008-03-10 16:00:26 +00:00
Aaron Giles
0862cce453 Replaced the following macros (SMH == static memory handler)
MRA*_BANK*/MRA*_BANK* -> SMH_BANK*
   MRA*_RAM/MRA*_ROM     -> SMH_RAM
   MRA*_ROM/MWA*_ROM     -> SMH_ROM
   MRA*_NOP/MWA*_NOP     -> SMH_NOP
   MRA*_UNMAP/MWA*_UNMAP -> SMH_UNMAP

This removes the silly need for a bunch of redundant constants
with faux type definitions that didn't buy anything.

Moved some memory system constants into memory.c.
2008-03-10 02:29:15 +00:00