Commit Graph

101 Commits

Author SHA1 Message Date
Scott Stone
ca0f74f334 Fix the memory leaks with the strconv.c function by
using osd_malloc() instead.  Fixed other memory leaks as well.  [Oliver Stoneberg]
2010-04-23 17:10: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
Miodrag Milanovic
3a4544a651 ui.c,ui.h,windows/input.c: [Miodrag Milanovic]
- removed ui_use_new_ui check used by MESS code
- moved ui_mess_handler_ingame call in proper place, so device UI callbacks works again
- removed toggle of menu bar (MESS related)
2010-02-16 12:45:38 +00:00
Aaron Giles
6b663f66a7 Cleanups and version bump. 2010-02-14 16:59:22 +00:00
Aaron Giles
6b3dc3d421 Minor function rename. 2010-02-14 08:09:59 +00:00
Miodrag Milanovic
0a6b13608d - Moved natural keyboard support from MESS to MAME
- Moved OSD file functions and clipboard access functions into OSD core
2010-02-12 15:40:11 +00:00
Miodrag Milanovic
a8aedb92b0 - Renamed GAME_COMPUTER_MODIFIED to GAME_UNOFFICIAL to mark unofficial hardware modifications
- Removed GAME_COMPUTER it is distinct by IPT_KEYBOARD
- Added GAME_NO_SOUND_HW (to mark that there is no sound hardware) and marked drivers in dotrikun.c, minivadr.c and tgtpanic.c as such
- Added GAME_CAN_SHARE_ROMS - to mark that there can be other driver using same ROM as this one but with different hardware (common in computer/console world)
2010-02-11 09:44:23 +00:00
Miodrag Milanovic
51f4cf5be9 Rollback of show_warning add, sorry did not know about policy of this issue. 2010-02-10 10:40:58 +00:00
Miodrag Milanovic
96413ff354 - Added skip_warnings option
- Removed MESS dependent checks
2010-02-10 10:25:00 +00:00
Miodrag Milanovic
312b80701c - Moved compatibility validation into MAME core from MESS.
- Made GAME_COMPUTER type visible for all, and removed ifdefs for it.
- Made GAME_NO_SOUND check done on MESS too.
2010-02-09 14:23:13 +00:00
Couriersud
77cc6538e1 UI menu interface changes
- all ui functions now expect a render_container
- removed all macros referencing render_container_get_ui
- ui_menu_alloc now is passed a container to which to render the menu.
This is a first round of changes to allow using ui_* functions in a more generic way.
2010-01-27 23:52:28 +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
Miodrag Milanovic
04875f17b7 - Added MESS dependent code missing in emu.h
- Fixed compiling CPU core of V30MZ (only used by MESS)
- Fixed MESS dependent code of wave.c
- Added include of emu.h in sid (used only by MESS)

no whatsnew needed
2010-01-19 13:00:22 +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
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
smf-
8d88859471 moved the fix for the crash when you toggle cheats inside cheat.c, to avoid duplicating the checks and looking up whether cheats are enabled. 2010-01-06 17:30:05 +00:00
Fabio Priuli
49b2d89ab2 Fix for MT03621: Hitting F6 without -cheat trigger causes crash
now cheat toggling has no effect if there is no OPTION_CHEAT among mame_options().
2010-01-06 16:03:02 +00:00
Aaron Giles
bd24fb23c1 Results of running the latest srcclean. 2009-12-28 09:04:00 +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
Aaron Giles
731077c991 From: Dirk Best <startaq@gmail.com>
Date: Sat, Oct 10, 2009 at 20:09
Subject: patch for ui.c
To: submit@mamedev.org


Hello,

attached is a small patch that changes the way cpu clocks are
displayed on the initial information page. It now displays the real
values, which takes internal mulitpliers/dividers into account.

