/* int2tap - Convert an Intel segment file to a loadable Spectrum tape file Copyright (C) 2004 Ian Cowburn (ianc@noddybox.demon.co.uk) 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ------------------------------------------------------------------------- $Name$ */ static const char id[]="$Id$"; #include #include #include #include "intel.h" #include "tap.h" #include "basic.h" /* ---------------------------------------- GLOBALS */ #undef TRUE #undef FALSE #define TRUE 1 #define FALSE 0 const char *progname; /* ---------------------------------------- PRIVATE UTILS */ static void Usage(void) { fprintf(stderr,"%s: usage %s [-b] [-s] [-a addr] [-c addr] " "output-file input-file ... \n",progname,progname); exit(EXIT_FAILURE); } static unsigned ToUnsigned(const char *p) { char *end; unsigned u; u=(unsigned)strtoul(p,&end,0); if (end==p || *end!=0) { fprintf(stderr,"%s: invalid number %s\n",progname,p); exit(EXIT_FAILURE); } return u; } /* ---------------------------------------- MAIN */ int main(int argc, char *argv[]) { unsigned char mem[0x10000]; IntelInfo *info; char *outname; unsigned exec_addr; unsigned clear_addr; int addr_defined; int clear_defined; int bin_only; int split; int base; int no; int f; int done; /* Set program name */ if ((progname=strrchr(argv[0],'/'))) { progname++; } else { progname=argv[0]; } /* Set defaults and parse args */ addr_defined=FALSE; clear_defined=FALSE; bin_only=FALSE; split=FALSE; done=FALSE; f=1; while(fargc-2) { Usage(); } addr_defined=TRUE; exec_addr=ToUnsigned(argv[++f]); break; case 'c': if (f>argc-2) { Usage(); } clear_defined=TRUE; clear_addr=ToUnsigned(argv[++f]); break; default: Usage(); break; } f++; } } if (base>=argc-1) { Usage(); } outname=argv[base++]; no=argc-base; if (!(info=malloc(sizeof *info * no))) { fprintf(stderr,"%s: malloc failed\n",progname); } /* Process Intel files */ for(f=0;fhigh) { high=info[f].high; } } TapBinary(mem,low,high-low+1); } TapClose(); return EXIT_SUCCESS; } /* END OF FILE */