dos33: clear up some whitespace

This commit is contained in:
Vince Weaver 2016-12-07 19:47:42 -05:00
parent 2ebf3d489b
commit 6264373203

View File

@ -990,71 +990,81 @@ static int dump_sector(void) {
return 0; return 0;
} }
static int dos33_dump(int fd) { static int dos33_dump(int fd) {
int num_tracks,catalog_t,catalog_s,file,ts_t,ts_s,ts_total,track,sector;
int i,j;
int deleted=0;
char temp_string[BUFSIZ];
unsigned char tslist[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"); int num_tracks,catalog_t,catalog_s,file,ts_t,ts_s,ts_total;
dump_sector(); int track,sector;
printf("Startup Filename: "); int i,j;
for(i=0;i<30;i++) printf("%c",sector_buffer[0x75+i]&0x7f); int deleted=0;
printf("\n"); char temp_string[BUFSIZ];
unsigned char tslist[BYTES_PER_SECTOR];
dos33_read_vtoc(fd); int result;
printf("\nVTOC Sector:\n"); /* Read Track 1 Sector 9 */
dump_sector(); lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
printf("\n\n");
printf("VTOC INFORMATION:\n"); printf("Finding name of startup file, Track 1 Sector 9 offset $75\n");
catalog_t=sector_buffer[VTOC_CATALOG_T]; dump_sector();
catalog_s=sector_buffer[VTOC_CATALOG_S];
printf("\tFirst Catalog = %02X/%02X\n",catalog_t,catalog_s); printf("Startup Filename: ");
printf("\tDOS RELEASE = 3.%i\n",sector_buffer[VTOC_DOS_RELEASE]); for(i=0;i<30;i++) {
printf("\tDISK VOLUME = %i\n",sector_buffer[VTOC_DISK_VOLUME]); printf("%c",sector_buffer[0x75+i]&0x7f);
ts_total=sector_buffer[VTOC_MAX_TS_PAIRS]; }
printf("\tT/S pairs that will fit in T/S List = %i\n",ts_total); printf("\n");
printf("\tLast track where sectors were allocated = $%02X\n", dos33_read_vtoc(fd);
sector_buffer[VTOC_LAST_ALLOC_T]);
printf("\tDirection of track allocation = %i\n", printf("\nVTOC Sector:\n");
sector_buffer[VTOC_ALLOC_DIRECT]); dump_sector();
num_tracks=sector_buffer[VTOC_NUM_TRACKS]; printf("\n\n");
printf("\tNumber of tracks per disk = %i\n",num_tracks); printf("VTOC INFORMATION:\n");
printf("\tNumber of sectors per track = %i\n", catalog_t=sector_buffer[VTOC_CATALOG_T];
sector_buffer[VTOC_S_PER_TRACK]); catalog_s=sector_buffer[VTOC_CATALOG_S];
printf("\tNumber of bytes per sector = %i\n", printf("\tFirst Catalog = %02X/%02X\n",catalog_t,catalog_s);
(sector_buffer[VTOC_BYTES_PER_SH]<<8)+sector_buffer[VTOC_BYTES_PER_SL]); printf("\tDOS RELEASE = 3.%i\n",sector_buffer[VTOC_DOS_RELEASE]);
printf("\tDISK VOLUME = %i\n",sector_buffer[VTOC_DISK_VOLUME]);
printf("\nFree sector bitmap:\n"); ts_total=sector_buffer[VTOC_MAX_TS_PAIRS];
printf("\tTrack FEDCBA98 76543210\n"); printf("\tT/S pairs that will fit in T/S List = %i\n",ts_total);
for(i=0;i<num_tracks;i++) {
printf("\t $%02X: ",i); printf("\tLast track where sectors were allocated = $%02X\n",
for(j=0;j<8;j++) { sector_buffer[VTOC_LAST_ALLOC_T]);
if ((sector_buffer[VTOC_FREE_BITMAPS+(i*4)]<<j)&0x80) printf("."); printf("\tDirection of track allocation = %i\n",
else printf("U"); sector_buffer[VTOC_ALLOC_DIRECT]);
}
printf(" "); num_tracks=sector_buffer[VTOC_NUM_TRACKS];
for(j=0;j<8;j++) { printf("\tNumber of tracks per disk = %i\n",num_tracks);
if ((sector_buffer[VTOC_FREE_BITMAPS+(i*4)+1]<<j)&0x80) printf("."); printf("\tNumber of sectors per track = %i\n",
else printf("U"); sector_buffer[VTOC_S_PER_TRACK]);
} printf("\tNumber of bytes per sector = %i\n",
(sector_buffer[VTOC_BYTES_PER_SH]<<8)+
printf("\n"); sector_buffer[VTOC_BYTES_PER_SL]);
}
printf("\nFree sector bitmap:\n");
printf("\tTrack FEDCBA98 76543210\n");
for(i=0;i<num_tracks;i++) {
printf("\t $%02X: ",i);
for(j=0;j<8;j++) {
if ((sector_buffer[VTOC_FREE_BITMAPS+(i*4)]<<j)&0x80) {
printf(".");
}
else {
printf("U");
}
}
printf(" ");
for(j=0;j<8;j++) {
if ((sector_buffer[VTOC_FREE_BITMAPS+(i*4)+1]<<j)&0x80) {
printf(".");
}
else {
printf("U");
}
}
printf("\n");
}
repeat_catalog: repeat_catalog:
@ -1135,26 +1145,28 @@ continue_dump:;
return 0; return 0;
} }
int dos33_rename_hello(int fd, char *new_name) { /* ??? */
char buffer[BYTES_PER_SECTOR]; static int dos33_rename_hello(int fd, char *new_name) {
int i;
char buffer[BYTES_PER_SECTOR];
lseek(fd,DISK_OFFSET(1,9),SEEK_SET); int i;
read(fd,buffer,BYTES_PER_SECTOR);
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
for(i=0;i<30;i++) { read(fd,buffer,BYTES_PER_SECTOR);
if (i<strlen(new_name)) {
buffer[0x75+i]=new_name[i]|0x80; for(i=0;i<30;i++) {
} if (i<strlen(new_name)) {
else { buffer[0x75+i]=new_name[i]|0x80;
buffer[0x75+i]=' '|0x80; }
} else {
} buffer[0x75+i]=' '|0x80;
}
lseek(fd,DISK_OFFSET(1,9),SEEK_SET); }
write(fd,buffer,BYTES_PER_SECTOR);
lseek(fd,DISK_OFFSET(1,9),SEEK_SET);
return 0; write(fd,buffer,BYTES_PER_SECTOR);
return 0;
} }
static int display_help(char *name) { static int display_help(char *name) {
@ -1170,6 +1182,7 @@ static int display_help(char *name) {
printf("\tCATALOG\n"); printf("\tCATALOG\n");
printf("\tLOAD apple_file <local_file>\n"); printf("\tLOAD apple_file <local_file>\n");
printf("\tSAVE type local_file <apple_file>\n"); printf("\tSAVE type local_file <apple_file>\n");
printf("\tBSAVE type local_file <apple_file>\n");
printf("\tDELETE apple_file\n"); printf("\tDELETE apple_file\n");
printf("\tLOCK apple_file\n"); printf("\tLOCK apple_file\n");
printf("\tUNLOCK apple_file\n"); printf("\tUNLOCK apple_file\n");
@ -1185,20 +1198,21 @@ static int display_help(char *name) {
return 0; return 0;
} }
#define COMMAND_UNKNOWN 0 #define COMMAND_UNKNOWN 0
#define COMMAND_LOAD 1 #define COMMAND_LOAD 1
#define COMMAND_SAVE 2 #define COMMAND_SAVE 2
#define COMMAND_CATALOG 3 #define COMMAND_CATALOG 3
#define COMMAND_DELETE 4 #define COMMAND_DELETE 4
#define COMMAND_UNDELETE 5 #define COMMAND_UNDELETE 5
#define COMMAND_LOCK 6 #define COMMAND_LOCK 6
#define COMMAND_UNLOCK 7 #define COMMAND_UNLOCK 7
#define COMMAND_INIT 8 #define COMMAND_INIT 8
#define COMMAND_RENAME 9 #define COMMAND_RENAME 9
#define COMMAND_COPY 10 #define COMMAND_COPY 10
#define COMMAND_DUMP 11 #define COMMAND_DUMP 11
#define COMMAND_HELLO 12 #define COMMAND_HELLO 12
#define MAX_COMMAND 13 #define COMMAND_BSAVE 13
#define MAX_COMMAND 14
static struct command_type { static struct command_type {
int type; int type;
@ -1216,6 +1230,7 @@ static struct command_type {
{COMMAND_COPY,"COPY"}, {COMMAND_COPY,"COPY"},
{COMMAND_DUMP,"DUMP"}, {COMMAND_DUMP,"DUMP"},
{COMMAND_HELLO,"HELLO"}, {COMMAND_HELLO,"HELLO"},
{COMMAND_BSAVE,"BSAVE"},
}; };
static int lookup_command(char *name) { static int lookup_command(char *name) {
@ -1298,39 +1313,41 @@ int main(int argc, char **argv) {
/* Load a file from disk image to local machine */ /* Load a file from disk image to local machine */
case COMMAND_LOAD: case COMMAND_LOAD:
/* check and make sure we have apple_filename */ /* check and make sure we have apple_filename */
if (argc<4+extra_ops) { if (argc<4+extra_ops) {
fprintf(stderr,"Error! Need apple file_name\n"); fprintf(stderr,"Error! Need apple file_name\n");
fprintf(stderr,"%s %s LOAD apple_filename\n",argv[0],image); fprintf(stderr,"%s %s LOAD apple_filename\n",
goto exit_and_close; argv[0],image);
} goto exit_and_close;
/* Truncate filename if too long */ }
if (strlen(argv[firstarg+2])>30) { /* Truncate filename if too long */
fprintf(stderr,"Warning! Truncating %s to 30 chars\n", if (strlen(argv[firstarg+2])>30) {
argv[firstarg+2]); fprintf(stderr,"Warning! Truncating %s to 30 chars\n",
} argv[firstarg+2]);
strncpy(apple_filename,argv[firstarg+2],30); }
apple_filename[30]='\0'; strncpy(apple_filename,argv[firstarg+2],30);
apple_filename[30]='\0';
/* get output filename */ /* get output filename */
if (argc==5+extra_ops) { if (argc==5+extra_ops) {
strncpy(output_filename,argv[firstarg+3],BUFSIZ); strncpy(output_filename,argv[firstarg+3],BUFSIZ);
} }
else { else {
strncpy(output_filename,apple_filename,30); strncpy(output_filename,apple_filename,30);
} }
/* get the entry/track/sector for file */ /* get the entry/track/sector for file */
catalog_entry=dos33_check_file_exists(dos_fd, catalog_entry=dos33_check_file_exists(dos_fd,
apple_filename, apple_filename,
FILE_NORMAL); FILE_NORMAL);
if (catalog_entry<0) { if (catalog_entry<0) {
fprintf(stderr,"Error! %s not found!\n",apple_filename); fprintf(stderr,"Error! %s not found!\n",
goto exit_and_close; apple_filename);
} goto exit_and_close;
}
dos33_load_file(dos_fd,catalog_entry,output_filename); dos33_load_file(dos_fd,catalog_entry,output_filename);
break; break;
case COMMAND_CATALOG: case COMMAND_CATALOG: