Esempio n. 1
0
void CGeneral::BonusGame()
{
   int i, j, k;
   char dat[] = {0xe9, 0x85, 0x8d, 0x00,
                 0xe7, 0x89, 0x8c, 0x00,
                 0xe5, 0x87, 0xba, 0x00,
                 0xe8, 0xa1, 0x80, 0x00,
                 0xe5, 0xa5, 0x96, 0xe5,
                 0x8a, 0xb1, 0xe6, 0xb8,
                 0xb8, 0xe6, 0x88, 0x8f, 0x00};

   SDL_BlitSurface(m_imgBonusGame, NULL, gpScreen, NULL);
   UpdateScreen();
   PlayMusic(m_musBGame, 0);
   UTIL_Delay(6000);

   bool locked = false;
   if (SDL_MUSTLOCK(gpScreen)) {
      SDL_LockSurface(gpScreen);
      locked = true;
   }

   for (i = 0; i < 640; i++) {
      for (j = 0; j < 480; j++) {
         unsigned char r, g, b;

         k = 0;
         UTIL_GetPixel(gpScreen, i, j, &r, &g, &b);
         k += r;
         k += g;
         k += b;
         k /= 3;
         UTIL_PutPixel(gpScreen, i, j, k, k, k);
      }
   }

   if (locked) {
      SDL_UnlockSurface(gpScreen);
   }

   for (i = 0; i < 4; i++) {
      DrawUTF8Text(&dat[i * 4], 150 + i * 100, 100, 2, 255, 255, 0);
      UpdateScreen();
      PlaySound(SND_SOUND1);
      UTIL_Delay(1300);
   }

   DrawUTF8Text(&dat[i * 4], 175, 200, 2, 0, 255, 255);

   PlaySound(SND_DISCARD2);
   UpdateScreen();
   UTIL_Delay(2500);
   ScreenFade();
}
Esempio n. 2
0
void CGeneral::AnimSelfDrawn(const CTile &t)
{
   EraseArea(20, 265, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 265);
   UpdateScreen(20, 265, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 265);
   int i;
   SDL_Rect dstrect;

   PlaySound(SND_FLASH);
   for (i = 0; i < 12; i++) {
      EraseArea(20, 265, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 265);
      EraseArea(dstrect.x, dstrect.y, dstrect.w, 30);

      dstrect.x = 245;
      dstrect.y = 235;
      dstrect.w = m_imgFlash1->w;
      dstrect.h = m_imgFlash1->h;

      SDL_BlitSurface(m_imgFlash1, NULL, gpScreen, &dstrect);
      DrawTile(t, 280, 255);
      UpdateScreen(20, 235, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 235);

      UTIL_Delay(50);

      EraseArea(20, 265, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 265);
      EraseArea(dstrect.x, dstrect.y, dstrect.w, 30);

      dstrect.w = m_imgFlash2->w;
      dstrect.h = m_imgFlash2->h;

      SDL_BlitSurface(m_imgFlash2, NULL, gpScreen, &dstrect);
      DrawTile(t, 280, 255);
      UpdateScreen(20, 235, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 235);
      UTIL_Delay(50);
   }

   UTIL_Delay(20);
   EraseArea(20, 265, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 265);
   EraseArea(dstrect.x, dstrect.y, dstrect.w, 30);

   dstrect.w = m_imgFlash1->w;
   dstrect.h = m_imgFlash1->h;

   SDL_BlitSurface(m_imgFlash1, NULL, gpScreen, &dstrect);
   DrawTile(t, 280, 255);
   DrawUTF8Text(msg("out_selfdrawn"), 215, 265, 2, 255, 255, 255);
   UpdateScreen(20, 205, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 205);
   UTIL_Delay(1000);
   EraseArea(20, 265, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 265);
   EraseArea(dstrect.x, dstrect.y, dstrect.w, 30);
   UpdateScreen(20, 205, TILE_WIDTH * 10, 303 + TILE_HEIGHT_SHOWN - 205);
}
Esempio n. 3
0
void CGeneral::DrawDotBar(int x, int y, bool anim)
{
   SDL_Rect dstrect, dstrect2;

   dstrect.x = x;
   dstrect2.x = 359;
   dstrect.w = dstrect2.w = 20;

   if (anim) {
      int i;
      for (i = 0; i < 20; i++) {
         dstrect.y = y + (20 - i) * 85 / 40;
         dstrect2.y = 531 + (20 - i) * 85 / 40;
         dstrect.h = dstrect2.h = i * 85 / 20;
         SDL_BlitSurface(m_imgTiles, &dstrect2, gpScreen, &dstrect);
         UpdateScreen(dstrect.x, dstrect.y, dstrect.w, dstrect.h);
         UTIL_Delay(10);
      }
   }

   dstrect.h = dstrect2.h = 85;

   dstrect.y = y;
   dstrect2.y = 531;
   SDL_BlitSurface(m_imgTiles, &dstrect2, gpScreen, &dstrect);
}
Esempio n. 4
0
void CUIManager::PopMessage(const char *text, int timeout)
{
   CBox box(150, 300, 340, 26, 20, 50, 120, false);
   gpGeneral->DrawText(text, 320 - strlen(text) * 4, 305, 255, 255, 50);
   gpGeneral->UpdateScreen(150, 300, 340, 36);
   UTIL_Delay(timeout);
}
Esempio n. 5
0
VOID
PAL_NEW_EndingScreen2(
VOID
)
/*++
Purpose:

显示结尾处的人物介绍,对应95/98版的第六个avi视频

Parameters:

None.

Return value:

None.

--*/
{
	PAL_SetPalette(5, FALSE);//不加这句有可能会出现白屏的情况

	//1141 00A5 0031 FFFF 0007 淡入FBP图片 49 65535 07
	PAL_EndingSetEffectSprite(0x27b);
	PAL_ShowFBP(49, 7);

	//1142 0076 0031 0006 0000 显示FBP图像 49 06
	PAL_EndingSetEffectSprite(0);
	PAL_ShowFBP(49, 6);

	//1143 004D 0000 0000 0000 等待按键
	PAL_WaitForKey(0);

	//1144 0077 0001 0000 0000 停止播放音乐 01
	PAL_PlayMUS(0, FALSE, 0.5);
	UTIL_Delay(500);

	//1145 0043 0009 0003 0000 设置播放音乐 09
	if (!SOUND_PlayCDA(13))
	{
		PAL_PlayMUS(9, TRUE, 0);
	}

	//1146 00A4 0030 0000 0010 卷动FBP图片 48 00 16
	int i = 48;
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);
	PAL_ScrollFBP(i--, 0xf, TRUE);

	//1150 0077 0001 0000 0000 停止播放音乐 01
	PAL_PlayMUS(0, FALSE, 3);

	//1151 0050 0004 0000 0000 全屏淡出
	PAL_FadeOut(3);
}
Esempio n. 6
0
VOID
PAL_WaitForKey(
WORD      wTimeOut
)
/*++
  Purpose:

  Wait for any key.

  Parameters:

  [IN]  wTimeOut - the maximum time of the waiting. 0 = wait forever.

  Return value:

  None.

  --*/
{
	DWORD     dwTimeOut = SDL_GetTicks() + wTimeOut;

	PAL_ClearKeyState();

	while (wTimeOut == 0 || SDL_GetTicks() < dwTimeOut)
	{
		UTIL_Delay(5);

		if (g_InputState.dwKeyPress & (kKeySearch | kKeyMenu))
		{
			break;
		}
	}
}
Esempio n. 7
0
VOID
PAL_WaitForKey(
   VOID
)
/*++
  Purpose:

    Wait for any key.

  Parameters:

    None.

  Return value:

    None.

--*/
{
	LoginInfo("PAL_WaitForKey\n" );   
	PAL_ClearKeyState();

   while (TRUE)
   {
      UTIL_Delay(50);
      if (g_InputState.dwKeyPress & (kKeySearch | kKeyMenu))
      {
         break;
      }
   }
}
Esempio n. 8
0
int CBot::Discard(CCard rgDiscarded[20], bool fFirstHand)
{
   UTIL_Delay(470); // delay a while
   if (fFirstHand) {
      return FirstHandDiscard(rgDiscarded);
   }
   return FollowCard(rgDiscarded);
}
Esempio n. 9
0
/*++
 Enemy flee the battle.
 --*/
