From a0c03a5194d5a36ceb9ca4c68b79e4c097ba7d0c Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 18 Jul 2026 13:08:45 +0100 Subject: [PATCH 1/3] Save-state: Prevent strings with backslashes being doubled a 2nd time. (#1510) --- source/YamlHelper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/YamlHelper.cpp b/source/YamlHelper.cpp index b738f98be..c119332f4 100644 --- a/source/YamlHelper.cpp +++ b/source/YamlHelper.cpp @@ -522,7 +522,9 @@ void YamlSaveHelper::SaveString(const char* key, const char* value) } // A string in quotes needs double-backslashes, otherwise backslash treated as an escape-character (GH#1499) - if (std::string(m_pMbStr).find("\\") != std::string::npos) + // . Instead of special-casing quoted-strings, just double-up the backslashes for all strings (to reduce test cases) + if (std::string(m_pMbStr).find("\\") != std::string::npos && // String contains a backslash? + std::string(m_pMbStr).find("\\\\") == std::string::npos) // and backslashes haven't been already doubled { std::string str(m_pMbStr); size_t pos = 0; From d5db8e84a64134a5a23dc9475bafe42d6b677ea2 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 18 Jul 2026 15:42:12 +0100 Subject: [PATCH 2/3] AY: support empty socket AY regs: ENABLE(bits 7-6), PORTA, PORTB: support depends on AY chip type Add cmd line: -sN ay-socketX Save-state: Mockingboard v15: add type for AY/YM --- source/AY8910.cpp | 68 ++++++++++++++++++++++++++++++++++--- source/AY8910.h | 8 ++++- source/CmdLine.cpp | 25 ++++++++++++-- source/CmdLine.h | 3 ++ source/Common.h | 4 +++ source/Mockingboard.cpp | 41 ++++++++++++++++------ source/Mockingboard.h | 3 +- source/Windows/AppleWin.cpp | 8 ++++- 8 files changed, 141 insertions(+), 19 deletions(-) diff --git a/source/AY8910.cpp b/source/AY8910.cpp index 54a4729e7..187e89bb3 100644 --- a/source/AY8910.cpp +++ b/source/AY8910.cpp @@ -124,6 +124,7 @@ AY8913::AY8913() memset(sound_ay_registers, 0, sizeof(sound_ay_registers)); init(); m_fCurrentCLK_AY8910 = g_fCurrentCLK6502; + m_type = AY_3_8913; }; @@ -763,8 +764,24 @@ BYTE AY8913::sound_ay_read( int reg ) case 10: val &= 31; break; + case 7: // ENABLE + if (m_type == AY_3_8912) + val &= 0x7f; + if (m_type == AY_3_8913) + val &= 0x3f; + break; + case 14: // PORTA + if (m_type == AY_3_8913) + val = 14; // reg doesn't exist, so bus just returns reg number + break; + case 15: // PORTB + if (m_type == AY_3_8912 || m_type == AY_3_8913) + val = 15; // reg doesn't exist, so bus just returns reg number } + if (m_type == AY_Empty) + val = 0xff; + return val; } @@ -776,6 +793,9 @@ BYTE AY8913::sound_ay_read( int reg ) */ void AY8913::sound_ay_write( int reg, int val, libspectrum_dword now ) { + if (m_type == AY_Empty) + return; + if( ay_change_count < AY_CHANGE_MAX ) { ay_change[ ay_change_count ].tstates = now; ay_change[ ay_change_count ].reg = ( reg & 15 ); @@ -1009,8 +1029,10 @@ sound_beeper( int is_tape, int on ) // -#define SS_YAML_KEY_AY8910 "AY8910" +#define SS_YAML_KEY_AY8910_v14 "AY8910" // v14 +#define SS_YAML_KEY_AY891x "AY891x" // v15+ +#define SS_YAML_KEY_TYPE "Type" // v15+ #define SS_YAML_KEY_TONE0_TICK "Tone0 Tick" #define SS_YAML_KEY_TONE1_TICK "Tone1 Tick" #define SS_YAML_KEY_TONE2_TICK "Tone2 Tick" @@ -1051,11 +1073,37 @@ sound_beeper( int is_tape, int on ) #define SS_YAML_KEY_CHANGE "Change" #define SS_YAML_VALUE_CHANGE_FORMAT "%d, %d, 0x%1X, 0x%02X" +std::string AY8913::Type2String() +{ + if (m_type == AY_Empty) return "Empty"; + if (m_type == AY_3_8910) return "AY-3-8910"; + if (m_type == AY_3_8912) return "AY-3-8912"; + if (m_type == AY_3_8913) return "AY-3-8913"; + if (m_type == YM2149F) return "YM2149F"; + _ASSERT(0); + return "AY-3-8913"; +} + +AY891xType AY8913::String2Type(std::string type) +{ + if (type == "Empty") return AY_Empty; + if (type == "AY-3-8910") return AY_3_8910; + if (type == "AY-3-8912") return AY_3_8912; + if (type == "AY-3-8913") return AY_3_8913; + if (type == "YM2149F") return YM2149F; + _ASSERT(0); + return AY_3_8913; +} + void AY8913::SaveSnapshot(YamlSaveHelper& yamlSaveHelper, const std::string& suffix) { - std::string unit = std::string(SS_YAML_KEY_AY8910) + suffix; + std::string unit = std::string(SS_YAML_KEY_AY891x) + suffix; YamlSaveHelper::Label label(yamlSaveHelper, "%s:\n", unit.c_str()); + yamlSaveHelper.SaveString(SS_YAML_KEY_TYPE, Type2String()); + if (m_type == AY_Empty) + return; + yamlSaveHelper.SaveUint(SS_YAML_KEY_TONE0_TICK, ay_tone_tick[0]); yamlSaveHelper.SaveUint(SS_YAML_KEY_TONE1_TICK, ay_tone_tick[1]); yamlSaveHelper.SaveUint(SS_YAML_KEY_TONE2_TICK, ay_tone_tick[2]); @@ -1106,12 +1154,24 @@ void AY8913::SaveSnapshot(YamlSaveHelper& yamlSaveHelper, const std::string& suf } } -bool AY8913::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, const std::string& suffix) +bool AY8913::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, const std::string& suffix, UINT version) { - std::string unit = std::string(SS_YAML_KEY_AY8910) + suffix; + std::string unit = (version >= 15 ? std::string(SS_YAML_KEY_AY891x) + : std::string(SS_YAML_KEY_AY8910_v14)) + suffix; if (!yamlLoadHelper.GetSubMap(unit)) throw std::runtime_error("Card: Expected key: " + unit); + m_type = AY_3_8913; + if (version >= 15) + { + m_type = String2Type(yamlLoadHelper.LoadString(SS_YAML_KEY_TYPE)); + if (m_type == AY_Empty) + { + yamlLoadHelper.PopMap(); + return true; + } + } + ay_tone_tick[0] = yamlLoadHelper.LoadUint(SS_YAML_KEY_TONE0_TICK); ay_tone_tick[1] = yamlLoadHelper.LoadUint(SS_YAML_KEY_TONE1_TICK); ay_tone_tick[2] = yamlLoadHelper.LoadUint(SS_YAML_KEY_TONE2_TICK); diff --git a/source/AY8910.h b/source/AY8910.h index cf3b2f8d8..6fb0442c4 100644 --- a/source/AY8910.h +++ b/source/AY8910.h @@ -1,5 +1,7 @@ #pragma once +enum AY891xType {AY_Empty, AY_3_8910, AY_3_8912, AY_3_8913, YM2149F, AY_Unknown}; + //------------------------------------- // FUSE stuff @@ -29,8 +31,11 @@ class AY8913 void SetFramesize(int frameSize) { sound_generator_framesiz = frameSize; } void SetSoundBuffers(INT16** buffers) { ppSoundBuffers = buffers; } static void SetCLK( double CLK ) { m_fCurrentCLK_AY8910 = CLK; } + void SetType(AY891xType type) { m_type = type; } + std::string Type2String(); + AY891xType String2Type(std::string type); void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper, const std::string& suffix); - bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, const std::string& suffix); + bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, const std::string& suffix, UINT version); private: void init(); @@ -72,6 +77,7 @@ class AY8913 int sound_generator_framesiz; int sound_generator_freq; unsigned int ay_tone_levels[16]; + AY891xType m_type; // Vars shared between all AY's static double m_fCurrentCLK_AY8910; diff --git a/source/CmdLine.cpp b/source/CmdLine.cpp index 39586d52c..a2d145762 100644 --- a/source/CmdLine.cpp +++ b/source/CmdLine.cpp @@ -274,12 +274,33 @@ bool ProcessCmdLine(LPSTR lpCmdLine) if (!CardInstanceExists(CT_VidHD)) g_cmdLine.slotInfo[slot].card = CT_VidHD; } + else if (strncmp(lpCmdLine, "ay-socket", 9) == 0 && + (lpCmdLine[9] >= '0' || lpCmdLine[9] <= '3') && // 0=bottom of MB-C card, 1=top of MB-C card, 2+3 for Phasor + lpCmdLine[10] == '=') + { + const BYTE socket = lpCmdLine[9] - '0'; + const LPSTR socketType = &lpCmdLine[11]; + AY891xType type = AY_Unknown; + if (strcmp(socketType, "empty") == 0) + type = AY_Empty; + else if (strcmp(socketType, "ay8910") == 0) + type = AY_3_8910; + else if (strcmp(socketType, "ay8912") == 0) + type = AY_3_8912; + else if (strcmp(socketType, "ay8913") == 0) + type = AY_3_8913; + else if (strcmp(socketType, "ym2149") == 0) + type = YM2149F; + g_cmdLine.slotInfo[slot].socketAY891x[socket] = type; + if (type == AY_Unknown) + LogFileOutput("Unsupported AY type: %s\n", socketType); + } else if (strncmp(lpCmdLine, "socket", 6) == 0 && (lpCmdLine[6] == '0' || lpCmdLine[6] == '1') && // 0=$Cs20(bottom of MB-C card), 1=$Cs40(top of MB-C card) lpCmdLine[7] == '=') { - BYTE socket = lpCmdLine[6] - '0'; - LPSTR socketType = &lpCmdLine[8]; + const BYTE socket = lpCmdLine[6] - '0'; + const LPSTR socketType = &lpCmdLine[8]; SSI263Type type = SSI263Unknown; if (strcmp(socketType, "empty") == 0) type = SSI263Empty; diff --git a/source/CmdLine.h b/source/CmdLine.h index ad975312d..bd8cc0279 100644 --- a/source/CmdLine.h +++ b/source/CmdLine.h @@ -6,6 +6,7 @@ #include "Common.h" #include "Card.h" #include "MockingboardDefs.h" +#include "AY8910.h" struct CmdLine { @@ -18,6 +19,7 @@ struct CmdLine useHdcFirmwareMode = HdcUndefinedFromCmdLine; useBad6522A = false; useBad6522B = false; + for (int i = 0; i < NUM_AY8913; i++) socketAY891x[i] = AY_Unknown; socketSSI263[0] = socketSSI263[1] = socketSC01 = SSI263Unknown; } @@ -26,6 +28,7 @@ struct CmdLine HdcMode useHdcFirmwareMode; bool useBad6522A; bool useBad6522B; + AY891xType socketAY891x[NUM_AY8913]; SSI263Type socketSSI263[NUM_SSI263]; SSI263Type socketSC01; }; diff --git a/source/Common.h b/source/Common.h index 488277d29..1b7e35f81 100644 --- a/source/Common.h +++ b/source/Common.h @@ -125,6 +125,10 @@ enum AppMode_e #define REGVALUE_LAST_DISK_1 "Last Disk Image 1" #define REGVALUE_LAST_DISK_2 "Last Disk Image 2" #define REGVALUE_LAST_HARDDISK_ "Last Harddisk Image " +#define REGVALUE_MOCKINGBOARD_AY_SOCKET0 "AY Socket 0" +#define REGVALUE_MOCKINGBOARD_AY_SOCKET1 "AY Socket 1" +#define REGVALUE_MOCKINGBOARD_AY_SOCKET2 "AY Socket 2" +#define REGVALUE_MOCKINGBOARD_AY_SOCKET3 "AY Socket 3" #define REGVALUE_MOCKINGBOARD_SSI263_SOCKET0 "SSI263 Socket 0" #define REGVALUE_MOCKINGBOARD_SSI263_SOCKET1 "SSI263 Socket 1" #define REGVALUE_MOCKINGBOARD_SC01 "SC01" diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index b8f984c88..8c2f80a8f 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -98,6 +98,9 @@ MockingboardCard::MockingboardCard(UINT slot, SS_CARDTYPE type) : Card(type, slo m_MBSubUnit[i].sy6522.InitSyncEvents(m_syncEvent[id0], m_syncEvent[id1]); m_MBSubUnit[i].ssi263.SetDevice(i); + // Load AY891x chip config from Registry + // TODO: do this when we can config the AYs via the Config GUI + // Load speech chip config from Registry uint32_t type; std::string regSection = RegGetConfigSlotSection(m_slot); @@ -130,6 +133,23 @@ MockingboardCard::~MockingboardCard() //--------------------------------------------------------------------------- +void MockingboardCard::SetSocketAY891x(BYTE socket, AY891xType type) +{ + UINT subUnit = socket & 1; + UINT ayUnit = socket < 2 ? 0 : 1; + m_MBSubUnit[subUnit].ay8913[ayUnit].SetType(type); + + std::string regSection = RegGetConfigSlotSection(m_slot); + if (socket == 0) + RegSaveValue(regSection.c_str(), REGVALUE_MOCKINGBOARD_AY_SOCKET0, true, type); + else if (socket == 1) + RegSaveValue(regSection.c_str(), REGVALUE_MOCKINGBOARD_AY_SOCKET1, true, type); + else if (socket == 2) + RegSaveValue(regSection.c_str(), REGVALUE_MOCKINGBOARD_AY_SOCKET2, true, type); + else + RegSaveValue(regSection.c_str(), REGVALUE_MOCKINGBOARD_AY_SOCKET3, true, type); +} + void MockingboardCard::SetSocketSSI263(BYTE socket, SSI263Type type) { m_MBSubUnit[socket].ssi263.SetType(type); @@ -1158,10 +1178,10 @@ UINT MockingboardCard::AY8910_SaveSnapshot(YamlSaveHelper& yamlSaveHelper, BYTE return 1; } -UINT MockingboardCard::AY8910_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, BYTE subunit, BYTE ay, const std::string& suffix) +UINT MockingboardCard::AY8910_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, BYTE subunit, BYTE ay, const std::string& suffix, UINT version) { _ASSERT(subunit < NUM_SUBUNITS_PER_MB && ay < NUM_AY8913_PER_SUBUNIT); - return m_MBSubUnit[subunit].ay8913[ay].LoadSnapshot(yamlLoadHelper, suffix) ? 1 : 0; + return m_MBSubUnit[subunit].ay8913[ay].LoadSnapshot(yamlLoadHelper, suffix, version) ? 1 : 0; } //============================================================================= @@ -1191,7 +1211,8 @@ UINT MockingboardCard::AY8910_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, BYTE //13: Removed SS_YAML_KEY_SSI263_ACTIVE_PHONEME // Removed SS_YAML_KEY_VOTRAX_PHONEME (as this has been present in the SC01 subunit since v12!) //14: Added: SSI263: Type -const UINT kUNIT_VERSION = 14; +//15: Added: AY891x: Type +const UINT kUNIT_VERSION = 15; #define SS_YAML_KEY_MB_UNIT "Unit" #define SS_YAML_KEY_AY_CURR_REG "AY Current Register" @@ -1306,7 +1327,7 @@ bool MockingboardCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version pMB->sy6522.LoadSnapshot(yamlLoadHelper, version); UpdateIFRandIRQ(pMB, 0, pMB->sy6522.GetReg(SY6522::rIFR)); // Assert any pending IRQs (GH#677) - AY8910_LoadSnapshot(yamlLoadHelper, subunit, AY8913_DEVICE_A, std::string("")); + AY8910_LoadSnapshot(yamlLoadHelper, subunit, AY8913_DEVICE_A, std::string(""), version); pMB->ssi263.LoadSnapshot(yamlLoadHelper, PH_Mockingboard, version, subunit); @@ -1430,19 +1451,19 @@ bool MockingboardCard::Phasor_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT if (version >= 5 && version <= 8) { const BYTE phasorDevice = subunit == 0 ? AY8913_DEVICE_B : AY8913_DEVICE_A; - AY8910_LoadSnapshot(yamlLoadHelper, 0, phasorDevice, std::string("-A")); - AY8910_LoadSnapshot(yamlLoadHelper, 1, phasorDevice, std::string("-B")); + AY8910_LoadSnapshot(yamlLoadHelper, 0, phasorDevice, std::string("-A"), version); + AY8910_LoadSnapshot(yamlLoadHelper, 1, phasorDevice, std::string("-B"), version); } else if (version <= 4 || version == 9) { const BYTE phasorDevice = subunit == 0 ? AY8913_DEVICE_A : AY8913_DEVICE_B; - AY8910_LoadSnapshot(yamlLoadHelper, 0, phasorDevice, std::string("-A")); - AY8910_LoadSnapshot(yamlLoadHelper, 1, phasorDevice, std::string("-B")); + AY8910_LoadSnapshot(yamlLoadHelper, 0, phasorDevice, std::string("-A"), version); + AY8910_LoadSnapshot(yamlLoadHelper, 1, phasorDevice, std::string("-B"), version); } else { - AY8910_LoadSnapshot(yamlLoadHelper, subunit, AY8913_DEVICE_A, std::string("-A")); - AY8910_LoadSnapshot(yamlLoadHelper, subunit, AY8913_DEVICE_B, std::string("-B")); + AY8910_LoadSnapshot(yamlLoadHelper, subunit, AY8913_DEVICE_A, std::string("-A"), version); + AY8910_LoadSnapshot(yamlLoadHelper, subunit, AY8913_DEVICE_B, std::string("-B"), version); } pMB->ssi263.LoadSnapshot(yamlLoadHelper, m_phasorMode, version, subunit); diff --git a/source/Mockingboard.h b/source/Mockingboard.h index b2a433358..fda02882a 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -50,6 +50,7 @@ class MockingboardCard : public Card bool IsAnyTimer1Active(); void UseBad6522A() { m_MBSubUnit[0].sy6522.InitBadState(true); } void UseBad6522B() { m_MBSubUnit[1].sy6522.InitBadState(true); } + void SetSocketAY891x(BYTE socket, AY891xType type); SSI263Type GetSocketSSI263(BYTE socket) { return m_MBSubUnit[socket].ssi263.GetType(); } void SetSocketSSI263(BYTE socket, SSI263Type type); SSI263Type GetSocketSC01() { return m_MBSubUnit[0].ssi263.GetSC01(); } @@ -146,7 +147,7 @@ class MockingboardCard : public Card void AY8910UpdateSetCycles(); UINT AY8910_SaveSnapshot(class YamlSaveHelper& yamlSaveHelper, BYTE subunit, BYTE ay, const std::string& suffix); - UINT AY8910_LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, BYTE subunit, BYTE ay, const std::string& suffix); + UINT AY8910_LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, BYTE subunit, BYTE ay, const std::string& suffix, UINT version); UINT64 m_lastAYUpdateCycle; //------------------------------------- diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index d9921ea72..ee1aa9a63 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -741,7 +741,7 @@ static void RepeatInitialization() VideoSwitchVideocardPalette(RGB_GetVideocard(), GetVideo().GetVideoType()); // Allow the slots to be configured as empty - // . remove all first, so that single-instance cards can can switch slots + // . remove all first, so that single-instance cards can switch slots // NB. this state is persisted to the Registry/conf.ini for (UINT i = SLOT0; i < NUM_SLOTS; i++) { @@ -795,6 +795,12 @@ static void RepeatInitialization() dynamic_cast(GetCardMgr().GetRef(i)).UseBad6522A(); if (g_cmdLine.slotInfo[i].useBad6522B) dynamic_cast(GetCardMgr().GetRef(i)).UseBad6522B(); + for (UINT socket = 0; socket < NUM_AY8913; socket++) + { + const AY891xType type = g_cmdLine.slotInfo[i].socketAY891x[socket]; + if (type != AY_Unknown) + dynamic_cast(GetCardMgr().GetRef(i)).SetSocketAY891x(socket, type); + } for (UINT socket = 0; socket < NUM_SSI263; socket++) { const SSI263Type type = g_cmdLine.slotInfo[i].socketSSI263[socket]; From 3e8054b4627624398e4589f7f27b3d40a6b9718e Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Mon, 27 Jul 2026 06:49:53 +1000 Subject: [PATCH 3/3] Replace BOOL (almost all) with bool (PR #1509) . Remove uses of !! --- source/6522.cpp | 36 ++++---- source/6522.h | 18 ++-- source/CPU.cpp | 12 +-- source/Configuration/About.cpp | 2 +- source/Configuration/PageAdvanced.cpp | 8 +- source/Configuration/PageConfig.cpp | 34 +++---- source/Configuration/PageConfig.h | 2 +- source/Configuration/PageConfigTfe.cpp | 25 ++---- source/Configuration/PageConfigTfe.h | 2 +- source/Configuration/PageInput.cpp | 6 +- source/Configuration/PageSlots.cpp | 80 +++++++++-------- source/Configuration/PageSlots.h | 6 +- source/Configuration/PropertySheetHelper.cpp | 10 +-- source/Configuration/PropertySheetHelper.h | 2 +- source/Debugger/Debug.cpp | 31 +++---- source/Debugger/Debug.h | 4 +- source/Debugger/Debugger_Color.cpp | 6 +- source/Debugger/Debugger_Display.cpp | 8 +- source/Debugger/Debugger_Symbols.cpp | 6 +- source/Disk.cpp | 22 +++-- source/Disk.h | 2 +- source/DiskImage.cpp | 8 +- source/DiskImage.h | 2 +- source/DiskImageHelper.cpp | 12 +-- source/FourPlay.cpp | 81 ++++++++++------- source/FourPlay.h | 5 +- source/FrameBase.cpp | 2 +- source/Harddisk.cpp | 4 +- source/Joystick.cpp | 92 +++++++++---------- source/Joystick.h | 16 ++-- source/Keyboard.cpp | 20 ++--- source/LanguageCard.cpp | 14 +-- source/LanguageCard.h | 8 +- source/Memory.cpp | 61 +++++++------ source/Memory.h | 2 +- source/Mockingboard.cpp | 10 +-- source/Mockingboard.h | 2 +- source/NTSC.cpp | 4 +- source/ParallelPrinter.cpp | 12 +-- source/RGBMonitor.cpp | 4 +- source/Registry.cpp | 4 +- source/Riff.cpp | 4 +- source/SaveState.cpp | 2 +- source/SerialComms.cpp | 8 +- source/Tape.cpp | 2 +- source/Tfe/PCapBackend.cpp | 10 +-- source/Tfe/PCapBackend.h | 8 +- source/Tfe/tfearch.cpp | 72 +++++++-------- source/Tfe/tfearch.h | 22 ++--- source/Uthernet1.cpp | 58 ++++++------ source/Uthernet1.h | 18 ++-- source/Uthernet2.cpp | 4 +- source/Utilities.cpp | 15 ++-- source/VidHD.cpp | 2 +- source/VidHD.h | 6 +- source/Video.cpp | 46 +++++----- source/Video.h | 22 ++--- source/Windows/AppleWin.cpp | 10 +-- source/Windows/DirectInput.cpp | 23 ++--- source/Windows/Win32Frame.cpp | 8 +- source/Windows/Win32Frame.h | 8 +- source/Windows/WinFrame.cpp | 94 ++++++++++---------- source/YamlHelper.cpp | 2 +- 63 files changed, 577 insertions(+), 552 deletions(-) diff --git a/source/6522.cpp b/source/6522.cpp index f4df0f551..df847ab59 100644 --- a/source/6522.cpp +++ b/source/6522.cpp @@ -57,7 +57,7 @@ void SY6522::Reset(const bool powerCycle) StopTimer1(); StopTimer2(); - m_timer1IrqDelay = m_timer2IrqDelay = 0; + m_timer1IrqDelay = m_timer2IrqDelay = false; } //--------------------------------------------------------------------------- @@ -215,9 +215,9 @@ void SY6522::Write(BYTE nReg, BYTE nValue) m_regs.IER |= nValue; } if (m_syncEvent[0]) - m_syncEvent[0]->m_canAssertIRQ = (m_regs.IER & IxR_TIMER1) ? true : false; + m_syncEvent[0]->m_canAssertIRQ = (m_regs.IER & IxR_TIMER1); if (m_syncEvent[1]) - m_syncEvent[1]->m_canAssertIRQ = (m_regs.IER & IxR_TIMER2) ? true : false; + m_syncEvent[1]->m_canAssertIRQ = (m_regs.IER & IxR_TIMER2); UpdateIFR(0); break; } @@ -239,7 +239,7 @@ void SY6522::UpdateTimer2(USHORT clocks) //----------------------------------------------------------------------------- -bool SY6522::CheckTimerUnderflow(USHORT& counter, int& timerIrqDelay, const USHORT clocks) +bool SY6522::CheckTimerUnderflow(USHORT& counter, bool& timerIrqDelay, const USHORT clocks) const { if (clocks == 0) return false; @@ -253,8 +253,8 @@ bool SY6522::CheckTimerUnderflow(USHORT& counter, int& timerIrqDelay, const USHO if (timerIrqDelay) // Deal with any previous counter underflow which didn't yet result in an IRQ { - _ASSERT(timerIrqDelay == 1); - timerIrqDelay = 0; + _ASSERT(timerIrqDelay); + timerIrqDelay = false; timerIrq = true; // if LATCH is very small then could underflow for every opcode... } @@ -266,14 +266,14 @@ bool SY6522::CheckTimerUnderflow(USHORT& counter, int& timerIrqDelay, const USHO if (timer <= -3) // TIMER = 0xFFFD (or less) timerIrq = true; else // TIMER = 0xFFFF or 0xFFFE - timerIrqDelay = 1; // ...so 1 or 2 cycles until IRQ + timerIrqDelay = true; // ...so 1 or 2 cycles until IRQ } else { if (timer <= -2) // TIMER = 0xFFFE (or less) timerIrq = true; else // TIMER = 0xFFFF - timerIrqDelay = 1; // ...so 1 cycle until IRQ + timerIrqDelay = true; // ...so 1 cycle until IRQ } } @@ -281,7 +281,7 @@ bool SY6522::CheckTimerUnderflow(USHORT& counter, int& timerIrqDelay, const USHO return timerIrq; } -int SY6522::OnTimer1Underflow(USHORT& counter) +bool SY6522::OnTimer1Underflow(USHORT& counter) const { int timer = (int)(short)(counter); if (m_isMegaAudio) @@ -296,7 +296,7 @@ int SY6522::OnTimer1Underflow(USHORT& counter) timer += (m_regs.TIMER1_LATCH.w + kExtraTimerCycles); // GH#651: account for underflowed cycles / GH#652: account for extra 2 cycles } counter = (USHORT)timer; - return (timer < 0) ? 1 : 0; // timer1IrqDelay + return (timer < 0); // timer1IrqDelay } //----------------------------------------------------------------------------- @@ -304,7 +304,7 @@ int SY6522::OnTimer1Underflow(USHORT& counter) USHORT SY6522::GetTimer1Counter(BYTE reg) { USHORT counter = m_regs.TIMER1_COUNTER.w; // NB. don't update the real T1C - int timerIrqDelay = m_timer1IrqDelay; // NB. don't update the real timer1IrqDelay + bool timerIrqDelay = m_timer1IrqDelay; // NB. don't update the real timer1IrqDelay const UINT opcodeCycleAdjust = GetOpcodeCyclesForRead(reg) - 1; // to compensate for the 4/5/6 cycle read opcode if (CheckTimerUnderflow(counter, timerIrqDelay, opcodeCycleAdjust)) OnTimer1Underflow(counter); @@ -320,7 +320,7 @@ USHORT SY6522::GetTimer2Counter(BYTE reg) bool SY6522::IsTimer1Underflowed(BYTE reg) { USHORT counter = m_regs.TIMER1_COUNTER.w; // NB. don't update the real T1C - int timerIrqDelay = m_timer1IrqDelay; // NB. don't update the real timer1IrqDelay + bool timerIrqDelay = m_timer1IrqDelay; // NB. don't update the real timer1IrqDelay const UINT opcodeCycleAdjust = GetOpcodeCyclesForRead(reg); // to compensate for the 4/5/6 cycle read opcode return CheckTimerUnderflow(counter, timerIrqDelay, opcodeCycleAdjust); } @@ -328,7 +328,7 @@ bool SY6522::IsTimer1Underflowed(BYTE reg) bool SY6522::IsTimer2Underflowed(BYTE reg) { USHORT counter = m_regs.TIMER2_COUNTER.w; // NB. don't update the real T2C - int timerIrqDelay = m_timer2IrqDelay; // NB. don't update the real timer2IrqDelay + bool timerIrqDelay = m_timer2IrqDelay; // NB. don't update the real timer2IrqDelay const UINT opcodeCycleAdjust = GetOpcodeCyclesForRead(reg); // to compensate for the 4/5/6 cycle read opcode return CheckTimerUnderflow(counter, timerIrqDelay, opcodeCycleAdjust); } @@ -641,10 +641,12 @@ void SY6522::SaveSnapshot(YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_SY6522_REG_DDRA, m_regs.DDRA); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_SY6522_REG_T1_COUNTER, m_regs.TIMER1_COUNTER.w); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_SY6522_REG_T1_LATCH, m_regs.TIMER1_LATCH.w); + // SS_YAML_KEY_SY6522_TIMER1_IRQ_DELAY is saved/loaded as Uint for backward compatibility. yamlSaveHelper.SaveUint(SS_YAML_KEY_SY6522_TIMER1_IRQ_DELAY, m_timer1IrqDelay); // v4 yamlSaveHelper.SaveBool(SS_YAML_KEY_SY6522_TIMER1_ACTIVE, m_timer1Active); // v8 yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_SY6522_REG_T2_COUNTER, m_regs.TIMER2_COUNTER.w); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_SY6522_REG_T2_LATCH, m_regs.TIMER2_LATCH.w); + // SS_YAML_KEY_SY6522_TIMER2_IRQ_DELAY is saved/loaded as Uint for backward compatibility. yamlSaveHelper.SaveUint(SS_YAML_KEY_SY6522_TIMER2_IRQ_DELAY, m_timer2IrqDelay); // v4 yamlSaveHelper.SaveBool(SS_YAML_KEY_SY6522_TIMER2_ACTIVE, m_timer2Active); // v8 yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_SY6522_REG_SERIAL_SHIFT, m_regs.SERIAL_SHIFT); @@ -675,10 +677,12 @@ void SY6522::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) m_regs.IER = yamlLoadHelper.LoadUint(SS_YAML_KEY_SY6522_REG_IER); m_regs.ORA_NO_HS = 0; // Not saved - m_timer1IrqDelay = m_timer2IrqDelay = 0; + m_timer1IrqDelay = m_timer2IrqDelay = false; if (version >= 4) { + // SS_YAML_KEY_SY6522_TIMER1_IRQ_DELAY|SS_YAML_KEY_SY6522_TIMER2_IRQ_DELAY are + // saved/loaded as Uint for backward compatibility. m_timer1IrqDelay = yamlLoadHelper.LoadUint(SS_YAML_KEY_SY6522_TIMER1_IRQ_DELAY); m_timer2IrqDelay = yamlLoadHelper.LoadUint(SS_YAML_KEY_SY6522_TIMER2_IRQ_DELAY); } @@ -721,14 +725,14 @@ void SY6522::SetTimersActiveFromSnapshot(bool timer1Active, bool timer2Active, U { SyncEvent* syncEvent = m_syncEvent[0]; syncEvent->SetCycles(GetRegT1C() + kExtraTimerCycles); // NB. use COUNTER, not LATCH - syncEvent->m_canAssertIRQ = (m_regs.IER & IxR_TIMER1) ? true : false; + syncEvent->m_canAssertIRQ = (m_regs.IER & IxR_TIMER1); g_SynchronousEventMgr.Insert(syncEvent); } if (IsTimer2Active()) { SyncEvent* syncEvent = m_syncEvent[1]; syncEvent->SetCycles(GetRegT2C() + kExtraTimerCycles); // NB. use COUNTER, not LATCH - syncEvent->m_canAssertIRQ = (m_regs.IER & IxR_TIMER2) ? true : false; + syncEvent->m_canAssertIRQ = (m_regs.IER & IxR_TIMER2); g_SynchronousEventMgr.Insert(syncEvent); } } diff --git a/source/6522.h b/source/6522.h index b4b1ef48b..1bb2c4ea3 100644 --- a/source/6522.h +++ b/source/6522.h @@ -53,14 +53,14 @@ class SY6522 _ASSERT(0); return 0; } - BYTE GetBusViewOfORB() { return m_regs.ORB & m_regs.DDRB; } // Return how the AY8913 sees ORB on the bus (ie. not CPU's view which will be OR'd with !DDRB) - USHORT GetRegT1C() { return m_regs.TIMER1_COUNTER.w; } - USHORT GetRegT2C() { return m_regs.TIMER2_COUNTER.w; } + BYTE GetBusViewOfORB() const { return (m_regs.ORB & m_regs.DDRB); } // Return how the AY8913 sees ORB on the bus (ie. not CPU's view which will be OR'd with !DDRB) + USHORT GetRegT1C() const { return m_regs.TIMER1_COUNTER.w; } + USHORT GetRegT2C() const { return m_regs.TIMER2_COUNTER.w; } void GetRegs(BYTE regs[SIZE_6522_REGS]) { memcpy(®s[0], (BYTE*)&m_regs, SIZE_6522_REGS); } // For debugger void SetRegIRA(BYTE reg) { m_regs.ORA = reg; } - bool IsTimer1IrqDelay() { return m_timer1IrqDelay ? true : false; } + bool IsTimer1IrqDelay() const { return m_timer1IrqDelay; } void SetBusBeingDriven(bool state) { m_isBusDriven = state; } - bool IsBad() { return m_bad6522; } + bool IsBad() const { return m_bad6522; } BYTE Read(BYTE nReg); void Write(BYTE nReg, BYTE nValue); @@ -92,8 +92,8 @@ class SY6522 bool IsTimer1Underflowed(BYTE reg); bool IsTimer2Underflowed(BYTE reg); - bool CheckTimerUnderflow(USHORT& counter, int& timerIrqDelay, const USHORT clocks); - int OnTimer1Underflow(USHORT& counter); + bool CheckTimerUnderflow(USHORT& counter, bool& timerIrqDelay, const USHORT clocks) const; + bool OnTimer1Underflow(USHORT& counter) const; UINT GetOpcodeCyclesForRead(BYTE reg); UINT GetOpcodeCyclesForWrite(BYTE reg); @@ -144,8 +144,8 @@ class SY6522 Regs m_regs; - int m_timer1IrqDelay; - int m_timer2IrqDelay; + bool m_timer1IrqDelay; + bool m_timer2IrqDelay; bool m_timer1Active; bool m_timer2Active; diff --git a/source/CPU.cpp b/source/CPU.cpp index 6a16f9102..02aa0baf7 100644 --- a/source/CPU.cpp +++ b/source/CPU.cpp @@ -132,7 +132,7 @@ static bool g_bCritSectionValid = false; // Deleting CritialSection when not val static CRITICAL_SECTION g_CriticalSection; // To guard /g_bmIRQ/ & /g_bmNMI/ static volatile UINT32 g_bmIRQ = 0; static volatile UINT32 g_bmNMI = 0; -static volatile BOOL g_bNmiFlank = FALSE; // Positive going flank on NMI line +static volatile bool g_bNmiFlank = false; // Positive going flank on NMI line static bool g_irqDefer1Opcode = false; static bool g_interruptInLastExecutionBatch = false; // Last batch of executed cycles included an interrupt (IRQ/NMI) @@ -187,7 +187,7 @@ void SetActiveCpu(eCpuType cpu) bool IsIrqAsserted() { - return g_bmIRQ ? true : false; + return (g_bmIRQ != 0); } bool Is6502InterruptEnabled() @@ -319,7 +319,7 @@ void CaptureCOUT() } else if (ch == 0x1B) // Escape { - bEscMode = bEscMode ? false : true; // Toggle mode + bEscMode = !bEscMode; // Toggle mode } else if (ch >= ' ' && ch <= '~') { @@ -405,7 +405,7 @@ static __forceinline bool NMI(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn, return false; // NMI signals are only serviced once - g_bNmiFlank = FALSE; + g_bNmiFlank = false; #ifdef _DEBUG g_nCycleIrqStart = g_nCumulativeCycles + uExecutedCycles; #endif @@ -886,7 +886,7 @@ void CpuNmiReset() _ASSERT(g_bCritSectionValid); if (g_bCritSectionValid) EnterCriticalSection(&g_CriticalSection); g_bmNMI = 0; - g_bNmiFlank = FALSE; + g_bNmiFlank = false; if (g_bCritSectionValid) LeaveCriticalSection(&g_CriticalSection); } @@ -895,7 +895,7 @@ void CpuNmiAssert(eIRQSRC Device) _ASSERT(g_bCritSectionValid); if (g_bCritSectionValid) EnterCriticalSection(&g_CriticalSection); if (g_bmNMI == 0) // NMI line is just becoming active - g_bNmiFlank = TRUE; + g_bNmiFlank = true; g_bmNMI |= 1<= rect.top) && (pt.y <= rect.bottom)) { CheckRadioButton(hWnd, IDC_AUTHENTIC_SPEED, IDC_CUSTOM_SPEED, IDC_CUSTOM_SPEED); - EnableTrackbar(hWnd, TRUE); + EnableTrackbar(hWnd, true); SetFocus(GetDlgItem(hWnd,IDC_SLIDER_CPU_SPEED)); ScreenToClient(GetDlgItem(hWnd,IDC_SLIDER_CPU_SPEED),&pt); PostMessage(GetDlgItem(hWnd,IDC_SLIDER_CPU_SPEED),WM_LBUTTONDOWN,wparam,MAKELONG(pt.x,pt.y)); @@ -248,7 +248,7 @@ void CPageConfig::InitOptions(HWND hWnd) const VideoStyle_e style = m_PropertySheetHelper.GetConfigNew().m_videoStyle; CheckDlgButton(hWnd, IDC_CHECK_HALF_SCAN_LINES, GetVideo().IsVideoStyle(style, VS_HALF_SCANLINES) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_CHECK_VERTICAL_BLEND, GetVideo().IsVideoStyle(style, VS_COLOR_VERTICAL_BLEND) ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_CHECK_VERTICAL_BLEND), (m_PropertySheetHelper.GetConfigNew().m_videoType == VT_COLOR_IDEALIZED) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_CHECK_VERTICAL_BLEND), (m_PropertySheetHelper.GetConfigNew().m_videoType == VT_COLOR_IDEALIZED)); CheckDlgButton(hWnd, IDC_CHECK_50HZ_VIDEO, (m_PropertySheetHelper.GetConfigNew().m_videoRefreshRate == VR_50HZ) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_CHECK_FS_SHOW_SUBUNIT_STATUS, m_PropertySheetHelper.GetConfigNew().m_fullScreen_ShowSubunitStatus ? BST_CHECKED : BST_UNCHECKED); @@ -263,7 +263,7 @@ void CPageConfig::InitOptions(HWND hWnd) SendDlgItemMessage(hWnd, IDC_SLIDER_CPU_SPEED, TBM_SETTICFREQ, 10, 0); SendDlgItemMessage(hWnd, IDC_SLIDER_CPU_SPEED, TBM_SETPOS, TRUE, m_PropertySheetHelper.GetConfigNew().m_machineSpeed); - BOOL bCustom = m_PropertySheetHelper.GetConfigNew().m_machineSpeed != SPEED_NORMAL ? TRUE : FALSE; + const bool bCustom = m_PropertySheetHelper.GetConfigNew().m_machineSpeed != SPEED_NORMAL; CheckRadioButton(hWnd, IDC_AUTHENTIC_SPEED, IDC_CUSTOM_SPEED, bCustom ? IDC_CUSTOM_SPEED : IDC_AUTHENTIC_SPEED); SetFocus(GetDlgItem(hWnd, bCustom ? IDC_SLIDER_CPU_SPEED : IDC_AUTHENTIC_SPEED)); EnableTrackbar(hWnd, bCustom); @@ -274,7 +274,7 @@ void CPageConfig::DlgOK(HWND hWnd) // This GetConfigNew() has already been set: // . m_Apple2Type, m_CpuType, m_monochromeRGB - m_PropertySheetHelper.GetConfigNew().m_confirmReboot = IsDlgButtonChecked(hWnd, IDC_CHECK_CONFIRM_REBOOT) ? true : false; + m_PropertySheetHelper.GetConfigNew().m_confirmReboot = IsDlgButtonChecked(hWnd, IDC_CHECK_CONFIRM_REBOOT); const uint32_t newMasterVolume = VOLUME_MAX - (uint32_t)SendDlgItemMessage(hWnd, IDC_SLIDER_MASTER_VOLUME, TBM_GETPOS, 0, 0); // Invert: L=MIN, R=MAX m_PropertySheetHelper.GetConfigNew().m_masterVolume = newMasterVolume; @@ -290,11 +290,11 @@ void CPageConfig::DlgOK(HWND hWnd) m_PropertySheetHelper.GetConfigNew().m_videoRefreshRate = IsDlgButtonChecked(hWnd, IDC_CHECK_50HZ_VIDEO) ? VR_50HZ : VR_60HZ; - m_PropertySheetHelper.GetConfigNew().m_fullScreen_ShowSubunitStatus = IsDlgButtonChecked(hWnd, IDC_CHECK_FS_SHOW_SUBUNIT_STATUS) ? true : false; + m_PropertySheetHelper.GetConfigNew().m_fullScreen_ShowSubunitStatus = IsDlgButtonChecked(hWnd, IDC_CHECK_FS_SHOW_SUBUNIT_STATUS); // Emulation speed control - m_PropertySheetHelper.GetConfigNew().m_enhanceDiskAccessSpeed = IsDlgButtonChecked(hWnd, IDC_ENHANCE_DISK_ENABLE) ? true : false; + m_PropertySheetHelper.GetConfigNew().m_enhanceDiskAccessSpeed = IsDlgButtonChecked(hWnd, IDC_ENHANCE_DISK_ENABLE); m_PropertySheetHelper.GetConfigNew().m_scrollLockToggle = IsDlgButtonChecked(hWnd, IDC_SCROLLLOCK_TOGGLE) ? 1 : 0; m_PropertySheetHelper.GetConfigNew().m_machineSpeed = IsDlgButtonChecked(hWnd, IDC_AUTHENTIC_SPEED) ? SPEED_NORMAL @@ -335,7 +335,7 @@ void CPageConfig::ApplyConfigAfterClose() bVideoReinit = true; } - const bool newHalfScanLines = ((UINT)m_PropertySheetHelper.GetConfigNew().m_videoStyle & (UINT)VS_HALF_SCANLINES) ? true : false; + const bool newHalfScanLines = ((UINT)m_PropertySheetHelper.GetConfigNew().m_videoStyle & (UINT)VS_HALF_SCANLINES); const bool currentHalfScanLines = GetVideo().IsVideoStyle(VS_HALF_SCANLINES); if (currentHalfScanLines != newHalfScanLines) { @@ -346,7 +346,7 @@ void CPageConfig::ApplyConfigAfterClose() bVideoReinit = true; } - const bool newVerticalBlend = ((UINT)m_PropertySheetHelper.GetConfigNew().m_videoStyle & (UINT)VS_COLOR_VERTICAL_BLEND) ? true : false; + const bool newVerticalBlend = ((UINT)m_PropertySheetHelper.GetConfigNew().m_videoStyle & (UINT)VS_COLOR_VERTICAL_BLEND); const bool currentVerticalBlend = GetVideo().IsVideoStyle(VS_COLOR_VERTICAL_BLEND); if (currentVerticalBlend != newVerticalBlend) { @@ -418,13 +418,13 @@ eApple2Type CPageConfig::GetApple2Type(uint32_t NewMenuItem) } } -void CPageConfig::EnableTrackbar(HWND hWnd, BOOL enable) +void CPageConfig::EnableTrackbar(HWND hWnd, bool enable) { - EnableWindow(GetDlgItem(hWnd,IDC_SLIDER_CPU_SPEED),enable); - EnableWindow(GetDlgItem(hWnd,IDC_0_5_MHz),enable); - EnableWindow(GetDlgItem(hWnd,IDC_1_0_MHz),enable); - EnableWindow(GetDlgItem(hWnd,IDC_2_0_MHz),enable); - EnableWindow(GetDlgItem(hWnd,IDC_MAX_MHz),enable); + EnableWindow(GetDlgItem(hWnd, IDC_SLIDER_CPU_SPEED), enable); + EnableWindow(GetDlgItem(hWnd, IDC_0_5_MHz), enable); + EnableWindow(GetDlgItem(hWnd, IDC_1_0_MHz), enable); + EnableWindow(GetDlgItem(hWnd, IDC_2_0_MHz), enable); + EnableWindow(GetDlgItem(hWnd, IDC_MAX_MHz), enable); } diff --git a/source/Configuration/PageConfig.h b/source/Configuration/PageConfig.h index 3d974ed49..71f0a139e 100644 --- a/source/Configuration/PageConfig.h +++ b/source/Configuration/PageConfig.h @@ -38,7 +38,7 @@ class CPageConfig : private IPropertySheetPage private: void InitOptions(HWND hWnd); eApple2Type GetApple2Type(uint32_t NewMenuItem); - void EnableTrackbar(HWND hWnd, BOOL enable); + void EnableTrackbar(HWND hWnd, bool enable); void ui_tfe_settings_dialog(HWND hWnd); static CPageConfig* ms_this; diff --git a/source/Configuration/PageConfigTfe.cpp b/source/Configuration/PageConfigTfe.cpp index 2eb664184..7569dc257 100644 --- a/source/Configuration/PageConfigTfe.cpp +++ b/source/Configuration/PageConfigTfe.cpp @@ -80,7 +80,7 @@ void CPageConfigTfe::DlgCANCEL(HWND window) EndDialog(window, 0); } -BOOL CPageConfigTfe::get_tfename(int number, std::string & name, std::string & description) +bool CPageConfigTfe::get_tfename(int number, std::string & name, std::string & description) { if (PCapBackend::tfe_enumadapter_open()) { @@ -98,13 +98,13 @@ BOOL CPageConfigTfe::get_tfename(int number, std::string & name, std::string & d name = adapterName; description = adapterDescription; PCapBackend::tfe_enumadapter_close(); - return TRUE; + return true; } PCapBackend::tfe_enumadapter_close(); } - return FALSE; + return false; } void CPageConfigTfe::gray_ungray_items(HWND hwnd) @@ -119,7 +119,7 @@ void CPageConfigTfe::gray_ungray_items(HWND hwnd) SetWindowText(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_DESC), description.c_str()); } - EnableWindow(GetDlgItem(hwnd, IDC_CHECK_TFE_VIRTUAL_DNS), m_enableVirtualDnsCheckbox ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_CHECK_TFE_VIRTUAL_DNS), m_enableVirtualDnsCheckbox); } void CPageConfigTfe::init_tfe_dialog(HWND hwnd) @@ -131,9 +131,9 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd) } else { - EnableWindow(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE), 0); - EnableWindow(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_NAME), 0); - EnableWindow(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_DESC), 0); + EnableWindow(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_NAME), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_DESC), FALSE); SetWindowText(GetDlgItem(hwnd, IDC_TFE_NPCAP_INFO), "Limited Uthernet support is available on your system.\n\n" @@ -154,18 +154,11 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd) for (cnt = 0; PCapBackend::tfe_enumadapter(name, description); cnt++) { - BOOL this_entry = FALSE; - - if (name == m_tfe_interface_name) - { - this_entry = TRUE; - } - SetWindowText(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_NAME), name.c_str()); SetWindowText(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE_DESC), description.c_str()); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)name.c_str()); - if (this_entry) + if (name == m_tfe_interface_name) { SendMessage(GetDlgItem(hwnd, IDC_TFE_SETTINGS_INTERFACE), CB_SETCURSEL, (WPARAM)cnt, 0); @@ -184,5 +177,5 @@ void CPageConfigTfe::save_tfe_dialog(HWND hwnd) GetDlgItemText(hwnd, IDC_TFE_SETTINGS_INTERFACE, buffer, sizeof(buffer) - 1); m_tfe_interface_name = buffer; - m_tfe_virtual_dns = IsDlgButtonChecked(hwnd, IDC_CHECK_TFE_VIRTUAL_DNS) ? true : false; + m_tfe_virtual_dns = IsDlgButtonChecked(hwnd, IDC_CHECK_TFE_VIRTUAL_DNS); } diff --git a/source/Configuration/PageConfigTfe.h b/source/Configuration/PageConfigTfe.h index 4d7b6fb8c..55ee09788 100644 --- a/source/Configuration/PageConfigTfe.h +++ b/source/Configuration/PageConfigTfe.h @@ -29,7 +29,7 @@ class CPageConfigTfe : private IPropertySheetPage virtual void ResetToDefault() {} private: - BOOL get_tfename(int number, std::string & name, std::string & description); + bool get_tfename(int number, std::string & name, std::string & description); void gray_ungray_items(HWND hwnd); void init_tfe_dialog(HWND hwnd); void save_tfe_dialog(HWND hwnd); diff --git a/source/Configuration/PageInput.cpp b/source/Configuration/PageInput.cpp index 6cde0f08b..16e5d9679 100644 --- a/source/Configuration/PageInput.cpp +++ b/source/Configuration/PageInput.cpp @@ -169,8 +169,8 @@ void CPageInput::InitOptions(HWND hWnd) CheckDlgButton(hWnd, IDC_CURSORCONTROL, m_PropertySheetHelper.GetConfigNew().m_cursorControl ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_SWAPBUTTONS0AND1, m_PropertySheetHelper.GetConfigNew().m_swapButtons0and1 ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_CURSORCONTROL), JoyUsingKeyboardCursors() ? TRUE : FALSE); - EnableWindow(GetDlgItem(hWnd, IDC_CENTERINGCONTROL), JoyUsingKeyboard() ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_CURSORCONTROL), JoyUsingKeyboardCursors()); + EnableWindow(GetDlgItem(hWnd, IDC_CENTERINGCONTROL), JoyUsingKeyboard()); } void CPageInput::DlgOK(HWND hWnd) @@ -183,7 +183,7 @@ void CPageInput::DlgOK(HWND hWnd) m_PropertySheetHelper.GetConfigNew().m_cursorControl = IsDlgButtonChecked(hWnd, IDC_CURSORCONTROL) ? 1 : 0; m_PropertySheetHelper.GetConfigNew().m_autofire = IsDlgButtonChecked(hWnd, IDC_AUTOFIRE) ? 7 : 0; // bitmap of 3 bits - m_PropertySheetHelper.GetConfigNew().m_swapButtons0and1 = IsDlgButtonChecked(hWnd, IDC_SWAPBUTTONS0AND1) ? true : false; + m_PropertySheetHelper.GetConfigNew().m_swapButtons0and1 = IsDlgButtonChecked(hWnd, IDC_SWAPBUTTONS0AND1); m_PropertySheetHelper.GetConfigNew().m_centeringControl = IsDlgButtonChecked(hWnd, IDC_CENTERINGCONTROL) ? 1 : 0; m_PropertySheetHelper.PostMsgAfterClose(hWnd, m_Page); diff --git a/source/Configuration/PageSlots.cpp b/source/Configuration/PageSlots.cpp index 60a65878f..c519bc6da 100644 --- a/source/Configuration/PageSlots.cpp +++ b/source/Configuration/PageSlots.cpp @@ -263,19 +263,26 @@ int CPageSlots::CardTypeToComboItem(UINT slot) return currentChoice; } -BOOL CPageSlots::CardTypeHasOptions(SS_CARDTYPE card) +bool CPageSlots::CardTypeHasOptions(SS_CARDTYPE card) { - return (card == CT_Disk2 || - card == CT_GenericHDD || - card == CT_SSC || - card == CT_GenericPrinter || - card == CT_MockingboardC || - card == CT_MouseInterface || - card == CT_Phasor || - card == CT_Saturn128K || - card == CT_Uthernet || - card == CT_Uthernet2 || - card == CT_RamWorksIII) ? TRUE : FALSE; + switch (card) + { + case CT_Disk2: + case CT_GenericHDD: + case CT_SSC: + case CT_GenericPrinter: + case CT_MockingboardC: + case CT_MouseInterface: + case CT_Phasor: + case CT_Saturn128K: + case CT_Uthernet: + case CT_Uthernet2: + case CT_RamWorksIII: + return true; + default: + break; + } + return false; } // @@ -284,7 +291,8 @@ BOOL CPageSlots::CardTypeHasOptions(SS_CARDTYPE card) void CPageSlots::InitOptions(HWND hWnd) { - BOOL enable = FALSE, enableOpt = FALSE; + bool enable = false; + bool enableOpt = false; SS_CARDTYPE currConfig[NUM_SLOTS]; for (int i = SLOT0; i < NUM_SLOTS; i++) @@ -294,8 +302,8 @@ void CPageSlots::InitOptions(HWND hWnd) { if (slot == SLOT0 && IsAppleIIe(m_PropertySheetHelper.GetConfigNew().m_Apple2Type)) { - enable = FALSE; - enableOpt = FALSE; + enable = false; + enableOpt = false; } else { @@ -304,7 +312,7 @@ void CPageSlots::InitOptions(HWND hWnd) int currentChoice = CardTypeToComboItem(slot); m_PropertySheetHelper.FillComboBox(hWnd, IDC_SLOT0 + slot, choices.c_str(), currentChoice); - enable = TRUE; + enable = true; enableOpt = CardTypeHasOptions(m_PropertySheetHelper.GetConfigNew().m_Slot[slot]); } @@ -319,13 +327,13 @@ void CPageSlots::InitOptions(HWND hWnd) int currentChoice = CardTypeToComboItem(SLOT_AUX); m_PropertySheetHelper.FillComboBox(hWnd, IDC_SLOTAUX, choices.c_str(), currentChoice); - enable = TRUE; + enable = true; enableOpt = CardTypeHasOptions(m_PropertySheetHelper.GetConfigNew().m_SlotAux); } else { - enable = FALSE; - enableOpt = FALSE; + enable = false; + enableOpt = false; } EnableWindow(GetDlgItem(hWnd, IDC_SLOTAUX), enable); @@ -593,11 +601,11 @@ void CPageSlots::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comb if (dwComboSelection == dwOpenDialogIndex) { - EnableFloppyDrive(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered + EnableFloppyDrive(hWnd, false); // Prevent multiple Selection dialogs to be triggered std::string pathname; DWORD flags = 0; bool bRes = card.UserSelectNewDiskImageOnly(driveSelected, "", pathname, flags); - EnableFloppyDrive(hWnd, TRUE); + EnableFloppyDrive(hWnd, true); if (!bRes) { @@ -673,11 +681,11 @@ void CPageSlots::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comb } } -void CPageSlots::EnableFloppyDrive(HWND hWnd, BOOL enable) +void CPageSlots::EnableFloppyDrive(HWND hWnd, bool enable) { EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_COMBO_DISK1), enable); EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_COMBO_DISK2), enable); - EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_DISK_SWAP), enable); + EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_DISK_SWAP), enable); } void CPageSlots::HandleFloppyDriveSwap(HWND hWnd, UINT slot) @@ -697,7 +705,7 @@ void CPageSlots::DlgDisk2OK(HWND hWnd) if (ms_slot == SLOT5 || ms_slot == SLOT6) { Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); - const bool bNewDiskiiStatus = IsDlgButtonChecked(hWnd, IDC_DISKII_STATUS_ENABLE) ? true : false; + const bool bNewDiskiiStatus = IsDlgButtonChecked(hWnd, IDC_DISKII_STATUS_ENABLE); if (win32Frame.GetWindowedModeShowDiskiiStatus() != bNewDiskiiStatus) { @@ -709,7 +717,7 @@ void CPageSlots::DlgDisk2OK(HWND hWnd) } } - const bool newDiskii13SectorFW = IsDlgButtonChecked(hWnd, IDC_DISKII_13_SECTOR_FW_ENABLE) ? true : false; + const bool newDiskii13SectorFW = IsDlgButtonChecked(hWnd, IDC_DISKII_13_SECTOR_FW_ENABLE); m_PropertySheetHelper.GetConfigNew().m_diskII13SectorFirmware[ms_slot] = newDiskii13SectorFW; } @@ -844,11 +852,11 @@ void CPageSlots::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte if (dwComboSelection == dwOpenDialogIndex) { - EnableHDD(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered + EnableHDD(hWnd, false); // Prevent multiple Selection dialogs to be triggered std::string pathname; DWORD flags = 0; bool bRes = card.UserSelectNewDiskImageOnly(driveSelected, "", pathname, flags); - EnableHDD(hWnd, TRUE); + EnableHDD(hWnd, true); if (!bRes) { @@ -930,11 +938,11 @@ void CPageSlots::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte } } -void CPageSlots::EnableHDD(HWND hWnd, BOOL enable) +void CPageSlots::EnableHDD(HWND hWnd, bool enable) { EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_COMBO_HDD1), enable); EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_COMBO_HDD2), enable); - EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_HDD_SWAP), enable); + EnableWindow(GetDlgItem(hWnd, IDC_SLOT_OPT_HDD_SWAP), enable); } void CPageSlots::HandleHDDSwap(HWND hWnd, UINT slot) @@ -1041,10 +1049,8 @@ INT_PTR CPageSlots::DlgProcSSCInternal(HWND hWnd, UINT message, WPARAM wparam, L const UINT serialPortItem = m_PropertySheetHelper.GetConfigNew().m_serialPortItem; m_PropertySheetHelper.FillComboBox(hWnd, IDC_SERIALPORT, cardForConfig.GetSerialPortChoices().c_str(), serialPortItem); - BOOL enable = TRUE; CSuperSerialCard* card = GetCardMgr().GetSSC(); - if (card && card->IsActive()) - enable = FALSE; + const bool enable = !card || !card->IsActive(); EnableWindow(GetDlgItem(hWnd, IDC_SERIALPORT), enable); break; } @@ -1124,7 +1130,7 @@ INT_PTR CPageSlots::DlgProcPrinterInternal(HWND hWnd, UINT message, WPARAM wpara SendDlgItemMessage(hWnd, IDC_PRINTER_DUMP_FILENAME, WM_SETTEXT, 0, (LPARAM)card.GetFilename().c_str()); // Need to specify cmd-line switch: -printer-real to enable this control - EnableWindow(GetDlgItem(hWnd, IDC_DUMPTOPRINTER), card.GetEnableDumpToRealPrinter() ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_DUMPTOPRINTER), card.GetEnableDumpToRealPrinter()); } break; @@ -1155,10 +1161,10 @@ void CPageSlots::DlgPrinterOK(HWND hWnd) card.SetFilename(szFilename); } - card.SetDumpToPrinter(IsDlgButtonChecked(hWnd, IDC_DUMPTOPRINTER) ? true : false); - card.SetConvertEncoding(IsDlgButtonChecked(hWnd, IDC_PRINTER_CONVERT_ENCODING) ? true : false); - card.SetFilterUnprintable(IsDlgButtonChecked(hWnd, IDC_PRINTER_FILTER_UNPRINTABLE) ? true : false); - card.SetPrinterAppend(IsDlgButtonChecked(hWnd, IDC_PRINTER_APPEND) ? true : false); + card.SetDumpToPrinter(IsDlgButtonChecked(hWnd, IDC_DUMPTOPRINTER)); + card.SetConvertEncoding(IsDlgButtonChecked(hWnd, IDC_PRINTER_CONVERT_ENCODING)); + card.SetFilterUnprintable(IsDlgButtonChecked(hWnd, IDC_PRINTER_FILTER_UNPRINTABLE)); + card.SetPrinterAppend(IsDlgButtonChecked(hWnd, IDC_PRINTER_APPEND)); card.SetIdleLimit((short)SendDlgItemMessage(hWnd, IDC_SPIN_PRINTER_IDLE, UDM_GETPOS, 0, 0)); } diff --git a/source/Configuration/PageSlots.h b/source/Configuration/PageSlots.h index 7f127d357..a65f3e409 100644 --- a/source/Configuration/PageSlots.h +++ b/source/Configuration/PageSlots.h @@ -42,7 +42,7 @@ class CPageSlots : private IPropertySheetPage void ResetCardOptionsToDefault(UINT slot); void DiskCardCleanup(); int CardTypeToComboItem(UINT slot); - BOOL CardTypeHasOptions(SS_CARDTYPE card); + bool CardTypeHasOptions(SS_CARDTYPE card); static INT_PTR CALLBACK DlgProcDisk2(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam); INT_PTR DlgProcDisk2Internal(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam); @@ -66,13 +66,13 @@ class CPageSlots : private IPropertySheetPage void InitComboFloppyDrive(HWND hWnd, UINT slot); bool CheckFloppyPathnameInUse(const std::string& pathname, BYTE& inUseSlot, BYTE& inUseDrive); void HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected, UINT slot); - void EnableFloppyDrive(HWND hWnd, BOOL enable); + void EnableFloppyDrive(HWND hWnd, bool enable); void HandleFloppyDriveSwap(HWND hWnd, UINT slot); void InitComboHDD(HWND hWnd, UINT slot); bool CheckHDDPathnameInUse(const std::string& pathname, BYTE& inUseSlot, BYTE& inUseDrive); void HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected, UINT slot); - void EnableHDD(HWND hWnd, BOOL enable); + void EnableHDD(HWND hWnd, bool enable); void HandleHDDSwap(HWND hWnd, UINT slot); void DlgDisk2OK(HWND hWnd); diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index a043aec9a..6a0998b1e 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -184,7 +184,7 @@ void CPropertySheetHelper::SaveStateUpdate() } // NB. OK'ing this property sheet will call SaveStateUpdate()->Snapshot_SetFilename() with this new path & filename -int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, const char* pszTitle, bool bSave) +bool CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, const char* pszTitle, bool bSave) { // Whenever harddisks/disks are inserted (or removed) and *if path has changed* then: // . Snapshot's path & Snapshot's filename will be updated to reflect the new defaults. @@ -212,8 +212,8 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, const char* pszTitl ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrTitle = pszTitle; - int nRes = bSave ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn); - if (nRes) + const bool bRes = bSave ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn); + if (bRes) { if (bSave) // Only for saving (allow loading of any file for backwards compatibility) { @@ -253,8 +253,8 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, const char* pszTitl m_szSSNewDirectory = szFilename; // always set this, even if unchanged } - m_bSSNewFilename = nRes ? true : false; - return nRes; + m_bSSNewFilename = bRes; + return bRes; } // On OK: Optionally post a single "uAfterClose" msg after last page closes diff --git a/source/Configuration/PropertySheetHelper.h b/source/Configuration/PropertySheetHelper.h index cf2be3453..57e3ac8de 100644 --- a/source/Configuration/PropertySheetHelper.h +++ b/source/Configuration/PropertySheetHelper.h @@ -17,7 +17,7 @@ class CPropertySheetHelper void FillComboBox(HWND window, int controlid, LPCTSTR choices, int currentchoice); std::string BrowseToFile(HWND hWindow, const char* pszTitle, const char* REGVALUE, const char* FILEMASKS); void SaveStateUpdate(); - int SaveStateSelectImage(HWND hWindow, const char* pszTitle, bool bSave); + bool SaveStateSelectImage(HWND hWindow, const char* pszTitle, bool bSave); void PostMsgAfterClose(HWND hWnd, PAGETYPE page); void ResetPageMask() { m_bmPages = 0; } // Req'd because cancelling doesn't clear the page-mask diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 907e3afeb..17ab2f3a4 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -340,7 +340,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA static bool g_bBenchmarking = false; - static BOOL g_bProfiling = 0; + static bool g_bProfiling = false; static int g_nDebugSteps = 0; static uint32_t g_nDebugStepCycles = 0; static int g_nDebugStepStart = 0; @@ -386,7 +386,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA void _BWZ_RemoveOne ( Breakpoint_t *aBreakWatchZero, const int iSlot, int & nTotal ); void _BWZ_RemoveAll ( Breakpoint_t *aBreakWatchZero, const int nMax, int & nTotal ); -// bool CheckBreakpoint (WORD address, BOOL memory); bool _CmdBreakpointAddReg ( Breakpoint_t *pBP, BreakpointSource_t iSrc, BreakpointOperator_t iCmp, WORD nAddress, int nLen, bool bIsTempBreakpoint ); int _CmdBreakpointAddCommonArg ( const int nArg, int iArg, BreakpointSource_t iSrc, BreakpointOperator_t iCmp, bool bIsTempBreakpoint=false ); @@ -818,7 +817,7 @@ Update_t CmdProfile (int nArgs) if (iParam == PARAM_RESET) { ProfileReset(); - g_bProfiling = 1; + g_bProfiling = true; ConsoleBufferPush( " Resetting profile data." ); } else @@ -888,7 +887,7 @@ Update_t _BP_InfoNone () // iOpcodeType = AM_IMPLIED (BRK), AM_1, AM_2, AM_3 static bool IsDebugBreakOnInvalid (int iOpcodeType) { - return ((g_nDebugBreakOnInvalid >> iOpcodeType) & 1) ? true : false; + return (g_nDebugBreakOnInvalid & (1 << iOpcodeType)); } // iOpcodeType = AM_IMPLIED (BRK), AM_1, AM_2, AM_3 @@ -1073,7 +1072,7 @@ Update_t CmdBreakOnInterrupt (int nArgs) if (nArgs == 1) { - g_bDebugBreakOnInterrupt = (iParam == PARAM_ON) ? true : false; + g_bDebugBreakOnInterrupt = (iParam == PARAM_ON); strcpy(sAction, "Setting"); } @@ -1086,7 +1085,6 @@ Update_t CmdBreakOnInterrupt (int nArgs) } -// bool bBP = g_nBreakpoints && CheckBreakpoint(nOffset,nOffset == regs.pc); //=========================================================================== bool GetBreakpointInfo ( WORD nOffset, bool & bBreakpointActive_, bool & bBreakpointEnable_ ) { @@ -2764,7 +2762,7 @@ Update_t CmdUnassemble (int nArgs) Update_t CmdKey (int nArgs) { KeybQueueKeypress( - nArgs ? g_aArgs[1].nValue ? g_aArgs[1].nValue : g_aArgs[1].sArg[0] : ' ', ASCII); // FIXME!!! + nArgs ? (g_aArgs[1].nValue ? g_aArgs[1].nValue : g_aArgs[1].sArg[0]) : ' ', ASCII); // FIXME!!! return UPDATE_CONSOLE_DISPLAY; } @@ -3190,7 +3188,7 @@ Update_t CmdConfigDisasm (int nArgs) if ((nArgs > 1) && (! bDisplayCurrentSettings)) // set { iArg++; - g_bConfigDisasmAddressColon = (g_aArgs[ iArg ].nValue) ? true : false; + g_bConfigDisasmAddressColon = (g_aArgs[ iArg ].nValue != 0); } else // show current setting { @@ -3204,7 +3202,7 @@ Update_t CmdConfigDisasm (int nArgs) if ((nArgs > 1) && (! bDisplayCurrentSettings)) // set { iArg++; - g_bConfigDisasmOpcodesView = (g_aArgs[ iArg ].nValue) ? true : false; + g_bConfigDisasmOpcodesView = (g_aArgs[ iArg ].nValue != 0); } else { @@ -3218,7 +3216,7 @@ Update_t CmdConfigDisasm (int nArgs) if ((nArgs > 1) && (! bDisplayCurrentSettings)) // set { iArg++; - g_bConfigInfoTargetPointer = (g_aArgs[ iArg ].nValue) ? true : false; + g_bConfigInfoTargetPointer = (g_aArgs[ iArg ].nValue != 0); } else { @@ -3232,7 +3230,7 @@ Update_t CmdConfigDisasm (int nArgs) if ((nArgs > 1) && (! bDisplayCurrentSettings)) // set { iArg++; - g_bConfigDisasmOpcodeSpaces = (g_aArgs[ iArg ].nValue) ? true : false; + g_bConfigDisasmOpcodeSpaces = (g_aArgs[ iArg ].nValue != 0); } else { @@ -4034,10 +4032,7 @@ Update_t CmdDisk (int nArgs) if (nArgs > 3) return HelpLastCommand(); - bool bProtect = true; - - if (nArgs == 3) - bProtect = g_aArgs[ 3 ].nValue ? true : false; + const bool bProtect = (nArgs < 3) || (g_aArgs[ 3 ].nValue != 0); diskCard.SetProtect( iDrive, bProtect ); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); @@ -6588,7 +6583,7 @@ Update_t CmdOutputPrint (int nArgs) for ( int iArg = 1; iArg <= nArgs; iArg++ ) { - sText += (!!(g_aArgs[ iArg ].bType & TYPE_QUOTED_2)) + sText += (g_aArgs[ iArg ].bType & TYPE_QUOTED_2) ? g_aArgs[ iArg ].sArg : WordToHexStr( g_aArgs[ iArg ].nValue ); @@ -7028,7 +7023,7 @@ Update_t CmdSource (int nArgs) const std::string pFileName = g_aArgs[ iArg ].sArg; int iParam; - bool bFound = FindParam( pFileName.c_str(), MATCH_EXACT, iParam, _PARAM_SOURCE_BEGIN, _PARAM_SOURCE_END ) > 0 ? true : false; + bool bFound = FindParam( pFileName.c_str(), MATCH_EXACT, iParam, _PARAM_SOURCE_BEGIN, _PARAM_SOURCE_END ) > 0; if (bFound && (iParam == PARAM_SRC_SYMBOLS)) { g_bSourceAddSymbols = true; @@ -10103,7 +10098,7 @@ void DebuggerProcessKey ( int keycode ) UpdateDisplay( bUpdateDisplay ); } -void DebugDisplay ( BOOL bInitDisasm/*=FALSE*/ ) +void DebugDisplay ( bool bInitDisasm /*=false*/ ) { if (bInitDisasm) InitDisasm(); diff --git a/source/Debugger/Debug.h b/source/Debugger/Debug.h index 9932a8c14..daa2ee1a8 100644 --- a/source/Debugger/Debug.h +++ b/source/Debugger/Debug.h @@ -71,7 +71,7 @@ bool operator() ( const Command_t & rLHS, const Command_t & rRHS ) const { // return true if lhs 0; iLevel--) diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index bb4fea888..354d9edc5 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -639,7 +639,7 @@ void StretchBltMemToFrameDC() int wdest = nViewportCX; int hdest = nViewportCY; - BOOL bRes = StretchBlt( + StretchBlt( win32Frame.FrameGetDC(), // HDC hdcDest, xdest, ydest, // int nXOriginDest, int nYOriginDest, wdest, hdest, // int nWidthDest, int nHeightDest, @@ -2814,8 +2814,8 @@ void _DrawSoftSwitchMainAuxBanks( RECT & rect, int bg_default = BG_INFO ) int dx = 7 * w; int nAddress = 0xC002; - bool bMainRead = (GetMemMode() & MF_AUXREAD) ? true : false; - bool bAuxWrite = (GetMemMode() & MF_AUXWRITE) ? true : false; + bool bMainRead = (GetMemMode() & MF_AUXREAD); + bool bAuxWrite = (GetMemMode() & MF_AUXWRITE); temp.right = rect.left + dx; _DrawSoftSwitch( temp, nAddress, !bMainRead, "R", "m", "x", NULL, BG_DATA_2 ); @@ -3471,7 +3471,7 @@ void DrawSubWindow_Data (Update_t bUpdate) rect.right = DISPLAY_DISASM_RIGHT; rect.bottom = rect.top + nFontHeight; - iBackground = !!(iLine & 1) ? BG_DATA_1 : BG_DATA_2; + iBackground = (iLine & 1) ? BG_DATA_1 : BG_DATA_2; DebuggerSetColorBG( DebuggerGetColor( iBackground ) ); diff --git a/source/Debugger/Debugger_Symbols.cpp b/source/Debugger/Debugger_Symbols.cpp index df401e255..f41e13624 100644 --- a/source/Debugger/Debugger_Symbols.cpp +++ b/source/Debugger/Debugger_Symbols.cpp @@ -284,7 +284,7 @@ Update_t CmdSymbolsClear (int nArgs) std::string _CmdSymbolsInfoHeader ( int iTable, int nDisplaySize /* = 0 */ ) { // Common case is to use/calc the table size - bool bActive = (g_bDisplaySymbolTables & (1 << iTable)) ? true : false; + bool bActive = (g_bDisplaySymbolTables & (1 << iTable)); int nSymbols = nDisplaySize ? nDisplaySize : (int)g_aSymbols[ iTable ].size(); // Short Desc: `MAIN`: `1000` @@ -299,7 +299,7 @@ std::string _CmdSymbolsInfoHeader ( int iTable, int nDisplaySize /* = 0 */ ) //=========================================================================== std::string _CmdSymbolsSummaryStatus ( int iTable ) { - bool bActive = (g_bDisplaySymbolTables & (1 << iTable)) ? true : false; + bool bActive = (g_bDisplaySymbolTables & (1 << iTable)); int iParam = bActive ? PARAM_ON : PARAM_OFF @@ -339,7 +339,7 @@ Update_t CmdSymbolsInfo (int nArgs) for ( int iTable = 0, bTable = 1; bTable <= bDisplaySymbolTables; iTable++, bTable <<= 1 ) { - if ( !!(bDisplaySymbolTables & bTable) ) + if ( (bDisplaySymbolTables & bTable) ) { std::string hdr = _CmdSymbolsInfoHeader( iTable ); // 15 chars per table diff --git a/source/Disk.cpp b/source/Disk.cpp index 9c6268c80..ed1c04631 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -76,11 +76,11 @@ Disk2InterfaceCard::Disk2InterfaceCard(UINT slot) : m_deferredStepperAddress = 0; m_deferredStepperCumulativeCycles = 0; - uint32_t tmp; + uint32_t tmp = 0; std::string regSection = RegGetConfigSlotSection(m_slot); const uint32_t kForce13SectorFirmware_Default = 0; RegLoadValue(regSection.c_str(), REGVALUE_DISKII_13_SECTOR_FIRMWARE, true, &tmp, kForce13SectorFirmware_Default); - m_force13SectorFirmware = tmp ? true : false; + m_force13SectorFirmware = (tmp != 0); ResetLogicStateSequencer(); @@ -494,14 +494,14 @@ void Disk2InterfaceCard::Boot() // THIS FUNCTION RELOADS A PROGRAM IMAGE IF ONE IS LOADED IN DRIVE ONE. // IF A DISK IMAGE OR NO IMAGE IS LOADED IN DRIVE ONE, IT DOES NOTHING. if (m_floppyDrive[0].m_disk.m_imagehandle && ImageBoot(m_floppyDrive[0].m_disk.m_imagehandle)) - m_floppyMotorOn = 0; + m_floppyMotorOn = false; } //=========================================================================== void __stdcall Disk2InterfaceCard::ControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { - BOOL newState = address & 1; + bool newState = (address & 1); bool stateChanged = (newState != m_floppyMotorOn); // "2. [...] (DRIVES OFF forces the control flip-flops to clear.)" (UTAIIe page 9-12) @@ -509,7 +509,7 @@ void __stdcall Disk2InterfaceCard::ControlMotor(WORD, WORD address, BYTE, BYTE, // "5. Causes the ENABLE1' or the ENABLE2' signal to go low depending on which drive is selected by the drive1/drive2 switch." // - so m_currDrive not affected. // TODO: what about m_seqFunc.function? - if (newState == FALSE) + if (!newState) { m_magnetStates = 0; // GH#926, GH#1315 ControlStepperLogging(address, g_nCumulativeCycles); @@ -1948,7 +1948,7 @@ void __stdcall Disk2InterfaceCard::SetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uE { m_formatTrack.DriveSwitchedToWriteMode(m_floppyDrive[m_currDrive].m_disk.m_byte); - BOOL modechange = !m_floppyDrive[m_currDrive].m_writelight; + const bool modechange = !m_floppyDrive[m_currDrive].m_writelight; #if LOG_DISK_RW_MODE LOG_DISK("rw mode: write (mode changed=%d)\r\n", modechange ? 1 : 0); #endif @@ -2324,6 +2324,8 @@ void Disk2InterfaceCard::SaveSnapshotFloppy(YamlSaveHelper& yamlSaveHelper, UINT yamlSaveHelper.SaveHexUint32(SS_YAML_KEY_BIT_COUNT, m_floppyDrive[unit].m_disk.m_bitCount); // v4 yamlSaveHelper.SaveDouble(SS_YAML_KEY_EXTRA_CYCLES, m_floppyDrive[unit].m_disk.m_extraCycles); // v4 yamlSaveHelper.SaveBool(SS_YAML_KEY_WRITE_PROTECTED, m_floppyDrive[unit].m_disk.m_bWriteProtected); + // SS_YAML_KEY_TRACK_IMAGE_DATA|SS_YAML_KEY_TRACK_IMAGE_DIRTY are saved/loaded + // as Uint for backward compatibility. yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK_IMAGE_DATA, m_floppyDrive[unit].m_disk.m_trackimagedata); yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY, m_floppyDrive[unit].m_disk.m_trackimagedirty); @@ -2358,7 +2360,7 @@ void Disk2InterfaceCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_PHASES, m_magnetStates); yamlSaveHelper.SaveBool(SS_YAML_KEY_ENHANCE_DISK, m_enhanceDisk); yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_FLOPPY_LATCH, m_floppyLatch); - yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_MOTOR_ON, m_floppyMotorOn == TRUE); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_MOTOR_ON, m_floppyMotorOn); yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_CYCLE, m_diskLastCycle); // v2 yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_READ_LATCH_CYCLE, m_diskLastReadLatchCycle); // v3 yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_LSS_SHIFT_REG, m_shiftReg); // v4 @@ -2417,8 +2419,10 @@ bool Disk2InterfaceCard::LoadSnapshotFloppy(YamlLoadHelper& yamlLoadHelper, UINT yamlLoadHelper.LoadBool(SS_YAML_KEY_WRITE_PROTECTED); // Consume m_floppyDrive[unit].m_disk.m_byte = yamlLoadHelper.LoadUint(SS_YAML_KEY_BYTE); m_floppyDrive[unit].m_disk.m_nibbles = yamlLoadHelper.LoadUint(SS_YAML_KEY_NIBBLES); - m_floppyDrive[unit].m_disk.m_trackimagedata = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DATA) ? true : false; - m_floppyDrive[unit].m_disk.m_trackimagedirty = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY) ? true : false; + // SS_YAML_KEY_TRACK_IMAGE_DATA|SS_YAML_KEY_TRACK_IMAGE_DIRTY are saved/loaded + // as Uint for backward compatibility. + m_floppyDrive[unit].m_disk.m_trackimagedata = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DATA); + m_floppyDrive[unit].m_disk.m_trackimagedirty = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY); if (version >= 4) { diff --git a/source/Disk.h b/source/Disk.h index 125705b95..7da2d73ff 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -268,7 +268,7 @@ class Disk2InterfaceCard : public Card WORD m_currDrive; FloppyDrive m_floppyDrive[NUM_DRIVES]; BYTE m_floppyLatch; - BOOL m_floppyMotorOn; + bool m_floppyMotorOn; // Although the magnets are a property of the drive, their state is a property of the controller card, // since the magnets will only be on for whichever of the 2 drives is currently selected. diff --git a/source/DiskImage.cpp b/source/DiskImage.cpp index 5919cd9cc..1d9481627 100644 --- a/source/DiskImage.cpp +++ b/source/DiskImage.cpp @@ -107,9 +107,9 @@ void ImageClose(ImageInfo* const pImageInfo) //=========================================================================== -BOOL ImageBoot(ImageInfo* const pImageInfo) +bool ImageBoot(ImageInfo* const pImageInfo) { - BOOL result = 0; + bool result = false; if (pImageInfo->pImageType->AllowBoot()) result = pImageInfo->pImageType->Boot(pImageInfo); @@ -284,12 +284,12 @@ void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pF imagetitle[MAX_DISK_FULL_NAME] = 0; // if imagetitle contains a lowercase char, then found=1 (why?) - BOOL found = 0; + bool found = false; int loop = 0; while (imagetitle[loop] && !found) { if (IsCharLower(imagetitle[loop])) - found = 1; + found = true; else loop++; } diff --git a/source/DiskImage.h b/source/DiskImage.h index 536d35b14..9649a399d 100644 --- a/source/DiskImage.h +++ b/source/DiskImage.h @@ -80,7 +80,7 @@ struct ImageInfo; ImageError_e ImageOpen(const std::string & pszImageFilename, ImageInfo** ppImageInfo, bool* pWriteProtected, const bool bCreateIfNecessary, std::string& strFilenameInZip, const bool bExpectFloppy=true); void ImageClose(ImageInfo* const pImageInfo); -BOOL ImageBoot(ImageInfo* const pImageInfo); +bool ImageBoot(ImageInfo* const pImageInfo); void ImageReadTrack(ImageInfo* const pImageInfo, float phase, LPBYTE pTrackImageBuffer, int* pNibbles, UINT* pBitCount, bool enhanceDisk); void ImageWriteTrack(ImageInfo* const pImageInfo, float phase, LPBYTE pTrackImageBuffer, int nNibbles); diff --git a/source/DiskImageHelper.cpp b/source/DiskImageHelper.cpp index b88317048..2467765c3 100644 --- a/source/DiskImageHelper.cpp +++ b/source/DiskImageHelper.cpp @@ -144,7 +144,7 @@ bool CImageBase::ReadBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBloc SetFilePointer(pImageInfo->hFile, Offset, NULL, FILE_BEGIN); DWORD dwBytesRead; - BOOL bRes = ReadFile(pImageInfo->hFile, pBlockBuffer, HD_BLOCK_SIZE, &dwBytesRead, NULL); + const bool bRes = ReadFile(pImageInfo->hFile, pBlockBuffer, HD_BLOCK_SIZE, &dwBytesRead, NULL); if (!bRes || dwBytesRead != HD_BLOCK_SIZE) return false; } @@ -218,7 +218,7 @@ bool CImageBase::WriteImageData(ImageInfo* pImageInfo, LPBYTE pSrcBuffer, const } DWORD dwBytesWritten; - BOOL bRes = WriteFile(pImageInfo->hFile, pSrcBuffer, uSrcSize, &dwBytesWritten, NULL); + const bool bRes = WriteFile(pImageInfo->hFile, pSrcBuffer, uSrcSize, &dwBytesWritten, NULL); _ASSERT(dwBytesWritten == uSrcSize); if (!bRes || dwBytesWritten != uSrcSize) return false; @@ -360,7 +360,7 @@ void CImageBase::Decode62(LPBYTE imageptr) { // IF WE HAVEN'T ALREADY DONE SO, GENERATE A TABLE FOR CONVERTING // DISK BYTES BACK INTO 6-BIT BYTES - static BOOL tablegenerated = 0; + static bool tablegenerated = false; static BYTE sixbitbyte[0x80]; if (!tablegenerated) { @@ -370,7 +370,7 @@ void CImageBase::Decode62(LPBYTE imageptr) sixbitbyte[ms_DiskByte[loop]-0x80] = loop << 2; loop++; } - tablegenerated = 1; + tablegenerated = true; } // USING OUR TABLE, CONVERT THE DISK BYTES BACK INTO 6-BIT BYTES @@ -1889,7 +1889,7 @@ ImageError_e CImageHelperBase::CheckNormalFile(LPCTSTR pszImageFilename, ImageIn pImageInfo->pImageBuffer = new BYTE [dwSize]; DWORD dwBytesRead; - BOOL bRes = ReadFile(hFile, pImageInfo->pImageBuffer, dwSize, &dwBytesRead, NULL); + const bool bRes = ReadFile(hFile, pImageInfo->pImageBuffer, dwSize, &dwBytesRead, NULL); if (!bRes || dwSize != dwBytesRead) { delete [] pImageInfo->pImageBuffer; @@ -1941,7 +1941,7 @@ ImageError_e CImageHelperBase::CheckNormalFile(LPCTSTR pszImageFilename, ImageIn // As a convenience, resize the file to the complete size (GH#506) // - this also means that a save-state done mid-way through a format won't reference an image file with a partial size (GH#494) DWORD dwBytesWritten = 0; - BOOL res = WriteFile(hFile, pImageInfo->pImageBuffer, dwSize, &dwBytesWritten, NULL); + const bool res = WriteFile(hFile, pImageInfo->pImageBuffer, dwSize, &dwBytesWritten, NULL); if (!res || dwBytesWritten != dwSize) return eIMAGE_ERROR_FAILED_TO_INIT_ZEROLENGTH; } diff --git a/source/FourPlay.cpp b/source/FourPlay.cpp index e1bf1c25b..d7ecba55e 100644 --- a/source/FourPlay.cpp +++ b/source/FourPlay.cpp @@ -32,7 +32,7 @@ Bit 1 = Down, Active High Bit 2 = Left, Active High Bit 3 = Right, Active High - Bit 4 = Trigger 2, Active High + Bit 4 = Not Used, Always Low Bit 5 = Not Used, Always High Bit 6 = Trigger 2, Active High Bit 7 = Trigger 1, Active High @@ -53,19 +53,32 @@ #include "Memory.h" #include "YamlHelper.h" +inline static int bool_to_bit(bool b, int shift) +{ + return b ? (1 << shift) : 0; +} + +BYTE FourPlayCard::MakeByte(bool up, bool down, bool left, bool right, bool trigger1, bool trigger2) +{ + const int byte = bool_to_bit(up, 0) + | bool_to_bit(down, 1) + | bool_to_bit(left, 2) + | bool_to_bit(right, 3) + | bool_to_bit(false, 4) + | bool_to_bit(true, 5) + | bool_to_bit(trigger2, 6) + | bool_to_bit(trigger1, 7); + return byte; +} + BYTE __stdcall FourPlayCard::IORead(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG nExecutedCycles) { - BYTE nOutput = MemReadFloatingBus(nExecutedCycles); - BOOL up = 0; - BOOL down = 0; - BOOL left = 0; - BOOL right = 0; - BOOL trigger1 = 0; - BOOL trigger2 = 0; - BOOL trigger3 = 0; - BOOL alwaysHigh = 1; - UINT xAxis = 0; - UINT yAxis = 0; + bool up = false; + bool down = false; + bool left = false; + bool right = false; + bool trigger1 = false; + bool trigger2 = false; JOYINFOEX infoEx; infoEx.dwSize = sizeof(infoEx); @@ -76,49 +89,57 @@ BYTE __stdcall FourPlayCard::IORead(WORD pc, WORD addr, BYTE bWrite, BYTE value, case 0: // Joystick 1 if (GetJoystick1() >= 0 && joyGetPosEx(GetJoystick1(), &infoEx) == JOYERR_NOERROR) { - xAxis = (infoEx.dwXpos >> 8) & 0xFF; - yAxis = (infoEx.dwYpos >> 8) & 0xFF; - trigger1 = infoEx.dwButtons & 0x01; - trigger2 = (infoEx.dwButtons & 0x02) >> 1; + UINT xAxis = (infoEx.dwXpos >> 8) & 0xFF; + UINT yAxis = (infoEx.dwYpos >> 8) & 0xFF; + trigger1 = (infoEx.dwButtons & 0x01); + trigger2 = (infoEx.dwButtons & 0x02); up = yAxis < 103 || infoEx.dwPOV == 0 || infoEx.dwPOV == 4500 || infoEx.dwPOV == 31500; down = yAxis > 153 || (infoEx.dwPOV >= 13500 && infoEx.dwPOV <= 22500); left = xAxis < 103 || (infoEx.dwPOV >= 22500 && infoEx.dwPOV <= 31500); right = xAxis > 153 || (infoEx.dwPOV >= 4500 && infoEx.dwPOV <= 13500); } - nOutput = up | (down << 1) | (left << 2) | (right << 3) | (alwaysHigh << 5) | (trigger2 << 6) | (trigger1 << 7); break; case 1: // Joystick 2 if (GetJoystick2() >= 0 && joyGetPosEx(GetJoystick2(), &infoEx) == JOYERR_NOERROR) { - xAxis = (infoEx.dwXpos >> 8) & 0xFF; - yAxis = (infoEx.dwYpos >> 8) & 0xFF; - trigger1 = infoEx.dwButtons & 0x01; - trigger2 = (infoEx.dwButtons & 0x02) >> 1; + UINT xAxis = (infoEx.dwXpos >> 8) & 0xFF; + UINT yAxis = (infoEx.dwYpos >> 8) & 0xFF; + trigger1 = (infoEx.dwButtons & 0x01); + trigger2 = (infoEx.dwButtons & 0x02); up = yAxis < 103 || infoEx.dwPOV == 0 || infoEx.dwPOV == 4500 || infoEx.dwPOV == 31500; down = yAxis > 153 || (infoEx.dwPOV >= 13500 && infoEx.dwPOV <= 22500); left = xAxis < 103 || (infoEx.dwPOV >= 22500 && infoEx.dwPOV <= 31500); right = xAxis > 153 || (infoEx.dwPOV >= 4500 && infoEx.dwPOV <= 13500); } - nOutput = up | (down << 1) | (left << 2) | (right << 3) | (alwaysHigh << 5) | (trigger2 << 6) | (trigger1 << 7); break; case 2: // Joystick 3 - nOutput = FourPlayCard::JOYSTICKSTATIONARY; // esdf - direction buttons, zx - trigger buttons - nOutput = nOutput | (MyGetAsyncKeyState('E') | (MyGetAsyncKeyState('D') << 1) | (MyGetAsyncKeyState('S') << 2) | (MyGetAsyncKeyState('F') << 3) | (MyGetAsyncKeyState('X') << 6) | (MyGetAsyncKeyState('Z') << 7)); + // esdf - direction buttons, zx - trigger buttons + trigger1 = MyGetAsyncKeyState('Z'); + trigger2 = MyGetAsyncKeyState('X'); + up = MyGetAsyncKeyState('E'); + down = MyGetAsyncKeyState('D'); + left = MyGetAsyncKeyState('S'); + right = MyGetAsyncKeyState('F'); break; case 3: // Joystick 4 - nOutput = FourPlayCard::JOYSTICKSTATIONARY; // ijkl - direction buttons, nm - trigger buttons - nOutput = nOutput | (MyGetAsyncKeyState('I') | (MyGetAsyncKeyState('K') << 1) | (MyGetAsyncKeyState('J') << 2) | (MyGetAsyncKeyState('L') << 3) | (MyGetAsyncKeyState('M') << 6) | (MyGetAsyncKeyState('N') << 7)); + // ijkl - direction buttons, nm - trigger buttons + trigger1 = MyGetAsyncKeyState('N'); + trigger2 = MyGetAsyncKeyState('M'); + up = MyGetAsyncKeyState('I'); + down = MyGetAsyncKeyState('K'); + left = MyGetAsyncKeyState('J'); + right = MyGetAsyncKeyState('L'); break; default: - break; + return MemReadFloatingBus(nExecutedCycles); } - return nOutput; + return MakeByte(up, down, left, right, trigger1, trigger2); } -BYTE FourPlayCard::MyGetAsyncKeyState(int vKey) +bool FourPlayCard::MyGetAsyncKeyState(int vKey) { - return GetAsyncKeyState(vKey) < 0 ? 1 : 0; + return (GetAsyncKeyState(vKey) < 0); } void FourPlayCard::InitializeIO(LPBYTE pCxRomPeripheral) diff --git a/source/FourPlay.h b/source/FourPlay.h index 0d02ebfa7..0f225fd29 100644 --- a/source/FourPlay.h +++ b/source/FourPlay.h @@ -23,8 +23,7 @@ class FourPlayCard : public Card virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper); virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version); - static const UINT JOYSTICKSTATIONARY = 0x20; - private: - static BYTE MyGetAsyncKeyState(int vKey); + static bool MyGetAsyncKeyState(int vKey); + static BYTE MakeByte(bool up, bool down, bool left, bool right, bool trigger1, bool trigger2); }; diff --git a/source/FrameBase.cpp b/source/FrameBase.cpp index 5606aef43..bce6b2a57 100644 --- a/source/FrameBase.cpp +++ b/source/FrameBase.cpp @@ -127,7 +127,7 @@ std::string FrameBase::Util_MakeScreenShotFileName() const return StrFormat("%s%s_%09d.bmp", folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot); } -// Returns TRUE if file exists, else FALSE +// Returns true if file exists, else false bool FrameBase::Util_TestScreenShotFileName(const char* pFileName) { bool bFileExists = false; diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 2f463d0bb..e0dd86e06 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -432,7 +432,7 @@ bool HarddiskInterfaceCard::Insert(const int iDrive, const std::string& pathname if (dwAttributes == INVALID_FILE_ATTRIBUTES) m_hardDiskDrive[iDrive].m_bWriteProtected = false; // File doesn't exist - so ImageOpen() below will fail else - m_hardDiskDrive[iDrive].m_bWriteProtected = (dwAttributes & FILE_ATTRIBUTE_READONLY) ? true : false; + m_hardDiskDrive[iDrive].m_bWriteProtected = (dwAttributes & FILE_ATTRIBUTE_READONLY); // Check if image is being used by any other HDD, and unplug it in order to be swapped for (UINT i = HARDDISK_1; i < NUM_HARDDISKS; i++) @@ -1042,7 +1042,7 @@ BYTE HarddiskInterfaceCard::GetProDOSBlockDeviceUnit() HardDiskDrive* HarddiskInterfaceCard::GetUnit() { - const bool isSmartPortCmd = !!(m_command & SP_Cmd_base); + const bool isSmartPortCmd = (m_command & SP_Cmd_base); if (!isSmartPortCmd) return &m_hardDiskDrive[GetProDOSBlockDeviceUnit()]; diff --git a/source/Joystick.cpp b/source/Joystick.cpp index e69959852..e48aad9ed 100644 --- a/source/Joystick.cpp +++ b/source/Joystick.cpp @@ -77,12 +77,12 @@ const UINT PDL_MIN = 0; const UINT PDL_CENTRAL = 127; const UINT PDL_MAX = 255; -static BOOL keydown[JK_MAX] = {FALSE}; +static bool keydown[JK_MAX] = {false}; static POINT keyvalue[9] = {{PDL_MIN,PDL_MAX}, {PDL_CENTRAL,PDL_MAX}, {PDL_MAX,PDL_MAX}, {PDL_MIN,PDL_CENTRAL},{PDL_CENTRAL,PDL_CENTRAL},{PDL_MAX,PDL_CENTRAL}, {PDL_MIN,PDL_MIN}, {PDL_CENTRAL,PDL_MIN}, {PDL_MAX,PDL_MIN}}; -static BOOL joybutton[3] = {0,0,0}; +static bool joybutton[3] = {false, false, false}; static int joyshrx[2] = {8,8}; static int joyshry[2] = {8,8}; @@ -92,7 +92,7 @@ static int joysuby[2] = {0,0}; // Value persisted to Registry for REGVALUE_JOYSTICK0_EMU_TYPE static uint32_t joytype[JN_NUM] = { kJoystick_Default[JN_JOYSTICK0], kJoystick_Default[JN_JOYSTICK1] }; // Emulation Type for joysticks #0 & #1 -static BOOL setbutton[3] = {0,0,0}; // Used when a mouse button is pressed/released +static bool setbutton[3] = {false, false, false}; // Used when a mouse button is pressed/released static int xpos[2] = { PDL_MAX,PDL_MAX }; static int ypos[2] = { PDL_MAX,PDL_MAX }; @@ -348,7 +348,7 @@ void JoySetButtonVirtualKey(UINT button, UINT virtKey) #define SUPPORT_CURSOR_KEYS -BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) +bool JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) { static struct { @@ -365,32 +365,32 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) (virtKeyWithExtended != g_buttonVirtKey[0]) && (virtKeyWithExtended != g_buttonVirtKey[1]) ) { - return 0; + return false; } if (!g_bHookAltKeys && virtkey == VK_MENU) // GH#583 - return 0; + return false; // - BOOL keychange = 0; + bool keychange = false; bool bIsCursorKey = false; if (virtKeyWithExtended == g_buttonVirtKey[0]) { - keychange = 1; + keychange = true; keydown[JK_OPENAPPLE] = down; } else if (virtKeyWithExtended == g_buttonVirtKey[1]) { - keychange = 1; + keychange = true; keydown[JK_CLOSEDAPPLE] = down; } else if (!extended) { if (JoyUsingKeyboardNumpad()) { - keychange = 1; + keychange = true; if ((virtkey >= VK_NUMPAD1) && (virtkey <= VK_NUMPAD9)) // NumLock on { @@ -413,7 +413,7 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) case VK_NUMPAD0: keydown[JK_BUTTON0] = down; break; // NumLock on case VK_DELETE: // fall through... (NB. extended=0 for NumPad's Delete) case VK_DECIMAL: keydown[JK_BUTTON1] = down; break; // NumLock on - default: keychange = 0; break; + default: keychange = false; break; } } } @@ -423,7 +423,7 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) { if (JoyUsingKeyboardCursors() && (virtkey == VK_LEFT || virtkey == VK_UP || virtkey == VK_RIGHT || virtkey == VK_DOWN)) { - keychange = 1; // This prevents cursors keys being available to the Apple II (eg. Lode Runner uses cursor left/right for game speed & Ctrl-J/K for joystick/keyboard) + keychange = true; // This prevents cursors keys being available to the Apple II (eg. Lode Runner uses cursor left/right for game speed & Ctrl-J/K for joystick/keyboard) bIsCursorKey = true; switch (virtkey) @@ -438,7 +438,7 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) #endif if (!keychange) - return 0; + return false; // @@ -500,23 +500,23 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) if (bIsCursorKey && GetPropertySheet().GetJoystickCursorControl()) { // Allow AppleII keyboard to see this cursor keypress too - return 0; + return false; } - return 1; + return true; } //=========================================================================== -static void DoAutofire(UINT uButton, BOOL& pressed) +static void DoAutofire(UINT uButton, bool& pressed) { - static BOOL toggle[3] = {0,0,0}; - static BOOL lastPressed[3] = {0,0,0}; + static bool toggle[3] = {false, false, false}; + static bool lastPressed[3] = {false, false, false}; - BOOL nowPressed = pressed; + bool nowPressed = pressed; if (GetPropertySheet().GetAutofire(uButton) && pressed) { - toggle[uButton] = (!lastPressed[uButton]) ? TRUE : !toggle[uButton]; + toggle[uButton] = (!lastPressed[uButton]) ? true : !toggle[uButton]; pressed = pressed && toggle[uButton]; } lastPressed[uButton] = nowPressed; @@ -524,7 +524,7 @@ static void DoAutofire(UINT uButton, BOOL& pressed) BYTE __stdcall JoyportReadButton(WORD address, ULONG nExecutedCycles) { - BOOL pressed = 0; + bool pressed = false; if (g_uJoyportActiveStick == 0) { @@ -540,12 +540,12 @@ BYTE __stdcall JoyportReadButton(WORD address, ULONG nExecutedCycles) if (g_uJoyportReadMode == JOYPORT_LEFTRIGHT) // LEFT { if (xpos[0] == 0) // TODO: More range for mouse control? - pressed = 1; + pressed = true; } else // UP { if (ypos[0] == 0) // TODO: More range for mouse control? - pressed = 1; + pressed = true; } break; @@ -553,12 +553,12 @@ BYTE __stdcall JoyportReadButton(WORD address, ULONG nExecutedCycles) if (g_uJoyportReadMode == JOYPORT_LEFTRIGHT) // RIGHT { if (xpos[0] >= 255) // TODO: More range for mouse control? - pressed = 1; + pressed = true; } else // DOWN { if (ypos[0] >= 255) // TODO: More range for mouse control? - pressed = 1; + pressed = true; } break; } @@ -567,14 +567,14 @@ BYTE __stdcall JoyportReadButton(WORD address, ULONG nExecutedCycles) { } - pressed = pressed ? 0 : 1; // Invert as Joyport signals are active low + pressed = !pressed; // Invert as Joyport signals are active low return MemReadFloatingBus(pressed, nExecutedCycles); } -static BOOL CheckButton0Pressed() +static bool CheckButton0Pressed() { - BOOL pressed = joybutton[0] || + bool pressed = joybutton[0] || setbutton[0] || keydown[JK_OPENAPPLE]; @@ -584,9 +584,9 @@ static BOOL CheckButton0Pressed() return pressed; } -static BOOL CheckButton1Pressed() +static bool CheckButton1Pressed() { - BOOL pressed = joybutton[1] || + bool pressed = joybutton[1] || setbutton[1] || keydown[JK_CLOSEDAPPLE]; @@ -614,7 +614,7 @@ BYTE __stdcall JoyReadButton(WORD pc, WORD address, BYTE, BYTE, ULONG nExecutedC const bool swapButtons0and1 = GetPropertySheet().GetButtonsSwapState(); - BOOL pressed = FALSE; + bool pressed = false; switch (address) { case 0x61: @@ -680,14 +680,14 @@ BYTE __stdcall JoyReadPosition(WORD programcounter, WORD address, BYTE, BYTE, UL { CpuCalcCycles(nExecutedCycles); - BOOL nPdlCntrActive = g_nCumulativeCycles <= g_paddleInactiveCycle[address & 3]; + bool bPdlCntrActive = g_nCumulativeCycles <= g_paddleInactiveCycle[address & 3]; // If no joystick connected, then this is always active (GH#778) && no copy-protection dongle connected const UINT joyNum = (address & 2) ? 1 : 0; // $C064..$C067 if (joyinfo[joytype[joyNum]] == DEVICE_NONE && CopyProtectionDonglePDL(address & 3) < 0) - nPdlCntrActive = TRUE; + bPdlCntrActive = true; - return MemReadFloatingBus(nPdlCntrActive, nExecutedCycles); + return MemReadFloatingBus(bPdlCntrActive, nExecutedCycles); } //=========================================================================== @@ -695,7 +695,7 @@ void JoyReset() { int loop = 0; while (loop < JK_MAX) - keydown[loop++] = FALSE; + keydown[loop++] = false; } //=========================================================================== @@ -792,14 +792,14 @@ void JoySetButton(eBUTTON number, eBUTTONSTATE down) number = BUTTON1; // 2nd joystick controls Apple button #1 } - setbutton[number] = down; + setbutton[number] = (down == BUTTON_DOWN); } //=========================================================================== -BOOL JoySetEmulationType(HWND window, uint32_t newtype, int nJoystickNumber, const bool bMousecardActive) +bool JoySetEmulationType(HWND window, uint32_t newtype, int nJoystickNumber, const bool bMousecardActive) { if(joytype[nJoystickNumber] == newtype) - return 1; // Already set to this type. Return OK. + return true; // Already set to this type. Return OK. if (joyinfo[newtype] == DEVICE_JOYSTICK || joyinfo[newtype] == DEVICE_JOYSTICK_THUMBSTICK2) { @@ -815,7 +815,7 @@ BOOL JoySetEmulationType(HWND window, uint32_t newtype, int nJoystickNumber, con "you have a joystick driver installed.", "Configuration", MB_ICONEXCLAMATION | MB_SETFOREGROUND); - return 0; + return false; } if ((joyinfo[newtype] == DEVICE_JOYSTICK_THUMBSTICK2) && (caps.wNumAxes < 4)) { @@ -826,7 +826,7 @@ BOOL JoySetEmulationType(HWND window, uint32_t newtype, int nJoystickNumber, con "you have a joystick driver installed.", "Configuration", MB_ICONEXCLAMATION | MB_SETFOREGROUND); - return 0; + return false; } } else if ((joyinfo[newtype] == DEVICE_MOUSE) && @@ -839,7 +839,7 @@ BOOL JoySetEmulationType(HWND window, uint32_t newtype, int nJoystickNumber, con "Mouse interface card is enabled - unable to use mouse for joystick emulation.", "Configuration", MB_ICONEXCLAMATION | MB_SETFOREGROUND); - return 0; + return false; } MessageBox(window, @@ -873,7 +873,7 @@ BOOL JoySetEmulationType(HWND window, uint32_t newtype, int nJoystickNumber, con joytype[nJoystickNumber] = newtype; JoyInitialize(); JoyReset(); - return 1; + return true; } @@ -889,22 +889,22 @@ void JoySetPosition(int xvalue, int xrange, int yvalue, int yrange) //=========================================================================== -BOOL JoyUsingMouse() +bool JoyUsingMouse() { return (joyinfo[joytype[0]] == DEVICE_MOUSE) || (joyinfo[joytype[1]] == DEVICE_MOUSE); } -BOOL JoyUsingKeyboard() +bool JoyUsingKeyboard() { return (joyinfo[joytype[0]] == DEVICE_KEYBOARD) || (joyinfo[joytype[1]] == DEVICE_KEYBOARD); } -BOOL JoyUsingKeyboardCursors() +bool JoyUsingKeyboardCursors() { return (joytype[0] == J0C_KEYBD_CURSORS) || (joytype[1] == J1C_KEYBD_CURSORS); } -BOOL JoyUsingKeyboardNumpad() +bool JoyUsingKeyboardNumpad() { return (joytype[0] == J0C_KEYBD_NUMPAD) || (joytype[1] == J1C_KEYBD_NUMPAD); } diff --git a/source/Joystick.h b/source/Joystick.h index 249dd1e1e..af7f8a345 100644 --- a/source/Joystick.h +++ b/source/Joystick.h @@ -13,15 +13,15 @@ const SHORT kPdlXTrim_Default = 0; const SHORT kPdlYTrim_Default = 0; void JoyInitialize(); -BOOL JoyProcessKey(int,bool,bool,bool); +bool JoyProcessKey(int, bool, bool, bool); void JoyReset(); -void JoySetButton(eBUTTON,eBUTTONSTATE); -BOOL JoySetEmulationType(HWND,uint32_t,int, const bool bMousecardActive); -void JoySetPosition(int,int,int,int); -BOOL JoyUsingMouse(); -BOOL JoyUsingKeyboard(); -BOOL JoyUsingKeyboardCursors(); -BOOL JoyUsingKeyboardNumpad(); +void JoySetButton(eBUTTON, eBUTTONSTATE); +bool JoySetEmulationType(HWND, uint32_t, int, const bool bMousecardActive); +void JoySetPosition(int, int, int, int); +bool JoyUsingMouse(); +bool JoyUsingKeyboard(); +bool JoyUsingKeyboardCursors(); +bool JoyUsingKeyboardNumpad(); void JoyDisableUsingMouse(); void JoySetJoyType(UINT num, uint32_t type); uint32_t JoyGetJoyType(UINT num); diff --git a/source/Keyboard.cpp b/source/Keyboard.cpp index 60f6a92b7..1e98391bc 100644 --- a/source/Keyboard.cpp +++ b/source/Keyboard.cpp @@ -51,7 +51,7 @@ static bool g_bTK3KModeKey = false; //TK3000 //e |Mode| key static bool g_bCapsLock = true; //Caps lock key for Apple2 and Lat/Cyr lock for Pravets8 static BYTE keycode = 0; // Current Apple keycode -static BOOL keywaiting = 0; +static bool keywaiting = false; static bool g_bAltGrSendsWM_CHAR = false; // @@ -73,7 +73,7 @@ void KeybSetCapsLock(bool state) void KeybReset() { keycode = 0; - keywaiting = 0; + keywaiting = false; } //=========================================================================== @@ -103,9 +103,9 @@ bool KeybGetShiftStatus() //=========================================================================== void KeybUpdateCtrlShiftStatus() { - g_bAltKey = (GetKeyState( VK_MENU ) < 0) ? true : false; // L or R alt - g_bCtrlKey = (GetKeyState( VK_CONTROL) < 0) ? true : false; // L or R ctrl - g_bShiftKey = (GetKeyState( VK_SHIFT ) < 0) ? true : false; // L or R shift + g_bAltKey = (GetKeyState( VK_MENU ) < 0); // L or R alt + g_bCtrlKey = (GetKeyState( VK_CONTROL) < 0); // L or R ctrl + g_bShiftKey = (GetKeyState( VK_SHIFT ) < 0); // L or R shift } //=========================================================================== @@ -213,7 +213,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) { // For the TK3000 //e we use Scroll Lock to switch between Apple ][ and accented chars modes if (GetApple2Type() == A2TYPE_TK30002E) { - g_bTK3KModeKey = (GetKeyState(VK_SCROLL) & 1) ? true : false; // Sync with the Scroll Lock status + g_bTK3KModeKey = (GetKeyState(VK_SCROLL) & 1); // Sync with the Scroll Lock status GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); // TODO: Implement |Mode| LED in the UI; make it appear only when in TK3000 mode GetFrame().VideoRedrawScreen(); // TODO: Still need to implement page mode switching and 'whatnot' } @@ -256,7 +256,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) } } - keywaiting = 1; + keywaiting = true; } //=========================================================================== @@ -429,7 +429,7 @@ BYTE KeybReadData() BYTE KeybClearStrobe() { - keywaiting = 0; + keywaiting = false; return ClipboardReadOrPeek(true); } @@ -472,7 +472,7 @@ void KeybSaveSnapshot(YamlSaveHelper& yamlSaveHelper) { YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", KeybGetSnapshotStructName().c_str()); yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_LASTKEY, keycode); - yamlSaveHelper.SaveBool(SS_YAML_KEY_KEYWAITING, keywaiting ? true : false); + yamlSaveHelper.SaveBool(SS_YAML_KEY_KEYWAITING, keywaiting); } void KeybLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) @@ -483,7 +483,7 @@ void KeybLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) keycode = (BYTE) yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTKEY); if (version >= 2) - keywaiting = (BOOL) yamlLoadHelper.LoadBool(SS_YAML_KEY_KEYWAITING); + keywaiting = yamlLoadHelper.LoadBool(SS_YAML_KEY_KEYWAITING); yamlLoadHelper.PopMap(); } diff --git a/source/LanguageCard.cpp b/source/LanguageCard.cpp index 8e7475344..6a3e62c60 100644 --- a/source/LanguageCard.cpp +++ b/source/LanguageCard.cpp @@ -68,7 +68,7 @@ LanguageCardUnit * LanguageCardUnit::create(UINT slot) LanguageCardUnit::LanguageCardUnit(SS_CARDTYPE type, UINT slot) : Card(type, slot), - m_uLastRamWrite(0), + m_bLastRamWrite(false), m_memMode(kMemModeInitialState), m_pMemory(NULL) { @@ -145,7 +145,7 @@ BYTE __stdcall LanguageCardUnit::IO(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValu memmode &= ~MF_WRITERAM; // UTAIIe:5-23 } - pLC->SetLastRamWrite( ((uAddr & 1) && !bWrite) ); // UTAIIe:5-23 + pLC->SetLastRamWrite((uAddr & 1) && !bWrite); // UTAIIe:5-23 pLC->SetLCMemMode(memmode); const bool bCardChanged = GetCardMgr().GetLanguageCardMgr().GetLastSlotToSetMainMemLC() != SLOT0; @@ -257,13 +257,15 @@ const std::string& LanguageCardSlot0::GetSnapshotCardName() void LanguageCardSlot0::SaveLCState(YamlSaveHelper& yamlSaveHelper) { yamlSaveHelper.SaveHexUint32(SS_YAML_KEY_MEMORYMODE, GetLCMemMode() & MF_LANGCARD_MASK); - yamlSaveHelper.SaveUint(SS_YAML_KEY_LASTRAMWRITE, GetLastRamWrite() ? 1 : 0); + // SS_YAML_KEY_LASTRAMWRITE is saved/loaded as Uint for backward compatibility. + yamlSaveHelper.SaveUint(SS_YAML_KEY_LASTRAMWRITE, GetLastRamWrite()); } void LanguageCardSlot0::LoadLCState(YamlLoadHelper& yamlLoadHelper) { UINT memMode = yamlLoadHelper.LoadUint(SS_YAML_KEY_MEMORYMODE) & MF_LANGCARD_MASK; - BOOL lastRamWrite = yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTRAMWRITE) ? TRUE : FALSE; + // SS_YAML_KEY_LASTRAMWRITE is saved/loaded as Uint for backward compatibility. + bool lastRamWrite = yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTRAMWRITE); SetLCMemMode(memMode); SetLastRamWrite(lastRamWrite); } @@ -444,7 +446,7 @@ BYTE __stdcall Saturn128K::IO(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULO else memmode &= ~MF_WRITERAM; - pLC->SetLastRamWrite(uAddr & 1); // Saturn differs from Apple's 16K LC: any access (LC is read-only) + pLC->SetLastRamWrite((uAddr & 1)); // Saturn differs from Apple's 16K LC: any access (LC is read-only) pLC->SetLCMemMode(memmode); bBankChanged = GetCardMgr().GetLanguageCardMgr().GetLastSlotToSetMainMemLC() != uSlot; @@ -616,7 +618,7 @@ void LanguageCardManager::Reset(const bool powerCycle /*=false*/) return; // if (GetLanguageCard()) // Redundant: done via GetCardMgr().Reset() -// GetLanguageCard()->SetLastRamWrite(0); +// GetLanguageCard()->SetLastRamWrite(false); if (IsApple2PlusOrClone(GetApple2Type()) && GetCardMgr().QuerySlot(SLOT0) == CT_Empty) ::SetMemMode(0); diff --git a/source/LanguageCard.h b/source/LanguageCard.h index f1e37601d..2f4abdba1 100644 --- a/source/LanguageCard.h +++ b/source/LanguageCard.h @@ -25,9 +25,9 @@ class LanguageCardUnit : public Card virtual void SetMainMemLanguageCardMemory(); - BOOL GetLastRamWrite() { return m_uLastRamWrite; } - void SetLastRamWrite(BOOL count) { m_uLastRamWrite = count; } - UINT GetLCMemMode() { return m_memMode; } + bool GetLastRamWrite() const { return m_bLastRamWrite; } + void SetLastRamWrite(bool bLastRamWrite) { m_bLastRamWrite = bLastRamWrite; } + UINT GetLCMemMode() const { return m_memMode; } void SetLCMemMode(UINT memMode) { m_memMode = memMode; } SS_CARDTYPE GetMemoryType() { return QueryType(); } bool IsOpcodeRMWabs(WORD addr); @@ -44,7 +44,7 @@ class LanguageCardUnit : public Card LPBYTE m_pMemory; private: - UINT m_uLastRamWrite; + bool m_bLastRamWrite; UINT m_memMode; }; diff --git a/source/Memory.cpp b/source/Memory.cpp index 79fb72ead..43e121545 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -436,17 +436,17 @@ UINT GetRamWorksActiveBank() // -static BOOL GetLastRamWrite() +static bool GetLastRamWrite() { if (GetCardMgr().GetLanguageCardMgr().GetLanguageCard()) return GetCardMgr().GetLanguageCardMgr().GetLanguageCard()->GetLastRamWrite(); - return 0; + return false; } -static void SetLastRamWrite(BOOL count) +static void SetLastRamWrite(bool bLastRamWrite) { if (GetCardMgr().GetLanguageCardMgr().GetLanguageCard()) - GetCardMgr().GetLanguageCardMgr().GetLanguageCard()->SetLastRamWrite(count); + GetCardMgr().GetLanguageCardMgr().GetLanguageCard()->SetLastRamWrite(bLastRamWrite); } // @@ -588,18 +588,18 @@ static BYTE __stdcall IORead_C01x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG switch (addr & 0xf) { case 0x0: return KeybReadFlag(); - case 0x1: res = SW_BANK2 ? true : false; break; - case 0x2: res = SW_HIGHRAM ? true : false; break; - case 0x3: res = SW_AUXREAD ? true : false; break; - case 0x4: res = SW_AUXWRITE ? true : false; break; - case 0x5: res = SW_INTCXROM ? true : false; break; - case 0x6: res = SW_ALTZP ? true : false; break; - case 0x7: res = SW_SLOTC3ROM ? true : false; break; - case 0x8: res = SW_80STORE ? true : false; break; + case 0x1: res = SW_BANK2; break; + case 0x2: res = SW_HIGHRAM; break; + case 0x3: res = SW_AUXREAD; break; + case 0x4: res = SW_AUXWRITE; break; + case 0x5: res = SW_INTCXROM; break; + case 0x6: res = SW_ALTZP; break; + case 0x7: res = SW_SLOTC3ROM; break; + case 0x8: res = SW_80STORE; break; case 0x9: res = GetVideo().VideoGetVblBar(nExecutedCycles); break; case 0xA: res = GetVideo().VideoGetSWTEXT(); break; case 0xB: res = GetVideo().VideoGetSWMIXED(); break; - case 0xC: res = SW_PAGE2 ? true : false; break; + case 0xC: res = SW_PAGE2; break; case 0xD: res = GetVideo().VideoGetSWHIRES(); break; case 0xE: res = GetVideo().VideoGetSWAltCharSet(); break; case 0xF: res = GetVideo().VideoGetSW80COL(); break; @@ -771,7 +771,7 @@ static BYTE __stdcall IORead_C07x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG case 0xB: return IO_Null(pc, addr, bWrite, d, nExecutedCycles); case 0xC: return IO_Null(pc, addr, bWrite, d, nExecutedCycles); case 0xD: return IO_Null(pc, addr, bWrite, d, nExecutedCycles); - case 0xE: return IS_APPLE2C() ? MemReadFloatingBus(SW_IOUDIS ? true : false, nExecutedCycles) // GH#636 + case 0xE: return IS_APPLE2C() ? MemReadFloatingBus(SW_IOUDIS, nExecutedCycles) // GH#636 : IO_Null(pc, addr, bWrite, d, nExecutedCycles); case 0xF: return IsEnhancedIIEorIIC() ? MemReadFloatingBus(GetVideo().VideoGetSWDHIRES(), nExecutedCycles) // GH#636 : IO_Null(pc, addr, bWrite, d, nExecutedCycles); @@ -883,7 +883,7 @@ BYTE __stdcall IO_Annunciator(WORD programcounter, WORD address, BYTE write, BYT DongleControl(address); // do before setting g_Annunciator[] as may need to access old MemGetAnnunciator() state - g_Annunciator[(address>>1) & 3] = (address&1) ? true : false; + g_Annunciator[(address>>1) & 3] = (address & 1); if (address >= 0xC058 && address <= 0xC05B) JoyportControl(address & 0x3); // AN0 and AN1 control @@ -1635,12 +1635,12 @@ void MemDestroy() bool MemCheckSLOTC3ROM() { - return SW_SLOTC3ROM ? true : false; + return SW_SLOTC3ROM; } bool MemCheckINTCXROM() { - return SW_INTCXROM ? true : false; + return SW_INTCXROM; } //=========================================================================== @@ -2142,11 +2142,11 @@ void MemInitializeCustomF8ROM() SetFilePointer(g_hCustomRomF8, 0, NULL, FILE_BEGIN); DWORD uNumBytesRead; - BOOL bRes = ReadFile(g_hCustomRomF8, memrom+F8RomOffset, F8RomSize, &uNumBytesRead, NULL); + bool bRes = ReadFile(g_hCustomRomF8, memrom+F8RomOffset, F8RomSize, &uNumBytesRead, NULL); if (uNumBytesRead != F8RomSize) { memcpy(memrom, &oldRom[0], Apple2RomSize); // ROM at $D000...$FFFF - bRes = FALSE; + bRes = false; } // NB. If succeeded, then keep g_hCustomRomF8 handle open - so that any next restart can load it again @@ -2177,7 +2177,7 @@ void MemInitializeCustomROM() SetFilePointer(g_hCustomRom, 0, NULL, FILE_BEGIN); DWORD uNumBytesRead; - BOOL bRes = TRUE; + bool bRes = true; if (GetFileSize(g_hCustomRom, NULL) == Apple2eRomSize) { @@ -2186,7 +2186,7 @@ void MemInitializeCustomROM() if (uNumBytesRead != CxRomSize) { memcpy(pCxRomInternal, &oldRomC0[0], CxRomSize); // ROM at $C000...$CFFF - bRes = FALSE; + bRes = false; } } @@ -2197,7 +2197,7 @@ void MemInitializeCustomROM() if (uNumBytesRead != Apple2RomSize) { memcpy(memrom, &oldRom[0], Apple2RomSize); // ROM at $D000...$FFFF - bRes = FALSE; + bRes = false; } } @@ -2475,7 +2475,7 @@ BYTE MemReadFloatingBus(const ULONG uExecutedCycles) return ReadFloatingBus(uExecutedCycles, g_bFullSpeed); } -BYTE MemReadFloatingBus(const BYTE highbit, const ULONG uExecutedCycles) +BYTE MemReadFloatingBus(const bool highbit, const ULONG uExecutedCycles) { BYTE r = ReadFloatingBus(uExecutedCycles, g_bFullSpeed); return (r & ~0x80) | (highbit ? 0x80 : 0); @@ -2841,10 +2841,12 @@ void MemSaveSnapshot(YamlSaveHelper& yamlSaveHelper) if (!IsApple2PlusOrClone(GetApple2Type())) // NB. Thesed are set later for II,II+ by slot-0 LC or Saturn { yamlSaveHelper.SaveHexUint32(SS_YAML_KEY_MMULCMODE, g_memmode & MF_LANGCARD_MASK); - yamlSaveHelper.SaveUint(SS_YAML_KEY_LASTRAMWRITE, GetLastRamWrite() ? 1 : 0); + // SS_YAML_KEY_LASTRAMWRITE is saved/loaded as Uint for backward compatibility. + yamlSaveHelper.SaveUint(SS_YAML_KEY_LASTRAMWRITE, GetLastRamWrite()); } yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_IOSELECT, IO_SELECT); - yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_IOSELECT_INT, INTC8ROM ? 1 : 0); + // SS_YAML_KEY_IOSELECT_INT is saved/loaded as HexUint8 for backward compatibility. + yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_IOSELECT_INT, INTC8ROM); yamlSaveHelper.SaveUint(SS_YAML_KEY_EXPANSIONROMTYPE, (UINT) g_eExpansionRomType); yamlSaveHelper.SaveUint(SS_YAML_KEY_PERIPHERALROMSLOT, g_uPeripheralRomSlot); yamlSaveHelper.SaveUint(SS_YAML_KEY_LASTSLOTTOSETMAINMEMLC, GetCardMgr().GetLanguageCardMgr().GetLastSlotToSetMainMemLC()); @@ -2880,7 +2882,8 @@ bool MemLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) // IO_SELECT = (BYTE) yamlLoadHelper.LoadUint(SS_YAML_KEY_IOSELECT); - INTC8ROM = yamlLoadHelper.LoadUint(SS_YAML_KEY_IOSELECT_INT) ? true : false; + // SS_YAML_KEY_IOSELECT_INT is saved/loaded as HexUint8 for backward compatibility. + INTC8ROM = yamlLoadHelper.LoadUint(SS_YAML_KEY_IOSELECT_INT); g_eExpansionRomType = (eExpansionRomType) yamlLoadHelper.LoadUint(SS_YAML_KEY_EXPANSIONROMTYPE); g_uPeripheralRomSlot = yamlLoadHelper.LoadUint(SS_YAML_KEY_PERIPHERALROMSLOT); @@ -2892,7 +2895,8 @@ bool MemLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) if (GetCardMgr().GetLanguageCardMgr().GetLanguageCard()) GetCardMgr().GetLanguageCardMgr().GetLanguageCard()->SetLCMemMode(uMemMode & MF_LANGCARD_MASK); - SetLastRamWrite(yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTRAMWRITE) ? TRUE : FALSE); + // SS_YAML_KEY_LASTRAMWRITE is saved/loaded as Uint for backward compatibility. + SetLastRamWrite(yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTRAMWRITE)); } else { @@ -2914,7 +2918,8 @@ bool MemLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) UINT LCMemMode = yamlLoadHelper.LoadUint(SS_YAML_KEY_MMULCMODE); GetCardMgr().GetLanguageCardMgr().GetLanguageCard()->SetLCMemMode(LCMemMode); } - SetLastRamWrite(yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTRAMWRITE) ? TRUE : FALSE); + // SS_YAML_KEY_LASTRAMWRITE is saved/loaded as Uint for backward compatibility. + SetLastRamWrite(yamlLoadHelper.LoadUint(SS_YAML_KEY_LASTRAMWRITE)); } } diff --git a/source/Memory.h b/source/Memory.h index 085d607c5..d78b7dc2c 100644 --- a/source/Memory.h +++ b/source/Memory.h @@ -80,7 +80,7 @@ void MemInitializeCustomF8ROM(); void MemInitializeIO(); void MemInitializeFromSnapshot(); BYTE MemReadFloatingBus(const ULONG uExecutedCycles); -BYTE MemReadFloatingBus(const BYTE highbit, const ULONG uExecutedCycles); +BYTE MemReadFloatingBus(const bool highbit, const ULONG uExecutedCycles); BYTE MemReadFloatingBusFromNTSC(); void MemReset (); void MemResetPaging (); diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 8c2f80a8f..e348d339b 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -114,7 +114,7 @@ MockingboardCard::MockingboardCard(UINT slot, SS_CARDTYPE type) : Card(type, slo { uint32_t hasSC01; std::string regSection = RegGetConfigSlotSection(m_slot); - RegLoadValue(regSection.c_str(), REGVALUE_MOCKINGBOARD_SC01, true, &hasSC01, kSC01_Default == SC01 ? TRUE : FALSE); + RegLoadValue(regSection.c_str(), REGVALUE_MOCKINGBOARD_SC01, true, &hasSC01, kSC01_Default == SC01 ? 1 : 0); m_MBSubUnit[i].ssi263.SetSC01(hasSC01 ? SC01 : SSI263Empty); } } @@ -458,7 +458,7 @@ bool MockingboardCard::Is6522IRQ() // . OR-sum of all active TIMER1, TIMER2 & SPEECH sources (from all 6522s) bool irq = false; for (UINT i = 0; i < NUM_SUBUNITS_PER_MB; i++) - irq |= m_MBSubUnit[i].sy6522.GetReg(SY6522::rIFR) & 0x80 ? true : false; + irq |= ((m_MBSubUnit[i].sy6522.GetReg(SY6522::rIFR) & 0x80) != 0); // NB. Mockingboard generates IRQ on both 6522s: // . SSI263's IRQ (A/!R) is routed via the 2nd 6522's CA1 input (at $Cn80) and must generate a 6502 IRQ (not NMI) @@ -698,7 +698,7 @@ BYTE MockingboardCard::IOReadInternal(WORD PC, WORD nAddr, BYTE bWrite, BYTE nVa if (CS & 2) nRes |= m_MBSubUnit[SY6522_DEVICE_B].sy6522.Read(nAddr & 0xf); - bool bAccessedDevice = (CS & 3) ? true : false; + bool bAccessedDevice = (CS & 3); bool CS_SSI263 = !(nAddr & 0x10) && (nAddr & 0x60) && !(nAddr & 0x80); // SSI263 at $Cn2x and/or $Cn4x @@ -806,9 +806,9 @@ BYTE MockingboardCard::IOWriteInternal(WORD PC, WORD nAddr, BYTE bWrite, BYTE nV if (m_phasorMode == PH_Mockingboard || m_phasorMode == PH_Phasor) // No SSI263 for Echo+ { // Confirmed that Phasor has no extra logic to map SSI263 (it's the same as Mockingboard's) - bool CS_SSI263_A = !!(nAddr & 0x40); // SSI263 at $Cn4x-Cn7x, $CnCx-CnFx + bool CS_SSI263_A = (nAddr & 0x40); // SSI263 at $Cn4x-Cn7x, $CnCx-CnFx - bool CS_SSI263_B = !!(nAddr & 0x20); // SSI263 at $Cn2x-Cn3x, $Cn6x-Cn7x, $CnAx-CnBx, $CnEx-CnFx + bool CS_SSI263_B = (nAddr & 0x20); // SSI263 at $Cn2x-Cn3x, $Cn6x-Cn7x, $CnAx-CnBx, $CnEx-CnFx // NB. Mockingboard mode: writes to $Cn4x/SSI263 also get written to 1st 6522 (have confirmed on real Phasor h/w) if (CS_SSI263_A) // Primary SSI263 diff --git a/source/Mockingboard.h b/source/Mockingboard.h index fda02882a..b6f055628 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -109,7 +109,7 @@ class MockingboardCard : public Card nAYCurrentRegister[0] = nAYCurrentRegister[1] = 0; // not valid state[0] = state[1] = AY_INACTIVE; isAYLatchedAddressValid[0] = isAYLatchedAddressValid[1] = false; // after AY reset - isChipSelected[0] = type == CT_Phasor ? false : true; // Only Phasor is false, all other MB variants are true + isChipSelected[0] = (type != CT_Phasor); // Only Phasor is false, all other MB variants are true isChipSelected[1] = false; SetBusState(false); } diff --git a/source/NTSC.cpp b/source/NTSC.cpp index 3743e7b7c..f8c2e2733 100644 --- a/source/NTSC.cpp +++ b/source/NTSC.cpp @@ -1879,8 +1879,8 @@ void updateScreenSHR(long cycles6502) uint8_t* pControl = MemGetAuxPtr(0x9D00 + g_nVideoClockVert); // scan-line control byte uint8_t c = pControl[0]; - bool is640Mode = !!(c & 0x80); - bool isColorFillMode = !!(c & 0x20); + bool is640Mode = (c & 0x80); + bool isColorFillMode = (c & 0x20); UINT paletteSelectCode = c & 0xf; const UINT kColorsPerPalette = 16; const UINT kColorSize = 2; diff --git a/source/ParallelPrinter.cpp b/source/ParallelPrinter.cpp index 9e7a782bb..67e11fd86 100644 --- a/source/ParallelPrinter.cpp +++ b/source/ParallelPrinter.cpp @@ -184,16 +184,16 @@ void ParallelPrinterCard::GetRegistryConfig() char szFilename[MAX_PATH]; if (RegLoadValue(regSection.c_str(), REGVALUE_DUMP_TO_PRINTER, true, &dwTmp)) - SetDumpToPrinter(dwTmp ? true : false); + SetDumpToPrinter(dwTmp != 0); if (RegLoadValue(regSection.c_str(), REGVALUE_CONVERT_ENCODING, true, &dwTmp)) - SetConvertEncoding(dwTmp ? true : false); + SetConvertEncoding(dwTmp != 0); if (RegLoadValue(regSection.c_str(), REGVALUE_FILTER_UNPRINTABLE, true, &dwTmp)) - SetFilterUnprintable(dwTmp ? true : false); + SetFilterUnprintable(dwTmp != 0); if (RegLoadValue(regSection.c_str(), REGVALUE_PRINTER_APPEND, true, &dwTmp)) - SetPrinterAppend(dwTmp ? true : false); + SetPrinterAppend(dwTmp != 0); if (RegLoadString(regSection.c_str(), REGVALUE_PRINTER_FILENAME, true, szFilename, MAX_PATH, "")) SetFilename(szFilename); @@ -239,7 +239,7 @@ void ParallelPrinterCard::SaveSnapshot(class YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveUint(SS_YAML_KEY_INACTIVITY, m_inactivity); yamlSaveHelper.SaveUint(SS_YAML_KEY_IDLELIMIT, m_printerIdleLimit); yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, m_szPrintFilename); - yamlSaveHelper.SaveBool(SS_YAML_KEY_FILEOPEN, (m_file != NULL) ? true : false); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FILEOPEN, (m_file != NULL)); yamlSaveHelper.SaveBool(SS_YAML_KEY_DUMPTOPRINTER, m_bDumpToPrinter); yamlSaveHelper.SaveBool(SS_YAML_KEY_CONVERTENCODING, m_bConvertEncoding); yamlSaveHelper.SaveBool(SS_YAML_KEY_FILTERUNPRINTABLE, m_bFilterUnprintable); @@ -260,7 +260,7 @@ bool ParallelPrinterCard::LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UIN { yamlLoadHelper.LoadBool(SS_YAML_KEY_APPEND); // Consume m_bPrinterAppend = true; // Re-open print-file in append mode - BOOL bRes = CheckPrint(); + const bool bRes = CheckPrint(); if (!bRes) throw std::runtime_error("Printer Card: Unable to resume printing to file"); } diff --git a/source/RGBMonitor.cpp b/source/RGBMonitor.cpp index 0a1080f95..8d1dc2b32 100644 --- a/source/RGBMonitor.cpp +++ b/source/RGBMonitor.cpp @@ -671,10 +671,10 @@ void UpdateHiResRGBCell(int x, int y, uint16_t addr, bgra_t* pVideoAddress) int color = 0; uint32_t dwordval_tmp = dwordval; dwordval_tmp = dwordval_tmp >> 7; - bool offset = (byteval2 & 0x80) ? true : false; + bool offset = (byteval2 & 0x80); for (int i = 0; i < 14; i++) { - if (i == 7) offset = (byteval3 & 0x80) ? true : false; + if (i == 7) offset = (byteval3 & 0x80); color = dwordval_tmp & 0x3; // Two cases because AppleWin's palette is in a strange order if (offset) diff --git a/source/Registry.cpp b/source/Registry.cpp index 0d48db77e..21a327bbd 100644 --- a/source/Registry.cpp +++ b/source/Registry.cpp @@ -43,14 +43,14 @@ namespace _ini { //=========================================================================== void RegSaveString(LPCTSTR section, LPCTSTR key, bool /*peruser*/, const std::string& buffer) { - bool updated = !!WritePrivateProfileString(section, key, buffer.c_str(), g_sConfigFile.c_str()); + bool updated = WritePrivateProfileString(section, key, buffer.c_str(), g_sConfigFile.c_str()); _ASSERT(updated || GetLastError() == 0); } //=========================================================================== void RegDeleteString(LPCTSTR section, bool /*peruser*/) { - bool updated = !!WritePrivateProfileString(section, NULL, NULL, g_sConfigFile.c_str()); + bool updated = WritePrivateProfileString(section, NULL, NULL, g_sConfigFile.c_str()); _ASSERT(updated || GetLastError() == 0); } } diff --git a/source/Riff.cpp b/source/Riff.cpp index 71aadc8af..6a207c6fb 100644 --- a/source/Riff.cpp +++ b/source/Riff.cpp @@ -115,7 +115,7 @@ bool RiffFinishWriteFile() SetFilePointer(g_hRiffFile, dwDataOffset, NULL, FILE_BEGIN); WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL); - return CloseHandle(g_hRiffFile) ? true : false; + return CloseHandle(g_hRiffFile); } bool RiffPutSamples(const short* buf, unsigned int uSamples) @@ -127,7 +127,7 @@ bool RiffPutSamples(const short* buf, unsigned int uSamples) DWORD dwNumberOfBytesWritten; - BOOL bRes = WriteFile( + WriteFile( g_hRiffFile, buf, uSamples * sizeof(short) * g_NumChannels, diff --git a/source/SaveState.cpp b/source/SaveState.cpp index 37621d8e4..869045db7 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -456,7 +456,7 @@ static void Snapshot_LoadState_v2() DebugReset(); if (g_nAppMode == MODE_DEBUG) - DebugDisplay(TRUE); + DebugDisplay(true); frame.Initialize(false); // don't reset the video state frame.ResizeWindow(); diff --git a/source/SerialComms.cpp b/source/SerialComms.cpp index 4bf9f1306..9afab6bc1 100644 --- a/source/SerialComms.cpp +++ b/source/SerialComms.cpp @@ -291,7 +291,7 @@ bool CSuperSerialCard::CheckComm() { GetCommModemStatus(m_hCommHandle, const_cast(&m_dwModemStatus)); - //BOOL bRes = SetupComm(m_hCommHandle, 8192, 8192); + //const bool bRes = SetupComm(m_hCommHandle, 8192, 8192); //_ASSERT(bRes); UpdateCommState(); @@ -762,7 +762,7 @@ BYTE __stdcall CSuperSerialCard::CommTransmit(WORD, WORD, BYTE, BYTE value, ULON } else if (m_hCommHandle != INVALID_HANDLE_VALUE) { - BOOL res = false; + bool res = false; DWORD error = 0; // Use CriticalSection to keep WriteFile() & m_vbTxEmpty in sync (GH#707) @@ -1077,7 +1077,7 @@ DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter) { CSuperSerialCard* pSSC = (CSuperSerialCard*) lpParameter; - BOOL bRes = SetCommMask(pSSC->m_hCommHandle, EV_RLSD | EV_DSR | EV_CTS | EV_TXEMPTY | EV_RXCHAR); + const bool bRes = SetCommMask(pSSC->m_hCommHandle, EV_RLSD | EV_DSR | EV_CTS | EV_TXEMPTY | EV_RXCHAR); if (!bRes) { LogOutput("SSC: CommThread(): SetCommMask() failed\n"); @@ -1095,7 +1095,7 @@ DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter) DWORD dwEvtMask = 0; DWORD dwWaitResult; - bRes = WaitCommEvent(pSSC->m_hCommHandle, &dwEvtMask, &pSSC->m_o); // Will return immediately (probably with ERROR_IO_PENDING) + const bool bRes = WaitCommEvent(pSSC->m_hCommHandle, &dwEvtMask, &pSSC->m_o); // Will return immediately (probably with ERROR_IO_PENDING) if (!bRes) { DWORD dwRet = GetLastError(); diff --git a/source/Tape.cpp b/source/Tape.cpp index dff2c54c1..8ed2d4645 100644 --- a/source/Tape.cpp +++ b/source/Tape.cpp @@ -42,7 +42,7 @@ BYTE __stdcall TapeRead(WORD, WORD address, BYTE, BYTE, ULONG nExecutedCycles) / if (g_Apple2Type == A2TYPE_PRAVETS8A) return GetPravets().GetKeycode( MemReadFloatingBus(nExecutedCycles) ); - return MemReadFloatingBus(1, nExecutedCycles); // TAPEIN has high bit 1 when input is low or not connected (UTAIIe page 7-5, 7-6) + return MemReadFloatingBus(true, nExecutedCycles); // TAPEIN has high bit 1 when input is low or not connected (UTAIIe page 7-5, 7-6) } BYTE __stdcall TapeWrite(WORD, WORD address, BYTE, BYTE, ULONG nExecutedCycles) // $C020 TAPEOUT diff --git a/source/Tfe/PCapBackend.cpp b/source/Tfe/PCapBackend.cpp index 87383e45e..52fe40cfd 100644 --- a/source/Tfe/PCapBackend.cpp +++ b/source/Tfe/PCapBackend.cpp @@ -65,7 +65,7 @@ int PCapBackend::receive(const int size, uint8_t * rxframe) bool PCapBackend::isValid() { - return !!m_tfePcapFP; + return m_tfePcapFP != nullptr; } void PCapBackend::update(const ULONG /* nExecutedCycles */) @@ -88,17 +88,17 @@ const std::string & PCapBackend::getInterfaceName() return m_interfaceName; } -int PCapBackend::tfe_enumadapter_open() +bool PCapBackend::tfe_enumadapter_open() { return tfe_arch_enumadapter_open(); } -int PCapBackend::tfe_enumadapter(std::string & name, std::string & description) +bool PCapBackend::tfe_enumadapter(std::string & name, std::string & description) { return tfe_arch_enumadapter(name, description); } -int PCapBackend::tfe_enumadapter_close() +bool PCapBackend::tfe_enumadapter_close() { return tfe_arch_enumadapter_close(); } @@ -122,7 +122,7 @@ std::string PCapBackend::GetRegistryInterface(UINT slot) return interfaceName; } -int PCapBackend::tfe_is_npcap_loaded() +bool PCapBackend::tfe_is_npcap_loaded() { return tfe_arch_is_npcap_loaded(); } diff --git a/source/Tfe/PCapBackend.h b/source/Tfe/PCapBackend.h index c8bde5e89..85c16e95f 100644 --- a/source/Tfe/PCapBackend.h +++ b/source/Tfe/PCapBackend.h @@ -60,11 +60,11 @@ class PCapBackend : public NetworkBackend *ppname and *ppdescription are not altered. */ - static int tfe_enumadapter_open(); - static int tfe_enumadapter(std::string & name, std::string & description); - static int tfe_enumadapter_close(); + static bool tfe_enumadapter_open(); + static bool tfe_enumadapter(std::string & name, std::string & description); + static bool tfe_enumadapter_close(); static const char * tfe_lib_version(); - static int tfe_is_npcap_loaded(); + static bool tfe_is_npcap_loaded(); private: const std::string m_interfaceName; diff --git a/source/Tfe/tfearch.cpp b/source/Tfe/tfearch.cpp index 417abf6e6..97605a6c0 100644 --- a/source/Tfe/tfearch.cpp +++ b/source/Tfe/tfearch.cpp @@ -117,18 +117,18 @@ void TfePcapFreeLibrary() } static -BOOL TfePcapLoadLibrary() +bool TfePcapLoadLibrary() { if (pcap_library) { // already loaded - return TRUE; + return true; } if (tfe_cannot_use) { // already failed - return FALSE; + return false; } // try to load @@ -145,7 +145,7 @@ BOOL TfePcapLoadLibrary() { tfe_cannot_use = 1; if(g_fh) fprintf(g_fh, "LoadLibrary WPCAP.DLL failed!\n" ); - return FALSE; + return false; } GET_PROC_ADDRESS_AND_TEST(pcap_open_live); @@ -161,7 +161,7 @@ BOOL TfePcapLoadLibrary() LogOutput("%s\n", p_pcap_lib_version()); LogFileOutput("%s\n", p_pcap_lib_version()); - return TRUE; + return true; } #undef GET_PROC_ADDRESS_AND_TEST @@ -180,7 +180,7 @@ BOOL TfePcapLoadLibrary() #define p_pcap_lib_version pcap_lib_version #define p_pcap_geterr pcap_geterr -static BOOL TfePcapLoadLibrary() +static bool TfePcapLoadLibrary() { static bool loaded = false; if (!loaded) @@ -189,7 +189,7 @@ static BOOL TfePcapLoadLibrary() LogOutput("%s\n", p_pcap_lib_version()); LogFileOutput("%s\n", p_pcap_lib_version()); } - return TRUE; + return true; } #endif @@ -257,33 +257,33 @@ void TfePcapCloseAdapter() TfeEnumAdapter() only fails if there is no more adpater; in this case, *ppname and *ppdescription are not altered. */ -int tfe_arch_enumadapter_open() +bool tfe_arch_enumadapter_open() { if (!TfePcapLoadLibrary()) { - return 0; + return false; } if ((*p_pcap_findalldevs)(&TfePcapAlldevs, TfePcapErrbuf) == -1) { if(g_fh) fprintf(g_fh, "ERROR in TfeEnumAdapterOpen: pcap_findalldevs: '%s'\n", TfePcapErrbuf); - return 0; + return false; } if (!TfePcapAlldevs) { if(g_fh) fprintf(g_fh, "ERROR in TfeEnumAdapterOpen, finding all pcap devices - " "Do we have the necessary privilege rights?\n"); - return 0; + return false; } TfePcapNextDev = TfePcapAlldevs; - return 1; + return true; } -int tfe_arch_enumadapter(std::string & name, std::string & description) +bool tfe_arch_enumadapter(std::string & name, std::string & description) { if (!TfePcapNextDev) - return 0; + return false; name = TfePcapNextDev->name; if (TfePcapNextDev->description) @@ -293,16 +293,16 @@ int tfe_arch_enumadapter(std::string & name, std::string & description) TfePcapNextDev = TfePcapNextDev->next; - return 1; + return true; } -int tfe_arch_enumadapter_close() +bool tfe_arch_enumadapter_close() { if (TfePcapAlldevs) { (*p_pcap_freealldevs)(TfePcapAlldevs); TfePcapAlldevs = NULL; } - return 1; + return true; } @@ -317,7 +317,7 @@ pcap_t * TfePcapOpenAdapter(const std::string & interface_name) /* look if we can find the specified adapter */ std::string name; std::string description; - BOOL found = FALSE; + bool found = false; if (!interface_name.empty()) { /* we have an interface name, try it */ @@ -325,7 +325,7 @@ pcap_t * TfePcapOpenAdapter(const std::string & interface_name) while (tfe_arch_enumadapter(name, description)) { if (name == interface_name) { - found = TRUE; + found = true; } if (found) break; TfePcapDevice = TfePcapNextDev; @@ -409,35 +409,37 @@ void tfe_arch_receive_remove_committed_frame() } */ -void tfe_arch_recv_ctl( int bBroadcast, /* broadcast */ - int bIA, /* individual address (IA) */ - int bMulticast, /* multicast if address passes the hash filter */ - int bCorrect, /* accept correct frames */ - int bPromiscuous, /* promiscuous mode */ - int bIAHash /* accept if IA passes the hash filter */ +inline static const char* bool_to_cstring(bool b) { return b ? "true" : "false"; } + +void tfe_arch_recv_ctl( bool bBroadcast, /* broadcast */ + bool bIA, /* individual address (IA) */ + bool bMulticast, /* multicast if address passes the hash filter */ + bool bCorrect, /* accept correct frames */ + bool bPromiscuous, /* promiscuous mode */ + bool bIAHash /* accept if IA passes the hash filter */ ) { #if defined(TFE_DEBUG_ARCH) || defined(TFE_DEBUG_FRAMES) if(g_fh) { fprintf( g_fh, "tfe_arch_recv_ctl() called with the following parameters:" ); - fprintf( g_fh, "\tbBroadcast = %s", bBroadcast ? "TRUE" : "FALSE" ); - fprintf( g_fh, "\tbIA = %s", bIA ? "TRUE" : "FALSE" ); - fprintf( g_fh, "\tbMulticast = %s", bMulticast ? "TRUE" : "FALSE" ); - fprintf( g_fh, "\tbCorrect = %s", bCorrect ? "TRUE" : "FALSE" ); - fprintf( g_fh, "\tbPromiscuous = %s", bPromiscuous ? "TRUE" : "FALSE" ); - fprintf( g_fh, "\tbIAHash = %s", bIAHash ? "TRUE" : "FALSE" ); + fprintf( g_fh, "\tbBroadcast = %s", bool_to_cstring(bBroadcast) ); + fprintf( g_fh, "\tbIA = %s", bool_to_cstring(bIA) ); + fprintf( g_fh, "\tbMulticast = %s", bool_to_cstring(bMulticast) ); + fprintf( g_fh, "\tbCorrect = %s", bool_to_cstring(bCorrect) ); + fprintf( g_fh, "\tbPromiscuous = %s", bool_to_cstring(bPromiscuous) ); + fprintf( g_fh, "\tbIAHash = %s", bool_to_cstring(bIAHash) ); fprintf( g_fh, "\n" ); } #endif } -void tfe_arch_line_ctl(int bEnableTransmitter, int bEnableReceiver ) +void tfe_arch_line_ctl(bool bEnableTransmitter, bool bEnableReceiver) { #if defined(TFE_DEBUG_ARCH) || defined(TFE_DEBUG_FRAMES) if(g_fh) { fprintf( g_fh, "tfe_arch_line_ctl() called with the following parameters:" ); - fprintf( g_fh, "\tbEnableTransmitter = %s", bEnableTransmitter ? "TRUE" : "FALSE" ); - fprintf( g_fh, "\tbEnableReceiver = %s", bEnableReceiver ? "TRUE" : "FALSE" ); + fprintf( g_fh, "\tbEnableTransmitter = %s", bool_to_cstring(bEnableTransmitter) ); + fprintf( g_fh, "\tbEnableReceiver = %s", bool_to_cstring(bEnableReceiver) ); fprintf( g_fh, "\n" ); } #endif @@ -584,7 +586,7 @@ const char * tfe_arch_lib_version() return p_pcap_lib_version(); } -int tfe_arch_is_npcap_loaded() +bool tfe_arch_is_npcap_loaded() { return TfePcapLoadLibrary(); } diff --git a/source/Tfe/tfearch.h b/source/Tfe/tfearch.h index 82683851e..3c138ffdd 100644 --- a/source/Tfe/tfearch.h +++ b/source/Tfe/tfearch.h @@ -41,16 +41,16 @@ pcap_t * TfePcapOpenAdapter(const std::string & interface_name); void TfePcapCloseAdapter(pcap_t * TfePcapFP); extern -void tfe_arch_recv_ctl( int bBroadcast, /* broadcast */ - int bIA, /* individual address (IA) */ - int bMulticast, /* multicast if address passes the hash filter */ - int bCorrect, /* accept correct frames */ - int bPromiscuous, /* promiscuous mode */ - int bIAHash /* accept if IA passes the hash filter */ +void tfe_arch_recv_ctl( bool bBroadcast, /* broadcast */ + bool bIA, /* individual address (IA) */ + bool bMulticast, /* multicast if address passes the hash filter */ + bool bCorrect, /* accept correct frames */ + bool bPromiscuous, /* promiscuous mode */ + bool bIAHash /* accept if IA passes the hash filter */ ); extern -void tfe_arch_line_ctl(int bEnableTransmitter, int bEnableReceiver); +void tfe_arch_line_ctl(bool bEnableTransmitter, bool bEnableReceiver); extern void tfe_arch_transmit(pcap_t * TfePcapFP, @@ -64,10 +64,10 @@ int tfe_arch_receive(pcap_t * TfePcapFP, BYTE *pbuffer /* where to store a frame */ ); -extern int tfe_arch_is_npcap_loaded(); -extern int tfe_arch_enumadapter_open(); -extern int tfe_arch_enumadapter(std::string & name, std::string & description); -extern int tfe_arch_enumadapter_close(); +extern bool tfe_arch_is_npcap_loaded(); +extern bool tfe_arch_enumadapter_open(); +extern bool tfe_arch_enumadapter(std::string & name, std::string & description); +extern bool tfe_arch_enumadapter_close(); extern const char * tfe_arch_lib_version(); diff --git a/source/Uthernet1.cpp b/source/Uthernet1.cpp index 199230d64..28e9af089 100644 --- a/source/Uthernet1.cpp +++ b/source/Uthernet1.cpp @@ -196,15 +196,15 @@ void Uthernet1::Init() memset( tfe_ia_mac, 0, sizeof(tfe_ia_mac) ); memset( tfe_hash_mask, 0, sizeof(tfe_hash_mask) ); - tfe_recv_broadcast = 0; - tfe_recv_mac = 0; - tfe_recv_multicast = 0; - tfe_recv_correct = 0; - tfe_recv_promiscuous = 0; - tfe_recv_hashfilter = 0; + tfe_recv_broadcast = false; + tfe_recv_mac = false; + tfe_recv_multicast = false; + tfe_recv_correct = false; + tfe_recv_promiscuous = false; + tfe_recv_hashfilter = false; #ifdef TFE_DEBUG_WARN - tfe_started_tx = 0; + tfe_started_tx = false; #endif /* initialize visible IO register and PacketPage registers */ @@ -303,7 +303,7 @@ void Uthernet1::tfe_sideeffects_write_pp_on_txframe(WORD ppaddress) #ifdef TFE_DEBUG_WARN /* remember that the TXCMD has been completed */ - tfe_started_tx = 0; + tfe_started_tx = false; #endif } } @@ -338,12 +338,12 @@ void Uthernet1::tfe_sideeffects_write_pp(WORD ppaddress, int oddaddress) case TFE_PP_ADDR_CC_RXCTL: - tfe_recv_broadcast = content & 0x0800; /* broadcast */ - tfe_recv_mac = content & 0x0400; /* individual address (IA) */ - tfe_recv_multicast = content & 0x0200; /* multicast if address passes the hash filter */ - tfe_recv_correct = content & 0x0100; /* accept correct frames */ - tfe_recv_promiscuous = content & 0x0080; /* promiscuous mode */ - tfe_recv_hashfilter = content & 0x0040; /* accept if IA passes the hash filter */ + tfe_recv_broadcast = (content & 0x0800); /* broadcast */ + tfe_recv_mac = (content & 0x0400); /* individual address (IA) */ + tfe_recv_multicast = (content & 0x0200); /* multicast if address passes the hash filter */ + tfe_recv_correct = (content & 0x0100); /* accept correct frames */ + tfe_recv_promiscuous = (content & 0x0080); /* promiscuous mode */ + tfe_recv_hashfilter = (content & 0x0040); /* accept if IA passes the hash filter */ tfe_arch_recv_ctl( tfe_recv_broadcast, tfe_recv_mac, @@ -355,8 +355,8 @@ void Uthernet1::tfe_sideeffects_write_pp(WORD ppaddress, int oddaddress) break; case TFE_PP_ADDR_CC_LINECTL: - tfe_arch_line_ctl( content & 0x0080, /* enable transmitter */ - content & 0x0040 /* enable receiver */ + tfe_arch_line_ctl( (content & 0x0080), /* enable transmitter */ + (content & 0x0040) /* enable receiver */ ); break; @@ -381,7 +381,7 @@ void Uthernet1::tfe_sideeffects_write_pp(WORD ppaddress, int oddaddress) if (tfe_started_tx && !oddaddress) { if(g_fh) fprintf(g_fh, "WARNING! Early abort of transmitted frame\n"); } - tfe_started_tx = 1; + tfe_started_tx = true; #endif /* make sure we put the octets to transmit at the right place */ @@ -778,12 +778,12 @@ void Uthernet1::tfe_store(WORD ioaddress, BYTE byte) This function is even allowed to be called in tfearch.c from tfe_arch_receive() if necessary, which is the reason why its prototype is included here in tfearch.h. */ -int Uthernet1::tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index, - int *pcorrect_mac, int *pbroadcast, int *pmulticast) +bool Uthernet1::tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index, + int *pcorrect_mac, int *pbroadcast, int *pmulticast) const { int hashreg; /* Hash Register (for hash computation) */ - assert(length>=6); /* we need at least 6 octets since the DA has this length */ + assert(length >= 6); /* we need at least 6 octets since the DA has this length */ /* first of all, delete any status */ *phashed = 0; @@ -817,7 +817,7 @@ int Uthernet1::tfe_should_accept(unsigned char *buffer, int length, int *phashed * that this address fits the hash index */ if (tfe_recv_mac || tfe_recv_promiscuous) - return(1); + return true; } if ( buffer[0]==0xFF @@ -831,7 +831,7 @@ int Uthernet1::tfe_should_accept(unsigned char *buffer, int length, int *phashed *pbroadcast = 1; /* broadcasts cannot be accepted by the hash filter */ - return((tfe_recv_broadcast || tfe_recv_promiscuous) ? 1 : 0); + return (tfe_recv_broadcast || tfe_recv_promiscuous); } /* now check if DA passes the hash filter */ @@ -851,12 +851,12 @@ int Uthernet1::tfe_should_accept(unsigned char *buffer, int length, int *phashed */ *phashed = 0; - return((tfe_recv_multicast || tfe_recv_promiscuous) ? 1 : 0); + return (tfe_recv_multicast || tfe_recv_promiscuous); } - return((tfe_recv_hashfilter || tfe_recv_promiscuous) ? 1 : 0); + return (tfe_recv_hashfilter || tfe_recv_promiscuous); } - return(tfe_recv_promiscuous ? 1 : 0); + return tfe_recv_promiscuous; } #ifdef TFE_DEBUG_FRAMES @@ -1069,11 +1069,11 @@ void Uthernet1::SaveSnapshot(class YamlSaveHelper& yamlSaveHelper) YamlSaveHelper::Label unit(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE); - yamlSaveHelper.SaveBool(SS_YAML_KEY_ENABLED, networkBackend->isValid() ? true : false); + yamlSaveHelper.SaveBool(SS_YAML_KEY_ENABLED, networkBackend->isValid()); yamlSaveHelper.SaveString(SS_YAML_KEY_NETWORK_INTERFACE, networkBackend->getInterfaceName()); - yamlSaveHelper.SaveBool(SS_YAML_KEY_STARTED_TX, tfe_started_tx ? true : false); - yamlSaveHelper.SaveBool(SS_YAML_KEY_CANNOT_USE, PCapBackend::tfe_is_npcap_loaded() ? false : false); + yamlSaveHelper.SaveBool(SS_YAML_KEY_STARTED_TX, tfe_started_tx); + yamlSaveHelper.SaveBool(SS_YAML_KEY_CANNOT_USE, PCapBackend::tfe_is_npcap_loaded()); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_TXCOLLECT_BUFFER, txcollect_buffer); yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_RX_BUFFER, rx_buffer); @@ -1097,7 +1097,7 @@ bool Uthernet1::LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT version) yamlLoadHelper.LoadBool(SS_YAML_KEY_ENABLED); // FIXME: what is the point of this? PCapBackend::SetRegistryInterface(m_slot, yamlLoadHelper.LoadString(SS_YAML_KEY_NETWORK_INTERFACE)); - tfe_started_tx = yamlLoadHelper.LoadBool(SS_YAML_KEY_STARTED_TX) ? true : false; + tfe_started_tx = yamlLoadHelper.LoadBool(SS_YAML_KEY_STARTED_TX); // it is meaningless to restore this boolean flag // as it depends on the availability of npcap on *this* pc diff --git a/source/Uthernet1.h b/source/Uthernet1.h index 0c5478a5b..ee0fe70cc 100644 --- a/source/Uthernet1.h +++ b/source/Uthernet1.h @@ -145,8 +145,8 @@ class Uthernet1 : public Card void tfe_proceed_rx_buffer(int oddaddress); WORD tfe_receive(); - int tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index, - int *pcorrect_mac, int *pbroadcast, int *pmulticast); + bool tfe_should_accept(unsigned char *buffer, int length, int *phashed, int *phash_index, + int *pcorrect_mac, int *pbroadcast, int *pmulticast) const; // this function is virtually useless // it is only here to keep a record of these unused arguments @@ -177,16 +177,16 @@ class Uthernet1 : public Card /* remember the value of the hash mask */ uint32_t tfe_hash_mask[2]; - int tfe_recv_broadcast; /* broadcast */ - int tfe_recv_mac; /* individual address (IA) */ - int tfe_recv_multicast; /* multicast if address passes the hash filter */ - int tfe_recv_correct; /* accept correct frames */ - int tfe_recv_promiscuous; /* promiscuous mode */ - int tfe_recv_hashfilter; /* accept if IA passes the hash filter */ + bool tfe_recv_broadcast; /* broadcast */ + bool tfe_recv_mac; /* individual address (IA) */ + bool tfe_recv_multicast; /* multicast if address passes the hash filter */ + bool tfe_recv_correct; /* accept correct frames */ + bool tfe_recv_promiscuous; /* promiscuous mode */ + bool tfe_recv_hashfilter; /* accept if IA passes the hash filter */ #ifdef TFE_DEBUG_WARN /* remember if the TXCMD has been completed before a new one is issued */ - int tfe_started_tx; + bool tfe_started_tx; #endif /* TFE registers */ diff --git a/source/Uthernet2.cpp b/source/Uthernet2.cpp index 187cf94cf..f163f1000 100644 --- a/source/Uthernet2.cpp +++ b/source/Uthernet2.cpp @@ -604,7 +604,7 @@ void Uthernet2::receiveOnePacketRaw() const uint8_t mr = myMemory[socket0.registerAddress + W5100_SN_MR]; // see if MAC RAW filters or not - const bool filterMAC = !!(mr & W5100_SN_MR_MF); + const bool filterMAC = (mr & W5100_SN_MR_MF); if (!filterMAC) { acceptAll = true; @@ -951,7 +951,7 @@ void Uthernet2::openSocket(const size_t i) const uint8_t mr = myMemory[socket.registerAddress + W5100_SN_MR]; const uint8_t protocol = mr & W5100_SN_MR_PROTO_MASK; - const bool virtual_dns = !!(protocol & W5100_SN_VIRTUAL_DNS); + const bool virtual_dns = (protocol & W5100_SN_VIRTUAL_DNS); // if virtual_dns is requested, but not enabled, we cannot handle it here. if (virtual_dns && !myVirtualDNSEnabled) diff --git a/source/Utilities.cpp b/source/Utilities.cpp index 7f1cd819e..fcb684db9 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -180,16 +180,16 @@ void LoadConfiguration(bool loadImages) uint32_t dwTmp = 0; if(REGLOAD(REGVALUE_FS_SHOW_SUBUNIT_STATUS, &dwTmp)) - GetFrame().SetFullScreenShowSubunitStatus(dwTmp ? true : false); + GetFrame().SetFullScreenShowSubunitStatus(dwTmp != 0); if (REGLOAD(REGVALUE_SHOW_DISKII_STATUS, &dwTmp)) - GetFrame().SetWindowedModeShowDiskiiStatus(dwTmp ? true : false); + GetFrame().SetWindowedModeShowDiskiiStatus(dwTmp != 0); if(REGLOAD(REGVALUE_THE_FREEZES_F8_ROM, &dwTmp)) GetPropertySheet().SetTheFreezesF8Rom(dwTmp); if(REGLOAD(REGVALUE_SAVE_STATE_ON_EXIT, &dwTmp)) - SetSaveStateOnExit(dwTmp ? true : false); + SetSaveStateOnExit(dwTmp != 0); if(REGLOAD(REGVALUE_PDL_XTRIM, &dwTmp)) JoySetTrim((short)dwTmp, true); @@ -204,7 +204,7 @@ void LoadConfiguration(bool loadImages) if(REGLOAD(REGVALUE_AUTOFIRE, &dwTmp)) GetPropertySheet().SetAutofire(dwTmp); if(REGLOAD(REGVALUE_SWAP_BUTTONS_0_AND_1, &dwTmp)) - GetPropertySheet().SetButtonsSwapState(dwTmp ? true : false); + GetPropertySheet().SetButtonsSwapState(dwTmp != 0); if(REGLOAD(REGVALUE_CENTERING_CONTROL, &dwTmp)) GetPropertySheet().SetJoystickCenteringControl(dwTmp); @@ -325,7 +325,7 @@ void LoadConfiguration(bool loadImages) // Do this after populating the slots with Disk II controller(s) uint32_t dwEnhanceDisk; REGLOAD_DEFAULT(REGVALUE_ENHANCE_DISK_SPEED, &dwEnhanceDisk, 1); - GetCardMgr().GetDisk2CardMgr().SetEnhanceDisk(dwEnhanceDisk ? true : false); + GetCardMgr().GetDisk2CardMgr().SetEnhanceDisk(dwEnhanceDisk != 0); // @@ -338,7 +338,7 @@ void LoadConfiguration(bool loadImages) GetFrame().SetViewportScale(dwTmp); if (REGLOAD(REGVALUE_CONFIRM_REBOOT, &dwTmp)) - GetFrame().g_bConfirmReboot = !!dwTmp; + GetFrame().g_bConfirmReboot = (dwTmp != 0); } static std::string GetFullPath(LPCSTR szFileName) @@ -406,8 +406,7 @@ static bool DoHardDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileNam std::string strPathName = GetFullPath(szFileName); if (strPathName.empty()) return false; - BOOL bRes = card.Insert(nDrive, strPathName); - bool res = (bRes == TRUE); + const bool res = card.Insert(nDrive, strPathName); if (res) SetCurrentDir(strPathName); return res; diff --git a/source/VidHD.cpp b/source/VidHD.cpp index 7d7517abe..3e5f1a1e4 100644 --- a/source/VidHD.cpp +++ b/source/VidHD.cpp @@ -99,7 +99,7 @@ void VidHDCard::VideoIOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG } } -bool VidHDCard::IsWriteAux() +bool VidHDCard::IsWriteAux() const { return MemIsWriteAux(m_memMode); } diff --git a/source/VidHD.h b/source/VidHD.h index fe9ff664b..e5ecc03bc 100644 --- a/source/VidHD.h +++ b/source/VidHD.h @@ -34,9 +34,9 @@ class VidHDCard : public Card void VideoIOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG nExecutedCycles); - bool IsSHR() { return (m_NEWVIDEO & 0xC0) == 0xC0; } // 11000000 = Enable SHR(b7) | Linearize SHR video memory(b6) - bool IsDHGRBlackAndWhite() { return (m_NEWVIDEO & (1 << 5)) ? true : false; } - bool IsWriteAux(); + bool IsSHR() const { return ((m_NEWVIDEO & 0xC0) == 0xC0); } // 11000000 = Enable SHR(b7) | Linearize SHR video memory(b6) + bool IsDHGRBlackAndWhite() const { return (m_NEWVIDEO & (1 << 5)); } + bool IsWriteAux() const; static void UpdateSHRCell(bool is640Mode, bool isColorFillMode, uint16_t addrPalette, bgra_t* pVideoAddress, uint32_t a); diff --git a/source/Video.cpp b/source/Video.cpp index 8a7b508ce..38aa83ed4 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -163,7 +163,7 @@ void Video::VideoReinitialize(bool bInitVideoScannerAddress) void Video::VideoResetState() { - g_nAltCharSetOffset = 0; + g_bAltCharSetOffset = false; g_uVideoMode = VF_TEXT; NTSC_SetVideoTextMode( 40 ); @@ -187,8 +187,8 @@ BYTE Video::VideoSetMode(WORD pc, WORD address, BYTE write, BYTE d, ULONG uExecu case 0x01: g_uVideoMode |= VF_80STORE; break; case 0x0C: if (!IS_APPLE2) { g_uVideoMode &= ~VF_80COL; NTSC_SetVideoTextMode(40); } break; case 0x0D: if (!IS_APPLE2) { g_uVideoMode |= VF_80COL; NTSC_SetVideoTextMode(80); } break; - case 0x0E: if (!IS_APPLE2) g_nAltCharSetOffset = 0; break; // Alternate char set off - case 0x0F: if (!IS_APPLE2) g_nAltCharSetOffset = 256; break; // Alternate char set on + case 0x0E: if (!IS_APPLE2) g_bAltCharSetOffset = false; break; // Alternate char set off + case 0x0F: if (!IS_APPLE2) g_bAltCharSetOffset = true; break; // Alternate char set on case 0x22: if (vidHD) vidHD->VideoIOWrite(pc, address, write, d, uExecutedCycles); break; // VidHD IIgs video mode register case 0x29: if (vidHD) vidHD->VideoIOWrite(pc, address, write, d, uExecutedCycles); break; // VidHD IIgs video mode register case 0x34: if (vidHD) vidHD->VideoIOWrite(pc, address, write, d, uExecutedCycles); break; // VidHD IIgs video mode register @@ -242,49 +242,49 @@ BYTE Video::VideoSetMode(WORD pc, WORD address, BYTE write, BYTE d, ULONG uExecu //=========================================================================== -bool Video::VideoGetSW80COL() +bool Video::VideoGetSW80COL() const { - return SW_80COL ? true : false; + return SW_80COL; } -bool Video::VideoGetSWDHIRES() +bool Video::VideoGetSWDHIRES() const { - return SW_DHIRES ? true : false; + return SW_DHIRES; } -bool Video::VideoGetSWHIRES() +bool Video::VideoGetSWHIRES() const { - return SW_HIRES ? true : false; + return SW_HIRES; } -bool Video::VideoGetSW80STORE() +bool Video::VideoGetSW80STORE() const { - return SW_80STORE ? true : false; + return SW_80STORE; } -bool Video::VideoGetSWMIXED() +bool Video::VideoGetSWMIXED() const { - return SW_MIXED ? true : false; + return SW_MIXED; } -bool Video::VideoGetSWPAGE2() +bool Video::VideoGetSWPAGE2() const { - return SW_PAGE2 ? true : false; + return SW_PAGE2; } -bool Video::VideoGetSWTEXT() +bool Video::VideoGetSWTEXT() const { - return SW_TEXT ? true : false; + return SW_TEXT; } -bool Video::VideoGetSWAltCharSet() +bool Video::VideoGetSWAltCharSet() const { - return g_nAltCharSetOffset != 0; + return g_bAltCharSetOffset; } -bool Video::VideoGet80COLAUXEMPTY() +bool Video::VideoGet80COLAUXEMPTY() const { - return g_uVideoMode & VF_80COL_AUX_EMPTY ? true : false; + return (g_uVideoMode & VF_80COL_AUX_EMPTY); } //=========================================================================== @@ -303,7 +303,7 @@ const std::string& Video::VideoGetSnapshotStructName() void Video::VideoSaveSnapshot(YamlSaveHelper& yamlSaveHelper) { YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", VideoGetSnapshotStructName().c_str()); - yamlSaveHelper.SaveBool(SS_YAML_KEY_ALT_CHARSET, g_nAltCharSetOffset ? true : false); + yamlSaveHelper.SaveBool(SS_YAML_KEY_ALT_CHARSET, g_bAltCharSetOffset); yamlSaveHelper.SaveHexUint32(SS_YAML_KEY_VIDEO_MODE, g_uVideoMode); yamlSaveHelper.SaveUint(SS_YAML_KEY_CYCLES_THIS_FRAME, g_dwCyclesThisFrame); yamlSaveHelper.SaveUint(SS_YAML_KEY_VIDEO_REFRESH_RATE, (UINT)GetVideoRefreshRate()); @@ -321,7 +321,7 @@ void Video::VideoLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) SetCurrentCLK6502(); } - g_nAltCharSetOffset = yamlLoadHelper.LoadBool(SS_YAML_KEY_ALT_CHARSET) ? 256 : 0; + g_bAltCharSetOffset = yamlLoadHelper.LoadBool(SS_YAML_KEY_ALT_CHARSET); g_uVideoMode = yamlLoadHelper.LoadUint(SS_YAML_KEY_VIDEO_MODE); g_dwCyclesThisFrame = yamlLoadHelper.LoadUint(SS_YAML_KEY_CYCLES_THIS_FRAME); diff --git a/source/Video.h b/source/Video.h index 7b0b6887e..b60421430 100644 --- a/source/Video.h +++ b/source/Video.h @@ -190,7 +190,7 @@ class Video Video() { g_pFramebufferbits = NULL; // last drawn frame (initialized in WinVideoInitialize) - g_nAltCharSetOffset = 0; + g_bAltCharSetOffset = false; g_uVideoMode = VF_TEXT; g_eVideoType = VT_DEFAULT; g_eVideoStyle = VS_DEFAULT; @@ -233,15 +233,15 @@ class Video bool VideoGetVblBarEx(const uint32_t dwCyclesThisFrame); bool VideoGetVblBar(const uint32_t uExecutedCycles); - bool VideoGetSW80COL(); - bool VideoGetSWDHIRES(); - bool VideoGetSWHIRES(); - bool VideoGetSW80STORE(); - bool VideoGetSWMIXED(); - bool VideoGetSWPAGE2(); - bool VideoGetSWTEXT(); - bool VideoGetSWAltCharSet(); - bool VideoGet80COLAUXEMPTY(); + bool VideoGetSW80COL() const; + bool VideoGetSWDHIRES() const; + bool VideoGetSWHIRES() const; + bool VideoGetSW80STORE() const; + bool VideoGetSWMIXED() const; + bool VideoGetSWPAGE2() const; + bool VideoGetSWTEXT() const; + bool VideoGetSWAltCharSet() const; + bool VideoGet80COLAUXEMPTY() const; void VideoSaveSnapshot(class YamlSaveHelper& yamlSaveHelper); void VideoLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT version); @@ -298,7 +298,7 @@ class Video void SetFrameBuffer(uint8_t* frameBuffer) { g_pFramebufferbits = frameBuffer; } const std::string& VideoGetSnapshotStructName(); - int g_nAltCharSetOffset; + bool g_bAltCharSetOffset; uint32_t g_uVideoMode; // Current Video Mode (this is the last set one as it may change mid-scan line!) uint32_t g_eVideoType; // saved to Registry VideoStyle_e g_eVideoStyle; diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index ee1aa9a63..d698cbf0c 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -458,30 +458,30 @@ void RegisterExtensions() // NB. On a restart, it's OK to call RegisterHotKey() again since the old g_hFrameWindow has been destroyed static void RegisterHotKeys() { - BOOL bStatus[3] = {0,0,0}; + bool bStatus[3] = {false, false, false}; - bStatus[0] = RegisterHotKey( + bStatus[0] = RegisterHotKey( GetFrame().g_hFrameWindow , // HWND hWnd VK_SNAPSHOT_560, // int id (user/custom id) 0 , // UINT fsModifiers VK_SNAPSHOT // UINT vk = PrintScreen ); - bStatus[1] = RegisterHotKey( + bStatus[1] = RegisterHotKey( GetFrame().g_hFrameWindow , // HWND hWnd VK_SNAPSHOT_280, // int id (user/custom id) MOD_SHIFT , // UINT fsModifiers VK_SNAPSHOT // UINT vk = PrintScreen ); - bStatus[2] = RegisterHotKey( + bStatus[2] = RegisterHotKey( GetFrame().g_hFrameWindow , // HWND hWnd VK_SNAPSHOT_TEXT, // int id (user/custom id) MOD_CONTROL , // UINT fsModifiers VK_SNAPSHOT // UINT vk = PrintScreen ); - if ((!bStatus[0] || !bStatus[1] || !bStatus[2])) + if (!bStatus[0] || !bStatus[1] || !bStatus[2]) { std::string msg("Unable to register for PrintScreen key(s):\n"); diff --git a/source/Windows/DirectInput.cpp b/source/Windows/DirectInput.cpp index 39e1b0bf6..2315e9555 100644 --- a/source/Windows/DirectInput.cpp +++ b/source/Windows/DirectInput.cpp @@ -70,23 +70,18 @@ namespace DIMouse #else // NO_DIRECT_X HRESULT hr; - BOOL bExclusive; - BOOL bForeground; - BOOL bImmediate; - DWORD dwCoopFlags; + + // Determine where the buffer would like to be allocated + const bool bExclusive = false; + const bool bForeground = false; // Otherwise get DIERR_OTHERAPPHASPRIO (== E_ACCESSDENIED) on Acquire() + const bool bImmediate = true; DirectInputUninit(hDlg); LogFileOutput("DirectInputInit: DirectInputUninit()\n"); - // Determine where the buffer would like to be allocated - bExclusive = FALSE; - bForeground = FALSE; // Otherwise get DIERR_OTHERAPPHASPRIO (== E_ACCESSDENIED) on Acquire() - bImmediate = TRUE; - - if( bExclusive ) - dwCoopFlags = DISCL_EXCLUSIVE; - else - dwCoopFlags = DISCL_NONEXCLUSIVE; + DWORD dwCoopFlags = ( bExclusive ) + ? DISCL_EXCLUSIVE + : DISCL_NONEXCLUSIVE; if( bForeground ) dwCoopFlags |= DISCL_FOREGROUND; @@ -200,7 +195,7 @@ namespace DIMouse if (g_TimerIDEvent) { - BOOL bRes = KillTimer(hDlg, g_TimerIDEvent); + const bool bRes = KillTimer(hDlg, g_TimerIDEvent); LogFileOutput("DirectInputUninit: KillTimer(), res=%d\n", bRes ? 1 : 0); g_TimerIDEvent = 0; } diff --git a/source/Windows/Win32Frame.cpp b/source/Windows/Win32Frame.cpp index 1f7d0acb5..14b1f1f85 100644 --- a/source/Windows/Win32Frame.cpp +++ b/source/Windows/Win32Frame.cpp @@ -112,7 +112,7 @@ Win32Frame::Win32Frame() g_bLastCursorInAppleViewport = false; g_uCount100msec = 0; g_TimerIDEvent_100msec = 0; - g_bUsingCursor = FALSE; + g_bUsingCursor = false; g_bAppActive = false; g_bFrameActive = false; g_windowMinimized = false; @@ -317,7 +317,7 @@ void Win32Frame::Benchmark() while (GetTickCount() == milliseconds); milliseconds = GetTickCount(); do { - CpuExecute(100000, i == 0 ? true : false); + CpuExecute(100000, (i == 0)); totalmhz10[i]++; } while (GetTickCount() - milliseconds < 1000); } @@ -331,14 +331,14 @@ void Win32Frame::Benchmark() "information?", "Benchmarks", MB_ICONQUESTION | MB_YESNO | MB_SETFOREGROUND) == IDYES) { - BOOL error = 0; + bool error = false; WORD lastpc = 0x300; int loop = 0; while ((loop < 10000) && !error) { CpuSetupBenchmark(); CpuExecute(loop, true); if ((regs.pc < 0x300) || (regs.pc > 0x400)) - error = 1; + error = true; else { lastpc = regs.pc; ++loop; diff --git a/source/Windows/Win32Frame.h b/source/Windows/Win32Frame.h index 1ddd4eace..ba539d462 100644 --- a/source/Windows/Win32Frame.h +++ b/source/Windows/Win32Frame.h @@ -105,7 +105,7 @@ class Win32Frame : public FrameBase void DrawCrosshairs(int x, int y); void DrawFrameWindow(bool bPaintingWindow = false); void DrawStatusArea(HDC passdc, int drawflags); - void Draw3dRect(HDC dc, int x1, int y1, int x2, int y2, BOOL out); + void Draw3dRect(HDC dc, int x1, int y1, int x2, int y2, bool out); void DrawBitmapRect(HDC dc, int x, int y, LPRECT rect, HBITMAP bitmap); void ProcessButtonClick(int button, bool bFromButtonUI = false); bool ConfirmReboot(bool bFromButtonUI); @@ -113,7 +113,7 @@ class Win32Frame : public FrameBase void RelayEvent(UINT message, WPARAM wparam, LPARAM lparam); void SetFullScreenMode(); void SetNormalMode(); - void SetUsingCursor(BOOL bNewValue); + void SetUsingCursor(bool bNewValue); void SetupTooltipControls(); void FrameResizeWindow(int nNewScale); void RevealCursor(); @@ -123,7 +123,7 @@ class Win32Frame : public FrameBase void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeavingAppleScreen); void CreateGdiObjects(); void DeleteGdiObjects(); - void FrameShowCursor(BOOL bShow); + void FrameShowCursor(bool bShow); void FullScreenRevealCursor(); void GetWidthHeight(int& nWidth, int& nHeight); void SetSlotUIOffsets(); @@ -138,7 +138,7 @@ class Win32Frame : public FrameBase HBITMAP g_hDeviceBitmap; HDC g_hDeviceDC; LPBITMAPINFO g_pFramebufferinfo; - BOOL g_bUsingCursor; // TRUE = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor() + bool g_bUsingCursor; // true = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor() bool g_bAppActive; bool g_bFrameActive; bool g_windowMinimized; diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index 3371751e9..6f5a3f34c 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -127,7 +127,7 @@ UINT Win32Frame::Get3DBorderHeight() //=========================================================================== -void Win32Frame::FrameShowCursor(BOOL bShow) +void Win32Frame::FrameShowCursor(bool bShow) { int nCount; @@ -164,13 +164,13 @@ void Win32Frame::RevealCursor() pMouseCard->SetEnabled(false); - FrameShowCursor(TRUE); + FrameShowCursor(true); if (GetPropertySheet().GetMouseShowCrosshair()) // Erase crosshairs if they are being drawn DrawCrosshairs(0,0); if (GetPropertySheet().GetMouseRestrictToWindow()) - SetUsingCursor(FALSE); + SetUsingCursor(false); g_bLastCursorInAppleViewport = false; } @@ -189,7 +189,7 @@ void Win32Frame::FullScreenRevealCursor() if (!g_bUsingCursor && !g_bShowingCursor) { - FrameShowCursor(TRUE); + FrameShowCursor(true); g_uCount100msec = 0; } } @@ -293,19 +293,19 @@ void Win32Frame::DeleteGdiObjects() // Draws an 3D box around the main apple screen //=========================================================================== -void Win32Frame::Draw3dRect(HDC dc, int x1, int y1, int x2, int y2, BOOL out) +void Win32Frame::Draw3dRect(HDC dc, int x1, int y1, int x2, int y2, bool out) { - SelectObject(dc,GetStockObject(NULL_BRUSH)); - SelectObject(dc,out ? btnshadowpen : btnhighlightpen); + SelectObject(dc, GetStockObject(NULL_BRUSH)); + SelectObject(dc, out ? btnshadowpen : btnhighlightpen); POINT pt[3]; pt[0].x = x1; pt[0].y = y2-1; pt[1].x = x2-1; pt[1].y = y2-1; pt[2].x = x2-1; pt[2].y = y1; - Polyline(dc,(LPPOINT)&pt,3); - SelectObject(dc,(out == 1) ? btnhighlightpen : btnshadowpen); + Polyline(dc, (LPPOINT)&pt, 3); + SelectObject(dc, (out == 1) ? btnhighlightpen : btnshadowpen); pt[1].x = x1; pt[1].y = y1; pt[2].x = x2; pt[2].y = y1; - Polyline(dc,(LPPOINT)&pt,3); + Polyline(dc, (LPPOINT)&pt, 3); } //=========================================================================== @@ -331,13 +331,13 @@ void Win32Frame::DrawButton (HDC passdc, int number) { if (number == buttondown) { int loop = 0; while (loop++ < 3) - Draw3dRect(dc,x+loop,y+loop,x+BUTTONCX,y+BUTTONCY,0); + Draw3dRect(dc, x+loop, y+loop, x+BUTTONCX, y+BUTTONCY, false); RECT rect = {0,0,39,39}; DrawBitmapRect(dc,x+4,y+4,&rect,buttonbitmap[number]); } else { - Draw3dRect(dc,x+1,y+1,x+BUTTONCX,y+BUTTONCY,1); - Draw3dRect(dc,x+2,y+2,x+BUTTONCX-1,y+BUTTONCY-1,1); + Draw3dRect(dc, x+1, y+1, x+BUTTONCX, y+BUTTONCY, true); + Draw3dRect(dc, x+2, y+2, x+BUTTONCX-1, y+BUTTONCY-1, true); RECT rect = {1,1,40,40}; DrawBitmapRect(dc,x+3,y+3,&rect,buttonbitmap[number]); } @@ -475,11 +475,11 @@ void Win32Frame::DrawFrameWindow (bool bPaintingWindow/*=false*/) Draw3dRect(dc, VIEWPORTX-2,VIEWPORTY-2, VIEWPORTX+g_nViewportCX+2,VIEWPORTY+g_nViewportCY+2, - 0); + false); Draw3dRect(dc, VIEWPORTX-3,VIEWPORTY-3, VIEWPORTX+g_nViewportCX+3,VIEWPORTY+g_nViewportCY+3, - 0); + false); SelectObject(dc,btnfacepen); Rectangle(dc, VIEWPORTX-4,VIEWPORTY-4, @@ -913,16 +913,16 @@ void Win32Frame::DrawStatusArea(HDC passdc, int drawflags) if (drawflags & DRAW_BACKGROUND) { // Erase background (Slot6 drive LEDs, HDD LED & Caps) - SelectObject(dc,GetStockObject(NULL_PEN)); - SelectObject(dc,btnfacebrush); - Rectangle(dc,x,y,x+BUTTONCX+2,y+34); - Draw3dRect(dc,x+1,y+3,x+BUTTONCX,y+30,0); + SelectObject(dc, GetStockObject(NULL_PEN)); + SelectObject(dc, btnfacebrush); + Rectangle(dc, x, y, x+BUTTONCX+2, y+34); + Draw3dRect(dc, x+1, y+3, x+BUTTONCX, y+30, false); // Add text for Slot6 drives: "1" & "2" - SelectObject(dc,smallfont); - SetTextAlign(dc,TA_CENTER | TA_TOP); - SetTextColor(dc,RGB(0,0,0)); - SetBkMode(dc,TRANSPARENT); + SelectObject(dc, smallfont); + SetTextAlign(dc, TA_CENTER | TA_TOP); + SetTextColor(dc, RGB(0,0,0)); + SetBkMode(dc, TRANSPARENT); TextOut(dc, x + 7, y + yOffsetSlot6LEDNumbers, "1", 1); TextOut(dc, x + 27, y + yOffsetSlot6LEDNumbers, "2", 1); @@ -1029,7 +1029,7 @@ LRESULT Win32Frame::WndProc( case WM_ACTIVATE: // Sent when window is activated/deactivated. wParam indicates WA_ACTIVE, WA_INACTIVE, etc // Eg. Deactivate when Config dialog is active, AppleWin app loses focus, etc JoyReset(); - SetUsingCursor(FALSE); + SetUsingCursor(false); RevealCursor(); FullScreenRevealCursor(); g_bFrameActive = (wparam != WA_INACTIVE); @@ -1037,7 +1037,7 @@ LRESULT Win32Frame::WndProc( case WM_ACTIVATEAPP: // Sent when different app's window is activated/deactivated. // Eg. Deactivate when AppleWin app loses focus - g_bAppActive = (wparam ? TRUE : FALSE); + g_bAppActive = (wparam != 0); break; case WM_SIZE: @@ -1066,14 +1066,14 @@ LRESULT Win32Frame::WndProc( RegSaveValue(REG_PREFS, REGVALUE_PREF_WINDOW_X_POS, true, framerect.left); RegSaveValue(REG_PREFS, REGVALUE_PREF_WINDOW_Y_POS, true, framerect.top); FrameReleaseDC(); - SetUsingCursor(FALSE); + SetUsingCursor(false); if (helpquit) { helpquit = 0; HtmlHelp(NULL,NULL,HH_CLOSE_ALL,0); } if (g_TimerIDEvent_100msec) { - BOOL bRes = KillTimer(g_hFrameWindow, g_TimerIDEvent_100msec); + const bool bRes = KillTimer(g_hFrameWindow, g_TimerIDEvent_100msec); LogFileOutput("KillTimer(g_TimerIDEvent_100msec), res=%d\n", bRes ? 1 : 0); g_TimerIDEvent_100msec = 0; } @@ -1238,7 +1238,7 @@ LRESULT Win32Frame::WndProc( // Processing is done in WM_KEYUP for: VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8 if ((wparam >= VK_F1) && (wparam <= VK_F8) && (buttondown == -1)) { - SetUsingCursor(FALSE); + SetUsingCursor(false); buttondown = (int)(wparam-VK_F1); if (g_bIsFullScreen && (buttonover != -1)) { if (buttonover != buttondown) @@ -1307,7 +1307,7 @@ LRESULT Win32Frame::WndProc( } else if (wparam == VK_PAUSE) { - SetUsingCursor(FALSE); + SetUsingCursor(false); switch (g_nAppMode) { case MODE_RUNNING: @@ -1318,7 +1318,7 @@ LRESULT Win32Frame::WndProc( case MODE_PAUSED: g_nAppMode = MODE_RUNNING; SoundCore_SetFade(FADE_IN); - // Don't call FrameShowCursor(FALSE) else ClipCursor() won't be called + // Don't call FrameShowCursor(false) else ClipCursor() won't be called break; case MODE_STEPPING: SoundCore_SetFade(FADE_OUT); @@ -1340,7 +1340,7 @@ LRESULT Win32Frame::WndProc( bool extended = (HIWORD(lparam) & KF_EXTENDED) != 0; bool down = true; bool autorep = (HIWORD(lparam) & KF_REPEAT) != 0; - BOOL IsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep); + bool IsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep); #if DEBUG_KEY_MESSAGES LogOutput("WM_KEYDOWN: %08X (scanCode=%04X)\n", wparam, (lparam>>16)&0xfff); @@ -1445,7 +1445,7 @@ LRESULT Win32Frame::WndProc( bool extended = (HIWORD(lparam) & KF_EXTENDED) != 0; bool down = false; bool autorep = false; - BOOL bIsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep); + bool bIsJoyKey = JoyProcessKey((int)wparam, extended, down, autorep); #if DEBUG_KEY_MESSAGES LogOutput("WM_KEYUP: %08X\n", wparam); @@ -1474,7 +1474,7 @@ LRESULT Win32Frame::WndProc( { if (wparam & (MK_CONTROL | MK_SHIFT)) { - SetUsingCursor(FALSE); + SetUsingCursor(false); } else { @@ -1483,7 +1483,7 @@ LRESULT Win32Frame::WndProc( } else if ( ((x < buttonx) && JoyUsingMouse() && ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_STEPPING))) ) { - SetUsingCursor(TRUE); + SetUsingCursor(true); } else if (GetCardMgr().IsMouseCardInstalled()) { @@ -1634,7 +1634,7 @@ LRESULT Win32Frame::WndProc( g_uCount100msec++; if (g_uCount100msec > 20) // Hide every 2sec of mouse inactivity { - FrameShowCursor(FALSE); + FrameShowCursor(false); } } } @@ -2046,7 +2046,7 @@ void Win32Frame::ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) { CtrlReset(); if (g_nAppMode == MODE_DEBUG) - DebugDisplay(TRUE); + DebugDisplay(true); return; } @@ -2078,7 +2078,7 @@ void Win32Frame::ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) // NB. Don't exit debugger or stepping if (g_nAppMode == MODE_DEBUG) - DebugDisplay(TRUE); + DebugDisplay(true); } } @@ -2443,7 +2443,7 @@ void Win32Frame::ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) if (nRes) { - New_DOSProDOS_Disk(pTitle, pathname, nDiskSize, bIsDOS33, !!bNewDiskCopyBitsyBoot, !!bNewDiskCopyBitsyBye, !!bNewDiskCopyBASIC, !!bNewDiskCopyProDOS, this); + New_DOSProDOS_Disk(pTitle, pathname, nDiskSize, bIsDOS33, bNewDiskCopyBitsyBoot, bNewDiskCopyBitsyBye, bNewDiskCopyBASIC, bNewDiskCopyProDOS, this); } } } @@ -2701,7 +2701,7 @@ void Win32Frame::ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } // Destroy the menu. - BOOL bRes = DestroyMenu(hmenu); + const bool bRes = DestroyMenu(hmenu); _ASSERT(bRes); SoundCore_SetFade(FADE_IN); @@ -2839,7 +2839,7 @@ void Win32Frame::SetNormalMode() } //=========================================================================== -void Win32Frame::SetUsingCursor (BOOL bNewValue) +void Win32Frame::SetUsingCursor (bool bNewValue) { if (bNewValue == g_bUsingCursor) return; @@ -2848,7 +2848,7 @@ void Win32Frame::SetUsingCursor (BOOL bNewValue) if (g_bUsingCursor) { - // Set TRUE when: + // Set true when: // . Using mouse for joystick emulation // . Using mousecard and mouse is restricted to window SetCapture(g_hFrameWindow); @@ -2859,7 +2859,7 @@ void Win32Frame::SetUsingCursor (BOOL bNewValue) ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.left); ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.right); ClipCursor(&rect); - FrameShowCursor(FALSE); + FrameShowCursor(false); POINT pt; GetCursorPos(&pt); ScreenToClient(g_hFrameWindow,&pt); @@ -2868,7 +2868,7 @@ void Win32Frame::SetUsingCursor (BOOL bNewValue) else { DrawCrosshairs(0,0); - FrameShowCursor(TRUE); + FrameShowCursor(true); ClipCursor(NULL); ReleaseCapture(); } @@ -3321,7 +3321,7 @@ void Win32Frame::UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY #ifdef _DEBUG_SHOW_CURSOR g_bShowingCursor = true; #else - FrameShowCursor(TRUE); + FrameShowCursor(true); #endif } } @@ -3336,13 +3336,13 @@ void Win32Frame::UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY #ifdef _DEBUG_SHOW_CURSOR g_bShowingCursor = false; #else - FrameShowCursor(FALSE); + FrameShowCursor(false); #endif // if (GetPropertySheet().GetMouseRestrictToWindow()) - SetUsingCursor(TRUE); + SetUsingCursor(true); } else { @@ -3386,7 +3386,7 @@ bool Win32Frame::GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& be DEVMODE devMode; devMode.dmSize = sizeof(DEVMODE); devMode.dmDriverExtra = 0; - BOOL bValid = EnumDisplaySettings(NULL, iModeNum, &devMode); + const bool bValid = EnumDisplaySettings(NULL, iModeNum, &devMode); if (!bValid) break; if (iModeNum == 0) // 0 is the initial "cache info about display device" operation diff --git a/source/YamlHelper.cpp b/source/YamlHelper.cpp index c119332f4..25d7a3677 100644 --- a/source/YamlHelper.cpp +++ b/source/YamlHelper.cpp @@ -195,7 +195,7 @@ int YamlHelper::ParseMap(MapYaml& mapYaml) pKey.clear(); } - bKey = bKey ? false : true; + bKey = !bKey; break; case YAML_SEQUENCE_START_EVENT: case YAML_SEQUENCE_END_EVENT: