mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix opening nonexistent overlay files
This commit is contained in:
@@ -104,15 +104,19 @@ Output(void)
|
|||||||
if ((f = fopen(tzOutname, "wb"))) {
|
if ((f = fopen(tzOutname, "wb"))) {
|
||||||
if (tzOverlayname) {
|
if (tzOverlayname) {
|
||||||
f_overlay = fopen(tzOverlayname, "rb");
|
f_overlay = fopen(tzOverlayname, "rb");
|
||||||
|
if (!f_overlay) {
|
||||||
|
fprintf(stderr, "Failed to open overlay file %s\n", tzOverlayname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
fseek(f_overlay, 0, SEEK_END);
|
fseek(f_overlay, 0, SEEK_END);
|
||||||
if (ftell(f_overlay) % 0x4000 != 0) {
|
if (ftell(f_overlay) % 0x4000 != 0) {
|
||||||
fprintf(stderr, "Overlay file must be aligned to 0x4000 bytes");
|
fprintf(stderr, "Overlay file must be aligned to 0x4000 bytes\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
MaxOverlayBank = (ftell(f_overlay) / 0x4000) - 1;
|
MaxOverlayBank = (ftell(f_overlay) / 0x4000) - 1;
|
||||||
if (MaxOverlayBank < 1) {
|
if (MaxOverlayBank < 1) {
|
||||||
fprintf(stderr, "Overlay file be at least 0x8000 bytes");
|
fprintf(stderr, "Overlay file be at least 0x8000 bytes\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (MaxOverlayBank > MaxBankUsed) {
|
if (MaxOverlayBank > MaxBankUsed) {
|
||||||
MaxBankUsed = MaxOverlayBank;
|
MaxBankUsed = MaxOverlayBank;
|
||||||
|
|||||||
Reference in New Issue
Block a user