Commit Graph

87 Commits

Author SHA1 Message Date
Aaron Giles
fe289e67f5 > -----Original Message-----
> From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Sunday, September 27, 2009 7:58 AM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] More _NAME macros
> 
> Hi mamedev,
> 
> MAME's idiom for function/data macros is to first implement
> <name>_NAME, then implement the other macros in terms of the _NAME
> macro.  Then in principle only a single line needs editing to change
> the naming convention.
> 
> This patchset implements this idiom more completely.  The first patch
> adds some missing _NAME macros and fixes cases in source files that
> should be using the macros.  The second patch then changes header
> files where the macros should have been used, but weren't.  This
> required changing the idiom for removing a machine driver function
> pointer from MDRV_<FUNCTION>(NULL) to MDRV_<FUNCTION>(0), to avoid
> problems with NULL being macro expanded.  This actually unifies the
> handling of all such cases, as we already had ipt_0 and driver_init_0.
> It also required reworking the devtempl.h implementation in a way that
> triggered a warning on MSVC about using empty macros, so vconv.c
> needed to be updated.  The third patch then renames all the _NAME and
> _0 macros to verify that all the cases have been covered, so it isn't
> intended to be applied.
> 
> ~aa
2009-10-01 17:27:29 +00:00
Aaron Giles
38916f18c8 Made INI file order explicit via priorities. 2009-09-21 08:45:00 +00:00
Aaron Giles
e47035e834 Cleanups and version bump. 2009-09-10 08:39:42 +00:00
Aaron Giles
50b4a43bfd Fix CPP_COMPILE (except for internal compiler error on snes.c). 2009-09-08 16:58:02 +00:00
Aaron Giles
96d7f2cf3b Remove remaining references to machine->cpu[n]. Removed cpu[n] array.
Replaced with machine->firstcpu which is a fast access to the head
of the list of CPUs.
2009-09-08 09:13:10 +00:00
Aaron Giles
3d59122bb2 Added debug_global_input_code_pressed() for use in debugging.
Also some other small tweaks/cleanups.
2009-09-08 01:40:11 +00:00
Aaron Giles
4a80c53a8d [from AtariAce]
Hi mamedev,

