Commit Graph

38 Commits

Author SHA1 Message Date
Aaron Giles
eb8366c740 Added new #define ENDIANNESS_NATIVE, which maps to either ENDIANNESS_LITTLE
or ENDIANNESS_BIG based on the LSB_FIRST definition. Unlink LSB_FIRST,
ENDIANNESS_NATIVE always exists and can be used in expressions without
invoking the preprocessor.

Added macro ENDIAN_VALUE_LE_BE() which selects one of two values based
on the endianness passed in. Also added NATIVE_ENDIAN_VALUE_LE_BE()
which calls ENDIAN_VALUE_LE_BE with ENDIANNESS_NATIVE.

Updated a number of drivers and call sites to use these macros in favor
of #ifdef LSB_FIRST.
2009-01-17 23:03:17 +00:00
Aaron Giles
835ace034d Cleanups and version bump. 2009-01-04 23:31:12 +00:00
Aaron Giles
84618c3f7a romload cleanups:
- added running_machine to internal structure, removed as explicit parameter
 - added new function rom_file_size() to compute the size of a ROM
 - removed rom_first_chunk() and rom_next_chunk() which are no longer needed
 - changed progress display to be based on size of ROMs loaded, not number
 - changed temporary load buffer to be dynamically allocated
 - fixed reload logic to handle skipped BIOSes

Also changed rand_memory() to use a fixed seed for consistent behavior.
2009-01-02 19:20:55 +00:00
Aaron Giles
b7c652b8dd Removed a couple of unnecessary typedefs from mamecore.h.
Updated romload to use an astring for accumulating errors (I always feared
busting that buffer with some huge romlist).
2009-01-02 17:26:37 +00:00
Aaron Giles
a748f24dae Added the ability for a ROMset to specify a default BIOS. Use
ROM_DEFAULT_BIOS("biosname") in the ROM definition. This can be
used to ensure a correct default BIOS for ROM versions that care.
2008-12-31 02:58:30 +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
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
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
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
1eb3c2d964 Changed requirements for laserdisc CHDs to require a new chunk of
metadata with pre-decoded frame information. Modified chdman to
automatically produce this for CHDs that are of the appropriate
parameters. To fix up existing CHDs, use chdman -fixavdata on the
CHD.

Modified the laserdisc core to leverage the pre-decoded frame
metadata, which is now required. This improves seek times when
searching and allows the player-specific emulation access to the
VBI data as soon as it would really be available. Changed update
callback timing to fire just before the first line of VBI data
would be read; at that point, the frame selection is assumed to
be committed. 

Converted PR-8210 emulation over to using the actual MCU from the
laserdisc player. This MCU controls low-level functions such as
slider position and laser on/off, and receives decoded vertical
blanking data in order to make decisions. Removed old HLE behavior.
Note that the overlay text is displayed via the UI; this is
temporary and will be fixed shortly.

Converted Simutrek-hacked laserdisc emulation to using the actual
MCU from the game, which in turn hands off commands to the PR-8210
MCU. This is still not 100% but is pretty close at this point and
achieves the correct behaviors in most cases.

Fixed Cube Quest overlay scaling to cover the whole screen.

Changed laserdisc video parameters to position the screen area at
the bottom rather than the top, since this corresponds more closely
to standard line numbering.

Extended the vbiparse code to support pack/unpack, and to more
fully document all the meanings of the VBI codes.

Updated ldplayer to support slow/fast forward movement, frame/chapter
display, and separate controls for scanning/stepping.

Added new built-in variable "frame" to the debugger.

Fixed device-based ROM loading to support loading ROMs from the
game's ZIP as well.
2008-09-18 15:17:42 +00:00
Aaron Giles
aa2b6bd29a Cleanups and version bump. 2008-09-11 16:25:46 +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
c0b1419a96 Added concept of rom sources to the rom loader. Updated auditing,
CLI utilities, validity checks, and ROM loading to use these new
functions so that device-specific ROMs are handled properly.
2008-09-06 22:17:37 +00:00
Aaron Giles
8c9f7cbc76 Added new device interface selector: DEVINFO_PTR_ROM_REGION. This allows a
device to provide a set of ROM regions to be loaded along with the game
ROMs. It is expected that most regions defined for devices will use the
ROMREGION_LOADBYNAME flag to enable the ROMs to live in a central location.

Added new device interface selector: DEVINFO_PTR_MACHINE_CONFIG. This allows
a device to specify a partial machine driver which is appended to the end of
the machine driver for any game using that device. The intention for this is
to allow devices which have their own BIOS logic to specify CPUs and other
characteristics common to all systems using the device.

Added new ROMREGION flag: ROMREGION_LOADBYNAME, which means that if the ROMs
in that region are not found in the usual driver files, then the name of the
region will be used as a driver filename for loading.

