diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 4563490..cd05158 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -25,7 +25,8 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v3 with: - version: '5.14.2' + version: '6.5.*' + modules: qtwebsockets target: 'desktop' arch: ${{ matrix.qt_version }} install-deps: 'true' @@ -33,8 +34,8 @@ jobs: - name: Install Third Party run: | brew install openal-soft - brew install qt5 - export Qt5_DIR=$(brew --prefix)/opt/qt5 + brew install qt6 + export Qt6_DIR=$(brew --prefix)/opt/qt6 - name: Checkout submodules diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index f5462f9..a752987 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -26,8 +26,8 @@ jobs: - name: Prepare Environement run: | sudo apt-get update - sudo apt install qtbase5-dev --fix-missing - sudo apt-get install libqt5websockets5-dev --fix-missing + sudo apt install qt6-base-dev --fix-missing + sudo apt-get install libqt6websockets6-dev --fix-missing sudo apt-get install udev build-essential libpthread-stubs0-dev libgl1-mesa-dev libx11-dev libxrandr-dev libfreetype6-dev libglew-dev libjpeg-dev libxi-dev --fix-missing sudo apt-get install libxinerama-dev libxcursor-dev --fix-missing sudo apt-get install libudev-dev libglu1-mesa-dev libsecret-1-dev libnotify-dev --fix-missing diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a79aa03..a491a8a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -29,10 +29,11 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v3 with: - version: '5.14.2' + version: '6.5.*' target: 'desktop' - arch: win32_msvc2017 + arch: win64_msvc2019_64 install-deps: 'true' + modules: qtwebsockets - name: Install udev run: ${{ matrix.other_installer }} @@ -43,7 +44,7 @@ jobs: - name: Configure CMake run: | echo 'Version : ' ${{ inputs.version }} - cmake -B ${{github.workspace}}\build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\install -AWin32 -DSUGARBOX_VERSION='${{ inputs.version }}' + cmake -B ${{github.workspace}}\build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}\install -DSUGARBOX_VERSION='${{ inputs.version }}' - name: Build # Build your program with the given configuration @@ -61,7 +62,7 @@ jobs: - name: Archive zip uses: actions/upload-artifact@v3 with: - name: SugarboxV2Win32 + name: SugarboxV2 path: ${{github.workspace}}\build\*.7z diff --git a/CPCCore b/CPCCore index 8d4b432..ea62323 160000 --- a/CPCCore +++ b/CPCCore @@ -1 +1 @@ -Subproject commit 8d4b432e2b955ba29aa7baa84afc475562f25a75 +Subproject commit ea623239c7f3a4e1631770746dd62226d2330b0c diff --git a/README.md b/README.md index 3de56b5..3a22bfb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Sugarbox V2](https://raw.githubusercontent.com/Tom1975/SugarboxV2/master/SplashScreen.bmp) -[![Windows](https://github.com/Tom1975/SugarboxV2/actions/workflows/cmake.yml/badge.svg)](https://github.com/Tom1975/SugarboxV2/actions/workflows/cmake.yml) +[![Windows](https://github.com/Tom1975/SugarboxV2/actions/workflows/windows.yml/badge.svg)](https://github.com/Tom1975/SugarboxV2/actions/workflows/windows.yml) [![Ubuntu](https://github.com/Tom1975/SugarboxV2/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/Tom1975/SugarboxV2/actions/workflows/ubuntu.yml) [![MacOS](https://github.com/Tom1975/SugarboxV2/actions/workflows/macos.yml/badge.svg)](https://github.com/Tom1975/SugarboxV2/actions/workflows/macos.yml) diff --git a/Sugarbox/CMakeLists.txt b/Sugarbox/CMakeLists.txt index 18d86d7..73c43f2 100644 --- a/Sugarbox/CMakeLists.txt +++ b/Sugarbox/CMakeLists.txt @@ -16,7 +16,7 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -set (SUGARBOX_VERSION "2.0.1" CACHE STRING "Version to build" FORCE) +set (SUGARBOX_VERSION "2.0.2" CACHE STRING "Version to build" FORCE) MESSAGE (STATUS "Version :" ${SUGARBOX_VERSION}) @@ -32,31 +32,31 @@ set(CompilerFlags ) -find_package(Qt5 COMPONENTS Widgets WebSockets REQUIRED) -qt5_add_resources(QRCS resources.qrc) +find_package(Qt6 COMPONENTS Widgets WebSockets OpenGLWidgets OpenGL REQUIRED) +qt6_add_resources(QRCS resources.qrc) -if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) - get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION) +if(Qt6_FOUND AND WIN32 AND TARGET Qt6::qmake AND NOT TARGET Qt6::windeployqt) + get_target_property(_qt6_qmake_location Qt6::qmake IMPORTED_LOCATION) execute_process( - COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX + COMMAND "${_qt6_qmake_location}" -query QT_INSTALL_PREFIX RESULT_VARIABLE return_code - OUTPUT_VARIABLE qt5_install_prefix + OUTPUT_VARIABLE qt6_install_prefix OUTPUT_STRIP_TRAILING_WHITESPACE ) - set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe") + set(imported_location "${qt6_install_prefix}/bin/windeployqt.exe") if(EXISTS ${imported_location}) - add_executable(Qt5::windeployqt IMPORTED) + add_executable(Qt6::windeployqt IMPORTED) - set_target_properties(Qt5::windeployqt PROPERTIES + set_target_properties(Qt6::windeployqt PROPERTIES IMPORTED_LOCATION ${imported_location} ) endif() endif() -get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION) +get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") @@ -146,8 +146,10 @@ set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_INSTALL_BINDIR}) set ( SUGARBOX_OUTPUT_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}) # Link test executable against gtest & gtest_main -target_link_libraries(Sugarbox CPCCoreEmu zlibstatic OpenAL Qt5::Core Qt5::Widgets Qt5::WebSockets ${LIB_EXT}) +target_link_libraries(Sugarbox CPCCoreEmu zlibstatic OpenAL Qt6::Core Qt6::Widgets Qt6::WebSockets Qt6::OpenGLWidgets ${LIB_EXT}) + set_property(TARGET Sugarbox PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_INSTALL_BINDIR}") +MESSAGE ( CMAKE_INSTALL_BINDIR = ${CMAKE_INSTALL_BINDIR}) if (APPLE) target_link_libraries(Sugarbox "-framework OpenGL") @@ -161,6 +163,7 @@ install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/CART" DESTINATION .) install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/CONF" DESTINATION .) install ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Resources" DESTINATION .) +set_property(TARGET Sugarbox PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}") # MSVC CPACK Qt dlls IF(MSVC) diff --git a/Sugarbox/CONF/KeyboardMaps.ini b/Sugarbox/CONF/KeyboardMaps.ini index 3e74367..d96a51b 100644 --- a/Sugarbox/CONF/KeyboardMaps.ini +++ b/Sugarbox/CONF/KeyboardMaps.ini @@ -49,7 +49,7 @@ 0_3_UCHAR_Alt = 0_3_UCHAR_value = 0_3_UCHAR_value_Alt = -0_3_char = 9 +0_3_char = 0_3_charCtrl = 0_3_charCtrl_value = 0_3_char_Alt = @@ -63,7 +63,7 @@ 0_4_UCHAR_Alt = 0_4_UCHAR_value = 0_4_UCHAR_value_Alt = -0_4_char = 6 +0_4_char = 0_4_charCtrl = 0_4_charCtrl_value = 0_4_char_Alt = @@ -77,7 +77,7 @@ 0_5_UCHAR_Alt = 0_5_UCHAR_value = 0_5_UCHAR_value_Alt = -0_5_char = 3 +0_5_char = 0_5_charCtrl = 0_5_charCtrl_value = 0_5_char_Alt = @@ -147,7 +147,7 @@ 1_2_UCHAR_Alt = 1_2_UCHAR_value = 1_2_UCHAR_value_Alt = -1_2_char = 7 +1_2_char = 1_2_charCtrl = 1_2_charCtrl_value = 1_2_char_Alt = @@ -161,7 +161,7 @@ 1_3_UCHAR_Alt = 1_3_UCHAR_value = 1_3_UCHAR_value_Alt = -1_3_char = 8 +1_3_char = 1_3_charCtrl = 1_3_charCtrl_value = 1_3_char_Alt = @@ -175,7 +175,7 @@ 1_4_UCHAR_Alt = 1_4_UCHAR_value = 1_4_UCHAR_value_Alt = -1_4_char = 5 +1_4_char = 1_4_charCtrl = 1_4_charCtrl_value = 1_4_char_Alt = @@ -189,7 +189,7 @@ 1_5_UCHAR_Alt = 1_5_UCHAR_value = 1_5_UCHAR_value_Alt = -1_5_char = 1 +1_5_char = 1_5_charCtrl = 1_5_charCtrl_value = 1_5_char_Alt = @@ -203,7 +203,7 @@ 1_6_UCHAR_Alt = 1_6_UCHAR_value = 1_6_UCHAR_value_Alt = -1_6_char = 2 +1_6_char = 1_6_charCtrl = 1_6_charCtrl_value = 1_6_char_Alt = @@ -217,7 +217,7 @@ 1_7_UCHAR_Alt = 1_7_UCHAR_value = 1_7_UCHAR_value_Alt = -1_7_char = 0 +1_7_char = 1_7_charCtrl = 1_7_charCtrl_value = 1_7_char_Alt = @@ -287,7 +287,7 @@ 2_4_UCHAR_Alt = 2_4_UCHAR_value = 2_4_UCHAR_value_Alt = -2_4_char = 4 +2_4_char = 2_4_charCtrl = 2_4_charCtrl_value = 2_4_char_Alt = @@ -671,6 +671,20 @@ 6_0_char_Alt = 6_0_char_value = 6_0_char_value_Alt = +6_1_SC = 40 +6_1_SCA = 0 +6_1_UCHAR = % +6_1_UCHARCTRL = +6_1_UCHARCTRL_value = +6_1_UCHAR_Alt = +6_1_UCHAR_value = +6_1_UCHAR_value_Alt = +6_1_char = 5 +6_1_charCtrl = +6_1_charCtrl_value = +6_1_char_Alt = +6_1_char_value = +6_1_char_value_Alt = 6_2_SC = 82 6_2_SCA = 0 6_2_UCHAR = R @@ -1044,7 +1058,7 @@ 0_3_UCHAR_Alt = 0_3_UCHAR_value = 0_3_UCHAR_value_Alt = -0_3_char = 9 +0_3_char = 0_3_charCtrl = 0_3_charCtrl_value = 0_3_char_Alt = @@ -1058,7 +1072,7 @@ 0_4_UCHAR_Alt = 0_4_UCHAR_value = 0_4_UCHAR_value_Alt = -0_4_char = 6 +0_4_char = 0_4_charCtrl = 0_4_charCtrl_value = 0_4_char_Alt = @@ -1072,7 +1086,7 @@ 0_5_UCHAR_Alt = 0_5_UCHAR_value = 0_5_UCHAR_value_Alt = -0_5_char = 3 +0_5_char = 0_5_charCtrl = 0_5_charCtrl_value = 0_5_char_Alt = @@ -1142,7 +1156,7 @@ 1_2_UCHAR_Alt = 1_2_UCHAR_value = 1_2_UCHAR_value_Alt = -1_2_char = 7 +1_2_char = 1_2_charCtrl = 1_2_charCtrl_value = 1_2_char_Alt = @@ -1156,7 +1170,7 @@ 1_3_UCHAR_Alt = 1_3_UCHAR_value = 1_3_UCHAR_value_Alt = -1_3_char = 8 +1_3_char = 1_3_charCtrl = 1_3_charCtrl_value = 1_3_char_Alt = @@ -1170,7 +1184,7 @@ 1_4_UCHAR_Alt = 1_4_UCHAR_value = 1_4_UCHAR_value_Alt = -1_4_char = 5 +1_4_char = 1_4_charCtrl = 1_4_charCtrl_value = 1_4_char_Alt = @@ -1184,7 +1198,7 @@ 1_5_UCHAR_Alt = 1_5_UCHAR_value = 1_5_UCHAR_value_Alt = -1_5_char = 1 +1_5_char = 1_5_charCtrl = 1_5_charCtrl_value = 1_5_char_Alt = @@ -1198,7 +1212,7 @@ 1_6_UCHAR_Alt = 1_6_UCHAR_value = 1_6_UCHAR_value_Alt = -1_6_char = 2 +1_6_char = 1_6_charCtrl = 1_6_charCtrl_value = 1_6_char_Alt = @@ -1212,7 +1226,7 @@ 1_7_UCHAR_Alt = 1_7_UCHAR_value = 1_7_UCHAR_value_Alt = -1_7_char = 0 +1_7_char = 1_7_charCtrl = 1_7_charCtrl_value = 1_7_char_Alt = @@ -1282,7 +1296,7 @@ 2_4_UCHAR_Alt = 2_4_UCHAR_value = 2_4_UCHAR_value_Alt = -2_4_char = 4 +2_4_char = 2_4_charCtrl = 2_4_charCtrl_value = 2_4_char_Alt = @@ -1666,6 +1680,20 @@ 6_0_char_Alt = 6_0_char_value = 6_0_char_value_Alt = +6_1_SC = 40 +6_1_SCA = 0 +6_1_UCHAR = % +6_1_UCHARCTRL = +6_1_UCHARCTRL_value = +6_1_UCHAR_Alt = +6_1_UCHAR_value = +6_1_UCHAR_value_Alt = +6_1_char = 5 +6_1_charCtrl = +6_1_charCtrl_value = +6_1_char_Alt = +6_1_char_value = +6_1_char_value_Alt = 6_2_SC = 82 6_2_SCA = 0 6_2_UCHAR = R @@ -2039,7 +2067,7 @@ 0_3_UCHAR_Alt = 0_3_UCHAR_value = 0_3_UCHAR_value_Alt = -0_3_char = 9 +0_3_char = 0_3_charCtrl = 0_3_charCtrl_value = 0_3_char_Alt = @@ -2053,7 +2081,7 @@ 0_4_UCHAR_Alt = 0_4_UCHAR_value = 0_4_UCHAR_value_Alt = -0_4_char = 6 +0_4_char = 0_4_charCtrl = 0_4_charCtrl_value = 0_4_char_Alt = @@ -2067,7 +2095,7 @@ 0_5_UCHAR_Alt = 0_5_UCHAR_value = 0_5_UCHAR_value_Alt = -0_5_char = 3 +0_5_char = 0_5_charCtrl = 0_5_charCtrl_value = 0_5_char_Alt = @@ -2137,7 +2165,7 @@ 1_2_UCHAR_Alt = 1_2_UCHAR_value = 1_2_UCHAR_value_Alt = -1_2_char = 7 +1_2_char = 1_2_charCtrl = 1_2_charCtrl_value = 1_2_char_Alt = @@ -2151,7 +2179,7 @@ 1_3_UCHAR_Alt = 1_3_UCHAR_value = 1_3_UCHAR_value_Alt = -1_3_char = 8 +1_3_char = 1_3_charCtrl = 1_3_charCtrl_value = 1_3_char_Alt = @@ -2165,7 +2193,7 @@ 1_4_UCHAR_Alt = 1_4_UCHAR_value = 1_4_UCHAR_value_Alt = -1_4_char = 5 +1_4_char = 1_4_charCtrl = 1_4_charCtrl_value = 1_4_char_Alt = @@ -2179,7 +2207,7 @@ 1_5_UCHAR_Alt = 1_5_UCHAR_value = 1_5_UCHAR_value_Alt = -1_5_char = 1 +1_5_char = 1_5_charCtrl = 1_5_charCtrl_value = 1_5_char_Alt = @@ -2193,7 +2221,7 @@ 1_6_UCHAR_Alt = 1_6_UCHAR_value = 1_6_UCHAR_value_Alt = -1_6_char = 2 +1_6_char = 1_6_charCtrl = 1_6_charCtrl_value = 1_6_char_Alt = @@ -2207,7 +2235,7 @@ 1_7_UCHAR_Alt = 1_7_UCHAR_value = 1_7_UCHAR_value_Alt = -1_7_char = 0 +1_7_char = 1_7_charCtrl = 1_7_charCtrl_value = 1_7_char_Alt = @@ -2277,7 +2305,7 @@ 2_4_UCHAR_Alt = 2_4_UCHAR_value = 2_4_UCHAR_value_Alt = -2_4_char = 4 +2_4_char = 2_4_charCtrl = 2_4_charCtrl_value = 2_4_char_Alt = @@ -3062,7 +3090,7 @@ 0_3_UCHAR_Alt = 0_3_UCHAR_value = 0_3_UCHAR_value_Alt = -0_3_char = 9 +0_3_char = 0_3_charCtrl = 0_3_charCtrl_value = 0_3_char_Alt = @@ -3076,7 +3104,7 @@ 0_4_UCHAR_Alt = 0_4_UCHAR_value = 0_4_UCHAR_value_Alt = -0_4_char = 6 +0_4_char = 0_4_charCtrl = 0_4_charCtrl_value = 0_4_char_Alt = @@ -3090,7 +3118,7 @@ 0_5_UCHAR_Alt = 0_5_UCHAR_value = 0_5_UCHAR_value_Alt = -0_5_char = 3 +0_5_char = 0_5_charCtrl = 0_5_charCtrl_value = 0_5_char_Alt = @@ -3160,7 +3188,7 @@ 1_2_UCHAR_Alt = 1_2_UCHAR_value = 1_2_UCHAR_value_Alt = -1_2_char = 7 +1_2_char = 1_2_charCtrl = 1_2_charCtrl_value = 1_2_char_Alt = @@ -3174,7 +3202,7 @@ 1_3_UCHAR_Alt = 1_3_UCHAR_value = 1_3_UCHAR_value_Alt = -1_3_char = 8 +1_3_char = 1_3_charCtrl = 1_3_charCtrl_value = 1_3_char_Alt = @@ -3188,7 +3216,7 @@ 1_4_UCHAR_Alt = 1_4_UCHAR_value = 1_4_UCHAR_value_Alt = -1_4_char = 5 +1_4_char = 1_4_charCtrl = 1_4_charCtrl_value = 1_4_char_Alt = @@ -3202,7 +3230,7 @@ 1_5_UCHAR_Alt = 1_5_UCHAR_value = 1_5_UCHAR_value_Alt = -1_5_char = 1 +1_5_char = 1_5_charCtrl = 1_5_charCtrl_value = 1_5_char_Alt = @@ -3216,7 +3244,7 @@ 1_6_UCHAR_Alt = 1_6_UCHAR_value = 1_6_UCHAR_value_Alt = -1_6_char = 2 +1_6_char = 1_6_charCtrl = 1_6_charCtrl_value = 1_6_char_Alt = @@ -3230,7 +3258,7 @@ 1_7_UCHAR_Alt = 1_7_UCHAR_value = 1_7_UCHAR_value_Alt = -1_7_char = 0 +1_7_char = 1_7_charCtrl = 1_7_charCtrl_value = 1_7_char_Alt = @@ -3300,7 +3328,7 @@ 2_4_UCHAR_Alt = 2_4_UCHAR_value = 2_4_UCHAR_value_Alt = -2_4_char = 4 +2_4_char = 2_4_charCtrl = 2_4_charCtrl_value = 2_4_char_Alt = diff --git a/Sugarbox/DebugCommand.cpp b/Sugarbox/DebugCommand.cpp index c391300..8239753 100644 --- a/Sugarbox/DebugCommand.cpp +++ b/Sugarbox/DebugCommand.cpp @@ -1,6 +1,9 @@ #include "DebugCommand.h" +#include "DebugSocket.h" +#include "Emulation.h" + // Cross compilation : use stricmp / strcasecmp depending on windows / linux #ifndef _WIN32 #define stricmp strcasecmp @@ -317,4 +320,4 @@ bool RemoteCommandSetBreakpoint::Execute(std::vector& param) emulation_->CreateBreakpoint(indice, sub_param); return true; -} \ No newline at end of file +} diff --git a/Sugarbox/DebugCommand.h b/Sugarbox/DebugCommand.h index 33f26da..3f46a5a 100644 --- a/Sugarbox/DebugCommand.h +++ b/Sugarbox/DebugCommand.h @@ -1,7 +1,9 @@ #pragma once +#include #include #include -#include "Emulation.h" + +class Emulation; //////////////////////////////////////////////////////// // Command Interface @@ -196,3 +198,5 @@ class RemoteCommandSetBreakpoint : public IRemoteCommand virtual bool Execute(std::vector&); virtual std::string Help() { return "Sets a breakpoint at desired index entry with condition. If no condition set, breakpoint will be handled as disabled"; } }; + + diff --git a/Sugarbox/DisassemblyWidget.cpp b/Sugarbox/DisassemblyWidget.cpp index 22e5145..b52420e 100644 --- a/Sugarbox/DisassemblyWidget.cpp +++ b/Sugarbox/DisassemblyWidget.cpp @@ -121,10 +121,10 @@ void DisassemblyWidget::keyPressEvent(QKeyEvent* event) void DisassemblyWidget::mousePressEvent(QMouseEvent* event) { // Check line - int line = event->y() / line_height_; + int line = event->position().y() / line_height_; // check position - int x = event->x(); + int x = event->position().x(); if ( line < nb_lines_ && x < width()) { diff --git a/Sugarbox/Display.cpp b/Sugarbox/Display.cpp index 4915be5..4f2be5b 100644 --- a/Sugarbox/Display.cpp +++ b/Sugarbox/Display.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "Display.h" @@ -180,6 +182,48 @@ void CDisplay::HSync () void CDisplay::StartSync() { +} + +void CDisplay::Screenshot() +{ + // Take a screenshot : Last displayed + + QImage img((unsigned char*)framebufferArray_[0], 1024, 1024, QImage::Format_ARGB32); + QImage scr(DISP_WINDOW_X, DISP_WINDOW_Y, QImage::Format_ARGB32); + + QPainter p; + for (int line = ORIGIN_Y; line < DISP_WINDOW_Y / 2; line++) + { + p.begin(&scr); + p.drawImage(QRectF(0, line * 2, DISP_WINDOW_X, 2), + img, QRectF(ORIGIN_X, line, DISP_WINDOW_X, 1), + Qt::AutoColor); + p.end(); + } + + scr.save("SCREENSHOT.JPG"); +} + +void CDisplay::Screenshot(const char* scr_path) +{ + // Take a screenshot : Last displayed + + QImage img((unsigned char*)framebufferArray_[0], 1024, 1024, QImage::Format_ARGB32); + QImage scr(DISP_WINDOW_X, DISP_WINDOW_Y, QImage::Format_ARGB32); + + QPainter p; + for (int line = ORIGIN_Y; line < DISP_WINDOW_Y/2; line++) + { + p.begin(&scr); + p.drawImage(QRectF(0, line*2, DISP_WINDOW_X, 2), + img, QRectF(ORIGIN_X, line, DISP_WINDOW_X, 1), + Qt::AutoColor); + p.end(); + } + + scr.save(scr_path); + + } void CDisplay::VSync (bool bDbg) diff --git a/Sugarbox/Display.h b/Sugarbox/Display.h index 930d0c5..ed03064 100644 --- a/Sugarbox/Display.h +++ b/Sugarbox/Display.h @@ -41,7 +41,8 @@ public : virtual void WaitVbl () ; virtual int* GetVideoBuffer (int y) ; virtual void Reset () ; - virtual void Screenshot (){}; + virtual void Screenshot (const char* scr_path); + virtual void Screenshot(); virtual void ScreenshotEveryFrame(int bSetOn) {}; virtual bool IsEveryFrameScreened() { return false; diff --git a/Sugarbox/DlgSettings.cpp b/Sugarbox/DlgSettings.cpp index 5a09b27..7794d0b 100644 --- a/Sugarbox/DlgSettings.cpp +++ b/Sugarbox/DlgSettings.cpp @@ -45,7 +45,8 @@ void DlgSettings::DisplayMenu() void DlgSettings::UpdateCombo(QComboBox *config_box) { config_box->clear(); - for (unsigned int i = 0; i < settings_list_.GetNumberOfConfigurations(); i++) + int index_sel = 0; + for (int i = 0; i < settings_list_.GetNumberOfConfigurations(); i++) { MachineSettings* settings = settings_list_.GetConfiguration(i); if (settings != nullptr) @@ -53,8 +54,15 @@ void DlgSettings::UpdateCombo(QComboBox *config_box) const char* shortname = settings->GetShortDescription(); config_box->addItem( shortname, i ); + + if (*engine_->GetSettings() == *settings) + { + index_sel = i; + } } } + config_box->setCurrentIndex(index_sel); + //connect(config_box, QOverload::of(&QComboBox::currentIndexChanged), [=](int index) { parent_->ChangeSettings(settings_list_.GetConfiguration(index)); }); QObject::connect(config_box, SIGNAL(currentIndexChanged(int)), SLOT(ChangeSettings(int))); } diff --git a/Sugarbox/Emulation.cpp b/Sugarbox/Emulation.cpp index d4279b2..3188f79 100644 --- a/Sugarbox/Emulation.cpp +++ b/Sugarbox/Emulation.cpp @@ -64,7 +64,7 @@ unsigned int Emulation::GetSpeed() return emulator_engine_->GetSpeed(); } -void Emulation::Init( IDisplay* display, ISoundFactory* sound, ALSoundMixer* sound_mixer, const char* current_path) +void Emulation::Init( IDisplay* display, ISoundFactory* sound, ALSoundMixer* sound_mixer, const char* current_path, SugarboxInitialisation& init) { sound_mixer_ = sound_mixer; current_path_ = current_path; @@ -80,14 +80,11 @@ void Emulation::Init( IDisplay* display, ISoundFactory* sound, ALSoundMixer* sou emulator_engine_->SetSettings(emulator_settings_); emulator_engine_->SetNotifier(this); - emulator_engine_->LoadConfiguration("Current", "Sugarbox.ini"); + emulator_engine_->LoadConfiguration("Current", "Sugarbox.ini", &init); emulator_engine_->GetMem()->Initialisation(); // Update computer emulator_engine_->Reinit(); - running_thread_ = true; - worker_thread_ = new std::thread(RunLoop, this); - sound_mixer_->AddWav(SND_SEEK_SHORT, seek_short_wav, sizeof(seek_short_wav)); sound_mixer_->AddWav(SND_SEEK_LONG, seek_long_wav, sizeof(seek_short_wav)); sound_mixer_->AddWav(SND_INSERT_DISK, insert_wav, sizeof(seek_short_wav)); @@ -95,6 +92,12 @@ void Emulation::Init( IDisplay* display, ISoundFactory* sound, ALSoundMixer* sou sound_mixer_->AddWav(SND_MOTOR_ON, drive_mo_wav, sizeof(seek_short_wav)); disassembler_ = new Z80Desassember(emulator_engine_); + + // Start thread + running_thread_ = true; + debug_action_ = init._debug_start ? DBG_BREAK : DBG_NONE; + worker_thread_ = new std::thread(RunLoop, this); + } void Emulation::Stop() @@ -168,6 +171,12 @@ void Emulation::EmulationLoop() // - break : Stop emulation until next command std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; + + case DBG_SCRIPT: + // Script running + ExecuteNextScript(); + debug_action_ = DBG_BREAK; + break; } if (old_action != debug_action_) @@ -177,7 +186,12 @@ void Emulation::EmulationLoop() { it->NotifyStop(); } + } + // Script to be run ? + if (script_player_.WaitingScript() ) + { + debug_action_ = DBG_SCRIPT; } } @@ -195,6 +209,23 @@ void Emulation::EmulationLoop() emulation_stopped_ = true; } +void Emulation::Lock() +{ + command_mutex_.lock(); +} + +void Emulation::Unlock() +{ + command_mutex_.unlock(); +} + + +void Emulation::ExecuteNextScript () +{ + // Is there any script left ? + script_player_.ExecuteNext(); +} + void Emulation::Pause() { pause_ = !pause_; @@ -688,7 +719,7 @@ void Emulation::Run(int nb_opcodes ) } else { - debug_action_ = DBG_RUN_FIXED_OP; + debug_action_ = DBG_RUN_FIXED_OP; nb_opcode_to_run_ = nb_opcodes; } @@ -698,3 +729,17 @@ void Emulation::AddUpdateListener(IUpdate* listener) { listeners_.push_back(listener); } + +void Emulation::AddScript(std::filesystem::path& path) +{ + script_player_.LoadScript(path); + +} + +void Emulation::ChangeConfiguration (const char* config_name) +{ + command_waiting_ = true; + const std::lock_guard lock(command_mutex_); + emulator_engine_->LoadConfiguration(config_name); + emulator_engine_->UpdateFromSettings(); +} diff --git a/Sugarbox/Emulation.h b/Sugarbox/Emulation.h index aa50d54..0817a95 100644 --- a/Sugarbox/Emulation.h +++ b/Sugarbox/Emulation.h @@ -7,11 +7,14 @@ #include "Snapshot.h" #include "ConfigurationManager.h" #include "ISound.h" -#include "Inotify.h" +#include "Inotify.h" #include "ALSoundMixer.h" #include "IUpdate.h" #include "Z80Desassember.h" +#include "SCLPlayer.h" + + class INotifier { public: @@ -58,7 +61,7 @@ public : virtual void DiskRunning(bool on); virtual void TrackChanged(int nb_tracks); - virtual void Init(IDisplay* display, ISoundFactory* sound, ALSoundMixer* sound_mixer, const char* current_path); + virtual void Init(IDisplay* display, ISoundFactory* sound, ALSoundMixer* sound_mixer, const char* current_path, SugarboxInitialisation& init); virtual void Stop(); virtual void HardReset(); virtual void Pause(); @@ -109,6 +112,7 @@ public : DBG_RUN_FIXED_OP, DBG_STEP, DBG_BREAK, + DBG_SCRIPT }debug_action_; void AddNotifier(IBeakpointNotifier*); @@ -149,6 +153,13 @@ public : return &config_manager_; } + void ChangeConfiguration(const char* config_name); + + + void AddScript(std::filesystem::path& path); + + void Lock(); + void Unlock(); protected: // Listener list @@ -183,4 +194,10 @@ public : bool command_waiting_; std::mutex command_mutex_; std::string current_path_; -}; \ No newline at end of file + + // Script + void ExecuteNextScript(); + + SCLPlayer script_player_; + +}; diff --git a/Sugarbox/Functions.cpp b/Sugarbox/Functions.cpp index fa19eab..909e5d6 100644 --- a/Sugarbox/Functions.cpp +++ b/Sugarbox/Functions.cpp @@ -96,7 +96,8 @@ void FunctionList::InitFunctions(IFunctionInterface* function_handler) menu_list_.push_back(new Function(multilanguage_, "L_FN_MENU_Files", { &function_list_.at(IFunctionInterface::FN_EXIT), &function_list_.at(IFunctionInterface::FN_AUTOLOAD), - & function_list_.at(IFunctionInterface::FN_AUTOTYPE) + & function_list_.at(IFunctionInterface::FN_AUTOTYPE), + & function_list_.at(IFunctionInterface::FN_CSL_LOAD), },[]() { return true; })); diff --git a/Sugarbox/Functions.h b/Sugarbox/Functions.h index e970e6d..1793eb8 100644 --- a/Sugarbox/Functions.h +++ b/Sugarbox/Functions.h @@ -27,6 +27,7 @@ class IFunctionInterface { // File FN_EXIT, + FN_CSL_LOAD, FN_SNA_LOAD, FN_SNA_QUICK_LOAD, FN_SNA_SAVE, diff --git a/Sugarbox/Resources/labels.ini b/Sugarbox/Resources/labels.ini index ebcbf17..2daccd6 100644 --- a/Sugarbox/Resources/labels.ini +++ b/Sugarbox/Resources/labels.ini @@ -31,6 +31,7 @@ L_FN_MENU_Tape = Tape L_FILE_EXIT = Exit L_FN_AUTOLOAD = Autorun inserted disk L_FN_AUTOTYPE = Paste clipboard +L_FN_LOADCSL = Load CSL script L_SETTINGS_CONFIG = Configurations L_FN_DISK_1_SAVE_AS = Save disk 1 as... L_FN_DISK_2_SAVE_AS = Save disk 2 as... @@ -101,6 +102,7 @@ L_FN_MENU_Tape = Cassette L_FILE_EXIT = Quitter L_FN_AUTOLOAD = Lancement automatique disque L_FN_AUTOTYPE = Coller le presse papier +L_FN_LOADCSL = Charger script CSL L_SETTINGS_CONFIG = Configurations L_FN_DISK_1_SAVE_AS = Enregistrer disk 1 sous... L_FN_DISK_2_SAVE_AS = Enregistrer disk 2 sous... diff --git a/Sugarbox/SCLPlayer.cpp b/Sugarbox/SCLPlayer.cpp new file mode 100644 index 0000000..531edb1 --- /dev/null +++ b/Sugarbox/SCLPlayer.cpp @@ -0,0 +1,103 @@ +#include + +#include "SCLPlayer.h" + +template void split(const std::string& s, char delim, Out result); + +SCLPlayer::SCLPlayer() +{ + // Init commands + +} + +SCLPlayer::~SCLPlayer() +{ +} + + +void SCLPlayer::LoadScript(std::filesystem::path& script_path) +{ + std::ifstream f(script_path); + std::string line; + + while (std::getline(f, line)) + { + // Handle line + std::string::size_type begin = line.find_first_not_of(" \f\t\v"); + + // Skip blank lines + if (begin == std::string::npos) continue; + // Skip commentary + std::string::size_type end = line.find_first_of(";"); + if ( end != std::string::npos) + line = line.substr(begin, end); + + if (line.empty()) continue; + + // Get command + std::vector command_parameters; + + std::string current_parameter; + char current_delim = ' '; + for (auto& c : line) + { + if (c == ';') + { + break; + } + if (c == current_delim) + { + // New + if (current_parameter.size() > 0) + command_parameters.push_back(current_parameter); + current_parameter.clear(); + current_delim = ' '; + } + else if (c == '\'' && current_parameter.size() == 0) + { + current_delim = '\''; + } + else if (c == '\"' && current_parameter.size() == 0) + { + current_delim = '\"'; + } + else + { + current_parameter += c; + } + } + // Comment : no more parameter to handle + if (current_parameter.size() > 0) + command_parameters.push_back(current_parameter); + + // Look for command + IScriptCommand* command = ScriptCommandFactory::GetCommand(command_parameters[0]); + if (command != nullptr) + { + script_.push(Script(command, command_parameters)); + } + + } +} + +void SCLPlayer::AddCommand(const char* command) +{ + +} + +bool SCLPlayer::WaitingScript() +{ + return script_.empty() == false; +} + +void SCLPlayer::ExecuteNext() +{ + if(!script_.empty()) + { + auto script = script_.front(); + + script.Execute(); + script_.pop(); + } +} + diff --git a/Sugarbox/SCLPlayer.h b/Sugarbox/SCLPlayer.h new file mode 100644 index 0000000..0e244f1 --- /dev/null +++ b/Sugarbox/SCLPlayer.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include + +#include "Script.h" + +class SCLPlayer +{ +public: + SCLPlayer(); + virtual ~SCLPlayer(); + + void LoadScript(std::filesystem::path& path); + + void AddCommand(const char* command); + + bool WaitingScript(); + void ExecuteNext(); + +protected: + + std::queue