summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-01-31 11:33:12 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-01-31 11:33:12 -0500
commit3720e9bcdd15a30058bc5f8a2913a924760796a0 (patch)
treee89b433276a71e765a456c60adf28a325ceeb69f /tools
parent3fc3a14a94ed7c3942c1e430b4628b22512cce34 (diff)
downloadtanetane-3720e9bcdd15a30058bc5f8a2913a924760796a0.tar.gz
tanetane-3720e9bcdd15a30058bc5f8a2913a924760796a0.tar.bz2
tanetane-3720e9bcdd15a30058bc5f8a2913a924760796a0.zip
Fixed errors with signedness... yay!
Diffstat (limited to 'tools')
-rw-r--r--tools/sprite_dumper/main.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/tools/sprite_dumper/main.cpp b/tools/sprite_dumper/main.cpp index 79e3df0..c8dd956 100644 --- a/tools/sprite_dumper/main.cpp +++ b/tools/sprite_dumper/main.cpp
@@ -58,7 +58,7 @@ public:
58 } 58 }
59 59
60 int ReadTwoBytes(int addr) const { 60 int ReadTwoBytes(int addr) const {
61 return static_cast<unsigned char>(data_[addr]) | (data_[addr + 1] << 8); 61 return static_cast<unsigned char>(data_[addr]) | (static_cast<unsigned char>(data_[addr + 1]) << 8);
62 } 62 }
63 63
64 int ReadNextFourBytes() { 64 int ReadNextFourBytes() {
@@ -67,8 +67,8 @@ public:
67 return ReadFourBytes(o2r); 67 return ReadFourBytes(o2r);
68 } 68 }
69 69
70 int ReadFourBytes(int addr) const { 70 unsigned long ReadFourBytes(int addr) const {
71 return static_cast<unsigned char>(data_[addr]) | (data_[addr + 1] << 8) | (data_[addr + 2] << 16) | (data_[addr + 3] << 24); 71 return static_cast<unsigned char>(data_[addr]) | (static_cast<unsigned char>(data_[addr + 1]) << 8) | (static_cast<unsigned char>(data_[addr + 2]) << 16) | (static_cast<unsigned char>(data_[addr + 3]) << 24);
72 } 72 }
73 73
74 void Seek(int offset) { 74 void Seek(int offset) {
@@ -332,6 +332,7 @@ public:
332 m3.SeekAdd(8); 332 m3.SeekAdd(8);
333 333
334 unsigned short spriteCount = m3.ReadNextTwoBytes(); 334 unsigned short spriteCount = m3.ReadNextTwoBytes();
335 //std::cout << i << ":" << spriteCount << " at " << std::hex << sheetAddr << std::endl;
335 for (int j=0; j<spriteCount; j++) { 336 for (int j=0; j<spriteCount; j++) {
336 Sprite sprite; 337 Sprite sprite;
337 338
@@ -348,9 +349,9 @@ public:
348 subsprite.objSize = static_cast<unsigned char>((ch >> 12) & 3); 349 subsprite.objSize = static_cast<unsigned char>((ch >> 12) & 3);
349 subsprite.objShape = static_cast<unsigned char>((ch >> 14) & 3); 350 subsprite.objShape = static_cast<unsigned char>((ch >> 14) & 3);
350 351
351 std::cout << subsprite.y << std::endl; 352 /*std::cout << subsprite.y << std::endl;
352 std::cout << subsprite.x << std::endl; 353 std::cout << subsprite.x << std::endl;
353 std::cout << subsprite.flipH << "," << subsprite.flipV << std::endl; 354 std::cout << subsprite.flipH << "," << subsprite.flipV << std::endl;*/
354 355
355 sprite.subsprites.push_back(std::move(subsprite)); 356 sprite.subsprites.push_back(std::move(subsprite));
356 } 357 }
@@ -361,7 +362,7 @@ public:
361 } 362 }
362 363
363 spritesheets_[i] = std::move(ss); 364 spritesheets_[i] = std::move(ss);
364 if (i == 2) return; 365 //if (i == 15) return;
365 } 366 }
366 } 367 }
367 368
@@ -370,7 +371,9 @@ public:
370private: 371private:
371 372
372 int GetPointerToSheet(Rom& m3, int index) { 373 int GetPointerToSheet(Rom& m3, int index) {
373 int a = m3.ReadFourBytes(baseAddr_ + 4 + (index << 2)); 374 int readAt = baseAddr_ + 4 + (index << 2);
375 int a = m3.ReadFourBytes(readAt);
376 //std::cout << readAt << " :: " << a << std::hex << std::endl;
374 if (a == 0) return -1; 377 if (a == 0) return -1;
375 return a + baseAddr_; 378 return a + baseAddr_;
376 } 379 }
@@ -396,7 +399,10 @@ int main(int argc, char** argv) {
396 PaletteSet palettes(m3); 399 PaletteSet palettes(m3);
397 //const int banks[] = {0x1A442A4, 0x1AE0638, 0x1AEE4C4, 0x1AF1ED0}; 400 //const int banks[] = {0x1A442A4, 0x1AE0638, 0x1AEE4C4, 0x1AF1ED0};
398 Bank b1(m3, 0x1A442A4, 0x14383E4); 401 Bank b1(m3, 0x1A442A4, 0x14383E4);
399 Magick::Image im = b1.SpriteSheets().at(1).render(m3, palettes); 402 Bank b2(m3, 0x1AE0638, 0x194BC30);
403 Bank b3(m3, 0x1AEE4C4, 0x1A012B8);
404 Bank b4(m3, 0x1AF1ED0, 0x1A36AA0);
405 Magick::Image im = b2.SpriteSheets().at(3).render(m3, palettes);
400 im.magick("png"); 406 im.magick("png");
401 im.write("out.png"); 407 im.write("out.png");
402 408