This patch continues deglobalifying the MAME core, this time targeting
sound.c.  The first two patches adds running_machine to apis in
sound.h that lack it (the first patch is generated by the perl script,
the second patch fixes some cases it didn't handle well).  The last
patch then removes the globals in the traditional way.

~aa
2009-08-30 05:42:33 +00:00
Aaron Giles
c3b50fe048 Changed profiler to separate start/stop cases. [Christophe Jaillet] 2009-08-19 16:43:04 +00:00
Aaron Giles
7af2304c81 Removed PREDECODE_GFX compile flag, as the on-the-fly decoding seems
to be working reliably.

Deprecated the ROMREGION_DISPOSE flag, as 98% of the use of it no
longer is applicable with on-the-fly decoding, and the remaining
cases are difficult to identify among the others.
2009-07-09 08:03:31 +00:00
Aaron Giles
ab7d486957 Cleanups and version bump. 2009-05-28 15:59:16 +00:00
Aaron Giles
fc14ac39cc From: William Krick [mailto:bill@3feetunder.com]
Sent: Monday, May 25, 2009 9:31 PM
To: submit@mamedev.org
Subject: DIFF: vertical.ini & horizont.ini

This simple 4 line change (5 if you count the comment) to mame.c adds the
ability to parse vertical.ini and/or horizont.ini files.

I wanted this functionality so that I could specify different resolution
and artwork options for all vertical games in one shot.

I had a MAMEUI user ask that I submit this code to baseline MAME so that
it could be included in MAMEUI GUI without making changes to the core
codebase.

I chose to shorten "horizontal" to "horizont" to make sure that the
ini file falls within 8.3 filename guidelines.

thanks for your consideration
...
Krick
2009-05-28 15:13:53 +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
54498e58ed Add muting just before saving the NVRAM, and de-mute just after
loading the NVRAM. Should cure the stuck sound issue for games
with large NVRAM.
2009-03-09 04:43:02 +00:00
Aaron Giles
cef6764910 Cleanups and version bump. 2009-02-17 15:31:20 +00:00
Aaron Giles
5cb6bf00e9 Ok, this is The Big One.
Please note: regression testing is in progress, but the first round 
of glaring regressions have already been taken care of. That said, 
there is likely to be a host of regressions as a result of this 
change.

Also note: There are still a few rough edges in the interfaces. I
will try to clean them up systematically once the basic system is
working.

All sound chips are now proper devices.

Merged the sound chip interface into the device interface,
removing any differences (such as the whole ALIASing concept).

Modified every sound chip in the following ways:
 * updated to match the device interface
 * reduced read/write handlers down to the minimal number
 * added the use of get_safe_token() for ensuring correctness
 * other minor cleanup

Removed the custom sound device. The additional work to just make
custom sound cases into full devices is minimal, so I just converted
them all over to be actual devices.

Vastly simplified the sound interfaces, removing the ghastly
sndti_* business and moving everyone over to using tags for
sound identity. sndintrf, like cpuintrf, is now just a header
file with no implementation.

Modified each and every driver that references a sound chip:
 * all memory maps explicitly reference the targeted device via
    AM_DEVREAD/AM_DEVWRITE/AM_DEVREADWRITE
 * 16-bit and 32-bit accesses to 8-bit chips no longer use
    trampoline functions but instead use the 8-bit AM_DEVREAD/WRITE
    macros
 * all references to sound chips are now done via tags
 * note that these changes are brute force, not optimal; in many
    cases drivers should grab pointers to devices in MACHINE_START
    and stash them away
2009-02-11 19:48:39 +00:00
Aaron Giles
ac0abd1706 Major drawgfx cleanup, global removal, and feature enhancements:
- Added built-in dirty tile tracking to the gfx_element. This removes
    the need for all drivers that had dynamically populated graphics
    to do their own dirty tracking. Tiles are marked dirty via the
    new function gfx_element_mark_dirty(). Any driver that needs access
    to the decoded data must call gfx_element_get_data() in order to
    ensure that the referenced tile is clean before proceeding.
    
 - In order to support dirty tracking, the gfx_element was enhanced to
    keep track of the original source pointer, so that it can go back
    and regenerate tiles on demand. For systems that set NULL for the
    region in the gfxdecode, they must use gfx_element_set_source()
    to specify a pointer to the raw data before drawing anything.
 
 - Changed allocgfx() to gfx_element_alloc(), and added parameters to
    specify the source data pointer, base color index, and total colors.
    Many drivers had to whack these values in after the fact, so this
    allowed for some minor additional cleanup.
 
 - Added a dirtyseq member to the gfx_element struct. This is 
    incremented on each tile dirty, and can be used to sniff if 
    something has changed.
 
 - Added logic in the tilemap engine to track which gfx_elements are
    used for a given tilemap, and automatically detect changes to the
    tiles so that drivers no longer have to explicitly invalidate the
    tilemap when tiles change. In the future, this may grow smarter to
    only invalidate the affected tiles, but for now it invalidates the
    entire tilemap.
 
 - Updated a number of drivers to remove their own dirty handling and
    leverage the new internal dirty marking.

 - Because the source data must always be present, updated the atarigen
    zwackery and mystwarr graphics handing code to support this.

 - Thanks to the dirty tracking, this actually allows all gfx decoding
    to happen on the fly instead of all at once up front. Since there 
    was some concern that this would cause undesirable behavior due to 
    decoding lots of tiles on the fly, it is controlled with a compile-
    time constant in mame.h (PREDECODE_GFX). Set this to 1 to get the
    old behavior back.
    
 - Moved decodechar() and decodegfx() to deprecat.h. All drivers in MAME
    have been updated to simply mark tiles dirty and let the rendering
    system decode them as needed, so these functions may go away in the
    future.

 - Rewrote entirely the rendering code in drawgfx. This code previously
    used extensive recursive #includes and tricks to build, and was
    very difficult to understand. The new code is based off of a set of 
    macros defined in drawgfxm.h. These new macros separate the core 
    rendering logic from the per-pixel operation, allowing the operation 
    to be easily "plugged" into any of the renderers. These macros are
    also available to any driver that wants custom rendering behavior
    that is similar to existing core behavior, without needing to
    populate the core with esoteric one-off rendering behaviors.
 
 - Added a set of new functions for [p]drawgfx[zoom], one for each
    transparency type. The old [p]drawgfx[zoom] functions are still
    present, but now switch off the transparency type and call through
    to one of these new transparency-specific functions. The old
    functions are also now reduced to only supporting TRANSPARENCY_NONE,
    TRANSPARENCY_PEN, and TRANSPARENCY_PENS. All other rendering types
    must use the new functions.
 
 - All new rendering functions have extensive asserts to catch improper
    clipping rectangles and other common errors.
    
 - All new rendering functions automatically downgrade to optimized
    versions where appropriate. For example, calling drawgfx_transpen
    with an out-of-range pen automatically falls back to drawgfx_opaque.
    And drawgfxzoom_* with xscale=yscale=1.0 automatically falls back
    to drawgfx_*. And many other examples. In general, this relieves 
    drivers from needing to make these sorts of decisions.
 
 - All new rendering functions have a consistent parameter order that
    is a bit different from the existing functions. The cliprect
    parameter is now specified immediately after the destination bitmap,
    to match the convention used throughout the rest of the system.
    The core parameters are followed by the scale parameters (for the
    zoom functions), and then followed by the priority parameters (for
    the pdrawgfx* functions), finally followed by any PIXEL_OP*-specific
    parameters (such as transparent pen, alpha, drawing tables, etc.)
  
 - Removed drawgfx_alpha_cache, alpha_set_level(), and the inline 
    functions alpha_blend16() and alpha_blend32(). To render graphics 
    with alpha, use the new [p]drawgfx[zoom]_alpha functions, which 
    take an explicit alpha value. To render tilemaps with alpha, the 
    TILEMAP_DRAW_ALPHA option now takes an explicit alpha parameter. 
    And to do you own alpha blending, use the alpha_blend_r16() and
    alpha_blend_r32() functions, which take an explicit alpha.
  
 - Updated a number of drivers as a result of removing the implicit
    alpha in the drawgfx_alpha_cache. 

 - Removed drawgfx_pen_table and TRANSPARENCY_PEN_TABLE. To achieve 
    the same effect, build your own table and pass it to 
    [p]drawgfx[zoom]_transtable, along with a pointer to the 
    machine->shadow_table to use for shadows. Eventually 
    machine->shadow_table is likely to go away, and drivers will need 
    to fetch the shadow table from the palette directly.
    
 - Updated a number of drivers to remove use of drawgfx_pen_table.
 
 - Removed TRANSPARENCY_ALPHARANGE; it was only used by the psikyosh
    driver, so it is now moved locally into that driver and built
    using the macros in drawgfxm.h.
 
 - Removed TRANSPARENCY_PEN_RAW; to achieve the same effect, call the
    new [p]drawgfx[zoom]_transpen_raw() functions. Updated drivers to
    make this change.
 
 - Removed the unused mdrawgfx* functions entirely.
 
 - Added new function gfx_element_set_source_clip() to specify a
    source clipping rectangle for any element. This replaces the nasty 
    hacks that were being used in bnstars, ms32, namcos86, and namcos1
    to achieve similar behaviors.
    
 - Simplified the copyrozbitmap() functions to match the copybitmap()
    functions in having separate opaque and transparent versions. Also
    removed the 'priority' parameter which was only used by one driver,
    and moved that logic into a custom renderer built using macros in
    drawgfxm.h. Updated copyrozbitmap* to use the destbitmap, cliprect
    parameter ordering convention as well.
 
 - Simplified the draw_scanline*() functions to always render opaque.
    Only one driver was doing otherwise, and it now does its work
    internally (draw_scanline is dead-simple ever since we moved 
    rotation to the OSD code; I almost just removed it entirely).
 
Other changes:

 - Added a cliprect to the bitmap_t type, which describes the full 
    bitmap.
    
 - Removed tilemap_set_pen_data_offset; unfortunately, this adds a
    random tile offset behind the scenes and goes against the dirty
    tile detection and invalidation. Updated the mainsnk, snk, and 
    snk68 drivers to use old fashioned tile banking. (Sorry Nicola.)
 
 - Changed zac2650 gfxdecode to use scale factors.

 - Added function video_assert_out_of_range_pixels() to help find
    the source of invalid pixels (generally out-of-range palette
    entries due to invalid data or sloppy calculations). Place this
    after each step in your rendering in a debug build to discover
    which code is generating improper pixels.
2009-01-12 11:05:15 +00:00
Aaron Giles
bf20e586d1 Significantly optimized the inner execution loop. arknoid2 is ~2.5x
faster with maximum interleave now.
2008-12-22 10:28:20 +00:00
Aaron Giles
f36fc8641e This update is the below two patches, plus the remaining changes
necessary to remove 12 of the final 14 references to the global
Machine. The remaining 2 are in fatalerror() and logerror(), which
are both local to mame.c, so Machine is now fully static.

--

From: Atari Ace [mailto:atari_ace@verizon.net] 
Sent: Thursday, December 18, 2008 5:47 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Make Machine static followup

Hi mamedev,

This incremental patch to my last patch undoes the change that caches
the ppu2c0x videorom.  I changed the code back to how it behaved
originally, using an existing machine on the chip struct to eliminate
the one troublesome Machine reference.

~aa

--

From: Atari Ace [mailto:atari_ace@verizon.net] 
Sent: Thursday, December 18, 2008 2:54 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Make Machine static!

Hi mamedev,

This large patch completes the removal of the use of Machine
throughout MAME.  It does so primarily by adding machine, device or
space to various apis and modifying the callers, but for some
remaining cases it adds a new api, mame_get_running_machine(), which
will be called instead.  There are only 14 uses of this api currently,
and that number should drop over time.

There are a few changes of note:
1.  6821pia.c.  I attached machine to the 'device' structure.  I'm
working on converting this to a proper device, but that change isn't
ready.
2.  fddebug.c.  I added a proper header so that the apis won't get
accidentally converted to static again.
3.  scsi.c.  I added a machine to SCSIInstance.
4.  system16.c.  I modified sys16_patch_code to take an array of
patches.
4.  custom.h.  I added the owning sound device to the reset/stop
routines as well as the token.  Note that passing only the device
would require exposing the internals of custom_sound, as the token
passed is not the device token, but the token returned from the
CUSTOM_START routine.  Better ideas here are welcome.
4.  ppc2c0x.c.  To avoid changing more interfaces, the init routine
saves the videorom location rather than looks it up each time.

I tried to choose what I felt was the natural parameter for an api,
rather than always pass machine, but in some cases I used machine to
limit the number of additional changes.  Some additional cleanup here
is probably warranted, I'll look into that later once I'm recovered
from this two-week project.

~aa
2008-12-19 19:40:22 +00:00
Aaron Giles
cf9fc58618 Made the concept of a "clock" native to devices. The clock is now
specified when the device is added, and the clock is available in
the device_config directly via device->clock. Updated all devices
that have a clock to specify it when adding the device, rather than
as part of their configuration. As part of this work, also created
device-specific _ADD and _REMOVE macros to simplify configuration.

Dfined a generic device execute function callback, though it
is not used yet. The long term plan is that any device with an 
execute callback will be scheduled along with the CPUs. Now that
CPUs are devices, their scheduling will be moved over to this
logic eventually.

Changed various NVRAM devices to fetch their default memory region
from the device->region rather than specifying it in the 
configuration.

Moved a number of CPUINFO_PTR_* constants to CPUINFO_FCT_*.

Fixed several drivers that manually created their own gfx_elements
to fill in the machine object, so they no longer crash.

Fixed incorrect CPU display on info screen (recently broken).

Moved device startup to *before* the DRIVER_INIT is called. This
is to allow the DRIVER_INIT to configure devices that have been
properly allocated. So far I don't see any negative effects, but
be on the lookout if something weird shows up.

Rewrote the device iteration logic to make use of the typenext
field and the newly-introduced classnext field for iterating more
efficiently through devices of a given type or class.

Fixed behavior of MDRV_CPU_REPLACE so it does not delete and then
re-add a CPU (causing the order to change).
2008-12-18 08:28:50 +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
54db8f077b Cleanups and version bump. 2008-12-15 01:46:32 +00:00
Aaron Giles
e26c70d35b Fixed crash bug in DCS games.
Updated the fcompress APIs to allow for specifying a compression level.

Removed the concept of state saving tags, which was a hack to get save states
to work with multiple CPU cores. Simplified the state saving system as a
result, performing the operation in a single pass and without allocating
a full blob of memory. Also enabled minimal compression.
2008-12-11 17:03:13 +00:00
Aaron Giles
d87ef8f79b Here's the big one....
Added new function cpuexec_describe_context(machine) which can be
used in logerror() and other printf-style functions to return a
description of the current CPU/PC given only the machine. Changed
several dozen sites to use this instead of directly interrogating
the activecpu.

Removed all other uses of activecpu throughout the system. Removed
activecpu from the machine structure to prevent future abuse.

Removed cpu_push_context() and cpu_pop_context(), and all call
sites.

Voodoo devices now require a CPU to be defined in the configuration
in order to know whom to steal cycles from or stall when FIFOs get
full. Updated all voodoo users to specify one.

CPD1869 devices now also require a CPU to be defined in the
configuration, in order to know which CPU's registers to fetch.
Updated all cdp1869 users to specify one.

Many other small changes to make this all work.
2008-12-11 09:40:22 +00:00
Aaron Giles
f57ab32404 Removed mame_find_cpu_index(). Use cputag_get_cpu() instead.
Updated all drivers calling this to the newer function, and
generally simplified their code as a result.
2008-12-06 07:25:48 +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
0142411b98 Move cpunum_get_active() removal. 2008-11-27 05:22:51 +00:00
Aaron Giles
6924ad8120 Changed timer_alloc, timer_set, timer_pulse, timer_call_after_resynch,
and timer_get_time to pass the machine parameter. Moved timer globals
to hang off of the running_machine.
2008-11-26 06:38:08 +00:00
Aaron Giles
1d05ea6089 Cleanups and version bump for 0.128u4. 2008-11-24 04:10:18 +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
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
a33640f46d Added concept of scheduling quanta to the timer system. Also added
means of setting the minimum useful scheduling quantum, and clamping
all quanta to that value.

Changed interleave/boost handling to use scheduling quanta instead
of timers.

Added machine parameter to cpu_boost_interleave.

Updated cpuexec to compute the "perfect" interleave value taking into
account the minimum number of cycles per instruction specified by the
CPU core. Updated Z80 core to indicate that the minimum cpi is 2. Fixed
incorrect minimum cpi in the 68020+ cores.

Simplified a bit of logic in cpuexec_timeslice.
2008-11-05 16:04:56 +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
f5d90dac56 CPUs, sound chips, devices, and ROM-regions which are specified by devices
now have their tags auto-prefixed with the device's tag. This allows for
multiple instances to be present. For example, the PR-8210 laserdisc player
has a CPU with a tag of "pr8210". When it is included as a device by a
driver, the driver may tag the device "laserdisc". The resulting final
CPU tag name will be "laserdisc:pr8210". Also updated the debugger
expression engine to support names with embedded colons.

Added warnings to ensure that tags used for CPUs, sound chips, regions, and
devices follow some basic rules: they should be less than 12 characters long,
be all lower-case, and only contain letters, numbers, underscores, or dots
(no spaces). This is to ensure that they can be used properly in debugger
expressions and don't get too long or unwieldy to type (even 12 chars is a
bit long).
2008-09-08 03:05:09 +00:00
Aaron Giles
57bd1856b5 Cleanups/version bump. 2008-07-31 09:00:13 +00:00
Aaron Giles
a69088c498 Added new options 'cheatpath' to specify one or more paths for cheat
files. Removed old option 'cheat_file'.

