Compare commits

...

10 Commits

Author SHA1 Message Date
f4fdca7fee Cleaned up Font
Startet working on Keyboard Routines
2024-02-18 22:54:51 +01:00
fdacbb1deb Added new Files 2023-12-07 22:45:26 +01:00
3e1b5e70af Expanded hardware.s 2023-11-20 13:22:50 +01:00
3cfc9583c7 Merge branch 'main' of https://github.com/0xMAC8205/LS7-Kernel 2023-11-16 12:06:22 +01:00
4ae7644a94 Added seperate Build and Upload scripts 2023-11-16 12:02:51 +01:00
0xMAC
39c5f162b6
Update README.md 2023-11-16 12:02:34 +01:00
75d8ae5d7f Project restructuring 2023-11-15 14:12:14 +01:00
06fb7d975b Added Kernel Stack 2023-11-15 12:19:10 +01:00
6d7ce1cd53 Added a.out to .gitignore 2023-11-14 00:57:07 +01:00
eb7f25fc64 idk 2023-11-10 11:34:35 +01:00
31 changed files with 397 additions and 121 deletions

4
.gitignore vendored Normal file → Executable file
View File

@ -1 +1,3 @@
.vscode .vscode
build
src/tools

13
Makefile Normal file → Executable file
View File

@ -1,13 +1,8 @@
# Please Ignore for now, I will make a better makefile in the future # Please Ignore for now, I will make a better makefile in the future
# I promisse # I promisse
all: compile upload # ToDo:
# Ignore Upload when no programmer found
compile:
@echo "Compiling for 65c02"
@vasm6502_oldstyle -Fbin -dotdir -wdc02 main.s | grep :
upload:
@echo "Uploading"
@minipro -p SST39SF040 -w a.out -Sy
all:
@sh build.sh

14
README.md Normal file → Executable file
View File

@ -1,15 +1,13 @@
# LS7-Kernel # LS7-Kernel
Kernel for the LS/7 Computer Kernel for the LS/7 Computer
!! Still in Development !! **Not yet stable**
# Building & Compiling # Building & Compiling
Although, there already is a pre-compiled Binary "a.out", Build and Upload scripts are contained in the main directory,
if you want to make and apply changes you have to compile the program or use the binder Makefile
yourself.
The Compile and Upload scripts are contained in the Makefile
# Dependencies: # Dependencies:
* Compiler: vasm6502 (may switch to cc65) * Compiler: vasm6502_oldstyle (may switch to cc65)
* Uploader: minipro * Uploader: minipro

BIN
a.out

Binary file not shown.

Binary file not shown.

0
assets/UTF-8.bmf → assets/bold.bmf Normal file → Executable file
View File

BIN
assets/font.bin Executable file

Binary file not shown.

BIN
assets/thin.bmf Executable file

Binary file not shown.

36
build.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
echo "Compiling for 65c02"
# Removing previous build
rm -rf build
mkdir build
bold=$(tput bold)
normal=$(tput sgr0)
build(){
output=$(vasm6502_oldstyle -Fbin -dotdir -wdc02 src/main.s -o build/a.out | grep :)
if `find build/a.out* > /dev/null`;
then
echo -e "\n\e[0;32m${bold}Compiled Succsessfully${normal}"
sh upload.sh
else
echo -e "\n\e[0;31m${bold}Error while Compiling${normal}"
fi
echo ""
echo $output | sed 's/bytes /bytes\n/g'
}
# Checking dependencies
if command -v vasm6502_oldstyle > /dev/null 2<&1;
then
build
else
echo -e "\n\e[0;31m${bold}vasm6502_oldstyle not found${normal}"
echo "Aborting build..."
fi

41
KernelRoutineList.txt → docs/KernelRoutineList.txt Normal file → Executable file
View File

