Refactor ROM handling and update Overworld methods
Updated MessageEditor, RoomEntrance, and Overworld classes to use WriteByte instead of Write for byte values. Refactored ROM class by removing Write and toint16 methods, moving constants, and updating operator[]. Modified Overworld methods to return absl::Status and handle errors. Updated Inventory and OverworldMap methods to use ReadWord instead of toint16.
This commit is contained in:
@@ -231,6 +231,17 @@ absl::Status Rom::LoadFromPointer(uchar *data, size_t length, bool z3_load) {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Rom::LoadFromBytes(const std::vector<uint8_t>& data) {
|
||||
if (data.empty()) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Could not load ROM: parameter `data` is empty.");
|
||||
}
|
||||
rom_data_ = data;
|
||||
size_ = data.size();
|
||||
is_loaded_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Rom::LoadZelda3() {
|
||||
// Check if the ROM has a header
|
||||
constexpr size_t kBaseRomSize = 1048576; // 1MB
|
||||
@@ -267,17 +278,6 @@ absl::Status Rom::LoadZelda3() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Rom::LoadFromBytes(const std::vector<uint8_t> &data) {
|
||||
if (data.empty()) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Could not load ROM: parameter `data` is empty.");
|
||||
}
|
||||
rom_data_ = data;
|
||||
size_ = data.size();
|
||||
is_loaded_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Rom::SaveToFile(bool backup, bool save_new, std::string filename) {
|
||||
absl::Status non_firing_status;
|
||||
if (rom_data_.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user