#include #include #include #include #include #include "common.h" const int NUM_ROOMS = 1000; struct RoomInfo { int width; int height; static std::map ReadFromRom(BufferView m3) { const int BASE_ADDR = 0xD2E1D8 + 12; const int ENTRY_LEN = 28; std::map output; for (int i=0; i> 3) + 1) << 4; } return output; } }; int main(int argc, char** argv) { if (argc < 3) { std::cout << "Usage: ./tileset_dumper [path to rom] {map ID}" << std::endl; return -1; } Magick::InitializeMagick(nullptr); Rom m3(argv[1]); int roomNum = std::stoi(argv[2]); auto roomInfos = RoomInfo::ReadFromRom(m3.buffer()); std::cout << roomInfos[roomNum].width << "," << roomInfos[roomNum].height << std::endl; /*const unsigned long ROOM_TILES_BASE = 0x104D9CC; unsigned long metatilesInfoAddr = ROOM_TILES_BASE + 4 + (roomNum << 2); unsigned long metatilesOffset = m3.buffer().ReadFourBytes(metatilesInfoAddr); unsigned long metatilesAddr = metatilesOffset + ROOM_TILES_BASE; std::vector metatiles = m3.buffer().Decompress(metatilesAddr); std::cout << (metatiles.size()/8) << std::endl; for (int i=0; i<10; i++) { int tile00 = metatiles[i*8+4]; int tile01 = metatiles[i*8+5]; int tile10 = metatiles[i*8+6]; int tile11 = metatiles[i*8+7]; int mask = metatiles[i*8+2]; if ((mask & 0x1) == 0) tile00 = -1; if ((mask & 0x2) == 0) tile01 = -1; if ((mask & 0x4) == 0) tile10 = -1; if ((mask & 0x8) == 0) tile11 = -1; std::cout << tile00 << "," << tile01 << "," << tile10 << "," << tile11 << std::endl; }*/ }