@ -33,15 +33,16 @@ Hardware.s
+- vram_write_color +- vram_write_color
+- vram_read +- vram_read
+- vram_dump +- vram_dump
+- beep
+- set_activity_led
+- set_activity_led_duration
+- set_user_led
+- set_user_led_duration
+- expansion_set
+- expansion_get
beep
set_activity_led
set_user_led
scan_keyboard scan_keyboard
expansion_set
expansion_get
Int.s Int.s
| |
+- int16_add_byte +- int16_add_byte
@ -58,20 +59,22 @@ Keyboard.s
+- keyboard_format +- keyboard_format
Memory_Manager.s Memory_Manager.s
|
+- kernel_push_a
+- kernel_push_x
+- kernel_push_y
+- kernel_pull_a
+- kernel_pull_x
+- kernel_pull_y
--- Still planing --- --- Still planing ---
Software Stack:
(for A, X and Y)
push
pop
reserve reserve
dispose dispose
grow grow
shrink shrink
Maybe also: External Fragmantation External Fragmantation
or: Variable houskeeping in a List of pointers or: Variable houskeeping in a List of pointers
--- Still planing --- --- Still planing ---
@ -124,4 +127,14 @@ video.s
+- video_set_mode +- video_set_mode
+- video_get_mode +- video_get_mode
+- video_set_accent +- video_set_accent
+- video_get_accent +- video_get_accent
filesystem.s
serial.s
sound.s

BIN
docs/LS7 Kernel Manual.pdf Executable file

Binary file not shown.

0
src/bootloader.s Executable file
View File

25
src/kernel.s Normal file → Executable file
View File

@ -3,9 +3,28 @@
.include "src/kernel/video.s" .include "src/kernel/video.s"
.include "src/kernel/console.s" .include "src/kernel/console.s"
.include "src/kernel/graphics.s" .include "src/kernel/graphics.s"
.include "src/kernel/string.s"
.include "src/kernel/int.s"
.include "src/kernel/event_handler.s" .include "src/kernel/event_handler.s"
.include "src/kernel/memory_manager.s" .include "src/kernel/memory_manager.s"
.include "src/kernel/hardware.s" .include "src/kernel/hardware.s"
.include "src/kernel/string.s"
.include "src/kernel/int.s"
.include "src/kernel/byte.s"
.include "src/kernel/char.s"
kernel_init:
; Kernel Init
; Initialises some Kernel parameters
; Input : (none)
; Output : (none)
stz kernel_stack_counter
lda #<kernel_stack
sta kernel_stack_pointer
lda #>kernel_stack
sta kernel_stack_pointer + 1
rts

0
src/kernel/byte.s Normal file → Executable file
View File

0
src/kernel/char.s Normal file → Executable file
View File

16
src/kernel/console.s Normal file → Executable file
View File

@ -14,9 +14,16 @@ console_write:
; ToDo: ; ToDo:
; Support for ASCII (0-32) Chars, Line feed etc. ; Support for ASCII (0-32) Chars, Line feed etc.
; Support for Color codes => Maybe #$ff Indicator ; Support for Color codes => Maybe #$ff Indicator
; Return propper work addresses in X & Y ; Return propper work addresses in X & Y (for static support)
; ;
; 00 = END of string
; 0a = New Line
; 08 = Backspace
; 09 | 0b = Tab
; 0d = x cursor origin
;
stx z0 stx z0
sty z1 sty z1
@ -49,7 +56,7 @@ console_write_loop:
lda #$1f lda #$1f
sta cursor_y sta cursor_y
console_write_skip_overflow: console_write_skip_overflow:
ldx cursor_x ldx cursor_x
ldy cursor_y ldy cursor_y
jsr vram_write jsr vram_write
@ -285,6 +292,11 @@ console_reset:
; Input: (none) ; Input: (none)
; Output: (none) ; Output: (none)
jsr console_clear
ldx #$00
ldy #$00
jsr console_set_cursor
rts rts

0
src/kernel/event_handler.s Normal file → Executable file
View File

0
src/kernel/graphics.s Normal file → Executable file
View File

86
src/kernel/hardware.s Normal file → Executable file
View File