Dirk
2009-10-25 05:04:51 +00:00
Aaron Giles
477a71e7d2 Centralized color definitions and made some colors more specific.
[Mamesick]
2009-10-03 22:15:40 +00:00
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
e47035e834 Cleanups and version bump. 2009-09-10 08:39:42 +00:00
Aaron Giles
8f9ec7de59 Hooked up F6 again as a global cheat enable/disable. [Pugsy] 2009-09-10 07:17:35 +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
191fe9cdc3 > From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Sunday, September 06, 2009 7:25 AM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] Deglobalize input.c
> 
> Hi mamedev,
> 
> These patches deglobalize input.c.  The first adds running_machine to
> some driver apis.  The (large) second patch adds the machine parameter
> to the most input_code_pressed apis (generated by script, not
> compilable).  The last patch then actually changes those apis and
> others to take running_machine, and adds struct _input_private to hold
> the input state variables.
> 
> ~aa
2009-09-06 22:28:58 +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
40cc74b98f > -----Original Message-----
> From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Monday, August 03, 2009 10:52 PM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] De-globalize romload.c/validity.c
> 
> Hi mamedev,
> 
> Static and global variables in the core of MAME have slowly been
> replaced with opaque structures latched onto the running machine. This
> patch extends this idiom to two more files, romload.c and validity.c.
> validity.c in fact didn't need any global state (it was used only to
> pass data between function calls), and romload.c already had a struct
> that largely served that purpose.
> 
> ~aa
2009-08-13 04:55:32 +00:00
Aaron Giles
9eb86548bb Added missing casts and made other tweaks. The entire project
can now be optionally compiled with the C++ compiler (mingw g++
only for the moment; MSVC still has issues).
2009-04-27 09:18:17 +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
Derrick Renaud
01962d4fc5 Crosshair update
* Added Crosshair Options menu
  - ability to individually enable/disable crosshairs
  - ability for them to automatically disappear after a set amount of time
  - ability to select crosshair graphic
  - all settings are saved in the cfg file
 * Removed F1 toggle for crosshairs
 * Added new command option -crsshairpath
  - store all selectable graphics here
  - see config.txt for further info

OSD NOTE: render_load_png() has been changed to no longer force usage of the artwork directory.
Do a search for "render_load_png(" and replace with "render_load_png(OPTION_ARTPATH, " if needed.

----------------------------
F1 is now free to use for something new.  I was thinking it would be perfect for a context sensitive help file.  Each menu item could have a help tag, that it would look up and display info from an HTML file.
2009-03-28 22:55:34 +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
25b126291e 03001: "Working clones" display problem
Also tweaked the "not working" message.
2009-03-07 07:58:27 +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
davidhay
ed3bf17889 getting the AGEMAME ball rolling.
Moved over some of the drivers (thanks to James Wallace / ageMAME)
2009-02-02 22:52:37 +00:00
Aaron Giles
0b2c86bb02 Cleaned up the profiler. Reduced its runtime overhead significantly by
inlining the check to see if it is running. Removed obsolete entries
and updated the text to more accurately describe each one. Added CPU
tags to the CPU names. Switched to using an astring for building the
final string.

Unfortunately, still a bit too much overhead to leave it on in all builds.
2009-01-02 10:52:40 +00:00
Aaron Giles
967eb6ef16 Fixed minor glitch in UI display of screen information. 2009-01-02 08:23:53 +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
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
78622af0eb This patch furthers the process of aligning the sound cores with the
recent cpu core changes.  Specifically, it adds a fake device
implementation similar to the one the cpu cores were using in 128u3
(i.e. it only provides the machine pointer and the token), and makes
some interface adjustments aligned to 128u4 (i.e. adding
snd_class_header, adding get_ to various getter functions).  The
primary benefit of this change is the removal of "deprecat.h" from 23
sound cores.  I also adjusted ui.c to stop calling sndnum_clock and
access the clock data similarly to how it does the cpu clock data.

[AtariAce]
2008-12-04 10:44:15 +00:00
Aaron Giles
0309522e87 Re-enabled the OSD key for master volume control. All other
sliders are still only accessible via the menus.
2008-12-04 06:07:16 +00:00
davidhay
57c9bd0a87 make non-critical UI warnings yellow instead so that they stand out [BarnacleEd]
(was posted on Mametesters, I quite like it myself, although obviously it's open for debate)
2008-11-24 20:13:01 +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
296347baab Plumbed machine parameters through the renderer. Removed need for
deprecat.h.

Changed render_texture_set_bitmap() to accept a palette object 
instead of a palette index. The renderer remains optimized for the 
system palette but will work if objects have their own palette as 
well.

Changed renderer to permit palettes for RGB and YUY textures. If
specified, these palettes specify a 32-entry (RGB15) or 256-entry
(others) lookup for applying additional brightness/contrast/gamma
on a per-texture basis.

Removed rescale notification. It never really worked that well and 
violated proper layering.

Renamed palette_set_brightness() to palette_set_pen_contrast() for 
clarity.

Changed palette objects to support global brightness/contrast/gamma
in addition to per-group and per-entry controls.
2008-09-29 08:02:58 +00:00
Wilbert Pol
e4dc04a323 rescale_notifier() changed to always allow rescaling for screenless drivers. 2008-09-25 10:02: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
a2caa558e2 Cleanups and version bump. 2008-08-28 15:26:11 +00:00