Browse Source

Sound play fix

The original version of PAL uses signed integers.
There are some negative sound index, so that if unsigned integers are used, they will be large numbers.
Now switch the sound index into signed values, so that these values can be converted into their absolute values at runtime.
louyihua 7 years ago
parent
commit
245744b48a
4 changed files with 10 additions and 19 deletions
  1. 1 1
      fight.c
  2. 0 9
      global.c
  3. 6 6
      global.h
  4. 3 3
      sound.c

+ 1 - 1
fight.c

@@ -1079,7 +1079,7 @@ PAL_BattleStartFrame(
       // All enemies are cleared. Won the battle.
       //
       g_Battle.BattleResult = kBattleResultWon;
-      SOUND_Play(-1);
+      SOUND_Play(0);
       return;
    }
    else

+ 0 - 9
global.c

@@ -197,15 +197,6 @@ PAL_ReadGlobalGameData(
    PAL_MKFReadChunk((LPBYTE)(p->rgLevelUpExp), sizeof(p->rgLevelUpExp),
       14, gpGlobals->f.fpDATA);
    DO_BYTESWAP(p->rgLevelUpExp, sizeof(p->rgLevelUpExp));
-
-   // FIX: Enemy magic sound may be negative
-   for (int i = 0; i < p->nEnemy; i++)
-   {
-	   if (p->lprgEnemy[i].wMagicSound >= 32768)
-	   {
-		   p->lprgEnemy[i].wMagicSound = -(short)p->lprgEnemy[i].wMagicSound;
-	   }
-   }
 }
 
 static VOID

+ 6 - 6
global.h

@@ -319,11 +319,11 @@ typedef struct tagENEMY
    WORD        wIdleAnimSpeed;      // speed of the animation when idle
    WORD        wActWaitFrames;      // FIXME: ???
    WORD        wYPosOffset;
-   WORD        wAttackSound;        // sound played when this enemy uses normal attack
-   WORD        wActionSound;        // FIXME: ???
-   WORD        wMagicSound;         // sound played when this enemy uses magic
-   WORD        wDeathSound;         // sound played when this enemy dies
-   WORD        wCallSound;          // sound played when entering the battle
+   SHORT       wAttackSound;        // sound played when this enemy uses normal attack
+   SHORT       wActionSound;        // FIXME: ???
+   SHORT       wMagicSound;         // sound played when this enemy uses magic
+   SHORT       wDeathSound;         // sound played when this enemy dies
+   SHORT       wCallSound;          // sound played when entering the battle
    WORD        wHealth;             // total HP of the enemy
    WORD        wExp;                // How many EXPs we'll get for beating this enemy
    WORD        wCash;               // how many cashes we'll get for beating this enemy
@@ -333,7 +333,7 @@ typedef struct tagENEMY
    WORD        wAttackEquivItem;    // equivalence item of this enemy's normal attack
    WORD        wAttackEquivItemRate;// chance for equivalence item
    WORD        wStealItem;          // which item we'll get when stealing from this enemy
-   USHORT      nStealItem;          // total amount of the items which can be stolen
+   WORD        nStealItem;          // total amount of the items which can be stolen
    WORD        wAttackStrength;     // normal attack strength
    WORD        wMagicStrength;      // magical attack strength
    WORD        wDefense;            // resistance to all kinds of attacking

+ 3 - 3
sound.c

@@ -833,11 +833,11 @@ SOUND_PlayChannel(
 /*++
   Purpose:
 
-    Play a sound in voc.mkf file.
+    Play a sound in voc.mkf/sounds.mkf file.
 
   Parameters:
 
-    [IN]  iSoundNum - number of the sound.
+    [IN]  iSoundNum - number of the sound; the absolute value is used.
 
     [IN]  iChannel - the number of channel (0 or 1).
 
@@ -871,7 +871,7 @@ SOUND_PlayChannel(
 
    if (iSoundNum < 0)
    {
-      return;
+      iSoundNum = -iSoundNum;
    }
 
    //