Commit Graph

95 Commits

Author SHA1 Message Date
Couriersud
865ef1e9fc Tools now include stdlib.h where needed 2010-01-17 19:14:55 +00:00
Aaron Giles
aebc07a897 Cleanups and version bump. 2010-01-16 04:12:04 +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
91a1b8d634 NOTE: This change requires two new osd functions: osd_malloc() and
osd_free(). They take the same parameters as malloc() and free().

Renamed mamecore.h -> emucore.h.

New C++-aware memory manager, implemented in emualloc.*. This is a
simple manager that allows you to add any type of object to a
resource pool. Most commonly, allocated objects are added, and so
a set of allocation macros is provided to allow you to manage
objects in a particular pool:

  pool_alloc(p, t) = allocate object of type 't' and add to pool 'p'
  pool_alloc_clear(p, t) = same as above, but clear the memory first
  pool_alloc_array(p, t, c) = allocate an array of 'c' objects of type
                              't' and add to pool 'p'
  pool_alloc_array_clear(p, t, c) = same, but with clearing
  pool_free(p, v) = free object 'v' and remove it from the pool

Note that pool_alloc[_clear] is roughly equivalent to "new t" and
pool_alloc_array[_clear] is roughly equivalent to "new t[c]". Also
note that pool_free works for single objects and arrays.

There is a single global_resource_pool defined which should be used
for any global allocations. It has equivalent macros to the pool_*
macros above that automatically target the global pool.

In addition, the memory module defines global new/delete overrides
that access file and line number parameters so that allocations can
be tracked. Currently this tracking is only done if MAME_DEBUG is
enabled. In debug builds, any unfreed memory will be printed at
the end of the session.

emualloc.h also has #defines to disable malloc/free/realloc/calloc.
Since emualloc.h is included by emucore.h, this means pretty much
all code within the emulator is forced to use the new allocators.
Although straight new/delete do work, their use is discouraged, as
any allocations made with them will not be tracked.

Changed the familar auto_alloc_* macros to map to the resource pool
model described above. The running_machine is now a class and contains
a resource pool which is automatically destructed upon deletion. If
you are a driver writer, all your allocations should be done with
auto_alloc_*.

Changed all drivers and files in the core using malloc/realloc or the 
old alloc_*_or_die macros to use (preferably) the auto_alloc_* macros 
instead, or the global_alloc_* macros if necessary.

Added simple C++ wrappers for astring and bitmap_t, as these need
proper constructors/destructors to be used for auto_alloc_astring and
auto_alloc_bitmap.

Removed references to the winalloc prefix file. Most of its 
functionality has moved into the core, save for the guard page 
allocations, which are now implemented in osd_alloc and osd_free.
2010-01-08 06:05:29 +00:00
Paul Priest
fb8599a36c Make unidasm compile and link again. Make exception-aware (hopefully).
Note kludge of defining osd_break_into_debugger() since it is referenced from emu_fatalerror.
2010-01-06 12:37:59 +00:00
Aaron Giles
45d1ff4d1e Cleaned up braces in the code so that they are properly balanced. [Atari Ace] 2009-12-28 09:09:20 +00:00
Aaron Giles
bd24fb23c1 Results of running the latest srcclean. 2009-12-28 09:04:00 +00:00
Aaron Giles
6763b10bf0 Updated srcclean to remove "invisible spaces" immediately preceding
tabs. [Atari Ace]
2009-12-28 09:01:46 +00:00
Aaron Giles
79b8f09ad8 From: Samuele Zannoli <samuele.zannoli@sparkbio.it>
Date: Tue, Dec 22, 2009 at 11:57 AM
Subject: Core for PIC 16c62x series of processors
To: submit@mamedev.org


Hello,
         this patch contains a core for the PIC 16c62x series of processors.

It has been made starting from the pic16c5x that is already present.
This version stil misses the various internal devices, however the
opcodes and i/o ports work, and it is enough to run the emulation of
the security pics used with the gd-roms.

Bye,
       Samuele Zannoli
2009-12-23 18:01:49 +00:00
Aaron Giles
505f0d7caf From: Atari Ace <atari_ace@verizon.net>
Date: Tue, Dec 22, 2009 at 4:44 PM
Subject: [patch] Fix srcclean/src2html bugs, misbalanced tokens and
visible whitespace errors
To: submit@mamedev.org
Cc: atariace@hotmail.com


