Pārlūkot izejas kodu

Fixed an issue where output 8xp files would be corrupt. How this ever was considered to be 'working' is beyond me.

Matthew Iselin 13 gadi atpakaļ
vecāks
revīzija
a47301b21e
1 mainītis faili ar 4 papildinājumiem un 6 dzēšanām
  1. 4 6
      src/tibasic.cpp

+ 4 - 6
src/tibasic.cpp

@@ -51,7 +51,7 @@ bool Compiler::compile(string inFile, string outFile)
 
     // Output information ready for writing the compiled code to a file.
     vector<token_t> output;
-    size_t outputSize = 0;
+    unsigned short outputSize = 0;
 
     while(!f.eof())
     {
@@ -118,6 +118,7 @@ bool Compiler::compile(string inFile, string outFile)
     phdr.datalen = sizeof(VariableEntry) + outputSize;
     strcpy(phdr.sig, "**TI83F*");
     phdr.extsig[0] = 0x1A; phdr.extsig[1] = 0x0A; phdr.extsig[2] = 0;
+    strcpy(phdr.comment, "Generated by the TI-BASIC Compiler.");
 
     /// \todo Magic numbers!
     ventry.start = 0x0D;
@@ -139,18 +140,15 @@ bool Compiler::compile(string inFile, string outFile)
     // Begin writing to file.
     FILE *out = fopen(outFile.c_str(), "wb");
     fwrite(&phdr, sizeof(phdr), 1, out);
-    cout << "file is at " << ftell(out) << endl;
-    fwrite(&ventry, sizeof(ventry), 1, out);
-    cout << "file is at " << ftell(out) << endl;
     fwrite(&outputSize, 2, 1, out);
-    cout << "file is at " << ftell(out) << endl;
+    fwrite(&ventry, sizeof(ventry), 1, out);
 
     // Sum of all bytes for checksum purposes.
     size_t sum = 0;
 
     for(vector<token_t>::iterator it = output.begin();
         it != output.end();
-        it++)
+        ++it)
     {
         fwrite(&(it->token), it->sz, 1, out);
         sum += it->token;