@GTV reviews the Cosmic Fantasy 1-2 Switch collection by Edia, provides examples of the poor English editing/localization work. It's much worse for CF1. Rated "D" for disappointment, finding that TurboGrafx CF2 is better & while CF1's the real draw, Edia screwed it up...
Main Menu

Critique my various animation techniques

Started by DildoKKKobold, 12/21/2016, 04:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DildoKKKobold

Difficulty - No "Assembly is better"

In our final level, we are using a lot of animations. Big sprites moving around. Lots of combined animations to step through. However, since there is no player input, we don't need to care too much about CPU usage, more just code size.

In reality, I was just curious what people thought of the two techniques I'm alternating between.

#1
char animstate, animtimer;
animtimer = 30;
for (i=0; i < 120; i++)
{
animtimer--;
if (!animtimer)
{  if (!animstate)
    { do stuffs(0)
       animstate = 1;
    }
    else
   {
      do stuffs(1)
       animstate = 0;
  }
 animtimer = 30;
}
 do other stuffs
 vsync();
}

#2

for (i=0; i < 120; i++)
{
if (!(i%60))

   do stuffs(1)
  }
else if (!(i%30))
{
 do stuffs(0)
}
 do other stuffs
 vsync();
}

I really like #2, because its super fast to write, and doesn't require a whole lot of extra variables to keep track of. I have this feeling that (!(i%X)) generates nasty assembly code.
AvatarDildoKKKobold.jpg
For a good time, email: kylethomson@gmail.com
Dildos provided free of charge, no need to bring your own! :lol:
DoxPhile .com / chat
IMG

TurboXray

For the !(i%60) part, I think you can do:
 if(i== 60 || i==0)

 And for !(i%30)
 if(i==90 ||  i==30 )

 Because of your else if, cases of 60 and 0 won't trigger on the i%30 part. And 120 is never a case because the loop maxes at 119.

Arkhan Asylum

Approach 1 can be simplified assuming stuffs() is indeed a single function that takes in a variable:

char animstate, animtimer;

for (i=0, animtimer = 30; i < 120; i++,animtimer--)
{
if (!animtimer)

dostuffs(animstate);
animstate ^= 1; /* this will toggle animstate every 30 frames, like you want */
animtimer = 30;
}
do other stuffs
vsync();
}

you might not be allowed to do multiple variables in a forloop in HuC.  I can't remember if it's possible.

If it doesn't let you, just move animtimer back out of the loop to define it, and decrement it at the start of the loop.


Approach #2 is no longer relevant, because Approach #1 is now easier to write, and I think will also be faster.  I am not 100% sure on the speed without seeing what HuC actually does for the two.

Using what Tom said for your second approach is probably the best idea unless you want to setup a jump table instead.



This "max-level forum psycho" (:lol:) destroyed TWO PC Engine groups in rage: one by Aaron Lambert on Facebook "Because Chris 'Shadowland' Runyon!," then the other by Aaron Nanto "Because Le NightWolve!" Him and PCE Aarons don't have a good track record together... Both times he blamed the Aarons in a "Look-what-you-made-us-do?!" manner, never himself nor his deranged, destructive, toxic turbo troll gang!