Browse Source

Various changes

1. Remove the unused 'getopt.h'/'getopt.c'.
2. Remove some rarely-used makefiles.
3. Create sub-directories for platforms, and move makefiles into these directories.
4. Setting GUI for generic Unix and Linux platforms (using FLTK library).
5. Change the order in enumeration definition of `MUSICTYPE` to simplify GUI processing.
6. Fix volume processing bug in GUI under WIN32/WinRT.
louyihua 8 years ago
parent
commit
f194722fc4

+ 0 - 42
Makefile

@@ -1,42 +0,0 @@
-# Adapted from Makefile for Dingux by Rikku2000
-
-TARGET = sdlpal
-
-HOST =
-
-ADPLUG_FILES = adplug/rix.cpp adplug/player.cpp adplug/binio.cpp \
-	adplug/fprovide.cpp adplug/binfile.cpp adplug/dosbox_opl.cpp \
-	adplug/fmopl.c adplug/dbopl.cpp adplug/surroundopl.cpp \
-	adplug/emuopl.cpp adplug/demuopl.cpp adplug/dbemuopl.cpp
-
-LIBMAD_FILES = libmad/bit.c libmad/decoder.c libmad/fixed.c libmad/frame.c \
-	libmad/huffman.c libmad/layer12.c libmad/layer3.c libmad/music_mad.c \
-	libmad/stream.c libmad/synth.c libmad/timer.c
-
-LIBOGGVORBIS_FILES = liboggvorbis/src/analysis.c liboggvorbis/src/bitrate.c \
-    liboggvorbis/src/bitwise.c liboggvorbis/src/block.c liboggvorbis/src/codebook.c \
-    liboggvorbis/src/envelope.c liboggvorbis/src/floor0.c liboggvorbis/src/floor1.c \
-    liboggvorbis/src/framing.c liboggvorbis/src/info.c liboggvorbis/src/lookup.c \
-    liboggvorbis/src/lpc.c liboggvorbis/src/lsp.c liboggvorbis/src/mapping0.c \
-    liboggvorbis/src/mdct.c liboggvorbis/src/psy.c liboggvorbis/src/registry.c \
-    liboggvorbis/src/res0.c liboggvorbis/src/sharedbook.c liboggvorbis/src/smallft.c \
-    liboggvorbis/src/synthesis.c liboggvorbis/src/vorbisenc.c liboggvorbis/src/vorbisfile.c \
-    liboggvorbis/src/window.c
-
-FILES = battle.c ending.c fight.c font.c game.c getopt.c global.c input.c \
-    itemmenu.c magicmenu.c main.c map.c mp3play.c oggplay.c palcommon.c \
-	palette.c play.c res.c resampler.c rixplay.cpp rngplay.c scene.c script.c \
-	sound.c text.c ui.c uibattle.c uigame.c util.c video.c yj1.c 
-
-FILES += $(ADPLUG_FILES)
-FILES += $(LIBMAD_FILES)
-FILES += $(LIBOGGVORBIS_FILES)
-
-CFLAGS = `sdl-config --cflags` -g -Wall -O2 -fno-strict-aliasing -Iliboggvorbis/include -Iliboggvorbis/src
-LDFLAGS = `sdl-config --libs` -lstdc++ -lm
-
-$(TARGET):
-	$(HOST)gcc $(CFLAGS) -o $(TARGET) $(FILES) $(LDFLAGS)
-
-clean:
-	rm -f $(TARGET)

+ 0 - 28
Makefile.cygwin

@@ -1,28 +0,0 @@
-TARGET = sdlpal.exe
-
-HOST = i686-pc-cygwin-
-
-SOURCES = . ./adplug
-CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
-CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))
-RCFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.rc))
-OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(RCFILES:.rc=.o)
-
-CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DCYGWIN -DPAL_CLASSIC
-CXXFLAGS = $(CFLAGS)
-LDFLAGS = `sdl-config --libs`
-
-$(TARGET): $(OFILES)
-	$(HOST)g++ $(OFILES) -o $@ $(LDFLAGS)
-
-%.o: %.c
-	$(HOST)gcc $(CFLAGS) -c $< -o $@
-
-%.o: %.cpp
-	$(HOST)g++ $(CXXFLAGS) -c $< -o $@
-
-%.o: %.rc
-	windres.exe -i $< --input-format=rc -o $@ -O coff
-
-clean:
-	rm -f $(TARGET) $(OFILES)

+ 0 - 42
Makefile.sdl2

@@ -1,42 +0,0 @@
-# Adapted from Makefile for Dingux by Rikku2000
-
-TARGET = sdlpal
-
-HOST =
-
-ADPLUG_FILES = adplug/rix.cpp adplug/player.cpp adplug/binio.cpp \
-	adplug/fprovide.cpp adplug/binfile.cpp adplug/dosbox_opl.cpp \
-	adplug/fmopl.c adplug/dbopl.cpp adplug/surroundopl.cpp \
-	adplug/emuopl.cpp adplug/demuopl.cpp adplug/dbemuopl.cpp
-
-LIBMAD_FILES = libmad/bit.c libmad/decoder.c libmad/fixed.c libmad/frame.c \
-	libmad/huffman.c libmad/layer12.c libmad/layer3.c libmad/music_mad.c \
-	libmad/stream.c libmad/synth.c libmad/timer.c
-
-LIBOGGVORBIS_FILES = liboggvorbis/src/analysis.c liboggvorbis/src/bitrate.c \
-    liboggvorbis/src/bitwise.c liboggvorbis/src/block.c liboggvorbis/src/codebook.c \
-    liboggvorbis/src/envelope.c liboggvorbis/src/floor0.c liboggvorbis/src/floor1.c \
-    liboggvorbis/src/framing.c liboggvorbis/src/info.c liboggvorbis/src/lookup.c \
-    liboggvorbis/src/lpc.c liboggvorbis/src/lsp.c liboggvorbis/src/mapping0.c \
-    liboggvorbis/src/mdct.c liboggvorbis/src/psy.c liboggvorbis/src/registry.c \
-    liboggvorbis/src/res0.c liboggvorbis/src/sharedbook.c liboggvorbis/src/smallft.c \
-    liboggvorbis/src/synthesis.c liboggvorbis/src/vorbisenc.c liboggvorbis/src/vorbisfile.c \
-    liboggvorbis/src/window.c
-
-FILES = battle.c ending.c fight.c font.c game.c getopt.c global.c input.c \
-    itemmenu.c magicmenu.c main.c map.c mp3play.c oggplay.c palcommon.c \
-	palette.c play.c res.c resampler.c rixplay.cpp rngplay.c scene.c script.c \
-	sound.c text.c ui.c uibattle.c uigame.c util.c video.c yj1.c 
-
-FILES += $(ADPLUG_FILES)
-FILES += $(LIBMAD_FILES)
-FILES += $(LIBOGGVORBIS_FILES)
-
-CFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing
-LDFLAGS = `sdl2-config --libs` -lstdc++ -lm
-
-$(TARGET):
-	$(HOST)gcc $(CFLAGS) -o $(TARGET) $(FILES) $(LDFLAGS)
-
-clean:
-	rm -f $(TARGET)

