Clarify API usage

IconAddress makes no sense, points to the start of the banner, with the icon directly following,
This commit is contained in:
Phillip Stephens 2016-06-30 09:15:05 -07:00
parent 4d9bb795b9
commit 369d2cc23f
3 changed files with 16 additions and 16 deletions

View File

@ -169,8 +169,8 @@ public:
EImageFormat iconFormat(const std::unique_ptr<IFileHandle>& fh, uint32_t idx) const; EImageFormat iconFormat(const std::unique_ptr<IFileHandle>& fh, uint32_t idx) const;
void setIconSpeed(const std::unique_ptr<IFileHandle>& fh, uint32_t idx, EAnimationSpeed speed); void setIconSpeed(const std::unique_ptr<IFileHandle>& fh, uint32_t idx, EAnimationSpeed speed);
EAnimationSpeed iconSpeed(const std::unique_ptr<IFileHandle>& fh, uint32_t idx) const; EAnimationSpeed iconSpeed(const std::unique_ptr<IFileHandle>& fh, uint32_t idx) const;
void setIconAddress(const std::unique_ptr<IFileHandle>& fh, uint32_t addr); void setImageAddress(const std::unique_ptr<IFileHandle>& fh, uint32_t addr);
int32_t iconAddress(const std::unique_ptr<IFileHandle>& fh) const; int32_t imageAddress(const std::unique_ptr<IFileHandle>& fh) const;
void setCommentAddress(const std::unique_ptr<IFileHandle>& fh, uint32_t addr); void setCommentAddress(const std::unique_ptr<IFileHandle>& fh, uint32_t addr);
int32_t commentAddress(const std::unique_ptr<IFileHandle>& fh) const; int32_t commentAddress(const std::unique_ptr<IFileHandle>& fh) const;

View File

@ -435,7 +435,7 @@ EAnimationType Card::iconAnimationType(const std::unique_ptr<IFileHandle> &fh) c
{ {
File* file = _fileFromHandle(fh); File* file = _fileFromHandle(fh);
if (!file) if (!file)
return EAnimationType::Loop; return EAnimationType::Loop;
return EAnimationType(file->m_bannerFlags & 4); return EAnimationType(file->m_bannerFlags & 4);
} }
@ -476,7 +476,7 @@ EAnimationSpeed Card::iconSpeed(const std::unique_ptr<IFileHandle> &fh, uint32_t
return EAnimationSpeed((file->m_animSpeed >> (2 * (idx))) & 3); return EAnimationSpeed((file->m_animSpeed >> (2 * (idx))) & 3);
} }
void Card::setIconAddress(const std::unique_ptr<IFileHandle> &fh, uint32_t addr) void Card::setImageAddress(const std::unique_ptr<IFileHandle> &fh, uint32_t addr)
{ {
File* file = _fileFromHandle(fh); File* file = _fileFromHandle(fh);
if (!file) if (!file)
@ -484,7 +484,7 @@ void Card::setIconAddress(const std::unique_ptr<IFileHandle> &fh, uint32_t addr)
file->m_iconAddress = addr; file->m_iconAddress = addr;
} }
int32_t Card::iconAddress(const std::unique_ptr<IFileHandle> &fh) const int32_t Card::imageAddress(const std::unique_ptr<IFileHandle> &fh) const
{ {
File* file = _fileFromHandle(fh); File* file = _fileFromHandle(fh);
if (!file) if (!file)

View File

@ -17,7 +17,6 @@ int main()
mc.setPublic(f, true); mc.setPublic(f, true);
mc.setCanCopy(f, true); mc.setCanCopy(f, true);
mc.setCanMove(f, true); mc.setCanMove(f, true);
mc.setIconAddress(f, mc.commentAddress(f) + 64);
} }
if (f) if (f)
@ -26,16 +25,17 @@ int main()
mc.setIconFormat(f, 0, kabufuda::EImageFormat::C8); mc.setIconFormat(f, 0, kabufuda::EImageFormat::C8);
mc.setIconSpeed(f, 0, kabufuda::EAnimationSpeed::Middle); mc.setIconSpeed(f, 0, kabufuda::EAnimationSpeed::Middle);
const char* test = "Metroid Prime B is Cool"; mc.seek(f, 4, kabufuda::SeekOrigin::Begin);
size_t len = strlen(test); mc.setCommentAddress(f, 4);
mc.seek(f, 0, kabufuda::SeekOrigin::Begin);
mc.write(f, test, len + 1); std::string comment("Metroid Prime PC Edition");
uint16_t derp = 1234; mc.write(f, comment.c_str(), comment.length());
mc.seek(f, 1, kabufuda::SeekOrigin::End); mc.seek(f, 32 - comment.length(), kabufuda::SeekOrigin::Current);
mc.write(f, &derp, 2); comment = "Metroid Prime PC Is Cool";
mc.seek(f, -2, kabufuda::SeekOrigin::Current); mc.write(f, comment.c_str(), comment.length());
mc.read(f, &derp, 2); mc.seek(f, 32 - comment.length(), kabufuda::SeekOrigin::Current);
std::cout << derp << std::endl; mc.setImageAddress(f, mc.tell(f));
if (mc.copyFileTo(f, mc2)) if (mc.copyFileTo(f, mc2))
printf("Copy succeeded!\n"); printf("Copy succeeded!\n");
else else