This commit is contained in:
2024-08-07 09:12:07 -04:00
parent ca445435a0
commit fdfadd5c7e
1021 changed files with 73601 additions and 0 deletions

47
as68hc11/S19Generator.cpp Normal file
View File

@@ -0,0 +1,47 @@
#include <as68hc11/S19Generator.hpp>
bool S19Generator::generateCode(PureViewOfFile &rawCode,const String &strPathOutput)
{
File outFile;
DWORD genBytes=0;
String endLine;
endLine="S9030000FC";
rawCode.rewind();
if(!outFile.open(strPathOutput,"wb"))return false;
generateLines(rawCode.tell(),rawCode.size(),rawCode,outFile);
outFile.writeLine(endLine);
::OutputDebugString(endLine+String("\r\n"));
return false;
}
void S19Generator::generateLines(DWORD origin,DWORD codeSize,PureViewOfFile &rawCode,File &outFile)
{
String strByte;
BYTE codeByte;
int checksum=0;
while(codeSize>0)
{
String strLine;
checksum=0;
int bytesInLine=codeSize<MaxDataBytesPerLine?codeSize:MaxDataBytesPerLine;
::sprintf(strLine,"S1%02x%04x",bytesInLine+1+2,origin);
checksum+=(bytesInLine+1+2);
checksum+=origin;
for(int index=0;index<bytesInLine;index++,codeSize--,origin++)
{
rawCode.read(codeByte);
checksum+=codeByte;
::sprintf(strByte,"%02x",codeByte);
strLine+=strByte;
}
checksum=checksum&0xFF;
checksum=~checksum;
::sprintf(strByte,"%02x",(BYTE)checksum);
strLine+=strByte;
strLine.upper();
::OutputDebugString(strLine+String("\r\n"));
outFile.writeLine(strLine);
}
}