diff --git a/build.nr b/build.nr index 6e2eace..9851ace 100644 --- a/build.nr +++ b/build.nr @@ -1 +1 @@ -1613 +1614 diff --git a/extra/config/testMachine.dvm b/extra/config/testMachine.dvm index 877a95b..59a1e9a 100644 --- a/extra/config/testMachine.dvm +++ b/extra/config/testMachine.dvm @@ -4,7 +4,7 @@ CMOS = dragon/cmos.dr cpuext = extmov, extalu fixed_clock = false -clock_rate_sec = 644 +clock_rate_sec = 2000 memory_extension_pages = 16 SingleColor_foreground = #009900FF diff --git a/extra/dragon/cmos.dr b/extra/dragon/cmos.dr index 85b346b..229d29c 100644 Binary files a/extra/dragon/cmos.dr and b/extra/dragon/cmos.dr differ diff --git a/src/gui/RawTextRenderer.cpp b/src/gui/RawTextRenderer.cpp index d1d3787..15d4413 100644 --- a/src/gui/RawTextRenderer.cpp +++ b/src/gui/RawTextRenderer.cpp @@ -84,18 +84,18 @@ namespace dragon } if (applyBackground) { - screenPixels[screenIndex] = 255; - screenPixels[screenIndex + 1] = background.b; - screenPixels[screenIndex + 2] = background.g; - screenPixels[screenIndex + 3] = background.r; + screenPixels[screenIndex + 0] = background.b; + screenPixels[screenIndex + 1] = background.g; + screenPixels[screenIndex + 2] = background.r; + screenPixels[screenIndex + 3] = 255; applyBackground = false; continue; } tintedColor = applyTint({ fontPixels[index], fontPixels[index + 1], fontPixels[index + 2], 255 }, color); - screenPixels[screenIndex] = fontPixels[index + 3]; - screenPixels[screenIndex + 1] = tintedColor.b; - screenPixels[screenIndex + 2] = tintedColor.g; - screenPixels[screenIndex + 3] = tintedColor.r; + screenPixels[screenIndex + 0] = tintedColor.b; + screenPixels[screenIndex + 1] = tintedColor.g; + screenPixels[screenIndex + 2] = tintedColor.r; + screenPixels[screenIndex + 3] = fontPixels[index + 3]; } screeny += 1; screenx = x * 4; diff --git a/src/gui/Renderer.cpp b/src/gui/Renderer.cpp index 23278cc..f8a43c3 100644 --- a/src/gui/Renderer.cpp +++ b/src/gui/Renderer.cpp @@ -18,7 +18,7 @@ namespace dragon return; //TODO: Error m_parent = &parent; m_pixels = ostd::Utils::createArray(parent.getWindowWidth() * parent.getWindowHeight()); - m_texture = SDL_CreateTexture(parent.getSDLRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, parent.getWindowWidth(), parent.getWindowHeight()); + m_texture = SDL_CreateTexture(parent.getSDLRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, parent.getWindowWidth(), parent.getWindowHeight()); m_windowWidth = parent.getWindowWidth(); m_windowHeight = parent.getWindowHeight(); setTypeName("dragon::Renderer"); @@ -34,7 +34,7 @@ namespace dragon { m_pixels = ostd::Utils::resizeArray(m_pixels, m_parent->getWindowWidth() * m_parent->getWindowHeight()); SDL_DestroyTexture(m_texture); - m_texture = SDL_CreateTexture(m_parent->getSDLRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, m_parent->getWindowWidth(), m_parent->getWindowHeight()); + m_texture = SDL_CreateTexture(m_parent->getSDLRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, m_parent->getWindowWidth(), m_parent->getWindowHeight()); m_windowWidth = m_parent->getWindowWidth(); m_windowHeight = m_parent->getWindowHeight(); updateBuffer(); @@ -45,10 +45,7 @@ namespace dragon void Renderer::updateBuffer(void) { if (isInvalid()) return; - ostd::Timer timer; - timer.start(true, "DISPLAY_PROFILER", ostd::eTimeUnits::Milliseconds); SDL_UpdateTexture(m_texture, NULL, m_pixels, m_windowWidth * 4); - timer.end(true); } void Renderer::displayBuffer(void) @@ -66,7 +63,7 @@ namespace dragon for (uint32_t x = 0; x < m_windowWidth; x++) { int32_t index = CONVERT_2D_1D(x, y, m_windowWidth); - m_pixels[index] = color.asInteger(); + m_pixels[index] = color.asInteger(ostd::Color::eColorFormat::ARGB); } } } diff --git a/src/hardware/VirtualDisplay.cpp b/src/hardware/VirtualDisplay.cpp index 6f6abac..3ae9e6d 100644 --- a/src/hardware/VirtualDisplay.cpp +++ b/src/hardware/VirtualDisplay.cpp @@ -71,7 +71,11 @@ namespace dragon } } - m_renderer.updateBuffer(); + if (m_redrawScreen) + { + m_renderer.updateBuffer(); + m_redrawScreen = false; + } m_renderer.displayBuffer(); } diff --git a/src/hardware/VirtualDisplay.hpp b/src/hardware/VirtualDisplay.hpp index 7c38b04..07a8fd4 100644 --- a/src/hardware/VirtualDisplay.hpp +++ b/src/hardware/VirtualDisplay.hpp @@ -57,6 +57,8 @@ namespace dragon void onFixedUpdate(void) override; void onSlowUpdate(void) override; + inline void redrawScreen(void) { m_redrawScreen = true; } + private: void single_text_add_char_to_line(char c); void single_text_add_char_to_buffer(char c); @@ -80,6 +82,8 @@ namespace dragon std::vector m_text16_palettes; data::IBiosVideoPalette* m_text16_Currentpalette { nullptr }; uint8_t m_currentPaletteID { 0 }; + + bool m_redrawScreen { true }; }; } } \ No newline at end of file diff --git a/src/runtime/DragonRuntime.cpp b/src/runtime/DragonRuntime.cpp index f1c9fce..e0d231f 100644 --- a/src/runtime/DragonRuntime.cpp +++ b/src/runtime/DragonRuntime.cpp @@ -346,6 +346,7 @@ namespace dragon { double clock_speed_us = 1000000.0 / machine_config.clock_rate_sec; double acc = 0; + double acc2 = 0; uint64_t avg_count = 0; uint64_t _time = 0; double avg_tot = 0; @@ -377,8 +378,14 @@ namespace dragon // out.fg(ostd::ConsoleColors::Red).p(s_avgInstTime).nl().reset(); acc = 0; } + if (acc2 == 100) + { + vDisplay.redrawScreen(); + acc2 = 0; + } _time = clock_timer.endCount(); acc++; + acc2++; if (_time < clock_speed_us && fixed_clock) ostd::Utils::sleep(clock_speed_us - _time, ostd::eTimeUnits::Microseconds); }