From dc16365eeae145314aa3108de9ac007e24a5ea43 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 21 Sep 2012 00:51:25 -0400 Subject: [PATCH] Add commands to change name of HELLO program Both dos33 and mkdos33fs now support this --- CHANGES | 5 +++++ TODO | 1 + dos33.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---- mkdos33fs.c | 34 +++++++++++++++++++++++++----- 4 files changed, 90 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 0b225b16..5ce8c12b 100644 --- a/CHANGES +++ b/CHANGES @@ -44,3 +44,8 @@ RELEASE 0.0.8 + Fix some minor bugs RELEASE 0.0.10 + +21 September 2012 ++ Add -f option to mkdos33fs that lets you specify the name of + the HELLO file ++ Add HELLO option to dos33 that does something similar diff --git a/TODO b/TODO index 539e8e91..94def001 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ + pcx2hgr: error checking complain if not 140x160 or 140x192 diff --git a/dos33.c b/dos33.c index 5b7aac76..418680ea 100644 --- a/dos33.c +++ b/dos33.c @@ -959,7 +959,7 @@ keep_deleting: return 0; } -static int dump_sector() { +static int dump_sector(void) { int i,j; for(i=0;i<16;i++) { @@ -983,8 +983,19 @@ static int dos33_dump(int fd) { 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"); + dump_sector(); + printf("Startup Filename: "); + for(i=0;i<30;i++) printf("%c",sector_buffer[0x75+i]&0x7f); + printf("\n"); + dos33_read_vtoc(fd); + printf("\nVTOC Sector:\n"); dump_sector(); printf("\n\n"); @@ -1032,7 +1043,7 @@ repeat_catalog: lseek(fd,DISK_OFFSET(catalog_t,catalog_s),SEEK_SET); result=read(fd,sector_buffer,BYTES_PER_SECTOR); - dump_sector(sector_buffer); + dump_sector(); for(file=0;file<7;file++) { printf("\n\n"); @@ -1105,7 +1116,27 @@ continue_dump:; return 0; } - +int dos33_rename_hello(int fd, char *new_name) { + char buffer[BYTES_PER_SECTOR]; + int i; + + lseek(fd,DISK_OFFSET(1,9),SEEK_SET); + read(fd,buffer,BYTES_PER_SECTOR); + + for(i=0;i<30;i++) { + if (i30) { + fprintf(stderr,"Auto boot filename too long!\n"); + exit(1); + } + memcpy(boot_filename,optarg,strlen(optarg)); + for(i=strlen(optarg);i<30;i++) boot_filename[i]=' '; +// printf("Writing boot filename \"%s\"\n",boot_filename); + break; + case 'v': usage(argv[0],0); case 'h': usage(argv[0],1); @@ -92,7 +105,7 @@ int main(int argc, char **argv) { buffer=calloc(1,sizeof(char)*block_size); /* Open device */ - fd=open(device,O_WRONLY|O_CREAT,0666); + fd=open(device,O_RDWR|O_CREAT,0666); if (fd<0) { fprintf(stderr,"Error opening %s\n",device); goto end_of_program; @@ -119,6 +132,18 @@ int main(int argc, char **argv) { } close(dos_fd); + /* Set boot filename */ + + /* Track 1 sector 9 */ + lseek(fd,((1*num_sectors)+9)*block_size,SEEK_SET); + result=read(fd,buffer,block_size); + + /* filename begins at offset 75 */ + for(i=0;i<30;i++) { + buffer[0x75+i]=boot_filename[i]|0x80; + } + lseek(fd,((1*num_sectors)+9)*block_size,SEEK_SET); + result=write(fd,buffer,block_size); } /* clear buffer */ @@ -159,6 +184,7 @@ int main(int argc, char **argv) { buffer[VTOC_FREE_BITMAPS+2]=0x00; buffer[VTOC_FREE_BITMAPS+3]=0x00; + /* if copying dos reserve tracks 1 and 2 as well */ if (copy_dos) { buffer[VTOC_FREE_BITMAPS+4]=0x00; buffer[VTOC_FREE_BITMAPS+5]=0x00; @@ -176,8 +202,6 @@ int main(int argc, char **argv) { buffer[VTOC_FREE_BITMAPS+17*4+1]=0x00; buffer[VTOC_FREE_BITMAPS+17*4+2]=0x00; buffer[VTOC_FREE_BITMAPS+17*4+3]=0x00; - - /* Write out VTOC to disk */ lseek(fd,((17*num_sectors)+0)*block_size,SEEK_SET);