diff --git a/Makefile b/Makefile index 818b404..c8cf3c8 100644 --- a/Makefile +++ b/Makefile @@ -11,19 +11,28 @@ CC65LIBDIR = $(CC65DIR)/lib CC65INCDIR = $(CC65DIR)/include CA65INCDIR = $(CC65DIR)/asminc -all: sortdir.po sortdir.system\#ff0000 +all: sortdir.po sortdir.system\#ff0000 disconn.system\#ff0000 clean: - rm -f *.s *.o *.map sortdir + rm -f *.s *.o *.map sortdir.system* disconn.system* sortdir.o: sortdir.c $(CC65BINDIR)/cc65 -I $(CC65INCDIR) -t apple2enh -D A2E -o sortdir.s sortdir.c $(CC65BINDIR)/ca65 -I $(CA65INCDIR) -t apple2enh sortdir.s +disconn.o: disconn.c + $(CC65BINDIR)/cc65 -I $(CC65INCDIR) -t apple2enh -o disconn.s disconn.c + $(CC65BINDIR)/ca65 -I $(CA65INCDIR) -t apple2enh disconn.s + sortdir.system\#ff0000: sortdir.o $(CC65BINDIR)/ld65 -m sortdir.map -o sortdir.system\#ff0000 -C apple2enh-system.cfg sortdir.o $(CC65LIBDIR)/apple2enh.lib -sortdir.po: sortdir.system\#ff0000 +disconn.system\#ff0000: disconn.o + $(CC65BINDIR)/ld65 -m disconn.map -o disconn.system\#ff0000 -C apple2enh-system.cfg disconn.o $(CC65LIBDIR)/apple2enh.lib + +sortdir.po: sortdir.system\#ff0000 disconn.system\#ff0000 cadius deletefile sortdir.po /p8.2.5/sortdir.system cadius addfile sortdir.po /p8.2.5 sortdir.system\#ff0000 + cadius deletefile sortdir.po /p8.2.5/disconn.system + cadius addfile sortdir.po /p8.2.5 disconn.system\#ff0000 diff --git a/disconn.c b/disconn.c new file mode 100644 index 0000000..46c3b2e --- /dev/null +++ b/disconn.c @@ -0,0 +1,59 @@ +// +// Very simple utility which just disconnects any drives mapped to slot 1 +// Bobbi September 2020 +// + +#include +#include +#include + +/* + * Disconnect drives from slot 1 + */ +void disconnect_slot1(void) { + uint8_t i, j; + uint8_t *devcnt = (uint8_t*)0xbf31; // Number of devices + uint8_t *devlst = (uint8_t*)0xbf32; // Disk device numbers + uint16_t *s0d1 = (uint16_t*)0xbf10; // s0d1 driver vector + uint16_t *s1d1 = (uint16_t*)0xbf12; // s3d1 driver vector + uint16_t *s1d2 = (uint16_t*)0xbf22; // s3d2 driver vector + if (*s0d1 == *s1d2) + goto s1d1; // No s1d2 + for (i = 0; i <= *devcnt; ++i) + if ((devlst[i] & 0xf0) == 0x90) { + for (j = i; j <= *devcnt; ++j) + devlst[j] = devlst[j + 1]; + break; + } + *s1d2 = *s0d1; + --(*devcnt); +s1d1: + if (*s0d1 == *s1d1) + return; // No s1d1 + for (i = 0; i <= *devcnt; ++i) + if ((devlst[i] & 0xf0) == 0x10) { + for (j = i; j <= *devcnt; ++j) + devlst[j] = devlst[j + 1]; + break; + } + *s1d1 = *s0d1; + --(*devcnt); +} + +void main(void) { + char c; + printf("*********************************\n"); + printf("** Will disconnect any drives **\n"); + printf("** mapped to slot 1 **\n"); + printf("*********************************\n\n"); + printf(" Press [D] to disconnect drives\n"); + printf(" Any other key to cancel\n"); + c = cgetc(); + if ((c == 'd') || (c == 'D')) { + disconnect_slot1(); + printf("\n** Done.\n"); + } else { + printf("\n** Cancelled.\n"); + } +} + diff --git a/sortdir.po b/sortdir.po index 7272cc8..e4d947a 100644 Binary files a/sortdir.po and b/sortdir.po differ