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 8156f73..888d99b 100644 Binary files a/a.out and b/a.out differ diff --git a/main.s b/main.s index db4b53d..5a4f46b 100644 --- a/main.s +++ b/main.s @@ -19,7 +19,7 @@ reset: sei lda #$E0 sta vidm - + lda #$60 sta cursor_delay lda #$06 @@ -44,6 +44,9 @@ reset: sei stz system_register stz soft_system_register + jsr video_writeline_static + .string "Hello World" + jsr kernel_init diff --git a/src/kernel/byte.s b/src/kernel/byte.s new file mode 100644 index 0000000..8c42f9b --- /dev/null +++ b/src/kernel/byte.s @@ -0,0 +1,54 @@ +byte_flip: + ; Byte Flip + ; Flips the Byte around + ; Position 0 gets swapped with 7 + ; Position 1 gets swapped with 6 and so on... + + ; Input: + ; A => 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 ;----------------------------------------------------------------------------------------------- ; ;-----------------------------------------------------------------------------------------------