From dcbf3cce6625925f9166581f8e18b45a4619c8fb Mon Sep 17 00:00:00 2001 From: Syl4r39 Date: Mon, 7 Apr 2025 07:15:50 +0200 Subject: [PATCH] First step of implementing Scroll in Text16Color mode --- build.nr | 2 +- extra/dragon/bios.bin | Bin 4096 -> 4096 bytes extra/dragon/disk1.dr | Bin 4194304 -> 4194304 bytes extra/dss/DragonOS/ascii.dss | 132 +++++++++++++++++++++++++ extra/dss/DragonOS/kernel0.dss | 47 ++++++++- extra/dss/DragonOS/keyboard_driver.dss | 2 + extra/dss/bios/data.dss | 1 + extra/dss/bios/drivers.dss | 4 + extra/dss/bios_api.dss | 1 + extra/dss/drake/bootsector.dss | 1 - extra/info/todo.txt | 1 + src/assembler/Assembler.cpp | 2 + src/hardware/VirtualDisplay.cpp | 5 + src/hardware/VirtualDisplay.hpp | 1 + src/hardware/VirtualIODevices.cpp | 22 +++++ src/hardware/VirtualIODevices.hpp | 1 + src/runtime/DragonRuntime.cpp | 13 ++- src/runtime/DragonRuntime.hpp | 2 + 18 files changed, 233 insertions(+), 4 deletions(-) create mode 100644 extra/dss/DragonOS/ascii.dss diff --git a/build.nr b/build.nr index c772079..ff0ba09 100644 --- a/build.nr +++ b/build.nr @@ -1 +1 @@ -1620 +1621 diff --git a/extra/dragon/bios.bin b/extra/dragon/bios.bin index 10b22bfd789a8c8360ff48c69d51a4e428a14614..838cc56342fb3de0142136e86ece649a292c7d3d 100644 GIT binary patch delta 501 zcmZWlp-uxq5Pf&soh{c(peq(da@SH)2%-swpb7?op^(;q!hj)MCddX56a#|f90?x) zj_?IIfF?d5keFAYxiWiD?Hh(>_wBOH`PyQDwTtG}8lWOpoX@J!8^g!?vpuBh4;`6#2QeZ!g(1`uem#{MTFSWI za)zAFXbVW34!)mjpSF%e2*%tudT9g6>id-q<)C;lc(;~Hf`$8zVDu2$nPe> z4#SA`h2>9FUwQ}H9qN?IacPjoQ1$V6A_6i~0oKuIMqRVWW)T=n5~4v_q0v%4Tgm6m z)QS|U@p#)yI+U4%Ur~=u@4x6^!!AeuZ)Tk`Wr{M>%g@b6aF`zz=Yp&Io8p@J0zSKG AVgLXD delta 473 zcmZWlu}T9$5S_cdojuQhxh+-;g}X#Fksv88PYWBH#9%tB6s8f5=>mbIPzwc{EA$8a z01-Pov5AFNHa5vGDA?+3B8gzJJMYcRdo#QJs2_>0-@g?{viAfI$yabmzJnn72_B&f zk}w1$Tn0rLfls&&bA+1^5bnY};UVM*+Yl38K!NZYii9_?O85Xn!bcc&aZom%j*M^_ zM#c*m3WlXXbHOq<(WM^hlqUlh@(SF#u7T4~wFwn}=&zY|U@7wPCQx#ic?$MqOWxF4 zuAz}BHUT0dopHOgX>HIhrWj_&SV#u-&`xq2_{^y(`C<~A6P@VToQ>~OE3;3Vg`qWh z!;qmZNu&)RHMTHQZKn4u6Oc8b_q#40X9irQ8uqmZNu&)%vhtt0Ma129 + .code _init_keyboard: ## _init_keyboard(func_ptr* key_pressed_handler) diff --git a/extra/dss/bios/data.dss b/extra/dss/bios/data.dss index a8520ec..4551901 100644 --- a/extra/dss/bios/data.dss +++ b/extra/dss/bios/data.dss @@ -141,6 +141,7 @@ SWAP_BUFFERS 0x10 WRITE_VRAM 0x11 + SCROLL 0x12 FORCE_REFRESH_SCREEN 0xE0 FORCE_CLEAR_SCREEN 0xE1 diff --git a/extra/dss/bios/drivers.dss b/extra/dss/bios/drivers.dss index 9f99cf0..c43b5cb 100644 --- a/extra/dss/bios/drivers.dss +++ b/extra/dss/bios/drivers.dss @@ -67,6 +67,7 @@ _int_30_handler: jeq $_int_30_print_string_text16, 0x0022 jeq $_int_30_print_integer_text16, 0x0023 jeq $_int_30_clear_screen_text16, 0x0024 + jeq $_int_30_scroll_text16, 0x0025 jeq $_int_30_clear_screen, 0x00E0 jeq $_int_30_refresh_screen, 0x00E1 @@ -166,6 +167,9 @@ _int_30_clear_screen_text16: movb [VGA_Registers.MEMORY_CONTROLLER_BG_COL], *R9 movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.FORCE_CLEAR_SCREEN jmp $_int_30_end +_int_30_scroll_text16: + movb [VGA_Registers.SIGNAL], Sig_VGA_Text_16_Color.SCROLL + jmp $_int_30_end _int_30_clear_screen: movb [VGA_Registers.SIGNAL], Sig_VGA_Text_Single_Color.CLEAR_SCREEN diff --git a/extra/dss/bios_api.dss b/extra/dss/bios_api.dss index 8fd1d90..850645d 100644 --- a/extra/dss/bios_api.dss +++ b/extra/dss/bios_api.dss @@ -100,6 +100,7 @@ CONTINUE 0x00 SWAP_BUFFERS 0x10 WRITE_VRAM 0x11 + SCROLL 0x12 FORCE_REFRESH_SCREEN 0xE0 FORCE_CLEAR_SCREEN 0xE1 FORCE_REDRAW_SCREEN 0xE2 diff --git a/extra/dss/drake/bootsector.dss b/extra/dss/drake/bootsector.dss index 70e4062..872dc2a 100644 --- a/extra/dss/drake/bootsector.dss +++ b/extra/dss/drake/bootsector.dss @@ -125,7 +125,6 @@ _endless_loop: mov R10, 0x12 ## int 0x20 parameter for load_from_ddd_blocking int 0x20 ## Bios interrupt - debug_break jmp OS_LOAD_ADDR jmp $_main_end diff --git a/extra/info/todo.txt b/extra/info/todo.txt index 09ad29d..7a8cf86 100644 --- a/extra/info/todo.txt +++ b/extra/info/todo.txt @@ -1,4 +1,5 @@ Runtime: + Add option to disable screenRedrawRate in debugger top-level prompt Assembler: Add subroutine address export functionality diff --git a/src/assembler/Assembler.cpp b/src/assembler/Assembler.cpp index 7c7fd19..38b8997 100644 --- a/src/assembler/Assembler.cpp +++ b/src/assembler/Assembler.cpp @@ -34,6 +34,8 @@ namespace dragon m_lines = IncludePreprocessor::loadEntryFile(fileName); if (m_lines.size() == 0) return { }; //TODO: Error + // for (auto& line : m_lines) + // std::cout << line << "\n"; removeComments(); parseExportSpecifications(); createExports(); diff --git a/src/hardware/VirtualDisplay.cpp b/src/hardware/VirtualDisplay.cpp index c584bf0..4e5a5b1 100644 --- a/src/hardware/VirtualDisplay.cpp +++ b/src/hardware/VirtualDisplay.cpp @@ -179,6 +179,11 @@ namespace dragon DragonRuntime::vGraphicsInterface.swapBuffers_16Colors(); __redraw_screen(); } + else if (signal == tSignalValues::Text16Color_Scroll) + { + DragonRuntime::vGraphicsInterface.scroll_16Colors(); + __redraw_screen(); + } } else return; mem.write8(vga_addr + tRegisters::Signal, tSignalValues::Continue); diff --git a/src/hardware/VirtualDisplay.hpp b/src/hardware/VirtualDisplay.hpp index 0545ce5..83f7ce9 100644 --- a/src/hardware/VirtualDisplay.hpp +++ b/src/hardware/VirtualDisplay.hpp @@ -47,6 +47,7 @@ namespace dragon inline static constexpr uint8_t Text16Color_SwapBuffers = 0x10; inline static constexpr uint8_t Text16Color_WriteMemory = 0x11; + inline static constexpr uint8_t Text16Color_Scroll = 0x12; inline static constexpr uint8_t RefreshScreen = 0xE0; inline static constexpr uint8_t ClearSCreen = 0xE1; diff --git a/src/hardware/VirtualIODevices.cpp b/src/hardware/VirtualIODevices.cpp index 1b7d03c..c73a2e8 100644 --- a/src/hardware/VirtualIODevices.cpp +++ b/src/hardware/VirtualIODevices.cpp @@ -799,6 +799,28 @@ namespace dragon m_16Color_secondFrameAddr = tmp; } + void Graphics::scroll_16Colors(void) + { + int32_t line_len = (RawTextRenderer::CONSOLE_CHARS_H * 4); + for (int32_t i = m_16Color_currentFrameAddr + line_len; i < m_16Color_currentFrameAddr + m_16Color_frameSize; i += 4) + { + int32_t k = i; + int8_t outByte = 0; + m_videoMemory.r_Byte(k, outByte); + m_videoMemory.w_Byte(k - line_len, outByte); + k++; + m_videoMemory.r_Byte(k, outByte); + m_videoMemory.w_Byte(k - line_len, outByte); + k++; + m_videoMemory.r_Byte(k, outByte); + m_videoMemory.w_Byte(k - line_len, outByte); + } + for (int32_t i = m_16Color_currentFrameAddr + m_16Color_frameSize - line_len; i < m_16Color_currentFrameAddr + m_16Color_frameSize; i += 4) + { + m_videoMemory.w_Byte(i, 0x20); + } + } + diff --git a/src/hardware/VirtualIODevices.hpp b/src/hardware/VirtualIODevices.hpp index e6fa3d0..7b3aeb8 100644 --- a/src/hardware/VirtualIODevices.hpp +++ b/src/hardware/VirtualIODevices.hpp @@ -380,6 +380,7 @@ namespace dragon bool writeVRAM_16Colors(uint8_t x, uint8_t y, uint8_t character = 0, uint8_t background = 0xFF, uint8_t foreground = 0xFF); bool clearVRAM_16Colors(uint8_t character = 0, uint8_t background = 0x00, uint8_t foreground = 0xFF); void swapBuffers_16Colors(void); + void scroll_16Colors(void); private: ostd::serial::SerialIO m_videoMemory; diff --git a/src/runtime/DragonRuntime.cpp b/src/runtime/DragonRuntime.cpp index f7dcfd7..c029760 100644 --- a/src/runtime/DragonRuntime.cpp +++ b/src/runtime/DragonRuntime.cpp @@ -403,8 +403,19 @@ namespace dragon __get_machine_footprint(&s_machineInfo, trackedAddresses, true); __track_call_stack(&s_machineInfo); bool running = cpu.execute() && vDisplay.isRunning(); + uint8_t screenRedrawRate = vCMOS.read8(data::CMOSRegisters::ScreenRedrawRate); vDisplay.update(); - vDisplay.redrawScreen(); // This is slow...maybe it should be on a 100ms rate, like in normal runtime mode + if (s_enableScreenRedrawDelay && s_stepAcc2 == (1000 / screenRedrawRate)) + { + vDisplay.redrawScreen(); + s_stepAcc2 = 0; + } + else if (!s_enableScreenRedrawDelay) + { + vDisplay.redrawScreen(); + } + s_stepAcc2++; + // vDisplay.redrawScreen(); // This is slow...maybe it should be on a 100ms rate, like in normal runtime mode vDiskInterface.cycleStep(); __get_machine_footprint(&s_machineInfo, trackedAddresses, false); return running || vDiskInterface.isBusy(); diff --git a/src/runtime/DragonRuntime.hpp b/src/runtime/DragonRuntime.hpp index 5b6e229..db664d8 100644 --- a/src/runtime/DragonRuntime.hpp +++ b/src/runtime/DragonRuntime.hpp @@ -132,6 +132,8 @@ namespace dragon inline static tMachineConfig machine_config; inline static uint64_t s_avgInstTime { 0 }; + inline static double s_stepAcc2 { 0 }; + inline static bool s_enableScreenRedrawDelay { true }; private: inline static tMachineDebugInfo s_machineInfo;