From 3c76d941fa09f575903288fbcc49b39d680af211 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 19 Nov 2019 11:56:18 +0100 Subject: [PATCH 01/14] + multiple process entries per event type --- src/internal.cpp | 7 +++++-- src/internal.hpp | 3 ++- src/vkvm.cpp | 30 ++++++++++++++++++------------ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/internal.cpp b/src/internal.cpp index 82b515a..a6c5937 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -37,8 +37,11 @@ namespace vkvm { auto callEvent(EventType type) -> bool { auto ivt = getInterrupTable(); - if (ivt[type].pid != 0) { - sendSignal(ivt[type].pid, ivt[type].signum); + for(int i = 0; i < impl.interruptEntrysPerEventType;i++){ + auto &entry= ivt[type * impl.interruptEntrysPerEventType + i]; + if (entry.pid != 0) { + sendSignal(entry.pid, entry.signum); + } } return true; } diff --git a/src/internal.hpp b/src/internal.hpp index d237f92..a2fe49f 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -54,7 +54,8 @@ constexpr int keyboardBufferSize = 16; int sharedMemoryPid; key_t sharedMemoryKey; int sharedMemorySize; - int interruptEntyCount = 64; //NOLINT + int interruptEntyCount = 256; //NOLINT + int interruptEntrysPerEventType = 8; int reservedSize = 1024; //NOLINT std::vector> eventTable; }; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 3493667..57cf76e 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -37,21 +37,27 @@ namespace vkvm { lockSharedMemory(); - ivt[type].pid = getpid(); - ivt[type].signum = signum; - impl.eventTable.push_back(handler); + for(int i = 0; i < impl.interruptEntrysPerEventType;i++){ + auto &entry= ivt[type * impl.interruptEntrysPerEventType + i]; + if (entry.pid == 0) { - onSignal(signum, [](int sig){ - if(sig >= SIGUSR1){ - if((sig - SIGUSR1) < impl.eventTable.size()){ - impl.eventTable[sig - SIGUSR1](); - } + entry.pid = getpid(); + entry.signum = signum; + impl.eventTable.push_back(handler); + + onSignal(signum, [](int sig){ + if(sig >= SIGUSR1){ + if((sig - SIGUSR1) < impl.eventTable.size()){ + impl.eventTable[sig - SIGUSR1](); + } + } + }); + unlockSharedMemory(); + return true; } - }); - + } unlockSharedMemory(); - - return true; + return false; } auto setPixel(int x, int y, Color color) -> bool { From 04c0e189e54554ff6c18ae216443b6174a63b220 Mon Sep 17 00:00:00 2001 From: chenhuan Date: Wed, 20 Nov 2019 12:43:11 +0100 Subject: [PATCH 02/14] Keycode --- src/KeyCode.hpp | 57 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/src/KeyCode.hpp b/src/KeyCode.hpp index 34d2890..d09dfdb 100644 --- a/src/KeyCode.hpp +++ b/src/KeyCode.hpp @@ -5,18 +5,53 @@ namespace vkvm { - class KeyCode { - private: - int value; - public: - explicit KeyCode(int value) noexcept; - - auto getValue() -> int; + enum KeyCode { + Backspcce = 32, + Tab = 33, + Enter = 37, + ShiftLeft = 249, + ShiftRight = 249, + Ctrl = 251, + Alt = 257, + Delete = 279, + Space = -65224, + Zero = -65208, + One = -65207, + Two = -65206, + Three = -65205, + Four = -65204, + Five = -65203, + Six = -65202, + Seven = -65201, + Eight = -65200, + Nine = -65199, + A = -65159, + B = -65158, + C = -65157, + D = -65156, + E = -65155, + F = -65154, + G = -65153, + H = -65152, + I = -65151, + J = -65150, + K = -65149, + L = -65148, + M = -65147, + N = -65146, + O = -65145, + P = -65144, + Q = -65143, + R = -65142, + S = -65141, + T = -65140, + U = -65139, + V = -65138, + W = -65137, + X = -65136, + Y = -65135, + Z = -65134, }; - - const static KeyCode Backspace = KeyCode(8); - const static KeyCode tabulator = KeyCode(9); - } #endif \ No newline at end of file From 256c7d16bce779f9e7bc5189dbded4fccf7fc3dd Mon Sep 17 00:00:00 2001 From: chenhuan Date: Wed, 20 Nov 2019 13:14:50 +0100 Subject: [PATCH 03/14] delete Keycode.cpp --- src/KeyCode.cpp | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/KeyCode.cpp diff --git a/src/KeyCode.cpp b/src/KeyCode.cpp deleted file mode 100644 index aaa7e7d..0000000 --- a/src/KeyCode.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "KeyCode.hpp" - -namespace vkvm { - - KeyCode::KeyCode(int value) noexcept : value(value) {} - - auto KeyCode::getValue() -> int { - return value; - } - -} From e4dce850cc6114c20742a0a46e042669a98d99d0 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 21 Nov 2019 11:35:54 +0100 Subject: [PATCH 04/14] + pixelwerte getter/setter --- .ci/clang-tidy.sh | 2 +- .clang-tidy | 3 ++- CMakeLists.txt | 5 ++--- src/Color.cpp | 8 ++++++++ src/Color.hpp | 7 +++++++ src/internal.hpp | 2 +- src/vkvm.cpp | 24 ++++++++++++++++++------ test/color_test.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 test/color_test.cpp diff --git a/.ci/clang-tidy.sh b/.ci/clang-tidy.sh index e5861a2..f567cec 100755 --- a/.ci/clang-tidy.sh +++ b/.ci/clang-tidy.sh @@ -9,7 +9,7 @@ filelist="$(find . -not \( -path './*build*' -prune \) -not \( -path './include' for file in $filelist; do if echo "$file" | grep -q -E ".*(\.cpp|\.h|\.hpp)$" ; then #Extra check missing dependencies due to clang-tidy doesn't toggle exit code. - clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' --color -header-filter='.*,-cpptoml.hpp' "$file" -- -I. -std=c++14 2>&1)" + clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' --color "$file" -- -I. -std=c++14 2>&1)" for tidy_line in $clang_tidy_lib_check; do echo "$tidy_line" | grep -q -v -E "^Error while processing*" if [ $? -eq 1 ]; then diff --git a/.clang-tidy b/.clang-tidy index de644d1..f404c2e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,2 +1,3 @@ Checks: '*,-llvm-header-guard,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-modernize-use-trailing-return-type' -WarningsAsErrors: 'true' \ No newline at end of file +WarningsAsErrors: 'true' +HeaderFilterRegex: '.*,-catch.hpp' \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a23c62..828a9ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,7 @@ project(library) set(CMAKE_CXX_STANDARD 14) # enable clang_tidy -set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*") -set(CMAKE_CXX_CLANG_TIDY clang-tidy;-header-filter=.;) +set(CMAKE_CXX_CLANG_TIDY clang-tidy;) file(GLOB_RECURSE SOURCES src/*.cpp) @@ -22,7 +21,7 @@ file(GLOB_RECURSE TESTS test/*.cpp) include_directories(src) include_directories(test) -add_library(library ${SOURCES} ${HEADERS} src/FontType.cpp) +add_library(library ${SOURCES} ${HEADERS}) file(COPY "${CMAKE_SOURCE_DIR}/src/" DESTINATION "${CMAKE_SOURCE_DIR}/include" diff --git a/src/Color.cpp b/src/Color.cpp index 85ac7df..3acc402 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -30,4 +30,12 @@ namespace vkvm { auto Color::setBlue(unsigned char value) -> void { blue = value; } + + bool Color::operator==(const Color &other) const { + return this->blue == other.blue && this->green == other.green && this->red == other.red; + } + + bool Color::operator!=(const Color &other) const { + return this->blue != other.blue || this->green != other.green || this->red != other.red; + } } \ No newline at end of file diff --git a/src/Color.hpp b/src/Color.hpp index a8159b1..909eb9e 100644 --- a/src/Color.hpp +++ b/src/Color.hpp @@ -30,10 +30,17 @@ namespace vkvm { auto setBlue(unsigned char value) -> void; + bool operator==(const Color &other) const ; + + bool operator!=(const Color &other) const ; + }; const static Color black = Color(0, 0, 0); const static Color white = Color(255, 255, 255); + const static Color green = Color(0, 255, 0); + const static Color red = Color(255, 0, 0); + const static Color blue = Color(0, 0, 255); } diff --git a/src/internal.hpp b/src/internal.hpp index a2fe49f..c29e932 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -55,7 +55,7 @@ constexpr int keyboardBufferSize = 16; key_t sharedMemoryKey; int sharedMemorySize; int interruptEntyCount = 256; //NOLINT - int interruptEntrysPerEventType = 8; + int interruptEntrysPerEventType = 8; //NOLINT int reservedSize = 1024; //NOLINT std::vector> eventTable; }; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 57cf76e..46e5709 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -23,9 +23,9 @@ namespace vkvm { setHeight(600);// NOLINT setWidth(800);// NOLINT setMousePosition(42, 42);// NOLINT - setBackgroundColor(Color(200, 50, 20));// NOLINT - setForegroundColor(Color(20, 200, 50));// NOLINT - setMode(GraphicMode::RGB);// NOLINT + setBackgroundColor(black); + setForegroundColor(white); + setMode(GraphicMode::RGB); setRedrawInterval(20);// NOLINT setTimerInterruptInterval(10);// NOLINT } @@ -69,10 +69,22 @@ namespace vkvm { } auto getPixel(int x, int y) -> Color { - //TODO(julian): other than RGB colores - //only RGB colores for now unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 3; - return {ptr[0], ptr[1], ptr[2]}; + + Color color = {ptr[0], ptr[1], ptr[2]}; + + if(getMode() == GraphicMode::TwoColors || getMode() == GraphicMode::Text) { + if(color != getForegroundColor()) { + color = getBackgroundColor(); + } + } + + else if(getMode() == GraphicMode::Gray_256) { + unsigned char average = (color.getBlue() + color.getGreen() + color.getRed()) / 3; + color = {average, average, average}; + } + + return color; } auto setText(std::string text) -> bool { diff --git a/test/color_test.cpp b/test/color_test.cpp new file mode 100644 index 0000000..9037a40 --- /dev/null +++ b/test/color_test.cpp @@ -0,0 +1,45 @@ +#include "../src/vkvm.hpp" +#include +#include + +TEST_CASE("Colors") { + vkvm::initialize(0); + vkvm::setPixel(10, 10, vkvm::black);//NOLINT + vkvm::setPixel(11, 11, vkvm::white);//NOLINT + vkvm::setPixel(12, 12, vkvm::green);//NOLINT + vkvm::setPixel(13, 13, vkvm::red);//NOLINT + vkvm::setPixel(14, 14, vkvm::blue);//NOLINT + vkvm::setPixel(15, 15, vkvm::Color(66, 77, 88)); //NOLINT + + SECTION("RGB") { + REQUIRE(vkvm::getPixel(10, 10) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(11, 11) == vkvm::white);//NOLINT + REQUIRE(vkvm::getPixel(12, 12) == vkvm::green);//NOLINT + REQUIRE(vkvm::getPixel(13, 13) == vkvm::red);//NOLINT + REQUIRE(vkvm::getPixel(14, 14) == vkvm::blue);//NOLINT + REQUIRE(vkvm::getPixel(15, 15) == vkvm::Color(66, 77, 88));//NOLINT + } + + SECTION("TwoColors") { + vkvm::setMode(vkvm::TwoColors); + REQUIRE(vkvm::getPixel(10, 10) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(11, 11) == vkvm::white);//NOLINT + REQUIRE(vkvm::getPixel(12, 12) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(13, 13) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(14, 14) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(15, 15) == vkvm::black);//NOLINT + + } + + SECTION("Gray256") { + vkvm::setMode(vkvm::Gray_256); + REQUIRE(vkvm::getPixel(10, 10) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(11, 11) == vkvm::white);//NOLINT + REQUIRE(vkvm::getPixel(12, 12) == vkvm::Color(85, 85, 85));//NOLINT + REQUIRE(vkvm::getPixel(13, 13) == vkvm::Color(85, 85, 85));//NOLINT + REQUIRE(vkvm::getPixel(14, 14) == vkvm::Color(85, 85, 85));//NOLINT + REQUIRE(vkvm::getPixel(15, 15) == vkvm::Color(77, 77, 77));//NOLINT + } + +} + From 511f04edae55d3b5e4a9bbc31f33f55cb1654c34 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 21 Nov 2019 12:37:52 +0100 Subject: [PATCH 05/14] + hex Werte umrechnen zu Color --- src/Color.cpp | 5 +++++ src/Color.hpp | 2 ++ src/internal.cpp | 2 +- test/color_test.cpp | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Color.cpp b/src/Color.cpp index 3acc402..f554401 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -4,7 +4,12 @@ namespace vkvm { Color::Color(unsigned char red, unsigned char green, unsigned char blue) noexcept : red(red), green(green), blue(blue) { + } + Color::Color(unsigned int hex) noexcept { + red = (unsigned char) ((hex >> 16 & 0xFF));//NOLINT + green = (unsigned char) ((hex >> 8u & 0xFF));//NOLINT + blue = (unsigned char) ((hex & 0xFF));//NOLINT } auto Color::getRed() -> unsigned char { diff --git a/src/Color.hpp b/src/Color.hpp index 909eb9e..b622d3d 100644 --- a/src/Color.hpp +++ b/src/Color.hpp @@ -18,6 +18,8 @@ namespace vkvm { public: Color(unsigned char red, unsigned char green, unsigned char blue) noexcept; + explicit Color(unsigned int hex) noexcept; + auto getRed() -> unsigned char; auto getGreen() -> unsigned char; diff --git a/src/internal.cpp b/src/internal.cpp index a6c5937..614e42c 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -77,7 +77,7 @@ namespace vkvm { if (reg->keyboardBuffer_index_write == sizeof(reg->keyboardBuffer)) { reg->keyboardBuffer_index_write = 0; } - reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode.getValue(); + reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode; unlockSharedMemory(); } diff --git a/test/color_test.cpp b/test/color_test.cpp index 9037a40..32154ff 100644 --- a/test/color_test.cpp +++ b/test/color_test.cpp @@ -10,6 +10,7 @@ TEST_CASE("Colors") { vkvm::setPixel(13, 13, vkvm::red);//NOLINT vkvm::setPixel(14, 14, vkvm::blue);//NOLINT vkvm::setPixel(15, 15, vkvm::Color(66, 77, 88)); //NOLINT + vkvm::setPixel(16, 16, vkvm::Color(0xFFFFFF));//NOLINT SECTION("RGB") { REQUIRE(vkvm::getPixel(10, 10) == vkvm::black);//NOLINT @@ -18,6 +19,7 @@ TEST_CASE("Colors") { REQUIRE(vkvm::getPixel(13, 13) == vkvm::red);//NOLINT REQUIRE(vkvm::getPixel(14, 14) == vkvm::blue);//NOLINT REQUIRE(vkvm::getPixel(15, 15) == vkvm::Color(66, 77, 88));//NOLINT + REQUIRE(vkvm::getPixel(16, 16) == vkvm::white);//NOLINT } SECTION("TwoColors") { @@ -28,6 +30,7 @@ TEST_CASE("Colors") { REQUIRE(vkvm::getPixel(13, 13) == vkvm::black);//NOLINT REQUIRE(vkvm::getPixel(14, 14) == vkvm::black);//NOLINT REQUIRE(vkvm::getPixel(15, 15) == vkvm::black);//NOLINT + REQUIRE(vkvm::getPixel(16, 16) == vkvm::white);//NOLINT } @@ -39,6 +42,7 @@ TEST_CASE("Colors") { REQUIRE(vkvm::getPixel(13, 13) == vkvm::Color(85, 85, 85));//NOLINT REQUIRE(vkvm::getPixel(14, 14) == vkvm::Color(85, 85, 85));//NOLINT REQUIRE(vkvm::getPixel(15, 15) == vkvm::Color(77, 77, 77));//NOLINT + REQUIRE(vkvm::getPixel(16, 16) == vkvm::white);//NOLINT } } From 82bab57e98ad690ee8301eff516e600254b1731a Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Thu, 21 Nov 2019 13:03:53 +0100 Subject: [PATCH 06/14] ~ segfault bug fix on getPixel --- src/SharedMemoryAccess.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/SharedMemoryAccess.cpp b/src/SharedMemoryAccess.cpp index 697b5b0..9ea7ba2 100644 --- a/src/SharedMemoryAccess.cpp +++ b/src/SharedMemoryAccess.cpp @@ -60,18 +60,26 @@ namespace vkvm { unlockSharedMemory(); } + char *getLocalMemory(){ + if (localSharedMemory.empty()) { + constexpr int kilo = 1024; + localSharedMemory.resize(impl.sharedMemorySize); + } + return &localSharedMemory[0]; + } + auto getSharedMemory() -> char * { int shmId = shmget(impl.sharedMemoryKey, 0, 0); if (shmId < 0) { //using a local buffer for shared memory testing - if (localSharedMemory.empty()) { - initSemaphore(); - constexpr int kilo = 1024; - localSharedMemory.resize(impl.sharedMemorySize * kilo); - } - return &localSharedMemory[0]; + return getLocalMemory(); + } + char *ptr = static_cast(shmat(shmId, nullptr, 0)); + if((size_t)ptr == (size_t)-1){ + return getLocalMemory(); + }else{ + return ptr; } - return static_cast(shmat(shmId, nullptr, 0)); } auto getSharedMemory(char *address, int size, int offset) -> void { From 32b66cf8bfafb4c5b497588ae4bdbbdd5945c60d Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 26 Nov 2019 11:49:19 +0100 Subject: [PATCH 07/14] + read and write keyboard buffer --- src/internal.cpp | 2 +- src/vkvm.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/internal.cpp b/src/internal.cpp index 614e42c..510e56b 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -74,7 +74,7 @@ namespace vkvm { auto buttonPressed(KeyCode keyCode) -> void { lockSharedMemory(); auto reg = getRegisters(); - if (reg->keyboardBuffer_index_write == sizeof(reg->keyboardBuffer)) { + if (reg->keyboardBuffer_index_write >= sizeof(reg->keyboardBuffer)) { reg->keyboardBuffer_index_write = 0; } reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 46e5709..fdbff7a 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -210,8 +210,17 @@ namespace vkvm { } auto getLastPressedKey() -> KeyCode { - //TODO(julian): get key properly - return KeyCode(0); + lockSharedMemory(); + auto reg = getRegisters(); + if(reg->keyboardBuffer_index_read == reg->keyboardBuffer_index_write){ + return KeyCode(0); + } + KeyCode keyCode = (KeyCode)reg->keyboardBuffer[reg->keyboardBuffer_index_read++]; + if(reg->keyboardBuffer_index_read >= sizeof(reg->keyboardBuffer)){ + reg->keyboardBuffer_index_read = 0; + } + unlockSharedMemory(); + return keyCode; } } \ No newline at end of file From 7fa09884130095dfe7b0192f971413a4107616f0 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 26 Nov 2019 12:33:34 +0100 Subject: [PATCH 08/14] + getPixel and setPixel with different GraphicsMode and memory usage per pixel --- src/SharedMemoryAccess.cpp | 1 + src/vkvm.cpp | 108 +++++++++++++++++++++++++++++-------- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/src/SharedMemoryAccess.cpp b/src/SharedMemoryAccess.cpp index 9ea7ba2..6147181 100644 --- a/src/SharedMemoryAccess.cpp +++ b/src/SharedMemoryAccess.cpp @@ -11,6 +11,7 @@ #include "SharedMemoryAccess.hpp" /* header is important for the shmID. name could be different. maybe not needed cause: (shmget(memory_access_key, NULL, 0)) */ #include "internal.hpp" +#include "log.hpp" namespace vkvm { constexpr int PERM = 0666; /* access rights */ diff --git a/src/vkvm.cpp b/src/vkvm.cpp index fdbff7a..9f52356 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -61,29 +61,93 @@ namespace vkvm { } auto setPixel(int x, int y, Color color) -> bool { - char *ptr = getPixelArea() + (y * getWidth() + x) * 3; - ptr[0] = color.getRed(); - ptr[1] = color.getGreen(); - ptr[2] = color.getBlue(); + lockSharedMemory(); + auto reg = getRegisters(); + + switch(reg->graphicMode) { + case Text: { + int pixelIndex = (y * getWidth() + x); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / 8); + if(color == reg->foreground_color){ + //set bit to 1 + ptr[0] |= (1 << (pixelIndex % 8)); + } + else{ + //set bit to 0 + ptr[0] &= ~(1 << (pixelIndex % 8)); + } + break; + } + case TwoColors: { + int pixelIndex = (y * getWidth() + x); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / 8); + if(color == reg->foreground_color){ + //set bit to 1 + ptr[0] |= (1 << (pixelIndex % 8)); + } + else{ + //set bit to 0 + ptr[0] &= ~(1 << (pixelIndex % 8)); + } + break; + } + case Gray_256: { + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 1; + int avg = color.getRed() + color.getGreen() + color.getBlue(); + avg /= 3; + ptr[0] = (unsigned char)avg; + break; + } + case RGB: { + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 3; + ptr[0] = (unsigned char)color.getRed(); + ptr[1] = (unsigned char)color.getGreen(); + ptr[2] = (unsigned char)color.getBlue(); + break; + } + } + unlockSharedMemory(); return false; } auto getPixel(int x, int y) -> Color { - unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 3; + Color color = Color(0,0,0); + auto reg = getRegisters(); - Color color = {ptr[0], ptr[1], ptr[2]}; - - if(getMode() == GraphicMode::TwoColors || getMode() == GraphicMode::Text) { - if(color != getForegroundColor()) { - color = getBackgroundColor(); + switch(reg->graphicMode) { + case Text: { + int pixelIndex = (y * getWidth() + x); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + pixelIndex / 8; + bool bit = (bool)(ptr[0] & (1 << (pixelIndex % 8))); + if(bit){ + color = reg->foreground_color; + }else{ + color =reg->background_color; + } + break; + } + case TwoColors: { + int pixelIndex = (y * getWidth() + x); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / 8); + bool bit = (bool)(ptr[0] & (1 << (pixelIndex % 8))); + if(bit){ + color = reg->foreground_color; + }else{ + color =reg->background_color; + } + break; + } + case Gray_256: { + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 1; + color = {ptr[0], ptr[0], ptr[0]}; + break; + } + case RGB: { + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 3; + color = {ptr[0], ptr[1], ptr[2]}; + break; } } - - else if(getMode() == GraphicMode::Gray_256) { - unsigned char average = (color.getBlue() + color.getGreen() + color.getRed()) / 3; - color = {average, average, average}; - } - return color; } @@ -211,13 +275,13 @@ namespace vkvm { auto getLastPressedKey() -> KeyCode { lockSharedMemory(); + KeyCode keyCode = KeyCode(0); auto reg = getRegisters(); - if(reg->keyboardBuffer_index_read == reg->keyboardBuffer_index_write){ - return KeyCode(0); - } - KeyCode keyCode = (KeyCode)reg->keyboardBuffer[reg->keyboardBuffer_index_read++]; - if(reg->keyboardBuffer_index_read >= sizeof(reg->keyboardBuffer)){ - reg->keyboardBuffer_index_read = 0; + if(reg->keyboardBuffer_index_read != reg->keyboardBuffer_index_write) { + keyCode = (KeyCode) reg->keyboardBuffer[reg->keyboardBuffer_index_read++]; + if (reg->keyboardBuffer_index_read >= sizeof(reg->keyboardBuffer)) { + reg->keyboardBuffer_index_read = 0; + } } unlockSharedMemory(); return keyCode; From cc7e3e09ade62540b1c37d42e268c741d64f707c Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Tue, 26 Nov 2019 13:22:53 +0100 Subject: [PATCH 09/14] + translate pixel colors on change GraphicMode --- src/Color.cpp | 8 ++++++-- src/Color.hpp | 4 ++++ src/SharedMemoryAccess.cpp | 7 ++++++- src/internal.hpp | 1 + src/vkvm.cpp | 31 +++++++++++++++++++++++++++++-- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/Color.cpp b/src/Color.cpp index f554401..8531c15 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -2,9 +2,13 @@ namespace vkvm { + Color::Color() noexcept + : red(0), green(0), blue(0) {} + Color::Color(unsigned char red, unsigned char green, unsigned char blue) noexcept - : red(red), green(green), blue(blue) { - } + : red(red), green(green), blue(blue) {} + + Color::Color(const Color &color) noexcept = default; Color::Color(unsigned int hex) noexcept { red = (unsigned char) ((hex >> 16 & 0xFF));//NOLINT diff --git a/src/Color.hpp b/src/Color.hpp index b622d3d..d9b6040 100644 --- a/src/Color.hpp +++ b/src/Color.hpp @@ -16,8 +16,12 @@ namespace vkvm { unsigned char blue; public: + Color() noexcept; + Color(unsigned char red, unsigned char green, unsigned char blue) noexcept; + Color(const Color &color) noexcept; + explicit Color(unsigned int hex) noexcept; auto getRed() -> unsigned char; diff --git a/src/SharedMemoryAccess.cpp b/src/SharedMemoryAccess.cpp index 6147181..7bd1013 100644 --- a/src/SharedMemoryAccess.cpp +++ b/src/SharedMemoryAccess.cpp @@ -62,9 +62,14 @@ namespace vkvm { } char *getLocalMemory(){ + static bool givenWarning {false}; + if(!givenWarning && impl.localMemoryWarn){ + givenWarning = true; + log(LogLevel::WARNING, "no shared memory found, using local memory instead!"); + } if (localSharedMemory.empty()) { constexpr int kilo = 1024; - localSharedMemory.resize(impl.sharedMemorySize); + localSharedMemory.resize(impl.sharedMemorySize * kilo); } return &localSharedMemory[0]; } diff --git a/src/internal.hpp b/src/internal.hpp index c29e932..7f57add 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -58,6 +58,7 @@ constexpr int keyboardBufferSize = 16; int interruptEntrysPerEventType = 8; //NOLINT int reservedSize = 1024; //NOLINT std::vector> eventTable; + bool localMemoryWarn = true; }; extern Impl impl; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 9f52356..f938548 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -16,8 +16,10 @@ namespace vkvm { } auto setDefaultValues() -> void { + impl.localMemoryWarn = false; if(getSharedMemory() != nullptr) { //set default values + setMode(GraphicMode::RGB); setCharactersPerRow(60);// NOLINT setCharactersPerColumn(20);// NOLINT setHeight(600);// NOLINT @@ -25,10 +27,10 @@ namespace vkvm { setMousePosition(42, 42);// NOLINT setBackgroundColor(black); setForegroundColor(white); - setMode(GraphicMode::RGB); setRedrawInterval(20);// NOLINT setTimerInterruptInterval(10);// NOLINT } + impl.localMemoryWarn = true; } auto registerEvent(EventType type, const std::function &handler) -> bool { @@ -205,7 +207,32 @@ namespace vkvm { auto setMode(GraphicMode newValue) -> void { lockSharedMemory(); - getRegisters()->graphicMode = newValue; + auto reg = getRegisters(); + if(reg->graphicMode != newValue){ + + std::vector pixels; + int height = reg->height_pixels; + int width = reg->width_pixels; + pixels.resize(height * width); + + for(int y = 0; y < height;y++){ + for(int x = 0;x < width;x++){ + pixels[y * width + x] = getPixel(x,y); + } + } + + getRegisters()->graphicMode = newValue; + + unlockSharedMemory(); + for(int y = 0; y < height;y++){ + for(int x = 0;x < width;x++){ + setPixel(x,y, pixels[y * width + x]); + } + } + lockSharedMemory(); + }else{ + reg->graphicMode = newValue; + } unlockSharedMemory(); } From 23b52249461afc20d5fcee8a54ade02dbb7fb524 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Wed, 27 Nov 2019 11:40:54 +0100 Subject: [PATCH 10/14] ~ fixed shared memory access error --- src/SharedMemoryAccess.cpp | 5 +++++ src/internal.hpp | 1 + src/vkvm.cpp | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SharedMemoryAccess.cpp b/src/SharedMemoryAccess.cpp index 7bd1013..6bd11b2 100644 --- a/src/SharedMemoryAccess.cpp +++ b/src/SharedMemoryAccess.cpp @@ -75,6 +75,9 @@ namespace vkvm { } auto getSharedMemory() -> char * { + if(impl.sharedMemory != nullptr){ + return impl.sharedMemory; + } int shmId = shmget(impl.sharedMemoryKey, 0, 0); if (shmId < 0) { //using a local buffer for shared memory testing @@ -82,8 +85,10 @@ namespace vkvm { } char *ptr = static_cast(shmat(shmId, nullptr, 0)); if((size_t)ptr == (size_t)-1){ + log(LogLevel::WARNING, strerror(errno)); return getLocalMemory(); }else{ + impl.sharedMemory = ptr; return ptr; } } diff --git a/src/internal.hpp b/src/internal.hpp index 7f57add..c0dcaac 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -59,6 +59,7 @@ constexpr int keyboardBufferSize = 16; int reservedSize = 1024; //NOLINT std::vector> eventTable; bool localMemoryWarn = true; + char *sharedMemory = nullptr; }; extern Impl impl; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index f938548..41c8a36 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -22,8 +22,8 @@ namespace vkvm { setMode(GraphicMode::RGB); setCharactersPerRow(60);// NOLINT setCharactersPerColumn(20);// NOLINT - setHeight(600);// NOLINT - setWidth(800);// NOLINT + setHeight(60);// NOLINT + setWidth(80);// NOLINT setMousePosition(42, 42);// NOLINT setBackgroundColor(black); setForegroundColor(white); From 0eee01d4c6d8b660fb931138fa5641929b2dc5fb Mon Sep 17 00:00:00 2001 From: cigerxwinchaker Date: Wed, 27 Nov 2019 12:32:54 +0100 Subject: [PATCH 11/14] fix include for mac --- src/internal.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/internal.hpp b/src/internal.hpp index c0dcaac..2f248c2 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace vkvm { From 39a9fd4bbffe792905a422ad460260da1c3614b1 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Wed, 27 Nov 2019 13:39:16 +0100 Subject: [PATCH 12/14] ~ fixed all clang-tidy errors --- CMakeLists.txt | 1 + src/Color.cpp | 2 -- src/Color.hpp | 4 +--- src/SharedMemoryAccess.cpp | 4 ++-- src/internal.cpp | 2 +- src/internal.hpp | 2 +- src/vkvm.cpp | 44 ++++++++++++++++++++------------------ src/vkvm.hpp | 4 ++-- 8 files changed, 31 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 828a9ac..1554107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ include_directories(test) add_library(library ${SOURCES} ${HEADERS}) + file(COPY "${CMAKE_SOURCE_DIR}/src/" DESTINATION "${CMAKE_SOURCE_DIR}/include" FILES_MATCHING diff --git a/src/Color.cpp b/src/Color.cpp index 8531c15..8f03829 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -8,8 +8,6 @@ namespace vkvm { Color::Color(unsigned char red, unsigned char green, unsigned char blue) noexcept : red(red), green(green), blue(blue) {} - Color::Color(const Color &color) noexcept = default; - Color::Color(unsigned int hex) noexcept { red = (unsigned char) ((hex >> 16 & 0xFF));//NOLINT green = (unsigned char) ((hex >> 8u & 0xFF));//NOLINT diff --git a/src/Color.hpp b/src/Color.hpp index d9b6040..4ec1b75 100644 --- a/src/Color.hpp +++ b/src/Color.hpp @@ -20,10 +20,8 @@ namespace vkvm { Color(unsigned char red, unsigned char green, unsigned char blue) noexcept; - Color(const Color &color) noexcept; - explicit Color(unsigned int hex) noexcept; - + auto getRed() -> unsigned char; auto getGreen() -> unsigned char; diff --git a/src/SharedMemoryAccess.cpp b/src/SharedMemoryAccess.cpp index 6bd11b2..57392e3 100644 --- a/src/SharedMemoryAccess.cpp +++ b/src/SharedMemoryAccess.cpp @@ -84,13 +84,13 @@ namespace vkvm { return getLocalMemory(); } char *ptr = static_cast(shmat(shmId, nullptr, 0)); - if((size_t)ptr == (size_t)-1){ + if(reinterpret_cast(ptr) == static_cast(-1)){ log(LogLevel::WARNING, strerror(errno)); - return getLocalMemory(); }else{ impl.sharedMemory = ptr; return ptr; } + return getLocalMemory(); } auto getSharedMemory(char *address, int size, int offset) -> void { diff --git a/src/internal.cpp b/src/internal.cpp index 510e56b..798c3b2 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -16,7 +16,7 @@ namespace vkvm { signal(signalNumber, callback); } - auto getInterrupTable() -> InterruptEntry * { + auto getInterruptTable() -> InterruptEntry * { return reinterpret_cast(getSharedMemory() + sizeof(Registers) + impl.reservedSize); } diff --git a/src/internal.hpp b/src/internal.hpp index 2f248c2..f828779 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -6,10 +6,10 @@ #include "GraphicMode.hpp" #include "KeyCode.hpp" #include "LayoutVersion.hpp" +#include #include #include #include -#include namespace vkvm { diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 41c8a36..0cda6b6 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -22,8 +22,8 @@ namespace vkvm { setMode(GraphicMode::RGB); setCharactersPerRow(60);// NOLINT setCharactersPerColumn(20);// NOLINT - setHeight(60);// NOLINT - setWidth(80);// NOLINT + setHeight(600);// NOLINT + setWidth(800);// NOLINT setMousePosition(42, 42);// NOLINT setBackgroundColor(black); setForegroundColor(white); @@ -65,46 +65,47 @@ namespace vkvm { auto setPixel(int x, int y, Color color) -> bool { lockSharedMemory(); auto reg = getRegisters(); + const int bitsPerPixel = 8; switch(reg->graphicMode) { case Text: { int pixelIndex = (y * getWidth() + x); - unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / 8); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / bitsPerPixel); if(color == reg->foreground_color){ //set bit to 1 - ptr[0] |= (1 << (pixelIndex % 8)); + ptr[0] |= (1 << (pixelIndex % bitsPerPixel)); } else{ //set bit to 0 - ptr[0] &= ~(1 << (pixelIndex % 8)); + ptr[0] &= ~(1 << (pixelIndex % bitsPerPixel)); } break; } case TwoColors: { int pixelIndex = (y * getWidth() + x); - unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / 8); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / bitsPerPixel); if(color == reg->foreground_color){ //set bit to 1 - ptr[0] |= (1 << (pixelIndex % 8)); + ptr[0] |= (1 << (pixelIndex % bitsPerPixel)); } else{ //set bit to 0 - ptr[0] &= ~(1 << (pixelIndex % 8)); + ptr[0] &= ~(1 << (pixelIndex % bitsPerPixel)); } break; } case Gray_256: { - unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 1; + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x); int avg = color.getRed() + color.getGreen() + color.getBlue(); avg /= 3; - ptr[0] = (unsigned char)avg; + ptr[0] = avg; break; } case RGB: { unsigned char *ptr = reinterpret_cast(getPixelArea()) + (y * getWidth() + x) * 3; - ptr[0] = (unsigned char)color.getRed(); - ptr[1] = (unsigned char)color.getGreen(); - ptr[2] = (unsigned char)color.getBlue(); + ptr[0] = color.getRed(); + ptr[1] = color.getGreen(); + ptr[2] = color.getBlue(); break; } } @@ -115,12 +116,13 @@ namespace vkvm { auto getPixel(int x, int y) -> Color { Color color = Color(0,0,0); auto reg = getRegisters(); + const int bitsPerPixel = 8; switch(reg->graphicMode) { case Text: { int pixelIndex = (y * getWidth() + x); - unsigned char *ptr = reinterpret_cast(getPixelArea()) + pixelIndex / 8; - bool bit = (bool)(ptr[0] & (1 << (pixelIndex % 8))); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + pixelIndex / bitsPerPixel; + bool bit = static_cast(ptr[0] & (1 << (pixelIndex % bitsPerPixel))); if(bit){ color = reg->foreground_color; }else{ @@ -130,8 +132,8 @@ namespace vkvm { } case TwoColors: { int pixelIndex = (y * getWidth() + x); - unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / 8); - bool bit = (bool)(ptr[0] & (1 << (pixelIndex % 8))); + unsigned char *ptr = reinterpret_cast(getPixelArea()) + (pixelIndex / bitsPerPixel); + bool bit = static_cast(ptr[0] & (1 << (pixelIndex % bitsPerPixel))); if(bit){ color = reg->foreground_color; }else{ @@ -260,7 +262,7 @@ namespace vkvm { return getRegisters()->background_color; } - auto setBackgroundColor(Color newValue) -> void { + auto setBackgroundColor(const Color &newValue) -> void { lockSharedMemory(); getRegisters()->background_color = newValue; unlockSharedMemory(); @@ -270,7 +272,7 @@ namespace vkvm { return getRegisters()->foreground_color; } - auto setForegroundColor(Color newValue) -> void { + auto setForegroundColor(const Color &newValue) -> void { lockSharedMemory(); getRegisters()->foreground_color = newValue; unlockSharedMemory(); @@ -302,10 +304,10 @@ namespace vkvm { auto getLastPressedKey() -> KeyCode { lockSharedMemory(); - KeyCode keyCode = KeyCode(0); + auto keyCode = KeyCode(0); auto reg = getRegisters(); if(reg->keyboardBuffer_index_read != reg->keyboardBuffer_index_write) { - keyCode = (KeyCode) reg->keyboardBuffer[reg->keyboardBuffer_index_read++]; + keyCode = static_cast(reg->keyboardBuffer[reg->keyboardBuffer_index_read++]); if (reg->keyboardBuffer_index_read >= sizeof(reg->keyboardBuffer)) { reg->keyboardBuffer_index_read = 0; } diff --git a/src/vkvm.hpp b/src/vkvm.hpp index 8f86e7f..ed70601 100644 --- a/src/vkvm.hpp +++ b/src/vkvm.hpp @@ -153,7 +153,7 @@ namespace vkvm { * set background color in two color mode. * @param newValue new background color. */ - auto setBackgroundColor(Color newValue) -> void; + auto setBackgroundColor(const Color &newValue) -> void; /** * get foreground color in two color mode. @@ -165,7 +165,7 @@ namespace vkvm { * set foreground color in two color mode. * @param newValue new foreground color. */ - auto setForegroundColor(Color newValue) -> void; + auto setForegroundColor(const Color &newValue) -> void; //text mode From 4a0b7a5bf17c88d93a1733373810f1880e00c8ee Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Thu, 28 Nov 2019 12:19:46 +0100 Subject: [PATCH 13/14] ~ changed default values for resolution and font --- src/Color.hpp | 2 +- src/internal.cpp | 2 +- src/internal.hpp | 2 +- src/vkvm.cpp | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Color.hpp b/src/Color.hpp index 4ec1b75..8b3cc99 100644 --- a/src/Color.hpp +++ b/src/Color.hpp @@ -21,7 +21,7 @@ namespace vkvm { Color(unsigned char red, unsigned char green, unsigned char blue) noexcept; explicit Color(unsigned int hex) noexcept; - + auto getRed() -> unsigned char; auto getGreen() -> unsigned char; diff --git a/src/internal.cpp b/src/internal.cpp index 798c3b2..436c76e 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -36,7 +36,7 @@ namespace vkvm { } auto callEvent(EventType type) -> bool { - auto ivt = getInterrupTable(); + auto ivt = getInterruptTable(); for(int i = 0; i < impl.interruptEntrysPerEventType;i++){ auto &entry= ivt[type * impl.interruptEntrysPerEventType + i]; if (entry.pid != 0) { diff --git a/src/internal.hpp b/src/internal.hpp index f828779..e1b5ea2 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -79,7 +79,7 @@ constexpr int keyboardBufferSize = 16; auto onSignal(int signalNumber, void(*callback)(int)) -> void; - auto getInterrupTable() -> InterruptEntry *; + auto getInterruptTable() -> InterruptEntry *; auto getRegisters() -> Registers *; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 0cda6b6..6401b5c 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -29,13 +29,14 @@ namespace vkvm { setForegroundColor(white); setRedrawInterval(20);// NOLINT setTimerInterruptInterval(10);// NOLINT + setFont(FontType(3,"",0,0)); } impl.localMemoryWarn = true; } auto registerEvent(EventType type, const std::function &handler) -> bool { int signum = SIGUSR1 + impl.eventTable.size(); - auto ivt = getInterrupTable(); + auto ivt = getInterruptTable(); lockSharedMemory(); @@ -288,7 +289,7 @@ namespace vkvm { auto getFont() -> FontType { //TODO(julian): get font properly - return font_1; + return FontType(getRegisters()->textMode_font, "", 0, 0); } auto setFont(const FontType &newValue) -> void { From ab2e1daea2278c421f3648117127756114a8e952 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Thu, 28 Nov 2019 13:19:08 +0100 Subject: [PATCH 14/14] + added more event types --- src/EventType.hpp | 17 +++++++++++------ src/vkvm.cpp | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/EventType.hpp b/src/EventType.hpp index 79f4d94..49ca834 100644 --- a/src/EventType.hpp +++ b/src/EventType.hpp @@ -11,12 +11,17 @@ namespace vkvm { enum EventType { Timer = 1, MouseMove = 2, - MouseButton = 3, - KeyDown = 4, - KeyUp = 5, - UpdateControlRegisters = 6, - Redraw = 7, - RenderText = 8 + MouseLeftUp = 3, + MouseLeftDown = 4, + MouseRightUp = 5, + MouseRightDown = 6, + MouseMiddleDown = 7, + MouseMiddleUp = 8, + KeyDown = 9, + KeyUp = 10, + UpdateControlRegisters = 11, + Redraw = 12, + RenderText = 13 }; } diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 6401b5c..df48721 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -289,7 +289,7 @@ namespace vkvm { auto getFont() -> FontType { //TODO(julian): get font properly - return FontType(getRegisters()->textMode_font, "", 0, 0); + return {getRegisters()->textMode_font, "", 0, 0}; } auto setFont(const FontType &newValue) -> void {