VOID PAL_BattleEnemyEscape(void)
{
    int j, x, y, w;
    BOOL f = TRUE;
    
    SOUND_Play(45);
    
    //
    // Show the animation
    //
    while (f)
    {
        f = FALSE;
        
        for (j = 0; j <= g_Battle.wMaxEnemyIndex; j++)
        {
            if (g_Battle.rgEnemy[j].wObjectID == 0)
            {
                continue;
            }
            
            x = PAL_X(g_Battle.rgEnemy[j].pos) - 5;
            y = PAL_Y(g_Battle.rgEnemy[j].pos);
            
            g_Battle.rgEnemy[j].pos = PAL_XY(x, y);
            
            w = PAL_RLEGetWidth(PAL_SpriteGetFrame(g_Battle.rgEnemy[j].lpSprite, 0));
            
            if (x + w > 0)
            {
                f = TRUE;
            }
        }
        
        PAL_BattleMakeScene();
        SDL_BlitSurface(g_Battle.lpSceneBuf, NULL, gpScreen, NULL);
        VIDEO_UpdateScreen(NULL);
        
        UTIL_Delay(10);
    }
    
    UTIL_Delay(500);
    g_Battle.BattleResult = kBattleResultTerminated;
}
Esempio n. 10
0
void CPlayerLocal::BecomeLord(int iLocation, const CCard rgKittyCards[3])
{
   UTIL_Delay(800);
   gpGeneral->EraseArea(220 - 65 / 2, 240 - 65 / 2, 270, 140, true);
   gpGeneral->UpdateScreen(220 - 65 / 2, 240 - 65 / 2, 270, 150);
   g_UI.DrawLord(iLocation);
   g_UI.DrawKittyCard(rgKittyCards);
   g_UI.DrawPlayer(iLocation, iLocation == PLAYER_LOCAL ? m_rgHandCard : NULL,
      20, NULL, -1);
}
Esempio n. 11
0
void CGeneral::Fire()
{
   int i;
   SDL_Surface *save = SDL_CreateRGBSurface(gpScreen->flags & (~SDL_HWSURFACE),
      575, 130, gpScreen->format->BitsPerPixel, gpScreen->format->Rmask,
      gpScreen->format->Gmask, gpScreen->format->Bmask, gpScreen->format->Amask);

   SDL_Rect dstrect;
   dstrect.x = 5;
   dstrect.y = 470 - 130;
   dstrect.w = 575;
   dstrect.h = 130;

   SDL_BlitSurface(gpScreen, &dstrect, save, NULL);

   UTIL_Delay(400);
   PlaySound(SND_FIRE);

   for (i = 0; i < 6; i++) {
      dstrect.y = 470 - 125;
      dstrect.h = 125;

      SDL_BlitSurface(m_imgFire1, NULL, gpScreen, &dstrect);
      UpdateScreen(0, 470 - 130, 575, 130);
      UTIL_Delay(100);

      dstrect.y = 470 - 130;
      dstrect.h = 130;

      SDL_BlitSurface(save, NULL, gpScreen, &dstrect);
      SDL_BlitSurface(m_imgFire2, NULL, gpScreen, &dstrect);
      UpdateScreen(0, 470 - 130, 575, 130);
      UTIL_Delay(100);

      SDL_BlitSurface(save, NULL, gpScreen, &dstrect);
   }
   UpdateScreen(0, 470 - 130, 575, 130);
   SDL_FreeSurface(save);
   UTIL_Delay(100);
}
Esempio n. 12
0
void CUIManager::ScoreBoard(const char rgszPlayerName[3][20], int rgiGotScore[3], int rgiTotalScore[3])
{
   UTIL_Delay(500); // delay a while
   int i;
   m_pScoreBox = new CBox(150, 150, 340, 150, 200, 20, 200);
   gpGeneral->DrawText(msg("got_pt_this_round"), 330, 160, 255, 255, 0);
   gpGeneral->DrawText(msg("total_pt"), 410, 160, 255, 255, 0);
   for (i = 0; i < 3; i++) {
      gpGeneral->DrawText(rgszPlayerName[i], 160, 190 + i * 20, 255, 255, 255);
      gpGeneral->DrawText(va("%8d", rgiGotScore[i]), 330, 190 + i * 20, 255, 255, 255);
      gpGeneral->DrawText(va("%8d", rgiTotalScore[i]), 410, 190 + i * 20, 255, 255, 255);
   }
   const char *pszContinue = msg("continue");
   m_pFakeReadyButton = new CBox(300, 260, 50, 22, 25, 70, 250);
   gpGeneral->DrawText(pszContinue, 325 - strlen(pszContinue) * 4, 263, 255, 255, 0);
   m_fInGame = false;
   g_fLocalReady = false;
}
Esempio n. 13
0
VOID
PAL_ShowDialogText(
   LPCSTR       lpszText
)
/*++
  Purpose:

    Show one line of the dialog text.

  Parameters:

    [IN]  lpszText - the text to be shown.

  Return value:

    None.

--*/
{
   SDL_Rect        rect;
   int             x, y, len = strlen(lpszText);

   PAL_ClearKeyState();
   g_TextLib.bIcon = 0;

   if (gpGlobals->fInBattle && !g_fUpdatedInBattle)
   {
      //
      // Update the screen in battle, or the graphics may seem messed up
      //
      VIDEO_UpdateScreen(NULL);
      g_fUpdatedInBattle = TRUE;
   }

   if (g_TextLib.nCurrentDialogLine > 3)
   {
      //
      // The rest dialogs should be shown in the next page.
      //
      PAL_DialogWaitForKey();
      g_TextLib.nCurrentDialogLine = 0;
      VIDEO_RestoreScreen();
      VIDEO_UpdateScreen(NULL);
   }

   x = PAL_X(g_TextLib.posDialogText);
   y = PAL_Y(g_TextLib.posDialogText) + g_TextLib.nCurrentDialogLine * 18;

   if (g_TextLib.bDialogPosition == kDialogCenterWindow)
   {
      //
      // The text should be shown in a small window at the center of the screen
      //
#ifndef PAL_CLASSIC
      if (gpGlobals->fInBattle && g_Battle.BattleResult == kBattleResultOnGoing)
      {
         PAL_BattleUIShowText(lpszText, 1400);
      }
      else
#endif
      {
         PAL_POS    pos;
         LPBOX      lpBox;

         //
         // Create the window box
         //
         pos = PAL_XY(PAL_X(g_TextLib.posDialogText) - len * 4, PAL_Y(g_TextLib.posDialogText));
         lpBox = PAL_CreateSingleLineBox(pos, (len + 1) / 2, TRUE);

         rect.x = PAL_X(pos);
         rect.y = PAL_Y(pos);
         rect.w = 320 - rect.x * 2 + 32;
         rect.h = 64;

         //
         // Show the text on the screen
         //
         pos = PAL_XY(PAL_X(pos) + 8 + ((len & 1) << 2), PAL_Y(pos) + 10);
         PAL_DrawText(lpszText, pos, 0, FALSE, FALSE);
         VIDEO_UpdateScreen(&rect);

         PAL_DialogWaitForKey();

         //
         // Delete the box
         //
         PAL_DeleteBox(lpBox);
         VIDEO_UpdateScreen(&rect);

         PAL_EndDialog();
      }
   }
   else
   {
      if (g_TextLib.nCurrentDialogLine == 0 &&
         g_TextLib.bDialogPosition != kDialogCenter &&
         (BYTE)lpszText[len - 1] == 0x47 && (BYTE)lpszText[len - 2] == 0xA1)
      {
         //
         // name of character
         //
         PAL_DrawText(lpszText, g_TextLib.posDialogTitle, FONT_COLOR_CYAN_ALT, TRUE, TRUE);
      }
      else
      {
         //
         // normal texts
         //
         char text[3];

         if (!g_TextLib.fPlayingRNG && g_TextLib.nCurrentDialogLine == 0)
         {
            //
            // Save the screen before we show the first line of dialog
            //
            VIDEO_BackupScreen();
         }

         while (lpszText != NULL && *lpszText != '\0')
         {
            switch (*lpszText)
            {
            case '-':
               //
               // Set the font color to Cyan
               //
               if (g_TextLib.bCurrentFontColor == FONT_COLOR_CYAN)
               {
                  g_TextLib.bCurrentFontColor = FONT_COLOR_DEFAULT;
               }
               else
               {
                  g_TextLib.bCurrentFontColor = FONT_COLOR_CYAN;
               }
               lpszText++;
               break;

            case '\'':
               //
               // Set the font color to Red
               //
               if (g_TextLib.bCurrentFontColor == FONT_COLOR_RED)
               {
                  g_TextLib.bCurrentFontColor = FONT_COLOR_DEFAULT;
               }
               else
               {
                  g_TextLib.bCurrentFontColor = FONT_COLOR_RED;
               }
               lpszText++;
               break;

            case '\"':
               //
               // Set the font color to Yellow
               //
               if (g_TextLib.bCurrentFontColor == FONT_COLOR_YELLOW)
               {
                  g_TextLib.bCurrentFontColor = FONT_COLOR_DEFAULT;
               }
               else
               {
                  g_TextLib.bCurrentFontColor = FONT_COLOR_YELLOW;
               }
               lpszText++;
               break;

            case '$':
               //
               // Set the delay time of text-displaying
               //
               g_TextLib.iDelayTime = atoi(lpszText + 1) * 10 / 7;
               lpszText += 3;
               break;

            case '~':
               //
               // Delay for a period and quit
               //
               UTIL_Delay(atoi(lpszText + 1) * 80 / 7);
               g_TextLib.nCurrentDialogLine = 0;
               g_TextLib.fUserSkip = FALSE;
               return; // don't go further

            case ')':
               //
               // Set the waiting icon
               //
               g_TextLib.bIcon = 1;
               lpszText++;
               break;

            case '(':
               //
               // Set the waiting icon
               //
               g_TextLib.bIcon = 2;
               lpszText++;
               break;

            case '\\':
               lpszText++;

            default:
               if (*lpszText & 0x80)
               {
                  text[0] = lpszText[0];
                  text[1] = lpszText[1];
                  text[2] = '\0';
                  lpszText += 2;
               }
               else
               {
                  text[0] = *lpszText;
                  text[1] = '\0';
                  lpszText++;
               }

               PAL_DrawText(text, PAL_XY(x, y), g_TextLib.bCurrentFontColor, TRUE, TRUE);
               x += ((text[0] & 0x80) ? 16 : 8);

               if (!g_TextLib.fUserSkip)
               {
                  PAL_ClearKeyState();
                  UTIL_Delay(g_TextLib.iDelayTime * 8);

                  if (g_InputState.dwKeyPress & (kKeySearch | kKeyMenu))
                  {
                     //
                     // User pressed a key to skip the dialog
                     //
                     g_TextLib.fUserSkip = TRUE;
                  }
               }
            }
         }

         g_TextLib.posIcon = PAL_XY(x, y);
         g_TextLib.nCurrentDialogLine++;
      }
   }
}
Esempio n. 14
0
static VOID
PAL_DialogWaitForKey(
   VOID
)
/*++
  Purpose:

    Wait for player to press a key after showing a dialog.

  Parameters:

    None.

  Return value:

    None.

--*/
{
   PAL_LARGE SDL_Color   palette[256];
   SDL_Color   *pCurrentPalette, t;
   int         i;

   //
   // get the current palette
   //
   pCurrentPalette = PAL_GetPalette(gpGlobals->wNumPalette, gpGlobals->fNightPalette);
   memcpy(palette, pCurrentPalette, sizeof(palette));

   if (g_TextLib.bDialogPosition != kDialogCenterWindow &&
      g_TextLib.bDialogPosition != kDialogCenter)
   {
      //
      // show the icon
      //
      LPCBITMAPRLE p = PAL_SpriteGetFrame(g_TextLib.bufDialogIcons, g_TextLib.bIcon);
      if (p != NULL)
      {
         SDL_Rect rect;

         rect.x = PAL_X(g_TextLib.posIcon);
         rect.y = PAL_Y(g_TextLib.posIcon);
         rect.w = 16;
         rect.h = 16;

         PAL_RLEBlitToSurface(p, gpScreen, g_TextLib.posIcon);
         VIDEO_UpdateScreen(&rect);
      }
   }

   PAL_ClearKeyState();

   while (TRUE)
   {
      UTIL_Delay(100);

      if (g_TextLib.bDialogPosition != kDialogCenterWindow &&
         g_TextLib.bDialogPosition != kDialogCenter)
      {
         //
         // palette shift
         //
         t = palette[0xF9];
         for (i = 0xF9; i < 0xFE; i++)
         {
            palette[i] = palette[i + 1];
         }
         palette[0xFE] = t;

         VIDEO_SetPalette(palette);
      }

      if (g_InputState.dwKeyPress != 0)
      {
         break;
      }
   }

   if (g_TextLib.bDialogPosition != kDialogCenterWindow &&
      g_TextLib.bDialogPosition != kDialogCenter)
   {
      PAL_SetPalette(gpGlobals->wNumPalette, gpGlobals->fNightPalette);
   }

   PAL_ClearKeyState();

   g_TextLib.fUserSkip = FALSE;
}
Esempio n. 15
0
VOID
PAL_FadeIn(
   INT         iPaletteNum,
   BOOL        fNight,
   INT         iDelay
)
/*++
  Purpose:

    Fade in the screen to the specified palette.

  Parameters:

    [IN]  iPaletteNum - number of the palette.

    [IN]  fNight - whether use the night palette or not.

    [IN]  iDelay - delay time for each step.

  Return value:

    None.

--*/
{
   int                      i, j;
   UINT                     time;
   SDL_Color               *palette;
   PAL_LARGE SDL_Color      newpalette[256];

   //
   // Get the new palette...
   //
   palette = PAL_GetPalette(iPaletteNum, fNight);

   //
   // Start fading in...
   //
   time = SDL_GetTicks() + iDelay * 10 * 60;
   while (TRUE)
   {
      //
      // Set the current palette...
      //
      j = (int)(time - SDL_GetTicks()) / iDelay / 10;
      if (j < 0)
      {
         break;
      }

      j = 60 - j;

      for (i = 0; i < 256; i++)
      {
         newpalette[i].r = (palette[i].r * j) >> 6;
         newpalette[i].g = (palette[i].g * j) >> 6;
         newpalette[i].b = (palette[i].b * j) >> 6;
      }

      VIDEO_SetPalette(newpalette);

      UTIL_Delay(10);
   }

   VIDEO_SetPalette(palette);
}
Esempio n. 16
0
/*++
 The main battle routine.
 
 Return value:
 The result of the battle.
 --*/
