From bd9a62c1ce3355c59d76439904d45dd56da5d6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Thu, 23 Mar 2023 18:27:40 +0200 Subject: [PATCH] Properly access directory when launching files --- ponydos_static.inc | 2 ++ shell.asm | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ponydos_static.inc b/ponydos_static.inc index 58cb2cf..7775791 100644 --- a/ponydos_static.inc +++ b/ponydos_static.inc @@ -5,6 +5,8 @@ GLOBAL_DIRENTS equ 0x2000 FS_DIRENT_SIZE equ 32 FS_DIRENT_NAME_SIZE equ 30 +FS_DIRENT_NAME_OFFSET equ 2 +FS_DIRECTORY_DIRENTS equ 512/FS_DIRENT_SIZE FS_FILE_MAX_SIZE equ 128 COLUMNS equ 80 diff --git a/shell.asm b/shell.asm index 5659e59..f3f9799 100644 --- a/shell.asm +++ b/shell.asm @@ -396,6 +396,8 @@ click: sub ax, [si + window.y] jz .end dec ax + cmp ax, FS_DIRECTORY_DIRENTS + jae .end push ds @@ -406,9 +408,15 @@ click: mul bp mov si, GLOBAL_DIRENTS add si, ax - add si, 2 ; File name begins two bytes into the start of the dirent + + cmp word [si], 0 + jne .dirent_present + pop ds + jmp .end + .dirent_present: ; Copy file name to launch_filename + add si, FS_DIRENT_NAME_OFFSET mov di, launch_filename mov cx, FS_DIRENT_NAME_SIZE rep movsb @@ -752,11 +760,11 @@ print_ls: push cx push di - mov si, GLOBAL_DIRENTS + 2 + mov si, GLOBAL_DIRENTS + FS_DIRENT_NAME_OFFSET xor ax, ax ; Maximum filename size .name_loop: - cmp word [ds:si - 2], 0 + cmp word [ds:si - FS_DIRENT_NAME_OFFSET], 0 je .done_names push cx @@ -789,7 +797,7 @@ print_ls: add di, dx add si, FS_DIRENT_SIZE - cmp si, GLOBAL_DIRENTS + 0x200 + cmp si, GLOBAL_DIRENTS + FS_DIRECTORY_DIRENTS*FS_DIRENT_SIZE jge .done_names dec cx