Fix Overworld, add matchedBytes constant array

This commit is contained in:
Justin Scofield
2023-08-02 12:59:05 -04:00
parent 7b2e017bb3
commit 88c915ce9d
2 changed files with 10 additions and 9 deletions

View File

@@ -13,12 +13,13 @@ namespace yaze {
namespace app {
namespace viewer {
constexpr int kMatchedBytes[] = {0x4E, 0x41, 0x4B, 0x31, 0x39, 0x38, 0x39};
void CgxViewer::LoadCgx(ROM &cgx_rom) {
std::cout << "Loading CGX" << std::endl;
raw_data_.malloc(0x40000);
all_tiles_data_.malloc(0x40000);
std::vector<unsigned char> matched_bytes;
int matching_position = -1;
bool matched = false;
for (int i = 0; i < cgx_rom.size(); i++) {
@@ -27,9 +28,9 @@ void CgxViewer::LoadCgx(ROM &cgx_rom) {
}
raw_data_[i] = cgx_rom[i];
for (int j = 0; j < matched_bytes.size(); j++) {
if (cgx_rom[i + j] == matched_bytes[j]) {
if (j == matched_bytes.size() - 1) {
for (int j = 0; j < 7; j++) {
if (cgx_rom[i + j] == kMatchedBytes[j]) {
if (j == 7 - 1) {
matching_position = i;
matched = true;
break;

View File

@@ -65,7 +65,7 @@ absl::Status Overworld::Load(ROM &rom) {
}
}
LoadSprites();
// LoadSprites();
is_loaded_ = true;
return absl::OkStatus();
@@ -280,13 +280,13 @@ void Overworld::SaveMap16Tiles() {
int tpos = core::map16Tiles;
// 3760
for (int i = 0; i < core::NumberOfMap16; i += 1) {
rom_.WriteShort(tpos, tiles16[i].tile0_.ToShort());
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile0_));
tpos += 2;
rom_.WriteShort(tpos, tiles16[i].tile1_.ToShort());
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile1_));
tpos += 2;
rom_.WriteShort(tpos, tiles16[i].tile2_.ToShort());
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile2_));
tpos += 2;
rom_.WriteShort(tpos, tiles16[i].tile3_.ToShort());
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile3_));
tpos += 2;
}
}