+ 42 - 18
README.txt

@@ -10,7 +10,7 @@ LICENSE
 
 SDLPAL is originally created by Wei Mingzhi from 2009.
 Copyright (c) 2009-2011 Wei Mingzhi <whistler_wmz@users.sf.net>.
-Copyright (c) 2011-2015 SDLPAL development team.
+Copyright (c) 2011-2016 SDLPAL development team.
 All rights reserved.
 
 SDLPAL is distributed under the terms of GNU General Public License, version 3
@@ -21,8 +21,6 @@ Many of the ideas of this program are based on documents from PAL
 Research Project (https://github.com/palxex/palresearch), and portions of the
 code are based on the work done by Baldur and louyihua.
 
-The getopt.c file is based on source code in OpenBSD.
-
 The resampler code is based on the code in Kode54's foo_input_adplug project
 (https://github.com/kode54/foo_input_adplug).
 
@@ -33,9 +31,10 @@ Adplug (http://adplug.sourceforge.net/)
 SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/)
 libmad (http://www.underbit.com/products/mad/)
 libogg & libvorbis (http://www.vorbis.com/)
+FLTK (http://www.fltk.org)
 
 And some of the OPL simulation cores this program used are from the DOSBOX
-project (http://www.dosbox.com).
+project (http://www.dosbox.com) and MAME project (http://mamedev.org/).
 
 Please see authors.txt for additional authors.
 
@@ -43,36 +42,43 @@ This program does NOT include any code or data files of the original game,
 which is proprietary and copyrighted by SoftStar Inc.
 
 
-COMPILE UNDER WINDOWS
-=====================
+COMPILE FOR WINDOWS
+===================
+
+The Microsoft Visual Studio 2013 or higher is supported under Windows.
 
-The following compilers/IDEs are supported under Windows:
+To compile the WIN32 desktop version, open the Visual Studio project file 
+'sdlpal.sln' under the 'win32' directory.
 
-1) Microsoft Visual Studio 2013 or higher (official)
-2) Dev-C++ 4.9.9.2 (unofficial)
-3) Open Watcom 1.7 (unofficial)
+To comiple the WinRT version, open one of the project files (SDLPal.UWP.sln,
+SDLPal.Windows.sln, SDLPal.WindowsPhone.sln) under the 'winrt' directory.
+Please note that, to compile the UWP version, Visual Studio 2015 or higher
+is required.
 
-To compile, open the respective project file (sdlpal.sln, sdlpal.dev, or
-sdlpal.wpj). You need to have SDL 2.0 development files installed.
+For all situations, you need to have SDL 2.0 development or source files 
+installed at the SDL2 directory under the source tree.
 
 
-COMPILE UNDER GNU/LINUX
-=======================
+COMPILE FOR GNU/LINUX OR UNIX
+=============================
 
 To compile, type:
 
+cd unix
 make
 
 You need to have SDL 2.0 development files installed. The compiled executable
-should be generated with the filename 'sdlpal' at the top directory of source
-files.
+should be generated with the filename 'sdlpal' at the current directory. By
+default, SDLPAL uses the FLTK library to provide setting GUI at launch. If you
+do not want to use the library, please define the macro 'PAL_NO_LAUNCH_UI' in
+the makefile.
 
 SDLPAL should also be able to compile and run under other UNIX-like systems, 
 however it's not tested.
 
 
-COMPILE UNDER MAC OS X
-======================
+COMPILE FOR MAC OS X
+====================
 
 To compile, open the project Pal.xcodeproj with Xcode, and click Build. You
 need to have SDL framework installed at /Library/Frameworks.
@@ -81,6 +87,24 @@ The compiled bundle should work as a "universal" binary which works on both
 Intel and PowerPC.
 
 
+COMPILE FOR IOS
+===============
+
+To be written.
+
+
+COMPILE FOR ANDROID
+===================
+
+To be written.
+
+
+COMPILE FOR OTHER PLATFORMS
+===========================
+
+To be written.
+
+
 CLASSIC BUILD
 =============
 

+ 3 - 2
android/jni/src/Android.mk

@@ -4,7 +4,7 @@ include $(CLEAR_VARS)
 
 LOCAL_MODULE := main
 
-SDL_PATH := ../SDL2
+SDL_PATH := ../../../SDL2
 OGG_PATH := ../../../liboggvorbis
 
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include $(LOCAL_PATH)/$(OGG_PATH)/include $(LOCAL_PATH)/$(OGG_PATH)/src
@@ -15,7 +15,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
 	../../../fight.c \
 	../../../font.c \
 	../../../game.c \
-	../../../getopt.c \
 	../../../global.c \
 	../../../input.c \
 	../../../itemmenu.c \
@@ -24,7 +23,9 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
 	../../../map.c \
 	../../../mp3play.c \
 	../../../oggplay.c \
+	../../../overlay.c \
 	../../../palcommon.c \
+	../../../palcfg.c \
 	../../../palette.c \
 	../../../play.c \
 	../../../resampler.c \

Makefile.dingux → dingux/Makefile.dingux


+ 1 - 0
dingux/README.txt

@@ -0,0 +1 @@
+This port should be updated for SDL2 and newly changes in source code.

+ 0 - 128
getopt.c

@@ -1,128 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 1987, 1993, 1994
-//   The Regents of the University of California. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// 1. Redistributions of source code must retain the above copyright
-//    notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-//    notice, this list of conditions and the following disclaimer in the
-//    documentation and/or other materials provided with the distribution.
-// 3. Neither the name of the University nor the names of its contributors
-//    may be used to endorse or promote products derived from this software
-//    without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "getopt.h"
-
-int     opterr = 1;      // if error message should be printed
-int     optind = 1;      // index into parent argv vector
-int     optopt;          // character checked for validity
-int     optreset;        // reset getopt
-char   *optarg;          // argument associated with option
-
-#define   BADCH       (int)'?'
-#define   BADARG      (int)':'
-#define   EMSG        ""
-
-//
-// getopt --
-//   Parse argc/argv argument vector.
-//
-int
-getopt(
-   int             nargc,
-   char * const   *nargv,
-   const char     *ostr
-)
-{
-   static char *place = EMSG; // option letter processing
-   char *oli;                 // option letter list index
-
-   if (optreset || !*place)
-   {
-      // update scanning pointer
-      optreset = 0;
-      if (optind >= nargc || *(place = nargv[optind]) != '-')
-      {
-         place = EMSG;
-         return -1;
-      }
-      if (place[1] && *++place == '-')
-      {
-         // found "--"
-         ++optind;
-         place = EMSG;
-         return -1;
-      }
-   }
-
-   // option letter okay?
-   if ((optopt = (int)*place++) == (int)':' ||
-      !(oli = strchr(ostr, optopt)))
-   {
-      //
-      // if the user didn't specify '-' as an option,
-      // assume it means -1.
-      //
-      if (optopt == (int)'-')
-         return -1;
-      if (!*place)
-         ++optind;
-      if (opterr && *ostr != ':')
-         fprintf(stderr, "%s: illegal option -- %c\n", nargv[0], optopt);
-      return BADCH;
-   }
-
-   if (*++oli != ':')
-   {
-      // don't need argument
-      optarg = NULL;
-      if (!*place)
-         ++optind;
-   }
-   else
-   {
-      // need an argument
-      if (*place) // no white space
-         optarg = place;
-      else if (nargc <= ++optind)
-      {
-         // no arg
-         place = EMSG;
-         if (*ostr == ':')
-            return BADARG;
-         if (opterr)
-         {
-            fprintf(stderr, "%s: option requires an argument -- %c\n",
-               nargv[0], optopt);
-         }
-         return BADCH;
-      }
-      else // white space
-         optarg = nargv[optind];
-      place = EMSG;
-      ++optind;
-   }
-
-   return optopt; // dump back option letter
-}

+ 0 - 64
getopt.h

@@ -1,64 +0,0 @@
-/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
-//
-// Copyright (c) 1987, 1993, 1994
-//   The Regents of the University of California. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// 1. Redistributions of source code must retain the above copyright
-//    notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-//    notice, this list of conditions and the following disclaimer in the
-//    documentation and/or other materials provided with the distribution.
-// 3. Neither the name of the University nor the names of its contributors
-//    may be used to endorse or promote products derived from this software
-//    without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-//
-
-#ifndef GETOPT_H
-#define GETOPT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define opterr     PAL_opterr
-#define optind     PAL_optind
-#define optopt     PAL_optopt
-#define optreset   PAL_optreset
-#define optarg     PAL_optarg
-#define getopt     PAL_getopt
-
-extern int     opterr;
-extern int     optind;
-extern int     optopt;
-extern int     optreset;
-extern char   *optarg;
-
-int
-getopt(
-   int             nargc,
-   char * const   *nargv,
-   const char     *ostr
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 1 - 1
global.h

@@ -550,8 +550,8 @@ typedef struct tagPOISONSTATUS
 
 typedef enum tagMUSICTYPE
 {
-	MUSIC_RIX,
 	MUSIC_MIDI,
+	MUSIC_RIX,
 	MUSIC_MP3,
 	MUSIC_OGG,
 	MUSIC_SDLCD

Makefile.gph → gph/Makefile.gph


+ 1 - 0
gph/README.txt

@@ -0,0 +1 @@
+This port should be updated for SDL2 and newly changes in source code.

+ 2 - 10
midi.h

@@ -45,16 +45,8 @@ MIDI_CheckLoop(
 
 #else
 
-static VOID
-MIDI_Play(
-   INT       iNumRIX,
-   BOOL      fLoop
-) {}
-
-static VOID
-MIDI_CheckLoop(
-   VOID
-) {}
+# define MIDI_Play(iNumRIX, fLoop)
+# define MIDI_CheckLoop()
 
 #endif
 

+ 2 - 2
palcfg.c

@@ -397,7 +397,7 @@ PAL_SaveConfig(
 	VOID
 )
 {
-	static const char *music_types[] = { "RIX", "MIDI", "MP3", "OGG", "RAW" };
+	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");
@@ -421,7 +421,7 @@ PAL_SaveConfig(
 		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_VOLUME), gConfig.iVolume); fputs(buf, fp);
+		sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_VOLUME), gConfig.iVolume * 100 / SDL_MIX_MAXVOLUME); 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);
 

Makefile.psp → psp/Makefile.psp


+ 1 - 0
psp/README.txt

@@ -0,0 +1 @@
+This port should be updated for SDL2 and newly changes in source code.

input_PSP.c → psp/input_PSP.c


main_PSP.c → psp/main_PSP.c


File diff suppressed because it is too large
+ 0 - 1203
sdlpal.dev


File diff suppressed because it is too large
+ 0 - 2808
sdlpal.tgt


+ 0 - 43
sdlpal.wpj

@@ -1,43 +0,0 @@
-40
-projectIdent
-0
-VpeMain
-1
-WRect
-832
-273
-7680
-9147
-2
-MProject
-3
-MCommand
-0
-4
-MCommand
-0
-1
-5
-WFileName
-10
-sdlpal.tgt
-6
-WVList
-1
-7
-VComponent
-8
-WRect
-192
-22
-5632
-4141
-0
-0
-9
-WFileName
-10
-sdlpal.tgt
-75
-89
-7

+ 26 - 0
unix/Makefile

@@ -0,0 +1,26 @@
+# General makefile for generic unix & linux platforms
+
+TARGET = sdlpal
+
+HOST =
+
+CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../liboggvorbis/src/*.c) $(wildcard ../*.c)
+CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp)
+OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
+
+CCFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_CLASSIC -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
+CXXFLAGS = $(CCFLAGS) -std=c++11 `fltk-config --cxxflags`
+CFLAGS = $(CCFLAGS) -std=gnu99 `fltk-config --cflags`
+LDFLAGS = `sdl2-config --libs` `fltk-config --ldflags` -lstdc++ -lm
+
+$(TARGET): $(OBJFILES)
+	$(HOST)g++ $(OBJFILES) -o $(TARGET) $(LDFLAGS)
+
+%.o: %.c
+	$(HOST)gcc $(CFLAGS) -c $< -o $@
+
+%.o: %.cpp
+	$(HOST)gcc $(CXXFLAGS) -c $< -o $@
+
+clean:
+	rm -f $(TARGET)

+ 254 - 0
unix/unix.cpp

@@ -0,0 +1,254 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../global.h"
+#include "../../util.h"
+#include "../../palcfg.h"
+
+#ifndef PAL_NO_LAUNCH_UI
+
+#include <Fl/Fl.h>
+#include <Fl/Fl_Window.h>
+#include <Fl/Fl_Box.h>
+#include <Fl/Fl_Button.h>
+#include <Fl/Fl_Check_Button.h>
+#include <Fl/Fl_Radio_Round_Button.h>
+#include <Fl/Fl_Hor_Value_Slider.h>
+#include <Fl/Fl_Input.h>
+#include <Fl/Fl_Int_Input.h>
+#include <Fl/Fl_Choice.h>
+
+struct {
+   Fl_Input* gamepath;
+   Fl_Radio_Round_Button* cht;
+   Fl_Radio_Round_Button* chs;
+   Fl_Input* msgfile;
+   Fl_Check_Button* font;
+   Fl_Check_Button* touch;
+   Fl_Check_Button* aspect;
+   Fl_Check_Button* fullscreen;
+   Fl_Choice* cd;
+   Fl_Choice* bgm;
+   Fl_Choice* opl;
+   Fl_Int_Input* samplerate;
+   Fl_Check_Button* stereo;
+   Fl_Int_Input* oplrate;
+   Fl_Check_Button* surround;
+   Fl_Int_Input* buffer;
+   Fl_Hor_Value_Slider* quality;
+   Fl_Hor_Value_Slider* volume;
+} gWidgets;
+
+struct {
+   const char* title;
+   const char* language;
+   const char* display;
+   const char* audio;
+   const char* gamepath;
+   const char* cht;
+   const char* chs;
+   const char* msgfile;
+   const char* font;
+   const char* touch;
+   const char* aspect;
+   const char* fullscreen;
+   const char* cd;
+   const char* bgm;
+   const char* opl;
+   const char* samplerate;
+   const char* stereo;
+   const char* oplrate;
+   const char* surround;
+   const char* buffer;
+   const char* quality;
+   const char* volume;
+   const char* exit;
+   const char* launch;
+   const char* def;
+} gLabels[3] = {
+   { "SDLPAL Launcher", "Game language", "Display", "Audio", "Game resource path:",
+     "&Traditional Chinese", "&Simplified Chinese", "Message file:", "Use &embedded font",
+     "Use touc&h overlay", "&Keep aspect ratio", "&Full screen", "&CD type:", "&BGM type:",
+     "&OPL type:", "Sample rate:", "Ste&reo", "OPL rate:", "Surround O&PL", "Buffer:",
+     "Quality:", "Volume:", "E&xit", "&Launch game", "&Default" },
+   { "SDLPAL 启动器", "游戏语言设置", "显示设置", "音频设置", "游戏资源目录:",
+     "繁体中文(&T)", "简体中文(&S)", "语言文件:", "使用游戏资源内嵌字体(&E)",
+     "启用触屏辅助(&H)", "保持纵横比(&K)", "全屏模式(&F)", "&CD 音源:", "&BGM 音源:",
+     "&OPL 类型:", "采样率:", "立体声(&R)", "OPL 采样率:", "环绕声 O&PL", "缓冲区:",
+     "质量:", "音量:", "退出(&X)", "启动游戏(&L)", "默认设置(&D)" },
+   { "SDLPAL 啟動器", "遊戲語言設置", "顯示設定", "音訊設定", "遊戲資源目錄:",
+     "繁體中文(&T)", "簡體中文(&S)", "語言檔:", "使用遊戲資源內嵌字體(&E)",
+     "啟用觸屏輔助(&H)", "保持縱橫比(&K)", "全屏模式(&F)", "&CD 音源:", "&BGM 音源:",
+     "&OPL 類型:", "取樣速率:", "立體聲(&R)", "OPL 取樣速率:", "環繞聲 O&PL", "緩衝區:",
+     "品質:", "音量:", "退出(&X)", "啟動遊戲(&L)", "默認設定(&D)" },
+};
+
+void InitControls()
+{
+   char buffer[64];
+   gWidgets.gamepath->value(gConfig.pszGamePath);
+   gWidgets.cht->value(gConfig.uCodePage == CP_BIG5 ? 1 : 0);
+   gWidgets.chs->value(gConfig.uCodePage == CP_GBK ? 1 : 0);
+   gWidgets.msgfile->value(gConfig.pszMsgFile);
+   gWidgets.font->value(gConfig.fUseEmbeddedFonts ? 1 : 0);
+   gWidgets.touch->value(gConfig.fUseTouchOverlay ? 1 : 0);
+   gWidgets.aspect->value(gConfig.fKeepAspectRatio ? 1 : 0);
+   gWidgets.fullscreen->value(gConfig.fFullScreen ? 1 : 0);
+   gWidgets.cd->value(gConfig.eCDType - MUSIC_MP3);
+   gWidgets.bgm->value(gConfig.eMusicType - MUSIC_RIX);
+   gWidgets.stereo->value(gConfig.iAudioChannels == 2 ? 1 : 0);
+   sprintf(buffer, "%d", gConfig.iSampleRate); gWidgets.samplerate->value(buffer);
+   gWidgets.opl->value(gConfig.eOPLType);
+   sprintf(buffer, "%d", gConfig.iOPLSampleRate); gWidgets.oplrate->value(buffer);
+   gWidgets.surround->value(gConfig.fUseSurroundOPL ? 1 : 0);
+   sprintf(buffer, "%d", gConfig.wAudioBufferSize); gWidgets.buffer->value(buffer);
+   gWidgets.quality->value(gConfig.iResampleQuality);
+   gWidgets.volume->value(gConfig.iVolume * 100 / SDL_MIX_MAXVOLUME);
+}
+
+void SaveControls()
+{
+   free(gConfig.pszGamePath);
+   gConfig.pszGamePath = strlen(gWidgets.gamepath->value()) ? strdup(gWidgets.gamepath->value()) : nullptr;
+   free(gConfig.pszMsgFile);
+   gConfig.pszMsgFile = strlen(gWidgets.msgfile->value()) ? strdup(gWidgets.msgfile->value()) : nullptr;
+   gConfig.uCodePage = (gWidgets.cht->value() ? CP_BIG5 : CP_GBK);
+   gConfig.fUseEmbeddedFonts = gWidgets.font->value();
+   gConfig.fUseTouchOverlay = gWidgets.touch->value();
+   gConfig.fKeepAspectRatio = gWidgets.aspect->value();
+   gConfig.fFullScreen = gWidgets.fullscreen->value();
+   gConfig.eCDType = (MUSICTYPE)(gWidgets.cd->value() + MUSIC_MP3);
+   gConfig.eMusicType = (MUSICTYPE)(gWidgets.bgm->value() + MUSIC_RIX);
+   gConfig.iAudioChannels = gWidgets.stereo->value() ? 2 : 1;
+   gConfig.iSampleRate = atoi(gWidgets.samplerate->value());
+   gConfig.eOPLType = (OPLTYPE)gWidgets.opl->value();
+   gConfig.iOPLSampleRate = atoi(gWidgets.oplrate->value());
+   gConfig.fUseSurroundOPL = gWidgets.surround->value();
+   gConfig.wAudioBufferSize = atoi(gWidgets.buffer->value());
+   gConfig.iResampleQuality = (int)gWidgets.quality->value();
+   gConfig.iVolume = (int)gWidgets.volume->value() * SDL_MIX_MAXVOLUME / 100;
+   gConfig.fLaunchSetting = FALSE;
+}
+
+int GetLanguage()
+{
+   auto lang = getenv("LANG");
+   if (!lang) return 0;
+   if (strncasecmp(lang, "zh_", 3) == 0)
+   {
+      if (strncasecmp(lang + 3, "hans", 4) == 0 || strncasecmp(lang + 3, "CN", 2) == 0 || strncasecmp(lang + 3, "SG", 2) == 0)
+         return 1;
+      else
+         return 2;
+   }
+   else
+      return 0;
+}
+
+Fl_Window* InitWindow()
+{
+   int lang = GetLanguage();
+   Fl_Window* window = new Fl_Window(640, 400, gLabels[lang].title);
+
+   (gWidgets.gamepath = new Fl_Input(160, 9, 475, 22, gLabels[lang].gamepath))->value(gConfig.pszGamePath);
+
+   (new Fl_Box(FL_BORDER_BOX, 5, 70, 310, 100, gLabels[lang].language))->align(FL_ALIGN_TOP);
+   gWidgets.cht = new Fl_Radio_Round_Button(10, 80, 160, 20, gLabels[lang].cht);
+   gWidgets.chs = new Fl_Radio_Round_Button(10, 110, 160, 20, gLabels[lang].chs);
+   (gWidgets.msgfile = new Fl_Input(109, 139, 196, 22, gLabels[lang].msgfile))->value(gConfig.pszMsgFile);
+
+   (new Fl_Box(FL_BORDER_BOX, 325, 70, 310, 100, gLabels[lang].display))->align(FL_ALIGN_TOP);
+   gWidgets.font = new Fl_Check_Button(330, 80, 160, 20, gLabels[lang].font);
+   gWidgets.touch = new Fl_Check_Button(330, 110, 160, 20, gLabels[lang].touch);
+   gWidgets.aspect = new Fl_Check_Button(330, 140, 160, 20, gLabels[lang].aspect);
+   gWidgets.fullscreen = new Fl_Check_Button(520, 140, 120, 20, gLabels[lang].fullscreen);
+
+   (new Fl_Box(FL_BORDER_BOX, 5, 210, 630, 110, gLabels[lang].audio))->align(FL_ALIGN_TOP);
+   (gWidgets.cd = new Fl_Choice(84, 219, lang ? 100 : 120, 22, gLabels[lang].cd))->add("MP3|OGG");
+   (gWidgets.bgm = new Fl_Choice(285, 219, 60, 22, gLabels[lang].bgm))->add("RIX|MP3|OGG");
+   gWidgets.stereo = new Fl_Check_Button(365, 220, 60, 20, gLabels[lang].stereo);
+   gWidgets.samplerate = new Fl_Int_Input(570, 219, 60, 22, gLabels[lang].samplerate);
+   (gWidgets.opl = new Fl_Choice(84, 249, lang ? 100 : 120, 22, gLabels[lang].opl))->add("DOSBOX|MAME|DOSBOXNEW");
+   gWidgets.oplrate = new Fl_Int_Input(285, 249, 60, 22, gLabels[lang].oplrate);
+   gWidgets.surround = new Fl_Check_Button(365, 250, 60, 20, gLabels[lang].surround);
+   gWidgets.buffer = new Fl_Int_Input(570, 249, 60, 22, gLabels[lang].buffer);
+
+   gWidgets.quality = new Fl_Hor_Value_Slider(72, 289, 230, 22, gLabels[lang].quality);
+   gWidgets.quality->align(FL_ALIGN_LEFT);
+   gWidgets.quality->bounds(0, 4);
+   gWidgets.quality->precision(0);
+
+   gWidgets.volume = new Fl_Hor_Value_Slider(400, 289, 230, 22, gLabels[lang].volume);
+   gWidgets.volume->align(FL_ALIGN_LEFT);
+   gWidgets.volume->bounds(0, 100);
+   gWidgets.volume->precision(0);
+
+   (new Fl_Button(5, 370, 120, 24, gLabels[lang].exit))->callback([](Fl_Widget* ctrl, void* window) {
+      if (ctrl->when() == FL_WHEN_RELEASE)
+         static_cast<Fl_Window*>(window)->hide();
+   }, window);
+
+   (new Fl_Button(260, 370, 120, 24, gLabels[lang].launch))->callback([](Fl_Widget* ctrl, void* window) {
+      if (ctrl->when() == FL_WHEN_RELEASE) {
+         SaveControls();
+         PAL_SaveConfig();
+         static_cast<Fl_Window*>(window)->hide();
+      }
+   }, window);
+
+   (new Fl_Button(515, 370, 120, 24, gLabels[lang].def))->callback([](Fl_Widget*) { PAL_LoadConfig(FALSE); InitControls(); });
+
+   window->end();
+
+   InitControls();
+
+   return window;
+}
+
+#endif
+
+BOOL
+UTIL_GetScreenSize(
+   DWORD *pdwScreenWidth,
+   DWORD *pdwScreenHeight
+)
+{
+   return pdwScreenWidth && pdwScreenHeight && *pdwScreenWidth && *pdwScreenHeight;
+}
+
+BOOL
+UTIL_IsAbsolutePath(
+   LPCSTR lpszFileName
+)
+{
+   return lpszFileName && *lpszFileName == '/';
+}
+
+INT
+UTIL_Platform_Init(
+   int argc,
+   char* argv[]
+)
+{
+#ifndef PAL_NO_LAUNCH_UI
+   if (gConfig.fLaunchSetting)
+   {
+      Fl_Window *window = InitWindow();
+      window->show(argc, argv);
+      Fl::run();
+      Fl::flush();
+      delete window;
+   }
+#else
+   gConfig.fLaunchSetting = FALSE;
+#endif
+   return 0;
+}
+
+VOID
+UTIL_Platform_Quit(
+   VOID
+)
+{
+}

+ 14 - 0
util.c

@@ -26,6 +26,7 @@
 #include "input.h"
 #include "global.h"
 #include "palcfg.h"
+#include <errno.h>
 
 #include "midi.h"
 #if SDL_VERSION_ATLEAST(2, 0, 0)
@@ -33,6 +34,18 @@
 #include "SDL_messagebox.h"
 #endif
 
+long
+flength(
+   FILE *fp
+)
+{
+   long old_pos = ftell(fp), length;
+   if (old_pos == -1) return -1;
+   if (fseek(fp, 0, SEEK_END) == -1) return -1;
+   length = ftell(fp); fseek(fp, old_pos, SEEK_SET);
+   return length;
+}
+
 void
 trim(
    char *str
@@ -553,6 +566,7 @@ UTIL_Platform_Init(
    char* argv[]
 )
 {
+   gConfig.fLaunchSetting = FALSE;
    return 0;
 }
 

+ 5 - 4
util.h

@@ -32,6 +32,11 @@ extern "C"
 {
 #endif
 
+long
+flength(
+   FILE *fp
+);
+
 void
 trim(
    char *str
@@ -134,15 +139,11 @@ UTIL_IsAbsolutePath(
 	LPCSTR  lpszFileName
 );
 
-#if PAL_HAS_TOUCH
-
 BOOL
 UTIL_TouchEnabled(
    VOID
 );
 
-#endif
-
 INT
 UTIL_Platform_Init(
    int argc,

Makefile.wii → wii/Makefile.wii


+ 1 - 0
wii/README.txt

@@ -0,0 +1 @@
+This port should be updated for SDL2 and newly changes in source code.

+ 6 - 0
win32/sdlpal.sln

@@ -8,13 +8,19 @@ EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
+		Debug|x64 = Debug|x64
 		Release|Win32 = Release|Win32
+		Release|x64 = Release|x64
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{837BDF47-9375-4C30-866B-07E262E94A01}.Debug|Win32.ActiveCfg = Debug|Win32
 		{837BDF47-9375-4C30-866B-07E262E94A01}.Debug|Win32.Build.0 = Debug|Win32
+		{837BDF47-9375-4C30-866B-07E262E94A01}.Debug|x64.ActiveCfg = Debug|x64
+		{837BDF47-9375-4C30-866B-07E262E94A01}.Debug|x64.Build.0 = Debug|x64
 		{837BDF47-9375-4C30-866B-07E262E94A01}.Release|Win32.ActiveCfg = Release|Win32
 		{837BDF47-9375-4C30-866B-07E262E94A01}.Release|Win32.Build.0 = Release|Win32
+		{837BDF47-9375-4C30-866B-07E262E94A01}.Release|x64.ActiveCfg = Release|x64
+		{837BDF47-9375-4C30-866B-07E262E94A01}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 103 - 4
win32/sdlpal.vcxproj

@@ -5,10 +5,18 @@
       <Configuration>Debug</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
     <ProjectConfiguration Include="Release|Win32">
       <Configuration>Release</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{837BDF47-9375-4C30-866B-07E262E94A01}</ProjectGuid>
@@ -20,11 +28,21 @@
     <UseOfMfc>false</UseOfMfc>
     <PlatformToolset>v120_xp</PlatformToolset>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseOfMfc>false</UseOfMfc>
+    <PlatformToolset>v120_xp</PlatformToolset>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
     <UseOfMfc>false</UseOfMfc>
     <PlatformToolset>v120_xp</PlatformToolset>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseOfMfc>false</UseOfMfc>
+    <PlatformToolset>v120_xp</PlatformToolset>
+  </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
   </ImportGroup>
@@ -32,23 +50,41 @@
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
     <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+  </ImportGroup>
   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
     <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+  </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup>
     <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
     <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
     <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
-    <LibraryPath>..\SDL2\lib\x86;..\SDL2\VisualC\$(Platform)\$(Configuration)\;$(LibraryPath)</LibraryPath>
+    <LibraryPath>..\SDL2\VisualC\$(Platform)\$(Configuration)\;..\SDL2\lib\x86;$(LibraryPath)</LibraryPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <LibraryPath>..\SDL2\VisualC\$(Platform)\$(Configuration)\;..\SDL2\lib\x64;$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
-    <LibraryPath>..\SDL2\lib\x86;..\SDL2\VisualC\$(Platform)\$(Configuration)\;$(LibraryPath)</LibraryPath>
+    <LibraryPath>..\SDL2\VisualC\$(Platform)\$(Configuration)\;..\SDL2\lib\x86;$(LibraryPath)</LibraryPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <LibraryPath>..\SDL2\VisualC\$(Platform)\$(Configuration)\;..\SDL2\lib\x64;$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <Midl>
@@ -82,6 +118,36 @@
     </Link>
     <Bscmake />
   </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Midl>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MkTypLibCompatible>true</MkTypLibCompatible>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <TypeLibraryName>.\Release/sdlpal_sdl2.tlb</TypeLibraryName>
+      <HeaderFileName>
+      </HeaderFileName>
+    </Midl>
+    <ClCompile>
+      <AdditionalIncludeDirectories>..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>PAL_HAS_PLATFORM_SPECIFIC_UTILS;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <WarningLevel>Level3</WarningLevel>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <ResourceCompile>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <Culture>0x0804</Culture>
+    </ResourceCompile>
+    <Link>
+      <AdditionalDependencies>winmm.lib;sdl2.lib;sdl2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+    <Bscmake />
+  </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <Midl>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -116,14 +182,49 @@
     </Link>
     <Bscmake />
   </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Midl>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MkTypLibCompatible>true</MkTypLibCompatible>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <TypeLibraryName>.\Debug/sdlpal_sdl2.tlb</TypeLibraryName>
+      <HeaderFileName>
+      </HeaderFileName>
+    </Midl>
+    <ClCompile>
+      <AdditionalIncludeDirectories>..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>PAL_HAS_PLATFORM_SPECIFIC_UTILS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <WarningLevel>Level3</WarningLevel>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <Optimization>Disabled</Optimization>
+    </ClCompile>
+    <ResourceCompile>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <Culture>0x0804</Culture>
+    </ResourceCompile>
+    <Link>
+      <AdditionalDependencies>winmm.lib;sdl2.lib;sdl2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+    </Link>
+    <Bscmake />
+  </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="..\adplug\adlibemu.c" />
     <ClCompile Include="..\adplug\dbemuopl.cpp" />
     <ClCompile Include="..\adplug\dbopl.cpp">
       <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AnySuitable</InlineFunctionExpansion>
+      <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AnySuitable</InlineFunctionExpansion>
       <IntrinsicFunctions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</IntrinsicFunctions>
+      <IntrinsicFunctions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</IntrinsicFunctions>
       <FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Speed</FavorSizeOrSpeed>
+      <FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Speed</FavorSizeOrSpeed>
       <OmitFramePointers Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</OmitFramePointers>
+      <OmitFramePointers Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</OmitFramePointers>
     </ClCompile>
     <ClCompile Include="..\adplug\demuopl.cpp" />
     <ClCompile Include="..\battle.c" />
@@ -131,7 +232,6 @@
     <ClCompile Include="..\fight.c" />
     <ClCompile Include="..\font.c" />
     <ClCompile Include="..\game.c" />
-    <ClCompile Include="..\getopt.c" />
     <ClCompile Include="..\global.c" />
     <ClCompile Include="..\input.c" />
     <ClCompile Include="..\itemmenu.c" />
@@ -223,7 +323,6 @@
     <ClInclude Include="..\font.h" />
     <ClInclude Include="..\fontglyph.h" />
     <ClInclude Include="..\game.h" />
-    <ClInclude Include="..\getopt.h" />
     <ClInclude Include="..\global.h" />
     <ClInclude Include="..\input.h" />
     <ClInclude Include="..\itemmenu.h" />

+ 0 - 6
win32/sdlpal.vcxproj.filters

@@ -71,9 +71,6 @@
     <ClCompile Include="..\game.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\getopt.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\global.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -334,9 +331,6 @@
     <ClInclude Include="..\game.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\getopt.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\global.h">
       <Filter>Header Files</Filter>
     </ClInclude>

+ 3 - 3
win32/win32.cpp

@@ -110,7 +110,7 @@ void SaveSettings(HWND hwndDlg, BOOL fWriteFile)
 	gConfig.iAudioChannels = IsDlgButtonChecked(hwndDlg, IDC_STEREO) ? 2 : 1;
 	gConfig.iSampleRate = GetDlgItemInt(hwndDlg, IDC_SAMPLERATE, nullptr, FALSE);
 	gConfig.wAudioBufferSize = GetDlgItemInt(hwndDlg, IDC_AUDIOBUFFER, nullptr, FALSE);
-	gConfig.iVolume = TrackBar_GetPos(hwndDlg, IDC_VOLUME);
+	gConfig.iVolume = TrackBar_GetPos(hwndDlg, IDC_VOLUME) * SDL_MIX_MAXVOLUME / 100;
 	gConfig.iResampleQuality = TrackBar_GetPos(hwndDlg, IDC_QUALITY);
 	if (gConfig.eMusicType == MUSIC_RIX)
 	{
@@ -158,7 +158,7 @@ void ResetControls(HWND hwndDlg)
 	TrackBar_SetRange(hwndDlg, IDC_QUALITY, 0, 4, FALSE);
 	TrackBar_SetPos(hwndDlg, IDC_QUALITY, gConfig.iResampleQuality, TRUE);
 	TrackBar_SetRange(hwndDlg, IDC_VOLUME, 0, 100, FALSE);
-	TrackBar_SetPos(hwndDlg, IDC_VOLUME, gConfig.iVolume, TRUE);
+	TrackBar_SetPos(hwndDlg, IDC_VOLUME, gConfig.iVolume * 100 / SDL_MIX_MAXVOLUME, TRUE);
 }
 
 INT_PTR InitProc(HWND hwndDlg, HWND hwndCtrl, LPARAM lParam)
@@ -168,8 +168,8 @@ INT_PTR InitProc(HWND hwndDlg, HWND hwndCtrl, LPARAM lParam)
 	ComboBox_AddString(hwndDlg, IDC_CD, TEXT("MP3"));
 	ComboBox_AddString(hwndDlg, IDC_CD, TEXT("OGG"));
 
-	ComboBox_AddString(hwndDlg, IDC_BGM, TEXT("RIX"));
 	ComboBox_AddString(hwndDlg, IDC_BGM, TEXT("MIDI"));
+	ComboBox_AddString(hwndDlg, IDC_BGM, TEXT("RIX"));
 	ComboBox_AddString(hwndDlg, IDC_BGM, TEXT("MP3"));
 	ComboBox_AddString(hwndDlg, IDC_BGM, TEXT("OGG"));
 

+ 4 - 9
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -49,16 +49,11 @@ void SDLPal::MainPage::LoadControlContents()
 	tsSurroundOPL->IsOn = (gConfig.fUseSurroundOPL == TRUE);
 	tsTouchOverlay->IsOn = (gConfig.fUseTouchOverlay == TRUE);
 
-	slVolume->Value = gConfig.iVolume;
+	slVolume->Value = gConfig.iVolume * 100 / SDL_MIX_MAXVOLUME;
 	slQuality->Value = gConfig.iResampleQuality;
 
 	cbCD->SelectedIndex = (gConfig.eCDType == MUSIC_MP3) ? 0 : 1;
-	if (gConfig.eMusicType == MUSIC_OGG)
-		cbBGM->SelectedIndex = 2;
-	else if (gConfig.eMusicType == MUSIC_MP3)
-		cbBGM->SelectedIndex = 1;
-	else
-		cbBGM->SelectedIndex = 0;
+	cbBGM->SelectedIndex = (gConfig.eMusicType >= MUSIC_RIX && gConfig.eMusicType <= MUSIC_OGG) ? (gConfig.eMusicType - MUSIC_RIX) : 0;
 	cbOPL->SelectedIndex = (int)gConfig.eOPLType;
 
 	if (gConfig.iSampleRate <= 11025)
@@ -102,12 +97,12 @@ void SDLPal::MainPage::SaveControlContents()
 	gConfig.fUseSurroundOPL = tsSurroundOPL->IsOn ? TRUE : FALSE;
 	gConfig.fUseTouchOverlay = tsTouchOverlay->IsOn ? TRUE : FALSE;
 
-	gConfig.iVolume = (int)slVolume->Value;
+	gConfig.iVolume = (int)slVolume->Value * SDL_MIX_MAXVOLUME / 100;
 	gConfig.iResampleQuality = (int)slQuality->Value;
 	gConfig.uCodePage = tsLanguage->IsOn ? CP_GBK : CP_BIG5;
 
 	gConfig.eCDType = (MUSICTYPE)(MUSIC_MP3 + cbCD->SelectedIndex);
-	gConfig.eMusicType = (cbBGM->SelectedIndex >= 1) ? (MUSICTYPE)(MUSIC_MIDI + cbBGM->SelectedIndex) : MUSIC_RIX;
+	gConfig.eMusicType = (MUSICTYPE)(MUSIC_RIX + cbBGM->SelectedIndex);
 	gConfig.eOPLType = (OPLTYPE)cbOPL->SelectedIndex;
 
 	gConfig.iSampleRate = wcstoul(static_cast<Platform::String^>(static_cast<ComboBoxItem^>(cbSampleRate->SelectedItem)->Content)->Data(), nullptr, 10);

+ 1 - 1
winrt/SDLPal.Common/Strings/en/Resources.resw

@@ -227,7 +227,7 @@ You can use the main menu option inside the game to return to this page.</value>
     <value>Sample rate of OPL simulator</value>
   </data>
   <data name="Publisher" xml:space="preserve">
-    <value>SDLPAL developing team</value>
+    <value>SDLPAL development team</value>
   </data>
   <data name="Quality.Header" xml:space="preserve">
     <value>Audio quality</value>

+ 0 - 2
winrt/SDLPal.UWP/SDLPal.Core.vcxproj

@@ -238,7 +238,6 @@
     <ClInclude Include="..\..\font.h" />
     <ClInclude Include="..\..\fontglyph.h" />
     <ClInclude Include="..\..\game.h" />
-    <ClInclude Include="..\..\getopt.h" />
     <ClInclude Include="..\..\global.h" />
     <ClInclude Include="..\..\input.h" />
     <ClInclude Include="..\..\itemmenu.h" />
@@ -345,7 +344,6 @@
     <ClCompile Include="..\..\fight.c" />
     <ClCompile Include="..\..\font.c" />
     <ClCompile Include="..\..\game.c" />
-    <ClCompile Include="..\..\getopt.c" />
     <ClCompile Include="..\..\global.c" />
     <ClCompile Include="..\..\input.c" />
     <ClCompile Include="..\..\itemmenu.c" />

+ 0 - 6
winrt/SDLPal.UWP/SDLPal.Core.vcxproj.filters

@@ -302,9 +302,6 @@
     <ClInclude Include="..\..\game.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\getopt.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\global.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -538,9 +535,6 @@
     <ClCompile Include="..\..\game.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\getopt.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\global.c">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 0 - 2
winrt/SDLPal.Windows/SDLPal.Core.vcxproj

@@ -220,7 +220,6 @@
     <ClInclude Include="..\..\font.h" />
     <ClInclude Include="..\..\fontglyph.h" />
     <ClInclude Include="..\..\game.h" />
-    <ClInclude Include="..\..\getopt.h" />
     <ClInclude Include="..\..\global.h" />
     <ClInclude Include="..\..\input.h" />
     <ClInclude Include="..\..\itemmenu.h" />
@@ -327,7 +326,6 @@
     <ClCompile Include="..\..\fight.c" />
     <ClCompile Include="..\..\font.c" />
     <ClCompile Include="..\..\game.c" />
-    <ClCompile Include="..\..\getopt.c" />
     <ClCompile Include="..\..\global.c" />
     <ClCompile Include="..\..\input.c" />
     <ClCompile Include="..\..\itemmenu.c" />

+ 0 - 6
winrt/SDLPal.Windows/SDLPal.Core.vcxproj.filters

@@ -302,9 +302,6 @@
     <ClInclude Include="..\..\game.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\getopt.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\global.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -538,9 +535,6 @@
     <ClCompile Include="..\..\game.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\getopt.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\global.c">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 0 - 2
winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj

@@ -165,7 +165,6 @@
     <ClInclude Include="..\..\font.h" />
     <ClInclude Include="..\..\fontglyph.h" />
     <ClInclude Include="..\..\game.h" />
-    <ClInclude Include="..\..\getopt.h" />
     <ClInclude Include="..\..\global.h" />
     <ClInclude Include="..\..\input.h" />
     <ClInclude Include="..\..\itemmenu.h" />
@@ -272,7 +271,6 @@
     <ClCompile Include="..\..\fight.c" />
     <ClCompile Include="..\..\font.c" />
     <ClCompile Include="..\..\game.c" />
-    <ClCompile Include="..\..\getopt.c" />
     <ClCompile Include="..\..\global.c" />
     <ClCompile Include="..\..\input.c" />
     <ClCompile Include="..\..\itemmenu.c" />

+ 0 - 6
winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj.filters

@@ -302,9 +302,6 @@
     <ClInclude Include="..\..\game.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\getopt.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\global.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -538,9 +535,6 @@
     <ClCompile Include="..\..\game.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\getopt.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\global.c">
       <Filter>Source Files</Filter>
     </ClCompile>