2022-10-15 01:53:41 +02:00
|
|
|
; terminal
|
|
|
|
|
2023-01-21 09:17:10 +01:00
|
|
|
; create the window
|
2022-10-15 01:53:41 +02:00
|
|
|
mov r0, window_struct
|
|
|
|
mov r1, window_title
|
|
|
|
mov r2, 320
|
|
|
|
mov r3, 400
|
|
|
|
mov r4, 32
|
|
|
|
mov r5, 32
|
2022-12-25 07:51:43 +01:00
|
|
|
mov r6, 0
|
2022-12-28 03:01:55 +01:00
|
|
|
mov r7, 0
|
2022-10-15 01:53:41 +02:00
|
|
|
call new_window
|
|
|
|
|
2023-02-01 07:03:24 +01:00
|
|
|
; fill the window with the "black" color
|
|
|
|
mov r0, [colors]
|
|
|
|
mov r1, window_struct
|
|
|
|
call fill_window
|
|
|
|
|
2023-01-21 09:17:10 +01:00
|
|
|
; start an instance of sh.fxf
|
2022-10-15 01:53:41 +02:00
|
|
|
call get_unused_task_id
|
|
|
|
mov.8 [shell_task_id], r0
|
|
|
|
mov r1, stream_struct
|
|
|
|
call new_shell_task
|
|
|
|
|
|
|
|
event_loop:
|
|
|
|
mov r0, window_struct
|
|
|
|
call get_next_window_event
|
|
|
|
|
|
|
|
cmp r0, EVENT_TYPE_MOUSE_CLICK
|
|
|
|
ifz jmp mouse_down
|
|
|
|
|
|
|
|
cmp r0, EVENT_TYPE_KEY_DOWN
|
|
|
|
ifz jmp key_down
|
|
|
|
|
|
|
|
cmp r0, EVENT_TYPE_KEY_UP
|
|
|
|
ifz jmp key_up
|
|
|
|
|
|
|
|
event_loop_end:
|
|
|
|
movz.8 r0, [shell_task_id]
|
|
|
|
call is_task_id_used
|
|
|
|
ifz jmp close_window
|
|
|
|
call yield_task
|
2023-01-30 21:28:33 +01:00
|
|
|
cmp.8 [read_buffer_ack], 1
|
|
|
|
ifz mov.8 [read_buffer], 0
|
|
|
|
ifz mov.8 [read_buffer_ack], 0
|
2022-10-15 01:53:41 +02:00
|
|
|
rjmp event_loop
|
|
|
|
|
|
|
|
mouse_down:
|
|
|
|
; check if we are attempting to drag or close the window
|
|
|
|
cmp r2, 16
|
|
|
|
iflteq jmp drag_window
|
|
|
|
|
|
|
|
jmp event_loop_end
|
|
|
|
|
|
|
|
key_down:
|
|
|
|
mov r0, r1
|
|
|
|
|
2023-01-21 08:30:43 +01:00
|
|
|
cmp.8 r0, KEY_CTRL
|
|
|
|
ifz jmp event_loop_end
|
2022-10-15 01:53:41 +02:00
|
|
|
cmp.8 r0, KEY_LSHIFT
|
|
|
|
ifz push event_loop_end
|
|
|
|
ifz jmp shift_pressed
|
|
|
|
cmp.8 r0, KEY_RSHIFT
|
|
|
|
ifz push event_loop_end
|
|
|
|
ifz jmp shift_pressed
|
|
|
|
cmp.8 r0, KEY_CAPS
|
|
|
|
ifz push event_loop_end
|
|
|
|
ifz jmp caps_pressed
|
|
|
|
|
|
|
|
mov.8 [read_buffer], r0
|
|
|
|
|
|
|
|
jmp event_loop_end
|
|
|
|
|
|
|
|
key_up:
|
|
|
|
mov r0, r1
|
|
|
|
|
2023-01-21 08:30:43 +01:00
|
|
|
cmp.8 r0, KEY_CTRL
|
|
|
|
ifz jmp event_loop_end
|
2022-10-15 01:53:41 +02:00
|
|
|
cmp.8 r0, KEY_LSHIFT
|
|
|
|
ifz push event_loop_end
|
|
|
|
ifz jmp shift_released
|
|
|
|
cmp.8 r0, KEY_RSHIFT
|
|
|
|
ifz push event_loop_end
|
|
|
|
ifz jmp shift_released
|
|
|
|
|
|
|
|
jmp event_loop_end
|
|
|
|
|
|
|
|
drag_window:
|
|
|
|
cmp r1, 8
|
|
|
|
iflteq jmp event_loop_end
|
|
|
|
mov r0, window_struct
|
|
|
|
call start_dragging_window
|
|
|
|
jmp event_loop_end
|
|
|
|
|
|
|
|
close_window:
|
|
|
|
mov r0, window_struct
|
|
|
|
call destroy_window
|
|
|
|
call end_current_task
|
|
|
|
jmp event_loop_end
|
|
|
|
|
2023-02-02 00:08:22 +01:00
|
|
|
window_title: data.strz "Terminal"
|
2022-12-28 03:01:55 +01:00
|
|
|
window_struct: data.fill 0, 36
|
2022-10-15 01:53:41 +02:00
|
|
|
|
|
|
|
shell_task_id: data.8 0
|
|
|
|
|
|
|
|
stream_struct:
|
|
|
|
data.8 0x00
|
|
|
|
data.16 0x00
|
|
|
|
data.32 0x00
|
|
|
|
data.8 0x01
|
|
|
|
data.32 stream_get_input
|
|
|
|
data.32 stream_write_to_terminal
|
|
|
|
|
|
|
|
#include "stream.asm"
|
2023-01-21 09:17:10 +01:00
|
|
|
#include "task.asm"
|
2022-10-15 01:53:41 +02:00
|
|
|
#include "text.asm"
|
|
|
|
|
|
|
|
; include system defs
|
2022-12-27 04:05:27 +01:00
|
|
|
#include "../../../fox32rom/fox32rom.def"
|
|
|
|
#include "../../fox32os.def"
|