Run from the asset files alone: built-in numbers and texts for BMH and FLTD
The game no longer needs BMH.EXE or FLTD.EXE. The numbers and the game texts of the Diamond 3.7 executable and of the English Football Limited are generated into formats/diamond_constants.inc and formats/fltd_constants.inc (tools/diamond_constants). A missing BMH.exe loads the embedded German image, an English installation without FLTD.EXE gets the embedded English image; an executable that is present is used as before. The default manager name is OpenBMH. The launcher accepts directories and archives that hold only the asset files. Replays of a recorded session give identical output with and without BMH.EXE, and the English image equals the translated one. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6aa7c4f4a2
commit
524b9e4158
15 files changed
+4262
-23
No files matched your search
+16
-2
@@ -16,19 +16,33 @@
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Read recording for building the embedded constants (formats/diamond_constants.inc): when the environment variable
|
||||
// OPENBMH_LE_TRACE names a file, every image read is noted (numbers, strings, bulk pointers) and appended to that
|
||||
// file when the program ends. Without the variable the hook is a null pointer and costs one branch per read.
|
||||
namespace le_trace {
|
||||
extern void (*hook)(uint32_t address, uint32_t length, char kind); // kind: 'n' number, 't' string, 'b' bulk pointer
|
||||
void enable_from_environment();
|
||||
} // namespace le_trace
|
||||
|
||||
class LeImage {
|
||||
public:
|
||||
uint32_t base() const { return base_; }
|
||||
uint32_t size() const { return uint32_t(bytes_.size()); }
|
||||
bool contains(uint32_t address) const { return address >= base_ && address - base_ < bytes_.size(); }
|
||||
uint8_t u8(uint32_t address) const { return bytes_.at(address - base_); }
|
||||
uint8_t u8(uint32_t address) const {
|
||||
if (le_trace::hook) le_trace::hook(address, 1, 'n');
|
||||
return bytes_.at(address - base_);
|
||||
}
|
||||
uint16_t u16(uint32_t address) const { return uint16_t(u8(address) | u8(address + 1) << 8); }
|
||||
uint32_t u32(uint32_t address) const { return uint32_t(u16(address)) | uint32_t(u16(address + 2)) << 16; }
|
||||
// A NUL terminated string at `address` (ISO 646-DE bytes, see textd.hpp).
|
||||
std::string cstring(uint32_t address) const;
|
||||
// The string a pointer variable at `address` points to (e.g. Weekly_AdvertisingOffers_TextPointer).
|
||||
std::string string_at_pointer(uint32_t address) const { return cstring(u32(address)); }
|
||||
const uint8_t* data(uint32_t address) const { return bytes_.data() + (address - base_); }
|
||||
const uint8_t* data(uint32_t address) const {
|
||||
if (le_trace::hook) le_trace::hook(address, 0, 'b');
|
||||
return bytes_.data() + (address - base_);
|
||||
}
|
||||
// Overwrites bytes inside a prepared image for verified address translation.
|
||||
void patch(uint32_t address, const uint8_t* bytes, size_t count) {
|
||||
for (size_t i = 0; i < count; ++i) bytes_.at(address - base_ + i) = bytes[i];
|
||||
|
||||
Reference in new issue
Block a user