Updated xmlfile.c to specify the line number for each node, for more
accurate error reporting.

Removed old cheat.c/.h and replaced them with code that will read and
write the new XML-based cheat format using the new cheatpath option
(cheats still need to be enabled in order to load at all). Note that
the cheats are not implemented yet, but they are fully parsed. To test
saving, whenever a cheat file is successfully loaded, it is immediately
written back out as 'output.xml' to the cheat directory for validation.
2008-07-31 08:19:53 +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
Nathan Woods
251b59b069 Cleaned up MESS-specific hooks 2008-07-27 12:08:09 +00:00
Aaron Giles
5244807bf3 Cleanups. 2008-07-17 08:09:52 +00:00
Aaron Giles
b5f2aa1240 Changed direct access EEPROM interface to return the "bus width" of the
EEPROM data, and the size is in terms of units, not bytes. Updated all
drivers accordingly.

Changed the ROM loading code to actually alter the region flags based
on the CPU endianness and bus width when creating the region, rather
than fixing them up on the fly. This means that callers to
memory_region_flags() will get the correct results.

Changed the expression engine to use two callbacks for read/write rather
than relying on externally defined functions.

Expanded memory access support in the expression engine. Memory accesses
can now be specified as [space][num]<size>@<address>. 'space' can be
one of the following:

   p = program address space of CPU #num (default)
   d = data address space of CPU #num
   i = I/O address space of CPU #num
   o = opcode address space of CPU #num (R/W access to decrypted opcodes)
   r = direct RAM space of CPU #num (always allows writes, even for ROM)
   e = EEPROM index #num
   c = direct REGION_CPU#num access
   u = direct REGION_USER#num access
   g = direct REGION_GFX#num access
   s = direct REGION_SOUND#num access

