From 68570ff2ad16808f1b3462b76af8e0b49882b7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Mon, 27 Mar 2023 12:39:22 +0300 Subject: [PATCH] Add a non-launchable-file error dialog to shell --- shell.asm | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/shell.asm b/shell.asm index e42c20b..a5cc345 100644 --- a/shell.asm +++ b/shell.asm @@ -20,6 +20,7 @@ endstruc WINDOW_ID_ICON equ 0 WINDOW_ID_FILE_WINDOW equ 1 WINDOW_ID_OOM_ERROR equ 2 +WINDOW_ID_LAUNCH_ERROR equ 3 WINDOW_MOVE equ 1 WINDOW_RESIZE equ 2 @@ -87,6 +88,12 @@ initialize: mov word [windows + WINDOW_ID_OOM_ERROR*window.size + window.y], 10 mov word [windows + WINDOW_ID_OOM_ERROR*window.size + window.data], oom_error_dialog + mov word [windows + WINDOW_ID_LAUNCH_ERROR*window.size + window.width], FS_DIRENT_NAME_SIZE-1 ; Size includes null terminator + mov word [windows + WINDOW_ID_LAUNCH_ERROR*window.size + window.height], 3 + mov word [windows + WINDOW_ID_LAUNCH_ERROR*window.size + window.x], 24 + mov word [windows + WINDOW_ID_LAUNCH_ERROR*window.size + window.y], 11 + mov word [windows + WINDOW_ID_LAUNCH_ERROR*window.size + window.data], launch_error_dialog + call request_redraw .end: @@ -551,14 +558,13 @@ launch: sub si, 4 mov di, bin_extension call strcmp - jne .end ; No, wrong extension + jne .not_launchable ; No, wrong extension mov si, launch_filename mov dx, 1 ; Don't create a new file if not found call PONYDOS_SEG:SYS_OPEN_FILE test ax, ax - ; TODO: Display an alert on file not being found - jz .end + jz .not_launchable push ax push cx @@ -609,6 +615,24 @@ launch: .end: ret + .not_launchable: + ; Copy filename into the launch error dialog + mov si, launch_filename + mov di, launch_error_dialog.filename + mov cx, FS_DIRENT_NAME_SIZE-1 + .loop: + lodsb + stosb + inc di + loop .loop + + ; Show dialog + mov ax, cs + add ax, WINDOW_ID_LAUNCH_ERROR + mov si, windows + WINDOW_ID_LAUNCH_ERROR*window.size + call show_window + ret + ; out: ; clobbers everything set_wallpaper: @@ -1072,12 +1096,26 @@ oom_error_dialog: db 'E', 0x0f, 'r', 0x0f, 'r', 0x0f, 'o', 0x0f, 'r', 0x0f times 13-5-1 db 0x00, 0x0f db 'x', 0x0f - db 'O', 0xf0, 'u', 0xf0, 't', 0xf0, ' ', 0xf0, 'o', 0xf0, 'f', 0xf0, ' ', 0xf0, 'm', 0xf0, 'e', 0xf0, 'm', 0xf0, 'o', 0xf0, 'r', 0xf0, 'y', 0xf0 + db 'O', 0xf0, 'u', 0xf0, 't', 0xf0, ' ', 0xf0, 'o', 0xf0, 'f', 0xf0 + db ' ', 0xf0, 'm', 0xf0, 'e', 0xf0, 'm', 0xf0, 'o', 0xf0, 'r', 0xf0 + db 'y', 0xf0 + +launch_error_dialog: + db 'E', 0x0f, 'r', 0x0f, 'r', 0x0f, 'o', 0x0f, 'r', 0x0f + times FS_DIRENT_NAME_SIZE-1-5-1 db 0x00, 0x0f + db 'x', 0x0f + db 'C', 0xf0, 'a', 0xf0, 'n', 0xf0, 'n', 0xf0, 'o', 0xf0, 't', 0xf0 + db ' ', 0xf0, 'l', 0xf0, 'a', 0xf0, 'u', 0xf0, 'n', 0xf0, 'c', 0xf0 + db 'h', 0xf0, ' ', 0xf0, 'f', 0xf0, 'i', 0xf0, 'l', 0xf0, 'e', 0xf0 + db ':', 0xf0 + times FS_DIRENT_NAME_SIZE-1-19 db 0x00, 0xf0 + .filename times FS_DIRENT_NAME_SIZE-1 db 0x00, 0xf0 windows: times window.size db 0 times window.size db 0 times window.size db 0 + times window.size db 0 launch_filename times FS_DIRENT_NAME_SIZE db 0