@ -98,3 +98,89 @@ vram_dump:
rts rts
beep:
; Beep
; Beeps the main speaker
; Input:
; A => Beep Duration
; Output: (none)
sta beep_counter
rts
set_activity_led:
; Set Activity LED
; Sets the Activity LED Constant
; Input:
; A => State
; Output: (none)
rts
set_user_led:
; Set User LED
; Sets the User LED Constant
; Input:
; A => State
; Output: (none)
rts
set_activity_led_duration:
; Set Activity LED Duration
; Sets the Time (in Ticks),
; where the Activity LED is HIGH
; Input:
; A => Duration
; Output: (none)
rts
set_user_led_duration:
; Set User LED Duration
; Sets the Time (in Ticks),
; where the User LED is HIGH
; Input:
; A => Duration
; Output: (none)
rts
expansion_get:
; Expansion Get
; Gets Data from the Selected Expansion port,
; at the given Port-Address
; Input:
; X => Port Number
; Y => Port Address
; Output:
; A <= Read Data
rts
expansion_set:
; Expansion Set
; Sets Data from the Selected Expansion port,
; at the given Port-Address
; Input:
; A => Data
; X => Port Number
; Y => Port Address
; Output: (none)
rts

0
src/kernel/int.s Normal file → Executable file
View File

0
src/kernel/irq.s Normal file → Executable file
View File

43
src/kernel/keyboard.s Normal file → Executable file
View File

@ -28,49 +28,6 @@ keyboard_scan:
sta soft_system_register sta soft_system_register
sta system_register sta system_register
ldy #$00 ; Result Index
ldx #$00 ; Row Counter
keyboard_scan_load:
lda #$fe ; Bit shifter
keyboard_scan_loop:
cmp keyboard_port
beq keyboard_scan_return
iny
rol
cmp #$fe
bne keyboard_scan_loop
inx
cpx #$08 ; Checking if Counted to 7
beq keyboard_scan_return
inc soft_system_register
lda soft_system_register
sta system_register
jmp keyboard_scan_load
keyboard_scan_return:
sty k0
lda soft_system_register
ora #$05
sta system_register
lda keyboard_port
tax
and #$0f
tay ; => Arrow Keys
txa
rol
rol
rol
rol
and #$07
tax ; => Modifier Keys
lda k0 ; => Scancode
rts
keyboard_translate: keyboard_translate:
; Keyboard Translate ; Keyboard Translate

120
src/kernel/memory_manager.s Normal file → Executable file
View File

@ -0,0 +1,120 @@
kernel_push_a:
; Kernel Push A
; Pushes the A Register to Kernel Stack
; Input:
; A => Data to Push
; Output: (none)
sty kernel_stack_offload_1
ldy kernel_stack_counter
sta (kernel_stack_pointer), y
inc kernel_stack_counter
ldy kernel_stack_offload_1
rts
kernel_push_x:
; Kernel Push X
; Pushes the X Register to Kernel Stack
; Input:
; X => Data to Push
; Output: (none)
sty kernel_stack_offload_1
sta kernel_stack_offload_2
txa
ldy kernel_stack_counter
sta (kernel_stack_pointer), y
tax
inc kernel_stack_counter
ldy kernel_stack_offload_1
lda kernel_stack_offload_2
rts
kernel_push_y:
; Kernel Push Y
; Pushes the Y Register to Kernel Stack
; Input:
; Y => Data to Push
; Output: (none)
stx kernel_stack_offload_1
sta kernel_stack_offload_2
tya
ldy kernel_stack_counter
sta (kernel_stack_pointer), y
tay
inc kernel_stack_counter
ldx kernel_stack_offload_1
lda kernel_stack_offload_2
rts
kernel_pull_a:
; Kernel Pull A
; Pulls the Current Index Data
; of the Kernel Stack to A
; Input: (none)
; Output:
; A <= Pulled Data
sty kernel_stack_offload_1
ldy kernel_stack_counter
lda (kernel_stack_pointer), y
dec kernel_stack_pointer
ldy kernel_stack_offload_1
rts
kernel_pull_x:
; Kernel Pull X
; Pulls the Current Index Data
; of the Kernel Stack to X
; Input: (none)
; Output:
; X <= Pulled Data
sty kernel_stack_offload_1
sta kernel_stack_offload_2
ldy kernel_stack_counter
lda (kernel_stack_pointer), y
tax
dec kernel_stack_pointer
ldy kernel_stack_offload_1
lda kernel_stack_offload_2
rts
kernel_pull_y:
; Kernel Pull Y
; Pulls the Current Index Data
; of the Kernel Stack to Y
; Input: (none)
; Output:
; Y <= Pulled Data
sta kernel_stack_offload_1
ldy kernel_stack_counter
lda (kernel_stack_pointer), y
tay
dec kernel_stack_pointer
lda kernel_stack_offload_1
rts

