dos33: split off the dump code

This commit is contained in:
Vince Weaver 2021-03-29 16:28:14 -04:00
parent c3a278b76a
commit fc2c2f3f91
4 changed files with 363 additions and 388 deletions

View File

@ -15,9 +15,11 @@ char2hex.o: char2hex.c
dos33: dos33.o \
dos33_catalog.o \
dos33_dump.o \
dos33_vtoc_bitmap.o
$(CC) -o dos33 dos33.o \
dos33_catalog.o \
dos33_dump.o \
dos33_vtoc_bitmap.o $(LFLAGS)
dos33.o: dos33.c dos33.h
@ -68,6 +70,11 @@ dos33_catalog.o: dos33_catalog.c dos33.h
###
dos33_dump.o: dos33_dump.c dos33.h
$(CC) $(CFLAGS) -c dos33_dump.c
###
install:
cp dos33 dos33_raw mkdos33fs make_b dos33_text2ascii char2hex $(INSTALL_LOC)

View File

@ -759,391 +759,6 @@ keep_deleting:
return 0;
}
static int dump_sector(unsigned char *sector_buffer) {
int i,j;
for(i=0;i<16;i++) {
printf("$%02X : ",i*16);
for(j=0;j<16;j++) {
printf("%02X ",sector_buffer[i*16+j]);
}
printf("\n");
}
return 0;
}
static int dos33_dump(int fd) {
int num_tracks,catalog_t,catalog_s,file,ts_t,ts_s,ts_total;
int track,sector;
int i;
int deleted=0;
char temp_string[BUFSIZ];
unsigned char tslist[BYTES_PER_SECTOR],vtoc[BYTES_PER_SECTOR];
unsigned char sector_buffer[BYTES_PER_SECTOR];
int result;
/* Read Track 1 Sector 9 */
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
printf("Finding name of startup file, Track 1 Sector 9 offset $75\n");
dump_sector(sector_buffer);
printf("Startup Filename: ");
for(i=0;i<30;i++) {
printf("%c",sector_buffer[0x75+i]&0x7f);
}
printf("\n");
dos33_read_vtoc(fd,vtoc);
printf("\nVTOC Sector:\n");
dump_sector(vtoc);
printf("\n\n");
printf("VTOC INFORMATION:\n");
catalog_t=sector_buffer[VTOC_CATALOG_T];
catalog_s=sector_buffer[VTOC_CATALOG_S];
printf("\tFirst Catalog = %02X/%02X\n",catalog_t,catalog_s);
printf("\tDOS RELEASE = 3.%i\n",sector_buffer[VTOC_DOS_RELEASE]);
printf("\tDISK VOLUME = %i\n",sector_buffer[VTOC_DISK_VOLUME]);
ts_total=sector_buffer[VTOC_MAX_TS_PAIRS];
printf("\tT/S pairs that will fit in T/S List = %i\n",ts_total);
printf("\tLast track where sectors were allocated = $%02X\n",
sector_buffer[VTOC_LAST_ALLOC_T]);
printf("\tDirection of track allocation = %i\n",
sector_buffer[VTOC_ALLOC_DIRECT]);
num_tracks=sector_buffer[VTOC_NUM_TRACKS];
printf("\tNumber of tracks per disk = %i\n",num_tracks);
printf("\tNumber of sectors per track = %i\n",
sector_buffer[VTOC_S_PER_TRACK]);
printf("\tNumber of bytes per sector = %i\n",
(sector_buffer[VTOC_BYTES_PER_SH]<<8)+
sector_buffer[VTOC_BYTES_PER_SL]);
dos33_vtoc_dump_bitmap(sector_buffer,num_tracks);
repeat_catalog:
printf("\nCatalog Sector $%02X/$%02x\n",catalog_t,catalog_s);
lseek(fd,DISK_OFFSET(catalog_t,catalog_s),SEEK_SET);
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
printf("\tNext track/sector $%02X/$%02X (found at offsets $%02X/$%02X\n",
sector_buffer[CATALOG_NEXT_T],sector_buffer[CATALOG_NEXT_S],
CATALOG_NEXT_T,CATALOG_NEXT_S);
dump_sector(sector_buffer);
for(file=0;file<7;file++) {
printf("\n\n");
ts_t=sector_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_T))];
ts_s=sector_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_S))];
printf("%i+$%02X/$%02X - ",file,catalog_t,catalog_s);
deleted=0;
if (ts_t==0xff) {
printf("**DELETED** ");
deleted=1;
ts_t=sector_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME+0x1e))];
}
if (ts_t==0x00) {
printf("UNUSED!\n");
goto continue_dump;
}
dos33_filename_to_ascii(temp_string,
sector_buffer+(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME)),30);
for(i=0;i<strlen(temp_string);i++) {
if (temp_string[i]<0x20) {
printf("^%c",temp_string[i]+0x40);
}
else {
printf("%c",temp_string[i]);
}
}
printf("\n");
printf("\tLocked = %s\n",
sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f?
"YES":"NO");
printf("\tType = %c\n",
dos33_file_type(sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]));
printf("\tSize in sectors = %i\n",
sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+
(sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8));
repeat_tsl:
printf("\tT/S List $%02X/$%02X:\n",ts_t,ts_s);
if (deleted) goto continue_dump;
lseek(fd,DISK_OFFSET(ts_t,ts_s),SEEK_SET);
result=read(fd,&tslist,BYTES_PER_SECTOR);
for(i=0;i<ts_total;i++) {
track=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)];
sector=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)+1];
if ((track==0) && (sector==0)) printf(".");
else printf("\n\t\t%02X/%02X",track,sector);
}
ts_t=tslist[TSL_NEXT_TRACK];
ts_s=tslist[TSL_NEXT_SECTOR];
if (!((ts_s==0) && (ts_t==0))) goto repeat_tsl;
continue_dump:;
}
catalog_t=sector_buffer[CATALOG_NEXT_T];
catalog_s=sector_buffer[CATALOG_NEXT_S];
if (catalog_s!=0) {
file=0;
goto repeat_catalog;
}
printf("\n");
if (result<0) fprintf(stderr,"Error on I/O\n");
return 0;
}
static int dos33_showfree(int fd) {
int num_tracks,catalog_t,catalog_s,file,ts_t,ts_s,ts_total;
int track,sector;
int i,j;
int deleted=0;
char temp_string[BUFSIZ];
unsigned char tslist[BYTES_PER_SECTOR];
unsigned char vtoc[BYTES_PER_SECTOR];
unsigned char sector_buffer[BYTES_PER_SECTOR];
int result;
int sectors_per_track;
int catalog_used;
int next_letter='a';
struct file_key_type {
int ch;
char *filename;
} file_key[100];
int num_files=0;
unsigned char usage[35][16];
for(i=0;i<35;i++) for(j=0;j<16;j++) usage[i][j]=0;
/* Read Track 1 Sector 9 */
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
printf("Finding name of startup file, Track 1 Sector 9 offset $75\n");
printf("Startup Filename: ");
for(i=0;i<30;i++) {
printf("%c",sector_buffer[0x75+i]&0x7f);
}
printf("\n");
dos33_read_vtoc(fd,vtoc);
printf("\n");
printf("VTOC INFORMATION:\n");
catalog_t=sector_buffer[VTOC_CATALOG_T];
catalog_s=sector_buffer[VTOC_CATALOG_S];
printf("\tFirst Catalog = %02X/%02X\n",catalog_t,catalog_s);
printf("\tDOS RELEASE = 3.%i\n",sector_buffer[VTOC_DOS_RELEASE]);
printf("\tDISK VOLUME = %i\n",sector_buffer[VTOC_DISK_VOLUME]);
ts_total=sector_buffer[VTOC_MAX_TS_PAIRS];
printf("\tT/S pairs that will fit in T/S List = %i\n",ts_total);
printf("\tLast track where sectors were allocated = $%02X\n",
sector_buffer[VTOC_LAST_ALLOC_T]);
printf("\tDirection of track allocation = %i\n",
sector_buffer[VTOC_ALLOC_DIRECT]);
num_tracks=sector_buffer[VTOC_NUM_TRACKS];
printf("\tNumber of tracks per disk = %i\n",num_tracks);
printf("\tNumber of sectors per track = %i\n",
sector_buffer[VTOC_S_PER_TRACK]);
sectors_per_track=sector_buffer[VTOC_S_PER_TRACK];
printf("\tNumber of bytes per sector = %i\n",
(sector_buffer[VTOC_BYTES_PER_SH]<<8)+
sector_buffer[VTOC_BYTES_PER_SL]);
printf("\nFree sector bitmap:\n\n");
printf("\t 1111111111111111222\n");
printf("\t0123456789ABCDEF0123456789ABCDEF012\n");
for(j=0;j<sectors_per_track;j++) {
printf("$%01X:\t",j);
for(i=0;i<num_tracks;i++) {
if (j<8) {
if ((sector_buffer[VTOC_FREE_BITMAPS+(i*4)]<<j)&0x80) {
printf(".");
}
else {
printf("U");
}
}
else {
if ((sector_buffer[VTOC_FREE_BITMAPS+(i*4)+1]<<j)&0x80) {
printf(".");
}
else {
printf("U");
}
}
}
printf("\n");
}
printf("Key: U=used, .=free\n\n");
/* Reserve DOS */
for(i=0;i<3;i++) for(j=0;j<16;j++) usage[i][j]='$';
/* Reserve CATALOG (not all used?) */
i=0x11;
for(j=0;j<16;j++) usage[i][j]='#';
repeat_catalog:
catalog_used=0;
// printf("\nCatalog Sector $%02X/$%02x\n",catalog_t,catalog_s);
lseek(fd,DISK_OFFSET(catalog_t,catalog_s),SEEK_SET);
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
// dump_sector();
for(file=0;file<7;file++) {
// printf("\n\n");
ts_t=sector_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_T))];
ts_s=sector_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_S))];
// printf("%i+$%02X/$%02X - ",file,catalog_t,catalog_s);
deleted=0;
if (ts_t==0xff) {
printf("**DELETED** ");
deleted=1;
ts_t=sector_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME+0x1e))];
}
if (ts_t==0x00) {
// printf("UNUSED!\n");
goto continue_dump;
}
dos33_filename_to_ascii(temp_string,
sector_buffer+(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME)),
30);
for(i=0;i<strlen(temp_string);i++) {
if (temp_string[i]<0x20) {
printf("^%c",temp_string[i]+0x40);
}
else {
printf("%c",temp_string[i]);
}
}
printf("\n");
// printf("\tLocked = %s\n",
// sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f?
// "YES":"NO");
// printf("\tType = %c\n",
// dos33_file_type(sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]));
// printf("\tSize in sectors = %i\n",
// sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+
// (sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8));
if (!deleted) {
catalog_used++;
usage[catalog_t][catalog_s]='@';
}
repeat_tsl:
// printf("\tT/S List $%02X/$%02X:\n",ts_t,ts_s);
if (deleted) goto continue_dump;
usage[ts_t][ts_s]=next_letter;
file_key[num_files].ch=next_letter;
file_key[num_files].filename=strdup(temp_string);
num_files++;
lseek(fd,DISK_OFFSET(ts_t,ts_s),SEEK_SET);
result=read(fd,&tslist,BYTES_PER_SECTOR);
for(i=0;i<ts_total;i++) {
track=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)];
sector=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)+1];
if ((track==0) && (sector==0)) {
//printf(".");
}
else {
// printf("\n\t\t%02X/%02X",track,sector);
usage[track][sector]=toupper(next_letter);
}
}
ts_t=tslist[TSL_NEXT_TRACK];
ts_s=tslist[TSL_NEXT_SECTOR];
if (!((ts_s==0) && (ts_t==0))) goto repeat_tsl;
continue_dump:;
next_letter++;
}
catalog_t=sector_buffer[CATALOG_NEXT_T];
catalog_s=sector_buffer[CATALOG_NEXT_S];
if (catalog_s!=0) {
file=0;
goto repeat_catalog;
}
printf("\n");
if (result<0) fprintf(stderr,"Error on I/O\n");
printf("\nDetailed sector bitmap:\n\n");
printf("\t 1111111111111111222\n");
printf("\t0123456789ABCDEF0123456789ABCDEF012\n");
for(j=0;j<sectors_per_track;j++) {
printf("$%01X:\t",j);
for(i=0;i<num_tracks;i++) {
if (usage[i][j]==0) printf(".");
else printf("%c",usage[i][j]);
}
printf("\n");
}
printf("Key: $=DOS, @=catalog used, #=catalog reserved, .=free\n\n");
for(i=0;i<num_files;i++) {
printf("\t%c %s\n",file_key[i].ch,file_key[i].filename);
}
return 0;
}
/* ??? */
static int dos33_rename_hello(int fd, char *new_name) {
@ -1546,12 +1161,12 @@ int main(int argc, char **argv) {
case COMMAND_DUMP:
printf("Dumping %s!\n",image);
dos33_dump(dos_fd);
dos33_dump(vtoc,dos_fd);
break;
case COMMAND_SHOWFREE:
printf("Showing Free %s!\n",image);
dos33_showfree(dos_fd);
dos33_showfree(vtoc,dos_fd);
break;
case COMMAND_LOCK:

View File

@ -70,3 +70,7 @@ unsigned char dos33_char_to_type(char type, int lock);
void dos33_catalog(int dos_fd, unsigned char *vtoc);
char *dos33_filename_to_ascii(char *dest,unsigned char *src,int len);
unsigned char dos33_file_type(int value);
/* dos33_dump.c */
int dos33_dump(unsigned char *vtoc, int fd);
int dos33_showfree(unsigned char *vtoc, int fd);

View File

@ -0,0 +1,349 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "version.h"
#include "dos33.h"
static int dump_sector(unsigned char *sector_buffer) {
int i,j;
for(i=0;i<16;i++) {
printf("$%02X : ",i*16);
for(j=0;j<16;j++) {
printf("%02X ",sector_buffer[i*16+j]);
}
printf("\n");
}
return 0;
}
static void dump_vtoc(unsigned char *vtoc) {
int num_tracks,catalog_t,catalog_s,ts_total;
printf("\nVTOC Sector:\n");
dump_sector(vtoc);
printf("\n\n");
printf("VTOC INFORMATION:\n");
catalog_t=vtoc[VTOC_CATALOG_T];
catalog_s=vtoc[VTOC_CATALOG_S];
printf("\tFirst Catalog = %02X/%02X\n",catalog_t,catalog_s);
printf("\tDOS RELEASE = 3.%i\n",vtoc[VTOC_DOS_RELEASE]);
printf("\tDISK VOLUME = %i\n",vtoc[VTOC_DISK_VOLUME]);
ts_total=vtoc[VTOC_MAX_TS_PAIRS];
printf("\tT/S pairs that will fit in T/S List = %i\n",ts_total);
printf("\tLast track where sectors were allocated = $%02X\n",
vtoc[VTOC_LAST_ALLOC_T]);
printf("\tDirection of track allocation = %i\n",
vtoc[VTOC_ALLOC_DIRECT]);
num_tracks=vtoc[VTOC_NUM_TRACKS];
printf("\tNumber of tracks per disk = %i\n",num_tracks);
printf("\tNumber of sectors per track = %i\n",
vtoc[VTOC_S_PER_TRACK]);
printf("\tNumber of bytes per sector = %i\n",
(vtoc[VTOC_BYTES_PER_SH]<<8)+
vtoc[VTOC_BYTES_PER_SL]);
}
int dos33_dump(unsigned char *vtoc, int fd) {
int num_tracks,catalog_t,catalog_s,file,ts_t,ts_s,ts_total;
int track,sector;
int i;
int deleted=0;
char temp_string[BUFSIZ];
unsigned char tslist[BYTES_PER_SECTOR];
unsigned char catalog_buffer[BYTES_PER_SECTOR];
unsigned char data[BYTES_PER_SECTOR];
int result;
/* Read Track 1 Sector 9 */
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
result=read(fd,data,BYTES_PER_SECTOR);
printf("Finding name of startup file, Track 1 Sector 9 offset $75\n");
if (data[0x75]!=0) {
printf("Startup Filename: ");
for(i=0;i<30;i++) {
printf("%c",data[0x75+i]&0x7f);
}
printf("\n");
}
dump_vtoc(vtoc);
catalog_t=vtoc[VTOC_CATALOG_T];
catalog_s=vtoc[VTOC_CATALOG_S];
ts_total=vtoc[VTOC_MAX_TS_PAIRS];
num_tracks=vtoc[VTOC_NUM_TRACKS];
dos33_vtoc_dump_bitmap(vtoc,num_tracks);
repeat_catalog:
printf("\nCatalog Sector $%02X/$%02x\n",catalog_t,catalog_s);
lseek(fd,DISK_OFFSET(catalog_t,catalog_s),SEEK_SET);
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
printf("\tNext track/sector $%02X/$%02X (found at offsets $%02X/$%02X\n",
catalog_buffer[CATALOG_NEXT_T],catalog_buffer[CATALOG_NEXT_S],
CATALOG_NEXT_T,CATALOG_NEXT_S);
dump_sector(catalog_buffer);
for(file=0;file<7;file++) {
printf("\n\n");
ts_t=catalog_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_T))];
ts_s=catalog_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_S))];
printf("%i+$%02X/$%02X - ",file,catalog_t,catalog_s);
deleted=0;
if (ts_t==0xff) {
printf("**DELETED** ");
deleted=1;
ts_t=catalog_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME+0x1e))];
}
if (ts_t==0x00) {
printf("UNUSED!\n");
goto continue_dump;
}
dos33_filename_to_ascii(temp_string,
catalog_buffer+(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME)),30);
for(i=0;i<strlen(temp_string);i++) {
if (temp_string[i]<0x20) {
printf("^%c",temp_string[i]+0x40);
}
else {
printf("%c",temp_string[i]);
}
}
printf("\n");
printf("\tLocked = %s\n",
catalog_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f?
"YES":"NO");
printf("\tType = %c\n",
dos33_file_type(catalog_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]));
printf("\tSize in sectors = %i\n",
catalog_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+
(catalog_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8));
repeat_tsl:
printf("\tT/S List $%02X/$%02X:\n",ts_t,ts_s);
if (deleted) goto continue_dump;
lseek(fd,DISK_OFFSET(ts_t,ts_s),SEEK_SET);
result=read(fd,&tslist,BYTES_PER_SECTOR);
for(i=0;i<ts_total;i++) {
track=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)];
sector=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)+1];
if ((track==0) && (sector==0)) printf(".");
else printf("\n\t\t%02X/%02X",track,sector);
}
ts_t=tslist[TSL_NEXT_TRACK];
ts_s=tslist[TSL_NEXT_SECTOR];
if (!((ts_s==0) && (ts_t==0))) goto repeat_tsl;
continue_dump:;
}
catalog_t=catalog_buffer[CATALOG_NEXT_T];
catalog_s=catalog_buffer[CATALOG_NEXT_S];
if (catalog_s!=0) {
file=0;
goto repeat_catalog;
}
printf("\n");
if (result<0) fprintf(stderr,"Error on I/O\n");
return 0;
}
int dos33_showfree(unsigned char *vtoc, int fd) {
int num_tracks,catalog_t,catalog_s,file,ts_t,ts_s,ts_total;
int track,sector;
int i,j;
int deleted=0;
char temp_string[BUFSIZ];
unsigned char tslist[BYTES_PER_SECTOR];
unsigned char catalog_buffer[BYTES_PER_SECTOR];
int result;
int sectors_per_track;
int catalog_used;
int next_letter='a';
struct file_key_type {
int ch;
char *filename;
} file_key[100];
int num_files=0;
unsigned char usage[35][16];
for(i=0;i<35;i++) for(j=0;j<16;j++) usage[i][j]=0;
dump_vtoc(vtoc);
catalog_t=vtoc[VTOC_CATALOG_T];
catalog_s=vtoc[VTOC_CATALOG_S];
ts_total=vtoc[VTOC_MAX_TS_PAIRS];
num_tracks=vtoc[VTOC_NUM_TRACKS];
sectors_per_track=vtoc[VTOC_S_PER_TRACK];
dos33_vtoc_dump_bitmap(vtoc,num_tracks);
/* Reserve DOS */
for(i=0;i<3;i++) for(j=0;j<16;j++) usage[i][j]='$';
/* Reserve CATALOG (not all used?) */
i=0x11;
for(j=0;j<16;j++) usage[i][j]='#';
repeat_catalog:
catalog_used=0;
// printf("\nCatalog Sector $%02X/$%02x\n",catalog_t,catalog_s);
lseek(fd,DISK_OFFSET(catalog_t,catalog_s),SEEK_SET);
result=read(fd,catalog_buffer,BYTES_PER_SECTOR);
// dump_sector();
for(file=0;file<7;file++) {
// printf("\n\n");
ts_t=catalog_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_T))];
ts_s=catalog_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_TS_LIST_S))];
// printf("%i+$%02X/$%02X - ",file,catalog_t,catalog_s);
deleted=0;
if (ts_t==0xff) {
printf("**DELETED** ");
deleted=1;
ts_t=catalog_buffer[(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME+0x1e))];
}
if (ts_t==0x00) {
// printf("UNUSED!\n");
goto continue_dump;
}
dos33_filename_to_ascii(temp_string,
catalog_buffer+(CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_NAME)),
30);
for(i=0;i<strlen(temp_string);i++) {
if (temp_string[i]<0x20) {
printf("^%c",temp_string[i]+0x40);
}
else {
printf("%c",temp_string[i]);
}
}
printf("\n");
// printf("\tLocked = %s\n",
// sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]>0x7f?
// "YES":"NO");
// printf("\tType = %c\n",
// dos33_file_type(sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE)+FILE_TYPE]));
// printf("\tSize in sectors = %i\n",
// sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_L)]+
// (sector_buffer[CATALOG_FILE_LIST+(file*CATALOG_ENTRY_SIZE+FILE_SIZE_H)]<<8));
if (!deleted) {
catalog_used++;
usage[catalog_t][catalog_s]='@';
}
repeat_tsl:
// printf("\tT/S List $%02X/$%02X:\n",ts_t,ts_s);
if (deleted) goto continue_dump;
usage[ts_t][ts_s]=next_letter;
file_key[num_files].ch=next_letter;
file_key[num_files].filename=strdup(temp_string);
num_files++;
lseek(fd,DISK_OFFSET(ts_t,ts_s),SEEK_SET);
result=read(fd,&tslist,BYTES_PER_SECTOR);
for(i=0;i<ts_total;i++) {
track=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)];
sector=tslist[TSL_LIST+(i*TSL_ENTRY_SIZE)+1];
if ((track==0) && (sector==0)) {
//printf(".");
}
else {
// printf("\n\t\t%02X/%02X",track,sector);
usage[track][sector]=toupper(next_letter);
}
}
ts_t=tslist[TSL_NEXT_TRACK];
ts_s=tslist[TSL_NEXT_SECTOR];
if (!((ts_s==0) && (ts_t==0))) goto repeat_tsl;
continue_dump:;
next_letter++;
}
catalog_t=catalog_buffer[CATALOG_NEXT_T];
catalog_s=catalog_buffer[CATALOG_NEXT_S];
if (catalog_s!=0) {
file=0;
goto repeat_catalog;
}
printf("\n");
if (result<0) fprintf(stderr,"Error on I/O\n");
printf("\nDetailed sector bitmap:\n\n");
printf("\t 1111111111111111222\n");
printf("\t0123456789ABCDEF0123456789ABCDEF012\n");
for(j=0;j<sectors_per_track;j++) {
printf("$%01X:\t",j);
for(i=0;i<num_tracks;i++) {
if (usage[i][j]==0) printf(".");
else printf("%c",usage[i][j]);
}
printf("\n");
}
printf("Key: $=DOS, @=catalog used, #=catalog reserved, .=free\n\n");
for(i=0;i<num_files;i++) {
printf("\t%c %s\n",file_key[i].ch,file_key[i].filename);
}
return 0;
}