Skip to content

Commit

Permalink
reorg xattr, client compat profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
bkw777 committed Jan 23, 2025
1 parent e4936fd commit 81a9991
Show file tree
Hide file tree
Showing 7 changed files with 476 additions and 289 deletions.
104 changes: 71 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ APP_NAME := DeskLink2
APP_LIB_DIR := $(PREFIX)/lib/$(NAME)
APP_DOC_DIR := $(PREFIX)/share/doc/$(NAME)
APP_VERSION := $(shell git describe --long 2>&-)
#FB100_ROM := Brother_FB-100.rom # no use yet
TPDD2_ROM := TANDY_26-3814.rom

DEFAULT_BASIC_BYTE_MS := 8 # ms per byte in bootstrap
DEFAULT_MODEL := 1 # 1=tpdd1 2=tpdd2 (TS-DOS directory support requires tpdd1)
DEFAULT_OPERATION_MODE := 1 # 0=FDC-mode 1=Operation-mode
DEFAULT_BAUD := 19200
DEFAULT_RTSCTS := false
DEFAULT_UPCASE := false
DEFAULT_DOTPOS := 6 # default 6.2 filenames compatible with Floppy/TS-DOS/etc.
DEFAULT_TILDES := true
DEFAULT_ATTR := 0x46 # default attribute 'F' compatible with Floppy/TS-DOS/etc.
RAW_ATTR := 0x20 # attr for "raw" mode, 0x00, 0x20, 0x46 are all plausible.
XATTR_NAME := pdd.attr
DEFAULT_DME_ROOT_LABEL := "0: "
DEFAULT_DME_PARENT_LABEL := "^ "
# optional configurables
#FB100_ROM := Brother_FB-100.rom # exists but not used
TPDD2_ROM := TANDY_26-3814.rom
#DEFAULT_BASIC_BYTE_MS := 8 # ms per byte in bootstrap
#DEFAULT_MODEL := 1 # 1=tpdd1 2=tpdd2 (TS-DOS directory support requires tpdd1)
#DEFAULT_OPERATION_MODE := 1 # 0=FDC-mode 1=Operation-mode
#DEFAULT_BAUD := 19200
#DEFAULT_RTSCTS := false
#DEFAULT_UPCASE := false
#DEFAULT_PROFILE := "k85" # k85 = Floppy/TS-DOS/etc - 6.2, dme, magic files
#DEFAULT_BASELEN := 6 # default 6.2 filenames compatible with Floppy/TS-DOS/etc.
#DEFAULT_EXTLEN := 2
#DEFAULT_ATTR := 0x46 # default attribute 'F' compatible with Floppy/TS-DOS/etc.
#RAW_ATTR := 0x20 # attr for "raw" mode, drive firmware fills unused fields with 0x20
#DEFAULT_TILDES := true
#XATTR_NAME := pdd.attr
#TSDOS_ROOT_LABEL := "0: "
#TSDOS_PARENT_LABEL := "^ "

CLIENT_LOADERS := \
clients/teeny/TINY.100 \
Expand Down Expand Up @@ -71,8 +74,8 @@ CLIENT_DOCS := \
# clients/power-dos/powr-d.txt

DOCS := dl.do README.txt README.md LICENSE $(CLIENT_DOCS)
SOURCES := dl.c dir_list.c
HEADERS := dir_list.h constants.h
SOURCES := dl.c dir_list.c xattr.c
HEADERS := constants.h dir_list.h xattr.h

ifeq ($(OS),Darwin)
TTY_PREFIX := cu.usbserial
Expand All @@ -93,37 +96,72 @@ ifeq ($(OS),Windows_NT)
CFLAGS += -D_WIN
endif

