Add save as .prg for overlay files
This commit is contained in:
parent
7f51d6330e
commit
b0dc6fdd1e
|
@ -1177,9 +1177,17 @@ bool Compiler::BuildLZO(const char* targetPath)
|
||||||
bool Compiler::WriteOutputFile(const char* targetPath, DiskImage * d64)
|
bool Compiler::WriteOutputFile(const char* targetPath, DiskImage * d64)
|
||||||
{
|
{
|
||||||
char prgPath[200], mapPath[200], asmPath[200], lblPath[200], intPath[200], bcsPath[200], dbjPath[200];
|
char prgPath[200], mapPath[200], asmPath[200], lblPath[200], intPath[200], bcsPath[200], dbjPath[200];
|
||||||
|
char basePath[200];
|
||||||
|
|
||||||
|
strcpy_s(basePath, targetPath);
|
||||||
|
int i = strlen(basePath);
|
||||||
|
while (i > 0 && basePath[i - 1] != '/' && basePath[i - 1] != '\\' && basePath[i - 1] != ':')
|
||||||
|
i--;
|
||||||
|
if (i > 0)
|
||||||
|
basePath[i] = 0;
|
||||||
|
|
||||||
strcpy_s(prgPath, targetPath);
|
strcpy_s(prgPath, targetPath);
|
||||||
int i = strlen(prgPath);
|
i = strlen(prgPath);
|
||||||
while (i > 0 && prgPath[i - 1] != '.')
|
while (i > 0 && prgPath[i - 1] != '.')
|
||||||
i--;
|
i--;
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
@ -1213,7 +1221,7 @@ bool Compiler::WriteOutputFile(const char* targetPath, DiskImage * d64)
|
||||||
strcat_s(prgPath, "prg");
|
strcat_s(prgPath, "prg");
|
||||||
if (mCompilerOptions & COPT_VERBOSE)
|
if (mCompilerOptions & COPT_VERBOSE)
|
||||||
printf("Writing <%s>\n", prgPath);
|
printf("Writing <%s>\n", prgPath);
|
||||||
mLinker->WritePrgFile(prgPath);
|
mLinker->WritePrgFile(prgPath, basePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mCompilerOptions & COPT_TARGET_CRT)
|
else if (mCompilerOptions & COPT_TARGET_CRT)
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ bool Linker::WriteXexFile(const char* filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Linker::WritePrgFile(const char* filename)
|
bool Linker::WritePrgFile(const char* filename, const char* pathname)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
fopen_s(&file, filename, "wb");
|
fopen_s(&file, filename, "wb");
|
||||||
|
@ -1185,10 +1185,36 @@ bool Linker::WritePrgFile(const char* filename)
|
||||||
|
|
||||||
int done = fwrite(mMemory + mProgramStart - 2, 1, mProgramEnd - mProgramStart + 2, file);
|
int done = fwrite(mMemory + mProgramStart - 2, 1, mProgramEnd - mProgramStart + 2, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return done == mProgramEnd - mProgramStart + 2;
|
if (done == mProgramEnd - mProgramStart + 2)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mOverlays.Size(); i++)
|
||||||
|
{
|
||||||
|
char ofname[200];
|
||||||
|
strcpy_s(ofname, pathname);
|
||||||
|
strcat_s(ofname, mOverlays[i]->mIdent->mString);
|
||||||
|
strcat_s(ofname, ".prg");
|
||||||
|
|
||||||
|
fopen_s(&file, ofname, "wb");
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
int b = mOverlays[i]->mBank;
|
||||||
|
int s = mCartridgeBankStart[b];
|
||||||
|
|
||||||
|
mCartridge[b][s - 2] = s & 0xff;
|
||||||
|
mCartridge[b][s - 1] = s >> 8;
|
||||||
|
|
||||||
|
fwrite(mCartridge[b] + s - 22, 1, mCartridgeBankEnd[b] - s + 2, file);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int memlzcomp(uint8 * dp, const uint8 * sp, int size)
|
static int memlzcomp(uint8 * dp, const uint8 * sp, int size)
|
||||||
|
|
|
@ -266,7 +266,7 @@ public:
|
||||||
// void AddReference(const LinkerReference& ref);
|
// void AddReference(const LinkerReference& ref);
|
||||||
|
|
||||||
bool WritePrgFile(DiskImage * image, const char* filename);
|
bool WritePrgFile(DiskImage * image, const char* filename);
|
||||||
bool WritePrgFile(const char* filename);
|
bool WritePrgFile(const char* filename, const char * pathname);
|
||||||
bool WriteXexFile(const char* filename);
|
bool WriteXexFile(const char* filename);
|
||||||
bool WriteMapFile(const char* filename);
|
bool WriteMapFile(const char* filename);
|
||||||
bool WriteAsmFile(const char* filename, const char * version);
|
bool WriteAsmFile(const char* filename, const char * version);
|
||||||
|
|
Loading…
Reference in New Issue