Worked on Function planning

This commit is contained in:
0xMAC8205 2023-10-30 20:37:11 +01:00
parent 49d9e0a38e
commit 9cee94df92
13 changed files with 334 additions and 49 deletions

View File

@ -1,13 +1,18 @@
Kernel Routines Grouped Kernel Routines Grouped by File
(everything NOT starting with "+-", are "wants")
Char.s Char.s
|
+- char_to_lower
+- char_to_upper
+- is_char
Event_Handler.s Event_Handler.s
|
+- event_invoke
+- event_append
+- event_remove
+- event_count
Hardware.s Hardware.s
| |
@ -18,34 +23,44 @@ Hardware.s
Int.s Int.s
Irq.s Irq.s
| |
+- irq +- irq
+- irq_init
Keyboard.s Keyboard.s
|
+- keyboard_scan
+- keyboard_translate
+- keyboard_format
Memory_Manager.s Memory_Manager.s
--- Still planing ---
Software Stack: Software Stack:
(for A, X and Y) (for A, X and Y)
push push
pop pop
reserve
dispose
grow
shrink
Maybe also: External Fragmantation Maybe also: External Fragmantation
or: Variable houskeeping in a List of pointers or: Variable houskeeping in a List of pointers
--- Still planing ---
String.s String.s
|
to lower +- string_to_lower
to upper +- string_to_upper
count +- string_count
flip +- string_flip
contains +- string_contains
equals +- string_equals
trim +- is_string
Video.s Video.s
| |

BIN
a.out

Binary file not shown.

BIN
b.out Normal file

Binary file not shown.

8
main.s
View File

@ -6,10 +6,10 @@
.org $f700 .org $f700
charset .incbin "assets/UTF-8.bin" charset: .incbin "assets/UTF-8.bin"
.org $ff00 .org $ff00
reset sei reset: sei
cld cld
lda #<irq lda #<irq
@ -48,9 +48,9 @@ reset sei
jsr kernel_init jsr kernel_init
loop jmp loop loop: jmp loop
irq_jump jmp (irq_vector) irq_jump: jmp (irq_vector)
.org $fffa .org $fffa

View File

@ -7,7 +7,7 @@
.include "src/kernel/memory_manager.s" .include "src/kernel/memory_manager.s"
.include "src/kernel/hardware.s" .include "src/kernel/hardware.s"
kernel_init kernel_init:
rts rts

View File

@ -0,0 +1,38 @@
char_to_lower:
; Char To Lower
; Char is converted to Lowercase
; Input:
; A => Char
; Output:
; A <= Char
rts
char_to_upper:
; Char To Upper
; Char is converted to Uppercase
; Input:
; A => Char
; Output:
; A <= Char
rts
is_char:
; Is Char
; Checks if the Byte given, is a valid char
; Input:
; A => Char
; Output:
; A <= 0 if False, 1 if True
rts

View File

@ -0,0 +1,62 @@
event_invoke:
; Event Invoke
; Invokes the Event, as a list of Sub-Routines,
; Starting at the pointer
; Input:
; K0 => LOW Event-List Pointer
; K1 => HIGH Event-List Pointer
; A => A Event Carry
; X => X Event Carry
; Y => Y Evet Carry
; Output: (none)
rts
event_append:
; Event Append
; Appens the given Adress to the given Event-List
; Input:
; K0 => LOW Event-List Pointer
; K1 => HIGH Event-List Pointer
; X => LOW Event Adress Pointer
; Y => HIGH Event Adress Pointer
; Output:
; A <= 0 if added successfully, 1 if not
rts
event_remove:
; Event Remove
; Removes the given Adress from the Event-List
; Input:
; K0 => LOW Event-List Pointer
; K1 => HIGH Event-List Pointer
; X => LOW Event Adress Pointer
; Y => HIGH Event Adress Pointer
; Output: (none)
rts
event_count:
; Event Count
; Counts how many Events are in a Event-List
; Input:
; X => LOW Event-List Pointer
; Y => HIGH Event-List Pointer
; Output:
; A <= Count
rts

View File

@ -1,5 +1,5 @@
vram_write vram_write:
; VRAM Write ; VRAM Write
; Writes A to the given Coordinate ; Writes A to the given Coordinate
@ -14,7 +14,7 @@ vram_write
rts rts
vram_write_color vram_write_color:
; VRAM Write Color ; VRAM Write Color
; Writes A to the given Coordinate, but adds 0x40 to X ; Writes A to the given Coordinate, but adds 0x40 to X
@ -28,7 +28,7 @@ vram_write_color
rts rts
vram_read vram_read:
; VRAM Read ; VRAM Read
; Reads Data from the given Coordinate ; Reads Data from the given Coordinate
@ -42,7 +42,7 @@ vram_read
rts rts
vram_dump vram_dump:
; VRAM Dump ; VRAM Dump
; Dumps all bytes from VRAM in the given Range ; Dumps all bytes from VRAM in the given Range
; to a specified Memory Adress ; to a specified Memory Adress

