Man, I don't want this to turn into "MMG's help with coding corner" but I have an odd issue that just doesn't make sense to me from a coding standpoint.
I'm currently working on my vertical slice demo, where you interact with the priest, so everything is priest.c, priest2.c, etc, you get the idea.
In priest.c I play a bit of an intro animation and then some lip flaps:
priest.c:
int priestStart(void) {
...
install_int(priestIntro, 9999);
install_int(priestTalk, 9999);
/*character intro sequence*/
play_midi(priestData[PRIESTMID].dat, 0);
while (priest_x > 250)
{
while (priest_y < 100)
{
clear_to_color(priestBuffer, makecol(0,0,0));
blit(priestData[CHURCH].dat, priestBuffer, 0, 0, 5, 5, 630, 280);
priestIntro();
...
blit(priestBuffer, screen, 0, 0, 0, 0, priestBuffer->w, priestBuffer->h);
clear_bitmap(priestBuffer);
}
}
remove_int(priestIntro);
//do the talking
while (priestAnim < 20)
{
clear_to_color(priestBuffer, makecol(0,0,0));
blit(priestData[CHURCH].dat, priestBuffer, 0, 0, 5, 5, 630, 280);
textprintf_ex(priestBuffer, font, 0, 80, makecol(255, 255, 0), -1, "PRIESTANIM %d", priestAnim);
textout_ex(priestBuffer, npcFont, priestSays, 30, 290, makecol(83, 255, 93), -1);
priestTalk();
blit(priestBuffer, screen, 0, 0, 0, 0, priestBuffer->w, priestBuffer->h);
clear_bitmap(priestBuffer);
}
remove_int(priestTalk);
...
}
void priestTalk() {
rest(99);
//play some animation here
if (priestAnim % 2)
{
blit(priestData[PRIESTCHAR2].dat, priestBuffer, 0, 0, priest_x, priest_y, 100, 150);
} else {
blit(priestData[PRIESTCHAR].dat, priestBuffer, 0, 0, priest_x, priest_y, 100, 150);
}
++priestAnim;
}
I have the rest(99) and timer(9999) in there so the animation doesn't fly by in a fraction of a second. What's weird though is that I tried to recreate the same behaviour once you proceed to priest2 but it hangs on the rest command (if it's not set to 0):
priest2.c:
int priestPhaseTwo(int selection) {
...
install_int(priest2Talk, 10);
priest2Anim = 0;
...
while (priest2Anim < 20)
{
clear_to_color(priestBuffer, makecol(0,0,0));
blit(priestData[CHURCH].dat, priestBuffer, 0, 0, 5, 5, 630, 280);
textout_ex(priestBuffer, npcFont, priestSays, 30, 290, makecol(83, 255, 93), -1);
priest2Talk();
blit(priestBuffer, screen, 0, 0, 0, 0, priestBuffer->w, priestBuffer->h);
clear_bitmap(priestBuffer);
}
remove_int(priest2Talk);
...
}
void priest2Talk() {
//play some animation here
rest(99);
if (priest2Anim % 2)
{
blit(priestData[PRIESTCHAR2].dat, priestBuffer, 0, 0, priest_x, priest_y, 100, 150);
} else {
blit(priestData[PRIESTCHAR].dat, priestBuffer, 0, 0, priest_x, priest_y, 100, 150);
}
++priest2Anim;
}
It's weird, as I'm not getting any SIGSEGV faults, it's just if it's set to rest(0) it works (and the animation plays before a human eye can see it) or if rest is set to anything other than 0 it hangs.
Is there some form of memory cleanup or processing I'm missing here? I admit this part of my coding skill is pretty threadbare, didn't have to worry about wait times and sleeps when coding websites in C#.