static BATTLERESULT PAL_BattleMain(void)
{
    int         i;
    DWORD       dwTime;
    
    VIDEO_BackupScreen();
    
    //
    // Generate the scene and draw the scene to the screen buffer
    //
    PAL_BattleMakeScene();
    SDL_BlitSurface(g_Battle.lpSceneBuf, NULL, gpScreen, NULL);
    
    //
    // Fade out the music and delay for a while
    //
    PAL_PlayMUS(0, FALSE, 1);
    UTIL_Delay(200);
    
    //
    // Switch the screen
    //
    VIDEO_SwitchScreen(5);
    
    //
    // Play the battle music
    //
    PAL_PlayMUS(gpGlobals->wNumBattleMusic, TRUE, 0);
    
    //
    // Fade in the screen when needed
    //
    if (gpGlobals->fNeedToFadeIn)
    {
        PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
        gpGlobals->fNeedToFadeIn = FALSE;
    }
    
    //
    // Run the pre-battle scripts for each enemies
    //
    for (i = 0; i <= g_Battle.wMaxEnemyIndex; i++)
    {
        g_Battle.rgEnemy[i].wScriptOnTurnStart =
        PAL_RunTriggerScript(g_Battle.rgEnemy[i].wScriptOnTurnStart, i);
        
        if (g_Battle.BattleResult != kBattleResultPreBattle)
        {
            break;
        }
    }
    
    if (g_Battle.BattleResult == kBattleResultPreBattle)
    {
        g_Battle.BattleResult = kBattleResultOnGoing;
    }
    
#ifndef PAL_CLASSIC
    PAL_UpdateTimeChargingUnit();
#endif
    
    dwTime = SDL_GetTicks();
    
    PAL_ClearKeyState();
    
    //
    // Run the main battle loop.
    //
    while (TRUE)
    {
        //
        // Break out if the battle ended.
        //
        if (g_Battle.BattleResult != kBattleResultOnGoing)
        {
            break;
        }
        
        //
        // Wait for the time of one frame. Accept input here.
        //
        PAL_ProcessEvent();
        while (SDL_GetTicks() <= dwTime)
        {
            PAL_ProcessEvent();
            SDL_Delay(1);
        }
        
        //
        // Set the time of the next frame.
        //
        dwTime = SDL_GetTicks() + BATTLE_FRAME_TIME;
        
        //
        // Run the main frame routine.
        //
        PAL_BattleStartFrame();
        
        //
        // Update the screen.
        //
        VIDEO_UpdateScreen(NULL);
    }
    
    //
    // Return the battle result
    //
    return g_Battle.BattleResult;
}
Esempio n. 17
0
VOID
PAL_ShowFBP(
WORD         wChunkNum,
WORD         wFade
)
/*++
  Purpose:

  Draw an FBP picture to the screen.

  Parameters:

  [IN]  wChunkNum - number of chunk in fbp.mkf file.

  [IN]  wFade - fading speed of showing the picture.

  Return value:

  None.

  --*/
{
	PAL_LARGE BYTE            buf[320 * 200];
	PAL_LARGE BYTE            bufSprite[320 * 200];
	const int                 rgIndex[6] = {0, 3, 1, 5, 2, 4};
	SDL_Surface              *p;
	int                       i, j, k;
	BYTE                      a, b;

	if (PAL_MKFDecompressChunk(buf, 320 * 200, wChunkNum, gpGlobals->f.fpFBP) <= 0)
	{
		memset(buf, 0, sizeof(buf));
	}

	if (g_wCurEffectSprite != 0)
	{
		PAL_MKFDecompressChunk(bufSprite, 320 * 200, g_wCurEffectSprite, gpGlobals->f.fpMGO);
	}

	if (wFade)
	{
		wFade++;
		wFade *= 10;

		p = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
			gpScreen->format->Rmask, gpScreen->format->Gmask,
			gpScreen->format->Bmask, gpScreen->format->Amask);
#if SDL_VERSION_ATLEAST(2, 0, 0)
		SDL_SetSurfacePalette(p, gpScreen->format->palette);
#else
		SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
#endif
		PAL_FBPBlitToSurface(buf, p);
		VIDEO_BackupScreen();

		for (i = 0; i < 16; i++)
		{
			for (j = 0; j < 6; j++)
			{
				//
				// Blend the pixels in the 2 buffers, and put the result into the
				// backup buffer
				//
				for (k = rgIndex[j]; k < gpScreen->pitch * gpScreen->h; k += 6)
				{
					a = ((LPBYTE)(p->pixels))[k];
					b = ((LPBYTE)(gpScreenBak->pixels))[k];

					if (i > 0)
					{
						if ((a & 0x0F) > (b & 0x0F))
						{
							b++;
						}
						else if ((a & 0x0F) < (b & 0x0F))
						{
							b--;
						}
					}

					((LPBYTE)(gpScreenBak->pixels))[k] = ((a & 0xF0) | (b & 0x0F));
				}

				SDL_BlitSurface(gpScreenBak, NULL, gpScreen, NULL);

				if (g_wCurEffectSprite != 0)
				{
					int f = SDL_GetTicks() / 150;
					PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufSprite, f % PAL_SpriteGetNumFrames(bufSprite)),
						gpScreen, PAL_XY(0, 0));
				}

				VIDEO_UpdateScreen(NULL);
				UTIL_Delay(wFade);
			}
		}

		SDL_FreeSurface(p);
	}

	//
	// HACKHACK: to make the ending show correctly
	//
