diff --git a/C64.emu/src/vice/resid/sid.cc b/C64.emu/src/vice/resid/sid.cc index e0a85b487..cc3d8dd22 100644 --- a/C64.emu/src/vice/resid/sid.cc +++ b/C64.emu/src/vice/resid/sid.cc @@ -579,7 +579,7 @@ bool SID::set_sampling_parameters(double clock_freq, sampling_method method, if (method == SAMPLE_RESAMPLE || method == SAMPLE_RESAMPLE_FASTMEM) { // Check whether the sample ring buffer would overfill. - if (FIR_N*clock_freq/sample_freq >= RINGSIZE) { + if (double(FIR_N)*clock_freq/sample_freq >= double(RINGSIZE)) { return false; } diff --git a/EmuFramework/include/emuframework/DataPathSelectView.hh b/EmuFramework/include/emuframework/DataPathSelectView.hh index eaa8419b2..3842a3565 100644 --- a/EmuFramework/include/emuframework/DataPathSelectView.hh +++ b/EmuFramework/include/emuframework/DataPathSelectView.hh @@ -44,8 +44,6 @@ template; -class VControllerElement : public VControllerElementVariant +class VControllerElement : public VControllerElementVariant, public AddVisit { public: using VControllerElementVariant::VControllerElementVariant; + using AddVisit::visit; std::array layoutPos; VControllerState state{VControllerState::SHOWN}; @@ -394,13 +395,13 @@ public: { return (sizeof(VControllerLayoutPosition::pos) + sizeof(_2DOrigin::PackedType)) * 2 + sizeof(state) - + visit([](auto &e){ return e.configSize(); }, *this); + + visit([](auto &e){ return e.configSize(); }); } - WRect bounds() const { return visit([](auto &e){ return e.bounds(); }, *this); } - WRect realBounds() const { return visit([](auto &e){ return e.realBounds(); }, *this); } - void setPos(WPt pos, WRect viewBounds) { visit([&](auto &e){ e.setPos(pos, viewBounds); }, *this); } - void setAlpha(float alpha) { visit([&](auto &e){ e.setAlpha(alpha); }, *this); } + WRect bounds() const { return visit([](auto &e){ return e.bounds(); }); } + WRect realBounds() const { return visit([](auto &e){ return e.realBounds(); }); } + void setPos(WPt pos, WRect viewBounds) { visit([&](auto &e){ e.setPos(pos, viewBounds); }); } + void setAlpha(float alpha) { visit([&](auto &e){ e.setAlpha(alpha); }); } static bool shouldDraw(VControllerState state, bool showHidden) { @@ -411,7 +412,7 @@ public: { if(!shouldDraw(state, showHidden)) return; - visit([&](auto &e){ e.drawButtons(cmds); }, *this); + visit([&](auto &e){ e.drawButtons(cmds); }); } void drawBounds(Gfx::RendererCommands &__restrict__ cmds, bool showHidden) const @@ -424,7 +425,7 @@ public: { e.drawBounds(cmds); } - }, *this); + }); } void place(WRect viewBounds, WRect windowBounds, int layoutIdx) @@ -440,7 +441,7 @@ public: [&](VControllerDPad &e){ e.setShowBounds(r, on); }, [&](VControllerButtonGroup &e){ e.setShowBounds(on); }, [](auto &e){} - }, *this); + }); } _2DOrigin layoutOrigin() const @@ -449,12 +450,12 @@ public: { [&](const VControllerDPad &e){ return LB2DO; }, [](auto &e){ return e.layout.origin; } - }, *this); + }); } std::string name(const InputManager &mgr) const { - return visit([&](auto &e){ return e.name(mgr); }, *this); + return visit([&](auto &e){ return e.name(mgr); }); } void updateMeasurements(const Window &win) @@ -465,7 +466,7 @@ public: { e.updateMeasurements(win); } - }, *this); + }); } void transposeKeysForPlayer(const InputManager &mgr, int player) @@ -476,7 +477,7 @@ public: { e.transposeKeysForPlayer(mgr, player); } - }, *this); + }); } std::span buttons() @@ -487,7 +488,7 @@ public: return e.buttons; else return {}; - }, *this); + }); } void add(KeyInfo keyCode) @@ -498,7 +499,7 @@ public: { e.buttons.emplace_back(keyCode); } - }, *this); + }); } void remove(VControllerButton &btnToErase) @@ -509,7 +510,7 @@ public: { std::erase_if(e.buttons, [&](auto &b) { return &b == &btnToErase; }); } - }, *this); + }); } void setRowSize(int8_t size) @@ -518,7 +519,7 @@ public: { if constexpr(requires {e.layout.rowItems;}) e.layout.rowItems = size; - }, *this); + }); } auto rowSize() const @@ -529,7 +530,7 @@ public: return e.layout.rowItems; else return 1; - }, *this); + }); } void updateSprite(VControllerButton &b) @@ -538,7 +539,7 @@ public: { if constexpr(requires {e.updateSprite(b);}) e.updateSprite(b); - }, *this); + }); } }; diff --git a/EmuFramework/include/emuframework/inputDefs.hh b/EmuFramework/include/emuframework/inputDefs.hh index a62777f2a..8299d5d15 100644 --- a/EmuFramework/include/emuframework/inputDefs.hh +++ b/EmuFramework/include/emuframework/inputDefs.hh @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -49,7 +50,7 @@ struct KeyInfo constexpr KeyInfo() = default; - constexpr KeyInfo(auto code, KeyFlags flags = {}): + constexpr KeyInfo(NotPointer auto code, KeyFlags flags = {}): codes{KeyCode(code)}, flags{flags} {} template diff --git a/EmuFramework/metadata/conf.mk b/EmuFramework/metadata/conf.mk index 100cffa66..0c7fa2049 100644 --- a/EmuFramework/metadata/conf.mk +++ b/EmuFramework/metadata/conf.mk @@ -1,4 +1,4 @@ -metadata_version = 1.5.81 +metadata_version = 1.5.82 metadata_supportedMIMETypes = application/zip metadata_supportedFileExtensions = rar 7z android_metadata_versionCodeExtra = 16 diff --git a/EmuFramework/src/gui/ButtonConfigView.cc b/EmuFramework/src/gui/ButtonConfigView.cc index 2662db5b1..6c73f09c5 100644 --- a/EmuFramework/src/gui/ButtonConfigView.cc +++ b/EmuFramework/src/gui/ButtonConfigView.cc @@ -226,7 +226,7 @@ void ButtonConfigSetView::place() bool ButtonConfigSetView::inputEvent(const Input::Event &e) { - return visit(overloaded + return e.visit(overloaded { [&](const Input::MotionEvent &motionEv) { @@ -300,7 +300,7 @@ bool ButtonConfigSetView::inputEvent(const Input::Event &e) } return true; } - }, e); + }); } void ButtonConfigSetView::finalize() diff --git a/EmuFramework/src/gui/CreditsView.cc b/EmuFramework/src/gui/CreditsView.cc index 748dbebb4..7f3d218fc 100644 --- a/EmuFramework/src/gui/CreditsView.cc +++ b/EmuFramework/src/gui/CreditsView.cc @@ -59,11 +59,11 @@ void CreditsView::place() bool CreditsView::inputEvent(const Input::Event &e) { - if(visit(overloaded + if(e.visit(overloaded { [&](const Input::MotionEvent &e) { return viewRect().overlaps(e.pos()) && e.released(); }, [&](const Input::KeyEvent &e) { return e.pushed(Input::DefaultKey::CANCEL); } - }, e)) + })) { dismiss(); return true; diff --git a/EmuFramework/src/gui/EmuInputView.cc b/EmuFramework/src/gui/EmuInputView.cc index 528a567d9..206c6938a 100644 --- a/EmuFramework/src/gui/EmuInputView.cc +++ b/EmuFramework/src/gui/EmuInputView.cc @@ -75,7 +75,7 @@ void EmuInputView::updateRunSpeed(AltSpeedMode mode) bool EmuInputView::inputEvent(const Input::Event &e) { - return visit(overloaded + return e.visit(overloaded { [&](const Input::MotionEvent &motionEv) { @@ -139,7 +139,7 @@ bool EmuInputView::inputEvent(const Input::Event &e) || keyEv.isGamepad() // consume all gamepad events || devData.devConf.shouldHandleUnboundKeys; } - }, e); + }); } void EmuInputView::setSystemGestureExclusion(bool on) diff --git a/EmuFramework/src/gui/InputManagerView.cc b/EmuFramework/src/gui/InputManagerView.cc index ca4d85ba0..d65c18479 100644 --- a/EmuFramework/src/gui/InputManagerView.cc +++ b/EmuFramework/src/gui/InputManagerView.cc @@ -53,7 +53,7 @@ void IdentInputDeviceView::place() bool IdentInputDeviceView::inputEvent(const Input::Event &e) { - return visit(overloaded + return e.visit(overloaded { [&](const Input::MotionEvent &e) { @@ -75,7 +75,7 @@ bool IdentInputDeviceView::inputEvent(const Input::Event &e) } return false; } - }, e); + }); } void IdentInputDeviceView::draw(Gfx::RendererCommands &__restrict__ cmds) diff --git a/EmuFramework/src/gui/PlaceVControlsView.cc b/EmuFramework/src/gui/PlaceVControlsView.cc index c4cb02daa..04d08ec03 100644 --- a/EmuFramework/src/gui/PlaceVControlsView.cc +++ b/EmuFramework/src/gui/PlaceVControlsView.cc @@ -84,7 +84,7 @@ void PlaceVControlsView::place() bool PlaceVControlsView::inputEvent(const Input::Event &e) { - return visit(overloaded + return e.visit(overloaded { [&](const Input::KeyEvent &e) { @@ -170,7 +170,7 @@ bool PlaceVControlsView::inputEvent(const Input::Event &e) }); return true; } - }, e); + }); } void PlaceVControlsView::draw(Gfx::RendererCommands &__restrict__ cmds) diff --git a/EmuFramework/src/gui/PlaceVideoView.cc b/EmuFramework/src/gui/PlaceVideoView.cc index 8a9fce77f..059c884eb 100644 --- a/EmuFramework/src/gui/PlaceVideoView.cc +++ b/EmuFramework/src/gui/PlaceVideoView.cc @@ -65,7 +65,7 @@ void PlaceVideoView::place() bool PlaceVideoView::inputEvent(const Input::Event &e) { - return visit(overloaded + return e.visit(overloaded { [&](const Input::KeyEvent &e) { @@ -150,7 +150,7 @@ bool PlaceVideoView::inputEvent(const Input::Event &e) } return true; } - }, e); + }); } void PlaceVideoView::draw(Gfx::RendererCommands &__restrict__ cmds) diff --git a/EmuFramework/src/gui/TouchConfigView.cc b/EmuFramework/src/gui/TouchConfigView.cc index 8801f0ec8..de1049c9b 100644 --- a/EmuFramework/src/gui/TouchConfigView.cc +++ b/EmuFramework/src/gui/TouchConfigView.cc @@ -1029,12 +1029,12 @@ void TouchConfigView::reloadItems() elem.name(app().inputManager), attachParams(), [this, &elem](const Input::Event &e) { - visit(overloaded + elem.visit(overloaded { [&](VControllerDPad &){ pushAndShow(makeView(*this, vController, elem), e); }, [&](VControllerButtonGroup &){ pushAndShow(makeView(*this, vController, elem), e); }, [](auto &){} - }, elem); + }); }); item.emplace_back(&i); } @@ -1045,11 +1045,11 @@ void TouchConfigView::reloadItems() elem.name(app().inputManager), attachParams(), [this, &elem](const Input::Event &e) { - visit(overloaded + elem.visit(overloaded { [&](VControllerUIButtonGroup &){ pushAndShow(makeView(*this, vController, elem), e); }, [](auto &){} - }, elem); + }); }); item.emplace_back(&i); } diff --git a/EmuFramework/src/vcontrols/VController.cc b/EmuFramework/src/vcontrols/VController.cc index 675c217a5..f62af695d 100644 --- a/EmuFramework/src/vcontrols/VController.cc +++ b/EmuFramework/src/vcontrols/VController.cc @@ -63,7 +63,7 @@ int VController::yMMSizeToPixel(const IG::Window &win, float mm) const static void updateTexture(const EmuApp &app, VControllerElement &e, Gfx::RendererTask &task, const Gfx::IndexBuffer &fanQuadIdxs) { - visit(overloaded + e.visit(overloaded { [&](VControllerDPad &dpad){ dpad.setImage(task, app.asset(app.vControllerAssetDesc(0)), fanQuadIdxs); }, [&](VControllerButtonGroup &grp) @@ -109,7 +109,7 @@ static void updateTexture(const EmuApp &app, VControllerElement &e, Gfx::Rendere } grp.setTask(task); } - }, e); + }); } void VController::updateTextures() @@ -121,12 +121,12 @@ void VController::updateTextures() static void setSize(VControllerElement &elem, int sizePx, Gfx::Renderer &r) { assert(sizePx); - visit(overloaded + elem.visit(overloaded { [&](VControllerDPad &dpad){ dpad.setSize(r, makeEvenRoundedUp(int(sizePx * 2.5f))); }, [&](VControllerButtonGroup &grp){ grp.setButtonSize(sizePx); }, [&](VControllerUIButtonGroup &grp){ grp.setButtonSize(sizePx); }, - }, elem); + }); } void VController::setButtonSizes(int gamepadBtnSizeInPixels, int uiBtnSizeInPixels) @@ -206,7 +206,7 @@ std::array VController::findGamepadElements(WPt pos) { for(const auto &gpElem : gpElements) { - auto indices = visit(overloaded + auto indices = gpElem.visit(overloaded { [&](const VControllerDPad &dpad) -> std::array { @@ -221,7 +221,7 @@ std::array VController::findGamepadElements(WPt pos) return grp.findButtonIndices(pos); }, [](auto &e) -> std::array { return {}; } - }, gpElem); + }); if(indices != std::array{}) return indices; } @@ -435,11 +435,11 @@ void VController::setDisabledInputKeys(std::span disabledKeys_) disabledKeys = disabledKeys_; for(auto &e : gpElements) { - visit(overloaded + e.visit(overloaded { [&](VControllerButtonGroup &grp) { updateEnabledButtons(grp); }, [](auto &e){} - }, e); + }); } place(); } @@ -701,7 +701,7 @@ bool VController::readConfig(EmuApp &app, MapIO &io, unsigned key) static void writeToConfig(const VControllerElement &e, FileIO &io) { io.put(e.dPad() ? int8_t(1) : int8_t(0)); - visit(overloaded + e.visit(overloaded { [&](const VControllerButtonGroup &e) { @@ -734,7 +734,7 @@ static void writeToConfig(const VControllerElement &e, FileIO &io) io.put(config.deadzoneMM100x); io.put(config.visualizeBounds); }, - }, e); + }); io.put(e.layoutPos[0].pos); io.put(e.layoutPos[0].origin.pack()); io.put(e.layoutPos[1].pos); @@ -1070,7 +1070,7 @@ void VController::updateSystemKeys(KeyInfo key, bool isPushed) }; for(auto &e : gpElements) { - visit(overloaded + e.visit(overloaded { [&](VControllerButtonGroup &grp) { @@ -1098,7 +1098,7 @@ void VController::updateSystemKeys(KeyInfo key, bool isPushed) dpad.setAlpha(alphaF); }, [](auto &e){} - }, e); + }); } } @@ -1106,7 +1106,7 @@ void VController::resetHighlightedKeys() { for(auto &e : gpElements) { - visit(overloaded + e.visit(overloaded { [&](VControllerButtonGroup &grp) { @@ -1120,7 +1120,7 @@ void VController::resetHighlightedKeys() } }, [](auto &e){} - }, e); + }); } } diff --git a/GBA.emu/src/vbam/apu/Gb_Apu.h b/GBA.emu/src/vbam/apu/Gb_Apu.h index 7e9eff901..edca76f47 100644 --- a/GBA.emu/src/vbam/apu/Gb_Apu.h +++ b/GBA.emu/src/vbam/apu/Gb_Apu.h @@ -19,7 +19,7 @@ class Gb_Apu // Sets buffer(s) to generate sound into. If left and right are NULL, output is mono. // If all are NULL, no output is generated but other emulation still runs. // If chan is specified, only that channel's output is changed, otherwise all are. - enum { osc_count = 4 }; // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise + static constexpr int osc_count = 4; // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise void set_output(Blip_Buffer *center, Blip_Buffer *left = NULL, Blip_Buffer *right = NULL, int chan = osc_count); @@ -34,9 +34,9 @@ class Gb_Apu // Reads and writes must be within the start_addr to end_addr range, inclusive. // Addresses outside this range are not mapped to the sound hardware. - enum { start_addr = 0xFF10 }; - enum { end_addr = 0xFF3F }; - enum { register_count = end_addr - start_addr + 1 }; + static constexpr unsigned start_addr = 0xFF10; + static constexpr unsigned end_addr = 0xFF3F; + static constexpr unsigned register_count = end_addr - start_addr + 1; // Times are specified as the number of clocks since the beginning of the // current time frame. diff --git a/GBA.emu/src/vbam/apu/Gb_Oscs.h b/GBA.emu/src/vbam/apu/Gb_Oscs.h index 700f28f1d..c0413fc35 100644 --- a/GBA.emu/src/vbam/apu/Gb_Oscs.h +++ b/GBA.emu/src/vbam/apu/Gb_Oscs.h @@ -125,8 +125,8 @@ class Gb_Sweep_Square : public Gb_Square } private: - enum { period_mask = 0x70 }; - enum { shift_mask = 0x07 }; + static constexpr unsigned period_mask = 0x70; + static constexpr unsigned shift_mask = 0x07; void calc_sweep(bool update); void reload_sweep_timer(); diff --git a/GBC.emu/src/common/resample/src/chainresampler.h b/GBC.emu/src/common/resample/src/chainresampler.h index 72076c899..2de1b13de 100644 --- a/GBC.emu/src/common/resample/src/chainresampler.h +++ b/GBC.emu/src/common/resample/src/chainresampler.h @@ -45,8 +45,8 @@ private: typedef std::list List; typedef SubResampler * (*CreateSinc)(unsigned div, float rollOffStart, float rollOffWidth, double gain); - enum { big_sinc_mul = 2048 }; - enum { small_sinc_mul = 32 }; + static constexpr int big_sinc_mul = 2048; + static constexpr int small_sinc_mul = 32; List list_; SubResampler *bigSinc_; diff --git a/GBC.emu/src/libgambatte/src/minkeeper.h b/GBC.emu/src/libgambatte/src/minkeeper.h index 8fb797300..a740c2fea 100644 --- a/GBC.emu/src/libgambatte/src/minkeeper.h +++ b/GBC.emu/src/libgambatte/src/minkeeper.h @@ -23,15 +23,15 @@ namespace min_keeper_detail { -template struct CeiledLog2 { enum { r = 1 + CeiledLog2<(n + 1) / 2>::r }; }; -template<> struct CeiledLog2<1> { enum { r = 0 }; }; +template struct CeiledLog2 { static constexpr int r = 1 + CeiledLog2<(n + 1) / 2>::r; }; +template<> struct CeiledLog2<1> { static constexpr int r = 0; }; -template struct CeiledDiv2n { enum { r = CeiledDiv2n<(v + 1) / 2, n - 1>::r }; }; -template struct CeiledDiv2n { enum { r = v }; }; -// alternatively: template struct CeiledDiv2n { enum { r = (v + (1 << n) - 1) >> n }; }; +template struct CeiledDiv2n { static constexpr int r = CeiledDiv2n<(v + 1) / 2, n - 1>::r; }; +template struct CeiledDiv2n { static constexpr int r = v; }; +// alternatively: template struct CeiledDiv2n { static constexpr int r = (v + (1 << n) - 1) >> n; }; -template class T, int n> struct Sum { enum { r = T::r + Sum::r }; }; -template class T> struct Sum { enum { r = 0 }; }; +template class T, int n> struct Sum { static constexpr int r = T::r + Sum::r; }; +template class T> struct Sum { static constexpr int r = 0; }; } diff --git a/GBC.emu/src/libgambatte/src/statesaver.h b/GBC.emu/src/libgambatte/src/statesaver.h index 1f46ecdf5..94878e412 100644 --- a/GBC.emu/src/libgambatte/src/statesaver.h +++ b/GBC.emu/src/libgambatte/src/statesaver.h @@ -32,10 +32,10 @@ struct SaveState; class StateSaver { public: - enum { ss_shift = 2 }; - enum { ss_div = 1 << 2 }; - enum { ss_width = 160 >> ss_shift }; - enum { ss_height = 144 >> ss_shift }; + static constexpr int ss_shift = 2; + static constexpr int ss_div = 1 << 2; + static constexpr int ss_width = 160 >> ss_shift; + static constexpr int ss_height = 144 >> ss_shift; static bool saveState(SaveState const &state, uint_least32_t const *videoBuf, std::ptrdiff_t pitch, diff --git a/GBC.emu/src/libgambatte/src/video/lcddef.h b/GBC.emu/src/libgambatte/src/video/lcddef.h index 4860fbd40..d805159d0 100644 --- a/GBC.emu/src/libgambatte/src/video/lcddef.h +++ b/GBC.emu/src/libgambatte/src/video/lcddef.h @@ -20,14 +20,14 @@ enum { lcdstat_m2irqen = 0x20, lcdstat_lycirqen = 0x40 }; -enum { +constexpr int lcd_hres = 160, lcd_vres = 144, lcd_lines_per_frame = 154, lcd_max_num_sprites_per_line = 10, lcd_num_oam_entries = 40, lcd_cycles_per_line = 456, - lcd_force_signed_enum1 = -1 }; + lcd_force_signed_enum1 = -1; enum { lcd_cycles_per_frame = 1l * lcd_lines_per_frame * lcd_cycles_per_line, lcd_force_signed_enum2 = -1 }; diff --git a/GBC.emu/src/libgambatte/src/video/ppu.cpp b/GBC.emu/src/libgambatte/src/video/ppu.cpp index 9a676db33..9a5e0e237 100644 --- a/GBC.emu/src/libgambatte/src/video/ppu.cpp +++ b/GBC.emu/src/libgambatte/src/video/ppu.cpp @@ -97,8 +97,8 @@ namespace StartWindowDraw { #undef DECLARE_FUNC -enum { attr_cgbpalno = 0x07, attr_tdbank = 0x08, attr_dmgpalno = 0x10, attr_xflip = 0x20, - attr_yflip = 0x40, attr_bgpriority = 0x80 }; +constexpr unsigned attr_cgbpalno = 0x07, attr_tdbank = 0x08, attr_dmgpalno = 0x10, attr_xflip = 0x20, + attr_yflip = 0x40, attr_bgpriority = 0x80; enum { win_draw_start = 1, win_draw_started = 2 }; int const max_m3start_cycles = 80; diff --git a/GBC.emu/src/libgambatte/src/video/ppu.h b/GBC.emu/src/libgambatte/src/video/ppu.h index 70d267aa8..adf6ee880 100644 --- a/GBC.emu/src/libgambatte/src/video/ppu.h +++ b/GBC.emu/src/libgambatte/src/video/ppu.h @@ -28,10 +28,10 @@ namespace gambatte { -enum { +constexpr int max_num_palettes = 8, num_palette_entries = 4, - ppu_force_signed_enum = -1 }; + ppu_force_signed_enum = -1; class PPUFrameBuf { public: diff --git a/GBC.emu/src/libgambatte/src/video/sprite_mapper.h b/GBC.emu/src/libgambatte/src/video/sprite_mapper.h index 288746f0f..fa1a7bec3 100644 --- a/GBC.emu/src/libgambatte/src/video/sprite_mapper.h +++ b/GBC.emu/src/libgambatte/src/video/sprite_mapper.h @@ -103,7 +103,7 @@ private: bool cgb_; }; - enum { need_sorting_flag = 0x80 }; + static constexpr unsigned need_sorting_flag = 0x80; mutable unsigned char spritemap_[lcd_vres][lcd_max_num_sprites_per_line]; mutable unsigned char num_[lcd_vres]; diff --git a/MD.emu/src/genplus-gx/sound/blip.cc b/MD.emu/src/genplus-gx/sound/blip.cc index 5778ea449..5bfd13ac6 100644 --- a/MD.emu/src/genplus-gx/sound/blip.cc +++ b/MD.emu/src/genplus-gx/sound/blip.cc @@ -17,12 +17,12 @@ details. You should have received a copy of the GNU Lesser General Public License along with this module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -enum { buf_extra = 2 }; /* extra samples to save past end */ -enum { time_bits = 16 }; /* bits in fraction of fixed-point sample counts */ -enum { time_unit = 1 << time_bits }; -enum { phase_bits = 15 }; /* bits in fraction of deltas in buffer */ -enum { phase_count = 1 << phase_bits }; -enum { phase_shift = time_bits - phase_bits }; +constexpr int buf_extra = 2; /* extra samples to save past end */ +constexpr int time_bits = 16; /* bits in fraction of fixed-point sample counts */ +constexpr int time_unit = 1 << time_bits; +constexpr int phase_bits = 15; /* bits in fraction of deltas in buffer */ +constexpr int phase_count = 1 << phase_bits; +constexpr int phase_shift = time_bits - phase_bits; typedef int buf_t; /* type of element in delta buffer */ diff --git a/NES.emu/res/palette/Lightful.pal b/NES.emu/res/palette/Lightful.pal index 0a10a493e..28b1f01b5 100644 Binary files a/NES.emu/res/palette/Lightful.pal and b/NES.emu/res/palette/Lightful.pal differ diff --git a/NES.emu/res/palette/Palightful.pal b/NES.emu/res/palette/Palightful.pal new file mode 100644 index 000000000..144138493 Binary files /dev/null and b/NES.emu/res/palette/Palightful.pal differ diff --git a/NES.emu/src/main/EmuMenuViews.cc b/NES.emu/src/main/EmuMenuViews.cc index aea47bcab..462475d4b 100644 --- a/NES.emu/src/main/EmuMenuViews.cc +++ b/NES.emu/src/main/EmuMenuViews.cc @@ -329,6 +329,7 @@ class CustomVideoOptionView : public VideoOptionView, public MainAppHelper static constexpr auto classicPalPath = "Classic (FBX).pal"; static constexpr auto wavebeamPalPath = "Wavebeam.pal"; static constexpr auto lightfulPalPath = "Lightful.pal"; + static constexpr auto palightfulPalPath = "Palightful.pal"; void setPalette(IG::ApplicationContext ctx, IG::CStringView palPath) { @@ -346,21 +347,19 @@ class CustomVideoOptionView : public VideoOptionView, public MainAppHelper return lastIndex(defaultPalItem); } - TextMenuItem defaultPalItem[8] + TextMenuItem defaultPalItem[9] { - {"FCEUX", attachParams(), [this](){ setPalette(appContext(), ""); }}, + {"FCEUX", attachParams(), [this]() { setPalette(appContext(), ""); }}, {"Digital Prime (FBX)", attachParams(), [this]() { setPalette(appContext(), digitalPrimePalPath); }}, - {"Smooth V2 (FBX)", attachParams(), [this]() { setPalette(appContext(), smoothPalPath); }}, - {"Magnum (FBX)", attachParams(), [this]() { setPalette(appContext(), magnumPalPath); }}, - {"Classic (FBX)", attachParams(), [this]() { setPalette(appContext(), classicPalPath); }}, - {"Wavebeam", attachParams(), [this]() { setPalette(appContext(), wavebeamPalPath); }}, - {"Lightful", attachParams(), [this]() { setPalette(appContext(), lightfulPalPath); }}, - {"Custom File", attachParams(), [this](TextMenuItem &, View &, Input::Event e) + {"Smooth V2 (FBX)", attachParams(), [this]() { setPalette(appContext(), smoothPalPath); }}, + {"Magnum (FBX)", attachParams(), [this]() { setPalette(appContext(), magnumPalPath); }}, + {"Classic (FBX)", attachParams(), [this]() { setPalette(appContext(), classicPalPath); }}, + {"Wavebeam", attachParams(), [this]() { setPalette(appContext(), wavebeamPalPath); }}, + {"Lightful", attachParams(), [this]() { setPalette(appContext(), lightfulPalPath); }}, + {"Palightful", attachParams(), [this]() { setPalette(appContext(), palightfulPalPath); }}, + {"Custom File", attachParams(), [this](Input::Event e) { - auto fsFilter = [](std::string_view name) - { - return IG::endsWithAnyCaseless(name, ".pal"); - }; + auto fsFilter = [](std::string_view name) { return endsWithAnyCaseless(name, ".pal"); }; auto fPicker = makeView(FSPicker::Mode::FILE, fsFilter, e, false); fPicker->setOnSelectPath( [this](FSPicker &picker, IG::CStringView path, std::string_view name, Input::Event) @@ -388,6 +387,7 @@ class CustomVideoOptionView : public VideoOptionView, public MainAppHelper if(system().defaultPalettePath == classicPalPath) return 4; if(system().defaultPalettePath == wavebeamPalPath) return 5; if(system().defaultPalettePath == lightfulPalPath) return 6; + if(system().defaultPalettePath == palightfulPalPath) return 7; return (int)defaultPaletteCustomFileIdx(); }(), defaultPalItem, diff --git a/PCE.emu/src/pce/huc6280.h b/PCE.emu/src/pce/huc6280.h index 77a87f001..3c8dea9fd 100644 --- a/PCE.emu/src/pce/huc6280.h +++ b/PCE.emu/src/pce/huc6280.h @@ -15,14 +15,14 @@ class alignas(128) HuC6280 typedef uint8 (MDFN_FASTCALL *readfunc)(uint32 A); typedef int32 (MDFN_FASTCALL *ehfunc)(const int32 timestamp); - enum { N_FLAG = 0x80 }; - enum { V_FLAG = 0x40 }; - enum { T_FLAG = 0x20 }; - enum { B_FLAG = 0x10 }; - enum { D_FLAG = 0x08 }; - enum { I_FLAG = 0x04 }; - enum { Z_FLAG = 0x02 }; - enum { C_FLAG = 0x01 }; + static constexpr unsigned N_FLAG = 0x80; + static constexpr unsigned V_FLAG = 0x40; + static constexpr unsigned T_FLAG = 0x20; + static constexpr unsigned B_FLAG = 0x10; + static constexpr unsigned D_FLAG = 0x08; + static constexpr unsigned I_FLAG = 0x04; + static constexpr unsigned Z_FLAG = 0x02; + static constexpr unsigned C_FLAG = 0x01; // If emulate_wai is true, then the "0xCB" opcode will be handled by waiting for the next high-level event, NOT // for the IRQ line to be asserted as on a 65816. @@ -35,10 +35,10 @@ class alignas(128) HuC6280 void Reset(void) MDFN_COLD; void Power(void) MDFN_COLD; - enum { IQIRQ1 = 0x002 }; - enum { IQIRQ2 = 0x001 }; - enum { IQTIMER = 0x004 }; - enum { IQRESET = 0x020 }; + static constexpr unsigned IQIRQ1 = 0x002; + static constexpr unsigned IQIRQ2 = 0x001; + static constexpr unsigned IQTIMER = 0x004; + static constexpr unsigned IQRESET = 0x020; INLINE void IRQBegin(int w) { diff --git a/Saturn.emu/src/ss/sh7095.h b/Saturn.emu/src/ss/sh7095.h index 2eb8e994a..56c2744f7 100644 --- a/Saturn.emu/src/ss/sh7095.h +++ b/Saturn.emu/src/ss/sh7095.h @@ -117,8 +117,7 @@ class SH7095 final INLINE uint64 GetMAC64(void) { return MACL | ((uint64)MACH << 32); } INLINE void SetMAC64(uint64 nv) { MACL = nv; MACH = nv >> 32; } - enum // must be in range of 0 ... 7 - { + static constexpr int // must be in range of 0 ... 7 PEX_POWERON = 0, PEX_RESET = 1, PEX_CPUADDR = 2, @@ -126,10 +125,9 @@ class SH7095 final PEX_INT = 4, PEX_NMI = 5, PEX_PSEUDO_DMABURST = 6, - PEX_PSEUDO_EXTHALT = 7 - }; - enum { EPENDING_PEXBITS_SHIFT = 16 }; - enum { EPENDING_OP_OR = 0xFF000000 }; + PEX_PSEUDO_EXTHALT = 7; + static constexpr int EPENDING_PEXBITS_SHIFT = 16; + static constexpr unsigned EPENDING_OP_OR = 0xFF000000; uint32 EPending; diff --git a/Saturn.emu/src/ss/ss.cpp b/Saturn.emu/src/ss/ss.cpp index 0342be275..659ef30ca 100644 --- a/Saturn.emu/src/ss/ss.cpp +++ b/Saturn.emu/src/ss/ss.cpp @@ -1955,8 +1955,8 @@ static MDFN_COLD void LoadRTC(void) struct EventsPacker { - enum : size_t { eventcopy_first = SS_EVENT__SYNFIRST + 1 }; - enum : size_t { eventcopy_bound = SS_EVENT__SYNLAST }; + static constexpr size_t eventcopy_first = SS_EVENT__SYNFIRST + 1; + static constexpr size_t eventcopy_bound = SS_EVENT__SYNLAST; bool Restore(const unsigned state_version); void Save(void); diff --git a/Saturn.emu/src/ss/ss.h b/Saturn.emu/src/ss/ss.h index eaf4bd4db..72b94995c 100644 --- a/Saturn.emu/src/ss/ss.h +++ b/Saturn.emu/src/ss/ss.h @@ -30,8 +30,7 @@ using namespace Mednafen; namespace MDFN_IEN_SS { - enum - { + constexpr unsigned SS_DBG_ERROR = (1U << 0), SS_DBG_WARNING = (1U << 1), @@ -69,8 +68,7 @@ namespace MDFN_IEN_SS SS_DBG_SCSP = (1U << 26), SS_DBG_SCSP_REGW = (1U << 27), - SS_DBG_SCSP_MOBUF= (1U << 28), - }; + SS_DBG_SCSP_MOBUF= (1U << 28); #ifdef MDFN_ENABLE_DEV_BUILD MDFN_HIDE extern uint32 ss_dbg_mask; #else diff --git a/Saturn.emu/src/ss/vdp1_common.h b/Saturn.emu/src/ss/vdp1_common.h index 467d9e7f2..07f440b5e 100644 --- a/Saturn.emu/src/ss/vdp1_common.h +++ b/Saturn.emu/src/ss/vdp1_common.h @@ -53,10 +53,10 @@ MDFN_HIDE extern int32 LocalX, LocalY; MDFN_HIDE extern uint32 (MDFN_FASTCALL *const TexFetchTab[0x20])(uint32 x); -enum { TVMR_8BPP = 0x1 }; -enum { TVMR_ROTATE = 0x2 }; -enum { TVMR_HDTV = 0x4 }; -enum { TVMR_VBE = 0x8 }; +constexpr unsigned TVMR_8BPP = 0x1; +constexpr unsigned TVMR_ROTATE = 0x2; +constexpr unsigned TVMR_HDTV = 0x4; +constexpr unsigned TVMR_VBE = 0x8; MDFN_HIDE extern uint8 TVMR; enum { FBCR_FCT = 0x01 }; // Frame buffer change trigger diff --git a/imagine/build.mk b/imagine/build.mk index 9d8f2ef20..46b6a4716 100644 --- a/imagine/build.mk +++ b/imagine/build.mk @@ -41,7 +41,7 @@ prefix ?= $(IMAGINE_SDK_PLATFORM_PATH) imaginePkgconfigTemplate := $(IMAGINE_PATH)/pkgconfig/imagine.pc pkgName := $(libName) pkgDescription := Game/Multimedia Engine -pkgVersion := 1.5.81 +pkgVersion := 1.5.82 LDLIBS := -l$(libName) $(LDLIBS) ifdef libNameExt pkgCFlags := -DIMAGINE_CONFIG_H=$(configFilename) diff --git a/imagine/bundle/all/src/freetype/common.mk b/imagine/bundle/all/src/freetype/common.mk deleted file mode 100644 index aad209df3..000000000 --- a/imagine/bundle/all/src/freetype/common.mk +++ /dev/null @@ -1,41 +0,0 @@ -ifndef CHOST - CHOST := $(shell $(CC) -dumpmachine) -endif - -freetypeVer := 2.4.11 -freetypeSrcDir := $(tempDir)/freetype-$(freetypeVer) -freetypeSrcArchive := freetype-$(freetypeVer).tar.bz2 - -makeFile := $(buildDir)/Makefile -outputLibFile := $(buildDir)/.libs/libfreetype.a -installIncludeDir := $(installDir)/include - -all : $(outputLibFile) - -$(freetypeSrcDir)/configure : | $(freetypeSrcArchive) - @echo "Extracting freetype..." - @mkdir -p $(freetypeSrcDir) - tar -mxjf $| -C $(freetypeSrcDir)/.. - cd $(freetypeSrcDir) && patch -p1 < ../freetype.patch - -install : $(outputLibFile) - @echo "Installing freetype to: $(installDir)" - @mkdir -p $(installIncludeDir) $(installDir)/lib/pkgconfig - cp $(outputLibFile) $(installDir)/lib/ - cp -r $(freetypeSrcDir)/include/* $(installIncludeDir)/ - cp $(buildDir)/freetype2.pc $(installDir)/lib/pkgconfig/ - -.PHONY : all install - -$(outputLibFile) : $(makeFile) - @echo "Building freetype..." - $(MAKE) -C $( #include #include +#include #include namespace IG::Audio @@ -79,11 +80,12 @@ using OutputStreamVariant = std::variant; NullOutputStream>; #endif -class OutputStream : public OutputStreamVariant +class OutputStream : public OutputStreamVariant, public AddVisit { public: using OutputStreamVariant::OutputStreamVariant; using OutputStreamVariant::operator=; + using AddVisit::visit; constexpr OutputStream(): OutputStreamVariant{std::in_place_type} {} void setApi(const Manager &, Api api = Api::DEFAULT); diff --git a/imagine/include/imagine/base/BaseApplication.hh b/imagine/include/imagine/base/BaseApplication.hh index 47594be50..023c19f3b 100644 --- a/imagine/include/imagine/base/BaseApplication.hh +++ b/imagine/include/imagine/base/BaseApplication.hh @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/imagine/include/imagine/base/FrameTimerInterface.hh b/imagine/include/imagine/base/FrameTimerInterface.hh index 33be358b3..149de631a 100644 --- a/imagine/include/imagine/base/FrameTimerInterface.hh +++ b/imagine/include/imagine/base/FrameTimerInterface.hh @@ -23,14 +23,15 @@ namespace IG { template -class FrameTimerInterface : public VariantBase +class FrameTimerInterface : public VariantBase, public AddVisit { public: using VariantBase::VariantBase; + using AddVisit::visit; - void scheduleVSync() { visit([](auto &e){ e.scheduleVSync(); }, *this); } - void cancel() { visit([](auto &e){ e.cancel(); }, *this); } - void setFrameRate(FrameRate rate) { visit([&](auto &e){ e.setFrameRate(rate); }, *this); } + void scheduleVSync() { visit([](auto &e){ e.scheduleVSync(); }); } + void cancel() { visit([](auto &e){ e.cancel(); }); } + void setFrameRate(FrameRate rate) { visit([&](auto &e){ e.setFrameRate(rate); }); } }; } diff --git a/imagine/include/imagine/config/version.h b/imagine/include/imagine/config/version.h index a03126571..92c68ed51 100755 --- a/imagine/include/imagine/config/version.h +++ b/imagine/include/imagine/config/version.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with Imagine. If not, see */ -#define IMAGINE_VERSION_BASE "1.5.81" +#define IMAGINE_VERSION_BASE "1.5.82" #ifdef NDEBUG #define IMAGINE_VERSION IMAGINE_VERSION_BASE diff --git a/imagine/include/imagine/gui/MenuItem.hh b/imagine/include/imagine/gui/MenuItem.hh index e82f75fc8..7cabc9ec3 100644 --- a/imagine/include/imagine/gui/MenuItem.hh +++ b/imagine/include/imagine/gui/MenuItem.hh @@ -16,14 +16,12 @@ along with Imagine. If not, see */ #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -36,6 +34,21 @@ class Event; namespace IG { +template +constexpr bool callAndAutoReturnTrue(Func& f, Args&&... args) +{ + if constexpr(VoidInvokeResult) + { + // auto-return true if the supplied function doesn't return a value + f(std::forward(args)...); + return true; + } + else + { + return f(std::forward(args)...); + } +} + template class MenuItemSelectDelegate : public DelegateFunc { @@ -49,58 +62,44 @@ public: constexpr MenuItemSelectDelegate(Callable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f, i, v, e); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f, i, v, e); } } {} constexpr MenuItemSelectDelegate(std::invocable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f, i, e); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f, i, e); } } {} constexpr MenuItemSelectDelegate(std::invocable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f, v, e); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f, v, e); } } {} constexpr MenuItemSelectDelegate(std::invocable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f, i); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f, i); } } {} constexpr MenuItemSelectDelegate(std::invocable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f, v); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f, v); } } {} constexpr MenuItemSelectDelegate(std::invocable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f, e); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f, e); } } {} constexpr MenuItemSelectDelegate(std::invocable auto &&f): DelegateFuncBase { - [=](Item &i, View &v, const Input::Event &e) { return callAndReturnBool(f); } + [=](Item &i, View &v, const Input::Event &e) { return callAndAutoReturnTrue(f); } } {} - - constexpr static bool callAndReturnBool(auto &f, auto &&...args) - { - if constexpr(VoidInvokeResult) - { - // auto-return true if the supplied function doesn't return a value - f(IG_forward(args)...); - return true; - } - else - { - return f(IG_forward(args)...); - } - } }; struct MenuItemFlags diff --git a/imagine/include/imagine/gui/View.hh b/imagine/include/imagine/gui/View.hh index 2ee9d62b4..2718de3c8 100644 --- a/imagine/include/imagine/gui/View.hh +++ b/imagine/include/imagine/gui/View.hh @@ -16,7 +16,6 @@ along with Imagine. If not, see */ #include -#include #include #include #include diff --git a/imagine/include/imagine/gui/ViewAttachParams.hh b/imagine/include/imagine/gui/ViewAttachParams.hh deleted file mode 100644 index a330f4beb..000000000 --- a/imagine/include/imagine/gui/ViewAttachParams.hh +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -/* This file is part of Imagine. - - Imagine is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Imagine is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Imagine. If not, see */ - -namespace IG -{ -class Window; -class ApplicationContext; -} - -namespace IG::Gfx -{ -class Renderer; -class RendererTask; -} - -namespace IG -{ - -class ViewManager; - -struct ViewAttachParams -{ - ViewManager &viewManager; - Window &window; - Gfx::RendererTask &rendererTask; - - Gfx::Renderer &renderer() const; - ApplicationContext appContext() const; -}; - -} diff --git a/imagine/include/imagine/gui/viewDefs.hh b/imagine/include/imagine/gui/viewDefs.hh index 270015b24..1cf1c29f7 100644 --- a/imagine/include/imagine/gui/viewDefs.hh +++ b/imagine/include/imagine/gui/viewDefs.hh @@ -33,13 +33,24 @@ constexpr auto imageSamplerConfig = Gfx::SamplerConfigs::nearestMipClamp; namespace IG { +class ApplicationContext; +class Window; class View; class ViewController; -struct ViewAttachParams; class ViewManager; class TableView; class MenuItem; +struct ViewAttachParams +{ + ViewManager &viewManager; + Window &window; + Gfx::RendererTask &rendererTask; + + Gfx::Renderer &renderer() const; + ApplicationContext appContext() const; +}; + struct TableUIState { int highlightedCell{-1}; diff --git a/imagine/include/imagine/input/Device.hh b/imagine/include/imagine/input/Device.hh index 99ec2b867..1f572f274 100644 --- a/imagine/include/imagine/input/Device.hh +++ b/imagine/include/imagine/input/Device.hh @@ -84,11 +84,12 @@ AppleGameDevice, NullDevice >; -class Device : public DeviceVariant +class Device : public DeviceVariant, public AddVisit { public: using Subtype = DeviceSubtype; using DeviceVariant::DeviceVariant; + using AddVisit::visit; bool hasKeyboard() const { return typeFlags().keyboard; } bool hasGamepad() const { return typeFlags().gamepad; } @@ -128,10 +129,10 @@ public: return k; } - int id() const { return visit([](auto &d){ return d.id_; }, *this); } - uint8_t enumId() const { return visit([](auto &d){ return d.enumId_; }, *this); } - void setEnumId(uint8_t id) { visit([&](auto &d){ d.enumId_ = id; }, *this); } - std::string_view name() const { return visit([](auto &d){ return std::string_view{d.name_}; }, *this); } + int id() const { return visit([](auto &d){ return d.id_; }); } + uint8_t enumId() const { return visit([](auto &d){ return d.enumId_; }); } + void setEnumId(uint8_t id) { visit([&](auto &d){ d.enumId_ = id; }); } + std::string_view name() const { return visit([](auto &d){ return std::string_view{d.name_}; }); } Map map() const; DeviceTypeFlags typeFlags() const { @@ -141,10 +142,10 @@ public: if(iCadeMode()) flags.gamepad = true; return flags; - }, *this); + }); } - Subtype subtype() const { return visit([](auto &d){ return d.subtype_; }, *this); } - void setSubtype(Subtype s) { visit([&](auto &d){ d.subtype_ = s; }, *this); } + Subtype subtype() const { return visit([](auto &d){ return d.subtype_; }); } + void setSubtype(Subtype s) { visit([&](auto &d){ d.subtype_ = s; }); } bool operator==(Device const&) const = default; void setJoystickAxesAsKeys(AxisSetId, bool on); bool joystickAxesAsKeys(AxisSetId); @@ -159,7 +160,7 @@ public: template T &makeAppData(auto &&...args) { - auto &appDataPtr = visit([&](auto &d) -> auto& { return d.appDataPtr; }, *this); + auto &appDataPtr = visit([&](auto &d) -> auto& { return d.appDataPtr; }); appDataPtr = std::make_shared(IG_forward(args)...); return *appData(); } @@ -167,7 +168,7 @@ public: template T *appData() const { - return visit([&](auto &d){ return static_cast(d.appDataPtr.get()); }, *this); + return visit([&](auto &d){ return static_cast(d.appDataPtr.get()); }); } // optional API @@ -179,7 +180,7 @@ public: return d.motionAxes(); else return std::span{}; - }, *this); + }); } const char *keyName(Key k) const; void setICadeMode(bool on); diff --git a/imagine/include/imagine/input/Event.hh b/imagine/include/imagine/input/Event.hh index 5b742f4e8..5be441532 100755 --- a/imagine/include/imagine/input/Event.hh +++ b/imagine/include/imagine/input/Event.hh @@ -156,15 +156,16 @@ protected: using EventVariant = std::variant; -class Event : public EventVariant +class Event : public EventVariant, public AddVisit { public: using EventVariant::EventVariant; + using AddVisit::visit; constexpr auto motionEvent(this auto&& self) { return std::get_if(&self); } constexpr auto keyEvent(this auto&& self) { return std::get_if(&self); } - constexpr auto state() const { return visit([](auto &e){ return e.state(); }, *this); } - constexpr auto metaKeyBits() const { return visit([](auto &e){ return e.metaKeyBits(); }, *this); } + constexpr auto state() const { return visit([](auto &e){ return e.state(); }); } + constexpr auto metaKeyBits() const { return visit([](auto &e){ return e.metaKeyBits(); }); } SteadyClockTimePoint time() const; const Device *device() const; diff --git a/imagine/include/imagine/io/IO.hh b/imagine/include/imagine/io/IO.hh index 9be690136..6a3f41046 100644 --- a/imagine/include/imagine/io/IO.hh +++ b/imagine/include/imagine/io/IO.hh @@ -21,6 +21,7 @@ #ifdef __ANDROID__ #include #endif +#include #include #include #include @@ -36,11 +37,12 @@ AAssetIO, #endif ArchiveIO>; -class IO : public IOVariant, public IOUtils +class IO : public IOVariant, public IOUtils, public AddVisit { public: using IOVariant::IOVariant; using IOVariant::operator=; + using AddVisit::visit; using IOUtilsBase = IOUtils; using IOUtilsBase::read; using IOUtilsBase::write; diff --git a/imagine/include/imagine/util/DelegateFunc.hh b/imagine/include/imagine/util/DelegateFunc.hh index 33e7722f9..4f2dbeb0e 100644 --- a/imagine/include/imagine/util/DelegateFunc.hh +++ b/imagine/include/imagine/util/DelegateFunc.hh @@ -16,7 +16,7 @@ along with Imagine. If not, see */ #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ public: { [](const Storage &funcObj, Args ...args) -> R { - return ((F*)funcObj.data())->operator()(IG_forward(args)...); + return ((F*)funcObj.data())->operator()(std::forward(args)...); } } { @@ -64,7 +64,7 @@ public: { [](const Storage &funcObj, Args ...args) -> R { - return (*((FreeFuncPtr*)funcObj.data()))(IG_forward(args)...); + return (*((FreeFuncPtr*)funcObj.data()))(std::forward(args)...); } } { @@ -78,33 +78,37 @@ public: return exec; } - constexpr R operator()(auto &&...args) const - requires ValidInvokeArgs + template + constexpr R operator()(CallArgs&&... args) const + requires ValidInvokeArgs { assert(exec); - return exec(store, IG_forward(args)...); + return exec(store, std::forward(args)...); } constexpr bool operator ==(DelegateFuncBase const&) const = default; - constexpr R callCopy(auto &&...args) const + template + constexpr R callCopy(CallArgs&&... args) const { // Call a copy to avoid trashing captured variables // if delegate's function can modify the delegate - return ({auto copy = *this; copy;})(IG_forward(args)...); + return ({auto copy = *this; copy;})(std::forward(args)...); } - constexpr R callSafe(auto &&...args) const + template + constexpr R callSafe(CallArgs&&... args) const { if(exec) - return this->operator()(IG_forward(args)...); + return this->operator()(std::forward(args)...); return R(); } - constexpr R callCopySafe(auto &&...args) const + template + constexpr R callCopySafe(CallArgs&&... args) const { if(exec) - return callCopy(IG_forward(args)...); + return callCopy(std::forward(args)...); return R(); } diff --git a/imagine/include/imagine/util/variant.hh b/imagine/include/imagine/util/variant.hh index 32dee727b..06ec4a26a 100644 --- a/imagine/include/imagine/util/variant.hh +++ b/imagine/include/imagine/util/variant.hh @@ -29,7 +29,7 @@ template overloaded(Ts&&...) -> overloaded...>; // TODO: remove when clang implements a similar optimization, // currently Clang 14's libc++ uses a function jump table that prevents inline optimization template, auto vSize = std::variant_size_v> -constexpr decltype(auto) visitVariant(auto &&func, Variant &v) +constexpr decltype(auto) visitVariant(auto&& func, Variant& v) requires (vSize <= 16) { #define VISIT_CASE(i) case i: \ @@ -60,26 +60,38 @@ constexpr decltype(auto) visitVariant(auto &&func, Variant &v) } template -constexpr decltype(auto) asVariant(std::variant &v) noexcept { return v; } +constexpr decltype(auto) asVariant(std::variant& v) noexcept { return v; } template -constexpr decltype(auto) asVariant(const std::variant &v) noexcept { return v; } +constexpr decltype(auto) asVariant(const std::variant& v) noexcept { return v; } template -constexpr decltype(auto) asVariant(std::variant &&v) noexcept { return std::move(v); } +constexpr decltype(auto) asVariant(std::variant&& v) noexcept { return std::move(v); } template -constexpr decltype(auto) asVariant(const std::variant &&v) noexcept { return std::move(v); } +constexpr decltype(auto) asVariant(const std::variant&& v) noexcept { return std::move(v); } // visit a std::variant or object derived from std::variant -constexpr decltype(auto) visit(auto &&func, auto &v) +template +constexpr decltype(auto) visit(Func&& func, auto& v) { - return visitVariant(std::forward(func), - asVariant(std::forward(v))); + return visitVariant(std::forward(func), asVariant(v)); } +class AddVisit +{ +public: + template + constexpr decltype(auto) visit(this auto&& self, Func&& func) + { + return IG::visit(std::forward(func), asVariant(self)); + } + + bool operator==(AddVisit const&) const = default; +}; + template -constexpr T& getAs(std::variant &v) +constexpr T& getAs(std::variant& v) { auto vPtr = std::get_if(&v); assumeExpr(vPtr); @@ -87,7 +99,7 @@ constexpr T& getAs(std::variant &v) } template -constexpr const T& getAs(const std::variant &v) +constexpr const T& getAs(const std::variant& v) { auto vPtr = std::get_if(&v); assumeExpr(vPtr); diff --git a/imagine/make/gcc-common.mk b/imagine/make/gcc-common.mk index ad9e31541..18bd9f9b1 100644 --- a/imagine/make/gcc-common.mk +++ b/imagine/make/gcc-common.mk @@ -8,7 +8,7 @@ CFLAGS_OPTIMIZE_LEVEL_RELEASE_DEFAULT ?= -Ofast CFLAGS_OPTIMIZE_RELEASE_DEFAULT ?= $(CFLAGS_OPTIMIZE_LEVEL_RELEASE_DEFAULT) $(CFLAGS_OPTIMIZE_MISC_RELEASE_DEFAULT) CFLAGS_CODEGEN += -pipe -fvisibility=hidden -ffunction-sections -fdata-sections CFLAGS_LANG = -fno-common -CXXFLAGS_LANG = -std=gnu++2b $(if $(cxxThreadSafeStatics),,-fno-threadsafe-statics) -fvisibility-inlines-hidden +CXXFLAGS_LANG = -std=gnu++26 $(if $(cxxThreadSafeStatics),,-fno-threadsafe-statics) -fvisibility-inlines-hidden ifeq ($(ENV), ios) ifeq ($(SUBARCH), armv7) @@ -19,7 +19,6 @@ endif # setup warnings CFLAGS_WARN ?= -Wall -Wextra -Werror=return-type -Wno-comment -Wno-unused -Wno-unused-parameter -CFLAGS_WARN += $(CFLAGS_WARN_EXTRA) CXXFLAGS_WARN ?= $(CFLAGS_WARN) -Woverloaded-virtual # setup optimizations diff --git a/imagine/make/gcc-link.mk b/imagine/make/gcc-link.mk index 117c9e24b..2410a4e23 100755 --- a/imagine/make/gcc-link.mk +++ b/imagine/make/gcc-link.mk @@ -1,4 +1,4 @@ -LD := $(CXX) +LD = $(CXX) ifdef LINK_MAP MAPFILE := link.map diff --git a/imagine/make/package/freetype.mk b/imagine/make/package/freetype.mk index e1bb7d3dd..6ffc48c9e 100644 --- a/imagine/make/package/freetype.mk +++ b/imagine/make/package/freetype.mk @@ -1,15 +1,6 @@ ifndef inc_pkg_freetype inc_pkg_freetype := 1 -ifeq ($(ENV), webos) - CPPFLAGS += -I$(WEBOS_PDK_PATH)/include/freetype2 - LDLIBS += -lfreetype -else ifeq ($(ENV), macosx) - # MacPorts version - CPPFLAGS += -I/opt/local/include/freetype2 - LDLIBS += /opt/local/lib/libfreetype.a -lz -else - pkgConfigDeps += freetype2 -endif +pkgConfigDeps += freetype2 endif \ No newline at end of file diff --git a/imagine/src/audio/OutputStream.cc b/imagine/src/audio/OutputStream.cc index 34e3d6597..9882362ef 100644 --- a/imagine/src/audio/OutputStream.cc +++ b/imagine/src/audio/OutputStream.cc @@ -46,13 +46,13 @@ void OutputStream::setApi(const Manager &mgr, Api api) } } -StreamError OutputStream::open(OutputStreamConfig config) { return visit([&](auto &v){ return v.open(config); }, *this); } -void OutputStream::play() { visit([&](auto &v){ v.play(); }, *this); } -void OutputStream::pause() { visit([&](auto &v){ v.pause(); }, *this); } -void OutputStream::close() { visit([&](auto &v){ v.close(); }, *this); } -void OutputStream::flush() { visit([&](auto &v){ v.flush(); }, *this); } -bool OutputStream::isOpen() { return visit([&](auto &v){ return v.isOpen(); }, *this); } -bool OutputStream::isPlaying() { return visit([&](auto &v){ return v.isPlaying(); }, *this); } +StreamError OutputStream::open(OutputStreamConfig config) { return visit([&](auto &v){ return v.open(config); }); } +void OutputStream::play() { visit([&](auto &v){ v.play(); }); } +void OutputStream::pause() { visit([&](auto &v){ v.pause(); }); } +void OutputStream::close() { visit([&](auto &v){ v.close(); }); } +void OutputStream::flush() { visit([&](auto &v){ v.flush(); }); } +bool OutputStream::isOpen() { return visit([&](auto &v){ return v.isOpen(); }); } +bool OutputStream::isPlaying() { return visit([&](auto &v){ return v.isPlaying(); }); } void OutputStream::reset() { emplace(); } OutputStreamConfig Manager::makeNativeOutputStreamConfig() const diff --git a/imagine/src/base/common/Window.cc b/imagine/src/base/common/Window.cc index 1d1b802d8..546b20aa4 100644 --- a/imagine/src/base/common/Window.cc +++ b/imagine/src/base/common/Window.cc @@ -229,13 +229,13 @@ void Window::drawNow(bool needsSync) bool Window::dispatchInputEvent(Input::Event event) { bool handled = onEvent.callCopy(*this, event); - return visit(overloaded{ + return event.visit(overloaded{ [&](const Input::MotionEvent &e) { return handled || (e.isPointer() && contentBounds().overlaps(e.pos())); }, [&](const Input::KeyEvent &e) { return handled; } - }, event); + }); } bool Window::dispatchRepeatableKeyInputEvent(Input::KeyEvent event) diff --git a/imagine/src/input/Device.cc b/imagine/src/input/Device.cc index 3bdfd56a7..b3ba6338c 100644 --- a/imagine/src/input/Device.cc +++ b/imagine/src/input/Device.cc @@ -315,7 +315,7 @@ void Device::setICadeMode(bool on) { if constexpr(requires {d.setICadeMode(on);}) d.setICadeMode(on); - }, *this); + }); } bool Device::iCadeMode() const @@ -326,7 +326,7 @@ bool Device::iCadeMode() const return d.iCadeMode(); else return false; - }, *this); + }); } void Device::setJoystickAxesAsKeys(AxisSetId id, bool on) @@ -361,7 +361,7 @@ const char *Device::keyName(Key k) const return d.keyName(k); else return nullptr; - }, *this); + }); if(customName) return customName; switch(map()) @@ -420,7 +420,7 @@ std::string Device::keyString(Key k, KeyNameFlags flags) const Map Device::map() const { - return visit([](auto &d){ return d.map_; }, *this); + return visit([](auto &d){ return d.map_; }); } static DeviceSubtype gamepadSubtype(std::string_view name) diff --git a/imagine/src/input/Event.cc b/imagine/src/input/Event.cc index fa8ceb53e..708357cef 100644 --- a/imagine/src/input/Event.cc +++ b/imagine/src/input/Event.cc @@ -356,8 +356,8 @@ bool KeyEvent::hasSwappedConfirmKeys() const return keyFlags; // currently there is only a single flag } -SteadyClockTimePoint Event::time() const { return visit([](auto &e){ return e.time(); }, *this); } +SteadyClockTimePoint Event::time() const { return visit([](auto &e){ return e.time(); }); } -const Device *Event::device() const { return visit([](auto &e){ return e.device(); }, *this); } +const Device *Event::device() const { return visit([](auto &e){ return e.device(); }); } } diff --git a/imagine/src/io/IO.cc b/imagine/src/io/IO.cc index 60eab6002..53d34b07e 100644 --- a/imagine/src/io/IO.cc +++ b/imagine/src/io/IO.cc @@ -27,18 +27,18 @@ template class IOUtils; ssize_t IO::read(void *buff, size_t bytes, std::optional offset) { - return visit([&](auto &io){ return io.read(buff, bytes, offset); }, *this); + return visit([&](auto &io){ return io.read(buff, bytes, offset); }); } ssize_t IO::write(const void *buff, size_t bytes, std::optional offset) { - return visit([&](auto &io){ return io.write(buff, bytes, offset); }, *this); + return visit([&](auto &io){ return io.write(buff, bytes, offset); }); } -off_t IO::seek(off_t offset, IOSeekMode mode) { return visit([&](auto &io){ return io.seek(offset, mode); }, *this); } -size_t IO::size() { return visit([&](auto &io){ return io.size(); }, *this); } -bool IO::eof() { return visit([&](auto &io){ return io.eof(); }, *this); } -IO::operator bool() const { return visit([&](auto &io){ return (bool)io; }, *this); } +off_t IO::seek(off_t offset, IOSeekMode mode) { return visit([&](auto &io){ return io.seek(offset, mode); }); } +size_t IO::size() { return visit([&](auto &io){ return io.size(); }); } +bool IO::eof() { return visit([&](auto &io){ return io.eof(); }); } +IO::operator bool() const { return visit([&](auto &io){ return (bool)io; }); } std::span IO::map() { @@ -48,7 +48,7 @@ std::span IO::map() return io.map(); else return std::span{}; - }, *this); + }); }; ssize_t IO::writeVector(std::span buffs, std::optional offset) @@ -59,7 +59,7 @@ ssize_t IO::writeVector(std::span buffs, std::optional o return io.writeVector(buffs, offset); else return io.genericWriteVector(buffs, offset); - }, *this); + }); } bool IO::truncate(off_t offset) @@ -70,7 +70,7 @@ bool IO::truncate(off_t offset) return io.truncate(offset); else return false; - }, *this); + }); }; void IO::sync() @@ -79,7 +79,7 @@ void IO::sync() { if constexpr(requires {io.sync();}) io.sync(); - }, *this); + }); } void IO::advise(off_t offset, size_t bytes, Advice advice) @@ -88,7 +88,7 @@ void IO::advise(off_t offset, size_t bytes, Advice advice) { if constexpr(requires {io.advise(offset, bytes, advice);}) return io.advise(offset, bytes, advice); - }, *this); + }); } } diff --git a/imagine/tests/FrameRateTest/src/main/main.cc b/imagine/tests/FrameRateTest/src/main/main.cc index 3490f0cad..4bf4a33e7 100755 --- a/imagine/tests/FrameRateTest/src/main/main.cc +++ b/imagine/tests/FrameRateTest/src/main/main.cc @@ -233,7 +233,7 @@ void FrameRateTestApplication::setActiveTestHandlers(IG::Window &win) [&](Input::Event &e) { auto &activeTest = windowData(win).activeTest; - return visit(overloaded + return e.visit(overloaded { [&](const Input::MotionEvent &motionEv) { @@ -261,7 +261,7 @@ void FrameRateTestApplication::setActiveTestHandlers(IG::Window &win) } return false; } - }, e); + }); }, [](auto &){ return false; } }, winEvent);