0
src/kernel/scheduler.s Executable file
View File

0
src/kernel/string.s Normal file → Executable file
View File

0
src/kernel/threading.s Executable file
View File

0
src/kernel/video.s Normal file → Executable file
View File

19
main.s → src/main.s Normal file → Executable file
View File

@ -1,5 +1,5 @@
; Important To-Do! ; Important To-Do!
; ;
; Get launch & tasks json working ; Get launch & tasks json working
; fix Keyboard scanning ; fix Keyboard scanning
; work on KernelRoutinesList.txt ; work on KernelRoutinesList.txt
@ -8,15 +8,15 @@
; Does not support the Graphics module ! ; Does not support the Graphics module !
.include "src/variables.s" .include "src/variables.s"
.org $c000 ; $c000 for 16k ROM .org $c000 ; $c000 for 16k ROM
.include "src/kernel.s" .include "src/kernel.s"
.org $f700 .org $f700
charset: .incbin "assets/UTF-8.bin" charset: .incbin "assets/font.bin"
.org $ff00 .org $ff00
reset: sei reset: sei
@ -29,7 +29,7 @@ reset: sei
lda #$E0 lda #$E0
sta vidm sta vidm
lda #$60 lda #$60
sta cursor_delay sta cursor_delay
lda #$06 lda #$06
@ -54,6 +54,8 @@ reset: sei
stz system_register stz system_register
stz soft_system_register stz soft_system_register
jsr kernel_init
;jsr video_writeline_static ;jsr video_writeline_static
;.string "Hello World" ;.string "Hello World"
@ -84,7 +86,8 @@ lp:
cpy #$10 cpy #$10
bne lp bne lp
loop: loop:
jmp loop jmp loop
irq_jump: jmp (irq_vector) irq_jump: jmp (irq_vector)
@ -95,4 +98,4 @@ irq_jump: jmp (irq_vector)
.addr reset .addr reset
.addr irq_jump .addr irq_jump
.end .end

0
src/monitor.s Normal file → Executable file
View File

81
src/variables.s Normal file → Executable file
View File