Extended the ldcore interface structure to allow each player type to provide
its own ROM region and partial machine driver.

Moved preliminary PR-8210 emulation code from ldplayer.c to ldpr8210.c. It
is currently disabled behind the EMULATE_PR8210_ROM compile time flag.
2008-09-06 06:36:32 +00:00
Aaron Giles
7521888dd7 Added PR-8210 support to the ldplayer. Fixed step forward command on the PR-8210.
02136: cubeqst: from minimal UI cubeqst requires the optional CHD 
02127: xymg: The game name should be Xing Yun Man Guan and "Pin Yin:"should be omitted 
02138: flamegun: Debugger/Cheat System upper case cpu tag of MAIN doesn't work 
02139: In audio/system16.c, there is a reference to REGION_SOUND1 
02133: chindrah: The title of Zhong Guo Long?(Hong Kong,V011H) is Dong Fang Zhi Zhu(Hong Kong, V011H) 
02126: corrupt CHDs are reported as missing
2008-08-22 02:43:32 +00:00
Aaron Giles
284b5a0d95 Added new generic laserdisc VIDEO_UPDATE handler to the laserdisc code.
This handler works for both disc-only games and those with overlays. 
For disc-only games, the base macro is sufficient. For games with 
overlays, an additional set of configuration macros are provided:

   MDRV_LASERDISC_OVERLAY - specifies update function, width, height,
      and bitmap format of the overlay
   MDRV_LASERDISC_OVERLAY_CLIP - specifies the visible area of the
      overlay bitmap
   MDRV_LASERDISC_OVERLAY_POSITION - specifies default x,y position
   MDRV_LASERDISC_OVERLAY_SCALE - specifies default x,y scale factors

The update function provided to MDRV_LASERDISC_OVERLAY is identical to
a normal VIDEO_UPDATE callback, so a standard one can be used. All
existing laserdisc drivers have been updated to support this new
rendering mechanism, removing much duplicated code.

Added the ability to configure the overlay position and scale 
parameters at runtime. Added OSD menus to control them. Added logic
to save/restore the data in the game's configuration file.

Added new macros MDRV_LASERDISC_SCREEN_ADD_NTSC and _PAL, which
defines a standard screen with the correct video timing characteristics
and update function for laserdiscs. Updated all drivers to use these
macros instead of defining their own screens.

Added DISK_REGIONS to all laserdisc drivers.

Added DISK_IMAGE_READONLY_OPTIONAL to support games (like Cube Quest)
where the disk is non-essential to the game's operation.

Fixed bug in identifying the custom sound driver for the laserdisc.

Updated ldverify to identify blank regions of the disc for post-
processing.

Fixed rendering 16bpp with alpha using bilinear filters (fixes
screenshots of laserdisc games with overlays).

Included support for parsing .gdi files in chdman. [ElSemi]

Added new driver for Cube Quest. This includes CPU cores for the three
bitslice processors, as well as laserdisc support for the hacked
laserdisc that was used to drive the games. 
[Philip Bennett, Joe Magiera, Warren Ondras]

Note that the SHA1/MD5 for the laserdisc will likely undergo at least
one more change before being finalized.
2008-08-18 04:31:08 +00:00
Aaron Giles
a0574bb473 Moved several include files from mame/ to emu/, as they were
included by generic components in emu/ and thus should have no
dependencies on the MAME code.

Added new target ldplayer, which is based on MAME but serves as
a standalone laserdisc player for CHDs. Right now only the
Pioneer LD-V1000 is connected, and limited commands are available.
Each player type is a driver, so you specify the player type on
the command-line. The driver then opens the first CHD it finds
in your ROM path and uses that as the laserdisc. The intention is
that you specify the -rompath each time on the command-line, so
a typical approach might be:

   ldplayer ldv1000 -rompath j:\mach3

where it will pick up the mach3.chd lurking in your j:\mach3
folder. Several basic commands are supported:

   Space = play/pause
   Alt   = toggle frame display
   Left  = scan forward (when playing) or step forward (when paused)
   Right = scan backward (when playing) or step backward (when paused)
   0-9   = enter numbers for search
   Enter = execute search to frame
2008-08-13 15:09:08 +00:00
Aaron Giles
b40a4f5531 Cleanups and version bump. 2008-08-07 16:02:05 +00:00
Aaron Giles
6d5941e085 Disks opened by the romload module are no longer identified by index.
Instead, they are identified by the region they were loaded in. This
generally means one disk per region. get_disk_handle() now takes a
region name in place of an index. Updated all callers to do this.
The SCSI modules in particular posed a challenge to make this work,
so watch out for potential bugs there.

Changed the IDE interfaces to default to choosing the region with the
same tag as the device for its master disk (assuming no slave). Added
support for specifying explicit master/slave disk regions as part of
the configuration, though slave disks are still not supported yet.

