yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
extract_vanilla_values.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <fstream>
4#include <vector>
5
6#include "app/rom.h"
9
10using namespace yaze::zelda3;
11using namespace yaze;
12
13int main() {
14 // Load the vanilla ROM
15 Rom rom;
16 if (!rom.LoadFromFile("zelda3.sfc").ok()) {
17 std::cerr << "Failed to load ROM file" << std::endl;
18 return 1;
19 }
20
21 std::cout << "// Vanilla ROM values extracted from zelda3.sfc" << std::endl;
22 std::cout << "// Generated on " << __DATE__ << " " << __TIME__ << std::endl;
23 std::cout << std::endl;
24
25 // Extract ASM version
26 uint8_t asm_version = rom[OverworldCustomASMHasBeenApplied];
27 std::cout << "constexpr uint8_t kVanillaASMVersion = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)asm_version << ";" << std::endl;
28 std::cout << std::endl;
29
30 // Extract area graphics for first 10 maps
31 std::cout << "// Area graphics for first 10 maps" << std::endl;
32 for (int i = 0; i < 10; i++) {
33 uint8_t area_gfx = rom[kAreaGfxIdPtr + i];
34 std::cout << "constexpr uint8_t kVanillaAreaGraphics" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)area_gfx << ";" << std::endl;
35 }
36 std::cout << std::endl;
37
38 // Extract area palettes for first 10 maps
39 std::cout << "// Area palettes for first 10 maps" << std::endl;
40 for (int i = 0; i < 10; i++) {
41 uint8_t area_pal = rom[kOverworldMapPaletteIds + i];
42 std::cout << "constexpr uint8_t kVanillaAreaPalette" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)area_pal << ";" << std::endl;
43 }
44 std::cout << std::endl;
45
46 // Extract message IDs for first 10 maps
47 std::cout << "// Message IDs for first 10 maps" << std::endl;
48 for (int i = 0; i < 10; i++) {
49 uint16_t message_id = rom[kOverworldMessageIds + (i * 2)] | (rom[kOverworldMessageIds + (i * 2) + 1] << 8);
50 std::cout << "constexpr uint16_t kVanillaMessageId" << i << " = 0x" << std::hex << std::setw(4) << std::setfill('0') << message_id << ";" << std::endl;
51 }
52 std::cout << std::endl;
53
54 // Extract screen sizes for first 10 maps
55 std::cout << "// Screen sizes for first 10 maps" << std::endl;
56 for (int i = 0; i < 10; i++) {
57 uint8_t screen_size = rom[kOverworldScreenSize + i];
58 std::cout << "constexpr uint8_t kVanillaScreenSize" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)screen_size << ";" << std::endl;
59 }
60 std::cout << std::endl;
61
62 // Extract sprite sets for first 10 maps
63 std::cout << "// Sprite sets for first 10 maps" << std::endl;
64 for (int i = 0; i < 10; i++) {
65 uint8_t sprite_set = rom[kOverworldSpriteset + i];
66 std::cout << "constexpr uint8_t kVanillaSpriteSet" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)sprite_set << ";" << std::endl;
67 }
68 std::cout << std::endl;
69
70 // Extract sprite palettes for first 10 maps
71 std::cout << "// Sprite palettes for first 10 maps" << std::endl;
72 for (int i = 0; i < 10; i++) {
73 uint8_t sprite_pal = rom[kOverworldSpritePaletteIds + i];
74 std::cout << "constexpr uint8_t kVanillaSpritePalette" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)sprite_pal << ";" << std::endl;
75 }
76 std::cout << std::endl;
77
78 // Extract music for first 10 maps
79 std::cout << "// Music for first 10 maps" << std::endl;
80 for (int i = 0; i < 10; i++) {
81 uint8_t music = rom[kOverworldMusicBeginning + i];
82 std::cout << "constexpr uint8_t kVanillaMusic" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)music << ";" << std::endl;
83 }
84 std::cout << std::endl;
85
86 // Extract some special world values
87 std::cout << "// Special world graphics and palettes" << std::endl;
88 for (int i = 0; i < 5; i++) {
89 uint8_t special_gfx = rom[kOverworldSpecialGfxGroup + i];
90 uint8_t special_pal = rom[kOverworldSpecialPalGroup + i];
91 std::cout << "constexpr uint8_t kVanillaSpecialGfx" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)special_gfx << ";" << std::endl;
92 std::cout << "constexpr uint8_t kVanillaSpecialPal" << i << " = 0x" << std::hex << std::setw(2) << std::setfill('0') << (int)special_pal << ";" << std::endl;
93 }
94
95 return 0;
96}
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:289
Zelda 3 specific classes and functions.
constexpr int kAreaGfxIdPtr
Definition overworld.h:40
constexpr int kOverworldSpriteset
Definition overworld.h:33
constexpr int kOverworldScreenSize
Definition overworld.h:66
constexpr int kOverworldMusicBeginning
Definition overworld.h:43
constexpr int kOverworldSpecialPalGroup
Definition overworld.h:35
constexpr int kOverworldSpritePaletteIds
Definition overworld.h:31
constexpr int OverworldCustomASMHasBeenApplied
constexpr int kOverworldMessageIds
Definition overworld.h:41
constexpr int kOverworldMapPaletteIds
Definition overworld.h:30
constexpr int kOverworldSpecialGfxGroup
Definition overworld.h:34
Main namespace for the application.