Hi mamedev,

While experimenting with srcclean and src2html as indentation
validators, I stumbled across a couple of bugs.  The first is that
srcclean doesn't properly handle /*...*//.  It sees the last / char at
the end as the second / of an inline comment, where it might be a
division token or the start of either type of comment.

The second bug is that src2html improperly handles strings with
embedded quotes preceded by escaped backslashes, e.g. "ab\\\"cd".  It
believes the string terminated in the middle, and the last quote
starts a new string.  This issue is unlikely in actual code, but
should be handled correctly.

The first patch fixes these, and a some cases where there are
dangling/missing tokens which my validation tools are noticing.  These
occur in some unused macros, dead code sections, and in some macros
that are deliberately misbalanced (v9938.c, psx.c).  In the deliberate
cases, I balanced the braces by making exactly one open and one close
macro and using those throughout.

The second patch is then a set of visible whitespace "problems". Cases
where the closing brace isn't at the same indent level as the open
brace, and some cases where the indent level isn't a multiple of four.
In the case of ssv.c I folded the assignments into init_ssv() to
simplify the code and restore the brace balance, otherwise I kept to
simply adding or removing whitespace.

~aa
2009-12-23 17:59:08 +00:00
Phil Bennett
54570e176e Fixed srcclean handling of embedded comments within strings [Atari Ace]
(Update of r7501)

---------- Forwarded message ----------
From: Atari Ace <atari_ace@verizon.net>
Date: Sun, Dec 6, 2009 at 5:51 PM
Subject: [patch] srcclean bugfix
To: submit@mamedev.org
Cc: atariace@hotmail.com


Hi mamedev,

My srcclean changes to track C-style quotes didn't handle all the
special cases correctly (for instance, '\"' and "\\\"").  This fixes
it, and adds some /* ... */ to m68k_in.c so that src2html.exe does a
better job on it.

~aa
2009-12-07 11:13:54 +00:00
Phil Bennett
16ed9e0dcc Fixed srcclean handling of embedded comments within strings [Atari Ace]
---------- Forwarded message ----------
From: Atari Ace <atari_ace@verizon.net>
Date: Wed, Dec 2, 2009 at 2:14 AM
Subject: [patch] Fix srcclean to handle strings
To: submit@mamedev.org
Cc: atariace@hotmail.com


Hi mamedev,

I noticed an odd case in src2html.c where tabs were converted to
spaces unnecessarily.  Turns out srcclean does not track quoted
strings, so an embedded comment in a string will be treated the same
as a comment.  Attached is a patch to fix this.

~aa

P.S. The *.lay files could use a run through srcclean.
2009-12-03 14:34:31 +00:00
Miodrag Milanovic
d98fa09e1f Added Intel 8008 and National Semiconductor SC/MP CPU cores 2009-11-23 08:19:29 +00:00
Aaron Giles
5ecfb2044b Cleanups and version bump. 2009-10-31 22:47:46 +00:00
Aaron Giles
721087eeeb Added -flipped option to unidasm to output with disassembly
first and address/data bytes afterwards in comment form.
2009-10-31 19:46:55 +00:00
Aaron Giles
8b430a357f Change tools I wrote to be straight BSD. 2009-10-31 19:35:41 +00:00
R. Belmont
505c25f0c7 chdman: add option to create uncompressed writeable HD images for MESS 2009-10-28 02:49:30 +00:00
Aaron Giles
59a1941469 > -----Original Message-----
> From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Saturday, October 17, 2009 12:14 PM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] Remove dead prototypes
> 
> Hi mamedev,
> 
> This patch mostly removes dead prototypes, especially in source files
> as opposed to header files which I've previously audited.  It also
> migrates a few prototypes to existing header files, and adds missing
> prototypes to segamsys.h.
> 
> ~aa
2009-10-21 05:20:23 +00:00
Aaron Giles
d81f1f98d3 > From: atari_ace@verizon.net
> To: submit@mamedev.org
> CC: atariace@hotmail.com
> Subject: [patch] Eliminate more .data
> Date: Wed, 7 Oct 2009 08:51:56 -0700
> 
> Hi mamedev,
> 
> Most variables in .data are likely to lead to multisession bugs, so it
> is best to eliminate them and add explicit init/reset code for them
> instead. This patch does that for almost all the cases, with a few
> changes deserving some comments:
> 
> z180: cc was global when it should be per-cpu.
> nesapu: the noise table would be different run to run in multisession
> which probably wasn't intended.
> astring: i constified the dummy string to make it impossible to
> modify.
> mediagx: hits was separated from the constant data
> tecmosys: i reduced the number of exports and renamed them to use
> tecmosys_ as a prefix.
> atari: i moved the renderer function into ANTIC.
> naomibd: the array provided to x76f100 was too small and might have
> caused memory corruption.
> n64: i constified the one and zero colors, requiring many more const
> qualifiers to be added.
> ldverify: i encapsulated the audio and video variables to reduce the
> amount of global state.
2009-10-21 05:18:32 +00:00
Phil Bennett
8f3f75ff0f Relaxed romcmp filename length restriction 2009-10-12 21:34:07 +00:00
Aaron Giles
ed981ad74b Only applied the first patch. The second one I'll save for the next
full release so we don't have a giant spacing diff.

