Commit Graph

135 Commits

Author SHA1 Message Date
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