mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
Fixed display of banners.
Turns out the YAGCD stuff was wrong, and it messed up the meaning of two bits. Also I had a bug in the CI8(C8) icon format display (wrong unswizzling). Next will be adding icon display & animation, in a separate column git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@417 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
73a5e1cb91
commit
f0b41b1f0d
@ -186,15 +186,37 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||
for(int i=0;i<nFiles;i++)
|
||||
{
|
||||
static u32 pxdata[96*32];
|
||||
static u8 animDelay[8];
|
||||
static u32 animData[32*32*8];
|
||||
|
||||
if(memoryCard[card]->ReadBannerRGBA8(i,pxdata))
|
||||
{
|
||||
// TODO: replace this debug stuff with actually showing the image data in the lists!
|
||||
|
||||
wxBitmap map((char*)pxdata,96,32,32);
|
||||
|
||||
images[i] = list->Add(map);
|
||||
//// it looks better without alpha
|
||||
//for(int i=0;i<96*32;i++)
|
||||
// pxdata[i]|=0xFF000000;
|
||||
}
|
||||
else images[i]=-1;
|
||||
else
|
||||
{
|
||||
memset(pxdata,0,96*32*4);
|
||||
|
||||
int numFrames = memoryCard[card]->ReadAnimRGBA8(i,animData,animDelay);
|
||||
if(numFrames>0) // just use the first one
|
||||
{
|
||||
int n = numFrames/2;
|
||||
u32 *icdata = animData+n*32*32;
|
||||
|
||||
for(int y=0;y<32;y++)
|
||||
{
|
||||
for(int x=0;x<32;x++)
|
||||
{
|
||||
pxdata[y*96+x+32] = icdata[y*32+x] /* | 0xFF000000 */;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmap map((char*)pxdata,96,32,32);
|
||||
images[i] = list->Add(map);
|
||||
}
|
||||
|
||||
for(int i=0;i<nFiles;i++)
|
||||
@ -214,38 +236,6 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||
{
|
||||
m_MemcardList[card]->SetItemImage(index, images[i]);
|
||||
}
|
||||
|
||||
#if FALSE
|
||||
static u8 animDelay[8];
|
||||
static u32 animData[32*32*8];
|
||||
int numFrames = memoryCard[card]->ReadAnimRGBA8(i,animData,animDelay);
|
||||
for(int n=0;n<numFrames;n++)
|
||||
{
|
||||
// TODO: replace this debug stuff with actually showing the image data in the lists!
|
||||
#if FALSE
|
||||
char t[257];
|
||||
sprintf(t,"card%d_%d_anim%d.bmp",card,i,n);
|
||||
FILE*f=fopen(t,"wb");
|
||||
if(f) {
|
||||
const u8 hdr[] = {
|
||||
0x42,0x4D,0x38,0x30,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,
|
||||
0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,
|
||||
0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00,
|
||||
0x00,0x00,0x02,0x30,0x00,0x00,0x12,0x0B,
|
||||
0x00,0x00,0x12,0x0B,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
const u8 ftr[] = {0,0};
|
||||
|
||||
fwrite(hdr,1,sizeof(hdr),f);
|
||||
fwrite(animData+(n*32*32),4,32*32,f); // note BMP "inverts" the image vertically, so it'll look upside-down when exported this way
|
||||
fwrite(ftr,1,2,f);
|
||||
fclose(f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
m_MemcardList[card]->Show();
|
||||
|
||||
|
@ -372,16 +372,16 @@ void decode5A3image(u32* dst, u16* src, int width, int height)
|
||||
|
||||
void decodeCI8image(u32* dst, u8* src, u16* pal, int width, int height)
|
||||
{
|
||||
for (int y = 0; y < height; y += 4)
|
||||
for (int y = 0; y < height; y += 4)
|
||||
{
|
||||
for (int x = 0; x < width; x += 4)
|
||||
for (int x = 0; x < width; x += 8)
|
||||
{
|
||||
for (int iy = 0; iy < 4; iy++, src += 4)
|
||||
for (int iy = 0; iy < 4; iy++, src += 8)
|
||||
{
|
||||
for (int ix = 0; ix < 4; ix++)
|
||||
u32 *tdst = dst+(y+iy)*width+x;
|
||||
for (int ix = 0; ix < 8; ix++)
|
||||
{
|
||||
u32 RGBA = decode5A3(bswap16(pal[src[ix]]));
|
||||
dst[(y + iy) * width + (x + ix)] = RGBA;
|
||||
tdst[ix] = decode5A3(bswap16(pal[src[ix]]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -394,10 +394,9 @@ bool GCMemcard::ReadBannerRGBA8(u32 index, u32* buffer)
|
||||
|
||||
int flags = dir.Dir[index].BIFlags;
|
||||
|
||||
bool hasBanner = (flags&2)!=0;
|
||||
bool fmtIsCI8 = (flags&1)!=0; // else RGB5A3 (if bit15 [ RGB5 A=0xFF ] else [ RGB4 A3 ] )
|
||||
int bnrFormat = (flags&3);
|
||||
|
||||
if(!hasBanner)
|
||||
if(bnrFormat==0)
|
||||
return false;
|
||||
|
||||
u32 DataOffset=BE32(dir.Dir[index].ImageOffset);
|
||||
@ -410,7 +409,7 @@ bool GCMemcard::ReadBannerRGBA8(u32 index, u32* buffer)
|
||||
|
||||
const int pixels = 96*32;
|
||||
|
||||
if(fmtIsCI8)
|
||||
if(bnrFormat&1)
|
||||
{
|
||||
u8 *pxdata = (u8* )(mc_data +(DataBlock*0x2000) + DataOffset);
|
||||
u16 *paldata = (u16*)(mc_data +(DataBlock*0x2000) + DataOffset + pixels);
|
||||
@ -435,8 +434,7 @@ u32 GCMemcard::ReadAnimRGBA8(u32 index, u32* buffer, u8 *delays)
|
||||
|
||||
int flags = dir.Dir[index].BIFlags;
|
||||
|
||||
bool hasBanner = (flags&2)!=0;
|
||||
bool fmtIsCI8 = (flags&1)!=0;
|
||||
int bnrFormat = (flags&3);
|
||||
|
||||
u32 DataOffset=BE32(dir.Dir[index].ImageOffset);
|
||||
u32 DataBlock =BE16(dir.Dir[index].FirstBlock)-5;
|
||||
@ -446,12 +444,17 @@ u32 GCMemcard::ReadAnimRGBA8(u32 index, u32* buffer, u8 *delays)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8* animData=(u8* )(mc_data +(DataBlock*0x2000) + DataOffset);
|
||||
u8* animData=(u8*)(mc_data +(DataBlock*0x2000) + DataOffset);
|
||||
|
||||
if(hasBanner)
|
||||
switch(bnrFormat)
|
||||
{
|
||||
if(fmtIsCI8) animData+=96*32 + 2*256; // image+palette
|
||||
else animData+=96*32*2;
|
||||
case 1:
|
||||
case 3:
|
||||
animData+=96*32 + 2*256; // image+palette
|
||||
break;
|
||||
case 2:
|
||||
animData+=96*32*2;
|
||||
break;
|
||||
}
|
||||
|
||||
int fmts[8];
|
||||
@ -461,8 +464,8 @@ u32 GCMemcard::ReadAnimRGBA8(u32 index, u32* buffer, u8 *delays)
|
||||
|
||||
for(int i=0;i<8;i++)
|
||||
{
|
||||
fmts[i] = formats>>(2*i);
|
||||
delays[i] = (fdelays>>(2*i))<<2;
|
||||
fmts[i] = (formats>>(2*i))&3;
|
||||
delays[i] = ((fdelays>>(2*i))&3)<<2;
|
||||
data[i] = animData;
|
||||
|
||||
switch(fmts[i])
|
||||
|
@ -63,8 +63,13 @@ public:
|
||||
u8 BIFlags; //0x07 0x01 banner gfx format and icon animation (Image Key)
|
||||
// bit(s) description
|
||||
// 2 Icon Animation 0: forward 1: ping-pong
|
||||
// 1 0: No Banner 1: Banner present
|
||||
// 0 Banner Color 0: RGB5A3 1: CI8
|
||||
// 1 [--0: No Banner 1: Banner present--] WRONG! YAGCD LIES!
|
||||
// 0 [--Banner Color 0: RGB5A3 1: CI8--] WRONG! YAGCD LIES!
|
||||
// bits 0 and 1: image format
|
||||
// 00 no banner
|
||||
// 01 CI8 banner
|
||||
// 01 RGB5A3 banner
|
||||
// 11 ? maybe ==01? haven't seen it
|
||||
//
|
||||
u8 Filename[32]; //0x08 0x20 filename
|
||||
u8 ModTime[4]; //0x28 0x04 Time of file's last modification in seconds since 12am, January 1st, 2000
|
||||
|
Loading…
x
Reference in New Issue
Block a user