Skip to content

Commit

Permalink
vdfs: add a PWD command to print current directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Fosdick committed Nov 27, 2023
1 parent ac1baae commit d2de210
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/vdfs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ prtextws = &A8
equw cmd_build ; *BUILD
equw cmd_append ; *APPEND.
equw opt1_print
equw print_split
.dispend

; Stubs to transfer control to the vdfs.c module.
Expand Down Expand Up @@ -666,6 +667,19 @@ prtextws = &A8
lda #&01
rts

.print_split
{
ldy #0
.loop lda (&a8),y
beq done
jsr OSWRCH
iny
bne loop
inc &a9
bne loop
.done rts
}

; The *DUMP command.

.cmd_dump
Expand Down
36 changes: 35 additions & 1 deletion src/vdfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ enum vdfs_action {
VDFS_ROM_BUILD,
VDFS_ROM_APPEND,
VDFS_ROM_OPT1,
VDFS_ROM_PRINT_SPLIT,
VDFS_ACT_NOP,
VDFS_ACT_QUIT,
VDFS_ACT_SRLOAD,
Expand Down Expand Up @@ -273,7 +274,8 @@ enum vdfs_action {
VDFS_ACT_MMBDIN,
VDFS_ACT_DRIVE,
VDFS_ACT_ACCESS,
VDFS_ACT_COPY
VDFS_ACT_COPY,
VDFS_ACT_PWD
};

/*
Expand Down Expand Up @@ -3695,6 +3697,34 @@ static void cmd_drive(uint16_t addr)
adfs_error(err_badparms);
}

static uint16_t cmd_pwd_recurse(uint16_t addr, vdfs_entry *ent)
{
vdfs_entry *parent = ent->parent;
if (parent && parent != ent)
addr = cmd_pwd_recurse(addr, parent);
const char *ptr = ent->acorn_fn;
int ch;
while ((ch = *ptr++))
writemem(addr++, ch);
writemem(addr++, '.');
return addr;
}

static void cmd_pwd(void)
{
if (check_valid_dir(&cur_dir)) {
int romno = readmem(0xf4);
uint16_t addr = (rom_slots[romno & 0x0f].split) << 8;
log_debug("vdfs: cmd_pwd, addr=%04X\n", addr);
writemem16(0xa8, addr);
addr = cmd_pwd_recurse(addr, cur_dir.dir);
writemem(addr-1, 0x0d);
writemem(addr, 0x0a);
writemem(addr+1, 0);
rom_dispatch(VDFS_ROM_PRINT_SPLIT);
}
}

static void cmd_title(uint16_t addr)
{
if (check_valid_dir(&cur_dir)) {
Expand Down Expand Up @@ -3854,6 +3884,7 @@ const struct cmdent ctab_filing[] = {
{ "LIB", VDFS_ACT_LIB },
{ "MAP", VDFS_ACT_NOP },
{ "MOunt", VDFS_ACT_NOP },
{ "PWD", VDFS_ACT_PWD },
{ "OSW7f", VDFS_ACT_OSW7F },
{ "REname", VDFS_ACT_RENAME },
{ "REScan", VDFS_ACT_RESCAN },
Expand Down Expand Up @@ -4516,6 +4547,9 @@ static bool vdfs_do(enum vdfs_action act, uint16_t addr)
case VDFS_ACT_LIB:
cmd_lib(addr);
break;
case VDFS_ACT_PWD:
cmd_pwd();
break;
case VDFS_ACT_RENAME:
rename_file(addr);
break;
Expand Down

0 comments on commit d2de210

Please sign in to comment.