Made the directory functions compatible with the Commander X16's DOS.
It's directory listing's last line says, "mb free."
This commit is contained in:
parent
43881afca2
commit
98f8064b83
5 changed files with 33 additions and 18 deletions
|
@ -191,6 +191,8 @@ unsigned char cbm_k_acptr (void);
|
||||||
unsigned char cbm_k_basin (void);
|
unsigned char cbm_k_basin (void);
|
||||||
void __fastcall__ cbm_k_bsout (unsigned char C);
|
void __fastcall__ cbm_k_bsout (unsigned char C);
|
||||||
unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
|
unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
|
||||||
|
unsigned char cbm_k_chrin (void);
|
||||||
|
void __fastcall__ cbm_k_chrout (unsigned char C);
|
||||||
void __fastcall__ cbm_k_ciout (unsigned char C);
|
void __fastcall__ cbm_k_ciout (unsigned char C);
|
||||||
unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
|
unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
|
||||||
void cbm_k_clall (void);
|
void cbm_k_clall (void);
|
||||||
|
@ -295,7 +297,15 @@ unsigned char __fastcall__ cbm_readdir (unsigned char lfn,
|
||||||
/* Reads one directory line into cbm_dirent structure.
|
/* Reads one directory line into cbm_dirent structure.
|
||||||
** Returns 0 if reading directory-line was successful.
|
** Returns 0 if reading directory-line was successful.
|
||||||
** Returns non-zero if reading directory failed, or no more file-names to read.
|
** Returns non-zero if reading directory failed, or no more file-names to read.
|
||||||
** Returns 2 on last line. Then, l_dirent->size = the number of "blocks free."
|
** Returns 2 on last line. Then, l_dirent->size = the number of "blocks free",
|
||||||
|
** "blocks used", or "mb free". Return codes:
|
||||||
|
** 0 = read file-name
|
||||||
|
** 1 = couldn't read directory
|
||||||
|
** 2 = read "blocks free", "blocks used", or "mb free"
|
||||||
|
** 3 = couldn't find start of file-name
|
||||||
|
** 4 = couldn't find end of file-name
|
||||||
|
** 5 = couldn't read file-type
|
||||||
|
** 6 = premature end of file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void __fastcall__ cbm_closedir (unsigned char lfn);
|
void __fastcall__ cbm_closedir (unsigned char lfn);
|
||||||
|
|
|
@ -2,14 +2,16 @@
|
||||||
; Ullrich von Bassewitz, 03.06.1999
|
; Ullrich von Bassewitz, 03.06.1999
|
||||||
;
|
;
|
||||||
; unsigned char cbm_k_basin (void);
|
; unsigned char cbm_k_basin (void);
|
||||||
|
; unsigned char cbm_k_chrin (void);
|
||||||
;
|
;
|
||||||
|
|
||||||
.include "cbm.inc"
|
.include "cbm.inc"
|
||||||
|
|
||||||
.export _cbm_k_basin
|
.export _cbm_k_basin, _cbm_k_chrin
|
||||||
|
|
||||||
|
|
||||||
_cbm_k_basin:
|
_cbm_k_basin:
|
||||||
|
_cbm_k_chrin:
|
||||||
jsr BASIN
|
jsr BASIN
|
||||||
ldx #0 ; Clear high byte
|
ldx #0 ; Clear high byte
|
||||||
rts
|
rts
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
; Ullrich von Bassewitz, 03.06.1999
|
; Ullrich von Bassewitz, 03.06.1999
|
||||||
;
|
;
|
||||||
; void __fastcall__ cbm_k_bsout (unsigned char C);
|
; void __fastcall__ cbm_k_bsout (unsigned char C);
|
||||||
|
; void __fastcall__ cbm_k_chrout (unsigned char C);
|
||||||
;
|
;
|
||||||
|
|
||||||
.include "cbm.inc"
|
.include "cbm.inc"
|
||||||
|
|
||||||
.export _cbm_k_bsout
|
.export _cbm_k_bsout, _cbm_k_chrout
|
||||||
|
|
||||||
_cbm_k_bsout = BSOUT
|
_cbm_k_bsout := BSOUT
|
||||||
|
_cbm_k_chrout := CHROUT
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
/* 2009-10-10 -- Version 0.3 */
|
/* 2009-10-10 -- Version 0.3 */
|
||||||
/* 2011-04-07 -- Version 0.4, groepaz */
|
/* 2011-04-07 -- Version 0.4, groepaz */
|
||||||
/* 2011-04-14 -- Version 0.5, Greg King */
|
/* 2011-04-14 -- Version 0.5, Greg King */
|
||||||
|
/* 2021-02-15 -- Version 0.6, Greg King */
|
||||||
|
|
||||||
/* Tested with floppy-drive and IDE64 devices. */
|
/* Tested with floppy-drive and IDE64 devices. */
|
||||||
/* Not tested with messed (buggy) directory listings. */
|
/* Not tested with messed (buggy) directory listings. */
|
||||||
|
@ -29,7 +30,7 @@ unsigned char cbm_opendir (unsigned char lfn, unsigned char device, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
const char* name = "$";
|
const char* name = "$";
|
||||||
|
|
||||||
/* The name used in cbm_open may optionally be passed */
|
/* The name used in cbm_open() optionally may be passed */
|
||||||
if (__argsize__ == 4) {
|
if (__argsize__ == 4) {
|
||||||
va_start (ap, device);
|
va_start (ap, device);
|
||||||
name = va_arg (ap, const char*);
|
name = va_arg (ap, const char*);
|
||||||
|
@ -76,9 +77,10 @@ unsigned char __fastcall__ cbm_readdir (unsigned char lfn, register struct cbm_d
|
||||||
|
|
||||||
byte = cbm_k_basin();
|
byte = cbm_k_basin();
|
||||||
switch (byte) {
|
switch (byte) {
|
||||||
|
/* "B" BLOCKS FREE/USED. */
|
||||||
/* "B" BLOCKS FREE. */
|
/* "M" MB FREE. */
|
||||||
case 'b':
|
case 'b':
|
||||||
|
case 'm':
|
||||||
/* Read until end; careless callers might call us again. */
|
/* Read until end; careless callers might call us again. */
|
||||||
while (!cbm_k_readst()) {
|
while (!cbm_k_readst()) {
|
||||||
cbm_k_basin();
|
cbm_k_basin();
|
||||||
|
@ -168,7 +170,6 @@ unsigned char __fastcall__ cbm_readdir (unsigned char lfn, register struct cbm_d
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = 0;
|
rv = 0;
|
||||||
goto ret_val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
** Ullrich von Bassewitz, 2012-05-30. Based on code by Groepaz.
|
** Based on code by Groepaz.
|
||||||
|
** 2012-05-30, Ullrich von Bassewitz
|
||||||
|
** 2021-02-15, Greg King
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,11 +54,13 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
||||||
/* Bump the directory offset and include the bytes for line-link and size */
|
/* Bump the directory offset and include the bytes for line-link and size */
|
||||||
dir->off += count + 4;
|
dir->off += count + 4;
|
||||||
|
|
||||||
/* End of directory is reached if the buffer contains "blocks free". It is
|
/* End of directory is reached if the buffer contains "blocks free/used" or
|
||||||
** sufficient here to check for the leading 'b'. buffer will contain at
|
** "mb free.". It is sufficient here to check for the leading 'b' and 'm'.
|
||||||
** least one byte if we come here.
|
** buffer will contain at least one byte if we come here.
|
||||||
*/
|
*/
|
||||||
if (buffer[0] == 'b') {
|
switch (buffer[0]) {
|
||||||
|
case 'b':
|
||||||
|
case 'm':
|
||||||
goto exitpoint;
|
goto exitpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +71,6 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
||||||
b = buffer;
|
b = buffer;
|
||||||
while (i < count) {
|
while (i < count) {
|
||||||
switch (s) {
|
switch (s) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
/* Searching for start of file name */
|
/* Searching for start of file name */
|
||||||
if (*b == '"') {
|
if (*b == '"') {
|
||||||
|
@ -127,6 +130,3 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
||||||
exitpoint:
|
exitpoint:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue