Go to file
Olivier Galibert c46e1007a8 emumem: API change [O. Galibert]
* direct_read_data is now a template which takes the address bus shift
  as a parameter.

* address_space::direct<shift>() is now a template method that takes
  the shift as a parameter and returns a pointer instead of a
  reference

* the address to give to {read|write}_* on address_space or
  direct_read_data is now the address one wants to access

Longer explanation:

Up until now, the {read|write}_* methods required the caller to give
the byte offset instead of the actual address.  That's the same on
byte-addressing CPUs, e.g. the ones everyone knows, but it's different
on the word/long/quad addressing ones (tms, sharc, etc...) or the
bit-addressing one (tms340x0).  Changing that required templatizing
the direct access interface on the bus addressing granularity,
historically called address bus shift.  Also, since everybody was
taking the address of the reference returned by direct(), and
structurally didn't have much choice in the matter, it got changed to
return a pointer directly.

Longest historical explanation:

In a cpu core, the hottest memory access, by far, is the opcode
fetching.  It's also an access with very good locality (doesn't move
much, tends to stay in the same rom/ram zone even when jumping around,
tends not to hit handlers), which makes efficient caching worthwhile
(as in, 30-50% faster core iirc on something like the 6502, but that
was 20 years ago and a number of things changed since then).  In fact,
opcode fetching was, in the distant past, just an array lookup indexed
by pc on an offset pointer, which was updated on branches.  It didn't
stay that way because more elaborate access is often needed (handlers,
banking with instructions crossing a bank...) but it still ends up with
a frontend of "if the address is still in the current range read from
pointer+address otherwise do the slowpath", e.g. two usually correctly
predicted branches plus the read most of the time.

Then the >8 bits cpus arrived.  That was ok, it just required to do
the add to a u8 *, then convert to a u16/u32 * and do the read.  At
the asm level, it was all identical except for the final read, and
read_byte/word/long being separate there was no test (and associated
overhead) added in the path.

Then the word-addressing CPUs arrived with, iirc, the tms cpus used in
atari games.  They require, to read from the pointer, to shift the
address, either explicitely, or implicitely through indexing a u16 *.
There were three possibilities:

1- create a new read_* method for each size and granularity.  That
   amounts to a lot of copy/paste in the end, and functions with
   identical prototypes so the compiler can't detect you're using the
   wrong one.

2- put a variable shift in the read path.  That was too expensive
   especially since the most critical cpus are byte-addressing (68000 at
   the time was the key).  Having bit-adressing cpus which means the
   shift can either be right or left depending on the variable makes
   things even worse.

3- require the caller to do the shift himself when needed.

The last solution was chosen, and starting that day the address was a
byte offset and not the real address.  Which is, actually, quite
surprising when writing a new cpu core or, worse, when using the
read/write methods from the driver code.

