From 4f495994c41cd2fbaf89c08f755e828ae3261828 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 6 Sep 2021 06:34:42 +1000 Subject: [PATCH] -ui: Made zoom controls a bit more intuitive. * The UI controls are described as zoom in/out, but they had the opposite effect on the palette and tile viewers. That has been changed to make them consistent with the tilemap viewer. * Made the default zoom key not act as a toggle. People are familiar with the function of Ctrl+0/=/- in web browsers, so making them behave similarly in MAME should make it more approachable. Also added the default zoom key to the relevant documentation page. * Implemented the default zoom key for the palette and tile viewers. * In the tilemap viewer, if the view is in default expand to fit mode, zoom in/out starting from the actual zoom ratio. Once again, this behaves more like the zoom controls in a web browser displaying an image so it should be more intuitive. * Made more messages from the tilemap viewer localisable. -util/zippath.cpp: Fixed MT08074. * There were multiple issues at play here. After #8443 was applied, is_root was simply never returning true on Windows, as OSD_WINDOWS isn't actually defined outside libosd and libocore. This caused phantom parent items to appear in disk roots on Windows, but it meant that the check in zippath_resolve would always fail so the trailing backslash would be trimmed. Fixing the macro test in is_root meant the trailing backslash from C:\ would no longer be trimmed, which caused the stat in zippath_resolve to fail. -bigbord2.cpp: Hooked up floppy DRQ that had somehow got lost. -Reduced tag map lookups in several drivers and devices. -util/coretmpl.h: Removed an overload of bitswap that can be avoided using if constexpr. -Added doxygen comments to some classes, and fixed several doxygen warnings. -util, osd: Test for _WIN32 rather than WIN32. * In C++17 mode, WIN32 is no longer a predefined macro, although various things in 3rdparty define it to maintain legacy support. We're better off moving forward anyway for when WIN32 disappears entirely. (WIN32 is not a reserved name, while _WIN32 is, starting with an underscore follwed by an uppercase letter.) --- docs/source/usingmame/defaultkeys.rst | 7 +- scripts/target/mame/arcade.lua | 2 - src/devices/sound/gaelco.h | 3 +- src/devices/sound/scsp.h | 4 +- src/emu/attotime.h | 12 +- src/emu/devfind.h | 4 - src/emu/inpttype.ipp | 2 +- src/emu/ioport.cpp | 8 +- src/emu/ioport.h | 4 +- src/emu/rendlay.h | 30 +-- src/emu/screen.h | 9 - src/frontend/mame/ui/viewgfx.cpp | 193 ++++++++--------- src/frontend/mame/ui/viewgfx.h | 1 + src/lib/formats/flopimg.h | 8 +- src/lib/netlist/nl_config.h | 4 +- src/lib/netlist/tests/test_pfunction.cpp | 2 +- src/lib/util/bitmap.cpp | 2 +- src/lib/util/chdcodec.cpp | 2 +- src/lib/util/coretmpl.h | 19 +- src/lib/util/ioprocs.h | 138 ++++++++++++ src/lib/util/path.h | 38 +++- src/lib/util/unicode.cpp | 4 +- src/lib/util/zippath.cpp | 20 +- src/mame/audio/dcs.cpp | 57 +++-- src/mame/audio/dcs.h | 12 +- src/mame/audio/m72.h | 4 +- src/mame/drivers/apple2e.cpp | 25 ++- src/mame/drivers/applix.cpp | 2 +- src/mame/drivers/bigbord2.cpp | 20 +- src/mame/drivers/calchase.cpp | 46 +--- src/mame/drivers/ccs2810.cpp | 20 +- src/mame/drivers/cops.cpp | 56 ++--- src/mame/drivers/cortex.cpp | 23 +- src/mame/drivers/cvicny.cpp | 13 +- src/mame/drivers/cz101.cpp | 68 +++--- src/mame/drivers/dps1.cpp | 18 +- src/mame/drivers/dsb46.cpp | 27 ++- src/mame/drivers/excali64.cpp | 115 +++++----- src/mame/drivers/force68k.cpp | 2 +- src/mame/drivers/galgames.cpp | 5 +- src/mame/drivers/hng64.cpp | 59 ++--- src/mame/drivers/kaypro.cpp | 4 +- src/mame/drivers/konendev.cpp | 52 ++--- src/mame/drivers/mbc200.cpp | 19 +- src/mame/drivers/mes.cpp | 19 +- src/mame/drivers/mmd1.cpp | 27 ++- src/mame/drivers/nakajies.cpp | 67 +++--- src/mame/drivers/pegasus.cpp | 54 +++-- src/mame/drivers/taxidriv.cpp | 265 +++++++++++++++++++---- src/mame/drivers/ultim809.cpp | 22 +- src/mame/drivers/v6809.cpp | 12 +- src/mame/includes/hng64.h | 94 +++----- src/mame/includes/taxidriv.h | 89 -------- src/mame/video/hng64.cpp | 2 +- src/mame/video/taxidriv.cpp | 136 ------------ src/osd/asio.h | 2 +- src/osd/modules/debugger/debugqt.cpp | 12 +- src/osd/modules/file/posixdir.cpp | 6 +- src/osd/modules/file/posixfile.cpp | 34 +-- src/osd/modules/netdev/taptun.cpp | 14 +- src/osd/modules/sound/pa_sound.cpp | 4 +- src/osd/osdcore.cpp | 12 +- src/osd/strconv.h | 4 +- src/tools/chdman.cpp | 2 +- src/tools/srcclean.cpp | 2 +- 65 files changed, 1078 insertions(+), 964 deletions(-) delete mode 100644 src/mame/includes/taxidriv.h delete mode 100644 src/mame/video/taxidriv.cpp diff --git a/docs/source/usingmame/defaultkeys.rst b/docs/source/usingmame/defaultkeys.rst index 31fb6ad7d1a..2f20996be06 100644 --- a/docs/source/usingmame/defaultkeys.rst +++ b/docs/source/usingmame/defaultkeys.rst @@ -110,6 +110,7 @@ and saving/loading save states. * **Page Up**/**Page Down** - scroll up/down one page at a time. * **Home**/**End** - move to top/bottom of list. * **-**/**+** - increase/decrease the number of colors per row. + * **0** - restore the default number of colors per row. * **Enter** - switch to graphics viewer. Graphics mode: @@ -121,6 +122,7 @@ and saving/loading save states. * **Left**/**Right** - change color displayed. * **R** - rotate tiles 90 degrees clockwise. * **-**/**+** - increase/decrease the number of tiles per row. + * **0** - restore the default number of tiles per row. * **Enter** - switch to tilemap viewer. Tilemap mode: @@ -130,10 +132,11 @@ and saving/loading save states. * **Shift+Up**/**Down**/**Left**/**Right** - scroll 1 pixel at a time. * **Control+Up**/**Down**/**Left**/**Right** - scroll 64 pixels at a time. * **R** - rotate tilemap view 90 degrees clockwise. - * **-**/**+** - increase/decrease the zoom factor. + * **-**/**+** - decrease/increase the zoom factor. + * **0** - expand small tilemaps to fill the display. * **Enter** - switch to palette/colortable mode. - Note: Not all games have decoded graphics and/or tilemaps. + Note: Not all systems have decoded graphics and/or tilemaps. **Left Ctrl+F5** Toggle Filter. (*SDL MAME only*) diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 572f3a05482..375bae3369b 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -5139,8 +5139,6 @@ files { MAME_DIR .. "src/mame/drivers/tapatune.cpp", MAME_DIR .. "src/mame/drivers/tattack.cpp", MAME_DIR .. "src/mame/drivers/taxidriv.cpp", - MAME_DIR .. "src/mame/includes/taxidriv.h", - MAME_DIR .. "src/mame/video/taxidriv.cpp", MAME_DIR .. "src/mame/drivers/teamjocs.cpp", MAME_DIR .. "src/mame/drivers/tecnodar.cpp", MAME_DIR .. "src/mame/drivers/thayers.cpp", diff --git a/src/devices/sound/gaelco.h b/src/devices/sound/gaelco.h index 76a77c0bb40..2d0180e290f 100644 --- a/src/devices/sound/gaelco.h +++ b/src/devices/sound/gaelco.h @@ -7,14 +7,13 @@ #include "dirom.h" + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** // ======================> gaelco_gae1_device -#include "dirom.h" - class gaelco_gae1_device : public device_t, public device_sound_interface, public device_rom_interface<27> // Unknown address bits diff --git a/src/devices/sound/scsp.h b/src/devices/sound/scsp.h index 7ff91fdb576..f3d08df9793 100644 --- a/src/devices/sound/scsp.h +++ b/src/devices/sound/scsp.h @@ -9,9 +9,11 @@ #pragma once -#include "dirom.h" #include "scspdsp.h" +#include "dirom.h" + + #define SCSP_FM_DELAY 0 // delay in number of slots processed before samples are written to the FM ring buffer // driver code indicates should be 4, but sounds distorted then diff --git a/src/emu/attotime.h b/src/emu/attotime.h index c6fa441733c..c975bbde0d3 100644 --- a/src/emu/attotime.h +++ b/src/emu/attotime.h @@ -133,15 +133,15 @@ public: static attotime from_double(double _time); static attotime from_ticks(u64 ticks, u32 frequency); static attotime from_ticks(u64 ticks, const XTAL &xtal) { return from_ticks(ticks, xtal.value()); } - /** Create an attotime from a integer count of seconds @seconds */ + /** Create an attotime from an integer count of seconds @p seconds */ static constexpr attotime from_seconds(s32 seconds) { return attotime(seconds, 0); } - /** Create an attotime from a integer count of milliseconds @msec */ + /** Create an attotime from an integer count of milliseconds @p msec */ static constexpr attotime from_msec(s64 msec) { return attotime(msec / 1000, (msec % 1000) * (ATTOSECONDS_PER_SECOND / 1000)); } - /** Create an attotime from a integer count of microseconds @usec */ + /** Create an attotime from an integer count of microseconds @p usec */ static constexpr attotime from_usec(s64 usec) { return attotime(usec / 1000000, (usec % 1000000) * (ATTOSECONDS_PER_SECOND / 1000000)); } - /** Create an attotime from a integer count of nanoseconds @nsec */ + /** Create an attotime from an integer count of nanoseconds @p nsec */ static constexpr attotime from_nsec(s64 nsec) { return attotime(nsec / 1000000000, (nsec % 1000000000) * (ATTOSECONDS_PER_SECOND / 1000000000)); } - /** Create an attotime from at the given frequency @frequency */ + /** Create an attotime from at the given frequency @p frequency */ static attotime from_hz(u32 frequency) { return (frequency > 1) ? attotime(0, HZ_TO_ATTOSECONDS(frequency)) : (frequency == 1) ? attotime(1, 0) : attotime::never; } static attotime from_hz(int frequency) { return (frequency > 0) ? from_hz(u32(frequency)) : attotime::never; } static attotime from_hz(const XTAL &xtal) { return (xtal.dvalue() > 1.0) ? attotime(0, HZ_TO_ATTOSECONDS(xtal)) : from_hz(xtal.dvalue()); } @@ -346,7 +346,7 @@ inline u64 attotime::as_ticks(u32 frequency) const } -/** Create an attotime from a tick count @ticks at the given frequency @frequency */ +/** Create an attotime from a tick count @p ticks at the given frequency @p frequency */ inline attotime attotime::from_ticks(u64 ticks, u32 frequency) { if (frequency > 0) diff --git a/src/emu/devfind.h b/src/emu/devfind.h index 8253fb123f6..c8884d9582f 100644 --- a/src/emu/devfind.h +++ b/src/emu/devfind.h @@ -350,8 +350,6 @@ protected: /// report_missing to print an error message if the region is /// not found. Returns true if the region is required but no /// matching region is found, or false otherwise. - /// \param [in] bytes Desired region length in bytes, or 0U to match - /// any length. /// \param [in] required True if the region is required, or false if /// it is optional. /// \return True if the region is optional, or if the region is @@ -1059,8 +1057,6 @@ public: /// \param [in] tag Memory region tag to search for. This is not /// copied, it is the caller's responsibility to ensure this /// pointer remains valid until resolution time. - /// \param [in] length Desired memory region length in units of the - /// size of the element type, or zero to match any region length. region_ptr_finder(device_t &base, char const *tag) : object_finder_base(base, tag) , m_length(0) diff --git a/src/emu/inpttype.ipp b/src/emu/inpttype.ipp index 172d206f48c..989400b064e 100644 --- a/src/emu/inpttype.ipp +++ b/src/emu/inpttype.ipp @@ -838,7 +838,7 @@ namespace { INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CLEAR, "UI Clear", input_seq(KEYCODE_DEL) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_IN, "UI Zoom In", input_seq(KEYCODE_EQUALS) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_OUT, "UI Zoom Out", input_seq(KEYCODE_MINUS) ) \ - INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_AUTO, "UI Toggle Auto Zoom", input_seq(KEYCODE_0) ) \ + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_DEFAULT, "UI Default Zoom", input_seq(KEYCODE_0) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PREV_GROUP, "UI Previous Group", input_seq(KEYCODE_OPENBRACE) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_NEXT_GROUP, "UI Next Group", input_seq(KEYCODE_CLOSEBRACE) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ROTATE, "UI Rotate", input_seq(KEYCODE_R) ) \ diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index cae37f28c17..4d9e8d186f7 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -1659,9 +1659,10 @@ ioport_manager::ioport_manager(running_machine &machine) , m_timecode_file(machine.options().input_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS) , m_timecode_count(0) , m_timecode_last_time(attotime::zero) - , m_deselected_card_config(nullptr) + , m_deselected_card_config() { - memset(m_type_to_entry, 0, sizeof(m_type_to_entry)); + for (auto &entries : m_type_to_entry) + std::fill(std::begin(entries), std::end(entries), nullptr); } @@ -1837,7 +1838,6 @@ void ioport_manager::exit() ioport_manager::~ioport_manager() { - delete m_deselected_card_config; } @@ -2429,7 +2429,7 @@ void ioport_manager::load_system_config(util::xml::data_node const &portnode, in if (parent_device->interface(slot) && (slot->option_list().find(std::string(child_tag)) != slot->option_list().end())) { if (!m_deselected_card_config) - m_deselected_card_config = util::xml::file::create().release(); + m_deselected_card_config = util::xml::file::create(); portnode.copy_into(*m_deselected_card_config); } break; diff --git a/src/emu/ioport.h b/src/emu/ioport.h index 53e1e9ad5e8..20f21bc4f76 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -357,7 +357,7 @@ enum ioport_type IPT_UI_CLEAR, IPT_UI_ZOOM_IN, IPT_UI_ZOOM_OUT, - IPT_UI_ZOOM_AUTO, + IPT_UI_ZOOM_DEFAULT, IPT_UI_PREV_GROUP, IPT_UI_NEXT_GROUP, IPT_UI_ROTATE, @@ -1462,7 +1462,7 @@ private: attotime m_timecode_last_time; // storage for inactive configuration - util::xml::file * m_deselected_card_config; // using smart pointer would pull xmlfile.h into emu.h + std::unique_ptr m_deselected_card_config; }; diff --git a/src/emu/rendlay.h b/src/emu/rendlay.h index fb7871bd0ef..5555af820ac 100644 --- a/src/emu/rendlay.h +++ b/src/emu/rendlay.h @@ -52,12 +52,11 @@ class view_environment; /// \brief A description of a piece of visible artwork /// -/// Most view_items (except for those in the screen layer) have exactly +/// Most view items (except for those referencing screens) have exactly /// one layout_element which describes the contents of the item. /// Elements are separate from items because they can be re-used /// multiple times within a layout. Even though an element can contain -/// a number of components, they are treated as if they were a single -/// bitmap. +/// a number of components, they are drawn as a single textured quad. class layout_element { public: @@ -76,13 +75,14 @@ public: void preload(); private: - /// \brief An image, rectangle, or disk in an element + /// \brief A drawing component within a layout element /// - /// Each layout_element contains one or more components. Each + /// Each #layout_element contains one or more components. Each /// component can describe either an image or a rectangle/disk - /// primitive. Each component also has a "state" associated with it, - /// which controls whether or not the component is visible (if the - /// owning item has the same state, it is visible). + /// primitive. A component can also have a state mask and value + /// for controlling visibility. If the state of the item + /// instantiating the element matches the component's state value + /// for the bits that are set in the mask, the component is visible. class component { public: @@ -188,14 +188,14 @@ private: }; -/// \brief A reusable group of elements +/// \brief A reusable group of items /// /// Views expand/flatten groups into their component elements applying -/// an optional coordinate transform. This is mainly useful duplicating -/// the same sublayout in multiple views. It would be more useful -/// within a view if it could be parameterised. Groups only exist while -/// parsing a layout file - no information about element grouping is -/// preserved. +/// an optional coordinate transform. This is useful for duplicating +/// the same sublayout in multiple views, or grouping related items to +/// simplify overall view arrangement. Groups only exist while parsing +/// a layout file - no information about element grouping is preserved +/// after the views have been built. class layout_group { public: @@ -233,7 +233,7 @@ private: }; -/// \brief A single view within a layout_file +/// \brief A single view within a #layout_file /// /// The view is described using arbitrary coordinates that are scaled to /// fit within the render target. Pixels within a view are assumed to diff --git a/src/emu/screen.h b/src/emu/screen.h index bfff28d0f6f..b909c25cecc 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -552,13 +552,4 @@ DECLARE_DEVICE_TYPE(SCREEN, screen_device) // iterator helper typedef device_type_enumerator screen_device_enumerator; -/*! - @defgroup Screen device configuration functions - @{ - @def set_type - Modify the screen device type - @see screen_type_enum - @} - */ - #endif // MAME_EMU_SCREEN_H diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp index 1da14866c57..1c263fed451 100644 --- a/src/frontend/mame/ui/viewgfx.cpp +++ b/src/frontend/mame/ui/viewgfx.cpp @@ -9,14 +9,15 @@ *********************************************************************/ #include "emu.h" +#include "ui/viewgfx.h" + + #include "emupal.h" -#include "ui/ui.h" -#include "uiinput.h" #include "render.h" #include "rendfont.h" #include "rendutil.h" #include "tilemap.h" -#include "ui/viewgfx.h" +#include "uiinput.h" #include @@ -32,9 +33,9 @@ enum ui_gfx_modes UI_GFX_TILEMAP }; -static const uint8_t MAX_GFX_DECODERS = 8; -static const int MAX_ZOOM_LEVEL = 8; -static const int MIN_ZOOM_LEVEL = 8; +constexpr uint8_t MAX_GFX_DECODERS = 8; +constexpr int MAX_ZOOM_LEVEL = 8; +constexpr int MIN_ZOOM_LEVEL = 8; @@ -49,16 +50,16 @@ struct ui_gfx_info uint8_t setcount; // how many gfx sets device has uint8_t rotate[MAX_GFX_ELEMENTS]; // current rotation (orientation) value uint8_t columns[MAX_GFX_ELEMENTS]; // number of items per row - int offset[MAX_GFX_ELEMENTS]; // current offset of top,left item - int color[MAX_GFX_ELEMENTS]; // current color selected + int offset[MAX_GFX_ELEMENTS]; // current offset of top,left item + int color[MAX_GFX_ELEMENTS]; // current color selected device_palette_interface *palette[MAX_GFX_ELEMENTS]; // associated palette (maybe multiple choice one day?) - int color_count[MAX_GFX_ELEMENTS]; // Range of color values + int color_count[MAX_GFX_ELEMENTS]; // Range of color values }; struct ui_gfx_state { bool started; // have we called ui_gfx_count_devices() yet? - uint8_t mode; // which mode are we in? + uint8_t mode; // which mode are we in? // intermediate bitmaps bool bitmap_dirty; // is the bitmap dirty? @@ -69,19 +70,19 @@ struct ui_gfx_state struct { device_palette_interface *interface; // pointer to current palette - int devcount; // how many palette devices exist - int devindex; // which palette device is visible - uint8_t which; // which subset (pens or indirect colors)? - uint8_t columns; // number of items per row - int offset; // current offset of top left item + int devcount; // how many palette devices exist + int devindex; // which palette device is visible + uint8_t which; // which subset (pens or indirect colors)? + uint8_t columns; // number of items per row + int offset; // current offset of top left item } palette; // graphics-specific data struct { - uint8_t devcount; // how many gfx devices exist - uint8_t devindex; // which device is visible - uint8_t set; // which set is visible + uint8_t devcount; // how many gfx devices exist + uint8_t devindex; // which device is visible + uint8_t set; // which set is visible } gfxset; // information about each gfx device @@ -90,14 +91,14 @@ struct ui_gfx_state // tilemap-specific data struct { - int which; // which tilemap are we viewing? - int xoffs; // current X offset - int yoffs; // current Y offset - int zoom; // zoom factor, either x or 1/x - bool zoom_frac; // zoom via reciprocal fractions - bool auto_zoom; // auto-zoom toggle - uint8_t rotate; // current rotation (orientation) value - uint32_t flags; // render flags + int which; // which tilemap are we viewing? + int xoffs; // current X offset + int yoffs; // current Y offset + int zoom; // zoom factor, either x or 1/x + bool zoom_frac; // zoom via reciprocal fractions + bool auto_zoom; // auto-zoom toggle + uint8_t rotate; // current rotation (orientation) value + uint32_t flags; // render flags } tilemap; }; @@ -130,7 +131,7 @@ static void gfxset_update_bitmap(running_machine &machine, ui_gfx_state &state, static void gfxset_handler(mame_ui_manager &mui, render_container &container, ui_gfx_state &state); // tilemap handling -static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, int viswidth, int visheight); +static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, float pixelscale); static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, int width, int height); static void tilemap_handler(mame_ui_manager &mui, render_container &container, ui_gfx_state &state); @@ -542,20 +543,13 @@ static void palette_handler(mame_ui_manager &mui, render_container &container, u static void palette_handle_keys(running_machine &machine, ui_gfx_state &state) { device_palette_interface *palette = state.palette.interface; - int rowcount, screencount; - int total; - // handle zoom (minus,plus) if (machine.ui_input().pressed(IPT_UI_ZOOM_OUT)) - state.palette.columns /= 2; + state.palette.columns = std::min(state.palette.columns * 2, 64); if (machine.ui_input().pressed(IPT_UI_ZOOM_IN)) - state.palette.columns *= 2; - - // clamp within range - if (state.palette.columns <= 4) - state.palette.columns = 4; - if (state.palette.columns > 64) - state.palette.columns = 64; + state.palette.columns = std::max(state.palette.columns / 2, 4); + if (machine.ui_input().pressed(IPT_UI_ZOOM_DEFAULT)) + state.palette.columns = 16; // handle colormap selection (open bracket,close bracket) if (machine.ui_input().pressed(IPT_UI_PREV_GROUP)) @@ -584,11 +578,11 @@ static void palette_handle_keys(running_machine &machine, ui_gfx_state &state) } // cache some info in locals - total = state.palette.which ? palette->indirect_entries() : palette->entries(); + const int total = state.palette.which ? palette->indirect_entries() : palette->entries(); // determine number of entries per row and total - rowcount = state.palette.columns; - screencount = rowcount * rowcount; + const int rowcount = state.palette.columns; + const int screencount = rowcount * rowcount; // handle keyboard navigation if (machine.ui_input().pressed_repeat(IPT_UI_UP, 4)) @@ -855,17 +849,14 @@ static void gfxset_handle_keys(running_machine &machine, ui_gfx_state &state, in gfx_element &gfx = *info.interface->gfx(set); // handle cells per line (minus,plus) - if (machine.ui_input().pressed(IPT_UI_ZOOM_OUT)) - { info.columns[set] = xcells - 1; state.bitmap_dirty = true; } - - if (machine.ui_input().pressed(IPT_UI_ZOOM_IN)) + if (machine.ui_input().pressed(IPT_UI_ZOOM_OUT) && (xcells < 128)) { info.columns[set] = xcells + 1; state.bitmap_dirty = true; } - // clamp within range - if (info.columns[set] < 2) - { info.columns[set] = 2; state.bitmap_dirty = true; } - if (info.columns[set] > 128) - { info.columns[set] = 128; state.bitmap_dirty = true; } + if (machine.ui_input().pressed(IPT_UI_ZOOM_IN) && (xcells > 2)) + { info.columns[set] = xcells - 1; state.bitmap_dirty = true; } + + if (machine.ui_input().pressed(IPT_UI_ZOOM_DEFAULT) && (xcells != 16)) + { info.columns[set] = 16; state.bitmap_dirty = true; } // handle rotation (R) if (machine.ui_input().pressed(IPT_UI_ROTATE)) @@ -918,18 +909,16 @@ static void gfxset_handle_keys(running_machine &machine, ui_gfx_state &state, in static void gfxset_update_bitmap(running_machine &machine, ui_gfx_state &state, int xcells, int ycells, gfx_element &gfx) { - int dev = state.gfxset.devindex; - int set = state.gfxset.set; + const int dev = state.gfxset.devindex; + const int set = state.gfxset.set; ui_gfx_info &info = state.gfxdev[dev]; - int cellxpix, cellypix; - int x, y; // compute the number of source pixels in a cell - cellxpix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.height() : gfx.width()); - cellypix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.width() : gfx.height()); + const int cellxpix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.height() : gfx.width()); + const int cellypix = 1 + ((info.rotate[set] & ORIENTATION_SWAP_XY) ? gfx.width() : gfx.height()); // realloc the bitmap if it is too small - if (!state.bitmap.valid() || state.texture == nullptr || state.bitmap.width() != cellxpix * xcells || state.bitmap.height() != cellypix * ycells) + if (!state.bitmap.valid() || !state.texture || state.bitmap.width() != cellxpix * xcells || state.bitmap.height() != cellypix * ycells) { // free the old stuff machine.render().texture_free(state.texture); @@ -948,37 +937,28 @@ static void gfxset_update_bitmap(running_machine &machine, ui_gfx_state &state, if (state.bitmap_dirty) { // loop over rows - for (y = 0; y < ycells; y++) + for (int y = 0, index = info.offset[set]; y < ycells; y++) { - rectangle cellbounds; - // make a rect that covers this row - cellbounds.set(0, state.bitmap.width() - 1, y * cellypix, (y + 1) * cellypix - 1); + rectangle cellbounds(0, state.bitmap.width() - 1, y * cellypix, (y + 1) * cellypix - 1); // only display if there is data to show - if (info.offset[set] + y * xcells < gfx.elements()) + if (index < gfx.elements()) { // draw the individual cells - for (x = 0; x < xcells; x++) + for (int x = 0; x < xcells; x++, index++) { - int index = info.offset[set] + y * xcells + x; - // update the bounds for this cell cellbounds.min_x = x * cellxpix; cellbounds.max_x = (x + 1) * cellxpix - 1; - // only render if there is data - if (index < gfx.elements()) + if (index < gfx.elements()) // only render if there is data gfxset_draw_item(machine, gfx, index, state.bitmap, cellbounds.min_x, cellbounds.min_y, info.color[set], info.rotate[set], info.palette[set]); - - // otherwise, fill with transparency - else + else // otherwise, fill with transparency state.bitmap.fill(0, cellbounds); } } - - // otherwise, fill with transparency - else + else // otherwise, fill with transparency state.bitmap.fill(0, cellbounds); } @@ -1090,19 +1070,21 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u mapboxwidth = (mapboxbounds.x1 - mapboxbounds.x0) * float(targwidth); mapboxheight = (mapboxbounds.y1 - mapboxbounds.y0) * float(targheight); - // determine the maximum integral scaling factor - float pixelscale = state.tilemap.zoom_frac ? (1.0f / state.tilemap.zoom) : float(state.tilemap.zoom); + float pixelscale; if (state.tilemap.auto_zoom) { - uint32_t maxxscale, maxyscale; - for (maxxscale = 1; mapwidth * (maxxscale + 1) < mapboxwidth; maxxscale++) { } - for (maxyscale = 1; mapheight * (maxyscale + 1) < mapboxheight; maxyscale++) { } - pixelscale = float(std::min(maxxscale, maxyscale)); + // determine the maximum integral scaling factor + pixelscale = std::min(std::floor(mapboxwidth / mapwidth), std::floor(mapboxheight / mapheight)); + pixelscale = std::max(pixelscale, 1.0f); + } + else + { + pixelscale = state.tilemap.zoom_frac ? (1.0f / state.tilemap.zoom) : float(state.tilemap.zoom); } // recompute the final box size - mapboxwidth = std::min(mapboxwidth, int(std::round(mapwidth * pixelscale))); - mapboxheight = std::min(mapboxheight, int(std::round(mapheight * pixelscale))); + mapboxwidth = std::min(mapboxwidth, std::lround(mapwidth * pixelscale)); + mapboxheight = std::min(mapboxheight, std::lround(mapheight * pixelscale)); // recompute the bounds, centered within the existing bounds mapboxbounds.x0 += 0.5f * ((mapboxbounds.x1 - mapboxbounds.x0) - float(mapboxwidth) / targwidth); @@ -1137,8 +1119,8 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u ypixel = (mapboxheight - 1) - ypixel; if (state.tilemap.rotate & ORIENTATION_SWAP_XY) std::swap(xpixel, ypixel); - uint32_t col = ((int(std::round(xpixel / pixelscale)) + state.tilemap.xoffs) / tilemap->tilewidth()) % tilemap->cols(); - uint32_t row = ((int(std::round(ypixel / pixelscale)) + state.tilemap.yoffs) / tilemap->tileheight()) % tilemap->rows(); + uint32_t col = ((std::lround(xpixel / pixelscale) + state.tilemap.xoffs) / tilemap->tilewidth()) % tilemap->cols(); + uint32_t row = ((std::lround(ypixel / pixelscale) + state.tilemap.yoffs) / tilemap->tileheight()) % tilemap->rows(); uint8_t gfxnum; uint32_t code, color; tilemap->get_info_debug(col, row, gfxnum, code, color); @@ -1174,7 +1156,7 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u } // update the bitmap - tilemap_update_bitmap(mui.machine(), state, int(std::round(mapboxwidth / pixelscale)), int(std::round(mapboxheight / pixelscale))); + tilemap_update_bitmap(mui.machine(), state, std::lround(mapboxwidth / pixelscale), std::lround(mapboxheight / pixelscale)); // add the final quad container.add_quad(mapboxbounds.x0, mapboxbounds.y0, @@ -1183,7 +1165,7 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state.tilemap.rotate)); // handle keyboard input - tilemap_handle_keys(mui.machine(), state, mapboxwidth, mapboxheight); + tilemap_handle_keys(mui.machine(), state, pixelscale); } @@ -1192,7 +1174,7 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u // tilemap view //------------------------------------------------- -static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, int viswidth, int visheight) +static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, float pixelscale) { // handle tilemap selection (open bracket,close bracket) if (machine.ui_input().pressed(IPT_UI_PREV_GROUP) && state.tilemap.which > 0) @@ -1211,9 +1193,16 @@ static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, i // handle zoom (minus,plus) if (machine.ui_input().pressed(IPT_UI_ZOOM_OUT) && !at_min_zoom) { - state.tilemap.auto_zoom = false; - - if (state.tilemap.zoom_frac) + if (state.tilemap.auto_zoom) + { + // auto zoom never uses fractional factors + state.tilemap.zoom = std::lround(pixelscale) - 1; + state.tilemap.zoom_frac = !state.tilemap.zoom; + if (state.tilemap.zoom_frac) + state.tilemap.zoom = 2; + state.tilemap.auto_zoom = false; + } + else if (state.tilemap.zoom_frac) { // remaining in fractional zoom range state.tilemap.zoom++; @@ -1232,14 +1221,19 @@ static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, i state.bitmap_dirty = true; - machine.popmessage(state.tilemap.zoom_frac ? "Zoom = 1/%d" : "Zoom = %d", state.tilemap.zoom); + machine.popmessage(state.tilemap.zoom_frac ? _("Zoom = 1/%1$d") : _("Zoom = %1$d"), state.tilemap.zoom); } if (machine.ui_input().pressed(IPT_UI_ZOOM_IN) && !at_max_zoom) { - state.tilemap.auto_zoom = false; - - if (!state.tilemap.zoom_frac) + if (state.tilemap.auto_zoom) + { + // auto zoom never uses fractional factors + state.tilemap.zoom = std::min(std::lround(pixelscale) + 1, MAX_ZOOM_LEVEL); + state.tilemap.zoom_frac = false; + state.tilemap.auto_zoom = false; + } + else if (!state.tilemap.zoom_frac) { // remaining in integer zoom range state.tilemap.zoom++; @@ -1258,17 +1252,14 @@ static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, i state.bitmap_dirty = true; - machine.popmessage(state.tilemap.zoom_frac ? "Zoom = 1/%d" : "Zoom = %d", state.tilemap.zoom); + machine.popmessage(state.tilemap.zoom_frac ? _("Zoom = 1/%1$d") : _("Zoom = %1$d"), state.tilemap.zoom); } - if (machine.ui_input().pressed(IPT_UI_ZOOM_AUTO)) + if (machine.ui_input().pressed(IPT_UI_ZOOM_DEFAULT) && !state.tilemap.auto_zoom) { - state.tilemap.auto_zoom = !state.tilemap.auto_zoom; + state.tilemap.auto_zoom = true; - if (state.tilemap.auto_zoom) - machine.popmessage("Auto Zoom"); - else - machine.popmessage(state.tilemap.zoom_frac ? "Zoom = 1/%d" : "Zoom = %d", state.tilemap.zoom); + machine.popmessage(_("Expand to fit")); } // handle rotation (R) @@ -1372,7 +1363,7 @@ static void tilemap_update_bitmap(running_machine &machine, ui_gfx_state &state, std::swap(width, height); // realloc the bitmap if it is too small - if (!state.bitmap.valid() || state.texture == nullptr || state.bitmap.width() != width || state.bitmap.height() != height) + if (!state.bitmap.valid() || !state.texture || state.bitmap.width() != width || state.bitmap.height() != height) { // free the old stuff machine.render().texture_free(state.texture); diff --git a/src/frontend/mame/ui/viewgfx.h b/src/frontend/mame/ui/viewgfx.h index a4d2205d7a8..765384b4bea 100644 --- a/src/frontend/mame/ui/viewgfx.h +++ b/src/frontend/mame/ui/viewgfx.h @@ -13,6 +13,7 @@ #pragma once +#include "ui/ui.h" /*************************************************************************** diff --git a/src/lib/formats/flopimg.h b/src/lib/formats/flopimg.h index 6279def82f8..550c9a62fa8 100644 --- a/src/lib/formats/flopimg.h +++ b/src/lib/formats/flopimg.h @@ -734,9 +734,9 @@ public: //! floppy_image constructor /*! - @param _tracks number of tracks. - @param _heads number of heads. - @param _form_factor form factor of drive (from enum) + @param tracks number of tracks. + @param heads number of heads. + @param form_factor form factor of drive (from enum) */ floppy_image(int tracks, int heads, uint32_t form_factor); virtual ~floppy_image(); @@ -788,7 +788,7 @@ public: //! Returns the variant name for the particular disk form factor/variant //! @param form_factor //! @param variant - //! @param returns a string containing the variant name. + //! @return a string containing the variant name. static const char *get_variant_name(uint32_t form_factor, uint32_t variant); private: diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 76d1d40d530..8dad2b36cc2 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -192,8 +192,8 @@ namespace netlist /// /// This is the recommended clock to be used in fixed clock applications limited /// to 32 bit clock resolution. The MAME code (netlist.cpp) contains code - /// illustrating how to deal with remainders if \ref NETLIST_INTERNAL_RES is - /// bigger than NETLIST_CLOCK. + /// illustrating how to deal with remainders if \ref INTERNAL_RES is bigger than + /// NETLIST_CLOCK. using DEFAULT_CLOCK = std::integral_constant; // NOLINT /// \brief Default logic family diff --git a/src/lib/netlist/tests/test_pfunction.cpp b/src/lib/netlist/tests/test_pfunction.cpp index 3d251d620d0..c87671d8c7a 100644 --- a/src/lib/netlist/tests/test_pfunction.cpp +++ b/src/lib/netlist/tests/test_pfunction.cpp @@ -2,7 +2,7 @@ // copyright-holders:Couriersud /// -/// \file pfunction_test.cpp +/// \file test_pfunction.cpp /// /// tests for pfunction /// diff --git a/src/lib/util/bitmap.cpp b/src/lib/util/bitmap.cpp index 9722fea7218..8757d928fff 100644 --- a/src/lib/util/bitmap.cpp +++ b/src/lib/util/bitmap.cpp @@ -415,7 +415,7 @@ void bitmap_t::set_palette(palette_t *palette) * -------------------------------------------------. * * @param color The color. - * @param cliprect The cliprect. + * @param bounds The bounds. */ void bitmap_t::fill(uint64_t color, const rectangle &bounds) diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp index eca9403b56c..cd708d0f507 100644 --- a/src/lib/util/chdcodec.cpp +++ b/src/lib/util/chdcodec.cpp @@ -771,7 +771,7 @@ chd_zlib_allocator::chd_zlib_allocator() //------------------------------------------------- -// ~chd_zlib_allocator - constructor +// ~chd_zlib_allocator - destructor //------------------------------------------------- chd_zlib_allocator::~chd_zlib_allocator() diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index 18b64e7c0ff..49f01f8415c 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -610,20 +610,6 @@ template constexpr T BIT(T x, U n, V w) } -/// \brief Extract and right-align a single bit field -/// -/// This overload is used to terminate a recursive template -/// implementation. It is functionally equivalent to the BIT -/// function for extracting a single bit. -/// -/// \param [in] val The integer to extract the bit from. -/// \param [in] b The bit to extract, where zero is the least -/// significant bit of the input. -/// \return The specified bit of the input extracted to the least -/// significant position. -template constexpr T bitswap(T val, U b) noexcept { return BIT(val, b) << 0U; } - - /// \brief Extract bits in arbitrary order /// /// Extracts bits from an integer. Specify the bits in the order they @@ -641,7 +627,10 @@ template constexpr T bitswap(T val, U b) noexcept { ret /// \return The extracted bits packed into a right-aligned field. template constexpr T bitswap(T val, U b, V... c) noexcept { - return (BIT(val, b) << sizeof...(c)) | bitswap(val, c...); + if constexpr (sizeof...(c)) + return (BIT(val, b) << sizeof...(c)) | bitswap(val, c...); + else + return BIT(val, b); } diff --git a/src/lib/util/ioprocs.h b/src/lib/util/ioprocs.h index 78c06e71318..0a4e5c384f0 100644 --- a/src/lib/util/ioprocs.h +++ b/src/lib/util/ioprocs.h @@ -27,6 +27,14 @@ class osd_file; namespace util { +/// \defgroup ioprocs Generic I/O interfaces +/// \{ + +/// \brief Interface to an input stream +/// +/// Represents a stream producing a sequence of bytes with no further +/// structure. +/// \sa write_stream read_write_stream random_read class read_stream { public: @@ -34,10 +42,29 @@ public: virtual ~read_stream() = default; + /// \brief Read from the current position in the stream + /// + /// Reads up to the specified number of bytes from the stream into + /// the supplied buffer. May read less than the requested number of + /// bytes if the end of the stream is reached or an error occurs. + /// If the stream supports seeking, reading starts at the current + /// position in the stream, and the current position is incremented + /// by the number of bytes read. + /// \param [out] buffer Destination buffer. Must be large enough to + /// hold the requested number of bytes. + /// \param [in] length Maximum number of bytes to read. + /// \param [out] actual Number of bytes actually read. Will always + /// be less than or equal to the requested length. + /// \return An error condition if reading stopped due to an error. virtual std::error_condition read(void *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to an output stream +/// +/// Represents a stream that accepts a sequence of bytes with no further +/// structure. +/// \sa read_stream read_write_stream random_write class write_stream { public: @@ -45,12 +72,43 @@ public: virtual ~write_stream() = default; + /// \brief Finish writing data + /// + /// Performs any tasks necessary to finish writing data to the + /// stream and guarantee that the written data can be read in its + /// entirety. Further writes may not be possible. + /// \return An error condition if the operation fails. virtual std::error_condition finalize() noexcept = 0; + + /// \brief Flush application-side caches + /// + /// Flushes any caches to the underlying stream. Success does not + /// guarantee that data has reached persistent storage. + /// \return An error condition if flushing caches fails. virtual std::error_condition flush() noexcept = 0; + + /// \brief Write at the current position in the stream + /// + /// Writes up to the specified number of bytes from the supplied + /// buffer to the stream. May write less than the requested number + /// of bytes if an error occurs. If the stream supports seeking, + /// writing starts at the current position in the stream, and the + /// current position is incremented by the number of bytes written. + /// \param [in] buffer Buffer containing the data to write. Must + /// contain at least the specified number of bytes. + /// \param [in] length Number of bytes to write. + /// \param [out] actual Number of bytes actually written. Will + /// always be less than or equal to the requested length. + /// \return An error condition if writing stopped due to an error. virtual std::error_condition write(void const *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to an I/O stream +/// +/// Represents an object that acts as both a source of and sink for byte +/// sequences. +/// \sa read_stream write_stream random_read_write class read_write_stream : public virtual read_stream, public virtual write_stream { public: @@ -58,41 +116,121 @@ public: }; +/// \brief Interface to a byte sequence that supports seeking +/// +/// Provides an interface for controlling the position within a byte +/// sequence that supports seeking. +/// \sa random_read random_write random_read_write class random_access { public: virtual ~random_access() = default; + /// \brief Set the position in the stream + /// + /// Sets the position for the next read or write operation. It may + /// be possible to set the position beyond the end of the stream. + /// \param [in] offset The offset in bytes, relative to the position + /// specified by the whence parameter. + /// \param [in] whence One of SEEK_SET, SEEK_CUR or SEEK_END, to + /// interpret the offset parameter relative to the beginning of + /// the stream, the current position in the stream, or the end of + /// the stream, respectively. + /// \return An error condition of the operation failed. virtual std::error_condition seek(std::int64_t offset, int whence) noexcept = 0; + + /// \brief Get the current position in the stream + /// + /// Gets the position in the stream for the next read or write + /// operation. The position may be beyond the end of the stream. + /// \param [out] result The position in bytes relative to the + /// beginning of the stream. Not valid if the operation fails. + /// \return An error condition if the operation failed. virtual std::error_condition tell(std::uint64_t &result) noexcept = 0; + + /// \brief Get the length of the stream + /// + /// Gets the current length of the stream. + /// \param [out] result The lenght of the stream in bytes. Not + /// valid if the operation fails. + /// \return An error condtion if the operation failed. virtual std::error_condition length(std::uint64_t &result) noexcept = 0; }; +/// \brief Interface to a random-access byte input sequence +/// +/// Provides an interface for reading from aritrary positions within a +/// byte sequence. No further structure is provided. +/// \sa read_stream random_write random_read_write class random_read : public virtual read_stream, public virtual random_access { public: using ptr = std::unique_ptr; + /// \brief Read from specified position + /// + /// Reads up to the specified number of bytes into the supplied + /// buffer. If seeking is supported, reading starts at the + /// specified position and the current position is unaffected. May + /// read less than the requested number of bytes if the end of the + /// stream is encountered or an error occurs. + /// \param [in] offset The position to start reading from, specified + /// as a number of bytes from the beginning of the stream. + /// \param [out] buffer Destination buffer. Must be large enough to + /// hold the requested number of bytes. + /// \param [in] length Maximum number of bytes to read. + /// \param [out] actual Number of bytes actually read. Will always + /// be less than or equal to the requested length. + /// \return An error condition if seeking failed or reading stopped + /// due to an error. virtual std::error_condition read_at(std::uint64_t offset, void *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to a random-access byte output sequence +/// +/// Provides an interface for writing to arbitrary positions within a +/// byte sequence. No further structure is provided. +/// \sa write_stream random_read random_read_write class random_write : public virtual write_stream, public virtual random_access { public: using ptr = std::unique_ptr; + /// \brief Write at specified position + /// + /// Writes up to the specified number of bytes from the supplied + /// buffer. If seeking is supported, writing starts at the + /// specified position and the current position is unaffected. May + /// write less than the requested number of bytes if an error + /// occurs. + /// \param [in] offset The position to start writing at, specified + /// as a number of bytes from the beginning of the stream. + /// \param [in] buffer Buffer containing the data to write. Must + /// contain at least the specified number of bytes. + /// \param [in] length Number of bytes to write. + /// \param [out] actual Number of bytes actually written. Will + /// always be less than or equal to the requested length. + /// \return An error condition if seeking failed or writing stopped + /// due to an error. virtual std::error_condition write_at(std::uint64_t offset, void const *buffer, std::size_t length, std::size_t &actual) noexcept = 0; }; +/// \brief Interface to a random-access read/write byte sequence +/// +/// Provides an interface for reading from and writing to arbitrary +/// positions within a byte sequence. No further structure is provided. +/// \sa random_read random_write read_write_stream class random_read_write : public read_write_stream, public virtual random_read, public virtual random_write { public: using ptr = std::unique_ptr; }; +/// \} + random_read::ptr ram_read(void const *data, std::size_t size) noexcept; random_read::ptr ram_read(void const *data, std::size_t size, std::uint8_t filler) noexcept; diff --git a/src/lib/util/path.h b/src/lib/util/path.h index 1291d7b17d3..8638bcb332b 100644 --- a/src/lib/util/path.h +++ b/src/lib/util/path.h @@ -18,15 +18,19 @@ namespace util { -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -// is a given character a directory separator? +/// \defgroup pathutils Filesystem path utilities +/// \{ +/// \brief Is a character a directory separator? +/// +/// Determine whether a character is used to separate components within +/// a filesystem path. +/// \param [in] c A character to test. +/// \return True if the character is used to separate components in +/// filesystem paths. constexpr bool is_directory_separator(char c) { -#if defined(WIN32) +#if defined(_WIN32) return ('\\' == c) || ('/' == c) || (':' == c); #else return '/' == c; @@ -34,8 +38,15 @@ constexpr bool is_directory_separator(char c) } -// append to a path - +/// \brief Append components to a filesystem path +/// +/// Appends directory components to a filesystem path. +/// \param [in,out] path The path to append to. +/// \param [in] next The first directory component to append to the +/// path. +/// \param [in] more Additional directory components to append to the +/// path. +/// \return A reference to the modified path. template inline std::string &path_append(std::string &path, T &&next, U &&... more) { @@ -49,8 +60,13 @@ inline std::string &path_append(std::string &path, T &&next, U &&... more) } -// concatenate paths - +/// \brief Concatenate filsystem paths +/// +/// Concatenates multiple filesystem paths. +/// \param [in] first Initial filesystem path. +/// \param [in] more Additional directory components to append to the +/// intial path. +/// \return The concatenated filesystem path. template inline std::string path_concat(T &&first, U &&... more) { @@ -60,6 +76,8 @@ inline std::string path_concat(T &&first, U &&... more) return result; } +/// \} + } // namespace util #endif // MAME_LIB_UTIL_PATH_H diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp index a375224fd1e..6787db4a501 100644 --- a/src/lib/util/unicode.cpp +++ b/src/lib/util/unicode.cpp @@ -457,7 +457,7 @@ int utf16f_from_uchar(char16_t *utf16string, size_t count, char32_t uchar) std::wstring wstring_from_utf8(const std::string &utf8string) { -#ifdef WIN32 +#ifdef _WIN32 // for some reason, using codecvt yields bad results on MinGW (but not MSVC) return osd::text::to_wstring(utf8string); #else @@ -473,7 +473,7 @@ std::wstring wstring_from_utf8(const std::string &utf8string) std::string utf8_from_wstring(const std::wstring &string) { -#ifdef WIN32 +#ifdef _WIN32 // for some reason, using codecvt yields bad results on MinGW (but not MSVC) return osd::text::from_wstring(string); #else diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index 9d2e51a6833..6fad365d6fc 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -48,7 +48,7 @@ int is_path_separator(char c) bool is_root(std::string_view path) { -#if defined(WIN32) +#if defined(_WIN32) // FIXME: don't assume paths are DOS-like - UNC paths, \\?\ long path prefix, etc. complicate this // skip drive letter @@ -58,8 +58,7 @@ bool is_root(std::string_view path) // skip path separators return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #else - // FIXME: handle multiple successive path separators, current directory references, parent directory references - return (path.length() == 1) && (path[0] == '/'); + return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #endif } @@ -208,14 +207,11 @@ std::error_condition zippath_resolve(std::string_view path, osd::directory::entr bool went_up = false; do { - if (!is_root(apath)) - { - // trim the path of trailing path separators - auto i = apath.find_last_not_of(PATH_SEPARATOR); - if (i == std::string::npos) - break; - apath = apath.substr(0, i + 1); - } + // trim the path of trailing path separators + auto i = apath.find_last_not_of(PATH_SEPARATOR); + if (i == std::string::npos) + break; + apath = apath.erase(std::min(i + 1, 2)); apath_trimmed = apath; @@ -613,7 +609,7 @@ std::string &zippath_combine(std::string &dst, const std::string &path1, const s { dst.assign(path2); } - else if (!path1.empty() && !is_path_separator(*path1.rbegin())) + else if (!path1.empty() && !is_path_separator(path1.back())) { dst.assign(path1).append(PATH_SEPARATOR).append(path2); } diff --git a/src/mame/audio/dcs.cpp b/src/mame/audio/dcs.cpp index 8ce7402b59e..aeadfc27a21 100644 --- a/src/mame/audio/dcs.cpp +++ b/src/mame/audio/dcs.cpp @@ -693,9 +693,9 @@ dcs_audio_device::dcs_audio_device(const machine_config &mconfig, device_type ty m_channels(0), m_size(0), m_incs(0), - m_reg_timer(nullptr), - m_sport0_timer(nullptr), - m_internal_timer(nullptr), + m_reg_timer(*this, "dcs_reg_timer"), + m_sport0_timer(*this, "dcs_sport0_timer"), + m_internal_timer(*this, "dcs_int_timer"), m_ireg(0), m_ireg_base(0), m_bootrom(nullptr), @@ -790,10 +790,6 @@ void dcs_audio_device::device_start() m_data_bank->configure_entries(0, m_sounddata_banks, m_sounddata, 0x800*2); } - /* create the timers */ - m_internal_timer = subdevice("dcs_int_timer"); - m_reg_timer = subdevice("dcs_reg_timer"); - /* non-RAM based automatically acks */ m_auto_ack = true; /* register for save states */ @@ -882,11 +878,6 @@ void dcs2_audio_device::device_start() /* allocate memory for the SRAM */ m_sram = std::make_unique(0x8000*4/2); - /* create the timers */ - m_internal_timer = subdevice("dcs_int_timer"); - m_reg_timer = subdevice("dcs_reg_timer"); - m_sport0_timer = subdevice("dcs_sport0_timer"); - /* we don't do auto-ack by default */ m_auto_ack = false; @@ -906,14 +897,17 @@ void dcs2_audio_device::device_start() } -void dcs_audio_device::install_speedup(void) +void dcs_audio_device::install_speedup() { - if (m_polling_offset) { - if (m_rev < REV_DSIO) { + if (m_polling_offset) + { + if (m_rev < REV_DSIO) + { m_cpu->space(AS_DATA).install_read_handler(m_polling_offset, m_polling_offset, read16mo_delegate(*this, FUNC(dcs_audio_device::dcs_polling_r))); m_cpu->space(AS_DATA).install_write_handler(m_polling_offset, m_polling_offset, write16s_delegate(*this, FUNC(dcs_audio_device::dcs_polling_w))); } - else { + else + { // ADSP 2181 (DSIO and DENVER) use program memory m_cpu->space(AS_PROGRAM).install_read_handler(m_polling_offset, m_polling_offset, read32mo_delegate(*this, FUNC(dcs_audio_device::dcs_polling32_r))); m_cpu->space(AS_PROGRAM).install_write_handler(m_polling_offset, m_polling_offset, write32s_delegate(*this, FUNC(dcs_audio_device::dcs_polling32_w))); @@ -1560,7 +1554,7 @@ void dcs_audio_device::data_w(uint16_t data) return; /* if we are DCS1, set a timer to latch the data */ - if (m_sport0_timer == nullptr) + if (!m_sport0_timer) machine().scheduler().synchronize(timer_expired_delegate(FUNC(dcs_audio_device::dcs_delayed_data_w_callback),this), data); else dcs_delayed_data_w(data); @@ -1916,15 +1910,18 @@ void dcs_audio_device:: adsp_control_w(offs_t offset, uint16_t data) } // Check SPORT0 enabled - if (m_sport0_timer != nullptr) { - if (data & 0x1000) { + if (m_sport0_timer) + { + if (data & 0x1000) + { // Start the SPORT0 timer // SPORT0 is used as a 1kHz timer m_sport0_timer->adjust(attotime::from_usec(10), 0, attotime::from_hz(1000)); if (LOG_DCS_IO) logerror("adsp_control_w: Setting SPORT0 freqency to 1kHz\n"); } - else { + else + { // Stop the SPORT0 timer m_sport0_timer->reset(); } @@ -2476,7 +2473,7 @@ int dcs_audio_device::preprocess_write(uint16_t data) int result; /* if we're not DCS2, skip */ - if (m_sport0_timer == nullptr) + if (!m_sport0_timer) return 0; /* state 0 - initialization phase */ @@ -2506,8 +2503,8 @@ void dcs_audio_device::add_mconfig_dcs(machine_config &config) dcs.set_addrmap(AS_PROGRAM, &dcs_audio_device::dcs_2k_program_map); dcs.set_addrmap(AS_DATA, &dcs_audio_device::dcs_2k_data_map); - TIMER(config, "dcs_reg_timer").configure_generic(FUNC(dcs_audio_device::dcs_irq)); - TIMER(config, "dcs_int_timer").configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); + TIMER(config, m_reg_timer).configure_generic(FUNC(dcs_audio_device::dcs_irq)); + TIMER(config, m_internal_timer).configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); SPEAKER(config, "mono").front_center(); @@ -2677,9 +2674,9 @@ void dcs2_audio_dsio_device::device_add_mconfig(machine_config &config) ADDRESS_MAP_BANK(config, "data_map_bank").set_map(&dcs2_audio_dsio_device::dsio_rambank_map).set_options(ENDIANNESS_LITTLE, 16, 14, 0x2000); - TIMER(config, "dcs_reg_timer").configure_generic(FUNC(dcs_audio_device::dcs_irq)); - TIMER(config, "dcs_int_timer").configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); - TIMER(config, "dcs_sport0_timer").configure_generic(FUNC(dcs_audio_device::sport0_irq)); // roadburn needs this to pass hardware test + TIMER(config, m_reg_timer).configure_generic(FUNC(dcs_audio_device::dcs_irq)); + TIMER(config, m_internal_timer).configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); + TIMER(config, m_sport0_timer).configure_generic(FUNC(dcs_audio_device::sport0_irq)); // roadburn needs this to pass hardware test SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); @@ -2707,11 +2704,11 @@ void dcs2_audio_denver_device::device_add_mconfig(machine_config &config) denver.set_addrmap(AS_DATA, &dcs2_audio_denver_device::denver_data_map); denver.set_addrmap(AS_IO, &dcs2_audio_denver_device::denver_io_map); - ADDRESS_MAP_BANK(config, "data_map_bank").set_map(&dcs2_audio_denver_device::denver_rambank_map).set_options(ENDIANNESS_LITTLE, 16, 15, 0x2000*2); + ADDRESS_MAP_BANK(config, m_ram_map).set_map(&dcs2_audio_denver_device::denver_rambank_map).set_options(ENDIANNESS_LITTLE, 16, 15, 0x2000*2); - TIMER(config, "dcs_reg_timer").configure_generic(FUNC(dcs_audio_device::dcs_irq)); - TIMER(config, "dcs_int_timer").configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); - TIMER(config, "dcs_sport0_timer").configure_generic(FUNC(dcs_audio_device::sport0_irq)); // Atlantis driver waits for sport0 rx interrupts + TIMER(config, m_reg_timer).configure_generic(FUNC(dcs_audio_device::dcs_irq)); + TIMER(config, m_internal_timer).configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); + TIMER(config, m_sport0_timer).configure_generic(FUNC(dcs_audio_device::sport0_irq)); // Atlantis driver waits for sport0 rx interrupts } dcs2_audio_denver_5ch_device::dcs2_audio_denver_5ch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : diff --git a/src/mame/audio/dcs.h b/src/mame/audio/dcs.h index 0cebee16dec..38bd283a768 100644 --- a/src/mame/audio/dcs.h +++ b/src/mame/audio/dcs.h @@ -44,8 +44,8 @@ public: uint32_t dsio_idma_data_r(); void dmovlay_remap_memory(); void dmovlay_callback(uint32_t data); - void denver_postload(void); - void install_speedup(void); + void denver_postload(); + void install_speedup(); // non public void dcs_boot(); @@ -63,7 +63,7 @@ public: void dsio_reset(); uint16_t dsio_r(offs_t offset); void dsio_w(offs_t offset, uint16_t data); - void denver_alloc_dmadac(void); + void denver_alloc_dmadac(); void denver_reset(); uint16_t denver_r(offs_t offset); void denver_w(offs_t offset, uint16_t data); @@ -181,9 +181,9 @@ protected: uint16_t m_size; uint16_t m_incs; dmadac_sound_device *m_dmadac[6]; - timer_device *m_reg_timer; - timer_device *m_sport0_timer; - timer_device *m_internal_timer; + required_device m_reg_timer; + optional_device m_sport0_timer; + required_device m_internal_timer; int32_t m_ireg; uint16_t m_ireg_base; uint16_t m_control_regs[32]; diff --git a/src/mame/audio/m72.h b/src/mame/audio/m72.h index be4a31ce2fb..bf6995c10a6 100644 --- a/src/mame/audio/m72.h +++ b/src/mame/audio/m72.h @@ -10,9 +10,11 @@ #pragma once -#include "dirom.h" #include "sound/dac.h" +#include "dirom.h" + + class m72_audio_device : public device_t, public device_rom_interface<32> // unknown address bits { public: diff --git a/src/mame/drivers/apple2e.cpp b/src/mame/drivers/apple2e.cpp index d0279537c2c..4a0b7119b64 100644 --- a/src/mame/drivers/apple2e.cpp +++ b/src/mame/drivers/apple2e.cpp @@ -3222,19 +3222,20 @@ u8 apple2e_state::read_floatingbus() ADDRESS MAP ***************************************************************************/ -u8 apple2e_state::ram0000_r(offs_t offset) { return m_ram_ptr[offset]; } +u8 apple2e_state::ram0000_r(offs_t offset) { return m_ram_ptr[offset]; } void apple2e_state::ram0000_w(offs_t offset, u8 data) { m_ram_ptr[offset] = data; } -u8 apple2e_state::ram0200_r(offs_t offset) { return m_ram_ptr[offset+0x200]; } +u8 apple2e_state::ram0200_r(offs_t offset) { return m_ram_ptr[offset+0x200]; } void apple2e_state::ram0200_w(offs_t offset, u8 data) { m_ram_ptr[offset+0x200] = data; } -u8 apple2e_state::ram0400_r(offs_t offset) { return m_ram_ptr[offset+0x400]; } +u8 apple2e_state::ram0400_r(offs_t offset) { return m_ram_ptr[offset+0x400]; } void apple2e_state::ram0400_w(offs_t offset, u8 data) { m_ram_ptr[offset+0x400] = data; } -u8 apple2e_state::ram0800_r(offs_t offset) { return m_ram_ptr[offset+0x800]; } +u8 apple2e_state::ram0800_r(offs_t offset) { return m_ram_ptr[offset+0x800]; } void apple2e_state::ram0800_w(offs_t offset, u8 data) { m_ram_ptr[offset+0x800] = data; } -u8 apple2e_state::ram2000_r(offs_t offset) { return m_ram_ptr[offset+0x2000]; } +u8 apple2e_state::ram2000_r(offs_t offset) { return m_ram_ptr[offset+0x2000]; } void apple2e_state::ram2000_w(offs_t offset, u8 data) { m_ram_ptr[offset+0x2000] = data; } -u8 apple2e_state::ram4000_r(offs_t offset) { return m_ram_ptr[offset+0x4000]; } +u8 apple2e_state::ram4000_r(offs_t offset) { return m_ram_ptr[offset+0x4000]; } void apple2e_state::ram4000_w(offs_t offset, u8 data) { m_ram_ptr[offset+0x4000] = data; } void apple2e_state::ram8000_w(offs_t offset, u8 data) { m_ram_ptr[offset+0x8000] = data; } + u8 apple2e_state::cec4000_r(offs_t offset) { //printf("cec4000_r: ofs %x\n", offset); @@ -3254,17 +3255,17 @@ u8 apple2e_state::cec8000_r(offs_t offset) } } -u8 apple2e_state::auxram0000_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset]; } else { return read_floatingbus(); } } +u8 apple2e_state::auxram0000_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset]; } else { return read_floatingbus(); } } void apple2e_state::auxram0000_w(offs_t offset, u8 data) { if (m_aux_bank_ptr) { m_aux_bank_ptr[offset] = data; } } -u8 apple2e_state::auxram0200_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x200]; } else { return read_floatingbus(); } } +u8 apple2e_state::auxram0200_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x200]; } else { return read_floatingbus(); } } void apple2e_state::auxram0200_w(offs_t offset, u8 data) { if (m_aux_bank_ptr) { m_aux_bank_ptr[offset+0x200] = data; } } -u8 apple2e_state::auxram0400_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x400]; } else { return read_floatingbus(); } } +u8 apple2e_state::auxram0400_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x400]; } else { return read_floatingbus(); } } void apple2e_state::auxram0400_w(offs_t offset, u8 data) { if (m_aux_bank_ptr) { m_aux_bank_ptr[offset+0x400] = data; } } -u8 apple2e_state::auxram0800_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x800]; } else { return read_floatingbus(); } } +u8 apple2e_state::auxram0800_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x800]; } else { return read_floatingbus(); } } void apple2e_state::auxram0800_w(offs_t offset, u8 data) { if (m_aux_bank_ptr) { m_aux_bank_ptr[offset+0x800] = data; } } -u8 apple2e_state::auxram2000_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x2000]; } else { return read_floatingbus(); } } +u8 apple2e_state::auxram2000_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x2000]; } else { return read_floatingbus(); } } void apple2e_state::auxram2000_w(offs_t offset, u8 data) { if (m_aux_bank_ptr) { m_aux_bank_ptr[offset+0x2000] = data; } } -u8 apple2e_state::auxram4000_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x4000]; } else { return read_floatingbus(); } } +u8 apple2e_state::auxram4000_r(offs_t offset) { if (m_aux_bank_ptr) { return m_aux_bank_ptr[offset+0x4000]; } else { return read_floatingbus(); } } void apple2e_state::auxram4000_w(offs_t offset, u8 data) { if (m_aux_bank_ptr) { m_aux_bank_ptr[offset+0x4000] = data; } } void apple2e_state::apple2e_map(address_map &map) diff --git a/src/mame/drivers/applix.cpp b/src/mame/drivers/applix.cpp index 4002406aa4c..c9e15828714 100644 --- a/src/mame/drivers/applix.cpp +++ b/src/mame/drivers/applix.cpp @@ -462,7 +462,7 @@ void applix_state::main_mem(address_map &map) map(0x500000, 0x51ffff).rom().region("maincpu", 0); map(0x600000, 0x60007f).w(FUNC(applix_state::palette_w)); map(0x600080, 0x6000ff).w(FUNC(applix_state::dac_latch_w)); - map(0x600100, 0x60017f).w(FUNC(applix_state::video_latch_w)); //video latch (=border colour, high nibble; video base, low nibble) (odd) + map(0x600100, 0x60017f).w(FUNC(applix_state::video_latch_w)); //video latch (=border colour, high nybble; video base, low nybble) (odd) map(0x600180, 0x6001ff).w(FUNC(applix_state::analog_latch_w)); map(0x700000, 0x700007).mirror(0x78).rw("scc", FUNC(scc8530_device::ab_dc_r), FUNC(scc8530_device::ab_dc_w)).umask16(0xff00).cswidth(16); map(0x700080, 0x7000ff).r(FUNC(applix_state::applix_inputs_r)); diff --git a/src/mame/drivers/bigbord2.cpp b/src/mame/drivers/bigbord2.cpp index cd01639c220..144cfc293d4 100644 --- a/src/mame/drivers/bigbord2.cpp +++ b/src/mame/drivers/bigbord2.cpp @@ -71,6 +71,7 @@ X - change banks #include "emu.h" + #include "cpu/z80/z80.h" #include "imagedev/floppy.h" #include "machine/z80daisy.h" @@ -83,11 +84,14 @@ X - change banks #include "machine/z80sio.h" #include "sound/beep.h" #include "video/mc6845.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + class bigbord2_state : public driver_device { public: @@ -334,11 +338,11 @@ void bigbord2_state::syslatch2_w(u8 data) void bigbord2_state::mem_map(address_map &map) { map.unmap_value_high(); - map(0x0000, 0x5fff).bankr("bankr").bankw("bankw"); - map(0x6000, 0x67ff).bankrw("bankv"); - map(0x6800, 0x6fff).bankrw("bankv1"); - map(0x7000, 0x77ff).bankrw("banka"); - map(0x7800, 0x7fff).bankrw("banka1"); + map(0x0000, 0x5fff).bankr(m_bankr).bankw(m_bankw); + map(0x6000, 0x67ff).bankrw(m_bankv); + map(0x6800, 0x6fff).bankrw(m_bankv1); + map(0x7000, 0x77ff).bankrw(m_banka); + map(0x7800, 0x7fff).bankrw(m_banka1); map(0x8000, 0xffff).ram(); } @@ -627,6 +631,7 @@ void bigbord2_state::bigbord2(machine_config &config) MB8877(config, m_fdc, 16_MHz_XTAL / 8); // U10 : 2MHz for 8 inch, or 1MHz otherwise (jumper-selectable) //m_fdc->intrq_wr_callback().set_inputline(m_maincpu, ??); // info missing from schematic + m_fdc->drq_wr_callback().set(FUNC(bigbord2_state::fdc_drq_w)); FLOPPY_CONNECTOR(config, "fdc:0", bigbord2_floppies, "8dsdd", floppy_image_device::default_mfm_floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, "fdc:1", bigbord2_floppies, "8dsdd", floppy_image_device::default_mfm_floppy_formats).enable_sound(true); @@ -670,7 +675,6 @@ void bigbord2_state::bigbord2(machine_config &config) /* ROMs */ - ROM_START( bigbord2 ) // for optional roms and eproms ROM_REGION( 0x6000, "maincpu", ROMREGION_ERASEFF ) @@ -683,6 +687,10 @@ ROM_START( bigbord2 ) ROM_LOAD( "pal16l8.u23", 0x0000, 0x0400, NO_DUMP ) ROM_LOAD( "pal10l8.u34", 0x0400, 0x0400, NO_DUMP ) ROM_END + +} // anonymous namespace + + /* System Drivers */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/calchase.cpp b/src/mame/drivers/calchase.cpp index d67a94fa8b5..eed6b695b0d 100644 --- a/src/mame/drivers/calchase.cpp +++ b/src/mame/drivers/calchase.cpp @@ -131,6 +131,7 @@ something wrong in the disk geometry reported by calchase.chd (20,255,63) since #include "emu.h" + #include "bus/isa/trident.h" #include "cpu/i386/i386.h" #include "machine/lpci.h" @@ -141,6 +142,7 @@ something wrong in the disk geometry reported by calchase.chd (20,255,63) since #include "machine/nvram.h" #include "sound/dac.h" #include "video/pc_vga.h" + #include "screen.h" #include "speaker.h" @@ -176,11 +178,6 @@ private: void bios_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); uint8_t nvram_r(offs_t offset); void nvram_w(offs_t offset, uint8_t data); - uint16_t calchase_iocard1_r(); - uint16_t calchase_iocard2_r(); - uint16_t calchase_iocard3_r(); - uint16_t calchase_iocard4_r(); - uint16_t calchase_iocard5_r(); uint32_t calchase_idle_skip_r(); void calchase_idle_skip_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); @@ -380,32 +377,6 @@ void calchase_state::nvram_w(offs_t offset, uint8_t data) m_nvram_data[offset] = data; } -uint16_t calchase_state::calchase_iocard1_r() -{ - return ioport("IOCARD1")->read(); -} - -uint16_t calchase_state::calchase_iocard2_r() -{ - return ioport("IOCARD2")->read(); -} - -uint16_t calchase_state::calchase_iocard3_r() -{ - return ioport("IOCARD3")->read(); -} - -/* These two controls wheel pot or whatever this game uses ... */ -uint16_t calchase_state::calchase_iocard4_r() -{ - return ioport("IOCARD4")->read(); -} - -uint16_t calchase_state::calchase_iocard5_r() -{ - return ioport("IOCARD5")->read(); -} - void calchase_state::calchase_map(address_map &map) { @@ -414,11 +385,11 @@ void calchase_state::calchase_map(address_map &map) map(0x000c0000, 0x000c7fff).rom().region("video_bios", 0); map(0x000c8000, 0x000cffff).noprw(); //map(0x000d0000, 0x000d0003).ram(); // XYLINX - Sincronus serial communication - map(0x000d0004, 0x000d0005).r(FUNC(calchase_state::calchase_iocard1_r)); - map(0x000d000c, 0x000d000d).r(FUNC(calchase_state::calchase_iocard2_r)); - map(0x000d0032, 0x000d0033).r(FUNC(calchase_state::calchase_iocard3_r)); - map(0x000d0030, 0x000d0031).r(FUNC(calchase_state::calchase_iocard4_r)); - map(0x000d0034, 0x000d0035).r(FUNC(calchase_state::calchase_iocard5_r)); + map(0x000d0004, 0x000d0005).portr("IOCARD1"); + map(0x000d000c, 0x000d000d).portr("IOCARD2"); + map(0x000d0032, 0x000d0033).portr("IOCARD3"); + map(0x000d0030, 0x000d0031).portr("IOCARD4"); // These two controls wheel pot or whatever this game uses ... + map(0x000d0034, 0x000d0035).portr("IOCARD5"); map(0x000d0008, 0x000d000b).nopw(); // ??? map(0x000d0024, 0x000d0025).w("ldac", FUNC(dac_word_interface::data_w)); map(0x000d0028, 0x000d0029).w("rdac", FUNC(dac_word_interface::data_w)); @@ -496,6 +467,7 @@ static INPUT_PORTS_START( calchase ) PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_START("IOCARD2") PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE1 ) // guess PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Reset SW") @@ -514,6 +486,7 @@ static INPUT_PORTS_START( calchase ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Turbo") PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) // returns back to MS-DOS (likely to be unmapped and actually used as a lame protection check) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_START("IOCARD3") PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") PORT_BIT( 0xdfff, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -565,6 +538,7 @@ static INPUT_PORTS_START( calchase ) PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x8000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_START("IOCARD5") PORT_DIPNAME( 0x01, 0x01, "DSWA" ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) diff --git a/src/mame/drivers/ccs2810.cpp b/src/mame/drivers/ccs2810.cpp index 704d856500c..339ed5f04a5 100644 --- a/src/mame/drivers/ccs2810.cpp +++ b/src/mame/drivers/ccs2810.cpp @@ -99,6 +99,8 @@ ToDo: #include "machine/z80sio.h" +namespace { + class ccs_state : public driver_device { public: @@ -121,6 +123,9 @@ public: void ccs2422(machine_config &config); protected: + void machine_start() override; + void machine_reset() override; + u8 port04_r(); u8 port34_r(); void port04_w(u8 data); @@ -150,9 +155,6 @@ private: u8 io_read(offs_t offset); void io_write(offs_t offset, u8 data); - void machine_start() override; - void machine_reset() override; - void port40_w(u8 data); void ccs2422_io(address_map &map); @@ -173,9 +175,11 @@ public: void ccs300(machine_config &config); -private: +protected: void machine_start() override; void machine_reset() override; + +private: void ccs300_io(address_map &map); void ccs300_mem(address_map &map); void port40_w(u8 data); @@ -978,6 +982,7 @@ void ccs300_state::machine_start() { m_bank1->configure_entry(0, m_ram1); m_bank1->configure_entry(1, m_rom); + save_item(NAME(m_ss)); save_item(NAME(m_dden)); save_item(NAME(m_dsize)); @@ -1139,9 +1144,12 @@ ROM_START( ccs300 ) ROM_LOAD( "ccs300.rom", 0x0000, 0x0800, CRC(6cf22e31) SHA1(9aa3327cd8c23d0eab82cb6519891aff13ebe1d0)) ROM_END +} // anonymous namespace + + /* Driver */ -/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */ +// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS COMP( 1980, ccs2810, 0, 0, ccs2810, ccs2810, ccs_state, empty_init, "California Computer Systems", "CCS Model 2810 CPU card", MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE ) COMP( 1980, ccs2422, ccs2810, 0, ccs2422, ccs2810, ccs_state, empty_init, "California Computer Systems", "CCS Model 2422B FDC card", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE ) -COMP( 1981, ccs300, ccs2810, 0, ccs300, ccs300, ccs300_state, empty_init, "California Computer Systems", "CCS Model 300", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE ) +COMP( 1981, ccs300, ccs2810, 0, ccs300, ccs300, ccs300_state, empty_init, "California Computer Systems", "CCS Model 300", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/cops.cpp b/src/mame/drivers/cops.cpp index 52d4d37d927..ac23064fdf7 100644 --- a/src/mame/drivers/cops.cpp +++ b/src/mame/drivers/cops.cpp @@ -31,12 +31,14 @@ #include "emu.h" + #include "cpu/m6502/m6502.h" #include "machine/6522via.h" -#include "sound/sn76496.h" -#include "machine/msm6242.h" #include "machine/ldp1450.h" #include "machine/mos6551.h" +#include "machine/msm6242.h" +#include "sound/sn76496.h" + #include "speaker.h" #include "cops.lh" @@ -60,6 +62,9 @@ public: , m_maincpu(*this, "maincpu") , m_sn(*this, "snsnd") , m_ld(*this, "laserdisc") + , m_switches(*this, "SW%u", 0U) + , m_steer(*this, "STEER") + , m_digits(*this, "digit%u", 0U) , m_irq(0) { } @@ -83,6 +88,9 @@ private: required_device m_maincpu; required_device m_sn; required_device m_ld; + required_ioport_array<3> m_switches; + optional_ioport m_steer; + output_finder<16> m_digits; // screen updates [[maybe_unused]] uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -581,11 +589,11 @@ uint8_t cops_state::io1_r(offs_t offset) switch( offset & 0x0f ) { case 0x08: /* SW0 */ - return ioport("SW0")->read(); + return m_switches[0]->read(); case 0x09: /* SW1 */ - return ioport("SW1")->read(); + return m_switches[1]->read(); case 0x0a: /* SW2 */ - return ioport("SW2")->read(); + return m_switches[2]->read(); default: logerror("Unknown io1_r, offset = %03x\n", offset); return 0; @@ -599,11 +607,11 @@ uint8_t cops_state::io1_lm_r(offs_t offset) case 0x07: /* WDI */ return 1; case 0x08: /* SW0 */ - return ioport("SW0")->read(); + return m_switches[0]->read(); case 0x09: /* SW1 */ - return ioport("SW1")->read(); + return m_switches[1]->read(); case 0x0a: /* SW2 */ - return ioport("SW2")->read(); + return m_switches[2]->read(); default: logerror("Unknown io1_r, offset = %03x\n", offset); return 0; @@ -612,11 +620,7 @@ uint8_t cops_state::io1_lm_r(offs_t offset) void cops_state::io1_w(offs_t offset, uint8_t data) { - int i; - char output_name[16]; - uint16_t display_data; - - switch( offset & 0x0f ) + switch (offset & 0x0f) { case 0x00: /* WOP0 Alpha display*/ m_lcd_addr_l = data; @@ -625,24 +629,19 @@ void cops_state::io1_w(offs_t offset, uint8_t data) m_lcd_addr_h = data; { // update display - const uint16_t addrs_table[] = { 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0002, 0x0001, 0x0080, - 0x1000, 0x0800, 0x0400, 0x2000, 0x4000, 0x0200, 0x0100, 0x8000 }; - uint16_t addr = m_lcd_addr_l | (m_lcd_addr_h << 8); - for (i = 0; i < 16; i++ ) + constexpr uint16_t addrs_table[] = { + 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0002, 0x0001, 0x0080, + 0x1000, 0x0800, 0x0400, 0x2000, 0x4000, 0x0200, 0x0100, 0x8000 }; + const uint16_t addr = m_lcd_addr_l | (m_lcd_addr_h << 8); + for (int i = 0; i < 16; i++) { if (addr == addrs_table[i]) { + const uint16_t display_data = m_lcd_data_l | (m_lcd_data_h << 8); + m_digits[i] = bitswap<16>(display_data, 4, 5, 12, 1, 0, 11, 10, 6, 7, 2, 9, 3, 15, 8, 14, 13); break; } } - - if (i < 16) - { - sprintf(output_name, "digit%d", i); - display_data = m_lcd_data_l | (m_lcd_data_h << 8); - display_data = bitswap<16>(display_data, 4, 5, 12, 1, 0, 11, 10, 6, 7, 2, 9, 3, 15, 8, 14, 13); - output().set_value(output_name, display_data); - } } break; case 0x02: /* WOP2 Alpha display*/ @@ -690,7 +689,7 @@ uint8_t cops_state::io2_r(offs_t offset) switch( offset & 0x0f ) { case 0x03: - return ioport("STEER")->read(); + return m_steer->read(); default: logerror("Unknown io2_r, offset = %02x\n", offset); return 0; @@ -871,11 +870,12 @@ static INPUT_PORTS_START( revlatns ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_CUSTOM ) - INPUT_PORTS_END void cops_state::machine_start() { + m_digits.resolve(); + m_ld_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cops_state::ld_timer_callback),this)); m_ld_timer->adjust(attotime::from_hz(167*5), 0, attotime::from_hz(167*5)); @@ -941,6 +941,7 @@ void cops_state::base(machine_config &config) void cops_state::cops(machine_config &config) { base(config); + m_maincpu->set_addrmap(AS_PROGRAM, &cops_state::cops_map); via6522_device &via2(MOS6522(config, "via6522_2", MAIN_CLOCK/2)); @@ -955,6 +956,7 @@ void cops_state::cops(machine_config &config) void cops_state::revlatns(machine_config &config) { base(config); + m_maincpu->set_addrmap(AS_PROGRAM, &cops_state::revlatns_map); MSM6242(config, "rtc", XTAL(32'768)); diff --git a/src/mame/drivers/cortex.cpp b/src/mame/drivers/cortex.cpp index e5f2774683f..4b4a7b85d8a 100644 --- a/src/mame/drivers/cortex.cpp +++ b/src/mame/drivers/cortex.cpp @@ -44,16 +44,20 @@ packed into a single address-byte (CRU 0 = bit 0, etc). So the address is ****************************************************************************/ - #include "emu.h" + #include "cpu/tms9900/tms9995.h" #include "machine/74259.h" -#include "video/tms9928a.h" -//#include "machine/tms9902.h" #include "machine/keyboard.h" +//#include "machine/tms9902.h" +#include "video/tms9928a.h" #include "sound/beep.h" + #include "speaker.h" + +namespace { + class cortex_state : public driver_device { public: @@ -69,6 +73,10 @@ public: void cortex(machine_config &config); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + private: void kbd_put(u8 data); DECLARE_WRITE_LINE_MEMBER(keyboard_ack_w); @@ -76,13 +84,13 @@ private: DECLARE_WRITE_LINE_MEMBER(vdp_int_w); u8 pio_r(offs_t offset); u8 keyboard_r(offs_t offset); + void io_map(address_map &map); void mem_map(address_map &map); + bool m_kbd_ack; bool m_vdp_int; u8 m_term_data; - void machine_reset() override; - void machine_start() override; required_device m_maincpu; required_region_ptr m_rom; required_shared_ptr m_ram; @@ -93,7 +101,7 @@ private: void cortex_state::mem_map(address_map &map) { - map(0x0000, 0x7fff).ram().share("mainram").bankr("bank1"); + map(0x0000, 0x7fff).ram().share(m_ram).bankr(m_bank1); map(0x8000, 0xefff).ram(); map(0xf100, 0xf11f).ram(); // memory mapping unit map(0xf120, 0xf121).rw("crtc", FUNC(tms9928a_device::read), FUNC(tms9928a_device::write)); @@ -245,6 +253,9 @@ ROM_START( cortex ) ROMX_LOAD( "forth.ic46", 0x2000, 0x2000, CRC(8eca54cc) SHA1(0f1680e941ef60bb9bde9a4b843b78f30dff3202), ROM_BIOS(1)) ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/cvicny.cpp b/src/mame/drivers/cvicny.cpp index b73d9852482..dc2752e7f16 100644 --- a/src/mame/drivers/cvicny.cpp +++ b/src/mame/drivers/cvicny.cpp @@ -34,6 +34,9 @@ Test Paste: #include "video/pwm.h" #include "cvicny.lh" + +namespace { + class cvicny_state : public driver_device { public: @@ -42,16 +45,19 @@ public: , m_maincpu(*this, "maincpu") , m_display(*this, "display") , m_io_keyboard(*this, "X%u", 0U) - { } + { } void cvicny(machine_config &config); +protected: + virtual void machine_start() override; + private: void cvicny_mem(address_map &map); - virtual void machine_start() override; u8 key_r(); void digit_w(u8 data); void segment_w(u8 data); + u8 m_digit; u8 m_seg; required_device m_maincpu; @@ -155,6 +161,9 @@ ROM_START( cvicny ) ROM_LOAD("cvicny8080.bin", 0x0000, 0x05ea, CRC(e6119052) SHA1(d03c2cbfd047f0d090a787fbbde6353593cc2dd8) ) ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/cz101.cpp b/src/mame/drivers/cz101.cpp index 122e0e86a0b..a10bf9c7537 100644 --- a/src/mame/drivers/cz101.cpp +++ b/src/mame/drivers/cz101.cpp @@ -25,6 +25,8 @@ #include "cz101.lh" +namespace { + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -266,50 +268,50 @@ HD44780_PIXEL_UPDATE( cz101_state::lcd_pixel_update ) void cz101_state::led_4_w(uint8_t data) { - m_leds[0] = BIT(data, 7) ? 0 : 1; - m_leds[1] = BIT(data, 6) ? 0 : 1; - m_leds[2] = BIT(data, 5) ? 0 : 1; - m_leds[3] = BIT(data, 4) ? 0 : 1; - m_leds[4] = BIT(data, 3) ? 0 : 1; - m_leds[5] = BIT(data, 2) ? 0 : 1; - m_leds[6] = BIT(data, 1) ? 0 : 1; - m_leds[7] = BIT(data, 0) ? 0 : 1; + m_leds[0] = BIT(~data, 7); + m_leds[1] = BIT(~data, 6); + m_leds[2] = BIT(~data, 5); + m_leds[3] = BIT(~data, 4); + m_leds[4] = BIT(~data, 3); + m_leds[5] = BIT(~data, 2); + m_leds[6] = BIT(~data, 1); + m_leds[7] = BIT(~data, 0); } void cz101_state::led_3_w(uint8_t data) { - m_leds[8] = BIT(data, 7) ? 0 : 1; - m_leds[9] = BIT(data, 6) ? 0 : 1; - m_leds[10] = BIT(data, 5) ? 0 : 1; - m_leds[11] = BIT(data, 4) ? 0 : 1; - m_leds[12] = BIT(data, 3) ? 0 : 1; - m_leds[13] = BIT(data, 2) ? 0 : 1; - m_leds[14] = BIT(data, 1) ? 0 : 1; - m_leds[15] = BIT(data, 0) ? 0 : 1; + m_leds[8] = BIT(~data, 7); + m_leds[9] = BIT(~data, 6); + m_leds[10] = BIT(~data, 5); + m_leds[11] = BIT(~data, 4); + m_leds[12] = BIT(~data, 3); + m_leds[13] = BIT(~data, 2); + m_leds[14] = BIT(~data, 1); + m_leds[15] = BIT(~data, 0); } void cz101_state::led_2_w(uint8_t data) { - m_leds[16] = BIT(data, 7) ? 0 : 1; - m_leds[17] = BIT(data, 6) ? 0 : 1; - m_leds[18] = BIT(data, 5) ? 0 : 1; - m_leds[19] = BIT(data, 4) ? 0 : 1; - m_leds[20] = BIT(data, 3) ? 0 : 1; - m_leds[21] = BIT(data, 2) ? 0 : 1; - m_leds[22] = BIT(data, 1) ? 0 : 1; - m_leds[23] = BIT(data, 0) ? 0 : 1; + m_leds[16] = BIT(~data, 7); + m_leds[17] = BIT(~data, 6); + m_leds[18] = BIT(~data, 5); + m_leds[19] = BIT(~data, 4); + m_leds[20] = BIT(~data, 3); + m_leds[21] = BIT(~data, 2); + m_leds[22] = BIT(~data, 1); + m_leds[23] = BIT(~data, 0); } void cz101_state::led_1_w(uint8_t data) { - m_leds[24] = BIT(data, 7) ? 0 : 1; - m_leds[25] = BIT(data, 6) ? 0 : 1; - m_leds[26] = BIT(data, 5) ? 0 : 1; - m_leds[27] = BIT(data, 4) ? 0 : 1; - m_leds[28] = BIT(data, 3) ? 0 : 1; - m_leds[29] = BIT(data, 2) ? 0 : 1; - m_leds[30] = BIT(data, 1) ? 0 : 1; - m_leds[31] = BIT(data, 0) ? 0 : 1; + m_leds[24] = BIT(~data, 7); + m_leds[25] = BIT(~data, 6); + m_leds[26] = BIT(~data, 5); + m_leds[27] = BIT(~data, 4); + m_leds[28] = BIT(~data, 3); + m_leds[29] = BIT(~data, 2); + m_leds[30] = BIT(~data, 1); + m_leds[31] = BIT(~data, 0); } uint8_t cz101_state::keys_r() @@ -412,6 +414,8 @@ ROM_START( cz101 ) ROM_LOAD("5f3_s40.bin", 0x0000, 0x8000, CRC(c417bc57) SHA1(2aa5bfb76dc0a56797cf5dd547197816cedfa370)) ROM_END +} // anonymous namespace + //************************************************************************** // SYSTEM DRIVERS diff --git a/src/mame/drivers/dps1.cpp b/src/mame/drivers/dps1.cpp index 0b1707f3292..d4a30cde501 100644 --- a/src/mame/drivers/dps1.cpp +++ b/src/mame/drivers/dps1.cpp @@ -23,6 +23,9 @@ ToDo: //#include "bus/s100/s100.h" #include "softlist.h" + +namespace { + class dps1_state : public driver_device { public: @@ -39,9 +42,11 @@ public: void dps1(machine_config &config); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + private: - void machine_reset() override; - void machine_start() override; void portb2_w(u8 data); void portb4_w(u8 data); void portb6_w(u8 data); @@ -55,6 +60,7 @@ private: void io_map(address_map &map); void mem_map(address_map &map); + bool m_dma_dir; u16 m_dma_adr; required_device m_maincpu; @@ -68,8 +74,8 @@ private: void dps1_state::mem_map(address_map &map) { - map(0x0000, 0xffff).ram().share("mainram"); - map(0x0000, 0x03ff).bankr("bank1"); + map(0x0000, 0xffff).ram().share(m_ram); + map(0x0000, 0x03ff).bankr(m_bank1); } void dps1_state::io_map(address_map &map) @@ -176,6 +182,7 @@ void dps1_state::machine_start() { m_bank1->configure_entry(0, m_ram); m_bank1->configure_entry(1, m_rom); + save_item(NAME(m_dma_dir)); save_item(NAME(m_dma_adr)); } @@ -236,4 +243,7 @@ ROM_START( dps1 ) ROM_LOAD( "boot 1280", 0x0000, 0x0400, CRC(9c2e98fa) SHA1(78e6c9d00aa6e8f6c4d3c65984cfdf4e99434c66) ) // actually on the FDC-2 board ROM_END +} // anonymous namespace + + COMP( 1979, dps1, 0, 0, dps1, dps1, dps1_state, empty_init, "Ithaca InterSystems", "DPS-1", MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/dsb46.cpp b/src/mame/drivers/dsb46.cpp index 9d97d17a692..554dc62b0a0 100644 --- a/src/mame/drivers/dsb46.cpp +++ b/src/mame/drivers/dsb46.cpp @@ -25,14 +25,16 @@ The photos show 3 boards: ********************************************************************************************************************/ - #include "emu.h" -#include "cpu/z80/z80.h" -#include "machine/z80daisy.h" -#include "machine/z80ctc.h" -#include "machine/z80sio.h" -#include "bus/rs232/rs232.h" +#include "bus/rs232/rs232.h" +#include "cpu/z80/z80.h" +#include "machine/z80ctc.h" +#include "machine/z80daisy.h" +#include "machine/z80sio.h" + + +namespace { class dsb46_state : public driver_device { @@ -47,9 +49,11 @@ public: void dsb46(machine_config &config); +protected: + virtual void machine_reset() override; + virtual void machine_start() override; + private: - void machine_reset() override; - void machine_start() override; void port1a_w(u8 data); void io_map(address_map &map); void mem_map(address_map &map); @@ -61,8 +65,8 @@ private: void dsb46_state::mem_map(address_map &map) { - map(0x0000, 0xffff).ram().share("mainram"); - map(0x0000, 0x07ff).bankr("bank1"); + map(0x0000, 0xffff).ram().share(m_ram); + map(0x0000, 0x07ff).bankr(m_bank1); } void dsb46_state::io_map(address_map &map) @@ -143,4 +147,7 @@ ROM_START( dsb46 ) ROM_LOAD( "ades.bin", 0x0000, 0x4000, CRC(d374abf0) SHA1(331f51a2bb81375aeffbe63c1ebc1d7cd779b9c3) ) ROM_END +} // anonymous namespace + + COMP( 198?, dsb46, 0, 0, dsb46, dsb46, dsb46_state, empty_init, "Davidge", "DSB-4/6", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/excali64.cpp b/src/mame/drivers/excali64.cpp index 30a46d6bb31..dde711a63a1 100644 --- a/src/mame/drivers/excali64.cpp +++ b/src/mame/drivers/excali64.cpp @@ -64,6 +64,8 @@ public: , m_palette(*this, "palette") , m_maincpu(*this, "maincpu") , m_p_chargen(*this, "chargen") + , m_bankr(*this, "bankr%u", 1U) + , m_bankw(*this, "bankw%u", 1U) , m_cass(*this, "cassette") , m_crtc(*this, "crtc") , m_io_keyboard(*this, "KEY.%u", 0) @@ -119,6 +121,8 @@ private: required_device m_palette; required_device m_maincpu; required_region_ptr m_p_chargen; + required_memory_bank_array<4> m_bankr; + required_memory_bank_array<4> m_bankw; required_device m_cass; required_device m_crtc; required_ioport_array<8> m_io_keyboard; @@ -132,11 +136,11 @@ private: void excali64_state::mem_map(address_map &map) { - map(0x0000, 0x1FFF).bankr("bankr1").bankw("bankw1"); - map(0x2000, 0x2FFF).bankr("bankr2").bankw("bankw2"); - map(0x3000, 0x3FFF).bankr("bankr3").bankw("bankw3"); - map(0x4000, 0xBFFF).bankr("bankr4").bankw("bankw4"); - map(0xC000, 0xFFFF).ram(); + map(0x0000, 0x1fff).bankr(m_bankr[0]).bankw(m_bankw[0]); + map(0x2000, 0x2fff).bankr(m_bankr[1]).bankw(m_bankw[1]); + map(0x3000, 0x3fff).bankr(m_bankr[2]).bankw(m_bankw[2]); + map(0x4000, 0xbfff).bankr(m_bankr[3]).bankw(m_bankw[3]); + map(0xc000, 0xffff).ram(); } void excali64_state::io_map(address_map &map) @@ -386,52 +390,57 @@ void excali64_state::port70_w(u8 data) if (BIT(data, 1)) { // select 64k ram - membank("bankr1")->set_entry(0); - membank("bankr2")->set_entry(0); - membank("bankr3")->set_entry(0); - membank("bankr4")->set_entry(0); - membank("bankw2")->set_entry(0); - membank("bankw3")->set_entry(0); - membank("bankw4")->set_entry(0); + m_bankr[0]->set_entry(0); + m_bankr[1]->set_entry(0); + m_bankr[2]->set_entry(0); + m_bankr[3]->set_entry(0); + + m_bankw[1]->set_entry(0); + m_bankw[2]->set_entry(0); + m_bankw[3]->set_entry(0); } else if (BIT(data, 0)) { // select videoram and hiresram - membank("bankr1")->set_entry(1); - membank("bankr2")->set_entry(2); - membank("bankr3")->set_entry(2); - membank("bankw2")->set_entry(2); - membank("bankw3")->set_entry(2); - membank("bankr4")->set_entry(2); - membank("bankw4")->set_entry(2); + m_bankr[0]->set_entry(1); + m_bankr[1]->set_entry(2); + m_bankr[2]->set_entry(2); + m_bankr[3]->set_entry(2); + + m_bankw[1]->set_entry(2); + m_bankw[2]->set_entry(2); + m_bankw[3]->set_entry(2); } else { // select rom, videoram, and main ram - membank("bankr1")->set_entry(1); - membank("bankr2")->set_entry(1); - membank("bankr3")->set_entry(1); - membank("bankw2")->set_entry(2); - membank("bankw3")->set_entry(2); - membank("bankr4")->set_entry(0); - membank("bankw4")->set_entry(0); + m_bankr[0]->set_entry(1); + m_bankr[1]->set_entry(1); + m_bankr[2]->set_entry(1); + m_bankr[3]->set_entry(0); + + m_bankw[1]->set_entry(2); + m_bankw[2]->set_entry(2); + m_bankw[3]->set_entry(0); } // other half of ROM_1 if ((data & 0x22) == 0x20) - membank("bankr1")->set_entry(2); + m_bankr[0]->set_entry(2); } void excali64_state::machine_reset() { - membank("bankr1")->set_entry(1); // read from ROM - membank("bankr2")->set_entry(1); // read from ROM - membank("bankr3")->set_entry(1); // read from ROM - membank("bankr4")->set_entry(0); // read from RAM - membank("bankw1")->set_entry(0); // write to RAM - membank("bankw2")->set_entry(2); // write to videoram - membank("bankw3")->set_entry(2); // write to videoram hires pointers - membank("bankw4")->set_entry(0); // write to RAM + m_bankr[0]->set_entry(1); // read from ROM + m_bankr[1]->set_entry(1); // read from ROM + m_bankr[2]->set_entry(1); // read from ROM + m_bankr[3]->set_entry(0); // read from RAM + + m_bankw[0]->set_entry(0); // write to RAM + m_bankw[1]->set_entry(2); // write to videoram + m_bankw[2]->set_entry(2); // write to videoram hires pointers + m_bankw[3]->set_entry(0); // write to RAM + m_maincpu->reset(); } @@ -492,28 +501,28 @@ void excali64_state::excali64_palette(palette_device &palette) u8 *main = memregion("roms")->base(); // main ram (cp/m mode) - membank("bankr1")->configure_entry(0, r); - membank("bankr2")->configure_entry(0, r+0x2000); - membank("bankr3")->configure_entry(0, r+0x3000); - membank("bankr4")->configure_entry(0, r+0x4000);//boot - membank("bankw1")->configure_entry(0, r);//boot - membank("bankw2")->configure_entry(0, r+0x2000); - membank("bankw3")->configure_entry(0, r+0x3000); - membank("bankw4")->configure_entry(0, r+0x4000);//boot + m_bankr[0]->configure_entry(0, r); + m_bankr[1]->configure_entry(0, r+0x2000); + m_bankr[2]->configure_entry(0, r+0x3000); + m_bankr[3]->configure_entry(0, r+0x4000);//boot + m_bankw[0]->configure_entry(0, r);//boot + m_bankw[1]->configure_entry(0, r+0x2000); + m_bankw[2]->configure_entry(0, r+0x3000); + m_bankw[3]->configure_entry(0, r+0x4000);//boot // rom_1 - membank("bankr1")->configure_entry(1, &main[0x0000]);//boot - membank("bankr1")->configure_entry(2, &main[0x2000]); + m_bankr[0]->configure_entry(1, &main[0x0000]);//boot + m_bankr[0]->configure_entry(2, &main[0x2000]); // rom_2 - membank("bankr2")->configure_entry(1, &main[0x4000]);//boot - membank("bankr3")->configure_entry(1, &main[0x5000]);//boot + m_bankr[1]->configure_entry(1, &main[0x4000]);//boot + m_bankr[2]->configure_entry(1, &main[0x5000]);//boot // videoram - membank("bankr2")->configure_entry(2, v); - membank("bankw2")->configure_entry(2, v);//boot + m_bankr[1]->configure_entry(2, v); + m_bankw[1]->configure_entry(2, v);//boot // hiresram - membank("bankr3")->configure_entry(2, v+0x1000); - membank("bankw3")->configure_entry(2, v+0x1000);//boot - membank("bankr4")->configure_entry(2, h); - membank("bankw4")->configure_entry(2, h); + m_bankr[2]->configure_entry(2, v+0x1000); + m_bankw[2]->configure_entry(2, v+0x1000);//boot + m_bankr[3]->configure_entry(2, h); + m_bankw[3]->configure_entry(2, h); // Set up foreground colours for (u8 i = 0; i < 32; i++) diff --git a/src/mame/drivers/force68k.cpp b/src/mame/drivers/force68k.cpp index 03d594ca831..88b41fb6aad 100644 --- a/src/mame/drivers/force68k.cpp +++ b/src/mame/drivers/force68k.cpp @@ -382,7 +382,7 @@ void force68k_state::machine_start () m_usrrom = (uint16_t*)m_cart->get_rom_base(); #if 0 // This should be the correct way but produces odd and even bytes swapped m_maincpu->space(AS_PROGRAM).install_read_handler(0xa0000, 0xbffff, read16sm_delegate(*m_cart, FUNC(generic_slot_device::read16_rom))); -#else // So we installs a custom very inefficient handler for now until we understand hop to solve the problem better +#else // So we install a custom very inefficient handler for now until we understand how to solve the problem better m_maincpu->space(AS_PROGRAM).install_read_handler(0xa0000, 0xbffff, read16sm_delegate(*this, FUNC(force68k_state::read16_rom))); #endif } diff --git a/src/mame/drivers/galgames.cpp b/src/mame/drivers/galgames.cpp index a96793e50dd..094f875b71a 100644 --- a/src/mame/drivers/galgames.cpp +++ b/src/mame/drivers/galgames.cpp @@ -38,6 +38,7 @@ Notes: ***************************************************************************/ #include "emu.h" + #include "cpu/m68000/m68000.h" #include "cpu/pic16c5x/pic16c5x.h" #include "machine/eepromser.h" @@ -45,10 +46,12 @@ Notes: #include "machine/watchdog.h" #include "sound/okim6295.h" #include "video/cesblit.h" + +#include "dirom.h" #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "dirom.h" + /*************************************************************************** diff --git a/src/mame/drivers/hng64.cpp b/src/mame/drivers/hng64.cpp index 2598f38de5c..569c85e461b 100644 --- a/src/mame/drivers/hng64.cpp +++ b/src/mame/drivers/hng64.cpp @@ -2313,21 +2313,6 @@ void hng64_state::ioport4_w(uint8_t data) LOG("%s: ioport4_w %02x\n", machine().describe_context(), data); } -/*********************************************** - - Other port accesses from MCU side - -***********************************************/ - -uint8_t hng64_state::anport0_r() { return m_an_in[0]->read(); } -uint8_t hng64_state::anport1_r() { return m_an_in[1]->read(); } -uint8_t hng64_state::anport2_r() { return m_an_in[2]->read(); } -uint8_t hng64_state::anport3_r() { return m_an_in[3]->read(); } -uint8_t hng64_state::anport4_r() { return m_an_in[4]->read(); } -uint8_t hng64_state::anport5_r() { return m_an_in[5]->read(); } -uint8_t hng64_state::anport6_r() { return m_an_in[6]->read(); } -uint8_t hng64_state::anport7_r() { return m_an_in[7]->read(); } - /*********************************************** Serial Accesses from MCU side @@ -2418,14 +2403,14 @@ void hng64_state::hng64(machine_config &config) //iomcu.p6_out_cb().set(FUNC(hng64_state::ioport6_w)); // the IO MCU code uses the ADC which shares pins with port 6, meaning port 6 isn't used as an IO port iomcu.p7_out_cb().set(FUNC(hng64_state::ioport7_w)); // configuration / clocking for shared ram (port 0) accesses // most likely the analog inputs, up to a maximum of 8 - iomcu.an0_in_cb().set(FUNC(hng64_state::anport0_r)); - iomcu.an1_in_cb().set(FUNC(hng64_state::anport1_r)); - iomcu.an2_in_cb().set(FUNC(hng64_state::anport2_r)); - iomcu.an3_in_cb().set(FUNC(hng64_state::anport3_r)); - iomcu.an4_in_cb().set(FUNC(hng64_state::anport4_r)); - iomcu.an5_in_cb().set(FUNC(hng64_state::anport5_r)); - iomcu.an6_in_cb().set(FUNC(hng64_state::anport6_r)); - iomcu.an7_in_cb().set(FUNC(hng64_state::anport7_r)); + iomcu.an0_in_cb().set_ioport("AN0"); + iomcu.an1_in_cb().set_ioport("AN1"); + iomcu.an2_in_cb().set_ioport("AN2"); + iomcu.an3_in_cb().set_ioport("AN3"); + iomcu.an4_in_cb().set_ioport("AN4"); + iomcu.an5_in_cb().set_ioport("AN5"); + iomcu.an6_in_cb().set_ioport("AN6"); + iomcu.an7_in_cb().set_ioport("AN7"); // network related? iomcu.serial0_out_cb().set(FUNC(hng64_state::sio0_w)); //iomcu.serial1_out_cb().set(FUNC(hng64_state::sio1_w)); // not initialized / used @@ -2439,14 +2424,14 @@ void hng64_state::hng64_default(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps0_out_cb().set(FUNC(hng64_state::hng64_default_lamps0_w)); - lamps.lamps1_out_cb().set(FUNC(hng64_state::hng64_default_lamps1_w)); - lamps.lamps2_out_cb().set(FUNC(hng64_state::hng64_default_lamps2_w)); - lamps.lamps3_out_cb().set(FUNC(hng64_state::hng64_default_lamps3_w)); - lamps.lamps4_out_cb().set(FUNC(hng64_state::hng64_default_lamps4_w)); - lamps.lamps5_out_cb().set(FUNC(hng64_state::hng64_default_lamps5_w)); - lamps.lamps6_out_cb().set(FUNC(hng64_state::hng64_default_lamps6_w)); - lamps.lamps7_out_cb().set(FUNC(hng64_state::hng64_default_lamps7_w)); + lamps.lamps_out_cb<0>().set(FUNC(hng64_state::hng64_default_lamps_w<0>)); + lamps.lamps_out_cb<1>().set(FUNC(hng64_state::hng64_default_lamps_w<1>)); + lamps.lamps_out_cb<2>().set(FUNC(hng64_state::hng64_default_lamps_w<2>)); + lamps.lamps_out_cb<3>().set(FUNC(hng64_state::hng64_default_lamps_w<3>)); + lamps.lamps_out_cb<4>().set(FUNC(hng64_state::hng64_default_lamps_w<4>)); + lamps.lamps_out_cb<5>().set(FUNC(hng64_state::hng64_default_lamps_w<5>)); + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_default_lamps_w<6>)); + lamps.lamps_out_cb<7>().set(FUNC(hng64_state::hng64_default_lamps_w<7>)); } void hng64_state::hng64_drive(machine_config &config) @@ -2454,9 +2439,9 @@ void hng64_state::hng64_drive(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps5_out_cb().set(FUNC(hng64_state::hng64_drive_lamps5_w)); // force feedback steering - lamps.lamps6_out_cb().set(FUNC(hng64_state::hng64_drive_lamps6_w)); // lamps + coin counter - lamps.lamps7_out_cb().set(FUNC(hng64_state::hng64_drive_lamps7_w)); // lamps + lamps.lamps_out_cb<5>().set(FUNC(hng64_state::hng64_drive_lamps5_w)); // force feedback steering + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_drive_lamps6_w)); // lamps + coin counter + lamps.lamps_out_cb<7>().set(FUNC(hng64_state::hng64_drive_lamps7_w)); // lamps } void hng64_state::hng64_shoot(machine_config &config) @@ -2464,8 +2449,8 @@ void hng64_state::hng64_shoot(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps6_out_cb().set(FUNC(hng64_state::hng64_shoot_lamps6_w)); // start lamps (some missing?!) - lamps.lamps7_out_cb().set(FUNC(hng64_state::hng64_shoot_lamps7_w)); // gun lamps + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_shoot_lamps6_w)); // start lamps (some missing?!) + lamps.lamps_out_cb<7>().set(FUNC(hng64_state::hng64_shoot_lamps7_w)); // gun lamps } void hng64_state::hng64_fight(machine_config &config) @@ -2473,7 +2458,7 @@ void hng64_state::hng64_fight(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps6_out_cb().set(FUNC(hng64_state::hng64_fight_lamps6_w)); // coin counters + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_fight_lamps6_w)); // coin counters } diff --git a/src/mame/drivers/kaypro.cpp b/src/mame/drivers/kaypro.cpp index 933a5d4dfc5..18a56259e03 100644 --- a/src/mame/drivers/kaypro.cpp +++ b/src/mame/drivers/kaypro.cpp @@ -67,8 +67,8 @@ u8 kaypro_state::kaypro484_87_r() { return 0x7f; } /* to bypass unemulated HD void kaypro_state::kaypro_map(address_map &map) { - map(0x0000, 0x2fff).bankr("bankr").bankw("bankw"); - map(0x3000, 0x3fff).bankrw("bank3"); + map(0x0000, 0x2fff).bankr(m_bankr).bankw(m_bankw); + map(0x3000, 0x3fff).bankrw(m_bank3); map(0x4000, 0xffff).ram(); } diff --git a/src/mame/drivers/konendev.cpp b/src/mame/drivers/konendev.cpp index 6736bdbf813..d6bf652d1f6 100644 --- a/src/mame/drivers/konendev.cpp +++ b/src/mame/drivers/konendev.cpp @@ -62,17 +62,22 @@ */ #include "emu.h" -#include "cpu/powerpc/ppc.h" -#include "cpu/h8/h83006.h" -#include "machine/eepromser.h" -#include "machine/nvram.h" -#include "machine/msm6242.h" -#include "sound/ymz280b.h" #include "video/k057714.h" + +#include "cpu/h8/h83006.h" +#include "cpu/powerpc/ppc.h" +#include "machine/eepromser.h" +#include "machine/msm6242.h" +#include "machine/nvram.h" +#include "sound/ymz280b.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" + +namespace { + class konendev_state : public driver_device { public: @@ -99,10 +104,6 @@ public: private: uint32_t mcu2_r(offs_t offset, uint32_t mem_mask = ~0); uint32_t ifu2_r(offs_t offset, uint32_t mem_mask = ~0); - uint32_t ctrl0_r(); - uint32_t ctrl1_r(); - uint32_t ctrl2_r(); - uint32_t ctrl3_r(); void eeprom_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); uint32_t sound_data_r(); void sound_data_w(uint32_t data); @@ -177,26 +178,6 @@ uint32_t konendev_state::ifu2_r(offs_t offset, uint32_t mem_mask) return r; } -uint32_t konendev_state::ctrl0_r() // doors, switches -{ - return ioport("IN1")->read(); -} - -uint32_t konendev_state::ctrl1_r() // hard meter access, hopper -{ - return ioport("IN2")->read(); -} - -uint32_t konendev_state::ctrl2_r() // main door optic -{ - return ioport("IN3")->read(); -} - -uint32_t konendev_state::ctrl3_r() // buttons -{ - return ioport("IN0")->read(); -} - void konendev_state::eeprom_w(offs_t offset, uint32_t data, uint32_t mem_mask) { if (ACCESSING_BITS_0_7) @@ -224,11 +205,11 @@ void konendev_state::konendev_map(address_map &map) map(0x780c0000, 0x780c0003).rw(FUNC(konendev_state::sound_data_r), FUNC(konendev_state::sound_data_w)); map(0x78100000, 0x78100003).w(FUNC(konendev_state::eeprom_w)); map(0x78800000, 0x78800003).r(FUNC(konendev_state::ifu2_r)); - map(0x78800004, 0x78800007).r(FUNC(konendev_state::ctrl0_r)); - map(0x78a00000, 0x78a00003).r(FUNC(konendev_state::ctrl1_r)); - map(0x78a00004, 0x78a00007).r(FUNC(konendev_state::ctrl2_r)); + map(0x78800004, 0x78800007).portr("IN1"); // doors, switches + map(0x78a00000, 0x78a00003).portr("IN2"); // hard meter access, hopper + map(0x78a00004, 0x78a00007).portr("IN3"); // main door optic map(0x78c00000, 0x78c003ff).ram().share("dpram"); - map(0x78e00000, 0x78e00003).r(FUNC(konendev_state::ctrl3_r)); + map(0x78e00000, 0x78e00003).portr("IN0"); // buttons map(0x79000000, 0x79000003).w(m_gcu, FUNC(k057714_device::fifo_w)); map(0x79800000, 0x798000ff).rw(m_gcu, FUNC(k057714_device::read), FUNC(k057714_device::write)); map(0x7a000000, 0x7a01ffff).ram().share("nvram0"); @@ -702,6 +683,9 @@ void konendev_state::init_enchlamp() rom[0] = 0x5782b930; // new checksum for program rom } +} // anonymous namespace + + // BIOS GAME( 200?, konendev, 0, konendev, konendev, konendev_state, init_enchlamp, ROT0, "Konami", "Konami Endeavour BIOS", MACHINE_NOT_WORKING|MACHINE_IS_BIOS_ROOT ) diff --git a/src/mame/drivers/mbc200.cpp b/src/mame/drivers/mbc200.cpp index f8413ef1e9d..673cef8aa92 100644 --- a/src/mame/drivers/mbc200.cpp +++ b/src/mame/drivers/mbc200.cpp @@ -44,6 +44,7 @@ TODO: ****************************************************************************/ #include "emu.h" + #include "cpu/z80/z80.h" #include "imagedev/floppy.h" #include "machine/i8251.h" @@ -53,11 +54,15 @@ TODO: #include "sound/beep.h" #include "sound/spkrdev.h" #include "video/mc6845.h" + #include "emupal.h" #include "screen.h" #include "softlist.h" #include "speaker.h" + +namespace { + class mbc200_state : public driver_device { public: @@ -79,6 +84,10 @@ public: void mbc200(machine_config &config); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + private: u8 p2_porta_r(); void p1_portc_w(u8 data); @@ -89,13 +98,11 @@ private: MC6845_UPDATE_ROW(update_row); required_device m_palette; - void main_io(address_map &map); void main_mem(address_map &map); - void sub_io(address_map &map); + void main_io(address_map &map); void sub_mem(address_map &map); + void sub_io(address_map &map); - virtual void machine_start() override; - virtual void machine_reset() override; u8 m_comm_latch; u8 m_term_data; required_device m_crtc; @@ -366,8 +373,10 @@ ROM_START( mbc200 ) ROM_LOAD( "m5l2764.bin", 0x0000, 0x2000, CRC(377300a2) SHA1(8563172f9e7f84330378a8d179f4138be5fda099)) ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS COMP( 1982, mbc200, 0, 0, mbc200, mbc200, mbc200_state, empty_init, "Sanyo", "MBC-200", MACHINE_SUPPORTS_SAVE ) - diff --git a/src/mame/drivers/mes.cpp b/src/mame/drivers/mes.cpp index de379ba2a96..76bec55abfb 100644 --- a/src/mame/drivers/mes.cpp +++ b/src/mame/drivers/mes.cpp @@ -9,15 +9,19 @@ Schleicher MES ****************************************************************************/ #include "emu.h" + #include "cpu/z80/z80.h" #include "machine/z80ctc.h" #include "machine/z80pio.h" #include "machine/z80sio.h" #include "machine/keyboard.h" + #include "emupal.h" #include "screen.h" +namespace { + class mes_state : public driver_device { public: @@ -30,9 +34,11 @@ public: void mes(machine_config &config); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + private: - void machine_reset() override; - void machine_start() override; u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void kbd_put(u8 data); u8 port00_r(); @@ -99,7 +105,7 @@ void mes_state::machine_reset() Also the screen dimensions are a guess. */ uint32_t mes_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - u16 sy=0,ma=0; + u16 sy = 0, ma = 0; for (u8 y = 0; y < 25; y++) { @@ -112,7 +118,7 @@ uint32_t mes_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c u8 gfx = 0; if (ra < 9) { - u8 chr = m_p_videoram[x]; + const u8 chr = m_p_videoram[x]; gfx = m_p_chargen[(chr<<4) | ra ]; } @@ -127,7 +133,7 @@ uint32_t mes_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c *p++ = BIT(gfx, 0); } } - ma+=80; + ma += 80; } return 0; } @@ -177,6 +183,9 @@ ROM_START( mes ) ROM_LOAD( "c10_char.bin", 0x0000, 0x2000, BAD_DUMP CRC(cb530b6f) SHA1(95590bbb433db9c4317f535723b29516b9b9fcbf)) ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/mmd1.cpp b/src/mame/drivers/mmd1.cpp index d09e61806e3..84b2a07eaff 100644 --- a/src/mame/drivers/mmd1.cpp +++ b/src/mame/drivers/mmd1.cpp @@ -73,15 +73,20 @@ ToDo: ****************************************************************************/ #include "emu.h" + #include "cpu/i8085/i8085.h" #include "imagedev/cassette.h" #include "machine/ay31015.h" #include "machine/clock.h" #include "machine/timer.h" + #include "speaker.h" + #include "mmd1.lh" +namespace { + class mmd1_state : public driver_device { public: @@ -90,6 +95,7 @@ public: , m_maincpu(*this, "maincpu") , m_cass(*this, "cassette") , m_uart(*this, "uart") + , m_lines(*this, "LINE%u", 1U) , m_digits(*this, "digit%u", 0U) , m_p(*this, "p%u_%u", 0U, 0U) { } @@ -98,9 +104,11 @@ public: DECLARE_INPUT_CHANGED_MEMBER(reset_button); -private: +protected: virtual void machine_start() override; virtual void machine_reset() override; + +private: void round_leds_w(offs_t offset, u8 data); u8 keyboard_r(); u8 port13_r(); @@ -119,6 +127,7 @@ private: required_device m_maincpu; required_device m_cass; required_device m_uart; + required_ioport_array<2> m_lines; output_finder<9> m_digits; output_finder<3, 8> m_p; }; @@ -134,21 +143,20 @@ void mmd1_state::round_leds_w(offs_t offset, u8 data) // keyboard has a keydown and a keyup code. Keyup = last keydown + bit 7 set u8 mmd1_state::keyboard_r() { - u8 line1 = ioport("LINE1")->read(); - u8 line2 = ioport("LINE2")->read(); - u8 i, data = 0xff; + const u8 line1 = m_lines[0]->read(); + const u8 line2 = m_lines[1]->read(); + u8 data = 0xff; - - for (i = 0; i < 8; i++) + for (unsigned i = 0; i < 8; i++) { if (!BIT(line1, i)) data = i; } - for (i = 0; i < 8; i++) + for (unsigned i = 0; i < 8; i++) { if (!BIT(line2, i)) - data = i+8; + data = i + 8; } if (data < 0x10) @@ -336,6 +344,9 @@ ROM_START( mmd1 ) ROM_LOAD( "prom1.ic16", 0x0100, 0x0100, BAD_DUMP CRC(d23a6ac3) SHA1(469d981b635058dd23e843a3efc555316f87ece4) ) // Typed in by hand from the manual ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/nakajies.cpp b/src/mame/drivers/nakajies.cpp index 8551fc700c6..15fd8a41478 100644 --- a/src/mame/drivers/nakajies.cpp +++ b/src/mame/drivers/nakajies.cpp @@ -270,17 +270,20 @@ disabled). Perhaps power on/off related?? ******************************************************************************/ - #include "emu.h" + #include "cpu/nec/nec.h" #include "machine/rp5c01.h" #include "machine/timer.h" #include "sound/spkrdev.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + #define LOG 0 @@ -315,17 +318,9 @@ private: uint8_t unk_a0_r(); void lcd_memory_start_w(uint8_t data); uint8_t keyboard_r(); - void banking_w(offs_t offset, uint8_t data) ; + void banking_w(offs_t offset, uint8_t data); void update_banks(); - void bank_w(uint8_t banknr, offs_t offset, uint8_t data); - void bank0_w(offs_t offset, uint8_t data) ; - void bank1_w(offs_t offset, uint8_t data) ; - void bank2_w(offs_t offset, uint8_t data) ; - void bank3_w(offs_t offset, uint8_t data) ; - void bank4_w(offs_t offset, uint8_t data) ; - void bank5_w(offs_t offset, uint8_t data) ; - void bank6_w(offs_t offset, uint8_t data) ; - void bank7_w(offs_t offset, uint8_t data) ; + template void bank_w(offs_t offset, uint8_t data); void nakajies_palette(palette_device &palette) const; TIMER_DEVICE_CALLBACK_MEMBER(kb_timer); @@ -376,44 +371,36 @@ void nakajies_state::update_banks() m_bank_base[i] = &m_rom_base[(((m_bank[i] & 0x0f) ^ 0xf) << 17) % m_rom_size]; } } - membank( "bank0" )->set_base( m_bank_base[0] ); - membank( "bank1" )->set_base( m_bank_base[1] ); - membank( "bank2" )->set_base( m_bank_base[2] ); - membank( "bank3" )->set_base( m_bank_base[3] ); - membank( "bank4" )->set_base( m_bank_base[4] ); - membank( "bank5" )->set_base( m_bank_base[5] ); - membank( "bank6" )->set_base( m_bank_base[6] ); - membank( "bank7" )->set_base( m_bank_base[7] ); + membank( "bank0" )->set_base(m_bank_base[0]); + membank( "bank1" )->set_base(m_bank_base[1]); + membank( "bank2" )->set_base(m_bank_base[2]); + membank( "bank3" )->set_base(m_bank_base[3]); + membank( "bank4" )->set_base(m_bank_base[4]); + membank( "bank5" )->set_base(m_bank_base[5]); + membank( "bank6" )->set_base(m_bank_base[6]); + membank( "bank7" )->set_base(m_bank_base[7]); } -void nakajies_state::bank_w( uint8_t banknr, offs_t offset, uint8_t data ) +template +void nakajies_state::bank_w(offs_t offset, uint8_t data) { - if ( m_bank[banknr] & 0x10 ) + if (m_bank[N] & 0x10) { - m_bank_base[banknr][offset] = data; + m_bank_base[N][offset] = data; } } -void nakajies_state::bank0_w(offs_t offset, uint8_t data) { bank_w( 0, offset, data ); } -void nakajies_state::bank1_w(offs_t offset, uint8_t data) { bank_w( 1, offset, data ); } -void nakajies_state::bank2_w(offs_t offset, uint8_t data) { bank_w( 2, offset, data ); } -void nakajies_state::bank3_w(offs_t offset, uint8_t data) { bank_w( 3, offset, data ); } -void nakajies_state::bank4_w(offs_t offset, uint8_t data) { bank_w( 4, offset, data ); } -void nakajies_state::bank5_w(offs_t offset, uint8_t data) { bank_w( 5, offset, data ); } -void nakajies_state::bank6_w(offs_t offset, uint8_t data) { bank_w( 6, offset, data ); } -void nakajies_state::bank7_w(offs_t offset, uint8_t data) { bank_w( 7, offset, data ); } - void nakajies_state::nakajies_map(address_map &map) { - map(0x00000, 0x1ffff).bankr("bank0").w(FUNC(nakajies_state::bank0_w)); - map(0x20000, 0x3ffff).bankr("bank1").w(FUNC(nakajies_state::bank1_w)); - map(0x40000, 0x5ffff).bankr("bank2").w(FUNC(nakajies_state::bank2_w)); - map(0x60000, 0x7ffff).bankr("bank3").w(FUNC(nakajies_state::bank3_w)); - map(0x80000, 0x9ffff).bankr("bank4").w(FUNC(nakajies_state::bank4_w)); - map(0xa0000, 0xbffff).bankr("bank5").w(FUNC(nakajies_state::bank5_w)); - map(0xc0000, 0xdffff).bankr("bank6").w(FUNC(nakajies_state::bank6_w)); - map(0xe0000, 0xfffff).bankr("bank7").w(FUNC(nakajies_state::bank7_w)); + map(0x00000, 0x1ffff).bankr("bank0").w(FUNC(nakajies_state::bank_w<0>)); + map(0x20000, 0x3ffff).bankr("bank1").w(FUNC(nakajies_state::bank_w<1>)); + map(0x40000, 0x5ffff).bankr("bank2").w(FUNC(nakajies_state::bank_w<2>)); + map(0x60000, 0x7ffff).bankr("bank3").w(FUNC(nakajies_state::bank_w<3>)); + map(0x80000, 0x9ffff).bankr("bank4").w(FUNC(nakajies_state::bank_w<4>)); + map(0xa0000, 0xbffff).bankr("bank5").w(FUNC(nakajies_state::bank_w<5>)); + map(0xc0000, 0xdffff).bankr("bank6").w(FUNC(nakajies_state::bank_w<6>)); + map(0xe0000, 0xfffff).bankr("bank7").w(FUNC(nakajies_state::bank_w<7>)); } @@ -843,6 +830,8 @@ ROM_START( es210_es ) ROM_LOAD("nakajima_es.ic303", 0x00000, 0x80000, CRC(214d73ce) SHA1(ce9967c5b2d122ebebe9401278d8ea374e8fb289)) ROM_END +} // anonymous namespace + // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS COMP( 199?, wales210, 0, 0, nakajies210, nakajies, nakajies_state, empty_init, "Walther", "ES-210", MACHINE_NOT_WORKING | MACHINE_NO_SOUND ) // German, 128KB RAM diff --git a/src/mame/drivers/pegasus.cpp b/src/mame/drivers/pegasus.cpp index a8bd6934e77..e454f1afc03 100644 --- a/src/mame/drivers/pegasus.cpp +++ b/src/mame/drivers/pegasus.cpp @@ -38,18 +38,22 @@ ****************************************************************************/ #include "emu.h" + #include "bus/generic/carts.h" #include "bus/generic/slot.h" #include "cpu/m6809/m6809.h" #include "imagedev/cassette.h" #include "machine/6821pia.h" #include "machine/timer.h" + #include "emupal.h" #include "screen.h" #include "softlist.h" #include "speaker.h" +namespace { + class pegasus_state : public driver_device { public: @@ -74,6 +78,10 @@ public: void init_pegasus(); +protected: + virtual void machine_reset() override; + virtual void machine_start() override; + private: u8 pegasus_keyboard_r(); u8 pegasus_protection_r(); @@ -100,8 +108,6 @@ private: u8 m_kbd_row; bool m_kbd_irq; u8 m_control_bits; - virtual void machine_reset() override; - virtual void machine_start() override; std::unique_ptr m_pcg; void pegasus_decrypt_rom(u8 *ROM); required_device m_maincpu; @@ -130,13 +136,13 @@ WRITE_LINE_MEMBER( pegasus_state::pegasus_firq_clr ) u8 pegasus_state::pegasus_keyboard_r() { - u8 i,data = 0xff; - for (i = 0; i < 8; i++) + u8 data = 0xff; + for (unsigned i = 0; i < 8; i++) if (!BIT(m_kbd_row, i)) data &= m_io_keyboard[i]->read(); m_kbd_irq = (data == 0xff) ? 1 : 0; if (BIT(m_control_bits, 3)) - data<<=4; + data <<= 4; return data; } @@ -314,16 +320,16 @@ static const u8 mcm6571a_shift[] = u32 pegasus_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - u16 sy=0,ma=0; - bool pcg_mode = BIT(m_control_bits, 1); + u16 sy=0, ma=0; + const bool pcg_mode = BIT(m_control_bits, 1); - for(u8 y = 0; y < 16; y++ ) + for (u8 y = 0; y < 16; y++) { - for(u8 ra = 0; ra < 16; ra++ ) + for (u8 ra = 0; ra < 16; ra++) { u16 *p = &bitmap.pix(sy++); - for(u16 x = ma; x < ma + 32; x++ ) + for (u16 x = ma; x < ma + 32; x++) { u8 inv = 0xff; u8 chr = m_vram[x]; @@ -373,15 +379,15 @@ u32 pegasus_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, co /* F4 Character Displayer */ static const gfx_layout pegasus_charlayout = { - 8, 16, /* text = 7 x 9, pcg = 8 x 16 */ - 128, /* 128 characters */ - 1, /* 1 bits per pixel */ - { 0 }, /* no bitplanes */ - /* x offsets */ + 8, 16, // text = 7 x 9, pcg = 8 x 16 + 128, // 128 characters + 1, // 1 bits per pixel + { 0 }, // no bitplanes + // x offsets { 0, 1, 2, 3, 4, 5, 6, 7 }, - /* y offsets */ + // y offsets { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, - 8*16 /* every char takes 16 bytes */ + 8*16 // every char takes 16 bytes }; static GFXDECODE_START( gfx_pegasus ) @@ -396,10 +402,6 @@ GFXDECODE_END void pegasus_state::pegasus_decrypt_rom(u8 *ROM) { bool doit = false; - u8 b; - u16 j; - std::vector temp_copy; - temp_copy.resize(0x1000); if (ROM[0] == 0x02) doit = true; if (ROM[0] == 0x1e && ROM[1] == 0xfa && ROM[2] == 0x60 && ROM[3] == 0x71) doit = true; // xbasic 2nd rom @@ -409,11 +411,12 @@ void pegasus_state::pegasus_decrypt_rom(u8 *ROM) if (doit) { + std::vector temp_copy; + temp_copy.resize(0x1000); for (int i = 0; i < 0x1000; i++) { - b = ROM[i]; - j = bitswap<16>(i, 15, 14, 13, 12, 11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 7); - b = bitswap<8>(b, 3, 2, 1, 0, 7, 6, 5, 4); + const u16 j = bitswap<16>(i, 15, 14, 13, 12, 11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 7); + const u8 b = bitswap<8>(ROM[i], 3, 2, 1, 0, 7, 6, 5, 4); temp_copy[j & 0xfff] = b; } memcpy(ROM, &temp_copy[0], 0x1000); @@ -575,6 +578,9 @@ ROM_END #define rom_pegasusm rom_pegasus +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/taxidriv.cpp b/src/mame/drivers/taxidriv.cpp index 2a0e6bd0d76..d17a623a01a 100644 --- a/src/mame/drivers/taxidriv.cpp +++ b/src/mame/drivers/taxidriv.cpp @@ -12,15 +12,78 @@ OTHER: 5 * M5L8255AP ***************************************************************************/ #include "emu.h" -#include "includes/taxidriv.h" #include "cpu/z80/z80.h" #include "machine/i8255.h" #include "sound/ay8910.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + +class taxidriv_state : public driver_device +{ +public: + taxidriv_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_vram(*this, "vram%u", 0U), + m_scroll(*this, "scroll"), + m_servcoin(*this, "SERVCOIN") + { } + + void taxidriv(machine_config &config); + +protected: + virtual void machine_start() override; + +private: + required_device m_maincpu; + required_device m_gfxdecode; + required_device m_palette; + + required_shared_ptr_array m_vram; + required_shared_ptr m_scroll; + + required_ioport m_servcoin; + + int m_s1; + int m_s2; + int m_s3; + int m_s4; + int m_latchA; + int m_latchB; + int m_bghide; + int m_spritectrl[9]; + + uint8_t p0a_r(); + uint8_t p0c_r(); + void p0b_w(uint8_t data); + void p0c_w(uint8_t data); + uint8_t p1b_r(); + uint8_t p1c_r(); + void p1a_w(uint8_t data); + void p1c_w(uint8_t data); + uint8_t p8910_0a_r(); + uint8_t p8910_1a_r(); + void p8910_0b_w(uint8_t data); + template void spritectrl_w(uint8_t data); + + void taxidriv_palette(palette_device &palette) const; + + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void cpu2_map(address_map &map); + void cpu3_map(address_map &map); + void cpu3_port_map(address_map &map); + void main_map(address_map &map); +}; + + void taxidriv_state::machine_start() { save_item(NAME(m_s1)); @@ -33,16 +96,6 @@ void taxidriv_state::machine_start() save_item(NAME(m_spritectrl)); } -void taxidriv_state::p2a_w(uint8_t data) { spritectrl_w(0,data); } -void taxidriv_state::p2b_w(uint8_t data) { spritectrl_w(1,data); } -void taxidriv_state::p2c_w(uint8_t data) { spritectrl_w(2,data); } -void taxidriv_state::p3a_w(uint8_t data) { spritectrl_w(3,data); } -void taxidriv_state::p3b_w(uint8_t data) { spritectrl_w(4,data); } -void taxidriv_state::p3c_w(uint8_t data) { spritectrl_w(5,data); } -void taxidriv_state::p4a_w(uint8_t data) { spritectrl_w(6,data); } -void taxidriv_state::p4b_w(uint8_t data) { spritectrl_w(7,data); } -void taxidriv_state::p4c_w(uint8_t data) { spritectrl_w(8,data); } - uint8_t taxidriv_state::p0a_r() { @@ -51,7 +104,7 @@ uint8_t taxidriv_state::p0a_r() uint8_t taxidriv_state::p0c_r() { - return (m_s1 << 7); + return m_s1 << 7; } void taxidriv_state::p0b_w(uint8_t data) @@ -79,7 +132,7 @@ uint8_t taxidriv_state::p1b_r() uint8_t taxidriv_state::p1c_r() { - return (m_s2 << 7) | (m_s4 << 6) | ((ioport("SERVCOIN")->read() & 1) << 4); + return (m_s2 << 7) | (m_s4 << 6) | ((m_servcoin->read() & 1) << 4); } void taxidriv_state::p1a_w(uint8_t data) @@ -110,27 +163,159 @@ void taxidriv_state::p8910_0b_w(uint8_t data) m_s4 = data & 1; } + +template +void taxidriv_state::spritectrl_w(uint8_t data) +{ + m_spritectrl[Offset] = data; +} + + +uint32_t taxidriv_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + if (m_bghide) + { + bitmap.fill(0, cliprect); + + + /* kludge to fix scroll after death */ + m_scroll[0] = m_scroll[1] = m_scroll[2] = m_scroll[3] = 0; + m_spritectrl[2] = m_spritectrl[5] = m_spritectrl[8] = 0; + } + else + { + for (int offs = 0;offs < 0x400;offs++) + { + int sx = offs % 32; + int sy = offs / 32; + + m_gfxdecode->gfx(3)->opaque(bitmap,cliprect, + m_vram[3][offs], + 0, + 0,0, + (sx*8-m_scroll[0])&0xff,(sy*8-m_scroll[1])&0xff); + } + + for (int offs = 0;offs < 0x400;offs++) + { + int sx = offs % 32; + int sy = offs / 32; + + m_gfxdecode->gfx(2)->transpen(bitmap,cliprect, + m_vram[2][offs]+256*m_vram[2][offs+0x400], + 0, + 0,0, + (sx*8-m_scroll[2])&0xff,(sy*8-m_scroll[3])&0xff,0); + } + + if (m_spritectrl[2] & 4) + { + for (int offs = 0;offs < 0x1000;offs++) + { + int sx = ((offs/2) % 64-m_spritectrl[0]-256*(m_spritectrl[2]&1))&0x1ff; + int sy = ((offs/2) / 64-m_spritectrl[1]-128*(m_spritectrl[2]&2))&0x1ff; + + int color = (m_vram[5][offs/4]>>(2*(offs&3)))&0x03; + if (color) + { + if (sx > 0 && sx < 256 && sy > 0 && sy < 256) + bitmap.pix(sy, sx) = color; + } + } + } + + if (m_spritectrl[5] & 4) + { + for (int offs = 0;offs < 0x1000;offs++) + { + int sx = ((offs/2) % 64-m_spritectrl[3]-256*(m_spritectrl[5]&1))&0x1ff; + int sy = ((offs/2) / 64-m_spritectrl[4]-128*(m_spritectrl[5]&2))&0x1ff; + + int color = (m_vram[6][offs/4]>>(2*(offs&3)))&0x03; + if (color) + { + if (sx > 0 && sx < 256 && sy > 0 && sy < 256) + bitmap.pix(sy, sx) = color; + } + } + } + + if (m_spritectrl[8] & 4) + { + for (int offs = 0;offs < 0x1000;offs++) + { + int sx = ((offs/2) % 64-m_spritectrl[6]-256*(m_spritectrl[8]&1))&0x1ff; + int sy = ((offs/2) / 64-m_spritectrl[7]-128*(m_spritectrl[8]&2))&0x1ff; + + int color = (m_vram[7][offs/4]>>(2*(offs&3)))&0x03; + if (color) + { + if (sx > 0 && sx < 256 && sy > 0 && sy < 256) + bitmap.pix(sy, sx) = color; + } + } + } + + for (int offs = 0;offs < 0x400;offs++) + { + int sx = offs % 32; + int sy = offs / 32; + + m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, + m_vram[1][offs], + 0, + 0,0, + sx*8,sy*8,0); + } + + for (int offs = 0;offs < 0x2000;offs++) + { + int sx = (offs/2) % 64; + int sy = (offs/2) / 64; + + int color = (m_vram[4][offs/4]>>(2*(offs&3)))&0x03; + if (color) + { + bitmap.pix(sy, sx) = 2 * color; + } + } + } + + for (int offs = 0;offs < 0x400;offs++) + { + int sx = offs % 32; + int sy = offs / 32; + + m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, + m_vram[0][offs], + 0, + 0,0, + sx*8,sy*8,0); + } + return 0; +} + void taxidriv_state::main_map(address_map &map) { map(0x0000, 0x7fff).rom(); - map(0x8000, 0x8fff).ram(); /* ??? */ - map(0x9000, 0x9fff).ram(); /* ??? */ - map(0xa000, 0xafff).ram(); /* ??? */ - map(0xb000, 0xbfff).ram(); /* ??? */ - map(0xc000, 0xc7ff).ram().share("vram4"); /* radar bitmap */ - map(0xc800, 0xcfff).writeonly().share("vram5"); /* "sprite1" bitmap */ - map(0xd000, 0xd7ff).writeonly().share("vram6"); /* "sprite2" bitmap */ - map(0xd800, 0xdfff).ram().share("vram7"); /* "sprite3" bitmap */ - map(0xe000, 0xe3ff).ram().share("vram1"); /* car tilemap */ - map(0xe400, 0xebff).ram().share("vram2"); /* bg1 tilemap */ - map(0xec00, 0xefff).ram().share("vram0"); /* fg tilemap */ - map(0xf000, 0xf3ff).ram().share("vram3"); /* bg2 tilemap */ + map(0x8000, 0x8fff).ram(); // ??? + map(0x9000, 0x9fff).ram(); // ??? + map(0xa000, 0xafff).ram(); // ??? + map(0xb000, 0xbfff).ram(); // ??? + map(0xc000, 0xc7ff).ram().share(m_vram[4]); // radar bitmap + map(0xc800, 0xcfff).writeonly().share(m_vram[5]); // "sprite1" bitmap + map(0xd000, 0xd7ff).writeonly().share(m_vram[6]); // "sprite2" bitmap + map(0xd800, 0xdfff).ram().share(m_vram[7]); // "sprite3" bitmap + map(0xe000, 0xe3ff).ram().share(m_vram[1]); // car tilemap + map(0xe400, 0xebff).ram().share(m_vram[2]); // bg1 tilemap + map(0xec00, 0xefff).ram().share(m_vram[0]); // fg tilemap + map(0xf000, 0xf3ff).ram().share(m_vram[3]); // bg2 tilemap map(0xf400, 0xf403).rw("ppi8255_0", FUNC(i8255_device::read), FUNC(i8255_device::write)); - map(0xf480, 0xf483).rw("ppi8255_2", FUNC(i8255_device::read), FUNC(i8255_device::write)); /* "sprite1" placement */ - map(0xf500, 0xf503).rw("ppi8255_3", FUNC(i8255_device::read), FUNC(i8255_device::write)); /* "sprite2" placement */ - map(0xf580, 0xf583).rw("ppi8255_4", FUNC(i8255_device::read), FUNC(i8255_device::write)); /* "sprite3" placement */ - //map(0xf780, 0xf781).writeonly(); /* more scroll registers? */ - map(0xf782, 0xf787).writeonly().share("scroll"); /* bg scroll (three copies always identical) */ + map(0xf480, 0xf483).rw("ppi8255_2", FUNC(i8255_device::read), FUNC(i8255_device::write)); // "sprite1" placement + map(0xf500, 0xf503).rw("ppi8255_3", FUNC(i8255_device::read), FUNC(i8255_device::write)); // "sprite2" placement + map(0xf580, 0xf583).rw("ppi8255_4", FUNC(i8255_device::read), FUNC(i8255_device::write)); // "sprite3" placement + //map(0xf780, 0xf781).writeonly(); // more scroll registers? + map(0xf782, 0xf787).writeonly().share("scroll"); // bg scroll (three copies always identical) map(0xf800, 0xffff).ram(); } @@ -363,19 +548,19 @@ void taxidriv_state::taxidriv(machine_config &config) ppi1.out_pc_callback().set(FUNC(taxidriv_state::p1c_w)); i8255_device &ppi2(I8255A(config, "ppi8255_2")); - ppi2.out_pa_callback().set(FUNC(taxidriv_state::p2a_w)); - ppi2.out_pb_callback().set(FUNC(taxidriv_state::p2b_w)); - ppi2.out_pc_callback().set(FUNC(taxidriv_state::p2c_w)); + ppi2.out_pa_callback().set(FUNC(taxidriv_state::spritectrl_w<0>)); + ppi2.out_pb_callback().set(FUNC(taxidriv_state::spritectrl_w<1>)); + ppi2.out_pc_callback().set(FUNC(taxidriv_state::spritectrl_w<2>)); i8255_device &ppi3(I8255A(config, "ppi8255_3")); - ppi3.out_pa_callback().set(FUNC(taxidriv_state::p3a_w)); - ppi3.out_pb_callback().set(FUNC(taxidriv_state::p3b_w)); - ppi3.out_pc_callback().set(FUNC(taxidriv_state::p3c_w)); + ppi3.out_pa_callback().set(FUNC(taxidriv_state::spritectrl_w<3>)); + ppi3.out_pb_callback().set(FUNC(taxidriv_state::spritectrl_w<4>)); + ppi3.out_pc_callback().set(FUNC(taxidriv_state::spritectrl_w<5>)); i8255_device &ppi4(I8255A(config, "ppi8255_4")); - ppi4.out_pa_callback().set(FUNC(taxidriv_state::p4a_w)); - ppi4.out_pb_callback().set(FUNC(taxidriv_state::p4b_w)); - ppi4.out_pc_callback().set(FUNC(taxidriv_state::p4c_w)); + ppi4.out_pa_callback().set(FUNC(taxidriv_state::spritectrl_w<6>)); + ppi4.out_pb_callback().set(FUNC(taxidriv_state::spritectrl_w<7>)); + ppi4.out_pc_callback().set(FUNC(taxidriv_state::spritectrl_w<8>)); /* video hardware */ screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); @@ -447,5 +632,7 @@ ROM_START( taxidriv ) ROM_LOAD( "tbp18s030.ic2", 0x0000, 0x020, CRC(c366a9c5) SHA1(d38581e5c425cab4a4f216d99651e86d8034a7d2) ) // color prom located at edge of pcb ROM_END +} // anonymous namespace + GAME( 1984, taxidriv, 0, taxidriv, taxidriv, taxidriv_state, empty_init, ROT90, "Graphic Techno", "Taxi Driver", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/ultim809.cpp b/src/mame/drivers/ultim809.cpp index 8f7e2220cc8..29b69bbb1ba 100644 --- a/src/mame/drivers/ultim809.cpp +++ b/src/mame/drivers/ultim809.cpp @@ -36,14 +36,19 @@ Status: ****************************************************************************************************/ #include "emu.h" -#include "cpu/m6809/m6809.h" -#include "video/tms9928a.h" -#include "machine/6522via.h" -#include "sound/ay8910.h" -#include "machine/ins8250.h" + #include "bus/rs232/rs232.h" +#include "cpu/m6809/m6809.h" +#include "machine/6522via.h" +#include "machine/ins8250.h" +#include "sound/ay8910.h" +#include "video/tms9928a.h" + #include "speaker.h" + +namespace { + class ultim809_state : public driver_device { public: @@ -61,9 +66,11 @@ public: DECLARE_INPUT_CHANGED_MEMBER(nmi_button); +protected: + virtual void machine_start() override; + private: void mem_map(address_map &map); - virtual void machine_start() override; std::unique_ptr m_ram; required_device m_maincpu; required_device m_via; @@ -168,6 +175,9 @@ ROM_START( ultim809 ) ROM_LOAD( "ultim809.u9", 0x0000, 0x2000, CRC(b827aaf1) SHA1(64d9e94542d8ff13f64a4d787508eef7b64d4946) ) ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/v6809.cpp b/src/mame/drivers/v6809.cpp index 77ad42d0de4..d94b32b958a 100644 --- a/src/mame/drivers/v6809.cpp +++ b/src/mame/drivers/v6809.cpp @@ -46,6 +46,7 @@ ToDo: *******************************************************************************************/ #include "emu.h" + #include "cpu/m6809/m6809.h" #include "imagedev/floppy.h" #include "machine/6821pia.h" @@ -57,11 +58,14 @@ ToDo: #include "machine/wd_fdc.h" #include "sound/spkrdev.h" #include "video/mc6845.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + class v6809_state : public driver_device { public: @@ -81,10 +85,11 @@ public: void v6809(machine_config &config); -private: - virtual void machine_reset() override; +protected: virtual void machine_start() override; + virtual void machine_reset() override; +private: DECLARE_WRITE_LINE_MEMBER(speaker_en_w); DECLARE_WRITE_LINE_MEMBER(speaker_w); u8 pb_r(); @@ -368,6 +373,9 @@ ROM_START( v6809 ) ROM_RELOAD(0x0800, 0x0800) ROM_END +} // anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/includes/hng64.h b/src/mame/includes/hng64.h index 13ed54c51a1..6d77879759b 100644 --- a/src/mame/includes/hng64.h +++ b/src/mame/includes/hng64.h @@ -5,38 +5,19 @@ #pragma once -#include "machine/msm6242.h" -#include "machine/timer.h" #include "cpu/mips/mips3.h" #include "cpu/nec/v5x.h" -#include "sound/l7a1045_l6028_dsp_a.h" -#include "video/poly.h" #include "cpu/tlcs870/tlcs870.h" #include "machine/mb8421.h" +#include "machine/msm6242.h" +#include "machine/timer.h" +#include "sound/l7a1045_l6028_dsp_a.h" +#include "video/poly.h" + #include "emupal.h" #include "screen.h" #include "tilemap.h" -enum hng64trans_t -{ - HNG64_TILEMAP_NORMAL = 1, - HNG64_TILEMAP_ADDITIVE, - HNG64_TILEMAP_ALPHA -}; - -struct blit_parameters -{ - bitmap_rgb32 * bitmap; - rectangle cliprect; - uint32_t tilemap_priority_code; - uint8_t mask; - uint8_t value; - uint8_t alpha; - hng64trans_t drawformat; -}; - -#define HNG64_MASTER_CLOCK 50000000 - ///////////////// /// 3d Engine /// @@ -141,14 +122,7 @@ class hng64_lamps_device : public device_t public: hng64_lamps_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - auto lamps0_out_cb() { return m_lamps_out_cb[0].bind(); } - auto lamps1_out_cb() { return m_lamps_out_cb[1].bind(); } - auto lamps2_out_cb() { return m_lamps_out_cb[2].bind(); } - auto lamps3_out_cb() { return m_lamps_out_cb[3].bind(); } - auto lamps4_out_cb() { return m_lamps_out_cb[4].bind(); } - auto lamps5_out_cb() { return m_lamps_out_cb[5].bind(); } - auto lamps6_out_cb() { return m_lamps_out_cb[6].bind(); } - auto lamps7_out_cb() { return m_lamps_out_cb[7].bind(); } + template auto lamps_out_cb() { return m_lamps_out_cb[N].bind(); } void lamps_w(offs_t offset, uint8_t data) { m_lamps_out_cb[offset](data); } @@ -191,7 +165,6 @@ public: m_idt7133_dpram(*this, "com_ram"), m_gfxdecode(*this, "gfxdecode"), m_in(*this, "IN%u", 0U), - m_an_in(*this, "AN%u", 0U), m_samsho64_3d_hack(0), m_roadedge_3d_hack(0) { } @@ -214,17 +187,36 @@ public: required_device m_palette; private: + static constexpr int HNG64_MASTER_CLOCK = 50'000'000; + /* TODO: NOT measured! */ - const int PIXEL_CLOCK = (HNG64_MASTER_CLOCK*2)/4; // x 2 is due to the interlaced screen ... + static constexpr int PIXEL_CLOCK = (HNG64_MASTER_CLOCK*2)/4; // x 2 is due to the interlaced screen ... - const int HTOTAL = 0x200+0x100; - const int HBEND = 0; - const int HBSTART = 0x200; + static constexpr int HTOTAL = 0x200+0x100; + static constexpr int HBEND = 0; + static constexpr int HBSTART = 0x200; - const int VTOTAL = 264*2; - const int VBEND = 0; - const int VBSTART = 224*2; + static constexpr int VTOTAL = 264*2; + static constexpr int VBEND = 0; + static constexpr int VBSTART = 224*2; + enum hng64trans_t + { + HNG64_TILEMAP_NORMAL = 1, + HNG64_TILEMAP_ADDITIVE, + HNG64_TILEMAP_ALPHA + }; + + struct blit_parameters + { + bitmap_rgb32 * bitmap; + rectangle cliprect; + uint32_t tilemap_priority_code; + uint8_t mask; + uint8_t value; + uint8_t alpha; + hng64trans_t drawformat; + }; required_device m_maincpu; required_device m_audiocpu; @@ -257,17 +249,8 @@ private: required_device m_gfxdecode; required_ioport_array<8> m_in; - required_ioport_array<8> m_an_in; - - void hng64_default_lamps0_w(uint8_t data) { logerror("lamps0 %02x\n", data); } - void hng64_default_lamps1_w(uint8_t data) { logerror("lamps1 %02x\n", data); } - void hng64_default_lamps2_w(uint8_t data) { logerror("lamps2 %02x\n", data); } - void hng64_default_lamps3_w(uint8_t data) { logerror("lamps3 %02x\n", data); } - void hng64_default_lamps4_w(uint8_t data) { logerror("lamps4 %02x\n", data); } - void hng64_default_lamps5_w(uint8_t data) { logerror("lamps5 %02x\n", data); } - void hng64_default_lamps6_w(uint8_t data) { logerror("lamps6 %02x\n", data); } - void hng64_default_lamps7_w(uint8_t data) { logerror("lamps7 %02x\n", data); } + template void hng64_default_lamps_w(uint8_t data) { logerror("lamps%u %02x\n", N, data); } void hng64_drive_lamps7_w(uint8_t data); void hng64_drive_lamps6_w(uint8_t data); @@ -405,16 +388,6 @@ private: // unknown access void ioport4_w(uint8_t data); - // analog input access - uint8_t anport0_r(); - uint8_t anport1_r(); - uint8_t anport2_r(); - uint8_t anport3_r(); - uint8_t anport4_r(); - uint8_t anport5_r(); - uint8_t anport6_r(); - uint8_t anport7_r(); - DECLARE_WRITE_LINE_MEMBER( sio0_w ); uint8_t m_port7; @@ -470,6 +443,7 @@ private: uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, int wraparound, uint32_t flags, uint8_t priority, uint8_t priority_mask, hng64trans_t drawformat); + static void hng64_configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask, hng64trans_t drawformat); diff --git a/src/mame/includes/taxidriv.h b/src/mame/includes/taxidriv.h deleted file mode 100644 index 9c7a2834396..00000000000 --- a/src/mame/includes/taxidriv.h +++ /dev/null @@ -1,89 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -#ifndef MAME_INCLUDES_TAXIDRIV_H -#define MAME_INCLUDES_TAXIDRIV_H - -#pragma once - -#include "emupal.h" - -class taxidriv_state : public driver_device -{ -public: - taxidriv_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_vram0(*this, "vram0"), - m_vram1(*this, "vram1"), - m_vram2(*this, "vram2"), - m_vram3(*this, "vram3"), - m_vram4(*this, "vram4"), - m_vram5(*this, "vram5"), - m_vram6(*this, "vram6"), - m_vram7(*this, "vram7"), - m_scroll(*this, "scroll") - { } - - void taxidriv(machine_config &config); - -protected: - virtual void machine_start() override; - -private: - required_device m_maincpu; - required_device m_gfxdecode; - required_device m_palette; - - required_shared_ptr m_vram0; - required_shared_ptr m_vram1; - required_shared_ptr m_vram2; - required_shared_ptr m_vram3; - required_shared_ptr m_vram4; - required_shared_ptr m_vram5; - required_shared_ptr m_vram6; - required_shared_ptr m_vram7; - required_shared_ptr m_scroll; - - int m_s1; - int m_s2; - int m_s3; - int m_s4; - int m_latchA; - int m_latchB; - int m_bghide; - int m_spritectrl[9]; - - void p2a_w(uint8_t data); - void p2b_w(uint8_t data); - void p2c_w(uint8_t data); - void p3a_w(uint8_t data); - void p3b_w(uint8_t data); - void p3c_w(uint8_t data); - void p4a_w(uint8_t data); - void p4b_w(uint8_t data); - void p4c_w(uint8_t data); - uint8_t p0a_r(); - uint8_t p0c_r(); - void p0b_w(uint8_t data); - void p0c_w(uint8_t data); - uint8_t p1b_r(); - uint8_t p1c_r(); - void p1a_w(uint8_t data); - void p1c_w(uint8_t data); - uint8_t p8910_0a_r(); - uint8_t p8910_1a_r(); - void p8910_0b_w(uint8_t data); - void spritectrl_w(offs_t offset, uint8_t data); - - void taxidriv_palette(palette_device &palette) const; - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void cpu2_map(address_map &map); - void cpu3_map(address_map &map); - void cpu3_port_map(address_map &map); - void main_map(address_map &map); -}; - -#endif // MAME_INCLUDES_TAXIDRIV_H diff --git a/src/mame/video/hng64.cpp b/src/mame/video/hng64.cpp index b3ff066a323..23228f88733 100644 --- a/src/mame/video/hng64.cpp +++ b/src/mame/video/hng64.cpp @@ -176,7 +176,7 @@ void hng64_state::hng64_videoram_w(offs_t offset, uint32_t data, uint32_t mem_ma /* internal set of transparency states for rendering */ -static void hng64_configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask, hng64trans_t drawformat) +void hng64_state::hng64_configure_blit_parameters(blit_parameters *blit, tilemap_t *tmap, bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask, hng64trans_t drawformat) { /* start with nothing */ memset(blit, 0, sizeof(*blit)); diff --git a/src/mame/video/taxidriv.cpp b/src/mame/video/taxidriv.cpp deleted file mode 100644 index ddf06c509a5..00000000000 --- a/src/mame/video/taxidriv.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -#include "emu.h" -#include "includes/taxidriv.h" - - -void taxidriv_state::spritectrl_w(offs_t offset, uint8_t data) -{ - m_spritectrl[offset] = data; -} - - - -uint32_t taxidriv_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - if (m_bghide) - { - bitmap.fill(0, cliprect); - - - /* kludge to fix scroll after death */ - m_scroll[0] = m_scroll[1] = m_scroll[2] = m_scroll[3] = 0; - m_spritectrl[2] = m_spritectrl[5] = m_spritectrl[8] = 0; - } - else - { - for (int offs = 0;offs < 0x400;offs++) - { - int sx = offs % 32; - int sy = offs / 32; - - m_gfxdecode->gfx(3)->opaque(bitmap,cliprect, - m_vram3[offs], - 0, - 0,0, - (sx*8-m_scroll[0])&0xff,(sy*8-m_scroll[1])&0xff); - } - - for (int offs = 0;offs < 0x400;offs++) - { - int sx = offs % 32; - int sy = offs / 32; - - m_gfxdecode->gfx(2)->transpen(bitmap,cliprect, - m_vram2[offs]+256*m_vram2[offs+0x400], - 0, - 0,0, - (sx*8-m_scroll[2])&0xff,(sy*8-m_scroll[3])&0xff,0); - } - - if (m_spritectrl[2] & 4) - { - for (int offs = 0;offs < 0x1000;offs++) - { - int sx = ((offs/2) % 64-m_spritectrl[0]-256*(m_spritectrl[2]&1))&0x1ff; - int sy = ((offs/2) / 64-m_spritectrl[1]-128*(m_spritectrl[2]&2))&0x1ff; - - int color = (m_vram5[offs/4]>>(2*(offs&3)))&0x03; - if (color) - { - if (sx > 0 && sx < 256 && sy > 0 && sy < 256) - bitmap.pix(sy, sx) = color; - } - } - } - - if (m_spritectrl[5] & 4) - { - for (int offs = 0;offs < 0x1000;offs++) - { - int sx = ((offs/2) % 64-m_spritectrl[3]-256*(m_spritectrl[5]&1))&0x1ff; - int sy = ((offs/2) / 64-m_spritectrl[4]-128*(m_spritectrl[5]&2))&0x1ff; - - int color = (m_vram6[offs/4]>>(2*(offs&3)))&0x03; - if (color) - { - if (sx > 0 && sx < 256 && sy > 0 && sy < 256) - bitmap.pix(sy, sx) = color; - } - } - } - - if (m_spritectrl[8] & 4) - { - for (int offs = 0;offs < 0x1000;offs++) - { - int sx = ((offs/2) % 64-m_spritectrl[6]-256*(m_spritectrl[8]&1))&0x1ff; - int sy = ((offs/2) / 64-m_spritectrl[7]-128*(m_spritectrl[8]&2))&0x1ff; - - int color = (m_vram7[offs/4]>>(2*(offs&3)))&0x03; - if (color) - { - if (sx > 0 && sx < 256 && sy > 0 && sy < 256) - bitmap.pix(sy, sx) = color; - } - } - } - - for (int offs = 0;offs < 0x400;offs++) - { - int sx = offs % 32; - int sy = offs / 32; - - m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, - m_vram1[offs], - 0, - 0,0, - sx*8,sy*8,0); - } - - for (int offs = 0;offs < 0x2000;offs++) - { - int sx = (offs/2) % 64; - int sy = (offs/2) / 64; - - int color = (m_vram4[offs/4]>>(2*(offs&3)))&0x03; - if (color) - { - bitmap.pix(sy, sx) = 2 * color; - } - } - } - - for (int offs = 0;offs < 0x400;offs++) - { - int sx = offs % 32; - int sy = offs / 32; - - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - m_vram0[offs], - 0, - 0,0, - sx*8,sy*8,0); - } - return 0; -} diff --git a/src/osd/asio.h b/src/osd/asio.h index 3ee31a467d7..d59a90b8929 100644 --- a/src/osd/asio.h +++ b/src/osd/asio.h @@ -17,7 +17,7 @@ #pragma GCC diagnostic ignored "-Wunused-variable" #endif -#if defined(WIN32) && !defined(_WIN32_WINNT) +#if defined(_WIN32) && !defined(_WIN32_WINNT) #if defined(OSD_WINDOWS) #define _WIN32_WINNT 0x0501 #else diff --git a/src/osd/modules/debugger/debugqt.cpp b/src/osd/modules/debugger/debugqt.cpp index 6731dc63e21..a48f419a6a3 100644 --- a/src/osd/modules/debugger/debugqt.cpp +++ b/src/osd/modules/debugger/debugqt.cpp @@ -33,7 +33,7 @@ #include "qt/deviceinformationwindow.h" class debug_qt : public osd_module, public debug_module -#if defined(WIN32) && !defined(SDLMAME_WIN32) +#if defined(_WIN32) && !defined(SDLMAME_WIN32) , public QAbstractNativeEventFilter #endif { @@ -50,7 +50,7 @@ public: virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); virtual void debugger_update(); -#if defined(WIN32) && !defined(SDLMAME_WIN32) +#if defined(_WIN32) && !defined(SDLMAME_WIN32) virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE; #endif private: @@ -230,7 +230,7 @@ void bring_main_window_to_front() // Core functionality //============================================================ -#if defined(WIN32) && !defined(SDLMAME_WIN32) +#if defined(_WIN32) && !defined(SDLMAME_WIN32) bool winwindow_qt_filter(void *message); bool debug_qt::nativeEventFilter(const QByteArray &eventType, void *message, long *) @@ -246,7 +246,7 @@ void debug_qt::init_debugger(running_machine &machine) { // If you're starting from scratch, create a new qApp new QApplication(qtArgc, qtArgv); -#if defined(WIN32) && !defined(SDLMAME_WIN32) +#if defined(_WIN32) && !defined(SDLMAME_WIN32) QAbstractEventDispatcher::instance()->installNativeEventFilter(this); #endif } @@ -276,7 +276,7 @@ void debug_qt::init_debugger(running_machine &machine) #if defined(SDLMAME_UNIX) || defined(SDLMAME_WIN32) extern int sdl_entered_debugger; -#elif defined(WIN32) +#elif defined(_WIN32) void winwindow_update_cursor_state(running_machine &machine); #endif @@ -343,7 +343,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop) // all the QT windows are already gone. gather_save_configurations(); } -#if defined(WIN32) && !defined(SDLMAME_WIN32) +#if defined(_WIN32) && !defined(SDLMAME_WIN32) winwindow_update_cursor_state(*m_machine); // make sure the cursor isn't hidden while in debugger #endif } diff --git a/src/osd/modules/file/posixdir.cpp b/src/osd/modules/file/posixdir.cpp index 9cd29a84600..63a02925bf1 100644 --- a/src/osd/modules/file/posixdir.cpp +++ b/src/osd/modules/file/posixdir.cpp @@ -22,7 +22,7 @@ #endif #endif -#ifdef WIN32 +#ifdef _WIN32 #define _FILE_OFFSET_BITS 64 #endif @@ -63,13 +63,13 @@ namespace { // CONSTANTS //============================================================ -#if defined(WIN32) +#if defined(_WIN32) constexpr char PATHSEPCH = '\\'; #else constexpr char PATHSEPCH = '/'; #endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__) || defined(_WIN32) || defined(SDLMAME_NO64BITIO) using sdl_dirent = struct dirent; using sdl_stat = struct stat; #define sdl_readdir readdir diff --git a/src/osd/modules/file/posixfile.cpp b/src/osd/modules/file/posixfile.cpp index b7c1cde7442..580288c7d10 100644 --- a/src/osd/modules/file/posixfile.cpp +++ b/src/osd/modules/file/posixfile.cpp @@ -22,7 +22,7 @@ #endif #endif -#ifdef WIN32 +#ifdef _WIN32 #define _FILE_OFFSET_BITS 64 #endif @@ -69,7 +69,7 @@ namespace { // CONSTANTS //============================================================ -#if defined(WIN32) +#if defined(_WIN32) constexpr char PATHSEPCH = '\\'; constexpr char INVPATHSEPCH = '/'; #else @@ -102,7 +102,7 @@ public: #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__) result = ::pread(m_fd, buffer, size_t(count), off_t(std::make_unsigned_t(offset))); -#elif defined(WIN32) || defined(SDLMAME_NO64BITIO) +#elif defined(_WIN32) || defined(SDLMAME_NO64BITIO) if (lseek(m_fd, off_t(std::make_unsigned_t(offset)), SEEK_SET) < 0) return std::error_condition(errno, std::generic_category()); result = ::read(m_fd, buffer, size_t(count)); @@ -123,7 +123,7 @@ public: #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__) result = ::pwrite(m_fd, buffer, size_t(count), off_t(std::make_unsigned_t(offset))); -#elif defined(WIN32) || defined(SDLMAME_NO64BITIO) +#elif defined(_WIN32) || defined(SDLMAME_NO64BITIO) if (lseek(m_fd, off_t(std::make_unsigned_t(offset)), SEEK_SET) < 0) return std::error_condition(errno, std::generic_category()); result = ::write(m_fd, buffer, size_t(count)); @@ -142,7 +142,7 @@ public: { int result; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__EMSCRIPTEN__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__EMSCRIPTEN__) || defined(_WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) result = ::ftruncate(m_fd, off_t(std::make_unsigned_t(offset))); #else result = ::ftruncate64(m_fd, off64_t(offset)); @@ -171,7 +171,7 @@ private: bool is_path_separator(char c) noexcept { -#if defined(WIN32) +#if defined(_WIN32) return (c == PATHSEPCH) || (c == INVPATHSEPCH); #else return c == PATHSEPCH; @@ -205,7 +205,7 @@ std::error_condition create_path_recursive(std::string_view path) noexcept return std::error_condition(); // create the path -#ifdef WIN32 +#ifdef _WIN32 if (mkdir(p.c_str()) < 0) #else if (mkdir(p.c_str(), 0777) < 0) @@ -247,13 +247,13 @@ std::error_condition osd_file::open(std::string const &path, std::uint32_t openf { return std::errc::invalid_argument; } -#if defined(WIN32) +#if defined(_WIN32) access |= O_BINARY; #endif // convert the path into something compatible dst = path; -#if defined(WIN32) +#if defined(_WIN32) for (auto it = dst.begin(); it != dst.end(); ++it) *it = (INVPATHSEPCH == *it) ? PATHSEPCH : *it; #endif @@ -262,7 +262,7 @@ std::error_condition osd_file::open(std::string const &path, std::uint32_t openf // attempt to open the file int fd = -1; -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(_WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) fd = ::open(dst.c_str(), access, 0666); #else fd = ::open64(dst.c_str(), access, 0666); @@ -285,7 +285,7 @@ std::error_condition osd_file::open(std::string const &path, std::uint32_t openf // attempt to reopen the file if (!createrr) { -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(_WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) fd = ::open(dst.c_str(), access, 0666); #else fd = ::open64(dst.c_str(), access, 0666); @@ -306,7 +306,7 @@ std::error_condition osd_file::open(std::string const &path, std::uint32_t openf } // get the file size -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(_WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) struct stat st; if (::fstat(fd, &st) < 0) #else @@ -371,7 +371,7 @@ bool osd_get_physical_drive_geometry(const char *filename, uint32_t *cylinders, std::unique_ptr osd_stat(const std::string &path) { -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__HAIKU__) || defined(_WIN32) || defined(SDLMAME_NO64BITIO) || defined(__ANDROID__) struct stat st; int const err = ::stat(path.c_str(), &st); #else @@ -405,7 +405,7 @@ std::error_condition osd_get_full_path(std::string &dst, std::string const &path { try { -#if defined(WIN32) +#if defined(_WIN32) std::vector path_buffer(MAX_PATH); if (::_fullpath(&path_buffer[0], path.c_str(), MAX_PATH)) { @@ -465,7 +465,7 @@ bool osd_is_absolute_path(std::string const &path) noexcept { if (!path.empty() && is_path_separator(path[0])) return true; -#if !defined(WIN32) +#if !defined(_WIN32) else if (!path.empty() && (path[0] == '.') && (!path[1] || is_path_separator(path[1]))) // FIXME: why is this even here? foo/./bar is a valid way to refer to foo/bar return true; #elif !defined(UNDER_CE) @@ -509,7 +509,7 @@ bool osd_is_valid_filename_char(char32_t uchar) noexcept // The only one that's actually invalid is the slash // The other two are just problematic because they're the escape character and path separator return osd_is_valid_filepath_char(uchar) -#if defined(WIN32) +#if defined(_WIN32) && uchar != PATHSEPCH && uchar != INVPATHSEPCH #else @@ -529,7 +529,7 @@ bool osd_is_valid_filepath_char(char32_t uchar) noexcept // One could argue that colon should be in here too because it functions as path separator return uchar >= 0x20 && !(uchar >= '\x7F' && uchar <= '\x9F') -#if defined(WIN32) +#if defined(_WIN32) && uchar != '<' && uchar != '>' && uchar != '\"' diff --git a/src/osd/modules/netdev/taptun.cpp b/src/osd/modules/netdev/taptun.cpp index 6999d6f63ba..c0d99ec750c 100644 --- a/src/osd/modules/netdev/taptun.cpp +++ b/src/osd/modules/netdev/taptun.cpp @@ -2,7 +2,7 @@ // copyright-holders:Carl #if defined(OSD_NET_USE_TAPTUN) -#if defined(WIN32) +#if defined(_WIN32) #include #include #else @@ -23,7 +23,7 @@ #define IFF_TAP 0x0002 #define IFF_NO_PI 0x1000 #define TUNSETIFF _IOW('T', 202, int) -#elif defined(WIN32) +#elif defined(_WIN32) #include "tap-windows6/tap-windows.h" // for some reason this isn't defined in the header, and presumably it changes @@ -62,7 +62,7 @@ public: protected: int recv_dev(uint8_t **buf) override; private: -#if defined(WIN32) +#if defined(_WIN32) HANDLE m_handle = INVALID_HANDLE_VALUE; OVERLAPPED m_overlapped; bool m_receive_pending; @@ -98,7 +98,7 @@ netdev_tap::netdev_tap(const char *name, class device_network_interface *ifdev, osd_printf_verbose("netdev_tap: network up!\n"); strncpy(m_ifname, ifr.ifr_name, 10); fcntl(m_fd, F_SETFL, O_NONBLOCK); -#elif defined(WIN32) +#elif defined(_WIN32) std::wstring device_path(L"" USERMODEDEVICEDIR); device_path.append(wstring_from_utf8(name)); device_path.append(L"" TAP_WIN_SUFFIX); @@ -121,7 +121,7 @@ netdev_tap::netdev_tap(const char *name, class device_network_interface *ifdev, netdev_tap::~netdev_tap() { -#if defined(WIN32) +#if defined(_WIN32) if (m_handle != INVALID_HANDLE_VALUE) { if (m_receive_pending) @@ -169,7 +169,7 @@ static u32 finalise_frame(u8 buf[], u32 length) return length; } -#if defined(WIN32) +#if defined(_WIN32) int netdev_tap::send(uint8_t *buf, int len) { OVERLAPPED overlapped = {}; @@ -344,7 +344,7 @@ static CREATE_NETDEV(create_tap) int taptun_module::init(const osd_options &options) { -#if defined(WIN32) +#if defined(_WIN32) for (std::wstring &id : get_tap_adapters()) add_netdev(utf8_from_wstring(id).c_str(), utf8_from_wstring(get_connection_name(id)).c_str(), create_tap); #else diff --git a/src/osd/modules/sound/pa_sound.cpp b/src/osd/modules/sound/pa_sound.cpp index c71852df8e8..ce191b6086a 100644 --- a/src/osd/modules/sound/pa_sound.cpp +++ b/src/osd/modules/sound/pa_sound.cpp @@ -24,7 +24,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include "pa_win_wasapi.h" #endif @@ -216,7 +216,7 @@ int sound_pa::init(osd_options const &options) // 0 = use default stream_params.suggestedLatency = options.pa_latency() ? options.pa_latency() : device_info->defaultLowOutputLatency; -#ifdef WIN32 +#ifdef _WIN32 PaWasapiStreamInfo wasapi_stream_info; // if requested latency is less than 20 ms, we need to use exclusive mode diff --git a/src/osd/osdcore.cpp b/src/osd/osdcore.cpp index f883e50f321..f5860416381 100644 --- a/src/osd/osdcore.cpp +++ b/src/osd/osdcore.cpp @@ -139,7 +139,7 @@ void osd_vprintf_debug(util::format_argument_pack const &args) osd_ticks_t osd_ticks() { -#ifdef WIN32 +#ifdef _WIN32 LARGE_INTEGER val; QueryPerformanceCounter(&val); return val.QuadPart; @@ -155,7 +155,7 @@ osd_ticks_t osd_ticks() osd_ticks_t osd_ticks_per_second() { -#ifdef WIN32 +#ifdef _WIN32 LARGE_INTEGER val; QueryPerformanceFrequency(&val); return val.QuadPart; @@ -170,7 +170,7 @@ osd_ticks_t osd_ticks_per_second() void osd_sleep(osd_ticks_t duration) { -#ifdef WIN32 +#ifdef _WIN32 // sleep_for appears to oversleep on Windows with gcc 8 Sleep(duration / (osd_ticks_per_second() / 1000)); #else @@ -190,7 +190,7 @@ void osd_sleep(osd_ticks_t duration) std::vector osd_get_command_line(int argc, char *argv[]) { std::vector results; -#ifdef WIN32 +#ifdef _WIN32 { // Get the command line from Windows int count; @@ -206,7 +206,7 @@ std::vector osd_get_command_line(int argc, char *argv[]) LocalFree(wide_args); } -#else // !WIN32 +#else // !_WIN32 { // for non Windows platforms, we are assuming that arguments are // already UTF-8; we just need to convert to std::vector @@ -214,6 +214,6 @@ std::vector osd_get_command_line(int argc, char *argv[]) for (int i = 0; i < argc; i++) results.emplace_back(argv[i]); } -#endif // WIN32 +#endif // _WIN32 return results; } diff --git a/src/osd/strconv.h b/src/osd/strconv.h index f1eed54a49a..3843ee00f98 100644 --- a/src/osd/strconv.h +++ b/src/osd/strconv.h @@ -17,7 +17,7 @@ // FUNCTION PROTOTYPES //============================================================ -#if defined(WIN32) +#if defined(_WIN32) #include @@ -56,7 +56,7 @@ typedef std::string tstring; } } -#endif // defined(WIN32) +#endif // defined(_WIN32) #endif // MAME_OSD_STRCONV_H diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp index e0243ce7277..d1cb963a8f8 100644 --- a/src/tools/chdman.cpp +++ b/src/tools/chdman.cpp @@ -39,7 +39,7 @@ using util::string_format; // CONSTANTS & DEFINES //************************************************************************** // MINGW has adopted the MSVC formatting for 64-bit ints as of GCC 4.4 and deprecated it as of GCC 9.3 -#if defined(WIN32) && defined(__GNUC__) && ((__GNUC__ < 9) || ((__GNUC__ == 9) && (__GNUC_MINOR__ < 3))) +#if defined(_WIN32) && defined(__GNUC__) && ((__GNUC__ < 9) || ((__GNUC__ == 9) && (__GNUC_MINOR__ < 3))) #define I64FMT "I64" #elif !defined(__APPLE__) && defined(__LP64__) #define I64FMT "l" diff --git a/src/tools/srcclean.cpp b/src/tools/srcclean.cpp index 340217c7768..85cf28a22a2 100644 --- a/src/tools/srcclean.cpp +++ b/src/tools/srcclean.cpp @@ -2212,7 +2212,7 @@ int main(int argc, char *argv[]) { bool keep_backup(false); bool dry_run(false); -#if defined(WIN32) +#if defined(_WIN32) cleaner_base::newline newline_mode(cleaner_base::newline::DOS); #else cleaner_base::newline newline_mode(cleaner_base::newline::UNIX);