Browse Source

Bug fix: dead lock on exit, overlay on non-touch devices
Improvement: Back key for windows phone
Change: Split configuration from global vars, layout customize

louyihua 8 years ago
parent
commit
614e33d3c2
34 changed files with 892 additions and 499 deletions
  1. 288 1
      ascii.h
  2. 22 40
      battle.c
  3. 5 5
      common.h
  4. 4 4
      ending.c
  5. 12 15
      fight.c
  6. 43 17
      font.c
  7. 7 1
      font.h
  8. 1 0
      game.c
  9. 52 41
      global.c
  10. 65 34
      global.h
  11. 11 19
      input.c
  12. 10 12
      itemmenu.c
  13. 10 12
      magicmenu.c
  14. 11 13
      main.c
  15. 0 3
      main.h
  16. 46 0
      makemessage.py
  17. 1 1
      midi.c
  18. 16 0
      midi.h
  19. 3 3
      mp3play.c
  20. 13 13
      oggplay.c
  21. 2 2
      palcommon.c
  22. 1 0
      palcommon.h
  23. 32 32
      rixplay.cpp
  24. 14 14
      script.c
  25. 22 31
      sound.c
  26. 1 1
      sound.h
  27. 61 38
      text.c
  28. 2 1
      text.h
  29. 13 14
      ui.c
  30. 8 1
      ui.h
  31. 4 6
      uibattle.c
  32. 90 54
      uigame.c
  33. 0 5
      util.c
  34. 22 66
      video.c

+ 288 - 1
ascii.h

