mirror of
https://github.com/suloku/gcmm.git
synced 2026-04-24 23:08:10 -05:00
Fixed typo (previous revision only animated well icons with 8 frames)
Simplified icon animation logic
This commit is contained in:
parent
17daeaf37c
commit
4952ad60a3
|
|
@ -45,8 +45,8 @@ extern u16 icondataRGB[8][1024] ATTRIBUTE_ALIGN (32);
|
|||
extern u16 tlut[9][256] ATTRIBUTE_ALIGN (32);
|
||||
extern u16 tlutbanner[256] ATTRIBUTE_ALIGN (32);
|
||||
extern int numicons;
|
||||
extern int icontable[8];
|
||||
extern int lasticon;
|
||||
extern int frametable[8];
|
||||
extern int lastframe;
|
||||
extern Header cardheader;
|
||||
extern s32 memsize, sectsize;
|
||||
extern syssramex *sramex;
|
||||
|
|
@ -1054,7 +1054,7 @@ static void ShowFiles (int offset, int selection, int upordown, int saveinfo) {
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_VALUES
|
||||
static u8 CalculateFrameRate()
|
||||
{
|
||||
static u8 frameCount = 0;
|
||||
|
|
@ -1070,7 +1070,7 @@ static u8 CalculateFrameRate()
|
|||
}
|
||||
return FPS;
|
||||
}
|
||||
|
||||
#endif
|
||||
int getdurationmilisecs(u16 icon_speed, int index)
|
||||
{
|
||||
int speed = ((icon_speed >> (2*index))&CARD_SPEED_MASK)*4;
|
||||
|
|
@ -1102,8 +1102,7 @@ int ShowSelector (int saveinfo)
|
|||
int offset = 0;//further determines redraw conditions
|
||||
int selection = 0;
|
||||
//animated icon display vars
|
||||
int curricon = 0;
|
||||
int iconwait = 0;
|
||||
int currframe = 0;
|
||||
int reverse = 0;
|
||||
|
||||
u64 lasttime, currtime;
|
||||
|
|
@ -1135,73 +1134,52 @@ int ShowSelector (int saveinfo)
|
|||
|
||||
//reinit variables
|
||||
redraw = 0;
|
||||
curricon = 1;
|
||||
reverse = 0;
|
||||
iconwait = 1;
|
||||
currframe = 1;
|
||||
lasttime = ticks_to_millisecs(gettime());
|
||||
|
||||
}
|
||||
#ifdef DEBUG_VALUES
|
||||
sprintf (test, "FPS%d numicons%d CI%d LI%d iTiw%d iw%d anim%d speed%d", fps, numicons, curricon, lasticon, icontable[iconwait],iconwait, CHECK_BIT(gci.banner_fmt,2), ((gci.icon_speed >> (2*iconwait))&CARD_SPEED_MASK)*4 );
|
||||
sprintf (test, "FPS%d numicons%d CF%d LF%d FT%d animtype%d speed%d", fps, numicons, currframe, lastframe, frametable[currframe], CHECK_BIT(gci.banner_fmt,2), ((gci.icon_speed >> (2*currframe))&CARD_SPEED_MASK)*4 );
|
||||
ShowAction(test);
|
||||
#endif
|
||||
|
||||
if (numicons > 1){
|
||||
|
||||
if((currtime - lasttime) >= getdurationmilisecs(gci.icon_speed, iconwait) ){
|
||||
//If there's an icon show it, if not just wait
|
||||
//if (((gci.icon_speed >> (2*iconwait))&CARD_SPEED_MASK)){
|
||||
if (icontable[iconwait]){
|
||||
if ( ((gci.icon_fmt >> (2*iconwait))&CARD_ICON_MASK)== 1) {
|
||||
if((currtime - lasttime) >= getdurationmilisecs(gci.icon_speed, currframe) ){
|
||||
//If there's a real icon show it, if not just wait until next icon frame
|
||||
if (frametable[currframe]){
|
||||
if ( ((gci.icon_fmt >> (2*currframe))&CARD_ICON_MASK)== 1) {
|
||||
//CI with shared palette
|
||||
iconloadCI(icondata[curricon], tlut[8]);
|
||||
iconloadCI(icondata[currframe], tlut[8]);
|
||||
}
|
||||
else if ( ((gci.icon_fmt >> (2*iconwait))&CARD_ICON_MASK)== 3) {
|
||||
iconloadCI(icondata[curricon], tlut[curricon]);
|
||||
else if ( ((gci.icon_fmt >> (2*currframe))&CARD_ICON_MASK)== 3) {
|
||||
iconloadCI(icondata[currframe], tlut[currframe]);
|
||||
}
|
||||
else if ( ((gci.icon_fmt >> (2*iconwait))&CARD_ICON_MASK)== 2) {
|
||||
iconloadRGB(icondataRGB[curricon]);
|
||||
else if ( ((gci.icon_fmt >> (2*currframe))&CARD_ICON_MASK)== 2) {
|
||||
iconloadRGB(icondataRGB[currframe]);
|
||||
}
|
||||
ShowScreen();
|
||||
//Check animation type (ping pong style if true)
|
||||
if (CHECK_BIT(gci.banner_fmt,2)){
|
||||
if (reverse) curricon --;
|
||||
if (!reverse) curricon ++;
|
||||
//Bounce back
|
||||
if (curricon >= numicons){
|
||||
reverse = 1;
|
||||
curricon = numicons -2;
|
||||
}
|
||||
if (curricon < 0){
|
||||
reverse = 0;
|
||||
curricon = 1;
|
||||
}
|
||||
}else{
|
||||
curricon ++;
|
||||
//start from first icon
|
||||
if (curricon >= numicons){
|
||||
curricon = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Each bit pair in gci.icon_speed states for an icon's speed.
|
||||
//Blank bit pairs can be used to delay the animation
|
||||
//Check animation type (ping pong style if true)
|
||||
if (CHECK_BIT(gci.banner_fmt,2)){
|
||||
if (reverse) iconwait --;
|
||||
if (!reverse) iconwait ++;
|
||||
if (reverse) currframe --;
|
||||
if (!reverse) currframe ++;
|
||||
//Bounce back
|
||||
if (iconwait > lasticon){
|
||||
iconwait = lasticon -1;
|
||||
}
|
||||
if (iconwait < 0){
|
||||
iconwait = 1;
|
||||
if (currframe > lastframe){
|
||||
reverse = 1;
|
||||
currframe = lastframe -1;
|
||||
}else if (currframe < 0){
|
||||
reverse = 0;
|
||||
currframe = 1;
|
||||
}
|
||||
}else{
|
||||
iconwait ++;
|
||||
if (iconwait > lasticon){
|
||||
iconwait = 0;
|
||||
currframe ++;
|
||||
if (currframe > lastframe){
|
||||
currframe = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ u16 bannerdata[CARD_BANNER_W*CARD_BANNER_H] ATTRIBUTE_ALIGN (32);
|
|||
Needs decoding by bannerloadCI function before we can show it ***/
|
||||
u8 bannerdataCI[CARD_BANNER_W*CARD_BANNER_H] ATTRIBUTE_ALIGN (32);
|
||||
int numicons;
|
||||
int icontable[8];
|
||||
int lasticon;
|
||||
int frametable[8];
|
||||
int lastframe;
|
||||
/*** This matrix will serve as our array of filenames for each file on the card
|
||||
We add 10 to filenamelen since we add on game company info***/
|
||||
u8 filelist[1024][1024];
|
||||
|
|
@ -262,7 +262,7 @@ int CardReadFileHeader (int slot, int id)
|
|||
char gamecode[6];
|
||||
int filesize;
|
||||
int i;
|
||||
u16 check, check2;
|
||||
u16 check_fmt, check_speed;
|
||||
|
||||
if (id >= cardcount)
|
||||
{
|
||||
|
|
@ -345,50 +345,56 @@ int CardReadFileHeader (int slot, int id)
|
|||
offset += 512;
|
||||
}
|
||||
//Icon data
|
||||
check = gci.icon_fmt;
|
||||
check2 = gci.icon_speed;
|
||||
check_fmt = gci.icon_fmt;
|
||||
check_speed = gci.icon_speed;
|
||||
int shared_pal = 0;
|
||||
lasticon = 0;
|
||||
lastframe = 0;
|
||||
numicons = 0;
|
||||
for (i=0;i<8;i++){
|
||||
icontable[i] = 0;
|
||||
//Animation speed is mandatory to be set even for a singe icon
|
||||
//this stores if the frame has a real icon or not
|
||||
//no need to clear all values since we will only use the ones until last frame
|
||||
frametable[i] = 0;
|
||||
|
||||
//Animation speed is mandatory to be set even for a single icon
|
||||
//When a speed is 0 there are no more icons
|
||||
//Some games may have bits set after the "blank icon" both in
|
||||
//speed (Baten Kaitos) and format (Wario Ware Inc.) bytes, which are just garbage
|
||||
if (!(check2&CARD_ICON_MASK)){
|
||||
//There are no more icons
|
||||
lasticon=-1;
|
||||
if (!(check_speed&CARD_ICON_MASK)){
|
||||
break;
|
||||
}
|
||||
//count the number of icons
|
||||
if (check & CARD_ICON_MASK){
|
||||
}else
|
||||
{//We've got a frame
|
||||
lastframe=i;
|
||||
|
||||
if (check_fmt & CARD_ICON_MASK){
|
||||
//count the number of real icons
|
||||
numicons++;
|
||||
icontable[i]=1;
|
||||
}
|
||||
//CI with shared palette
|
||||
if ((check&CARD_ICON_MASK) == 1) {
|
||||
memcpy(icondata[numicons-1], offset, 1024);
|
||||
offset += 1024;
|
||||
shared_pal = 1;
|
||||
}
|
||||
//CI with palette after the icon
|
||||
else if ((check&CARD_ICON_MASK) == 3)
|
||||
{
|
||||
memcpy(icondata[numicons-1], offset, 1024);
|
||||
offset += 1024;
|
||||
memcpy(tlut[numicons-1], offset, 512);
|
||||
offset += 512;
|
||||
}
|
||||
//RGB 16 bit icon
|
||||
else if ((check&CARD_ICON_MASK) == 2)
|
||||
{
|
||||
memcpy(icondataRGB[numicons-1], offset, 2048);
|
||||
offset += 2048;
|
||||
frametable[i]=1; //There's a real icon
|
||||
|
||||
//CI with shared palette
|
||||
if ((check_fmt&CARD_ICON_MASK) == 1) {
|
||||
memcpy(icondata[i], offset, 1024);
|
||||
offset += 1024;
|
||||
shared_pal = 1;
|
||||
}
|
||||
//CI with palette after the icon
|
||||
else if ((check_fmt&CARD_ICON_MASK) == 3)
|
||||
{
|
||||
memcpy(icondata[i], offset, 1024);
|
||||
offset += 1024;
|
||||
memcpy(tlut[i], offset, 512);
|
||||
offset += 512;
|
||||
}
|
||||
//RGB 16 bit icon
|
||||
else if ((check_fmt&CARD_ICON_MASK) == 2)
|
||||
{
|
||||
memcpy(icondataRGB[i], offset, 2048);
|
||||
offset += 2048;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check = check >> 2;
|
||||
check2 = check2 >> 2;
|
||||
check_fmt = check_fmt >> 2;
|
||||
check_speed = check_speed >> 2;
|
||||
}
|
||||
//Get the shared palette
|
||||
if (shared_pal) memcpy(tlut[8], offset, 512);
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ extern u16 icondataRGB[8][1024] ATTRIBUTE_ALIGN (32);
|
|||
extern u16 tlut[9][256] ATTRIBUTE_ALIGN (32);
|
||||
extern u16 tlutbanner[256] ATTRIBUTE_ALIGN (32);
|
||||
extern int numicons;
|
||||
extern int icontable[8];
|
||||
extern int lasticon;
|
||||
extern int frametable[8];
|
||||
extern int lastframe;
|
||||
extern u8 filelist[1024][1024];
|
||||
extern u32 maxfile;
|
||||
extern GCI gci;
|
||||
|
|
@ -254,7 +254,7 @@ int SDLoadMCImageHeader(char *sdfilename)
|
|||
//int bytesToRead = 0;
|
||||
long bytesToRead = 0;
|
||||
int i;
|
||||
u16 check, check2;
|
||||
u16 check_fmt, check_speed;
|
||||
|
||||
/*** Clear the work buffers ***/
|
||||
memset (FileBuffer, 0, MAXFILEBUFFER);
|
||||
|
|
@ -408,47 +408,52 @@ int SDLoadMCImageHeader(char *sdfilename)
|
|||
fread(tlutbanner, 1, 512, handle);
|
||||
}
|
||||
//Icon data
|
||||
check = gci.icon_fmt;
|
||||
check2 = gci.icon_speed;
|
||||
check_fmt = gci.icon_fmt;
|
||||
check_speed = gci.icon_speed;
|
||||
int shared_pal = 0;
|
||||
lasticon = 0;
|
||||
lastframe = 0;
|
||||
numicons = 0;
|
||||
for (i=0;i<8;i++){
|
||||
icontable[i] = 0;
|
||||
//Animation speed is mandatory to be set even for a singe icon
|
||||
//this stores if the frame has a real icon or not
|
||||
//no need to clear all values since we will only use the ones until last frame
|
||||
frametable[i] = 0;
|
||||
|
||||
//Animation speed is mandatory to be set even for a single icon
|
||||
//When a speed is 0 there are no more icons
|
||||
//Some games may have bits set after the "blank icon" both in
|
||||
//speed (Baten Kaitos) and format (Wario Ware Inc.) bytes, which are just garbage
|
||||
if (!(check2&CARD_ICON_MASK)){
|
||||
//There are no more icons
|
||||
lasticon=-1;
|
||||
if (!(check_speed&CARD_ICON_MASK)){
|
||||
break;
|
||||
}
|
||||
}else
|
||||
{//We've got a frame
|
||||
lastframe=i;
|
||||
|
||||
//count the number of icons
|
||||
if (check & CARD_ICON_MASK){
|
||||
if (check_fmt & CARD_ICON_MASK){
|
||||
//count the number of real icons
|
||||
numicons++;
|
||||
icontable[i]=1;
|
||||
}
|
||||
//CI with shared palette
|
||||
if ((check&CARD_ICON_MASK) == 1) {
|
||||
fread(icondata[numicons-1], 1, 1024, handle);
|
||||
shared_pal = 1;
|
||||
}
|
||||
//CI with palette after the icon
|
||||
else if ((check&CARD_ICON_MASK) == 3)
|
||||
{
|
||||
fread(icondata[numicons-1], 1, 1024, handle);
|
||||
fread(tlut[numicons-1], 1, 512, handle);
|
||||
}
|
||||
//RGB 16 bit icon
|
||||
else if ((check&CARD_ICON_MASK) == 2)
|
||||
{
|
||||
fread(icondataRGB[numicons-1], 1, 2048, handle);
|
||||
frametable[i]=1; //There's a real icon
|
||||
|
||||
//CI with shared palette
|
||||
if ((check_fmt&CARD_ICON_MASK) == 1) {
|
||||
fread(icondata[i], 1, 1024, handle);
|
||||
shared_pal = 1;
|
||||
}
|
||||
//CI with palette after the icon
|
||||
else if ((check_fmt&CARD_ICON_MASK) == 3)
|
||||
{
|
||||
fread(icondata[i], 1, 1024, handle);
|
||||
fread(tlut[i], 1, 512, handle);
|
||||
}
|
||||
//RGB 16 bit icon
|
||||
else if ((check_fmt&CARD_ICON_MASK) == 2)
|
||||
{
|
||||
fread(icondataRGB[i], 1, 2048, handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check = check >> 2;
|
||||
check2 = check2 >> 2;
|
||||
check_fmt = check_fmt >> 2;
|
||||
check_speed = check_speed >> 2;
|
||||
}
|
||||
//Get the shared palette
|
||||
if (shared_pal) fread(tlut[8], 1, 512, handle);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user