2019-10-14 19:59:48 +02:00
|
|
|
; diskbuf needs to be defined
|
|
|
|
|
2019-10-08 19:54:39 +02:00
|
|
|
; User-accessible part of FCB (12 bytes)
|
2019-10-15 22:19:55 +02:00
|
|
|
fcb_drv: equ 0 ; 1 byte, 1=A: 2=B: 3=C:
|
|
|
|
fcb_fn: equ 1 ; 8 bytes
|
|
|
|
fcb_ext: equ 9 ; 3 bytes
|
2019-10-08 19:54:39 +02:00
|
|
|
|
2019-10-12 20:33:26 +02:00
|
|
|
; Drive & FS data (6 bytes)
|
2019-10-15 22:19:55 +02:00
|
|
|
fcb_spt: equ 12 ; byte sectors per track
|
|
|
|
fcb_nos: equ 13 ; byte number of sides/heads
|
|
|
|
fcb_ss: equ 14 ; byte sector size: 0=128, 1=256, 2=512, ...
|
|
|
|
fcb_cs: equ 15 ; byte cluster size: 0=128, 1=256, 2=512, ...
|
|
|
|
fcb_co: equ 16 ; word start sector for theoretical cluster 0
|
2019-10-12 20:33:26 +02:00
|
|
|
|
|
|
|
; Read/Write pointer (6 bytes)
|
2019-10-15 22:19:55 +02:00
|
|
|
fcb_left: equ 18 ; word number of bytes left to read from diskbuf
|
|
|
|
fcb_off: equ 20 ; dword offset in disk (not in file)
|
2019-10-12 20:33:26 +02:00
|
|
|
|
|
|
|
; Link to directory item (4 bytes)
|
2019-10-15 22:19:55 +02:00
|
|
|
fcb_ds: equ 24 ; dword offset of directory item
|
2019-10-12 20:33:26 +02:00
|
|
|
|
2019-10-15 22:19:55 +02:00
|
|
|
fcb_end: equ 32
|
2019-10-12 20:33:26 +02:00
|
|
|
|
2019-10-14 19:59:48 +02:00
|
|
|
fcb_open_rootdir:
|
2019-10-12 20:33:26 +02:00
|
|
|
mov dl, 0x01
|
|
|
|
mov [bx], dl
|
2019-09-29 23:25:29 +02:00
|
|
|
dec dl
|
|
|
|
|
2019-10-14 19:59:48 +02:00
|
|
|
; Setup default data
|
|
|
|
; Default 2 heads, 9 sectors
|
|
|
|
mov word [bx+fcb_spt], 0x0209
|
2019-10-08 19:54:39 +02:00
|
|
|
xor ax, ax
|
2019-10-14 19:59:48 +02:00
|
|
|
lea di, [bx+fcb_ss]
|
|
|
|
; Sector & Cluster size 128 bytes
|
|
|
|
mov cx, (fcb_end - fcb_ss)
|
2019-10-12 20:33:26 +02:00
|
|
|
rep stosb
|
|
|
|
|
2019-10-08 19:54:39 +02:00
|
|
|
; load first sector
|
|
|
|
call drive_read
|
|
|
|
|
2019-10-12 20:33:26 +02:00
|
|
|
; copy sector size
|
2019-10-08 19:54:39 +02:00
|
|
|
mov ax, [diskbuf + 0x0B]
|
2019-10-15 22:19:55 +02:00
|
|
|
; ... save as number of valid bytes in diskbuf
|
|
|
|
mov WORD [bx+fcb_left], ax
|
2019-10-08 19:54:39 +02:00
|
|
|
call log2
|
2019-10-12 20:33:26 +02:00
|
|
|
sub ax, 7
|
2019-10-15 22:19:55 +02:00
|
|
|
; ... save as sector size
|
2019-10-08 19:54:39 +02:00
|
|
|
mov byte [bx+fcb_ss], al
|
|
|
|
|
2019-10-12 20:33:26 +02:00
|
|
|
; copy cluster size
|
|
|
|
xor ah, ah
|
2019-10-08 19:54:39 +02:00
|
|
|
mov al, [diskbuf + 0x0D]
|
|
|
|
call log2
|
2019-10-12 20:33:26 +02:00
|
|
|
add al, [bx+fcb_ss]
|
2019-10-08 19:54:39 +02:00
|
|
|
mov byte [bx+fcb_cs], al
|
|
|
|
|
2019-10-15 22:19:55 +02:00
|
|
|
; copy sectors per track
|
2019-10-08 19:54:39 +02:00
|
|
|
mov al, [diskbuf + 0x18]
|
|
|
|
mov byte [bx+fcb_spt], al
|
|
|
|
|
2019-10-15 22:19:55 +02:00
|
|
|
; copy number of heads/sides
|
2019-10-08 19:54:39 +02:00
|
|
|
mov al, [diskbuf + 0x1A]
|
|
|
|
mov byte [bx+fcb_nos], al
|
2019-09-29 23:25:29 +02:00
|
|
|
|
2019-10-12 20:33:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
fcb_get_sector_mask:
|
|
|
|
push cx
|
|
|
|
xor ax, ax
|
|
|
|
not ax
|
|
|
|
mov cl, [bx+fcb_ss]
|
|
|
|
add cl, 7
|
|
|
|
shl ax, cl
|
|
|
|
pop cx
|
|
|
|
ret
|
|
|
|
|
|
|
|
fcb_getc:
|
|
|
|
push bx
|
|
|
|
call fcb_get_sector_mask
|
|
|
|
not ax
|
|
|
|
and ax, [bx+fcb_off]
|
|
|
|
xchg ax, bx
|
|
|
|
add bx, diskbuf
|
|
|
|
mov al, [bx]
|
|
|
|
pop bx
|
|
|
|
add word [bx+fcb_off], 1
|
|
|
|
adc word [bx+fcb_off+2], 0
|
|
|
|
dec word [bx+fcb_left]
|
2019-09-29 14:23:39 +02:00
|
|
|
ret
|