mirror of
https://github.com/holub/mame
synced 2025-06-06 12:53:46 +03:00
C++ guidelins update and cleanup:
docs: Expanded C++ guidelines following suggestions by P. Mackinlay. ui/inifile.cpp: Got rid of the check for "arcade" systems - it broke managing favourites for the slotted Neo Geo. luaengine.cpp: Removed the "type" property from system driver metadata. It's effectively deprecated. bus/vme/vme_fcisio.cpp, commodore/mps1230.cpp: Fixed inappropriate use of machine type flag constants. megadriv.xml: Made notes about the two Galaxy Force 2 sets more explcit.
This commit is contained in:
parent
a88b7def11
commit
8edb88dbaa
@ -42,6 +42,23 @@ Llama case:
|
|||||||
capitalised, with no separators between words: ``LlamaCaseSample``
|
capitalised, with no separators between words: ``LlamaCaseSample``
|
||||||
|
|
||||||
|
|
||||||
|
.. _contributing-cxx-fileformat:
|
||||||
|
|
||||||
|
Source file format
|
||||||
|
------------------
|
||||||
|
|
||||||
|
MAME C++ source files are encoded as UTF-8 text, assuming fixed-width
|
||||||
|
characters, with tab stops at four-space intervals. Source files should
|
||||||
|
end with a terminating end-of-line. Any valid printable Unicode text is
|
||||||
|
permitted in comments. Outside comments and strings, only the printable
|
||||||
|
ASCII subset of Unicode is permitted.
|
||||||
|
|
||||||
|
The ``srcclean`` tool is used to enforce file format rules before each
|
||||||
|
release. You can build this tool and apply it to the files you modify
|
||||||
|
before opening a pull request to avoid conflicts or surprising changes
|
||||||
|
later.
|
||||||
|
|
||||||
|
|
||||||
.. _contributing-cxx-naming:
|
.. _contributing-cxx-naming:
|
||||||
|
|
||||||
Naming conventions
|
Naming conventions
|
||||||
@ -84,6 +101,18 @@ Template parameters
|
|||||||
Template parameters should use llama case (both type and value
|
Template parameters should use llama case (both type and value
|
||||||
parameters).
|
parameters).
|
||||||
|
|
||||||
|
Identifiers containing two consecutive underscores or starting with an
|
||||||
|
underscore followed by an uppercase letter are always reserved and
|
||||||
|
should not be used.
|
||||||
|
|
||||||
|
Type names and other identifiers with a leading underscore should be
|
||||||
|
avoided within the global namespace, as they are explicitly reserved
|
||||||
|
according to the C++ standard. Additionally, identifiers suffixed with
|
||||||
|
``_t`` should be avoided within the global namespace, as they are also
|
||||||
|
reserved according to POSIX standards. While MAME violates this policy
|
||||||
|
occasionally – most notably with ``device_t`` – it’s considered to be an
|
||||||
|
unfortunate legacy decision that should be avoided in any new code.
|
||||||
|
|
||||||
|
|
||||||
.. _contributing-cxx-literals:
|
.. _contributing-cxx-literals:
|
||||||
|
|
||||||
@ -109,6 +138,13 @@ the intended use of a given literal at a glance. Uppercase long integer
|
|||||||
literal suffixes should be used to avoid confusion with the digit 1,
|
literal suffixes should be used to avoid confusion with the digit 1,
|
||||||
e.g. ``7LL`` rather than ``7ll``.
|
e.g. ``7LL`` rather than ``7ll``.
|
||||||
|
|
||||||
|
Digit grouping should be used for longer numeric literals, as it aids in
|
||||||
|
recognising order of magnitude or bit field positions at a glance.
|
||||||
|
Decimal literals should use groups of three digits, and hexadecimal
|
||||||
|
literals should use groups of four digits, outside of specific
|
||||||
|
situations where different grouping would be easier to understand, e.g.
|
||||||
|
``4'433'619`` or ``0xfff8'1fff``.
|
||||||
|
|
||||||
Types that do not have a specifically defined size should be avoided if
|
Types that do not have a specifically defined size should be avoided if
|
||||||
they are to be registered with MAME’s save-state system, as it harms
|
they are to be registered with MAME’s save-state system, as it harms
|
||||||
portability. In general, this means avoiding the use of ``int`` for
|
portability. In general, this means avoiding the use of ``int`` for
|
||||||
@ -450,6 +486,16 @@ a pull request.
|
|||||||
Structural organization
|
Structural organization
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
All C++ source files must begin with a two comments listing the
|
||||||
|
distribution license and copyright holders in a standard format.
|
||||||
|
Licenses are specified by their SPDX short identifier if available.
|
||||||
|
Here is an example of the standard format:
|
||||||
|
|
||||||
|
.. code-block:: C++
|
||||||
|
|
||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:David Haywood, Tomasz Slanina
|
||||||
|
|
||||||
Header includes should generally be grouped from most-dependent to
|
Header includes should generally be grouped from most-dependent to
|
||||||
least-dependent, and sorted alphabetically within said groups:
|
least-dependent, and sorted alphabetically within said groups:
|
||||||
|
|
||||||
@ -491,20 +537,37 @@ follows:
|
|||||||
#define VERBOSE (0)
|
#define VERBOSE (0)
|
||||||
#include "logmacro.h"
|
#include "logmacro.h"
|
||||||
|
|
||||||
The class declaration for a machine driver should be within the
|
In most cases, the class declaration for a system driver should be
|
||||||
corresponding source file. In such cases, the class declaration and all
|
within the corresponding source file along with the implementation. In
|
||||||
contents of the source file, excluding the ``GAME``, ``COMP``, or
|
such cases, the class declaration and all contents of the source file,
|
||||||
``CONS`` macro, should be enclosed in an anonymous namespace.
|
excluding the ``GAME``, ``COMP``, or ``CONS`` macro, should be enclosed
|
||||||
|
in an anonymous namespace (this produces better compiler diagnostics,
|
||||||
|
allows more aggressive optimisation, reduces the chance of duplicate
|
||||||
|
symbols, and reduces linking time).
|
||||||
|
|
||||||
|
Within a class declaration, there should be one section for each member
|
||||||
|
access level (``public``, ``protected`` and ``private``) if practical.
|
||||||
|
This may not be possible in cases where private constants and/or types
|
||||||
|
need to be declared before public members. Members should use the least
|
||||||
|
public access level necessary. Overridden virtual member functions
|
||||||
|
should generally use the same access level as the corresponding member
|
||||||
|
function in the base class.
|
||||||
|
|
||||||
|
Class member declarations should be grouped to aid understanding:
|
||||||
|
|
||||||
|
* Within a member access level section, constants, types, data members,
|
||||||
|
instance member functions and static member functions should be
|
||||||
|
grouped.
|
||||||
|
* In device classes, configuration member functions should be grouped
|
||||||
|
separately from live signal member functions.
|
||||||
|
* Overridden virtual member functions should be grouped according to the
|
||||||
|
base classes they are inherited from.
|
||||||
|
|
||||||
|
For classes with multiple overloaded constructors, constructor
|
||||||
|
delegation should be used where possible to avoid repeated member
|
||||||
|
initialiser lists.
|
||||||
|
|
||||||
Constants which are used by a device or machine driver should be in the
|
Constants which are used by a device or machine driver should be in the
|
||||||
form of explicitly-sized enumerated values within the class declaration,
|
form of explicitly-sized enumerated values within the class declaration,
|
||||||
or be relegated to ``#define`` macros within the source file. This
|
or be relegated to ``#define`` macros within the source file. This
|
||||||
helps avoid polluting the preprocessor.
|
helps avoid polluting the preprocessor.
|
||||||
|
|
||||||
Type names and other identifiers with a leading underscore should be
|
|
||||||
avoided within the global namespace, as they are explicitly reserved
|
|
||||||
according to the C++ standard. Additionally, identifiers suffixed with
|
|
||||||
``_t`` should be avoided within the global namespace, as they are also
|
|
||||||
reserved according to POSIX standards. While MAME violates this policy
|
|
||||||
occasionally – most notably with ``device_t`` – it’s considered to be an
|
|
||||||
unfortunate legacy decision that should be avoided in any new code.
|
|
||||||
|
@ -615,10 +615,6 @@ driver.rotation (read-only)
|
|||||||
A string indicating the rotation applied to all screens in the system after
|
A string indicating the rotation applied to all screens in the system after
|
||||||
the screen orientation specified in the machine configuration is applied.
|
the screen orientation specified in the machine configuration is applied.
|
||||||
Will be one of ``"rot0"``, ``"rot90"``, ``"rot180"`` or ``"rot270"``.
|
Will be one of ``"rot0"``, ``"rot90"``, ``"rot180"`` or ``"rot270"``.
|
||||||
driver.type (read-only)
|
|
||||||
A string providing a system type. Will be one of ``"arcade"``,
|
|
||||||
``"console"``, ``"computer"`` or ``"other"``. This is for informational
|
|
||||||
purposes only, and may not be supported in the future.
|
|
||||||
driver.not_working (read-only)
|
driver.not_working (read-only)
|
||||||
A Boolean indicating whether the system is marked as not working.
|
A Boolean indicating whether the system is marked as not working.
|
||||||
driver.supports_save (read-only)
|
driver.supports_save (read-only)
|
||||||
|
@ -3240,7 +3240,7 @@ Crashes after EA logo, requires better [VDP] irq handling
|
|||||||
</software>
|
</software>
|
||||||
|
|
||||||
|
|
||||||
<!-- Only Euro is confirmed -->
|
<!-- Only Euro is confirmed - this revision fixes graphical corruption on PAL consoles -->
|
||||||
<software name="gforce2">
|
<software name="gforce2">
|
||||||
<description>Galaxy Force II (World, rev. B)</description>
|
<description>Galaxy Force II (World, rev. B)</description>
|
||||||
<year>1991</year>
|
<year>1991</year>
|
||||||
@ -16844,7 +16844,7 @@ https://segaretro.org/Feng_Shen_Ying_Jie_Chuan
|
|||||||
</part>
|
</part>
|
||||||
</software>
|
</software>
|
||||||
|
|
||||||
<!-- heavy graphical corruption on PAL consoles -->
|
<!-- Heavy graphical corruption on PAL consoles - original game bug, fixed in rev. B (gforce2) -->
|
||||||
<software name="gforce2a" cloneof="gforce2">
|
<software name="gforce2a" cloneof="gforce2">
|
||||||
<description>Galaxy Force II (World)</description>
|
<description>Galaxy Force II (World)</description>
|
||||||
<year>1991</year>
|
<year>1991</year>
|
||||||
|
@ -461,4 +461,4 @@ uint8_t vme_fcisio1_card_device::config_rd(){
|
|||||||
|
|
||||||
// This info isn't kept in a card driver atm so storing it as a comment for later use
|
// This info isn't kept in a card driver atm so storing it as a comment for later use
|
||||||
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
|
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
|
||||||
//COMP( 1986, fcisio1, 0, 0, fcisio1, fcisio1, driver_device, 0, "Force Computers Gmbh", "SYS68K/ISIO-1", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_TYPE_COMPUTER )
|
//COMP( 1986, fcisio1, 0, 0, fcisio1, fcisio1, driver_device, 0, "Force Computers Gmbh", "SYS68K/ISIO-1", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW )
|
||||||
|
@ -1315,29 +1315,6 @@ void lua_engine::initialize()
|
|||||||
}
|
}
|
||||||
return rot;
|
return rot;
|
||||||
});
|
});
|
||||||
game_driver_type["type"] = sol::property(
|
|
||||||
[] (game_driver const &driver)
|
|
||||||
{
|
|
||||||
// FIXME: this shouldn't be called type - there's potendial for confusion with the device type
|
|
||||||
// also, this should eventually go away in favour of richer flags
|
|
||||||
std::string type;
|
|
||||||
switch (driver.flags & machine_flags::MASK_TYPE)
|
|
||||||
{
|
|
||||||
case machine_flags::TYPE_ARCADE:
|
|
||||||
type = "arcade";
|
|
||||||
break;
|
|
||||||
case machine_flags::TYPE_CONSOLE:
|
|
||||||
type = "console";
|
|
||||||
break;
|
|
||||||
case machine_flags::TYPE_COMPUTER:
|
|
||||||
type = "computer";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
type = "other";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
});
|
|
||||||
game_driver_type["not_working"] = sol::property([] (game_driver const &driver) { return (driver.flags & machine_flags::NOT_WORKING) != 0; });
|
game_driver_type["not_working"] = sol::property([] (game_driver const &driver) { return (driver.flags & machine_flags::NOT_WORKING) != 0; });
|
||||||
game_driver_type["supports_save"] = sol::property([] (game_driver const &driver) { return (driver.flags & machine_flags::SUPPORTS_SAVE) != 0; });
|
game_driver_type["supports_save"] = sol::property([] (game_driver const &driver) { return (driver.flags & machine_flags::SUPPORTS_SAVE) != 0; });
|
||||||
game_driver_type["no_cocktail"] = sol::property([] (game_driver const &driver) { return (driver.flags & machine_flags::NO_COCKTAIL) != 0; });
|
game_driver_type["no_cocktail"] = sol::property([] (game_driver const &driver) { return (driver.flags & machine_flags::NO_COCKTAIL) != 0; });
|
||||||
|
@ -488,31 +488,23 @@ void favorite_manager::apply_running_machine(running_machine &machine, T &&actio
|
|||||||
{
|
{
|
||||||
bool done(false);
|
bool done(false);
|
||||||
|
|
||||||
// TODO: this should be changed - it interacts poorly with cartslots on arcade systems
|
bool have_software(false);
|
||||||
if ((machine.system().flags & machine_flags::MASK_TYPE) == machine_flags::TYPE_ARCADE)
|
for (device_image_interface &image_dev : image_interface_enumerator(machine.root_device()))
|
||||||
{
|
{
|
||||||
action(machine.system(), nullptr, nullptr, done);
|
software_info const *const sw(image_dev.software_entry());
|
||||||
}
|
if (image_dev.exists() && image_dev.loaded_through_softlist() && sw)
|
||||||
else
|
|
||||||
{
|
|
||||||
bool have_software(false);
|
|
||||||
for (device_image_interface &image_dev : image_interface_enumerator(machine.root_device()))
|
|
||||||
{
|
{
|
||||||
software_info const *const sw(image_dev.software_entry());
|
assert(image_dev.software_list_name());
|
||||||
if (image_dev.exists() && image_dev.loaded_through_softlist() && sw)
|
|
||||||
{
|
|
||||||
assert(image_dev.software_list_name());
|
|
||||||
|
|
||||||
have_software = true;
|
have_software = true;
|
||||||
action(machine.system(), &image_dev, sw, done);
|
action(machine.system(), &image_dev, sw, done);
|
||||||
if (done)
|
if (done)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!have_software)
|
|
||||||
action(machine.system(), nullptr, nullptr, done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!have_software)
|
||||||
|
action(machine.system(), nullptr, nullptr, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
void favorite_manager::update_sorted()
|
void favorite_manager::update_sorted()
|
||||||
|
@ -173,5 +173,5 @@ ROM_START(mps1230)
|
|||||||
ROM_END
|
ROM_END
|
||||||
|
|
||||||
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */
|
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */
|
||||||
COMP( 1986, mps1000, 0, 0, mps1000, mps1230, mps1230_state, empty_init, "Commodore Business Machines", "MPS-1000 Printer", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_TYPE_OTHER )
|
SYST( 1986, mps1000, 0, 0, mps1000, mps1230, mps1230_state, empty_init, "Commodore Business Machines", "MPS-1000 Printer", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW )
|
||||||
COMP( 1988, mps1230, 0, 0, mps1230, mps1230, mps1230_state, empty_init, "Commodore Business Machines", "MPS-1230 NLQ Printer", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_TYPE_OTHER )
|
SYST( 1988, mps1230, 0, 0, mps1230, mps1230, mps1230_state, empty_init, "Commodore Business Machines", "MPS-1230 NLQ Printer", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW )
|
||||||
|
Loading…
Reference in New Issue
Block a user