#ifdef PAL_WIN95
	if (wChunkNum != 68)
#else
	if (wChunkNum != 49)
#endif
	{
		PAL_FBPBlitToSurface(buf, gpScreen);
	}

	VIDEO_UpdateScreen(NULL);
}
Esempio n. 18
0
VOID
PAL_EndingAnimation(
VOID
)
/*++
  Purpose:

  Show the ending animation.//就是灵儿独自面对合体水魔兽的动画

  Parameters:

  None.

  Return value:

  None.

  --*/
{
	LPBYTE            buf;
	LPBYTE            bufGirl;
	SDL_Surface      *pUpper;
	SDL_Surface      *pLower;
	SDL_Rect          srcrect, dstrect;

	int               yPosGirl = 180;
	int               i;

	buf = (LPBYTE)UTIL_calloc(1, 64000);
	bufGirl = (LPBYTE)UTIL_calloc(1, 6000);

	pUpper = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
		gpScreen->format->Rmask, gpScreen->format->Gmask,
		gpScreen->format->Bmask, gpScreen->format->Amask);

	pLower = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
		gpScreen->format->Rmask, gpScreen->format->Gmask,
		gpScreen->format->Bmask, gpScreen->format->Amask);

#if SDL_VERSION_ATLEAST(2, 0, 0)
	SDL_SetSurfacePalette(pUpper, gpScreen->format->palette);
	SDL_SetSurfacePalette(pLower, gpScreen->format->palette);
