From b3df18bb0467268c3385cff9d8d709371c2ef975 Mon Sep 17 00:00:00 2001 From: shikhin Date: Sun, 19 Mar 2023 20:09:35 +0530 Subject: [PATCH] Switch from read_sectors to modify_sectors; return dirent in open_file --- extract_symbols.py | 2 +- ponydos.asm | 38 ++++++++++++++++++-------------------- ponydos_static.inc | 1 + shell.asm | 3 ++- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/extract_symbols.py b/extract_symbols.py index b0d64cf..ecd1e5e 100644 --- a/extract_symbols.py +++ b/extract_symbols.py @@ -2,7 +2,7 @@ import sys syscalls = { 'open_file': None, - 'read_sectors': None, + 'modify_sectors': None, 'draw_rect': None, } diff --git a/ponydos.asm b/ponydos.asm index 1a99f82..d008b44 100644 --- a/ponydos.asm +++ b/ponydos.asm @@ -11,7 +11,6 @@ org 0x7c00 COLUMNS equ 80 ROWS equ 25 -DIRENTS equ 0x2000 DIRENT_SIZE equ 32 FILE_MAX_SIZE equ 128 @@ -65,7 +64,8 @@ load_shell: mov si, shell_name call 0:open_file xor bx, bx - call 0:read_sectors + xor di, di ; read + call 0:modify_sectors ; TODO: error management? Surely this works... xor ax, ax ; WM_INITIALIZE @@ -231,11 +231,11 @@ flip_mouse_cursor: ;; bl = drive number ; cx = number of sectors to read (must be at least 1) ; es:bx = output buffer +; di = 0x0100 for write, 0x0000 for read ; [Far calls only] -read_sectors: +modify_sectors: pusha - xor di, di .loop: call modify_sector inc ax @@ -299,10 +299,10 @@ shell_name db 'shell.bin', 0 ; out: ; ax = LBA of first sector, 0 if no space left ; cx = length in sectors +; di = dirent address (in GLOBAL_DIRENTS) ; [Far calls only] open_file: push si - push di push bx push es @@ -319,7 +319,7 @@ open_file: mov es, ax ;mov ax, 1 mov al, 1 - mov bx, DIRENTS + mov bx, GLOBAL_DIRENTS xor di, di call modify_sector @@ -329,48 +329,46 @@ open_file: cmp word [es:di], 0 je .create_file + pusha inc di inc di - pusha repe cmpsb popa je .success add ax, FILE_MAX_SIZE - add di, DIRENT_SIZE - 2 - cmp di, DIRENTS + 0x200 + add di, DIRENT_SIZE + cmp di, GLOBAL_DIRENTS + 0x200 jl .loop .error: xor ax, ax - ; Return with mangled cx + ; Return with mangled cx, di .success: - mov cx, [es:di - 2] + mov cx, [es:di] .return: pop es pop bx - pop di pop si retf .create_file: ; TODO: zero out the sector for this file? inc word [es:di] + + pusha inc di inc di rep movsb - - push ax + mov ax, 1 - ;mov bx, DIRENTS + ;mov bx, GLOBAL_DIRENTS mov di, 0x0100 ; write call modify_sector - pop ax - - ;mov cx, 1 - mov cl, 1 - jmp .return + popa + + jmp .success ; ------------------------------------------------------------------ ; Mouse callback diff --git a/ponydos_static.inc b/ponydos_static.inc index d9005c9..1ec8106 100644 --- a/ponydos_static.inc +++ b/ponydos_static.inc @@ -1,6 +1,7 @@ PONYDOS_SEG equ 0 GLOBAL_WALLPAPER equ 0x500 +GLOBAL_DIRENTS equ 0x2000 WM_INITIALIZE equ 0 WM_PAINT equ 1 diff --git a/shell.asm b/shell.asm index 3430946..5387601 100644 --- a/shell.asm +++ b/shell.asm @@ -49,7 +49,8 @@ initialize: mov bp, PONYDOS_SEG mov es, bp mov bx, GLOBAL_WALLPAPER - call PONYDOS_SEG:SYS_READ_SECTORS + xor di, di ; read + call PONYDOS_SEG:SYS_MODIFY_SECTORS ; Put window 1 in the window chain mov ax, cs