From 532c675a3ae4d465b63d69cdf3fd623f5eeed058 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Sun, 31 Aug 2008 21:08:47 +0000 Subject: [PATCH] Added animation reading. It seems to work fine for the first frame, but none of my saves have >1 frames so I can't test the reading of the other frames, which should work fine anyway. Only missing is DISPLAYING the banner and the animation/icon. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@410 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/src/MemcardManager.cpp | 32 ++++++- .../DolphinWX/src/MemoryCards/GCMemcard.cpp | 84 ++++++++++++++++++- .../DolphinWX/src/MemoryCards/GCMemcard.h | 3 + 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinWX/src/MemcardManager.cpp b/Source/Core/DolphinWX/src/MemcardManager.cpp index bb02e8f2e6..f9ba954d9d 100644 --- a/Source/Core/DolphinWX/src/MemcardManager.cpp +++ b/Source/Core/DolphinWX/src/MemcardManager.cpp @@ -193,7 +193,7 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card) #if FALSE char t[257]; - sprintf(t,"card%d_%d.bmp",card,index); + sprintf(t,"card%d_%d.bmp",card,i); FILE*f=fopen(t,"wb"); if(f) { const u8 hdr[] = { @@ -212,6 +212,36 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card) fwrite(ftr,1,2,f); fclose(f); } +#endif + } + + static u8 animDelay[8]; + static u32 animData[32*32*8]; + int numFrames = memoryCard[card]->ReadAnimRGBA8(i,animData,animDelay); + for(int n=0;n>(2*i); + delays[i] = (fdelays>>(2*i))<<2; + data[i] = animData; + + switch(fmts[i]) + { + case 1: // CI8 with shared palette + animData+=32*32; + frames++; + break; + case 2: // RGB5A3 + animData+=32*32*2; + frames++; + break; + case 3: // CI8 with own palette + animData+=32*32 + 2*256; + frames++; + break; + } + } + + u16* sharedPal = (u16*)(animData); + + for(int i=0;i<8;i++) + { + switch(fmts[i]) + { + case 1: // CI8 with shared palette + decodeCI8image(buffer,data[i],sharedPal,32,32); + buffer+=32*32; + break; + case 2: // RGB5A3 + decode5A3image(buffer,(u16*)(data[i]),32,32); + break; + case 3: // CI8 with own palette + u16 *paldata = (u16*)(data[i]+32*32); + decodeCI8image(buffer,data[i],paldata,32,32); + buffer+=32*32; + break; + } + } + + return frames; +} + u32 GCMemcard::TestChecksums() { if(!mcdFile) return 0xFFFFFFFF; diff --git a/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.h b/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.h index 86e3c8a1d1..411829547b 100644 --- a/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.h +++ b/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.h @@ -157,6 +157,9 @@ public: // reads the banner image bool ReadBannerRGBA8(u32 index, u32* buffer); + // reads the animation frames + u32 ReadAnimRGBA8(u32 index, u32* buffer, u8 *delays); + bool Save(); };