View File

@ -1,2 +1,5 @@
irq irq_init:
rts
irq:
rti rti

View File

@ -0,0 +1,42 @@
keyboard_scan:
; Keyboard Scan
; Scans the Keyboard matrix, and returns a Scan Code,
; the held Modifier Keys and Arrow Keys
; Input: (none)
; Output:
; A <= Scan Code
; X <= Modifier Keys
; Y <= Arrow Keys
rts
keyboard_translate:
; Keyboard Translate
; Converts the Scan Code into lowercase ASCII
; Input:
; A => Scan Code
; Output:
; A <= ASCII Char
rts
keyboard_format:
; Keyboard Format
; Formats the given ASCII Character to
; Uppercase / Special Characters, for final use
; Input:
; A => ASCII Char
; X => Modifier Keys
; Output:
; A <= ASCII Char
rts

View File

@ -0,0 +1,100 @@
string_to_lower:
; String To Lower
; Converts the given string to Lowercase
; Input:
; X => LOW Memory Pointer
; Y => HIGH Memory Pointer
; Output: (none)
rts
string_to_upper:
; String To Upper
; Converts the given string to Uppercase
; Input:
; X => LOW Memory Pointer
; Y => HIGH Memory Pointer
; Output: (none)
rts
string_count:
; String Count
; Counts the Characters in the given String
; Input:
; X => LOW Memory Pointer
; Y => HIGH Memory Pointer
; Output:
; A <= Count
rts
string_flip:
; String Flip
; Reverses the given String
; Input:
; X => LOW Memory Pointer
; Y => HIGH Memory Pointer
; Output: (none)
rts
string_contains:
; String Contains
; Checks if a String is contained in the given String
; Input:
; K0 => LOW Memory Pointer Shorter String
; K1 => HIGH Memory Pointer Shorter String
; X => LOW Memory Pointer Longer String
; Y => HIGH Memory Pointer Longer String
; Output:
; A <= 0 if False, 1 if True
rts
string_equals:
; String Equals
; Checks if a String is equal to the given String
; Input:
; K0 => LOW Memory Pointer String A
; K1 => HIGH Memory Pointer String A
; X => LOW Memory Pointer String B
; Y => HIGH Memory Pointer String B
; Output:
; A <= 0 if False, 1 if True
rts
is_string:
; Is String
; Checks if the given String contains valid Chars
; Input:
; X => LOW Memory Pointer
; Y => HIGH Memory Pointer
; A => Max. String Length
; Output:
; A <= 0 if False, 1 if True
rts

View File

@ -1,5 +1,5 @@
video_write video_write:
; Video Write (string) ; Video Write (string)
; String will be written from a Pointer, ; String will be written from a Pointer,
; without a new line at the end ; without a new line at the end
@ -13,7 +13,7 @@ video_write
rts rts
video_write_static video_write_static:
; Video Write Static (string) ; Video Write Static (string)
; String will be written wich follows after ; String will be written wich follows after
; the JSR call without a new line at the end ; the JSR call without a new line at the end
@ -24,7 +24,7 @@ video_write_static
rts rts
video_writeline video_writeline:
; Video Writeline (string) ; Video Writeline (string)
; Same as "video_write", except at ; Same as "video_write", except at
; the end, a new line begins ; the end, a new line begins
@ -38,7 +38,7 @@ video_writeline
rts rts
video_writeline_static video_writeline_static:
; Video Writeline Static (string) ; Video Writeline Static (string)
; Same as "video_write_static", except at ; Same as "video_write_static", except at
; the end, a new line begins ; the end, a new line begins
@ -49,7 +49,7 @@ video_writeline_static
rts rts
video_set_color video_set_color:
; Video Set Color ; Video Set Color
; Sets the color, of the content ; Sets the color, of the content
; that will be written, following ; that will be written, following
@ -62,7 +62,7 @@ video_set_color
rts rts
video_set_foreground video_set_foreground:
; Video Set Foreground ; Video Set Foreground
; Sets the Foreground color ; Sets the Foreground color
@ -74,7 +74,7 @@ video_set_foreground
rts rts
video_set_background video_set_background:
; Video Set Background ; Video Set Background
; Sets the Background color ; Sets the Background color
@ -86,7 +86,7 @@ video_set_background
rts rts
video_read_line video_read_line:
; Video Read Line ; Video Read Line
; Loops, till the Return key is pressed ; Loops, till the Return key is pressed
; Output is stored in $300 => "Typebuffer" ; Output is stored in $300 => "Typebuffer"
@ -97,7 +97,7 @@ video_read_line
rts rts
video_read_char video_read_char:
; Video Read Char ; Video Read Char
; Loops, till a Key is pressed ; Loops, till a Key is pressed
@ -109,7 +109,7 @@ video_read_char
rts rts
video_set_cursor video_set_cursor:
; Video Set Cursor ; Video Set Cursor
; Sets the Cursor Location ; Sets the Cursor Location
@ -122,7 +122,7 @@ video_set_cursor
rts rts
video_get_cursor video_get_cursor:
; Video Get Cursor ; Video Get Cursor
; Gets the Cursor Location ; Gets the Cursor Location
@ -135,7 +135,7 @@ video_get_cursor
rts rts
video_return video_return:
; Video Return ; Video Return
; Sets the Cursor to it's line starting Position ; Sets the Cursor to it's line starting Position
; and if nessesary, scrolls it up and prints the Start Text ; and if nessesary, scrolls it up and prints the Start Text
@ -146,7 +146,7 @@ video_return
rts rts
video_scroll video_scroll:
; Video Scroll ; Video Scroll
; Scrolls the screen in the given direction ; Scrolls the screen in the given direction
@ -174,14 +174,14 @@ video_scroll
rts rts
video_clear video_clear:
; Video Clear ; Video Clear
; Clears the Screen blank, with the normal Color ; Clears the Screen blank, with the normal Color
rts rts
video_reset_color video_reset_color:
; Video Reset Color ; Video Reset Color
; Resets the Color to it's initial state ; Resets the Color to it's initial state
@ -191,7 +191,7 @@ video_reset_color
rts rts
video_reset video_reset:
; Video Reset ; Video Reset
; Resets the Video Display ; Resets the Video Display
; to it's initial state, i.e ; to it's initial state, i.e
@ -203,7 +203,7 @@ video_reset
rts rts
video_load_font video_load_font:
; Video Load Font ; Video Load Font
; Loads a 2k BitMap font from a Pointer to VRAM ; Loads a 2k BitMap font from a Pointer to VRAM

