Content-type: multipart/mixed; boundary="Boundary_(ID_OeE3Oas5+7smp4ol3E/h6Q)" --Boundary_(ID_OeE3Oas5+7smp4ol3E/h6Q) Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: 7BIT --Boundary_(ID_OeE3Oas5+7smp4ol3E/h6Q) Content-type: application/octet-stream; name=dwgh2b.c Content-transfer-encoding: 7bit Content-disposition: attachment; filename=dwgh2b.c // --------------------------------------------------- // hex2bin.c 21-May-11 Running on Mac OS X 10.6.6 // S/n 2011-1042-654321 Written by Douglas W. Goodall // Copyright(c)2011 Douglas W. Goodall, United States. // --------------------------------------------------- // This file is part of Vintage Modern Assembler Plus Tools. // // VMAPT 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. // // VMAPT 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 VMAPT. If not, see . // #include #include #include #define DATA_RECORD 0x00 #define EOF_RECORD 0x01 int main(int argc,char **argv) { char g_szBuffer2[128]; char szByteBuffer[2+1]; char *p; int i; int iTemp; char cColon; char szLength[2+1]; int iLength; char szAddress[4+1]; unsigned int uiAddress; char szRecordType[2+1]; unsigned char ucRecordType; char szData[80]; unsigned char ucBinBuffer[32+1]; char szChecksum[2+1]; unsigned char ucChecksum; unsigned int uiLastByte = 0; if(1 == argc) { printf("usage - hex2bin \n"); exit(EXIT_FAILURE); } char szBinFile[255]; char szHexFile[255]; strcpy(szHexFile,argv[1]); strcpy(szBinFile,argv[1]); strcat(szBinFile,".bin"); strcat(szHexFile,".hex"); unsigned char memory[0xfff0]; memset(memory,0,sizeof(memory)); FILE * fhex = fopen(szHexFile,"r"); if(NULL == fhex) { printf("Sorry, cannot open %s for input\n",szHexFile); exit(EXIT_FAILURE); } p = fgets(g_szBuffer2,sizeof(g_szBuffer2),fhex); while(NULL != p) { g_szBuffer2[strlen(g_szBuffer2)-1] = 0; cColon = g_szBuffer2[0]; memset(szLength,0,sizeof(szLength)); memcpy(szLength,&g_szBuffer2[1],2); sscanf(szLength,"%02X",&iLength); memset(szAddress,0,sizeof(szAddress)); memcpy(szAddress,&g_szBuffer2[3],4); sscanf(szAddress,"%04X",&uiAddress); memset(szRecordType,0,sizeof(szRecordType)); memcpy(szRecordType,&g_szBuffer2[7],2); sscanf(szRecordType,"%02X",&iTemp); ucRecordType = (unsigned char)iTemp; if(0 == ucRecordType) { memset(szData,0,sizeof(szData)); memcpy(szData,&g_szBuffer2[9],iLength*2); for(i=0;i

Here is my humble hex to binary converter

Douglas Goodall

On Nov 13, 2011, at 3:37 PM, Adam Courchesne wrote:

Hey guys,
I'm looking to use SDCC to develop some code for an Z80 based arcade game: Pole Position.

I have some sample C code that I've compiled and it looks like the compiler successfully compiled and linked everything but what I'm looking for is a resulting binary file that I can burn into the game's ROMs (or load up in MAME) to test it out. I see an intel HEX dump. Are there flags I can pass to the compiler to have it dump straight to a binary file?


"Please don't judge my God by my inability to follow him"  - Chris Mollins
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
Sdcc-user mailing list