More Sub-Routine Planning

Wrote Hardware VRAM Routines
This commit is contained in:
0xMAC8205 2023-11-01 01:59:25 +01:00
parent d9ac5bbe75
commit c1f1b8c064
7 changed files with 144 additions and 7 deletions

View File

@ -1,6 +1,12 @@
Kernel Routines Grouped by File Kernel Routines Grouped by File
Byte.S
|
+- byte_flip
+- byte_swap
+- byte_drill
Char.s Char.s
| |
+- char_to_lower +- char_to_lower

BIN
a.out

Binary file not shown.

3
main.s
View File

@ -44,6 +44,9 @@ reset: sei
stz system_register stz system_register
stz soft_system_register stz soft_system_register
jsr video_writeline_static
.string "Hello World"
jsr kernel_init jsr kernel_init

54
src/kernel/byte.s Normal file
View File

@ -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

View File

@ -10,6 +10,15 @@ vram_write:
; Output: (none) ; 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 rts
@ -25,6 +34,23 @@ vram_write_color:
; Output: (none) ; 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 rts
@ -39,6 +65,14 @@ vram_read:
; Output: ; Output:
; A <= Data ; 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 rts

View File

@ -1,5 +1,45 @@
irq_init: 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 rts
irq: 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 rti

View File

@ -21,7 +21,7 @@ k7 = $20c ; 8 bit
keyboard_current = $20d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key" keyboard_current = $20d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key"
keyboard_previous = $20e ; 8 bit Previous held "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_arrow = $210 ; 8 bit Held Arrow Keys
keyboard_modifier = $211 ; 8 bit Held Modifier Keys, such as "shift, alt, control" 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 color = $21e ; 8 bit Fore & Background Color
typelength = $21f ; 8 bit Length of typebuffer 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 ; Hardware Registers
@ -82,9 +82,9 @@ system_register = $bc00 ; 8 bit System Register
;----------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------
; $200-$27f: Kernel Variables ; $200-$27f: Kernel Variables
;----------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------
; $280-$37f: Kernel Stack ; $300-$3ff: Kernel Stack
;----------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------
; $380-$47f: Typebuffer ; $400-$4ff: Typebuffer
;----------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------
; ;
;----------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------