Browse Source

Move source files into src/, keeping compatibility with symbol links

LouYihua 7 years ago
parent
commit
4115facc0a
100 changed files with 51 additions and 90546 deletions
  1. 1 0
      adplug
  2. 0 442
      ascii.h
  3. 1 0
      ascii.h
  4. 0 604
      audio.c
  5. 1 0
      audio.c
  6. 0 100
      audio.h
  7. 1 0
      audio.h
  8. 0 1485
      battle.c
  9. 1 0
      battle.c
  10. 0 239
      battle.h
  11. 1 0
      battle.h
  12. 0 4177
      codepage.h
  13. 1 0
      codepage.h
  14. 0 233
      common.h
  15. 1 0
      common.h
  16. 0 515
      ending.c
  17. 1 0
      ending.c
  18. 0 61
      ending.h
  19. 1 0
      ending.h
  20. 0 4961
      fight.c
  21. 1 0
      fight.c
  22. 0 108
      fight.h
  23. 1 0
      fight.h
  24. 0 414
      font.c
  25. 1 0
      font.c
  26. 0 73
      font.h
  27. 1 0
      font.h
  28. 0 58920
      fontglyph.h
  29. 1 0
      fontglyph.h
  30. 0 129
      game.c
  31. 1 0
      game.c
  32. 0 35
      game.h
  33. 1 0
      game.h
  34. 0 2276
      global.c
  35. 1 0
      global.c
  36. 0 803
      global.h
  37. 1 0
      global.h
  38. 0 1099
      input.c
  39. 1 0
      input.c
  40. 0 108
      input.h
  41. 1 0
      input.h
  42. 0 467
      itemmenu.c
  43. 1 0
      itemmenu.c
  44. 0 49
      itemmenu.h
  45. 1 0
      itemmenu.h
  46. 1 0
      libmad
  47. 1 0
      liboggvorbis
  48. 0 478
      magicmenu.c
  49. 1 0
      magicmenu.c
  50. 0 52
      magicmenu.h
  51. 1 0
      magicmenu.h
  52. 0 565
      main.c
  53. 1 0
      main.c
  54. 0 59
      main.h
  55. 1 0
      main.h
  56. 0 418
      map.c
  57. 1 0
      map.c
  58. 0 139
      map.h
  59. 1 0
      map.h
  60. 0 140
      midi.c
  61. 1 0
      midi.c
  62. 0 52
      midi.h
  63. 1 0
      midi.h
  64. 0 162
      mp3play.c
  65. 1 0
      mp3play.c
  66. 1 0
      native_midi
  67. 0 514
      oggplay.c
  68. 1 0
      oggplay.c
  69. 0 5318
      overlay.c
  70. 1 0
      overlay.c
  71. 0 458
      palcfg.c
  72. 1 0
      palcfg.c
  73. 0 237
      palcfg.h
  74. 1 0
      palcfg.h
  75. 0 960
      palcommon.c
  76. 1 0
      palcommon.c
  77. 0 180
      palcommon.h
  78. 1 0
      palcommon.h
  79. 0 653
      palette.c
  80. 1 0
      palette.c
  81. 0 86
      palette.h
  82. 1 0
      palette.h
  83. 0 618
      play.c
  84. 1 0
      play.c
  85. 0 59
      play.h
  86. 1 0
      play.h
  87. 0 80
      players.h
  88. 1 0
      players.h
  89. 0 3
      private.c
  90. 1 0
      private.c
  91. 0 430
      res.c
  92. 1 0
      res.c
  93. 0 80
      res.h
  94. 1 0
      res.h
  95. 0 941
      resampler.c
  96. 1 0
      resampler.c
  97. 0 65
      resampler.h
  98. 1 0
      resampler.h
  99. 0 501
      rixplay.cpp
  100. 0 0
      rixplay.cpp

+ 1 - 0
adplug

@@ -0,0 +1 @@
+src/adplug

+ 0 - 442
ascii.h

@@ -1,442 +0,0 @@
-
-#ifndef _ASCII_H
-#define _ASCII_H
-
-#ifndef _FONT_C
-#error "This file should only be included inside font.c!"
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-	
-static unsigned char iso_font[] =
-{
-   /*
-    * Copyright (c) 2000
-    * Ka-Ping Yee <ping@lfw.org>
-    * This font may be freely used for any purpose.
-    */
-   /* 00 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 01 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 02 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 03 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 04 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 05 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 06 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 07 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 08 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 09 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 0A */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 0B */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 0C */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 0D */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 0E */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 0F */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 10 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 11 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 12 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 13 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 14 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 15 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 16 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 17 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 18 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 19 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 1A */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 1B */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 1C */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 1D */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 1E */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 1F */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 20 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 21 */ 0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,
-   /* 22 */ 0x00,0x00,0x6c,0x6c,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 23 */ 0x00,0x00,0x00,0x36,0x36,0x7f,0x36,0x36,0x7f,0x36,0x36,0x00,0x00,0x00,0x00,
-   /* 24 */ 0x00,0x08,0x08,0x3e,0x6b,0x0b,0x0b,0x3e,0x68,0x68,0x6b,0x3e,0x08,0x08,0x00,
-   /* 25 */ 0x00,0x00,0x00,0x33,0x13,0x18,0x08,0x0c,0x04,0x06,0x32,0x33,0x00,0x00,0x00,
-   /* 26 */ 0x00,0x00,0x1c,0x36,0x36,0x1c,0x6c,0x3e,0x33,0x33,0x7b,0xce,0x00,0x00,0x00,
-   /* 27 */ 0x00,0x00,0x18,0x18,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 28 */ 0x00,0x00,0x30,0x18,0x18,0x0c,0x0c,0x0c,0x0c,0x0c,0x18,0x18,0x30,0x00,0x00,
-   /* 29 */ 0x00,0x00,0x0c,0x18,0x18,0x30,0x30,0x30,0x30,0x30,0x18,0x18,0x0c,0x00,0x00,
-   /* 2A */ 0x00,0x00,0x00,0x00,0x00,0x36,0x1c,0x7f,0x1c,0x36,0x00,0x00,0x00,0x00,0x00,
-   /* 2B */ 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
-   /* 2C */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x0c,0x00,0x00,
-   /* 2D */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 2E */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,
-   /* 2F */ 0x00,0x00,0x60,0x20,0x30,0x10,0x18,0x08,0x0c,0x04,0x06,0x02,0x03,0x00,0x00,
-   /* 30 */ 0x00,0x00,0x3e,0x63,0x63,0x63,0x6b,0x6b,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,
-   /* 31 */ 0x00,0x00,0x18,0x1e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,
-   /* 32 */ 0x00,0x00,0x3e,0x63,0x60,0x60,0x30,0x18,0x0c,0x06,0x03,0x7f,0x00,0x00,0x00,
-   /* 33 */ 0x00,0x00,0x3e,0x63,0x60,0x60,0x3c,0x60,0x60,0x60,0x63,0x3e,0x00,0x00,0x00,
-   /* 34 */ 0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x7f,0x30,0x30,0x30,0x30,0x00,0x00,0x00,
-   /* 35 */ 0x00,0x00,0x7f,0x03,0x03,0x3f,0x60,0x60,0x60,0x60,0x63,0x3e,0x00,0x00,0x00,
-   /* 36 */ 0x00,0x00,0x3c,0x06,0x03,0x03,0x3f,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,
-   /* 37 */ 0x00,0x00,0x7f,0x60,0x30,0x30,0x18,0x18,0x18,0x0c,0x0c,0x0c,0x00,0x00,0x00,
-   /* 38 */ 0x00,0x00,0x3e,0x63,0x63,0x63,0x3e,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,
-   /* 39 */ 0x00,0x00,0x3e,0x63,0x63,0x63,0x7e,0x60,0x60,0x60,0x30,0x1e,0x00,0x00,0x00,
-   /* 3A */ 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,
-   /* 3B */ 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x0c,0x00,0x00,
-   /* 3C */ 0x00,0x00,0x60,0x30,0x18,0x0c,0x06,0x06,0x0c,0x18,0x30,0x60,0x00,0x00,0x00,
-   /* 3D */ 0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 3E */ 0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0x60,0x30,0x18,0x0c,0x06,0x00,0x00,0x00,
-   /* 3F */ 0x00,0x00,0x3e,0x63,0x60,0x30,0x30,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,
-   /* 40 */ 0x00,0x00,0x3c,0x66,0x73,0x7b,0x6b,0x6b,0x7b,0x33,0x06,0x3c,0x00,0x00,0x00,
-   /* 41 */ 0x00,0x00,0x3e,0x63,0x63,0x63,0x7f,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00,
-   /* 42 */ 0x00,0x00,0x3f,0x63,0x63,0x63,0x3f,0x63,0x63,0x63,0x63,0x3f,0x00,0x00,0x00,
-   /* 43 */ 0x00,0x00,0x3c,0x66,0x03,0x03,0x03,0x03,0x03,0x03,0x66,0x3c,0x00,0x00,0x00,
-   /* 44 */ 0x00,0x00,0x1f,0x33,0x63,0x63,0x63,0x63,0x63,0x63,0x33,0x1f,0x00,0x00,0x00,
-   /* 45 */ 0x00,0x00,0x7f,0x03,0x03,0x03,0x3f,0x03,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,
-   /* 46 */ 0x00,0x00,0x7f,0x03,0x03,0x03,0x3f,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00,
-   /* 47 */ 0x00,0x00,0x3c,0x66,0x03,0x03,0x03,0x73,0x63,0x63,0x66,0x7c,0x00,0x00,0x00,
-   /* 48 */ 0x00,0x00,0x63,0x63,0x63,0x63,0x7f,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00,
-   /* 49 */ 0x00,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,
-   /* 4A */ 0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x33,0x1e,0x00,0x00,0x00,
-   /* 4B */ 0x00,0x00,0x63,0x33,0x1b,0x0f,0x07,0x07,0x0f,0x1b,0x33,0x63,0x00,0x00,0x00,
-   /* 4C */ 0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,
-   /* 4D */ 0x00,0x00,0x63,0x63,0x77,0x7f,0x7f,0x6b,0x6b,0x63,0x63,0x63,0x00,0x00,0x00,
-   /* 4E */ 0x00,0x00,0x63,0x63,0x67,0x6f,0x6f,0x7b,0x7b,0x73,0x63,0x63,0x00,0x00,0x00,
-   /* 4F */ 0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,
-   /* 50 */ 0x00,0x00,0x3f,0x63,0x63,0x63,0x63,0x3f,0x03,0x03,0x03,0x03,0x00,0x00,0x00,
-   /* 51 */ 0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x63,0x63,0x6f,0x7b,0x3e,0x30,0x60,0x00,
-   /* 52 */ 0x00,0x00,0x3f,0x63,0x63,0x63,0x63,0x3f,0x1b,0x33,0x63,0x63,0x00,0x00,0x00,
-   /* 53 */ 0x00,0x00,0x3e,0x63,0x03,0x03,0x0e,0x38,0x60,0x60,0x63,0x3e,0x00,0x00,0x00,
-   /* 54 */ 0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,
-   /* 55 */ 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,
-   /* 56 */ 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x36,0x36,0x1c,0x1c,0x08,0x00,0x00,0x00,
-   /* 57 */ 0x00,0x00,0x63,0x63,0x6b,0x6b,0x6b,0x6b,0x7f,0x36,0x36,0x36,0x00,0x00,0x00,
-   /* 58 */ 0x00,0x00,0x63,0x63,0x36,0x36,0x1c,0x1c,0x36,0x36,0x63,0x63,0x00,0x00,0x00,
-   /* 59 */ 0x00,0x00,0xc3,0xc3,0x66,0x66,0x3c,0x3c,0x18,0x18,0x18,0x18,0x00,0x00,0x00,
-   /* 5A */ 0x00,0x00,0x7f,0x30,0x30,0x18,0x18,0x0c,0x0c,0x06,0x06,0x7f,0x00,0x00,0x00,
-   /* 5B */ 0x00,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,0x00,0x00,
-   /* 5C */ 0x00,0x00,0x03,0x02,0x06,0x04,0x0c,0x08,0x18,0x10,0x30,0x20,0x60,0x00,0x00,
-   /* 5D */ 0x00,0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,0x00,0x00,
-   /* 5E */ 0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 5F */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
-   /* 60 */ 0x00,0x00,0x0c,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 61 */ 0x00,0x00,0x00,0x00,0x00,0x3e,0x60,0x7e,0x63,0x63,0x73,0x6e,0x00,0x00,0x00,
-   /* 62 */ 0x00,0x00,0x03,0x03,0x03,0x3b,0x67,0x63,0x63,0x63,0x67,0x3b,0x00,0x00,0x00,
-   /* 63 */ 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x03,0x03,0x03,0x63,0x3e,0x00,0x00,0x00,
-   /* 64 */ 0x00,0x00,0x60,0x60,0x60,0x6e,0x73,0x63,0x63,0x63,0x73,0x6e,0x00,0x00,0x00,
-   /* 65 */ 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x63,0x7f,0x03,0x63,0x3e,0x00,0x00,0x00,
-   /* 66 */ 0x00,0x00,0x3c,0x66,0x06,0x1f,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,
-   /* 67 */ 0x00,0x00,0x00,0x00,0x00,0x6e,0x73,0x63,0x63,0x63,0x73,0x6e,0x60,0x63,0x3e,
-   /* 68 */ 0x00,0x00,0x03,0x03,0x03,0x3b,0x67,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00,
-   /* 69 */ 0x00,0x00,0x0c,0x0c,0x00,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x38,0x00,0x00,0x00,
-   /* 6A */ 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x33,0x1e,
-   /* 6B */ 0x00,0x00,0x03,0x03,0x03,0x63,0x33,0x1b,0x0f,0x1f,0x33,0x63,0x00,0x00,0x00,
-   /* 6C */ 0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x38,0x00,0x00,0x00,
-   /* 6D */ 0x00,0x00,0x00,0x00,0x00,0x35,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x00,0x00,0x00,
-   /* 6E */ 0x00,0x00,0x00,0x00,0x00,0x3b,0x67,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00,
-   /* 6F */ 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,
-   /* 70 */ 0x00,0x00,0x00,0x00,0x00,0x3b,0x67,0x63,0x63,0x63,0x67,0x3b,0x03,0x03,0x03,
-   /* 71 */ 0x00,0x00,0x00,0x00,0x00,0x6e,0x73,0x63,0x63,0x63,0x73,0x6e,0x60,0xe0,0x60,
-   /* 72 */ 0x00,0x00,0x00,0x00,0x00,0x3b,0x67,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00,
-   /* 73 */ 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x0e,0x38,0x60,0x63,0x3e,0x00,0x00,0x00,
-   /* 74 */ 0x00,0x00,0x00,0x0c,0x0c,0x3e,0x0c,0x0c,0x0c,0x0c,0x0c,0x38,0x00,0x00,0x00,
-   /* 75 */ 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x73,0x6e,0x00,0x00,0x00,
-   /* 76 */ 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x36,0x36,0x1c,0x1c,0x08,0x00,0x00,0x00,
-   /* 77 */ 0x00,0x00,0x00,0x00,0x00,0x63,0x6b,0x6b,0x6b,0x3e,0x36,0x36,0x00,0x00,0x00,
-   /* 78 */ 0x00,0x00,0x00,0x00,0x00,0x63,0x36,0x1c,0x1c,0x1c,0x36,0x63,0x00,0x00,0x00,
-   /* 79 */ 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x36,0x36,0x1c,0x1c,0x0c,0x0c,0x06,0x03,
-   /* 7A */ 0x00,0x00,0x00,0x00,0x00,0x7f,0x60,0x30,0x18,0x0c,0x06,0x7f,0x00,0x00,0x00,
-   /* 7B */ 0x00,0x00,0x70,0x18,0x18,0x18,0x18,0x0e,0x18,0x18,0x18,0x18,0x70,0x00,0x00,
-   /* 7C */ 0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,
-   /* 7D */ 0x00,0x00,0x0e,0x18,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0e,0x00,0x00,
-   /* 7E */ 0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   /* 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
-
-#endif

+ 1 - 0
ascii.h

@@ -0,0 +1 @@
+src/ascii.h

+ 0 - 604
audio.c

@@ -1,604 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "palcommon.h"
-#include "global.h"
-#include "palcfg.h"
-#include "audio.h"
-#include "players.h"
-#include "util.h"
-#include "resampler.h"
-#include "midi.h"
-#include <math.h>
-
-#if PAL_HAS_OGG
-#include <vorbis/codec.h>
-#endif
-
-#define PAL_CDTRACK_BASE    10000
-
-typedef void(*ResampleMixFunction)(void *, const void *, int, void *, int, int, uint8_t);
-
-typedef struct tagAUDIODEVICE
-{
-   SDL_AudioSpec             spec;		/* Actual-used sound specification */
-   SDL_AudioCVT              cvt;		/* Audio format conversion parameter */
-   AUDIOPLAYER              *pMusPlayer;
-   AUDIOPLAYER              *pCDPlayer;
-#if PAL_HAS_SDLCD
-   SDL_CD                   *pCD;
-#endif
-   AUDIOPLAYER              *pSoundPlayer;
-   void                     *pSoundBuffer;	/* The output buffer for sound */
-   INT                       iMusicVolume;	/* The BGM volume ranged in [0, 128] for better performance */
-   INT                       iSoundVolume;	/* The sound effect volume ranged in [0, 128] for better performance */
-   BOOL                      fMusicEnabled; /* Is BGM enabled? */
-   BOOL                      fSoundEnabled; /* Is sound effect enabled? */
-   BOOL                      fOpened;       /* Is the audio device opened? */
-} AUDIODEVICE;
-
-static AUDIODEVICE gAudioDevice;
-
-PAL_FORCE_INLINE
-void
-AUDIO_MixNative(
-	short     *dst,
-	short     *src,
-	int        samples
-)
-{
-	while (samples > 0)
-	{
-		int val = *src++ + *dst;
-		if (val > SHRT_MAX)
-			*dst++ = SHRT_MAX;
-		else if (val < SHRT_MIN)
-			*dst++ = SHRT_MIN;
-		else
-			*dst++ = (short)val;
-		samples--;
-	}
-}
-
-PAL_FORCE_INLINE
-void
-AUDIO_AdjustVolume(
-	short     *srcdst,
-	int        iVolume,
-	int        samples
-)
-{
-	if (iVolume == SDL_MIX_MAXVOLUME) return;
-	if (iVolume == 0) { memset(srcdst, 0, samples << 1); return; }
-	while (samples > 0)
-	{
-		*srcdst = *srcdst * iVolume / SDL_MIX_MAXVOLUME;
-		samples--; srcdst++;
-	}
-}
-
-static VOID SDLCALL
-AUDIO_FillBuffer(
-   LPVOID          udata,
-   LPBYTE          stream,
-   INT             len
-)
-/*++
-  Purpose:
-
-    SDL sound callback function.
-
-  Parameters:
-
-    [IN]  udata - pointer to user-defined parameters (Not used).
-
-    [OUT] stream - pointer to the stream buffer.
-
-    [IN]  len - Length of the buffer.
-
-  Return value:
-
-    None.
-
---*/
-{
-#if SDL_VERSION_ATLEAST(2,0,0)
-   memset(stream, 0, len);
-#endif
-
-   gAudioDevice.cvt.buf = stream;
-   gAudioDevice.cvt.len = len;
-
-   //
-   // Play music
-   //
-   if (gAudioDevice.fMusicEnabled && gAudioDevice.iMusicVolume > 0)
-   {
-      if (gAudioDevice.pMusPlayer)
-      {
-         gAudioDevice.pMusPlayer->FillBuffer(gAudioDevice.pMusPlayer, stream, len);
-      }
-
-      if (gAudioDevice.pCDPlayer)
-      {
-         gAudioDevice.pCDPlayer->FillBuffer(gAudioDevice.pCDPlayer, stream, len);
-      }
-
-      //
-      // Adjust volume for music
-      //
-      AUDIO_AdjustVolume((short *)stream, gAudioDevice.iMusicVolume, len >> 1);
-   }
-
-   //
-   // Play sound
-   //
-   if (gAudioDevice.fSoundEnabled && gAudioDevice.pSoundPlayer && gAudioDevice.iSoundVolume > 0)
-   {
-	   memset(gAudioDevice.pSoundBuffer, 0, len);
-
-	   gAudioDevice.pSoundPlayer->FillBuffer(gAudioDevice.pSoundPlayer, gAudioDevice.pSoundBuffer, len);
-
-	   //
-	   // Adjust volume for sound
-	   //
-	   AUDIO_AdjustVolume((short *)gAudioDevice.pSoundBuffer, gAudioDevice.iSoundVolume, len >> 1);
-
-	   //
-	   // Mix sound & music
-	   //
-	   AUDIO_MixNative((short *)stream, gAudioDevice.pSoundBuffer, len >> 1);
-   }
-
-   //
-   // Convert audio from native byte-order to actual byte-order
-   //
-   SDL_ConvertAudio(&gAudioDevice.cvt);
-}
-
-INT
-AUDIO_OpenDevice(
-   VOID
-)
-/*++
-  Purpose:
-
-    Initialize the audio subsystem.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    0 if succeed, others if failed.
-
---*/
-{
-   SDL_AudioSpec spec;
-
-   if (gAudioDevice.fOpened)
-   {
-      //
-      // Already opened
-      //
-      return -1;
-   }
-#ifdef __EMSCRIPTEN__ // Now either music/sound enabled will makes whole app crash in emscripten. Disabled until a solution is found.
-   return -1;
-#endif
-
-   gAudioDevice.fOpened = FALSE;
-   gAudioDevice.fMusicEnabled = TRUE;
-   gAudioDevice.fSoundEnabled = TRUE;
-   gAudioDevice.iMusicVolume = gConfig.iMusicVolume * SDL_MIX_MAXVOLUME / PAL_MAX_VOLUME;
-   gAudioDevice.iSoundVolume = gConfig.iSoundVolume * SDL_MIX_MAXVOLUME / PAL_MAX_VOLUME;
-
-   //
-   // Initialize the resampler module
-   //
-   resampler_init();
-
-   //
-   // Open the audio device.
-   //
-   gAudioDevice.spec.freq = gConfig.iSampleRate;
-   gAudioDevice.spec.format = AUDIO_S16;
-   gAudioDevice.spec.channels = gConfig.iAudioChannels;
-   gAudioDevice.spec.samples = gConfig.wAudioBufferSize;
-   gAudioDevice.spec.callback = AUDIO_FillBuffer;
-
-   if (SDL_OpenAudio(&gAudioDevice.spec, &spec) < 0)
-   {
-      //
-      // Failed
-      //
-      return -3;
-   }
-   else
-   {
-      gAudioDevice.spec = spec;
-      gAudioDevice.pSoundBuffer = malloc(spec.size);
-   }
-
-   SDL_BuildAudioCVT(&gAudioDevice.cvt, AUDIO_S16SYS, spec.channels, spec.freq, spec.format, spec.channels, spec.freq);
-
-   gAudioDevice.fOpened = TRUE;
-
-   //
-   // Initialize the sound subsystem.
-   //
-   gAudioDevice.pSoundPlayer = SOUND_Init();
-
-   //
-   // Initialize the music subsystem.
-   //
-   switch (gConfig.eMusicType)
-   {
-   case MUSIC_RIX:
-	   if (!(gAudioDevice.pMusPlayer = RIX_Init(va("%s%s", gConfig.pszGamePath, "mus.mkf"))))
-	   {
-		   gAudioDevice.pMusPlayer = RIX_Init(va("%s%s", gConfig.pszGamePath, "MUS.MKF"));
-	   }
-	   break;
-   case MUSIC_MP3:
-#if PAL_HAS_MP3
-	   gAudioDevice.pMusPlayer = MP3_Init();
-#else
-	   gAudioDevice.pMusPlayer = NULL;
-#endif
-	   break;
-   case MUSIC_OGG:
-#if PAL_HAS_OGG
-	   gAudioDevice.pMusPlayer = OGG_Init();
-#else
-	   gAudioDevice.pMusPlayer = NULL;
-#endif
-	   break;
-   case MUSIC_MIDI:
-	   gAudioDevice.pMusPlayer = NULL;
-	   break;
-   }
-
-   //
-   // Initialize the CD audio.
-   //
-   switch (gConfig.eCDType)
-   {
-   case MUSIC_SDLCD:
-   {
-#if PAL_HAS_SDLCD
-	   int i;
-	   gAudioDevice.pCD = NULL;
-
-	   for (i = 0; i < SDL_CDNumDrives(); i++)
-	   {
-		   gAudioDevice.pCD = SDL_CDOpen(i);
-		   if (gAudioDevice.pCD != NULL)
-		   {
-			   if (!CD_INDRIVE(SDL_CDStatus(gAudioDevice.pCD)))
-			   {
-				   SDL_CDClose(gAudioDevice.pCD);
-				   gAudioDevice.pCD = NULL;
-			   }
-			   else
-			   {
-				   break;
-			   }
-		   }
-	   }
-#endif
-	   gAudioDevice.pCDPlayer = NULL;
-	   break;
-   }
-   case MUSIC_MP3:
-#if PAL_HAS_MP3
-	   gAudioDevice.pCDPlayer = MP3_Init();
-#else
-	   gAudioDevice.pCDPlayer = NULL;
-#endif
-	   break;
-   case MUSIC_OGG:
-#if PAL_HAS_OGG
-	   gAudioDevice.pCDPlayer = OGG_Init();
-#else
-	   gAudioDevice.pCDPlayer = NULL;
-#endif
-	   break;
-   }
-
-   //
-   // Let the callback function run so that musics will be played.
-   //
-   SDL_PauseAudio(0);
-
-   return 0;
-}
-
-VOID
-AUDIO_CloseDevice(
-   VOID
-)
-/*++
-  Purpose:
-
-    Close the audio subsystem.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_CloseAudio();
-
-   if (gAudioDevice.pSoundPlayer != NULL)
-   {
-      gAudioDevice.pSoundPlayer->Shutdown(gAudioDevice.pSoundPlayer);
-      gAudioDevice.pSoundPlayer = NULL;
-   }
-
-   if (gAudioDevice.pMusPlayer)
-   {
-	   gAudioDevice.pMusPlayer->Shutdown(gAudioDevice.pMusPlayer);
-	   gAudioDevice.pMusPlayer = NULL;
-   }
-
-   if (gAudioDevice.pCDPlayer)
-   {
-	   gAudioDevice.pCDPlayer->Shutdown(gAudioDevice.pCDPlayer);
-	   gAudioDevice.pCDPlayer = NULL;
-   }
-
-#if PAL_HAS_SDLCD
-   if (gAudioDevice.pCD != NULL)
-   {
-      AUDIO_PlayCDTrack(-1);
-      SDL_CDClose(gAudioDevice.pCD);
-   }
-#endif
-
-   if (gAudioDevice.pSoundBuffer != NULL)
-   {
-      free(gAudioDevice.pSoundBuffer);
-	  gAudioDevice.pSoundBuffer = NULL;
-   }
-
-#if PAL_HAS_NATIVEMIDI
-   if (gConfig.eMusicType == MUSIC_MIDI) MIDI_Play(0, FALSE);
-#endif
-}
-
-SDL_AudioSpec*
-AUDIO_GetDeviceSpec(
-	VOID
-)
-{
-	return &gAudioDevice.spec;
-}
-
-static INT
-AUDIO_ChangeVolumeByValue(
-   INT   *iVolume,
-   INT    iValue
-)
-{
-   *iVolume += iValue;
-   if (*iVolume > PAL_MAX_VOLUME)
-      *iVolume = PAL_MAX_VOLUME;
-   else if (*iVolume < 0)
-      *iVolume = 0;
-   return *iVolume;
-}
-
-VOID
-AUDIO_IncreaseVolume(
-   VOID
-)
-/*++
-  Purpose:
-
-    Increase global volume by 3%.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   AUDIO_ChangeVolumeByValue(&gConfig.iMusicVolume, 3);
-   AUDIO_ChangeVolumeByValue(&gConfig.iSoundVolume, 3);
-   gAudioDevice.iMusicVolume = gConfig.iMusicVolume * SDL_MIX_MAXVOLUME / PAL_MAX_VOLUME;
-   gAudioDevice.iSoundVolume = gConfig.iSoundVolume * SDL_MIX_MAXVOLUME / PAL_MAX_VOLUME;
-}
-
-VOID
-AUDIO_DecreaseVolume(
-   VOID
-)
-/*++
-  Purpose:
-
-    Decrease global volume by 3%.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   AUDIO_ChangeVolumeByValue(&gConfig.iMusicVolume, -3);
-   AUDIO_ChangeVolumeByValue(&gConfig.iSoundVolume, -3);
-   gAudioDevice.iMusicVolume = gConfig.iMusicVolume * SDL_MIX_MAXVOLUME / PAL_MAX_VOLUME;
-   gAudioDevice.iSoundVolume = gConfig.iSoundVolume * SDL_MIX_MAXVOLUME / PAL_MAX_VOLUME;
-}
-
-VOID
-AUDIO_PlaySound(
-   INT    iSoundNum
-)
-/*++
-  Purpose:
-
-    Play a sound in voc.mkf/sounds.mkf file.
-
-  Parameters:
-
-    [IN]  iSoundNum - number of the sound; the absolute value is used.
-
-  Return value:
-
-    None.
-
---*/
-{
-   // Unlike musics that use the 'load as required' strategy, sound player
-   // load the entire sound file at once, which may cause about 0.5s or longer
-   // latency for large sound files. To prevent this latency affects audio playing,
-   // the mutex lock is obtained inside the SOUND_Play function rather than here.
-   if (gAudioDevice.pSoundPlayer)
-   {
-      gAudioDevice.pSoundPlayer->Play(gAudioDevice.pSoundPlayer, abs(iSoundNum), FALSE, 0.0f);
-   }
-}
-
-VOID
-AUDIO_PlayMusic(
-   INT       iNumRIX,
-   BOOL      fLoop,
-   FLOAT     flFadeTime
-)
-{
-#if PAL_HAS_NATIVEMIDI
-   if (gConfig.eMusicType == MUSIC_MIDI)
-   {
-      MIDI_Play(iNumRIX, fLoop);
-      return;
-   }
-#endif
-   SDL_LockAudio();
-   if (gAudioDevice.pMusPlayer)
-   {
-      gAudioDevice.pMusPlayer->Play(gAudioDevice.pMusPlayer, iNumRIX, fLoop, flFadeTime);
-   }
-   SDL_UnlockAudio();
-}
-
-BOOL
-AUDIO_PlayCDTrack(
-   INT    iNumTrack
-)
-/*++
-  Purpose:
-
-    Play a CD Audio Track.
-
-  Parameters:
-
-    [IN]  iNumTrack - number of the CD Audio Track.
-
-  Return value:
-
-    TRUE if the track can be played, FALSE if not.
-
---*/
-{
-	BOOL ret = FALSE;
-#if PAL_HAS_SDLCD
-   if (gAudioDevice.pCD != NULL)
-   {
-      if (CD_INDRIVE(SDL_CDStatus(gAudioDevice.pCD)))
-      {
-         SDL_CDStop(gAudioDevice.pCD);
-
-         if (iNumTrack != -1)
-         {
-            AUDIO_PlayMusic(-1, FALSE, 0);
-
-            if (SDL_CDPlayTracks(gAudioDevice.pCD, iNumTrack - 1, 0, 1, 0) == 0)
-            {
-               return TRUE;
-            }
-         }
-      }
-   }
-#endif
-   SDL_LockAudio();
-   if (gAudioDevice.pCDPlayer)
-   {
-	   if (iNumTrack != -1)
-	   {
-		   AUDIO_PlayMusic(-1, FALSE, 0);
-		   ret = gAudioDevice.pCDPlayer->Play(gAudioDevice.pCDPlayer, PAL_CDTRACK_BASE + iNumTrack, TRUE, 0);
-	   }
-	   else
-	   {
-		   ret = gAudioDevice.pCDPlayer->Play(gAudioDevice.pCDPlayer, -1, FALSE, 0);
-	   }
-   }
-   SDL_UnlockAudio();
-
-   return ret;
-}
-
-VOID
-AUDIO_EnableMusic(
-   BOOL   fEnable
-)
-{
-   gAudioDevice.fMusicEnabled = fEnable;
-}
-
-BOOL
-AUDIO_MusicEnabled(
-   VOID
-)
-{
-   return gAudioDevice.fMusicEnabled;
-}
-
-VOID
-AUDIO_EnableSound(
-   BOOL   fEnable
-)
-{
-	gAudioDevice.fSoundEnabled = fEnable;
-}
-
-BOOL
-AUDIO_SoundEnabled(
-   VOID
-)
-{
-   return gAudioDevice.fSoundEnabled;
-}

+ 1 - 0
audio.c

@@ -0,0 +1 @@
+src/audio.c

+ 0 - 100
audio.h

@@ -1,100 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef AUDIO_H
-#define AUDIO_H
-
-#include "common.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-INT
-AUDIO_OpenDevice(
-   VOID
-);
-
-VOID
-AUDIO_CloseDevice(
-   VOID
-);
-
-SDL_AudioSpec*
-AUDIO_GetDeviceSpec(
-   VOID
-);
-
-VOID
-AUDIO_IncreaseVolume(
-   VOID
-);
-
-VOID
-AUDIO_DecreaseVolume(
-   VOID
-);
-
-VOID
-AUDIO_PlayMusic(
-   INT       iNumRIX,
-   BOOL      fLoop,
-   FLOAT     flFadeTime
-);
-
-BOOL
-AUDIO_PlayCDTrack(
-   INT    iNumTrack
-);
-
-VOID
-AUDIO_PlaySound(
-   INT    iSoundNum
-);
-
-VOID
-AUDIO_EnableMusic(
-   BOOL   fEnable
-);
-
-BOOL
-AUDIO_MusicEnabled(
-   VOID
-);
-
-VOID
-AUDIO_EnableSound(
-   BOOL   fEnable
-);
-
-BOOL
-AUDIO_SoundEnabled(
-   VOID
-);
-
-#define AUDIO_IsIntegerConversion(a) (((a) % gConfig.iSampleRate) == 0 || (gConfig.iSampleRate % (a)) == 0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
audio.h

@@ -0,0 +1 @@
+src/audio.h

File diff suppressed because it is too large
+ 0 - 1485
battle.c


+ 1 - 0
battle.c

@@ -0,0 +1 @@
+src/battle.c

+ 0 - 239
battle.h

@@ -1,239 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef BATTLE_H
-#define BATTLE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "global.h"
-#include "uibattle.h"
-
-#define       BATTLE_FPS               25
-#define       BATTLE_FRAME_TIME        (1000 / BATTLE_FPS)
-
-typedef enum tagBATTLERESULT
-{
-   kBattleResultWon        = 3,      // player won the battle
-   kBattleResultLost       = 1,      // player lost the battle
-   kBattleResultFleed      = 0xFFFF, // player fleed from the battle
-   kBattleResultTerminated = 0,      // battle terminated with scripts
-   kBattleResultOnGoing    = 1000,   // the battle is ongoing
-   kBattleResultPreBattle  = 1001,   // running pre-battle scripts
-   kBattleResultPause      = 1002,   // battle pause
-} BATTLERESULT;
-
-typedef enum tagFIGHTERSTATE
-{
-   kFighterWait,  // waiting time
-   kFighterCom,   // accepting command
-   kFighterAct,   // doing the actual move
-} FIGHTERSTATE;
-
-typedef enum tagBATTLEACTIONTYPE
-{
-   kBattleActionPass,          // do nothing
-   kBattleActionDefend,        // defend
-   kBattleActionAttack,        // physical attack
-   kBattleActionMagic,         // use magic
-   kBattleActionCoopMagic,     // use cooperative magic
-   kBattleActionFlee,          // flee from the battle
-   kBattleActionThrowItem,     // throw item onto enemy
-   kBattleActionUseItem,       // use item
-   kBattleActionAttackMate,    // attack teammate (confused only)
-} BATTLEACTIONTYPE;
-
-typedef struct tagBATTLEACTION
-{
-   BATTLEACTIONTYPE   ActionType;
-   WORD               wActionID;   // item/magic to use
-   SHORT              sTarget;     // -1 for everyone
-   FLOAT              flRemainingTime;  // remaining waiting time before the action start
-} BATTLEACTION;
-
-typedef struct tagBATTLEENEMY
-{
-   WORD               wObjectID;              // Object ID of this enemy
-   ENEMY              e;                      // detailed data of this enemy
-   WORD               rgwStatus[kStatusAll];  // status effects
-   FLOAT              flTimeMeter;            // time-charging meter (0 = empty, 100 = full).
-   POISONSTATUS       rgPoisons[MAX_POISONS]; // poisons
-   LPSPRITE           lpSprite;
-   PAL_POS            pos;                    // current position on the screen
-   PAL_POS            posOriginal;            // original position on the screen
-   WORD               wCurrentFrame;          // current frame number
-   FIGHTERSTATE       state;                  // state of this enemy
-
-   BOOL               fTurnStart;
-   BOOL               fFirstMoveDone;
-   BOOL               fDualMove;
-
-   WORD               wScriptOnTurnStart;
-   WORD               wScriptOnBattleEnd;
-   WORD               wScriptOnReady;
-
-   WORD               wPrevHP;              // HP value prior to action
-
-   INT                iColorShift;
-} BATTLEENEMY;
-
-// We only put some data used in battle here; other data can be accessed in the global data.
-typedef struct tagBATTLEPLAYER
-{
-   INT                iColorShift;
-   FLOAT              flTimeMeter;          // time-charging meter (0 = empty, 100 = full).
-   FLOAT              flTimeSpeedModifier;
-   WORD               wHidingTime;          // remaining hiding time
-   LPSPRITE           lpSprite;
-   PAL_POS            pos;                  // current position on the screen
-   PAL_POS            posOriginal;          // original position on the screen
-   WORD               wCurrentFrame;        // current frame number
-   FIGHTERSTATE       state;                // state of this player
-   BATTLEACTION       action;               // action to perform
-   BOOL               fDefending;           // TRUE if player is defending
-   WORD               wPrevHP;              // HP value prior to action
-   WORD               wPrevMP;              // MP value prior to action
-#ifndef PAL_CLASSIC
-   SHORT              sTurnOrder;           // turn order
-#endif
-} BATTLEPLAYER;
-
-typedef struct tagSUMMON
-{
-   LPSPRITE           lpSprite;
-   WORD               wCurrentFrame;
-} SUMMON;
-
-#define MAX_BATTLE_ACTIONS    256
-#define MAX_KILLED_ENEMIES    256
-
-#ifdef PAL_CLASSIC
-
-typedef enum tabBATTLEPHASE
-{
-   kBattlePhaseSelectAction,
-   kBattlePhasePerformAction
-} BATTLEPHASE;
-
-typedef struct tagACTIONQUEUE
-{
-   BOOL       fIsEnemy;
-   WORD       wDexterity;
-   WORD       wIndex;
-} ACTIONQUEUE;
-
-#define MAX_ACTIONQUEUE_ITEMS (MAX_PLAYERS_IN_PARTY + MAX_ENEMIES_IN_TEAM * 2)
-
-#endif
-
-typedef struct tagBATTLE
-{
-   BATTLEPLAYER     rgPlayer[MAX_PLAYERS_IN_PARTY];
-   BATTLEENEMY      rgEnemy[MAX_ENEMIES_IN_TEAM];
-
-   WORD             wMaxEnemyIndex;
-
-   SDL_Surface     *lpSceneBuf;
-   SDL_Surface     *lpBackground;
-
-   SHORT            sBackgroundColorShift;
-
-   LPSPRITE         lpSummonSprite;       // sprite of summoned god
-   PAL_POS          posSummon;
-   INT              iSummonFrame;         // current frame of the summoned god
-
-   INT              iExpGained;           // total experience value gained
-   INT              iCashGained;          // total cash gained
-
-   BOOL             fIsBoss;              // TRUE if boss fight
-   BOOL             fEnemyCleared;        // TRUE if enemies are cleared
-   BATTLERESULT     BattleResult;
-
-   FLOAT            flTimeChargingUnit;   // the base waiting time unit
-
-   BATTLEUI         UI;
-
-   LPBYTE           lpEffectSprite;
-
-   BOOL             fEnemyMoving;         // TRUE if enemy is moving
-
-   INT              iHidingTime;          // Time of hiding
-
-   WORD             wMovingPlayerIndex;   // current moving player index
-
-   int              iBlow;
-
-#ifdef PAL_CLASSIC
-   BATTLEPHASE      Phase;
-   ACTIONQUEUE      ActionQueue[MAX_ACTIONQUEUE_ITEMS];
-   int              iCurAction;
-   BOOL             fRepeat;              // TRUE if player pressed Repeat
-   BOOL             fForce;               // TRUE if player pressed Force
-   BOOL             fFlee;                // TRUE if player pressed Flee
-#endif
-} BATTLE;
-
-extern BATTLE g_Battle;
-
-VOID
-PAL_LoadBattleSprites(
-   VOID
-);
-
-VOID
-PAL_BattleMakeScene(
-   VOID
-);
-
-VOID
-PAL_BattleBackupScene(
-   VOID
-);
-
-VOID
-PAL_BattleFadeScene(
-   VOID
-);
-
-VOID
-PAL_BattleEnemyEscape(
-   VOID
-);
-
-VOID
-PAL_BattlePlayerEscape(
-   VOID
-);
-
-BATTLERESULT
-PAL_StartBattle(
-   WORD        wEnemyTeam,
-   BOOL        fIsBoss
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
battle.h

@@ -0,0 +1 @@
+src/battle.h

File diff suppressed because it is too large
+ 0 - 4177
codepage.h


+ 1 - 0
codepage.h

@@ -0,0 +1 @@
+src/codepage.h

+ 0 - 233
common.h

@@ -1,233 +0,0 @@
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-// Modified by Lou Yihua <louyihua@21cn.com> with unicode support, 2015.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef _COMMON_H
-#define _COMMON_H
-
-#ifndef ENABLE_REVISIED_BATTLE
-# define PAL_CLASSIC        1
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-
-#include <wchar.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <assert.h>
-
-#include "SDL.h"
-#include "SDL_endian.h"
-
-#if SDL_VERSION_ATLEAST(2,0,0)
-
-# define SDLK_KP1     SDLK_KP_1
-# define SDLK_KP2     SDLK_KP_2
-# define SDLK_KP3     SDLK_KP_3
-# define SDLK_KP4     SDLK_KP_4
-# define SDLK_KP5     SDLK_KP_5
-# define SDLK_KP6     SDLK_KP_6
-# define SDLK_KP7     SDLK_KP_7
-# define SDLK_KP8     SDLK_KP_8
-# define SDLK_KP9     SDLK_KP_9
-# define SDLK_KP0     SDLK_KP_0
-
-# define SDL_HWSURFACE     0
-
-#else
-
-# ifndef PAL_FATAL_OUTPUT
-#  define PAL_FATAL_OUTPUT(s)
-# endif
-
-#endif
-
-#ifndef max
-# define max fmax
-#endif
-
-#ifndef min
-# define min fmin
-#endif
-
-/* This is need when compiled with SDL 1.2 */
-#ifndef SDL_FORCE_INLINE
-#if defined(_MSC_VER)
-#define SDL_FORCE_INLINE __forceinline
-#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
-#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
-#else
-#define SDL_FORCE_INLINE static SDL_INLINE
-#endif
-#endif /* SDL_FORCE_INLINE not defined */
-
-#if defined(_MSC_VER)
-# define PAL_FORCE_INLINE static SDL_FORCE_INLINE
-#else
-# define PAL_FORCE_INLINE SDL_FORCE_INLINE
-#endif
-
-#ifdef _WIN32
-
-# include <windows.h>
-# include <io.h>
-
-# if defined(_MSC_VER)
-#  if _MSC_VER < 1900
-#   define vsnprintf _vsnprintf
-#   define snprintf _snprintf
-#  endif
-#  define strdup _strdup
-#  pragma warning (disable:4244)
-# endif
-
-# ifndef _LPCBYTE_DEFINED
-#  define _LPCBYTE_DEFINED
-typedef const BYTE *LPCBYTE;
-# endif
-
-#else
-
-# include <unistd.h>
-# include <dirent.h>
-
-# ifndef FALSE
-#  define FALSE               0
-# endif
-# ifndef TRUE
-#  define TRUE                1
-# endif
-# define VOID                void
-typedef char                CHAR;
-typedef wchar_t             WCHAR;
-typedef short               SHORT;
-typedef long                LONG;
-
-typedef unsigned long       ULONG, *PULONG;
-typedef unsigned short      USHORT, *PUSHORT;
-typedef unsigned char       UCHAR, *PUCHAR;
-
-typedef unsigned short      WORD, *LPWORD;
-typedef unsigned int        DWORD, *LPDWORD;
-typedef int                 INT, *LPINT;
-# ifndef __OBJC__
-typedef int                 BOOL, *LPBOOL;
-# endif
-typedef unsigned int        UINT, *PUINT, UINT32, *PUINT32;
-typedef unsigned char       BYTE, *LPBYTE;
-typedef const BYTE         *LPCBYTE;
-typedef float               FLOAT, *LPFLOAT;
-typedef void               *LPVOID;
-typedef const void         *LPCVOID;
-typedef CHAR               *LPSTR;
-typedef const CHAR         *LPCSTR;
-typedef WCHAR              *LPWSTR;
-typedef const WCHAR        *LPCWSTR;
-
-#endif
-
-/* When porting SDLPAL to a new platform, please make a separate directory and put a file 
-   named 'pal_config.h' that contains marco definitions & header includes into the directory.
-   The example of this file can be found in directories of existing portings.
- */
-#include "pal_config.h"
-
-#ifndef PAL_DEFAULT_FULLSCREEN_HEIGHT
-# define PAL_DEFAULT_FULLSCREEN_HEIGHT PAL_DEFAULT_WINDOW_HEIGHT
-#endif
-
-/* Default for 1024 samples */
-#ifndef PAL_AUDIO_DEFAULT_BUFFER_SIZE
-# define PAL_AUDIO_DEFAULT_BUFFER_SIZE   1024
-#endif
-
-#ifndef PAL_HAS_SDLCD
-# define PAL_HAS_SDLCD        0
-#endif
-
-#ifndef PAL_HAS_MP3
-# define PAL_HAS_MP3          1   /* Try always enable MP3. If compilation/run failed, please change this value to 0. */
-#endif
-#ifndef PAL_HAS_OGG
-# define PAL_HAS_OGG          1   /* Try always enable OGG. If compilation/run failed, please change this value to 0. */
-#endif
-
-#ifndef SDL_INIT_CDROM
-# define SDL_INIT_CDROM       0	  /* Compatibility with SDL 1.2 */
-#endif
-
-#ifndef SDL_AUDIO_BITSIZE
-# define SDL_AUDIO_BITSIZE(x)         (x & 0xFF)
-#endif
-
-#ifndef PAL_CONFIG_PREFIX
-# define PAL_CONFIG_PREFIX PAL_PREFIX
-#endif
-
-#ifndef PAL_SCREENSHOT_PREFIX
-# define PAL_SCREENSHOT_PREFIX PAL_SAVE_PREFIX
-#endif
-
-#ifndef PAL_HAS_NATIVEMIDI
-# define PAL_HAS_NATIVEMIDI  0
-#endif
-
-#ifndef PAL_LARGE
-# define PAL_LARGE
-#endif
-
-#ifndef PAL_SCALE_SCREEN
-# define PAL_SCALE_SCREEN   TRUE
-#endif
-
-#define __WIDETEXT(quote) L##quote
-#define WIDETEXT(quote) __WIDETEXT(quote)
-
-// For SDL 1.2 compatibility
-#ifndef SDL_TICKS_PASSED
-#define SDL_TICKS_PASSED(A, B)  ((Sint32)((B) - (A)) <= 0)
-#endif
-
-typedef enum tagCODEPAGE {
-	CP_MIN = 0,
-	CP_BIG5 = 0,
-	CP_GBK = 1,
-	CP_SHIFTJIS = 2,
-	CP_JISX0208 = 3,
-	CP_MAX = CP_GBK + 1,
-	CP_UTF_8 = CP_MAX + 1
-} CODEPAGE;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
common.h

@@ -0,0 +1 @@
+src/common.h

+ 0 - 515
ending.c

@@ -1,515 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "main.h"
-
-static WORD g_wCurEffectSprite = 0;
-
-VOID
-PAL_EndingSetEffectSprite(
-   WORD         wSpriteNum
-)
-/*++
-  Purpose:
-
-    Set the effect sprite of the ending.
-
-  Parameters:
-
-    [IN]  wSpriteNum - the number of the sprite.
-
-  Return value:
-
-    None.
-
---*/
-{
-   g_wCurEffectSprite = wSpriteNum;
-}
-
-VOID
-PAL_ShowFBP(
-   WORD         wChunkNum,
-   WORD         wFade
-)
-/*++
-  Purpose:
-
-    Draw an FBP picture to the screen.
-
-  Parameters:
-
-    [IN]  wChunkNum - number of chunk in fbp.mkf file.
-
-    [IN]  wFade - fading speed of showing the picture.
-
-  Return value:
-
-    None.
-
---*/
-{
-   PAL_LARGE BYTE            buf[320 * 200];
-   PAL_LARGE BYTE            bufSprite[320 * 200];
-   const int                 rgIndex[6] = {0, 3, 1, 5, 2, 4};
-   SDL_Surface              *p;
-   int                       i, j, k;
-   BYTE                      a, b;
-
-   if (PAL_MKFDecompressChunk(buf, 320 * 200, wChunkNum, gpGlobals->f.fpFBP) <= 0)
-   {
-      memset(buf, 0, sizeof(buf));
-   }
-
-   if (g_wCurEffectSprite != 0)
-   {
-      PAL_MKFDecompressChunk(bufSprite, 320 * 200, g_wCurEffectSprite, gpGlobals->f.fpMGO);
-   }
-
-   if (wFade)
-   {
-      wFade++;
-      wFade *= 10;
-
-      p = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
-         gpScreen->format->Rmask, gpScreen->format->Gmask,
-         gpScreen->format->Bmask, gpScreen->format->Amask);
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-      SDL_SetSurfacePalette(p, gpScreen->format->palette);
-#else
-      SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-      PAL_FBPBlitToSurface(buf, p);
-      VIDEO_BackupScreen();
-
-      for (i = 0; i < 16; i++)
-      {
-         for (j = 0; j < 6; j++)
-         {
-            //
-            // Blend the pixels in the 2 buffers, and put the result into the
-            // backup buffer
-            //
-            for (k = rgIndex[j]; k < gpScreen->pitch * gpScreen->h; k += 6)
-            {
-               a = ((LPBYTE)(p->pixels))[k];
-               b = ((LPBYTE)(gpScreenBak->pixels))[k];
-
-               if (i > 0)
-               {
-                  if ((a & 0x0F) > (b & 0x0F))
-                  {
-                     b++;
-                  }
-                  else if ((a & 0x0F) < (b & 0x0F))
-                  {
-                     b--;
-                  }
-               }
-
-               ((LPBYTE)(gpScreenBak->pixels))[k] = ((a & 0xF0) | (b & 0x0F));
-            }
-
-            SDL_BlitSurface(gpScreenBak, NULL, gpScreen, NULL);
-
-            if (g_wCurEffectSprite != 0)
-            {
-               int f = SDL_GetTicks() / 150;
-               PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufSprite, f % PAL_SpriteGetNumFrames(bufSprite)),
-                  gpScreen, PAL_XY(0, 0));
-            }
-
-            VIDEO_UpdateScreen(NULL);
-            UTIL_Delay(wFade);
-         }
-      }
-
-      SDL_FreeSurface(p);
-   }
-
-   //
-   // HACKHACK: to make the ending show correctly
-   //
-   if (wChunkNum != (gConfig.fIsWIN95 ? 68 : 49))
-   {
-      PAL_FBPBlitToSurface(buf, gpScreen);
-   }
-
-   VIDEO_UpdateScreen(NULL);
-}
-
-VOID
-PAL_ScrollFBP(
-   WORD         wChunkNum,
-   WORD         wScrollSpeed,
-   BOOL         fScrollDown
-)
-/*++
-  Purpose:
-
-    Scroll up an FBP picture to the screen.
-
-  Parameters:
-
-    [IN]  wChunkNum - number of chunk in fbp.mkf file.
-
-    [IN]  wScrollSpeed - scrolling speed of showing the picture.
-
-    [IN]  fScrollDown - TRUE if scroll down, FALSE if scroll up.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_Surface          *p;
-   PAL_LARGE BYTE        buf[320 * 200];
-   PAL_LARGE BYTE        bufSprite[320 * 200];
-   int                   i, l;
-   SDL_Rect              rect, dstrect;
-
-   if (PAL_MKFDecompressChunk(buf, 320 * 200, wChunkNum, gpGlobals->f.fpFBP) <= 0)
-   {
-      return;
-   }
-
-   if (g_wCurEffectSprite != 0)
-   {
-      PAL_MKFDecompressChunk(bufSprite, 320 * 200, g_wCurEffectSprite, gpGlobals->f.fpMGO);
-   }
-
-   p = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
-      gpScreen->format->Rmask, gpScreen->format->Gmask,
-      gpScreen->format->Bmask, gpScreen->format->Amask);
-
-   if (p == NULL)
-   {
-      return;
-   }
-
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-   SDL_SetSurfacePalette(p, gpScreen->format->palette);
-#else
-   SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-
-   VIDEO_BackupScreen();
-   PAL_FBPBlitToSurface(buf, p);
-
-   if (wScrollSpeed == 0)
-   {
-      wScrollSpeed = 1;
-   }
-
-   rect.x = 0;
-   rect.w = 320;
-   dstrect.x = 0;
-   dstrect.w = 320;
-
-   for (l = 0; l < 220; l++)
-   {
-      i = l;
-      if (i > 200)
-      {
-         i = 200;
-      }
-
-      if (fScrollDown)
-      {
-         rect.y = 0;
-         dstrect.y = i;
-         rect.h = 200 - i;
-         dstrect.h = 200 - i;
-      }
-      else
-      {
-         rect.y = i;
-         dstrect.y = 0;
-         rect.h = 200 - i;
-         dstrect.h = 200 - i;
-      }
-
-      SDL_BlitSurface(gpScreenBak, &rect, gpScreen, &dstrect);
-
-      if (fScrollDown)
-      {
-         rect.y = 200 - i;
-         dstrect.y = 0;
-         rect.h = i;
-         dstrect.h = i;
-      }
-      else
-      {
-         rect.y = 0;
-         dstrect.y = 200 - i;
-         rect.h = i;
-         dstrect.h = i;
-      }
-
-      SDL_BlitSurface(p, &rect, gpScreen, &dstrect);
-
-      PAL_ApplyWave(gpScreen);
-
-      if (g_wCurEffectSprite != 0)
-      {
-         int f = SDL_GetTicks() / 150;
-         PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufSprite, f % PAL_SpriteGetNumFrames(bufSprite)),
-            gpScreen, PAL_XY(0, 0));
-      }
-
-      VIDEO_UpdateScreen(NULL);
-
-      if (gpGlobals->fNeedToFadeIn)
-      {
-         PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
-         gpGlobals->fNeedToFadeIn = FALSE;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-         SDL_SetSurfacePalette(p, gpScreen->format->palette);
-#else
-         SDL_SetPalette(p, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-      }
-
-      UTIL_Delay(800 / wScrollSpeed);
-   }
-
-   SDL_BlitSurface(p, NULL, gpScreen, NULL);
-   SDL_FreeSurface(p);
-   VIDEO_UpdateScreen(NULL);
-}
-
-VOID
-PAL_EndingAnimation(
-   VOID
-)
-/*++
-  Purpose:
-
-    Show the ending animation.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   LPBYTE            buf;
-   LPBYTE            bufGirl;
-   SDL_Surface      *pUpper;
-   SDL_Surface      *pLower;
-   SDL_Rect          srcrect, dstrect;
-
-   int               yPosGirl = 180;
-   int               i;
-
-   buf = (LPBYTE)UTIL_calloc(1, 64000);
-   bufGirl = (LPBYTE)UTIL_calloc(1, 6000);
-
-   pUpper = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
-      gpScreen->format->Rmask, gpScreen->format->Gmask,
-      gpScreen->format->Bmask, gpScreen->format->Amask);
-
-   pLower = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
-      gpScreen->format->Rmask, gpScreen->format->Gmask,
-      gpScreen->format->Bmask, gpScreen->format->Amask);
-
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-   SDL_SetSurfacePalette(pUpper, gpScreen->format->palette);
-   SDL_SetSurfacePalette(pLower, gpScreen->format->palette);
-#else
-   SDL_SetPalette(pUpper, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-   SDL_SetPalette(pLower, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-
-   PAL_MKFDecompressChunk(buf, 64000, gConfig.fIsWIN95 ? 69 : 61, gpGlobals->f.fpFBP);
-   PAL_FBPBlitToSurface(buf, pUpper);
-
-   PAL_MKFDecompressChunk(buf, 64000, gConfig.fIsWIN95 ? 70 : 62, gpGlobals->f.fpFBP);
-   PAL_FBPBlitToSurface(buf, pLower);
-
-   PAL_MKFDecompressChunk(buf, 64000, 571, gpGlobals->f.fpMGO);
-   PAL_MKFDecompressChunk(bufGirl, 6000, 572, gpGlobals->f.fpMGO);
-
-   srcrect.x = 0;
-   dstrect.x = 0;
-   srcrect.w = 320;
-   dstrect.w = 320;
-
-   gpGlobals->wScreenWave = 2;
-
-   for (i = 0; i < 400; i++)
-   {
-      //
-      // Draw the background
-      //
-      srcrect.y = 0;
-      srcrect.h = 200 - i / 2;
-
-      dstrect.y = i / 2;
-      dstrect.h = 200 - i / 2;
-
-      SDL_BlitSurface(pLower, &srcrect, gpScreen, &dstrect);
-
-      srcrect.y = 200 - i / 2;
-      srcrect.h = i / 2;
-
-      dstrect.y = 0;
-      dstrect.h = i / 2;
-
-      SDL_BlitSurface(pUpper, &srcrect, gpScreen, &dstrect);
-
-      PAL_ApplyWave(gpScreen);
-
-      //
-      // Draw the beast
-      //
-      PAL_RLEBlitToSurface(PAL_SpriteGetFrame(buf, 0), gpScreen, PAL_XY(0, -400 + i));
-	  PAL_RLEBlitToSurface(gConfig.fIsWIN95 ? buf + 0x8444 : PAL_SpriteGetFrame(buf, 1), gpScreen, PAL_XY(0, -200 + i));
-      //
-      // Draw the girl
-      //
-      yPosGirl -= i & 1;
-      if (yPosGirl < 80)
-      {
-         yPosGirl = 80;
-      }
-
-      PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufGirl, (SDL_GetTicks() / 50) % 4),
-         gpScreen, PAL_XY(220, yPosGirl));
-
-      //
-      // Update the screen
-      //
-      VIDEO_UpdateScreen(NULL);
-      if (gpGlobals->fNeedToFadeIn)
-      {
-         PAL_FadeIn(gpGlobals->wNumPalette, gpGlobals->fNightPalette, 1);
-         gpGlobals->fNeedToFadeIn = FALSE;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-         SDL_SetSurfacePalette(pUpper, gpScreen->format->palette);
-         SDL_SetSurfacePalette(pLower, gpScreen->format->palette);
-#else
-         SDL_SetPalette(pUpper, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-         SDL_SetPalette(pLower, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-      }
-
-      UTIL_Delay(50);
-   }
-
-   gpGlobals->wScreenWave = 0;
-
-   SDL_FreeSurface(pUpper);
-   SDL_FreeSurface(pLower);
-
-   free(buf);
-   free(bufGirl);
-}
-
-VOID
-PAL_EndingScreen(
-   VOID
-)
-{
-	AUDIO_PlayMusic(0x1a, TRUE, 0);
-	PAL_RNGPlay(gpGlobals->iCurPlayingRNG, 110, 150, 7);
-	PAL_RNGPlay(gpGlobals->iCurPlayingRNG, 151, 999, 9);
-
-	PAL_FadeOut(2);
-
-	AUDIO_PlayMusic(0x19, TRUE, 0);
-
-	PAL_ShowFBP(75, 0);
-	PAL_FadeIn(5, FALSE, 1);
-	PAL_ScrollFBP(74, 0xf, TRUE);
-
-	PAL_FadeOut(1);
-
-	SDL_FillRect(gpScreen, NULL, 0);
-	gpGlobals->wNumPalette = 4;
-	gpGlobals->fNeedToFadeIn = TRUE;
-	PAL_EndingAnimation();
-
-	AUDIO_PlayMusic(0, FALSE, 2);
-	PAL_ColorFade(7, 15, FALSE);
-
-	if (!AUDIO_PlayCDTrack(2))
-	{
-		AUDIO_PlayMusic(0x11, TRUE, 0);
-	}
-
-	SDL_FillRect(gpScreen, NULL, 0);
-	PAL_SetPalette(0, FALSE);
-	PAL_RNGPlay(0xb, 0, 999, 7);
-
-	PAL_FadeOut(2);
-
-	SDL_FillRect(gpScreen, NULL, 0);
-	gpGlobals->wNumPalette = 8;
-	gpGlobals->fNeedToFadeIn = TRUE;
-	PAL_RNGPlay(10, 0, 999, 6);
-
-	PAL_EndingSetEffectSprite(0);
-	PAL_ShowFBP(77, 10);
-
-	VIDEO_BackupScreen();
-
-	PAL_EndingSetEffectSprite(0x27b);
-	PAL_ShowFBP(76, 7);
-
-	PAL_SetPalette(5, FALSE);
-	PAL_ShowFBP(73, 7);
-	PAL_ScrollFBP(72, 0xf, TRUE);
-
-	PAL_ShowFBP(71, 7);
-	PAL_ShowFBP(68, 7);
-
-	PAL_EndingSetEffectSprite(0);
-	PAL_ShowFBP(68, 6);
-
-	PAL_WaitForKey(0);
-	AUDIO_PlayMusic(0, FALSE, 1);
-	UTIL_Delay(500);
-
-	if (!AUDIO_PlayCDTrack(13))
-	{
-		AUDIO_PlayMusic(9, TRUE, 0);
-	}
-
-	PAL_ScrollFBP(67, 0xf, TRUE);
-	PAL_ScrollFBP(66, 0xf, TRUE);
-	PAL_ScrollFBP(65, 0xf, TRUE);
-	PAL_ScrollFBP(64, 0xf, TRUE);
-	PAL_ScrollFBP(63, 0xf, TRUE);
-	PAL_ScrollFBP(62, 0xf, TRUE);
-	PAL_ScrollFBP(61, 0xf, TRUE);
-	PAL_ScrollFBP(60, 0xf, TRUE);
-	PAL_ScrollFBP(59, 0xf, TRUE);
-
-	AUDIO_PlayMusic(0, FALSE, 6);
-	PAL_FadeOut(3);
-}
-

+ 1 - 0
ending.c

@@ -0,0 +1 @@
+src/ending.c

+ 0 - 61
ending.h

@@ -1,61 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef ENDGAME_H
-#define ENDGAME_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-VOID
-PAL_EndingSetEffectSprite(
-   WORD         wSpriteNum
-);
-
-VOID
-PAL_ShowFBP(
-   WORD         wChunkNum,
-   WORD         wFade
-);
-
-VOID
-PAL_ScrollFBP(
-   WORD         wChunkNum,
-   WORD         wScrollSpeed,
-   BOOL         fScrollDown
-);
-
-VOID
-PAL_EndingAnimation(
-   VOID
-);
-
-VOID
-PAL_EndingScreen(
-   VOID
-);
-
-#ifdef __cplusplus
-}
-#endif
-#endif

+ 1 - 0
ending.h

@@ -0,0 +1 @@
+src/ending.h

File diff suppressed because it is too large
+ 0 - 4961
fight.c


+ 1 - 0
fight.c

@@ -0,0 +1 @@
+src/fight.c

+ 0 - 108
fight.h

@@ -1,108 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef FIGHT_H
-#define FIGHT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-INT
-PAL_BattleSelectAutoTarget(
-   VOID
-);
-
-#ifndef PAL_CLASSIC
-
-VOID
-PAL_UpdateTimeChargingUnit(
-   VOID
-);
-
-FLOAT
-PAL_GetTimeChargingSpeed(
-   WORD           wDexterity
-);
-
-#endif
-
-VOID
-PAL_BattleUpdateFighters(
-   VOID
-);
-
-VOID
-PAL_BattlePlayerCheckReady(
-   VOID
-);
-
-VOID
-PAL_BattleStartFrame(
-   VOID
-);
-
-VOID
-PAL_BattleCommitAction(
-   BOOL         fRepeat
-);
-
-VOID
-PAL_BattlePlayerPerformAction(
-   WORD         wPlayerIndex
-);
-
-VOID
-PAL_BattleEnemyPerformAction(
-   WORD         wEnemyIndex
-);
-
-VOID
-PAL_BattleShowPlayerPreMagicAnim(
-   WORD         wPlayerIndex,
-   BOOL         fSummon
-);
-
-VOID
-PAL_BattleDelay(
-   WORD       wDuration,
-   WORD       wObjectID,
-   BOOL       fUpdateGesture
-);
-
-VOID
-PAL_BattleStealFromEnemy(
-   WORD           wTarget,
-   WORD           wStealRate
-);
-
-VOID
-PAL_BattleSimulateMagic(
-   SHORT      sTarget,
-   WORD       wMagicObjectID,
-   WORD       wBaseDamage
-);
-
-#ifdef __cplusplus
-}
-#endif
-#endif

+ 1 - 0
fight.h

@@ -0,0 +1 @@
+src/fight.h

+ 0 - 414
font.c

@@ -1,414 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
-//
-
-#include "font.h"
-#include "util.h"
-#include "text.h"
-
-#define _FONT_C
-
-#include "fontglyph.h"
-#include "ascii.h"
-
-static int _font_height = 16;
-
-uint8_t reverseBits(uint8_t x) {
-    uint8_t y = 0;
-    for(int i = 0 ; i < 8; i++){
-        y <<= 1;
-        y |= (x & 1);
-        x >>= 1;
-    }
-    return y;
-}
-INT
-PAL_InitEmbeddedFont(
-   VOID
-)
-/*++
-  Purpose:
-
-    None.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    Always return 0.
-
---*/
-{
-	FILE *fp;
-	char *char_buf;
-	wchar_t *wchar_buf;
-	int nBytes, nChars, i;
-
-	//
-	// Load the wor16.asc file.
-	//
-	if (NULL == (fp = UTIL_OpenFile("wor16.asc")))
-	{
-		return 0;
-	}
-
-	//
-	// Get the size of wor16.asc file.
-	//
-	fseek(fp, 0, SEEK_END);
-	nBytes = ftell(fp);
-
-	//
-	// Allocate buffer & read all the character codes.
-	//
-	if (NULL == (char_buf = (char *)malloc(nBytes)))
-	{
-		fclose(fp);
-		return 0;
-	}
-	fseek(fp, 0, SEEK_SET);
-	fread(char_buf, 1, nBytes, fp);
-
-	//
-	// Close wor16.asc file.
-	//
-	fclose(fp);
-
-	//
-	// Convert characters into unicode
-	//
-	nChars = PAL_MultiByteToWideChar(char_buf, nBytes, NULL, 0);
-	if (NULL == (wchar_buf = (wchar_t *)malloc(nChars * sizeof(wchar_t))))
-	{
-		free(char_buf);
-		return 0;
-	}
-	PAL_MultiByteToWideChar(char_buf, nBytes, wchar_buf, nChars);
-	free(char_buf);
-
-	//
-	// Read bitmaps from wor16.fon file.
-	//
-	fp = UTIL_OpenFile("wor16.fon");
-
-	//
-	// The font glyph data begins at offset 0x682 in wor16.fon.
-	//
-	fseek(fp, 0x682, SEEK_SET);
-
-	//
-	// Replace the original fonts
-	//
-	for (i = 0; i < nChars; i++)
-	{
-		wchar_t w = (wchar_buf[i] >= unicode_upper_base) ? (wchar_buf[i] - unicode_upper_base + 0xd800) : wchar_buf[i];
-		fread(unicode_font[w], 30, 1, fp);
-		unicode_font[w][30] = 0;
-		unicode_font[w][31] = 0;
-	}
-	free(wchar_buf);
-
-	fclose(fp);
-
-	for (i = 0; i < 0x80; i++)
-	{
-		int j=-1;while(j++<16)unicode_font[i][j]=reverseBits(iso_font[i*15+j]);
-		unicode_font[i][15] = 0;
-	}
-	_font_height = 15;
-
-	return 0;
-}
-
-INT
-PAL_LoadBdfFont(
-   LPCSTR      pszBdfFileName
-)
-/*++
-  Purpose:
-
-    Loads a BDF bitmap font file.
-
-  Parameters:
-
-    [IN]  pszBdfFileName - Name of BDF bitmap font file..
-
-  Return value:
-
-    0 = success, -1 = failure.
-
---*/
-{
-   char buf[4096];
-   int state = 0;
-   int codepage = -1;
-
-   DWORD dwEncoding = 0;
-   BYTE bFontGlyph[32] = {0};
-   int iCurHeight = 0;
-
-   FILE *fp = UTIL_OpenFileForMode(pszBdfFileName, "r");
-
-   if (fp == NULL)
-   {
-      return -1;
-   }
-
-   while (fgets(buf, 4096, fp) != NULL)
-   {
-      if (state == 0)
-      {
-         if (strncmp(buf, "CHARSET_REGISTRY", 16) == 0)
-         {
-            if (strstr(buf, "Big5") != NULL)
-            {
-               codepage = CP_BIG5;
-            }
-            else if (strstr(buf, "BIG5") != NULL)
-            {
-               codepage = CP_BIG5;
-            }
-            //else if (strstr(buf, "JISX0208") != NULL)
-            //
-            //  codepage = CP_JISX0208;
-            //}
-         }
-         else if (strncmp(buf, "ENCODING", 8) == 0)
-         {
-            dwEncoding = atoi(buf + 8);
-         }
-         else if (strncmp(buf, "BITMAP", 6) == 0)
-         {
-            state = 1;
-            iCurHeight = 0;
-            memset(bFontGlyph, 0, sizeof(bFontGlyph));
-         }
-      }
-      else if (state == 1)
-      {
-         if (strncmp(buf, "ENDCHAR", 7) == 0)
-         {
-            //
-            // Replace the original fonts
-            //
-            BYTE szCp[3];
-            szCp[0] = (dwEncoding >> 8) & 0xFF;
-            szCp[1] = dwEncoding & 0xFF;
-            szCp[2] = 0;
-            wchar_t wc[2] = { 0 };
-            PAL_MultiByteToWideCharCP(codepage, (LPCSTR)szCp, 2, wc, 1);
-            if (wc[0] != 0)
-            {
-               wchar_t w = (wc[0] >= unicode_upper_base) ? (wc[0] - unicode_upper_base + 0xd800) : wc[0];
-               memcpy(unicode_font[w], bFontGlyph, sizeof(bFontGlyph));
-            }
-
-            state = 0;
-         }
-         else
-         {
-            if (iCurHeight < 16)
-            {
-               WORD wCode = strtoul(buf, NULL, 16);
-               bFontGlyph[iCurHeight * 2] = (wCode >> 8);
-               bFontGlyph[iCurHeight * 2 + 1] = (wCode & 0xFF);
-               iCurHeight++;
-            }
-         }
-      }
-   }
-
-   _font_height = 16;
-   fclose(fp);
-   return 0;
-}
-
-VOID
-PAL_FreeFont(
-   VOID
-)
-/*++
-  Purpose:
-
-    None.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-}
-
-VOID
-PAL_DrawCharOnSurface(
-   WORD                     wChar,
-   SDL_Surface             *lpSurface,
-   PAL_POS                  pos,
-   BYTE                     bColor,
-   BOOL                     fUse8x8Font
-)
-/*++
-  Purpose:
-
-    Draw a Unicode character on a surface.
-
-  Parameters:
-
-    [IN]  wChar - the unicode character to be drawn.
-
-    [OUT] lpSurface - the destination surface.
-
-    [IN]  pos - the destination location of the surface.
-
-    [IN]  bColor - the color of the character.
-
-  Return value:
-
-    None.
-
---*/
-{
-	int       i, j;
-	int       x = PAL_X(pos), y = PAL_Y(pos);
-
-	//
-	// Check for NULL pointer & invalid char code.
-	//
-	if (lpSurface == NULL || (wChar >= 0xd800 && wChar < unicode_upper_base) ||
-		wChar >= unicode_upper_top || (_font_height == 8 && wChar >= 0x100))
-	{
-		return;
-	}
-
-	//
-	// Locate for this character in the font lib.
-	//
-	if (wChar >= unicode_upper_base)
-	{
-		wChar -= (unicode_upper_base - 0xd800);
-	}
-
-	//
-	// Draw the character to the surface.
-	//
-	LPBYTE dest = (LPBYTE)lpSurface->pixels + y * lpSurface->pitch + x;
-	LPBYTE top = (LPBYTE)lpSurface->pixels + lpSurface->h * lpSurface->pitch;
-	if (fUse8x8Font)
-	{
-		for (i = 0; i < 8 && dest < top; i++, dest += lpSurface->pitch)
-		{
-			for (j = 0; j < 8 && x + j < lpSurface->w; j++)
-			{
-				if (iso_font_8x8[wChar][i] & (1 << j))
-				{
-					dest[j] = bColor;
-				}
-			}
-		}
-	}
-	else
-	{
-		if (font_width[wChar] == 32)
-		{
-			for (i = 0; i < _font_height * 2 && dest < top; i += 2, dest += lpSurface->pitch)
-			{
-				for (j = 0; j < 8 && x + j < lpSurface->w; j++)
-				{
-					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)
-			{
-				for (j = 0; j < 8 && x + j < lpSurface->w; j++)
-				{
-					if (unicode_font[wChar][i] & (1 << (7 - j)))
-					{
-						dest[j] = bColor;
-					}
-				}
-			}
-		}
-	}
-}
-
-INT
-PAL_CharWidth(
-   WORD                     wChar
-)
-/*++
-  Purpose:
-
-    Get the text width of a character.
-
-  Parameters:
-
-    [IN]  wChar - the unicode character for width calculation.
-
-  Return value:
-
-    The width of the character, 16 for full-width char and 8 for half-width char.
-
---*/
-{
-	if ((wChar >= 0xd800 && wChar < unicode_upper_base) || wChar >= unicode_upper_top)
-	{
-		return 0;
-	}
-
-	//
-	// Locate for this character in the font lib.
-	//
-	if (wChar >= unicode_upper_base)
-	{
-		wChar -= (unicode_upper_base - 0xd800);
-	}
-
-	return font_width[wChar] >> 1;
-}
-
-INT
-PAL_FontHeight(
-   VOID
-)
-{
-	return _font_height;
-}

+ 1 - 0
font.c

@@ -0,0 +1 @@
+src/font.c

+ 0 - 73
font.h

@@ -1,73 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
-//
-
-#ifndef FONT_H
-#define FONT_H
-
-#include "common.h"
-#include "palcommon.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-INT
-PAL_InitEmbeddedFont(
-   VOID
-);
-
-INT
-PAL_LoadBdfFont(
-   LPCSTR      pszBdfFileName
-);
-
-VOID
-PAL_FreeFont(
-   VOID
-);
-
-VOID
-PAL_DrawCharOnSurface(
-   WORD                     wChar,
-   SDL_Surface             *lpSurface,
-   PAL_POS                  pos,
-   BYTE                     bColor,
-   BOOL                     fUse8x8Font
-);
-
-INT
-PAL_CharWidth(
-   WORD                     wChar
-);
-
-INT
-PAL_FontHeight(
-   VOID
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
font.h

@@ -0,0 +1 @@
+src/font.h

File diff suppressed because it is too large
+ 0 - 58920
fontglyph.h


+ 1 - 0
fontglyph.h

@@ -0,0 +1 @@
+src/fontglyph.h

+ 0 - 129
game.c

@@ -1,129 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "main.h"
-
-static VOID
-PAL_GameStart(
-   VOID
-)
-/*++
-  Purpose:
-
-    Do some initialization work when game starts (new game or load game).
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   PAL_SetLoadFlags(kLoadScene | kLoadPlayerSprite);
-
-   if (!gpGlobals->fEnteringScene)
-   {
-      //
-      // Fade in music if the player has loaded an old game.
-      //
-      AUDIO_PlayMusic(gpGlobals->wNumMusic, TRUE, 1);
-   }
-
-   gpGlobals->fNeedToFadeIn = TRUE;
-   gpGlobals->dwFrameNum = 0;
-}
-
-VOID
-PAL_GameMain(
-   VOID
-)
-/*++
-  Purpose:
-
-    The game entry routine.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   DWORD       dwTime;
-
-   //
-   // Show the opening menu.
-   //
-   gpGlobals->bCurrentSaveSlot = (BYTE)PAL_OpeningMenu();
-   gpGlobals->fInMainGame = TRUE;
-
-   //
-   // Initialize game data and set the flags to load the game resources.
-   //
-   PAL_InitGameData(gpGlobals->bCurrentSaveSlot);
-
-   //
-   // Run the main game loop.
-   //
-   dwTime = SDL_GetTicks();
-   while (TRUE)
-   {
-      //
-      // Do some initialization at game start.
-      //
-      if (gpGlobals->fGameStart)
-      {
-         PAL_GameStart();
-         gpGlobals->fGameStart = FALSE;
-      }
-
-      //
-      // Load the game resources if needed.
-      //
-      PAL_LoadResources();
-
-      //
-      // Clear the input state of previous frame.
-      //
-      PAL_ClearKeyState();
-
-      //
-      // Wait for the time of one frame. Accept input here.
-      //
-      PAL_DelayUntil(dwTime);
-
-      //
-      // Set the time of the next frame.
-      //
-      dwTime = SDL_GetTicks() + FRAME_TIME;
-
-      //
-      // Run the main frame routine.
-      //
-      PAL_StartFrame();
-   }
-}

+ 1 - 0
game.c

@@ -0,0 +1 @@
+src/game.c

+ 0 - 35
game.h

@@ -1,35 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef GAME_H
-#define GAME_H
-
-#include "common.h"
-
-#define    FPS             10
-#define    FRAME_TIME      (1000 / FPS)
-
-VOID
-PAL_GameMain(
-   VOID
-);
-
-#endif

+ 1 - 0
game.h

@@ -0,0 +1 @@
+src/game.h

File diff suppressed because it is too large
+ 0 - 2276
global.c


+ 1 - 0
global.c

@@ -0,0 +1 @@
+src/global.c

+ 0 - 803
global.h

@@ -1,803 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
-//
-
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-#include "common.h"
-#include "palcommon.h"
-#include "map.h"
-#include "ui.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-//
-// SOME NOTES ON "AUTO SCRIPT" AND "TRIGGER SCRIPT":
-//
-// Auto scripts are executed automatically in each frame.
-//
-// Trigger scripts are only executed when the event is triggered (player touched
-// an event object, player triggered an event script by pressing Spacebar).
-//
-
-// maximum number of players in party
-#define     MAX_PLAYERS_IN_PARTY         3
-
-// total number of possible player roles
-#define     MAX_PLAYER_ROLES             6
-
-// totally number of playable player roles
-#define     MAX_PLAYABLE_PLAYER_ROLES    5
-
-// maximum entries of inventory
-#define     MAX_INVENTORY                256
-
-// maximum items in a store
-#define     MAX_STORE_ITEM               9
-
-// total number of magic attributes
-#define     NUM_MAGIC_ELEMENTAL          5
-
-// maximum number of enemies in a team
-#define     MAX_ENEMIES_IN_TEAM          5
-
-// maximum number of equipments for a player
-#define     MAX_PLAYER_EQUIPMENTS        6
-
-// maximum number of magics for a player
-#define     MAX_PLAYER_MAGICS            32
-
-// maximum number of scenes
-#define     MAX_SCENES                   300
-
-// maximum number of objects
-#define     MAX_OBJECTS                  600
-
-// maximum number of event objects (should be somewhat more than the original,
-// as there are some modified versions which has more)
-#define     MAX_EVENT_OBJECTS            5500
-
-// maximum number of effective poisons to players
-#define     MAX_POISONS                  16
-
-// maximum number of level
-#define     MAX_LEVELS                   99
-
-#define     OBJECT_ITEM_START            0x3D
-#define     OBJECT_ITEM_END              0x126
-#define     OBJECT_MAGIC_START           0x127
-#define     OBJECT_MAGIC_END             0x18D
-
-#define     MINIMAL_WORD_COUNT           (MAX_OBJECTS + 13)
-
-// status of characters
-typedef enum tagSTATUS
-{
-   kStatusConfused = 0,  // attack friends randomly
-#ifdef PAL_CLASSIC
-   kStatusParalyzed,     // paralyzed
-#else
-   kStatusSlow,          // slower
-#endif
-   kStatusSleep,         // not allowed to move
-   kStatusSilence,       // cannot use magic
-   kStatusPuppet,        // for dead players only, continue attacking
-   kStatusBravery,       // more power for physical attacks
-   kStatusProtect,       // more defense value
-   kStatusHaste,         // faster
-   kStatusDualAttack,    // dual attack
-   kStatusAll
-} STATUS;
-
-#ifndef PAL_CLASSIC
-#define kStatusParalyzed kStatusSleep
-#endif
-
-// body parts of equipments
-typedef enum tagBODYPART
-{
-   kBodyPartHead     = 0,
-   kBodyPartBody,
-   kBodyPartShoulder,
-   kBodyPartHand,
-   kBodyPartFeet,
-   kBodyPartWear,
-   kBodyPartExtra,
-} BODYPART;
-
-// state of event object, used by the sState field of the EVENTOBJECT struct
-typedef enum tagOBJECTSTATE
-{
-   kObjStateHidden               = 0,
-   kObjStateNormal               = 1,
-   kObjStateBlocker              = 2
-} OBJECTSTATE, *LPOBJECTSTATE;
-
-typedef enum tagTRIGGERMODE
-{
-   kTriggerNone                  = 0,
-   kTriggerSearchNear            = 1,
-   kTriggerSearchNormal          = 2,
-   kTriggerSearchFar             = 3,
-   kTriggerTouchNear             = 4,
-   kTriggerTouchNormal           = 5,
-   kTriggerTouchFar              = 6,
-   kTriggerTouchFarther          = 7,
-   kTriggerTouchFarthest         = 8
-} TRIGGERMODE;
-
-typedef struct tagEVENTOBJECT
-{
-   SHORT        sVanishTime;         // vanish time (?)
-   WORD         x;                   // X coordinate on the map
-   WORD         y;                   // Y coordinate on the map
-   SHORT        sLayer;              // layer value
-   WORD         wTriggerScript;      // Trigger script entry
-   WORD         wAutoScript;         // Auto script entry
-   SHORT        sState;              // state of this object
-   WORD         wTriggerMode;        // trigger mode
-   WORD         wSpriteNum;          // number of the sprite
-   USHORT       nSpriteFrames;       // total number of frames of the sprite
-   WORD         wDirection;          // direction
-   WORD         wCurrentFrameNum;    // current frame number
-   USHORT       nScriptIdleFrame;    // count of idle frames, used by trigger script
-   WORD         wSpritePtrOffset;    // FIXME: ???
-   USHORT       nSpriteFramesAuto;   // total number of frames of the sprite, used by auto script
-   WORD         wScriptIdleFrameCountAuto;     // count of idle frames, used by auto script
-} EVENTOBJECT, *LPEVENTOBJECT;
-
-typedef struct tagSCENE
-{
-   WORD         wMapNum;         // number of the map
-   WORD         wScriptOnEnter;  // when entering this scene, execute script from here
-   WORD         wScriptOnTeleport;  // when teleporting out of this scene, execute script from here
-   WORD         wEventObjectIndex;  // event objects in this scene begins from number wEventObjectIndex + 1
-} SCENE, *LPSCENE;
-
-// object including system strings, players, items, magics, enemies and poison scripts.
-
-// system strings and players
-typedef struct tagOBJECT_PLAYER
-{
-   WORD         wReserved[2];    // always zero
-   WORD         wScriptOnFriendDeath; // when friends in party dies, execute script from here
-   WORD         wScriptOnDying;  // when dying, execute script from here
-} OBJECT_PLAYER;
-
-typedef enum tagITEMFLAG
-{
-   kItemFlagUsable          = (1 << 0),
-   kItemFlagEquipable       = (1 << 1),
-   kItemFlagThrowable       = (1 << 2),
-   kItemFlagConsuming       = (1 << 3),
-   kItemFlagApplyToAll      = (1 << 4),
-   kItemFlagSellable        = (1 << 5),
-   kItemFlagEquipableByPlayerRole_First  = (1 << 6)
-} ITEMFLAG;
-
-// items
-typedef struct tagOBJECT_ITEM_DOS
-{
-   WORD         wBitmap;         // bitmap number in BALL.MKF
-   WORD         wPrice;          // price
-   WORD         wScriptOnUse;    // script executed when using this item
-   WORD         wScriptOnEquip;  // script executed when equipping this item
-   WORD         wScriptOnThrow;  // script executed when throwing this item to enemy
-   WORD         wFlags;          // flags
-} OBJECT_ITEM_DOS;
-
-// items
-typedef struct tagOBJECT_ITEM
-{
-	WORD         wBitmap;         // bitmap number in BALL.MKF
-	WORD         wPrice;          // price
-	WORD         wScriptOnUse;    // script executed when using this item
-	WORD         wScriptOnEquip;  // script executed when equipping this item
-	WORD         wScriptOnThrow;  // script executed when throwing this item to enemy
-	WORD         wScriptDesc;     // description script
-	WORD         wFlags;          // flags
-} OBJECT_ITEM;
-
-typedef enum tagMAGICFLAG
-{
-   kMagicFlagUsableOutsideBattle        = (1 << 0),
-   kMagicFlagUsableInBattle             = (1 << 1),
-   kMagicFlagUsableToEnemy              = (1 << 3),
-   kMagicFlagApplyToAll                 = (1 << 4),
-} MAGICFLAG;
-
-// magics
-typedef struct tagOBJECT_MAGIC_DOS
-{
-   WORD         wMagicNumber;      // magic number, according to DATA.MKF #3
-   WORD         wReserved1;        // always zero
-   WORD         wScriptOnSuccess;  // when magic succeed, execute script from here
-   WORD         wScriptOnUse;      // when use this magic, execute script from here
-   WORD         wReserved2;        // always zero
-   WORD         wFlags;            // flags
-} OBJECT_MAGIC_DOS;
-
-// magics
-typedef struct tagOBJECT_MAGIC
-{
-	WORD         wMagicNumber;      // magic number, according to DATA.MKF #3
-	WORD         wReserved1;        // always zero
-	WORD         wScriptOnSuccess;  // when magic succeed, execute script from here
-	WORD         wScriptOnUse;      // when use this magic, execute script from here
-	WORD         wScriptDesc;       // description script
-	WORD         wReserved2;        // always zero
-	WORD         wFlags;            // flags
-} OBJECT_MAGIC;
-
-// enemies
-typedef struct tagOBJECT_ENEMY
-{
-   WORD         wEnemyID;        // ID of the enemy, according to DATA.MKF #1.
-                                 // Also indicates the bitmap number in ABC.MKF.
-   WORD         wResistanceToSorcery;  // resistance to sorcery and poison (0 min, 10 max)
-   WORD         wScriptOnTurnStart;    // script executed when turn starts
-   WORD         wScriptOnBattleEnd;    // script executed when battle ends
-   WORD         wScriptOnReady;        // script executed when the enemy is ready
-} OBJECT_ENEMY;
-
-// poisons (scripts executed in each round)
-typedef struct tagOBJECT_POISON
-{
-   WORD         wPoisonLevel;    // level of the poison
-   WORD         wColor;          // color of avatars
-   WORD         wPlayerScript;   // script executed when player has this poison (per round)
-   WORD         wReserved;       // always zero
-   WORD         wEnemyScript;    // script executed when enemy has this poison (per round)
-} OBJECT_POISON;
-
-typedef union tagOBJECT_DOS
-{
-	WORD              rgwData[6];
-	OBJECT_PLAYER     player;
-	OBJECT_ITEM_DOS   item;
-	OBJECT_MAGIC_DOS  magic;
-	OBJECT_ENEMY      enemy;
-	OBJECT_POISON     poison;
-} OBJECT_DOS, *LPOBJECT_DOS;
-
-typedef union tagOBJECT
-{
-	WORD              rgwData[7];
-	OBJECT_PLAYER     player;
-	OBJECT_ITEM       item;
-	OBJECT_MAGIC      magic;
-	OBJECT_ENEMY      enemy;
-	OBJECT_POISON     poison;
-} OBJECT, *LPOBJECT;
-
-typedef struct tagSCRIPTENTRY
-{
-   WORD          wOperation;     // operation code
-   WORD          rgwOperand[3];  // operands
-} SCRIPTENTRY, *LPSCRIPTENTRY;
-
-typedef struct tagINVENTORY
-{
-   WORD          wItem;             // item object code
-   USHORT        nAmount;           // amount of this item
-   USHORT        nAmountInUse;      // in-use amount of this item
-} INVENTORY, *LPINVENTORY;
-
-typedef struct tagSTORE
-{
-   WORD          rgwItems[MAX_STORE_ITEM];
-} STORE, *LPSTORE;
-
-typedef struct tagENEMY
-{
-   WORD        wIdleFrames;         // total number of frames when idle
-   WORD        wMagicFrames;        // total number of frames when using magics
-   WORD        wAttackFrames;       // total number of frames when doing normal attack
-   WORD        wIdleAnimSpeed;      // speed of the animation when idle
-   WORD        wActWaitFrames;      // FIXME: ???
-   WORD        wYPosOffset;
-   SHORT       wAttackSound;        // sound played when this enemy uses normal attack
-   SHORT       wActionSound;        // FIXME: ???
-   SHORT       wMagicSound;         // sound played when this enemy uses magic
-   SHORT       wDeathSound;         // sound played when this enemy dies
-   SHORT       wCallSound;          // sound played when entering the battle
-   WORD        wHealth;             // total HP of the enemy
-   WORD        wExp;                // How many EXPs we'll get for beating this enemy
-   WORD        wCash;               // how many cashes we'll get for beating this enemy
-   WORD        wLevel;              // this enemy's level
-   WORD        wMagic;              // this enemy's magic number
-   WORD        wMagicRate;          // chance for this enemy to use magic
-   WORD        wAttackEquivItem;    // equivalence item of this enemy's normal attack
-   WORD        wAttackEquivItemRate;// chance for equivalence item
-   WORD        wStealItem;          // which item we'll get when stealing from this enemy
-   WORD        nStealItem;          // total amount of the items which can be stolen
-   WORD        wAttackStrength;     // normal attack strength
-   WORD        wMagicStrength;      // magical attack strength
-   WORD        wDefense;            // resistance to all kinds of attacking
-   WORD        wDexterity;          // dexterity
-   WORD        wFleeRate;           // chance for successful fleeing
-   WORD        wPoisonResistance;   // resistance to poison
-   WORD        wElemResistance[NUM_MAGIC_ELEMENTAL]; // resistance to elemental magics
-   WORD        wPhysicalResistance; // resistance to physical attack
-   WORD        wDualMove;           // whether this enemy can do dual move or not
-   WORD        wCollectValue;       // value for collecting this enemy for items
-} ENEMY, *LPENEMY;
-
-typedef struct tagENEMYTEAM
-{
-   WORD        rgwEnemy[MAX_ENEMIES_IN_TEAM];
-} ENEMYTEAM, *LPENEMYTEAM;
-
-typedef WORD PLAYERS[MAX_PLAYER_ROLES];
-
-typedef struct tagPLAYERROLES
-{
-   PLAYERS            rgwAvatar;             // avatar (shown in status view)
-   PLAYERS            rgwSpriteNumInBattle;  // sprite displayed in battle (in F.MKF)
-   PLAYERS            rgwSpriteNum;          // sprite displayed in normal scene (in MGO.MKF)
-   PLAYERS            rgwName;               // name of player class (in WORD.DAT)
-   PLAYERS            rgwAttackAll;          // whether player can attack everyone in a bulk or not
-   PLAYERS            rgwUnknown1;           // FIXME: ???
-   PLAYERS            rgwLevel;              // level
-   PLAYERS            rgwMaxHP;              // maximum HP
-   PLAYERS            rgwMaxMP;              // maximum MP
-   PLAYERS            rgwHP;                 // current HP
-   PLAYERS            rgwMP;                 // current MP
-   WORD               rgwEquipment[MAX_PLAYER_EQUIPMENTS][MAX_PLAYER_ROLES]; // equipments
-   PLAYERS            rgwAttackStrength;     // normal attack strength
-   PLAYERS            rgwMagicStrength;      // magical attack strength
-   PLAYERS            rgwDefense;            // resistance to all kinds of attacking
-   PLAYERS            rgwDexterity;          // dexterity
-   PLAYERS            rgwFleeRate;           // chance of successful fleeing
-   PLAYERS            rgwPoisonResistance;   // resistance to poison
-   WORD               rgwElementalResistance[NUM_MAGIC_ELEMENTAL][MAX_PLAYER_ROLES]; // resistance to elemental magics
-   PLAYERS            rgwUnknown2;           // FIXME: ???
-   PLAYERS            rgwUnknown3;           // FIXME: ???
-   PLAYERS            rgwUnknown4;           // FIXME: ???
-   PLAYERS            rgwCoveredBy;          // who will cover me when I am low of HP or not sane
-   WORD               rgwMagic[MAX_PLAYER_MAGICS][MAX_PLAYER_ROLES]; // magics
-   PLAYERS            rgwWalkFrames;         // walk frame (???)
-   PLAYERS            rgwCooperativeMagic;   // cooperative magic
-   PLAYERS            rgwUnknown5;           // FIXME: ???
-   PLAYERS            rgwUnknown6;           // FIXME: ???
-   PLAYERS            rgwDeathSound;         // sound played when player dies
-   PLAYERS            rgwAttackSound;        // sound played when player attacks
-   PLAYERS            rgwWeaponSound;        // weapon sound (???)
-   PLAYERS            rgwCriticalSound;      // sound played when player make critical hits
-   PLAYERS            rgwMagicSound;         // sound played when player is casting a magic
-   PLAYERS            rgwCoverSound;         // sound played when player cover others
-   PLAYERS            rgwDyingSound;         // sound played when player is dying
-} PLAYERROLES, *LPPLAYERROLES;
-
-typedef enum tagMAGIC_TYPE
-{
-   kMagicTypeNormal           = 0,
-   kMagicTypeAttackAll        = 1,  // draw the effect on each of the enemies
-   kMagicTypeAttackWhole      = 2,  // draw the effect on the whole enemy team
-   kMagicTypeAttackField      = 3,  // draw the effect on the battle field
-   kMagicTypeApplyToPlayer    = 4,  // the magic is used on one player
-   kMagicTypeApplyToParty     = 5,  // the magic is used on the whole party
-   kMagicTypeTrance           = 8,  // trance the player
-   kMagicTypeSummon           = 9,  // summon
-} MAGIC_TYPE;
-
-typedef struct tagMAGIC
-{
-   WORD               wEffect;               // effect sprite
-   WORD               wType;                 // type of this magic
-   WORD               wXOffset;
-   WORD               wYOffset;
-   WORD               wSummonEffect;         // summon effect sprite (in F.MKF)
-   SHORT              wSpeed;                // speed of the effect
-   WORD               wKeepEffect;           // FIXME: ???
-   WORD               wFireDelay;            // start frame of the magic fire stage
-   WORD               wEffectTimes;          // total times of effect
-   WORD               wShake;                // shake screen
-   WORD               wWave;                 // wave screen
-   WORD               wUnknown;              // FIXME: ???
-   WORD               wCostMP;               // MP cost
-   WORD               wBaseDamage;           // base damage
-   WORD               wElemental;            // elemental (0 = No Elemental, last = poison)
-   SHORT              wSound;                // sound played when using this magic
-} MAGIC, *LPMAGIC;
-
-typedef struct tagBATTLEFIELD
-{
-   WORD               wScreenWave;                      // level of screen waving
-   SHORT              rgsMagicEffect[NUM_MAGIC_ELEMENTAL]; // effect of attributed magics
-} BATTLEFIELD, *LPBATTLEFIELD;
-
-// magics learned when level up
-typedef struct tagLEVELUPMAGIC
-{
-   WORD               wLevel;    // level reached
-   WORD               wMagic;    // magic learned
-} LEVELUPMAGIC, *LPLEVELUPMAGIC;
-
-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
-{
-	PALPOS pos[MAX_ENEMIES_IN_TEAM][MAX_ENEMIES_IN_TEAM];
-} ENEMYPOS, *LPENEMYPOS;
-
-// Exp. points needed for the next level
-typedef WORD LEVELUPEXP, *LPLEVELUPEXP;
-
-// game data which is available in data files.
-typedef struct tagGAMEDATA
-{
-   LPEVENTOBJECT           lprgEventObject;
-   int                     nEventObject;
-
-   SCENE                   rgScene[MAX_SCENES];
-   OBJECT                  rgObject[MAX_OBJECTS];
-
-   LPSCRIPTENTRY           lprgScriptEntry;
-   int                     nScriptEntry;
-
-   LPSTORE                 lprgStore;
-   int                     nStore;
-
-   LPENEMY                 lprgEnemy;
-   int                     nEnemy;
-
-   LPENEMYTEAM             lprgEnemyTeam;
-   int                     nEnemyTeam;
-
-   PLAYERROLES             PlayerRoles;
-
-   LPMAGIC                 lprgMagic;
-   int                     nMagic;
-
-   LPBATTLEFIELD           lprgBattleField;
-   int                     nBattleField;
-
-   LPLEVELUPMAGIC_ALL      lprgLevelUpMagic;
-   int                     nLevelUpMagic;
-
-   ENEMYPOS                EnemyPos;
-   LEVELUPEXP              rgLevelUpExp[MAX_LEVELS + 1];
-
-   WORD                    rgwBattleEffectIndex[10][2];
-} GAMEDATA, *LPGAMEDATA;
-
-typedef struct tagFILES
-{
-   FILE            *fpFBP;      // battlefield background images
-   FILE            *fpMGO;      // sprites in scenes
-   FILE            *fpBALL;     // item bitmaps
-   FILE            *fpDATA;     // misc data
-   FILE            *fpF;        // player sprites during battle
-   FILE            *fpFIRE;     // fire effect sprites
-   FILE            *fpRGM;      // character face bitmaps
-   FILE            *fpSSS;      // script data
-} FILES, *LPFILES;
-
-// player party
-typedef struct tagPARTY
-{
-   WORD             wPlayerRole;         // player role
-   SHORT            x, y;                // position
-   WORD             wFrame;              // current frame number
-   WORD             wImageOffset;        // FIXME: ???
-} PARTY, *LPPARTY;
-
-// player trail, used for other party members to follow the main party member
-typedef struct tagTRAIL
-{
-   WORD             x, y;          // position
-   WORD             wDirection;    // direction
-} TRAIL, *LPTRAIL;
-
-typedef struct tagEXPERIENCE
-{
-   WORD         wExp;                // current experience points
-   WORD         wReserved;
-   WORD         wLevel;              // current level
-   WORD         wCount;
-} EXPERIENCE, *LPEXPERIENCE;
-
-typedef struct tagALLEXPERIENCE
-{
-   EXPERIENCE        rgPrimaryExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgHealthExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgMagicExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgAttackExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgMagicPowerExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgDefenseExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgDexterityExp[MAX_PLAYER_ROLES];
-   EXPERIENCE        rgFleeExp[MAX_PLAYER_ROLES];
-} ALLEXPERIENCE, *LPALLEXPERIENCE;
-
-typedef struct tagPOISONSTATUS
-{
-   WORD              wPoisonID;       // kind of the poison
-   WORD              wPoisonScript;   // script entry
-} POISONSTATUS, *LPPOISONSTATUS;
-
-typedef enum tagMUSICTYPE
-{
-	MUSIC_MIDI,
-	MUSIC_RIX,
-	MUSIC_MP3,
-	MUSIC_OGG,
-	MUSIC_SDLCD
-} MUSICTYPE, *LPMUSICTYPE;
-
-typedef enum tagOPLTYPE
-{
-	OPL_DOSBOX,
-	OPL_MAME,
-	OPL_DOSBOX_NEW,
-} OPLTYPE, *LPOPLTYPE;
-
-typedef struct tagGLOBALVARS
-{
-   FILES            f;
-   GAMEDATA         g;
-
-   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
-   BOOL             fInBattle;           // TRUE if in battle
-   BOOL             fAutoBattle;         // TRUE if auto-battle
-#ifndef PAL_CLASSIC
-   BYTE             bBattleSpeed;        // Battle Speed (1 = Fastest, 5 = Slowest)
-#endif
-   WORD             wLastUnequippedItem; // last unequipped item
-
-   PLAYERROLES      rgEquipmentEffect[MAX_PLAYER_EQUIPMENTS + 1]; // equipment effects
-   WORD             rgPlayerStatus[MAX_PLAYER_ROLES][kStatusAll]; // player status
-
-   PAL_POS          viewport;            // viewport coordination
-   PAL_POS          partyoffset;
-   WORD             wLayer;
-   WORD             wMaxPartyMemberIndex;// max index of members in party (0 to MAX_PLAYERS_IN_PARTY - 1)
-   PARTY            rgParty[MAX_PLAYABLE_PLAYER_ROLES]; // player party
-   TRAIL            rgTrail[MAX_PLAYABLE_PLAYER_ROLES]; // player trail
-   WORD             wPartyDirection;     // direction of the party
-   WORD             wNumScene;           // current scene number
-   WORD             wNumPalette;         // current palette number
-   BOOL             fNightPalette;       // TRUE if use the darker night palette
-   WORD             wNumMusic;           // current music number
-   WORD             wNumBattleMusic;     // current music number in battle
-   WORD             wNumBattleField;     // current battle field number
-   WORD             wCollectValue;       // value of "collected" items
-   WORD             wScreenWave;         // level of screen waving
-   SHORT            sWaveProgression;
-   WORD             wChaseRange;
-   WORD             wChasespeedChangeCycles;
-   USHORT           nFollower;
-
-   DWORD            dwCash;              // amount of cash
-
-   ALLEXPERIENCE    Exp;                 // experience status
-   POISONSTATUS     rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
-   INVENTORY        rgInventory[MAX_INVENTORY];  // inventory status
-   LPOBJECTDESC     lpObjectDesc;
-   DWORD            dwFrameNum;
-} GLOBALVARS, *LPGLOBALVARS;
-
-extern GLOBALVARS * const gpGlobals;
-
-BOOL
-PAL_IsWINVersion(
-   BOOL *pfIsWIN95
-);
-
-INT
-PAL_InitGlobals(
-   VOID
-);
-
-VOID
-PAL_FreeGlobals(
-   VOID
-);
-
-VOID
-PAL_SaveGame(
-   LPCSTR        szFileName,
-   WORD          wSavedTimes
-);
-
-VOID
-PAL_InitGameData(
-   INT           iSaveSlot
-);
-
-BOOL
-PAL_AddItemToInventory(
-   WORD          wObjectID,
-   INT           iNum
-);
-
-BOOL
-PAL_IncreaseHPMP(
-   WORD          wPlayerRole,
-   SHORT         sHP,
-   SHORT         sMP
-);
-
-INT
-PAL_GetItemAmount(
-   WORD        wItem
-);
-
-VOID
-PAL_UpdateEquipments(
-   VOID
-);
-
-VOID
-PAL_CompressInventory(
-   VOID
-);
-
-VOID
-PAL_RemoveEquipmentEffect(
-   WORD         wPlayerRole,
-   WORD         wEquipPart
-);
-
-VOID
-PAL_AddPoisonForPlayer(
-   WORD           wPlayerRole,
-   WORD           wPoisonID
-);
-
-VOID
-PAL_CurePoisonByKind(
-   WORD           wPlayerRole,
-   WORD           wPoisonID
-);
-
-VOID
-PAL_CurePoisonByLevel(
-   WORD           wPlayerRole,
-   WORD           wMaxLevel
-);
-
-BOOL
-PAL_IsPlayerPoisonedByLevel(
-   WORD           wPlayerRole,
-   WORD           wMinLevel
-);
-
-BOOL
-PAL_IsPlayerPoisonedByKind(
-   WORD           wPlayerRole,
-   WORD           wPoisonID
-);
-
-WORD
-PAL_GetPlayerAttackStrength(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerMagicStrength(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerDefense(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerDexterity(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerFleeRate(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerPoisonResistance(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerElementalResistance(
-   WORD           wPlayerRole,
-   INT            iAttrib
-);
-
-WORD
-PAL_GetPlayerBattleSprite(
-   WORD           wPlayerRole
-);
-
-WORD
-PAL_GetPlayerCooperativeMagic(
-   WORD           wPlayerRole
-);
-
-BOOL
-PAL_PlayerCanAttackAll(
-   WORD           wPlayerRole
-);
-
-BOOL
-PAL_AddMagic(
-   WORD           wPlayerRole,
-   WORD           wMagic
-);
-
-VOID
-PAL_RemoveMagic(
-   WORD           wPlayerRole,
-   WORD           wMagic
-);
-
-VOID
-PAL_SetPlayerStatus(
-   WORD         wPlayerRole,
-   WORD         wStatusID,
-   WORD         wNumRound
-);
-
-VOID
-PAL_RemovePlayerStatus(
-   WORD         wPlayerRole,
-   WORD         wStatusID
-);
-
-VOID
-PAL_ClearAllPlayerStatus(
-   VOID
-);
-
-VOID
-PAL_PlayerLevelUp(
-   WORD          wPlayerRole,
-   WORD          wNumLevel
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
global.h

@@ -0,0 +1 @@
+src/global.h

File diff suppressed because it is too large
+ 0 - 1099
input.c


+ 1 - 0
input.c

@@ -0,0 +1 @@
+src/input.c

+ 0 - 108
input.h

@@ -1,108 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef INPUT_H
-#define INPUT_H
-
-#include "common.h"
-#include "palcommon.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct tagPALINPUTSTATE
-{
-   PALDIRECTION           dir, prevdir;
-   DWORD                  dwKeyPress;
-} PALINPUTSTATE;
-
-extern volatile PALINPUTSTATE g_InputState;
-
-enum PALKEY
-{
-   kKeyMenu        = (1 << 0),
-   kKeySearch      = (1 << 1),
-   kKeyDown        = (1 << 2),
-   kKeyLeft        = (1 << 3),
-   kKeyUp          = (1 << 4),
-   kKeyRight       = (1 << 5),
-   kKeyPgUp        = (1 << 6),
-   kKeyPgDn        = (1 << 7),
-   kKeyRepeat      = (1 << 8),
-   kKeyAuto        = (1 << 9),
-   kKeyDefend      = (1 << 10),
-   kKeyUseItem     = (1 << 11),
-   kKeyThrowItem   = (1 << 12),
-   kKeyFlee        = (1 << 13),
-   kKeyStatus      = (1 << 14),
-   kKeyForce       = (1 << 15),
-   kKeyHome        = (1 << 16),
-   kKeyEnd         = (1 << 17),
-};
-
-VOID
-PAL_ClearKeyState(
-   VOID
-);
-
-VOID
-PAL_InitInput(
-   VOID
-);
-
-VOID
-PAL_ProcessEvent(
-   VOID
-);
-
-VOID
-PAL_ShutdownInput(
-   VOID
-);
-
-int
-PAL_PollEvent(
-   SDL_Event *event
-);
-
-VOID
-PAL_SetTouchBounds(
-   DWORD dwScreenWidth,
-   DWORD dwScreenHeight,
-   SDL_Rect renderRect
-);
-
-VOID
-PAL_RegisterInputFilter(
-   void (*init_filter)(),
-   int (*event_filter)(const SDL_Event *, volatile PALINPUTSTATE *),
-   void (*shutdown_filter)()
-);
-
-extern BOOL g_fUseJoystick;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
input.h

@@ -0,0 +1 @@
+src/input.h

+ 0 - 467
itemmenu.c

@@ -1,467 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
-//
-
-#include "main.h"
-
-static int     g_iNumInventory = 0;
-static WORD    g_wItemFlags = 0;
-static BOOL    g_fNoDesc = FALSE;
-
-WORD
-PAL_ItemSelectMenuUpdate(
-   VOID
-)
-/*++
-  Purpose:
-
-    Initialize the item selection menu.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    The object ID of the selected item. 0 if cancelled, 0xFFFF if not confirmed.
-
---*/
-{
-   int                i, j, k, line, item_delta;
-   WORD               wObject, wScript;
-   BYTE               bColor;
-   static BYTE        bufImage[2048];
-   static WORD        wPrevImageIndex = 0xFFFF;
-   const int          iItemsPerLine = 34 / gConfig.dwWordLength;
-   const int          iItemTextWidth = 8 * gConfig.dwWordLength + 20;
-   const int          iLinesPerPage = 7 - gConfig.ScreenLayout.ExtraItemDescLines;
-   const int          iCursorXOffset = gConfig.dwWordLength * 5 / 2;
-   const int          iAmountXOffset = gConfig.dwWordLength * 8 + 1;
-   const int          iPageLineOffset = (iLinesPerPage + 1) / 2;
-   const int          iPictureYOffset = (gConfig.ScreenLayout.ExtraItemDescLines > 1) ? (gConfig.ScreenLayout.ExtraItemDescLines - 1) * 16 : 0;
-
-   //
-   // Process input
-   //
-   if (g_InputState.dwKeyPress & kKeyUp)
-   {
-      item_delta = -iItemsPerLine;
-   }
-   else if (g_InputState.dwKeyPress & kKeyDown)
-   {
-      item_delta = iItemsPerLine;
-   }
-   else if (g_InputState.dwKeyPress & kKeyLeft)
-   {
-      item_delta = -1;
-   }
-   else if (g_InputState.dwKeyPress & kKeyRight)
-   {
-      item_delta = 1;
-   }
-   else if (g_InputState.dwKeyPress & kKeyPgUp)
-   {
-      item_delta = -(iItemsPerLine * iLinesPerPage);
-   }
-   else if (g_InputState.dwKeyPress & kKeyPgDn)
-   {
-      item_delta = iItemsPerLine * iLinesPerPage;
-   }
-   else if (g_InputState.dwKeyPress & kKeyHome)
-   {
-      item_delta = -gpGlobals->iCurInvMenuItem;
-   }
-   else if (g_InputState.dwKeyPress & kKeyEnd)
-   {
-      item_delta = g_iNumInventory - gpGlobals->iCurInvMenuItem - 1;
-   }
-   else if (g_InputState.dwKeyPress & kKeyMenu)
-   {
-      return 0;
-   }
-   else
-   {
-      item_delta = 0;
-   }
-
-   //
-   // Make sure the current menu item index is in bound
-   //
-   if (gpGlobals->iCurInvMenuItem + item_delta >= 0 &&
-       gpGlobals->iCurInvMenuItem + item_delta < g_iNumInventory)
-      gpGlobals->iCurInvMenuItem += item_delta;
-
-   //
-   // Redraw the box
-   //
-   PAL_CreateBox(PAL_XY(2, 0), iLinesPerPage - 1, 17, 1, FALSE);
-
-   //
-   // Draw the texts in the current page
-   //
-   i = gpGlobals->iCurInvMenuItem / iItemsPerLine * iItemsPerLine - iItemsPerLine * iPageLineOffset;
-   if (i < 0)
-   {
-      i = 0;
-   }
-
-   for (j = 0; j < iLinesPerPage; j++)
-   {
-      for (k = 0; k < iItemsPerLine; k++)
-      {
-         wObject = gpGlobals->rgInventory[i].wItem;
-         bColor = MENUITEM_COLOR;
-
-         if (i >= MAX_INVENTORY || wObject == 0)
-         {
-            //
-            // End of the list reached
-            //
-            j = iLinesPerPage;
-            break;
-         }
-
-         if (i == gpGlobals->iCurInvMenuItem)
-         {
-            if (!(gpGlobals->g.rgObject[wObject].item.wFlags & g_wItemFlags) ||
-               (SHORT)gpGlobals->rgInventory[i].nAmount <= (SHORT)gpGlobals->rgInventory[i].nAmountInUse)
-            {
-               //
-               // This item is not selectable
-               //
-               bColor = MENUITEM_COLOR_SELECTED_INACTIVE;
-            }
-            else
-            {
-               //
-               // This item is selectable
-               //
-               if (gpGlobals->rgInventory[i].nAmount == 0)
-               {
-                  bColor = MENUITEM_COLOR_EQUIPPEDITEM;
-               }
-               else
-               {
-                  bColor = MENUITEM_COLOR_SELECTED;
-               }
-            }
-         }
-         else if (!(gpGlobals->g.rgObject[wObject].item.wFlags & g_wItemFlags) ||
-            (SHORT)gpGlobals->rgInventory[i].nAmount <= (SHORT)gpGlobals->rgInventory[i].nAmountInUse)
-         {
-            //
-            // This item is not selectable
-            //
-            bColor = MENUITEM_COLOR_INACTIVE;
-         }
-         else if (gpGlobals->rgInventory[i].nAmount == 0)
-         {
-            bColor = MENUITEM_COLOR_EQUIPPEDITEM;
-         }
-
-         //
-         // Draw the text
-         //
-		 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
-         //
-         if (i == gpGlobals->iCurInvMenuItem)
-         {
-            PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_CURSOR),
-               gpScreen, PAL_XY(15 + iCursorXOffset + k * iItemTextWidth, 22 + j * 18));
-         }
-
-         //
-         // Draw the amount of this item
-         //
-		 if ((SHORT)gpGlobals->rgInventory[i].nAmount - (SHORT)gpGlobals->rgInventory[i].nAmountInUse > 1)
-		 {
-            PAL_DrawNumber(gpGlobals->rgInventory[i].nAmount - gpGlobals->rgInventory[i].nAmountInUse,
-               2, PAL_XY(15 + iAmountXOffset + k * iItemTextWidth, 17 + j * 18), kNumColorCyan, kNumAlignRight);
-		 }
-
-         i++;
-      }
-   }
-
-   //
-   // Draw the picture of current selected item
-   //
-   PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_ITEMBOX), gpScreen,
-      PAL_XY(5, 140 - iPictureYOffset));
-
-   wObject = gpGlobals->rgInventory[gpGlobals->iCurInvMenuItem].wItem;
-
-   if (gpGlobals->g.rgObject[wObject].item.wBitmap != wPrevImageIndex)
-   {
-      if (PAL_MKFReadChunk(bufImage, 2048,
-         gpGlobals->g.rgObject[wObject].item.wBitmap, gpGlobals->f.fpBALL) > 0)
-      {
-         wPrevImageIndex = gpGlobals->g.rgObject[wObject].item.wBitmap;
-      }
-      else
-      {
-         wPrevImageIndex = 0xFFFF;
-      }
-   }
-
-   if (wPrevImageIndex != 0xFFFF)
-   {
-      PAL_RLEBlitToSurface(bufImage, gpScreen, PAL_XY(12, 148 - iPictureYOffset));
-   }
-
-   //
-   // Draw the description of the selected item
-   //
-   if (!gConfig.fIsWIN95)
-   {
-      if (!g_fNoDesc && gpGlobals->lpObjectDesc != NULL)
-	  {
-         WCHAR szDesc[512], *next;
-         const WCHAR *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, wObject);
-
-         if (d != NULL)
-         {
-            k = 150;
-            wcscpy(szDesc, d);
-            d = szDesc;
-
-            while (TRUE)
-            {
-               next = wcschr(d, '*');
-               if (next != NULL)
-               {
-                  *next++ = '\0';
-               }
-
-               PAL_DrawText(d, PAL_XY(75, k), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
-               k += 16;
-
-               if (next == NULL)
-               {
-                  break;
-               }
-
-               d = next;
-            }
-         }
-      }
-   }
-   else
-   {
-      if (!g_fNoDesc)
-      {
-         wScript = gpGlobals->g.rgObject[wObject].item.wScriptDesc;
-         line = 0;
-         while (wScript && gpGlobals->g.lprgScriptEntry[wScript].wOperation != 0)
-         {
-            if (gpGlobals->g.lprgScriptEntry[wScript].wOperation == 0xFFFF)
-            {
-               int line_incr = (gpGlobals->g.lprgScriptEntry[wScript].rgwOperand[1] != 1) ? 1 : 0;
-               wScript = PAL_RunAutoScript(wScript, PAL_ITEM_DESC_BOTTOM | line);
-               line += line_incr;
-            }
-            else
-            {
-               wScript = PAL_RunAutoScript(wScript, 0);
-            }
-         }
-      }
-   }
-
-   if (g_InputState.dwKeyPress & kKeySearch)
-   {
-      if ((gpGlobals->g.rgObject[wObject].item.wFlags & g_wItemFlags) &&
-         (SHORT)gpGlobals->rgInventory[gpGlobals->iCurInvMenuItem].nAmount >
-         (SHORT)gpGlobals->rgInventory[gpGlobals->iCurInvMenuItem].nAmountInUse)
-      {
-         if (gpGlobals->rgInventory[gpGlobals->iCurInvMenuItem].nAmount > 0)
-         {
-			 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, FALSE);
-         }
-
-         return wObject;
-      }
-   }
-
-   return 0xFFFF;
-}
-
-VOID
-PAL_ItemSelectMenuInit(
-   WORD                      wItemFlags
-)
-/*++
-  Purpose:
-
-    Initialize the item selection menu.
-
-  Parameters:
-
-    [IN]  wItemFlags - flags for usable item.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int           i, j;
-   WORD          w;
-
-   g_wItemFlags = wItemFlags;
-
-   //
-   // Compress the inventory
-   //
-   PAL_CompressInventory();
-
-   //
-   // Count the total number of items in inventory
-   //
-   g_iNumInventory = 0;
-   while (g_iNumInventory < MAX_INVENTORY &&
-      gpGlobals->rgInventory[g_iNumInventory].wItem != 0)
-   {
-      g_iNumInventory++;
-   }
-
-   //
-   // Also add usable equipped items to the list
-   //
-   if ((wItemFlags & kItemFlagUsable) && !gpGlobals->fInBattle)
-   {
-      for (i = 0; i <= gpGlobals->wMaxPartyMemberIndex; i++)
-      {
-         w = gpGlobals->rgParty[i].wPlayerRole;
-
-         for (j = 0; j < MAX_PLAYER_EQUIPMENTS; j++)
-         {
-            if (gpGlobals->g.rgObject[gpGlobals->g.PlayerRoles.rgwEquipment[j][w]].item.wFlags & kItemFlagUsable)
-            {
-               if (g_iNumInventory < MAX_INVENTORY)
-               {
-                  gpGlobals->rgInventory[g_iNumInventory].wItem = gpGlobals->g.PlayerRoles.rgwEquipment[j][w];
-                  gpGlobals->rgInventory[g_iNumInventory].nAmount = 0;
-                  gpGlobals->rgInventory[g_iNumInventory].nAmountInUse = (WORD)-1;
-
-                  g_iNumInventory++;
-               }
-            }
-         }
-      }
-   }
-}
-
-WORD
-PAL_ItemSelectMenu(
-   LPITEMCHANGED_CALLBACK    lpfnMenuItemChanged,
-   WORD                      wItemFlags
-)
-/*++
-  Purpose:
-
-    Show the item selection menu.
-
-  Parameters:
-
-    [IN]  lpfnMenuItemChanged - Callback function which is called when user
-                                changed the current menu item.
-
-    [IN]  wItemFlags - flags for usable item.
-
-  Return value:
-
-    The object ID of the selected item. 0 if cancelled.
-
---*/
-{
-   int              iPrevIndex;
-   WORD             w;
-   DWORD            dwTime;
-
-   PAL_ItemSelectMenuInit(wItemFlags);
-   iPrevIndex = gpGlobals->iCurInvMenuItem;
-
-   PAL_ClearKeyState();
-
-   if (lpfnMenuItemChanged != NULL)
-   {
-      g_fNoDesc = TRUE;
-      (*lpfnMenuItemChanged)(gpGlobals->rgInventory[gpGlobals->iCurInvMenuItem].wItem);
-   }
-
-   dwTime = SDL_GetTicks();
-
-   while (TRUE)
-   {
-      if (lpfnMenuItemChanged == NULL)
-      {
-         PAL_MakeScene();
-      }
-
-      w = PAL_ItemSelectMenuUpdate();
-      VIDEO_UpdateScreen(NULL);
-
-      PAL_ClearKeyState();
-
-      PAL_ProcessEvent();
-      while (!SDL_TICKS_PASSED(SDL_GetTicks(), dwTime))
-      {
-         PAL_ProcessEvent();
-         if (g_InputState.dwKeyPress != 0)
-         {
-            break;
-         }
-         SDL_Delay(5);
-      }
-
-      dwTime = SDL_GetTicks() + FRAME_TIME;
-
-      if (w != 0xFFFF)
-      {
-         g_fNoDesc = FALSE;
-         return w;
-      }
-
-      if (iPrevIndex != gpGlobals->iCurInvMenuItem)
-      {
-         if (gpGlobals->iCurInvMenuItem >= 0 && gpGlobals->iCurInvMenuItem < MAX_INVENTORY)
-         {
-            if (lpfnMenuItemChanged != NULL)
-            {
-               (*lpfnMenuItemChanged)(gpGlobals->rgInventory[gpGlobals->iCurInvMenuItem].wItem);
-            }
-         }
-
-         iPrevIndex = gpGlobals->iCurInvMenuItem;
-      }
-   }
-
-   assert(FALSE);
-   return 0; // should not really reach here
-}

+ 1 - 0
itemmenu.c

@@ -0,0 +1 @@
+src/itemmenu.c

+ 0 - 49
itemmenu.h

@@ -1,49 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef ITEMMENU_H
-#define ITEMMENU_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-WORD
-PAL_ItemSelectMenuUpdate(
-   VOID
-);
-
-VOID
-PAL_ItemSelectMenuInit(
-   WORD                      wItemFlags
-);
-
-WORD
-PAL_ItemSelectMenu(
-   LPITEMCHANGED_CALLBACK    lpfnMenuItemChanged,
-   WORD                      wItemFlags
-);
-
-#ifdef __cplusplus
-}
-#endif
-#endif

+ 1 - 0
itemmenu.h

@@ -0,0 +1 @@
+src/itemmenu.h

+ 1 - 0
libmad

@@ -0,0 +1 @@
+src/libmad

+ 1 - 0
liboggvorbis

@@ -0,0 +1 @@
+src/liboggvorbis

+ 0 - 478
magicmenu.c

@@ -1,478 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
-//
-
-#include "main.h"
-
-static struct MAGICITEM
-{
-   WORD         wMagic;
-   WORD         wMP;
-   BOOL         fEnabled;
-} rgMagicItem[MAX_PLAYER_MAGICS];
-
-static int     g_iNumMagic = 0;
-static int     g_iCurrentItem = 0;
-static WORD    g_wPlayerMP = 0;
-
-WORD
-PAL_MagicSelectionMenuUpdate(
-   VOID
-)
-/*++
-  Purpose:
-
-    Update the magic selection menu.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    The selected magic. 0 if cancelled, 0xFFFF if not confirmed.
-
---*/
-{
-   int         i, j, k, line, item_delta;
-   BYTE        bColor;
-   WORD        wScript;
-   const int   iItemsPerLine = 32 / gConfig.dwWordLength;
-   const int   iItemTextWidth = 8 * gConfig.dwWordLength + 7;
-   const int   iLinesPerPage = 5 - gConfig.ScreenLayout.ExtraMagicDescLines;
-   const int   iBoxYOffset = gConfig.ScreenLayout.ExtraMagicDescLines * 16;
-   const int   iCursorXOffset = gConfig.dwWordLength * 5 / 2;
-   const int   iPageLineOffset = iLinesPerPage / 2;
-
-   //
-   // Check for inputs
-   //
-   if (g_InputState.dwKeyPress & kKeyUp)
-   {
-      item_delta = -iItemsPerLine;
-   }
-   else if (g_InputState.dwKeyPress & kKeyDown)
-   {
-      item_delta = iItemsPerLine;
-   }
-   else if (g_InputState.dwKeyPress & kKeyLeft)
-   {
-      item_delta = -1;
-   }
-   else if (g_InputState.dwKeyPress & kKeyRight)
-   {
-      item_delta = 1;
-   }
-   else if (g_InputState.dwKeyPress & kKeyPgUp)
-   {
-      item_delta = -(iItemsPerLine * iLinesPerPage);
-   }
-   else if (g_InputState.dwKeyPress & kKeyPgDn)
-   {
-      item_delta = iItemsPerLine * iLinesPerPage;
-   }
-   else if (g_InputState.dwKeyPress & kKeyHome)
-   {
-      item_delta = -g_iCurrentItem;
-   }
-   else if (g_InputState.dwKeyPress & kKeyEnd)
-   {
-      item_delta = g_iNumMagic - g_iCurrentItem - 1;
-   }
-   else if (g_InputState.dwKeyPress & kKeyMenu)
-   {
-      return 0;
-   }
-   else
-   {
-      item_delta = 0;
-   }
-
-   //
-   // Make sure the current menu item index is in bound
-   //
-   if (g_iCurrentItem + item_delta >= 0 &&
-       g_iCurrentItem + item_delta < g_iNumMagic)
-      g_iCurrentItem += item_delta;
-
-   //
-   // Create the box.
-   //
-   PAL_CreateBoxWithShadow(PAL_XY(10, 42 + iBoxYOffset), iLinesPerPage - 1, 16, 1, FALSE, 0);
-
-   if (!gConfig.fIsWIN95)
-   {
-      if (gpGlobals->lpObjectDesc == NULL)
-      {
-         //
-         // Draw the cash amount.
-         //
-         PAL_CreateSingleLineBox(PAL_XY(0, 0), 5, FALSE);
-         PAL_DrawText(PAL_GetWord(CASH_LABEL), PAL_XY(10, 10), 0, FALSE, FALSE, FALSE);
-         PAL_DrawNumber(gpGlobals->dwCash, 6, PAL_XY(49, 14), kNumColorYellow, kNumAlignRight);
-
-         //
-         // Draw the MP of the selected magic.
-         //
-         PAL_CreateSingleLineBox(PAL_XY(215, 0), 5, FALSE);
-         PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH),
-            gpScreen, PAL_XY(260, 14));
-         PAL_DrawNumber(rgMagicItem[g_iCurrentItem].wMP, 4, PAL_XY(230, 14),
-            kNumColorYellow, kNumAlignRight);
-         PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(265, 14), kNumColorCyan, kNumAlignRight);
-      }
-      else
-      {
-         WCHAR szDesc[512], *next;
-         const WCHAR *d = PAL_GetObjectDesc(gpGlobals->lpObjectDesc, rgMagicItem[g_iCurrentItem].wMagic);
-
-         //
-         // Draw the magic description.
-         //
-         if (d != NULL)
-         {
-            k = 3;
-		    wcscpy(szDesc, d);
-            d = szDesc;
-
-            while (TRUE)
-            {
-               next = wcschr(d, '*');
-               if (next != NULL)
-               {
-                  *next++ = '\0';
-               }
-
-               PAL_DrawText(d, PAL_XY(100, k), DESCTEXT_COLOR, TRUE, FALSE, FALSE);
-               k += 16;
-
-               if (next == NULL)
-               {
-                  break;
-               }
-
-               d = next;
-            }
-         }
-
-         //
-         // Draw the MP of the selected magic.
-         //
-         PAL_CreateSingleLineBoxWithShadow(PAL_XY(0, 0), 5, FALSE,0);
-         PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH),
-            gpScreen, PAL_XY(45, 14));
-         PAL_DrawNumber(rgMagicItem[g_iCurrentItem].wMP, 4, PAL_XY(15, 14),
-            kNumColorYellow, kNumAlignRight);
-         PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(50, 14), kNumColorCyan, kNumAlignRight);
-      }
-   }
-   else
-   {
-      wScript = gpGlobals->g.rgObject[rgMagicItem[g_iCurrentItem].wMagic].item.wScriptDesc;
-      line = 0;
-      while (wScript && gpGlobals->g.lprgScriptEntry[wScript].wOperation != 0)
-      {
-         if (gpGlobals->g.lprgScriptEntry[wScript].wOperation == 0xFFFF)
-         {
-            int line_incr = (gpGlobals->g.lprgScriptEntry[wScript].rgwOperand[1] != 1) ? 1 : 0;
-            wScript = PAL_RunAutoScript(wScript, line);
-            line += line_incr;
-	     }
-         else
-         {
-            wScript = PAL_RunAutoScript(wScript, 0);
-         }
-      }
-
-      //
-      // Draw the MP of the selected magic.
-      //
-      PAL_CreateSingleLineBox(PAL_XY(0, 0), 5, FALSE);
-      PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_SLASH),
-         gpScreen, PAL_XY(45, 14));
-      PAL_DrawNumber(rgMagicItem[g_iCurrentItem].wMP, 4, PAL_XY(15, 14),
-         kNumColorYellow, kNumAlignRight);
-      PAL_DrawNumber(g_wPlayerMP, 4, PAL_XY(50, 14), kNumColorCyan, kNumAlignRight);
-   }
-
-
-   //
-   // Draw the texts of the current page
-   //
-   i = g_iCurrentItem / iItemsPerLine * iItemsPerLine - iItemsPerLine * iPageLineOffset;
-   if (i < 0)
-   {
-      i = 0;
-   }
-
-   for (j = 0; j < iLinesPerPage; j++)
-   {
-      for (k = 0; k < iItemsPerLine; k++)
-      {
-         bColor = MENUITEM_COLOR;
-
-         if (i >= g_iNumMagic)
-         {
-            //
-            // End of the list reached
-            //
-            j = iLinesPerPage;
-            break;
-         }
-
-         if (i == g_iCurrentItem)
-         {
-            if (rgMagicItem[i].fEnabled)
-            {
-               bColor = MENUITEM_COLOR_SELECTED;
-            }
-            else
-            {
-               bColor = MENUITEM_COLOR_SELECTED_INACTIVE;
-            }
-         }
-         else if (!rgMagicItem[i].fEnabled)
-         {
-            bColor = MENUITEM_COLOR_INACTIVE;
-         }
-
-         //
-         // Draw the text
-         //
-         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
-         //
-         if (i == g_iCurrentItem)
-         {
-            PAL_RLEBlitToSurface(PAL_SpriteGetFrame(gpSpriteUI, SPRITENUM_CURSOR),
-               gpScreen, PAL_XY(35 + iCursorXOffset + k * iItemTextWidth, 64 + j * 18 + iBoxYOffset));
-         }
-
-         i++;
-      }
-   }
-
-   if (g_InputState.dwKeyPress & kKeySearch)
-   {
-      if (rgMagicItem[g_iCurrentItem].fEnabled)
-      {
-         j = g_iCurrentItem % iItemsPerLine;
-		 k = (g_iCurrentItem < iItemsPerLine * iPageLineOffset) ? (g_iCurrentItem / iItemsPerLine) : iPageLineOffset;
-
-		 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, FALSE);
-
-         return rgMagicItem[g_iCurrentItem].wMagic;
-      }
-   }
-
-   return 0xFFFF;
-}
-
-VOID
-PAL_MagicSelectionMenuInit(
-   WORD         wPlayerRole,
-   BOOL         fInBattle,
-   WORD         wDefaultMagic
-)
-/*++
-  Purpose:
-
-    Initialize the magic selection menu.
-
-  Parameters:
-
-    [IN]  wPlayerRole - the player ID.
-
-    [IN]  fInBattle - TRUE if in battle, FALSE if not.
-
-    [IN]  wDefaultMagic - the default magic item.
-
-  Return value:
-
-    None.
-
---*/
-{
-   WORD       w;
-   int        i, j;
-
-   g_iCurrentItem = 0;
-   g_iNumMagic = 0;
-
-   g_wPlayerMP = gpGlobals->g.PlayerRoles.rgwMP[wPlayerRole];
-
-   //
-   // Put all magics of this player to the array
-   //
-   for (i = 0; i < MAX_PLAYER_MAGICS; i++)
-   {
-      w = gpGlobals->g.PlayerRoles.rgwMagic[i][wPlayerRole];
-      if (w != 0)
-      {
-         rgMagicItem[g_iNumMagic].wMagic = w;
-
-         w = gpGlobals->g.rgObject[w].magic.wMagicNumber;
-         rgMagicItem[g_iNumMagic].wMP = gpGlobals->g.lprgMagic[w].wCostMP;
-
-         rgMagicItem[g_iNumMagic].fEnabled = TRUE;
-
-         if (rgMagicItem[g_iNumMagic].wMP > g_wPlayerMP)
-         {
-            rgMagicItem[g_iNumMagic].fEnabled = FALSE;
-         }
-
-         w = gpGlobals->g.rgObject[rgMagicItem[g_iNumMagic].wMagic].magic.wFlags;
-         if (fInBattle)
-         {
-            if (!(w & kMagicFlagUsableInBattle))
-            {
-               rgMagicItem[g_iNumMagic].fEnabled = FALSE;
-            }
-         }
-         else
-         {
-            if (!(w & kMagicFlagUsableOutsideBattle))
-            {
-               rgMagicItem[g_iNumMagic].fEnabled = FALSE;
-            }
-         }
-
-         g_iNumMagic++;
-      }
-   }
-
-   //
-   // Sort the array
-   //
-   for (i = 0; i < g_iNumMagic - 1; i++)
-   {
-      BOOL fCompleted = TRUE;
-
-      for (j = 0; j < g_iNumMagic - 1 - i; j++)
-      {
-         if (rgMagicItem[j].wMagic > rgMagicItem[j + 1].wMagic)
-         {
-            struct MAGICITEM t = rgMagicItem[j];
-            rgMagicItem[j] = rgMagicItem[j + 1];
-            rgMagicItem[j + 1] = t;
-
-            fCompleted = FALSE;
-         }
-      }
-
-      if (fCompleted)
-      {
-         break;
-      }
-   }
-
-   //
-   // Place the cursor to the default item
-   //
-   for (i = 0; i < g_iNumMagic; i++)
-   {
-      if (rgMagicItem[i].wMagic == wDefaultMagic)
-      {
-         g_iCurrentItem = i;
-         break;
-      }
-   }
-}
-
-WORD
-PAL_MagicSelectionMenu(
-   WORD         wPlayerRole,
-   BOOL         fInBattle,
-   WORD         wDefaultMagic
-)
-/*++
-  Purpose:
-
-    Show the magic selection menu.
-
-  Parameters:
-
-    [IN]  wPlayerRole - the player ID.
-
-    [IN]  fInBattle - TRUE if in battle, FALSE if not.
-
-    [IN]  wDefaultMagic - the default magic item.
-
-  Return value:
-
-    The selected magic. 0 if cancelled.
-
---*/
-{
-   WORD            w;
-   int             i;
-   DWORD           dwTime;
-
-   PAL_MagicSelectionMenuInit(wPlayerRole, fInBattle, wDefaultMagic);
-   PAL_ClearKeyState();
-
-   dwTime = SDL_GetTicks();
-
-   while (TRUE)
-   {
-      PAL_MakeScene();
-
-      w = 45;
-
-      for (i = 0; i <= gpGlobals->wMaxPartyMemberIndex; i++)
-      {
-         PAL_PlayerInfoBox(PAL_XY(w, 165), gpGlobals->rgParty[i].wPlayerRole, 100,
-            TIMEMETER_COLOR_DEFAULT, FALSE);
-         w += 78;
-      }
-
-      w = PAL_MagicSelectionMenuUpdate();
-      VIDEO_UpdateScreen(NULL);
-
-      PAL_ClearKeyState();
-
-      if (w != 0xFFFF)
-      {
-         return w;
-      }
-
-      PAL_ProcessEvent();
-      while (!SDL_TICKS_PASSED(SDL_GetTicks(), dwTime))
-      {
-         PAL_ProcessEvent();
-         if (g_InputState.dwKeyPress != 0)
-         {
-            break;
-         }
-         SDL_Delay(5);
-      }
-
-      dwTime = SDL_GetTicks() + FRAME_TIME;
-   }
-
-   return 0; // should not really reach here
-}

+ 1 - 0
magicmenu.c

@@ -0,0 +1 @@
+src/magicmenu.c

+ 0 - 52
magicmenu.h

@@ -1,52 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef MAGICMENU_H
-#define MAGICMENU_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-WORD
-PAL_MagicSelectionMenuUpdate(
-   VOID
-);
-
-VOID
-PAL_MagicSelectionMenuInit(
-   WORD         wPlayerRole,
-   BOOL         fInBattle,
-   WORD         wDefaultMagic
-);
-
-WORD
-PAL_MagicSelectionMenu(
-   WORD         wPlayerRole,
-   BOOL         fInBattle,
-   WORD         wDefaultMagic
-);
-
-#ifdef __cplusplus
-}
-#endif
-#endif

+ 1 - 0
magicmenu.h

@@ -0,0 +1 @@
+src/magicmenu.h

+ 0 - 565
main.c

@@ -1,565 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-// Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
-//
-
-#include "main.h"
-
-#if defined(LONGJMP_EXIT)
-#include <setjmp.h>
-
-static jmp_buf g_exit_jmp_buf;
-#endif
-
-
-#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
-
-
-static VOID
-PAL_Init(
-   VOID
-)
-/*++
-  Purpose:
-
-    Initialize everything needed by the game.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int           e;
-
-   //
-   // Initialize defaults, video and audio
-   //
-   if (SDL_Init(PAL_SDL_INIT_FLAGS) == -1)
-   {
-#if defined (_WIN32) && SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
-      //
-      // Try the WINDIB driver if DirectX failed.
-      //
-      putenv("SDL_VIDEODRIVER=windib");
-      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK) == -1)
-      {
-         TerminateOnError("Could not initialize SDL: %s.\n", SDL_GetError());
-      }
-#else
-      TerminateOnError("Could not initialize SDL: %s.\n", SDL_GetError());
-#endif
-   }
-
-   //
-   // Initialize subsystems.
-   //
-   e = PAL_InitGlobals();
-   if (e != 0)
-   {
-	   TerminateOnError("Could not initialize global data: %d.\n", e);
-   }
-
-   e = VIDEO_Startup();
-   if (e != 0)
-   {
-      TerminateOnError("Could not initialize Video: %d.\n", e);
-   }
-
-   SDL_WM_SetCaption("Loading...", NULL);
-
-   if (!gConfig.fIsWIN95 && gConfig.fUseEmbeddedFonts)
-   {
-      e = PAL_InitEmbeddedFont();
-      if (e != 0)
-      {
-         TerminateOnError("Could not load fonts: %d.\n", e);
-      }
-   }
-
-   if (gConfig.pszBdfFile != NULL)
-   {
-	  e = PAL_LoadBdfFont(gConfig.pszBdfFile);
-      if (e != 0)
-      {
-         TerminateOnError("Could not load BDF fonts: %d.\n", e);
-      }
-   }
-
-   e = PAL_InitUI();
-   if (e != 0)
-   {
-      TerminateOnError("Could not initialize UI subsystem: %d.\n", e);
-   }
-
-   e = PAL_InitText();
-   if (e != 0)
-   {
-      TerminateOnError("Could not initialize text subsystem: %d.\n", e);
-   }
-
-   PAL_InitInput();
-   PAL_InitResources();
-   AUDIO_OpenDevice();
-
-   if (gConfig.fIsWIN95)
-   {
-#ifdef _DEBUG
-      SDL_WM_SetCaption("Pal WIN95 (Debug Build)", NULL);
-#else
-      SDL_WM_SetCaption("Pal WIN95", NULL);
-#endif
-   }
-   else
-   {
-#ifdef _DEBUG
-      SDL_WM_SetCaption("Pal (Debug Build)", NULL);
-#else
-      SDL_WM_SetCaption("Pal", NULL);
-#endif
-   }
-}
-
-VOID
-PAL_Shutdown(
-   int exit_code
-)
-/*++
-  Purpose:
-
-    Free everything needed by the game.
-
-  Parameters:
-
-    exit_code -  The exit code return to OS.
-
-  Return value:
-
-    None.
-
---*/
-{
-   AUDIO_CloseDevice();
-   PAL_FreeFont();
-   PAL_FreeResources();
-   PAL_FreeGlobals();
-   PAL_FreeUI();
-   PAL_FreeText();
-   PAL_ShutdownInput();
-   VIDEO_Shutdown();
-
-   UTIL_CloseLog();
-
-   SDL_Quit();
-   UTIL_Platform_Quit();
-#if defined(LONGJMP_EXIT)
-   longjmp(g_exit_jmp_buf, exit_code);
-#elif defined (NDS)
-   while (1);
-#else
-   exit(exit_code);
-#endif
-}
-
-VOID
-PAL_TrademarkScreen(
-   VOID
-)
-/*++
-  Purpose:
-
-    Show the trademark screen.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   PAL_SetPalette(3, FALSE);
-   PAL_RNGPlay(6, 0, 1000, 25);
-   UTIL_Delay(1000);
-   PAL_FadeOut(1);
-}
-
-VOID
-PAL_SplashScreen(
-   VOID
-)
-/*++
-  Purpose:
-
-    Show the splash screen.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_Color     *palette = PAL_GetPalette(1, FALSE);
-   SDL_Color      rgCurrentPalette[256];
-   SDL_Surface   *lpBitmapDown, *lpBitmapUp;
-   SDL_Rect       srcrect, dstrect;
-   LPSPRITE       lpSpriteCrane;
-   LPBITMAPRLE    lpBitmapTitle;
-   LPBYTE         buf, buf2;
-   int            cranepos[9][3], i, iImgPos = 200, iCraneFrame = 0, iTitleHeight;
-   DWORD          dwTime, dwBeginTime;
-   BOOL           fUseCD = TRUE;
-
-   if (palette == NULL)
-   {
-      fprintf(stderr, "ERROR: PAL_SplashScreen(): palette == NULL\n");
-      return;
-   }
-
-   //
-   // Allocate all the needed memory at once for simplification
-   //
-   buf = (LPBYTE)UTIL_calloc(1, 320 * 200 * 2);
-   buf2 = (LPBYTE)(buf + 320 * 200);
-   lpSpriteCrane = (LPSPRITE)buf2 + 32000;
-
-   //
-   // Create the surfaces
-   //
-   lpBitmapDown = SDL_CreateRGBSurface(gpScreen->flags, 320, 200, 8,
-      gpScreen->format->Rmask, gpScreen->format->Gmask, gpScreen->format->Bmask,
-      gpScreen->format->Amask);
-   lpBitmapUp = SDL_CreateRGBSurface(gpScreen->flags, 320, 200, 8,
-      gpScreen->format->Rmask, gpScreen->format->Gmask, gpScreen->format->Bmask,
-      gpScreen->format->Amask);
-
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-   SDL_SetSurfacePalette(lpBitmapDown, gpScreen->format->palette);
-   SDL_SetSurfacePalette(lpBitmapUp, gpScreen->format->palette);
-#else
-   SDL_SetPalette(lpBitmapDown, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-   SDL_SetPalette(lpBitmapUp, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-
-   //
-   // Read the bitmaps
-   //
-   PAL_MKFReadChunk(buf, 320 * 200, BITMAPNUM_SPLASH_UP, gpGlobals->f.fpFBP);
-   Decompress(buf, buf2, 320 * 200);
-   PAL_FBPBlitToSurface(buf2, lpBitmapUp);
-   PAL_MKFReadChunk(buf, 320 * 200, BITMAPNUM_SPLASH_DOWN, gpGlobals->f.fpFBP);
-   Decompress(buf, buf2, 320 * 200);
-   PAL_FBPBlitToSurface(buf2, lpBitmapDown);
-   PAL_MKFReadChunk(buf, 32000, SPRITENUM_SPLASH_TITLE, gpGlobals->f.fpMGO);
-   Decompress(buf, buf2, 32000);
-   lpBitmapTitle = (LPBITMAPRLE)PAL_SpriteGetFrame(buf2, 0);
-   PAL_MKFReadChunk(buf, 32000, SPRITENUM_SPLASH_CRANE, gpGlobals->f.fpMGO);
-   Decompress(buf, lpSpriteCrane, 32000);
-
-   iTitleHeight = PAL_RLEGetHeight(lpBitmapTitle);
-   lpBitmapTitle[2] = 0;
-   lpBitmapTitle[3] = 0; // HACKHACK
-
-   //
-   // Generate the positions of the cranes
-   //
-   for (i = 0; i < 9; i++)
-   {
-      cranepos[i][0] = RandomLong(300, 600);
-      cranepos[i][1] = RandomLong(0, 80);
-      cranepos[i][2] = RandomLong(0, 8);
-   }
-
-   //
-   // Play the title music
-   //
-   if (!AUDIO_PlayCDTrack(7))
-   {
-      fUseCD = FALSE;
-      AUDIO_PlayMusic(NUM_RIX_TITLE, TRUE, 2);
-   }
-
-   //
-   // Clear all of the events and key states
-   //
-   PAL_ProcessEvent();
-   PAL_ClearKeyState();
-
-   dwBeginTime = SDL_GetTicks();
-
-   srcrect.x = 0;
-   srcrect.w = 320;
-   dstrect.x = 0;
-   dstrect.w = 320;
-
-   while (TRUE)
-   {
-      PAL_ProcessEvent();
-      dwTime = SDL_GetTicks() - dwBeginTime;
-
-      //
-      // Set the palette
-      //
-      if (dwTime < 15000)
-      {
-         for (i = 0; i < 256; i++)
-         {
-            rgCurrentPalette[i].r = (BYTE)(palette[i].r * ((float)dwTime / 15000));
-            rgCurrentPalette[i].g = (BYTE)(palette[i].g * ((float)dwTime / 15000));
-            rgCurrentPalette[i].b = (BYTE)(palette[i].b * ((float)dwTime / 15000));
-         }
-      }
-
-      VIDEO_SetPalette(rgCurrentPalette);
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-	  SDL_SetSurfacePalette(lpBitmapDown, gpScreen->format->palette);
-	  SDL_SetSurfacePalette(lpBitmapUp, gpScreen->format->palette);
-#else
-      SDL_SetPalette(lpBitmapDown, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-      SDL_SetPalette(lpBitmapUp, SDL_LOGPAL | SDL_PHYSPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-
-      //
-      // Draw the screen
-      //
-      if (iImgPos > 1)
-      {
-         iImgPos--;
-      }
-
-      //
-      // The upper part...
-      //
-      srcrect.y = iImgPos;
-      srcrect.h = 200 - iImgPos;
-
-      dstrect.y = 0;
-      dstrect.h = srcrect.h;
-
-      SDL_BlitSurface(lpBitmapUp, &srcrect, gpScreen, &dstrect);
-
-      //
-      // The lower part...
-      //
-      srcrect.y = 0;
-      srcrect.h = iImgPos;
-
-      dstrect.y = 200 - iImgPos;
-      dstrect.h = srcrect.h;
-
-      SDL_BlitSurface(lpBitmapDown, &srcrect, gpScreen, &dstrect);
-
-      //
-      // Draw the cranes...
-      //
-      for (i = 0; i < 9; i++)
-      {
-         LPCBITMAPRLE lpFrame = PAL_SpriteGetFrame(lpSpriteCrane,
-            cranepos[i][2] = (cranepos[i][2] + (iCraneFrame & 1)) % 8);
-         cranepos[i][1] += ((iImgPos > 1) && (iImgPos & 1)) ? 1 : 0;
-         PAL_RLEBlitToSurface(lpFrame, gpScreen,
-            PAL_XY(cranepos[i][0], cranepos[i][1]));
-         cranepos[i][0]--;
-      }
-      iCraneFrame++;
-
-      //
-      // Draw the title...
-      //
-      if (PAL_RLEGetHeight(lpBitmapTitle) < iTitleHeight)
-      {
-         //
-         // HACKHACK
-         //
-         WORD w = lpBitmapTitle[2] | (lpBitmapTitle[3] << 8);
-         w++;
-         lpBitmapTitle[2] = (w & 0xFF);
-         lpBitmapTitle[3] = (w >> 8);
-      }
-
-      PAL_RLEBlitToSurface(lpBitmapTitle, gpScreen, PAL_XY(255, 10));
-      VIDEO_UpdateScreen(NULL);
-
-      //
-      // Check for keypress...
-      //
-      if (g_InputState.dwKeyPress & (kKeyMenu | kKeySearch))
-      {
-         //
-         // User has pressed a key...
-         //
-         lpBitmapTitle[2] = iTitleHeight & 0xFF;
-         lpBitmapTitle[3] = iTitleHeight >> 8; // HACKHACK
-
-         PAL_RLEBlitToSurface(lpBitmapTitle, gpScreen, PAL_XY(255, 10));
-
-         VIDEO_UpdateScreen(NULL);
-
-         if (dwTime < 15000)
-         {
-            //
-            // If the picture has not completed fading in, complete the rest
-            //
-            while (dwTime < 15000)
-            {
-               for (i = 0; i < 256; i++)
-               {
-                  rgCurrentPalette[i].r = (BYTE)(palette[i].r * ((float)dwTime / 15000));
-                  rgCurrentPalette[i].g = (BYTE)(palette[i].g * ((float)dwTime / 15000));
-                  rgCurrentPalette[i].b = (BYTE)(palette[i].b * ((float)dwTime / 15000));
-               }
-               VIDEO_SetPalette(rgCurrentPalette);
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-			   SDL_SetSurfacePalette(lpBitmapDown, gpScreen->format->palette);
-			   SDL_SetSurfacePalette(lpBitmapUp, gpScreen->format->palette);
-#else
-			   SDL_SetPalette(lpBitmapDown, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-			   SDL_SetPalette(lpBitmapUp, SDL_PHYSPAL | SDL_LOGPAL, VIDEO_GetPalette(), 0, 256);
-#endif
-               UTIL_Delay(8);
-               dwTime += 250;
-            }
-            UTIL_Delay(500);
-         }
-
-         //
-         // Quit the splash screen
-         //
-         break;
-      }
-
-      //
-      // Delay a while...
-      //
-      PAL_ProcessEvent();
-      while (SDL_GetTicks() - dwBeginTime < dwTime + 85)
-      {
-         SDL_Delay(1);
-         PAL_ProcessEvent();
-      }
-   }
-
-   SDL_FreeSurface(lpBitmapDown);
-   SDL_FreeSurface(lpBitmapUp);
-   free(buf);
-
-   if (!fUseCD)
-   {
-      AUDIO_PlayMusic(0, FALSE, 1);
-   }
-
-   PAL_FadeOut(1);
-}
-
-int
-main(
-   int      argc,
-   char    *argv[]
-)
-/*++
-  Purpose:
-
-    Program entry.
-
-  Parameters:
-
-    argc - Number of arguments.
-
-    argv - Array of arguments.
-
-  Return value:
-
-    Integer value.
-
---*/
-{
-#if defined(LONGJMP_EXIT)
-	int exit_code;
-	if (exit_code = setjmp(g_exit_jmp_buf))
-		return exit_code != 1 ? exit_code : 0;
-#endif
-
-#if defined(__APPLE__) && !defined(__IOS__) && !defined(DEBUG) //for ease of debugging(specify resource dir in xcode scheme)
-   char *p = strstr(argv[0], "/Pal.app/");
-
-   if (p != NULL)
-   {
-      char buf[4096];
-      strcpy(buf, argv[0]);
-      buf[p - argv[0]] = '\0';
-      chdir(buf);
-   }
-#endif
-
-   UTIL_OpenLog();
-
-   PAL_LoadConfig(TRUE);
-
-   //
-   // Platform-specific initialization
-   //
-   if (UTIL_Platform_Init(argc, argv) != 0)
-	   return -1;
-
-   //
-   // Should launch setting
-   // However, it may arrive here through the activatation event on WinRT platform
-   // So close the current process so that the new process can go to setting
-   //
-   if (gConfig.fLaunchSetting)
-	   return 0;
-
-   //
-   // Initialize everything
-   //
-   PAL_Init();
-
-   //
-   // Show the trademark screen and splash screen
-   //
-   PAL_TrademarkScreen();
-   PAL_SplashScreen();
-
-   //
-   // Run the main game routine
-   //
-   PAL_GameMain();
-
-   //
-   // Should not really reach here...
-   //
-   assert(FALSE);
-   return 255;
-}

+ 1 - 0
main.c

@@ -0,0 +1 @@
+src/main.c

+ 0 - 59
main.h

@@ -1,59 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef MAIN_H
-#define MAIN_H
-
-#include "common.h"
-#include "util.h"
-#include "palcommon.h"
-#include "font.h"
-#include "global.h"
-#include "palcfg.h"
-#include "map.h"
-#include "res.h"
-#include "scene.h"
-#include "players.h"
-#include "audio.h"
-#include "video.h"
-#include "input.h"
-#include "text.h"
-#include "ui.h"
-#include "uigame.h"
-#include "uibattle.h"
-#include "magicmenu.h"
-#include "itemmenu.h"
-#include "palette.h"
-#include "rngplay.h"
-#include "ending.h"
-#include "script.h"
-#include "battle.h"
-#include "fight.h"
-#include "play.h"
-#include "game.h"
-#include "midi.h"
-
-VOID
-PAL_Shutdown(
-   int exit_code
-);
-
-#endif

+ 1 - 0
main.h

@@ -0,0 +1 @@
+src/main.h

+ 0 - 418
map.c

@@ -1,418 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "palcommon.h"
-#include "map.h"
-
-LPPALMAP
-PAL_LoadMap(
-   INT               iMapNum,
-   FILE             *fpMapMKF,
-   FILE             *fpGopMKF
-)
-/*++
-  Purpose:
-
-    Load the specified map from the MKF file, as well as the tile bitmaps.
-
-  Parameters:
-
-    [IN]  iMapNum - Number of the map to load.
-
-    [IN]  fpMapMKF - Pointer to the fopen'ed map.mkf file, which
-                     contains the map tile data.
-
-    [IN]  fpGopMKF - Pointer to the fopen'ed gop.mkf file, which
-                     contains the tile bitmaps. The bitmap can be read
-                     by PAL_SpriteGetFrame() function.
-
-  Return value:
-
-    Pointer to the loaded map. NULL if failed.
-
---*/
-{
-   LPBYTE                     buf;
-   INT                        size, i, j;
-   LPPALMAP                   map;
-
-   //
-   // Check for invalid map number.
-   //
-   if (iMapNum >= PAL_MKFGetChunkCount(fpMapMKF) ||
-      iMapNum >= PAL_MKFGetChunkCount(fpGopMKF) ||
-      iMapNum <= 0)
-   {
-      return NULL;
-   }
-
-   //
-   // Load the map tile data.
-   //
-   size = PAL_MKFGetChunkSize(iMapNum, fpMapMKF);
-
-   //
-   // Allocate a temporary buffer for the compressed data.
-   //
-   buf = (LPBYTE)malloc(size);
-   if (buf == NULL)
-   {
-      return NULL;
-   }
-
-   //
-   // Create the map instance.
-   //
-   map = (LPPALMAP)malloc(sizeof(PALMAP));
-   if (map == NULL)
-   {
-      return NULL;
-   }
-
-   //
-   // Read the map data.
-   //
-   if (PAL_MKFReadChunk(buf, size, iMapNum, fpMapMKF) < 0)
-   {
-      free(buf);
-      free(map);
-      return NULL;
-   }
-
-   //
-   // Decompress the tile data.
-   //
-   if (Decompress(buf, (LPBYTE)(map->Tiles), sizeof(map->Tiles)) < 0)
-   {
-      free(map);
-      free(buf);
-      return NULL;
-   }
-
-   //
-   // The compressed data is useless now; delete it.
-   //
-   free(buf);
-
-   //
-   // Adjust the endianness of the decompressed data.
-   //
-   for (i = 0; i < 128; i++)
-   {
-      for (j = 0; j < 64; j++)
-      {
-         map->Tiles[i][j][0] = SDL_SwapLE32(map->Tiles[i][j][0]);
-         map->Tiles[i][j][1] = SDL_SwapLE32(map->Tiles[i][j][1]);
-      }
-   }
-
-   //
-   // Load the tile bitmaps.
-   //
-   size = PAL_MKFGetChunkSize(iMapNum, fpGopMKF);
-   if (size <= 0)
-   {
-      free(map);
-      return NULL;
-   }
-   map->pTileSprite = (LPSPRITE)malloc(size);
-   if (map->pTileSprite == NULL)
-   {
-      free(map);
-      return NULL;
-   }
-   if (PAL_MKFReadChunk(map->pTileSprite, size, iMapNum, fpGopMKF) < 0)
-   {
-      free(map);
-      return NULL;
-   }
-
-   //
-   // Done.
-   //
-   map->iMapNum = iMapNum;
-
-   return map;
-}
-
-VOID
-PAL_FreeMap(
-   LPPALMAP          lpMap
-)
-/*++
-  Purpose:
-
-    Free a loaded map, as well as the tile bitmaps.
-
-  Parameters:
-
-    [IN]  lpMap - Pointer to the loaded map structure.
-
-  Return value:
-
-    None.
-
---*/
-{
-   //
-   // Check for NULL pointer.
-   //
-   if (lpMap == NULL)
-   {
-      return;
-   }
-
-   //
-   // Free the tile bitmaps.
-   //
-   if (lpMap->pTileSprite != NULL)
-   {
-      free(lpMap->pTileSprite);
-   }
-
-   //
-   // Delete the instance.
-   //
-   free(lpMap);
-}
-
-LPCBITMAPRLE
-PAL_MapGetTileBitmap(
-   BYTE       x,
-   BYTE       y,
-   BYTE       h,
-   BYTE       ucLayer,
-   LPCPALMAP  lpMap
-)
-/*++
-  Purpose:
-
-    Get the tile bitmap on the specified layer at the location (x, y, h).
-
-  Parameters:
-
-    [IN]  x - Column number of the tile.
-
-    [IN]  y - Line number in the map.
-
-    [IN]  h - Each line in the map has two lines of tiles, 0 and 1.
-              (See map.h for details.)
-
-    [IN]  ucLayer - The layer. 0 for bottom, 1 for top.
-
-    [IN]  lpMap - Pointer to the loaded map.
-
-  Return value:
-
-    Pointer to the bitmap. NULL if failed.
-
---*/
-{
-   DWORD d;
-
-   //
-   // Check for invalid parameters.
-   //
-   if (x >= 64 || y >= 128 || h > 1 || lpMap == NULL)
-   {
-      return NULL;
-   }
-
-   //
-   // Get the tile data of the specified location.
-   //
-   d = lpMap->Tiles[y][x][h];
-
-   if (ucLayer == 0)
-   {
-      //
-      // Bottom layer
-      //
-      return PAL_SpriteGetFrame(lpMap->pTileSprite, (d & 0xFF) | ((d >> 4) & 0x100));
-   }
-   else
-   {
-      //
-      // Top layer
-      //
-      d >>= 16;
-      return PAL_SpriteGetFrame(lpMap->pTileSprite, ((d & 0xFF) | ((d >> 4) & 0x100)) - 1);
-   }
-}
-
-BOOL
-PAL_MapTileIsBlocked(
-   BYTE       x,
-   BYTE       y,
-   BYTE       h,
-   LPCPALMAP  lpMap
-)
-/*++
-  Purpose:
-
-    Check if the tile at the specified location is blocked.
-
-  Parameters:
-
-    [IN]  x - Column number of the tile.
-
-    [IN]  y - Line number in the map.
-
-    [IN]  h - Each line in the map has two lines of tiles, 0 and 1.
-              (See map.h for details.)
-
-    [IN]  lpMap - Pointer to the loaded map.
-
-  Return value:
-
-    TRUE if the tile is blocked, FALSE if not.
-
---*/
-{
-   //
-   // Check for invalid parameters.
-   //
-   if (x >= 64 || y >= 128 || h > 1 || lpMap == NULL)
-   {
-      return TRUE;
-   }
-
-   return (lpMap->Tiles[y][x][h] & 0x2000) >> 13;
-}
-
-BYTE
-PAL_MapGetTileHeight(
-   BYTE       x,
-   BYTE       y,
-   BYTE       h,
-   BYTE       ucLayer,
-   LPCPALMAP  lpMap
-)
-/*++
-  Purpose:
-
-    Get the logical height value of the specified tile. This value is used
-    to judge whether the tile bitmap should cover the sprites or not.
-
-  Parameters:
-
-    [IN]  x - Column number of the tile.
-
-    [IN]  y - Line number in the map.
-
-    [IN]  h - Each line in the map has two lines of tiles, 0 and 1.
-              (See map.h for details.)
-
-    [IN]  ucLayer - The layer. 0 for bottom, 1 for top.
-
-    [IN]  lpMap - Pointer to the loaded map.
-
-  Return value:
-
-    The logical height value of the specified tile.
-
---*/
-{
-   DWORD      d;
-
-   //
-   // Check for invalid parameters.
-   //
-   if (y >= 128 || x >= 64 || h > 1 || lpMap == NULL)
-   {
-      return 0;
-   }
-
-   d = lpMap->Tiles[y][x][h];
-
-   if (ucLayer)
-   {
-      d >>= 16;
-   }
-
-   d >>= 8;
-   return (BYTE)(d & 0xf);
-}
-
-VOID
-PAL_MapBlitToSurface(
-   LPCPALMAP             lpMap,
-   SDL_Surface          *lpSurface,
-   const SDL_Rect       *lpSrcRect,
-   BYTE                  ucLayer
-)
-/*++
-  Purpose:
-
-    Blit the specified map area to a SDL Surface.
-
-  Parameters:
-
-    [IN]  lpMap - Pointer to the map.
-
-    [OUT] lpSurface - Pointer to the destination surface.
-
-    [IN]  lpSrcRect - Pointer to the source area.
-
-    [IN]  ucLayer - The layer. 0 for bottom, 1 for top.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int              sx, sy, dx, dy, x, y, h, xPos, yPos;
-   LPCBITMAPRLE     lpBitmap = NULL;
-
-   //
-   // Convert the coordinate
-   //
-   sy = lpSrcRect->y / 16 - 1;
-   dy = (lpSrcRect->y + lpSrcRect->h) / 16 + 2;
-   sx = lpSrcRect->x / 32 - 1;
-   dx = (lpSrcRect->x + lpSrcRect->w) / 32 + 2;
-
-   //
-   // Do the drawing.
-   //
-   yPos = sy * 16 - 8 - lpSrcRect->y;
-   for (y = sy; y < dy; y++)
-   {
-      for (h = 0; h < 2; h++, yPos += 8)
-      {
-         xPos = sx * 32 + h * 16 - 16 - lpSrcRect->x;
-         for (x = sx; x < dx; x++, xPos += 32)
-         {
-            lpBitmap = PAL_MapGetTileBitmap((BYTE)x, (BYTE)y, (BYTE)h, ucLayer, lpMap);
-            if (lpBitmap == NULL)
-            {
-               if (ucLayer)
-               {
-                  continue;
-               }
-               lpBitmap = PAL_MapGetTileBitmap(0, 0, 0, ucLayer, lpMap);
-            }
-            PAL_RLEBlitToSurface(lpBitmap, lpSurface, PAL_XY(xPos, yPos));
-         }
-      }
-   }
-}

+ 1 - 0
map.c

@@ -0,0 +1 @@
+src/map.c

+ 0 - 139
map.h

@@ -1,139 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef _MAP_H
-#define _MAP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "common.h"
-
-//
-// Map format:
-//
-// +----------------------------------------------> x
-// | * * * * * * * * * * ... * * * * * * * * * *  (y = 0, h = 0)
-// |  * * * * * * * * * * ... * * * * * * * * * * (y = 0, h = 1)
-// | * * * * * * * * * * ... * * * * * * * * * *  (y = 1, h = 0)
-// |  * * * * * * * * * * ... * * * * * * * * * * (y = 1, h = 1)
-// | * * * * * * * * * * ... * * * * * * * * * *  (y = 2, h = 0)
-// |  * * * * * * * * * * ... * * * * * * * * * * (y = 2, h = 1)
-// | ............................................
-// v
-// y
-//
-// Note:
-//
-// Tiles are in diamond shape (32x15).
-//
-// Each tile is represented with a DWORD value, which contains information
-// about the tile bitmap, block flag, height, etc.
-//
-// Bottom layer sprite index:
-//  (d & 0xFF) | ((d >> 4) & 0x100)
-//
-// Top layer sprite index:
-//  d >>= 16;
-//  ((d & 0xFF) | ((d >> 4) & 0x100)) - 1)
-//
-// Block flag (player cannot walk through this tile):
-//  d & 0x2000
-//
-
-typedef struct tagPALMAP
-{
-   DWORD          Tiles[128][64][2];
-   LPSPRITE       pTileSprite;
-   INT            iMapNum;
-} PALMAP, *LPPALMAP;
-
-typedef const PALMAP *LPCPALMAP;
-
-LPPALMAP
-PAL_LoadMap(
-   INT               iMapNum,
-   FILE             *fpMapMKF,
-   FILE             *fpGopMKF
-);
-
-VOID
-PAL_FreeMap(
-   LPPALMAP          lpMap
-);
-
-LPCBITMAPRLE
-PAL_MapGetTileBitmap(
-   BYTE       x,
-   BYTE       y,
-   BYTE       h,
-   BYTE       ucLayer,
-   LPCPALMAP  lpMap
-);
-
-BOOL
-PAL_MapTileIsBlocked(
-   BYTE       x,
-   BYTE       y,
-   BYTE       h,
-   LPCPALMAP  lpMap
-);
-
-BYTE
-PAL_MapGetTileHeight(
-   BYTE       x,
-   BYTE       y,
-   BYTE       h,
-   BYTE       ucLayer,
-   LPCPALMAP  lpMap
-);
-
-VOID
-PAL_MapBlitToSurface(
-   LPCPALMAP             lpMap,
-   SDL_Surface          *lpSurface,
-   const SDL_Rect       *lpSrcRect,
-   BYTE                  ucLayer
-);
-
-//
-// Convert map location to the real location
-//
-#define PAL_XYH_TO_POS(x, y, h)                       \
-   PAL_POS((x) * 32 + (h) * 16, (y) * 16 + (h) * 8)
-
-//
-// Convert real location to map location
-//
-#define PAL_POS_TO_XYH(pos, x, y, h)                  \
-{                                                     \
-   (h) = (BYTE)(((PAL_X(pos) % 32) != 0) ? 1 : 0);    \
-   (x) = (BYTE)(PAL_X(pos) / 32);                     \
-   (y) = (BYTE)(PAL_Y(pos) / 16);                     \
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
map.h

@@ -0,0 +1 @@
+src/map.h

+ 0 - 140
midi.c

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

+ 1 - 0
midi.c

@@ -0,0 +1 @@
+src/midi.c

+ 0 - 52
midi.h

@@ -1,52 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2011, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef PAL_MIDI_H
-#define PAL_MIDI_H
-
-#include "common.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#if PAL_HAS_NATIVEMIDI
-#include "native_midi/native_midi.h"
-
-VOID
-MIDI_Play(
-   INT       iNumRIX,
-   BOOL      fLoop
-);
-
-VOID
-MIDI_CheckLoop(
-   VOID
-);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
midi.h

@@ -0,0 +1 @@
+src/midi.h

+ 0 - 162
mp3play.c

@@ -1,162 +0,0 @@
-/* -*- mode: c++; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-// Modified by Lou Yihua <louyihua@21cn.com>, 2015.
-//
-// This file is part of SDLPAL.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "util.h"
-#include "global.h"
-#include "palcfg.h"
-
-#if PAL_HAS_MP3
-
-#include "audio.h"
-#include "players.h"
-#include "resampler.h"
-#include "libmad/music_mad.h"
-
-typedef struct tagMP3PLAYER
-{
-	AUDIOPLAYER_COMMONS;
-
-	mad_data           *pMP3;
-	INT                 iMusic;
-	BOOL                fLoop;
-} MP3PLAYER, *LPMP3PLAYER;
-
-static VOID MP3_Close(
-	LPMP3PLAYER player
-	)
-{
-	if (player->pMP3)
-	{
-		mad_stop(player->pMP3);
-		mad_closeFile(player->pMP3);
-
-		player->pMP3 = NULL;
-	}
-}
-
-static VOID
-MP3_FillBuffer(
-	VOID       *object,
-	LPBYTE      stream,
-	INT         len
-	)
-{
-	LPMP3PLAYER player = (LPMP3PLAYER)object;
-	if (player->pMP3) {
-		if (!mad_isPlaying(player->pMP3) && player->fLoop)
-		{
-			mad_seek(player->pMP3, 0);
-			mad_start(player->pMP3);
-		}
-
-		if (mad_isPlaying(player->pMP3))
-			mad_getSamples(player->pMP3, stream, len);
-	}
-}
-
-static VOID
-MP3_Shutdown(
-	VOID       *object
-	)
-{
-	if (object)
-	{
-		MP3_Close((LPMP3PLAYER)object);
-		free(object);
-	}
-}
-
-static BOOL
-MP3_Play(
-	VOID       *object,
-	INT         iNum,
-	BOOL        fLoop,
-	FLOAT       flFadeTime
-	)
-{
-	LPMP3PLAYER player = (LPMP3PLAYER)object;
-
-	//
-	// Check for NULL pointer.
-	//
-	if (player == NULL)
-	{
-		return FALSE;
-	}
-
-	player->fLoop = fLoop;
-
-	if (iNum == player->iMusic)
-	{
-		return TRUE;
-	}
-
-	MP3_Close(player);
-
-	if (iNum > 0)
-	{
-		if ((player->pMP3 = mad_openFile(va("%smp3/%.2d.mp3", gConfig.pszGamePath, iNum), AUDIO_GetDeviceSpec(), gConfig.iResampleQuality)) == NULL)
-		{
-			player->pMP3 = mad_openFile(va("%sMP3/%.2d.MP3", gConfig.pszGamePath, iNum), AUDIO_GetDeviceSpec(), gConfig.iResampleQuality);
-		}
-
-		if (player->pMP3)
-		{
-			player->iMusic = iNum;
-			mad_start(player->pMP3);
-			return TRUE;
-		}
-		else
-		{
-			return FALSE;
-		}
-	}
-	else
-	{
-		return TRUE;
-	}
-}
-
-LPAUDIOPLAYER
-MP3_Init(
-	VOID
-)
-{
-	LPMP3PLAYER player;
-	if (player = (LPMP3PLAYER)malloc(sizeof(MP3PLAYER)))
-	{
-		player->FillBuffer = MP3_FillBuffer;
-		player->Play = MP3_Play;
-		player->Shutdown = MP3_Shutdown;
-
-		player->pMP3 = NULL;
-		player->iMusic = -1;
-		player->fLoop = FALSE;
-		return (LPAUDIOPLAYER)player;
-	}
-	else
-	{
-		return NULL;
-	}
-}
-
-#endif

+ 1 - 0
mp3play.c

@@ -0,0 +1 @@
+src/mp3play.c

+ 1 - 0
native_midi

@@ -0,0 +1 @@
+src/native_midi

+ 0 - 514
oggplay.c

@@ -1,514 +0,0 @@
-/* -*- mode: c++; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-// Created by Lou Yihua <louyihua@21cn.com>, 2015-07-28.
-//
-// This file is part of SDLPAL.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-// This file uses some code from decoder_example.c in libvorbis-1.3.4.
-
-#include "util.h"
-#include "global.h"
-#include "palcfg.h"
-#include "players.h"
-#include "audio.h"
-#include <math.h>
-#if PAL_HAS_OGG
-#include <vorbis/vorbisfile.h>
-
-#include "resampler.h"
-
-#define FLAG_OY 0x01
-#define FLAG_VI 0x02
-#define FLAG_VC 0x04
-#define FLAG_OS 0x08
-#define FLAG_VD 0x10
-#define FLAG_VB 0x20
-
-#define STAGE_PAGEOUT    1
-#define STAGE_PACKETOUT  2
-#define STAGE_PCMOUT	 3
-#define STAGE_REWIND     4
-
-#define OGG_BUFFER_LENGTH 4096
-
-typedef struct tagOGGPLAYER
-{
-	AUDIOPLAYER_COMMONS;
-
-	ogg_sync_state   oy; /* sync and verify incoming physical bitstream */
-	ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
-	ogg_page         og; /* one Ogg bitstream page. Vorbis packets are inside */
-	vorbis_info      vi; /* struct that stores all the static vorbis bitstream settings */
-	vorbis_comment   vc; /* struct that stores all the bitstream user comments */
-	vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
-	vorbis_block     vb; /* local working space for packet->PCM decode */
-
-	FILE            *fp;
-	void            *resampler[2];
-	INT              iFlags;
-	INT              iMusic;
-	INT              iStage;
-	INT              nChannels;
-	BOOL             fLoop;
-	BOOL             fReady;
-	BOOL             fUseResampler;
-} OGGPLAYER, *LPOGGPLAYER;
-
-PAL_FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm)
-{
-	int val = (int)(floor(pcm * 32767.f + .5f));
-	/* might as well guard against clipping */
-	if (val > 32767) {
-		val = 32767;
-	}
-	else if (val < -32768) {
-		val = -32768;
-	}
-	return (ogg_int16_t)val;
-}
-
-PAL_FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
-{
-	if (gConfig.iAudioChannels == 2) {
-		stream[0] = resampler_get_and_remove_sample(player->resampler[0]);
-		stream[1] = (player->vi.channels > 1) ? resampler_get_and_remove_sample(player->resampler[1]) : stream[0];
-	}
-	else {
-		if (player->vi.channels > 1) {
-			*stream = (short)((int)(resampler_get_and_remove_sample(player->resampler[0]) + resampler_get_and_remove_sample(player->resampler[1])) >> 1);
-		}
-		else {
-			*stream = resampler_get_and_remove_sample(player->resampler[0]);
-		}
-	}
-}
-
-static void OGG_Cleanup(LPOGGPLAYER player)
-{
-	int i;
-	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);
-	if (player->iFlags & FLAG_OS) ogg_stream_clear(&player->os);
-	if (player->iFlags & FLAG_VC) vorbis_comment_clear(&player->vc);
-	if (player->iFlags & FLAG_VI) vorbis_info_clear(&player->vi);  /* must be called last */
-	if (player->iFlags & FLAG_OY) ogg_sync_clear(&player->oy);
-	player->iFlags = player->iStage = 0;
-	player->fReady = FALSE;
-}
-
-
-static BOOL OGG_Rewind(LPOGGPLAYER player)
-{
-	ogg_packet       op; /* one raw packet of data for decode */
-	char *buffer;
-	int i, bytes;
-
-	OGG_Cleanup(player);
-
-	fseek(player->fp, 0, SEEK_SET);
-
-	ogg_sync_init(&player->oy); player->iFlags = FLAG_OY;
-
-	/* grab some data at the head of the stream. We want the first page
-	(which is guaranteed to be small and only contain the Vorbis
-	stream initial header) We need the first page to get the stream
-	serialno. */
-
-	/* submit a 4k block to libvorbis' Ogg layer */
-	buffer = ogg_sync_buffer(&player->oy, OGG_BUFFER_LENGTH);
-	bytes = fread(buffer, 1, OGG_BUFFER_LENGTH, player->fp);
-	ogg_sync_wrote(&player->oy, bytes);
-
-	/* Get the first page. */
-	if (ogg_sync_pageout(&player->oy, &player->og) != 1) {
-		/* have we simply run out of data?  If so, we're done. */
-		/* error case.  Must not be Vorbis data */
-		OGG_Cleanup(player);
-		return (player->fReady = FALSE);
-	}
-
-	/* Get the serial number and set up the rest of decode. */
-	/* serialno first; use it to set up a logical stream */
-	ogg_stream_init(&player->os, ogg_page_serialno(&player->og));
-	player->iFlags |= FLAG_OS;
-
-	/* extract the initial header from the first page and verify that the
-	Ogg bitstream is in fact Vorbis data */
-
-	/* I handle the initial header first instead of just having the code
-	read all three Vorbis headers at once because reading the initial
-	header is an easy way to identify a Vorbis bitstream and it's
-	useful to see that functionality seperated out. */
-
-	vorbis_info_init(&player->vi); player->iFlags |= FLAG_VI;
-	vorbis_comment_init(&player->vc); player->iFlags |= FLAG_VC;
-	if (ogg_stream_pagein(&player->os, &player->og)<0) {
-		/* error; stream version mismatch perhaps */
-		OGG_Cleanup(player);
-		return (player->fReady = FALSE);
-	}
-
-	if (ogg_stream_packetout(&player->os, &op) != 1) {
-		/* no page? must not be vorbis */
-		OGG_Cleanup(player);
-		return (player->fReady = FALSE);
-	}
-
-	if (vorbis_synthesis_headerin(&player->vi, &player->vc, &op)<0) {
-		/* error case; not a vorbis header */
-		OGG_Cleanup(player);
-		return (player->fReady = FALSE);
-	}
-
-	/* At this point, we're sure we're Vorbis. We've set up the logical
-	(Ogg) bitstream decoder. Get the comment and codebook headers and
-	set up the Vorbis decoder */
-
-	/* The next two packets in order are the comment and codebook headers.
-	They're likely large and may span multiple pages. Thus we read
-	and submit data until we get our two packets, watching that no
-	pages are missing. If a page is missing, error out; losing a
-	header page is the only place where missing data is fatal. */
-
-	i = 0;
-	while (i < 2) {
-		while (i < 2) {
-			int result = ogg_sync_pageout(&player->oy, &player->og);
-			if (result == 0)break; /* Need more data */
-								   /* Don't complain about missing or corrupt data yet. We'll
-								   catch it at the packet output phase */
-			if (result == 1) {
-				ogg_stream_pagein(&player->os, &player->og); /* we can ignore any errors here
-															 as they'll also become apparent
-															 at packetout */
-				while (i < 2) {
-					result = ogg_stream_packetout(&player->os, &op);
-					if (result == 0)break;
-					if (result < 0) {
-						/* Uh oh; data at some point was corrupted or missing!
-						We can't tolerate that in a header.  Die. */
-						OGG_Cleanup(player);
-						return (player->fReady = FALSE);
-					}
-					result = vorbis_synthesis_headerin(&player->vi, &player->vc, &op);
-					if (result < 0) {
-						OGG_Cleanup(player);
-						return (player->fReady = FALSE);
-					}
-					i++;
-				}
-			}
-		}
-		/* no harm in not checking before adding more */
-		buffer = ogg_sync_buffer(&player->oy, OGG_BUFFER_LENGTH);
-		bytes = fread(buffer, 1, OGG_BUFFER_LENGTH, player->fp);
-		if (bytes == 0 && i < 2) {
-			OGG_Cleanup(player);
-			return (player->fReady = FALSE);
-		}
-		ogg_sync_wrote(&player->oy, bytes);
-	}
-
-	if (vorbis_synthesis_init(&player->vd, &player->vi) == 0) { /* central decode state */
-		vorbis_block_init(&player->vd, &player->vb);            /* local state for most of the decode
-																so multiple block decodes can
-																proceed in parallel. We could init
-																multiple vorbis_block structures
-																for vd here */
-		player->iStage = STAGE_PAGEOUT;
-		player->iFlags |= FLAG_VD | FLAG_VB;
-
-		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], AUDIO_IsIntegerConversion(player->vi.rate) ? RESAMPLER_QUALITY_MIN : gConfig.iResampleQuality);
-				resampler_set_rate(player->resampler[i], factor);
-				resampler_clear(player->resampler[i]);
-			}
-		}
-		return (player->fReady = TRUE);
-	}
-	else {
-		OGG_Cleanup(player);
-		return (player->fReady = FALSE);
-	}
-}
-
-static VOID
-OGG_FillBuffer(
-	VOID       *object,
-	LPBYTE      stream,
-	INT         len
-	)
-{
-	LPOGGPLAYER player = (LPOGGPLAYER)object;
-
-	if (player->fReady) {
-		ogg_packet       op; /* one raw packet of data for decode */
-		int total_bytes = 0, stage = player->iStage;
-
-		while (total_bytes < len) {
-			float **pcm;
-			int samples, result;
-
-			switch (stage)
-			{
-			case STAGE_PAGEOUT: /* PAGEOUT stage */
-				result = ogg_sync_pageout(&player->oy, &player->og);
-				if (result > 0) {
-					/* can safely ignore errors at this point */
-					ogg_stream_pagein(&player->os, &player->og);
-					stage = STAGE_PACKETOUT;
-				}
-				else {
-					if (result == 0) { /* need more data */
-						char *buffer = ogg_sync_buffer(&player->oy, OGG_BUFFER_LENGTH);
-						int bytes = fread(buffer, 1, OGG_BUFFER_LENGTH, player->fp);
-						ogg_sync_wrote(&player->oy, bytes);
-						stage = (bytes > 0) ? STAGE_PAGEOUT : STAGE_REWIND;
-					}
-					break;
-				}
-			case STAGE_PACKETOUT:
-				result = ogg_stream_packetout(&player->os, &op);
-				if (result > 0) {
-					/* we have a packet.  Decode it */
-					if (vorbis_synthesis(&player->vb, &op) == 0) { /* test for success! */
-						vorbis_synthesis_blockin(&player->vd, &player->vb);
-					}
-					stage = STAGE_PCMOUT;
-				}
-				else {
-					if (result == 0) { /* need more data */
-						if (ogg_page_eos(&player->og)) {
-							if (player->fLoop) {
-								stage = STAGE_REWIND;
-							}
-							else {
-								OGG_Cleanup(player);
-								UTIL_CloseFile(player->fp);
-								player->fp = NULL;
-								return;
-							}
-						}
-						else {
-							stage = STAGE_PAGEOUT;
-						}
-					}
-					break;
-				}
-			case STAGE_PCMOUT:
-				if ((samples = vorbis_synthesis_pcmout(&player->vd, &pcm)) > 0) {
-					int bout;
-					if (player->fUseResampler) { /* Resampler is available and should be used */
-						bout = 0;
-						while (total_bytes < len && samples > 0) { /* Fill as many samples into resampler as possible */
-							int i, j, to_write = resampler_get_free_count(player->resampler[0]);
-
-							if (to_write > 0) {
-								if (to_write >= samples) to_write = samples;
-
-								for (i = 0; i < min(player->vi.channels, 2); i++) {
-									float *mono = pcm[i] + bout;
-									for (j = 0; j < to_write; j++) {
-										resampler_write_sample(player->resampler[i], OGG_GetSample(mono[j]));
-									}
-								}
-							}
-
-							/* Fetch resampled samples if available */
-							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 += gConfig.iAudioChannels * sizeof(ogg_int16_t);
-							}
-
-							samples -= to_write; bout += to_write;
-						}
-					}
-					else {
-						int i;
-						ogg_int16_t *ptr = (ogg_int16_t *)(stream + total_bytes);
-						bout = (len - total_bytes) / gConfig.iAudioChannels / sizeof(ogg_int16_t);
-						if (bout > samples) bout = samples;
-						for (i = 0; i < bout; i++) {
-							if (gConfig.iAudioChannels == 2) {
-								ptr[0] = OGG_GetSample(pcm[0][i]);
-								ptr[1] = (player->vi.channels > 1) ? OGG_GetSample(pcm[1][i]) : ptr[0];
-							}
-							else {
-								if (player->vi.channels > 1) {
-									ptr[0] = (short)((int)(OGG_GetSample(pcm[0][i]) + OGG_GetSample(pcm[1][i])) >> 1);
-								}
-								else {
-									ptr[0] = OGG_GetSample(pcm[0][i]);
-								}
-							}
-							ptr += gConfig.iAudioChannels;
-						}
-
-						total_bytes += bout * gConfig.iAudioChannels * sizeof(ogg_int16_t);
-					}
-					/* tell libvorbis how many samples we actually consumed */
-					vorbis_synthesis_read(&player->vd, bout);
-				}
-				else {
-					stage = STAGE_PACKETOUT;
-				}
-				break;
-			case STAGE_REWIND:
-				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 += 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;
-				}
-				OGG_Rewind(player);
-				stage = player->iStage;
-				break;
-			default:
-				return;
-			}
-		}
-		player->iStage = stage;
-	}
-}
-
-static BOOL
-OGG_Play(
-	VOID       *object,
-	INT         iNum,
-	BOOL        fLoop,
-	FLOAT       flFadeTime
-	)
-{
-	char filename[256];
-	LPOGGPLAYER player = (LPOGGPLAYER)object;
-
-	//
-	// Check for NULL pointer.
-	//
-	if (player == NULL)
-	{
-		return FALSE;
-	}
-
-	player->fLoop = fLoop;
-
-	if (iNum == player->iMusic)
-	{
-		return TRUE;
-	}
-
-	player->fReady = FALSE;
-	OGG_Cleanup(player);
-	if (player->fp)
-	{
-		UTIL_CloseFile(player->fp);
-		player->fp = NULL;
-	}
-
-	if (iNum == -1)
-	{
-		return TRUE;
-	}
-
-	player->fp = UTIL_OpenFile(strcpy(filename, va("ogg/%.2d.ogg", iNum)));
-	if (player->fp == NULL)
-	{
-		return FALSE;
-	}
-	else
-	{
-		player->iMusic = iNum;
-	}
-
-	if (!OGG_Rewind(player))
-	{
-		UTIL_CloseFile(player->fp);
-		player->fp = NULL;
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-static VOID
-OGG_Shutdown(
-	VOID       *object
-	)
-{
-	if (object)
-	{
-		LPOGGPLAYER player = (LPOGGPLAYER)object;
-		OGG_Cleanup(player);
-		resampler_delete(player->resampler[0]);
-		resampler_delete(player->resampler[1]);
-		UTIL_CloseFile(player->fp);
-		free(player);
-	}
-}
-
-LPAUDIOPLAYER
-OGG_Init(
-	VOID
-)
-{
-	LPOGGPLAYER player;
-	if (player = (LPOGGPLAYER)malloc(sizeof(OGGPLAYER)))
-	{
-		memset(player, 0, sizeof(LPOGGPLAYER));
-
-		player->FillBuffer = OGG_FillBuffer;
-		player->Play = OGG_Play;
-		player->Shutdown = OGG_Shutdown;
-
-		player->fp = NULL;
-		player->iMusic = -1;
-		player->iFlags = 0;
-		player->iStage = 0;
-		player->fLoop = FALSE;
-		player->fReady = FALSE;
-		player->fUseResampler = FALSE;
-
-		player->resampler[0] = resampler_create();
-		if (player->resampler[0])
-		{
-			player->resampler[1] = resampler_create();
-			if (player->resampler[1] == NULL)
-			{
-				resampler_delete(player->resampler[0]);
-				player->resampler[0] = NULL;
-			}
-		}
-
-		return (LPAUDIOPLAYER)player;
-	}
-	else
-	{
-		return NULL;
-	}
-}
-
-#endif

+ 1 - 0
oggplay.c

@@ -0,0 +1 @@
+src/oggplay.c

File diff suppressed because it is too large
+ 0 - 5318
overlay.c


+ 1 - 0
overlay.c

@@ -0,0 +1 @@
+src/overlay.c

+ 0 - 458
palcfg.c

@@ -1,458 +0,0 @@
-
-#include "global.h"
-#include "palcfg.h"
-#include "util.h"
-#include "resampler.h"
-#include <stdint.h>
-
-#if !defined(PAL_HAS_TOUCH)
-#define PAL_HAS_TOUCH     0
-#endif
-
-static const ConfigItem gConfigItems[PALCFG_ALL_MAX] = {
-	{ PALCFG_FULLSCREEN,        PALCFG_BOOLEAN,  "FULLSCREEN",        10, FALSE, FALSE, TRUE },
-	{ PALCFG_KEEPASPECTRATIO,   PALCFG_BOOLEAN,  "KEEPASPECTRATIO",   15, TRUE,  FALSE, TRUE },
-	{ PALCFG_LAUNCHSETTING,     PALCFG_BOOLEAN,  "LAUNCHSETTING",     13, TRUE,  FALSE, TRUE },
-	{ PALCFG_STEREO,            PALCFG_BOOLEAN,  "STEREO",             6, TRUE,  FALSE, TRUE },								// Default for stereo audio
-	{ PALCFG_USEEMBEDDEDFONTS,  PALCFG_BOOLEAN,  "USEEMBEDDEDFONTS",  16, TRUE,  FALSE, TRUE },								// Default for using embedded fonts in DOS version
-	{ PALCFG_USESURROUNDOPL,    PALCFG_BOOLEAN,  "USESURROUNDOPL",    14, TRUE,  FALSE, TRUE },								// Default for using surround opl
-	{ PALCFG_USETOUCHOVERLAY,   PALCFG_BOOLEAN,  "USETOUCHOVERLAY",   15, PAL_HAS_TOUCH, FALSE, TRUE },
-
-	{ PALCFG_SURROUNDOPLOFFSET, PALCFG_INTEGER,  "SURROUNDOPLOFFSET", 17, 384,   INT32_MIN, INT32_MAX },
-
-	{ PALCFG_AUDIOBUFFERSIZE,   PALCFG_UNSIGNED, "AUDIOBUFFERSIZE",   15, PAL_AUDIO_DEFAULT_BUFFER_SIZE, 2, 32768 },
-	{ PALCFG_CODEPAGE,          PALCFG_UNSIGNED, "CODEPAGE",           8, CP_BIG5, CP_BIG5, CP_MAX - 1 },											// Default for BIG5
-	{ PALCFG_OPLSAMPLERATE,     PALCFG_UNSIGNED, "OPLSAMPLERATE",     13, 49716,   0, UINT32_MAX },
-	{ PALCFG_RESAMPLEQUALITY,   PALCFG_UNSIGNED, "RESAMPLEQUALITY",   15, RESAMPLER_QUALITY_MAX, RESAMPLER_QUALITY_MIN, RESAMPLER_QUALITY_MAX },	// Default for best quality
-	{ PALCFG_SAMPLERATE,        PALCFG_UNSIGNED, "SAMPLERATE",        10, 44100,   0, PAL_MAX_SAMPLERATE },
-	{ PALCFG_MUSICVOLUME,       PALCFG_UNSIGNED, "MUSICVOLUME",       11, PAL_MAX_VOLUME, 0, PAL_MAX_VOLUME },										// Default for maximum volume
-	{ PALCFG_SOUNDVOLUME,       PALCFG_UNSIGNED, "SOUNDVOLUME",       11, PAL_MAX_VOLUME, 0, PAL_MAX_VOLUME },										// Default for maximum volume
-	{ PALCFG_WINDOWHEIGHT,      PALCFG_UNSIGNED, "WINDOWHEIGHT",      12, PAL_DEFAULT_WINDOW_HEIGHT, 0, UINT32_MAX },
-	{ PALCFG_WINDOWWIDTH,       PALCFG_UNSIGNED, "WINDOWWIDTH",       11, PAL_DEFAULT_WINDOW_WIDTH,  0, UINT32_MAX },
-
-	{ PALCFG_CD,                PALCFG_STRING,   "CD",                 2, "OGG", NULL, NULL },
-	{ PALCFG_GAMEPATH,          PALCFG_STRING,   "GAMEPATH",           8, NULL, NULL, NULL },
-	{ PALCFG_MESSAGEFILE,       PALCFG_STRING,   "MESSAGEFILENAME",   15, NULL, NULL, NULL },
-	{ PALCFG_BDFFILE,           PALCFG_STRING,   "BDFFILENAME",       11, NULL, NULL, NULL },
-	{ PALCFG_MUSIC,             PALCFG_STRING,   "MUSIC",              5, "RIX", NULL, NULL },
-	{ PALCFG_OPL,               PALCFG_STRING,   "OPL",                3, "DOSBOX", NULL, NULL },
-	{ PALCFG_RIXEXTRAINIT,      PALCFG_STRING,   "RIXEXTRAINIT",      12, NULL, NULL, NULL },
-};
-
-
-BOOL
-PAL_ParseConfigLine(
-	const char * line,
-	const ConfigItem ** ppItem,
-	ConfigValue * pValue
-)
-{
-	//
-	// Skip leading spaces
-	//
-	while (*line && isspace(*line)) line++;
-
-	//
-	// Skip comments
-	//
-	if (*line && *line != '#')
-	{
-		const char *ptr;
-		if (ptr = strchr(line, '='))
-		{
-			const char *end = ptr++;
-
-			//
-			// Skip tailing spaces
-			//
-			while (end > line && isspace(end[-1])) end--;
-
-			int len = end - line;
-
-			for (int i = 0; i < sizeof(gConfigItems) / sizeof(ConfigItem); i++)
-			{
-				if (gConfigItems[i].NameLength == len &&
-					SDL_strncasecmp(line, gConfigItems[i].Name, len) == 0)
-				{
-					if (ppItem) *ppItem = &gConfigItems[i];
-					if (pValue)
-					{
-						if (gConfigItems[i].Type != PALCFG_STRING)
-						{
-							switch (gConfigItems[i].Type)
-							{
-							case PALCFG_UNSIGNED:
-								sscanf(ptr, "%u", &pValue->uValue);
-								if (pValue->uValue < gConfigItems[i].MinValue.uValue)
-									pValue->uValue = gConfigItems[i].MinValue.uValue;
-								else if (pValue->uValue > gConfigItems[i].MaxValue.uValue)
-									pValue->uValue = gConfigItems[i].MaxValue.uValue;
-								break;
-							case PALCFG_INTEGER:
-								sscanf(ptr, "%d", &pValue->iValue);
-								if (pValue->iValue < gConfigItems[i].MinValue.iValue)
-									pValue->iValue = gConfigItems[i].MinValue.iValue;
-								else if (pValue->iValue > gConfigItems[i].MaxValue.iValue)
-									pValue->iValue = gConfigItems[i].MaxValue.iValue;
-								break;
-							case PALCFG_BOOLEAN:
-								sscanf(ptr, "%d", &pValue->bValue);
-								pValue->bValue = pValue->bValue ? TRUE : FALSE;
-								break;
-							}
-						}
-						else
-						{
-							//
-							// Skip leading spaces
-							//
-							while (*ptr && isspace(*ptr)) ptr++;
-							pValue->sValue = ptr;
-						}
-						return TRUE;
-					}
-				}
-			}
-		}
-	}
-	return FALSE;
-}
-
-ConfigValue
-PAL_DefaultConfig(
-	PALCFG_ITEM item
-)
-{
-	return gConfigItems[item].DefaultValue;
-}
-
-const char *
-PAL_ConfigName(
-	PALCFG_ITEM item
-)
-{
-	return gConfigItems[item].Name;
-}
-
-BOOL
-PAL_LimitConfig(
-	PALCFG_ITEM item,
-	ConfigValue * pValue
-)
-{
-	if (!pValue) return FALSE;
-
-	switch (gConfigItems[item].Type)
-	{
-	case PALCFG_UNSIGNED:
-		if (pValue->uValue < gConfigItems[item].MinValue.uValue)
-		{
-			pValue->uValue = gConfigItems[item].MinValue.uValue;
-			return TRUE;
-		}
-		else if (pValue->uValue > gConfigItems[item].MaxValue.uValue)
-		{
-			pValue->uValue = gConfigItems[item].MaxValue.uValue;
-			return TRUE;
-		}
-		else
-			return FALSE;
-	case PALCFG_INTEGER:
-		if (pValue->iValue < gConfigItems[item].MinValue.iValue)
-		{
-			pValue->iValue = gConfigItems[item].MinValue.iValue;
-			return TRUE;
-		}
-		else if (pValue->iValue > gConfigItems[item].MaxValue.iValue)
-		{
-			pValue->iValue = gConfigItems[item].MaxValue.iValue;
-			return TRUE;
-		}
-		else
-			return FALSE;
-	case PALCFG_BOOLEAN:
-		if (pValue->bValue != TRUE && pValue->bValue != FALSE)
-		{
-			pValue->bValue = pValue->bValue ? TRUE : FALSE;
-			return TRUE;
-		}
-		else
-			return FALSE;
-	default:
-		return FALSE;
-	}
-}
-
-VOID
-PAL_LoadConfig(
-	BOOL fFromFile
-)
-{
-	FILE     *fp;
-	ConfigValue  values[PALCFG_ALL_MAX];
-	MUSICTYPE eMusicType = MUSIC_RIX;
-	MUSICTYPE eCDType = MUSIC_OGG;
-	OPLTYPE   eOPLType = OPL_DOSBOX;
-	SCREENLAYOUT screen_layout = {
-		// Equipment Screen
-		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) },
-
-		// Status Screen
-		PAL_XY(110, 8), PAL_XY(110, 30), PAL_XY(6, 6),  PAL_XY(6, 32),  PAL_XY(6, 54),  PAL_XY(6, 76),
-		{ PAL_XY(6, 98),   PAL_XY(6, 118),  PAL_XY(6, 138),  PAL_XY(6, 158),  PAL_XY(6, 178) },
-		PAL_XY(58, 6), PAL_XY(58, 15), PAL_XY(0, 0), PAL_XY(54, 35), PAL_XY(42, 56),
-		PAL_XY(63, 61), PAL_XY(65, 58), PAL_XY(42, 78), PAL_XY(63, 83), PAL_XY(65, 80),
-		{ PAL_XY(42, 102), PAL_XY(42, 122), PAL_XY(42, 142), PAL_XY(42, 162), PAL_XY(42, 182) },
-		{ PAL_XY(189, -1), PAL_XY(247, 39), PAL_XY(251, 101), PAL_XY(201, 133), PAL_XY(141, 141), PAL_XY(81, 125) },
-		{ PAL_XY(195, 38), PAL_XY(253, 78), PAL_XY(257, 140), PAL_XY(207, 172), PAL_XY(147, 180), PAL_XY(87, 164) },
-		{ PAL_XY(185, 58), PAL_XY(185, 76), PAL_XY(185, 94), PAL_XY(185, 112), PAL_XY(185, 130), PAL_XY(185, 148), PAL_XY(185, 166), PAL_XY(185, 184), PAL_XY(185, 184), PAL_XY(185, 184) },
-
-		// Extra Lines
-		PAL_XY(0, 0), PAL_XY(0, 0)
-	};
-
-	for (PALCFG_ITEM i = PALCFG_ALL_MIN; i < PALCFG_ALL_MAX; i++) values[i] = PAL_DefaultConfig(i);
-
-	if (fFromFile && (fp = fopen(va("%ssdlpal.cfg", PAL_CONFIG_PREFIX), "r")))
-	{
-		PAL_LARGE char buf[512];
-
-		//
-		// Load the configuration data
-		//
-		while (fgets(buf, 512, fp) != NULL)
-		{
-			ConfigValue value;
-			const ConfigItem * item;
-			if (PAL_ParseConfigLine(buf, &item, &value))
-			{
-				switch (item->Item)
-				{
-				case PALCFG_AUDIOBUFFERSIZE:
-					if ((value.uValue & (value.uValue - 1)) != 0)
-					{
-						/* Make sure iAudioBufferSize is power of 2 */
-						int n = 0;
-						while (value.uValue) { value.uValue >>= 1; n++; }
-						value.uValue = 1 << (n - 1);
-					}
-					values[item->Item] = value;
-					break;
-				case PALCFG_MESSAGEFILE:
-				{
-					int n = strlen(value.sValue);
-					while (n > 0 && isspace(value.sValue[n - 1])) n--;
-					if (n > 0)
-					{
-						gConfig.pszMsgFile = (char *)realloc(gConfig.pszMsgFile, n + 1);
-						memcpy(gConfig.pszMsgFile, value.sValue, n);
-						gConfig.pszMsgFile[n] = '\0';
-					}
-					break;
-				}
-				case PALCFG_BDFFILE:
-				{
-					int n = strlen(value.sValue);
-					while (n > 0 && isspace(value.sValue[n - 1])) n--;
-					if (n > 0)
-					{
-						gConfig.pszBdfFile = (char *)realloc(gConfig.pszBdfFile, n + 1);
-						memcpy(gConfig.pszBdfFile, value.sValue, n);
-						gConfig.pszBdfFile[n] = '\0';
-					}
-					break;
-				}
-				case PALCFG_GAMEPATH:
-				{
-					int n = strlen(value.sValue);
-					while (n > 0 && isspace(value.sValue[n - 1])) n--;
-					if (n > 0)
-					{
-						gConfig.pszGamePath = (char *)realloc(gConfig.pszGamePath, n + 1);
-						memcpy(gConfig.pszGamePath, value.sValue, n);
-						gConfig.pszGamePath[n] = '\0';
-					}
-					break;
-				}
-				case PALCFG_CD:
-				{
-					if (PAL_HAS_MP3 && SDL_strncasecmp(value.sValue, "MP3", 3) == 0)
-						eCDType = MUSIC_MP3;
-					else if (PAL_HAS_OGG && SDL_strncasecmp(value.sValue, "OGG", 3) == 0)
-						eCDType = MUSIC_OGG;
-					else if (PAL_HAS_SDLCD && SDL_strncasecmp(value.sValue, "RAW", 3) == 0)
-						eCDType = MUSIC_SDLCD;
-					break;
-				}
-				case PALCFG_MUSIC:
-				{
-					if (PAL_HAS_NATIVEMIDI && SDL_strncasecmp(value.sValue, "MIDI", 4) == 0)
-						eMusicType = MUSIC_MIDI;
-					else if (PAL_HAS_MP3 && SDL_strncasecmp(value.sValue, "MP3", 3) == 0)
-						eMusicType = MUSIC_MP3;
-					else if (PAL_HAS_OGG && SDL_strncasecmp(value.sValue, "OGG", 3) == 0)
-						eMusicType = MUSIC_OGG;
-					else if (SDL_strncasecmp(value.sValue, "RIX", 3) == 0)
-						eMusicType = MUSIC_RIX;
-					break;
-				}
-				case PALCFG_OPL:
-				{
-					if (SDL_strncasecmp(value.sValue, "DOSBOXNEW", 9) == 0)
-						eOPLType = OPL_DOSBOX_NEW;
-					else if (SDL_strncasecmp(value.sValue, "DOSBOX", 6) == 0)
-						eOPLType = OPL_DOSBOX;
-					else if (SDL_strncasecmp(value.sValue, "MAME", 4) == 0)
-						eOPLType = OPL_MAME;
-					break;
-				}
-				case PALCFG_RIXEXTRAINIT:
-				{
-#if USE_RIX_EXTRA_INIT
-					int n = 1;
-					char *p;
-					for (p = ptr; *p < *end; p++)
-					{
-						if (*p == ',')
-							n++;
-					}
-					n &= ~0x1;
-
-					if (n > 0)
-					{
-						uint32_t *regs = malloc(sizeof(uint32_t) * (n >> 1));
-						uint8_t *vals = malloc(sizeof(uint8_t) * (n >> 1));
-						uint32_t d, i, v = 1;
-						if (regs && vals)
-						{
-							for (p = ptr, i = 0; *p < *end; p++, i++)
-							{
-								if (sscanf(p, "%u", &regs[i]) == 0) { v = 0; break; }
-								while (*p < *end && *p != ',') p++; p++;
-								if (sscanf(p, "%u", &d) == 0) { v = 0; break; }
-								while (*p < *end && *p != ',') p++;
-								vals[i] = (uint8_t)d;
-							}
-							if (v)
-							{
-								gConfig.pExtraFMRegs = regs;
-								gConfig.pExtraFMVals = vals;
-								gConfig.dwExtraLength = n >> 1;
-							}
-							else
-							{
-								free(regs);
-								free(vals);
-							}
-						}
-					}
-#endif
-					break;
-				}
-				default:
-					values[item->Item] = value;
-					break;
-				}
-			}
-		}
-
-		UTIL_CloseFile(fp);
-	}
-
-	//
-	// Set configurable global options
-	//
-	if (!gConfig.pszGamePath) gConfig.pszGamePath = strdup(PAL_PREFIX);
-	gConfig.eMusicType = eMusicType;
-	gConfig.eCDType = eCDType;
-	gConfig.eOPLType = eOPLType;
-	gConfig.dwWordLength = 10;	// This is the default value for Chinese version
-	gConfig.ScreenLayout = screen_layout;
-
-	gConfig.fIsWIN95 = FALSE;	// Default for DOS version
-	gConfig.fUseEmbeddedFonts = values[PALCFG_USEEMBEDDEDFONTS].bValue;
-	gConfig.fUseSurroundOPL = values[PALCFG_STEREO].bValue && values[PALCFG_USESURROUNDOPL].bValue;
-	gConfig.fLaunchSetting = values[PALCFG_LAUNCHSETTING].bValue;
-	gConfig.fUseTouchOverlay = values[PALCFG_USETOUCHOVERLAY].bValue;
-#if SDL_VERSION_ATLEAST(2,0,0)
-	gConfig.fKeepAspectRatio = values[PALCFG_KEEPASPECTRATIO].bValue;
-#endif
-	gConfig.fFullScreen = values[PALCFG_FULLSCREEN].bValue;
-	gConfig.iAudioChannels = values[PALCFG_STEREO].bValue ? 2 : 1;
-
-	gConfig.iSurroundOPLOffset = values[PALCFG_SURROUNDOPLOFFSET].iValue;
-
-	gConfig.iSampleRate = values[PALCFG_SAMPLERATE].uValue;
-	gConfig.iOPLSampleRate = values[PALCFG_OPLSAMPLERATE].uValue;
-	gConfig.iResampleQuality = values[PALCFG_RESAMPLEQUALITY].uValue;
-	gConfig.uCodePage = values[PALCFG_CODEPAGE].uValue;
-	gConfig.wAudioBufferSize = (WORD)values[PALCFG_AUDIOBUFFERSIZE].uValue;
-	gConfig.iMusicVolume = values[PALCFG_MUSICVOLUME].uValue;
-	gConfig.iSoundVolume = values[PALCFG_SOUNDVOLUME].uValue;
-
-	if (UTIL_GetScreenSize(&values[PALCFG_WINDOWWIDTH].uValue, &values[PALCFG_WINDOWHEIGHT].uValue))
-	{
-		gConfig.dwScreenWidth = values[PALCFG_WINDOWWIDTH].uValue;
-		gConfig.dwScreenHeight = values[PALCFG_WINDOWHEIGHT].uValue;
-	}
-	else
-	{
-		gConfig.dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
-		gConfig.dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
-	}
-}
-
-
-BOOL
-PAL_SaveConfig(
-	VOID
-)
-{
-	static const char *music_types[] = { "MIDI", "RIX", "MP3", "OGG", "RAW" };
-	static const char *opl_types[] = { "DOSBOX", "MAME", "DOSBOXNEW" };
-	char buf[512];
-	FILE *fp = fopen(va("%ssdlpal.cfg", PAL_CONFIG_PREFIX), "w");
-
-	if (fp)
-	{
-#if SDL_VERSION_ATLEAST(2,0,0)
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_KEEPASPECTRATIO), gConfig.fKeepAspectRatio); fputs(buf, fp);
-#endif
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_FULLSCREEN), gConfig.fFullScreen); fputs(buf, fp);
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_LAUNCHSETTING), gConfig.fLaunchSetting); fputs(buf, fp);
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_STEREO), gConfig.iAudioChannels == 2 ? TRUE : FALSE); fputs(buf, fp);
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USEEMBEDDEDFONTS), gConfig.fUseEmbeddedFonts); fputs(buf, fp);
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USESURROUNDOPL), gConfig.fUseSurroundOPL); fputs(buf, fp);
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USETOUCHOVERLAY), gConfig.fUseTouchOverlay); fputs(buf, fp);
-
-		sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_SURROUNDOPLOFFSET), gConfig.iSurroundOPLOffset); fputs(buf, fp);
-
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_AUDIOBUFFERSIZE), gConfig.wAudioBufferSize); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_CODEPAGE), gConfig.uCodePage); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_OPLSAMPLERATE), gConfig.iOPLSampleRate); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_RESAMPLEQUALITY), gConfig.iResampleQuality); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_SAMPLERATE), gConfig.iSampleRate); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_MUSICVOLUME), gConfig.iMusicVolume); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_SOUNDVOLUME), gConfig.iSoundVolume); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_WINDOWHEIGHT), gConfig.dwScreenHeight); fputs(buf, fp);
-		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_WINDOWWIDTH), gConfig.dwScreenWidth); fputs(buf, fp);
-
-		sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_CD), music_types[gConfig.eCDType]); fputs(buf, fp);
-		sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_MUSIC), music_types[gConfig.eMusicType]); fputs(buf, fp);
-		sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_OPL), opl_types[gConfig.eOPLType]); fputs(buf, fp);
-
-		if (gConfig.pszGamePath) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_GAMEPATH), gConfig.pszGamePath); fputs(buf, fp); }
-		if (gConfig.pszMsgFile) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_MESSAGEFILE), gConfig.pszMsgFile); fputs(buf, fp); }
-		if (gConfig.pszBdfFile) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_BDFFILE), gConfig.pszBdfFile); fputs(buf, fp); }
-
-		fclose(fp);
-
-		return TRUE;
-	}
-	else
-		return FALSE;
-}

+ 1 - 0
palcfg.c

@@ -0,0 +1 @@
+src/palcfg.c

+ 0 - 237
palcfg.h

@@ -1,237 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2016, Lou Yihua <louyihua@21cn.com>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-# ifdef __cplusplus
-extern "C"
-{
-# endif
-
-#include "palcommon.h"
-
-#define     PAL_MAX_SAMPLERATE           48000
-#define     PAL_MAX_VOLUME               100
-
-typedef enum tagPALCFG_ITEM
-{
-	PALCFG_ALL_MIN = 0,
-
-	PALCFG_BOOLEAN_MIN = PALCFG_ALL_MIN,
-	/* Booleans */
-	PALCFG_FULLSCREEN = PALCFG_BOOLEAN_MIN,
-	PALCFG_KEEPASPECTRATIO,
-	PALCFG_LAUNCHSETTING,
-	PALCFG_STEREO,
-	PALCFG_USEEMBEDDEDFONTS,
-	PALCFG_USESURROUNDOPL,
-	PALCFG_USETOUCHOVERLAY,
-	/* Booleans */
-	PALCFG_BOOLEAN_MAX,
-
-	PALCFG_INTEGER_MIN = PALCFG_BOOLEAN_MAX,
-	/* Integers */
-	PALCFG_SURROUNDOPLOFFSET = PALCFG_INTEGER_MIN,
-	/* Integers */
-	PALCFG_INTEGER_MAX,
-
-	PALCFG_UNSIGNED_MIN = PALCFG_INTEGER_MAX,
-	/* Unsigneds */
-	PALCFG_AUDIOBUFFERSIZE = PALCFG_UNSIGNED_MIN,
-	PALCFG_CODEPAGE,
-	PALCFG_OPLSAMPLERATE,
-	PALCFG_RESAMPLEQUALITY,
-	PALCFG_SAMPLERATE,
-	PALCFG_MUSICVOLUME,
-	PALCFG_SOUNDVOLUME,
-	PALCFG_WINDOWHEIGHT,
-	PALCFG_WINDOWWIDTH,
-	/* Unsigneds */
-	PALCFG_UNSIGNED_MAX,
-
-	PALCFG_STRING_MIN = PALCFG_UNSIGNED_MAX,
-	/* Strings */
-	PALCFG_CD = PALCFG_STRING_MIN,
-	PALCFG_GAMEPATH,
-	PALCFG_MESSAGEFILE,
-	PALCFG_BDFFILE,
-	PALCFG_MUSIC,
-	PALCFG_OPL,
-	PALCFG_RIXEXTRAINIT,
-	/* Strings */
-	PALCFG_STRING_MAX,
-
-	PALCFG_ALL_MAX = PALCFG_STRING_MAX
-} PALCFG_ITEM;
-
-typedef enum tagPALCFG_TYPE
-{
-	PALCFG_STRING,
-	PALCFG_BOOLEAN,
-	PALCFG_INTEGER,
-	PALCFG_UNSIGNED,
-} PALCFG_TYPE;
-
-typedef union tagConfigValue
-{
-	LPCSTR   sValue;
-	DWORD    uValue;
-	INT      iValue;
-	BOOL     bValue;
-} ConfigValue;
-
-typedef struct tagConfigItem
-{
-	PALCFG_ITEM        Item;
-	PALCFG_TYPE        Type;
-	const char*        Name;
-	int                NameLength;
-	const ConfigValue  DefaultValue;
-	const ConfigValue  MinValue;
-	const ConfigValue  MaxValue;
-} ConfigItem;
-
-typedef struct tagSCREENLAYOUT
-{
-	PAL_POS          EquipImageBox;
-	PAL_POS          EquipRoleListBox;
-	PAL_POS          EquipItemName;
-	PAL_POS          EquipItemAmount;
-	PAL_POS          EquipLabels[MAX_PLAYER_EQUIPMENTS];
-	PAL_POS          EquipNames[MAX_PLAYER_EQUIPMENTS];
-	PAL_POS          EquipStatusLabels[5];
-	PAL_POS          EquipStatusValues[5];
-
-	PAL_POS          RoleName;
-	PAL_POS          RoleImage;
-	PAL_POS          RoleExpLabel;
-	PAL_POS          RoleLevelLabel;
-	PAL_POS          RoleHPLabel;
-	PAL_POS          RoleMPLabel;
-	PAL_POS          RoleStatusLabels[5];
-	PAL_POS          RoleCurrExp;
-	PAL_POS          RoleNextExp;
-	PAL_POS          RoleExpSlash;
-	PAL_POS          RoleLevel;
-	PAL_POS          RoleCurHP;
-	PAL_POS          RoleMaxHP;
-	PAL_POS          RoleHPSlash;
-	PAL_POS          RoleCurMP;
-	PAL_POS          RoleMaxMP;
-	PAL_POS          RoleMPSlash;
-	PAL_POS          RoleStatusValues[5];
-	PAL_POS          RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
-	PAL_POS          RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
-	PAL_POS          RolePoisonNames[MAX_POISONS];
-
-	PAL_POS          ExtraItemDescLines;
-	PAL_POS          ExtraMagicDescLines;
-} SCREENLAYOUT;
-
-typedef struct tagCONFIGURATION
-{
-	union {
-		SCREENLAYOUT     ScreenLayout;
-		PAL_POS          ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
-	};
-	enum {
-		USE_8x8_FONT = 1,
-		DISABLE_SHADOW = 2,
-	}                ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
-
-	/* Configurable options */
-	char            *pszGamePath;
-	char            *pszMsgFile;
-	char            *pszBdfFile;
-	CODEPAGE         uCodePage;
-	DWORD            dwWordLength;
-	DWORD            dwScreenWidth;
-	DWORD            dwScreenHeight;
-	INT              iSurroundOPLOffset;
-	INT              iAudioChannels;
-	INT              iSampleRate;
-	INT              iOPLSampleRate;
-	INT              iResampleQuality;
-	INT              iMusicVolume;
-	INT              iSoundVolume;
-	MUSICTYPE        eMusicType;
-	MUSICTYPE        eCDType;
-	OPLTYPE          eOPLType;
-	WORD             wAudioBufferSize;
-	BOOL             fIsWIN95;
-	BOOL             fUseEmbeddedFonts;
-	BOOL             fUseSurroundOPL;
-#if SDL_VERSION_ATLEAST(2,0,0)
-	BOOL             fKeepAspectRatio;
-#endif
-	BOOL             fFullScreen;
-	BOOL             fEnableJoyStick;
-	BOOL             fUseCustomScreenLayout;
-	BOOL             fLaunchSetting;
-	BOOL             fUseTouchOverlay;
-#if USE_RIX_EXTRA_INIT
-	uint32_t        *pExtraFMRegs;
-	uint8_t         *pExtraFMVals;
-	uint32_t         dwExtraLength;
-#endif
-} CONFIGURATION, *LPCONFIGURATION;
-
-extern CONFIGURATION gConfig;
-
-VOID
-PAL_LoadConfig(
-	BOOL fFromFile
-);
-
-BOOL
-PAL_SaveConfig(
-	VOID
-);
-
-BOOL
-PAL_ParseConfigLine(
-	const char * line,
-	const ConfigItem ** pItem,
-	ConfigValue * pValue
-);
-
-ConfigValue
-PAL_DefaultConfig(
-	PALCFG_ITEM item
-);
-
-const char *
-PAL_ConfigName(
-	PALCFG_ITEM item
-);
-
-BOOL
-PAL_LimitConfig(
-	PALCFG_ITEM item,
-	ConfigValue * pValue
-);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif

+ 1 - 0
palcfg.h

@@ -0,0 +1 @@
+src/palcfg.h

+ 0 - 960
palcommon.c

@@ -1,960 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// Based on PAL MapEditor by Baldur.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "palcommon.h"
-#include "global.h"
-#include "palcfg.h"
-
-BYTE
-PAL_CalcShadowColor(
-   BYTE bSourceColor
-)
-{
-    return ((bSourceColor&0xF0)|((bSourceColor&0x0F)>>1));
-}
-
-INT
-PAL_RLEBlitToSurface(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos
-)
-{
-    return PAL_RLEBlitToSurfaceWithShadow ( lpBitmapRLE, lpDstSurface, pos, FALSE );
-}
-
-INT
-PAL_RLEBlitToSurfaceWithShadow(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos,
-   BOOL              bShadow
-)
-/*++
-  Purpose:
-
-    Blit an RLE-compressed bitmap to an SDL surface.
-    NOTE: Assume the surface is already locked, and the surface is a 8-bit one.
-
-  Parameters:
-
-    [IN]  lpBitmapRLE - pointer to the RLE-compressed bitmap to be decoded.
-
-    [OUT] lpDstSurface - pointer to the destination SDL surface.
-
-    [IN]  pos - position of the destination area.
-
-    [IN]  bShadow - flag to mention whether blit source color or just shadow.
-
-  Return value:
-
-    0 = success, -1 = error.
-
---*/
-{
-   UINT          i, j;
-   INT           x, y;
-   UINT          uiLen       = 0;
-   UINT          uiWidth     = 0;
-   UINT          uiHeight    = 0;
-   BYTE          T;
-   INT           dx          = PAL_X(pos);
-   INT           dy          = PAL_Y(pos);
-
-   //
-   // Check for NULL pointer.
-   //
-   if (lpBitmapRLE == NULL || lpDstSurface == NULL)
-   {
-      return -1;
-   }
-
-   //
-   // Skip the 0x00000002 in the file header.
-   //
-   if (lpBitmapRLE[0] == 0x02 && lpBitmapRLE[1] == 0x00 &&
-      lpBitmapRLE[2] == 0x00 && lpBitmapRLE[3] == 0x00)
-   {
-      lpBitmapRLE += 4;
-   }
-
-   //
-   // Get the width and height of the bitmap.
-   //
-   uiWidth = lpBitmapRLE[0] | (lpBitmapRLE[1] << 8);
-   uiHeight = lpBitmapRLE[2] | (lpBitmapRLE[3] << 8);
-
-   //
-   // Calculate the total length of the bitmap.
-   // The bitmap is 8-bpp, each pixel will use 1 byte.
-   //
-   uiLen = uiWidth * uiHeight;
-
-   //
-   // Start decoding and blitting the bitmap.
-   //
-   lpBitmapRLE += 4;
-   for (i = 0; i < uiLen;)
-   {
-      T = *lpBitmapRLE++;
-      if ((T & 0x80) && T <= 0x80 + uiWidth)
-      {
-         i += T - 0x80;
-      }
-      else
-      {
-         for (j = 0; j < T; j++)
-         {
-            //
-            // Calculate the destination coordination.
-            // FIXME: This could be optimized
-            //
-            y = (i + j) / uiWidth + dy;
-            x = (i + j) % uiWidth + dx;
-
-            //
-            // Skip the points which are out of the surface.
-            //
-            if (x < 0)
-            {
-               j += -x - 1;
-               continue;
-            }
-            else if (x >= lpDstSurface->w)
-            {
-               j += x - lpDstSurface->w;
-               continue;
-            }
-
-            if (y < 0)
-            {
-               j += -y * uiWidth - 1;
-               continue;
-            }
-            else if (y >= lpDstSurface->h)
-            {
-               goto end; // No more pixels needed, break out
-            }
-
-            //
-            // Put the pixel onto the surface (FIXME: inefficient).
-            //
-            if(bShadow)
-               ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] = PAL_CalcShadowColor(((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x]);
-            else
-               ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] = lpBitmapRLE[j];
-         }
-         lpBitmapRLE += T;
-         i += T;
-      }
-   }
-
-end:
-   //
-   // Success
-   //
-   return 0;
-}
-
-INT
-PAL_RLEBlitWithColorShift(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos,
-   INT               iColorShift
-)
-/*++
-  Purpose:
-
-    Blit an RLE-compressed bitmap to an SDL surface.
-    NOTE: Assume the surface is already locked, and the surface is a 8-bit one.
-
-  Parameters:
-
-    [IN]  lpBitmapRLE - pointer to the RLE-compressed bitmap to be decoded.
-
-    [OUT] lpDstSurface - pointer to the destination SDL surface.
-
-    [IN]  pos - position of the destination area.
-
-    [IN]  iColorShift - shift the color by this value.
-
-  Return value:
-
-    0 = success, -1 = error.
-
---*/
-{
-   UINT          i, j;
-   INT           x, y;
-   UINT          uiLen       = 0;
-   UINT          uiWidth     = 0;
-   UINT          uiHeight    = 0;
-   BYTE          T, b;
-   INT           dx          = PAL_X(pos);
-   INT           dy          = PAL_Y(pos);
-
-   //
-   // Check for NULL pointer.
-   //
-   if (lpBitmapRLE == NULL || lpDstSurface == NULL)
-   {
-      return -1;
-   }
-
-   //
-   // Skip the 0x00000002 in the file header.
-   //
-   if (lpBitmapRLE[0] == 0x02 && lpBitmapRLE[1] == 0x00 &&
-      lpBitmapRLE[2] == 0x00 && lpBitmapRLE[3] == 0x00)
-   {
-      lpBitmapRLE += 4;
-   }
-
-   //
-   // Get the width and height of the bitmap.
-   //
-   uiWidth = lpBitmapRLE[0] | (lpBitmapRLE[1] << 8);
-   uiHeight = lpBitmapRLE[2] | (lpBitmapRLE[3] << 8);
-
-   //
-   // Calculate the total length of the bitmap.
-   // The bitmap is 8-bpp, each pixel will use 1 byte.
-   //
-   uiLen = uiWidth * uiHeight;
-
-   //
-   // Start decoding and blitting the bitmap.
-   //
-   lpBitmapRLE += 4;
-   for (i = 0; i < uiLen;)
-   {
-      T = *lpBitmapRLE++;
-      if ((T & 0x80) && T <= 0x80 + uiWidth)
-      {
-         i += T - 0x80;
-      }
-      else
-      {
-         for (j = 0; j < T; j++)
-         {
-            //
-            // Calculate the destination coordination.
-            // FIXME: This could be optimized
-            //
-            y = (i + j) / uiWidth + dy;
-            x = (i + j) % uiWidth + dx;
-
-            //
-            // Skip the points which are out of the surface.
-            //
-            if (x < 0)
-            {
-               j += -x - 1;
-               continue;
-            }
-            else if (x >= lpDstSurface->w)
-            {
-               j += x - lpDstSurface->w;
-               continue;
-            }
-
-            if (y < 0)
-            {
-               j += -y * uiWidth - 1;
-               continue;
-            }
-            else if (y >= lpDstSurface->h)
-            {
-               goto end; // No more pixels needed, break out
-            }
-
-            //
-            // Put the pixel onto the surface (FIXME: inefficient).
-            //
-            b = (lpBitmapRLE[j] & 0x0F);
-            if ((INT)b + iColorShift > 0x0F)
-            {
-               b = 0x0F;
-            }
-            else if ((INT)b + iColorShift < 0)
-            {
-               b = 0;
-            }
-            else
-            {
-               b += iColorShift;
-            }
-
-            ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] =
-               (b | (lpBitmapRLE[j] & 0xF0));
-         }
-         lpBitmapRLE += T;
-         i += T;
-      }
-   }
-
-end:
-   //
-   // Success
-   //
-   return 0;
-}
-
-INT
-PAL_RLEBlitMonoColor(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos,
-   BYTE              bColor,
-   INT               iColorShift
-)
-/*++
-  Purpose:
-
-    Blit an RLE-compressed bitmap to an SDL surface in mono-color form.
-    NOTE: Assume the surface is already locked, and the surface is a 8-bit one.
-
-  Parameters:
-
-    [IN]  lpBitmapRLE - pointer to the RLE-compressed bitmap to be decoded.
-
-    [OUT] lpDstSurface - pointer to the destination SDL surface.
-
-    [IN]  pos - position of the destination area.
-
-    [IN]  bColor - the color to be used while drawing.
-
-    [IN]  iColorShift - shift the color by this value.
-
-  Return value:
-
-    0 = success, -1 = error.
-
---*/
-{
-   UINT          i, j;
-   INT           x, y;
-   UINT          uiLen       = 0;
-   UINT          uiWidth     = 0;
-   UINT          uiHeight    = 0;
-   BYTE          T, b;
-   INT           dx          = PAL_X(pos);
-   INT           dy          = PAL_Y(pos);
-
-   //
-   // Check for NULL pointer.
-   //
-   if (lpBitmapRLE == NULL || lpDstSurface == NULL)
-   {
-      return -1;
-   }
-
-   //
-   // Skip the 0x00000002 in the file header.
-   //
-   if (lpBitmapRLE[0] == 0x02 && lpBitmapRLE[1] == 0x00 &&
-      lpBitmapRLE[2] == 0x00 && lpBitmapRLE[3] == 0x00)
-   {
-      lpBitmapRLE += 4;
-   }
-
-   //
-   // Get the width and height of the bitmap.
-   //
-   uiWidth = lpBitmapRLE[0] | (lpBitmapRLE[1] << 8);
-   uiHeight = lpBitmapRLE[2] | (lpBitmapRLE[3] << 8);
-
-   //
-   // Calculate the total length of the bitmap.
-   // The bitmap is 8-bpp, each pixel will use 1 byte.
-   //
-   uiLen = uiWidth * uiHeight;
-
-   //
-   // Start decoding and blitting the bitmap.
-   //
-   lpBitmapRLE += 4;
-   bColor &= 0xF0;
-   for (i = 0; i < uiLen;)
-   {
-      T = *lpBitmapRLE++;
-      if ((T & 0x80) && T <= 0x80 + uiWidth)
-      {
-         i += T - 0x80;
-      }
-      else
-      {
-         for (j = 0; j < T; j++)
-         {
-            //
-            // Calculate the destination coordination.
-            // FIXME: This could be optimized
-            //
-            y = (i + j) / uiWidth + dy;
-            x = (i + j) % uiWidth + dx;
-
-            //
-            // Skip the points which are out of the surface.
-            //
-            if (x < 0)
-            {
-               j += -x - 1;
-               continue;
-            }
-            else if (x >= lpDstSurface->w)
-            {
-               j += x - lpDstSurface->w;
-               continue;
-            }
-
-            if (y < 0)
-            {
-               j += -y * uiWidth - 1;
-               continue;
-            }
-            else if (y >= lpDstSurface->h)
-            {
-               goto end; // No more pixels needed, break out
-            }
-
-            //
-            // Put the pixel onto the surface (FIXME: inefficient).
-            //
-            b = lpBitmapRLE[j] & 0x0F;
-            if ((INT)b + iColorShift > 0x0F)
-            {
-               b = 0x0F;
-            }
-            else if ((INT)b + iColorShift < 0)
-            {
-               b = 0;
-            }
-            else
-            {
-               b += iColorShift;
-            }
-            ((LPBYTE)lpDstSurface->pixels)[y * lpDstSurface->pitch + x] = (b | bColor);
-         }
-         lpBitmapRLE += T;
-         i += T;
-      }
-   }
-
-end:
-   //
-   // Success
-   //
-   return 0;
-}
-
-INT
-PAL_FBPBlitToSurface(
-   LPBYTE            lpBitmapFBP,
-   SDL_Surface      *lpDstSurface
-)
-/*++
-  Purpose:
-
-    Blit an uncompressed bitmap in FBP.MKF to an SDL surface.
-    NOTE: Assume the surface is already locked, and the surface is a 8-bit 320x200 one.
-
-  Parameters:
-
-    [IN]  lpBitmapFBP - pointer to the RLE-compressed bitmap to be decoded.
-
-    [OUT] lpDstSurface - pointer to the destination SDL surface.
-
-  Return value:
-
-    0 = success, -1 = error.
-
---*/
-{
-   int       x, y;
-   LPBYTE    p;
-
-   if (lpBitmapFBP == NULL || lpDstSurface == NULL ||
-      lpDstSurface->w != 320 || lpDstSurface->h != 200)
-   {
-      return -1;
-   }
-
-   //
-   // simply copy everything to the surface
-   //
-   for (y = 0; y < 200; y++)
-   {
-      p = (LPBYTE)(lpDstSurface->pixels) + y * lpDstSurface->pitch;
-      for (x = 0; x < 320; x++)
-      {
-         *(p++) = *(lpBitmapFBP++);
-      }
-   }
-
-   return 0;
-}
-
-INT
-PAL_RLEGetWidth(
-   LPCBITMAPRLE    lpBitmapRLE
-)
-/*++
-  Purpose:
-
-    Get the width of an RLE-compressed bitmap.
-
-  Parameters:
-
-    [IN]  lpBitmapRLE - pointer to an RLE-compressed bitmap.
-
-  Return value:
-
-    Integer value which indicates the height of the bitmap.
-
---*/
-{
-   if (lpBitmapRLE == NULL)
-   {
-      return 0;
-   }
-
-   //
-   // Skip the 0x00000002 in the file header.
-   //
-   if (lpBitmapRLE[0] == 0x02 && lpBitmapRLE[1] == 0x00 &&
-      lpBitmapRLE[2] == 0x00 && lpBitmapRLE[3] == 0x00)
-   {
-      lpBitmapRLE += 4;
-   }
-
-   //
-   // Return the width of the bitmap.
-   //
-   return lpBitmapRLE[0] | (lpBitmapRLE[1] << 8);
-}
-
-INT
-PAL_RLEGetHeight(
-   LPCBITMAPRLE       lpBitmapRLE
-)
-/*++
-  Purpose:
-
-    Get the height of an RLE-compressed bitmap.
-
-  Parameters:
-
-    [IN]  lpBitmapRLE - pointer of an RLE-compressed bitmap.
-
-  Return value:
-
-    Integer value which indicates the height of the bitmap.
-
---*/
-{
-   if (lpBitmapRLE == NULL)
-   {
-      return 0;
-   }
-
-   //
-   // Skip the 0x00000002 in the file header.
-   //
-   if (lpBitmapRLE[0] == 0x02 && lpBitmapRLE[1] == 0x00 &&
-      lpBitmapRLE[2] == 0x00 && lpBitmapRLE[3] == 0x00)
-   {
-      lpBitmapRLE += 4;
-   }
-
-   //
-   // Return the height of the bitmap.
-   //
-   return lpBitmapRLE[2] | (lpBitmapRLE[3] << 8);
-}
-
-WORD
-PAL_SpriteGetNumFrames(
-   LPCSPRITE       lpSprite
-)
-/*++
-  Purpose:
-
-    Get the total number of frames of a sprite.
-
-  Parameters:
-
-    [IN]  lpSprite - pointer to the sprite.
-
-  Return value:
-
-    Number of frames of the sprite.
-
---*/
-{
-   if (lpSprite == NULL)
-   {
-      return 0;
-   }
-
-   return (lpSprite[0] | (lpSprite[1] << 8)) - 1;
-}
-
-LPCBITMAPRLE
-PAL_SpriteGetFrame(
-   LPCSPRITE       lpSprite,
-   INT             iFrameNum
-)
-/*++
-  Purpose:
-
-    Get the pointer to the specified frame from a sprite.
-
-  Parameters:
-
-    [IN]  lpSprite - pointer to the sprite.
-
-    [IN]  iFrameNum - number of the frame.
-
-  Return value:
-
-    Pointer to the specified frame. NULL if the frame does not exist.
-
---*/
-{
-   int imagecount, offset;
-
-   if (lpSprite == NULL)
-   {
-      return NULL;
-   }
-
-   //
-   // Hack for broken sprites like the Bloody-Mouth Bug
-   //
-//   imagecount = (lpSprite[0] | (lpSprite[1] << 8)) - 1;
-   imagecount = (lpSprite[0] | (lpSprite[1] << 8));
-
-   if (iFrameNum < 0 || iFrameNum >= imagecount)
-   {
-      //
-      // The frame does not exist
-      //
-      return NULL;
-   }
-
-   //
-   // Get the offset of the frame
-   //
-   iFrameNum <<= 1;
-   offset = ((lpSprite[iFrameNum] | (lpSprite[iFrameNum + 1] << 8)) << 1);
-   if (!gConfig.fIsWIN95) offset = (WORD)offset;
-   return &lpSprite[offset];
-}
-
-INT
-PAL_MKFGetChunkCount(
-   FILE *fp
-)
-/*++
-  Purpose:
-
-    Get the number of chunks in an MKF archive.
-
-  Parameters:
-
-    [IN]  fp - pointer to an fopen'ed MKF file.
-
-  Return value:
-
-    Integer value which indicates the number of chunks in the specified MKF file.
-
---*/
-{
-   INT iNumChunk;
-   if (fp == NULL)
-   {
-      return 0;
-   }
-
-   fseek(fp, 0, SEEK_SET);
-   fread(&iNumChunk, sizeof(INT), 1, fp);
-
-   iNumChunk = (SDL_SwapLE32(iNumChunk) - 4) / 4;
-   return iNumChunk;
-}
-
-INT
-PAL_MKFGetChunkSize(
-   UINT    uiChunkNum,
-   FILE   *fp
-)
-/*++
-  Purpose:
-
-    Get the size of a chunk in an MKF archive.
-
-  Parameters:
-
-    [IN]  uiChunkNum - the number of the chunk in the MKF archive.
-
-    [IN]  fp - pointer to the fopen'ed MKF file.
-
-  Return value:
-
-    Integer value which indicates the size of the chunk.
-    -1 if the chunk does not exist.
-
---*/
-{
-   UINT    uiOffset       = 0;
-   UINT    uiNextOffset   = 0;
-   UINT    uiChunkCount   = 0;
-
-   //
-   // Get the total number of chunks.
-   //
-   uiChunkCount = PAL_MKFGetChunkCount(fp);
-   if (uiChunkNum >= uiChunkCount)
-   {
-      return -1;
-   }
-
-   //
-   // Get the offset of the specified chunk and the next chunk.
-   //
-   fseek(fp, 4 * uiChunkNum, SEEK_SET);
-   fread(&uiOffset, sizeof(UINT), 1, fp);
-   fread(&uiNextOffset, sizeof(UINT), 1, fp);
-   uiOffset = SDL_SwapLE32(uiOffset);
-   uiNextOffset = SDL_SwapLE32(uiNextOffset);
-
-   //
-   // Return the length of the chunk.
-   //
-   return uiNextOffset - uiOffset;
-}
-
-INT
-PAL_MKFReadChunk(
-   LPBYTE          lpBuffer,
-   UINT            uiBufferSize,
-   UINT            uiChunkNum,
-   FILE           *fp
-)
-/*++
-  Purpose:
-
-    Read a chunk from an MKF archive into lpBuffer.
-
-  Parameters:
-
-    [OUT] lpBuffer - pointer to the destination buffer.
-
-    [IN]  uiBufferSize - size of the destination buffer.
-
-    [IN]  uiChunkNum - the number of the chunk in the MKF archive to read.
-
-    [IN]  fp - pointer to the fopen'ed MKF file.
-
-  Return value:
-
-    Integer value which indicates the size of the chunk.
-    -1 if there are error in parameters.
-    -2 if buffer size is not enough.
-
---*/
-{
-   UINT     uiOffset       = 0;
-   UINT     uiNextOffset   = 0;
-   UINT     uiChunkCount;
-   UINT     uiChunkLen;
-
-   if (lpBuffer == NULL || fp == NULL || uiBufferSize == 0)
-   {
-      return -1;
-   }
-
-   //
-   // Get the total number of chunks.
-   //
-   uiChunkCount = PAL_MKFGetChunkCount(fp);
-   if (uiChunkNum >= uiChunkCount)
-   {
-      return -1;
-   }
-
-   //
-   // Get the offset of the chunk.
-   //
-   fseek(fp, 4 * uiChunkNum, SEEK_SET);
-   fread(&uiOffset, 4, 1, fp);
-   fread(&uiNextOffset, 4, 1, fp);
-   uiOffset = SDL_SwapLE32(uiOffset);
-   uiNextOffset = SDL_SwapLE32(uiNextOffset);
-
-   //
-   // Get the length of the chunk.
-   //
-   uiChunkLen = uiNextOffset - uiOffset;
-
-   if (uiChunkLen > uiBufferSize)
-   {
-      return -2;
-   }
-
-   if (uiChunkLen != 0)
-   {
-      fseek(fp, uiOffset, SEEK_SET);
-      fread(lpBuffer, uiChunkLen, 1, fp);
-   }
-   else
-   {
-      return -1;
-   }
-
-   return (INT)uiChunkLen;
-}
-
-INT
-PAL_MKFGetDecompressedSize(
-   UINT    uiChunkNum,
-   FILE   *fp
-)
-/*++
-  Purpose:
-
-    Get the decompressed size of a compressed chunk in an MKF archive.
-
-  Parameters:
-
-    [IN]  uiChunkNum - the number of the chunk in the MKF archive.
-
-    [IN]  fp - pointer to the fopen'ed MKF file.
-
-  Return value:
-
-    Integer value which indicates the size of the chunk.
-    -1 if the chunk does not exist.
-
---*/
-{
-   DWORD         buf[2];
-   UINT          uiOffset;
-   UINT          uiChunkCount;
-
-   if (fp == NULL)
-   {
-      return -1;
-   }
-
-   //
-   // Get the total number of chunks.
-   //
-   uiChunkCount = PAL_MKFGetChunkCount(fp);
-   if (uiChunkNum >= uiChunkCount)
-   {
-      return -1;
-   }
-
-   //
-   // Get the offset of the chunk.
-   //
-   fseek(fp, 4 * uiChunkNum, SEEK_SET);
-   fread(&uiOffset, 4, 1, fp);
-   uiOffset = SDL_SwapLE32(uiOffset);
-
-   //
-   // Read the header.
-   //
-   fseek(fp, uiOffset, SEEK_SET);
-   if (gConfig.fIsWIN95)
-   {
-      fread(buf, sizeof(DWORD), 1, fp);
-      buf[0] = SDL_SwapLE32(buf[0]);
-
-      return (INT)buf[0];
-   }
-   else
-   {
-      fread(buf, sizeof(DWORD), 2, fp);
-      buf[0] = SDL_SwapLE32(buf[0]);
-      buf[1] = SDL_SwapLE32(buf[1]);
-
-      return (buf[0] != 0x315f4a59) ? -1 : (INT)buf[1];
-   }
-}
-
-INT
-PAL_MKFDecompressChunk(
-   LPBYTE          lpBuffer,
-   UINT            uiBufferSize,
-   UINT            uiChunkNum,
-   FILE           *fp
-)
-/*++
-  Purpose:
-
-    Decompress a compressed chunk from an MKF archive into lpBuffer.
-
-  Parameters:
-
-    [OUT] lpBuffer - pointer to the destination buffer.
-
-    [IN]  uiBufferSize - size of the destination buffer.
-
-    [IN]  uiChunkNum - the number of the chunk in the MKF archive to read.
-
-    [IN]  fp - pointer to the fopen'ed MKF file.
-
-  Return value:
-
-    Integer value which indicates the size of the chunk.
-    -1 if there are error in parameters, or buffer size is not enough.
-    -3 if cannot allocate memory for decompression.
-
---*/
-{
-   LPBYTE          buf;
-   int             len;
-
-   len = PAL_MKFGetChunkSize(uiChunkNum, fp);
-
-   if (len <= 0)
-   {
-      return len;
-   }
-
-   buf = (LPBYTE)malloc(len);
-   if (buf == NULL)
-   {
-      return -3;
-   }
-
-   PAL_MKFReadChunk(buf, len, uiChunkNum, fp);
-
-   len = Decompress(buf, lpBuffer, uiBufferSize);
-   free(buf);
-
-   return len;
-}

+ 1 - 0
palcommon.c

@@ -0,0 +1 @@
+src/palcommon.c

+ 0 - 180
palcommon.h

@@ -1,180 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef _PALUTILS_H
-#define _PALUTILS_H
-
-#include "common.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef LPBYTE      LPSPRITE, LPBITMAPRLE;
-typedef LPCBYTE     LPCSPRITE, LPCBITMAPRLE;
-
-#ifndef PAL_POS_DEFINED
-#define PAL_POS_DEFINED
-typedef DWORD           PAL_POS;
-#endif
-
-#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
-{
-   kDirSouth = 0,
-   kDirWest,
-   kDirNorth,
-   kDirEast,
-   kDirUnknown
-} PALDIRECTION, *LPPALDIRECTION;
-    
-INT
-PAL_RLEBlitToSurface(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos
-);
-
-INT
-PAL_RLEBlitToSurfaceWithShadow(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos,
-   BOOL              bShadow
-);
-
-INT
-PAL_RLEBlitWithColorShift(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos,
-   INT               iColorShift
-);
-
-INT
-PAL_RLEBlitMonoColor(
-   LPCBITMAPRLE      lpBitmapRLE,
-   SDL_Surface      *lpDstSurface,
-   PAL_POS           pos,
-   BYTE              bColor,
-   INT               iColorShift
-);
-
-INT
-PAL_FBPBlitToSurface(
-   LPBYTE            lpBitmapFBP,
-   SDL_Surface      *lpDstSurface
-);
-
-INT
-PAL_RLEGetWidth(
-   LPCBITMAPRLE      lpBitmapRLE
-);
-
-INT
-PAL_RLEGetHeight(
-   LPCBITMAPRLE      lpBitmapRLE
-);
-
-WORD
-PAL_SpriteGetNumFrames(
-   LPCSPRITE       lpSprite
-);
-
-LPCBITMAPRLE
-PAL_SpriteGetFrame(
-   LPCSPRITE       lpSprite,
-   INT             iFrameNum
-);
-
-INT
-PAL_MKFGetChunkCount(
-   FILE *fp
-);
-
-INT
-PAL_MKFGetChunkSize(
-   UINT    uiChunkNum,
-   FILE   *fp
-);
-
-INT
-PAL_MKFReadChunk(
-   LPBYTE          lpBuffer,
-   UINT            uiBufferSize,
-   UINT            uiChunkNum,
-   FILE           *fp
-);
-
-INT
-PAL_MKFGetDecompressedSize(
-   UINT    uiChunkNum,
-   FILE   *fp
-);
-
-INT
-PAL_MKFDecompressChunk(
-   LPBYTE          lpBuffer,
-   UINT            uiBufferSize,
-   UINT            uiChunkNum,
-   FILE           *fp
-);
-
-// From yj1.c:
-extern INT
-(*Decompress)(
-   LPCVOID      Source,
-   LPVOID       Destination,
-   INT          DestSize
-);
-
-INT
-YJ1_Decompress(
-   LPCVOID      Source,
-   LPVOID       Destination,
-   INT          DestSize
-);
-
-INT
-YJ2_Decompress(
-   LPCVOID      Source,
-   LPVOID       Destination,
-   INT          DestSize
-);
-
-#define PAL_DelayUntil(t) \
-   PAL_ProcessEvent(); \
-   while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
-   { \
-      PAL_ProcessEvent(); \
-      SDL_Delay(1); \
-   }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _PALUTILS_H

+ 1 - 0
palcommon.h

@@ -0,0 +1 @@
+src/palcommon.h

+ 0 - 653
palette.c

@@ -1,653 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "main.h"
-
-SDL_Color *
-PAL_GetPalette(
-   INT         iPaletteNum,
-   BOOL        fNight
-)
-/*++
-  Purpose:
-
-    Get the specified palette in pat.mkf file.
-
-  Parameters:
-
-    [IN]  iPaletteNum - number of the palette.
-
-    [IN]  fNight - whether use the night palette or not.
-
-  Return value:
-
-    Pointer to the palette. NULL if failed.
-
---*/
-{
-   static SDL_Color      palette[256];
-   PAL_LARGE BYTE        buf[1536];
-   INT                   i;
-   FILE                 *fp;
-
-   fp = UTIL_OpenRequiredFile("pat.mkf");
-
-   //
-   // Read the palette data from the pat.mkf file
-   //
-   i = PAL_MKFReadChunk(buf, 1536, iPaletteNum, fp);
-
-   fclose(fp);
-
-   if (i < 0)
-   {
-      //
-      // Read failed
-      //
-      return NULL;
-   }
-   else if (i <= 256 * 3)
-   {
-      //
-      // There is no night colors in the palette
-      //
-      fNight = FALSE;
-   }
-
-   for (i = 0; i < 256; i++)
-   {
-      palette[i].r = buf[(fNight ? 256 * 3 : 0) + i * 3] << 2;
-      palette[i].g = buf[(fNight ? 256 * 3 : 0) + i * 3 + 1] << 2;
-      palette[i].b = buf[(fNight ? 256 * 3 : 0) + i * 3 + 2] << 2;
-#if 0
-      palette[i].r += (255 - palette[i].r) / 5;
-      palette[i].g += (255 - palette[i].g) / 5;
-      palette[i].b += (255 - palette[i].b) / 5;
-#endif
-   }
-
-   return palette;
-}
-
-VOID
-PAL_SetPalette(
-   INT         iPaletteNum,
-   BOOL        fNight
-)
-/*++
-  Purpose:
-
-    Set the screen palette to the specified one.
-
-  Parameters:
-
-    [IN]  iPaletteNum - number of the palette.
-
-    [IN]  fNight - whether use the night palette or not.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_Color *p = PAL_GetPalette(iPaletteNum, fNight);
-
-   if (p != NULL)
-   {
-      VIDEO_SetPalette(p);
-   }
-}
-
-VOID
-PAL_FadeOut(
-   INT         iDelay
-)
-/*++
-  Purpose:
-
-    Fadeout screen to black from the specified palette.
-
-  Parameters:
-
-    [IN]  iPaletteNum - number of the palette.
-
-    [IN]  fNight - whether use the night palette or not.
-
-    [IN]  iDelay - delay time for each step.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int                      i, j;
-   UINT                     time;
-   PAL_LARGE SDL_Color      palette[256];
-   PAL_LARGE SDL_Color      newpalette[256];
-
-   //
-   // Get the original palette...
-   //
-   for (i = 0; i < 256; i++)
-   {
-      palette[i] = VIDEO_GetPalette()[i];
-   }
-
-   //
-   // Start fading out...
-   //
-   time = SDL_GetTicks() + iDelay * 10 * 60;
-
-   while (TRUE)
-   {
-      //
-      // Set the current palette...
-      //
-      j = (int)(time - SDL_GetTicks()) / iDelay / 10;
-      if (j < 0)
-      {
-         break;
-      }
-
-      for (i = 0; i < 256; i++)
-      {
-         newpalette[i].r = (palette[i].r * j) >> 6;
-         newpalette[i].g = (palette[i].g * j) >> 6;
-         newpalette[i].b = (palette[i].b * j) >> 6;
-      }
-
-      VIDEO_SetPalette(newpalette);
-
-      UTIL_Delay(10);
-   }
-
-   memset(newpalette, 0, sizeof(newpalette));
-   VIDEO_SetPalette(newpalette);
-}
-
-VOID
-PAL_FadeIn(
-   INT         iPaletteNum,
-   BOOL        fNight,
-   INT         iDelay
-)
-/*++
-  Purpose:
-
-    Fade in the screen to the specified palette.
-
-  Parameters:
-
-    [IN]  iPaletteNum - number of the palette.
-
-    [IN]  fNight - whether use the night palette or not.
-
-    [IN]  iDelay - delay time for each step.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int                      i, j;
-   UINT                     time;
-   SDL_Color               *palette;
-   PAL_LARGE SDL_Color      newpalette[256];
-
-   //
-   // Get the new palette...
-   //
-   palette = PAL_GetPalette(iPaletteNum, fNight);
-
-   //
-   // Start fading in...
-   //
-   time = SDL_GetTicks() + iDelay * 10 * 60;
-   while (TRUE)
-   {
-      //
-      // Set the current palette...
-      //
-      j = (int)(time - SDL_GetTicks()) / iDelay / 10;
-      if (j < 0)
-      {
-         break;
-      }
-
-      j = 60 - j;
-
-      for (i = 0; i < 256; i++)
-      {
-         newpalette[i].r = (palette[i].r * j) >> 6;
-         newpalette[i].g = (palette[i].g * j) >> 6;
-         newpalette[i].b = (palette[i].b * j) >> 6;
-      }
-
-      VIDEO_SetPalette(newpalette);
-
-      UTIL_Delay(10);
-   }
-
-   VIDEO_SetPalette(palette);
-}
-
-VOID
-PAL_SceneFade(
-   INT         iPaletteNum,
-   BOOL        fNight,
-   INT         iStep
-)
-/*++
-  Purpose:
-
-    Fade in or fade out the screen. Update the scene during the process.
-
-  Parameters:
-
-    [IN]  iPaletteNum - number of the palette.
-
-    [IN]  fNight - whether use the night palette or not.
-
-    [IN]  iStep - positive to fade in, nagative to fade out.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_Color            *palette, newpalette[256];
-   int                   i, j;
-   DWORD                 time;
-
-   palette = PAL_GetPalette(iPaletteNum, fNight);
-
-   if (palette == NULL)
-   {
-      return;
-   }
-
-   if (iStep == 0)
-   {
-      iStep = 1;
-   }
-
-   gpGlobals->fNeedToFadeIn = FALSE;
-
-   if (iStep > 0)
-   {
-      for (i = 0; i < 64; i += iStep)
-      {
-         time = SDL_GetTicks() + 100;
-
-         //
-         // Generate the scene
-         //
-         PAL_ClearKeyState();
-         g_InputState.dir = kDirUnknown;
-         g_InputState.prevdir = kDirUnknown;
-         PAL_GameUpdate(FALSE);
-         PAL_MakeScene();
-         VIDEO_UpdateScreen(NULL);
-
-         //
-         // Calculate the current palette...
-         //
-         for (j = 0; j < 256; j++)
-         {
-            newpalette[j].r = (palette[j].r * i) >> 6;
-            newpalette[j].g = (palette[j].g * i) >> 6;
-            newpalette[j].b = (palette[j].b * i) >> 6;
-         }
-         VIDEO_SetPalette(newpalette);
-
-         while (PAL_PollEvent(NULL));
-
-         while (!SDL_TICKS_PASSED(SDL_GetTicks(), time))
-         {
-            while (PAL_PollEvent(NULL));
-            SDL_Delay(5);
-         }
-      }
-   }
-   else
-   {
-      for (i = 63; i >= 0; i += iStep)
-      {
-         time = SDL_GetTicks() + 100;
-
-         //
-         // Generate the scene
-         //
-         PAL_ClearKeyState();
-         g_InputState.dir = kDirUnknown;
-         g_InputState.prevdir = kDirUnknown;
-         PAL_GameUpdate(FALSE);
-         PAL_MakeScene();
-         VIDEO_UpdateScreen(NULL);
-
-         //
-         // Calculate the current palette...
-         //
-         for (j = 0; j < 256; j++)
-         {
-            newpalette[j].r = (palette[j].r * i) >> 6;
-            newpalette[j].g = (palette[j].g * i) >> 6;
-            newpalette[j].b = (palette[j].b * i) >> 6;
-         }
-         VIDEO_SetPalette(newpalette);
-
-         while (PAL_PollEvent(NULL));
-
-         while (!SDL_TICKS_PASSED(SDL_GetTicks(), time))
-         {
-            while (PAL_PollEvent(NULL));
-            SDL_Delay(5);
-         }
-      }
-   }
-}
-
-VOID
-PAL_PaletteFade(
-   INT         iPaletteNum,
-   BOOL        fNight,
-   BOOL        fUpdateScene
-)
-/*++
-  Purpose:
-
-    Fade from the current palette to the specified one.
-
-  Parameters:
-
-    [IN]  iPaletteNum - number of the palette.
-
-    [IN]  fNight - whether use the night palette or not.
-
-    [IN]  fUpdateScene - TRUE if update the scene in the progress.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int            i, j;
-   UINT           time;
-   SDL_Color     *newpalette = PAL_GetPalette(iPaletteNum, fNight);
-   PAL_LARGE SDL_Color      palette[256];
-   PAL_LARGE SDL_Color		t[256];
-
-   if (newpalette == NULL)
-   {
-      return;
-   }
-
-   for (i = 0; i < 256; i++)
-   {
-      palette[i] = VIDEO_GetPalette()[i];
-   }
-
-   //
-   // Start fading...
-   //
-   for (i = 0; i < 32; i++)
-   {
-      time = SDL_GetTicks() + (fUpdateScene ? FRAME_TIME : FRAME_TIME / 4);
-
-      for (j = 0; j < 256; j++)
-      {
-         t[j].r =
-            (BYTE)(((INT)(palette[j].r) * (31 - i) + (INT)(newpalette[j].r) * i) / 31);
-         t[j].g =
-            (BYTE)(((INT)(palette[j].g) * (31 - i) + (INT)(newpalette[j].g) * i) / 31);
-         t[j].b =
-            (BYTE)(((INT)(palette[j].b) * (31 - i) + (INT)(newpalette[j].b) * i) / 31);
-      }
-      VIDEO_SetPalette(t);
-
-      if (fUpdateScene)
-      {
-         PAL_ClearKeyState();
-         g_InputState.dir = kDirUnknown;
-         g_InputState.prevdir = kDirUnknown;
-         PAL_GameUpdate(FALSE);
-         PAL_MakeScene();
-         VIDEO_UpdateScreen(NULL);
-      }
-
-      while (PAL_PollEvent(NULL));
-
-      while (!SDL_TICKS_PASSED(SDL_GetTicks(), time))
-      {
-         while (PAL_PollEvent(NULL));
-         SDL_Delay(5);
-      }
-   }
-}
-
-VOID
-PAL_ColorFade(
-   INT        iDelay,
-   BYTE       bColor,
-   BOOL       fFrom
-)
-/*++
-  Purpose:
-
-    Fade the palette from/to the specified color.
-
-  Parameters:
-
-    [IN]  iDelay - the delay time of each step.
-
-    [IN]  bColor - the color to fade from/to.
-
-    [IN]  fFrom - if TRUE then fade from bColor, else fade to bColor.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_Color       *palette;
-   PAL_LARGE SDL_Color        newpalette[256];
-   int              i, j;
-
-   palette = PAL_GetPalette(gpGlobals->wNumPalette, gpGlobals->fNightPalette);
-
-   iDelay *= 10;
-   if (iDelay == 0)
-   {
-      iDelay = 10;
-   }
-
-   if (fFrom)
-   {
-      for (i = 0; i < 256; i++)
-      {
-         newpalette[i] = palette[bColor];
-      }
-
-      for (i = 0; i < 64; i++)
-      {
-         for (j = 0; j < 256; j++)
-         {
-            if (newpalette[j].r > palette[j].r)
-            {
-               newpalette[j].r -= 4;
-            }
-            else if (newpalette[j].r < palette[j].r)
-            {
-               newpalette[j].r += 4;
-            }
-
-            if (newpalette[j].g > palette[j].g)
-            {
-               newpalette[j].g -= 4;
-            }
-            else if (newpalette[j].g < palette[j].g)
-            {
-               newpalette[j].g += 4;
-            }
-
-            if (newpalette[j].b > palette[j].b)
-            {
-               newpalette[j].b -= 4;
-            }
-            else if (newpalette[j].b < palette[j].b)
-            {
-               newpalette[j].b += 4;
-            }
-         }
-
-         VIDEO_SetPalette(newpalette);
-         UTIL_Delay(iDelay);
-      }
-
-      VIDEO_SetPalette(palette);
-   }
-   else
-   {
-      memcpy(newpalette, palette, sizeof(newpalette));
-
-      for (i = 0; i < 64; i++)
-      {
-         for (j = 0; j < 256; j++)
-         {
-            if (newpalette[j].r > palette[bColor].r)
-            {
-               newpalette[j].r -= 4;
-            }
-            else if (newpalette[j].r < palette[bColor].r)
-            {
-               newpalette[j].r += 4;
-            }
-
-            if (newpalette[j].g > palette[bColor].g)
-            {
-               newpalette[j].g -= 4;
-            }
-            else if (newpalette[j].g < palette[bColor].g)
-            {
-               newpalette[j].g += 4;
-            }
-
-            if (newpalette[j].b > palette[bColor].b)
-            {
-               newpalette[j].b -= 4;
-            }
-            else if (newpalette[j].b < palette[bColor].b)
-            {
-               newpalette[j].b += 4;
-            }
-         }
-
-         VIDEO_SetPalette(newpalette);
-         UTIL_Delay(iDelay);
-      }
-
-      for (i = 0; i < 256; i++)
-      {
-         newpalette[i] = palette[bColor];
-      }
-
-      VIDEO_SetPalette(newpalette);
-   }
-}
-
-VOID
-PAL_FadeToRed(
-   VOID
-)
-/*++
-  Purpose:
-
-    Fade the whole screen to red color.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   SDL_Color                 *palette;
-   PAL_LARGE SDL_Color        newpalette[256];
-   int                        i, j;
-   BYTE                       color;
-
-   palette = PAL_GetPalette(gpGlobals->wNumPalette, gpGlobals->fNightPalette);
-   memcpy(newpalette, palette, sizeof(newpalette));
-
-   for (i = 0; i < gpScreen->pitch * gpScreen->h; i++)
-   {
-      if (((LPBYTE)(gpScreen->pixels))[i] == 0x4F)
-      {
-         ((LPBYTE)(gpScreen->pixels))[i] = 0x4E; // HACKHACK
-      }
-   }
-
-   VIDEO_UpdateScreen(NULL);
-
-   for (i = 0; i < 32; i++)
-   {
-      for (j = 0; j < 256; j++)
-      {
-         if (j == 0x4F)
-         {
-            continue; // so that texts will not be affected
-         }
-
-         color = ((INT)palette[j].r + (INT)palette[j].g + (INT)palette[j].b) / 4 + 64;
-
-         if (newpalette[j].r > color)
-         {
-            newpalette[j].r -= (newpalette[j].r - color > 8 ? 8 : newpalette[j].r - color);
-         }
-         else if (newpalette[j].r < color)
-         {
-            newpalette[j].r += (color - newpalette[j].r > 8 ? 8 : color - newpalette[j].r);
-         }
-
-         if (newpalette[j].g > 0)
-         {
-            newpalette[j].g -= (newpalette[j].g > 8 ? 8 : newpalette[j].g);
-         }
-
-         if (newpalette[j].b > 0)
-         {
-            newpalette[j].b -= (newpalette[j].b > 8 ? 8 : newpalette[j].b);
-         }
-      }
-
-      VIDEO_SetPalette(newpalette);
-      UTIL_Delay(75);
-   }
-}

+ 1 - 0
palette.c

@@ -0,0 +1 @@
+src/palette.c

+ 0 - 86
palette.h

@@ -1,86 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef PALETTE_H
-#define PALETTE_H
-
-#include "common.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-SDL_Color *
-PAL_GetPalette(
-   INT         iPaletteNum,
-   BOOL        fNight
-);
-
-VOID
-PAL_SetPalette(
-   INT         iPaletteNum,
-   BOOL        fNight
-);
-
-VOID
-PAL_FadeOut(
-   INT         iDelay
-);
-
-VOID
-PAL_FadeIn(
-   INT         iPaletteNum,
-   BOOL        fNight,
-   INT         iDelay
-);
-
-VOID
-PAL_SceneFade(
-   INT         iPaletteNum,
-   BOOL        fNight,
-   INT         iStep
-);
-
-VOID
-PAL_PaletteFade(
-   INT         iPaletteNum,
-   BOOL        fNight,
-   INT         iDelay
-);
-
-VOID
-PAL_ColorFade(
-   INT        iDelay,
-   BYTE       bColor,
-   BOOL       fFrom
-);
-
-VOID
-PAL_FadeToRed(
-   VOID
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
palette.h

@@ -0,0 +1 @@
+src/palette.h

+ 0 - 618
play.c

@@ -1,618 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2008, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// Portions based on PALx Project by palxex.
-// Copyright (c) 2006, Pal Lockheart <palxex@gmail.com>.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "main.h"
-
-VOID
-PAL_GameUpdate(
-   BOOL       fTrigger
-)
-/*++
-  Purpose:
-
-    The main game logic routine. Update the status of everything.
-
-  Parameters:
-
-    [IN]  fTrigger - whether to process trigger events or not.
-
-  Return value:
-
-    None.
-
---*/
-{
-   WORD            wEventObjectID, wDir;
-   int             i;
-   LPEVENTOBJECT   p;
-
-   //
-   // Check for trigger events
-   //
-   if (fTrigger)
-   {
-      //
-      // Check if we are entering a new scene
-      //
-      if (gpGlobals->fEnteringScene)
-      {
-         //
-         // Run the script for entering the scene
-         //
-         gpGlobals->fEnteringScene = FALSE;
-
-         i = gpGlobals->wNumScene - 1;
-         gpGlobals->g.rgScene[i].wScriptOnEnter =
-            PAL_RunTriggerScript(gpGlobals->g.rgScene[i].wScriptOnEnter, 0xFFFF);
-
-         if (gpGlobals->fEnteringScene || gpGlobals->fGameStart)
-         {
-            //
-            // Don't go further as we're switching to another scene
-            //
-            return;
-         }
-
-         PAL_ClearKeyState();
-         PAL_MakeScene();
-      }
-
-      //
-      // Update the vanish time for all event objects
-      //
-      for (wEventObjectID = 0; wEventObjectID < gpGlobals->g.nEventObject; wEventObjectID++)
-      {
-         p = &gpGlobals->g.lprgEventObject[wEventObjectID];
-
-         if (p->sVanishTime != 0)
-         {
-            p->sVanishTime += ((p->sVanishTime < 0) ? 1 : -1);
-         }
-      }
-
-      //
-      // Loop through all event objects in the current scene
-      //
-      for (wEventObjectID = gpGlobals->g.rgScene[gpGlobals->wNumScene - 1].wEventObjectIndex + 1;
-         wEventObjectID <= gpGlobals->g.rgScene[gpGlobals->wNumScene].wEventObjectIndex;
-         wEventObjectID++)
-      {
-         p = &gpGlobals->g.lprgEventObject[wEventObjectID - 1];
-
-         if (p->sVanishTime != 0)
-         {
-            continue;
-         }
-
-         if (p->sState < 0)
-         {
-            if (p->x < PAL_X(gpGlobals->viewport) ||
-               p->x > PAL_X(gpGlobals->viewport) + 320 ||
-               p->y < PAL_Y(gpGlobals->viewport) ||
-               p->y > PAL_Y(gpGlobals->viewport) + 320)
-            {
-               p->sState = abs(p->sState);
-               p->wCurrentFrameNum = 0;
-            }
-         }
-         else if (p->sState > 0 && p->wTriggerMode >= kTriggerTouchNear)
-         {
-            //
-            // This event object can be triggered without manually exploring
-            //
-            if (abs(PAL_X(gpGlobals->viewport) + PAL_X(gpGlobals->partyoffset) - p->x) +
-               abs(PAL_Y(gpGlobals->viewport) + PAL_Y(gpGlobals->partyoffset) - p->y) * 2 <
-               (p->wTriggerMode - kTriggerTouchNear) * 32 + 16)
-            {
-               //
-               // Player is in the trigger zone.
-               //
-
-               if (p->nSpriteFrames)
-               {
-                  //
-                  // The sprite has multiple frames. Try to adjust the direction.
-                  //
-                  int                xOffset, yOffset;
-
-                  p->wCurrentFrameNum = 0;
-
-                  xOffset = PAL_X(gpGlobals->viewport) + PAL_X(gpGlobals->partyoffset) - p->x;
-                  yOffset = PAL_Y(gpGlobals->viewport) + PAL_Y(gpGlobals->partyoffset) - p->y;
-
-                  if (xOffset > 0)
-                  {
-                     p->wDirection = ((yOffset > 0) ? kDirEast : kDirNorth);
-                  }
-                  else
-                  {
-                     p->wDirection = ((yOffset > 0) ? kDirSouth : kDirWest);
-                  }
-
-                  //
-                  // Redraw the scene
-                  //
-                  PAL_UpdatePartyGestures(FALSE);
-
-                  PAL_MakeScene();
-                  VIDEO_UpdateScreen(NULL);
-               }
-
-               //
-               // Execute the script.
-               //
-               p->wTriggerScript = PAL_RunTriggerScript(p->wTriggerScript, wEventObjectID);
-
-               PAL_ClearKeyState();
-
-               if (gpGlobals->fEnteringScene || gpGlobals->fGameStart)
-               {
-                  //
-                  // Don't go further on scene switching
-                  //
-                  return;
-               }
-            }
-         }
-      }
-   }
-
-   //
-   // Run autoscript for each event objects
-   //
-   for (wEventObjectID = gpGlobals->g.rgScene[gpGlobals->wNumScene - 1].wEventObjectIndex + 1;
-      wEventObjectID <= gpGlobals->g.rgScene[gpGlobals->wNumScene].wEventObjectIndex;
-      wEventObjectID++)
-   {
-      p = &gpGlobals->g.lprgEventObject[wEventObjectID - 1];
-
-      if (p->sState > 0 && p->sVanishTime == 0)
-      {
-         WORD wScriptEntry = p->wAutoScript;
-         if (wScriptEntry != 0)
-         {
-            p->wAutoScript = PAL_RunAutoScript(wScriptEntry, wEventObjectID);
-            if (gpGlobals->fEnteringScene || gpGlobals->fGameStart)
-            {
-               //
-               // Don't go further on scene switching
-               //
-               return;
-            }
-         }
-      }
-
-      //
-      // Check if the player is in the way
-      //
-      if (fTrigger && p->sState >= kObjStateBlocker && p->wSpriteNum != 0 &&
-         abs(p->x - PAL_X(gpGlobals->viewport) - PAL_X(gpGlobals->partyoffset)) +
-         abs(p->y - PAL_Y(gpGlobals->viewport) - PAL_Y(gpGlobals->partyoffset)) * 2 <= 12)
-      {
-         //
-         // Player is in the way, try to move a step
-         //
-         wDir = (p->wDirection + 1) % 4;
-         for (i = 0; i < 4; i++)
-         {
-            int              x, y;
-            PAL_POS          pos;
-
-            x = PAL_X(gpGlobals->viewport) + PAL_X(gpGlobals->partyoffset);
-            y = PAL_Y(gpGlobals->viewport) + PAL_Y(gpGlobals->partyoffset);
-
-            x += ((wDir == kDirWest || wDir == kDirSouth) ? -16 : 16);
-            y += ((wDir == kDirWest || wDir == kDirNorth) ? -8 : 8);
-
-            pos = PAL_XY(x, y);
-
-            if (!PAL_CheckObstacle(pos, TRUE, 0))
-            {
-               //
-               // move here
-               //
-               gpGlobals->viewport = PAL_XY(
-                  PAL_X(pos) - PAL_X(gpGlobals->partyoffset),
-                  PAL_Y(pos) - PAL_Y(gpGlobals->partyoffset));
-
-               break;
-            }
-
-            wDir = (wDir + 1) % 4;
-         }
-      }
-   }
-
-   gpGlobals->dwFrameNum++;
-}
-
-VOID
-PAL_GameUseItem(
-   VOID
-)
-/*++
-  Purpose:
-
-    Allow player use an item in the game.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   WORD         wObject;
-
-   while (TRUE)
-   {
-      wObject = PAL_ItemSelectMenu(NULL, kItemFlagUsable);
-
-      if (wObject == 0)
-      {
-         return;
-      }
-
-      if (!(gpGlobals->g.rgObject[wObject].item.wFlags & kItemFlagApplyToAll))
-      {
-         //
-         // Select the player to use the item on
-         //
-         WORD     wPlayer = 0;
-
-         while (TRUE)
-         {
-            wPlayer = PAL_ItemUseMenu(wObject);
-
-            if (wPlayer == MENUITEM_VALUE_CANCELLED)
-            {
-               break;
-            }
-
-            //
-            // Run the script
-            //
-            gpGlobals->g.rgObject[wObject].item.wScriptOnUse =
-               PAL_RunTriggerScript(gpGlobals->g.rgObject[wObject].item.wScriptOnUse, wPlayer);
-
-            //
-            // Remove the item if the item is consuming and the script succeeded
-            //
-            if ((gpGlobals->g.rgObject[wObject].item.wFlags & kItemFlagConsuming) &&
-               g_fScriptSuccess)
-            {
-               PAL_AddItemToInventory(wObject, -1);
-            }
-         }
-      }
-      else
-      {
-         //
-         // Run the script
-         //
-         gpGlobals->g.rgObject[wObject].item.wScriptOnUse =
-            PAL_RunTriggerScript(gpGlobals->g.rgObject[wObject].item.wScriptOnUse, 0xFFFF);
-
-         //
-         // Remove the item if the item is consuming and the script succeeded
-         //
-         if ((gpGlobals->g.rgObject[wObject].item.wFlags & kItemFlagConsuming) &&
-            g_fScriptSuccess)
-         {
-            PAL_AddItemToInventory(wObject, -1);
-         }
-
-         return;
-      }
-   }
-}
-
-VOID
-PAL_GameEquipItem(
-   VOID
-)
-/*++
-  Purpose:
-
-    Allow player equip an item in the game.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   WORD      wObject;
-
-   while (TRUE)
-   {
-      wObject = PAL_ItemSelectMenu(NULL, kItemFlagEquipable);
-
-      if (wObject == 0)
-      {
-         return;
-      }
-
-      PAL_EquipItemMenu(wObject);
-   }
-}
-
-VOID
-PAL_Search(
-   VOID
-)
-/*++
-  Purpose:
-
-    Process searching trigger events.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int                x, y, xOffset, yOffset, dx, dy, dh, ex, ey, eh, i, k, l;
-   LPEVENTOBJECT      p;
-   PAL_POS            rgPos[13];
-
-   //
-   // Get the party location
-   //
-   x = PAL_X(gpGlobals->viewport) + PAL_X(gpGlobals->partyoffset);
-   y = PAL_Y(gpGlobals->viewport) + PAL_Y(gpGlobals->partyoffset);
-
-   if (gpGlobals->wPartyDirection == kDirNorth || gpGlobals->wPartyDirection == kDirEast)
-   {
-      xOffset = 16;
-   }
-   else
-   {
-      xOffset = -16;
-   }
-
-   if (gpGlobals->wPartyDirection == kDirEast || gpGlobals->wPartyDirection == kDirSouth)
-   {
-      yOffset = 8;
-   }
-   else
-   {
-      yOffset = -8;
-   }
-
-   rgPos[0] = PAL_XY(x, y);
-
-   for (i = 0; i < 4; i++)
-   {
-      rgPos[i * 3 + 1] = PAL_XY(x + xOffset, y + yOffset);
-      rgPos[i * 3 + 2] = PAL_XY(x, y + yOffset * 2);
-      rgPos[i * 3 + 3] = PAL_XY(x + xOffset, y);
-      x += xOffset;
-      y += yOffset;
-   }
-
-   for (i = 0; i < 13; i++)
-   {
-      //
-      // Convert to map location
-      //
-      dh = ((PAL_X(rgPos[i]) % 32) ? 1 : 0);
-      dx = PAL_X(rgPos[i]) / 32;
-      dy = PAL_Y(rgPos[i]) / 16;
-
-      //
-      // Loop through all event objects
-      //
-      for (k = gpGlobals->g.rgScene[gpGlobals->wNumScene - 1].wEventObjectIndex;
-         k < gpGlobals->g.rgScene[gpGlobals->wNumScene].wEventObjectIndex; k++)
-      {
-         p = &(gpGlobals->g.lprgEventObject[k]);
-         ex = p->x / 32;
-         ey = p->y / 16;
-         eh = ((p->x % 32) ? 1 : 0);
-
-         if (p->sState <= 0 || p->wTriggerMode >= kTriggerTouchNear ||
-            p->wTriggerMode * 6 - 4 < i || dx != ex || dy != ey || dh != eh)
-         {
-            continue;
-         }
-
-         //
-         // Adjust direction/gesture for party members and the event object
-         //
-         if (p->nSpriteFrames * 4 > p->wCurrentFrameNum)
-         {
-            p->wCurrentFrameNum = 0; // use standing gesture
-            p->wDirection = (gpGlobals->wPartyDirection + 2) % 4; // face the party
-
-            for (l = 0; l <= gpGlobals->wMaxPartyMemberIndex; l++)
-            {
-               //
-               // All party members should face the event object
-               //
-               gpGlobals->rgParty[l].wFrame = gpGlobals->wPartyDirection * 3;
-            }
-
-            //
-            // Redraw everything
-            //
-            PAL_MakeScene();
-            VIDEO_UpdateScreen(NULL);
-         }
-
-         //
-         // Execute the script
-         //
-         p->wTriggerScript = PAL_RunTriggerScript(p->wTriggerScript, k + 1);
-
-         //
-         // Clear inputs and delay for a short time
-         //
-         UTIL_Delay(50);
-         PAL_ClearKeyState();
-
-         return; // don't go further
-      }
-   }
-}
-
-VOID
-PAL_StartFrame(
-   VOID
-)
-/*++
-  Purpose:
-
-    Starts a video frame. Called once per video frame.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   //
-   // Run the game logic of one frame
-   //
-   PAL_GameUpdate(TRUE);
-   if (gpGlobals->fEnteringScene)
-   {
-      return;
-   }
-
-   //
-   // Update the positions and gestures of party members
-   //
-   PAL_UpdateParty();
-
-   //
-   // Update the scene
-   //
-   PAL_MakeScene();
-   VIDEO_UpdateScreen(NULL);
-
-   if (g_InputState.dwKeyPress & kKeyMenu)
-   {
-      //
-      // Show the in-game menu
-      //
-      PAL_InGameMenu();
-   }
-   else if (g_InputState.dwKeyPress & kKeyUseItem)
-   {
-      //
-      // Show the use item menu
-      //
-      PAL_GameUseItem();
-   }
-   else if (g_InputState.dwKeyPress & kKeyThrowItem)
-   {
-      //
-      // Show the equipment menu
-      //
-      PAL_GameEquipItem();
-   }
-   else if (g_InputState.dwKeyPress & kKeyForce)
-   {
-      //
-      // Show the magic menu
-      //
-      PAL_InGameMagicMenu();
-   }
-   else if (g_InputState.dwKeyPress & kKeyStatus)
-   {
-      //
-      // Show the player status
-      //
-      PAL_PlayerStatus();
-   }
-   else if (g_InputState.dwKeyPress & kKeySearch)
-   {
-      //
-      // Process search events
-      //
-      PAL_Search();
-   }
-   else if (g_InputState.dwKeyPress & kKeyFlee)
-   {
-      //
-      // Quit Game
-      //
-      PAL_QuitGame();
-   }
-
-   if (--gpGlobals->wChasespeedChangeCycles == 0)
-   {
-      gpGlobals->wChaseRange = 1;
-   }
-}
-
-VOID
-PAL_WaitForKey(
-   WORD      wTimeOut
-)
-/*++
-  Purpose:
-
-    Wait for any key.
-
-  Parameters:
-
-    [IN]  wTimeOut - the maximum time of the waiting. 0 = wait forever.
-
-  Return value:
-
-    None.
-
---*/
-{
-   DWORD     dwTimeOut = SDL_GetTicks() + wTimeOut;
-
-   PAL_ClearKeyState();
-
-   while (wTimeOut == 0 || !SDL_TICKS_PASSED(SDL_GetTicks(), dwTimeOut))
-   {
-      UTIL_Delay(5);
-
-      if (g_InputState.dwKeyPress & (kKeySearch | kKeyMenu))
-      {
-         break;
-      }
-   }
-}

+ 1 - 0
play.c

@@ -0,0 +1 @@
+src/play.c

+ 0 - 59
play.h

@@ -1,59 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef PLAY_H
-#define PLAY_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-VOID
-PAL_GameUpdate(
-   BOOL       fTrigger
-);
-
-VOID
-PAL_GameUseItem(
-   VOID
-);
-
-VOID
-PAL_GameEquipItem(
-   VOID
-);
-
-VOID
-PAL_StartFrame(
-   VOID
-);
-
-VOID
-PAL_WaitForKey(
-   WORD      wTimeOut
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
play.h

@@ -0,0 +1 @@
+src/play.h

+ 0 - 80
players.h

@@ -1,80 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-// Created by Lou Yihua <louyihua@21cn.com>, 2015-07-28.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef PLAYERS_H
-#define PLAYERS_H
-
-#include "common.h"
-
-#ifdef __cplusplus
-
-extern "C"
-{
-#endif
-
-	typedef struct tagAUDIOPLAYER
-	{
-#define AUDIOPLAYER_COMMONS \
-	VOID (*Shutdown)(VOID*); \
-	BOOL (*Play)(VOID*, INT, BOOL, FLOAT); \
-	VOID (*FillBuffer)(VOID*, LPBYTE, INT)
-
-	AUDIOPLAYER_COMMONS;
-} AUDIOPLAYER, *LPAUDIOPLAYER;
-
-/* RIX */
-
-LPAUDIOPLAYER
-RIX_Init(
-   LPCSTR     szFileName
-);
-
-/* OGG */
-#if PAL_HAS_OGG
-
-LPAUDIOPLAYER
-OGG_Init(
-	VOID
-);
-
-#endif
-
-/* MP3 */
-#if PAL_HAS_MP3
-
-LPAUDIOPLAYER
-MP3_Init(
-	VOID
-);
-
-#endif
-
-LPAUDIOPLAYER
-SOUND_Init(
-	VOID
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
players.h

@@ -0,0 +1 @@
+src/players.h

+ 0 - 3
private.c

@@ -1,3 +0,0 @@
-#ifdef CYGWIN
-	SDLPAL_ICON ICON DISCARDABLE "sdlpal.ico"
-#endif

+ 1 - 0
private.c

@@ -0,0 +1 @@
+src/private.c

+ 0 - 430
res.c

@@ -1,430 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include "main.h"
-
-typedef struct tagRESOURCES
-{
-   BYTE             bLoadFlags;
-
-   LPPALMAP         lpMap;                                      // current loaded map
-   LPSPRITE        *lppEventObjectSprites;                      // event object sprites
-   int              nEventObject;                               // number of event objects
-
-   LPSPRITE         rglpPlayerSprite[MAX_PLAYERS_IN_PARTY + 1]; // player sprites
-} RESOURCES, *LPRESOURCES;
-
-static LPRESOURCES gpResources = NULL;
-
-static VOID
-PAL_FreeEventObjectSprites(
-   VOID
-)
-/*++
-  Purpose:
-
-    Free all sprites of event objects on the scene.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int i;
-
-   if (gpResources->lppEventObjectSprites != NULL)
-   {
-      for (i = 0; i < gpResources->nEventObject; i++)
-      {
-         free(gpResources->lppEventObjectSprites[i]);
-      }
-
-      free(gpResources->lppEventObjectSprites);
-
-      gpResources->lppEventObjectSprites = NULL;
-      gpResources->nEventObject = 0;
-   }
-}
-
-static VOID
-PAL_FreePlayerSprites(
-   VOID
-)
-/*++
-  Purpose:
-
-    Free all player sprites.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int i;
-
-   for (i = 0; i < MAX_PLAYERS_IN_PARTY + 1; i++)
-   {
-      free(gpResources->rglpPlayerSprite[i]);
-      gpResources->rglpPlayerSprite[i] = NULL;
-   }
-}
-
-VOID
-PAL_InitResources(
-   VOID
-)
-/*++
-  Purpose:
-
-    Initialze the resource manager.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   gpResources = (LPRESOURCES)UTIL_calloc(1, sizeof(RESOURCES));
-}
-
-VOID
-PAL_FreeResources(
-   VOID
-)
-/*++
-  Purpose:
-
-    Free all loaded resources.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   if (gpResources != NULL)
-   {
-      //
-      // Free all loaded sprites
-      //
-      PAL_FreePlayerSprites();
-      PAL_FreeEventObjectSprites();
-
-      //
-      // Free map
-      //
-      PAL_FreeMap(gpResources->lpMap);
-
-      //
-      // Delete the instance
-      //
-      free(gpResources);
-   }
-
-   gpResources = NULL;
-}
-
-VOID
-PAL_SetLoadFlags(
-   BYTE       bFlags
-)
-/*++
-  Purpose:
-
-    Set flags to load resources.
-
-  Parameters:
-
-    [IN]  bFlags - flags to be set.
-
-  Return value:
-
-    None.
-
---*/
-{
-   if (gpResources == NULL)
-   {
-      return;
-   }
-
-   gpResources->bLoadFlags |= bFlags;
-}
-
-VOID
-PAL_LoadResources(
-   VOID
-)
-/*++
-  Purpose:
-
-    Load the game resources if needed.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    None.
-
---*/
-{
-   int                i, index, l, n;
-   WORD               wPlayerID, wSpriteNum;
-
-   if (gpResources == NULL || gpResources->bLoadFlags == 0)
-   {
-      return;
-   }
-
-   //
-   // Load scene
-   //
-   if (gpResources->bLoadFlags & kLoadScene)
-   {
-      FILE              *fpMAP, *fpGOP;
-
-      fpMAP = UTIL_OpenRequiredFile("map.mkf");
-      fpGOP = UTIL_OpenRequiredFile("gop.mkf");
-
-      if (gpGlobals->fEnteringScene)
-      {
-         gpGlobals->wScreenWave = 0;
-         gpGlobals->sWaveProgression = 0;
-      }
-
-      //
-      // Free previous loaded scene (sprites and map)
-      //
-      PAL_FreeEventObjectSprites();
-      PAL_FreeMap(gpResources->lpMap);
-
-      //
-      // Load map
-      //
-      i = gpGlobals->wNumScene - 1;
-      gpResources->lpMap = PAL_LoadMap(gpGlobals->g.rgScene[i].wMapNum,
-         fpMAP, fpGOP);
-
-      if (gpResources->lpMap == NULL)
-      {
-         fclose(fpMAP);
-         fclose(fpGOP);
-
-         TerminateOnError("PAL_LoadResources(): Fail to load map #%d (scene #%d) !",
-            gpGlobals->g.rgScene[i].wMapNum, gpGlobals->wNumScene);
-      }
-
-      //
-      // Load sprites
-      //
-      index = gpGlobals->g.rgScene[i].wEventObjectIndex;
-      gpResources->nEventObject = gpGlobals->g.rgScene[i + 1].wEventObjectIndex;
-      gpResources->nEventObject -= index;
-
-      if (gpResources->nEventObject > 0)
-      {
-         gpResources->lppEventObjectSprites =
-            (LPSPRITE *)UTIL_calloc(gpResources->nEventObject, sizeof(LPSPRITE));
-      }
-
-      for (i = 0; i < gpResources->nEventObject; i++, index++)
-      {
-         n = gpGlobals->g.lprgEventObject[index].wSpriteNum;
-         if (n == 0)
-         {
-            //
-            // this event object has no sprite
-            //
-            gpResources->lppEventObjectSprites[i] = NULL;
-            continue;
-         }
-
-         l = PAL_MKFGetDecompressedSize(n, gpGlobals->f.fpMGO);
-
-         gpResources->lppEventObjectSprites[i] = (LPSPRITE)UTIL_malloc(l);
-
-         if (PAL_MKFDecompressChunk(gpResources->lppEventObjectSprites[i], l,
-            n, gpGlobals->f.fpMGO) > 0)
-         {
-            gpGlobals->g.lprgEventObject[index].nSpriteFramesAuto =
-               PAL_SpriteGetNumFrames(gpResources->lppEventObjectSprites[i]);
-         }
-      }
-
-      gpGlobals->partyoffset = PAL_XY(160, 112);
-
-      fclose(fpGOP);
-      fclose(fpMAP);
-   }
-
-   //
-   // Load player sprites
-   //
-   if (gpResources->bLoadFlags & kLoadPlayerSprite)
-   {
-      //
-      // Free previous loaded player sprites
-      //
-      PAL_FreePlayerSprites();
-
-      for (i = 0; i <= (short)gpGlobals->wMaxPartyMemberIndex; i++)
-      {
-         wPlayerID = gpGlobals->rgParty[i].wPlayerRole;
-         assert(wPlayerID < MAX_PLAYER_ROLES);
-
-         //
-         // Load player sprite
-         //
-         wSpriteNum = gpGlobals->g.PlayerRoles.rgwSpriteNum[wPlayerID];
-
-         l = PAL_MKFGetDecompressedSize(wSpriteNum, gpGlobals->f.fpMGO);
-
-         gpResources->rglpPlayerSprite[i] = (LPSPRITE)UTIL_malloc(l);
-
-         PAL_MKFDecompressChunk(gpResources->rglpPlayerSprite[i], l, wSpriteNum,
-            gpGlobals->f.fpMGO);
-      }
-
-      if (gpGlobals->nFollower > 0)
-      {
-         //
-         // Load the follower sprite
-         //
-         wSpriteNum = gpGlobals->rgParty[i].wPlayerRole;
-
-         l = PAL_MKFGetDecompressedSize(wSpriteNum, gpGlobals->f.fpMGO);
-
-         gpResources->rglpPlayerSprite[i] = (LPSPRITE)UTIL_malloc(l);
-
-         PAL_MKFDecompressChunk(gpResources->rglpPlayerSprite[i], l, wSpriteNum,
-            gpGlobals->f.fpMGO);
-      }
-   }
-
-   //
-   // Clear all of the load flags
-   //
-   gpResources->bLoadFlags = 0;
-}
-
-LPPALMAP
-PAL_GetCurrentMap(
-   VOID
-)
-/*++
-  Purpose:
-
-    Get the current loaded map.
-
-  Parameters:
-
-    None.
-
-  Return value:
-
-    Pointer to the current loaded map. NULL if no map is loaded.
-
---*/
-{
-   if (gpResources == NULL)
-   {
-      return NULL;
-   }
-
-   return gpResources->lpMap;
-}
-
-LPSPRITE
-PAL_GetPlayerSprite(
-   BYTE      bPlayerIndex
-)
-/*++
-  Purpose:
-
-    Get the player sprite.
-
-  Parameters:
-
-    [IN]  bPlayerIndex - index of player in party (starts from 0).
-
-  Return value:
-
-    Pointer to the player sprite.
-
---*/
-{
-   if (gpResources == NULL || bPlayerIndex > MAX_PLAYERS_IN_PARTY)
-   {
-      return NULL;
-   }
-
-   return gpResources->rglpPlayerSprite[bPlayerIndex];
-}
-
-LPSPRITE
-PAL_GetEventObjectSprite(
-   WORD      wEventObjectID
-)
-/*++
-  Purpose:
-
-    Get the sprite of the specified event object.
-
-  Parameters:
-
-    [IN]  wEventObjectID - the ID of event object.
-
-  Return value:
-
-    Pointer to the sprite.
-
---*/
-{
-   wEventObjectID -= gpGlobals->g.rgScene[gpGlobals->wNumScene - 1].wEventObjectIndex;
-   wEventObjectID--;
-
-   if (gpResources == NULL || wEventObjectID >= gpResources->nEventObject)
-   {
-      return NULL;
-   }
-
-   return gpResources->lppEventObjectSprites[wEventObjectID];
-}

+ 1 - 0
res.c

@@ -0,0 +1 @@
+src/res.c

+ 0 - 80
res.h

@@ -1,80 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-//
-// This file is part of SDLPAL.
-//
-// SDLPAL is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef RES_H
-#define RES_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef enum tagLOADRESFLAG
-{
-   kLoadScene          = (1 << 0),    // load a scene
-   kLoadPlayerSprite   = (1 << 1),    // load player sprites
-} LOADRESFLAG, *LPLOADRESFLAG;
-
-VOID
-PAL_InitResources(
-   VOID
-);
-
-VOID
-PAL_FreeResources(
-   VOID
-);
-
-VOID
-PAL_SetLoadFlags(
-   BYTE       bFlags
-);
-
-VOID
-PAL_LoadResources(
-   VOID
-);
-
-LPPALMAP
-PAL_GetCurrentMap(
-   VOID
-);
-
-LPSPRITE
-PAL_GetPlayerSprite(
-   BYTE      bPlayerIndex
-);
-
-LPSPRITE
-PAL_GetBattleSprite(
-   BYTE      bPlayerIndex
-);
-
-LPSPRITE
-PAL_GetEventObjectSprite(
-   WORD      wEventObjectID
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
res.h

@@ -0,0 +1 @@
+src/res.h

+ 0 - 941
resampler.c

@@ -1,941 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#define _USE_MATH_DEFINES
-#include <math.h>
-#if !defined(__MINGW32__) && !defined(__EMSCRIPTEN__)
-# if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__))
-#  include <xmmintrin.h>
-#  define RESAMPLER_SSE
-# endif
-#endif
-
-#ifdef _MSC_VER
-#define ALIGNED     _declspec(align(16))
-#else
-#define ALIGNED     __attribute__((aligned(16)))
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#include "resampler.h"
-
-enum { RESAMPLER_SHIFT = 10 };
-enum { RESAMPLER_RESOLUTION = 1 << RESAMPLER_SHIFT };
-enum { SINC_WIDTH = 16 };
-enum { SINC_SAMPLES = RESAMPLER_RESOLUTION * SINC_WIDTH };
-enum { CUBIC_SAMPLES = RESAMPLER_RESOLUTION * 4 };
-
-ALIGNED static float cubic_lut[CUBIC_SAMPLES];
-
-static float sinc_lut[SINC_SAMPLES + 1];
-static float window_lut[SINC_SAMPLES + 1];
-
-enum { resampler_buffer_size = SINC_WIDTH * 4 };
-
-typedef struct resampler
-{
-	int write_pos, write_filled;
-	int read_pos, read_filled;
-	unsigned int phase;
-	unsigned int phase_inc;
-	unsigned int inv_phase;
-	unsigned int inv_phase_inc;
-	unsigned char quality;
-	signed char delay_added;
-	signed char delay_removed;
-	float last_amp;
-	float accumulator;
-	float buffer_in[resampler_buffer_size * 2];
-	float buffer_out[resampler_buffer_size + SINC_WIDTH * 2 - 1];
-} resampler;
-
-static int fEqual(const float b, const float a)
-{
-    return fabs(a - b) < 1.0e-6;
-}
-
-static float sinc(float x)
-{
-    return fEqual(x, 0.0f) ? 1.0f : (float)(sin(x * M_PI) / (x * M_PI));
-}
-
-typedef int (*resampler_run)(resampler *, float **, float *);
-
-#ifdef RESAMPLER_SSE
-# ifdef _MSC_VER
-#  include <intrin.h>
-#  pragma warning(disable:4244)
-# elif defined(__clang__) || defined(__GNUC__)
-static inline void __cpuid(int *data, int selector)
-{
-#  if defined(__PIC__) && defined(__i386__)
-    asm("xchgl %%ebx, %%esi; cpuid; xchgl %%ebx, %%esi"
-        : "=a" (data[0]),
-        "=S" (data[1]),
-        "=c" (data[2]),
-        "=d" (data[3])
-        : "0" (selector));
-#  elif defined(__PIC__) && defined(__amd64__)
-    asm("xchg{q} {%%}rbx, %q1; cpuid; xchg{q} {%%}rbx, %q1"
-        : "=a" (data[0]),
-        "=&r" (data[1]),
-        "=c" (data[2]),
-        "=d" (data[3])
-        : "0" (selector));
-#  else
-    asm("cpuid"
-        : "=a" (data[0]),
-        "=b" (data[1]),
-        "=c" (data[2]),
-        "=d" (data[3])
-        : "0" (selector));
-#  endif
-}
-# else
-#  define __cpuid(a,b) memset((a), 0, sizeof(int) * 4)
-# endif
-
-static int query_cpu_feature_sse() {
-    int buffer[4];
-    __cpuid(buffer,1);
-    if ((buffer[3]&(1<<25)) == 0) return 0;
-    return 1;
-}
-
-static int resampler_run_blep_sse(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= 1;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		float last_amp = r->last_amp;
-		int inv_phase = r->inv_phase;
-		int inv_phase_inc = r->inv_phase_inc;
-
-		const int step = RESAMPLER_RESOLUTION;
-
-		do
-		{
-			// accumulate in extended precision
-			float kernel_sum = 0.0;
-			__m128 kernel[SINC_WIDTH / 2];
-			__m128 temp1, temp2;
-			__m128 samplex;
-			float sample;
-			float *kernelf = (float*)(&kernel);
-			int i = SINC_WIDTH;
-
-			if (out + SINC_WIDTH * 2 > out_end)
-				break;
-
-			for (; i >= -SINC_WIDTH + 1; --i)
-			{
-				int pos = i * step;
-				int abs_pos = abs(inv_phase - pos);
-				kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs_pos] * window_lut[abs_pos];
-			}
-			sample = *in++ - last_amp;
-			last_amp += sample;
-			sample /= kernel_sum;
-			samplex = _mm_set1_ps(sample);
-			for (i = 0; i < SINC_WIDTH / 2; ++i)
-			{
-				temp1 = _mm_load_ps((const float *)(kernel + i));
-				temp1 = _mm_mul_ps(temp1, samplex);
-				temp2 = _mm_loadu_ps((const float *)out + i * 4);
-				temp1 = _mm_add_ps(temp1, temp2);
-				_mm_storeu_ps((float *)out + i * 4, temp1);
-			}
-
-			inv_phase += inv_phase_inc;
-
-			out += inv_phase >> RESAMPLER_SHIFT;
-
-			inv_phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->inv_phase = inv_phase;
-		r->last_amp = last_amp;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static int resampler_run_cubic_sse(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= 4;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		int phase = r->phase;
-		int phase_inc = r->phase_inc;
-
-		do
-		{
-			__m128 temp1, temp2;
-			__m128 samplex = _mm_setzero_ps();
-
-			if (out >= out_end)
-				break;
-
-			temp1 = _mm_loadu_ps((const float *)(in));
-			temp2 = _mm_load_ps((const float *)(cubic_lut + phase * 4));
-			temp1 = _mm_mul_ps(temp1, temp2);
-			samplex = _mm_add_ps(samplex, temp1);
-			temp1 = _mm_movehl_ps(temp1, samplex);
-			samplex = _mm_add_ps(samplex, temp1);
-			temp1 = samplex;
-			temp1 = _mm_shuffle_ps(temp1, samplex, _MM_SHUFFLE(0, 0, 0, 1));
-			samplex = _mm_add_ps(samplex, temp1);
-			_mm_store_ss(out, samplex);
-			++out;
-
-			phase += phase_inc;
-
-			in += phase >> RESAMPLER_SHIFT;
-
-			phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->phase = phase;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static int resampler_run_sinc_sse(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= SINC_WIDTH * 2;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		int phase = r->phase;
-		int phase_inc = r->phase_inc;
-
-		int step = phase_inc > RESAMPLER_RESOLUTION ? RESAMPLER_RESOLUTION * RESAMPLER_RESOLUTION / phase_inc : RESAMPLER_RESOLUTION;
-		int window_step = RESAMPLER_RESOLUTION;
-
-		do
-		{
-			// accumulate in extended precision
-			float kernel_sum = 0.0;
-			__m128 kernel[SINC_WIDTH / 2];
-			__m128 temp1, temp2;
-			__m128 samplex = _mm_setzero_ps();
-			float *kernelf = (float*)(&kernel);
-			int i = SINC_WIDTH;
-			int phase_adj = phase * step / RESAMPLER_RESOLUTION;
-
-			if (out >= out_end)
-				break;
-
-			for (; i >= -SINC_WIDTH + 1; --i)
-			{
-				int pos = i * step;
-				int window_pos = i * window_step;
-				kernel_sum += kernelf[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase - window_pos)];
-			}
-			for (i = 0; i < SINC_WIDTH / 2; ++i)
-			{
-				temp1 = _mm_loadu_ps((const float *)(in + i * 4));
-				temp2 = _mm_load_ps((const float *)(kernel + i));
-				temp1 = _mm_mul_ps(temp1, temp2);
-				samplex = _mm_add_ps(samplex, temp1);
-			}
-			kernel_sum = 1.0f / kernel_sum;
-			temp1 = _mm_movehl_ps(temp1, samplex);
-			samplex = _mm_add_ps(samplex, temp1);
-			temp1 = samplex;
-			temp1 = _mm_shuffle_ps(temp1, samplex, _MM_SHUFFLE(0, 0, 0, 1));
-			samplex = _mm_add_ps(samplex, temp1);
-			temp1 = _mm_set_ss(kernel_sum);
-			samplex = _mm_mul_ps(samplex, temp1);
-			_mm_store_ss(out, samplex);
-			++out;
-
-			phase += phase_inc;
-
-			in += phase >> RESAMPLER_SHIFT;
-
-			phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->phase = phase;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-#endif
-
-static int resampler_run_zoh(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= 1;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		int phase = r->phase;
-		int phase_inc = r->phase_inc;
-
-		do
-		{
-			float sample;
-
-			if (out >= out_end)
-				break;
-
-			sample = *in;
-			*out++ = sample;
-
-			phase += phase_inc;
-
-			in += phase >> RESAMPLER_SHIFT;
-
-			phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->phase = (unsigned short)phase;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static int resampler_run_blep_c(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= 1;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		float last_amp = r->last_amp;
-		int inv_phase = r->inv_phase;
-		int inv_phase_inc = r->inv_phase_inc;
-
-		const int step = RESAMPLER_RESOLUTION;
-
-		do
-		{
-			float kernel[SINC_WIDTH * 2], kernel_sum = 0.0;
-			int i = SINC_WIDTH;
-			float sample;
-
-			if (out + SINC_WIDTH * 2 > out_end)
-				break;
-
-			for (; i >= -SINC_WIDTH + 1; --i)
-			{
-				int pos = i * step;
-				int abs_pos = abs(inv_phase - pos);
-				kernel_sum += kernel[i + SINC_WIDTH - 1] = sinc_lut[abs_pos] * window_lut[abs_pos];
-			}
-			sample = *in++ - last_amp;
-			last_amp += sample;
-			sample /= kernel_sum;
-			for (i = 0; i < SINC_WIDTH * 2; ++i)
-				out[i] += sample * kernel[i];
-
-			inv_phase += inv_phase_inc;
-
-			out += inv_phase >> RESAMPLER_SHIFT;
-
-			inv_phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->inv_phase = inv_phase;
-		r->last_amp = last_amp;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static int resampler_run_linear(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= 2;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		int phase = r->phase;
-		int phase_inc = r->phase_inc;
-
-		do
-		{
-			float sample;
-
-			if (out >= out_end)
-				break;
-
-			sample = in[0] + (in[1] - in[0]) * ((float)phase / RESAMPLER_RESOLUTION);
-			*out++ = sample;
-
-			phase += phase_inc;
-
-			in += phase >> RESAMPLER_SHIFT;
-
-			phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->phase = phase;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static int resampler_run_cubic_c(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= 4;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		int phase = r->phase;
-		int phase_inc = r->phase_inc;
-
-		do
-		{
-			float * kernel;
-			int i;
-			float sample;
-
-			if (out >= out_end)
-				break;
-
-			kernel = cubic_lut + phase * 4;
-
-			for (sample = 0, i = 0; i < 4; ++i)
-				sample += in[i] * kernel[i];
-			*out++ = sample;
-
-			phase += phase_inc;
-
-			in += phase >> RESAMPLER_SHIFT;
-
-			phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->phase = phase;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static int resampler_run_sinc_c(resampler * r, float ** out_, float * out_end)
-{
-	int in_size = r->write_filled;
-	float const* in_ = r->buffer_in + resampler_buffer_size + r->write_pos - r->write_filled;
-	int used = 0;
-	in_size -= SINC_WIDTH * 2;
-	if (in_size > 0)
-	{
-		float* out = *out_;
-		float const* in = in_;
-		float const* const in_end = in + in_size;
-		int phase = r->phase;
-		int phase_inc = r->phase_inc;
-
-		int step = phase_inc > RESAMPLER_RESOLUTION ? RESAMPLER_RESOLUTION * RESAMPLER_RESOLUTION / phase_inc : RESAMPLER_RESOLUTION;
-		int window_step = RESAMPLER_RESOLUTION;
-
-		do
-		{
-			float kernel[SINC_WIDTH * 2], kernel_sum = 0.0;
-			int i = SINC_WIDTH;
-			int phase_adj = phase * step / RESAMPLER_RESOLUTION;
-			float sample;
-
-			if (out >= out_end)
-				break;
-
-			for (; i >= -SINC_WIDTH + 1; --i)
-			{
-				int pos = i * step;
-				int window_pos = i * window_step;
-				kernel_sum += kernel[i + SINC_WIDTH - 1] = sinc_lut[abs(phase_adj - pos)] * window_lut[abs(phase - window_pos)];
-			}
-			for (sample = 0, i = 0; i < SINC_WIDTH * 2; ++i)
-				sample += in[i] * kernel[i];
-			*out++ = (float)(sample / kernel_sum);
-
-			phase += phase_inc;
-
-			in += phase >> RESAMPLER_SHIFT;
-
-			phase &= RESAMPLER_RESOLUTION - 1;
-		} while (in < in_end);
-
-		r->phase = phase;
-		*out_ = out;
-
-		used = (int)(in - in_);
-
-		r->write_filled -= used;
-	}
-
-	return used;
-}
-
-static resampler_run resampler_run_blep = resampler_run_blep_c;
-static resampler_run resampler_run_cubic = resampler_run_cubic_c;
-static resampler_run resampler_run_sinc = resampler_run_sinc_c;
-
-void resampler_init(void)
-{
-    unsigned i;
-    double dx = (float)(SINC_WIDTH) / SINC_SAMPLES, x = 0.0;
-    for (i = 0; i < SINC_SAMPLES + 1; ++i, x += dx)
-    {
-        float y = x / SINC_WIDTH;
-#if 0
-        // Blackman
-        float window = 0.42659 - 0.49656 * cos(M_PI + M_PI * y) + 0.076849 * cos(2.0 * M_PI * y);
-#elif 1
-        // Nuttal 3 term
-        float window = 0.40897 + 0.5 * cos(M_PI * y) + 0.09103 * cos(2.0 * M_PI * y);
-#elif 0
-        // C.R.Helmrich's 2 term window
-        float window = 0.79445 * cos(0.5 * M_PI * y) + 0.20555 * cos(1.5 * M_PI * y);
-#elif 0
-        // Lanczos
-        float window = sinc(y);
-#endif
-        sinc_lut[i] = fabs(x) < SINC_WIDTH ? sinc(x) : 0.0;
-        window_lut[i] = window;
-    }
-    dx = 1.0 / (float)(RESAMPLER_RESOLUTION);
-    x = 0.0;
-    for (i = 0; i < RESAMPLER_RESOLUTION; ++i, x += dx)
-    {
-        cubic_lut[i*4]   = (float)(-0.5 * x * x * x +       x * x - 0.5 * x);
-        cubic_lut[i*4+1] = (float)( 1.5 * x * x * x - 2.5 * x * x           + 1.0);
-        cubic_lut[i*4+2] = (float)(-1.5 * x * x * x + 2.0 * x * x + 0.5 * x);
-        cubic_lut[i*4+3] = (float)( 0.5 * x * x * x - 0.5 * x * x);
-    }
-#ifdef RESAMPLER_SSE
-	if (query_cpu_feature_sse())
-	{
-		resampler_run_blep = resampler_run_blep_sse;
-		resampler_run_cubic = resampler_run_cubic_sse;
-		resampler_run_sinc = resampler_run_sinc_sse;
-	}
-#endif
-}
-
-void * resampler_create(void)
-{
-    resampler * r = ( resampler * ) malloc( sizeof(resampler) );
-    if ( !r ) return 0;
-
-    r->write_pos = SINC_WIDTH - 1;
-    r->write_filled = 0;
-    r->read_pos = 0;
-    r->read_filled = 0;
-    r->phase = 0;
-    r->phase_inc = 0;
-    r->inv_phase = 0;
-    r->inv_phase_inc = 0;
-    r->quality = RESAMPLER_QUALITY_MAX;
-    r->delay_added = -1;
-    r->delay_removed = -1;
-    r->last_amp = 0;
-    r->accumulator = 0;
-    memset( r->buffer_in, 0, sizeof(r->buffer_in) );
-    memset( r->buffer_out, 0, sizeof(r->buffer_out) );
-
-    return r;
-}
-
-void resampler_delete(void * _r)
-{
-    free( _r );
-}
-
-void * resampler_dup(const void * _r)
-{
-    const resampler * r_in = ( const resampler * ) _r;
-    resampler * r_out = ( resampler * ) malloc( sizeof(resampler) );
-    if ( !r_out ) return 0;
-
-    r_out->write_pos = r_in->write_pos;
-    r_out->write_filled = r_in->write_filled;
-    r_out->read_pos = r_in->read_pos;
-    r_out->read_filled = r_in->read_filled;
-    r_out->phase = r_in->phase;
-    r_out->phase_inc = r_in->phase_inc;
-    r_out->inv_phase = r_in->inv_phase;
-    r_out->inv_phase_inc = r_in->inv_phase_inc;
-    r_out->quality = r_in->quality;
-    r_out->delay_added = r_in->delay_added;
-    r_out->delay_removed = r_in->delay_removed;
-    r_out->last_amp = r_in->last_amp;
-    r_out->accumulator = r_in->accumulator;
-    memcpy( r_out->buffer_in, r_in->buffer_in, sizeof(r_in->buffer_in) );
-    memcpy( r_out->buffer_out, r_in->buffer_out, sizeof(r_in->buffer_out) );
-
-    return r_out;
-}
-
-void resampler_dup_inplace(void *_d, const void *_s)
-{
-    const resampler * r_in = ( const resampler * ) _s;
-    resampler * r_out = ( resampler * ) _d;
-
-    r_out->write_pos = r_in->write_pos;
-    r_out->write_filled = r_in->write_filled;
-    r_out->read_pos = r_in->read_pos;
-    r_out->read_filled = r_in->read_filled;
-    r_out->phase = r_in->phase;
-    r_out->phase_inc = r_in->phase_inc;
-    r_out->inv_phase = r_in->inv_phase;
-    r_out->inv_phase_inc = r_in->inv_phase_inc;
-    r_out->quality = r_in->quality;
-    r_out->delay_added = r_in->delay_added;
-    r_out->delay_removed = r_in->delay_removed;
-    r_out->last_amp = r_in->last_amp;
-    r_out->accumulator = r_in->accumulator;
-    memcpy( r_out->buffer_in, r_in->buffer_in, sizeof(r_in->buffer_in) );
-    memcpy( r_out->buffer_out, r_in->buffer_out, sizeof(r_in->buffer_out) );
-}
-
-void resampler_set_quality(void *_r, int quality)
-{
-    resampler * r = ( resampler * ) _r;
-    if (quality < RESAMPLER_QUALITY_MIN)
-        quality = RESAMPLER_QUALITY_MIN;
-    else if (quality > RESAMPLER_QUALITY_MAX)
-        quality = RESAMPLER_QUALITY_MAX;
-    if ( r->quality != quality )
-    {
-        if ( quality == RESAMPLER_QUALITY_BLEP || r->quality == RESAMPLER_QUALITY_BLEP )
-        {
-            r->read_pos = 0;
-            r->read_filled = 0;
-            r->last_amp = 0;
-            r->accumulator = 0;
-            memset( r->buffer_out, 0, sizeof(r->buffer_out) );
-        }
-        r->delay_added = -1;
-        r->delay_removed = -1;
-    }
-    r->quality = (unsigned char)quality;
-}
-
-int resampler_get_free_count(void *_r)
-{
-    resampler * r = ( resampler * ) _r;
-    return resampler_buffer_size - r->write_filled;
-}
-
-static int resampler_min_filled(resampler *r)
-{
-    switch (r->quality)
-    {
-    default:
-    case RESAMPLER_QUALITY_ZOH:
-    case RESAMPLER_QUALITY_BLEP:
-        return 1;
-            
-    case RESAMPLER_QUALITY_LINEAR:
-        return 2;
-            
-    case RESAMPLER_QUALITY_CUBIC:
-        return 4;
-            
-    case RESAMPLER_QUALITY_SINC:
-        return SINC_WIDTH * 2;
-    }
-}
-
-static int resampler_input_delay(resampler *r)
-{
-    switch (r->quality)
-    {
-    default:
-    case RESAMPLER_QUALITY_ZOH:
-    case RESAMPLER_QUALITY_BLEP:
-    case RESAMPLER_QUALITY_LINEAR:
-        return 0;
-            
-    case RESAMPLER_QUALITY_CUBIC:
-        return 1;
-            
-    case RESAMPLER_QUALITY_SINC:
-        return SINC_WIDTH - 1;
-    }
-}
-
-static int resampler_output_delay(resampler *r)
-{
-    switch (r->quality)
-    {
-    default:
-    case RESAMPLER_QUALITY_ZOH:
-    case RESAMPLER_QUALITY_LINEAR:
-    case RESAMPLER_QUALITY_CUBIC:
-    case RESAMPLER_QUALITY_SINC:
-        return 0;
-            
-    case RESAMPLER_QUALITY_BLEP:
-        return SINC_WIDTH - 1;
-    }
-}
-
-int resampler_ready(void *_r)
-{
-    resampler * r = ( resampler * ) _r;
-    return r->write_filled > resampler_min_filled(r);
-}
-
-void resampler_clear(void *_r)
-{
-    resampler * r = ( resampler * ) _r;
-    r->write_pos = SINC_WIDTH - 1;
-    r->write_filled = 0;
-    r->read_pos = 0;
-    r->read_filled = 0;
-    r->phase = 0;
-    r->delay_added = -1;
-    r->delay_removed = -1;
-    memset(r->buffer_in, 0, (SINC_WIDTH - 1) * sizeof(r->buffer_in[0]));
-    memset(r->buffer_in + resampler_buffer_size, 0, (SINC_WIDTH - 1) * sizeof(r->buffer_in[0]));
-    if (r->quality == RESAMPLER_QUALITY_BLEP)
-        memset(r->buffer_out, 0, sizeof(r->buffer_out));
-}
-
-void resampler_set_rate(void *_r, double new_factor)
-{
-    resampler * r = ( resampler * ) _r;
-    r->phase_inc = (int)( new_factor * RESAMPLER_RESOLUTION );
-    new_factor = 1.0 / new_factor;
-    r->inv_phase_inc = (int)( new_factor * RESAMPLER_RESOLUTION );
-}
-
-void resampler_write_sample(void *_r, short s)
-{
-    resampler * r = ( resampler * ) _r;
-
-    if ( r->delay_added < 0 )
-    {
-        r->delay_added = 0;
-        r->write_filled = resampler_input_delay( r );
-    }
-    
-    if ( r->write_filled < resampler_buffer_size )
-    {
-        float s32 = s;
-        s32 *= 256.0;
-
-        r->buffer_in[ r->write_pos ] = s32;
-        r->buffer_in[ r->write_pos + resampler_buffer_size ] = s32;
-
-        ++r->write_filled;
-
-        r->write_pos = ( r->write_pos + 1 ) % resampler_buffer_size;
-    }
-}
-
-void resampler_write_sample_fixed(void *_r, int s, unsigned char depth)
-{
-    resampler * r = ( resampler * ) _r;
-    
-    if ( r->delay_added < 0 )
-    {
-        r->delay_added = 0;
-        r->write_filled = resampler_input_delay( r );
-    }
-    
-    if ( r->write_filled < resampler_buffer_size )
-    {
-        float s32 = s;
-        s32 /= (double)(1 << (depth - 1));
-        
-        r->buffer_in[ r->write_pos ] = s32;
-        r->buffer_in[ r->write_pos + resampler_buffer_size ] = s32;
-        
-        ++r->write_filled;
-        
-        r->write_pos = ( r->write_pos + 1 ) % resampler_buffer_size;
-    }
-}
-
-static void resampler_fill(resampler * r)
-{
-    int min_filled = resampler_min_filled(r);
-    int quality = r->quality;
-    while ( r->write_filled > min_filled &&
-            r->read_filled < resampler_buffer_size )
-    {
-        int write_pos = ( r->read_pos + r->read_filled ) % resampler_buffer_size;
-        int write_size = resampler_buffer_size - write_pos;
-        float * out = r->buffer_out + write_pos;
-        if ( write_size > ( resampler_buffer_size - r->read_filled ) )
-            write_size = resampler_buffer_size - r->read_filled;
-        switch (quality)
-        {
-        case RESAMPLER_QUALITY_ZOH:
-            resampler_run_zoh( r, &out, out + write_size );
-            break;
-                
-        case RESAMPLER_QUALITY_BLEP:
-        {
-            int used;
-            int write_extra = 0;
-            if ( write_pos >= r->read_pos )
-                write_extra = r->read_pos;
-            if ( write_extra > SINC_WIDTH * 2 - 1 )
-                write_extra = SINC_WIDTH * 2 - 1;
-            memcpy( r->buffer_out + resampler_buffer_size, r->buffer_out, write_extra * sizeof(r->buffer_out[0]) );
-            used = resampler_run_blep( r, &out, out + write_size + write_extra );
-            memcpy( r->buffer_out, r->buffer_out + resampler_buffer_size, write_extra * sizeof(r->buffer_out[0]) );
-            if (!used)
-                return;
-            break;
-        }
-                
-        case RESAMPLER_QUALITY_LINEAR:
-            resampler_run_linear( r, &out, out + write_size );
-            break;
-                
-        case RESAMPLER_QUALITY_CUBIC:
-            resampler_run_cubic( r, &out, out + write_size );
-            break;
-                
-        case RESAMPLER_QUALITY_SINC:
-            resampler_run_sinc( r, &out, out + write_size );
-            break;
-        }
-        r->read_filled += out - r->buffer_out - write_pos;
-    }
-}
-
-static void resampler_fill_and_remove_delay(resampler * r)
-{
-    resampler_fill( r );
-    if ( r->delay_removed < 0 )
-    {
-        int delay = resampler_output_delay( r );
-        r->delay_removed = 0;
-        while ( delay-- )
-            resampler_remove_sample( r );
-    }
-}
-
-int resampler_get_sample_count(void *_r)
-{
-    resampler * r = ( resampler * ) _r;
-    if ( r->read_filled < 1 && (r->quality != RESAMPLER_QUALITY_BLEP || r->inv_phase_inc))
-        resampler_fill_and_remove_delay( r );
-    return r->read_filled;
-}
-
-int resampler_get_sample(void *_r)
-{
-    resampler * r = ( resampler * ) _r;
-    if ( r->read_filled < 1 && r->phase_inc)
-        resampler_fill_and_remove_delay( r );
-    if ( r->read_filled < 1 )
-        return 0;
-    if ( r->quality == RESAMPLER_QUALITY_BLEP )
-        return (int)(r->buffer_out[ r->read_pos ] + r->accumulator);
-    else
-        return (int)r->buffer_out[ r->read_pos ];
-}
-
-void resampler_remove_sample(void *_r)
-{
-    resampler * r = ( resampler * ) _r;
-    if ( r->read_filled > 0 )
-    {
-        if ( r->quality == RESAMPLER_QUALITY_BLEP )
-        {
-            r->accumulator += r->buffer_out[ r->read_pos ];
-            r->buffer_out[ r->read_pos ] = 0;
-            r->accumulator -= r->accumulator * (1.0 / 8192.0);
-            if (fabs(r->accumulator) < 1e-20)
-                r->accumulator = 0;
-        }
-        --r->read_filled;
-        r->read_pos = ( r->read_pos + 1 ) % resampler_buffer_size;
-    }
-}
-
-/* Get a 16-bit sample with saturation */
-short resampler_get_and_remove_sample(void *_r)
-{
-	int sample = resampler_get_sample(_r) >> 8;
-	resampler_remove_sample(_r);
-	if (sample > 32767)
-		return 32767;
-	else if (sample < -32768)
-		return -32768;
-	else
-		return (short)sample;
-}

+ 1 - 0
resampler.c

@@ -0,0 +1 @@
+src/resampler.c

+ 0 - 65
resampler.h

@@ -1,65 +0,0 @@
-#ifndef _RESAMPLER_H_
-#define _RESAMPLER_H_
-
-// Ugglay
-#ifdef RESAMPLER_DECORATE
-#define PASTE(a,b) a ## b
-#define EVALUATE(a,b) PASTE(a,b)
-#define resampler_init EVALUATE(RESAMPLER_DECORATE,_resampler_init)
-#define resampler_create EVALUATE(RESAMPLER_DECORATE,_resampler_create)
-#define resampler_delete EVALUATE(RESAMPLER_DECORATE,_resampler_delete)
-#define resampler_dup EVALUATE(RESAMPLER_DECORATE,_resampler_dup)
-#define resampler_dup_inplace EVALUATE(RESAMPLER_DECORATE,_resampler_dup_inplace)
-#define resampler_set_quality EVALUATE(RESAMPLER_DECORATE,_resampler_set_quality)
-#define resampler_get_free_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_free_count)
-#define resampler_write_sample EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample)
-#define resampler_write_sample_fixed EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample_fixed)
-#define resampler_set_rate EVALUATE(RESAMPLER_DECORATE,_resampler_set_rate)
-#define resampler_ready EVALUATE(RESAMPLER_DECORATE,_resampler_ready)
-#define resampler_clear EVALUATE(RESAMPLER_DECORATE,_resampler_clear)
-#define resampler_get_sample_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample_count)
-#define resampler_get_sample EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample)
-#define resampler_remove_sample EVALUATE(RESAMPLER_DECORATE,_resampler_remove_sample)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void resampler_init(void);
-
-void * resampler_create(void);
-void resampler_delete(void *);
-void * resampler_dup(const void *);
-void resampler_dup_inplace(void *, const void *);
-
-enum
-{
-    RESAMPLER_QUALITY_MIN = 0,
-    RESAMPLER_QUALITY_ZOH = 0,
-    RESAMPLER_QUALITY_BLEP = 1,
-    RESAMPLER_QUALITY_LINEAR = 2,
-    RESAMPLER_QUALITY_CUBIC = 3,
-    RESAMPLER_QUALITY_SINC = 4,
-    RESAMPLER_QUALITY_MAX = 4
-};
-
-void resampler_set_quality(void *, int quality);
-
-int resampler_get_free_count(void *);
-void resampler_write_sample(void *, short sample);
-void resampler_write_sample_fixed(void *, int sample, unsigned char depth);
-void resampler_set_rate( void *, double new_factor );
-int resampler_ready(void *);
-void resampler_clear(void *);
-int resampler_get_sample_count(void *);
-int resampler_get_sample(void *);
-void resampler_remove_sample(void *);
-
-short resampler_get_and_remove_sample(void *_r);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 0
resampler.h

@@ -0,0 +1 @@
+src/resampler.h

+ 0 - 501
rixplay.cpp

@@ -1,501 +0,0 @@
-/* -*- mode: c++; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 2008, Wei Mingzhi <whistler_wmz@users.sf.net>.
-// All rights reserved.
-// Modified by Lou Yihua <louyihua@21cn.com>, 2015.
-//
-// This file is part of SDLPAL.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <math.h>
-#include "global.h"
-#include "palcfg.h"
-#include "players.h"
-#include "audio.h"
-
-#include "resampler.h"
-#include "adplug/opl.h"
-#include "adplug/demuopl.h"
-#include "adplug/dbemuopl.h"
-#include "adplug/emuopl.h"
-#include "adplug/surroundopl.h"
-#include "adplug/rix.h"
-
-typedef struct tagRIXPLAYER :
-	public AUDIOPLAYER
-{
-   Copl                      *opl;
-   CrixPlayer                *rix;
-   void                      *resampler[2];
-   BYTE                       buf[(PAL_MAX_SAMPLERATE + 69) / 70 * sizeof(short) * 2];
-   LPBYTE                     pos;
-   INT                        iCurrentMusic; // current playing music number
-   INT                        iNextMusic; // the next music number to switch to
-   DWORD                      dwStartFadeTime;
-   INT                        iTotalFadeOutSamples;
-   INT                        iTotalFadeInSamples;
-   INT                        iRemainingFadeSamples;
-   enum { NONE, FADE_IN, FADE_OUT } FadeType; // fade in or fade out ?
-   BOOL                       fLoop;
-   BOOL                       fNextLoop;
-   BOOL                       fReady;
-} RIXPLAYER, *LPRIXPLAYER;
-
-static VOID
-RIX_FillBuffer(
-	VOID      *object,
-	LPBYTE     stream,
-	INT        len
-)
-/*++
-	Purpose:
-
-	Fill the background music into the sound buffer. Called by the SDL sound
-	callback function only (audio.c: AUDIO_FillBuffer).
-
-	Parameters:
-
-	[OUT] stream - pointer to the stream buffer.
-
-	[IN]  len - Length of the buffer.
-
-	Return value:
-
-	None.
-
---*/
-{
-	LPRIXPLAYER pRixPlayer = (LPRIXPLAYER)object;
-
-	if (pRixPlayer == NULL || !pRixPlayer->fReady)
-	{
-		//
-		// Not initialized
-		//
-		return;
-	}
-
-	while (len > 0)
-	{
-		INT       volume, delta_samples = 0, vol_delta = 0;
-
-		//
-		// fading in or fading out
-		//
-		switch (pRixPlayer->FadeType)
-		{
-		case RIXPLAYER::FADE_IN:
-			if (pRixPlayer->iRemainingFadeSamples <= 0)
-			{
-				pRixPlayer->FadeType = RIXPLAYER::NONE;
-				volume = SDL_MIX_MAXVOLUME;
-			}
-			else
-			{
-				volume = (INT)(SDL_MIX_MAXVOLUME * (1.0 - (double)pRixPlayer->iRemainingFadeSamples / pRixPlayer->iTotalFadeInSamples));
-				delta_samples = pRixPlayer->iTotalFadeInSamples / SDL_MIX_MAXVOLUME; vol_delta = 1;
-			}
-			break;
-		case RIXPLAYER::FADE_OUT:
-			if (pRixPlayer->iTotalFadeOutSamples == pRixPlayer->iRemainingFadeSamples && pRixPlayer->iTotalFadeOutSamples > 0)
-			{
-				UINT  now = SDL_GetTicks();
-				INT   passed_samples = ((INT)(now - pRixPlayer->dwStartFadeTime) > 0) ? (INT)((now - pRixPlayer->dwStartFadeTime) * AUDIO_GetDeviceSpec()->freq / 1000) : 0;
-				pRixPlayer->iRemainingFadeSamples -= passed_samples;
-			}
-			if (pRixPlayer->iCurrentMusic == -1 || pRixPlayer->iRemainingFadeSamples <= 0)
-			{
-				//
-				// There is no current playing music, or fading time has passed.
-				// Start playing the next one or stop playing.
-				//
-				if (pRixPlayer->iNextMusic > 0)
-				{
-					pRixPlayer->iCurrentMusic = pRixPlayer->iNextMusic;
-					pRixPlayer->iNextMusic = -1;
-					pRixPlayer->fLoop = pRixPlayer->fNextLoop;
-					pRixPlayer->FadeType = RIXPLAYER::FADE_IN;
-					if (pRixPlayer->iCurrentMusic > 0)
-						pRixPlayer->dwStartFadeTime += pRixPlayer->iTotalFadeOutSamples * 1000 / gConfig.iSampleRate;
-					else
-						pRixPlayer->dwStartFadeTime = SDL_GetTicks();
-					pRixPlayer->iTotalFadeOutSamples = 0;
-					pRixPlayer->iRemainingFadeSamples = pRixPlayer->iTotalFadeInSamples;
-					pRixPlayer->rix->rewind(pRixPlayer->iCurrentMusic);
-					if (pRixPlayer->resampler[0]) resampler_clear(pRixPlayer->resampler[0]);
-					if (pRixPlayer->resampler[1]) resampler_clear(pRixPlayer->resampler[1]);
-					continue;
-				}
-				else
-				{
-					pRixPlayer->iCurrentMusic = -1;
-					pRixPlayer->FadeType = RIXPLAYER::NONE;
-					return;
-				}
-			}
-			else
-			{
-				volume = (INT)(SDL_MIX_MAXVOLUME * ((double)pRixPlayer->iRemainingFadeSamples / pRixPlayer->iTotalFadeOutSamples));
-				delta_samples = pRixPlayer->iTotalFadeOutSamples / SDL_MIX_MAXVOLUME; vol_delta = -1;
-			}
-			break;
-		default:
-			if (pRixPlayer->iCurrentMusic <= 0)
-			{
-				//
-				// No current playing music
-				//
-				return;
-			}
-			else
-			{
-				volume = SDL_MIX_MAXVOLUME;
-			}
-		}
-
-		//
-		// Fill the buffer with sound data
-		//
-		int buf_max_len = gConfig.iSampleRate / 70 * gConfig.iAudioChannels * sizeof(short);
-		bool fContinue = true;
-		while (len > 0 && fContinue)
-		{
-			if (pRixPlayer->pos == NULL || pRixPlayer->pos - pRixPlayer->buf >= buf_max_len)
-			{
-				pRixPlayer->pos = pRixPlayer->buf;
-				if (!pRixPlayer->rix->update())
-				{
-					if (!pRixPlayer->fLoop)
-					{
-						//
-						// Not loop, simply terminate the music
-						//
-						pRixPlayer->iCurrentMusic = -1;
-						if (pRixPlayer->FadeType != RIXPLAYER::FADE_OUT && pRixPlayer->iNextMusic == -1)
-						{
-							pRixPlayer->FadeType = RIXPLAYER::NONE;
-						}
-						return;
-					}
-					pRixPlayer->rix->rewind(pRixPlayer->iCurrentMusic, false);
-					if (!pRixPlayer->rix->update())
-					{
-						//
-						// Something must be wrong
-						//
-						pRixPlayer->iCurrentMusic = -1;
-						pRixPlayer->FadeType = RIXPLAYER::NONE;
-						return;
-					}
-				}
-				int sample_count = gConfig.iSampleRate / 70;
-				if (pRixPlayer->resampler[0])
-				{
-					unsigned int samples_written = 0;
-					short *finalBuf = (short*)pRixPlayer->buf;
-
-					while (sample_count)
-					{
-						int to_write = resampler_get_free_count(pRixPlayer->resampler[0]);
-						if (to_write)
-						{
-							short *tempBuf = (short*)alloca(to_write * gConfig.iAudioChannels * sizeof(short));
-							int temp_buf_read = 0;
-							pRixPlayer->opl->update(tempBuf, to_write);
-							for (int i = 0; i < to_write * gConfig.iAudioChannels; i++)
-								resampler_write_sample(pRixPlayer->resampler[i % gConfig.iAudioChannels], tempBuf[temp_buf_read++]);
-						}
-
-						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 * gConfig.iAudioChannels; i++)
-							finalBuf[samples_written++] = resampler_get_and_remove_sample(pRixPlayer->resampler[i % gConfig.iAudioChannels]);
-						sample_count -= to_get;
-					}
-				}
-				else
-				{
-					pRixPlayer->opl->update((short *)(pRixPlayer->buf), sample_count);
-				}
-			}
-
-			int l = buf_max_len - (pRixPlayer->pos - pRixPlayer->buf);
-			l = (l > len) ? len / sizeof(short) : l / sizeof(short);
-
-			//
-			// Put audio data into buffer and adjust volume
-			//
-			if (pRixPlayer->FadeType != RIXPLAYER::NONE)
-			{
-				short* ptr = (short*)stream;
-				for (int i = 0; i < l && pRixPlayer->iRemainingFadeSamples > 0; volume += vol_delta)
-				{
-					int j = 0;
-					for (j = 0; i < l && j < delta_samples; i++, j++)
-					{
-						*ptr++ = *(short*)pRixPlayer->pos * volume / SDL_MIX_MAXVOLUME;
-						pRixPlayer->pos += sizeof(short);
-					}
-					pRixPlayer->iRemainingFadeSamples -= j;
-				}
-				fContinue = (pRixPlayer->iRemainingFadeSamples > 0);
-				len -= (LPBYTE)ptr - stream; stream = (LPBYTE)ptr;
-			}
-			else
-			{
-				memcpy(stream, pRixPlayer->pos, l * sizeof(short));
-				pRixPlayer->pos += l * sizeof(short);
-				stream += l * sizeof(short);
-				len -= l * sizeof(short);
-			}
-		}
-	}
-}
-
-static VOID
-RIX_Shutdown(
-	VOID     *object
-)
-/*++
-	Purpose:
-
-	Shutdown the RIX player subsystem.
-
-	Parameters:
-
-	None.
-
-	Return value:
-
-	None.
-
---*/
-{
-	if (object != NULL)
-	{
-		LPRIXPLAYER pRixPlayer = (LPRIXPLAYER)object;
-		pRixPlayer->fReady = FALSE;
-		for (int i = 0; i < gConfig.iAudioChannels; i++)
-			if (pRixPlayer->resampler[i])
-				resampler_delete(pRixPlayer->resampler[i]);
-		delete pRixPlayer->rix;
-		delete pRixPlayer->opl;
-		delete pRixPlayer;
-	}
-}
-
-static BOOL
-RIX_Play(
-	VOID     *object,
-	INT       iNumRIX,
-	BOOL      fLoop,
-	FLOAT     flFadeTime
-)
-/*++
-	Purpose:
-
-	Start playing the specified music.
-
-	Parameters:
-
-	[IN]  iNumRIX - number of the music. 0 to stop playing current music.
-
-	[IN]  fLoop - Whether the music should be looped or not.
-
-	[IN]  flFadeTime - the fade in/out time when switching music.
-
-	Return value:
-
-	None.
-
---*/
-{
-	LPRIXPLAYER pRixPlayer = (LPRIXPLAYER)object;
-
-	//
-	// Check for NULL pointer.
-	//
-	if (pRixPlayer == NULL)
-	{
-		return FALSE;
-	}
-
-	//
-	// Stop the current CD music.
-	//
-	AUDIO_PlayCDTrack(-1);
-
-	if (iNumRIX == pRixPlayer->iCurrentMusic && pRixPlayer->iNextMusic == -1)
-	{
-		/* Will play the same music without any pending play changes,
-		   just change the loop attribute */
-		pRixPlayer->fLoop = fLoop;
-		return TRUE;
-	}
-
-	if (pRixPlayer->FadeType != RIXPLAYER::FADE_OUT)
-	{
-		if (pRixPlayer->FadeType == RIXPLAYER::FADE_IN && pRixPlayer->iTotalFadeInSamples > 0 && pRixPlayer->iRemainingFadeSamples > 0)
-		{
-			pRixPlayer->dwStartFadeTime = SDL_GetTicks() - (int)((float)pRixPlayer->iRemainingFadeSamples / pRixPlayer->iTotalFadeInSamples * flFadeTime * (1000 / 2));
-		}
-		else
-		{
-			pRixPlayer->dwStartFadeTime = SDL_GetTicks();
-		}
-		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 * gConfig.iSampleRate) * gConfig.iAudioChannels;
-	}
-
-	pRixPlayer->iNextMusic = iNumRIX;
-	pRixPlayer->FadeType = RIXPLAYER::FADE_OUT;
-	pRixPlayer->fNextLoop = fLoop;
-	pRixPlayer->fReady = TRUE;
-
-	return TRUE;
-}
-
-LPAUDIOPLAYER
-RIX_Init(
-	LPCSTR     szFileName
-)
-/*++
-  Purpose:
-
-    Initialize the RIX player subsystem.
-
-  Parameters:
-
-    [IN]  szFileName - Filename of the mus.mkf file.
-
-  Return value:
-
-    0 if success, -1 if cannot allocate memory, -2 if file not found.
---*/
-{
-	LPRIXPLAYER pRixPlayer = new RIXPLAYER;
-	if (pRixPlayer == NULL)
-	{
-		return NULL;
-	}
-	else
-	{
-		memset(pRixPlayer, 0, sizeof(RIXPLAYER));
-		pRixPlayer->FillBuffer = RIX_FillBuffer;
-		pRixPlayer->Shutdown = RIX_Shutdown;
-		pRixPlayer->Play = RIX_Play;
-	}
-
-	if (gConfig.fUseSurroundOPL)
-	{
-		switch (gConfig.eOPLType)
-		{
-		case OPL_DOSBOX:
-			pRixPlayer->opl = new CSurroundopl(
-				new CDemuopl(gConfig.iOPLSampleRate, true, false),
-				new CDemuopl(gConfig.iOPLSampleRate, true, false),
-				true, gConfig.iOPLSampleRate, gConfig.iSurroundOPLOffset);
-			break;
-		case OPL_DOSBOX_NEW:
-			pRixPlayer->opl = new CSurroundopl(
-				new CDBemuopl(gConfig.iOPLSampleRate, true, false),
-				new CDBemuopl(gConfig.iOPLSampleRate, true, false),
-				true, gConfig.iOPLSampleRate, gConfig.iSurroundOPLOffset);
-			break;
-		case OPL_MAME:
-			pRixPlayer->opl = new CSurroundopl(
-				new CEmuopl(gConfig.iOPLSampleRate, true, false),
-				new CEmuopl(gConfig.iOPLSampleRate, true, false),
-				true, gConfig.iOPLSampleRate, gConfig.iSurroundOPLOffset);
-			break;
-		}
-	}
-	else
-	{
-		switch (gConfig.eOPLType)
-		{
-		case OPL_DOSBOX:
-			pRixPlayer->opl = new CDemuopl(gConfig.iOPLSampleRate, true, gConfig.iAudioChannels == 2);
-			break;
-		case OPL_DOSBOX_NEW:
-			pRixPlayer->opl = new CDBemuopl(gConfig.iOPLSampleRate, true, gConfig.iAudioChannels == 2);
-			break;
-		case OPL_MAME:
-			pRixPlayer->opl = new CEmuopl(gConfig.iOPLSampleRate, true, gConfig.iAudioChannels == 2);
-			break;
-		}
-	}
-
-	if (pRixPlayer->opl == NULL)
-	{
-		delete pRixPlayer;
-		return NULL;
-	}
-
-	pRixPlayer->rix = new CrixPlayer(pRixPlayer->opl);
-	if (pRixPlayer->rix == NULL)
-	{
-		delete pRixPlayer->opl;
-		delete pRixPlayer;
-		return NULL;
-	}
-
-	//
-	// Load the MKF file.
-	//
-	if (!pRixPlayer->rix->load(szFileName, CProvider_Filesystem()))
-	{
-		delete pRixPlayer->rix;
-		delete pRixPlayer->opl;
-		delete pRixPlayer;
-		pRixPlayer = NULL;
-		return NULL;
-	}
-
-	if (gConfig.iOPLSampleRate != gConfig.iSampleRate)
-	{
-		for (int i = 0; i < gConfig.iAudioChannels; i++)
-		{
-			pRixPlayer->resampler[i] = resampler_create();
-			resampler_set_quality(pRixPlayer->resampler[i], AUDIO_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 (gConfig.pExtraFMRegs && gConfig.pExtraFMVals)
-	{
-		pRixPlayer->rix->set_extra_init(gConfig.pExtraFMRegs, gConfig.pExtraFMVals, gConfig.dwExtraLength);
-	}
-#endif
-
-	//
-	// Success.
-	//
-	pRixPlayer->FadeType = RIXPLAYER::NONE;
-	pRixPlayer->iCurrentMusic = pRixPlayer->iNextMusic = -1;
-	pRixPlayer->pos = NULL;
-	pRixPlayer->fLoop = FALSE;
-	pRixPlayer->fNextLoop = FALSE;
-	pRixPlayer->fReady = FALSE;
-
-	return pRixPlayer;
-}

+ 0 - 0
rixplay.cpp


Some files were not shown because too many files changed in this diff