Change the laserdisc interface to no longer require a disk number or
a custom sound device. Both are now assumed to be tagged the same as
the laserdisc device. Updated all drivers accordingly.
2008-08-01 23:11:08 +00:00
Aaron Giles
57bd1856b5 Cleanups/version bump. 2008-07-31 09:00:13 +00:00
Aaron Giles
e0409bc7b1 From: Oliver Stoeneberg [mailto:oliverst@online.de]
Subject: a few cleanups

This patch contains:
- removal of unprintable chars (newlines) in SH-2 disassembler (I 
submitted this in the past nd it wasn't included)
- a few unnecessary checks after malloc_ort_die() calls
- changes two romload.c warnings to use GAMENOUN instead
- adds "deprecat.h" in a  few src/mame/drivers files (would be 
necessary, if the debugger.h one would be removed)
- cleans up the mame.mak by adding all missing defines and grouping 
them based on cpu.mak
- renamed video_exit() to winvideo_exit() for consistency in function 
names
2008-07-31 08:26:39 +00:00
Aaron Giles
27061ca599 Moved region post-processing back to the end. Fixes endian issue on
second SH2 for ST-V games.

Fixed buffer overrun in latest SCSP code. Not sure how that ever
worked.

colmns97 still asserts in SCSPDSP, but this happened before the
region change.
2008-07-29 15:12:09 +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
0b77a69691 From: Atari Ace [mailto:atari_ace@verizon.net]
Subject: [patch] Conditional code cleanup resubmit

Hi mamedev,

This is a resubmit of a previous patch.  The earlier version would not
compile with 32-bit MSVC, due to the fact that its linker required
external dependencies in dead code to be met before dead code
elimination was done, causing linker errors.  The proper fix for this
would be to add the necessary dependencies, so I instead simply left
the conditional code in place in winalloc.c and chd.c.

~aa

Original submission email below:
----
Conditionally compiled code tends to bitrot, so MAME should try to
avoid it as much as possible.  I sent a patch six months ago to
eliminate conditional code associated with logging, here's another
patch that does more of this.  Some notes:

1.  drc_ops.c: I couldn't find a LOG_CODE anywhere, so I used if (0).
2.  romload.c: I converted all the users of debugload to use
LOG((...)) instead, following the traditional conditional logging
pattern.
3.  windows/sound.c: I eliminated the separate sound log and directed
the few outputs to the error log.

~aa
2008-07-24 06:26:47 +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
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
Couriersud
9aacf830fb Credit Fabio Priuli: Remove port_input_read_indexed in favor of the use of proper tags in a number of drivers
* Checked sprintf calls for sufficient buffer space [couriersud]
2008-06-02 20:00:25 +00:00
Aaron Giles
23890e5da7 This is a better fix for MAMETesters 00149: No error report for invalid BIOS setting 2008-05-01 14:02:12 +00:00
Aaron Giles
9fb86da645 From: Atari Ace
Subject: [patch] Fix 00149: No error report for invalid BIOS setting.
Hi mamedev,

This small patch makes specifying an invalid bios a fatalerror and
removes the need to expose system_bios to the drivers by reworking the
code in playch10.c to determine its bios more directly (in other
words, it removes an ugly hack).  This should resolve bug 00149,
although I did not implement the popmessage as suggested.

~aa
2008-04-21 00:05:54 +00:00
Aaron Giles
109bb332f0 The term "driver" is way overloaded in the system.
machine->drv is now machine->config.
Sorry.
2008-02-18 06:08:39 +00:00
Zsolt Vasvari
4930b2dbfd - Added deprecat.h that contains some deprecated/discouraged contructs (see below)
The idea is to create extra work if a driver wants to use these and hopefully
  gives an incentive to look for an alternate solution
- Added #include of deprecat.h that rely on these contructs
- Removed a bunch of unneccassary #include's from these files
2008-01-25 09:30:43 +00:00
Zsolt Vasvari
f7c5c67e2e First in a series of updates to remove the use of the global Machine from as many places as possible 2008-01-24 09:12:03 +00:00
Aaron Giles
ee9f88963c Copyright cleanup:
- removed years from copyright notices
 - removed redundant (c) from copyright notices
 - updated "the MAME Team" to be "Nicola Salmoria and the MAME Team"
2008-01-06 00:47:40 +00:00
Aaron Giles
422ccce762 (From Oliver Stoneberg)
This is an updated version of my earlier ATTR_PRINTF patch. It was 
reviewed by Atari Ace to use ATTR_PRINTF properly and fixes even more 
format errors. I also reviewed the whole source again and it is now 
used in all possible places.
2008-01-03 05:37:18 +00:00
Aaron Giles
7b77f12186 Initial checkin of MAME 0.121. 2007-12-17 15:19:59 +00:00