#else
	SDL_SetPalette(pUpper, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
	SDL_SetPalette(pLower, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
#endif

#ifdef PAL_WIN95
	PAL_MKFDecompressChunk(buf, 64000, 69, gpGlobals->f.fpFBP);
	PAL_FBPBlitToSurface(buf, pUpper);

	PAL_MKFDecompressChunk(buf, 64000, 70, gpGlobals->f.fpFBP);
	PAL_FBPBlitToSurface(buf, pLower);
#else
	PAL_MKFDecompressChunk(buf, 64000, 61, gpGlobals->f.fpFBP);
	PAL_FBPBlitToSurface(buf, pUpper);

	PAL_MKFDecompressChunk(buf, 64000, 62, gpGlobals->f.fpFBP);
	PAL_FBPBlitToSurface(buf, pLower);
#endif

	PAL_MKFDecompressChunk(buf, 64000, 571, gpGlobals->f.fpMGO);
	PAL_MKFDecompressChunk(bufGirl, 6000, 572, gpGlobals->f.fpMGO);

	srcrect.x = 0;
	dstrect.x = 0;
	srcrect.w = 320;
	dstrect.w = 320;

	gpGlobals->wScreenWave = 2;

	for (i = 0; i < 400; i++)
	{
		//
		// Draw the background
		//
		srcrect.y = 0;
		srcrect.h = 200 - i / 2;

		dstrect.y = i / 2;
		dstrect.h = 200 - i / 2;

		SDL_BlitSurface(pLower, &srcrect, gpScreen, &dstrect);

		srcrect.y = 200 - i / 2;
		srcrect.h = i / 2;

		dstrect.y = 0;
		dstrect.h = i / 2;

		SDL_BlitSurface(pUpper, &srcrect, gpScreen, &dstrect);

		PAL_ApplyWave(gpScreen);

		//
		// Draw the beast
		//
		PAL_RLEBlitToSurface(PAL_SpriteGetFrame(buf, 0), gpScreen, PAL_XY(0, -400 + i));
		PAL_RLEBlitToSurface(PAL_SpriteGetFrame(buf, 1), gpScreen, PAL_XY(0, -200 + i));

#ifdef PAL_WIN95
		PAL_RLEBlitToSurface(buf + 0x8444, gpScreen, PAL_XY(0, -200 + i));
#else
		PAL_RLEBlitToSurface(PAL_SpriteGetFrame(buf, 1), gpScreen, PAL_XY(0, -200 + i));
#endif

		//
		// Draw the girl
		//
		yPosGirl -= i & 1;
		if (yPosGirl < 80)
		{
			yPosGirl = 80;
		}

		PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufGirl, (SDL_GetTicks() / 50) % 4),
			gpScreen, PAL_XY(220, yPosGirl));

		//
		// Update the screen
		//
		VIDEO_UpdateScreen(NULL);
		if (gpGlobals->fNeedToFadeIn)
		{
			PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
			gpGlobals->fNeedToFadeIn = FALSE;
#if SDL_VERSION_ATLEAST(2, 0, 0)
			SDL_SetSurfacePalette(pUpper, gpScreen->format->palette);
			SDL_SetSurfacePalette(pLower, gpScreen->format->palette);
#else
			SDL_SetPalette(pUpper, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
			SDL_SetPalette(pLower, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
#endif
		}

		UTIL_Delay(50);
	}

	gpGlobals->wScreenWave = 0;

	SDL_FreeSurface(pUpper);
	SDL_FreeSurface(pLower);

	free(buf);
	free(bufGirl);
}
Esempio n. 19
0
VOID
PAL_BattleEnemyEscape(
   VOID
)
/*++
  Purpose:

    Enemy flee the battle.

  Parameters:

    None.

  Return value:

    None.

--*/
{
   int j, x, y, w;
   BOOL f = TRUE;
   
   UTIL_WriteLog(LOG_DEBUG, "[0x%08x][%s][%s] - %s", (long)PAL_BattleEnemyEscape, "PAL_BattleEnemyEscape", __FILE__, "start");
   
   SOUND_Play(45);

   //
   // Show the animation
   //
   while (f)
   {
   	  f = FALSE;

   	  for (j = 0; j <= g_Battle.wMaxEnemyIndex; j++)
   	  {
   	  	 if (g_Battle.rgEnemy[j].wObjectID == 0)
   	  	 {
   	  	 	continue;
   	  	 }

   	  	 x = PAL_X(g_Battle.rgEnemy[j].pos) - 5;
   	  	 y = PAL_Y(g_Battle.rgEnemy[j].pos);

   	  	 g_Battle.rgEnemy[j].pos = PAL_XY(x, y);

   	  	 w = PAL_RLEGetWidth(PAL_SpriteGetFrame(g_Battle.rgEnemy[j].lpSprite, 0));

   	  	 if (x + w > 0)
   	  	 {
   	  	 	f = TRUE;
   	  	 }
   	  }

   	  PAL_BattleMakeScene();
      SDL_BlitSurface(g_Battle.lpSceneBuf, NULL, gpScreen, NULL);
      VIDEO_UpdateScreen(NULL);

      UTIL_Delay(10);
   }

   UTIL_Delay(500);
   g_Battle.BattleResult = kBattleResultTerminated;
   
   UTIL_WriteLog(LOG_DEBUG, "[0x%08x][%s][%s] - %s", (long)PAL_BattleEnemyEscape, "PAL_BattleEnemyEscape", __FILE__, "end");
}
Esempio n. 20
0
void CGeneral::AnimOut(const CTile &t)
{
   EraseArea(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 94);
   UpdateScreen(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 64);
   int i;
   SDL_Rect dstrect, dhand;

   SDL_Surface *save = SDL_CreateRGBSurface(gpScreen->flags & (~SDL_HWSURFACE),
      m_imgHand->w, m_imgHand->h, gpScreen->format->BitsPerPixel,
      gpScreen->format->Rmask, gpScreen->format->Gmask,
      gpScreen->format->Bmask, gpScreen->format->Amask);

   dhand.x = 218;
   dhand.y = 125;
   dhand.w = m_imgHand->w;
   dhand.h = m_imgHand->h;

   SDL_BlitSurface(gpScreen, &dhand, save, NULL);
   SDL_BlitSurface(m_imgHand, NULL, gpScreen, &dhand);
   UpdateScreen(dhand.x, dhand.y, dhand.w, dhand.h);

   PlaySound(SND_FLASH);
   dhand.h = m_imgFlash2->h - (125 - 94);
   for (i = 0; i < 10; i++) {
      EraseArea(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 94);
      EraseArea(245, 94, m_imgFlash2->w, m_imgFlash2->h);

      dstrect.x = 245;
      dstrect.y = 94;
      dstrect.w = m_imgFlash1->w;
      dstrect.h = m_imgFlash1->h;

      SDL_BlitSurface(m_imgFlash1, NULL, gpScreen, &dstrect);
      DrawTile(t, 280, 104);
      SDL_BlitSurface(m_imgHand, NULL, gpScreen, &dhand);
      UpdateScreen(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 64);

      UTIL_Delay(50);

      EraseArea(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 94);
      EraseArea(dstrect.x, dstrect.y, dstrect.w, dstrect.h);

      dstrect.w = m_imgFlash2->w;
      dstrect.h = m_imgFlash2->h;
      SDL_BlitSurface(m_imgFlash2, NULL, gpScreen, &dstrect);
      DrawTile(t, 280, 104);
      SDL_BlitSurface(m_imgHand, NULL, gpScreen, &dhand);
      UpdateScreen(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 64);
      UTIL_Delay(50);
   }

   dhand.h = m_imgHand->h;
   UTIL_Delay(120);
   DrawUTF8Text(msg("out_discard"), 215, 114, 2, 255, 255, 255);
   UpdateScreen(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 64);
   UTIL_Delay(1000);
   EraseArea(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 94);
   EraseArea(dstrect.x, dstrect.y, dstrect.w, dstrect.h);
   SDL_BlitSurface(save, NULL, gpScreen, &dhand);
   SDL_FreeSurface(save);
   UpdateScreen(620 - 10 * TILE_WIDTH, 94, TILE_WIDTH * 10, 132 + TILE_HEIGHT_SHOWN - 64);
   UpdateScreen(dhand.x, dhand.y, dhand.w, dhand.h);
}
Esempio n. 21
0
VOID
PAL_ScrollFBP(
WORD         wChunkNum,
WORD         wScrollSpeed,
BOOL         fScrollDown
)
/*++
  Purpose:

  Scroll up an FBP picture to the screen.

  Parameters:

  [IN]  wChunkNum - number of chunk in fbp.mkf file.

  [IN]  wScrollSpeed - scrolling speed of showing the picture.

  [IN]  fScrollDown - TRUE if scroll down, FALSE if scroll up.

  Return value:

  None.

  --*/
{
	SDL_Surface          *p;
	PAL_LARGE BYTE        buf[320 * 200];
	PAL_LARGE BYTE        bufSprite[320 * 200];
	int                   i, l;
	SDL_Rect              rect, dstrect;

	if (PAL_MKFDecompressChunk(buf, 320 * 200, wChunkNum, gpGlobals->f.fpFBP) <= 0)
	{
		return;
	}

	if (g_wCurEffectSprite != 0)
	{
		PAL_MKFDecompressChunk(bufSprite, 320 * 200, g_wCurEffectSprite, gpGlobals->f.fpMGO);
	}

	p = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
		gpScreen->format->Rmask, gpScreen->format->Gmask,
		gpScreen->format->Bmask, gpScreen->format->Amask);

	if (p == NULL)
	{
		return;
	}

#if SDL_VERSION_ATLEAST(2, 0, 0)
	SDL_SetSurfacePalette(p, gpScreen->format->palette);
#else
	SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
#endif

	VIDEO_BackupScreen();
	PAL_FBPBlitToSurface(buf, p);

	if (wScrollSpeed == 0)
	{
		wScrollSpeed = 1;
	}

	rect.x = 0;
	rect.w = 320;
	dstrect.x = 0;
	dstrect.w = 320;

	for (l = 0; l < 220; l++)
	{
		i = l;
		if (i > 200)
		{
			i = 200;
		}

		if (fScrollDown)
		{
			rect.y = 0;
			dstrect.y = i;
			rect.h = 200 - i;
			dstrect.h = 200 - i;
		}
		else
		{
			rect.y = i;
			dstrect.y = 0;
			rect.h = 200 - i;
			dstrect.h = 200 - i;
		}

		SDL_BlitSurface(gpScreenBak, &rect, gpScreen, &dstrect);

		if (fScrollDown)
		{
			rect.y = 200 - i;
			dstrect.y = 0;
			rect.h = i;
			dstrect.h = i;
		}
		else
		{
			rect.y = 0;
			dstrect.y = 200 - i;
			rect.h = i;
			dstrect.h = i;
		}

		SDL_BlitSurface(p, &rect, gpScreen, &dstrect);

		PAL_ApplyWave(gpScreen);

		if (g_wCurEffectSprite != 0)
		{
			int f = SDL_GetTicks() / 150;
			PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufSprite, f % PAL_SpriteGetNumFrames(bufSprite)),
				gpScreen, PAL_XY(0, 0));
		}

		VIDEO_UpdateScreen(NULL);

		if (gpGlobals->fNeedToFadeIn)
		{
			PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
			gpGlobals->fNeedToFadeIn = FALSE;
#if SDL_VERSION_ATLEAST(2, 0, 0)
			SDL_SetSurfacePalette(p, gpScreen->format->palette);
#else
			SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
#endif
		}

		UTIL_Delay(800 / wScrollSpeed);
	}

	SDL_BlitSurface(p, NULL, gpScreen, NULL);
	SDL_FreeSurface(p);
	VIDEO_UpdateScreen(NULL);
}
Esempio n. 22
0
void CGame::Run()
{
   int i, j;

   // the game must be played with 3 players
   if (m_iNumPlayer != 3) {
      TerminateOnError("CGame::Run(): m_iNumPlayer != 3!");
   }

   for (i = 0; i < 3; i++) {
      char player_names[3][20];
      strncpy(player_names[RL(0, i)], m_rgszPlayerNames[0], 20);
      strncpy(player_names[RL(1, i)], m_rgszPlayerNames[1], 20);
      strncpy(player_names[RL(2, i)], m_rgszPlayerNames[2], 20);
      player_names[0][19] = '\0';
      player_names[1][19] = '\0';
      player_names[2][19] = '\0';
      m_rgpPlayers[i]->SetPlayerNames(player_names);
   }

   // The main game loop
   while (1) {
      int iWinner = PlayRound(), scores[3];
      bool fLordWon = (iWinner == m_iCurLord);
      CCard rgRemainCards[3][20];
      for (i = 0; i < 3; i++) {
         for (j = 0; j < 20; j++) {
            rgRemainCards[i][j] = m_rgpPlayers[i]->Hand()[j];
         }
      }

      scores[0] = m_iPoints * ((fLordWon ^ (m_iCurLord != 0)) ? 1 : -1);
      scores[1] = m_iPoints * ((fLordWon ^ (m_iCurLord != 1)) ? 1 : -1);
      scores[2] = m_iPoints * ((fLordWon ^ (m_iCurLord != 2)) ? 1 : -1);
      scores[m_iCurLord] *= 2;

      if (atoi(cfg.Get("GAME", "ShowCards", "1"))) {
         m_rgpPlayers[0]->ShowAllCards(RL(iWinner, 0), rgRemainCards);
         m_rgpPlayers[1]->ShowAllCards(RL(iWinner, 1), rgRemainCards);
         m_rgpPlayers[2]->ShowAllCards(RL(iWinner, 2), rgRemainCards);
      }

      m_rgiPlayerScore[0] += scores[0];
      m_rgiPlayerScore[1] += scores[1];
      m_rgiPlayerScore[2] += scores[2];

      if (m_fSingleGame) {
         cfg.Set("GAME", "Score", va("%d", m_rgiPlayerScore[0]));
         cfg.Set("GAME", "BotScore1", va("%d", m_rgiPlayerScore[1]));
         cfg.Set("GAME", "BotScore2", va("%d", m_rgiPlayerScore[2]));
      }

      // send score information to players
      m_rgpPlayers[0]->ScoreBoard(m_rgszPlayerNames, scores, m_rgiPlayerScore, scores[0] > 0);
      m_rgpPlayers[1]->ScoreBoard(m_rgszPlayerNames, scores, m_rgiPlayerScore, scores[1] > 0);
      m_rgpPlayers[2]->ScoreBoard(m_rgszPlayerNames, scores, m_rgiPlayerScore, scores[2] > 0);

      // Wait for all players to get ready for next round
      time_t t;
      time(&t);
      while (1) {
         UTIL_Delay(10);
         if (m_rgpPlayers[0]->IsReady() && m_rgpPlayers[1]->IsReady() && m_rgpPlayers[2]->IsReady()) {
            break;
         }
         if (time(NULL) - t > 30 && !m_fSingleGame) {
            g_UI.PopMessage(msg("someone_quit"));
            return; // someone delayed for too long; close the server
         }
      }
   }
}
Esempio n. 23
0
VOID
PAL_Search(
VOID
)
/*++
  Purpose:

  Process searching trigger events.

  Parameters:

  None.

  Return value:

  None.

  --*/
{
	int                x, y, xOffset, yOffset, dx, dy, dh, ex, ey, eh, i, k, l;
	LPEVENTOBJECT      p;
	PAL_POS            rgPos[13];

	//
	// Get the party location
	//
	x = PAL_X(gpGlobals->viewport) + PAL_X(gpGlobals->partyoffset);
	y = PAL_Y(gpGlobals->viewport) + PAL_Y(gpGlobals->partyoffset);

	if (gpGlobals->wPartyDirection == kDirNorth || gpGlobals->wPartyDirection == kDirEast)
	{
		xOffset = 16;
	}
	else
	{
		xOffset = -16;
	}

	if (gpGlobals->wPartyDirection == kDirEast || gpGlobals->wPartyDirection == kDirSouth)
	{
		yOffset = 8;
	}
	else
	{
		yOffset = -8;
	}

	rgPos[0] = PAL_XY(x, y);

	for (i = 0; i < 4; i++)
	{
		rgPos[i * 3 + 1] = PAL_XY(x + xOffset, y + yOffset);
		rgPos[i * 3 + 2] = PAL_XY(x, y + yOffset * 2);
		rgPos[i * 3 + 3] = PAL_XY(x + xOffset, y);
		x += xOffset;
		y += yOffset;
	}

	for (i = 0; i < 13; i++)
	{
		//
		// Convert to map location
		//
		dh = ((PAL_X(rgPos[i]) % 32) ? 1 : 0);
		dx = PAL_X(rgPos[i]) / 32;
		dy = PAL_Y(rgPos[i]) / 16;

		//
		// Loop through all event objects
		//
		for (k = gpGlobals->g.rgScene[gpGlobals->wNumScene - 1].wEventObjectIndex;
			k < gpGlobals->g.rgScene[gpGlobals->wNumScene].wEventObjectIndex; k++)
		{
			p = &(gpGlobals->g.lprgEventObject[k]);
			ex = p->x / 32;
			ey = p->y / 16;
			eh = ((p->x % 32) ? 1 : 0);

			if (p->sState <= 0 || p->wTriggerMode >= kTriggerTouchNear ||
				p->wTriggerMode * 6 - 4 < i || dx != ex || dy != ey || dh != eh)
			{
				continue;
			}

			//
			// Adjust direction/gesture for party members and the event object
			//
			if (p->nSpriteFrames * 4 > p->wCurrentFrameNum)
			{
				p->wCurrentFrameNum = 0; // use standing gesture
				p->wDirection = (gpGlobals->wPartyDirection + 2) % 4; // face the party

				for (l = 0; l <= gpGlobals->wMaxPartyMemberIndex; l++)
				{
					//
					// All party members should face the event object
					//
					gpGlobals->rgParty[l].wFrame = gpGlobals->wPartyDirection * 3;
				}

				//
				// Redraw everything
				//
				PAL_MakeScene();
				VIDEO_UpdateScreen(NULL);
			}

			//
			// Execute the script
			//
			p->wTriggerScript = PAL_RunTriggerScript(p->wTriggerScript, k + 1);

			//
			// Clear inputs and delay for a short time
			//
			UTIL_Delay(50);
			PAL_ClearKeyState();

			return; // don't go further
		}
	}
}
Esempio n. 24
0
VOID
PAL_PlayerStatus(
   VOID
)
/*++
  Purpose:

    Show the player status.

  Parameters:

    None.

  Return value:

    None.

--*/
{
   PAL_LARGE BYTE   bufBackground[320 * 200];
   PAL_LARGE BYTE   bufImage[16384];
   int              iCurrent;
   int              iPlayerRole;
   int              i, y;
   WORD             w;

   const int        rgEquipPos[MAX_PLAYER_EQUIPMENTS][2] = {
      {190, 0}, {248, 40}, {252, 102}, {202, 134}, {142, 142}, {82, 126}
   };

   PAL_MKFDecompressChunk(bufBackground, 320 * 200, STATUS_BACKGROUND_FBPNUM,
      gpGlobals->f.fpFBP);
   iCurrent = 0;

   while (iCurrent >= 0 && iCurrent <= gpGlobals->wMaxPartyMemberIndex)
   {
      iPlayerRole = gpGlobals->rgParty[iCurrent].wPlayerRole;

      //
      // Draw the background image
      //
      PAL_FBPBlitToSurface(bufBackground, gpScreen);

      //
      // Draw the text labels
      //
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_EXP), PAL_XY(6, 6), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(6, 32), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_HP), PAL_XY(6, 54), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_MP), PAL_XY(6, 76), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_ATTACKPOWER), PAL_XY(6, 98), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_MAGICPOWER), PAL_XY(6, 118), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_RESISTANCE), PAL_XY(6, 138), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_DEXTERITY), PAL_XY(6, 158), MENUITEM_COLOR, TRUE, FALSE);
      PAL_DrawText(PAL_GetWord(STATUS_LABEL_FLEERATE), PAL_XY(6, 178), MENUITEM_COLOR, TRUE, FALSE);

      PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[iPlayerRole]),
         PAL_XY(110, 8), MENUITEM_COLOR_CONFIRMED, TRUE, FALSE);

      //
      // Draw the stats
      //
      PAL_DrawNumber(gpGlobals->Exp.rgPrimaryExp[iPlayerRole].wExp, 5,
         PAL_XY(58, 6), kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(gpGlobals->g.rgLevelUpExp[gpGlobals->g.PlayerRoles.rgwLevel[iPlayerRole]],
         5, PAL_XY(58, 15), kNumColorCyan, kNumAlignRight);
      PAL_DrawNumber(gpGlobals->g.PlayerRoles.rgwLevel[iPlayerRole], 2,
         PAL_XY(54, 35), kNumColorYellow, kNumAlignRight);
      PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH), gpScreen,
         PAL_XY(65, 58));
      PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH), gpScreen,
         PAL_XY(65, 80));
      PAL_DrawNumber(gpGlobals->g.PlayerRoles.rgwHP[iPlayerRole], 4, PAL_XY(42, 56),
         kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(gpGlobals->g.PlayerRoles.rgwMaxHP[iPlayerRole], 4, PAL_XY(63, 61),
         kNumColorBlue, kNumAlignRight);
      PAL_DrawNumber(gpGlobals->g.PlayerRoles.rgwMP[iPlayerRole], 4, PAL_XY(42, 78),
         kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(gpGlobals->g.PlayerRoles.rgwMaxMP[iPlayerRole], 4, PAL_XY(63, 83),
         kNumColorBlue, kNumAlignRight);

      PAL_DrawNumber(PAL_GetPlayerAttackStrength(iPlayerRole), 4,
         PAL_XY(42, 102), kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(PAL_GetPlayerMagicStrength(iPlayerRole), 4,
         PAL_XY(42, 122), kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(PAL_GetPlayerDefense(iPlayerRole), 4,
         PAL_XY(42, 142), kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(PAL_GetPlayerDexterity(iPlayerRole), 4,
         PAL_XY(42, 162), kNumColorYellow, kNumAlignRight);
      PAL_DrawNumber(PAL_GetPlayerFleeRate(iPlayerRole), 4,
         PAL_XY(42, 182), kNumColorYellow, kNumAlignRight);

      //
      // Draw the equipments
      //
      for (i = 0; i < MAX_PLAYER_EQUIPMENTS; i++)
      {
         w = gpGlobals->g.PlayerRoles.rgwEquipment[i][iPlayerRole];

         if (w == 0)
         {
            continue;
         }

         //
         // Draw the image
         //
         if (PAL_MKFReadChunk(bufImage, 16384,
            gpGlobals->g.rgObject[w].item.wBitmap, gpGlobals->f.fpBALL) > 0)
         {
            PAL_RLEBlitToSurface(bufImage, gpScreen,
               PAL_XY(rgEquipPos[i][0], rgEquipPos[i][1]));
         }

         //
         // Draw the text label
         //
         PAL_DrawText(PAL_GetWord(w),
            PAL_XY(rgEquipPos[i][0] + 5, rgEquipPos[i][1] + 38), STATUS_COLOR_EQUIPMENT, TRUE, FALSE);
      }

      //
      // Draw the image of player role
      //
      if (PAL_MKFReadChunk(bufImage, 16384,
         gpGlobals->g.PlayerRoles.rgwAvatar[iPlayerRole], gpGlobals->f.fpRGM) > 0)
      {
         PAL_RLEBlitToSurface(bufImage, gpScreen, PAL_XY(110, 30));
      }

      //
      // Draw all poisons
      //
      y = 58;

      for (i = 0; i < MAX_POISONS; i++)
      {
         w = gpGlobals->rgPoisonStatus[i][iCurrent].wPoisonID;

         if (w != 0 &&
            gpGlobals->g.rgObject[w].poison.wPoisonLevel <= 3)
         {
            PAL_DrawText(PAL_GetWord(w), PAL_XY(185, y),
               (BYTE)(gpGlobals->g.rgObject[w].poison.wColor + 10), TRUE, FALSE);

            y += 18;
         }
      }

      //
      // Update the screen
      //
      VIDEO_UpdateScreen(NULL);

      //
      // Wait for input
      //
      PAL_ClearKeyState();

      while (TRUE)
      {
         UTIL_Delay(1);

         if (g_InputState.dwKeyPress & kKeyMenu)
         {
            iCurrent = -1;
            break;
         }
         else if (g_InputState.dwKeyPress & (kKeyLeft | kKeyUp))
         {
            iCurrent--;
            break;
         }
         else if (g_InputState.dwKeyPress & (kKeyRight | kKeyDown | kKeySearch))
         {
            iCurrent++;
            break;
         }
      }
   }
}
Esempio n. 25
0
VOID
PAL_FadeOut(
   INT         iDelay
)
/*++
  Purpose:

    Fadeout screen to black from the specified palette.

  Parameters:

    [IN]  iPaletteNum - number of the palette.

    [IN]  fNight - whether use the night palette or not.

    [IN]  iDelay - delay time for each step.

  Return value:

    None.

--*/
{
   int                      i, j;
   UINT                     time;
   PAL_LARGE SDL_Color      palette[256];
   PAL_LARGE SDL_Color      newpalette[256];

   //
   // Get the original palette...
   //
   for (i = 0; i < 256; i++)
   {
      palette[i] = VIDEO_GetPalette()[i];
   }

   //
   // Start fading out...
   //
   time = SDL_GetTicks() + iDelay * 10 * 60;

   while (TRUE)
   {
      //
      // Set the current palette...
      //
      j = (int)(time - SDL_GetTicks()) / iDelay / 10;
      if (j < 0)
      {
         break;
      }

      for (i = 0; i < 256; i++)
      {
         newpalette[i].r = (palette[i].r * j) >> 6;
         newpalette[i].g = (palette[i].g * j) >> 6;
         newpalette[i].b = (palette[i].b * j) >> 6;
      }

      VIDEO_SetPalette(newpalette);

      UTIL_Delay(10);
   }

   memset(newpalette, 0, sizeof(newpalette));
   VIDEO_SetPalette(newpalette);
}
Esempio n. 26
0
VOID
PAL_EndingScreen(
VOID
)
{
	RIX_Play(0x1a, TRUE, 0);
	PAL_RNGPlay(gpGlobals->iCurPlayingRNG, 110, 150, 7);
	PAL_RNGPlay(gpGlobals->iCurPlayingRNG, 151, 999, 9);

	PAL_FadeOut(2);

	RIX_Play(0x19, TRUE, 0);

	PAL_ShowFBP(75, 0);
	PAL_FadeIn(5, FALSE, 1);
	PAL_ScrollFBP(74, 0xf, TRUE);

	PAL_FadeOut(1);

	SDL_FillRect(gpScreen, NULL, 0);
	gpGlobals->wNumPalette = 4;
	gpGlobals->fNeedToFadeIn = TRUE;
	PAL_EndingAnimation();

	RIX_Play(0, FALSE, 2);
	PAL_ColorFade(7, 15, FALSE);

	if (!SOUND_PlayCDA(2))
	{
		RIX_Play(0x11, TRUE, 0);
	}

	SDL_FillRect(gpScreen, NULL, 0);
	PAL_SetPalette(0, FALSE);
	PAL_RNGPlay(0xb, 0, 999, 7);

	PAL_FadeOut(2);

	SDL_FillRect(gpScreen, NULL, 0);
	gpGlobals->wNumPalette = 8;
	gpGlobals->fNeedToFadeIn = TRUE;
	PAL_RNGPlay(10, 0, 999, 6);

	PAL_EndingSetEffectSprite(0);
	PAL_ShowFBP(77, 10);

	VIDEO_BackupScreen();

	PAL_EndingSetEffectSprite(0x27b);
	PAL_ShowFBP(76, 7);

	PAL_SetPalette(5, FALSE);
	PAL_ShowFBP(73, 7);
	PAL_ScrollFBP(72, 0xf, TRUE);

	PAL_ShowFBP(71, 7);
	PAL_ShowFBP(68, 7);

	PAL_EndingSetEffectSprite(0);
	PAL_ShowFBP(68, 6);

	PAL_WaitForKey(0);
	RIX_Play(0, FALSE, 1);
	UTIL_Delay(500);

	if (!SOUND_PlayCDA(13))
	{
		RIX_Play(9, TRUE, 0);
	}

	PAL_ScrollFBP(67, 0xf, TRUE);
	PAL_ScrollFBP(66, 0xf, TRUE);
	PAL_ScrollFBP(65, 0xf, TRUE);
	PAL_ScrollFBP(64, 0xf, TRUE);
	PAL_ScrollFBP(63, 0xf, TRUE);
	PAL_ScrollFBP(62, 0xf, TRUE);
	PAL_ScrollFBP(61, 0xf, TRUE);
	PAL_ScrollFBP(60, 0xf, TRUE);
	PAL_ScrollFBP(59, 0xf, TRUE);

	RIX_Play(0, FALSE, 6);
	PAL_FadeOut(3);
}
Esempio n. 27
0
// We only like to become the declarer when:
// 1) We have 3 or more beating cards (2's or Joker's)
// 2) We have 6 or more high-ranked cards (K/A/2/Joker)
// 3) We have 2 or less leftover cards which cannot be easily got rid of
// (single cards smaller than J or pairs smaller than 8)
// TODO: may be much smarter than this...
int CBot::Bid(int iAtLeast)
{
   UTIL_Delay(RandomLong(800, 1500)); // delay a while

   int iValue = 0, i, j, k, num_cards[16], iNumLeftOver = 0;
   int iNumTriple = 0, iNumHead = 0, subseq = -1, last_subseq = -1;

   // count all kind of cards
   memset(num_cards, 0, sizeof(num_cards));
   for (i = 0; i < m_iNumHandCard; i++) {
      num_cards[m_rgHandCard[i].GetValue() - 3]++;
   }

   if (num_cards[10] + num_cards[11] + num_cards[13] + num_cards[14] +
      num_cards[15] < 6) {
      // we have too few big cards, not feeling so good
      iValue = RandomLong(0, 1);
      goto end;
   }

   // take out all sequences
   for (i = 0; i < 8; i++) {
      if (num_cards[i] == 0) {
         continue;
      }
      for (j = i + 1; j < 12; j++) {
         if (num_cards[j] <= 0) {
            // the sequence ends right here
            break;
         }
      }
      if (j - i < 5) {
         i = j - 1;
         continue; // contains less than 5 cards, ignore this
      }
      if (num_cards[j - 1] >= 3 && j - i > 5) {
         j--; // do not end with a bomb or a triple
      }
      if (num_cards[i] >= 3 && j - i > 5) {
         i++; // do not start with a bomb or a triple
      }
      // take the sequence out
      for (k = i; k < j; k++) {
         num_cards[k]--; // take out one card from this rank
      }
      // see if we have some subsequences which can be included
      // in the main sequence to form 2 or more sequences...
      if (j - i < 7) {
         continue; // less than 7 cards is impossible
      }
      last_subseq = i;
      for (k = i; k < j; k++) {
         if (num_cards[k] > 0) {
            if (subseq == -1) {
               subseq = k;
            }
         } else {
            if (subseq != -1) {
               if (j - subseq >= 5 && k - last_subseq >= 5) {
                  // take this out as well
                  while (subseq < k) {
                     assert(num_cards[subseq] > 0);
                     num_cards[subseq++]--;
                  }
                  last_subseq = subseq;
               }
               subseq = -1;
            }
         }
      }
      i = j - 1; // skip the cards we have already proceeded
   }

   // take out all double sequences
   for (i = 0; i < 10; i++) {
      if (num_cards[i] < 2) {
         continue;
      }
      for (j = i + 1; j < 12; j++) {
         if (num_cards[j] < 2) {
            // the sequence ends right here
            break;
         }
      }
      if (j - i < 3) {
         i = j - 1;
         continue; // contains less than 5 cards, ignore this
      }
      if (num_cards[j - 1] >= 3 && j - i > 3) {
         j--; // do not end with a bomb or a triple
      }
      if (num_cards[i] >= 3 && j - i > 3) {
         i++; // do not start with a bomb or a triple
      }
      // take the sequence out
      for (k = i; k < j; k++) {
         num_cards[k] -= 2; // take out 2 cards from this rank
      }
   }

   // leftovers

   // pairs smaller than 8
   for (i = 0; i < 5; i++) {
      if (num_cards[i] == 2) {
         iNumLeftOver++;
      }
   }

   // singles smaller than J
   for (i = 0; i < 8; i++) {
      if (num_cards[i] == 1) {
         iNumLeftOver++;
      }
   }

   // triples and quads
   for (i = 0; i < 12; i++) {
      if (num_cards[i] == 3) {
         iNumTriple++;
      } else if (num_cards[i] == 4) {
         iNumHead++; // bomb
      }
   }

   // big cards
   iNumHead += num_cards[13]; // 2
   iNumHead += num_cards[14]; // Black Joker
   iNumHead += num_cards[15]; // Red Joker

   if (iNumHead < 3) {
      iValue = RandomLong(0, 1);
      goto end; // not feeling so good
   }

   if (!num_cards[15]) {
      iNumHead--;
   }
   if (!num_cards[14]) {
      iNumHead--;
   }

   i = iNumLeftOver - iNumTriple - iNumHead;

#ifdef BOT_DEBUG
   printf("CBot::Bid(): iNumLeftOver = %d, iNumTriple = %d, iNumHead =%d -> %d\n",
          iNumLeftOver, iNumTriple, iNumHead, i);
#endif

   if (i > 3) {
      iValue = RandomLong(0, 2); // we're not feeling so good
   } else if (i >= 2) {
      iValue = RandomLong(2, 3); // try a bet
   } else {
      iValue = 3; // very good
   }

end:
   return (iValue < iAtLeast) ? 0 : iValue;
}
Esempio n. 28
0
void CGeneral::GameOver()
{
   int iCurSel = 0;
   SDL_Event event;

   // Draw the background
   SDL_BlitSurface(m_imgGameOver, NULL, gpScreen, NULL);

   // Draw the text
   DrawText("GAME OVER", 22, 22, 1, 255, 255, 0);
   DrawUTF8Text(va("%s?", msg("Continue")), 400, 300, 1, 255, 255, 0);
   DrawUTF8Text(msg("Yes"), 450, 350, 1, 255, 255, 0);
   DrawUTF8Text(msg("No"), 450, 390, 1, 255, 255, 0);

   // Play the "Game Over" music
   PlayMusic(m_musGameOver, 0);

   while (1) {
      // Erase the original arrow
      SDL_Rect dstrect;
      dstrect.x = 400;
      dstrect.y = 350;
      dstrect.w = 32;
      dstrect.h = 80;

      SDL_BlitSurface(m_imgGameOver, &dstrect, gpScreen, &dstrect);

      // Draw the new arrow
      DrawText(">", 400, iCurSel ? 390 : 350, 1, 255, 255, 0);

      UpdateScreen();

      if (SDL_WaitEvent(&event)) {
         if (event.type == SDL_KEYDOWN) {
            switch (event.key.keysym.sym) {
            case SDLK_ESCAPE:
            case SDLK_n:
               // Quit the program immediately if user pressed ESC
               PlayMusic(NULL);
               UserQuit();
               break;

            case SDLK_UP:
            case SDLK_DOWN:
            case SDLK_LEFT:
            case SDLK_RIGHT:
               iCurSel ^= 1;
               break;

            case SDLK_y:
               PlayMusic(NULL);
               PlaySound(SND_SOUND1);
               UTIL_Delay(2000);
               ScreenFade(300);
               return;

            case SDLK_KP_ENTER:
            case SDLK_RETURN:
            case SDLK_SPACE:
               PlayMusic(NULL);
               if (iCurSel == 0) {
                  PlaySound(SND_SOUND1);
                  UTIL_Delay(2000);
                  ScreenFade(300);
                  return;
               } else {
                  UserQuit();
               }
               break;
            }
         } else if (event.type == SDL_QUIT) {
            PlayMusic(NULL);
            UserQuit();
         }
      }
   }

   PlayMusic(NULL);
   UserQuit();
}