Browse Source

Unified version

Use the option 'DOS=0' or 'DOS=1' in 'sdlpal.cfg' to control whether to use DOS or WIN format.
louyihua 8 years ago
parent
commit
fd9a91e7c6
25 changed files with 1194 additions and 48539 deletions
  1. 0 29525
      big5font.h
  2. 0 1
      common.h
  3. 5 23
      ending.c
  4. 0 2
      ending.h
  5. 19 76
      fight.c
  6. 0 12
      fight.h
  7. 0 306
      font.c
  8. 0 17707
      gbfont.h
  9. 387 72
      global.c
  10. 48 51
      global.h
  11. 47 50
      itemmenu.c
  12. 83 86
      magicmenu.c
  13. 14 18
      main.c
  14. 136 137
      midi.c
  15. 17 16
      palcommon.c
  16. 15 1
      palcommon.h
  17. 70 73
      script.c
  18. 0 2
      script.h
  19. 2 4
      sdlpal.vcxproj
  20. 3 9
      sdlpal.vcxproj.filters
  21. 9 9
      text.c
  22. 0 4
      ui.c
  23. 2 7
      ui.h
  24. 0 9
      video.c
  25. 337 339
      yj1.c

File diff suppressed because it is too large
+ 0 - 29525
big5font.h


+ 0 - 1
common.h

@@ -23,7 +23,6 @@
 #ifndef _COMMON_H
 #define _COMMON_H
 
-//#define PAL_WIN95          1
 #define PAL_CLASSIC        1
 #define PAL_UNICODE        1
 

+ 5 - 23
ending.c