@@ -11,7 +11,7 @@ extern "C"
 {
 #endif
 	
-unsigned char iso_font[] =
+static unsigned char iso_font[] =
 {
    /*
     * Copyright (c) 2000
@@ -148,6 +148,293 @@ unsigned char iso_font[] =
    /* 7F */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
 };
 
+static unsigned char iso_font_8x8[256][8] = {
+	/**
+	* 8x8 monochrome bitmap fonts for rendering
+	* Author: Daniel Hepper <daniel@hepper.net>
+	*
+	* License: Public Domain
+	*
+	* Based on:
+	* // Summary: font8x8.h
+	* // 8x8 monochrome bitmap fonts for rendering
+	* //
+	* // Author:
+	* //     Marcel Sondaar
+	* //     International Business Machines (public domain VGA fonts)
+	* //
+	* // License:
+	* //     Public Domain
+	*
+	* Fetched from: http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm
+	**/
+
+	// Constant: font8x8_basic
+	// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0000 (nul)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0001
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0002
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0003
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0004
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0005
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0006
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0007
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0008
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0009
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+000A
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+000B
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+000C
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+000D
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+000E
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+000F
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0010
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0011
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0012
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0013
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0014
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0015
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0016
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0017
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0018
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0019
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+001A
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+001B
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+001C
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+001D
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+001E
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+001F
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0020 (space)
+	{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00 },   // U+0021 (!)
+	{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0022 (")
+	{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00 },   // U+0023 (#)
+	{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00 },   // U+0024 ($)
+	{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00 },   // U+0025 (%)
+	{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00 },   // U+0026 (&)
+	{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0027 (')
+	{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00 },   // U+0028 (()
+	{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00 },   // U+0029 ())
+	{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00 },   // U+002A (*)
+	{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00 },   // U+002B (+)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06 },   // U+002C (,)
+	{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00 },   // U+002D (-)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00 },   // U+002E (.)
+	{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00 },   // U+002F (/)
+	{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00 },   // U+0030 (0)
+	{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00 },   // U+0031 (1)
+	{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00 },   // U+0032 (2)
+	{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00 },   // U+0033 (3)
+	{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00 },   // U+0034 (4)
+	{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00 },   // U+0035 (5)
+	{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00 },   // U+0036 (6)
+	{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00 },   // U+0037 (7)
+	{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00 },   // U+0038 (8)
+	{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00 },   // U+0039 (9)
+	{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00 },   // U+003A (:)
+	{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06 },   // U+003B (//)
+	{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00 },   // U+003C (<)
+	{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00 },   // U+003D (=)
+	{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00 },   // U+003E (>)
+	{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00 },   // U+003F (?)
+	{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00 },   // U+0040 (@)
+	{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00 },   // U+0041 (A)
+	{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00 },   // U+0042 (B)
+	{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00 },   // U+0043 (C)
+	{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00 },   // U+0044 (D)
+	{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00 },   // U+0045 (E)
+	{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00 },   // U+0046 (F)
+	{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00 },   // U+0047 (G)
+	{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00 },   // U+0048 (H)
+	{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+0049 (I)
+	{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00 },   // U+004A (J)
+	{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00 },   // U+004B (K)
+	{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00 },   // U+004C (L)
+	{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00 },   // U+004D (M)
+	{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00 },   // U+004E (N)
+	{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00 },   // U+004F (O)
+	{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00 },   // U+0050 (P)
+	{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00 },   // U+0051 (Q)
+	{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00 },   // U+0052 (R)
+	{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00 },   // U+0053 (S)
+	{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+0054 (T)
+	{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00 },   // U+0055 (U)
+	{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00 },   // U+0056 (V)
+	{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00 },   // U+0057 (W)
+	{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00 },   // U+0058 (X)
+	{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00 },   // U+0059 (Y)
+	{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00 },   // U+005A (Z)
+	{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00 },   // U+005B ([)
+	{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00 },   // U+005C (\)
+	{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00 },   // U+005D (])
+	{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00 },   // U+005E (^)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF },   // U+005F (_)
+	{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0060 (`)
+	{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00 },   // U+0061 (a)
+	{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00 },   // U+0062 (b)
+	{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00 },   // U+0063 (c)
+	{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00 },   // U+0064 (d)
+	{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00 },   // U+0065 (e)
+	{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00 },   // U+0066 (f)
+	{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F },   // U+0067 (g)
+	{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00 },   // U+0068 (h)
+	{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+0069 (i)
+	{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E },   // U+006A (j)
+	{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00 },   // U+006B (k)
+	{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+006C (l)
+	{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00 },   // U+006D (m)
+	{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00 },   // U+006E (n)
+	{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00 },   // U+006F (o)
+	{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F },   // U+0070 (p)
+	{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78 },   // U+0071 (q)
+	{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00 },   // U+0072 (r)
+	{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00 },   // U+0073 (s)
+	{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00 },   // U+0074 (t)
+	{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00 },   // U+0075 (u)
+	{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00 },   // U+0076 (v)
+	{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00 },   // U+0077 (w)
+	{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00 },   // U+0078 (x)
+	{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F },   // U+0079 (y)
+	{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00 },   // U+007A (z)
+	{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00 },   // U+007B ({)
+	{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00 },   // U+007C (|)
+	{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00 },   // U+007D (})
+	{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+007E (~)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+007F
+
+	// Constant: font8x8_0080
+	// Contains an 8x8 font map for unicode points U+0080 - U+009F (C1/C2 control)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0080
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0081
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0082
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0083
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0084
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0085
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0086
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0087
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0088
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0089
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+008A
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+008B
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+008C
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+008D
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+008E
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+008F
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0090
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0091
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0092
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0093
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0094
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0095
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0096
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0097
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0098
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+0099
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+009A
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+009B
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+009C
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+009D
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+009E
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+009F
+
+    // Constant: font8x8_00A0
+    // Contains an 8x8 font map for unicode points U+00A0 - U+00FF (extended latin)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+00A0 (no break space)
+	{ 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00 },   // U+00A1 (inverted !)
+	{ 0x18, 0x18, 0x7E, 0x03, 0x03, 0x7E, 0x18, 0x18 },   // U+00A2 (dollarcents)
+	{ 0x1C, 0x36, 0x26, 0x0F, 0x06, 0x67, 0x3F, 0x00 },   // U+00A3 (pound sterling)
+	{ 0x00, 0x00, 0x63, 0x3E, 0x36, 0x3E, 0x63, 0x00 },   // U+00A4 (currency mark)
+	{ 0x33, 0x33, 0x1E, 0x3F, 0x0C, 0x3F, 0x0C, 0x0C },   // U+00A5 (yen)
+	{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00 },   // U+00A6 (broken pipe)
+	{ 0x7C, 0xC6, 0x1C, 0x36, 0x36, 0x1C, 0x33, 0x1E },   // U+00A7 (paragraph)
+	{ 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+00A8 (diaeresis)
+	{ 0x3C, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3C },   // U+00A9 (copyright symbol)
+	{ 0x3C, 0x36, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00 },   // U+00AA (superscript a)
+	{ 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00 },   // U+00AB (<<)
+	{ 0x00, 0x00, 0x00, 0x3F, 0x30, 0x30, 0x00, 0x00 },   // U+00AC (gun pointing left)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+00AD (soft hyphen)
+	{ 0x3C, 0x42, 0x9D, 0xA5, 0x9D, 0xA5, 0x42, 0x3C },   // U+00AE (registered symbol)
+	{ 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+00AF (macron)
+	{ 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00 },   // U+00B0 (degree)
+	{ 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00 },   // U+00B1 (plusminus)
+	{ 0x1C, 0x30, 0x18, 0x0C, 0x3C, 0x00, 0x00, 0x00 },   // U+00B2 (superscript 2)
+	{ 0x1C, 0x30, 0x18, 0x30, 0x1C, 0x00, 0x00, 0x00 },   // U+00B2 (superscript 3)
+	{ 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // U+00B2 (aigu)
+	{ 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x03 },   // U+00B5 (mu)
+	{ 0xFE, 0xDB, 0xDB, 0xDE, 0xD8, 0xD8, 0xD8, 0x00 },   // U+00B6 (pilcrow)
+	{ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00 },   // U+00B7 (central dot)
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x1E },   // U+00B8 (cedille)
+	{ 0x08, 0x0C, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x00 },   // U+00B9 (superscript 1)
+	{ 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00 },   // U+00BA (superscript 0)
+	{ 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00 },   // U+00BB (>>)
+	{ 0xC3, 0x63, 0x33, 0xBD, 0xEC, 0xF6, 0xF3, 0x03 },   // U+00BC (1/4)
+	{ 0xC3, 0x63, 0x33, 0x7B, 0xCC, 0x66, 0x33, 0xF0 },   // U+00BD (1/2)
+	{ 0x03, 0xC4, 0x63, 0xB4, 0xDB, 0xAC, 0xE6, 0x80 },   // U+00BE (3/4)
+	{ 0x0C, 0x00, 0x0C, 0x06, 0x03, 0x33, 0x1E, 0x00 },   // U+00BF (inverted ?)
+	{ 0x07, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00 },   // U+00C0 (A grave)
+	{ 0x70, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00 },   // U+00C1 (A aigu)
+	{ 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00 },   // U+00C2 (A circumflex)
+	{ 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00 },   // U+00C3 (A ~)
+	{ 0x63, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x63, 0x00 },   // U+00C4 (A umlaut)
+	{ 0x0C, 0x0C, 0x00, 0x1E, 0x33, 0x3F, 0x33, 0x00 },   // U+00C5 (A ring)
+	{ 0x7C, 0x36, 0x33, 0x7F, 0x33, 0x33, 0x73, 0x00 },   // U+00C6 (AE)
+	{ 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x18, 0x30, 0x1E },   // U+00C7 (C cedille)
+	{ 0x07, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00 },   // U+00C8 (E grave)
+	{ 0x38, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00 },   // U+00C9 (E aigu)
+	{ 0x0C, 0x12, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00 },   // U+00CA (E circumflex)
+	{ 0x36, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00 },   // U+00CB (E umlaut)
+	{ 0x07, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00CC (I grave)
+	{ 0x38, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00CD (I aigu)
+	{ 0x0C, 0x12, 0x00, 0x1E, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00CE (I circumflex)
+	{ 0x33, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00CF (I umlaut)
+	{ 0x3F, 0x66, 0x6F, 0x6F, 0x66, 0x66, 0x3F, 0x00 },   // U+00D0 (Eth)
+	{ 0x3F, 0x00, 0x33, 0x37, 0x3F, 0x3B, 0x33, 0x00 },   // U+00D1 (N ~)
+	{ 0x0E, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00 },   // U+00D2 (O grave)
+	{ 0x70, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00 },   // U+00D3 (O aigu)
+	{ 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00 },   // U+00D4 (O circumflex)
+	{ 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x63, 0x3E, 0x00 },   // U+00D5 (O ~)
+	{ 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00 },   // U+00D6 (O umlaut)
+	{ 0x00, 0x36, 0x1C, 0x08, 0x1C, 0x36, 0x00, 0x00 },   // U+00D7 (multiplicative x)
+	{ 0x5C, 0x36, 0x73, 0x7B, 0x6F, 0x36, 0x1D, 0x00 },   // U+00D8 (O stroke)
+	{ 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00 },   // U+00D9 (U grave)
+	{ 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00 },   // U+00DA (U aigu)
+	{ 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00 },   // U+00DB (U circumflex)
+	{ 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x00 },   // U+00DC (U umlaut)
+	{ 0x70, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00 },   // U+00DD (Y aigu)
+	{ 0x0F, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x0F },   // U+00DE (Thorn)
+	{ 0x00, 0x1E, 0x33, 0x1F, 0x33, 0x1F, 0x03, 0x03 },   // U+00DF (beta)
+	{ 0x07, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00 },   // U+00E0 (a grave)
+	{ 0x38, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00 },   // U+00E1 (a aigu)
+	{ 0x7E, 0xC3, 0x3C, 0x60, 0x7C, 0x66, 0xFC, 0x00 },   // U+00E2 (a circumflex)
+	{ 0x6E, 0x3B, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00 },   // U+00E3 (a ~)
+	{ 0x33, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00 },   // U+00E4 (a umlaut)
+	{ 0x0C, 0x0C, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00 },   // U+00E5 (a ring)
+	{ 0x00, 0x00, 0xFE, 0x30, 0xFE, 0x33, 0xFE, 0x00 },   // U+00E6 (ae)
+	{ 0x00, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x30, 0x1C },   // U+00E7 (c cedille)
+	{ 0x07, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00 },   // U+00E8 (e grave)
+	{ 0x38, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00 },   // U+00E9 (e aigu)
+	{ 0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x06, 0x3C, 0x00 },   // U+00EA (e circumflex)
+	{ 0x33, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00 },   // U+00EB (e umlaut)
+	{ 0x07, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00EC (i grave)
+	{ 0x1C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00ED (i augu)
+	{ 0x3E, 0x63, 0x1C, 0x18, 0x18, 0x18, 0x3C, 0x00 },   // U+00EE (i circumflex)
+	{ 0x33, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00 },   // U+00EF (i umlaut)
+	{ 0x1B, 0x0E, 0x1B, 0x30, 0x3E, 0x33, 0x1E, 0x00 },   // U+00F0 (eth)
+	{ 0x00, 0x1F, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x00 },   // U+00F1 (n ~)
+	{ 0x00, 0x07, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00 },   // U+00F2 (o grave)
+	{ 0x00, 0x38, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00 },   // U+00F3 (o aigu)
+	{ 0x1E, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00 },   // U+00F4 (o circumflex)
+	{ 0x6E, 0x3B, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00 },   // U+00F5 (o ~)
+	{ 0x00, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00 },   // U+00F6 (o umlaut)
+	{ 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00 },   // U+00F7 (division)
+	{ 0x00, 0x60, 0x3C, 0x76, 0x7E, 0x6E, 0x3C, 0x06 },   // U+00F8 (o stroke)
+	{ 0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00 },   // U+00F9 (u grave)
+	{ 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00 },   // U+00FA (u aigu)
+	{ 0x1E, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00 },   // U+00FB (u circumflex)
+	{ 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00 },   // U+00FC (u umlaut)
+	{ 0x00, 0x38, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F },   // U+00FD (y aigu)
+	{ 0x00, 0x00, 0x06, 0x3E, 0x66, 0x3E, 0x06, 0x00 },   // U+00FE (thorn)
+	{ 0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F }    // U+00FF (y umlaut)
+};
+
 #ifdef __cplusplus
 }
 #endif

+ 22 - 40
battle.c

@@ -654,9 +654,9 @@ PAL_BattleWon(
 	  PAL_CreateSingleLineBox(PAL_XY(83 - ww1, 60), w1, FALSE);
 	  PAL_CreateSingleLineBox(PAL_XY(65, 105), 10, FALSE);
 
-	  PAL_DrawText(PAL_GetWord(BATTLEWIN_GETEXP_LABEL), PAL_XY(95 - ww1, 70), 0, FALSE, FALSE);
-	  PAL_DrawText(PAL_GetWord(BATTLEWIN_BEATENEMY_LABEL), PAL_XY(77, 115), 0, FALSE, FALSE);
-	  PAL_DrawText(PAL_GetWord(BATTLEWIN_DOLLAR_LABEL), PAL_XY(197, 115), 0, FALSE, FALSE);
+	  PAL_DrawText(PAL_GetWord(BATTLEWIN_GETEXP_LABEL), PAL_XY(95 - ww1, 70), 0, FALSE, FALSE, FALSE);
+	  PAL_DrawText(PAL_GetWord(BATTLEWIN_BEATENEMY_LABEL), PAL_XY(77, 115), 0, FALSE, FALSE, FALSE);
+	  PAL_DrawText(PAL_GetWord(BATTLEWIN_DOLLAR_LABEL), PAL_XY(197, 115), 0, FALSE, FALSE, FALSE);
 
       PAL_DrawNumber(g_Battle.iExpGained, 5, PAL_XY(182 + ww1, 74), kNumColorYellow, kNumAlignRight);
       PAL_DrawNumber(g_Battle.iCashGained, 5, PAL_XY(162, 119), kNumColorYellow, kNumAlignMid);
@@ -715,10 +715,9 @@ PAL_BattleWon(
          PAL_CreateSingleLineBox(PAL_XY(80, 0), 10, FALSE);
          PAL_CreateBox(PAL_XY(82, 32), 7, 8, 1, FALSE);
 
-         PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_XY(110, 10), 0,
-            FALSE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(110 + 16 * 3, 10), 0, FALSE, FALSE);
-         PAL_DrawText(PAL_GetWord(BATTLEWIN_LEVELUP_LABEL), PAL_XY(110 + 16 * 5, 10), 0, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_XY(110, 10), 0, FALSE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(110 + 16 * 3, 10), 0, FALSE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(BATTLEWIN_LEVELUP_LABEL), PAL_XY(110 + 16 * 5, 10), 0, FALSE, FALSE, FALSE);
 
          for (j = 0; j < 8; j++)
          {
@@ -726,22 +725,14 @@ PAL_BattleWon(
                gpScreen, PAL_XY(183, 48 + 18 * j));
          }
 
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(100, 44), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_HP), PAL_XY(100, 62), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_MP), PAL_XY(100, 80), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_ATTACKPOWER), PAL_XY(100, 98), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_MAGICPOWER), PAL_XY(100, 116), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_RESISTANCE), PAL_XY(100, 134), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_DEXTERITY), PAL_XY(100, 152), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
-         PAL_DrawText(PAL_GetWord(STATUS_LABEL_FLEERATE), PAL_XY(100, 170), BATTLEWIN_LEVELUP_LABEL_COLOR,
-            TRUE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(100, 44), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_HP), PAL_XY(100, 62), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_MP), PAL_XY(100, 80), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_ATTACKPOWER), PAL_XY(100, 98), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_MAGICPOWER), PAL_XY(100, 116), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_RESISTANCE), PAL_XY(100, 134), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_DEXTERITY), PAL_XY(100, 152), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
+         PAL_DrawText(PAL_GetWord(STATUS_LABEL_FLEERATE), PAL_XY(100, 170), BATTLEWIN_LEVELUP_LABEL_COLOR, TRUE, FALSE, FALSE);
 
          //
          // Draw the original stats and stats after level up
@@ -857,19 +848,13 @@ PAL_BattleWon(
                                                             \
    gpGlobals->Exp.expname[w].wExp = (WORD)dwExp;            \
                                                             \
-   if (gpGlobals->g.PlayerRoles.statname[w] !=              \
-      OrigPlayerRoles.statname[w])                          \
+   if (gpGlobals->g.PlayerRoles.statname[w] != OrigPlayerRoles.statname[w]) \
    {                                                        \
       PAL_CreateSingleLineBox(PAL_XY(83, 60), 8, FALSE);    \
-      PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_XY(95, 70), \
-         0, FALSE, FALSE);                                  \
-      PAL_DrawText(PAL_GetWord(label), PAL_XY(143, 70),     \
-         0, FALSE, FALSE);                                  \
-      PAL_DrawText(PAL_GetWord(BATTLEWIN_LEVELUP_LABEL), PAL_XY(175, 70),  \
-         0, FALSE, FALSE);                                  \
-      PAL_DrawNumber(gpGlobals->g.PlayerRoles.statname[w] - \
-         OrigPlayerRoles.statname[w],                       \
-         5, PAL_XY(188, 74), kNumColorYellow, kNumAlignRight); \
+      PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_XY(95, 70),  0, FALSE, FALSE, FALSE); \
+      PAL_DrawText(PAL_GetWord(label), PAL_XY(143, 70), 0, FALSE, FALSE, FALSE); \
+      PAL_DrawText(PAL_GetWord(BATTLEWIN_LEVELUP_LABEL), PAL_XY(175, 70), 0, FALSE, FALSE, FALSE); \
+      PAL_DrawNumber(gpGlobals->g.PlayerRoles.statname[w] - OrigPlayerRoles.statname[w], 5, PAL_XY(188, 74), kNumColorYellow, kNumAlignRight); \
       VIDEO_UpdateScreen(&rect);                            \
       PAL_WaitForKey(3000);                                 \
    }                                                        \
@@ -910,12 +895,9 @@ PAL_BattleWon(
 
             PAL_CreateSingleLineBox(PAL_XY(65 - ww, 105), w1 + w2 + w3, FALSE);
 
-            PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]),
-               PAL_XY(75 - ww, 115), 0, FALSE, FALSE);
-            PAL_DrawText(PAL_GetWord(BATTLEWIN_ADDMAGIC_LABEL), PAL_XY(75 + 16 * w1 - ww, 115),
-               0, FALSE, FALSE);
-            PAL_DrawText(PAL_GetWord(gpGlobals->g.lprgLevelUpMagic[j].m[w].wMagic),
-               PAL_XY(75 + 16 * (w1 + w2) - ww, 115), 0x1B, FALSE, FALSE);
+            PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]), PAL_XY(75 - ww, 115), 0, FALSE, FALSE, FALSE);
+            PAL_DrawText(PAL_GetWord(BATTLEWIN_ADDMAGIC_LABEL), PAL_XY(75 + 16 * w1 - ww, 115), 0, FALSE, FALSE, FALSE);
+            PAL_DrawText(PAL_GetWord(gpGlobals->g.lprgLevelUpMagic[j].m[w].wMagic), PAL_XY(75 + 16 * (w1 + w2) - ww, 115), 0x1B, FALSE, FALSE, FALSE);
 
             VIDEO_UpdateScreen(&rect);
             PAL_WaitForKey(3000);

+ 5 - 5
common.h

@@ -105,7 +105,7 @@ extern "C"
 # if SDL_VERSION_ATLEAST(2,0,0)
 #  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE)
 # else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gpGlobals->fFullScreen ? SDL_FULLSCREEN : 0))
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
 # endif
 
 # define PAL_PLATFORM         "  Symbian S60 \x79FB\x690D (c) 2009, netwan."
@@ -125,7 +125,7 @@ extern "C"
 # if SDL_VERSION_ATLEAST(2,0,0)
 #  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE)
 # else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gpGlobals->fFullScreen ? SDL_FULLSCREEN : 0))
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
 # endif
 
 # define PAL_PLATFORM         "Nintendo WII"
@@ -239,7 +239,7 @@ extern "C"
 # if SDL_VERSION_ATLEAST(2,0,0)
 #  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
 # else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gpGlobals->fFullScreen ? SDL_FULLSCREEN : 0))
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
 # endif
 
 # define PAL_PLATFORM         "Windows Phone"
@@ -265,7 +265,7 @@ extern "C"
 # if SDL_VERSION_ATLEAST(2,0,0)
 #  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
 # else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gpGlobals->fFullScreen ? SDL_FULLSCREEN : 0))
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
 # endif
 
 # define PAL_PLATFORM         NULL
@@ -321,7 +321,7 @@ extern "C"
 typedef const BYTE *LPCBYTE;
 #endif
 
-#ifndef __WINPHONE__
+#ifndef __WINRT__
 #define PAL_HAS_NATIVEMIDI  1
 #endif
 

+ 4 - 4
ending.c

@@ -148,7 +148,7 @@ PAL_ShowFBP(
    //
    // HACKHACK: to make the ending show correctly
    //
-   if (wChunkNum != (gpGlobals->fIsWIN95 ? 68 : 49))
+   if (wChunkNum != (gConfig.fIsWIN95 ? 68 : 49))
    {
       PAL_FBPBlitToSurface(buf, gpScreen);
    }
@@ -344,10 +344,10 @@ PAL_EndingAnimation(
    SDL_SetPalette(pLower, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
 #endif
 
-   PAL_MKFDecompressChunk(buf, 64000, gpGlobals->fIsWIN95 ? 69 : 61, gpGlobals->f.fpFBP);
+   PAL_MKFDecompressChunk(buf, 64000, gConfig.fIsWIN95 ? 69 : 61, gpGlobals->f.fpFBP);
    PAL_FBPBlitToSurface(buf, pUpper);
 
-   PAL_MKFDecompressChunk(buf, 64000, gpGlobals->fIsWIN95 ? 70 : 62, gpGlobals->f.fpFBP);
+   PAL_MKFDecompressChunk(buf, 64000, gConfig.fIsWIN95 ? 70 : 62, gpGlobals->f.fpFBP);
    PAL_FBPBlitToSurface(buf, pLower);
 
    PAL_MKFDecompressChunk(buf, 64000, 571, gpGlobals->f.fpMGO);
@@ -387,7 +387,7 @@ PAL_EndingAnimation(
       // Draw the beast
       //
       PAL_RLEBlitToSurface(PAL_SpriteGetFrame(buf, 0), gpScreen, PAL_XY(0, -400 + i));
-	  PAL_RLEBlitToSurface(gpGlobals->fIsWIN95 ? buf + 0x8444 : PAL_SpriteGetFrame(buf, 1), gpScreen, PAL_XY(0, -200 + i));
+	  PAL_RLEBlitToSurface(gConfig.fIsWIN95 ? buf + 0x8444 : PAL_SpriteGetFrame(buf, 1), gpScreen, PAL_XY(0, -200 + i));
       //
       // Draw the girl
       //

+ 12 - 15
fight.c

@@ -505,18 +505,15 @@ PAL_BattleDelay(
       {
          if (wObjectID == BATTLE_LABEL_ESCAPEFAIL) // HACKHACK
          {
-            PAL_DrawText(PAL_GetWord(wObjectID), PAL_XY(130, 75),
-               15, TRUE, FALSE);
+            PAL_DrawText(PAL_GetWord(wObjectID), PAL_XY(130, 75), 15, TRUE, FALSE, FALSE);
          }
          else if ((SHORT)wObjectID < 0)
          {
-            PAL_DrawText(PAL_GetWord(-((SHORT)wObjectID)), PAL_XY(170, 45),
-               DESCTEXT_COLOR, TRUE, FALSE);
+            PAL_DrawText(PAL_GetWord(-((SHORT)wObjectID)), PAL_XY(170, 45), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
          }
          else
          {
-            PAL_DrawText(PAL_GetWord(wObjectID), PAL_XY(210, 50),
-               15, TRUE, FALSE);
+            PAL_DrawText(PAL_GetWord(wObjectID), PAL_XY(210, 50), 15, TRUE, FALSE, FALSE);
          }
       }
 
@@ -2219,7 +2216,7 @@ PAL_BattleShowPlayerPreMagicAnim(
    PAL_BattleDelay(2, 0, TRUE);
 
    g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 5;
-   if (!gpGlobals->fIsWIN95)
+   if (!gConfig.fIsWIN95)
    {
       SOUND_Play(gpGlobals->g.PlayerRoles.rgwMagicSound[wPlayerRole]);
    }
@@ -2234,7 +2231,7 @@ PAL_BattleShowPlayerPreMagicAnim(
       index = gpGlobals->g.rgwBattleEffectIndex[PAL_GetPlayerBattleSprite(wPlayerRole)][0];
       index *= 10;
       index += 15;
-	  if (gpGlobals->fIsWIN95)
+	  if (gConfig.fIsWIN95)
 	  {
 		  SOUND_Play(gpGlobals->g.PlayerRoles.rgwMagicSound[wPlayerRole]);
 	  }
@@ -2501,7 +2498,7 @@ PAL_BattleShowPlayerOffMagicAnim(
 
    n = PAL_SpriteGetNumFrames(lpSpriteEffect);
 
-   if (gpGlobals->fIsWIN95 && wPlayerIndex != (WORD)-1)
+   if (gConfig.fIsWIN95 && wPlayerIndex != (WORD)-1)
    {
       g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 6;
    }
@@ -2516,7 +2513,7 @@ PAL_BattleShowPlayerOffMagicAnim(
    wave = gpGlobals->wScreenWave;
    gpGlobals->wScreenWave += gpGlobals->g.lprgMagic[iMagicNum].wWave;
 
-   if (gpGlobals->fIsWIN95 && !fSummon && gpGlobals->g.lprgMagic[iMagicNum].wSound != 0)
+   if (gConfig.fIsWIN95 && !fSummon && gpGlobals->g.lprgMagic[iMagicNum].wSound != 0)
    {
       SOUND_Play(gpGlobals->g.lprgMagic[iMagicNum].wSound);
    }
@@ -2524,7 +2521,7 @@ PAL_BattleShowPlayerOffMagicAnim(
    for (i = 0; i < l; i++)
    {
       LPCBITMAPRLE b;
-	  if (!gpGlobals->fIsWIN95 && i == gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay && wPlayerIndex != (WORD)-1)
+	  if (!gConfig.fIsWIN95 && i == gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay && wPlayerIndex != (WORD)-1)
       {
          g_Battle.rgPlayer[wPlayerIndex].wCurrentFrame = 6;
       }
@@ -2558,7 +2555,7 @@ PAL_BattleShowPlayerOffMagicAnim(
 
          b = PAL_SpriteGetFrame(lpSpriteEffect, k);
 
-		 if (!gpGlobals->fIsWIN95 && (i - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay) % n == 0)
+		 if (!gConfig.fIsWIN95 && (i - gpGlobals->g.lprgMagic[iMagicNum].wSoundDelay) % n == 0)
          {
             SOUND_Play(gpGlobals->g.lprgMagic[iMagicNum].wSound);
          }
@@ -2923,7 +2920,7 @@ PAL_BattleShowPlayerSummonMagicAnim(
 
    PAL_BattleBackupScene();
 
-   if (gpGlobals->fIsWIN95)
+   if (gConfig.fIsWIN95)
    {
       SOUND_Play(gpGlobals->g.lprgMagic[wMagicNum].wSound);
    }
@@ -4553,7 +4550,7 @@ PAL_BattleEnemyPerformAction(
          g_Battle.rgEnemy[wEnemyIndex].pos = PAL_XY(x, y);
          PAL_BattleDelay(1, 0, FALSE);
       }
-	  if (!gpGlobals->fIsWIN95 || g_Battle.rgEnemy[wEnemyIndex].e.wActionSound != 0)
+	  if (!gConfig.fIsWIN95 || g_Battle.rgEnemy[wEnemyIndex].e.wActionSound != 0)
       {
          SOUND_Play(g_Battle.rgEnemy[wEnemyIndex].e.wActionSound);
       }
@@ -4634,7 +4631,7 @@ PAL_BattleEnemyPerformAction(
 
          g_Battle.rgPlayer[sTarget].iColorShift = 6;
       }
-	  if (!gpGlobals->fIsWIN95 || iSound != 0)
+	  if (!gConfig.fIsWIN95 || iSound != 0)
       {
          SOUND_Play(iSound);
       }

+ 43 - 17
font.c

@@ -65,7 +65,7 @@ PAL_InitFont(
 		{
 			return 0;
 		}
-		
+
 		//
 		// Get the size of wor16.asc file.
 		//
@@ -121,7 +121,7 @@ PAL_InitFont(
 			unicode_font[w][31] = 0;
 		}
 		free(wchar_buf);
-		
+
 		fclose(fp);
 
 		for (i = 0; i < 0x80; i++)
@@ -161,7 +161,8 @@ PAL_DrawCharOnSurface(
    WORD                     wChar,
    SDL_Surface             *lpSurface,
    PAL_POS                  pos,
-   BYTE                     bColor
+   BYTE                     bColor,
+   BOOL                     fUse8x8Font
 )
 /*++
   Purpose:
@@ -190,7 +191,8 @@ PAL_DrawCharOnSurface(
 	//
 	// Check for NULL pointer & invalid char code.
 	//
-	if (lpSurface == NULL || (wChar >= 0xd800 && wChar < unicode_upper_base) || wChar >= unicode_upper_top)
+	if (lpSurface == NULL || (wChar >= 0xd800 && wChar < unicode_upper_base) ||
+		wChar >= unicode_upper_top || (_font_height == 8 && wChar >= 0x100))
 	{
 		return;
 	}
@@ -208,35 +210,51 @@ PAL_DrawCharOnSurface(
 	//
 	LPBYTE dest = (LPBYTE)lpSurface->pixels + y * lpSurface->pitch + x;
 	LPBYTE top = (LPBYTE)lpSurface->pixels + lpSurface->h * lpSurface->pitch;
-	if (font_width[wChar] == 32)
+	if (fUse8x8Font)
 	{
-		for (i = 0; i < _font_height * 2 && dest < top; i += 2, dest += lpSurface->pitch)
+		for (i = 0; i < 8 && dest < top; i++, dest += lpSurface->pitch)
 		{
 			for (j = 0; j < 8 && x + j < lpSurface->w; j++)
 			{
-				if (unicode_font[wChar][i] & (1 << (7 - j)))
+				if (iso_font_8x8[wChar][i] & (1 << j))
 				{
 					dest[j] = bColor;
 				}
 			}
-			for (j = 0; j < 8 && x + j + 8 < lpSurface->w; j++)
+		}
+	}
+	else
+	{
+		if (font_width[wChar] == 32)
+		{
+			for (i = 0; i < _font_height * 2 && dest < top; i += 2, dest += lpSurface->pitch)
 			{
-				if (unicode_font[wChar][i + 1] & (1 << (7 - j)))
+				for (j = 0; j < 8 && x + j < lpSurface->w; j++)
 				{
-					dest[j + 8] = bColor;
+					if (unicode_font[wChar][i] & (1 << (7 - j)))
+					{
+						dest[j] = bColor;
+					}
+				}
+				for (j = 0; j < 8 && x + j + 8 < lpSurface->w; j++)
+				{
+					if (unicode_font[wChar][i + 1] & (1 << (7 - j)))
+					{
+						dest[j + 8] = bColor;
+					}
 				}
 			}
 		}
-	}
-	else
-	{
-		for (i = 0; i < _font_height && dest < top; i++, dest += lpSurface->pitch)
+		else
 		{
-			for (j = 0; j < 8 && x + j < lpSurface->w; j++)
+			for (i = 0; i < _font_height && dest < top; i++, dest += lpSurface->pitch)
 			{
-				if (unicode_font[wChar][i] & (1 << (7 - j)))
+				for (j = 0; j < 8 && x + j < lpSurface->w; j++)
 				{
-					dest[j] = bColor;
+					if (unicode_font[wChar][i] & (1 << (7 - j)))
+					{
+						dest[j] = bColor;
+					}
 				}
 			}
 		}
@@ -277,3 +295,11 @@ PAL_CharWidth(
 
 	return font_width[wChar] >> 1;
 }
+
+INT
+PAL_FontHeight(
+   VOID
+)
+{
+	return _font_height;
+}

+ 7 - 1
font.h

@@ -47,7 +47,8 @@ PAL_DrawCharOnSurface(
    WORD                     wChar,
    SDL_Surface             *lpSurface,
    PAL_POS                  pos,
-   BYTE                     bColor
+   BYTE                     bColor,
+   BOOL                     fUse8x8Font
 );
 
 INT
@@ -55,6 +56,11 @@ PAL_CharWidth(
    WORD                     wChar
 );
 
+INT
+PAL_FontHeight(
+   VOID
+);
+
 #ifdef __cplusplus
 }
 #endif

+ 1 - 0
game.c

@@ -79,6 +79,7 @@ PAL_GameMain(
    // Show the opening menu.
    //
    gpGlobals->bCurrentSaveSlot = (BYTE)PAL_OpeningMenu();
+   gpGlobals->fInMainGame = TRUE;
 
    //
    // Initialize game data and set the flags to load the game resources.

+ 52 - 41
global.c

@@ -27,6 +27,8 @@
 static GLOBALVARS _gGlobals;
 GLOBALVARS * const  gpGlobals = &_gGlobals;
 
+CONFIGURATION gConfig;
+
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
 #define DO_BYTESWAP(buf, size)
 #else
@@ -87,6 +89,13 @@ PAL_InitGlobals(
    MUSICTYPE eMusicType = MUSIC_RIX;
    MUSICTYPE eCDType = PAL_HAS_SDLCD ? MUSIC_SDLCD : MUSIC_OGG;
    OPLTYPE   eOPLType = OPL_DOSBOX;
+   MENULAYOUT layout_equip = {
+	   PAL_XY(8, 8), PAL_XY(2, 95), PAL_XY(5, 70), PAL_XY(51, 57),
+	   { PAL_XY(92, 11), PAL_XY(92, 33), PAL_XY(92, 55), PAL_XY(92, 77), PAL_XY(92, 99), PAL_XY(92, 121) },
+	   { PAL_XY(130, 11), PAL_XY(130, 33), PAL_XY(130, 55), PAL_XY(130, 77), PAL_XY(130, 99), PAL_XY(130, 121) },
+	   { PAL_XY(226, 10), PAL_XY(226, 32), PAL_XY(226, 54), PAL_XY(226, 76), PAL_XY(226, 98)  },
+	   { PAL_XY(260, 14), PAL_XY(260, 36), PAL_XY(260, 58), PAL_XY(260, 80), PAL_XY(260, 102) }
+   };
 
    if (fp = UTIL_OpenFileForMode("sdlpal.cfg", "r"))
    {
@@ -211,7 +220,7 @@ PAL_InitGlobals(
 					   int n = strlen(ptr);
 					   if (n > 0 && ptr[n - 1] == '\n') ptr[--n] = 0;
 					   if (n > 0 && ptr[n - 1] == '\r') ptr[--n] = 0;
-					   if (n > 0) gpGlobals->pszMsgName = strdup(ptr);
+					   if (n > 0) gConfig.pszMsgName = strdup(ptr);
 				   }
 #if USE_RIX_EXTRA_INIT
 				   else if (SDL_strcasecmp(p, "RIXEXTRAINIT") == 0)
@@ -242,9 +251,9 @@ PAL_InitGlobals(
 							   }
 							   if (v)
 							   {
-								   gpGlobals->pExtraFMRegs = regs;
-								   gpGlobals->pExtraFMVals = vals;
-								   gpGlobals->dwExtraLength = n >> 1;
+								   gConfig.pExtraFMRegs = regs;
+								   gConfig.pExtraFMVals = vals;
+								   gConfig.dwExtraLength = n >> 1;
 							   }
 							   else
 							   {
@@ -300,51 +309,52 @@ PAL_InitGlobals(
    //
    // Set configurable global options
    //
-   gpGlobals->fIsWIN95 = dwIsDOS ? FALSE : TRUE;
-   gpGlobals->fUseEmbeddedFonts = dwIsDOS && dwUseEmbeddedFonts ? TRUE : FALSE;
-   gpGlobals->fUseSurroundOPL = dwUseStereo && dwUseSurroundOPL ? TRUE : FALSE;
-   gpGlobals->iAudioChannels = dwUseStereo ? 2 : 1;
-   gpGlobals->iSampleRate = iSampleRate;
-   gpGlobals->iOPLSampleRate = iOPLSampleRate;
-   gpGlobals->iResampleQuality = iResampleQuality;
-   gpGlobals->dSurroundOPLOffset = flSurroundOPLOffset;
-   gpGlobals->eMusicType = eMusicType;
-   gpGlobals->eCDType = eCDType;
-   gpGlobals->eOPLType = eOPLType;
-   gpGlobals->iCodePage = iCodePage;
-   gpGlobals->dwWordLength = 10;	// This is the default value for Chinese version
-   gpGlobals->dwExtraMagicDescLines = dwExtraMagicDescLines;
-   gpGlobals->dwExtraItemDescLines = dwExtraItemDescLines;
-   gpGlobals->wAudioBufferSize = (WORD)iAudioBufferSize;
-   gpGlobals->iVolume = SDL_MIX_MAXVOLUME * iVolume / 100;
+   gConfig.fIsWIN95 = dwIsDOS ? FALSE : TRUE;
+   gConfig.fUseEmbeddedFonts = dwIsDOS && dwUseEmbeddedFonts ? TRUE : FALSE;
+   gConfig.fUseSurroundOPL = dwUseStereo && dwUseSurroundOPL ? TRUE : FALSE;
+   gConfig.iAudioChannels = dwUseStereo ? 2 : 1;
+   gConfig.iSampleRate = iSampleRate;
+   gConfig.iOPLSampleRate = iOPLSampleRate;
+   gConfig.iResampleQuality = iResampleQuality;
+   gConfig.dSurroundOPLOffset = flSurroundOPLOffset;
+   gConfig.eMusicType = eMusicType;
+   gConfig.eCDType = eCDType;
+   gConfig.eOPLType = eOPLType;
+   gConfig.iCodePage = iCodePage;
+   gConfig.dwWordLength = 10;	// This is the default value for Chinese version
+   gConfig.dwExtraMagicDescLines = dwExtraMagicDescLines;
+   gConfig.dwExtraItemDescLines = dwExtraItemDescLines;
+   gConfig.wAudioBufferSize = (WORD)iAudioBufferSize;
+   gConfig.iVolume = SDL_MIX_MAXVOLUME * iVolume / 100;
 #if defined(NDS) || defined(__SYMBIAN32__) || defined(GEKKO) || defined(PSP) || defined(GEKKO) || defined(GPH) || defined(DINGOO) || defined(__ANDROID__)
-   gpGlobals->dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
-   gpGlobals->dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
+   gConfig.dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
+   gConfig.dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
 #elif defined(__WINPHONE__) || defined(__IOS__)
    if (UTIL_GetScreenSize(&dwScreenWidth, &dwScreenHeight))
    {
-      gpGlobals->dwScreenWidth = dwScreenWidth;
-      gpGlobals->dwScreenHeight = dwScreenHeight;
+      gConfig.dwScreenWidth = dwScreenWidth;
+      gConfig.dwScreenHeight = dwScreenHeight;
    }
    else
    {
-      gpGlobals->dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
-      gpGlobals->dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
+      gConfig.dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
+      gConfig.dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
    }
 #else
-   gpGlobals->dwScreenWidth = dwScreenWidth ? dwScreenWidth : PAL_DEFAULT_WINDOW_WIDTH;
-   gpGlobals->dwScreenHeight = dwScreenHeight ? dwScreenHeight : (dwFullScreen ? PAL_DEFAULT_FULLSCREEN_HEIGHT : PAL_DEFAULT_WINDOW_HEIGHT);
+   gConfig.dwScreenWidth = dwScreenWidth ? dwScreenWidth : PAL_DEFAULT_WINDOW_WIDTH;
+   gConfig.dwScreenHeight = dwScreenHeight ? dwScreenHeight : (dwFullScreen ? PAL_DEFAULT_FULLSCREEN_HEIGHT : PAL_DEFAULT_WINDOW_HEIGHT);
 #endif
 #if SDL_VERSION_ATLEAST(2,0,0)
-   gpGlobals->fKeepAspectRatio = dwKeepAspectRatio ? TRUE : FALSE;
+   gConfig.fKeepAspectRatio = dwKeepAspectRatio ? TRUE : FALSE;
 #else
-   gpGlobals->fFullScreen = dwFullScreen ? TRUE : FALSE;
+   gConfig.fFullScreen = dwFullScreen ? TRUE : FALSE;
 #endif
+   gConfig.MenuLayout = layout_equip;
 
    //
    // Set decompress function
    //
-   Decompress = gpGlobals->fIsWIN95 ? YJ2_Decompress : YJ1_Decompress;
+   Decompress = gConfig.fIsWIN95 ? YJ2_Decompress : YJ1_Decompress;
 
    //
    // Open files
@@ -358,7 +368,7 @@ PAL_InitGlobals(
    gpGlobals->f.fpRGM = UTIL_OpenRequiredFile("rgm.mkf");
    gpGlobals->f.fpSSS = UTIL_OpenRequiredFile("sss.mkf");
 
-   gpGlobals->lpObjectDesc = gpGlobals->fIsWIN95 ? NULL : PAL_LoadObjectDesc(va("%s%s", PAL_PREFIX, "desc.dat"));
+   gpGlobals->lpObjectDesc = gConfig.fIsWIN95 ? NULL : PAL_LoadObjectDesc(va("%s%s", PAL_PREFIX, "desc.dat"));
    gpGlobals->bCurrentSaveSlot = 1;
 
    return 0;
@@ -410,20 +420,21 @@ PAL_FreeGlobals(
    //
    // Free the object description data
    //
-   if (!gpGlobals->fIsWIN95)
+   if (!gConfig.fIsWIN95)
       PAL_FreeObjectDesc(gpGlobals->lpObjectDesc);
 
 #if USE_RIX_EXTRA_INIT
-   free(gpGlobals->pExtraFMRegs);
-   free(gpGlobals->pExtraFMVals);
-   free(gpGlobals->dwExtraLength);
+   free(gConfig.pExtraFMRegs);
+   free(gConfig.pExtraFMVals);
+   free(gConfig.dwExtraLength);
 #endif
-   free(gpGlobals->pszMsgName);
+   free(gConfig.pszMsgName);
 
    //
    // Clear the instance
    //
    memset(gpGlobals, 0, sizeof(GLOBALVARS));
+   memset(&gConfig, 0, sizeof(CONFIGURATION));
 }
 
 
@@ -565,7 +576,7 @@ 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));
-   if (gpGlobals->fIsWIN95)
+   if (gConfig.fIsWIN95)
    {
       PAL_MKFReadChunk((LPBYTE)(p->rgObject), sizeof(p->rgObject), 2, gpGlobals->f.fpSSS);
       DO_BYTESWAP(p->rgObject, sizeof(p->rgObject));
@@ -919,7 +930,7 @@ PAL_LoadGame(
    LPCSTR         szFileName
 )
 {
-	return gpGlobals->fIsWIN95 ? PAL_LoadGame_WIN(szFileName) : PAL_LoadGame_DOS(szFileName);
+	return gConfig.fIsWIN95 ? PAL_LoadGame_WIN(szFileName) : PAL_LoadGame_DOS(szFileName);
 }
 
 static VOID
@@ -1098,7 +1109,7 @@ PAL_SaveGame(
    WORD           wSavedTimes
 )
 {
-	if (gpGlobals->fIsWIN95)
+	if (gConfig.fIsWIN95)
 		PAL_SaveGame_WIN(szFileName, wSavedTimes);
 	else
 		PAL_SaveGame_DOS(szFileName, wSavedTimes);

+ 65 - 34
global.h

@@ -440,12 +440,15 @@ typedef struct tagLEVELUPMAGIC_ALL
    LEVELUPMAGIC       m[MAX_PLAYABLE_PLAYER_ROLES];
 } LEVELUPMAGIC_ALL, *LPLEVELUPMAGIC_ALL;
 
+typedef struct tagPALPOS
+{
+	WORD      x;
+	WORD      y;
+} PALPOS;
+
 typedef struct tagENEMYPOS
 {
-   struct {
-      WORD      x;
-      WORD      y;
-   } pos[MAX_ENEMIES_IN_TEAM][MAX_ENEMIES_IN_TEAM];
+	PALPOS pos[MAX_ENEMIES_IN_TEAM][MAX_ENEMIES_IN_TEAM];
 } ENEMYPOS, *LPENEMYPOS;
 
 // Exp. points needed for the next level
@@ -564,11 +567,12 @@ typedef struct tagGLOBALVARS
    FILES            f;
    GAMEDATA         g;
 
-   BYTE             bCurrentSaveSlot;    // current save slot (1-5)
    int              iCurMainMenuItem;    // current main menu item number
    int              iCurSystemMenuItem;  // current system menu item number
    int              iCurInvMenuItem;     // current inventory menu item number
    int              iCurPlayingRNG;      // current playing RNG animation
+   BYTE             bCurrentSaveSlot;    // current save slot (1-5)
+   BOOL             fInMainGame;         // TRUE if in main game
    BOOL             fGameStart;          // TRUE if the has just started
    BOOL             fEnteringScene;      // TRUE if entering a new scene
    BOOL             fNeedToFadeIn;       // TRUE if need to fade in when drawing scene
@@ -609,42 +613,69 @@ typedef struct tagGLOBALVARS
    INVENTORY        rgInventory[MAX_INVENTORY];  // inventory status
    LPOBJECTDESC     lpObjectDesc;
    DWORD            dwFrameNum;
+} GLOBALVARS, *LPGLOBALVARS;
 
-   /* Configurable options */
-   char            *pszMsgName;
+extern GLOBALVARS * const gpGlobals;
+
+typedef struct tagMENULAYOUT
+{
+	PAL_POS          ImageBox;
+	PAL_POS          RoleListBox;
+	PAL_POS          ItemName;
+	PAL_POS          ItemAmount;
+	PAL_POS          EquipLabels[6];
+	PAL_POS          EquipNames[6];
+	PAL_POS          StatusLabels[5];
+	PAL_POS          StatusValues[5];
+} MENULAYOUT;
+
+typedef struct tagCONFIGURATION
+{
+	union {
+	MENULAYOUT       MenuLayout;
+	PAL_POS          MenuLayoutArray[sizeof(MENULAYOUT) / sizeof(PAL_POS)];
+	};
+	enum {
+		USE_8x8_FONT = 1,
+		DISABLE_SHADOW = 2,
+	}                MenuLayoutFlag[sizeof(MENULAYOUT) / sizeof(PAL_POS)];
+
+	/* Configurable options */
+	char            *pszMsgName;
 #if USE_RIX_EXTRA_INIT
-   uint32_t        *pExtraFMRegs;
-   uint8_t         *pExtraFMVals;
-   uint32_t         dwExtraLength;
+	uint32_t        *pExtraFMRegs;
+	uint8_t         *pExtraFMVals;
+	uint32_t         dwExtraLength;
 #endif
-   CODEPAGE         iCodePage;
-   DWORD            dwWordLength;
-   DWORD            dwExtraMagicDescLines;
-   DWORD            dwExtraItemDescLines;
-   DWORD            dwScreenWidth;
-   DWORD            dwScreenHeight;
-   double           dSurroundOPLOffset;
-   INT              iAudioChannels;
-   INT              iSampleRate;
-   INT              iOPLSampleRate;
-   INT              iResampleQuality;
-   INT              iVolume;
-   MUSICTYPE        eMusicType;
-   MUSICTYPE        eCDType;
-   OPLTYPE          eOPLType;
-   WORD             wAudioBufferSize;
-   BOOL             fIsWIN95;
-   BOOL             fUseEmbeddedFonts;
-   BOOL             fUseSurroundOPL;
+	CODEPAGE         iCodePage;
+	DWORD            dwWordLength;
+	DWORD            dwExtraMagicDescLines;
+	DWORD            dwExtraItemDescLines;
+	DWORD            dwScreenWidth;
+	DWORD            dwScreenHeight;
+	double           dSurroundOPLOffset;
+	INT              iAudioChannels;
+	INT              iSampleRate;
+	INT              iOPLSampleRate;
+	INT              iResampleQuality;
+	INT              iVolume;
+	MUSICTYPE        eMusicType;
+	MUSICTYPE        eCDType;
+	OPLTYPE          eOPLType;
+	WORD             wAudioBufferSize;
+	BOOL             fIsWIN95;
+	BOOL             fUseEmbeddedFonts;
+	BOOL             fUseSurroundOPL;
 #if SDL_VERSION_ATLEAST(2,0,0)
-   BOOL             fKeepAspectRatio;
+	BOOL             fKeepAspectRatio;
 #else
-   BOOL             fFullScreen;
+	BOOL             fFullScreen;
 #endif
-   BOOL             fEnableJoyStick;
-} GLOBALVARS, *LPGLOBALVARS;
+	BOOL             fEnableJoyStick;
+	BOOL             fUseCustomMenuLayout;
+} CONFIGURATION, *LPCONFIGURATION;
 
-extern GLOBALVARS * const gpGlobals;
+extern CONFIGURATION gConfig;
 
 INT
 PAL_InitGlobals(

+ 11 - 19
input.c

@@ -39,7 +39,7 @@ BOOL                     g_fUseJoystick = TRUE;
 #endif
 
 #if defined(__WINPHONE__)
-unsigned int g_uiLastBackKeyTime = 0;
+static unsigned int g_uiLastBackKeyTime = 0;
 #endif
 
 static VOID
@@ -103,22 +103,6 @@ PAL_KeyboardEventFilter(
          SOUND_AdjustVolume(1);
          break;
 #endif
-
-#ifdef __WINPHONE__
-      case SDLK_AC_BACK:
-         if (g_uiLastBackKeyTime != 0 && !SDL_TICKS_PASSED(SDL_GetTicks(), g_uiLastBackKeyTime + 800))
-         {
-            PAL_Shutdown();
-            exit(0);
-         }
-		 else
-		 {
-            g_uiLastBackKeyTime = SDL_GetTicks();
-            VIDEO_UpdateScreen(NULL);
-		 }
-         break;
-#endif
-
       case SDLK_UP:
       case SDLK_KP8:
          if (gpGlobals->fInBattle || g_InputState.dir != kDirNorth)
@@ -223,6 +207,16 @@ PAL_KeyboardEventFilter(
          g_InputState.dwKeyPress |= kKeyThrowItem;
          break;
 
+#if defined(__WINPHONE__)
+      case SDLK_AC_BACK:
+         if (!gpGlobals->fInMainGame || !SDL_TICKS_PASSED(SDL_GetTicks(), g_uiLastBackKeyTime + 800))
+         {
+            // If game not started, or user press the BACK key quickly twice, force to exit
+            PAL_Shutdown();
+            exit(0);
+		 }
+         g_uiLastBackKeyTime = SDL_GetTicks();
+#endif
       case SDLK_q:
          g_InputState.dwKeyPress |= kKeyFlee;
          break;
@@ -1151,9 +1145,7 @@ PAL_ProcessEvent(
 
 --*/
 {
-#if PAL_HAS_NATIVEMIDI
    MIDI_CheckLoop();
-#endif
    while (PAL_PollEvent(NULL));
 }
 

+ 10 - 12
itemmenu.c

@@ -51,13 +51,13 @@ PAL_ItemSelectMenuUpdate(
    BYTE               bColor;
    static BYTE        bufImage[2048];
    static WORD        wPrevImageIndex = 0xFFFF;
-   const int          iItemsPerLine = 34 / gpGlobals->dwWordLength;
-   const int          iItemTextWidth = 8 * gpGlobals->dwWordLength + 20;
-   const int          iLinesPerPage = 7 - gpGlobals->dwExtraItemDescLines;
-   const int          iCursorXOffset = gpGlobals->dwWordLength * 5 / 2;
-   const int          iAmountXOffset = gpGlobals->dwWordLength * 8 + 1;
+   const int          iItemsPerLine = 34 / gConfig.dwWordLength;
+   const int          iItemTextWidth = 8 * gConfig.dwWordLength + 20;
+   const int          iLinesPerPage = 7 - gConfig.dwExtraItemDescLines;
+   const int          iCursorXOffset = gConfig.dwWordLength * 5 / 2;
+   const int          iAmountXOffset = gConfig.dwWordLength * 8 + 1;
    const int          iPageLineOffset = (iLinesPerPage + 1) / 2;
-   const int          iPictureYOffset = (gpGlobals->dwExtraItemDescLines > 1) ? (gpGlobals->dwExtraItemDescLines - 1) * 16 : 0;
+   const int          iPictureYOffset = (gConfig.dwExtraItemDescLines > 1) ? (gConfig.dwExtraItemDescLines - 1) * 16 : 0;
 
    //
    // Process input
@@ -181,8 +181,7 @@ PAL_ItemSelectMenuUpdate(
          //
          // Draw the text
          //
-		 PAL_DrawText(PAL_GetWord(wObject), PAL_XY(15 + k * iItemTextWidth, 12 + j * 18),
-            bColor, TRUE, FALSE);
+		 PAL_DrawText(PAL_GetWord(wObject), PAL_XY(15 + k * iItemTextWidth, 12 + j * 18), bColor, TRUE, FALSE, FALSE);
 
          //
          // Draw the cursor on the current selected item
@@ -235,7 +234,7 @@ PAL_ItemSelectMenuUpdate(
    //
    // Draw the description of the selected item
    //
-   if (!gpGlobals->fIsWIN95)
+   if (!gConfig.fIsWIN95)
    {
       if (!g_fNoDesc && gpGlobals->lpObjectDesc != NULL)
 	  {
@@ -256,7 +255,7 @@ PAL_ItemSelectMenuUpdate(
                   *next++ = '\0';
                }
 
-               PAL_DrawText(d, PAL_XY(75, k), DESCTEXT_COLOR, TRUE, FALSE);
+               PAL_DrawText(d, PAL_XY(75, k), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
                k += 16;
 
                if (next == NULL)
@@ -302,8 +301,7 @@ PAL_ItemSelectMenuUpdate(
 			 j = (gpGlobals->iCurInvMenuItem < iItemsPerLine * iPageLineOffset) ? (gpGlobals->iCurInvMenuItem / iItemsPerLine) : iPageLineOffset;
 			k = gpGlobals->iCurInvMenuItem % iItemsPerLine;
 
-            PAL_DrawText(PAL_GetWord(wObject), PAL_XY(15 + k * iItemTextWidth, 12 + j * 18),
-               MENUITEM_COLOR_CONFIRMED, FALSE, FALSE);
+            PAL_DrawText(PAL_GetWord(wObject), PAL_XY(15 + k * iItemTextWidth, 12 + j * 18), MENUITEM_COLOR_CONFIRMED, FALSE, FALSE, FALSE);
          }
 
          return wObject;

+ 10 - 12
magicmenu.c

@@ -56,11 +56,11 @@ PAL_MagicSelectionMenuUpdate(
    int         i, j, k, line, item_delta;
    BYTE        bColor;
    WORD        wScript;
-   const int   iItemsPerLine = 32 / gpGlobals->dwWordLength;
-   const int   iItemTextWidth = 8 * gpGlobals->dwWordLength + 7;
-   const int   iLinesPerPage = 5 - gpGlobals->dwExtraMagicDescLines;
-   const int   iBoxYOffset = gpGlobals->dwExtraMagicDescLines * 16;
-   const int   iCursorXOffset = gpGlobals->dwWordLength * 5 / 2;
+   const int   iItemsPerLine = 32 / gConfig.dwWordLength;
+   const int   iItemTextWidth = 8 * gConfig.dwWordLength + 7;
+   const int   iLinesPerPage = 5 - gConfig.dwExtraMagicDescLines;
+   const int   iBoxYOffset = gConfig.dwExtraMagicDescLines * 16;
+   const int   iCursorXOffset = gConfig.dwWordLength * 5 / 2;
    const int   iPageLineOffset = iLinesPerPage / 2;
 
    //
@@ -119,7 +119,7 @@ PAL_MagicSelectionMenuUpdate(
    //
    PAL_CreateBox(PAL_XY(10, 42 + iBoxYOffset), iLinesPerPage - 1, 16, 1, FALSE);
 
-   if (!gpGlobals->fIsWIN95)
+   if (!gConfig.fIsWIN95)
    {
       if (gpGlobals->lpObjectDesc == NULL)
       {
@@ -127,7 +127,7 @@ PAL_MagicSelectionMenuUpdate(
          // 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_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(10, 10), 0, FALSE, FALSE, FALSE);
          PAL_DrawNumber(gpGlobals->dwCash, 6, PAL_XY(49, 14), kNumColorYellow, kNumAlignRight);
 
          //
@@ -162,7 +162,7 @@ PAL_MagicSelectionMenuUpdate(
                   *next++ = '\0';
                }
 
-               PAL_DrawText(d, PAL_XY(100, k), DESCTEXT_COLOR, TRUE, FALSE);
+               PAL_DrawText(d, PAL_XY(100, k), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
                k += 16;
 
                if (next == NULL)
@@ -258,8 +258,7 @@ PAL_MagicSelectionMenuUpdate(
          //
          // Draw the text
          //
-         PAL_DrawText(PAL_GetWord(rgMagicItem[i].wMagic),
-            PAL_XY(35 + k * iItemTextWidth, 54 + j * 18 + iBoxYOffset), bColor, TRUE, FALSE);
+         PAL_DrawText(PAL_GetWord(rgMagicItem[i].wMagic), PAL_XY(35 + k * iItemTextWidth, 54 + j * 18 + iBoxYOffset), bColor, TRUE, FALSE, FALSE);
 
          //
          // Draw the cursor on the current selected item
@@ -284,8 +283,7 @@ PAL_MagicSelectionMenuUpdate(
 		 j = 35 + j * iItemTextWidth;
 		 k = 54 + k * 18 + iBoxYOffset;
 
-         PAL_DrawText(PAL_GetWord(rgMagicItem[g_iCurrentItem].wMagic), PAL_XY(j, k),
-            MENUITEM_COLOR_CONFIRMED, FALSE, TRUE);
+         PAL_DrawText(PAL_GetWord(rgMagicItem[g_iCurrentItem].wMagic), PAL_XY(j, k), MENUITEM_COLOR_CONFIRMED, FALSE, TRUE, FALSE);
 
          return rgMagicItem[g_iCurrentItem].wMagic;
       }

+ 11 - 13
main.c

@@ -28,19 +28,20 @@
 #endif
 
 #if defined (NDS) && defined (GEKKO)
-#include <fat.h>
-#endif
 
-#ifdef __WINPHONE__
-#include <setjmp.h>
+# include <fat.h>
+
+#elif defined(__WINPHONE__)
+
+# include <setjmp.h>
 
 static jmp_buf g_exit_jmp_env;
 # define LONGJMP_EXIT_CODE          0xff
 
 #endif
 
-#define BITMAPNUM_SPLASH_UP         (gpGlobals->fIsWIN95 ? 0x03 : 0x26)
-#define BITMAPNUM_SPLASH_DOWN       (gpGlobals->fIsWIN95 ? 0x04 : 0x27)
+#define BITMAPNUM_SPLASH_UP         (gConfig.fIsWIN95 ? 0x03 : 0x26)
+#define BITMAPNUM_SPLASH_DOWN       (gConfig.fIsWIN95 ? 0x04 : 0x27)
 #define SPRITENUM_SPLASH_TITLE      0x47
 #define SPRITENUM_SPLASH_CRANE      0x49
 #define NUM_RIX_TITLE               0x05
@@ -113,7 +114,7 @@ PAL_Init(
 
    SDL_WM_SetCaption("Loading...", NULL);
 
-   e = PAL_InitFont(gpGlobals->fUseEmbeddedFonts);
+   e = PAL_InitFont(gConfig.fUseEmbeddedFonts);
    if (e != 0)
    {
       TerminateOnError("Could not load fonts: %d.\n", e);
@@ -135,7 +136,7 @@ PAL_Init(
    PAL_InitResources();
    SOUND_OpenAudio();
 
-   if (gpGlobals->fIsWIN95)
+   if (gConfig.fIsWIN95)
    {
 #ifdef _DEBUG
       SDL_WM_SetCaption("Pal WIN95 (Debug Build)", NULL);
@@ -187,8 +188,7 @@ PAL_Shutdown(
 #if defined(GPH)
 	chdir("/usr/gp2x");
 	execl("./gp2xmenu", "./gp2xmenu", NULL);
-#endif
-#ifdef __WINPHONE__
+#elif defined(__WINPHONE__)
 	longjmp(g_exit_jmp_env, LONGJMP_EXIT_CODE);
 #endif
 }
@@ -521,9 +521,7 @@ main(
       buf[p - argv[0]] = '\0';
       chdir(buf);
    }
-#endif
-
-#ifdef __WINPHONE__
+#elif defined(__WINPHONE__)
    //
    // In windows phone, calling exit(0) directly will cause an abnormal exit.
    // By using setjmp/longjmp to avoid this.

+ 0 - 3
main.h

@@ -48,10 +48,7 @@
 #include "fight.h"
 #include "play.h"
 #include "game.h"
-
-#if PAL_HAS_NATIVEMIDI
 #include "midi.h"
-#endif
 
 VOID
 PAL_Shutdown(

+ 46 - 0
makemessage.py

@@ -80,6 +80,46 @@ def main():
     output += "11=    ...Press Enter to continue\n"
     output += "[END CREDITS]\n\n"
 
+    output += "# Each line controls one position value, lines from 1 to 26 is for the equipment menu.\n"
+    output += "# For each line, the format is 'idx=x,y,flag', while the flag is optional\n"
+    output += "# If bit 0 of flag is 1, then use 8x8 font; and while bit 1 of flag is 1, then disable shadow\n"
+    output += "[BEGIN LAYOUT]\n"
+    output += "# 1 is the position of image box in equip menu\n"
+    output += "1=8,8\n"
+    output += "# 2 is the position of role list box in equip menu\n"
+    output += "2=2,95\n"
+    output += "# 3 is the position of current equipment's name in equip menu\n"
+    output += "3=5,70\n"
+    output += "# 4 is the position of current equipment's amount in equip menu\n"
+    output += "4=51,57\n"
+    output += "# 5 .. 10 are the positions of words 566 ... 571 in equip menu\n"
+    output += "5=92,11\n"
+    output += "6=92,33\n"
+    output += "7=92,55\n"
+    output += "8=92,77\n"
+    output += "9=92,99\n"
+    output += "10=92,121\n"
+    output += "# 11 .. 16 are the positions of equipped equipments in equip menu\n"
+    output += "11=130,11\n"
+    output += "12=130,33\n"
+    output += "13=130,55\n"
+    output += "14=130,77\n"
+    output += "15=130,99\n"
+    output += "16=130,121\n"
+    output += "# 17 .. 21 are the positions of words 51 ... 55 in equip menu\n"
+    output += "17=226,10\n"
+    output += "18=226,32\n"
+    output += "19=226,54\n"
+    output += "20=226,76\n"
+    output += "21=226,98\n"
+    output += "# 22 .. 26 are the positions of status values in equip menu\n"
+    output += "22=260,14\n"
+    output += "23=260,36\n"
+    output += "24=260,58\n"
+    output += "25=260,80\n"
+    output += "26=260,102\n"
+    output += "[END LAYOUT]\n\n"
+
     output += "# This section contains the words used by the game.\n"
     output += "[BEGIN WORDS]\n"
     output += "# Each line is a pattern of 'key=value', where key is an integer and value is a string.\n"
@@ -87,6 +127,12 @@ def main():
         temp = data_bytes[i * options.wordwidth: (i + 1) * options.wordwidth].rstrip('\x20\x00').decode(options.encoding).encode('utf-8')
         if options.comment: output += "# Original word: %d=%s\n" % (i, temp)
         output += "%d=%s\n" % (i, temp)
+    output += "566=Headgear\n"
+    output += "567=Body Gear\n"
+    output += "568=Clothing\n"
+    output += "569=Weapon\n"
+    output += "570=Footwear\n"
+    output += "571=Accessory\n"
     output += "# This is the only addtional word for ATB in SDLPAL. It is not used in classical mode.\n"
     output += "65530=Battle Speed\n"
     output += "[END WORDS]\n\n"

+ 1 - 1
midi.c

@@ -65,7 +65,7 @@ MIDI_Play(
       return;
    }
 
-   if (gpGlobals->fIsWIN95)
+   if (gConfig.fIsWIN95)
    {
       char filename[1024];
       sprintf(filename, "%s/musics/%.3d.mid", PAL_PREFIX, iNumRIX);

+ 16 - 0
midi.h

@@ -29,6 +29,7 @@ extern "C"
 {
 #endif
 
+#if PAL_HAS_NATIVEMIDI
 #include "native_midi/native_midi.h"
 
 VOID
@@ -42,6 +43,21 @@ MIDI_CheckLoop(
    VOID
 );
 
+#else
+
+static VOID
+MIDI_Play(
+   INT       iNumRIX,
+   BOOL      fLoop
+) {}
+
+static VOID
+MIDI_CheckLoop(
+   VOID
+) {}
+
+#endif
+
 #ifdef __cplusplus
 }
 #endif

+ 3 - 3
mp3play.c

@@ -61,7 +61,7 @@ MP3_FillBuffer(
 {
 	LPMP3PLAYER player = (LPMP3PLAYER)object;
 	if (player->pMP3) {
-		player->pMP3->volume = gpGlobals->iVolume * 3 / 4;
+		player->pMP3->volume = gConfig.iVolume * 3 / 4;
 
 		mad_getSamples(player->pMP3, stream, len);
 
@@ -116,9 +116,9 @@ MP3_Play(
 
 	if (iNum > 0)
 	{
-		if ((player->pMP3 = mad_openFile(va("%s/mp3/%.2d.mp3", PAL_PREFIX, iNum), SOUND_GetAudioSpec(), gpGlobals->iResampleQuality)) == NULL)
+		if ((player->pMP3 = mad_openFile(va("%s/mp3/%.2d.mp3", PAL_PREFIX, iNum), SOUND_GetAudioSpec(), gConfig.iResampleQuality)) == NULL)
 		{
-			player->pMP3 = mad_openFile(va("%s/MP3/%.2d.MP3", PAL_PREFIX, iNum), SOUND_GetAudioSpec(), gpGlobals->iResampleQuality);
+			player->pMP3 = mad_openFile(va("%s/MP3/%.2d.MP3", PAL_PREFIX, iNum), SOUND_GetAudioSpec(), gConfig.iResampleQuality);
 		}
 
 		if (player->pMP3)

+ 13 - 13
oggplay.c

@@ -84,7 +84,7 @@ PAL_FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
 
 PAL_FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
 {
-	if (gpGlobals->iAudioChannels == 2) {
+	if (gConfig.iAudioChannels == 2) {
 		stream[0] = SDL_SwapLE16(resampler_get_and_remove_sample(player->resampler[0]));
 		stream[1] = (player->vi.channels > 1) ? SDL_SwapLE16(resampler_get_and_remove_sample(player->resampler[1])) : stream[0];
 	}
@@ -101,7 +101,7 @@ PAL_FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
 static void OGG_Cleanup(LPOGGPLAYER player)
 {
 	int i;
-	for (i = 0; i < gpGlobals->iAudioChannels; i++) resampler_clear(player->resampler[0]);
+	for (i = 0; i < gConfig.iAudioChannels; i++) resampler_clear(player->resampler[0]);
 	/* Do various cleanups */
 	if (player->iFlags & FLAG_VB) vorbis_block_clear(&player->vb);
 	if (player->iFlags & FLAG_VD) vorbis_dsp_clear(&player->vd);
@@ -235,11 +235,11 @@ static BOOL OGG_Rewind(LPOGGPLAYER player)
 		player->iStage = STAGE_PAGEOUT;
 		player->iFlags |= FLAG_VD | FLAG_VB;
 
-		if (player->fUseResampler = player->vi.rate != gpGlobals->iSampleRate) {
-			double factor = (double)player->vi.rate / (double)gpGlobals->iSampleRate;
+		if (player->fUseResampler = player->vi.rate != gConfig.iSampleRate) {
+			double factor = (double)player->vi.rate / (double)gConfig.iSampleRate;
 			for (i = 0; i < min(player->vi.channels, 2); i++)
 			{
-				resampler_set_quality(player->resampler[i], SOUND_IsIntegerConversion(player->vi.rate) ? RESAMPLER_QUALITY_MIN : gpGlobals->iResampleQuality);
+				resampler_set_quality(player->resampler[i], SOUND_IsIntegerConversion(player->vi.rate) ? RESAMPLER_QUALITY_MIN : gConfig.iResampleQuality);
 				resampler_set_rate(player->resampler[i], factor);
 				resampler_clear(player->resampler[i]);
 			}
@@ -263,7 +263,7 @@ OGG_FillBuffer(
 
 	if (player->fReady) {
 		ogg_packet       op; /* one raw packet of data for decode */
-		double volume = (double)gpGlobals->iVolume / (SDL_MIX_MAXVOLUME * 3 / 4);
+		double volume = (double)gConfig.iVolume / (SDL_MIX_MAXVOLUME * 3 / 4);
 		int total_bytes = 0, stage = player->iStage;
 
 		while (total_bytes < len) {
@@ -339,7 +339,7 @@ OGG_FillBuffer(
 							j = resampler_get_sample_count(player->resampler[0]);
 							while (total_bytes < len && resampler_get_sample_count(player->resampler[0]) > 0) {
 								OGG_FillResample(player, (ogg_int16_t *)(stream + total_bytes));
-								total_bytes += gpGlobals->iAudioChannels * sizeof(ogg_int16_t);
+								total_bytes += gConfig.iAudioChannels * sizeof(ogg_int16_t);
 							}
 
 							samples -= to_write; bout += to_write;
@@ -348,10 +348,10 @@ OGG_FillBuffer(
 					else {
 						int i;
 						ogg_int16_t *ptr = (ogg_int16_t *)(stream + total_bytes);
-						bout = (len - total_bytes) / gpGlobals->iAudioChannels / sizeof(ogg_int16_t);
+						bout = (len - total_bytes) / gConfig.iAudioChannels / sizeof(ogg_int16_t);
 						if (bout > samples) bout = samples;
 						for (i = 0; i < bout; i++) {
-							if (gpGlobals->iAudioChannels == 2) {
+							if (gConfig.iAudioChannels == 2) {
 								ptr[0] = SDL_SwapLE16(OGG_GetSample(pcm[0][i], volume));
 								ptr[1] = (player->vi.channels > 1) ? SDL_SwapLE16(OGG_GetSample(pcm[1][i], volume)) : ptr[0];
 							}
@@ -363,10 +363,10 @@ OGG_FillBuffer(
 									ptr[0] = SDL_SwapLE16(OGG_GetSample(pcm[0][i], volume));
 								}
 							}
-							ptr += gpGlobals->iAudioChannels;
+							ptr += gConfig.iAudioChannels;
 						}
 
-						total_bytes += bout * gpGlobals->iAudioChannels * sizeof(ogg_int16_t);
+						total_bytes += bout * gConfig.iAudioChannels * sizeof(ogg_int16_t);
 					}
 					/* tell libvorbis how many samples we actually consumed */
 					vorbis_synthesis_read(&player->vd, bout);
@@ -376,10 +376,10 @@ OGG_FillBuffer(
 				}
 				break;
 			case STAGE_REWIND:
-				if (player->vi.rate != gpGlobals->iSampleRate) { /* If there are samples in the resampler, fetch them first */
+				if (player->vi.rate != gConfig.iSampleRate) { /* If there are samples in the resampler, fetch them first */
 					while (total_bytes < len && resampler_get_sample_count(player->resampler[0]) > 0) {
 						OGG_FillResample(player, (ogg_int16_t *)(stream + total_bytes));
-						total_bytes += gpGlobals->iAudioChannels * sizeof(ogg_int16_t);
+						total_bytes += gConfig.iAudioChannels * sizeof(ogg_int16_t);
 					}
 					/* Break out if there are still samples in the resampler */
 					if (resampler_get_sample_count(player->resampler[0]) > 0) break;

+ 2 - 2
palcommon.c

@@ -643,7 +643,7 @@ PAL_SpriteGetFrame(
    //
    iFrameNum <<= 1;
    offset = ((lpSprite[iFrameNum] | (lpSprite[iFrameNum + 1] << 8)) << 1);
-   if (!gpGlobals->fIsWIN95) offset = (WORD)offset;
+   if (!gConfig.fIsWIN95) offset = (WORD)offset;
    return &lpSprite[offset];
 }
 
@@ -863,7 +863,7 @@ PAL_MKFGetDecompressedSize(
    // Read the header.
    //
    fseek(fp, uiOffset, SEEK_SET);
-   if (gpGlobals->fIsWIN95)
+   if (gConfig.fIsWIN95)
    {
       fread(buf, sizeof(DWORD), 1, fp);
       buf[0] = SDL_SwapLE32(buf[0]);

+ 1 - 0
palcommon.h

@@ -37,6 +37,7 @@ typedef DWORD           PAL_POS;
 #define PAL_XY(x, y)    (PAL_POS)(((((WORD)(y)) << 16) & 0xFFFF0000) | (((WORD)(x)) & 0xFFFF))
 #define PAL_X(xy)       (SHORT)((xy) & 0xFFFF)
 #define PAL_Y(xy)       (SHORT)(((xy) >> 16) & 0xFFFF)
+#define PAL_XY_OFFSET(xy, x, y)    (PAL_POS)(((((INT)(y) << 16) & 0xFFFF0000) + ((xy) & 0xFFFF0000)) | (((INT)(x) & 0xFFFF) + ((xy) & 0xFFFF)))
 
 typedef enum tagPALDIRECTION
 {

+ 32 - 32
rixplay.cpp

@@ -82,7 +82,7 @@ RIX_FillBuffer(
 --*/
 {
 	LPRIXPLAYER pRixPlayer = (LPRIXPLAYER)object;
-	const INT max_volume = gpGlobals->iVolume * 3 / 4;
+	const INT max_volume = gConfig.iVolume * 3 / 4;
 
 	if (pRixPlayer == NULL || !pRixPlayer->fReady)
 	{
@@ -133,7 +133,7 @@ RIX_FillBuffer(
 					pRixPlayer->fLoop = pRixPlayer->fNextLoop;
 					pRixPlayer->FadeType = RIXPLAYER::FADE_IN;
 					if (pRixPlayer->iCurrentMusic > 0)
-						pRixPlayer->dwStartFadeTime += pRixPlayer->iTotalFadeOutSamples * 1000 / gpGlobals->iSampleRate;
+						pRixPlayer->dwStartFadeTime += pRixPlayer->iTotalFadeOutSamples * 1000 / gConfig.iSampleRate;
 					else
 						pRixPlayer->dwStartFadeTime = SDL_GetTicks();
 					pRixPlayer->iTotalFadeOutSamples = 0;
@@ -173,7 +173,7 @@ RIX_FillBuffer(
 		//
 		// Fill the buffer with sound data
 		//
-		int buf_max_len = gpGlobals->iSampleRate / 70 * gpGlobals->iAudioChannels * sizeof(short);
+		int buf_max_len = gConfig.iSampleRate / 70 * gConfig.iAudioChannels * sizeof(short);
 		bool fContinue = true;
 		while (len > 0 && fContinue)
 		{
@@ -205,7 +205,7 @@ RIX_FillBuffer(
 						return;
 					}
 				}
-				int sample_count = gpGlobals->iSampleRate / 70;
+				int sample_count = gConfig.iSampleRate / 70;
 				if (pRixPlayer->resampler[0])
 				{
 					unsigned int samples_written = 0;
@@ -216,17 +216,17 @@ RIX_FillBuffer(
 						int to_write = resampler_get_free_count(pRixPlayer->resampler[0]);
 						if (to_write)
 						{
-							short *tempBuf = (short*)alloca(to_write * gpGlobals->iAudioChannels * sizeof(short));
+							short *tempBuf = (short*)alloca(to_write * gConfig.iAudioChannels * sizeof(short));
 							pRixPlayer->opl->update(tempBuf, to_write);
 							for (int i = 0; i < to_write; i++)
-								for (int j = 0; j < gpGlobals->iAudioChannels; j++)
-									resampler_write_sample(pRixPlayer->resampler[j], tempBuf[i * gpGlobals->iAudioChannels + j]);
+								for (int j = 0; j < gConfig.iAudioChannels; j++)
+									resampler_write_sample(pRixPlayer->resampler[j], tempBuf[i * gConfig.iAudioChannels + j]);
 						}
 
 						int to_get = resampler_get_sample_count(pRixPlayer->resampler[0]);
 						if (to_get > sample_count) to_get = sample_count;
 						for (int i = 0; i < to_get; i++)
-							for (int j = 0; j < gpGlobals->iAudioChannels; j++)
+							for (int j = 0; j < gConfig.iAudioChannels; j++)
 								finalBuf[samples_written++] = resampler_get_and_remove_sample(pRixPlayer->resampler[j]);
 						sample_count -= to_get;
 					}
@@ -295,7 +295,7 @@ RIX_Shutdown(
 	{
 		LPRIXPLAYER pRixPlayer = (LPRIXPLAYER)object;
 		pRixPlayer->fReady = FALSE;
-		for (int i = 0; i < gpGlobals->iAudioChannels; i++)
+		for (int i = 0; i < gConfig.iAudioChannels; i++)
 			if (pRixPlayer->resampler[i])
 				resampler_delete(pRixPlayer->resampler[i]);
 		delete pRixPlayer->rix;
@@ -363,13 +363,13 @@ RIX_Play(
 		{
 			pRixPlayer->dwStartFadeTime = SDL_GetTicks();
 		}
-		pRixPlayer->iTotalFadeOutSamples = (int)round(flFadeTime / 2.0f * gpGlobals->iSampleRate) * gpGlobals->iAudioChannels;
+		pRixPlayer->iTotalFadeOutSamples = (int)round(flFadeTime / 2.0f * gConfig.iSampleRate) * gConfig.iAudioChannels;
 		pRixPlayer->iRemainingFadeSamples = pRixPlayer->iTotalFadeOutSamples;
 		pRixPlayer->iTotalFadeInSamples = pRixPlayer->iTotalFadeOutSamples;
 	}
 	else
 	{
-		pRixPlayer->iTotalFadeInSamples = (int)round(flFadeTime / 2.0f * gpGlobals->iSampleRate) * gpGlobals->iAudioChannels;
+		pRixPlayer->iTotalFadeInSamples = (int)round(flFadeTime / 2.0f * gConfig.iSampleRate) * gConfig.iAudioChannels;
 	}
 
 	pRixPlayer->iNextMusic = iNumRIX;
@@ -412,45 +412,45 @@ RIX_Init(
 		pRixPlayer->Play = RIX_Play;
 	}
 
-	if (gpGlobals->fUseSurroundOPL)
+	if (gConfig.fUseSurroundOPL)
 	{
-		switch (gpGlobals->eOPLType)
+		switch (gConfig.eOPLType)
 		{
 		case OPL_DOSBOX_OLD:
 			pRixPlayer->opl = new CSurroundopl(
-				new CDemuopl(gpGlobals->iOPLSampleRate, true, false),
-				new CDemuopl(gpGlobals->iOPLSampleRate, true, false),
-				true, gpGlobals->iOPLSampleRate, gpGlobals->dSurroundOPLOffset);
+				new CDemuopl(gConfig.iOPLSampleRate, true, false),
+				new CDemuopl(gConfig.iOPLSampleRate, true, false),
+				true, gConfig.iOPLSampleRate, gConfig.dSurroundOPLOffset);
 			break;
 		case OPL_DOSBOX:
 			pRixPlayer->opl = new CSurroundopl(
-				new CDBemuopl(gpGlobals->iOPLSampleRate, true, false),
-				new CDBemuopl(gpGlobals->iOPLSampleRate, true, false),
-				true, gpGlobals->iOPLSampleRate, gpGlobals->dSurroundOPLOffset);
+				new CDBemuopl(gConfig.iOPLSampleRate, true, false),
+				new CDBemuopl(gConfig.iOPLSampleRate, true, false),
+				true, gConfig.iOPLSampleRate, gConfig.dSurroundOPLOffset);
 			break;
 #if PAL_HAS_MAME
 		case OPL_MAME:
 			pRixPlayer->opl = new CSurroundopl(
-				new CEmuopl(gpGlobals->iOPLSampleRate, true, false),
-				new CEmuopl(gpGlobals->iOPLSampleRate, true, false),
-				true, gpGlobals->iOPLSampleRate, gpGlobals->dSurroundOPLOffset);
+				new CEmuopl(gConfig.iOPLSampleRate, true, false),
+				new CEmuopl(gConfig.iOPLSampleRate, true, false),
+				true, gConfig.iOPLSampleRate, gConfig.dSurroundOPLOffset);
 #endif
 			break;
 		}
 	}
 	else
 	{
-		switch (gpGlobals->eOPLType)
+		switch (gConfig.eOPLType)
 		{
 		case OPL_DOSBOX_OLD:
-			pRixPlayer->opl = new CDemuopl(gpGlobals->iOPLSampleRate, true, gpGlobals->iAudioChannels == 2);
+			pRixPlayer->opl = new CDemuopl(gConfig.iOPLSampleRate, true, gConfig.iAudioChannels == 2);
 			break;
 		case OPL_DOSBOX:
-			pRixPlayer->opl = new CDBemuopl(gpGlobals->iOPLSampleRate, true, gpGlobals->iAudioChannels == 2);
+			pRixPlayer->opl = new CDBemuopl(gConfig.iOPLSampleRate, true, gConfig.iAudioChannels == 2);
 			break;
 #if PAL_HAS_MAME
 		case OPL_MAME:
-			pRixPlayer->opl = new CEmuopl(gpGlobals->iOPLSampleRate, true, gpGlobals->iAudioChannels == 2);
+			pRixPlayer->opl = new CEmuopl(gConfig.iOPLSampleRate, true, gConfig.iAudioChannels == 2);
 			break;
 #endif
 		}
@@ -482,20 +482,20 @@ RIX_Init(
 		return NULL;
 	}
 
-	if (gpGlobals->iOPLSampleRate != gpGlobals->iSampleRate)
+	if (gConfig.iOPLSampleRate != gConfig.iSampleRate)
 	{
-		for (int i = 0; i < gpGlobals->iAudioChannels; i++)
+		for (int i = 0; i < gConfig.iAudioChannels; i++)
 		{
 			pRixPlayer->resampler[i] = resampler_create();
-			resampler_set_quality(pRixPlayer->resampler[i], SOUND_IsIntegerConversion(gpGlobals->iOPLSampleRate) ? RESAMPLER_QUALITY_MIN : gpGlobals->iResampleQuality);
-			resampler_set_rate(pRixPlayer->resampler[i], (double)gpGlobals->iOPLSampleRate / (double)gpGlobals->iSampleRate);
+			resampler_set_quality(pRixPlayer->resampler[i], SOUND_IsIntegerConversion(gConfig.iOPLSampleRate) ? RESAMPLER_QUALITY_MIN : gConfig.iResampleQuality);
+			resampler_set_rate(pRixPlayer->resampler[i], (double)gConfig.iOPLSampleRate / (double)gConfig.iSampleRate);
 		}
 	}
 
 #if USE_RIX_EXTRA_INIT
-	if (gpGlobals->pExtraFMRegs && gpGlobals->pExtraFMVals)
+	if (gConfig.pExtraFMRegs && gConfig.pExtraFMVals)
 	{
-		pRixPlayer->rix->set_extra_init(gpGlobals->pExtraFMRegs, gpGlobals->pExtraFMVals, gpGlobals->dwExtraLength);
+		pRixPlayer->rix->set_extra_init(gConfig.pExtraFMRegs, gConfig.pExtraFMVals, gConfig.dwExtraLength);
 	}
 #endif
 

+ 14 - 14
script.c

@@ -567,15 +567,15 @@ PAL_AdditionalCredits(
 	  if (wcsncmp(rgszStrings[i], L"%ls", 3) == 0)
 	  {
 		  // We've limited the length of g_rcCredits[i] in text.c, so no need to double check here.
-		  wcscpy(buffer, gpGlobals->pszMsgName ? g_rcCredits[i] : rgszcps[i][gpGlobals->iCodePage]);
+		  wcscpy(buffer, gConfig.pszMsgName ? g_rcCredits[i] : rgszcps[i][gpGlobals->iCodePage]);
 		  wcscat(buffer, rgszStrings[i] + 3);
 	  }
 	  else
 		  wcscpy(buffer, rgszStrings[i]);
 #else
-	  swprintf(buffer, 48, rgszStrings[i], gpGlobals->pszMsgName ? g_rcCredits[i] : rgszcps[i][gpGlobals->iCodePage]);
+	  swprintf(buffer, 48, rgszStrings[i], gConfig.pszMsgName ? g_rcCredits[i] : rgszcps[i][gConfig.iCodePage]);
 #endif
-	  PAL_DrawText(buffer, PAL_XY(0, 2 + i * 16), DESCTEXT_COLOR, TRUE, FALSE);
+	  PAL_DrawText(buffer, PAL_XY(0, 2 + i * 16), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
    }
 
    PAL_SetPalette(0, FALSE);
@@ -2146,7 +2146,7 @@ PAL_InterpretInstruction(
       //
       // Show FBP picture
       //
-      if (gpGlobals->fIsWIN95)
+      if (gConfig.fIsWIN95)
 	  {
          SDL_FillRect(gpScreen, NULL, 0);
          VIDEO_UpdateScreen(NULL);
@@ -2636,7 +2636,7 @@ PAL_InterpretInstruction(
       //
       // Show the ending animation
       //
-      if (!gpGlobals->fIsWIN95)
+      if (!gConfig.fIsWIN95)
          PAL_EndingAnimation();
       break;
 
@@ -2905,7 +2905,7 @@ PAL_InterpretInstruction(
       //
       // Quit game
       //
-      if (gpGlobals->fIsWIN95)
+      if (gConfig.fIsWIN95)
          PAL_EndingScreen();
       PAL_AdditionalCredits();
       PAL_Shutdown();
@@ -2951,7 +2951,7 @@ PAL_InterpretInstruction(
       //
       // Scroll FBP to the screen
       //
-      if (!gpGlobals->fIsWIN95)
+      if (!gConfig.fIsWIN95)
 	  {
          if (pScript->rgwOperand[0] == 68)
          {
@@ -2972,7 +2972,7 @@ PAL_InterpretInstruction(
       //
       // Show FBP picture with sprite effects
       //
-      if (!gpGlobals->fIsWIN95)
+      if (!gConfig.fIsWIN95)
 	  {
          if (pScript->rgwOperand[1] != 0xFFFF)
          {
@@ -3302,7 +3302,7 @@ PAL_RunTriggerScript(
          //
          // Print dialog text
          //
-         if (gpGlobals->pszMsgName)
+         if (gConfig.pszMsgName)
          {
             int idx = 0, iMsg;
             while ((iMsg = PAL_GetMsgNum(pScript->rgwOperand[0], idx++)) >= 0)
@@ -3468,20 +3468,20 @@ begin:
       break;
 
    case 0xFFFF:
-	   if (gpGlobals->fIsWIN95)
+	   if (gConfig.fIsWIN95)
 	   {
 		   int XBase = (wEventObjectID & PAL_ITEM_DESC_BOTTOM) ? 75 : 100;
-		   int YBase = (wEventObjectID & PAL_ITEM_DESC_BOTTOM) ? 150 - gpGlobals->dwExtraItemDescLines * 16 : 3;
+		   int YBase = (wEventObjectID & PAL_ITEM_DESC_BOTTOM) ? 150 - gConfig.dwExtraItemDescLines * 16 : 3;
 		   int iDescLine = (wEventObjectID & ~PAL_ITEM_DESC_BOTTOM);
 
-		   if (gpGlobals->pszMsgName)
+		   if (gConfig.pszMsgName)
 		   {
 			   int idx = 0, iMsg;
 			   while ((iMsg = PAL_GetMsgNum(pScript->rgwOperand[0], idx++)) >= 0)
 			   {
 				   if (iMsg > 0)
 				   {
-					   PAL_DrawText(PAL_GetMsg(iMsg), PAL_XY(XBase, iDescLine * 16 + YBase), DESCTEXT_COLOR, TRUE, FALSE);
+					   PAL_DrawText(PAL_GetMsg(iMsg), PAL_XY(XBase, iDescLine * 16 + YBase), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
 					   iDescLine++;
 				   }
 			   }
@@ -3495,7 +3495,7 @@ begin:
 		   }
 		   else
 		   {
-			   PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(XBase, iDescLine * 16 + YBase), DESCTEXT_COLOR, TRUE, FALSE);
+			   PAL_DrawText(PAL_GetMsg(pScript->rgwOperand[0]), PAL_XY(XBase, iDescLine * 16 + YBase), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
 			   wScriptEntry++;
 		   }
 	   }

+ 22 - 31
sound.c

@@ -25,11 +25,8 @@
 #include "players.h"
 #include "util.h"
 #include "resampler.h"
-#include <math.h>
-
-#if PAL_HAS_NATIVEMIDI
 #include "midi.h"
-#endif
+#include <math.h>
 
 #if PAL_HAS_OGG
 #include <vorbis/codec.h>
@@ -496,7 +493,7 @@ SOUND_FillAudio(
       // Mix as much data as possible
       //
       len = (len > gSndPlayer.audio_len[i]) ? gSndPlayer.audio_len[i] : len;
-      SDL_MixAudio(stream, gSndPlayer.pos[i], len, gpGlobals->iVolume);
+      SDL_MixAudio(stream, gSndPlayer.pos[i], len, gConfig.iVolume);
       gSndPlayer.pos[i] += len;
       gSndPlayer.audio_len[i] -= len;
    }
@@ -526,7 +523,7 @@ SOUND_LoadMKF(
 	FNLoadSoundData func[2];
 	int i;
 
-	if (gpGlobals->fIsWIN95)
+	if (gConfig.fIsWIN95)
 	{
 		mkfs[0] = "sounds.mkf"; func[0] = SOUND_LoadWAVEData;
 		mkfs[1] = "voc.mkf"; func[1] = SOUND_LoadVOCData;
@@ -597,10 +594,10 @@ SOUND_OpenAudio(
    //
    // Open the sound subsystem.
    //
-   gSndPlayer.spec.freq = gpGlobals->iSampleRate;
+   gSndPlayer.spec.freq = gConfig.iSampleRate;
    gSndPlayer.spec.format = AUDIO_S16;
-   gSndPlayer.spec.channels = gpGlobals->iAudioChannels;
-   gSndPlayer.spec.samples = gpGlobals->wAudioBufferSize;
+   gSndPlayer.spec.channels = gConfig.iAudioChannels;
+   gSndPlayer.spec.samples = gConfig.wAudioBufferSize;
    gSndPlayer.spec.callback = SOUND_FillAudio;
 
    if (SDL_OpenAudio(&gSndPlayer.spec, &spec) < 0)
@@ -627,7 +624,7 @@ SOUND_OpenAudio(
    //
    // Initialize the music subsystem.
    //
-   switch (gpGlobals->eMusicType)
+   switch (gConfig.eMusicType)
    {
    case MUSIC_RIX:
 	   if (!(gSndPlayer.pMusPlayer = RIX_Init(va("%s%s", PAL_PREFIX, "mus.mkf"))))
@@ -657,7 +654,7 @@ SOUND_OpenAudio(
    //
    // Initialize the CD audio.
    //
-   switch (gpGlobals->eCDType)
+   switch (gConfig.eCDType)
    {
    case MUSIC_SDLCD:
    {
@@ -728,9 +725,10 @@ SOUND_CloseAudio(
 
 --*/
 {
-   SDL_mutexP(gSndPlayer.mtx);
    SDL_CloseAudio();
 
+   SDL_mutexP(gSndPlayer.mtx);
+
    if (gSndPlayer.buf[0] != NULL)
    {
       free(gSndPlayer.buf[0]);
@@ -769,9 +767,7 @@ SOUND_CloseAudio(
    }
 #endif
 
-#if PAL_HAS_NATIVEMIDI
-   MIDI_Play(0, FALSE);
-#endif
+   if (gConfig.eMusicType == MUSIC_MIDI) MIDI_Play(0, FALSE);
 
    if (gSndPlayer.resampler)
    {
@@ -812,18 +808,18 @@ SOUND_AdjustVolume(
 {
    if (iDirection > 0)
    {
-      gpGlobals->iVolume += SDL_MIX_MAXVOLUME * 0.03;
-      if (gpGlobals->iVolume > SDL_MIX_MAXVOLUME)
+      gConfig.iVolume += SDL_MIX_MAXVOLUME * 0.03;
+      if (gConfig.iVolume > SDL_MIX_MAXVOLUME)
       {
-		  gpGlobals->iVolume = SDL_MIX_MAXVOLUME;
+		  gConfig.iVolume = SDL_MIX_MAXVOLUME;
       }
    }
    else
    {
-      gpGlobals->iVolume -= SDL_MIX_MAXVOLUME * 0.03;
-      if (gpGlobals->iVolume < 0)
+      gConfig.iVolume -= SDL_MIX_MAXVOLUME * 0.03;
+      if (gConfig.iVolume < 0)
       {
-		  gpGlobals->iVolume = 0;
+		  gConfig.iVolume = 0;
       }
    }
 }
@@ -907,7 +903,7 @@ SOUND_PlayChannel(
    if (wavespec.freq != gSndPlayer.spec.freq)
    {
 	   /* Resampler is needed */
-	   resampler_set_quality(gSndPlayer.resampler, SOUND_IsIntegerConversion(wavespec.freq) ? RESAMPLER_QUALITY_MIN : gpGlobals->iResampleQuality);
+	   resampler_set_quality(gSndPlayer.resampler, SOUND_IsIntegerConversion(wavespec.freq) ? RESAMPLER_QUALITY_MIN : gConfig.iResampleQuality);
 	   resampler_set_rate(gSndPlayer.resampler, (double)wavespec.freq / (double)gSndPlayer.spec.freq);
 	   len = (int)ceil(wavespec.size * (double)gSndPlayer.spec.freq / (double)wavespec.freq) * (SDL_AUDIO_BITSIZE(AUDIO_S16) / SDL_AUDIO_BITSIZE(wavespec.format));
 	   if (len >= wavespec.channels * 2 && (bufdec = malloc(len)))
@@ -981,19 +977,14 @@ SOUND_PlayMUS(
    FLOAT     flFadeTime
 )
 {
-	SDL_mutexP(gSndPlayer.mtx);
-
-#if PAL_HAS_NATIVEMIDI
-   if (gpGlobals->eMusicType == MUSIC_MIDI)
+   SDL_mutexP(gSndPlayer.mtx);
+   if (gConfig.eMusicType == MUSIC_MIDI)
    {
       MIDI_Play(iNumRIX, fLoop);
-      return;
    }
-#endif
-
-   if (gSndPlayer.pMusPlayer)
+   else if (gSndPlayer.pMusPlayer)
    {
-	   gSndPlayer.pMusPlayer->Play(gSndPlayer.pMusPlayer, iNumRIX, fLoop, flFadeTime);
+      gSndPlayer.pMusPlayer->Play(gSndPlayer.pMusPlayer, iNumRIX, fLoop, flFadeTime);
    }
    SDL_mutexV(gSndPlayer.mtx);
 }

+ 1 - 1
sound.h

@@ -88,7 +88,7 @@ extern int g_iCurrChannel;
 extern BOOL       g_fNoSound;
 extern BOOL       g_fNoMusic;
 
-#define SOUND_IsIntegerConversion(a) ((((a) % gpGlobals->iSampleRate) | (gpGlobals->iSampleRate % (a))) == 0)
+#define SOUND_IsIntegerConversion(a) ((((a) % gConfig.iSampleRate) | (gConfig.iSampleRate % (a))) == 0)
 
 #ifdef __cplusplus
 }

+ 61 - 38
text.c

@@ -197,7 +197,8 @@ PAL_ReadMessageFile(
 		ST_OUTSIDE,
 		ST_DIALOG,
 		ST_WORD,
-		ST_CREDIT
+		ST_CREDIT,
+		ST_LAYOUT
 	} state = ST_OUTSIDE;
 	int idx_cnt = 0, msg_cnt = 0, word_cnt = 0, sid, eid = -1;
 #ifndef PAL_CLASSIC
@@ -250,6 +251,11 @@ PAL_ReadMessageFile(
 					{
 						state = ST_CREDIT;
 					}
+					else if (strncmp(buffer, "[BEGIN LAYOUT]", 14) == 0 && !witem)
+					{
+						state = ST_LAYOUT;
+						gConfig.fUseCustomMenuLayout = TRUE;
+					}
 					else
 					{
 						// Just ignore invalid lines
@@ -384,6 +390,28 @@ PAL_ReadMessageFile(
 					}
 				}
 				break;
+			case ST_LAYOUT:
+				if (strncmp(buffer, "[END LAYOUT]", 12) == 0)
+				{
+					// End layout
+					state = ST_OUTSIDE;
+				}
+				else
+				{
+					char *v;
+					int x, y, f, n, l, i = PAL_ParseLine(buffer, &v, &l, FALSE);
+					if (i >= 1 && i <= 26)
+					{
+						PAL_POS *poses = &gConfig.MenuLayout.ImageBox;
+						if ((n = sscanf(v, "%d,%d,%d", &x, &y, &f)) >= 2 &&
+							x >= 0 && y >= 0 && x < 320 && y < 200)
+						{
+							poses[i - 1] = PAL_XY(x, y);
+							if (n == 3) gConfig.MenuLayoutFlag[i - 1] = f;
+						}
+					}
+				}
+				break;
 			default:
 				TerminateOnError("PAL_ReadMessageFile(): Reached an unknown state. Something really wrong may have happened!");
 				break;
@@ -486,12 +514,12 @@ PAL_InitText(
 
 --*/
 {
-   if (gpGlobals->pszMsgName)
+   if (gConfig.pszMsgName)
    {
 	   //
 	   // Open the message, index and word data files.
 	   //
-	   FILE *fp = UTIL_OpenRequiredFileForMode(gpGlobals->pszMsgName, "r");
+	   FILE *fp = UTIL_OpenRequiredFileForMode(gConfig.pszMsgName, "r");
 
 	   //
 	   // Read the contents of the message, index and word data files.
@@ -514,7 +542,7 @@ PAL_InitText(
 				   if (dwWordLength < n) dwWordLength = n;
 			   }
 		   }
-		   gpGlobals->dwWordLength = dwWordLength;
+		   gConfig.dwWordLength = dwWordLength;
 		   for (i = 0; i < 12; i++)
 		   {
 			   if (!g_rcCredits[i])
@@ -543,9 +571,9 @@ PAL_InitText(
 	   i = ftell(fpWord);
 
 	   //
-	   // Each word has 10 or 16 bytes
+	   // Each word has 10 bytes
 	   //
-	   g_TextLib.nWords = (i + (gpGlobals->dwWordLength - 1)) / gpGlobals->dwWordLength;
+	   g_TextLib.nWords = (i + (gConfig.dwWordLength - 1)) / gConfig.dwWordLength;
 
 	   //
 	   // Read the words
@@ -568,10 +596,10 @@ PAL_InitText(
 	   // Split the words and do code page conversion
 	   for (i = 0, wlen = 0; i < g_TextLib.nWords; i++)
 	   {
-		   int base = i * gpGlobals->dwWordLength;
-		   int pos = base + gpGlobals->dwWordLength - 1;
+		   int base = i * gConfig.dwWordLength;
+		   int pos = base + gConfig.dwWordLength - 1;
 		   while (pos >= base && temp[pos] == ' ') temp[pos--] = 0;
-		   wlen += PAL_MultiByteToWideChar((LPCSTR)temp + base, gpGlobals->dwWordLength, NULL, 0) + 1;
+		   wlen += PAL_MultiByteToWideChar((LPCSTR)temp + base, gConfig.dwWordLength, NULL, 0) + 1;
 	   }
 	   g_TextLib.lpWordBuf = (LPWSTR*)malloc(g_TextLib.nWords * sizeof(LPWSTR));
 	   if (g_TextLib.lpWordBuf == NULL)
@@ -594,7 +622,7 @@ PAL_InitText(
 	   {
 		   int l;
 		   g_TextLib.lpWordBuf[i] = tmp + wpos;
-		   l = PAL_MultiByteToWideChar((LPCSTR)temp + i * gpGlobals->dwWordLength, gpGlobals->dwWordLength, g_TextLib.lpWordBuf[i], wlen - wpos);
+		   l = PAL_MultiByteToWideChar((LPCSTR)temp + i * gConfig.dwWordLength, gConfig.dwWordLength, g_TextLib.lpWordBuf[i], wlen - wpos);
 		   if (l > 0 && g_TextLib.lpWordBuf[i][l - 1] == '1')
 			   g_TextLib.lpWordBuf[i][l - 1] = 0;
 		   g_TextLib.lpWordBuf[i][l] = 0;
@@ -714,7 +742,7 @@ PAL_FreeText(
    int i;
    if (g_TextLib.lpMsgBuf != NULL)
    {
-      if (gpGlobals->pszMsgName)
+      if (gConfig.pszMsgName)
          for(i = 0; i < g_TextLib.nMsgs; i++) free(g_TextLib.lpMsgBuf[i]);
       else
          free(g_TextLib.lpMsgBuf[0]);
@@ -723,7 +751,7 @@ PAL_FreeText(
    }
    if (g_TextLib.lpWordBuf != NULL)
    {
-      if (gpGlobals->pszMsgName)
+      if (gConfig.pszMsgName)
          for(i = 0; i < g_TextLib.nWords; i++) free(g_TextLib.lpWordBuf[i]);
       else
          free(g_TextLib.lpWordBuf[0]);
@@ -732,7 +760,7 @@ PAL_FreeText(
    }
    if (g_TextLib.lpIndexBuf != NULL)
    {
-      if (gpGlobals->pszMsgName)
+      if (gConfig.pszMsgName)
          for(i = 0; i < g_TextLib.nIndices; i++) free(g_TextLib.lpIndexBuf[i]);
       else
          free(g_TextLib.lpIndexBuf[0]);
@@ -820,7 +848,8 @@ PAL_DrawText(
    PAL_POS    pos,
    BYTE       bColor,
    BOOL       fShadow,
-   BOOL       fUpdate
+   BOOL       fUpdate,
+   BOOL       fUse8x8Font
 )
 /*++
   Purpose:
@@ -839,6 +868,8 @@ PAL_DrawText(
 
     [IN]  fUpdate - TRUE if update the screen area.
 
+	[IN]  fUse8x8Font - TRUE if use 8x8 font.
+
   Return value:
 
     None.
@@ -847,12 +878,9 @@ PAL_DrawText(
 {
    SDL_Rect   rect, urect;
 
-   rect.x = PAL_X(pos);
-   rect.y = PAL_Y(pos);
-
-   urect.x = rect.x;
-   urect.y = rect.y;
-   urect.h = gpGlobals->fUseEmbeddedFonts ? 16 : 17;
+   urect.x = rect.x = PAL_X(pos);
+   urect.y = rect.y = PAL_Y(pos);
+   urect.h = (fUse8x8Font ? 8 : PAL_FontHeight()) + (fShadow ? 1 : 0);
    urect.w = 0;
 
    while (*lpszText)
@@ -860,17 +888,15 @@ PAL_DrawText(
       //
       // Draw the character
       //
-	  int char_width = PAL_CharWidth(*lpszText);
+	  int char_width = fUse8x8Font ? 8 : PAL_CharWidth(*lpszText);
 
       if (fShadow)
       {
-		  PAL_DrawCharOnSurface(*lpszText, gpScreen, PAL_XY(rect.x + 1, rect.y + 1), 0);
-		  PAL_DrawCharOnSurface(*lpszText, gpScreen, PAL_XY(rect.x + 1, rect.y), 0);
+		  PAL_DrawCharOnSurface(*lpszText, gpScreen, PAL_XY(rect.x + 1, rect.y + 1), 0, fUse8x8Font);
+		  PAL_DrawCharOnSurface(*lpszText, gpScreen, PAL_XY(rect.x + 1, rect.y), 0, fUse8x8Font);
       }
-	  PAL_DrawCharOnSurface(*lpszText, gpScreen, PAL_XY(rect.x, rect.y), bColor);
-      lpszText++;
-	  rect.x += char_width;
-	  urect.w += char_width;
+	  PAL_DrawCharOnSurface(*lpszText++, gpScreen, PAL_XY(rect.x, rect.y), bColor, fUse8x8Font);
+	  rect.x += char_width; urect.w += char_width;
    }
 
    //
@@ -878,13 +904,10 @@ PAL_DrawText(
    //
    if (fUpdate && urect.w > 0)
    {
-      if (gpGlobals->fIsWIN95)
-	  {
-         urect.w++;
-         if (urect.x + urect.w > 320)
-         {
-            urect.w = 320 - urect.x;
-         }
+      if (fShadow) urect.w++;
+      if (urect.x + urect.w > 320)
+      {
+         urect.w = 320 - urect.x;
       }
       VIDEO_UpdateScreen(&urect);
    }
@@ -1215,7 +1238,7 @@ PAL_ShowDialogText(
          // Show the text on the screen
          //
          pos = PAL_XY(PAL_X(pos) + 8 + ((len & 1) << 2), PAL_Y(pos) + 10);
-         PAL_DrawText(lpszText, pos, 0, FALSE, FALSE);
+         PAL_DrawText(lpszText, pos, 0, FALSE, FALSE, FALSE);
          VIDEO_UpdateScreen(&rect);
 
          PAL_DialogWaitForKey();
@@ -1242,7 +1265,7 @@ PAL_ShowDialogText(
          //
          // name of character
          //
-         PAL_DrawText(lpszText, g_TextLib.posDialogTitle, FONT_COLOR_CYAN_ALT, TRUE, TRUE);
+         PAL_DrawText(lpszText, g_TextLib.posDialogTitle, FONT_COLOR_CYAN_ALT, TRUE, TRUE, FALSE);
       }
       else
       {
@@ -1349,7 +1372,7 @@ PAL_ShowDialogText(
                text[0] = *lpszText++;
 			   text[1] = 0;
 
-               PAL_DrawText(text, PAL_XY(x, y), g_TextLib.bCurrentFontColor, TRUE, TRUE);
+               PAL_DrawText(text, PAL_XY(x, y), g_TextLib.bCurrentFontColor, TRUE, TRUE, FALSE);
 			   x += PAL_CharWidth(text[0]);
 
                if (!g_TextLib.fUserSkip)
@@ -1771,7 +1794,7 @@ PAL_MultiByteToWideChar(
 
 --*/
 {
-	return PAL_MultiByteToWideCharCP(gpGlobals->iCodePage, mbs, mbslength, wcs, wcslength);
+	return PAL_MultiByteToWideCharCP(gConfig.iCodePage, mbs, mbslength, wcs, wcslength);
 }
 
 WCHAR

+ 2 - 1
text.h

@@ -70,7 +70,8 @@ PAL_DrawText(
    PAL_POS    pos,
    BYTE       bColor,
    BOOL       fShadow,
-   BOOL       fUpdate
+   BOOL       fUpdate,
+   BOOL       fUse8x8Font
 );
 
 VOID

+ 13 - 14
ui.c

@@ -431,8 +431,7 @@ PAL_ReadMenu(
          }
       }
 
-      PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos,
-         bColor, TRUE, TRUE);
+      PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos, bColor, TRUE, TRUE, FALSE);
    }
 
    if (lpfnMenuItemChanged != NULL)
@@ -450,7 +449,7 @@ PAL_ReadMenu(
       if (rgMenuItem[wCurrentItem].fEnabled)
       {
          PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-            rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
+            rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE, FALSE);
       }
 
       PAL_ProcessEvent();
@@ -466,12 +465,12 @@ PAL_ReadMenu(
             // Dehighlight the unselected item.
             //
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE, FALSE);
          }
          else
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE, FALSE);
          }
 
          wCurrentItem++;
@@ -487,12 +486,12 @@ PAL_ReadMenu(
          if (rgMenuItem[wCurrentItem].fEnabled)
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE, FALSE);
          }
          else
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE, FALSE);
          }
 
          if (lpfnMenuItemChanged != NULL)
@@ -511,12 +510,12 @@ PAL_ReadMenu(
             // Dehighlight the unselected item.
             //
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE, FALSE);
          }
          else
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE, FALSE);
          }
 
          if (wCurrentItem > 0)
@@ -534,12 +533,12 @@ PAL_ReadMenu(
          if (rgMenuItem[wCurrentItem].fEnabled)
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE, FALSE);
          }
          else
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE, FALSE);
          }
 
          if (lpfnMenuItemChanged != NULL)
@@ -555,12 +554,12 @@ PAL_ReadMenu(
          if (rgMenuItem[wCurrentItem].fEnabled)
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE, FALSE);
          }
          else
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE, FALSE);
          }
 
          break;
@@ -573,7 +572,7 @@ PAL_ReadMenu(
          if (rgMenuItem[wCurrentItem].fEnabled)
          {
             PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
-               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_CONFIRMED, FALSE, TRUE);
+               rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_CONFIRMED, FALSE, TRUE, FALSE);
 
             return rgMenuItem[wCurrentItem].wValue;
          }

+ 8 - 1
ui.h

@@ -49,7 +49,7 @@ extern "C"
 
 #define DESCTEXT_COLOR                     0x2E
 
-#define MAINMENU_BACKGROUND_FBPNUM         (gpGlobals->fIsWIN95 ? 2 :60)
+#define MAINMENU_BACKGROUND_FBPNUM         (gConfig.fIsWIN95 ? 2 :60)
 
 #define RIX_NUM_OPENINGMENU                4
 #define MAINMENU_LABEL_NEWGAME             7
@@ -98,6 +98,13 @@ extern "C"
 #define STATUS_LABEL_FLEERATE              55
 #define STATUS_COLOR_EQUIPMENT             0xBE
 
+#define EQUIP_LABEL_HEAD                   566
+#define EQUIP_LABEL_SHOULDER               567
+#define EQUIP_LABEL_BODY                   568
+#define EQUIP_LABEL_HAND                   569
+#define EQUIP_LABEL_FOOT                   570
+#define EQUIP_LABEL_NECK                   571
+
 #define BUYMENU_LABEL_CURRENT              35
 #define SELLMENU_LABEL_PRICE               25
 

+ 4 - 6
uibattle.c

@@ -250,7 +250,7 @@ PAL_PlayerInfoBox(
          {
             PAL_DrawText(PAL_GetWord(rgwStatusWord[i]),
                PAL_XY(PAL_X(pos) + rgStatusPos[i][0], PAL_Y(pos) + rgStatusPos[i][1]),
-               rgbStatusColor[i], TRUE, FALSE);
+               rgbStatusColor[i], TRUE, FALSE, FALSE);
          }
       }
    }
@@ -407,8 +407,7 @@ PAL_BattleUIDrawMiscMenu(
          }
       }
 
-      PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos, bColor,
-         TRUE, FALSE);
+      PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos, bColor, TRUE, FALSE, FALSE);
    }
 }
 
@@ -517,8 +516,7 @@ PAL_BattleUIMiscItemSubMenuUpdate(
          bColor = MENUITEM_COLOR_SELECTED;
       }
 
-      PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos, bColor,
-         TRUE, FALSE);
+      PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos, bColor, TRUE, FALSE, FALSE);
    }
 
    //
@@ -816,7 +814,7 @@ PAL_BattleUIUpdate(
       else
       {
          PAL_DrawText(PAL_GetWord(BATTLEUI_LABEL_AUTO), PAL_XY(280, 10),
-            MENUITEM_COLOR_CONFIRMED, TRUE, FALSE);
+            MENUITEM_COLOR_CONFIRMED, TRUE, FALSE, FALSE);
       }
    }
 

+ 90 - 54
uigame.c

@@ -466,7 +466,7 @@ PAL_ShowCash(
    //
    // Draw the text label.
    //
-   PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(10, 10), 0, FALSE, FALSE);
+   PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(10, 10), 0, FALSE, FALSE, FALSE);
 
    //
    // Draw the cash amount.
@@ -630,8 +630,7 @@ PAL_SystemMenu(
       // Music
       //
       g_fNoMusic = !PAL_SwitchMenu(!g_fNoMusic);
-#if PAL_HAS_NATIVEMIDI
-      if (gpGlobals->eMusicType == MUSIC_MIDI)
+      if (gConfig.eMusicType == MUSIC_MIDI)
       {
          if (g_fNoMusic)
          {
@@ -642,7 +641,6 @@ PAL_SystemMenu(
             SOUND_PlayMUS(gpGlobals->wNumMusic, TRUE, 0);
          }
       }
-#endif
       break;
 
    case 4:
@@ -1112,18 +1110,18 @@ PAL_PlayerStatus(
       //
       // Draw the text labels
       //
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_EXP), PAL_XY(6, 6), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(6, 32), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_HP), PAL_XY(6, 54), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_MP), PAL_XY(6, 76), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_ATTACKPOWER), PAL_XY(6, 98), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_MAGICPOWER), PAL_XY(6, 118), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_RESISTANCE), PAL_XY(6, 138), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_DEXTERITY), PAL_XY(6, 158), MENUITEM_COLOR, TRUE, FALSE);
-      PAL_DrawText(PAL_GetWord(STATUS_LABEL_FLEERATE), PAL_XY(6, 178), MENUITEM_COLOR, TRUE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_EXP), PAL_XY(6, 6), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(6, 32), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_HP), PAL_XY(6, 54), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_MP), PAL_XY(6, 76), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_ATTACKPOWER), PAL_XY(6, 98), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_MAGICPOWER), PAL_XY(6, 118), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_RESISTANCE), PAL_XY(6, 138), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_DEXTERITY), PAL_XY(6, 158), MENUITEM_COLOR, TRUE, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(STATUS_LABEL_FLEERATE), PAL_XY(6, 178), MENUITEM_COLOR, TRUE, FALSE, FALSE);
 
       PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[iPlayerRole]),
-         PAL_XY(110, 8), MENUITEM_COLOR_CONFIRMED, TRUE, FALSE);
+         PAL_XY(110, 8), MENUITEM_COLOR_CONFIRMED, TRUE, FALSE, FALSE);
 
       //
       // Draw the stats
@@ -1194,8 +1192,7 @@ PAL_PlayerStatus(
          {
             offset = 0;
          }
-         PAL_DrawText(PAL_GetWord(w),
-            PAL_XY(rgEquipPos[i][0] + offset + 5, rgEquipPos[i][1] + 38), STATUS_COLOR_EQUIPMENT, TRUE, FALSE);
+         PAL_DrawText(PAL_GetWord(w), PAL_XY(rgEquipPos[i][0] + offset + 5, rgEquipPos[i][1] + 38), STATUS_COLOR_EQUIPMENT, TRUE, FALSE, FALSE);
       }
 
       //
@@ -1219,8 +1216,7 @@ PAL_PlayerStatus(
          if (w != 0 &&
             gpGlobals->g.rgObject[w].poison.wPoisonLevel <= 3)
          {
-            PAL_DrawText(PAL_GetWord(w), PAL_XY(185, y),
-               (BYTE)(gpGlobals->g.rgObject[w].poison.wColor + 10), TRUE, FALSE);
+            PAL_DrawText(PAL_GetWord(w), PAL_XY(185, y), (BYTE)(gpGlobals->g.rgObject[w].poison.wColor + 10), TRUE, FALSE, FALSE);
 
             y += 18;
          }
@@ -1305,21 +1301,21 @@ PAL_ItemUseMenu(
       // Draw the stats of the selected player
       //
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_LEVEL), PAL_XY(200, 16),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_HP), PAL_XY(200, 34),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_MP), PAL_XY(200, 52),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_ATTACKPOWER), PAL_XY(200, 70),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_MAGICPOWER), PAL_XY(200, 88),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_RESISTANCE), PAL_XY(200, 106),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_DEXTERITY), PAL_XY(200, 124),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
       PAL_DrawText(PAL_GetWord(STATUS_LABEL_FLEERATE), PAL_XY(200, 142),
-         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE);
+         ITEMUSEMENU_COLOR_STATLABEL, TRUE, FALSE, FALSE);
 
       i = gpGlobals->rgParty[wSelectedPlayer].wPlayerRole;
 
@@ -1366,7 +1362,7 @@ PAL_ItemUseMenu(
          }
 
          PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[gpGlobals->rgParty[i].wPlayerRole]),
-            PAL_XY(125, 16 + 20 * i), bColor, TRUE, FALSE);
+            PAL_XY(125, 16 + 20 * i), bColor, TRUE, FALSE, FALSE);
       }
 
       PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_ITEMBOX), gpScreen,
@@ -1388,8 +1384,7 @@ PAL_ItemUseMenu(
          //
          // Draw the amount and label of the item
          //
-         PAL_DrawText(PAL_GetWord(wItemToUse), PAL_XY(116, 143), STATUS_COLOR_EQUIPMENT,
-            TRUE, FALSE);
+         PAL_DrawText(PAL_GetWord(wItemToUse), PAL_XY(116, 143), STATUS_COLOR_EQUIPMENT, TRUE, FALSE, FALSE);
          PAL_DrawNumber(i, 2, PAL_XY(170, 133), kNumColorCyan, kNumAlignRight);
       }
 
@@ -1427,7 +1422,7 @@ PAL_ItemUseMenu(
             //
             PAL_DrawText(
                PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[gpGlobals->rgParty[wSelectedPlayer].wPlayerRole]),
-               PAL_XY(125, 16 + 20 * wSelectedPlayer), bSelectedColor, FALSE, TRUE);
+               PAL_XY(125, 16 + 20 * wSelectedPlayer), bSelectedColor, FALSE, TRUE, FALSE);
          }
 
          PAL_ProcessEvent();
@@ -1528,14 +1523,14 @@ PAL_BuyMenu_OnItemChange(
    // Draw the amount of this item in the inventory
    //
    PAL_CreateSingleLineBox(PAL_XY(20, 105), 5, FALSE);
-   PAL_DrawText(PAL_GetWord(BUYMENU_LABEL_CURRENT), PAL_XY(30, 115), 0, FALSE, FALSE);
+   PAL_DrawText(PAL_GetWord(BUYMENU_LABEL_CURRENT), PAL_XY(30, 115), 0, FALSE, FALSE, FALSE);
    PAL_DrawNumber(n, 6, PAL_XY(69, 119), kNumColorYellow, kNumAlignRight);
 
    //
    // Draw the cash amount
    //
    PAL_CreateSingleLineBox(PAL_XY(20, 145), 5, FALSE);
-   PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(30, 155), 0, FALSE, FALSE);
+   PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(30, 155), 0, FALSE, FALSE, FALSE);
    PAL_DrawNumber(gpGlobals->dwCash, 6, PAL_XY(69, 159), kNumColorYellow, kNumAlignRight);
 
    VIDEO_UpdateScreen(&rect);
@@ -1663,7 +1658,7 @@ PAL_SellMenu_OnItemChange(
    // Draw the cash amount
    //
    PAL_CreateSingleLineBox(PAL_XY(100, 150), 5, FALSE);
-   PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(110, 160), 0, FALSE, FALSE);
+   PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(110, 160), 0, FALSE, FALSE, FALSE);
    PAL_DrawNumber(gpGlobals->dwCash, 6, PAL_XY(149, 164), kNumColorYellow, kNumAlignRight);
 
    //
@@ -1673,7 +1668,7 @@ PAL_SellMenu_OnItemChange(
 
    if (gpGlobals->g.rgObject[wCurrentItem].item.wFlags & kItemFlagSellable)
    {
-      PAL_DrawText(PAL_GetWord(SELLMENU_LABEL_PRICE), PAL_XY(230, 160), 0, FALSE, FALSE);
+      PAL_DrawText(PAL_GetWord(SELLMENU_LABEL_PRICE), PAL_XY(230, 160), 0, FALSE, FALSE, FALSE);
       PAL_DrawNumber(gpGlobals->g.rgObject[wCurrentItem].item.wPrice / 2, 6,
          PAL_XY(269, 164), kNumColorYellow, kNumAlignRight);
    }
@@ -1738,6 +1733,7 @@ PAL_EquipItemMenu(
 --*/
 {
    PAL_LARGE BYTE   bufBackground[320 * 200];
+   PAL_LARGE BYTE   bufImageBox[72 * 72];
    PAL_LARGE BYTE   bufImage[2048];
    WORD             w;
    int              iCurrentPlayer, i;
@@ -1749,6 +1745,34 @@ PAL_EquipItemMenu(
    PAL_MKFDecompressChunk(bufBackground, 320 * 200, EQUIPMENU_BACKGROUND_FBPNUM,
       gpGlobals->f.fpFBP);
 
+   if (gConfig.fUseCustomMenuLayout)
+   {
+      int x = PAL_X(gConfig.MenuLayout.ImageBox);
+      int y = PAL_Y(gConfig.MenuLayout.ImageBox);
+      for (i = 8; i < 72; i++)
+      {
+         memcpy(&bufBackground[i * 320 + 92], &bufBackground[(i + 128) * 320 + 92], 32);
+         memcpy(&bufBackground[(i + 64) * 320 + 92], &bufBackground[(i + 128) * 320 + 92], 32);
+      }
+      for (i = 9; i < 90; i++)
+      {
+         memcpy(&bufBackground[i * 320 + 226], &bufBackground[(i + 104) * 320 + 226], 32);
+      }
+      for (i = 99; i < 113; i++)
+      {
+         memcpy(&bufBackground[i * 320 + 226], &bufBackground[(i + 16) * 320 + 226], 32);
+      }
+      for (i = 8; i < 80; i++)
+      {
+         memcpy(&bufImageBox[(i - 8) * 72], &bufBackground[i * 320 + 8], 72);
+         memcpy(&bufBackground[i * 320 + 8], &bufBackground[(i + 72) * 320 + 8], 72);
+      }
+      for (i = 0; i < 72; i++)
+      {
+         memcpy(&bufBackground[(i + y) * 320 + x], &bufImageBox[i * 72], 72);
+      }
+   }
+
    iCurrentPlayer = 0;
    bSelectedColor = MENUITEM_COLOR_SELECTED_FIRST;
    dwColorChangeTime = SDL_GetTicks() + (600 / MENUITEM_COLOR_SELECTED_TOTALNUM);
@@ -1768,7 +1792,27 @@ PAL_EquipItemMenu(
       if (PAL_MKFReadChunk(bufImage, 2048,
          gpGlobals->g.rgObject[wItem].item.wBitmap, gpGlobals->f.fpBALL) > 0)
       {
-         PAL_RLEBlitToSurface(bufImage, gpScreen, PAL_XY(16, 16));
+         PAL_RLEBlitToSurface(bufImage, gpScreen, PAL_XY_OFFSET(gConfig.MenuLayout.ImageBox, 8, 8));
+      }
+
+      if (gConfig.fUseCustomMenuLayout)
+      {
+         int labels1[] = { STATUS_LABEL_ATTACKPOWER, STATUS_LABEL_MAGICPOWER, STATUS_LABEL_RESISTANCE, STATUS_LABEL_DEXTERITY, STATUS_LABEL_FLEERATE };
+         int labels2[] = { EQUIP_LABEL_HEAD, EQUIP_LABEL_SHOULDER, EQUIP_LABEL_BODY, EQUIP_LABEL_HAND, EQUIP_LABEL_FOOT, EQUIP_LABEL_NECK };
+		 for (i = 0; i < sizeof(labels1) / sizeof(int); i++)
+         {
+            int index = &gConfig.MenuLayout.StatusLabels[i] - gConfig.MenuLayoutArray;
+            BOOL fShadow = (gConfig.MenuLayoutFlag[index] & DISABLE_SHADOW) ? FALSE : TRUE;
+            BOOL fUse8x8Font = (gConfig.MenuLayoutFlag[index] & USE_8x8_FONT) ? TRUE : FALSE;
+            PAL_DrawText(PAL_GetWord(labels1[i]), gConfig.MenuLayoutArray[index], MENUITEM_COLOR, fShadow, FALSE, fUse8x8Font);
+         }
+		 for (i = 0; i < sizeof(labels2) / sizeof(int); i++)
+         {
+            int index = &gConfig.MenuLayout.EquipLabels[i] - gConfig.MenuLayoutArray;
+            BOOL fShadow = (gConfig.MenuLayoutFlag[index] & DISABLE_SHADOW) ? FALSE : TRUE;
+            BOOL fUse8x8Font = (gConfig.MenuLayoutFlag[index] & USE_8x8_FONT) ? TRUE : FALSE;
+            PAL_DrawText(PAL_GetWord(labels2[i]), gConfig.MenuLayoutArray[index], MENUITEM_COLOR, fShadow, FALSE, fUse8x8Font);
+         }
       }
 
       //
@@ -1780,28 +1824,23 @@ PAL_EquipItemMenu(
          if (gpGlobals->g.PlayerRoles.rgwEquipment[i][w] != 0)
          {
             PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwEquipment[i][w]),
-               PAL_XY(130, 11 + i * 22), MENUITEM_COLOR, TRUE, FALSE);
+				gConfig.MenuLayout.EquipNames[i], MENUITEM_COLOR, TRUE, FALSE, FALSE);
          }
       }
 
       //
       // Draw the stats of the currently selected player
       //
-      PAL_DrawNumber(PAL_GetPlayerAttackStrength(w), 4, PAL_XY(260, 14),
-         kNumColorCyan, kNumAlignRight);
-      PAL_DrawNumber(PAL_GetPlayerMagicStrength(w), 4, PAL_XY(260, 36),
-         kNumColorCyan, kNumAlignRight);
-      PAL_DrawNumber(PAL_GetPlayerDefense(w), 4, PAL_XY(260, 58),
-         kNumColorCyan, kNumAlignRight);
-      PAL_DrawNumber(PAL_GetPlayerDexterity(w), 4, PAL_XY(260, 80),
-         kNumColorCyan, kNumAlignRight);
-      PAL_DrawNumber(PAL_GetPlayerFleeRate(w), 4, PAL_XY(260, 102),
-         kNumColorCyan, kNumAlignRight);
+      PAL_DrawNumber(PAL_GetPlayerAttackStrength(w), 4, gConfig.MenuLayout.StatusValues[0], kNumColorCyan, kNumAlignRight);
+      PAL_DrawNumber(PAL_GetPlayerMagicStrength(w), 4, gConfig.MenuLayout.StatusValues[1], kNumColorCyan, kNumAlignRight);
+      PAL_DrawNumber(PAL_GetPlayerDefense(w), 4, gConfig.MenuLayout.StatusValues[2], kNumColorCyan, kNumAlignRight);
+      PAL_DrawNumber(PAL_GetPlayerDexterity(w), 4, gConfig.MenuLayout.StatusValues[3], kNumColorCyan, kNumAlignRight);
+      PAL_DrawNumber(PAL_GetPlayerFleeRate(w), 4, gConfig.MenuLayout.StatusValues[4], kNumColorCyan, kNumAlignRight);
 
       //
       // Draw a box for player selection
       //
-      PAL_CreateBox(PAL_XY(2, 95), gpGlobals->wMaxPartyMemberIndex, 2, 0, FALSE);
+      PAL_CreateBox(gConfig.MenuLayout.RoleListBox, gpGlobals->wMaxPartyMemberIndex, PAL_WordMaxWidth(36, 4) - 1, 0, FALSE);
 
       //
       // Draw the label of players
@@ -1834,7 +1873,7 @@ PAL_EquipItemMenu(
          }
 
          PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]),
-            PAL_XY(15, 108 + 18 * i), bColor, TRUE, FALSE);
+            PAL_XY_OFFSET(gConfig.MenuLayout.RoleListBox, 13, 13 + 18 * i), bColor, TRUE, FALSE, FALSE);
       }
 
       //
@@ -1842,11 +1881,8 @@ PAL_EquipItemMenu(
       //
       if (wItem != 0)
       {
-         PAL_DrawText(PAL_GetWord(wItem), PAL_XY(5, 70), MENUITEM_COLOR_CONFIRMED, TRUE, FALSE);
-		 if (gpGlobals->dwWordLength > 10)
-            PAL_DrawNumber(PAL_GetItemAmount(wItem), 2, PAL_XY(51, 57), kNumColorCyan, kNumAlignRight);
-         else
-            PAL_DrawNumber(PAL_GetItemAmount(wItem), 2, PAL_XY(65, 73), kNumColorCyan, kNumAlignRight);
+         PAL_DrawText(PAL_GetWord(wItem), gConfig.MenuLayout.ItemName, MENUITEM_COLOR_CONFIRMED, TRUE, FALSE, FALSE);
+         PAL_DrawNumber(PAL_GetItemAmount(wItem), 2, gConfig.MenuLayout.ItemAmount, kNumColorCyan, kNumAlignRight);
       }
 
       //
@@ -1888,7 +1924,7 @@ PAL_EquipItemMenu(
             if (gpGlobals->g.rgObject[wItem].item.wFlags & (kItemFlagEquipableByPlayerRole_First << w))
             {
                PAL_DrawText(PAL_GetWord(gpGlobals->g.PlayerRoles.rgwName[w]),
-                  PAL_XY(15, 108 + 18 * iCurrentPlayer), bSelectedColor, TRUE, TRUE);
+                  PAL_XY_OFFSET(gConfig.MenuLayout.RoleListBox, 13, 13 + 18 * iCurrentPlayer), bSelectedColor, TRUE, TRUE, FALSE);
             }
          }
 

+ 0 - 5
util.c

@@ -25,10 +25,7 @@
 #include "util.h"
 #include "input.h"
 
-#if PAL_HAS_NATIVEMIDI
 #include "midi.h"
-#endif
-
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 #include "SDL_video.h"
 #include "SDL_messagebox.h"
@@ -277,9 +274,7 @@ UTIL_Delay(
       while (PAL_PollEvent(NULL));
    }
 
-#if PAL_HAS_NATIVEMIDI
    MIDI_CheckLoop();
-#endif
 }
 
 void

+ 22 - 66
video.c

@@ -31,11 +31,10 @@ SDL_Surface              *gpScreenBak        = NULL;
 SDL_Window               *gpWindow           = NULL;
 static SDL_Renderer      *gpRenderer         = NULL;
 static SDL_Texture       *gpTexture          = NULL;
+# if PAL_HAS_TOUCH
 static SDL_Texture       *gpTouchOverlay     = NULL;
+# endif
 static SDL_Rect          *gpRenderRect       = NULL;
-#ifdef __WINPHONE__
-static SDL_Texture       *gpBackKeyMessage   = NULL;
-#endif
 static SDL_Rect           gRenderRect;
 #endif
 
@@ -79,15 +78,14 @@ VIDEO_Startup(
 --*/
 {
 #if SDL_VERSION_ATLEAST(2,0,0)
+# if PAL_HAS_TOUCH
    SDL_Surface *overlay;
-#endif
-
-#if SDL_VERSION_ATLEAST(2,0,0)
+# endif
    //
    // Before we can render anything, we need a window and a renderer.
    //
    gpWindow = SDL_CreateWindow("Pal", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
-      gpGlobals->dwScreenWidth, gpGlobals->dwScreenHeight, PAL_VIDEO_INIT_FLAGS);
+	   gConfig.dwScreenWidth, gConfig.dwScreenHeight, PAL_VIDEO_INIT_FLAGS);
 
    if (gpWindow == NULL)
    {
@@ -161,6 +159,7 @@ VIDEO_Startup(
    //
    // Create texture for overlay.
    //
+#if PAL_HAS_TOUCH
    overlay = SDL_LoadBMP(va("%s%s", PAL_PREFIX, "overlay.bmp"));
    if (overlay != NULL)
    {
@@ -169,15 +168,16 @@ VIDEO_Startup(
       SDL_SetTextureAlphaMod(gpTouchOverlay, 120);
       SDL_FreeSurface(overlay);
    }
+#endif
 
    //
    // Check whether to keep the aspect ratio
    //
    gpRenderRect = NULL;
-   if (gpGlobals->fKeepAspectRatio)
+   if (gConfig.fKeepAspectRatio)
    {
-	   float ax = (float)gpGlobals->dwScreenWidth / 320.0f;
-	   float ay = (float)gpGlobals->dwScreenHeight / 200.0f;
+	   float ax = (float)gConfig.dwScreenWidth / 320.0f;
+	   float ay = (float)gConfig.dwScreenHeight / 200.0f;
 	   if (ax != ay)
 	   {
 		   float ratio = (ax > ay) ? ay : ax;
@@ -185,52 +185,22 @@ VIDEO_Startup(
 		   WORD h = (WORD)(ratio * 200.0f);
 		   if (w % 4 != 0) w += 4 - (w % 4);
 		   if (h % 4 != 0) h += 4 - (h % 4);
-		   gRenderRect.x = (gpGlobals->dwScreenWidth - w) / 2;
-		   gRenderRect.y = (gpGlobals->dwScreenHeight - h) / 2;
+		   gRenderRect.x = (gConfig.dwScreenWidth - w) / 2;
+		   gRenderRect.y = (gConfig.dwScreenHeight - h) / 2;
 		   gRenderRect.w = w;
 		   gRenderRect.h = h;
 		   gpRenderRect = &gRenderRect;
 # if PAL_HAS_TOUCH
-		   PAL_SetTouchBounds(gpGlobals->dwScreenWidth, gpGlobals->dwScreenHeight, gRenderRect);
+		   PAL_SetTouchBounds(gConfig.dwScreenWidth, gConfig.dwScreenHeight, gRenderRect);
 # endif
 	   }
    }
-
-# ifdef __WINPHONE__
-   {
-      //
-      // Totally ugly hack to satisfy M$'s silly requirements.
-      // No need to understand this crap.
-      //
-      SDL_Color palette[256] = { { 0, 0, 0, 0 }, { 255, 255, 255, 255 } };
-      SDL_Surface *p = gpScreen;
-      SDL_FillRect(gpScreenBak, NULL, 0);
-      VIDEO_SetPalette(palette);
-      gpScreen = gpScreenBak;
-	  switch(gpGlobals->iCodePage)
-	  {
-	  case CP_BIG5:
-		  PAL_DrawText(L"\x518D\x6B21\x6309 Back \x7D50\x675F", PAL_XY(30, 30), 1, FALSE, FALSE);
-		  break;
-	  case CP_GBK:
-		  PAL_DrawText(L"\x518D\x6B21\x6309 Back \x7ED3\x675F", PAL_XY(30, 30), 1, FALSE, FALSE);
-		  break;
-	  case CP_SHIFTJIS:
-		  PAL_DrawText(L"\x7D42\x4E86\x3059\x308B\x306B\x306F\x3001\x3082\x3046\x4E00\x5EA6 Back \x30AD\x30FC", PAL_XY(30, 30), 1, FALSE, FALSE);
-		  PAL_DrawText(L"\x3092\x62BC\x3057\x3066\x304F\x3060\x3055\x3044", PAL_XY(30, 46), 1, FALSE, FALSE);
-		  break;
-	  }
-      gpScreen = p;
-      gpBackKeyMessage = SDL_CreateTextureFromSurface(gpRenderer, gpScreenBak);
-      SDL_FillRect(gpScreenBak, NULL, 0);
-   }
-# endif
 #else
 
    //
    // Create the screen surface.
    //
-   gpScreenReal = SDL_SetVideoMode(gpGlobals->dwScreenWidth, gpGlobals->dwScreenHeight, 8, PAL_VIDEO_INIT_FLAGS);
+   gpScreenReal = SDL_SetVideoMode(gConfig.dwScreenWidth, gConfig.dwScreenHeight, 8, PAL_VIDEO_INIT_FLAGS);
 
    if (gpScreenReal == NULL)
    {
@@ -238,7 +208,7 @@ VIDEO_Startup(
       // Fall back to 640x480 software mode.
       //
       gpScreenReal = SDL_SetVideoMode(640, 480, 8,
-         SDL_SWSURFACE | (gpGlobals->fFullScreen ? SDL_FULLSCREEN : 0));
+         SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0));
    }
 
    //
@@ -283,7 +253,7 @@ VIDEO_Startup(
       return -2;
    }
 
-   if (gpGlobals->fFullScreen)
+   if (gConfig.fFullScreen)
    {
       SDL_ShowCursor(FALSE);
    }
@@ -326,19 +296,13 @@ VIDEO_Shutdown(
 
 #if SDL_VERSION_ATLEAST(2,0,0)
 
+# if PAL_HAS_TOUCH
    if (gpTouchOverlay)
    {
       SDL_DestroyTexture(gpTouchOverlay);
    }
    gpTouchOverlay = NULL;
-
-#ifdef __WINPHONE__
-   if (gpBackKeyMessage)
-   {
-      SDL_DestroyTexture(gpBackKeyMessage);
-   }
-   gpBackKeyMessage = NULL;
-#endif
+# endif
 
    if (gpTexture)
    {
@@ -376,19 +340,11 @@ VIDEO_RenderCopy(
 {
    SDL_UpdateTexture(gpTexture, NULL, gpScreenReal->pixels, gpScreenReal->pitch);
    SDL_RenderCopy(gpRenderer, gpTexture, NULL, gpRenderRect);
+#if PAL_HAS_TOUCH
    if (gpTouchOverlay)
    {
       SDL_RenderCopy(gpRenderer, gpTouchOverlay, NULL, gpRenderRect);
    }
-#ifdef __WINPHONE__
-   if (gpBackKeyMessage)
-   {
-      extern unsigned int g_uiLastBackKeyTime;
-      if (g_uiLastBackKeyTime != 0 && !SDL_TICKS_PASSED(SDL_GetTicks(), g_uiLastBackKeyTime + 800))
-      {
-         SDL_RenderCopy(gpRenderer, gpBackKeyMessage, NULL, gpRenderRect);
-      }
-   }
 #endif
    SDL_RenderPresent(gpRenderer);
 }
@@ -778,17 +734,17 @@ VIDEO_ToggleFullscreen(
    //
    // ... and create a new one
    //
-   if (gpGlobals->dwScreenWidth == 640 && gpGlobals->dwScreenHeight == 400 && (flags & SDL_FULLSCREEN))
+   if (gConfig.dwScreenWidth == 640 && gConfig.dwScreenHeight == 400 && (flags & SDL_FULLSCREEN))
    {
       gpScreenReal = SDL_SetVideoMode(640, 480, 8, flags);
    }
-   else if (gpGlobals->dwScreenWidth == 640 && gpGlobals->dwScreenHeight == 480 && !(flags & SDL_FULLSCREEN))
+   else if (gConfig.dwScreenWidth == 640 && gConfig.dwScreenHeight == 480 && !(flags & SDL_FULLSCREEN))
    {
       gpScreenReal = SDL_SetVideoMode(640, 400, 8, flags);
    }
    else
    {
-      gpScreenReal = SDL_SetVideoMode(gpGlobals->dwScreenWidth, gpGlobals->dwScreenHeight, 8, flags);
+      gpScreenReal = SDL_SetVideoMode(gConfig.dwScreenWidth, gConfig.dwScreenHeight, 8, flags);
    }
 
    VIDEO_SetPalette(palette);