--

> -----Original Message-----
> From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Thursday, October 01, 2009 8:13 AM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] srcclean perf, stye improvements
> 
> Hi mamedev,
> 
> srcclean.exe has a minor performance bug with it tab removing
> algorithm, in that the cost of removing n tabs is O(n^2).  The first
> patch fixes this by always tracking the current column.  The second
> patch then implements a new clean idiom, that spaces before tabs that
> are "invisible" should be removed.  This change finds ~14k invisible
> spaces in MAME, so I suspect there may be some hesitation to adopt it.
> 
> ~aa
2009-10-03 22:01:36 +00:00
Aaron Giles
fa68c11272 > From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Monday, September 07, 2009 8:08 PM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] const/static/include fixes
> 
> Hi mamedev,
> 
> A result of some code auditing, this patch adds missing static and
> const qualifiers, and fixes up some header files.
> 
> ~aa
2009-09-10 08:35:37 +00:00
Aaron Giles
03b5da1a55 Added 'options' parameter to the CPU_DISASSEMBLE prototype. For now, the
debugger always passes 0 for this. unidasm has been updated to accept a
mode parameter, which is passed for the options.
2009-09-07 00:26:56 +00:00
Aaron Giles
b12ea76a0d Fixed stupid unidasm bug that double-counted bytes. 2009-09-06 22:37:41 +00:00
Aaron Giles
095f6923fd unidasm.c needs some type casts.
Juergen
2009-09-06 21:51:39 +00:00
Curt Coder
1c56a127d5 Added preliminary Zilog Z8 CPU core for MESS. 2009-09-04 12:40:47 +00:00
Aaron Giles
5df39c5473 Cleanups and version bump. 2009-08-29 23:18:28 +00:00
Aaron Giles
3de780ea8a Usage for unidasm now dumps the available achitectures. 2009-08-29 22:07:55 +00:00
Aaron Giles
2128210d76 Ok, disassembler is implemented with basic functionality. 2009-08-22 23:31:02 +00:00
Aaron Giles
f474114e1d Added infrastructure to compile universal standalone disassembler:
- added unidasm to the tools build
 - split the disassemblers out of libcpu and into new libdasm
 - ensured the disassembly entry points for all disassemblers are
    in the source file for the disassembler (sometimes new generic
    versions were created)

Still needs command line options and file loading, but the 
fundamentals are present, and it links.
2009-08-22 06:25:07 +00:00
Aaron Giles
03d5253dca Added some missing casts and other minor tweaks. 2009-08-19 04:58:54 +00:00
Aaron Giles
0131119e09 Oops forgot part of the CHD changes. 2009-08-02 22:55:26 +00:00
Aaron Giles
6a36bae504 Fix chdman -update to leave the write protect state alone when updating
uncompressed CHDs. [Michael Zapf]
2009-08-02 22:01:47 +00:00
Aaron Giles
f6f6e2eaff Oops, meant to say "core_stricmp" 2009-07-16 08:48:16 +00:00
Aaron Giles
6519412d59 Cleanups and version bump. 2009-07-16 07:37:54 +00:00
Aaron Giles
96b4503e04 Forgot to add it to the list of tools. 2009-07-16 07:12:18 +00:00
Aaron Giles
d879a67a4a Never send a monster to do the work of an evil scientist... 2009-07-16 07:10:16 +00:00
Aaron Giles
a273e83afa From: David Haywood [neohaze@nildram.co.uk]
Sent: Wednesday, July 15, 2009 3:36 PM
To: Aaron Giles; Angelo Salese; Klaus Sommer, B.Sc
Subject: new clones - witch card , scherrym