The 'num' field is optional for p/d/i/o/r, where is defaults to the
current CPU, and for e, where it defaults to EEPROM #0. 'num' is required
for all region-related prefixes. Some examples:

   w@curpc = word at 'curpc' in the active CPU's program address space
   dd@0    = dword at 0x0 in the active CPU's data address space
   r2b@100 = byte at 0x100 from a RAM/ROM region in CPU #2's program space
   ew@7f   = word from EEPROM address 0x7f
   u2q@40  = qword from REGION_USER2, offset 0x40
   
The 'size' field is always required, and can be b/w/d/q for byte, word,
dword, and qword accesses.
2008-07-17 08:07:12 +00:00
Aaron Giles
d8715ab4ac Note: I have done some testing, but there are probably more bugs
lurking. If you run into anything odd, please let me know.

Added new module uiinput.c which manages input for the user interface.
The OSD is responsible for pushing mouse events and character events
to this interface in order to support mouse movement and text-based
input (currently only used for the select game menu). Added support
for navigating through the menus using the mouse. 
[Nathan Woods, Aaron Giles]

Redesigned the UI menus so that they can maintain a richer state. Now
the menus can be generated once and reused, rather than requiring them
to be regenerated on each frame. All menus also share a comment eventing
system and navigation through them is managed centrally. Rewrote all the 
menus to use the new system, apart from the cheat menus, which are now 
disabled. Reorganized the video menu to make it easier to understand.
[Aaron Giles]
2008-07-12 20:18:25 +00:00
Couriersud
08308f1f36 01935: All output commands (-listxml, -cc, -listfull, ETC) crash with error 2008-06-26 21:32:50 +00:00
Aaron Giles
3d1376ed97 Cleanups/version bump. 2008-06-26 16:05:46 +00:00
Aaron Giles
652fc279ae From: Oliver Stoeneberg [mailto:oliverst@online.de]
Subject: another Machine -> machine cleanup
This cleans up most of the Machine stuff in src/emu/machine. There is
a bit left to clean up, but it's mostly stuck at some interfaces now.
2008-06-26 15:34:42 +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