@@ -148,11 +148,7 @@ PAL_ShowFBP(
    //
    // HACKHACK: to make the ending show correctly
    //
-#ifdef PAL_WIN95
-   if (wChunkNum != 68)
-#else
-   if (wChunkNum != 49)
-#endif
+   if (wChunkNum != (gpGlobals->fIsWIN95 ? 68 : 49))
    {
       PAL_FBPBlitToSurface(buf, gpScreen);
    }
@@ -348,19 +344,11 @@ PAL_EndingAnimation(
    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_MKFDecompressChunk(buf, 64000, gpGlobals->fIsWIN95 ? 69 : 61, gpGlobals->f.fpFBP);
    PAL_FBPBlitToSurface(buf, pUpper);
 
-   PAL_MKFDecompressChunk(buf, 64000, 62, gpGlobals->f.fpFBP);
+   PAL_MKFDecompressChunk(buf, 64000, gpGlobals->fIsWIN95 ? 70 : 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);
@@ -399,11 +387,7 @@ PAL_EndingAnimation(
       // Draw the beast
       //
       PAL_RLEBlitToSurface(PAL_SpriteGetFrame(buf, 0), gpScreen, PAL_XY(0, -400 + 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
+	  PAL_RLEBlitToSurface(gpGlobals->fIsWIN95 ? buf + 0x8444 : PAL_SpriteGetFrame(buf, 1), gpScreen, PAL_XY(0, -200 + i));
       //
       // Draw the girl
       //
@@ -445,8 +429,6 @@ PAL_EndingAnimation(
    free(bufGirl);
 }
 
-#ifdef PAL_WIN95
-
 VOID
 PAL_EndingScreen(
    VOID
@@ -530,4 +512,4 @@ PAL_EndingScreen(
 	RIX_Play(0, FALSE, 6);
 	PAL_FadeOut(3);
 }
-#endif
+

+ 0 - 2
ending.h

@@ -50,12 +50,10 @@ PAL_EndingAnimation(
    VOID
 );
 
-#ifdef PAL_WIN95
 VOID
 PAL_EndingScreen(
    VOID
 );
-#endif
 
 #ifdef __cplusplus
 }

+ 19 - 76
fight.c

@@ -2191,19 +2191,11 @@ PAL_BattleShowPlayerUseItemAnim(
    }
 }
 
-#ifdef PAL_WIN95
-VOID
-PAL_BattleShowPlayerPreMagicAnim(
-   WORD         wPlayerIndex,
-   WORD         wObjectID
-)
-#else
 VOID
 PAL_BattleShowPlayerPreMagicAnim(
    WORD         wPlayerIndex,
    BOOL         fSummon
 )
-#endif
 /*++
   Purpose:
 
@@ -2224,13 +2216,6 @@ PAL_BattleShowPlayerPreMagicAnim(
    int   i, j;
    DWORD dwTime = SDL_GetTicks();
    WORD  wPlayerRole = gpGlobals->rgParty[wPlayerIndex].wPlayerRole;
-#ifdef PAL_WIN95
-   BOOL  fSummon = FALSE;
-   int   iMagicNum = gpGlobals->g.rgObject[wObjectID].magic.wMagicNumber;
-
-   if (gpGlobals->g.lprgMagic[iMagicNum].wType == kMagicTypeSummon)
-      fSummon = TRUE;
-#endif
 
    for (i = 0; i < 4; i++)
    {
@@ -2244,9 +2229,10 @@ 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 (!gpGlobals->fIsWIN95)
+   {
+      SOUND_Play(gpGlobals->g.PlayerRoles.rgwMagicSound[wPlayerRole]);
+   }
 
    if (!fSummon)
    {
@@ -2258,10 +2244,11 @@ 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++)
+	  if (gpGlobals->fIsWIN95)
+	  {
+		  SOUND_Play(gpGlobals->g.PlayerRoles.rgwMagicSound[wPlayerRole]);
+	  }
+	  for (i = 0; i < 10; i++)
       {
          LPCBITMAPRLE b = PAL_SpriteGetFrame(g_Battle.lpEffectSprite, index++);
 
@@ -2489,14 +2476,6 @@ PAL_BattleShowPlayerDefMagicAnim(
    }
 }
 
-#ifndef PAL_WIN95
-static VOID
-PAL_BattleShowPlayerOffMagicAnim(
-   WORD         wPlayerIndex,
-   WORD         wObjectID,
-   SHORT        sTarget
-)
-#else
 static VOID
 PAL_BattleShowPlayerOffMagicAnim(
    WORD         wPlayerIndex,
@@ -2504,7 +2483,6 @@ PAL_BattleShowPlayerOffMagicAnim(
    SHORT        sTarget,
    BOOL         fSummon
 )
-#endif
 /*++
   Purpose:
 
@@ -2543,12 +2521,10 @@ PAL_BattleShowPlayerOffMagicAnim(
 
    n = PAL_SpriteGetNumFrames(lpSpriteEffect);
 
-#ifdef PAL_WIN95
-   if (wPlayerIndex != (WORD)-1)
+   if (gpGlobals->fIsWIN95 && wPlayerIndex != (WORD)-1)
    {
       g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 6;
    }
-#endif
 
    PAL_BattleDelay(1, 0, TRUE);
 
@@ -2560,22 +2536,18 @@ PAL_BattleShowPlayerOffMagicAnim(
    wave = gpGlobals->wScreenWave;
    gpGlobals->wScreenWave += gpGlobals->g.lprgMagic[iMagicNum].wWave;
 
-#ifdef PAL_WIN95
-   if (!fSummon && gpGlobals->g.lprgMagic[iMagicNum].wSound != 0)
+   if (gpGlobals->fIsWIN95 && !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)
+	  if (!gpGlobals->fIsWIN95 && 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++)
@@ -2606,12 +2578,10 @@ PAL_BattleShowPlayerOffMagicAnim(
 
          b = PAL_SpriteGetFrame(lpSpriteEffect, k);
 
-#ifndef PAL_WIN95
-         if ((i - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay) % n == 0)
+		 if (!gpGlobals->fIsWIN95 && (i - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay) % n == 0)
          {
             SOUND_Play(gpGlobals->g.lprgMagic[iMagicNum].wSound);
          }
-#endif
       }
       else
       {
@@ -2983,9 +2953,10 @@ PAL_BattleShowPlayerSummonMagicAnim(
 
    PAL_BattleBackupScene();
 
-#ifdef PAL_WIN95
-   SOUND_Play(gpGlobals->g.lprgMagic[wMagicNum].wSound);
-#endif
+   if (gpGlobals->fIsWIN95)
+   {
+      SOUND_Play(gpGlobals->g.lprgMagic[wMagicNum].wSound);
+   }
 
    //
    // Load the sprite of the summoned god
@@ -3043,11 +3014,7 @@ 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
@@ -3622,11 +3589,7 @@ PAL_BattlePlayerPerformAction(
 
       if (gpGlobals->g.lprgMagic[wMagicNum].wType == kMagicTypeSummon)
       {
-#ifdef PAL_WIN95
-         PAL_BattleShowPlayerPreMagicAnim(wPlayerIndex, wObject);
-#else
          PAL_BattleShowPlayerPreMagicAnim(wPlayerIndex, TRUE);
-#endif
          PAL_BattleShowPlayerSummonMagicAnim((WORD)-1, wObject);
       }
       else
@@ -3697,11 +3660,7 @@ 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++)
@@ -3905,12 +3864,8 @@ PAL_BattlePlayerPerformAction(
       wObject = g_Battle.rgPlayer[wPlayerIndex].action.wActionID;
       wMagicNum = gpGlobals->g.rgObject[wObject].magic.wMagicNumber;
 
-#ifdef PAL_WIN95
-      PAL_BattleShowPlayerPreMagicAnim(wPlayerIndex, wObject);
-#else
       PAL_BattleShowPlayerPreMagicAnim(wPlayerIndex,
          (gpGlobals->g.lprgMagic[wMagicNum].wType == kMagicTypeSummon));
-#endif
 
       if (!gpGlobals->fAutoBattle)
       {
@@ -3986,11 +3941,7 @@ 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 =
@@ -4637,9 +4588,7 @@ PAL_BattleEnemyPerformAction(
          g_Battle.rgEnemy[wEnemyIndex].pos = PAL_XY(x, y);
          PAL_BattleDelay(1, 0, FALSE);
       }
-#ifdef PAL_WIN95
-      if (g_Battle.rgEnemy[wEnemyIndex].e.wActionSound != 0)
-#endif
+	  if (!gpGlobals->fIsWIN95 || g_Battle.rgEnemy[wEnemyIndex].e.wActionSound != 0)
       {
          SOUND_Play(g_Battle.rgEnemy[wEnemyIndex].e.wActionSound);
       }
@@ -4720,9 +4669,7 @@ PAL_BattleEnemyPerformAction(
 
          g_Battle.rgPlayer[sTarget].iColorShift = 6;
       }
-#ifdef PAL_WIN95
-      if (iSound != 0)
-#endif
+	  if (!gpGlobals->fIsWIN95 || iSound != 0)
       {
          SOUND_Play(iSound);
       }
@@ -4991,11 +4938,7 @@ 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)

+ 0 - 12
fight.h

@@ -76,24 +76,12 @@ PAL_BattleEnemyPerformAction(
    WORD         wEnemyIndex
 );
 
-#ifdef PAL_WIN95
-
-VOID
-PAL_BattleShowPlayerPreMagicAnim(
-   WORD         wPlayerIndex,
-   WORD         wObjectID
-);
-
-#else
-
 VOID
 PAL_BattleShowPlayerPreMagicAnim(
    WORD         wPlayerIndex,
    BOOL         fSummon
 );
 
-#endif
-
 VOID
 PAL_BattleDelay(
    WORD       wDuration,

+ 0 - 306
font.c

@@ -195,312 +195,6 @@ PAL_CharWidth(
 	return font_width[wChar] >> 1;
 }
 
-#elif defined(PAL_WIN95)
-
-/*
-* Portions based on:
-*
-* YH - Console Chinese Environment -
-* Copyright (C) 1999 Red Flag Linux (office@sonata.iscas.ac.cn)
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY RED FLAG LINUX ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-* SUCH DAMAGE.
-*
-*/
-
-/*
-* Portions based on:
-*
-* KON2 - Kanji ON Console -
-* Copyright (C) 1992-1996 Takashi MANABE (manabe@papilio.tutics.tut.ac.jp)
-*
-* CCE - Console Chinese Environment -
-* Copyright (C) 1998-1999 Rui He (herui@cs.duke.edu)
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY TAKASHI MANABE ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED.  IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-* SUCH DAMAGE.
-* 
-*/
-
-#include "gbfont.h"
-#include "big5font.h"
-
-BOOL fIsBig5 = FALSE;
-
-INT
-PAL_InitFont(
-   VOID
-)
-/*++
-Purpose:
-
-Load the font files.
-
-Parameters:
-
-None.
-
-Return value:
-
-0 if succeed, -1 if cannot allocate memory, -2 if cannot load files.
-
---*/
-{
-	FILE *fp;
-
-	fp = fopen(PAL_PREFIX "word.dat", "rb");
-	if (!fp)
-	{
-		return 0;
-	}
-
-	fseek(fp, 0x1E, SEEK_SET);
-	if (fgetc(fp) == 0xAA)
-	{
-		fIsBig5 = TRUE;
-	}
-
-	fclose(fp);
-	return 0;
-}
-
-VOID
-PAL_FreeFont(
-   VOID
-)
-/*++
-Purpose:
-
-Free the memory used for fonts.
-
-Parameters:
-
-None.
-
-Return value:
-
-None.
-
---*/
-{
-}
-
-static BOOL is_gb(unsigned char b1, unsigned char b2)
-{
-	if (b1 < 0xa1 || b1 > 0xfe)
-		return FALSE;
-	if (b2 < 0xa1 || b2 > 0xfe)
-		return FALSE;
-	return TRUE;
-}
-
-VOID
-PAL_DrawCharOnSurface(
-   WORD                     wChar,
-   SDL_Surface             *lpSurface,
-   PAL_POS                  pos,
-   BYTE                     bColor
-)
-/*++
-Purpose:
-
-Draw a BIG-5 Chinese character on a surface.
-
-Parameters:
-
-[IN]  wChar - the character to be drawn (in GB2312/BIG5).
-
-[OUT] lpSurface - the destination surface.
-
-[IN]  pos - the destination location of the surface.
-
-[IN]  bColor - the color of the character.
-
-Return value:
-
-None.
-
---*/
-{
-	int       i, j, dx;
-	int       x = PAL_X(pos), y = PAL_Y(pos);
-	LPBYTE    pChar;
-	BYTE      ch1, ch2;
-
-	//
-	// Check for NULL pointer.
-	//
-	if (lpSurface == NULL)
-	{
-		return;
-	}
-
-	//
-	// Locate for this character in the font lib.
-	//
-	ch1 = wChar & 0xff;
-	ch2 = wChar >> 8;
-
-	if (fIsBig5)
-	{
-		if (ch2 < 0xa1)
-			pChar = &big5font[((ch1 - 0xA1) * 157 + ch2 - 0x40) << 5] + 8;
-		else
-			pChar = &big5font[((ch1 - 0xA1) * 157 + 63 + ch2 - 0xA1) << 5] + 8;
-	}
-	else
-	{
-		if (!is_gb(ch1, ch2))
-		{
-			return;
-		}
-		pChar = &gbfont[((ch1 - 0xa1) * 94 + (ch2 - 0xa1)) * 32];
-	}
-
-	if (pChar == NULL) return;
-
-	//
-	// Draw the character to the surface.
-	//
-	if (y >= lpSurface->h) return;
-
-	y *= lpSurface->pitch;
-	for (i = 0; i < 32; i++)
-	{
-		dx = x + ((i & 1) << 3);
-		for (j = 0; j < 8; j++)
-		{
-			if (pChar[i] & (1 << (7 - j)))
-			{
-				if (dx < lpSurface->w)
-				{
-					((LPBYTE)(lpSurface->pixels))[y + dx] = bColor;
-				}
-				else
-				{
-					break;
-				}
-			}
-			dx++;
-		}
-		y += (i & 1) * lpSurface->pitch;
-		if (y / lpSurface->pitch >= lpSurface->h)
-		{
-			break;
-		}
-	}
-}
-
-VOID
-PAL_DrawASCIICharOnSurface(
-   BYTE                     bChar,
-   SDL_Surface             *lpSurface,
-   PAL_POS                  pos,
-   BYTE                     bColor
-)
-/*++
-Purpose:
-
-Draw a ASCII character on a surface.
-
-Parameters:
-
-[IN]  bChar - the character to be drawn.
-
-[OUT] lpSurface - the destination surface.
-
-[IN]  pos - the destination location of the surface.
-
-[IN]  bColor - the color of the character.
-
-Return value:
-
-None.
-
---*/
-{
-	int i, j, dx;
-	int x = PAL_X(pos), y = PAL_Y(pos);
-	LPBYTE pChar;
-
-	pChar = &iso_font[(int)(bChar & ~128) * 15];
-
-	//
-	// Check for NULL pointer.
-	//
-	if (lpSurface == NULL)
-	{
-		return;
-	}
-
-	//
-	// Draw the character to the surface.
-	//
-	if (y >= lpSurface->h) return;
-
-	y *= lpSurface->pitch;
-	for (i = 0; i < 15; i++)
-	{
-		dx = x;
-		for (j = 0; j < 8; j++)
-		{
-			if (pChar[i] & (1 << j))
-			{
-				if (dx < lpSurface->w)
-				{
-					((LPBYTE)(lpSurface->pixels))[y + dx] = bColor;
-				}
-				else
-				{
-					break;
-				}
-			}
-			dx++;
-		}
-		y += lpSurface->pitch;
-		if (y / lpSurface->pitch >= lpSurface->h)
-		{
-			break;
-		}
-	}
-}
-
 #else
 
 typedef struct tagFont

File diff suppressed because it is too large
+ 0 - 17707
gbfont.h


+ 387 - 72
global.c

@@ -70,6 +70,7 @@ PAL_InitGlobals(
    DWORD     dwWordLength = 10;		// Default for PAL DOS/WIN95
    DWORD     dwExtraMagicDescLines = 0;	// Default for PAL DOS/WIN95
    DWORD     dwExtraItemDescLines = 0;	// Default for PAL DOS/WIN95
+   DWORD     dwIsDOS = 1;				// Default for DOS
 #endif
 
    if (gpGlobals == NULL)
@@ -130,6 +131,10 @@ PAL_InitGlobals(
 				   {
 					   sscanf(ptr, "%u", &dwExtraItemDescLines);
 				   }
+				   else if (SDL_strcasecmp(p, "DOS") == 0)
+				   {
+					   sscanf(ptr, "%u", &dwIsDOS);
+				   }
 			   }
 		   }
 	   }
@@ -180,6 +185,11 @@ PAL_InitGlobals(
    }
 #endif
 
+   // Choose version
+   gpGlobals->fIsWIN95 = dwIsDOS ? FALSE : TRUE;
+   // Set decompress function
+   Decompress = gpGlobals->fIsWIN95 ? YJ2_Decompress : YJ1_Decompress;
+
    //
    // Open files
    //
@@ -191,9 +201,8 @@ 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->lpObjectDesc = gpGlobals->fIsWIN95 ? NULL : PAL_LoadObjectDesc(va("%s%s", PAL_PREFIX, "desc.dat"));
    gpGlobals->bCurrentSaveSlot = 1;
 #ifdef PAL_UNICODE
    gpGlobals->iCodePage = iCodePage;
@@ -253,9 +262,9 @@ PAL_FreeGlobals(
       //
       // Free the object description data
       //
-#ifndef PAL_WIN95
-      PAL_FreeObjectDesc(gpGlobals->lpObjectDesc);
-#endif
+	  if (!gpGlobals->fIsWIN95)
+         PAL_FreeObjectDesc(gpGlobals->lpObjectDesc);
+
       //
       // Delete the instance
       //
@@ -394,8 +403,8 @@ PAL_LoadDefaultGame(
 
 --*/
 {
-   const GAMEDATA    *p = &gpGlobals->g;
-   UINT32             i;
+   GAMEDATA    *p = &gpGlobals->g;
+   UINT32       i;
 
    //
    // Load the default data from the game data files.
@@ -404,8 +413,33 @@ PAL_LoadDefaultGame(
       0, gpGlobals->f.fpSSS);
    PAL_MKFReadChunk((LPBYTE)(p->rgScene), sizeof(p->rgScene), 1, gpGlobals->f.fpSSS);
    DO_BYTESWAP(p->rgScene, sizeof(p->rgScene));
-   PAL_MKFReadChunk((LPBYTE)(p->rgObject), sizeof(p->rgObject), 2, gpGlobals->f.fpSSS);
-   DO_BYTESWAP(p->rgObject, sizeof(p->rgObject));
+   if (gpGlobals->fIsWIN95)
+   {
+      PAL_MKFReadChunk((LPBYTE)(p->rgObject), sizeof(p->rgObject), 2, gpGlobals->f.fpSSS);
+      DO_BYTESWAP(p->rgObject, sizeof(p->rgObject));
+   }
+   else
+   {
+      OBJECT_DOS objects[MAX_OBJECTS];
+	  PAL_MKFReadChunk((LPBYTE)(objects), sizeof(objects), 2, gpGlobals->f.fpSSS);
+	  DO_BYTESWAP(objects, sizeof(objects));
+      //
+      // Convert the DOS-style data structure to WIN-style data structure
+      //
+      for (int i = 0; i < MAX_OBJECTS; i++)
+      {
+         memcpy(&p->rgObject[i], &objects[i], sizeof(OBJECT_DOS));
+	     if (i >= OBJECT_ITEM_START && i <= OBJECT_MAGIC_END)
+         {
+            p->rgObject[i].rgwData[6] = objects[i].rgwData[5];     // wFlags
+			p->rgObject[i].rgwData[5] = 0;                         // wScriptDesc or wReserved2
+         }
+         else
+         {
+            p->rgObject[i].rgwData[6] = 0;
+         }
+      }
+   }
 
    PAL_MKFReadChunk((LPBYTE)(&(p->PlayerRoles)), sizeof(PLAYERROLES),
       3, gpGlobals->f.fpDATA);
@@ -449,8 +483,137 @@ PAL_LoadDefaultGame(
    gpGlobals->fEnteringScene = TRUE;
 }
 
+typedef struct tagSAVEDGAME_COMMON
+{
+	WORD             wSavedTimes;             // saved times
+	WORD             wViewportX, wViewportY;  // viewport location
+	WORD             nPartyMember;            // number of members in party
+	WORD             wNumScene;               // scene number
+	WORD             wPaletteOffset;
+	WORD             wPartyDirection;         // party direction
+	WORD             wNumMusic;               // music number
+	WORD             wNumBattleMusic;         // battle music number
+	WORD             wNumBattleField;         // battle field number
+	WORD             wScreenWave;             // level of screen waving
+	WORD             wBattleSpeed;            // battle speed
+	WORD             wCollectValue;           // value of "collected" items
+	WORD             wLayer;
+	WORD             wChaseRange;
+	WORD             wChasespeedChangeCycles;
+	WORD             nFollower;
+	WORD             rgwReserved2[3];         // unused
+	DWORD            dwCash;                  // amount of cash
+	PARTY            rgParty[MAX_PLAYABLE_PLAYER_ROLES];       // player party
+	TRAIL            rgTrail[MAX_PLAYABLE_PLAYER_ROLES];       // player trail
+	ALLEXPERIENCE    Exp;                     // experience data
+	PLAYERROLES      PlayerRoles;
+	POISONSTATUS     rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
+	INVENTORY        rgInventory[MAX_INVENTORY];               // inventory status
+	SCENE            rgScene[MAX_SCENES];
+} SAVEDGAME_COMMON, *LPSAVEDGAME_COMMON;
+
+typedef struct tagSAVEDGAME_DOS
+{
+	WORD             wSavedTimes;             // saved times
+	WORD             wViewportX, wViewportY;  // viewport location
+	WORD             nPartyMember;            // number of members in party
+	WORD             wNumScene;               // scene number
+	WORD             wPaletteOffset;
+	WORD             wPartyDirection;         // party direction
+	WORD             wNumMusic;               // music number
+	WORD             wNumBattleMusic;         // battle music number
+	WORD             wNumBattleField;         // battle field number
+	WORD             wScreenWave;             // level of screen waving
+	WORD             wBattleSpeed;            // battle speed
+	WORD             wCollectValue;           // value of "collected" items
+	WORD             wLayer;
+	WORD             wChaseRange;
+	WORD             wChasespeedChangeCycles;
+	WORD             nFollower;
+	WORD             rgwReserved2[3];         // unused
+	DWORD            dwCash;                  // amount of cash
+	PARTY            rgParty[MAX_PLAYABLE_PLAYER_ROLES];       // player party
+	TRAIL            rgTrail[MAX_PLAYABLE_PLAYER_ROLES];       // player trail
+	ALLEXPERIENCE    Exp;                     // experience data
+	PLAYERROLES      PlayerRoles;
+	POISONSTATUS     rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
+	INVENTORY        rgInventory[MAX_INVENTORY];               // inventory status
+	SCENE            rgScene[MAX_SCENES];
+	OBJECT_DOS       rgObject[MAX_OBJECTS];
+	EVENTOBJECT      rgEventObject[MAX_EVENT_OBJECTS];
+} SAVEDGAME_DOS, *LPSAVEDGAME_DOS;
+
+typedef struct tagSAVEDGAME_WIN
+{
+	WORD             wSavedTimes;             // saved times
+	WORD             wViewportX, wViewportY;  // viewport location
+	WORD             nPartyMember;            // number of members in party
+	WORD             wNumScene;               // scene number
+	WORD             wPaletteOffset;
+	WORD             wPartyDirection;         // party direction
+	WORD             wNumMusic;               // music number
+	WORD             wNumBattleMusic;         // battle music number
+	WORD             wNumBattleField;         // battle field number
+	WORD             wScreenWave;             // level of screen waving
+	WORD             wBattleSpeed;            // battle speed
+	WORD             wCollectValue;           // value of "collected" items
+	WORD             wLayer;
+	WORD             wChaseRange;
+	WORD             wChasespeedChangeCycles;
+	WORD             nFollower;
+	WORD             rgwReserved2[3];         // unused
+	DWORD            dwCash;                  // amount of cash
+	PARTY            rgParty[MAX_PLAYABLE_PLAYER_ROLES];       // player party
+	TRAIL            rgTrail[MAX_PLAYABLE_PLAYER_ROLES];       // player trail
+	ALLEXPERIENCE    Exp;                     // experience data
+	PLAYERROLES      PlayerRoles;
+	POISONSTATUS     rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
+	INVENTORY        rgInventory[MAX_INVENTORY];               // inventory status
+	SCENE            rgScene[MAX_SCENES];
+	OBJECT           rgObject[MAX_OBJECTS];
+	EVENTOBJECT      rgEventObject[MAX_EVENT_OBJECTS];
+} SAVEDGAME_WIN, *LPSAVEDGAME_WIN;
+
+static VOID
+PAL_LoadGame_Common(
+	const LPSAVEDGAME_COMMON s
+)
+{
+	gpGlobals->viewport = PAL_XY(s->wViewportX, s->wViewportY);
+	gpGlobals->wMaxPartyMemberIndex = s->nPartyMember;
+	gpGlobals->wNumScene = s->wNumScene;
+	gpGlobals->fNightPalette = (s->wPaletteOffset != 0);
+	gpGlobals->wPartyDirection = s->wPartyDirection;
+	gpGlobals->wNumMusic = s->wNumMusic;
+	gpGlobals->wNumBattleMusic = s->wNumBattleMusic;
+	gpGlobals->wNumBattleField = s->wNumBattleField;
+	gpGlobals->wScreenWave = s->wScreenWave;
+	gpGlobals->sWaveProgression = 0;
+	gpGlobals->wCollectValue = s->wCollectValue;
+	gpGlobals->wLayer = s->wLayer;
+	gpGlobals->wChaseRange = s->wChaseRange;
+	gpGlobals->wChasespeedChangeCycles = s->wChasespeedChangeCycles;
+	gpGlobals->nFollower = s->nFollower;
+	gpGlobals->dwCash = s->dwCash;
+#ifndef PAL_CLASSIC
+	gpGlobals->bBattleSpeed = s->wBattleSpeed;
+	if (gpGlobals->bBattleSpeed > 5 || gpGlobals->bBattleSpeed == 0)
+	{
+		gpGlobals->bBattleSpeed = 2;
+	}
+#endif
+
+	memcpy(gpGlobals->rgParty, s->rgParty, sizeof(gpGlobals->rgParty));
+	memcpy(gpGlobals->rgTrail, s->rgTrail, sizeof(gpGlobals->rgTrail));
+	gpGlobals->Exp = s->Exp;
+	gpGlobals->g.PlayerRoles = s->PlayerRoles;
+	memset(gpGlobals->rgPoisonStatus, 0, sizeof(gpGlobals->rgPoisonStatus));
+	memcpy(gpGlobals->rgInventory, s->rgInventory, sizeof(gpGlobals->rgInventory));
+	memcpy(gpGlobals->g.rgScene, s->rgScene, sizeof(gpGlobals->g.rgScene));
+}
+
 static INT
-PAL_LoadGame(
+PAL_LoadGame_DOS(
    LPCSTR         szFileName
 )
 /*++
@@ -469,7 +632,7 @@ PAL_LoadGame(
 --*/
 {
    FILE                     *fp;
-   PAL_LARGE SAVEDGAME       s;
+   PAL_LARGE SAVEDGAME_DOS   s;
 
    //
    // Try to open the specified file
@@ -483,13 +646,13 @@ PAL_LoadGame(
    //
    // Read all data from the file and close.
    //
-   fread(&s, sizeof(SAVEDGAME), 1, fp);
+   fread(&s, sizeof(SAVEDGAME_DOS), 1, fp);
    fclose(fp);
 
    //
    // Adjust endianness
    //
-   DO_BYTESWAP(&s, sizeof(SAVEDGAME));
+   DO_BYTESWAP(&s, sizeof(SAVEDGAME_DOS));
 
    //
    // Cash amount is in DWORD, so do a wordswap in Big-Endian.
@@ -501,37 +664,89 @@ PAL_LoadGame(
    //
    // Get all the data from the saved game struct.
    //
-   gpGlobals->viewport = PAL_XY(s.wViewportX, s.wViewportY);
-   gpGlobals->wMaxPartyMemberIndex = s.nPartyMember;
-   gpGlobals->wNumScene = s.wNumScene;
-   gpGlobals->fNightPalette = (s.wPaletteOffset != 0);
-   gpGlobals->wPartyDirection = s.wPartyDirection;
-   gpGlobals->wNumMusic = s.wNumMusic;
-   gpGlobals->wNumBattleMusic = s.wNumBattleMusic;
-   gpGlobals->wNumBattleField = s.wNumBattleField;
-   gpGlobals->wScreenWave = s.wScreenWave;
-   gpGlobals->sWaveProgression = 0;
-   gpGlobals->wCollectValue = s.wCollectValue;
-   gpGlobals->wLayer = s.wLayer;
-   gpGlobals->wChaseRange = s.wChaseRange;
-   gpGlobals->wChasespeedChangeCycles = s.wChasespeedChangeCycles;
-   gpGlobals->nFollower = s.nFollower;
-   gpGlobals->dwCash = s.dwCash;
-#ifndef PAL_CLASSIC
-   gpGlobals->bBattleSpeed = s.wBattleSpeed;
-   if (gpGlobals->bBattleSpeed > 5 || gpGlobals->bBattleSpeed == 0)
+   PAL_LoadGame_Common((LPSAVEDGAME_COMMON)&s);
+   //
+   // Convert the DOS-style data structure to WIN-style data structure
+   //
+   for (int i = 0; i < MAX_OBJECTS; i++)
+   {
+      memcpy(&gpGlobals->g.rgObject[i], &s.rgObject[i], sizeof(OBJECT_DOS));
+	  if (i >= OBJECT_ITEM_START && i <= OBJECT_MAGIC_END)
+	  {
+         gpGlobals->g.rgObject[i].rgwData[6] = s.rgObject[i].rgwData[5];     // wFlags
+         gpGlobals->g.rgObject[i].rgwData[5] = 0;                            // wScriptDesc or wReserved2
+	  }
+	  else
+	  {
+         gpGlobals->g.rgObject[i].rgwData[6] = 0;
+      }
+   }
+   memcpy(gpGlobals->g.lprgEventObject, s.rgEventObject,
+      sizeof(EVENTOBJECT) * gpGlobals->g.nEventObject);
+
+   gpGlobals->fEnteringScene = FALSE;
+
+   PAL_CompressInventory();
+
+   //
+   // Success
+   //
+   return 0;
+}
+
+static INT
+PAL_LoadGame_WIN(
+   LPCSTR         szFileName
+)
+/*++
+  Purpose:
+
+    Load a saved game.
+
+  Parameters:
+
+    [IN]  szFileName - file name of saved game.
+
+  Return value:
+
+    0 if success, -1 if failed.
+
+--*/
+{
+   FILE                     *fp;
+   PAL_LARGE SAVEDGAME_WIN   s;
+
+   //
+   // Try to open the specified file
+   //
+   fp = fopen(szFileName, "rb");
+   if (fp == NULL)
    {
-      gpGlobals->bBattleSpeed = 2;
+      return -1;
    }
+
+   //
+   // Read all data from the file and close.
+   //
+   fread(&s, sizeof(SAVEDGAME_WIN), 1, fp);
+   fclose(fp);
+
+   //
+   // Adjust endianness
+   //
+   DO_BYTESWAP(&s, sizeof(SAVEDGAME_WIN));
+
+   //
+   // Cash amount is in DWORD, so do a wordswap in Big-Endian.
+   //
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+   s.dwCash = ((s.dwCash >> 16) | (s.dwCash << 16));
 #endif
 
-   memcpy(gpGlobals->rgParty, s.rgParty, sizeof(gpGlobals->rgParty));
-   memcpy(gpGlobals->rgTrail, s.rgTrail, sizeof(gpGlobals->rgTrail));
-   gpGlobals->Exp = s.Exp;
-   gpGlobals->g.PlayerRoles = s.PlayerRoles;
-   memset(gpGlobals->rgPoisonStatus, 0, sizeof(gpGlobals->rgPoisonStatus));
-   memcpy(gpGlobals->rgInventory, s.rgInventory, sizeof(gpGlobals->rgInventory));
-   memcpy(gpGlobals->g.rgScene, s.rgScene, sizeof(gpGlobals->g.rgScene));
+   //
+   // Get all the data from the saved game struct.
+   //
+   PAL_LoadGame_Common((LPSAVEDGAME_COMMON)&s);
    memcpy(gpGlobals->g.rgObject, s.rgObject, sizeof(gpGlobals->g.rgObject));
    memcpy(gpGlobals->g.lprgEventObject, s.rgEventObject,
       sizeof(EVENTOBJECT) * gpGlobals->g.nEventObject);
@@ -546,8 +761,52 @@ PAL_LoadGame(
    return 0;
 }
 
-VOID
-PAL_SaveGame(
+static INT
+PAL_LoadGame(
+   LPCSTR         szFileName
+)
+{
+	return gpGlobals->fIsWIN95 ? PAL_LoadGame_WIN(szFileName) : PAL_LoadGame_DOS(szFileName);
+}
+
+static VOID
+PAL_SaveGame_Common(
+    const LPSAVEDGAME_COMMON s
+)
+{
+	s->wViewportX = PAL_X(gpGlobals->viewport);
+	s->wViewportY = PAL_Y(gpGlobals->viewport);
+	s->nPartyMember = gpGlobals->wMaxPartyMemberIndex;
+	s->wNumScene = gpGlobals->wNumScene;
+	s->wPaletteOffset = (gpGlobals->fNightPalette ? 0x180 : 0);
+	s->wPartyDirection = gpGlobals->wPartyDirection;
+	s->wNumMusic = gpGlobals->wNumMusic;
+	s->wNumBattleMusic = gpGlobals->wNumBattleMusic;
+	s->wNumBattleField = gpGlobals->wNumBattleField;
+	s->wScreenWave = gpGlobals->wScreenWave;
+	s->wCollectValue = gpGlobals->wCollectValue;
+	s->wLayer = gpGlobals->wLayer;
+	s->wChaseRange = gpGlobals->wChaseRange;
+	s->wChasespeedChangeCycles = gpGlobals->wChasespeedChangeCycles;
+	s->nFollower = gpGlobals->nFollower;
+	s->dwCash = gpGlobals->dwCash;
+#ifndef PAL_CLASSIC
+	s->wBattleSpeed = gpGlobals->bBattleSpeed;
+#else
+	s->wBattleSpeed = 2;
+#endif
+
+	memcpy(s->rgParty, gpGlobals->rgParty, sizeof(gpGlobals->rgParty));
+	memcpy(s->rgTrail, gpGlobals->rgTrail, sizeof(gpGlobals->rgTrail));
+	s->Exp = gpGlobals->Exp;
+	s->PlayerRoles = gpGlobals->g.PlayerRoles;
+	memcpy(s->rgPoisonStatus, gpGlobals->rgPoisonStatus, sizeof(gpGlobals->rgPoisonStatus));
+	memcpy(s->rgInventory, gpGlobals->rgInventory, sizeof(gpGlobals->rgInventory));
+	memcpy(s->rgScene, gpGlobals->g.rgScene, sizeof(gpGlobals->g.rgScene));
+}
+
+static VOID
+PAL_SaveGame_DOS(
    LPCSTR         szFileName,
    WORD           wSavedTimes
 )
@@ -567,41 +826,85 @@ PAL_SaveGame(
 --*/
 {
    FILE                     *fp;
-   PAL_LARGE SAVEDGAME       s;
+   PAL_LARGE SAVEDGAME_DOS   s;
    UINT32                    i;
 
    //
    // Put all the data to the saved game struct.
    //
-   s.wViewportX = PAL_X(gpGlobals->viewport);
-   s.wViewportY = PAL_Y(gpGlobals->viewport);
-   s.nPartyMember = gpGlobals->wMaxPartyMemberIndex;
-   s.wNumScene = gpGlobals->wNumScene;
-   s.wPaletteOffset = (gpGlobals->fNightPalette ? 0x180 : 0);
-   s.wPartyDirection = gpGlobals->wPartyDirection;
-   s.wNumMusic = gpGlobals->wNumMusic;
-   s.wNumBattleMusic = gpGlobals->wNumBattleMusic;
-   s.wNumBattleField = gpGlobals->wNumBattleField;
-   s.wScreenWave = gpGlobals->wScreenWave;
-   s.wCollectValue = gpGlobals->wCollectValue;
-   s.wLayer = gpGlobals->wLayer;
-   s.wChaseRange = gpGlobals->wChaseRange;
-   s.wChasespeedChangeCycles = gpGlobals->wChasespeedChangeCycles;
-   s.nFollower = gpGlobals->nFollower;
-   s.dwCash = gpGlobals->dwCash;
-#ifndef PAL_CLASSIC
-   s.wBattleSpeed = gpGlobals->bBattleSpeed;
-#else
-   s.wBattleSpeed = 2;
+   PAL_SaveGame_Common((LPSAVEDGAME_COMMON)&s);
+   //
+   // Convert the WIN-style data structure to DOS-style data structure
+   //
+   for (int i = 0; i < MAX_OBJECTS; i++)
+   {
+      memcpy(&s.rgObject[i], &gpGlobals->g.rgObject[i], sizeof(OBJECT_DOS));
+	  if (i >= OBJECT_ITEM_START && i <= OBJECT_MAGIC_END)
+	  {
+         s.rgObject[i].rgwData[5] = gpGlobals->g.rgObject[i].rgwData[6];     // wFlags
+	  }
+   }
+   memcpy(s.rgEventObject, gpGlobals->g.lprgEventObject,
+      sizeof(EVENTOBJECT) * gpGlobals->g.nEventObject);
+
+   s.wSavedTimes = wSavedTimes;
+
+   //
+   // Adjust endianness
+   //
+   DO_BYTESWAP(&s, sizeof(SAVEDGAME));
+
+   //
+   // Cash amount is in DWORD, so do a wordswap in Big-Endian.
+   //
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+   s.dwCash = ((s.dwCash >> 16) | (s.dwCash << 16));
 #endif
 
-   memcpy(s.rgParty, gpGlobals->rgParty, sizeof(gpGlobals->rgParty));
-   memcpy(s.rgTrail, gpGlobals->rgTrail, sizeof(gpGlobals->rgTrail));
-   s.Exp = gpGlobals->Exp;
-   s.PlayerRoles = gpGlobals->g.PlayerRoles;
-   memcpy(s.rgPoisonStatus, gpGlobals->rgPoisonStatus, sizeof(gpGlobals->rgPoisonStatus));
-   memcpy(s.rgInventory, gpGlobals->rgInventory, sizeof(gpGlobals->rgInventory));
-   memcpy(s.rgScene, gpGlobals->g.rgScene, sizeof(gpGlobals->g.rgScene));
+   //
+   // Try writing to file
+   //
+   fp = fopen(szFileName, "wb");
+   if (fp == NULL)
+   {
+      return;
+   }
+
+   i = PAL_MKFGetChunkSize(0, gpGlobals->f.fpSSS);
+   i += sizeof(SAVEDGAME_DOS) - sizeof(EVENTOBJECT) * MAX_EVENT_OBJECTS;
+
+   fwrite(&s, i, 1, fp);
+   fclose(fp);
+}
+
+static VOID
+PAL_SaveGame_WIN(
+   LPCSTR         szFileName,
+   WORD           wSavedTimes
+)
+/*++
+  Purpose:
+
+    Save the current game state to file.
+
+  Parameters:
+
+    [IN]  szFileName - file name of saved game.
+
+  Return value:
+
+    None.
+
+--*/
+{
+   FILE                     *fp;
+   PAL_LARGE SAVEDGAME_WIN   s;
+   UINT32                    i;
+
+   //
+   // Put all the data to the saved game struct.
+   //
+   PAL_SaveGame_Common((LPSAVEDGAME_COMMON)&s);
    memcpy(s.rgObject, gpGlobals->g.rgObject, sizeof(gpGlobals->g.rgObject));
    memcpy(s.rgEventObject, gpGlobals->g.lprgEventObject,
       sizeof(EVENTOBJECT) * gpGlobals->g.nEventObject);
@@ -630,12 +933,24 @@ PAL_SaveGame(
    }
 
    i = PAL_MKFGetChunkSize(0, gpGlobals->f.fpSSS);
-   i += sizeof(SAVEDGAME) - sizeof(EVENTOBJECT) * MAX_EVENT_OBJECTS;
+   i += sizeof(SAVEDGAME_WIN) - sizeof(EVENTOBJECT) * MAX_EVENT_OBJECTS;
 
    fwrite(&s, i, 1, fp);
    fclose(fp);
 }
 
+VOID
+PAL_SaveGame(
+   LPCSTR         szFileName,
+   WORD           wSavedTimes
+)
+{
+	if (gpGlobals->fIsWIN95)
+		PAL_SaveGame_WIN(szFileName, wSavedTimes);
+	else
+		PAL_SaveGame_DOS(szFileName, wSavedTimes);
+}
+
 VOID
 PAL_InitGameData(
    INT         iSaveSlot

+ 48 - 51
global.h

@@ -85,6 +85,11 @@ extern "C"
 // maximum number of level
 #define     MAX_LEVELS                   99
 
+#define     OBJECT_ITEM_START            0x3D
+#define     OBJECT_ITEM_END              0x126
+#define     OBJECT_MAGIC_START           0x127
+#define     OBJECT_MAGIC_END             0x18D
+
 // status of characters
 typedef enum tagSTATUS
 {
@@ -191,17 +196,26 @@ typedef enum tagITEMFLAG
 } ITEMFLAG;
 
 // items
-typedef struct tagOBJECT_ITEM
+typedef struct tagOBJECT_ITEM_DOS
 {
    WORD         wBitmap;         // bitmap number in BALL.MKF
    WORD         wPrice;          // price
    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_DOS;
+
+// items
+typedef struct tagOBJECT_ITEM
+{
+	WORD         wBitmap;         // bitmap number in BALL.MKF
+	WORD         wPrice;          // price
+	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
+	WORD         wScriptDesc;     // description script
+	WORD         wFlags;          // flags
 } OBJECT_ITEM;
 
 typedef enum tagMAGICFLAG
@@ -213,17 +227,26 @@ typedef enum tagMAGICFLAG
 } MAGICFLAG;
 
 // magics
-typedef struct tagOBJECT_MAGIC
+typedef struct tagOBJECT_MAGIC_DOS
 {
    WORD         wMagicNumber;      // magic number, according to DATA.MKF #3
    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_DOS;
+
+// magics
+typedef struct tagOBJECT_MAGIC
+{
+	WORD         wMagicNumber;      // magic number, according to DATA.MKF #3
+	WORD         wReserved1;        // always zero
+	WORD         wScriptOnSuccess;  // when magic succeed, execute script from here
+	WORD         wScriptOnUse;      // when use this magic, execute script from here
+	WORD         wScriptDesc;       // description script
+	WORD         wReserved2;        // always zero
+	WORD         wFlags;            // flags
 } OBJECT_MAGIC;
 
 // enemies
@@ -247,18 +270,24 @@ typedef struct tagOBJECT_POISON
    WORD         wEnemyScript;    // script executed when enemy has this poison (per round)
 } OBJECT_POISON;
 
+typedef union tagOBJECT_DOS
+{
+	WORD              rgwData[6];
+	OBJECT_PLAYER     player;
+	OBJECT_ITEM_DOS   item;
+	OBJECT_MAGIC_DOS  magic;
+	OBJECT_ENEMY      enemy;
+	OBJECT_POISON     poison;
+} OBJECT_DOS, *LPOBJECT_DOS;
+
 typedef union tagOBJECT
 {
-#ifdef PAL_WIN95
-   WORD              rgwData[7];
-#else
-   WORD              rgwData[6];
-#endif
-   OBJECT_PLAYER     player;
-   OBJECT_ITEM       item;
-   OBJECT_MAGIC      magic;
-   OBJECT_ENEMY      enemy;
-   OBJECT_POISON     poison;
+	WORD              rgwData[7];
+	OBJECT_PLAYER     player;
+	OBJECT_ITEM       item;
+	OBJECT_MAGIC      magic;
+	OBJECT_ENEMY      enemy;
+	OBJECT_POISON     poison;
 } OBJECT, *LPOBJECT;
 
 typedef struct tagSCRIPTENTRY
@@ -561,49 +590,17 @@ 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;
 #ifdef PAL_UNICODE
    CODEPAGE         iCodePage;
    DWORD            dwWordLength;
    DWORD            dwExtraMagicDescLines;
    DWORD            dwExtraItemDescLines;
+   BOOL             fIsWIN95;
 #endif
 } GLOBALVARS, *LPGLOBALVARS;
 
-typedef struct tagSAVEDGAME
-{
-   WORD             wSavedTimes;             // saved times
-   WORD             wViewportX, wViewportY;  // viewport location
-   WORD             nPartyMember;            // number of members in party
-   WORD             wNumScene;               // scene number
-   WORD             wPaletteOffset;
-   WORD             wPartyDirection;         // party direction
-   WORD             wNumMusic;               // music number
-   WORD             wNumBattleMusic;         // battle music number
-   WORD             wNumBattleField;         // battle field number
-   WORD             wScreenWave;             // level of screen waving
-   WORD             wBattleSpeed;            // battle speed
-   WORD             wCollectValue;           // value of "collected" items
-   WORD             wLayer;
-   WORD             wChaseRange;
-   WORD             wChasespeedChangeCycles;
-   WORD             nFollower;
-   WORD             rgwReserved2[3];         // unused
-   DWORD            dwCash;                  // amount of cash
-   PARTY            rgParty[MAX_PLAYABLE_PLAYER_ROLES];       // player party
-   TRAIL            rgTrail[MAX_PLAYABLE_PLAYER_ROLES];       // player trail
-   ALLEXPERIENCE    Exp;                     // experience data
-   PLAYERROLES      PlayerRoles;
-   POISONSTATUS     rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
-   INVENTORY        rgInventory[MAX_INVENTORY];               // inventory status
-   SCENE            rgScene[MAX_SCENES];
-   OBJECT           rgObject[MAX_OBJECTS];
-   EVENTOBJECT      rgEventObject[MAX_EVENT_OBJECTS];
-} SAVEDGAME, *LPSAVEDGAME;
-
 extern LPGLOBALVARS gpGlobals;
 
 INT

+ 47 - 50
itemmenu.c

@@ -46,13 +46,8 @@ 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;
@@ -245,78 +240,80 @@ PAL_ItemSelectMenuUpdate(
    //
    // Draw the description of the selected item
    //
-#ifndef PAL_WIN95
-   if (!g_fNoDesc && gpGlobals->lpObjectDesc != NULL)
+   if (!gpGlobals->fIsWIN95)
    {
-#  ifdef PAL_UNICODE
-	  WCHAR szDesc[512], *next;
-	  const WCHAR *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, wObject);
-#  else
-      char szDesc[512], *next;
-      const char *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, wObject);
-#  endif
-
-      if (d != NULL)
-      {
-         k = 150;
+      if (!g_fNoDesc && gpGlobals->lpObjectDesc != NULL)
+	  {
 #     ifdef PAL_UNICODE
-		 wcscpy(szDesc, d);
+         WCHAR szDesc[512], *next;
+         const WCHAR *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, wObject);
 #     else
-         strcpy(szDesc, d);
+         char szDesc[512], *next;
+         const char *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, wObject);
 #     endif
-         d = szDesc;
 
-         while (TRUE)
+         if (d != NULL)
          {
+            k = 150;
 #        ifdef PAL_UNICODE
-			next = wcschr(d, '*');
+            wcscpy(szDesc, d);
 #        else
-			next = strchr(d, '*');
+            strcpy(szDesc, d);
 #        endif
-            if (next != NULL)
+            d = szDesc;
+
+            while (TRUE)
             {
-               *next = '\0';
-               next++;
-            }
+#           ifdef PAL_UNICODE
+               next = wcschr(d, '*');
+#           else
+               next = strchr(d, '*');
+#           endif
+               if (next != NULL)
+               {
+                  *next++ = '\0';
+               }
 
-            PAL_DrawText(d, PAL_XY(75, k), DESCTEXT_COLOR, TRUE, FALSE);
-            k += 16;
+               PAL_DrawText(d, PAL_XY(75, k), DESCTEXT_COLOR, TRUE, FALSE);
+               k += 16;
 
-            if (next == NULL)
-            {
-               break;
-            }
+               if (next == NULL)
+               {
+                  break;
+               }
 
-            d = next;
+               d = next;
+            }
          }
       }
    }
-#else
-   if (!g_fNoDesc)
+   else
    {
-      wScript = gpGlobals->g.rgObject[wObject].item.wScriptDesc;
-      line = 0;
-      while (wScript && gpGlobals->g.lprgScriptEntry[wScript].wOperation != 0)
+      if (!g_fNoDesc)
       {
-         if (gpGlobals->g.lprgScriptEntry[wScript].wOperation == 0xFFFF)
+         wScript = gpGlobals->g.rgObject[wObject].item.wScriptDesc;
+         line = 0;
+         while (wScript && gpGlobals->g.lprgScriptEntry[wScript].wOperation != 0)
          {
+            if (gpGlobals->g.lprgScriptEntry[wScript].wOperation == 0xFFFF)
+            {
 #ifdef PAL_UNICODE
-			 int line_incr = (gpGlobals->g.lprgScriptEntry[wScript].rgwOperand[1] != 1) ? 1 : 0;
+              int line_incr = (gpGlobals->g.lprgScriptEntry[wScript].rgwOperand[1] != 1) ? 1 : 0;
 #endif
-			 wScript = PAL_RunAutoScript(wScript, PAL_ITEM_DESC_BOTTOM | line);
+               wScript = PAL_RunAutoScript(wScript, PAL_ITEM_DESC_BOTTOM | line);
 #ifdef PAL_UNICODE
-			 line += line_incr;
+               line += line_incr;
 #else
-			 line++;
+               line++;
 #endif
-         }
-         else
-         {
-            wScript = PAL_RunAutoScript(wScript, 0);
+            }
+            else
+            {
+               wScript = PAL_RunAutoScript(wScript, 0);
+            }
          }
       }
    }
-#endif
 
    if (g_InputState.dwKeyPress & kKeySearch)
    {

+ 83 - 86
magicmenu.c

@@ -53,14 +53,9 @@ PAL_MagicSelectionMenuUpdate(
 
 --*/
 {
-#ifndef PAL_WIN95
-   int         i, j, k;
-   BYTE        bColor;
-#else
    int         i, j, k, line;
    BYTE        bColor;
    WORD        wScript;
-#endif
 #ifdef PAL_UNICODE
    const int   iItemsPerLine = 32 / gpGlobals->dwWordLength;
    const int   iItemTextWidth = 8 * gpGlobals->dwWordLength + 7;
@@ -126,71 +121,106 @@ PAL_MagicSelectionMenuUpdate(
    //
    PAL_CreateBox(PAL_XY(10, 42 + iBoxYOffset), iLinesPerPage - 1, 16, 1, FALSE);
 
-#ifndef PAL_WIN95
-   if (gpGlobals->lpObjectDesc == NULL)
+   if (!gpGlobals->fIsWIN95)
    {
-      //
-      // Draw the cash amount.
-      //
-      PAL_CreateSingleLineBox(PAL_XY(0, 0), 5, FALSE);
-      PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(10, 10), 0, FALSE, FALSE);
-      PAL_DrawNumber(gpGlobals->dwCash, 6, PAL_XY(49, 14), kNumColorYellow, kNumAlignRight);
+      if (gpGlobals->lpObjectDesc == NULL)
+      {
+         //
+         // Draw the cash amount.
+         //
+         PAL_CreateSingleLineBox(PAL_XY(0, 0), 5, FALSE);
+         PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(10, 10), 0, FALSE, FALSE);
+         PAL_DrawNumber(gpGlobals->dwCash, 6, PAL_XY(49, 14), kNumColorYellow, kNumAlignRight);
 
-      //
-      // Draw the MP of the selected magic.
-      //
-      PAL_CreateSingleLineBox(PAL_XY(215, 0), 5, FALSE);
-      PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH),
-         gpScreen, PAL_XY(260, 14));
-      PAL_DrawNumber(rgMagicItem[g_iCurrentItem].wMP, 4, PAL_XY(230, 14),
-         kNumColorYellow, kNumAlignRight);
-      PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(265, 14), kNumColorCyan, kNumAlignRight);
-   }
-   else
-   {
+         //
+         // Draw the MP of the selected magic.
+         //
+         PAL_CreateSingleLineBox(PAL_XY(215, 0), 5, FALSE);
+         PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH),
+            gpScreen, PAL_XY(260, 14));
+         PAL_DrawNumber(rgMagicItem[g_iCurrentItem].wMP, 4, PAL_XY(230, 14),
+            kNumColorYellow, kNumAlignRight);
+         PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(265, 14), kNumColorCyan, kNumAlignRight);
+      }
+      else
+      {
 #  ifdef PAL_UNICODE
-      WCHAR szDesc[512], *next;
-      const WCHAR *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, rgMagicItem[g_iCurrentItem].wMagic);
+         WCHAR szDesc[512], *next;
+         const WCHAR *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, rgMagicItem[g_iCurrentItem].wMagic);
 #  else
-      char szDesc[512], *next;
-      const char *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, rgMagicItem[g_iCurrentItem].wMagic);
+         char szDesc[512], *next;
+         const char *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, rgMagicItem[g_iCurrentItem].wMagic);
 #  endif
 
-      //
-      // Draw the magic description.
-      //
-      if (d != NULL)
-      {
-         k = 3;
+         //
+         // Draw the magic description.
+         //
+         if (d != NULL)
+         {
+            k = 3;
 #     ifdef PAL_UNICODE
-		 wcscpy(szDesc, d);
+		    wcscpy(szDesc, d);
 #     else
-         strcpy(szDesc, d);
+            strcpy(szDesc, d);
 #     endif
-         d = szDesc;
+            d = szDesc;
 
-         while (TRUE)
-         {
+            while (TRUE)
+            {
 #        ifdef PAL_UNICODE
-			next = wcschr(d, '*');
+               next = wcschr(d, '*');
 #        else
-			next = strchr(d, '*');
+               next = strchr(d, '*');
 #        endif
-            if (next != NULL)
-            {
-               *next = '\0';
-               next++;
-            }
+               if (next != NULL)
+               {
+                  *next++ = '\0';
+               }
 
-            PAL_DrawText(d, PAL_XY(100, k), DESCTEXT_COLOR, TRUE, FALSE);
-            k += 16;
+               PAL_DrawText(d, PAL_XY(100, k), DESCTEXT_COLOR, TRUE, FALSE);
+               k += 16;
 
-            if (next == NULL)
-            {
-               break;
+               if (next == NULL)
+               {
+                  break;
+               }
+
+               d = next;
             }
+         }
 
-            d = next;
+         //
+         // 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);
+      }
+   }
+   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)
+         {
+#ifdef PAL_UNICODE
+            int line_incr = (gpGlobals->g.lprgScriptEntry[wScript].rgwOperand[1] != 1) ? 1 : 0;
+#endif
+            wScript = PAL_RunAutoScript(wScript, line);
+#ifdef PAL_UNICODE
+            line += line_incr;
+#else
+            line++;
+#endif
+	     }
+         else
+         {
+            wScript = PAL_RunAutoScript(wScript, 0);
          }
       }
 
@@ -204,39 +234,6 @@ 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)
-      {
-#ifdef PAL_UNICODE
-         int line_incr = (gpGlobals->g.lprgScriptEntry[wScript].rgwOperand[1] != 1) ? 1 : 0;
-#endif
-		 wScript = PAL_RunAutoScript(wScript, line);
-#ifdef PAL_UNICODE
-		 line += line_incr;
-#else
-		 line++;
-#endif
-	  }
-      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
 
 
    //

+ 14 - 18
main.c

@@ -32,19 +32,12 @@
 #include <fat.h>
 #endif
 
-#ifdef PAL_WIN95
-#define BITMAPNUM_SPLASH_UP         3
-#define BITMAPNUM_SPLASH_DOWN       4
+#define BITMAPNUM_SPLASH_UP         (gpGlobals->fIsWIN95 ? 0x03 : 0x26)
+#define BITMAPNUM_SPLASH_DOWN       (gpGlobals->fIsWIN95 ? 0x04 : 0x27)
 #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
+#define NUM_RIX_TITLE               0x05
+
 static VOID
 PAL_Init(
    WORD             wScreenWidth,
@@ -144,19 +137,22 @@ PAL_Init(
    PAL_InitResources();
    SOUND_OpenAudio();
 
-#ifdef PAL_WIN95
+   if (gpGlobals->fIsWIN95)
+   {
 #ifdef _DEBUG
-   SDL_WM_SetCaption("Pal WIN95 (Debug Build)", NULL);
+      SDL_WM_SetCaption("Pal WIN95 (Debug Build)", NULL);
 #else
-   SDL_WM_SetCaption("Pal WIN95", NULL);
+      SDL_WM_SetCaption("Pal WIN95", NULL);
 #endif
-#else
+   }
+   else
+   {
 #ifdef _DEBUG
-   SDL_WM_SetCaption("Pal (Debug Build)", NULL);
+      SDL_WM_SetCaption("Pal (Debug Build)", NULL);
 #else
-   SDL_WM_SetCaption("Pal", NULL);
-#endif
+      SDL_WM_SetCaption("Pal", NULL);
 #endif
+   }
 }
 
 VOID

+ 136 - 137
midi.c

@@ -1,140 +1,139 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2011, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "main.h"
-
-#if !defined (CYGWIN) && !defined (DINGOO) &&  !defined (GEKKO) && !defined (GPH)
-
-static INT iMidCurrent = -1;
-static BOOL fMidLoop = FALSE;
-
-static NativeMidiSong *g_pMid = NULL;
-
-VOID
-MIDI_Play(
-   INT       iNumRIX,
-   BOOL      fLoop
-)
-/*++
-  Purpose:
-
-    Start playing the specified music in MIDI format.
-
-  Parameters:
-
-    [IN]  iNumRIX - number of the music. 0 to stop playing current music.
-
-    [IN]  fLoop - Whether the music should be looped or not.
-
-  Return value:
-
-    None.
-
---*/
-{
-#ifndef PAL_WIN95
-   FILE            *fp;
-   unsigned char   *buf;
-   int              size;
-   SDL_RWops       *rw;
-#else
-   char             filename[1024];
-#endif
-
-   if (g_pMid != NULL && iNumRIX == iMidCurrent && native_midi_active())
-   {
-      return;
-   }
-
-   SOUND_PlayCDA(-1);
-   native_midi_freesong(g_pMid);
-   g_pMid = NULL;
-   iMidCurrent = -1;
-
-   if (g_fNoMusic || iNumRIX <= 0)
-   {
-      return;
-   }
-
-#ifdef PAL_WIN95
-   sprintf(filename, "%s/musics/%.3d.mid", PAL_PREFIX, iNumRIX);
-
-   g_pMid = native_midi_loadsong(filename);
-   if (g_pMid != NULL)
+/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
+//
+// Copyright (c) 2011, Wei Mingzhi <whistler_wmz@users.sf.net>.
+// All rights reserved.
+//
+// This file is part of SDLPAL.
+//
+// SDLPAL is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include "main.h"
+
+#if !defined (CYGWIN) && !defined (DINGOO) &&  !defined (GEKKO) && !defined (GPH)
+
+static INT iMidCurrent = -1;
+static BOOL fMidLoop = FALSE;
+
+static NativeMidiSong *g_pMid = NULL;
+
+VOID
+MIDI_Play(
+   INT       iNumRIX,
+   BOOL      fLoop
+)
+/*++
+  Purpose:
+
+    Start playing the specified music in MIDI format.
+
+  Parameters:
+
+    [IN]  iNumRIX - number of the music. 0 to stop playing current music.
+
+    [IN]  fLoop - Whether the music should be looped or not.
+
+  Return value:
+
+    None.
+
+--*/
+{
+   if (g_pMid != NULL && iNumRIX == iMidCurrent && native_midi_active())
    {
-      native_midi_start(g_pMid);
+      return;
+   }
+
+   SOUND_PlayCDA(-1);
+   native_midi_freesong(g_pMid);
+   g_pMid = NULL;
+   iMidCurrent = -1;
 
-      iMidCurrent = iNumRIX;
-      fMidLoop = fLoop;
+   if (g_fNoMusic || iNumRIX <= 0)
+   {
+      return;
    }
-#else
-   fp = UTIL_OpenFile("midi.mkf");
-   if (fp == NULL)
-   {
-      return;
-   }
-
-   if (iNumRIX > PAL_MKFGetChunkCount(fp))
-   {
-      fclose(fp);
-      return;
-   }
-
-   size = PAL_MKFGetChunkSize(iNumRIX, fp);
-   if (size <= 0)
-   {
-      fclose(fp);
-      return;
-   }
-
-   buf = (unsigned char *)UTIL_malloc(size);
-
-   PAL_MKFReadChunk((LPBYTE)buf, size, iNumRIX, fp);
-   fclose(fp);
-
-   rw = SDL_RWFromConstMem((const void *)buf, size);
-
-   g_pMid = native_midi_loadsong_RW(rw);
-   if (g_pMid != NULL)
-   {
-      native_midi_start(g_pMid);
-
-      iMidCurrent = iNumRIX;
-      fMidLoop = fLoop;
-   }
-
-   SDL_RWclose(rw);
-   free(buf);
-#endif
-}
-
-VOID
-MIDI_CheckLoop(
-   VOID
-)
-{
-   if (fMidLoop && g_pMid != NULL && !native_midi_active())
-   {
-      MIDI_Play(iMidCurrent, TRUE);
-   }
-}
-
-#endif
+
+   if (gpGlobals->fIsWIN95)
+   {
+      char filename[1024];
+      sprintf(filename, "%s/musics/%.3d.mid", PAL_PREFIX, iNumRIX);
+
+      g_pMid = native_midi_loadsong(filename);
+      if (g_pMid != NULL)
+      {
+         native_midi_start(g_pMid);
+
+         iMidCurrent = iNumRIX;
+         fMidLoop = fLoop;
+      }
+   }
+   else
+   {
+      unsigned char   *buf;
+      int              size;
+      SDL_RWops       *rw;
+      FILE            *fp = UTIL_OpenFile("midi.mkf");
+
+      if (fp == NULL)
+      {
+         return;
+      }
+
+      if (iNumRIX > PAL_MKFGetChunkCount(fp))
+      {
+         fclose(fp);
+         return;
+      }
+
+      size = PAL_MKFGetChunkSize(iNumRIX, fp);
+      if (size <= 0)
+      {
+         fclose(fp);
+         return;
+      }
+
+      buf = (unsigned char *)UTIL_malloc(size);
+
+      PAL_MKFReadChunk((LPBYTE)buf, size, iNumRIX, fp);
+      fclose(fp);
+
+      rw = SDL_RWFromConstMem((const void *)buf, size);
+
+      g_pMid = native_midi_loadsong_RW(rw);
+      if (g_pMid != NULL)
+      {
+         native_midi_start(g_pMid);
+
+         iMidCurrent = iNumRIX;
+         fMidLoop = fLoop;
+      }
+
+      SDL_RWclose(rw);
+      free(buf);
+   }
+}
+
+VOID
+MIDI_CheckLoop(
+   VOID
+)
+{
+   if (fMidLoop && g_pMid != NULL && !native_midi_active())
+   {
+      MIDI_Play(iMidCurrent, TRUE);
+   }
+}
+
+#endif

+ 17 - 16
palcommon.c

@@ -22,6 +22,7 @@
 //
 
 #include "palcommon.h"
+#include "global.h"
 
 INT
 PAL_RLEBlitToSurface(
@@ -641,11 +642,8 @@ PAL_SpriteGetFrame(
    // Get the offset of the frame
    //
    iFrameNum <<= 1;
-#ifdef PAL_WIN95
    offset = ((lpSprite[iFrameNum] | (lpSprite[iFrameNum + 1] << 8)) << 1);
-#else
-   offset = (WORD)((lpSprite[iFrameNum] | (lpSprite[iFrameNum + 1] << 8)) << 1);
-#endif
+   if (!gpGlobals->fIsWIN95) offset = (WORD)offset;
    return &lpSprite[offset];
 }
 
@@ -865,18 +863,21 @@ PAL_MKFGetDecompressedSize(
    // Read the header.
    //
    fseek(fp, uiOffset, SEEK_SET);
-#ifdef PAL_WIN95
-   fread(buf, sizeof(DWORD), 1, 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
+   if (gpGlobals->fIsWIN95)
+   {
+      fread(buf, sizeof(DWORD), 1, 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];
+   }
 }
 
 INT

+ 15 - 1
palcommon.h

@@ -132,8 +132,22 @@ PAL_MKFDecompressChunk(
 );
 
 // From yj1.c:
+extern INT
+(*Decompress)(
+   LPCVOID      Source,
+   LPVOID       Destination,
+   INT          DestSize
+);
+
+INT
+YJ1_Decompress(
+   LPCVOID      Source,
+   LPVOID       Destination,
+   INT          DestSize
+);
+
 INT
-Decompress(
+YJ2_Decompress(
    LPCVOID      Source,
    LPVOID       Destination,
    INT          DestSize

+ 70 - 73
script.c

@@ -609,11 +609,6 @@ PAL_AdditionalCredits(
 
    int        i = 0;
 
-#if defined(PAL_WIN95) && !defined(PAL_UNICODE)
-   extern BOOL fIsBig5;
-   fIsBig5 = TRUE;
-#endif
-
    PAL_DrawOpeningMenuBackground();
 
    for (i = 0; rgszStrings[i]; i++)
@@ -2204,13 +2199,16 @@ 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
+      if (gpGlobals->fIsWIN95)
+	  {
+         SDL_FillRect(gpScreen, NULL, 0);
+         VIDEO_UpdateScreen(NULL);
+      }
+      else
+	  {
+         PAL_EndingSetEffectSprite(0);
+         PAL_ShowFBP(pScript->rgwOperand[0], pScript->rgwOperand[1]);
+      }
       break;
 
    case 0x0077:
@@ -2696,9 +2694,8 @@ PAL_InterpretInstruction(
       //
       // Show the ending animation
       //
-#ifndef PAL_WIN95
-      PAL_EndingAnimation();
-#endif
+      if (!gpGlobals->fIsWIN95)
+         PAL_EndingAnimation();
       break;
 
    case 0x0097:
@@ -2966,9 +2963,8 @@ PAL_InterpretInstruction(
       //
       // Quit game
       //
-#ifdef PAL_WIN95
-      PAL_EndingScreen();
-#endif
+      if (gpGlobals->fIsWIN95)
+         PAL_EndingScreen();
       PAL_AdditionalCredits();
       PAL_Shutdown();
       exit(0);
@@ -3013,33 +3009,35 @@ PAL_InterpretInstruction(
       //
       // Scroll FBP to the screen
       //
-#ifndef PAL_WIN95
-      if (pScript->rgwOperand[0] == 68)
-      {
-         //
-         // HACKHACK: to make the ending picture show correctly
-         //
-         PAL_ShowFBP(69, 0);
-         PAL_ScrollFBP(pScript->rgwOperand[0], pScript->rgwOperand[2], TRUE);
-      }
-      else
-      {
-         PAL_ScrollFBP(pScript->rgwOperand[0], pScript->rgwOperand[2], pScript->rgwOperand[1]);
+      if (!gpGlobals->fIsWIN95)
+	  {
+         if (pScript->rgwOperand[0] == 68)
+         {
+            //
+            // HACKHACK: to make the ending picture show correctly
+            //
+            PAL_ShowFBP(69, 0);
+            PAL_ScrollFBP(pScript->rgwOperand[0], pScript->rgwOperand[2], TRUE);
+         }
+         else
+         {
+            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]);
+      if (!gpGlobals->fIsWIN95)
+	  {
+         if (pScript->rgwOperand[1] != 0xFFFF)
+         {
+            PAL_EndingSetEffectSprite(pScript->rgwOperand[1]);
+         }
+         PAL_ShowFBP(pScript->rgwOperand[0], pScript->rgwOperand[2]);
       }
-      PAL_ShowFBP(pScript->rgwOperand[0], pScript->rgwOperand[2]);
-#endif
       break;
 
    case 0x00A6:
@@ -3424,9 +3422,7 @@ PAL_RunAutoScript(
 {
    LPSCRIPTENTRY          pScript;
    LPEVENTOBJECT          pEvtObj;
-#ifdef PAL_WIN95
    int                    iDescLine = 0;
-#endif
 
 begin:
    pScript = &(gpGlobals->g.lprgScriptEntry[wScriptEntry]);
@@ -3523,48 +3519,49 @@ begin:
       break;
 
    case 0xFFFF:
-#ifdef PAL_WIN95
-	  // Support for Japanese
-	  // If the second parameter is zero, then follow the standard behavior
-	  // Otherwise, use the extended behavior
-      // Either zero or two displays text
-	  if (pScript->rgwOperand[1] == 0 || pScript->rgwOperand[1] == 2)
-	  {
-		  iDescLine = (wEventObjectID & ~PAL_ITEM_DESC_BOTTOM);
-		  if (wEventObjectID & PAL_ITEM_DESC_BOTTOM)
-		  {
+	   if (gpGlobals->fIsWIN95)
+	   {
+		   // Support for Japanese
+		   // If the second parameter is zero, then follow the standard behavior
+		   // Otherwise, use the extended behavior
+		   // Either zero or two displays text
+		   if (pScript->rgwOperand[1] == 0 || pScript->rgwOperand[1] == 2)
+		   {
+			   iDescLine = (wEventObjectID & ~PAL_ITEM_DESC_BOTTOM);
+			   if (wEventObjectID & PAL_ITEM_DESC_BOTTOM)
+			   {
 #  ifdef PAL_UNICODE
-			  int YOffset = gpGlobals->dwExtraItemDescLines * 16;
+				   int YOffset = gpGlobals->dwExtraItemDescLines * 16;
 #  else
-			  int YOffset = 0;
+				   int YOffset = 0;
 #  endif
-			  PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(75, iDescLine * 16 + 150 - YOffset), DESCTEXT_COLOR, TRUE, FALSE);
-		  }
-		  else
-		  {
-			  PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(100, iDescLine * 16 + 3), DESCTEXT_COLOR, TRUE, FALSE);
-		  }
-		  iDescLine++;
-	  }
-	  if (pScript->rgwOperand[1] != 0)
-	  {
-		  // Then, jump to script given by the third parameter.
-		  wScriptEntry = pScript->rgwOperand[2];
-	  }
-	  else
-	  {
-		  wScriptEntry++;
-	  }
-#else
-	  wScriptEntry++;
-#endif
+				   PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(75, iDescLine * 16 + 150 - YOffset), DESCTEXT_COLOR, TRUE, FALSE);
+			   }
+			   else
+			   {
+				   PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(100, iDescLine * 16 + 3), DESCTEXT_COLOR, TRUE, FALSE);
+			   }
+			   iDescLine++;
+		   }
+		   if (pScript->rgwOperand[1] != 0)
+		   {
+			   // Then, jump to script given by the third parameter.
+			   wScriptEntry = pScript->rgwOperand[2];
+		   }
+		   else
+		   {
+			   wScriptEntry++;
+		   }
+	   }
+	   else
+	   {
+		   wScriptEntry++;
+	   }
 	  break;
 
-#ifdef PAL_WIN95
    case 0x00A7:
 	  wScriptEntry++;
       break;
-#endif
 
    default:
       //

+ 0 - 2
script.h

@@ -27,9 +27,7 @@ extern "C"
 {
 #endif
 
-#ifdef PAL_WIN95
 #define PAL_ITEM_DESC_BOTTOM	(1 << 15)
-#endif
 
 WORD
 PAL_RunTriggerScript(

+ 2 - 4
sdlpal.vcxproj

@@ -126,7 +126,7 @@
     <ClCompile>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <AdditionalIncludeDirectories>..\SDL2-2.0.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>PAL_WIN95;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <WarningLevel>Level3</WarningLevel>
@@ -202,7 +202,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>..\SDL2-2.0.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>PAL_WIN95;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -750,7 +750,6 @@
     <ClInclude Include="adplug\kemuopl.h" />
     <ClInclude Include="ascii.h" />
     <ClInclude Include="battle.h" />
-    <ClInclude Include="big5font.h" />
     <ClInclude Include="codepage.h" />
     <ClInclude Include="common.h" />
     <ClInclude Include="ending.h" />
@@ -758,7 +757,6 @@
     <ClInclude Include="font.h" />
     <ClInclude Include="fontglyph.h" />
     <ClInclude Include="game.h" />
-    <ClInclude Include="gbfont.h" />
     <ClInclude Include="getopt.h" />
     <ClInclude Include="global.h" />
     <ClInclude Include="input.h" />

+ 3 - 9
sdlpal.vcxproj.filters

@@ -107,9 +107,6 @@
     <ClCompile Include="video.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="yj1.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="adplug\binfile.cpp">
       <Filter>adplug</Filter>
     </ClCompile>
@@ -185,6 +182,9 @@
     <ClCompile Include="adplug\demuopl.cpp">
       <Filter>adplug</Filter>
     </ClCompile>
+    <ClCompile Include="yj1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="ascii.h">
@@ -364,12 +364,6 @@
     <ClInclude Include="fontglyph.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="gbfont.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="big5font.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="resampler.h">
       <Filter>Header Files</Filter>
     </ClInclude>

+ 9 - 9
text.c

@@ -481,7 +481,7 @@ PAL_DrawText(
 
    urect.x = rect.x;
    urect.y = rect.y;
-#if defined(PAL_WIN95) || defined(PAL_UNICODE)
+#if defined(PAL_UNICODE)
    urect.h = 17;
 #else
    urect.h = 16;
@@ -545,13 +545,14 @@ PAL_DrawText(
    //
    if (fUpdate && urect.w > 0)
    {
-#ifdef PAL_WIN95
-      urect.w++;
-      if (urect.x + urect.w > 320)
-      {
-         urect.w = 320 - urect.x;
+      if (gpGlobals->fIsWIN95)
+	  {
+         urect.w++;
+         if (urect.x + urect.w > 320)
+         {
+            urect.w = 320 - urect.x;
+         }
       }
-#endif
       VIDEO_UpdateScreen(&urect);
    }
 }
@@ -963,8 +964,8 @@ PAL_ShowDialogText(
                }
                lpszText++;
                break;
-#ifndef PAL_WIN95
             case '\'':
+               // !PAL_WIN95
                //
                // Set the font color to Red
                //
@@ -978,7 +979,6 @@ PAL_ShowDialogText(
                }
                lpszText++;
                break;
-#endif
             case '\"':
                //
                // Set the font color to Yellow

+ 0 - 4
ui.c

@@ -789,8 +789,6 @@ PAL_WordWidth(
 	return (w + 8) >> 4;
 }
 
-#ifndef PAL_WIN95
-
 LPOBJECTDESC
 PAL_LoadObjectDesc(
    LPCSTR         lpszFileName
@@ -931,5 +929,3 @@ PAL_GetObjectDesc(
 
    return NULL;
 }
-
-#endif

+ 2 - 7
ui.h

@@ -49,11 +49,8 @@ extern "C"
 
 #define DESCTEXT_COLOR                     0x2E
 
-#ifdef PAL_WIN95
-#define MAINMENU_BACKGROUND_FBPNUM         2
-#else
-#define MAINMENU_BACKGROUND_FBPNUM         60
-#endif
+#define MAINMENU_BACKGROUND_FBPNUM         (gpGlobals->fIsWIN95 ? 2 :60)
+
 #define RIX_NUM_OPENINGMENU                4
 #define MAINMENU_LABEL_NEWGAME             7
 #define MAINMENU_LABEL_LOADGAME            8
@@ -235,7 +232,6 @@ PAL_WordWidth(
    INT            nWordIndex
 );
 
-#ifndef PAL_WIN95
 LPOBJECTDESC
 PAL_LoadObjectDesc(
    LPCSTR          lpszFileName
@@ -255,7 +251,6 @@ PAL_GetObjectDesc(
    LPOBJECTDESC   lpObjectDesc,
    WORD           wObjectID
 );
-#endif
 
 extern LPSPRITE gpSpriteUI;
 

+ 0 - 9
video.c

@@ -198,14 +198,8 @@ VIDEO_Init(
       // Totally ugly hack to satisfy M$'s silly requirements.
       // No need to understand this crap.
       //
-#if defined(PAL_WIN95) && !defined(PAL_UNICODE)
-      extern BOOL fIsBig5;
-#endif
       SDL_Color palette[256] = { 0 };
       SDL_Surface *p;
-#if defined(PAL_WIN95) && !defined(PAL_UNICODE)
-      fIsBig5 = TRUE;
-#endif
       palette[0].r = palette[0].g = palette[0].b = palette[0].a = 0;
       palette[1].r = palette[1].g = palette[1].b = palette[1].a = 255;
       SDL_FillRect(gpScreenBak, NULL, 0);
@@ -231,9 +225,6 @@ VIDEO_Init(
       gpScreen = p;
       gpBackKeyMessage = SDL_CreateTextureFromSurface(gpRenderer, gpScreenBak);
       SDL_FillRect(gpScreenBak, NULL, 0);
-#if defined(PAL_WIN95) && !defined(PAL_UNICODE)
-      fIsBig5 = FALSE;
-#endif
    }
 #endif
 

+ 337 - 339
yj1.c

@@ -29,233 +29,231 @@
 
 #include "common.h"
 
-#ifndef PAL_WIN95
-
-typedef struct _TreeNode
+typedef struct _YJ1_TreeNode
 {
-   unsigned char   value;
-   unsigned char   leaf;
-   unsigned short  level;
-   unsigned int    weight;
+	unsigned char   value;
+	unsigned char   leaf;
+	unsigned short  level;
+	unsigned int    weight;
 
-   struct _TreeNode *parent;
-   struct _TreeNode *left;
-   struct _TreeNode *right;
-} TreeNode;
+	struct _YJ1_TreeNode *parent;
+	struct _YJ1_TreeNode *left;
+	struct _YJ1_TreeNode *right;
+} YJ1_TreeNode;
 
-typedef struct _TreeNodeList
+typedef struct _YJ1_TreeNodeList
 {
-   TreeNode *node;
-   struct _TreeNodeList *next;
-} TreeNodeList;
+	YJ1_TreeNode *node;
+	struct _YJ1_TreeNodeList *next;
+} YJ1_TreeNodeList;
 
 typedef struct _YJ_1_FILEHEADER
 {
-   unsigned int   Signature;          // 'YJ_1'
-   unsigned int   UncompressedLength; // size before compression
-   unsigned int   CompressedLength;   // size after compression
-   unsigned short BlockCount;       // number of blocks
-   unsigned char Unknown;
-   unsigned char HuffmanTreeLength; // length of huffman tree
+	unsigned int   Signature;          // 'YJ_1'
+	unsigned int   UncompressedLength; // size before compression
+	unsigned int   CompressedLength;   // size after compression
+	unsigned short BlockCount;       // number of blocks
+	unsigned char Unknown;
+	unsigned char HuffmanTreeLength; // length of huffman tree
 } YJ_1_FILEHEADER, *PYJ_1_FILEHEADER;
 
 typedef struct _YJ_1_BLOCKHEADER
 {
-   unsigned short UncompressedLength; // maximum 0x4000
-   unsigned short CompressedLength;   // including the header
-   unsigned short LZSSRepeatTable[4];
-   unsigned char LZSSOffsetCodeLengthTable[4];
-   unsigned char LZSSRepeatCodeLengthTable[3];
-   unsigned char CodeCountCodeLengthTable[3];
-   unsigned char CodeCountTable[2];
+	unsigned short UncompressedLength; // maximum 0x4000
+	unsigned short CompressedLength;   // including the header
+	unsigned short LZSSRepeatTable[4];
+	unsigned char LZSSOffsetCodeLengthTable[4];
+	unsigned char LZSSRepeatCodeLengthTable[3];
+	unsigned char CodeCountCodeLengthTable[3];
+	unsigned char CodeCountTable[2];
 } YJ_1_BLOCKHEADER, *PYJ_1_BLOCKHEADER;
 
 static unsigned int
-get_bits(
-   const void *src,
-   unsigned int *bitptr,
-   unsigned int count
-)
+	yj1_get_bits(
+	const void *src,
+	unsigned int *bitptr,
+	unsigned int count
+	)
 {
-   unsigned char *temp = ((unsigned char *)src) + ((*bitptr >> 4) << 1);
-   unsigned int bptr = *bitptr & 0xf;
-   unsigned short mask;
-   *bitptr += count;
-   if (count > 16 - bptr)
-   {
-      count = count + bptr - 16;
-      mask = 0xffff >> bptr;
-      return (((temp[0] | (temp[1] << 8)) & mask) << count) | ((temp[2] | (temp[3] << 8)) >> (16 - count));
-   }
-   else
-      return (((unsigned short)((temp[0] | (temp[1] << 8)) << bptr)) >> (16 - count));
+	unsigned char *temp = ((unsigned char *)src) + ((*bitptr >> 4) << 1);
+	unsigned int bptr = *bitptr & 0xf;
+	unsigned short mask;
+	*bitptr += count;
+	if (count > 16 - bptr)
+	{
+		count = count + bptr - 16;
+		mask = 0xffff >> bptr;
+		return (((temp[0] | (temp[1] << 8)) & mask) << count) | ((temp[2] | (temp[3] << 8)) >> (16 - count));
+	}
+	else
+		return (((unsigned short)((temp[0] | (temp[1] << 8)) << bptr)) >> (16 - count));
 }
 
 static unsigned short
-get_loop(
-   const void *src,
-   unsigned int *bitptr,
-   PYJ_1_BLOCKHEADER header
-)
+	yj1_get_loop(
+	const void *src,
+	unsigned int *bitptr,
+	PYJ_1_BLOCKHEADER header
+	)
 {
-   if (get_bits(src, bitptr, 1))
-      return header->CodeCountTable[0];
-   else
-   {
-      unsigned int temp = get_bits(src, bitptr, 2);
-      if (temp)
-         return get_bits(src, bitptr, header->CodeCountCodeLengthTable[temp - 1]);
-      else
-         return header->CodeCountTable[1];
-   }
+	if (yj1_get_bits(src, bitptr, 1))
+		return header->CodeCountTable[0];
+	else
+	{
+		unsigned int temp = yj1_get_bits(src, bitptr, 2);
+		if (temp)
+			return yj1_get_bits(src, bitptr, header->CodeCountCodeLengthTable[temp - 1]);
+		else
+			return header->CodeCountTable[1];
+	}
 }
 
 static unsigned short
-get_count(
-   const void *src,
-   unsigned int *bitptr,
-   PYJ_1_BLOCKHEADER header
-)
+	yj1_get_count(
+	const void *src,
+	unsigned int *bitptr,
+	PYJ_1_BLOCKHEADER header
+	)
 {
-   unsigned short temp;
-   if ((temp = get_bits(src, bitptr, 2)) != 0)
-   {
-      if (get_bits(src, bitptr, 1))
-         return get_bits(src, bitptr, header->LZSSRepeatCodeLengthTable[temp - 1]);
-      else
-         return SWAP16(header->LZSSRepeatTable[temp]);
-   }
-   else
-      return SWAP16(header->LZSSRepeatTable[0]);
+	unsigned short temp;
+	if ((temp = yj1_get_bits(src, bitptr, 2)) != 0)
+	{
+		if (yj1_get_bits(src, bitptr, 1))
+			return yj1_get_bits(src, bitptr, header->LZSSRepeatCodeLengthTable[temp - 1]);
+		else
+			return SWAP16(header->LZSSRepeatTable[temp]);
+	}
+	else
+		return SWAP16(header->LZSSRepeatTable[0]);
 }
 
 INT
-Decompress(
-   LPCVOID       Source,
-   LPVOID        Destination,
-   INT           DestSize
-)
+	YJ1_Decompress(
+	LPCVOID       Source,
+	LPVOID        Destination,
+	INT           DestSize
+	)
 {
-   PYJ_1_FILEHEADER hdr = (PYJ_1_FILEHEADER)Source;
-   unsigned char *src = (unsigned char *)Source;
-   unsigned char *dest;
-   unsigned int i;
-   TreeNode *root, *node;
-
-   if (Source == NULL)
-      return -1;
-   if (SWAP32(hdr->Signature) != 0x315f4a59)
-      return -1;
-   if (SWAP32(hdr->UncompressedLength) > (unsigned int)DestSize)
-      return -1;
-
-   do
-   {
-      unsigned short tree_len = ((unsigned short)hdr->HuffmanTreeLength) * 2;
-      unsigned int bitptr = 0;
-      unsigned char *flag = (unsigned char *)src + 16 + tree_len;
-
-      if ((node = root = (TreeNode *)malloc(sizeof(TreeNode) * (tree_len + 1))) == NULL)
-         return -1;
-      root[0].leaf = 0;
-      root[0].value = 0;
-      root[0].left = root + 1;
-      root[0].right = root + 2;
-      for (i = 1; i <= tree_len; i++)
-      {
-         root[i].leaf = !get_bits(flag, &bitptr, 1);
-         root[i].value = src[15 + i];
-         if (root[i].leaf)
-            root[i].left = root[i].right = NULL;
-         else
-         {
-            root[i].left =  root + (root[i].value << 1) + 1;
-            root[i].right = root[i].left + 1;
-         }
-      }
-      src += 16 + tree_len + (((tree_len & 0xf) ? (tree_len >> 4) + 1 : (tree_len >> 4)) << 1);
-   } while (0);
-
-   dest = (unsigned char *)Destination;
-
-   for (i = 0; i < SWAP16(hdr->BlockCount); i++)
-   {
-      unsigned int bitptr;
-      PYJ_1_BLOCKHEADER header;
-
-      header = (PYJ_1_BLOCKHEADER)src;
-      src += 4;
-      if (!SWAP16(header->CompressedLength))
-      {
-         unsigned short hul = SWAP16(header->UncompressedLength);
-         while (hul--)
-         {
-            *dest++ = *src++;
-         }
-         continue;
-      }
-      src += 20;
-      bitptr = 0;
-      for (;;)
-      {
-         unsigned short loop;
-         if ((loop = get_loop(src, &bitptr, header)) == 0)
-            break;
-
-         while (loop--)
-         {
-            node = root;
-            for(; !node->leaf;)
-            {
-               if (get_bits(src, &bitptr, 1))
-                  node = node->right;
-               else
-                  node = node->left;
-            }
-            *dest++ = node->value;
-         }
-
-         if ((loop = get_loop(src, &bitptr, header)) == 0)
-            break;
-
-         while (loop--)
-         {
-            unsigned int pos, count;
-            count = get_count(src, &bitptr, header);
-            pos = get_bits(src, &bitptr, 2);
-            pos = get_bits(src, &bitptr, header->LZSSOffsetCodeLengthTable[pos]);
-            while (count--)
-            {
-               *dest = *(dest - pos);
-               dest++;
-            }
-         }
-      }
-      src = ((unsigned char *)header) + SWAP16(header->CompressedLength);
-   }
-   free(root);
-
-   return SWAP32(hdr->UncompressedLength);
+	PYJ_1_FILEHEADER hdr = (PYJ_1_FILEHEADER)Source;
+	unsigned char *src = (unsigned char *)Source;
+	unsigned char *dest;
+	unsigned int i;
+	YJ1_TreeNode *root, *node;
+
+	if (Source == NULL)
+		return -1;
+	if (SWAP32(hdr->Signature) != 0x315f4a59)
+		return -1;
+	if (SWAP32(hdr->UncompressedLength) > (unsigned int)DestSize)
+		return -1;
+
+	do
+	{
+		unsigned short tree_len = ((unsigned short)hdr->HuffmanTreeLength) * 2;
+		unsigned int bitptr = 0;
+		unsigned char *flag = (unsigned char *)src + 16 + tree_len;
+
+		if ((node = root = (YJ1_TreeNode *)malloc(sizeof(YJ1_TreeNode) * (tree_len + 1))) == NULL)
+			return -1;
+		root[0].leaf = 0;
+		root[0].value = 0;
+		root[0].left = root + 1;
+		root[0].right = root + 2;
+		for (i = 1; i <= tree_len; i++)
+		{
+			root[i].leaf = !yj1_get_bits(flag, &bitptr, 1);
+			root[i].value = src[15 + i];
+			if (root[i].leaf)
+				root[i].left = root[i].right = NULL;
+			else
+			{
+				root[i].left = root + (root[i].value << 1) + 1;
+				root[i].right = root[i].left + 1;
+			}
+		}
+		src += 16 + tree_len + (((tree_len & 0xf) ? (tree_len >> 4) + 1 : (tree_len >> 4)) << 1);
+	} while (0);
+
+	dest = (unsigned char *)Destination;
+
+	for (i = 0; i < SWAP16(hdr->BlockCount); i++)
+	{
+		unsigned int bitptr;
+		PYJ_1_BLOCKHEADER header;
+
+		header = (PYJ_1_BLOCKHEADER)src;
+		src += 4;
+		if (!SWAP16(header->CompressedLength))
+		{
+			unsigned short hul = SWAP16(header->UncompressedLength);
+			while (hul--)
+			{
+				*dest++ = *src++;
+			}
+			continue;
+		}
+		src += 20;
+		bitptr = 0;
+		for (;;)
+		{
+			unsigned short loop;
+			if ((loop = yj1_get_loop(src, &bitptr, header)) == 0)
+				break;
+
+			while (loop--)
+			{
+				node = root;
+				for (; !node->leaf;)
+				{
+					if (yj1_get_bits(src, &bitptr, 1))
+						node = node->right;
+					else
+						node = node->left;
+				}
+				*dest++ = node->value;
+			}
+
+			if ((loop = yj1_get_loop(src, &bitptr, header)) == 0)
+				break;
+
+			while (loop--)
+			{
+				unsigned int pos, count;
+				count = yj1_get_count(src, &bitptr, header);
+				pos = yj1_get_bits(src, &bitptr, 2);
+				pos = yj1_get_bits(src, &bitptr, header->LZSSOffsetCodeLengthTable[pos]);
+				while (count--)
+				{
+					*dest = *(dest - pos);
+					dest++;
+				}
+			}
+		}
+		src = ((unsigned char *)header) + SWAP16(header->CompressedLength);
+	}
+	free(root);
+
+	return SWAP32(hdr->UncompressedLength);
 }
 
-#else
+/* ============================================================================================================================================= */
 
-typedef struct _TreeNode
+typedef struct _YJ2_TreeNode
 {
-   unsigned short      weight;
-   unsigned short      value;
-   struct _TreeNode   *parent;
-   struct _TreeNode   *left;
-   struct _TreeNode   *right;
-} TreeNode;
-
-typedef struct _Tree
+	unsigned short      weight;
+	unsigned short      value;
+	struct _YJ2_TreeNode   *parent;
+	struct _YJ2_TreeNode   *left;
+	struct _YJ2_TreeNode   *right;
+} YJ2_TreeNode;
+
+typedef struct _YJ2_Tree
 {
-   TreeNode    *node;
-   TreeNode   **list;
-} Tree;
+	YJ2_TreeNode    *node;
+	YJ2_TreeNode   **list;
+} YJ2_Tree;
 
-static unsigned char data1[0x100] =
+static unsigned char yj2_data1[0x100] =
 {
 	0x3f, 0x0b, 0x17, 0x03, 0x2f, 0x0a, 0x16, 0x00, 0x2e, 0x09, 0x15, 0x02, 0x2d, 0x01, 0x08, 0x00,
 	0x3e, 0x07, 0x14, 0x03, 0x2c, 0x06, 0x13, 0x00, 0x2b, 0x05, 0x12, 0x02, 0x2a, 0x01, 0x04, 0x00,
@@ -274,166 +272,166 @@ static unsigned char data1[0x100] =
 	0x31, 0x0b, 0x11, 0x03, 0x1d, 0x0a, 0x10, 0x00, 0x1c, 0x09, 0x0f, 0x02, 0x1b, 0x01, 0x08, 0x00,
 	0x30, 0x07, 0x0e, 0x03, 0x1a, 0x06, 0x0d, 0x00, 0x19, 0x05, 0x0c, 0x02, 0x18, 0x01, 0x04, 0x00
 };
-static unsigned char data2[0x10] =
+static unsigned char yj2_data2[0x10] =
 {
 	0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03
 };
 
-static void adjust_tree(Tree tree, unsigned short value)
+static void yj2_adjust_tree(YJ2_Tree tree, unsigned short value)
 {
-   TreeNode* node = tree.list[value];
-   TreeNode tmp;
-   TreeNode* tmp1;
-   TreeNode* temp;
-   while(node->value != 0x280)
-   {
-      temp = node + 1;
-      while(node->weight == temp->weight)
-         temp++;
-      temp--;
-      if (temp != node)
-      {
-         tmp1 = node->parent;
-         node->parent = temp->parent;
-         temp->parent = tmp1;
-         if (node->value > 0x140)
-         {
-            node->left->parent = temp;
-            node->right->parent = temp;
-         }
-         else
-            tree.list[node->value] = temp;
-         if (temp->value > 0x140)
-         {
-            temp->left->parent = node;
-            temp->right->parent = node;
-         }
-         else
-            tree.list[temp->value] = node;
-         tmp = *node; *node = *temp; *temp = tmp;
-         node = temp;
-      }
-      node->weight++;
-      node = node->parent;
-   }
-   node->weight++;
+	YJ2_TreeNode* node = tree.list[value];
+	YJ2_TreeNode tmp;
+	YJ2_TreeNode* tmp1;
+	YJ2_TreeNode* temp;
+	while (node->value != 0x280)
+	{
+		temp = node + 1;
+		while (node->weight == temp->weight)
+			temp++;
+		temp--;
+		if (temp != node)
+		{
+			tmp1 = node->parent;
+			node->parent = temp->parent;
+			temp->parent = tmp1;
+			if (node->value > 0x140)
+			{
+				node->left->parent = temp;
+				node->right->parent = temp;
+			}
+			else
+				tree.list[node->value] = temp;
+			if (temp->value > 0x140)
+			{
+				temp->left->parent = node;
+				temp->right->parent = node;
+			}
+			else
+				tree.list[temp->value] = node;
+			tmp = *node; *node = *temp; *temp = tmp;
+			node = temp;
+		}
+		node->weight++;
+		node = node->parent;
+	}
+	node->weight++;
 }
 
-static int build_tree(Tree *tree)
+static int yj2_build_tree(YJ2_Tree *tree)
 {
-   int i, ptr;
-   TreeNode** list;
-   TreeNode* node;
-   if ((tree->list = list = (TreeNode **)malloc(sizeof(TreeNode*) * 321)) == NULL)
-      return 0;
-   if ((tree->node = node = (TreeNode *)malloc(sizeof(TreeNode) * 641)) == NULL)
-   {
-      free(list);
-      return 0;
-   }
-   memset(list, 0, 321 * sizeof(TreeNode*));
-   memset(node, 0, 641 * sizeof(TreeNode));
-   for(i = 0; i <= 0x140; i++)
-      list[i] = node + i;
-   for(i = 0; i <= 0x280; i++)
-   {
-      node[i].value = i;
-      node[i].weight = 1;
-   }
-   tree->node[0x280].parent = tree->node + 0x280;
-   for(i = 0, ptr = 0x141; ptr <= 0x280; i += 2, ptr++)
-   {
-      node[ptr].left = node + i;
-      node[ptr].right = node + i + 1;
-      node[i].parent = node[i + 1].parent = node + ptr;
-      node[ptr].weight = node[i].weight + node[i + 1].weight;
-   }
-   return 1;
+	int i, ptr;
+	YJ2_TreeNode** list;
+	YJ2_TreeNode* node;
+	if ((tree->list = list = (YJ2_TreeNode **)malloc(sizeof(YJ2_TreeNode*) * 321)) == NULL)
+		return 0;
+	if ((tree->node = node = (YJ2_TreeNode *)malloc(sizeof(YJ2_TreeNode) * 641)) == NULL)
+	{
+		free(list);
+		return 0;
+	}
+	memset(list, 0, 321 * sizeof(YJ2_TreeNode*));
+	memset(node, 0, 641 * sizeof(YJ2_TreeNode));
+	for (i = 0; i <= 0x140; i++)
+		list[i] = node + i;
+	for (i = 0; i <= 0x280; i++)
+	{
+		node[i].value = i;
+		node[i].weight = 1;
+	}
+	tree->node[0x280].parent = tree->node + 0x280;
+	for (i = 0, ptr = 0x141; ptr <= 0x280; i += 2, ptr++)
+	{
+		node[ptr].left = node + i;
+		node[ptr].right = node + i + 1;
+		node[i].parent = node[i + 1].parent = node + ptr;
+		node[ptr].weight = node[i].weight + node[i + 1].weight;
+	}
+	return 1;
 }
 
-static int bt(const char* data, unsigned int pos)
+static int yj2_bt(const char* data, unsigned int pos)
 {
-   return (data[pos >> 3] & (unsigned char)(1 << (pos & 0x7))) >> (pos & 0x7);
+	return (data[pos >> 3] & (unsigned char)(1 << (pos & 0x7))) >> (pos & 0x7);
 }
 
 
 INT
-Decompress(
-   LPCVOID       Source,
-   LPVOID        Destination,
-   INT           DestSize
-)
+	YJ2_Decompress(
+	LPCVOID       Source,
+	LPVOID        Destination,
+	INT           DestSize
+	)
 {
-   int Length;
-   unsigned int len = 0, ptr = 0;
-   unsigned char* src = (unsigned char*)Source + 4;
-   unsigned char* dest;
-   Tree tree;
-   TreeNode* node;
-
-   if (Source == NULL)
-      return -1;
-
-   if (!build_tree(&tree))
-      return -1;
-
-   Length = SWAP32(*((unsigned int*)Source));
-   if (Length > DestSize)
-      return -1;
-   dest = (unsigned char*)Destination;
-
-   while (1)
-   {
-      unsigned short val;
-      node = tree.node + 0x280;
-      while(node->value > 0x140)
-      {
-         if (bt(src, ptr))
-            node = node->right;
-         else
-            node = node->left;
-         ptr++;
-      }
-      val = node->value;
-      if (tree.node[0x280].weight == 0x8000)
-      {
-         int i;
-         for(i = 0; i < 0x141; i++)
-            if (tree.list[i]->weight & 0x1)
-               adjust_tree(tree, i);
-         for(i = 0; i <= 0x280; i++)
-            tree.node[i].weight >>= 1;
-      }
-      adjust_tree(tree, val);
-      if (val > 0xff)
-      {
-         int i;
-         unsigned int temp, tmp, pos;
-         unsigned char* pre;
-         for(i = 0, temp = 0; i < 8; i++, ptr++)
-            temp |= (unsigned int)bt(src, ptr) << i;
-         tmp = temp & 0xff;
-         for(; i < data2[tmp & 0xf] + 6; i++, ptr++)
-            temp |= (unsigned int)bt(src, ptr) << i;
-         temp >>= data2[tmp & 0xf];
-         pos = (temp & 0x3f) | ((unsigned int)data1[tmp] << 6);
-         if (pos == 0xfff)
-            break;
-         pre = dest - pos - 1;
-         for(i = 0; i < val - 0xfd; i++)
-            *dest++ = *pre++;
-         len += val - 0xfd;
-      }
-      else
-      {
-         *dest++ = (unsigned char)val;
-         len++;
-      }
-   }
-
-   free(tree.list);
-   free(tree.node);
-   return Length;
+	int Length;
+	unsigned int len = 0, ptr = 0;
+	unsigned char* src = (unsigned char*)Source + 4;
+	unsigned char* dest;
+	YJ2_Tree tree;
+	YJ2_TreeNode* node;
+
+	if (Source == NULL)
+		return -1;
+
+	if (!yj2_build_tree(&tree))
+		return -1;
+
+	Length = SWAP32(*((unsigned int*)Source));
+	if (Length > DestSize)
+		return -1;
+	dest = (unsigned char*)Destination;
+
+	while (1)
+	{
+		unsigned short val;
+		node = tree.node + 0x280;
+		while (node->value > 0x140)
+		{
+			if (yj2_bt(src, ptr))
+				node = node->right;
+			else
+				node = node->left;
+			ptr++;
+		}
+		val = node->value;
+		if (tree.node[0x280].weight == 0x8000)
+		{
+			int i;
+			for (i = 0; i < 0x141; i++)
+				if (tree.list[i]->weight & 0x1)
+					yj2_adjust_tree(tree, i);
+			for (i = 0; i <= 0x280; i++)
+				tree.node[i].weight >>= 1;
+		}
+		yj2_adjust_tree(tree, val);
+		if (val > 0xff)
+		{
+			int i;
+			unsigned int temp, tmp, pos;
+			unsigned char* pre;
+			for (i = 0, temp = 0; i < 8; i++, ptr++)
+				temp |= (unsigned int)yj2_bt(src, ptr) << i;
+			tmp = temp & 0xff;
+			for (; i < yj2_data2[tmp & 0xf] + 6; i++, ptr++)
+				temp |= (unsigned int)yj2_bt(src, ptr) << i;
+			temp >>= yj2_data2[tmp & 0xf];
+			pos = (temp & 0x3f) | ((unsigned int)yj2_data1[tmp] << 6);
+			if (pos == 0xfff)
+				break;
+			pre = dest - pos - 1;
+			for (i = 0; i < val - 0xfd; i++)
+				*dest++ = *pre++;
+			len += val - 0xfd;
+		}
+		else
+		{
+			*dest++ = (unsigned char)val;
+			len++;
+		}
+	}
+
+	free(tree.list);
+	free(tree.node);
+	return Length;
 }
 
-#endif
+INT (*Decompress)(LPCVOID, LPVOID, INT);