From d03d49ac44dcec2172feb34c38a4fd6c90f0f249 Mon Sep 17 00:00:00 2001 From: jn Date: Thu, 2 Feb 2023 03:48:48 +0100 Subject: [PATCH 1/2] Move scancode-to-ASCII conversion into the terminal --- applications/sh/main.asm | 7 +++---- applications/terminal/main.asm | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/sh/main.asm b/applications/sh/main.asm index c743c33..839a8dc 100644 --- a/applications/sh/main.asm +++ b/applications/sh/main.asm @@ -21,11 +21,11 @@ shell_task_loop: shell_task_parse_key: ; first, check if enter, delete, or backspace was pressed - cmp.8 r0, 0x1C ; enter + cmp.8 r0, 0x0a ; enter ifz jmp shell_key_down_enter - cmp.8 r0, 0x6F ; delete + cmp.8 r0, 0x7f ; delete ifz jmp shell_key_down_backspace - cmp.8 r0, 0x0E ; backspace + cmp.8 r0, 0x08 ; backspace ifz jmp shell_key_down_backspace ; then, overwrite the cursor @@ -35,7 +35,6 @@ shell_task_parse_key: mov r0, r1 ; then, add it to the text buffer and print it to the screen - call scancode_to_ascii call print_character_to_terminal call shell_push_character diff --git a/applications/terminal/main.asm b/applications/terminal/main.asm index 34e57dc..ae160a9 100644 --- a/applications/terminal/main.asm +++ b/applications/terminal/main.asm @@ -67,6 +67,7 @@ key_down: ifz push event_loop_end ifz jmp caps_pressed + call scancode_to_ascii mov.8 [read_buffer], r0 jmp event_loop_end From bef0aa9700c26af011b79fa45848a37ddd840877 Mon Sep 17 00:00:00 2001 From: jn Date: Thu, 2 Feb 2023 03:18:08 +0100 Subject: [PATCH 2/2] Add serial.fxf: Serial terminal --- Makefile | 4 +++ applications/serial/main.asm | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 applications/serial/main.asm diff --git a/Makefile b/Makefile index 4fc8774..2c54e52 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,9 @@ base_image/barclock.fxf: applications/barclock/main.asm base_image/terminal.fxf: applications/terminal/main.asm $(wildcard applications/terminal/*.asm) $(FOX32ASM) $< $@ +base_image/serial.fxf: applications/serial/main.asm $(wildcard applications/terminal/*.asm) + $(FOX32ASM) $< $@ + base_image/foxpaint.fxf: applications/foxpaint/main.asm $(FOX32ASM) $< $@ @@ -53,6 +56,7 @@ FILES = \ base_image/sh.fxf \ base_image/barclock.fxf \ base_image/terminal.fxf \ + base_image/serial.fxf \ base_image/foxpaint.fxf \ base_image/bg.fxf \ base_image/bg.raw \ diff --git a/applications/serial/main.asm b/applications/serial/main.asm new file mode 100644 index 0000000..6e088bb --- /dev/null +++ b/applications/serial/main.asm @@ -0,0 +1,61 @@ +; serial terminal - spawn sh.fxf on the serial port + + ; start an instance of sh.fxf + call get_unused_task_id + mov.8 [shell_task_id], r0 + mov r1, stream_struct + call new_shell_task + +event_loop: + movz.8 r0, [shell_task_id] + call is_task_id_used + ifz call end_current_task + call yield_task + rjmp event_loop + +print_str_to_terminal: + push r0 + push r1 +print_str_to_terminal_loop: + mov r1, [r0] + cmp r1, 0 + ifz jmp print_str_to_terminal_out + out 0, r1 + inc r0 + jmp print_str_to_terminal_loop +print_str_to_terminal_out: + pop r1 + pop r0 + +stream_struct: + data.8 0x00 + data.16 0x00 + data.32 0x00 + data.8 0x01 + data.32 stream_read + data.32 stream_write + +shell_task_id: data.8 0 + +stream_read: + in r0, 0 + ret + +stream_write: + push r0 + movz.8 r0, [r0] + bts r0, 7 + ifnz jmp stream_write_special + out 0, r0 + pop r0 + ret +stream_write_special: + cmp r0, 0x8a + ifz out 0, ' ' + pop r0 + ret + + +#include "../terminal/task.asm" +#include "../../../fox32rom/fox32rom.def" +#include "../../fox32os.def"