kernel+apps: Use a more standard filename format (8.3 with no spaces)
This commit is contained in:
parent
76d669bfda
commit
60a322ca53
|
@ -18,7 +18,7 @@
|
|||
|
||||
call end_current_task
|
||||
|
||||
bg_file_name: data.str "bg raw"
|
||||
bg_file_name: data.str "bg.raw"
|
||||
bg_file_struct: data.fill 0, 8
|
||||
|
||||
#include "../../../fox32rom/fox32rom.def"
|
||||
|
|
|
@ -84,7 +84,7 @@ close_window:
|
|||
window_title: data.strz "Launcher"
|
||||
window_struct: data.fill 0, 36
|
||||
|
||||
terminal_button_fxf: data.strz "terminalfxf"
|
||||
terminal_button_fxf: data.strz "terminal.fxf"
|
||||
terminal_button_widget:
|
||||
data.32 0 ; next_ptr
|
||||
data.32 0 ; id
|
||||
|
|
|
@ -53,12 +53,13 @@ shell_dir_command_loop:
|
|||
call print_character_to_terminal
|
||||
|
||||
; get and print the file size
|
||||
; call ryfs_open instead of open because this uses the internal filename style
|
||||
call get_current_disk_id
|
||||
mov r1, r0
|
||||
mov r0, shell_dir_command_list_buffer
|
||||
add r0, r3
|
||||
mov r2, shell_dir_command_temp_file_struct
|
||||
call open
|
||||
call ryfs_open
|
||||
cmp r0, 0
|
||||
ifz jmp shell_dir_command_failed_to_open_file
|
||||
mov r0, shell_dir_command_temp_file_struct
|
||||
|
|
|
@ -23,7 +23,7 @@ shell_help_text:
|
|||
data.str "exit | exit the shell" data.8 10
|
||||
data.str "help | show this help text" data.8 10
|
||||
data.str "shutdown| turn the computer off" data.8 10
|
||||
data.str "type | print file $0 of type $1" data.8 10
|
||||
data.str "type | print contents of file $0" data.8 10
|
||||
data.8 10
|
||||
data.str "type the name of an FXF binary to launch" data.8 10
|
||||
data.str "it as a new task; the shell will suspend" data.8 10
|
||||
|
|
|
@ -2,38 +2,14 @@
|
|||
|
||||
shell_type_command_string: data.strz "type"
|
||||
|
||||
; FIXME: check string length before blindly copying
|
||||
shell_type_command:
|
||||
call shell_parse_arguments
|
||||
|
||||
; r0: file name
|
||||
; r1: file extension
|
||||
mov r3, r0
|
||||
|
||||
; copy empty file name
|
||||
push r1
|
||||
push r0
|
||||
mov r0, shell_type_command_file_empty
|
||||
mov r1, shell_type_command_file
|
||||
mov r2, 11
|
||||
call copy_memory_bytes
|
||||
|
||||
; copy file name
|
||||
pop r0
|
||||
mov r1, shell_type_command_file
|
||||
call custom_copy_string
|
||||
|
||||
; copy file extension
|
||||
pop r0
|
||||
mov r1, shell_type_command_file
|
||||
add r1, 8
|
||||
call custom_copy_string
|
||||
add r1, 3
|
||||
mov.8 [r1], 0
|
||||
|
||||
; open the file
|
||||
call get_current_disk_id
|
||||
mov r1, r0
|
||||
mov r0, shell_type_command_file
|
||||
mov r0, r3
|
||||
mov r2, shell_type_command_file_struct
|
||||
call open
|
||||
cmp r0, 0
|
||||
|
@ -60,32 +36,13 @@ shell_type_command_loop:
|
|||
shell_type_command_file_not_found:
|
||||
mov r0, shell_type_command_file_not_found_string
|
||||
call print_str_to_terminal
|
||||
mov r0, shell_type_command_file
|
||||
mov r0, r3
|
||||
call print_str_to_terminal
|
||||
mov r0, 10
|
||||
call print_character_to_terminal
|
||||
|
||||
ret
|
||||
|
||||
custom_copy_string:
|
||||
push r0
|
||||
push r1
|
||||
push r2
|
||||
custom_copy_string_loop:
|
||||
mov.8 r2, [r0]
|
||||
mov.8 [r1], r2
|
||||
inc r0
|
||||
inc r1
|
||||
cmp.8 [r0], 0
|
||||
ifnz jmp custom_copy_string_loop
|
||||
|
||||
pop r2
|
||||
pop r1
|
||||
pop r0
|
||||
ret
|
||||
|
||||
shell_type_command_file: data.fill 0, 12
|
||||
shell_type_command_file_empty: data.str " "
|
||||
shell_type_command_file_struct: data.32 0 data.32 0
|
||||
shell_type_command_file_character_buffer: data.8 0
|
||||
shell_type_command_file_not_found_string: data.strz "file not found: "
|
||||
|
|
|
@ -61,10 +61,12 @@ new_shell_task:
|
|||
sh_fxf_missing:
|
||||
mov r0, sh_fxf_missing_str
|
||||
call print_str_to_terminal
|
||||
rjmp 0
|
||||
sh_fxf_missing_yield_loop:
|
||||
call yield_task
|
||||
rjmp sh_fxf_missing_yield_loop
|
||||
|
||||
sh_fxf_name: data.str "sh fxf"
|
||||
sh_fxf_name: data.strz "sh.fxf"
|
||||
sh_fxf_struct: data.fill 0, 8
|
||||
sh_fxf_missing_str: data.strz "sh could not be launched!"
|
||||
sh_fxf_missing_str: data.str "sh could not be launched! hanging here" data.8 10 data.8 0
|
||||
sh_fxf_binary_ptr: data.32 0
|
||||
sh_fxf_stack_ptr: data.32 0
|
||||
|
|
|
@ -16,12 +16,15 @@
|
|||
|
||||
; open a file from a RYFS-formatted disk
|
||||
; inputs:
|
||||
; r0: pointer to file name string (8.3 format, for example "test txt" for test.txt)
|
||||
; r0: pointer to file name string (8.3 format, for example "testfile.txt" or "test.txt")
|
||||
; r1: disk ID
|
||||
; r2: file struct: pointer to a blank file struct
|
||||
; outputs:
|
||||
; r0: first file sector, or zero if file wasn't found
|
||||
open:
|
||||
call convert_filename
|
||||
cmp r0, 0
|
||||
ifz ret
|
||||
jmp ryfs_open
|
||||
|
||||
; seek specified file to the specified offset
|
||||
|
@ -156,3 +159,86 @@ stream_write_char:
|
|||
pop r1
|
||||
pop r0
|
||||
ret
|
||||
|
||||
; convert a user-friendly filename (test.txt) to the internal representation (test txt)
|
||||
; inputs:
|
||||
; r0: pointer to null-terminated input string
|
||||
; outputs:
|
||||
; r0: pointer to null-terminated output string, or zero if failure
|
||||
convert_filename:
|
||||
push r1
|
||||
push r2
|
||||
push r3
|
||||
push r31
|
||||
|
||||
; check the length of the filename to ensure it isn't too long
|
||||
mov r1, r0
|
||||
call string_length
|
||||
cmp r0, 12
|
||||
ifgt jmp convert_filename_fail
|
||||
cmp r0, 0
|
||||
ifz jmp convert_filename_fail
|
||||
|
||||
; fill the output string buffer with spaces and a null-terminator
|
||||
mov r2, convert_filename_output_string
|
||||
mov r31, 11
|
||||
convert_filename_space_loop:
|
||||
mov.8 [r2], ' '
|
||||
inc r2
|
||||
loop convert_filename_space_loop
|
||||
mov.8 [r2], 0
|
||||
|
||||
mov r2, convert_filename_output_string
|
||||
mov r3, 0
|
||||
|
||||
; r0: input filename length
|
||||
; r1: pointer to input filename
|
||||
; r2: pointer to output filename
|
||||
; r3: number of characters processed
|
||||
convert_filename_copy_loop:
|
||||
cmp.8 [r1], '.'
|
||||
ifz jmp convert_filename_found_ext
|
||||
mov.8 [r2], [r1]
|
||||
inc r1
|
||||
inc r2
|
||||
inc r3
|
||||
cmp r3, r0
|
||||
ifz jmp convert_filename_done
|
||||
iflt jmp convert_filename_copy_loop
|
||||
convert_filename_found_ext:
|
||||
cmp r3, 0
|
||||
ifz jmp convert_filename_fail
|
||||
cmp r3, 8
|
||||
ifgt jmp convert_filename_fail
|
||||
|
||||
mov r2, convert_filename_output_string
|
||||
add r2, 8
|
||||
inc r1
|
||||
cmp.8 [r1], 0
|
||||
ifz jmp convert_filename_fail
|
||||
mov.8 [r2], [r1]
|
||||
inc r1
|
||||
inc r2
|
||||
cmp.8 [r1], 0
|
||||
ifz jmp convert_filename_done
|
||||
mov.8 [r2], [r1]
|
||||
inc r1
|
||||
inc r2
|
||||
cmp.8 [r1], 0
|
||||
ifz jmp convert_filename_done
|
||||
mov.8 [r2], [r1]
|
||||
convert_filename_done:
|
||||
mov r0, convert_filename_output_string
|
||||
pop r31
|
||||
pop r3
|
||||
pop r2
|
||||
pop r1
|
||||
ret
|
||||
convert_filename_fail:
|
||||
mov r0, 0
|
||||
pop r31
|
||||
pop r3
|
||||
pop r2
|
||||
pop r1
|
||||
ret
|
||||
convert_filename_output_string: data.fill 0, 12
|
||||
|
|
Loading…
Reference in New Issue
Block a user