View File

@ -8,10 +8,10 @@ z1 = $1 ; 8 bit
irq_a = $200 ; 8 bit (internal) IRQ Variable Save irq_a = $200 ; 8 bit (internal) IRQ Variable Save
irq_x = $201 ; 8 bit (internal) irq_x = $201 ; 8 bit (internal)
irq_y = $202 ; 8 bit (internal) irq_y = $202 ; 8 bit (internal)
irq_vector = $203 ; 16 bit IRQ 16 bit Jump Vector irq_vector = $203 ; 16 bit (internal) IRQ 16 bit Jump Vector
k0 = $205 ; 8 bit General Purpose Registers k0 = $205 ; 8 bit General Purpose Kernel Registers,
k1 = $206 ; 8 bit ... k1 = $206 ; 8 bit usually used as Carry for Sub-Routines
k2 = $207 ; 8 bit k2 = $207 ; 8 bit
k3 = $208 ; 8 bit k3 = $208 ; 8 bit
k4 = $209 ; 8 bit k4 = $209 ; 8 bit
@ -38,12 +38,14 @@ cursor_delay_count = $21b ; 8 bit (internal)
cursor_delay_switch = $21c ; 8 bit (internal) cursor_delay_switch = $21c ; 8 bit (internal)
soft_system_register = $21d ; 8 bit (internal) soft_system_register = $21d ; 8 bit (internal)
color = $21e ; 8 bit Fore & Background Color
typelength = $21f ; 8 bit Length of typebuffer
color = $2fe ; 8 bit Fore & Background Color kernel_stack = $280 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers
typelength = $2ff ; 8 bit Length of typebuffer typebuffer = $380 ; 256 bytes 256 byte, All Purpose Char Buffer
typebuffer = $300 ; 256 byte 256 bit, All Purpose Char Buffer
; END => $480
; Hardware Registers ; Hardware Registers
@ -64,4 +66,27 @@ ifr = $bf8d ; 8 bit
ier = $bf8e ; 8 bit ier = $bf8e ; 8 bit
keyboard_port = $bd00 ; 8 bit Keyboard Scan-Row Input keyboard_port = $bd00 ; 8 bit Keyboard Scan-Row Input
system_register = $bc00 ; 8 bit System Register system_register = $bc00 ; 8 bit System Register
;-----------------------------------------------------------------------------------------------
; Memory Map
;-----------------------------------------------------------------------------------------------
; $00-$ff: Mostly free Zero page, except for $00 and $01
;-----------------------------------------------------------------------------------------------
; $100-$1ff: Stack
;-----------------------------------------------------------------------------------------------
; $200-$27f: Kernel Variables
;-----------------------------------------------------------------------------------------------
; $280-$37f: Kernel Stack
;-----------------------------------------------------------------------------------------------
; $380-$47f: Typebuffer
;-----------------------------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------------------------