diff --git a/docs/source/contributing/cxx.rst b/docs/source/contributing/cxx.rst index 67ac6f678f8..918c72032d2 100644 --- a/docs/source/contributing/cxx.rst +++ b/docs/source/contributing/cxx.rst @@ -42,6 +42,23 @@ Llama case: 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: Naming conventions @@ -84,6 +101,18 @@ Template parameters Template parameters should use llama case (both type and value 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: @@ -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, 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 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 @@ -450,6 +486,16 @@ a pull request. 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 least-dependent, and sorted alphabetically within said groups: @@ -491,20 +537,37 @@ follows: #define VERBOSE (0) #include "logmacro.h" -The class declaration for a machine driver should be within the -corresponding source file. In such cases, the class declaration and all -contents of the source file, excluding the ``GAME``, ``COMP``, or -``CONS`` macro, should be enclosed in an anonymous namespace. +In most cases, the class declaration for a system driver should be +within the corresponding source file along with the implementation. In +such cases, the class declaration and all contents of the source file, +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 form of explicitly-sized enumerated values within the class declaration, or be relegated to ``#define`` macros within the source file. This 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. diff --git a/docs/source/techspecs/luareference.rst b/docs/source/techspecs/luareference.rst index 206202df68a..dd63ab62de2 100644 --- a/docs/source/techspecs/luareference.rst +++ b/docs/source/techspecs/luareference.rst @@ -615,10 +615,6 @@ driver.rotation (read-only) A string indicating the rotation applied to all screens in the system after the screen orientation specified in the machine configuration is applied. 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) A Boolean indicating whether the system is marked as not working. driver.supports_save (read-only) diff --git a/hash/megadriv.xml b/hash/megadriv.xml index 045f8056e10..f372040ca11 100644 --- a/hash/megadriv.xml +++ b/hash/megadriv.xml @@ -3240,7 +3240,7 @@ Crashes after EA logo, requires better [VDP] irq handling - + Galaxy Force II (World, rev. B) 1991 @@ -16844,7 +16844,7 @@ https://segaretro.org/Feng_Shen_Ying_Jie_Chuan - + Galaxy Force II (World) 1991 diff --git a/src/devices/bus/vme/vme_fcisio.cpp b/src/devices/bus/vme/vme_fcisio.cpp index 9003384ce4d..8d50a671cc0 100644 --- a/src/devices/bus/vme/vme_fcisio.cpp +++ b/src/devices/bus/vme/vme_fcisio.cpp @@ -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 // 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 ) diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index d406a502583..1cb4b2dff44 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1315,29 +1315,6 @@ void lua_engine::initialize() } 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["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; }); diff --git a/src/frontend/mame/ui/inifile.cpp b/src/frontend/mame/ui/inifile.cpp index c4217f93fa3..e25f00da4a1 100644 --- a/src/frontend/mame/ui/inifile.cpp +++ b/src/frontend/mame/ui/inifile.cpp @@ -488,31 +488,23 @@ void favorite_manager::apply_running_machine(running_machine &machine, T &&actio { bool done(false); - // TODO: this should be changed - it interacts poorly with cartslots on arcade systems - if ((machine.system().flags & machine_flags::MASK_TYPE) == machine_flags::TYPE_ARCADE) + bool have_software(false); + for (device_image_interface &image_dev : image_interface_enumerator(machine.root_device())) { - action(machine.system(), nullptr, nullptr, done); - } - 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()); + if (image_dev.exists() && image_dev.loaded_through_softlist() && sw) { - software_info const *const sw(image_dev.software_entry()); - if (image_dev.exists() && image_dev.loaded_through_softlist() && sw) - { - assert(image_dev.software_list_name()); + assert(image_dev.software_list_name()); - have_software = true; - action(machine.system(), &image_dev, sw, done); - if (done) - return; - } + have_software = true; + action(machine.system(), &image_dev, sw, done); + if (done) + return; } - - if (!have_software) - action(machine.system(), nullptr, nullptr, done); } + + if (!have_software) + action(machine.system(), nullptr, nullptr, done); } void favorite_manager::update_sorted() diff --git a/src/mame/commodore/mps1230.cpp b/src/mame/commodore/mps1230.cpp index 425d93fa6e9..8020dfe26f2 100644 --- a/src/mame/commodore/mps1230.cpp +++ b/src/mame/commodore/mps1230.cpp @@ -173,5 +173,5 @@ ROM_START(mps1230) ROM_END /* 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 ) -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( 1986, mps1000, 0, 0, mps1000, mps1230, mps1230_state, empty_init, "Commodore Business Machines", "MPS-1000 Printer", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW ) +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 )