ntsc-beta: Get ROM fully matching

This commit is contained in:
Ryan Dwyer committed 2021-10-26 17:15:43 +10:00
1 parent e5e21c413e
commit 5d40470f89
72 files changed
+16927 -687

No files matched your search

+1 -1
View File
@@ -458,7 +458,7 @@ class Extractor:
'files': [0x29160, 0x28080, 0x28080, 0x29b90, 0x28910, 0x28800, ],
'data': [0x30850, 0x39850, 0x39850, 0x39850, 0x39850, 0x39850, ],
'game': [0x43c40, 0x4fc40, 0x4fc40, 0x4fc40, 0x4fc40, 0x4fc40, ],
'garbage': [0x155cc0, 0x194b20, 0x194b20, 0x0, 0x180330, 0x0, ],
'garbage': [0x148c40, 0x194b20, 0x194b20, 0x0, 0x180330, 0x0, ],
'animations': [0x155dc0, 0x1a15c0, 0x1a15c0, 0x18cdc0, 0x18cdc0, 0x190c50, ],
'mpconfigs': [0x785130, 0x7d0a40, 0x7d0a40, 0x7bc240, 0x7bc240, 0x7c00d0, ],
'firingrange': [0x79e410, 0x7e9d20, 0x7e9d20, 0x7d5520, 0x7d5520, 0x7d93b0, ],
+6
View File
@@ -54,6 +54,12 @@ struct state {
* Size of the above gametable allocation in bytes.
*/
size_t gametablelen;
/**
* NTSC beta doesn't duplicate zip data unneccessarily so it must be
* identified and handled differently.
*/
bool is_ntscbeta;
};
void game_zip(void);
+22 -18
View File
@@ -72,19 +72,21 @@ void pack_game(void)
memcpy(&state.rom[gamezipstart], state.gametable, state.gametablelen);
// Paste the second segment, truncating it to fit the allocation
truncatedlen = gamezipend - gamezipstart - state.gamezipslen;
if (!state.is_ntscbeta) {
// Paste the second segment, truncating it to fit the allocation
truncatedlen = gamezipend - gamezipstart - state.gamezipslen;
if (truncatedlen > state.gamezipslen) {
truncatedlen = state.gamezipslen;
if (truncatedlen > state.gamezipslen) {
truncatedlen = state.gamezipslen;
}
memcpy(&state.rom[gamezipstart + state.gamezipslen], state.gamezips, truncatedlen);
// The final two bytes from the real segment are duplicated into
// the first two bytes of the second segment's offset table
state.rom[gamezipstart + state.gamezipslen + 0] = state.rom[gamezipstart + state.gamezipslen - 2];
state.rom[gamezipstart + state.gamezipslen + 1] = state.rom[gamezipstart + state.gamezipslen - 1];
}
memcpy(&state.rom[gamezipstart + state.gamezipslen], state.gamezips, truncatedlen);
// The final two bytes from the real segment are duplicated into
// the first two bytes of the second segment's offset table
state.rom[gamezipstart + state.gamezipslen + 0] = state.rom[gamezipstart + state.gamezipslen - 2];
state.rom[gamezipstart + state.gamezipslen + 1] = state.rom[gamezipstart + state.gamezipslen - 1];
}
/**
@@ -117,17 +119,19 @@ void pack_lib(void)
// Copy the buffer to its real spot in the ROM
copy("lib", buffer, seglen, "ROMALLOCATION_LIB");
// Copy it truncated to its fake spot
map_get_segment_rompos("libzip", &libzipstart, &libzipend);
if (!state.is_ntscbeta) {
// Copy it truncated to its fake spot
map_get_segment_rompos("libzip", &libzipstart, &libzipend);
truncatedlen = libzipend - libzipstart - seglen;
truncatedlen = libzipend - libzipstart - seglen;
if (truncatedlen > seglen) {
truncatedlen = seglen;
if (truncatedlen > seglen) {
truncatedlen = seglen;
}
memcpy(state.rom + libzipstart + seglen, buffer, truncatedlen);
}
memcpy(state.rom + libzipstart + seglen, buffer, truncatedlen);
free(buffer);
}
+3
View File
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mkrom.h"
extern struct state state;
@@ -29,6 +30,8 @@ void rom_load(char *filename)
fseek(fp, 0, SEEK_SET);
fread(state.rom, state.romlen, 1, fp);
fclose(fp);
state.is_ntscbeta = strncmp(&state.rom[0x20], "Perfect Dark DBGNTSC", 20) == 0;
}
/**