This adds the recent team europe dumps.  I haven't looked at them much

'Poker' is another Witch Card set
'Super Cherry Master' runs on cb2001 hardware, but the graphic rom is
missing.

new clones
-----------

Witch Card (german?) [Team Europe / Dumping Union]

new not working
-----------------

Super Cherry Master [Team Europe / Dumping Union] (incomplete set)
2009-07-16 06:41:43 +00:00
Aaron Giles
e692918b34 Added casts to ensure proper values are passed to the ctype.h functions.
[Juergen Buchmueller]
2009-06-25 08:04:39 +00:00
Aaron Giles
0e3bd92f71 Fixed buffer overflow with longer driver names. 2009-05-13 02:58:45 +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
3b302a8bae Cleanups and version bump. 2009-03-19 07:28:58 +00:00
Aaron Giles
15ecfc3d29 Fixed bug where chdman -extract would not truncate to the logical size. 2009-03-16 16:12:10 +00:00
Aaron Giles
df24d3be59 Added new function core_fload() to load a file into an allocated buffer.
Updated src2html, regrep, and chdman tools to use this function where
appropriate.

In chdman, changed -addmeta to -addmetatext or -addmetabin to explicitly
specify the type of data (previous auto-detect was too dangerous).
2009-03-11 05:06:34 +00:00
Aaron Giles
e0ccde49a3 Moved chd_clone_metadata code into chdman.c so that it can intelligently
update old tags.

Modified cdrom.c to expose metadata read/write functions, and changed
chdman to use them. Also changed chdman to parse old-style metadata and
convert it to new-style metadata since we're going to need to re-do this
anyway and the two won't hash to the same value.

Added completely untested support for the ident metadata to the hard
disk creation path. If a filename is provided immediately after the
source filename, it is taken as an ident file and processed for CHS
data and added. Other metadata types can be added afterwards via
-addmeta.
2009-03-10 15:09:00 +00:00
Aaron Giles
d2d22a19af Redid metadata hashing. A digest of tags and hashes for each
piece of metadata along with the hash for the raw data is then 
hashed to produce the final SHA1.

Updated romload to skip the obsolete MD5 field.
2009-03-10 00:27:30 +00:00
Aaron Giles
21b5f27224 NOTE: With the change, all existing CHD diff files are invalid.
Updated CHD format to version 4. Checksums are now computed and
stored separately for raw data and metadata, and metadata is now
checksummed by default.

We will need to go through all existing CHDs, run a chdman -update
on them, and update the SHA1s stored in the drivers to accommodate
this (MD5s should be removed).

Updated chdman to support a generic metadata addition system:

  chdman -addmeta <chdfile> <tag> [<index>] <sourcefile>

The <sourcefile> is examined and if it appears to be strictly text,
any EOFs and trailing EOLs are stripped, and the result is NULL-
terminated to match the behavior of existing metadata.

Updated chdman to report and fix errors in the raw and metadata
SHA1s.

Changed the CHD verify interfaces to pass back a structure containing
all the necessary data for verification and fixing.
2009-03-09 16:49:56 +00:00
Aaron Giles
e8c09b35f6 Added flags to the metadata entries, encoded in the top bit. Right now
it is a no-op, but eventually will be used to indicate which bits of
metadata are included in the overall checksum.
2009-03-05 07:35:24 +00:00
Aaron Giles
5406ec6027 This patch just cleans up some memory and file handles in the error
cases of ldverify. The initial memory leak was rsound and exposed by 
cppcheck [Oliver Stoeneberg]
2009-01-04 22:59:10 +00:00
Aaron Giles
1c9b12c644 Modified regrep to display the soruce file. 2008-12-13 06:29:25 +00:00