diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-01-31 20:14:00 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-01-31 20:14:00 -0500 |
| commit | 83bac91872a2c4211e4f4ee62e5fefd769c00cdf (patch) | |
| tree | e36d77f533a8a574bb9ca065be79690782eaaf9f /tools | |
| parent | a64c85a3f5641581a19ef52a5c7898ec3cb71754 (diff) | |
| download | tanetane-83bac91872a2c4211e4f4ee62e5fefd769c00cdf.tar.gz tanetane-83bac91872a2c4211e4f4ee62e5fefd769c00cdf.tar.bz2 tanetane-83bac91872a2c4211e4f4ee62e5fefd769c00cdf.zip | |
Map dumper gets map width/height
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/sprite_dumper/tileset_dumper.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
| diff --git a/tools/sprite_dumper/tileset_dumper.cpp b/tools/sprite_dumper/tileset_dumper.cpp index 10e46fa..c0cea76 100644 --- a/tools/sprite_dumper/tileset_dumper.cpp +++ b/tools/sprite_dumper/tileset_dumper.cpp | |||
| @@ -2,8 +2,32 @@ | |||
| 2 | #include <Magick++.h> | 2 | #include <Magick++.h> |
| 3 | #include <vector> | 3 | #include <vector> |
| 4 | #include <string> | 4 | #include <string> |
| 5 | #include <map> | ||
| 5 | #include "common.h" | 6 | #include "common.h" |
| 6 | 7 | ||
| 8 | const int NUM_ROOMS = 1000; | ||
| 9 | |||
| 10 | struct RoomInfo { | ||
| 11 | int width; | ||
| 12 | int height; | ||
| 13 | |||
| 14 | static std::map<int, RoomInfo> ReadFromRom(BufferView m3) { | ||
| 15 | const int BASE_ADDR = 0xD2E1D8 + 12; | ||
| 16 | const int ENTRY_LEN = 28; | ||
| 17 | |||
| 18 | std::map<int, RoomInfo> output; | ||
| 19 | |||
| 20 | for (int i=0; i<NUM_ROOMS; i++) { | ||
| 21 | RoomInfo& ri = output[i]; | ||
| 22 | |||
| 23 | ri.width = ((m3.ReadByte(BASE_ADDR + i*ENTRY_LEN + 20) & 7) + 1) << 4; | ||
| 24 | ri.height = (((m3.ReadByte(BASE_ADDR + i*ENTRY_LEN + 24) & 0x3F) >> 3) + 1) << 4; | ||
| 25 | } | ||
| 26 | |||
| 27 | return output; | ||
| 28 | } | ||
| 29 | }; | ||
| 30 | |||
| 7 | int main(int argc, char** argv) { | 31 | int main(int argc, char** argv) { |
| 8 | if (argc < 3) { | 32 | if (argc < 3) { |
| 9 | std::cout << "Usage: ./tileset_dumper [path to rom] {map ID}" << std::endl; | 33 | std::cout << "Usage: ./tileset_dumper [path to rom] {map ID}" << std::endl; |
| @@ -15,7 +39,9 @@ int main(int argc, char** argv) { | |||
| 15 | Rom m3(argv[1]); | 39 | Rom m3(argv[1]); |
| 16 | 40 | ||
| 17 | int roomNum = std::stoi(argv[2]); | 41 | int roomNum = std::stoi(argv[2]); |
| 18 | const unsigned long ROOM_TILES_BASE = 0x104D9CC; | 42 | auto roomInfos = RoomInfo::ReadFromRom(m3.buffer()); |
| 43 | std::cout << roomInfos[roomNum].width << "," << roomInfos[roomNum].height << std::endl; | ||
| 44 | /*const unsigned long ROOM_TILES_BASE = 0x104D9CC; | ||
| 19 | unsigned long metatilesInfoAddr = ROOM_TILES_BASE + 4 + (roomNum << 2); | 45 | unsigned long metatilesInfoAddr = ROOM_TILES_BASE + 4 + (roomNum << 2); |
| 20 | unsigned long metatilesOffset = m3.buffer().ReadFourBytes(metatilesInfoAddr); | 46 | unsigned long metatilesOffset = m3.buffer().ReadFourBytes(metatilesInfoAddr); |
| 21 | unsigned long metatilesAddr = metatilesOffset + ROOM_TILES_BASE; | 47 | unsigned long metatilesAddr = metatilesOffset + ROOM_TILES_BASE; |
| @@ -35,5 +61,5 @@ int main(int argc, char** argv) { | |||
| 35 | if ((mask & 0x8) == 0) tile11 = -1; | 61 | if ((mask & 0x8) == 0) tile11 = -1; |
| 36 | 62 | ||
| 37 | std::cout << tile00 << "," << tile01 << "," << tile10 << "," << tile11 << std::endl; | 63 | std::cout << tile00 << "," << tile01 << "," << tile10 << "," << tile11 << std::endl; |
| 38 | } | 64 | }*/ |
| 39 | } \ No newline at end of file | 65 | } \ No newline at end of file |
