From 628c6fb370f5bc27ad4d7bdf866e245ae611f173 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Tue, 27 Aug 2024 21:34:13 -0230 Subject: [PATCH] Fix Unix build; minor formatting fixes. --- src/debugger/gui/CartELFStateWidget.cxx | 9 ++++++--- src/debugger/gui/CartELFWidget.cxx | 7 ++++--- src/debugger/gui/module.mk | 4 ++-- src/emucore/CartELF.cxx | 23 ++++------------------- src/emucore/CartELF.hxx | 11 ++++++++--- src/emucore/elf/ElfLinker.cxx | 7 ++++--- src/emucore/elf/ElfUtil.cxx | 24 ++++++++++++------------ src/emucore/module.mk | 4 ++-- 8 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/debugger/gui/CartELFStateWidget.cxx b/src/debugger/gui/CartELFStateWidget.cxx index 07d5647b8..8d59a115e 100644 --- a/src/debugger/gui/CartELFStateWidget.cxx +++ b/src/debugger/gui/CartELFStateWidget.cxx @@ -66,11 +66,13 @@ namespace { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeELFStateWidget::CartridgeELFStateWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, +CartridgeELFStateWidget::CartridgeELFStateWidget(GuiObject* boss, + const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h, CartridgeELF& cart) - : CartDebugWidget(boss, lfont, nfont, x, y, w, h), myCart(cart), myFlagValues(4) + : CartDebugWidget(boss, lfont, nfont, x, y, w, h), + myCart{cart}, + myFlagValues(4) { initialize(); } @@ -124,6 +126,7 @@ void CartridgeELFStateWidget::initialize() myNextTransaction = new StaticTextWidget(_boss, _font, x0, y, describeTransaction(0xffff, 0xffff, ~0ll)); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELFStateWidget::loadConfig() { for (uInt8 i = 0; i < 16; i++) diff --git a/src/debugger/gui/CartELFWidget.cxx b/src/debugger/gui/CartELFWidget.cxx index be382b982..a9af433e8 100644 --- a/src/debugger/gui/CartELFWidget.cxx +++ b/src/debugger/gui/CartELFWidget.cxx @@ -32,11 +32,12 @@ namespace { } // namespace // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeELFWidget::CartridgeELFWidget(GuiObject* boss, const GUI::Font& lfont, - const GUI::Font& nfont, +CartridgeELFWidget::CartridgeELFWidget(GuiObject* boss, + const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h, CartridgeELF& cart) - : CartDebugWidget(boss, lfont, nfont, x, y, w, h), myCart(cart) + : CartDebugWidget(boss, lfont, nfont, x, y, w, h), + myCart{cart} { initialize(); } diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 367322000..d8a2f92bc 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -32,6 +32,8 @@ MODULE_OBJS := \ src/debugger/gui/CartDPCPlusWidget.o \ src/debugger/gui/CartDPCWidget.o \ src/debugger/gui/CartE0Widget.o \ + src/debugger/gui/CartELFStateWidget.o \ + src/debugger/gui/CartELFWidget.o \ src/debugger/gui/CartEnhancedWidget.o \ src/debugger/gui/CartE7Widget.o \ src/debugger/gui/CartEFSCWidget.o \ @@ -48,8 +50,6 @@ MODULE_OBJS := \ src/debugger/gui/CartFCWidget.o \ src/debugger/gui/CartFEWidget.o \ src/debugger/gui/CartGLWidget.o \ - src/debugger/gui/CartELFWidget.o \ - src/debugger/gui/CartELFStateWidget.o \ src/debugger/gui/CartJANEWidget.o \ src/debugger/gui/CartMDMWidget.o \ src/debugger/gui/CartRamWidget.o \ diff --git a/src/emucore/CartELF.cxx b/src/emucore/CartELF.cxx index c12db4e6a..f2dc344d0 100644 --- a/src/emucore/CartELF.cxx +++ b/src/emucore/CartELF.cxx @@ -221,8 +221,10 @@ namespace { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeELF::CartridgeELF(const ByteBuffer& image, size_t size, string_view md5, const Settings& settings) - : Cartridge(settings, md5), myImageSize(size), myTransactionQueue(TRANSACTION_QUEUE_CAPACITY), - myVcsLib(myTransactionQueue) + : Cartridge(settings, md5), + myImageSize{size}, + myTransactionQueue{TRANSACTION_QUEUE_CAPACITY}, + myVcsLib{myTransactionQueue} { myImage = make_unique(size); std::memcpy(myImage.get(), image.get(), size); @@ -236,9 +238,6 @@ CartridgeELF::CartridgeELF(const ByteBuffer& image, size_t size, string_view md5 allocationSections(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeELF::~CartridgeELF() = default; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELF::reset() { @@ -376,7 +375,6 @@ uInt8 CartridgeELF::overdrivePoke(uInt16 address, uInt8 value) } #ifdef DEBUGGER_SUPPORT - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartDebugWidget* CartridgeELF::debugWidget( GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, int x, int y, int w, int h @@ -425,21 +423,8 @@ std::pair, size_t> CartridgeELF::getArmImage() const return {std::move(image), imageSize}; } - #endif -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -inline uInt64 CartridgeELF::getArmCycles() const -{ - return myCortexEmu.getCycles() + myArmCyclesOffset; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt64 CartridgeELF::getVcsCyclesArm() const -{ - return mySystem->cycles() * myArmCyclesPer6502Cycle; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value) { diff --git a/src/emucore/CartELF.hxx b/src/emucore/CartELF.hxx index 428e9aa70..f455a9e5d 100644 --- a/src/emucore/CartELF.hxx +++ b/src/emucore/CartELF.hxx @@ -25,6 +25,7 @@ #include "ElfParser.hxx" #include "BusTransactionQueue.hxx" #include "VcsLib.hxx" +#include "System.hxx" class ElfLinker; @@ -47,7 +48,7 @@ class CartridgeELF: public Cartridge { public: CartridgeELF(const ByteBuffer& image, size_t size, string_view md5, const Settings& settings); - ~CartridgeELF() override; + ~CartridgeELF() override = default; // Methods from Device public: @@ -127,8 +128,12 @@ class CartridgeELF: public Cartridge { void setupConfig(); void resetWithConfig(); - uInt64 getArmCycles() const; - uInt64 getVcsCyclesArm() const; + uInt64 getArmCycles() const { + return myCortexEmu.getCycles() + myArmCyclesOffset; + } + uInt64 getVcsCyclesArm() const { + return mySystem->cycles() * myArmCyclesPer6502Cycle; + } uInt8 driveBus(uInt16 address, uInt8 value); void syncArmTime(uInt64 armCycles); diff --git a/src/emucore/elf/ElfLinker.cxx b/src/emucore/elf/ElfLinker.cxx index daf55c7ac..c1f837e49 100644 --- a/src/emucore/elf/ElfLinker.cxx +++ b/src/emucore/elf/ElfLinker.cxx @@ -23,7 +23,6 @@ #include "ElfLinker.hxx" namespace { - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - optional determineSegmentType(const ElfFile::Section& section) { switch (section.type) { @@ -42,7 +41,6 @@ namespace { } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - constexpr bool checkSegmentOverlap(uInt32 segmentBase1, uInt32 segmentSize1, uInt32 segmentBase2, uInt32 segmentSize2) { return !(segmentBase1 + segmentSize1 <= segmentBase2 || segmentBase2 + segmentSize2 <= segmentBase1); } @@ -51,7 +49,10 @@ namespace { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ElfLinker::ElfLinker(uInt32 textBase, uInt32 dataBase, uInt32 rodataBase, const ElfFile& elf) - : myTextBase{textBase}, myDataBase{dataBase}, myRodataBase{rodataBase}, myElf{elf} + : myTextBase{textBase}, + myDataBase{dataBase}, + myRodataBase{rodataBase}, + myElf{elf} { } diff --git a/src/emucore/elf/ElfUtil.cxx b/src/emucore/elf/ElfUtil.cxx index 720f552db..b21352c59 100644 --- a/src/emucore/elf/ElfUtil.cxx +++ b/src/emucore/elf/ElfUtil.cxx @@ -20,23 +20,23 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Int32 elfUtil::decode_B_BL(uInt32 opcode) { - // nomenclature follows Thumb32 BL / B.W encoding in Arm Architecture Reference + // nomenclature follows Thumb32 BL / B.W encoding in Arm Architecture Reference - const uInt16 hw1 = opcode; - const uInt16 hw2 = opcode >> 16; + const uInt16 hw1 = opcode; + const uInt16 hw2 = opcode >> 16; - const uInt8 s = (hw1 >> 10) & 0x01; - const uInt8 i1 = ~((hw2 >> 13) ^ s) & 0x01; - const uInt8 i2 = ~((hw2 >> 11) ^ s) & 0x01; - const uInt32 imm11 = hw2 & 0x7ff; - const uInt32 imm10 = hw1 & 0x3ff; + const uInt8 s = (hw1 >> 10) & 0x01; + const uInt8 i1 = ~((hw2 >> 13) ^ s) & 0x01; + const uInt8 i2 = ~((hw2 >> 11) ^ s) & 0x01; + const uInt32 imm11 = hw2 & 0x7ff; + const uInt32 imm10 = hw1 & 0x3ff; - Int32 offset = imm11 | (imm10 << 11) | (i2 << 21) | (i1 << 22) | (s << 23); + Int32 offset = imm11 | (imm10 << 11) | (i2 << 21) | (i1 << 22) | (s << 23); - offset <<= 8; - offset >>= 7; + offset <<= 8; + offset >>= 7; - return offset; + return offset; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/module.mk b/src/emucore/module.mk index 56129e886..82246a2cb 100644 --- a/src/emucore/module.mk +++ b/src/emucore/module.mk @@ -36,6 +36,7 @@ MODULE_OBJS := \ src/emucore/CartBFSC.o \ src/emucore/CartDF.o \ src/emucore/CartDFSC.o \ + src/emucore/CartELF.o \ src/emucore/CartF0.o \ src/emucore/CartF4.o \ src/emucore/CartF4SC.o \ @@ -55,9 +56,8 @@ MODULE_OBJS := \ src/emucore/CartTVBoy.o \ src/emucore/CartUA.o \ src/emucore/CartWD.o \ - src/emucore/CartWF8.o \ + src/emucore/CartWF8.o \ src/emucore/CartX07.o \ - src/emucore/CartELF.o \ src/emucore/CompuMate.o \ src/emucore/Console.o \ src/emucore/Control.o \