@ -7,50 +7,65 @@
z0 = $0 ; 8 bit All Purpose 16 bit Zero Page Variable z0 = $0 ; 8 bit All Purpose 16 bit Zero Page Variable
z1 = $1 ; 8 bit z1 = $1 ; 8 bit
kernel_stack_pointer = $fe ; 16 bit Pointer to the Kernel Stack
irq_a = $200 ; 8 bit (internal) IRQ Variable Save kernel_stack = $200 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers
irq_x = $201 ; 8 bit (internal)
irq_y = $202 ; 8 bit (internal)
irq_vector = $203 ; 16 bit (internal) IRQ 16 bit Jump Vector
k0 = $205 ; 8 bit General Purpose Kernel Registers, typebuffer = $300 ; 256 bytes 256 byte, All Purpose Char Buffer
k1 = $206 ; 8 bit usually used as Carry for Sub-Routines
k2 = $207 ; 8 bit
k3 = $208 ; 8 bit
k4 = $209 ; 8 bit
k5 = $20a ; 8 bit
k6 = $20b ; 8 bit
k7 = $20c ; 8 bit
keyboard_current = $20d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key" irq_a = $400 ; 8 bit (internal) IRQ Variable Save
keyboard_previous = $20e ; 8 bit Previous held "Scan Key" irq_x = $401 ; 8 bit (internal)
keyboard_ascii = $20f ; 8 bit Formatted Char, from keyboard_current as ASCII irq_y = $402 ; 8 bit (internal)
keyboard_arrow = $210 ; 8 bit Held Arrow Keys irq_vector = $403 ; 16 bit (internal) IRQ 16 bit Jump Vector
keyboard_modifier = $211 ; 8 bit Held Modifier Keys, such as "shift, alt, control"
k0 = $405 ; 8 bit General Purpose Kernel Registers,
k1 = $406 ; 8 bit usually used as Carry for Sub-Routines
k2 = $407 ; 8 bit
k3 = $408 ; 8 bit
k4 = $409 ; 8 bit
k5 = $40a ; 8 bit
k6 = $40b ; 8 bit
k7 = $40c ; 8 bit
keyboard_current = $40d ; 8 bit Held Keyboard Key, without Formatting (shift, etc.) "Scan Key"
keyboard_previous = $40e ; 8 bit Previous held "Scan Key"
keyboard_ascii = $40f ; 8 bit Formatted Char, from keyboard_current as ASCII
keyboard_arrow = $410 ; 8 bit Held Arrow Keys
keyboard_modifier = $411 ; 8 bit Held Modifier Keys, such as "shift, alt, control"
cursor_x = $412 ; 8 bit Current Cursor X Position
cursor_y = $413 ; 8 bit Current Cursor Y Position
cursor_x_previous = $414 ; 8 bit (internal) Previous Cursor X Position
cursor_y_previous = $415 ; 8 bit (internal) Previous Cursor Y Position
cursor_value = $416 ; 8 bit
cursor_speed = $417 ; 8 bit Cursor Blink Speed (in IRQ Ticks)
cursor_speed_count = $418 ; 8 bit (internal) Cursor Blink Speed Counter
cursor_delay_interval = $419 ; 8 bit
cursor_delay = $41a ; 8 bit
cursor_delay_count = $41b ; 8 bit (internal)
cursor_delay_switch = $41c ; 8 bit (internal)
soft_system_register = $41d ; 8 bit (internal)
color = $41e ; 8 bit Fore & Background Color
typelength = $41f ; 8 bit Length of typebuffer
kernel_stack_counter = $420 ; 8 bit (internal) Length of Kernel Stack
kernel_stack_offload_1 = $421 ; 8 bit (internal) General Kernel Stack Offload Variable
kernel_stack_offload_2 = $422 ; 8 bit (internal) ..
beep_counter = $423 ; 8 bit (public) Beeper counter in IRQ Ticks
activity_led_counter = $424 ; 8 bit (public) Activity LED Counter in IRQ Ticks
user_led_counter = $425 ; 8 bit (public) User LED Counter in IRQ Ticks
cursor_x = $212 ; 8 bit Current Cursor X Position
cursor_y = $213 ; 8 bit Current Cursor Y Position
cursor_x_previous = $214 ; 8 bit (internal) Previous Cursor X Position
cursor_y_previous = $215 ; 8 bit (internal) Previous Cursor Y Position
cursor_value = $216 ; 8 bit
cursor_speed = $217 ; 8 bit Cursor Blink Speed (in IRQ Ticks)
cursor_speed_count = $218 ; 8 bit (internal) Cursor Blink Speed Counter
cursor_delay_interval = $219 ; 8 bit
cursor_delay = $21a ; 8 bit
cursor_delay_count = $21b ; 8 bit (internal)
cursor_delay_switch = $21c ; 8 bit (internal)
soft_system_register = $21d ; 8 bit (internal)
color = $21e ; 8 bit Fore & Background Color
typelength = $21f ; 8 bit Length of typebuffer
kernel_stack = $300 ; 256 bytes 256 byte, Kernel Stack, used for offloading Registers
typebuffer = $400 ; 256 bytes 256 byte, All Purpose Char Buffer
; END => $500 ; END => $500
; Hardware Registers ; Hardware Registers
vidx = $be00 ; 8 bit Video X Register vidx = $be00 ; 8 bit Video X Register

20
upload.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
echo -e "\nUploading..."
bold=$(tput bold)
normal=$(tput sgr0)
upload(){
output=`minipro -p SST39SF040 -w build/a.out -Sy`
}
# Checking dependencies
if command -v minipro > /dev/null 2<&1;
then
upload
else
echo -e "\n\e[0;31m${bold}minipro not found${normal}"
echo "Aborting upload..."
fi