Browse Source

merged win95 sources.

Wei Mingzhi 9 years ago
parent
commit
d585ac8600
12 changed files with 214 additions and 23 deletions
  1. 52 13
      fight.c
  2. 4 3
      global.c
  3. 12 2
      global.h
  4. 25 0
      itemmenu.c
  5. 34 0
      magicmenu.c
  6. 16 1
      main.c
  7. 6 0
      palcommon.c
  8. 35 0
      script.c
  9. 2 0
      sdlpal.vcxproj
  10. 6 0
      sdlpal.vcxproj.filters
  11. 18 4
      text.c
  12. 4 0
      ui.c

+ 52 - 13
fight.c

@@ -2227,7 +2227,9 @@ PAL_BattleShowPlayerPreMagicAnim(
    PAL_BattleDelay(2, 0, TRUE);
 
    g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 5;
+#ifndef PAL_WIN95
    SOUND_Play(gpGlobals->g.PlayerRoles.rgwMagicSound[wPlayerRole]);
+#endif
 
    if (!fSummon)
    {
@@ -2239,7 +2241,9 @@ PAL_BattleShowPlayerPreMagicAnim(
       index = gpGlobals->g.rgwBattleEffectIndex[PAL_GetPlayerBattleSprite(wPlayerRole)][0];
       index *= 10;
       index += 15;
-
+#ifdef PAL_WIN95
+      SOUND_Play(gpGlobals->g.PlayerRoles.rgwMagicSound[wPlayerRole]);
+#endif
       for (i = 0; i < 10; i++)
       {
          LPCBITMAPRLE b = PAL_SpriteGetFrame(g_Battle.lpEffectSprite, index++);
@@ -2468,12 +2472,22 @@ PAL_BattleShowPlayerDefMagicAnim(
    }
 }
 
+#ifndef PAL_WIN95
 static VOID
 PAL_BattleShowPlayerOffMagicAnim(
    WORD         wPlayerIndex,
    WORD         wObjectID,
    SHORT        sTarget
 )
+#else
+static VOID
+PAL_BattleShowPlayerOffMagicAnim(
+   WORD         wPlayerIndex,
+   WORD         wObjectID,
+   SHORT        sTarget,
+   BOOL         fSummon
+)
+#endif
 /*++
   Purpose:
 
@@ -2512,6 +2526,13 @@ PAL_BattleShowPlayerOffMagicAnim(
 
    n = PAL_SpriteGetNumFrames(lpSpriteEffect);
 
+#ifdef PAL_WIN95
+   if (wPlayerIndex != (WORD)-1)
+   {
+      g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 6;
+   }
+#endif
+
    PAL_BattleDelay(1, 0, TRUE);
 
    l = n - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay;
@@ -2522,15 +2543,22 @@ PAL_BattleShowPlayerOffMagicAnim(
    wave = gpGlobals->wScreenWave;
    gpGlobals->wScreenWave += gpGlobals->g.lprgMagic[iMagicNum].wWave;
 
+#ifdef PAL_WIN95
+   if (!fSummon && gpGlobals->g.lprgMagic[iMagicNum].wSound != 0)
+   {
+      SOUND_Play(gpGlobals->g.lprgMagic[iMagicNum].wSound);
+   }
+#endif
+
    for (i = 0; i < l; i++)
    {
       LPCBITMAPRLE b;
-
+#ifndef PAL_WIN95
       if (i == gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay && wPlayerIndex != (WORD)-1)
       {
          g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 6;
       }
-
+#endif
       blow = ((g_Battle.iBlow > 0) ? RandomLong(0, g_Battle.iBlow) : RandomLong(g_Battle.iBlow, 0));
 
       for (k = 0; k <= g_Battle.wMaxEnemyIndex; k++)
@@ -2561,20 +2589,11 @@ PAL_BattleShowPlayerOffMagicAnim(
 
          b = PAL_SpriteGetFrame(lpSpriteEffect, k);
 
-#if 1
+#ifndef PAL_WIN95
          if ((i - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay) % n == 0)
          {
             SOUND_Play(gpGlobals->g.lprgMagic[iMagicNum].wSound);
          }
-#else
-         //
-         // HACKHACK: Some of the sound effects in the original game are rather screwed
-         //
-         if (i == gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay ||
-            (((i - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay) % n == 0) && iMagicNum == 89))
-         {
-            SOUND_Play(gpGlobals->g.lprgMagic[iMagicNum].wSound);
-         }
 #endif
       }
       else
@@ -2947,6 +2966,10 @@ PAL_BattleShowPlayerSummonMagicAnim(
 
    PAL_BattleBackupScene();
 
+#ifdef PAL_WIN95
+   SOUND_Play(gpGlobals->g.lprgMagic[wMagicNum].wSound);
+#endif
+
    //
    // Load the sprite of the summoned god
    //
@@ -3003,7 +3026,11 @@ PAL_BattleShowPlayerSummonMagicAnim(
    //
    // Show the actual magic effect
    //
+#ifdef PAL_WIN95
+   PAL_BattleShowPlayerOffMagicAnim((WORD)-1, wEffectMagicID, -1, TRUE);
+#else
    PAL_BattleShowPlayerOffMagicAnim((WORD)-1, wEffectMagicID, -1);
+#endif
 }
 
 static VOID
@@ -3649,7 +3676,11 @@ PAL_BattlePlayerPerformAction(
          g_Battle.rgPlayer[wPlayerIndex].iColorShift = 0;
          PAL_BattleDelay(3, 0, TRUE);
 
+#ifdef PAL_WIN95
+         PAL_BattleShowPlayerOffMagicAnim((WORD)-1, wObject, sTarget, FALSE);
+#else
          PAL_BattleShowPlayerOffMagicAnim((WORD)-1, wObject, sTarget);
+#endif
       }
 
       for (i = 0; i <= gpGlobals->wMaxPartyMemberIndex; i++)
@@ -3930,7 +3961,11 @@ PAL_BattlePlayerPerformAction(
             }
             else
             {
+#ifdef PAL_WIN95
+               PAL_BattleShowPlayerOffMagicAnim(wPlayerIndex, wObject, sTarget, FALSE);
+#else
                PAL_BattleShowPlayerOffMagicAnim(wPlayerIndex, wObject, sTarget);
+#endif
             }
 
             gpGlobals->g.rgObject[wObject].magic.wScriptOnSuccess =
@@ -4910,7 +4945,11 @@ PAL_BattleSimulateMagic(
    //
    // Show the magic animation
    //
+#ifdef PAL_WIN95
+   PAL_BattleShowPlayerOffMagicAnim(0xFFFF, wMagicObjectID, sTarget, FALSE);
+#else
    PAL_BattleShowPlayerOffMagicAnim(0xFFFF, wMagicObjectID, sTarget);
+#endif
 
    if (gpGlobals->g.lprgMagic[gpGlobals->g.rgObject[wMagicObjectID].magic.wMagicNumber].wBaseDamage > 0 ||
       wBaseDamage > 0)

+ 4 - 3
global.c

@@ -74,9 +74,9 @@ PAL_InitGlobals(
    gpGlobals->f.fpFIRE = UTIL_OpenRequiredFile("fire.mkf");
    gpGlobals->f.fpRGM = UTIL_OpenRequiredFile("rgm.mkf");
    gpGlobals->f.fpSSS = UTIL_OpenRequiredFile("sss.mkf");
-
+#ifndef PAL_WIN95
    gpGlobals->lpObjectDesc = PAL_LoadObjectDesc(va("%s%s", PAL_PREFIX, "desc.dat"));
-
+#endif
    gpGlobals->bCurrentSaveSlot = 1;
 
    return 0;
@@ -130,8 +130,9 @@ PAL_FreeGlobals(
       //
       // Free the object description data
       //
+#ifndef PAL_WIN95
       PAL_FreeObjectDesc(gpGlobals->lpObjectDesc);
-
+#endif
       //
       // Delete the instance
       //

+ 12 - 2
global.h

@@ -196,6 +196,9 @@ typedef struct tagOBJECT_ITEM
    WORD         wScriptOnUse;    // script executed when using this item
    WORD         wScriptOnEquip;  // script executed when equipping this item
    WORD         wScriptOnThrow;  // script executed when throwing this item to enemy
+#ifdef PAL_WIN95
+   WORD         wScriptDesc;     // description script
+#endif
    WORD         wFlags;          // flags
 } OBJECT_ITEM;
 
@@ -214,6 +217,9 @@ typedef struct tagOBJECT_MAGIC
    WORD         wReserved1;        // always zero
    WORD         wScriptOnSuccess;  // when magic succeed, execute script from here
    WORD         wScriptOnUse;      // when use this magic, execute script from here
+#ifdef PAL_WIN95
+   WORD         wScriptDesc;       // description script
+#endif
    WORD         wReserved2;        // always zero
    WORD         wFlags;            // flags
 } OBJECT_MAGIC;
@@ -241,7 +247,11 @@ typedef struct tagOBJECT_POISON
 
 typedef union tagOBJECT
 {
+#ifdef PAL_WIN95
+   WORD              rgwData[7];
+#else
    WORD              rgwData[6];
+#endif
    OBJECT_PLAYER     player;
    OBJECT_ITEM       item;
    OBJECT_MAGIC      magic;
@@ -549,9 +559,9 @@ typedef struct tagGLOBALVARS
    ALLEXPERIENCE    Exp;                 // experience status
    POISONSTATUS     rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
    INVENTORY        rgInventory[MAX_INVENTORY];  // inventory status
-
+#ifndef PAL_WIN95
    LPOBJECTDESC     lpObjectDesc;
-
+#endif
    DWORD            dwFrameNum;
 } GLOBALVARS, *LPGLOBALVARS;
 

+ 25 - 0
itemmenu.c

@@ -44,8 +44,13 @@ PAL_ItemSelectMenuUpdate(
 
 --*/
 {
+#ifndef PAL_WIN95
    int                i, j, k;
    WORD               wObject;
+#else
+   int                i, j, k, line;
+   WORD               wObject, wScript;
+#endif
    BYTE               bColor;
    static BYTE        bufImage[2048];
    static WORD        wPrevImageIndex = 0xFFFF;
@@ -219,6 +224,7 @@ PAL_ItemSelectMenuUpdate(
    //
    // Draw the description of the selected item
    //
+#ifndef PAL_WIN95
    if (!g_fNoDesc && gpGlobals->lpObjectDesc != NULL)
    {
       char szDesc[512], *next;
@@ -251,6 +257,25 @@ PAL_ItemSelectMenuUpdate(
          }
       }
    }
+#else
+   if (!g_fNoDesc)
+   {
+      wScript = gpGlobals->g.rgObject[wObject].item.wScriptDesc;
+      line = 0;
+      while (wScript && gpGlobals->g.lprgScriptEntry[wScript].wOperation != 0)
+      {
+         if (gpGlobals->g.lprgScriptEntry[wScript].wOperation == 0xFFFF)
+         {
+            wScript = PAL_RunAutoScript(wScript, (1 << 15) | line);
+            line++;
+         }
+         else
+         {
+            wScript = PAL_RunAutoScript(wScript, 0);
+         }
+      }
+   }
+#endif
 
    if (g_InputState.dwKeyPress & kKeySearch)
    {

+ 34 - 0
magicmenu.c

@@ -51,8 +51,14 @@ PAL_MagicSelectionMenuUpdate(
 
 --*/
 {
+#ifndef PAL_WIN95
    int         i, j, k;
    BYTE        bColor;
+#else
+   int         i, j, k, line;
+   BYTE        bColor;
+   WORD        wScript;
+#endif
 
    //
    // Check for inputs
@@ -103,6 +109,7 @@ PAL_MagicSelectionMenuUpdate(
    //
    PAL_CreateBox(PAL_XY(10, 42), 4, 16, 1, FALSE);
 
+#ifndef PAL_WIN95
    if (gpGlobals->lpObjectDesc == NULL)
    {
       //
@@ -167,6 +174,33 @@ PAL_MagicSelectionMenuUpdate(
          kNumColorYellow, kNumAlignRight);
       PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(50, 14), kNumColorCyan, kNumAlignRight);
    }
+#else
+   wScript = gpGlobals->g.rgObject[rgMagicItem[g_iCurrentItem].wMagic].item.wScriptDesc;
+   line = 0;
+   while (wScript && gpGlobals->g.lprgScriptEntry[wScript].wOperation != 0)
+   {
+      if (gpGlobals->g.lprgScriptEntry[wScript].wOperation == 0xFFFF)
+      {
+         wScript = PAL_RunAutoScript(wScript, line);
+         line++;
+      }
+      else
+      {
+         wScript = PAL_RunAutoScript(wScript, 0);
+      }
+   }
+
+   //
+   // Draw the MP of the selected magic.
+   //
+   PAL_CreateSingleLineBox(PAL_XY(0, 0), 5, FALSE);
+   PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH),
+      gpScreen, PAL_XY(45, 14));
+   PAL_DrawNumber(rgMagicItem[g_iCurrentItem].wMP, 4, PAL_XY(15, 14),
+      kNumColorYellow, kNumAlignRight);
+   PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(50, 14), kNumColorCyan, kNumAlignRight);
+#endif
+
 
    //
    // Draw the texts of the current page

+ 16 - 1
main.c

@@ -30,12 +30,19 @@
 #include <fat.h>
 #endif
 
+#ifdef PAL_WIN95
+#define BITMAPNUM_SPLASH_UP         3
+#define BITMAPNUM_SPLASH_DOWN       4
+#define SPRITENUM_SPLASH_TITLE      0x47
+#define SPRITENUM_SPLASH_CRANE      0x49
+#define NUM_RIX_TITLE               0x5
+#else
 #define BITMAPNUM_SPLASH_UP         0x26
 #define BITMAPNUM_SPLASH_DOWN       0x27
 #define SPRITENUM_SPLASH_TITLE      0x47
 #define SPRITENUM_SPLASH_CRANE      0x49
 #define NUM_RIX_TITLE               0x5
-
+#endif
 static VOID
 PAL_Init(
    WORD             wScreenWidth,
@@ -135,11 +142,19 @@ PAL_Init(
    PAL_InitResources();
    SOUND_OpenAudio();
 
+#ifdef PAL_WIN95
+#ifdef _DEBUG
+   SDL_WM_SetCaption("Pal WIN95 (Debug Build)", NULL);
+#else
+   SDL_WM_SetCaption("Pal WIN95", NULL);
+#endif
+#else
 #ifdef _DEBUG
    SDL_WM_SetCaption("Pal (Debug Build)", NULL);
 #else
    SDL_WM_SetCaption("Pal", NULL);
 #endif
+#endif
 }
 
 VOID

+ 6 - 0
palcommon.c

@@ -861,12 +861,18 @@ PAL_MKFGetDecompressedSize(
    // Read the header.
    //
    fseek(fp, uiOffset, SEEK_SET);
+#ifdef PAL_WIN95
    fread(buf, sizeof(DWORD), 2, fp);
+   buf[0] = SWAP32(buf[0]);
 
+   return (INT)buf[0];
+#else
+   fread(buf, sizeof(DWORD), 2, fp);
    buf[0] = SWAP32(buf[0]);
    buf[1] = SWAP32(buf[1]);
 
    return (buf[0] != 0x315f4a59) ? -1 : (INT)buf[1];
+#endif
 }
 
 INT

+ 35 - 0
script.c

@@ -2125,8 +2125,13 @@ PAL_InterpretInstruction(
       //
       // Show FBP picture
       //
+#ifdef PAL_WIN95
+      SDL_FillRect(gpScreen, NULL, 0);
+      VIDEO_UpdateScreen(NULL);
+#else
       PAL_EndingSetEffectSprite(0);
       PAL_ShowFBP(pScript->rgwOperand[0], pScript->rgwOperand[1]);
+#endif
       break;
 
    case 0x0077:
@@ -2612,7 +2617,9 @@ PAL_InterpretInstruction(
       //
       // Show the ending animation
       //
+#ifndef PAL_WIN95
       PAL_EndingAnimation();
+#endif
       break;
 
    case 0x0097:
@@ -2880,6 +2887,9 @@ PAL_InterpretInstruction(
       //
       // Quit game
       //
+#ifdef PAL_WIN95
+      // TODO: ending
+#endif
       PAL_AdditionalCredits();
       PAL_Shutdown();
       exit(0);
@@ -2924,6 +2934,7 @@ PAL_InterpretInstruction(
       //
       // Scroll FBP to the screen
       //
+#ifndef PAL_WIN95
       if (pScript->rgwOperand[0] == 68)
       {
          //
@@ -2936,17 +2947,20 @@ PAL_InterpretInstruction(
       {
          PAL_ScrollFBP(pScript->rgwOperand[0], pScript->rgwOperand[2], pScript->rgwOperand[1]);
       }
+#endif
       break;
 
    case 0x00A5:
       //
       // Show FBP picture with sprite effects
       //
+#ifndef PAL_WIN95
       if (pScript->rgwOperand[1] != 0xFFFF)
       {
          PAL_EndingSetEffectSprite(pScript->rgwOperand[1]);
       }
       PAL_ShowFBP(pScript->rgwOperand[0], pScript->rgwOperand[2]);
+#endif
       break;
 
    case 0x00A6:
@@ -3315,6 +3329,9 @@ PAL_RunAutoScript(
 {
    LPSCRIPTENTRY          pScript;
    LPEVENTOBJECT          pEvtObj;
+#ifdef PAL_WIN95
+   int                    iDescLine = 0;
+#endif
 
 begin:
    pScript = &(gpGlobals->g.lprgScriptEntry[wScriptEntry]);
@@ -3411,9 +3428,27 @@ begin:
       break;
 
    case 0xFFFF:
+#ifdef PAL_WIN95
+      iDescLine = (wEventObjectID & ~(1 << 15));
+      if (wEventObjectID & (1 << 15))
+      {
+         PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(75, iDescLine * 16 + 150), DESCTEXT_COLOR, TRUE, FALSE);
+      }
+      else
+      {
+         PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(100, iDescLine * 16 + 3), DESCTEXT_COLOR, TRUE, FALSE);
+      }
+      iDescLine++;
+#endif
 	  wScriptEntry++;
 	  break;
 
+#ifdef PAL_WIN95
+   case 0x00A7:
+	  wScriptEntry++;
+      break;
+#endif
+
    default:
       //
       // Other operations

+ 2 - 0
sdlpal.vcxproj

@@ -446,11 +446,13 @@
   <ItemGroup>
     <ClInclude Include="ascii.h" />
     <ClInclude Include="battle.h" />
+    <ClInclude Include="big5font.h" />
     <ClInclude Include="common.h" />
     <ClInclude Include="ending.h" />
     <ClInclude Include="fight.h" />
     <ClInclude Include="font.h" />
     <ClInclude Include="game.h" />
+    <ClInclude Include="gbfont.h" />
     <ClInclude Include="getopt.h" />
     <ClInclude Include="global.h" />
     <ClInclude Include="input.h" />

+ 6 - 0
sdlpal.vcxproj.filters

@@ -349,6 +349,12 @@
     <ClInclude Include="libmad\timer.h">
       <Filter>libmad</Filter>
     </ClInclude>
+    <ClInclude Include="big5font.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="gbfont.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="sdlpal.ico">

+ 18 - 4
text.c

@@ -339,7 +339,11 @@ PAL_DrawText(
 
    urect.x = rect.x;
    urect.y = rect.y;
+#ifdef PAL_WIN95
+   urect.h = 17;
+#else
    urect.h = 16;
+#endif
    urect.w = 0;
 
    while (*lpszText)
@@ -350,7 +354,7 @@ PAL_DrawText(
       if (*lpszText & 0x80)
       {
          //
-         // BIG-5 Chinese Character
+         // Chinese Character
          //
          wChar = SWAP16(((LPBYTE)lpszText)[0] | (((LPBYTE)lpszText)[1] << 8));
          if (fShadow)
@@ -385,6 +389,13 @@ PAL_DrawText(
    //
    if (fUpdate && urect.w > 0)
    {
+#ifdef PAL_WIN95
+      urect.w++;
+      if (urect.x + urect.w > 320)
+      {
+         urect.w = 320 - urect.x;
+      }
+#endif
       VIDEO_UpdateScreen(&urect);
    }
 }
@@ -729,7 +740,10 @@ PAL_ShowDialogText(
    {
       if (g_TextLib.nCurrentDialogLine == 0 &&
          g_TextLib.bDialogPosition != kDialogCenter &&
-         (BYTE)lpszText[len - 1] == 0x47 && (BYTE)lpszText[len - 2] == 0xA1)
+         (((BYTE)lpszText[len - 1] == 0x47 && (BYTE)lpszText[len - 2] == 0xA1) ||
+          ((BYTE)lpszText[len - 1] == 0xBA && (BYTE)lpszText[len - 2] == 0xA3) ||
+          ((BYTE)lpszText[len - 1] == 0xC3 && (BYTE)lpszText[len - 2] == 0xA1) ||
+          ((BYTE)lpszText[len - 1] == ':')))
       {
          //
          // name of character
@@ -769,7 +783,7 @@ PAL_ShowDialogText(
                }
                lpszText++;
                break;
-
+#ifndef PAL_WIN95
             case '\'':
                //
                // Set the font color to Red
@@ -784,7 +798,7 @@ PAL_ShowDialogText(
                }
                lpszText++;
                break;
-
+#endif
             case '\"':
                //
                // Set the font color to Yellow

+ 4 - 0
ui.c

@@ -681,6 +681,8 @@ PAL_DrawNumber(
    }
 }
 
+#ifndef PAL_WIN95
+
 LPOBJECTDESC
 PAL_LoadObjectDesc(
    LPCSTR         lpszFileName
@@ -806,3 +808,5 @@ PAL_GetObjectDesc(
 
    return NULL;
 }
+
+#endif