From 9e41edbc48b85663236009cba2391df165dd1ee4 Mon Sep 17 00:00:00 2001 From: Jeff Armstrong Date: Wed, 5 Apr 2017 08:24:53 -0400 Subject: Initial import --- icreate.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100755 icreate.c (limited to 'icreate.c') diff --git a/icreate.c b/icreate.c new file mode 100755 index 0000000..7204282 --- /dev/null +++ b/icreate.c @@ -0,0 +1,120 @@ +/* Rainbow Image Utilities + * Copyright © 2008 Jeffrey Armstrong + * http://jeff.rainbow-100.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* icreate - A utility for creating a disk image file from an RX50 + * by Jeff Armstrong + */ + +#include +#include "rbfloppy.h" +#include "util.h" + +/* This method will return a blank (all \0) data buffer of 512 bytes + * for use when reading a specific sector fails. + */ +void blank_buffer(char *buffer, int length) +{ +int i; + + for(i=0;i \n"); + printf(" Source drive should be one of: A, B, C, D\n"); + printf("\nOptions:\n"); + printf(" /L = create image with logical sectors\n"); + return 0; + } + + /* Determine if logical addressing was requested */ + set_mode(MODE_PHYSICAL); + check_logical(argc, argv); + + printf("Creatting image using "); + if(get_mode() == MODE_LOGICAL) + printf("logical "); + else + printf("physical "); + printf("sectors.\n"); + + /* Open the target file to receive the disk image */ + fp = fopen(argv[1],"wb"); + if(fp == NULL) { + printf("Could not open image file:\n\t%s\n",argv[1]); + return 0; + } + + /* Determine drive */ + tmp = argv[2]; + drv = drive_id(tmp[0]); + if(drv < 0) { + printf("Could not process drive request %s\n",tmp); + return 0; + } + + /* Allocate a 512 byte buffer */ + data = (char *)malloc(BYTES_PER_SECTOR*sizeof(char)); + + printf("\nWriting floppy to %s ...\n",argv[1]); + floppy_errors = 0; + + for(track=0;track 1) + printf("\n%c%d floppy errors encountered during read.",007,floppy_errors); + + printf ("\n\nProcessing complete."); + + fclose(fp); + + free(data); + + return 0; +} -- cgit v1.2.3