But since then, C++ happened.  And, in particular, templates with
non-type parameters.  Suddendly, solution 1 can be done without the
copy/paste and with different types allowing to detect (at runtime,
but systematically and at startup) if you got it wrong, while still
generating optimal code.  So it was time to switch to that solution
and makes the address parameter sane again.  Especially since it makes
mucking in the rest of the memory subsystem code a lot more
understandable.
2017-11-29 10:32:31 +01:00
3rdparty Fix compile warning under Emscripten (#2552) (submitted to upstream asio) (nw) 2017-10-17 01:55:57 +00:00
android-project version bump (nw) 2017-11-29 05:24:46 +11:00
artwork move some content for release archive out of build repo into main repo 2017-08-14 19:30:35 +10:00
benchmarks fix some typos (#2772) 2017-11-03 14:58:54 +01:00
bgfx fix some typos (#2772) 2017-11-03 14:58:54 +01:00
ctrlr move some content for release archive out of build repo into main repo 2017-08-14 19:30:35 +10:00
docs dvdisasm: Overhaul [O. Galibert] 2017-11-26 17:41:27 +01:00
doxygen doc: update MAME short description (nw) 2017-11-05 18:12:28 +01:00
hash New NOT_WORKING software list additions 2017-11-28 22:10:26 -08:00
hlsl Revert "New phosphor persistence shaders for HLSL" 2017-01-05 12:30:07 -05:00
ini/presets Revert "New phosphor persistence shaders for HLSL" 2017-01-05 12:30:07 -05:00
keymaps fix some typos (#2772) 2017-11-03 14:58:54 +01:00
language Merge pull request #2864 from SSTSylvain/patch-1 2017-11-28 21:26:05 -05:00
nl_examples Doxygen work. How the heck can one enforce a consistent device 2017-02-05 17:19:51 +01:00
plugins plugins/hiscore: add option to hiscore.ini to only_save_at_exit (nw) 2017-11-10 08:48:53 -06:00
projects Enable building projects that are separate of MAME but use same core and lives in separate git tree (nw) 2016-12-08 11:46:15 +01:00
regtests fix some typos (#2772) 2017-11-03 14:58:54 +01:00
roms Restore this, it's used when building packages (nw) 2017-10-25 01:34:02 +11:00
samples move some content for release archive out of build repo into main repo 2017-08-14 19:30:35 +10:00
scripts dvdisasm: Overhaul [O. Galibert] 2017-11-26 17:41:27 +01:00
src emumem: API change [O. Galibert] 2017-11-29 10:32:31 +01:00
tests fix some typos (#2772) 2017-11-03 14:58:54 +01:00
web fix some typos (#2772) 2017-11-03 14:58:54 +01:00
.drone.sec
.drone.yml Can tea-ci build tools? 2016-07-08 15:35:57 +10:00
.gitattributes move some content for release archive out of build repo into main repo 2017-08-14 19:30:35 +10:00
.gitignore move some content for release archive out of build repo into main repo 2017-08-14 19:30:35 +10:00
.travis.yml Update .travis.yml 2017-07-23 00:45:52 +02:00
dist.mak add a clean target to dist.mak, mark targets phony (nw) 2017-08-14 21:05:28 +10:00
LICENSE.md missed one, sorry *nw* 2017-08-25 12:01:11 -04:00
makefile version bump (nw) 2017-11-29 05:24:46 +11:00
README.md doc: update MAME short description (nw) 2017-11-05 18:12:28 +01:00
uismall.bdf Updates "2016" strings to "2017 where relevant. 2017-01-24 17:29:49 -05:00

MAME

Join the chat at https://gitter.im/mamedev/mame

Build status for tiny build only, containing just core parts of project:

OS/Compiler Status
Linux GCC / OSX Clang Build Status
Windows MinGW Build Status

Static analysis status for entire build (except for third-party parts of project):

Coverity Scan Status

What is MAME?

MAME is a multi-purpose emulation framework.

MAME's purpose is to preserve decades of software history. As electronic technology continues to rush forward, MAME prevents this important "vintage" software from being lost and forgotten. This is achieved by documenting the hardware and how it functions. The source code to MAME serves as this documentation. The fact that the software is usable serves primarily to validate the accuracy of the documentation (how else can you prove that you have recreated the hardware faithfully?). Over time, MAME (originally stood for Multiple Arcade Machine Emulator) absorbed the sister-project MESS (Multi Emulator Super System), so MAME now documents a wide variety of (mostly vintage) computers, video game consoles and calculators, in addition to the arcade video games that were its initial focus.

How to compile?

If you're on a *NIX or OSX system, it could be as easy as typing

make

for a MAME build,

make SUBTARGET=arcade

for an arcade-only build, or

make SUBTARGET=mess

for MESS build.

See the Compiling MAME page on our documentation site for more information, including prerequisites for Mac OS X and popular Linux distributions.

For recent versions of OSX you need to install Xcode including command-line tools and SDL 2.0.

For Windows users, we provide a ready-made build environment based on MinGW-w64.

Visual Studio builds are also possible, but you still need build environment based on MinGW-w64. In order to generate solution and project files just run:

make vs2015

or use this command to build it directly using msbuild

make vs2015 MSBUILD=1

Where can I find out more?

Contributing

Coding standard

MAME source code should be viewed and edited with your editor set to use four spaces per tab. Tabs are used for initial indentation of lines, with one tab used per indentation level. Spaces are used for other alignment within a line.

Some parts of the code follow Allman style; some parts of the code follow K&R style -- mostly depending on who wrote the original version. Above all else, be consistent with what you modify, and keep whitespace changes to a minimum when modifying existing source. For new code, the majority tends to prefer Allman style, so if you don't care much, use that.

All contributors need to either add a standard header for license info (on new files) or inform us of their wishes regarding which of the following licenses they would like their code to be made available under: the BSD-3-Clause license, the LGPL-2.1, or the GPL-2.0.

License

The MAME project as a whole is distributed under the terms of the GNU General Public License, version 2 or later (GPL-2.0+), since it contains code made available under multiple GPL-compatible licenses. A great majority of files (over 90% including core files) are under the BSD-3-Clause License and we would encourage new contributors to distribute files under this license.

Please note that MAME is a registered trademark of Gregory Ember, and permission is required to use the "MAME" name, logo, or wordmark.

Copyright (C) 1997-2017  MAMEDev and contributors

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Please see LICENSE.md for further details.