DEFINES := \
DEFS = \
-DAPP_NAME=\"$(APP_NAME)\" \
-DAPP_VERSION=\"$(APP_VERSION)\" \
-DAPP_LIB_DIR=\"$(APP_LIB_DIR)\" \
-DTTY_PREFIX=\"$(TTY_PREFIX)\" \
-DDEFAULT_DME_ROOT_LABEL=\"$(DEFAULT_DME_ROOT_LABEL)\" \
-DDEFAULT_DME_PARENT_LABEL=\"$(DEFAULT_DME_PARENT_LABEL)\" \
-DTPDD2_ROM=\"$(TPDD2_ROM)\" \
-DDEFAULT_BASIC_BYTE_MS=$(DEFAULT_BASIC_BYTE_MS) \
-DDEFAULT_MODEL=$(DEFAULT_MODEL) \
-DDEFAULT_OPERATION_MODE=$(DEFAULT_OPERATION_MODE) \
-DDEFAULT_BAUD=$(DEFAULT_BAUD) \
-DDEFAULT_RTSCTS=$(DEFAULT_RTSCTS) \
-DDEFAULT_UPCASE=$(DEFAULT_UPCASE) \
-DDEFAULT_DOTPOS=$(DEFAULT_DOTPOS) \
-DDEFAULT_TILDES=$(DEFAULT_TILDES) \
-DDEFAULT_ATTR=$(DEFAULT_ATTR) \
-DRAW_ATTR=$(RAW_ATTR) \
-DXATTR_NAME=\"$(XATTR_NAME)\" \
# -DUSE_XATTR \
-DUSE_XATTR \
# -DPRINT_8BIT \
# -DNADSBOX_EXTENSIONS \
ifdef TSDOS_ROOT_LABEL
DEFS += -DTSDOS_ROOT_LABEL=\"$(TSDOS_ROOT_LABEL)\"
endif
ifdef TSDOS_PARENT_LABEL
DEFS += -DTSDOS_PARENT_LABEL=\"$(TSDOS_PARENT_LABEL)\"
endif
ifdef DEFAULT_BASIC_BYTE_MS
DEFS += -DDEFAULT_BASIC_BYTE_MS=$(DEFAULT_BASIC_BYTE_MS)
endif
ifdef DEFAULT_MODEL
DEFS += -DDEFAULT_MODEL=$(DEFAULT_MODEL)
endif
ifdef DEFAULT_OPERATION_MODE
DEFS += -DDEFAULT_OPERATION_MODE=$(DEFAULT_OPERATION_MODE)
endif
ifdef DEFAULT_BAUD
DEFS += -DDEFAULT_BAUD=$(DEFAULT_BAUD)
endif
ifdef DEFAULT_RTSCTS
DEFS += -DDEFAULT_RTSCTS=$(DEFAULT_RTSCTS)
endif
ifdef DEFAULT_UPCASE
DEFS += -DDEFAULT_UPCASE=$(DEFAULT_UPCASE)
endif
ifdef DEFAULT_PROFILE
DEFS += -DDEFAULT_PROFILE=$(DEFAULT_PROFILE)
endif
ifdef DEFAULT_BASELEN
DEFS += -DDEFAULT_BASELEN=$(DEFAULT_BASELEN)
endif
ifdef DEFAULT_EXTLEN
DEFS += -DDEFAULT_EXTLEN=$(DEFAULT_EXTLEN)
endif
ifdef DEFAULT_ATTR
DEFS += -DDEFAULT_ATTR=$(DEFAULT_ATTR)
endif
ifdef RAW_ATTR
DEFS += -DRAW_ATTR=$(RAW_ATTR)
endif
ifdef DEFAULT_TILDES
DEFS += -DDEFAULT_TILDES=$(DEFAULT_TILDES)
endif
ifdef XATTR_NAME
DEFS += -DXATTR_NAME=\"$(XATTR_NAME)\"
endif

DEFINES := $(DEFS)

ifdef DEBUG
CFLAGS += -g
endif

.PHONY: all
all: $(NAME)

$(NAME): $(SOURCES) $(HEADERS)
$(NAME): Makefile $(SOURCES) $(HEADERS)
$(CC) $(CFLAGS) $(CXXFLAGS) $(DEFINES) $(SOURCES) $(LDLIBS) -o $(@)

install: $(NAME) $(CLIENT_LOADERS) $(LIB_OTHER) $(DOCS)
Expand Down
16 changes: 13 additions & 3 deletions constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,20 @@ static const uint16_t FDC_LOGICAL_SECTOR_SIZE[7] = {64,80,128,256,512,1024,1280}
#define OPR_CMD_SYNC 0x5A
#define FDC_CMD_EOL 0x0D

// compatibility modes
#define DOT_FLOPPY 6
#define DOT_WP2 8
// drive operating modes
#define MODE_OPR 1
#define MODE_FDC 0

#ifdef RAW_ATTR
#define ATTR_RAW RAW_ATTR
#else
#define ATTR_RAW 0x20 // space - drive firmware fills unused with 0x20
#endif

#ifdef DEFAULT_ATTR
#define ATTR_DEF DEFAULT_ATTR
#else
#define ATTR_DEF 0x46 // F - almost all clients on all platforms hardcode F
#endif

#endif // PDD_CONSTANTS_H
13 changes: 7 additions & 6 deletions dir_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ MA 02111, USA.
#include <strings.h>
#include <string.h>
#include <ctype.h>

#include "dir_list.h"

static uint16_t allocated;
Expand All @@ -33,9 +34,9 @@ static FILE_ENTRY* tblp = 0;
static FILE_ENTRY* current_record(void);

int file_list_init() {
tblp = malloc(sizeof(FILE_ENTRY)*FEQ);
tblp = malloc(sizeof(FILE_ENTRY)*DIRENTS);
if (!tblp) return -1;
allocated = FEQ;
allocated = DIRENTS;
ndx = 0;
cur = 0;
return 0;
Expand All @@ -53,14 +54,14 @@ int file_list_cleanup() {
void file_list_clear_all() {
cur = ndx = 0;
}

int add_file(FILE_ENTRY* fe) {
/* allocate FEQ more records if out of space */
/* allocate DIRENTS more records if out of space */
if (ndx >= allocated) {
/* resize the array */
tblp = realloc(tblp, (allocated+FEQ)*sizeof(FILE_ENTRY));
tblp = realloc(tblp, (allocated+DIRENTS)*sizeof(FILE_ENTRY));
if (!tblp) return -1;
allocated += FEQ;
allocated += DIRENTS;
}

/* reference the entry */
Expand Down
5 changes: 1 addition & 4 deletions dir_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ MA 02111, USA.
#include <stdint.h>
#include "constants.h"

#define FEQ DIRENTS // number of FILE_ENTRYs to malloc for at a time

typedef struct
{
typedef struct {
char client_fname[TPDD_FILENAME_LEN+1];
char local_fname[LOCAL_FILENAME_MAX+1];
uint8_t attr;
Expand Down
Loading

0 comments on commit 81a9991

Please sign in to comment.