From c1f1b8c0646b270ce765f0a9d0cafe6ab6bcfd47 Mon Sep 17 00:00:00 2001 From: 0xMAC8205 Date: Wed, 1 Nov 2023 01:59:25 +0100 Subject: [PATCH] More Sub-Routine Planning Wrote Hardware VRAM Routines --- KernelRoutineList.txt | 6 +++++ a.out | Bin 16384 -> 16384 bytes main.s | 5 +++- src/kernel/byte.s | 54 ++++++++++++++++++++++++++++++++++++++++++ src/kernel/hardware.s | 34 ++++++++++++++++++++++++++ src/kernel/irq.s | 40 +++++++++++++++++++++++++++++++ src/variables.s | 12 +++++----- 7 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 src/kernel/byte.s diff --git a/KernelRoutineList.txt b/KernelRoutineList.txt index e63ffa5..e709b71 100644 --- a/KernelRoutineList.txt +++ b/KernelRoutineList.txt @@ -1,6 +1,12 @@ Kernel Routines Grouped by File +Byte.S + | + +- byte_flip + +- byte_swap + +- byte_drill + Char.s | +- char_to_lower diff --git a/a.out b/a.out index 8156f738161848ee9460fd607f3acd788c8e3b76..888d99b0d54ae6d08a388385ac567e34c2492dc7 100644 GIT binary patch delta 50 zcmZo@U~Fh$oFK80>x21b4hwg7agGBXsX00M3gP)hIVlVZst0@${^u|=O;nu9%FpmW G`9A=)a}lNh delta 38 ucmZo@U~Fh$oFK7L?UDIJ2foc57VhjE;s<;J|K~6>O*CA>%FpmW Data + + ; Output: + ; A <= Data + + + rts + +byte_swap: + ; Byte Swap + ; Swaps the first 4 bits of the Byte + ; 0x0f (0b0000ffff) => 0xf0 (0bffff0000) + + ; +----------+ + ; | | + ; 0xcb | (0b1100 1011) + ; | | + ; | +----+ + ; +----+ | + ; v v + ; 0xbc (0b1011 1100) + + ; Input: + ; A => Data + + ; Output: + ; A <= Data + + + rts + +byte_drill: + ; Byte Drill + ; Converts two ASCII Characters, decoded in HEX to a byte + ; Not Case sensitive + + ; Input: + ; A => First ASCII + ; X => Last ASCII + + ; Output: + ; A <= Converted Byte + + ; First Char => "FF" <= Last Char + + + rts \ No newline at end of file diff --git a/src/kernel/hardware.s b/src/kernel/hardware.s index 28dae39..c60ba78 100644 --- a/src/kernel/hardware.s +++ b/src/kernel/hardware.s @@ -10,6 +10,15 @@ vram_write: ; Output: (none) + ; Load Data into Registers + stx vidx ; Sets Read Mode, load X Coord + sty vidy ; load Y Coord + sta vidd ; Set Write Mode, load Data + nop ; Wait a bit... + nop + nop + nop + stx vidx ; Sets Read Mode rts @@ -25,6 +34,23 @@ vram_write_color: ; Output: (none) + ; I'm deliberately NOT using Kernel Stack here, + ; for more speed and efficiency and because It's just one Byte + + pha ; Push A to Stack + txa ; Transfer X to A for Math + adc #$40 ; Add #$40 (Color Range) + plx ; Pop Stack to X + + ; Load Data into Registers + sta vidx ; Sets Read Mode, load X Coord + sty vidy ; load Y Coord + stx vidd ; Set Write Mode, load Data + nop ; Wait a bit... + nop + nop + nop + sta vidx ; Sets Read Mode rts @@ -39,6 +65,14 @@ vram_read: ; Output: ; A <= Data + ; Load Data into Registers + stx vidx ; Set to Read Mode, load X Coord + sty vidy ; load Y Coords + nop ; Wait a bit... + nop + nop + nop + lda vidd ; Load Data rts diff --git a/src/kernel/irq.s b/src/kernel/irq.s index 0bf026f..8f68675 100644 --- a/src/kernel/irq.s +++ b/src/kernel/irq.s @@ -1,5 +1,45 @@ irq_init: + ; IRQ Init + ; Initialises the VIA to be resetted into a normal state and + ; to generate a constand IRQ Tick (Timer 1) + + ; Input: + ; A => Timer 1 Tick Rate (MSB) + + ; Output: (none) + + sta t1ch + + lda #$40 + sta acr + stz t1cl + lda #$00 + sta ier + cli + rts irq: + ; IRQ + ; This is the Standart IRQ Routine + ; It scans the Keyboard, invokes the Tick Event Handler + ; and does some other, housekeeping stuff + + ; Input: (none) + ; Output: (none) + + + php ; Save Processor Status, A, X and Y + sta irq_a + stx irq_x + sty irq_y + + + + bit t1cl ; "Ping" VIA Timer, to trigger Restart + lda irq_a ; Restore A, X, Y and Processor Status + ldx irq_x + ldy irq_y + plp + rti \ No newline at end of file diff --git a/src/variables.s b/src/variables.s index 60fbcf2..76952fd 100644 --- a/src/variables.s +++ b/src/variables.s @@ -21,7 +21,7 @@ k7 = $20c ; 8 bit keyboard_current = $20d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key" keyboard_previous = $20e ; 8 bit Previous held "Scan Key" -keyboard_format = $20f ; 8 bit Formatted Char, from keyboard_current +keyboard_ascii = $20f ; 8 bit Formatted Char, from keyboard_current as ASCII keyboard_arrow = $210 ; 8 bit Held Arrow Keys keyboard_modifier = $211 ; 8 bit Held Modifier Keys, such as "shift, alt, control" @@ -41,11 +41,11 @@ soft_system_register = $21d ; 8 bit (internal) color = $21e ; 8 bit Fore & Background Color typelength = $21f ; 8 bit Length of typebuffer -kernel_stack = $280 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers +kernel_stack = $300 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers -typebuffer = $380 ; 256 bytes 256 byte, All Purpose Char Buffer +typebuffer = $400 ; 256 bytes 256 byte, All Purpose Char Buffer -; END => $480 +; END => $500 ; Hardware Registers @@ -82,9 +82,9 @@ system_register = $bc00 ; 8 bit System Register ;----------------------------------------------------------------------------------------------- ; $200-$27f: Kernel Variables ;----------------------------------------------------------------------------------------------- -; $280-$37f: Kernel Stack +; $300-$3ff: Kernel Stack ;----------------------------------------------------------------------------------------------- -; $380-$47f: Typebuffer +; $400-$4ff: Typebuffer ;----------------------------------------------------------------------------------------------- ; ;-----------------------------------------------------------------------------------------------