void FadeToPtr(void *PalettePtr) { Word Count; Word i; int DestPalette[32*4]; /* Must be SIGNED! */ Byte WorkPalette[32*4]; if (!memcmp((char *)PalettePtr,(char *)CurrentPalette,32*4)) { /* Same palette? */ return; } memcpy(WorkPalette,CurrentPalette,32*4); /* Save the current palette */ i = 0; do { DestPalette[i]=((Byte *)PalettePtr)[i]-WorkPalette[i]; /* Get differances */ } while (++i<32*4); Count = 1; do { i = 1; /* Skip #0 */ do { if (i&3) { /* Only affect the RGB values, not the counter */ CurrentPalette[i] = ((DestPalette[i]*(int)Count)>>4)+WorkPalette[i]; } } while (++i<32*4); WaitTicks(FadeTimer); /* 1/15th of a second */ SetAPalettePtr(CurrentPalette); } while (++Count<17); }
static void RollRatio(Word x,Word y,Word ratio) { Word i; Word NoDelay; i = 0; NoDelay = 0; while (i<ratio) { DrawRatio(x,y,i); PlaySound(SND_MGUN|0x8000); ShowBJ(); if (WaitTicksEvent(6)) { NoDelay = 1; break; } i+=10; } DrawRatio(x,y,ratio); /* make ding sound */ if (ratio==100) { if (!NoDelay) { PlaySound(SND_EXTRA); WaitTicks(30); } BonusScore += 10000; DrawIBonus(); if (!NoDelay) { BJBreath(60); /* Breath a little */ } } }
void CharacterCast(void) { Word Enemy,count, cycle; Word up; state_t *StatePtr; /* reload level and set things up */ gamestate.mapon = 0; /* First level again */ PrepPlayLoop(); /* Prepare the system */ viewx = actors[0].x; /* Mark the starting x,y */ viewy = actors[0].y; topspritescale = 32*2; /* go through the cast */ Enemy = 0; cycle = 0; do { StatePtr = &states[caststate[Enemy]]; /* Init the state pointer */ count = 1; /* Force a fall through on first pass */ up = FALSE; for (;;) { if (++cycle>=60*4) { /* Time up? */ cycle = 0; /* Reset the clock */ if (++Enemy>=NUMCAST) { /* Next bad guy */ Enemy = 0; /* Reset the bad guy */ } break; } if (!--count) { count = StatePtr->tictime; StatePtr = &states[StatePtr->next]; } topspritenum = StatePtr->shapenum; /* Set the formost shape # */ RenderView(); /* Show the 3d view */ WaitTicks(1); /* Limit to 15 frames a second */ ReadSystemJoystick(); /* Read the joystick */ if (!joystick1 && !up) { up = TRUE; continue; } if (!up) { continue; } if (!joystick1) { continue; } if (joystick1 & (JOYPAD_START|JOYPAD_A|JOYPAD_B|JOYPAD_X|JOYPAD_Y)) { Enemy = NUMCAST; break; } if ( (joystick1 & (JOYPAD_TL|JOYPAD_LFT)) && Enemy >0) { Enemy--; break; } if ( (joystick1 & (JOYPAD_TR|JOYPAD_RGT)) && Enemy <NUMCAST-1) { Enemy++; break; } } } while (Enemy < NUMCAST); /* Still able to show */ StopSong(); /* Stop the music */ FadeToBlack(); /* Fade out */ }