├── .travis.yml ├── 3ds ├── banner.bin ├── banner.png ├── icon.bin ├── icon.png ├── icon_24x24.png ├── music.wav └── sdlpal.rsf ├── CREDITS.txt ├── English.lproj └── InfoPlist.strings ├── Info.plist ├── Makefile ├── Makefile.3ds ├── Makefile.cygwin ├── Makefile.dingux ├── Makefile.gph ├── Makefile.psp ├── Makefile.sdl2 ├── Makefile.wii ├── Pal.xcodeproj └── project.pbxproj ├── README.txt ├── adplug ├── NOTES │ ├── AUTHORS │ ├── COPYING │ ├── NOTES │ └── README ├── binfile.cpp ├── binfile.h ├── binio.cpp ├── binio.h ├── demuopl.h ├── dosbox_opl.cpp ├── dosbox_opl.h ├── emuopl.cpp ├── emuopl.h ├── fmopl.c ├── fmopl.h ├── fprovide.cpp ├── fprovide.h ├── opl.h ├── player.cpp ├── player.h ├── rix.cpp ├── rix.h ├── surroundopl.cpp └── surroundopl.h ├── android ├── .classpath ├── .project ├── AndroidManifest.xml ├── ant.properties ├── build.properties ├── build.xml ├── default.properties ├── jni │ ├── Android.mk │ ├── Application.mk │ ├── SDL2 │ │ └── README │ └── src │ │ └── Android.mk ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── main.xml │ └── values │ │ └── strings.xml └── src │ ├── com │ └── codeplex │ │ └── sdlpal │ │ └── PalActivity.java │ └── org │ └── libsdl │ └── app │ └── SDLActivity.java ├── ascii.h ├── battle.c ├── battle.h ├── big5font.h ├── common.h ├── data └── overlay.bmp ├── ending.c ├── ending.h ├── fight.c ├── fight.h ├── font.c ├── font.h ├── game.c ├── game.h ├── gbfont.h ├── getopt.c ├── getopt.h ├── global.c ├── global.h ├── gpl.txt ├── input.c ├── input.h ├── input_PSP.c ├── ios ├── SDL2 │ └── README └── SDLPal │ ├── SDLPal.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── SDLPal │ ├── Default-568h@2x.png │ ├── Default.png │ ├── Default@2x.png │ ├── Icon.png │ ├── SDLPal-Info.plist │ └── util.m ├── itemmenu.c ├── itemmenu.h ├── libmad ├── D.dat ├── bit.c ├── bit.h ├── decoder.c ├── decoder.h ├── fixed.c ├── fixed.h ├── frame.c ├── frame.h ├── huffman.c ├── huffman.h ├── imdct_s.dat ├── layer12.c ├── layer12.h ├── layer3.c ├── layer3.h ├── libmad_config.h ├── libmad_global.h ├── mad.h ├── music_mad.c ├── music_mad.h ├── qc_table.dat ├── rq_table.dat ├── sf_table.dat ├── stream.c ├── stream.h ├── synth.c ├── synth.h ├── timer.c └── timer.h ├── magicmenu.c ├── magicmenu.h ├── main.c ├── main.h ├── main_PSP.h ├── map.c ├── map.h ├── midi.c ├── midi.h ├── native_midi ├── native_midi.h ├── native_midi_common.c ├── native_midi_common.h ├── native_midi_macosx.c └── native_midi_win32.c ├── palcommon.c ├── palcommon.h ├── palette.c ├── palette.h ├── play.c ├── play.h ├── private.c ├── res.c ├── res.h ├── rixplay.cpp ├── rixplay.h ├── rngplay.c ├── rngplay.h ├── scene.c ├── scene.h ├── script.c ├── script.h ├── sdlpal.cproj ├── sdlpal.dev ├── sdlpal.dsp ├── sdlpal.icns ├── sdlpal.ico ├── sdlpal.rc ├── sdlpal.sln ├── sdlpal.tgt ├── sdlpal.vcxproj ├── sdlpal.vcxproj.filters ├── sdlpal.wpj ├── sdlpal.xpm ├── sound.c ├── sound.h ├── text.c ├── text.h ├── ui.c ├── ui.h ├── uibattle.c ├── uibattle.h ├── uigame.c ├── uigame.h ├── util.c ├── util.h ├── video.c ├── video.h ├── winphone ├── Assets │ ├── AlignmentGrid.png │ ├── ApplicationIcon.png │ ├── Data │ │ └── README.txt │ └── Tiles │ │ ├── FlipCycleTileLarge.png │ │ ├── FlipCycleTileMedium.png │ │ ├── FlipCycleTileSmall.png │ │ ├── IconicTileMediumLarge.png │ │ └── IconicTileSmall.png ├── SDL2 │ └── README.txt ├── SDLPal.sln ├── SDLPal.vcxproj ├── SDLPal.vcxproj.filters ├── WMAppManifest.xml └── WinPhoneUtil.cpp └── yj1.c /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | script: make 3 | compiler: clang 4 | before_install: 5 | - sudo apt-get update -qq 6 | - sudo apt-get install -qq libsdl1.2-dev 7 | -------------------------------------------------------------------------------- /3ds/banner.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/3ds/banner.bin -------------------------------------------------------------------------------- /3ds/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/3ds/banner.png -------------------------------------------------------------------------------- /3ds/icon.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/3ds/icon.bin -------------------------------------------------------------------------------- /3ds/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/3ds/icon.png -------------------------------------------------------------------------------- /3ds/icon_24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/3ds/icon_24x24.png -------------------------------------------------------------------------------- /3ds/music.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/3ds/music.wav -------------------------------------------------------------------------------- /3ds/sdlpal.rsf: -------------------------------------------------------------------------------- 1 | BasicInfo: 2 | Title : "SDLPAL" 3 | CompanyCode : "00" 4 | ProductCode : "CTR-P-PALD" 5 | ContentType : Application 6 | Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem 7 | 8 | RomFs: 9 | # Specifies the root path of the read only file system to include in the ROM. 10 | RootPath : "" 11 | 12 | TitleInfo: 13 | UniqueId : 0x8848 14 | Category : Application 15 | 16 | CardInfo: 17 | MediaSize : 128MB # 128MB / 256MB / 512MB / 1GB / 2GB / 4GB 18 | MediaType : Card1 # Card1 / Card2 19 | CardDevice : None # NorFlash(Pick this if you use savedata) / None 20 | 21 | 22 | Option: 23 | UseOnSD : true # true if App is to be installed to SD 24 | FreeProductCode : true # Removes limitations on ProductCode 25 | MediaFootPadding : false # If true CCI files are created with padding 26 | EnableCrypt : false # Enables encryption for NCCH and CIA 27 | EnableCompress : true # Compresses exefs code 28 | 29 | AccessControlInfo: 30 | #UseExtSaveData : true 31 | #ExtSaveDataId: 0xff3ff 32 | #UseExtendedSaveDataAccessControl: true 33 | #AccessibleSaveDataIds: [0x101, 0x202, 0x303, 0x404, 0x505, 0x606] 34 | 35 | SystemControlInfo: 36 | SaveDataSize: 128KB 37 | RemasterVersion: 0 38 | StackSize: 0x40000 39 | 40 | # DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely) 41 | 42 | AccessControlInfo: 43 | FileSystemAccess: 44 | - Debug 45 | - DirectSdmc 46 | - DirectSdmcWrite 47 | 48 | IdealProcessor : 0 49 | AffinityMask : 1 50 | 51 | Priority : 16 52 | 53 | MaxCpu : 0x9E # Default 54 | DisableDebug : false 55 | EnableForceDebug : false 56 | CanWriteSharedPage : false 57 | CanUsePrivilegedPriority : false 58 | CanUseNonAlphabetAndNumber : false 59 | PermitMainFunctionArgument : false 60 | CanShareDeviceMemory : false 61 | RunnableOnSleep : false 62 | SpecialMemoryArrange : false 63 | CoreVersion : 2 64 | DescVersion : 2 65 | 66 | ReleaseKernelMajor : "02" 67 | ReleaseKernelMinor : "33" 68 | MemoryType : Application 69 | HandleTableSize: 512 70 | 71 | SystemModeExt : Legacy # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode 72 | CpuSpeed : 268MHz # 268MHz(Default)/804MHz 73 | EnableL2Cache : false # false(default)/true 74 | CanAccessCore2 : false 75 | 76 | IORegisterMapping: 77 | - 1ff50000-1ff57fff 78 | - 1ff70000-1ff77fff 79 | MemoryMapping: 80 | - 1f000000-1f5fffff:r 81 | SystemCallAccess: 82 | ArbitrateAddress: 34 83 | Break: 60 84 | CancelTimer: 28 85 | ClearEvent: 25 86 | ClearTimer: 29 87 | CloseHandle: 35 88 | ConnectToPort: 45 89 | ControlMemory: 1 90 | CreateAddressArbiter: 33 91 | CreateEvent: 23 92 | CreateMemoryBlock: 30 93 | CreateMutex: 19 94 | CreateSemaphore: 21 95 | CreateThread: 8 96 | CreateTimer: 26 97 | DuplicateHandle: 39 98 | ExitProcess: 3 99 | ExitThread: 9 100 | GetCurrentProcessorNumber: 17 101 | GetHandleInfo: 41 102 | GetProcessId: 53 103 | GetProcessIdOfThread: 54 104 | GetProcessIdealProcessor: 6 105 | GetProcessInfo: 43 106 | GetResourceLimit: 56 107 | GetResourceLimitCurrentValues: 58 108 | GetResourceLimitLimitValues: 57 109 | GetSystemInfo: 42 110 | GetSystemTick: 40 111 | GetThreadContext: 59 112 | GetThreadId: 55 113 | GetThreadIdealProcessor: 15 114 | GetThreadInfo: 44 115 | GetThreadPriority: 11 116 | MapMemoryBlock: 31 117 | OutputDebugString: 61 118 | QueryMemory: 2 119 | ReleaseMutex: 20 120 | ReleaseSemaphore: 22 121 | SendSyncRequest1: 46 122 | SendSyncRequest2: 47 123 | SendSyncRequest3: 48 124 | SendSyncRequest4: 49 125 | SendSyncRequest: 50 126 | SetThreadPriority: 12 127 | SetTimer: 27 128 | SignalEvent: 24 129 | SleepThread: 10 130 | UnmapMemoryBlock: 32 131 | WaitSynchronization1: 36 132 | WaitSynchronizationN: 37 133 | InterruptNumbers: 134 | ServiceAccessControl: 135 | - APT:U 136 | - $hioFIO 137 | - $hostio0 138 | - $hostio1 139 | - ac:u 140 | - boss:U 141 | - cam:u 142 | - ir:rst 143 | - cfg:u 144 | - dlp:FKCL 145 | - dlp:SRVR 146 | - dsp::DSP 147 | - frd:u 148 | - fs:USER 149 | - gsp::Gpu 150 | - hid:USER 151 | - http:C 152 | - mic:u 153 | - ndm:u 154 | - news:s 155 | - nwm::UDS 156 | - ptm:u 157 | - pxi:dev 158 | - soc:U 159 | - gsp::Lcd 160 | - y2r:u 161 | - ldr:ro 162 | - ir:USER 163 | - ir:u 164 | - csnd:SND 165 | - am:u 166 | - ns:s 167 | 168 | SystemControlInfo: 169 | Dependency: 170 | ac: 0x0004013000002402L 171 | am: 0x0004013000001502L 172 | boss: 0x0004013000003402L 173 | camera: 0x0004013000001602L 174 | cecd: 0x0004013000002602L 175 | cfg: 0x0004013000001702L 176 | codec: 0x0004013000001802L 177 | csnd: 0x0004013000002702L 178 | dlp: 0x0004013000002802L 179 | dsp: 0x0004013000001a02L 180 | friends: 0x0004013000003202L 181 | gpio: 0x0004013000001b02L 182 | gsp: 0x0004013000001c02L 183 | hid: 0x0004013000001d02L 184 | http: 0x0004013000002902L 185 | i2c: 0x0004013000001e02L 186 | ir: 0x0004013000003302L 187 | mcu: 0x0004013000001f02L 188 | mic: 0x0004013000002002L 189 | ndm: 0x0004013000002b02L 190 | news: 0x0004013000003502L 191 | nim: 0x0004013000002c02L 192 | nwm: 0x0004013000002d02L 193 | pdn: 0x0004013000002102L 194 | ps: 0x0004013000003102L 195 | ptm: 0x0004013000002202L 196 | ro: 0x0004013000003702L 197 | socket: 0x0004013000002e02L 198 | spi: 0x0004013000002302L 199 | ssl: 0x0004013000002f02L -------------------------------------------------------------------------------- /CREDITS.txt: -------------------------------------------------------------------------------- 1 | SPECIAL THANKS 2 | -------------- 3 | 4 | Many of the ideas of this program are based on documents from PAL 5 | Research Project (http://code.google.com/p/palresearch). 6 | 7 | Portions of the code are based on the work done by Baldur and louyihua. 8 | 9 | getopt.c file is based on source code in OpenBSD. 10 | 11 | This program made extensive use of the following libraries: 12 | 13 | SDL (http://www.libsdl.org/) 14 | Adplug (http://adplug.sourceforge.net/) 15 | SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/) 16 | libmad (http://www.underbit.com/products/mad/) 17 | -------------------------------------------------------------------------------- /English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | sdlpal.icns 11 | CFBundleIdentifier 12 | com.weimingzhi.Pal 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | SDLMain 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Adapted from Makefile for Dingux by Rikku2000 2 | 3 | TARGET = sdlpal 4 | 5 | HOST = 6 | 7 | ADPLUG_FILES = adplug/rix.cpp adplug/player.cpp adplug/binio.cpp \ 8 | adplug/fprovide.cpp adplug/binfile.cpp adplug/dosbox_opl.cpp \ 9 | adplug/fmopl.c adplug/surroundopl.cpp adplug/emuopl.cpp 10 | 11 | LIBMAD_FILES = libmad/bit.c libmad/decoder.c libmad/fixed.c libmad/frame.c \ 12 | libmad/huffman.c libmad/layer12.c libmad/layer3.c libmad/music_mad.c \ 13 | libmad/stream.c libmad/synth.c libmad/timer.c 14 | 15 | FILES = rixplay.cpp text.c font.c itemmenu.c scene.c palcommon.c script.c \ 16 | util.c play.c getopt.c input.c uibattle.c game.c magicmenu.c map.c \ 17 | ending.c uigame.c rngplay.c ui.c global.c main.c fight.c \ 18 | video.c palette.c sound.c res.c battle.c yj1.c 19 | 20 | FILES += $(ADPLUG_FILES) 21 | FILES += $(LIBMAD_FILES) 22 | 23 | CFLAGS = `sdl-config --cflags` -g -Wall -O2 -fno-strict-aliasing 24 | LDFLAGS = `sdl-config --libs` -lstdc++ -lm 25 | 26 | $(TARGET): 27 | $(HOST)gcc $(CFLAGS) -o $(TARGET) $(FILES) $(LDFLAGS) 28 | 29 | clean: 30 | rm -f $(TARGET) 31 | -------------------------------------------------------------------------------- /Makefile.cygwin: -------------------------------------------------------------------------------- 1 | TARGET = sdlpal.exe 2 | 3 | HOST = i686-pc-cygwin- 4 | 5 | SOURCES = . ./adplug 6 | CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c)) 7 | CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp)) 8 | RCFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.rc)) 9 | OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(RCFILES:.rc=.o) 10 | 11 | CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DCYGWIN -DPAL_CLASSIC 12 | CXXFLAGS = $(CFLAGS) 13 | LDFLAGS = `sdl-config --libs` 14 | 15 | $(TARGET): $(OFILES) 16 | $(HOST)g++ $(OFILES) -o $@ $(LDFLAGS) 17 | 18 | %.o: %.c 19 | $(HOST)gcc $(CFLAGS) -c $< -o $@ 20 | 21 | %.o: %.cpp 22 | $(HOST)g++ $(CXXFLAGS) -c $< -o $@ 23 | 24 | %.o: %.rc 25 | windres.exe -i $< --input-format=rc -o $@ -O coff 26 | 27 | clean: 28 | rm -f $(TARGET) $(OFILES) 29 | -------------------------------------------------------------------------------- /Makefile.dingux: -------------------------------------------------------------------------------- 1 | TARGET = sdlpal.dge 2 | 3 | HOST = mipsel-linux-uclibc- 4 | 5 | SOURCES = . ./adplug 6 | CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c)) 7 | CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp)) 8 | OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) 9 | 10 | CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DDINGOO -DPAL_CLASSIC 11 | CXXFLAGS = $(CFLAGS) 12 | LDFLAGS = `sdl-config --libs` 13 | 14 | $(TARGET): $(OFILES) 15 | $(HOST)g++ $(OFILES) -o $@ $(LDFLAGS) 16 | 17 | %.o: %.c 18 | $(HOST)gcc $(CFLAGS) -c $< -o $@ 19 | 20 | %.o: %.cpp 21 | $(HOST)g++ $(CXXFLAGS) -c $< -o $@ 22 | 23 | clean: 24 | rm -f $(TARGET) $(OFILES) 25 | -------------------------------------------------------------------------------- /Makefile.gph: -------------------------------------------------------------------------------- 1 | BUILD_GP2XWIZ = NO 2 | BUILD_CAANOO = YES 3 | 4 | TARGET = sdlpal.gpe 5 | 6 | ifeq ($(BUILD_GP2XWIZ), YES) 7 | HOST = arm-open2x-linux- 8 | DEVICE = -DGP2XWIZ 9 | else 10 | ifeq ($(BUILD_CAANOO), YES) 11 | HOST = arm-gph-linux-gnueabi- 12 | DEVICE = -DCAANOO 13 | endif 14 | endif 15 | 16 | SOURCES = . ./adplug 17 | CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c)) 18 | CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp)) 19 | OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) 20 | 21 | CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DGPH $(DEVICE) -DPAL_CLASSIC 22 | CXXFLAGS = $(CFLAGS) 23 | LDFLAGS = `sdl-config --libs` 24 | 25 | $(TARGET): $(OFILES) 26 | $(HOST)g++ $(OFILES) -o $@ $(LDFLAGS) 27 | 28 | %.o: %.c 29 | $(HOST)gcc $(CFLAGS) -c $< -o $@ 30 | 31 | %.o: %.cpp 32 | $(HOST)g++ $(CXXFLAGS) -c $< -o $@ 33 | 34 | clean: 35 | rm -f $(TARGET) $(OFILES) 36 | -------------------------------------------------------------------------------- /Makefile.psp: -------------------------------------------------------------------------------- 1 | TARGET = sdlpal 2 | 3 | OBJS = adplug/binfile.o adplug/emuopl.o adplug/fprovide.o adplug/rix.o \ 4 | adplug/binio.o adplug/fmopl.o adplug/player.o \ 5 | battle.o getopt.o main.o play.o script.o uigame.o ending.o \ 6 | global.o map.o res.o sound.o util.o fight.o input_PSP.o palcommon.o \ 7 | rixplay.o text.o video.o font.o itemmenu.o palette.o rngplay.o \ 8 | uibattle.o yj1.o game.o magicmenu.o scene.o ui.o \ 9 | libmad/bit.o libmad/decoder.o libmad/fixed.o libmad/frame.o \ 10 | libmad/huffman.o libmad/layer12.o libmad/layer3.o libmad/music_mad.o \ 11 | libmad/stream.o libmad/synth.o libmad/timer.o 12 | 13 | 14 | PSPSDK = $(shell psp-config --pspsdk-path) 15 | 16 | INCDIR = 17 | CFLAGS = -O3 -G0 -Wall -g `$(PSPSDK)/../bin/sdl-config --cflags` -DPSP=1 18 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti `$(PSPSDK)/../bin/sdl-config --cflags` 19 | ASFLAGS = $(CFLAGS) 20 | 21 | LIBDIR = 22 | LIBS = `$(PSPSDK)/../bin/sdl-config --libs` -lstdc++ 23 | 24 | EXTRA_TARGETS = EBOOT.PBP 25 | PSP_EBOOT_TITLE = sdlpal 26 | 27 | BUILD_PRX = 1 28 | PSP_FW_VERSION = 371 29 | 30 | include $(PSPSDK)/lib/build.mak 31 | -------------------------------------------------------------------------------- /Makefile.sdl2: -------------------------------------------------------------------------------- 1 | # Adapted from Makefile for Dingux by Rikku2000 2 | 3 | TARGET = sdlpal 4 | 5 | HOST = 6 | 7 | ADPLUG_FILES = adplug/rix.cpp adplug/player.cpp adplug/binio.cpp \ 8 | adplug/fprovide.cpp adplug/binfile.cpp adplug/dosbox_opl.cpp \ 9 | adplug/fmopl.c adplug/surroundopl.cpp adplug/emuopl.cpp 10 | 11 | LIBMAD_FILES = libmad/bit.c libmad/decoder.c libmad/fixed.c libmad/frame.c \ 12 | libmad/huffman.c libmad/layer12.c libmad/layer3.c libmad/music_mad.c \ 13 | libmad/stream.c libmad/synth.c libmad/timer.c 14 | 15 | FILES = rixplay.cpp text.c font.c itemmenu.c scene.c palcommon.c script.c \ 16 | util.c play.c getopt.c input.c uibattle.c game.c magicmenu.c map.c \ 17 | ending.c uigame.c rngplay.c ui.c global.c main.c fight.c \ 18 | video.c palette.c sound.c res.c battle.c yj1.c 19 | 20 | FILES += $(ADPLUG_FILES) 21 | FILES += $(LIBMAD_FILES) 22 | 23 | CFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing 24 | LDFLAGS = `sdl2-config --libs` -lstdc++ -lm 25 | 26 | $(TARGET): 27 | $(HOST)gcc $(CFLAGS) -o $(TARGET) $(FILES) $(LDFLAGS) 28 | 29 | clean: 30 | rm -f $(TARGET) 31 | -------------------------------------------------------------------------------- /Makefile.wii: -------------------------------------------------------------------------------- 1 | TARGET = boot 2 | 3 | HOST = powerpc-eabi- 4 | 5 | SOURCES = . ./adplug 6 | CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c)) 7 | CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp)) 8 | OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) 9 | 10 | CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DGEKKO -DPAL_CLASSIC 11 | CXXFLAGS = $(CFLAGS) 12 | LDFLAGS = `sdl-config --libs` -DGEKKO -mrvl 13 | 14 | $(TARGET): $(OFILES) 15 | $(HOST)g++ $(OFILES) -o $@.elf $(LDFLAGS) 16 | elf2dol $(TARGET).elf $(TARGET).dol 17 | 18 | %.o: %.c 19 | $(HOST)gcc $(CFLAGS) -c $< -o $@ 20 | 21 | %.o: %.cpp 22 | $(HOST)g++ $(CXXFLAGS) -c $< -o $@ 23 | 24 | clean: 25 | rm -f $(TARGET).elf $(TARGET).dol $(OFILES) 26 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | SDLPAL 2 | ====== 3 | 4 | SDLPAL is an SDL-based reimplementation of the classic Chinese-language RPG 5 | "Xian Jian Qi Xia Zhuan" (also known as PAL or Legend of Sword and Fairy). 6 | 7 | 8 | LICENSE 9 | ======= 10 | 11 | SDLPAL is Copyrighted (c) 2009-2014 Wei Mingzhi . 12 | All rights reserved. 13 | 14 | SDLPAL is distributed under the terms of GNU General Public License, version 3 15 | (or any later version) as published by the Free Software Foundation. See 16 | gpl.txt for details. 17 | 18 | Also see credits.txt for additional credits. 19 | 20 | This program does NOT include any code or data files of the original game, 21 | which is proprietary and copyrighted by SoftStar Inc. 22 | 23 | 24 | COMPILE UNDER WINDOWS 25 | ===================== 26 | 27 | The following compilers/IDEs are supported under Windows: 28 | 29 | 1) Microsoft Visual Studio 2010 or higher 30 | 2) Dev-C++ 4.9.9.2 31 | 3) Open Watcom 1.7 32 | 33 | To compile, open the respective project file (sdlpal.sln, sdlpal.dev, or 34 | sdlpal.wpj). You need to have SDL development files installed. 35 | 36 | 37 | COMPILE UNDER GNU/LINUX 38 | ======================= 39 | 40 | To compile, type: 41 | 42 | make 43 | 44 | You need to have SDL development files installed. The compiled executable 45 | should be generated with the filename 'sdlpal' at the top directory of source 46 | files. 47 | 48 | SDLPAL should also be able to run under other UNIX-like systems, however 49 | it's not tested. 50 | 51 | 52 | COMPILE UNDER MAC OS X 53 | ====================== 54 | 55 | To compile, open the project Pal.xcodeproj with Xcode, and click Build. You 56 | need to have SDL framework installed at /Library/Frameworks. 57 | 58 | The compiled bundle should work as a "universal" binary which works on both 59 | Intel and PowerPC. 60 | 61 | 62 | CLASSIC BUILD 63 | ============= 64 | 65 | By default, SDLPAL uses a revised battle system which is more exciting yet 66 | somewhat harder than the original game. If you prefer the traditional 67 | turn-based battle system, uncomment the following line: 68 | 69 | //#define PAL_CLASSIC 1 70 | 71 | in the file common.h and recompile. This will build a "classic" build which is 72 | 100% the same as the original game. 73 | 74 | 75 | RUNNING THE GAME 76 | ================ 77 | 78 | The data files required for running the game are not included with the source 79 | package due to copyright issues. You must obtain them from the original CD. 80 | 81 | To run the game, copy all the files on the original CD to a directory, then 82 | copy the SDLPAL executable to the same directory, and run the executable. 83 | 84 | Note that the filenames of data files should be in lower-case under GNU/Linux 85 | (or other UNIX-like operating systems). 86 | 87 | 88 | -END OF FILE- 89 | -------------------------------------------------------------------------------- /adplug/NOTES/AUTHORS: -------------------------------------------------------------------------------- 1 | AdPlug is copyright (C) 1999 - 2007 Simon Peter , et al. 2 | All library code is written by Simon Peter, except the parts listed below. 3 | 4 | Additional Credits: 5 | ------------------- 6 | Phil Hassey : 7 | - Player development for the following formats: 8 | - MID: MIDI Audio File Format 9 | - CMF: Creative Music File Format 10 | - SCI: Sierra's AdLib Audio File Format 11 | - LAA: LucasArts AdLib Audio File Format 12 | 13 | Marc Winterrowd : 15 | - M: Origin Music player development 16 | 17 | Tatsuyuki Satoh : 18 | - First YM3812 emulator development 19 | 20 | Ken Silverman : 21 | - Second YM3812 emulator development 22 | 23 | Death Adder : 24 | - provided many file format specifications 25 | - moral support ;) 26 | 27 | Mamiya : 28 | - support for .SAT (early Surprise! Adlib Tracker) files 29 | 30 | Akintunde Omitowoju : 31 | - ROL: AdLib Visual Composer player development 32 | 33 | Nikita V. Kalaganov : 34 | - Player development: 35 | - XAD: shell player and custom module formats 36 | - Protracker loader development: 37 | - SNG: Faust Music Creator 38 | - MAD: Mlat Adlib Tracker 39 | - CFF: BoomTracker 4.0 40 | - DTM: DeFy Adlib Tracker 41 | - Scream Tracker 3 loader development: 42 | - DMO: Twin TrackPlayer 43 | - XMS-Tracker detection support in AMD loader 44 | 45 | Sjoerd van der Berg : 46 | - DRO: DOSBox Raw OPL player development 47 | 48 | Goetz Waschk : 49 | - Mandrake Linux packages 50 | - Red Hat RPM spec files 51 | 52 | Mike Gorchak : 53 | - QNX packages 54 | - QNX qpg file 55 | 56 | Tyler Montbriand : 57 | - AMD64 (x86_64) fixes 58 | - ROL: Added pitch handling 59 | 60 | Borg Number One [ Borg No. One ] : 61 | - Many thanks for the huge amount of work to find the original 62 | author (Andras Molnar) of the LOUDNESS Sound System and managing 63 | to get the sources from him. 64 | 65 | Matthew Gambrell : 66 | - Enhancements to the DRO (DOSBox Raw OPL) format 67 | - Added dual OPL2 and OPL3 support 68 | 69 | BSPAL , 70 | Palxex : 71 | - RIX: Softstar RIX OPL Music Format player development 72 | 73 | Torbjorn Andersson, 74 | Johannes Schickel 'lordhoto' : 75 | - Development of original ADL (Westwood ADL File Format) player in 76 | ScummVM, which has been adapted for AdPlug. 77 | -------------------------------------------------------------------------------- /adplug/NOTES/NOTES: -------------------------------------------------------------------------------- 1 | The source files are based on AdPlug 2.1. All players other than the 2 | RIX player are removed. 3 | 4 | -Wei Mingzhi 5 | 6 | 9/17/2011: Added OPL code from DOSBOX. 7 | -------------------------------------------------------------------------------- /adplug/NOTES/README: -------------------------------------------------------------------------------- 1 | AdPlug - A free AdLib sound player library 2 | Copyright (C) 1999 - 2007 Simon Peter, et al. 3 | 4 | Website: http://adplug.sourceforge.net/ 5 | 6 | Description: 7 | ------------ 8 | AdPlug is a free, multi-platform, hardware independent AdLib sound 9 | player library, mainly written in C++. AdPlug plays sound data, 10 | originally created for the AdLib (OPL2/3) audio board, on top of an 11 | OPL2/3 emulator or by using the real hardware. No OPL2/3 chips are 12 | required for playback. 13 | 14 | Supported platforms: 15 | -------------------- 16 | AdPlug currently is tested to compile and run well on the following 17 | platforms and compilers: 18 | 19 | Platform Operating System Compiler 20 | -------- ---------------- -------- 21 | IA32 - x86 Windows XP MinGW 3.4 22 | MS-DOS 6.22 DJGPP 4.0 23 | Linux 2.6 GCC 4.1 24 | 25 | This list only incorporates platforms on which this release of AdPlug has 26 | been tested successfully. This and/or earlier versions of AdPlug may and did 27 | run on a variety of other platforms as well. It just means they haven't been 28 | explicitly tested for this release. 29 | 30 | The library builds as dynamic and/or static link library, depending on 31 | the facilities provided by the host OS. These are autodetected. 32 | 33 | Prerequisites: 34 | -------------- 35 | AdPlug depends upon the following libraries: 36 | 37 | Library: Version: 38 | -------- -------- 39 | libbinio >= 1.4 40 | 41 | libbinio can be obtained from http://libbinio.sourceforge.net/. 42 | 43 | Installation: 44 | ------------- 45 | Please refer to the INSTALL file for installation instructions. 46 | 47 | CVS: 48 | ---- 49 | If you checked out from CVS, please first run: 50 | 51 | autoreconf --install 52 | 53 | to generate the build cruft and get the configure script. Oh, and did i 54 | mention you need recent versions of autoconf, automake and libtool? 55 | 56 | When building a CVS version, always supply the --enable-maintainer-mode 57 | option to the configure script! 58 | 59 | Debugging AdPlug: 60 | ----------------- 61 | If you feel you have to debug AdPlug, you can compile it with debug logging 62 | support. This is disabled by default. To enable it, you have to define the 63 | DEBUG preprocessor macro. This is done by passing the '--enable-debug' 64 | commandline option to the 'configure' script to enable debugging. 65 | 66 | AdPlug logs to stderr by default. The output can be redirected anytime to a 67 | user specified logfile. This is done by using the 'CAdPlug::debug_output' 68 | method of the 'CAdPlug' class. 69 | 70 | The emulator license issue: 71 | --------------------------- 72 | AdPlug uses MAME's fmopl OPL2 emulator. While this official distribution 73 | includes an old LGPL'd version of the emulator, which was developed by 74 | Tatsuyuki Satoh alone, who relicensed this version under the LGPL, there is 75 | a patch available at: 76 | 77 | http://www.informatik.uni-oldenburg.de/~dyna/adplug/ 78 | 79 | that replaces the old version by the latest version from the MAME source 80 | distribution. The new version features improved emulation quality, but is 81 | licensed under the MAME license, which restricts commercial redistribution. 82 | 83 | The same goes for the OPL3 emulator, which requires the new version of 84 | the OPL2 emulator to build. 85 | 86 | - Simon Peter 87 | -------------------------------------------------------------------------------- /adplug/binfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | * 16 | * binfile.h - Binary file I/O 17 | * Copyright (C) 2002, 2003 Simon Peter 18 | */ 19 | 20 | #ifndef H_BINIO_BINFILE 21 | #define H_BINIO_BINFILE 22 | 23 | #include 24 | 25 | #include "binio.h" 26 | 27 | #ifdef _MSC_VER 28 | #pragma warning (disable:4244) 29 | #pragma warning (disable:4996) 30 | #endif 31 | 32 | class binfbase: virtual public binio { 33 | public: 34 | typedef enum { 35 | Append = 1 << 0, 36 | NoCreate = 1 << 1 37 | } ModeFlags; 38 | 39 | typedef int Mode; 40 | 41 | binfbase(); 42 | virtual ~binfbase(); 43 | 44 | virtual void open(const char *filename, const Mode mode) = 0; 45 | #if BINIO_ENABLE_STRING 46 | virtual void open(const std::string &filename, const Mode mode) = 0; 47 | #endif 48 | void close(); 49 | 50 | virtual void seek(long pos, Offset offs = Set); 51 | virtual long pos(); 52 | 53 | protected: 54 | FILE *f; 55 | }; 56 | 57 | class binifstream: public binistream, virtual public binfbase { 58 | public: 59 | binifstream(); 60 | binifstream(const char *filename, const Mode mode = NoCreate); 61 | #if BINIO_ENABLE_STRING 62 | binifstream(const std::string &filename, const Mode mode = NoCreate); 63 | #endif 64 | 65 | virtual ~binifstream(); 66 | 67 | virtual void open(const char *filename, const Mode mode = NoCreate); 68 | #if BINIO_ENABLE_STRING 69 | virtual void open(const std::string &filename, const Mode mode = NoCreate); 70 | #endif 71 | 72 | protected: 73 | virtual Byte getByte(); 74 | }; 75 | 76 | class binofstream: public binostream, virtual public binfbase { 77 | public: 78 | binofstream(); 79 | binofstream(const char *filename, const Mode mode = 0); 80 | #if BINIO_ENABLE_STRING 81 | binofstream(const std::string &filename, const Mode mode = 0); 82 | #endif 83 | 84 | virtual ~binofstream(); 85 | 86 | virtual void open(const char *filename, const Mode mode = 0); 87 | #if BINIO_ENABLE_STRING 88 | virtual void open(const std::string &filename, const Mode mode = 0); 89 | #endif 90 | 91 | protected: 92 | virtual void putByte(Byte b); 93 | }; 94 | 95 | class binfstream: public binifstream, public binofstream { 96 | public: 97 | binfstream(); 98 | binfstream(const char *filename, const Mode mode = 0); 99 | #if BINIO_ENABLE_STRING 100 | binfstream(const std::string &filename, const Mode mode = 0); 101 | #endif 102 | 103 | virtual ~binfstream(); 104 | 105 | virtual void open(const char *filename, const Mode mode = 0); 106 | #if BINIO_ENABLE_STRING 107 | virtual void open(const std::string &filename, const Mode mode = 0); 108 | #endif 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /adplug/binio.h: -------------------------------------------------------------------------------- 1 | /* -*-C++-*- 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * This library is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * Lesser General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Lesser General Public 13 | * License along with this library; if not, write to the Free Software 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 | * 16 | * binio.h - Binary stream I/O classes 17 | * Copyright (C) 2002, 2003 Simon Peter 18 | */ 19 | 20 | #ifndef H_BINIO_BINIO 21 | #define H_BINIO_BINIO 22 | 23 | #ifdef _MSC_VER 24 | #pragma warning (disable:4244) 25 | #pragma warning (disable:4996) 26 | #pragma warning (disable:4267) 27 | #endif 28 | 29 | /***** Configuration *****/ 30 | 31 | // BINIO_ENABLE_STRING - Build std::string supporting methods 32 | // 33 | // Set to 1 to build std::string supporting methods. You need the STL to 34 | // do this. 35 | #define BINIO_ENABLE_STRING 1 36 | 37 | // BINIO_ENABLE_IOSTREAM - Build iostream wrapper classes 38 | // 39 | // Set to 1 to build the iostream wrapper classes. You need the standard 40 | // C++ library to do this. 41 | #define BINIO_ENABLE_IOSTREAM 1 42 | 43 | // BINIO_ISO_STDLIB - Build with ISO C++ standard library compliance 44 | // 45 | // Set to 1 to build for the ISO standard C++ library (i.e. namespaces, STL and 46 | // templatized iostream). Set to 0 to build for the traditional C++ library. 47 | #define BINIO_ISO_STDLIB 1 48 | 49 | // BINIO_WITH_MATH - Build with 'math.h' dependency to allow float conversions 50 | // 51 | // Set to 1 to also build routines that depend on the 'math.h' standard C header 52 | // file (this sometimes also implies a 'libm' or 'libmath' dependency). These 53 | // routines are needed in order to write IEEE-754 floating-point numbers on a 54 | // system that doesn't support this format natively. For only reading these 55 | // numbers, however, these routines are not needed. If set to 0, writing 56 | // IEEE-754 numbers on an incompatible system will be disabled. 57 | //#define BINIO_WITH_MATH 1 58 | 59 | /***** Implementation *****/ 60 | 61 | #ifdef _MSC_VER 62 | # pragma warning(disable: 4250) 63 | #else 64 | # define __int64 long long 65 | #endif 66 | 67 | #if BINIO_ENABLE_STRING 68 | #include 69 | #endif 70 | 71 | class binio { 72 | public: 73 | typedef enum { 74 | BigEndian = 1 << 0, 75 | FloatIEEE = 1 << 1 76 | } Flag; 77 | 78 | typedef enum { 79 | NoError = 0, 80 | Fatal = 1 << 0, 81 | Unsupported = 1 << 1, 82 | NotOpen = 1 << 2, 83 | Denied = 1 << 3, 84 | NotFound = 1 << 4, 85 | Eof = 1 << 5 86 | } ErrorCode; 87 | 88 | typedef enum { Set, Add, End } Offset; 89 | typedef enum { Single, Double } FType; 90 | typedef int Error; 91 | 92 | binio(); 93 | virtual ~binio(); 94 | 95 | void setFlag(Flag f, bool set = true); 96 | bool getFlag(Flag f); 97 | 98 | Error error(); 99 | bool eof(); 100 | 101 | virtual void seek(long, Offset = Set) = 0; 102 | virtual long pos() = 0; 103 | 104 | protected: 105 | typedef __int64 Int; 106 | typedef long double Float; 107 | typedef unsigned char Byte; // has to be unsigned! 108 | 109 | typedef int Flags; 110 | 111 | Flags my_flags; 112 | static const Flags system_flags; 113 | Error err; 114 | 115 | // Some math.h emulation functions... 116 | #if !BINIO_WITH_MATH 117 | Float pow(Float base, signed int exp); 118 | Float ldexp(Float x, signed int exp) { 119 | return x * pow(2, exp); 120 | } 121 | #endif 122 | 123 | private: 124 | static const Flags detect_system_flags(); 125 | }; 126 | 127 | class binistream: virtual public binio { 128 | public: 129 | binistream(); 130 | virtual ~binistream(); 131 | 132 | Int readInt(unsigned int size); 133 | Float readFloat(FType ft); 134 | unsigned long readString(char *str, unsigned long amount); 135 | unsigned long readString(char *str, unsigned long maxlen, const char delim); 136 | #if BINIO_ENABLE_STRING 137 | std::string readString(const char delim = '\0'); 138 | #endif 139 | 140 | Int peekInt(unsigned int size); 141 | Float peekFloat(FType ft); 142 | 143 | bool ateof(); 144 | void ignore(unsigned long amount = 1); 145 | 146 | protected: 147 | virtual Byte getByte() = 0; 148 | 149 | private: 150 | Float ieee_single2float(Byte *data); 151 | Float ieee_double2float(Byte *data); 152 | }; 153 | 154 | class binostream: virtual public binio { 155 | public: 156 | binostream(); 157 | virtual ~binostream(); 158 | 159 | void writeInt(Int val, unsigned int size); 160 | void writeFloat(Float f, FType ft); 161 | unsigned long writeString(const char *str, unsigned long amount = 0); 162 | #if BINIO_ENABLE_STRING 163 | unsigned long writeString(const std::string &str); 164 | #endif 165 | 166 | protected: 167 | virtual void putByte(Byte) = 0; 168 | 169 | private: 170 | void float2ieee_single(Float f, Byte *data); 171 | void float2ieee_double(Float f, Byte *data); 172 | }; 173 | 174 | class binstream: public binistream, public binostream { 175 | public: 176 | binstream(); 177 | virtual ~binstream(); 178 | }; 179 | 180 | #endif 181 | -------------------------------------------------------------------------------- /adplug/demuopl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2005 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * demuopl.h - Emulated OPL using DOSBOX's emulator, by Wei Mingzhi 20 | * . 21 | */ 22 | 23 | #ifndef H_ADPLUG_DEMUOPL 24 | #define H_ADPLUG_DEMUOPL 25 | 26 | #include "opl.h" 27 | #include "dosbox_opl.h" 28 | 29 | #include 30 | 31 | class CDemuopl: public Copl 32 | { 33 | public: 34 | CDemuopl(int rate, bool bit16, bool usestereo) 35 | :use16bit(bit16), stereo(usestereo) 36 | { 37 | adlib_init(rate); 38 | currType = TYPE_OPL2; 39 | }; 40 | 41 | void update(short *buf, int samples) 42 | { 43 | short *mixbuf0 = new short[samples*2],*mixbuf1 = new short[samples*2]; 44 | short *outbuf; 45 | if(use16bit) outbuf = buf; 46 | else outbuf = mixbuf1; 47 | //if(use16bit) samples *= 2; 48 | //if(stereo) samples *= 2; 49 | adlib_getsample(outbuf, samples); 50 | if(stereo) 51 | for(int i=samples-1;i>=0;i--) { 52 | outbuf[i*2] = outbuf[i]; 53 | outbuf[i*2+1] = outbuf[i]; 54 | } 55 | //now reduce to 8bit if we need to 56 | if(!use16bit) 57 | for(int i=0;i<(stereo ? samples*2 : samples);i++) 58 | ((char *)buf)[i] = (outbuf[i] >> 8) ^ 0x80; 59 | delete[] mixbuf0; delete[] mixbuf1; 60 | } 61 | 62 | // template methods 63 | void write(int reg, int val) 64 | { 65 | if(currChip == 0) 66 | adlib_write(reg, val); 67 | }; 68 | 69 | void init() {}; 70 | 71 | protected: 72 | bool use16bit,stereo; 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /adplug/emuopl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AdPlug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2005 Simon Peter , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * emuopl.cpp - Emulated OPL, by Simon Peter 20 | */ 21 | 22 | #include "emuopl.h" 23 | 24 | CEmuopl::CEmuopl(int rate, bool bit16, bool usestereo) 25 | : use16bit(bit16), stereo(usestereo), mixbufSamples(0) { 26 | opl[0] = OPLCreate(OPL_TYPE_YM3812, 3579545, rate); 27 | opl[1] = OPLCreate(OPL_TYPE_YM3812, 3579545, rate); 28 | 29 | currType = TYPE_OPL2; 30 | 31 | init(); 32 | } 33 | 34 | CEmuopl::~CEmuopl() { 35 | OPLDestroy(opl[0]); 36 | OPLDestroy(opl[1]); 37 | 38 | if (mixbufSamples) { 39 | delete [] mixbuf0; 40 | delete [] mixbuf1; 41 | } 42 | } 43 | 44 | void CEmuopl::update(short *buf, int samples) { 45 | int i; 46 | 47 | //ensure that our mix buffers are adequately sized 48 | if (mixbufSamples < samples) { 49 | if (mixbufSamples) { 50 | delete[] mixbuf0; 51 | delete[] mixbuf1; 52 | } 53 | mixbufSamples = samples; 54 | 55 | //*2 = make room for stereo, if we need it 56 | mixbuf0 = new short[samples*2]; 57 | mixbuf1 = new short[samples*2]; 58 | } 59 | 60 | //data should be rendered to outbuf 61 | //tempbuf should be used as a temporary buffer 62 | //if we are supposed to generate 16bit output, 63 | //then outbuf may point directly to the actual waveform output "buf" 64 | //if we are supposed to generate 8bit output, 65 | //then outbuf cannot point to "buf" (because there will not be enough room) 66 | //and so it must point to a mixbuf instead-- 67 | //it will be reduced to 8bit and put in "buf" later 68 | short *outbuf; 69 | short *tempbuf=mixbuf0; 70 | short *tempbuf2=mixbuf1; 71 | if (use16bit) outbuf = buf; 72 | else outbuf = mixbuf1; 73 | //...there is a potentially confusing situation where mixbuf1 can be aliased. 74 | //beware. it is a little loony. 75 | 76 | //all of the following rendering code produces 16bit output 77 | 78 | switch (currType) { 79 | case TYPE_OPL2: 80 | //for opl2 mode: 81 | //render chip0 to the output buffer 82 | YM3812UpdateOne(opl[0],outbuf,samples); 83 | 84 | //if we are supposed to output stereo, 85 | //then we need to dup the mono channel 86 | if (stereo) 87 | for (i=samples-1;i>=0;i--) { 88 | outbuf[i*2] = outbuf[i]; 89 | outbuf[i*2+1] = outbuf[i]; 90 | } 91 | break; 92 | 93 | case TYPE_OPL3: // unsupported 94 | break; 95 | 96 | case TYPE_DUAL_OPL2: 97 | //for dual opl2 mode: 98 | //render each chip to a different tempbuffer 99 | YM3812UpdateOne(opl[0],tempbuf2,samples); 100 | YM3812UpdateOne(opl[1],tempbuf,samples); 101 | 102 | //output stereo: 103 | //then we need to interleave the two buffers 104 | if (stereo) { 105 | //first, spread tempbuf's samples across left channel 106 | //left channel 107 | for (i=0;i>1) + (tempbuf2[i]>>1); 117 | break; 118 | } 119 | 120 | //now reduce to 8bit if we need to 121 | if (!use16bit) 122 | for (i=0;i<(stereo ? samples*2 : samples);i++) 123 | ((char *)buf)[i] = (outbuf[i] >> 8) ^ 0x80; 124 | } 125 | 126 | void CEmuopl::write(int reg, int val) { 127 | switch (currType) { 128 | case TYPE_OPL2: 129 | case TYPE_DUAL_OPL2: 130 | OPLWrite(opl[currChip], 0, reg); 131 | OPLWrite(opl[currChip], 1, val); 132 | break; 133 | case TYPE_OPL3: // unsupported 134 | break; 135 | } 136 | } 137 | 138 | void CEmuopl::init() { 139 | OPLResetChip(opl[0]); 140 | OPLResetChip(opl[1]); 141 | currChip = 0; 142 | } 143 | 144 | void CEmuopl::settype(ChipType type) { 145 | currType = type; 146 | } 147 | -------------------------------------------------------------------------------- /adplug/emuopl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2005 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * emuopl.h - Emulated OPL, by Simon Peter 20 | */ 21 | 22 | #ifndef H_ADPLUG_EMUOPL 23 | #define H_ADPLUG_EMUOPL 24 | 25 | #include "opl.h" 26 | extern "C" { 27 | #include "fmopl.h" 28 | } 29 | 30 | class CEmuopl: public Copl { 31 | public: 32 | CEmuopl(int rate, bool bit16, bool usestereo); // rate = sample rate 33 | virtual ~CEmuopl(); 34 | 35 | void update(short *buf, int samples); // fill buffer 36 | void write(int reg, int val); 37 | 38 | void init(); 39 | void settype(ChipType type); 40 | 41 | private: 42 | bool use16bit, stereo; 43 | FM_OPL *opl[2]; // OPL2 emulator data 44 | short *mixbuf0, *mixbuf1; 45 | int mixbufSamples; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /adplug/fprovide.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2002 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * fprovide.cpp - File provider class framework, by Simon Peter 20 | */ 21 | 22 | #include 23 | #include "binio.h" 24 | #include "binfile.h" 25 | 26 | #include "fprovide.h" 27 | 28 | #ifdef __SYMBIAN32__ 29 | #define stricmp strcasecmp 30 | #else 31 | #ifndef _WIN32 32 | #define stricmp strcasecmp 33 | #endif 34 | #endif 35 | /***** CFileProvider *****/ 36 | 37 | bool CFileProvider::extension(const std::string &filename, 38 | const std::string &extension) { 39 | const char *fname = filename.c_str(), *ext = extension.c_str(); 40 | 41 | if (strlen(fname) < strlen(ext) || 42 | stricmp(fname + strlen(fname) - strlen(ext), ext)) 43 | return false; 44 | else 45 | return true; 46 | } 47 | 48 | unsigned long CFileProvider::filesize(binistream *f) { 49 | unsigned long oldpos = f->pos(), size; 50 | 51 | f->seek(0, binio::End); 52 | size = f->pos(); 53 | f->seek(oldpos, binio::Set); 54 | 55 | return size; 56 | } 57 | 58 | /***** CProvider_Filesystem *****/ 59 | 60 | binistream *CProvider_Filesystem::open(std::string filename) const { 61 | binifstream *f = new binifstream(filename); 62 | 63 | if (!f) return 0; 64 | if (f->error()) { 65 | delete f; 66 | return 0; 67 | } 68 | 69 | // Open all files as little endian with IEEE floats by default 70 | f->setFlag(binio::BigEndian, false); 71 | f->setFlag(binio::FloatIEEE); 72 | 73 | return f; 74 | } 75 | 76 | void CProvider_Filesystem::close(binistream *f) const { 77 | binifstream *ff = (binifstream *)f; 78 | 79 | if (f) { 80 | ff->close(); 81 | delete ff; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /adplug/fprovide.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2006 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * fprovide.h - File provider class framework, by Simon Peter 20 | */ 21 | 22 | #ifndef H_ADPLUG_FILEPROVIDER 23 | #define H_ADPLUG_FILEPROVIDER 24 | 25 | #include 26 | #include "binio.h" 27 | 28 | class CFileProvider { 29 | public: 30 | virtual ~CFileProvider() { 31 | } 32 | 33 | virtual binistream *open(std::string) const = 0; 34 | virtual void close(binistream *) const = 0; 35 | 36 | static bool extension(const std::string &filename, 37 | const std::string &extension); 38 | static unsigned long filesize(binistream *f); 39 | }; 40 | 41 | class CProvider_Filesystem: public CFileProvider { 42 | public: 43 | virtual binistream *open(std::string filename) const; 44 | virtual void close(binistream *f) const; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /adplug/opl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2007 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * opl.h - OPL base class, by Simon Peter 20 | */ 21 | 22 | #ifndef H_ADPLUG_OPL 23 | #define H_ADPLUG_OPL 24 | 25 | class Copl { 26 | public: 27 | typedef enum { 28 | TYPE_OPL2, TYPE_OPL3, TYPE_DUAL_OPL2 29 | } ChipType; 30 | 31 | Copl() 32 | : currChip(0), currType(TYPE_OPL2) { 33 | } 34 | 35 | virtual ~Copl() { 36 | } 37 | 38 | virtual void write(int reg, int val) {} // combined register select + data write 39 | virtual void setchip(int n) { // select OPL chip 40 | if (n < 2) 41 | currChip = n; 42 | } 43 | 44 | virtual int getchip() { // returns current OPL chip 45 | return currChip; 46 | } 47 | 48 | virtual void init(void) {} // reinitialize OPL chip(s) 49 | 50 | // return this OPL chip's type 51 | ChipType gettype() { 52 | return currType; 53 | } 54 | 55 | // Emulation only: fill buffer 56 | virtual void update(short *buf, int samples) {} 57 | 58 | protected: 59 | int currChip; // currently selected OPL chip number 60 | ChipType currType; // this OPL chip's type 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /adplug/player.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2007 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * player.cpp - Replayer base class, by Simon Peter 20 | */ 21 | 22 | #include "player.h" 23 | #include "opl.h" 24 | 25 | /***** CPlayer *****/ 26 | 27 | const unsigned short CPlayer::note_table[12] = 28 | {363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647, 686}; 29 | 30 | const unsigned char CPlayer::op_table[9] = 31 | {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12}; 32 | 33 | CPlayer::CPlayer(Copl *newopl) 34 | : opl(newopl) { 35 | } 36 | 37 | CPlayer::~CPlayer() { 38 | } 39 | 40 | unsigned long CPlayer::songlength(int subsong) { 41 | Copl tempopl; 42 | Copl *saveopl = opl; 43 | float slength = 0.0f; 44 | 45 | // save original OPL from being overwritten 46 | opl = &tempopl; 47 | 48 | // get song length 49 | rewind(subsong); 50 | while (update() && slength < 600000) // song length limit: 10 minutes 51 | slength += 1000.0f / getrefresh(); 52 | rewind(subsong); 53 | 54 | // restore original OPL and return 55 | opl = saveopl; 56 | return (unsigned long)slength; 57 | } 58 | 59 | void CPlayer::seek(unsigned long ms) { 60 | float pos = 0.0f; 61 | 62 | rewind(); 63 | while (pos < ms && update()) // seek to new position 64 | pos += 1000/getrefresh(); 65 | } 66 | -------------------------------------------------------------------------------- /adplug/player.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2007 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * player.h - Replayer base class, by Simon Peter 20 | */ 21 | 22 | #ifndef H_ADPLUG_PLAYER 23 | #define H_ADPLUG_PLAYER 24 | 25 | #include 26 | 27 | #include "fprovide.h" 28 | #include "opl.h" 29 | 30 | class CPlayer { 31 | public: 32 | CPlayer(Copl *newopl); 33 | virtual ~CPlayer(); 34 | 35 | /***** Operational methods *****/ 36 | void seek(unsigned long ms); 37 | 38 | virtual bool load(const std::string &filename, // loads file 39 | const CFileProvider &fp = CProvider_Filesystem()) = 0; 40 | virtual bool update() = 0; // executes replay code for 1 tick 41 | virtual void rewind(int subsong = -1) = 0; // rewinds to specified subsong 42 | virtual float getrefresh() = 0; // returns needed timer refresh rate 43 | 44 | /***** Informational methods *****/ 45 | unsigned long songlength(int subsong = -1); 46 | 47 | virtual std::string gettype() = 0; // returns file type 48 | virtual std::string gettitle() { // returns song title 49 | return std::string(); 50 | } 51 | virtual std::string getauthor() { // returns song author name 52 | return std::string(); 53 | } 54 | virtual std::string getdesc() { // returns song description 55 | return std::string(); 56 | } 57 | virtual unsigned int getpatterns() { // returns number of patterns 58 | return 0; 59 | } 60 | virtual unsigned int getpattern() { // returns currently playing pattern 61 | return 0; 62 | } 63 | virtual unsigned int getorders() { // returns size of orderlist 64 | return 0; 65 | } 66 | virtual unsigned int getorder() { // returns currently playing song position 67 | return 0; 68 | } 69 | virtual unsigned int getrow() { // returns currently playing row 70 | return 0; 71 | } 72 | virtual unsigned int getspeed() { // returns current song speed 73 | return 0; 74 | } 75 | virtual unsigned int getsubsongs() { // returns number of subsongs 76 | return 1; 77 | } 78 | virtual unsigned int getinstruments() { // returns number of instruments 79 | return 0; 80 | } 81 | virtual std::string getinstrument(unsigned int n) { // returns n-th instrument name 82 | return std::string(); 83 | } 84 | 85 | protected: 86 | Copl *opl; // our OPL chip 87 | 88 | static const unsigned short note_table[12]; // standard adlib note table 89 | static const unsigned char op_table[9]; // the 9 operators as expected by the OPL 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /adplug/rix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2006 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * rix.h - Softstar RIX OPL Format Player by palxex 20 | * BSPAL 21 | */ 22 | 23 | #include "player.h" 24 | 25 | #ifdef _MSC_VER 26 | #include 27 | #define uint8_t BYTE 28 | #define uint16_t WORD 29 | #define uint32_t DWORD 30 | #else 31 | #include 32 | #endif 33 | 34 | class CrixPlayer: public CPlayer 35 | { 36 | public: 37 | static CPlayer *factory(Copl *newopl); 38 | 39 | CrixPlayer(Copl *newopl); 40 | ~CrixPlayer(); 41 | 42 | bool load(const std::string &filename, const CFileProvider &fp); 43 | bool update(); 44 | void rewind(int subsong); 45 | float getrefresh(); 46 | unsigned int getsubsongs(); 47 | 48 | std::string gettype() 49 | { return std::string("Softstar RIX OPL Music Format"); }; 50 | 51 | protected: 52 | typedef struct { 53 | uint8_t v[14]; 54 | } ADDT; 55 | 56 | int flag_mkf; 57 | uint8_t *file_buffer; 58 | uint8_t *rix_buf; /* rix files' f_buffer */ 59 | uint16_t f_buffer[300];//9C0h-C18h 60 | uint16_t a0b0_data2[11]; 61 | uint8_t a0b0_data3[18]; 62 | uint8_t a0b0_data4[18]; 63 | uint8_t a0b0_data5[96]; 64 | uint8_t addrs_head[96]; 65 | uint16_t insbuf[28]; 66 | uint16_t displace[11]; 67 | ADDT reg_bufs[18]; 68 | uint32_t pos,length; 69 | uint8_t index; 70 | 71 | static const uint8_t adflag[18]; 72 | static const uint8_t reg_data[18]; 73 | static const uint8_t ad_C0_offs[18]; 74 | static const uint8_t modify[28]; 75 | static const uint8_t bd_reg_data[124]; 76 | static uint8_t for40reg[18]; 77 | static const uint16_t mus_time; 78 | uint32_t I,T; 79 | uint16_t mus_block; 80 | uint16_t ins_block; 81 | uint8_t rhythm; 82 | uint8_t music_on; 83 | uint8_t pause_flag; 84 | uint16_t band; 85 | uint8_t band_low; 86 | uint16_t e0_reg_flag; 87 | uint8_t bd_modify; 88 | int sustain; 89 | int play_end; 90 | 91 | #define ad_08_reg() ad_bop(8,0) /**/ 92 | inline void ad_20_reg(uint16_t); /**/ 93 | inline void ad_40_reg(uint16_t); /**/ 94 | inline void ad_60_reg(uint16_t); /**/ 95 | inline void ad_80_reg(uint16_t); /**/ 96 | inline void ad_a0b0_reg(uint16_t); /**/ 97 | inline void ad_a0b0l_reg(uint16_t,uint16_t,uint16_t); /**/ 98 | inline void ad_a0b0l_reg_(uint16_t,uint16_t,uint16_t); /**/ 99 | inline void ad_bd_reg(); /**/ 100 | inline void ad_bop(uint16_t,uint16_t); /**/ 101 | inline void ad_C0_reg(uint16_t); /**/ 102 | inline void ad_E0_reg(uint16_t); /**/ 103 | inline uint16_t ad_initial(); /**/ 104 | inline uint16_t ad_test(); /**/ 105 | inline void crc_trans(uint16_t,uint16_t); /**/ 106 | inline void data_initial(); /* done */ 107 | inline void init(); /**/ 108 | inline void ins_to_reg(uint16_t,uint16_t*,uint16_t); /**/ 109 | inline void int_08h_entry(); /**/ 110 | inline void music_ctrl(); /**/ 111 | inline void Pause(); /**/ 112 | inline void prepare_a0b0(uint16_t,uint16_t); /**/ 113 | inline void rix_90_pro(uint16_t); /**/ 114 | inline void rix_A0_pro(uint16_t,uint16_t); /**/ 115 | inline void rix_B0_pro(uint16_t,uint16_t); /**/ 116 | inline void rix_C0_pro(uint16_t,uint16_t); /**/ 117 | inline void rix_get_ins(); /**/ 118 | inline uint16_t rix_proc(); /**/ 119 | inline void set_new_int(); 120 | inline void switch_ad_bd(uint16_t); /**/ 121 | }; 122 | -------------------------------------------------------------------------------- /adplug/surroundopl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adplug - Replayer for many OPL2/OPL3 audio file formats. 3 | * Copyright (C) 1999 - 2010 Simon Peter, , et al. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * surroundopl.h - Wrapper class to provide a surround/harmonic effect 20 | * for another OPL emulator, by Adam Nielsen 21 | * 22 | * Stereo harmonic algorithm by Adam Nielsen 23 | * Please give credit if you use this algorithm elsewhere :-) 24 | */ 25 | 26 | #ifndef H_ADPLUG_SURROUNDOPL 27 | #define H_ADPLUG_SURROUNDOPL 28 | 29 | //#include // for uintxx_t 30 | #include "opl.h" 31 | 32 | // The right-channel is increased in frequency by itself divided by this amount. 33 | // The right value should not noticeably change the pitch, but it should provide 34 | // a nice stereo harmonic effect. 35 | #define FREQ_OFFSET 128.0//96.0 36 | 37 | // Number of FNums away from the upper/lower limit before switching to the next 38 | // block (octave.) By rights it should be zero, but for some reason this seems 39 | // to cut it to close and the transposed OPL doesn't hit the right note all the 40 | // time. Setting it higher means it will switch blocks sooner and that seems 41 | // to help. Don't set it too high or it'll get stuck in an infinite loop if 42 | // one block is too high and the adjacent block is too low ;-) 43 | #define NEWBLOCK_LIMIT 32 44 | 45 | class CSurroundopl: public Copl 46 | { 47 | private: 48 | bool use16bit; 49 | short bufsize; 50 | short *lbuf, *rbuf; 51 | Copl *a, *b; 52 | unsigned char iFMReg[256]; 53 | unsigned char iTweakedFMReg[256]; 54 | unsigned char iCurrentTweakedBlock[9]; // Current value of the Block in the tweaked OPL chip 55 | unsigned char iCurrentFNum[9]; // Current value of the FNum in the tweaked OPL chip 56 | 57 | public: 58 | 59 | CSurroundopl(Copl *a, Copl *b, bool use16bit); 60 | ~CSurroundopl(); 61 | 62 | void update(short *buf, int samples); 63 | void write(int reg, int val); 64 | 65 | void init(); 66 | 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SDLActivity 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 10 | 11 | 20 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /android/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /android/build.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked in Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /android/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 30 | 31 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 50 | 51 | 52 | 53 | 57 | 58 | 70 | 71 | 72 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /android/default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-12 12 | -------------------------------------------------------------------------------- /android/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /android/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_STL := stlport_static 2 | APP_ABI := armeabi-v7a 3 | -------------------------------------------------------------------------------- /android/jni/SDL2/README: -------------------------------------------------------------------------------- 1 | Download SDL 2.0 from http://libsdl.org/ and extract to here. 2 | -------------------------------------------------------------------------------- /android/jni/src/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := main 6 | 7 | SDL_PATH := ../SDL2 8 | 9 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include 10 | 11 | LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ 12 | ../../../battle.c \ 13 | ../../../global.c \ 14 | ../../../map.c \ 15 | ../../../res.c \ 16 | ../../../ui.c \ 17 | ../../../ending.c \ 18 | ../../../input.c \ 19 | ../../../rngplay.c \ 20 | ../../../uibattle.c \ 21 | ../../../fight.c \ 22 | ../../../palcommon.c \ 23 | ../../../scene.c \ 24 | ../../../uigame.c \ 25 | ../../../font.c \ 26 | ../../../itemmenu.c \ 27 | ../../../palette.c \ 28 | ../../../script.c \ 29 | ../../../util.c \ 30 | ../../../game.c \ 31 | ../../../magicmenu.c \ 32 | ../../../play.c \ 33 | ../../../sound.c \ 34 | ../../../video.c \ 35 | ../../../getopt.c \ 36 | ../../../main.c \ 37 | ../../../private.c \ 38 | ../../../text.c \ 39 | ../../../yj1.c \ 40 | ../../../rixplay.cpp \ 41 | ../../../adplug/binfile.cpp \ 42 | ../../../adplug/binio.cpp \ 43 | ../../../adplug/dosbox_opl.cpp \ 44 | ../../../adplug/emuopl.cpp \ 45 | ../../../adplug/fmopl.c \ 46 | ../../../adplug/fprovide.cpp \ 47 | ../../../adplug/player.cpp \ 48 | ../../../adplug/rix.cpp \ 49 | ../../../adplug/surroundopl.cpp \ 50 | ../../../libmad/bit.c \ 51 | ../../../libmad/decoder.c \ 52 | ../../../libmad/fixed.c \ 53 | ../../../libmad/frame.c \ 54 | ../../../libmad/huffman.c \ 55 | ../../../libmad/layer12.c \ 56 | ../../../libmad/layer3.c \ 57 | ../../../libmad/music_mad.c \ 58 | ../../../libmad/stream.c \ 59 | ../../../libmad/synth.c \ 60 | ../../../libmad/timer.c 61 | 62 | LOCAL_SHARED_LIBRARIES := SDL2 63 | 64 | LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog 65 | 66 | include $(BUILD_SHARED_LIBRARY) 67 | -------------------------------------------------------------------------------- /android/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /android/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=Google Inc.:Google APIs (x86 System Image):19 15 | -------------------------------------------------------------------------------- /android/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/android/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/android/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/android/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/android/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | SDLPal 4 | 5 | -------------------------------------------------------------------------------- /android/src/com/codeplex/sdlpal/PalActivity.java: -------------------------------------------------------------------------------- 1 | package com.codeplex.sdlpal; 2 | 3 | import org.libsdl.app.SDLActivity; 4 | 5 | public class PalActivity extends SDLActivity { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /data/overlay.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/data/overlay.bmp -------------------------------------------------------------------------------- /ending.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef ENDGAME_H 23 | #define ENDGAME_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | VOID 31 | PAL_EndingSetEffectSprite( 32 | WORD wSpriteNum 33 | ); 34 | 35 | VOID 36 | PAL_ShowFBP( 37 | WORD wChunkNum, 38 | WORD wFade 39 | ); 40 | 41 | VOID 42 | PAL_ScrollFBP( 43 | WORD wChunkNum, 44 | WORD wScrollSpeed, 45 | BOOL fScrollDown 46 | ); 47 | 48 | VOID 49 | PAL_EndingAnimation( 50 | VOID 51 | ); 52 | 53 | #ifdef PAL_WIN95 54 | VOID 55 | PAL_EndingScreen( 56 | VOID 57 | ); 58 | #endif 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif 64 | -------------------------------------------------------------------------------- /fight.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef FIGHT_H 23 | #define FIGHT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | INT 31 | PAL_BattleSelectAutoTarget( 32 | VOID 33 | ); 34 | 35 | #ifndef PAL_CLASSIC 36 | 37 | VOID 38 | PAL_UpdateTimeChargingUnit( 39 | VOID 40 | ); 41 | 42 | FLOAT 43 | PAL_GetTimeChargingSpeed( 44 | WORD wDexterity 45 | ); 46 | 47 | #endif 48 | 49 | VOID 50 | PAL_BattleUpdateFighters( 51 | VOID 52 | ); 53 | 54 | VOID 55 | PAL_BattlePlayerCheckReady( 56 | VOID 57 | ); 58 | 59 | VOID 60 | PAL_BattleStartFrame( 61 | VOID 62 | ); 63 | 64 | VOID 65 | PAL_BattleCommitAction( 66 | BOOL fRepeat 67 | ); 68 | 69 | VOID 70 | PAL_BattlePlayerPerformAction( 71 | WORD wPlayerIndex 72 | ); 73 | 74 | VOID 75 | PAL_BattleEnemyPerformAction( 76 | WORD wEnemyIndex 77 | ); 78 | 79 | #ifdef PAL_WIN95 80 | 81 | VOID 82 | PAL_BattleShowPlayerPreMagicAnim( 83 | WORD wPlayerIndex, 84 | WORD wObjectID 85 | ); 86 | 87 | #else 88 | 89 | VOID 90 | PAL_BattleShowPlayerPreMagicAnim( 91 | WORD wPlayerIndex, 92 | BOOL fSummon 93 | ); 94 | 95 | #endif 96 | 97 | VOID 98 | PAL_BattleDelay( 99 | WORD wDuration, 100 | WORD wObjectID, 101 | BOOL fUpdateGesture 102 | ); 103 | 104 | VOID 105 | PAL_BattleStealFromEnemy( 106 | WORD wTarget, 107 | WORD wStealRate 108 | ); 109 | 110 | VOID 111 | PAL_BattleSimulateMagic( 112 | SHORT sTarget, 113 | WORD wMagicObjectID, 114 | WORD wBaseDamage 115 | ); 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | #endif 121 | -------------------------------------------------------------------------------- /font.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef FONT_H 23 | #define FONT_H 24 | 25 | #include "common.h" 26 | #include "palcommon.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" 30 | { 31 | #endif 32 | 33 | INT 34 | PAL_InitFont( 35 | VOID 36 | ); 37 | 38 | VOID 39 | PAL_FreeFont( 40 | VOID 41 | ); 42 | 43 | VOID 44 | PAL_DrawCharOnSurface( 45 | WORD wChar, 46 | SDL_Surface *lpSurface, 47 | PAL_POS pos, 48 | BYTE bColor 49 | ); 50 | 51 | VOID 52 | PAL_DrawASCIICharOnSurface( 53 | BYTE bChar, 54 | SDL_Surface *lpSurface, 55 | PAL_POS pos, 56 | BYTE bColor 57 | ); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /game.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #include "main.h" 23 | 24 | static VOID 25 | PAL_GameStart( 26 | VOID 27 | ) 28 | /*++ 29 | Purpose: 30 | 31 | Do some initialization work when game starts (new game or load game). 32 | 33 | Parameters: 34 | 35 | None. 36 | 37 | Return value: 38 | 39 | None. 40 | 41 | --*/ 42 | { 43 | PAL_SetLoadFlags(kLoadScene | kLoadPlayerSprite); 44 | 45 | if (!gpGlobals->fEnteringScene) 46 | { 47 | // 48 | // Fade in music if the player has loaded an old game. 49 | // 50 | PAL_PlayMUS(gpGlobals->wNumMusic, TRUE, 1); 51 | } 52 | 53 | gpGlobals->fNeedToFadeIn = TRUE; 54 | gpGlobals->dwFrameNum = 0; 55 | } 56 | 57 | VOID 58 | PAL_GameMain( 59 | VOID 60 | ) 61 | /*++ 62 | Purpose: 63 | 64 | The game entry routine. 65 | 66 | Parameters: 67 | 68 | None. 69 | 70 | Return value: 71 | 72 | None. 73 | 74 | --*/ 75 | { 76 | DWORD dwTime; 77 | 78 | // 79 | // Show the opening menu. 80 | // 81 | gpGlobals->bCurrentSaveSlot = (BYTE)PAL_OpeningMenu(); 82 | 83 | // 84 | // Initialize game data and set the flags to load the game resources. 85 | // 86 | PAL_InitGameData(gpGlobals->bCurrentSaveSlot); 87 | 88 | // 89 | // Run the main game loop. 90 | // 91 | dwTime = SDL_GetTicks(); 92 | while (TRUE) 93 | { 94 | // 95 | // Do some initialization at game start. 96 | // 97 | if (gpGlobals->fGameStart) 98 | { 99 | PAL_GameStart(); 100 | gpGlobals->fGameStart = FALSE; 101 | } 102 | 103 | // 104 | // Load the game resources if needed. 105 | // 106 | PAL_LoadResources(); 107 | 108 | // 109 | // Clear the input state of previous frame. 110 | // 111 | PAL_ClearKeyState(); 112 | 113 | // 114 | // Wait for the time of one frame. Accept input here. 115 | // 116 | PAL_ProcessEvent(); 117 | while (SDL_GetTicks() <= dwTime) 118 | { 119 | PAL_ProcessEvent(); 120 | SDL_Delay(1); 121 | } 122 | 123 | // 124 | // Set the time of the next frame. 125 | // 126 | dwTime = SDL_GetTicks() + FRAME_TIME; 127 | 128 | // 129 | // Run the main frame routine. 130 | // 131 | PAL_StartFrame(); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /game.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef GAME_H 23 | #define GAME_H 24 | 25 | #include "common.h" 26 | 27 | #define FPS 10 28 | #define FRAME_TIME (1000 / FPS) 29 | 30 | VOID 31 | PAL_GameMain( 32 | VOID 33 | ); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /getopt.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 1987, 1993, 1994 4 | // The Regents of the University of California. All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // 1. Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 3. Neither the name of the University nor the names of its contributors 16 | // may be used to endorse or promote products derived from this software 17 | // without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | // SUCH DAMAGE. 30 | // 31 | 32 | #include 33 | #include 34 | #include 35 | #include "getopt.h" 36 | 37 | int opterr = 1; // if error message should be printed 38 | int optind = 1; // index into parent argv vector 39 | int optopt; // character checked for validity 40 | int optreset; // reset getopt 41 | char *optarg; // argument associated with option 42 | 43 | #define BADCH (int)'?' 44 | #define BADARG (int)':' 45 | #define EMSG "" 46 | 47 | // 48 | // getopt -- 49 | // Parse argc/argv argument vector. 50 | // 51 | int 52 | getopt( 53 | int nargc, 54 | char * const *nargv, 55 | const char *ostr 56 | ) 57 | { 58 | static char *place = EMSG; // option letter processing 59 | char *oli; // option letter list index 60 | 61 | if (optreset || !*place) 62 | { 63 | // update scanning pointer 64 | optreset = 0; 65 | if (optind >= nargc || *(place = nargv[optind]) != '-') 66 | { 67 | place = EMSG; 68 | return -1; 69 | } 70 | if (place[1] && *++place == '-') 71 | { 72 | // found "--" 73 | ++optind; 74 | place = EMSG; 75 | return -1; 76 | } 77 | } 78 | 79 | // option letter okay? 80 | if ((optopt = (int)*place++) == (int)':' || 81 | !(oli = strchr(ostr, optopt))) 82 | { 83 | // 84 | // if the user didn't specify '-' as an option, 85 | // assume it means -1. 86 | // 87 | if (optopt == (int)'-') 88 | return -1; 89 | if (!*place) 90 | ++optind; 91 | if (opterr && *ostr != ':') 92 | fprintf(stderr, "%s: illegal option -- %c\n", nargv[0], optopt); 93 | return BADCH; 94 | } 95 | 96 | if (*++oli != ':') 97 | { 98 | // don't need argument 99 | optarg = NULL; 100 | if (!*place) 101 | ++optind; 102 | } 103 | else 104 | { 105 | // need an argument 106 | if (*place) // no white space 107 | optarg = place; 108 | else if (nargc <= ++optind) 109 | { 110 | // no arg 111 | place = EMSG; 112 | if (*ostr == ':') 113 | return BADARG; 114 | if (opterr) 115 | { 116 | fprintf(stderr, "%s: option requires an argument -- %c\n", 117 | nargv[0], optopt); 118 | } 119 | return BADCH; 120 | } 121 | else // white space 122 | optarg = nargv[optind]; 123 | place = EMSG; 124 | ++optind; 125 | } 126 | 127 | return optopt; // dump back option letter 128 | } 129 | -------------------------------------------------------------------------------- /getopt.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 1987, 1993, 1994 4 | // The Regents of the University of California. All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // 1. Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 3. Neither the name of the University nor the names of its contributors 16 | // may be used to endorse or promote products derived from this software 17 | // without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND 20 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | // ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | // SUCH DAMAGE. 30 | // 31 | 32 | #ifndef GETOPT_H 33 | #define GETOPT_H 34 | 35 | #ifdef __cplusplus 36 | extern "C" 37 | { 38 | #endif 39 | 40 | #define opterr PAL_opterr 41 | #define optind PAL_optind 42 | #define optopt PAL_optopt 43 | #define optreset PAL_optreset 44 | #define optarg PAL_optarg 45 | #define getopt PAL_getopt 46 | 47 | extern int opterr; 48 | extern int optind; 49 | extern int optopt; 50 | extern int optreset; 51 | extern char *optarg; 52 | 53 | int 54 | getopt( 55 | int nargc, 56 | char * const *nargv, 57 | const char *ostr 58 | ); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /input.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef INPUT_H 23 | #define INPUT_H 24 | 25 | #include "common.h" 26 | #include "palcommon.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" 30 | { 31 | #endif 32 | 33 | typedef struct tagPALINPUTSTATE 34 | { 35 | PALDIRECTION dir, prevdir; 36 | DWORD dwKeyPress; 37 | } PALINPUTSTATE; 38 | 39 | extern volatile PALINPUTSTATE g_InputState; 40 | 41 | enum PALKEY 42 | { 43 | kKeyMenu = (1 << 0), 44 | kKeySearch = (1 << 1), 45 | kKeyDown = (1 << 2), 46 | kKeyLeft = (1 << 3), 47 | kKeyUp = (1 << 4), 48 | kKeyRight = (1 << 5), 49 | kKeyPgUp = (1 << 6), 50 | kKeyPgDn = (1 << 7), 51 | kKeyRepeat = (1 << 8), 52 | kKeyAuto = (1 << 9), 53 | kKeyDefend = (1 << 10), 54 | kKeyUseItem = (1 << 11), 55 | kKeyThrowItem = (1 << 12), 56 | kKeyFlee = (1 << 13), 57 | kKeyStatus = (1 << 14), 58 | kKeyForce = (1 << 15), 59 | }; 60 | 61 | VOID 62 | PAL_ClearKeyState( 63 | VOID 64 | ); 65 | 66 | VOID 67 | PAL_InitInput( 68 | VOID 69 | ); 70 | 71 | VOID 72 | PAL_ProcessEvent( 73 | VOID 74 | ); 75 | 76 | VOID 77 | PAL_ShutdownInput( 78 | VOID 79 | ); 80 | 81 | int 82 | PAL_PollEvent( 83 | SDL_Event *event 84 | ); 85 | 86 | 87 | extern BOOL g_fUseJoystick; 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /ios/SDL2/README: -------------------------------------------------------------------------------- 1 | Download SDL 2.0 from http://libsdl.org/ and extract to here. 2 | -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/ios/SDLPal/SDLPal/Default-568h@2x.png -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/ios/SDLPal/SDLPal/Default.png -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/ios/SDLPal/SDLPal/Default@2x.png -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/ios/SDLPal/SDLPal/Icon.png -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal/SDLPal-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | Icon 13 | CFBundleIdentifier 14 | com.codeplex.sdlpal 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIFileSharingEnabled 30 | 31 | UIStatusBarHidden 32 | 33 | UIStatusBarStyle 34 | UIStatusBarStyleDefault 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ios/SDLPal/SDLPal/util.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include "common.h" 3 | #include "SDL_filesystem.h" 4 | 5 | LPCSTR 6 | UTIL_IOS_BasePath( 7 | VOID 8 | ) 9 | { 10 | static char buf[4096] = ""; 11 | 12 | if (buf[0] == '\0') 13 | { 14 | #ifdef CYDIA 15 | char *p = SDL_GetBasePath(); 16 | if (p != NULL) 17 | { 18 | strcpy(buf, p); 19 | free(p); 20 | } 21 | #else 22 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 23 | NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"]; 24 | strcpy(buf, [documentsDirectory UTF8String]); 25 | #endif 26 | } 27 | 28 | return buf; 29 | } 30 | 31 | LPCSTR 32 | UTIL_IOS_SavePath( 33 | VOID 34 | ) 35 | { 36 | static char buf[4096] = ""; 37 | 38 | if (buf[0] == '\0') 39 | { 40 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 41 | NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"]; 42 | strcpy(buf, [documentsDirectory UTF8String]); 43 | } 44 | 45 | return buf; 46 | } 47 | -------------------------------------------------------------------------------- /itemmenu.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef ITEMMENU_H 23 | #define ITEMMENU_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | WORD 31 | PAL_ItemSelectMenuUpdate( 32 | VOID 33 | ); 34 | 35 | VOID 36 | PAL_ItemSelectMenuInit( 37 | WORD wItemFlags 38 | ); 39 | 40 | WORD 41 | PAL_ItemSelectMenu( 42 | LPITEMCHANGED_CALLBACK lpfnMenuItemChanged, 43 | WORD wItemFlags 44 | ); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /libmad/bit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_BIT_H 23 | # define LIBMAD_BIT_H 24 | 25 | struct mad_bitptr { 26 | unsigned char const *byte; 27 | unsigned short cache; 28 | unsigned short left; 29 | }; 30 | 31 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); 32 | 33 | # define mad_bit_finish(bitptr) /* nothing */ 34 | 35 | unsigned int mad_bit_length(struct mad_bitptr const *, 36 | struct mad_bitptr const *); 37 | 38 | # define mad_bit_bitsleft(bitptr) ((bitptr)->left) 39 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); 40 | 41 | void mad_bit_skip(struct mad_bitptr *, unsigned int); 42 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); 43 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); 44 | 45 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); 46 | 47 | # endif 48 | -------------------------------------------------------------------------------- /libmad/decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_DECODER_H 23 | # define LIBMAD_DECODER_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | # include "synth.h" 28 | 29 | enum mad_decoder_mode { 30 | MAD_DECODER_MODE_SYNC = 0, 31 | MAD_DECODER_MODE_ASYNC 32 | }; 33 | 34 | enum mad_flow { 35 | MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ 36 | MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ 37 | MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ 38 | MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ 39 | }; 40 | 41 | struct mad_decoder { 42 | enum mad_decoder_mode mode; 43 | 44 | int options; 45 | 46 | struct { 47 | long pid; 48 | int in; 49 | int out; 50 | } async; 51 | 52 | struct { 53 | struct mad_stream stream; 54 | struct mad_frame frame; 55 | struct mad_synth synth; 56 | } *sync; 57 | 58 | void *cb_data; 59 | 60 | enum mad_flow (*input_func)(void *, struct mad_stream *); 61 | enum mad_flow (*header_func)(void *, struct mad_header const *); 62 | enum mad_flow (*filter_func)(void *, 63 | struct mad_stream const *, struct mad_frame *); 64 | enum mad_flow (*output_func)(void *, 65 | struct mad_header const *, struct mad_pcm *); 66 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); 67 | enum mad_flow (*message_func)(void *, void *, unsigned int *); 68 | }; 69 | 70 | void mad_decoder_init(struct mad_decoder *, void *, 71 | enum mad_flow (*)(void *, struct mad_stream *), 72 | enum mad_flow (*)(void *, struct mad_header const *), 73 | enum mad_flow (*)(void *, 74 | struct mad_stream const *, 75 | struct mad_frame *), 76 | enum mad_flow (*)(void *, 77 | struct mad_header const *, 78 | struct mad_pcm *), 79 | enum mad_flow (*)(void *, 80 | struct mad_stream *, 81 | struct mad_frame *), 82 | enum mad_flow (*)(void *, void *, unsigned int *)); 83 | int mad_decoder_finish(struct mad_decoder *); 84 | 85 | # define mad_decoder_options(decoder, opts) \ 86 | ((void) ((decoder)->options = (opts))) 87 | 88 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); 89 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); 90 | 91 | # endif 92 | -------------------------------------------------------------------------------- /libmad/fixed.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # include "libmad_config.h" 23 | 24 | # include "libmad_global.h" 25 | 26 | # include "fixed.h" 27 | 28 | /* 29 | * NAME: fixed->abs() 30 | * DESCRIPTION: return absolute value of a fixed-point number 31 | */ 32 | mad_fixed_t mad_f_abs(mad_fixed_t x) 33 | { 34 | return x < 0 ? -x : x; 35 | } 36 | 37 | /* 38 | * NAME: fixed->div() 39 | * DESCRIPTION: perform division using fixed-point math 40 | */ 41 | mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y) 42 | { 43 | mad_fixed_t q, r; 44 | unsigned int bits; 45 | 46 | q = mad_f_abs(x / y); 47 | 48 | if (x < 0) { 49 | x = -x; 50 | y = -y; 51 | } 52 | 53 | r = x % y; 54 | 55 | if (y < 0) { 56 | x = -x; 57 | y = -y; 58 | } 59 | 60 | if (q > mad_f_intpart(MAD_F_MAX) && 61 | !(q == -mad_f_intpart(MAD_F_MIN) && r == 0 && (x < 0) != (y < 0))) 62 | return 0; 63 | 64 | for (bits = MAD_F_FRACBITS; bits && r; --bits) { 65 | q <<= 1, r <<= 1; 66 | if (r >= y) 67 | r -= y, ++q; 68 | } 69 | 70 | /* round */ 71 | if (2 * r >= y) 72 | ++q; 73 | 74 | /* fix sign */ 75 | if ((x < 0) != (y < 0)) 76 | q = -q; 77 | 78 | return q << bits; 79 | } 80 | -------------------------------------------------------------------------------- /libmad/frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_FRAME_H 23 | # define LIBMAD_FRAME_H 24 | 25 | # include "fixed.h" 26 | # include "timer.h" 27 | # include "stream.h" 28 | 29 | enum mad_layer { 30 | MAD_LAYER_I = 1, /* Layer I */ 31 | MAD_LAYER_II = 2, /* Layer II */ 32 | MAD_LAYER_III = 3 /* Layer III */ 33 | }; 34 | 35 | enum mad_mode { 36 | MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ 37 | MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ 38 | MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ 39 | MAD_MODE_STEREO = 3 /* normal LR stereo */ 40 | }; 41 | 42 | enum mad_emphasis { 43 | MAD_EMPHASIS_NONE = 0, /* no emphasis */ 44 | MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ 45 | MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ 46 | MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ 47 | }; 48 | 49 | struct mad_header { 50 | enum mad_layer layer; /* audio layer (1, 2, or 3) */ 51 | enum mad_mode mode; /* channel mode (see above) */ 52 | int mode_extension; /* additional mode info */ 53 | enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ 54 | 55 | unsigned long bitrate; /* stream bitrate (bps) */ 56 | unsigned int samplerate; /* sampling frequency (Hz) */ 57 | 58 | unsigned short crc_check; /* frame CRC accumulator */ 59 | unsigned short crc_target; /* final target CRC checksum */ 60 | 61 | int flags; /* flags (see below) */ 62 | int private_bits; /* private bits (see below) */ 63 | 64 | mad_timer_t duration; /* audio playing time of frame */ 65 | }; 66 | 67 | struct mad_frame { 68 | struct mad_header header; /* MPEG audio header */ 69 | 70 | int options; /* decoding options (from stream) */ 71 | 72 | mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ 73 | mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ 74 | }; 75 | 76 | # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) 77 | # define MAD_NSBSAMPLES(header) \ 78 | ((header)->layer == MAD_LAYER_I ? 12 : \ 79 | (((header)->layer == MAD_LAYER_III && \ 80 | ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) 81 | 82 | enum { 83 | MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ 84 | MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ 85 | 86 | MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ 87 | MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ 88 | MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ 89 | MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ 90 | 91 | MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ 92 | MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ 93 | MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ 94 | 95 | MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ 96 | MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ 97 | MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ 98 | }; 99 | 100 | enum { 101 | MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ 102 | MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ 103 | }; 104 | 105 | void mad_header_init(struct mad_header *); 106 | 107 | # define mad_header_finish(header) /* nothing */ 108 | 109 | int mad_header_decode(struct mad_header *, struct mad_stream *); 110 | 111 | void mad_frame_init(struct mad_frame *); 112 | void mad_frame_finish(struct mad_frame *); 113 | 114 | int mad_frame_decode(struct mad_frame *, struct mad_stream *); 115 | 116 | void mad_frame_mute(struct mad_frame *); 117 | 118 | # endif 119 | -------------------------------------------------------------------------------- /libmad/huffman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_HUFFMAN_H 23 | # define LIBMAD_HUFFMAN_H 24 | 25 | union huffquad { 26 | struct { 27 | unsigned short final : 1; 28 | unsigned short bits : 3; 29 | unsigned short offset : 12; 30 | } ptr; 31 | struct { 32 | unsigned short final : 1; 33 | unsigned short hlen : 3; 34 | unsigned short v : 1; 35 | unsigned short w : 1; 36 | unsigned short x : 1; 37 | unsigned short y : 1; 38 | } value; 39 | unsigned short final : 1; 40 | }; 41 | 42 | union huffpair { 43 | struct { 44 | unsigned short final : 1; 45 | unsigned short bits : 3; 46 | unsigned short offset : 12; 47 | } ptr; 48 | struct { 49 | unsigned short final : 1; 50 | unsigned short hlen : 3; 51 | unsigned short x : 4; 52 | unsigned short y : 4; 53 | } value; 54 | unsigned short final : 1; 55 | }; 56 | 57 | struct hufftable { 58 | union huffpair const *table; 59 | unsigned short linbits; 60 | unsigned short startbits; 61 | }; 62 | 63 | extern union huffquad const *const mad_huff_quad_table[2]; 64 | extern struct hufftable const mad_huff_pair_table[32]; 65 | 66 | # endif 67 | -------------------------------------------------------------------------------- /libmad/imdct_s.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: imdct_s.dat,v 1.8 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */, 23 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 24 | -MAD_F(0x0216a2a2) /* -0.130526192 */, 25 | MAD_F(0x0fdcf549) /* 0.991444861 */, 26 | -MAD_F(0x061f78aa) /* -0.382683432 */, 27 | -MAD_F(0x0cb19346) /* -0.793353340 */ }, 28 | 29 | /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */, 30 | MAD_F(0x061f78aa) /* 0.382683432 */, 31 | MAD_F(0x0fdcf549) /* 0.991444861 */, 32 | MAD_F(0x0216a2a2) /* 0.130526192 */, 33 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 34 | -MAD_F(0x09bd7ca0) /* -0.608761429 */ }, 35 | 36 | /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */, 37 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 38 | MAD_F(0x0ec835e8) /* 0.923879533 */, 39 | -MAD_F(0x061f78aa) /* -0.382683432 */, 40 | -MAD_F(0x061f78aa) /* -0.382683432 */, 41 | MAD_F(0x0ec835e8) /* 0.923879533 */ }, 42 | 43 | /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */, 44 | -MAD_F(0x061f78aa) /* -0.382683432 */, 45 | MAD_F(0x061f78aa) /* 0.382683432 */, 46 | MAD_F(0x0ec835e8) /* 0.923879533 */, 47 | MAD_F(0x0ec835e8) /* 0.923879533 */, 48 | MAD_F(0x061f78aa) /* 0.382683432 */ }, 49 | 50 | /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */, 51 | -MAD_F(0x061f78aa) /* -0.382683432 */, 52 | MAD_F(0x09bd7ca0) /* 0.608761429 */, 53 | -MAD_F(0x0cb19346) /* -0.793353340 */, 54 | MAD_F(0x0ec835e8) /* 0.923879533 */, 55 | -MAD_F(0x0fdcf549) /* -0.991444861 */ }, 56 | 57 | /* 8 */ { -MAD_F(0x0fdcf549) /* -0.991444861 */, 58 | -MAD_F(0x0ec835e8) /* -0.923879533 */, 59 | -MAD_F(0x0cb19346) /* -0.793353340 */, 60 | -MAD_F(0x09bd7ca0) /* -0.608761429 */, 61 | -MAD_F(0x061f78aa) /* -0.382683432 */, 62 | -MAD_F(0x0216a2a2) /* -0.130526192 */ } 63 | -------------------------------------------------------------------------------- /libmad/layer12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: layer12.h,v 1.10 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_LAYER12_H 23 | # define LIBMAD_LAYER12_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | 28 | int mad_layer_I(struct mad_stream *, struct mad_frame *); 29 | int mad_layer_II(struct mad_stream *, struct mad_frame *); 30 | 31 | # endif 32 | -------------------------------------------------------------------------------- /libmad/layer3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_LAYER3_H 23 | # define LIBMAD_LAYER3_H 24 | 25 | # include "stream.h" 26 | # include "frame.h" 27 | 28 | int mad_layer_III(struct mad_stream *, struct mad_frame *); 29 | 30 | # endif 31 | -------------------------------------------------------------------------------- /libmad/libmad_config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to enable diagnostic debugging support. */ 5 | /* #undef DEBUG */ 6 | 7 | /* Define to enable experimental code. */ 8 | /* #undef EXPERIMENTAL */ 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_ASSERT_H 1 12 | 13 | /* Define to 1 if you have the header file. */ 14 | /* #undef HAVE_DLFCN_H */ 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_ERRNO_H 1 18 | 19 | /* Define to 1 if you have the `fcntl' function. */ 20 | /* #undef HAVE_FCNTL */ 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_FCNTL_H 1 24 | 25 | /* Define to 1 if you have the `fork' function. */ 26 | /* #undef HAVE_FORK */ 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_INTTYPES_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_LIMITS_H 1 33 | 34 | /* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */ 35 | /* #undef HAVE_MADD16_ASM */ 36 | 37 | /* Define if your MIPS CPU supports a 2-operand MADD instruction. */ 38 | /* #undef HAVE_MADD_ASM */ 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_MEMORY_H 1 42 | 43 | /* Define to 1 if you have the `pipe' function. */ 44 | /* #undef HAVE_PIPE */ 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_STDINT_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_STDLIB_H 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_STRINGS_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_STRING_H 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_SYS_STAT_H 1 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #define HAVE_SYS_TYPES_H 1 63 | 64 | /* Define to 1 if you have that is POSIX.1 compatible. */ 65 | /* #undef HAVE_SYS_WAIT_H */ 66 | 67 | /* Define to 1 if you have the header file. */ 68 | /* #undef HAVE_UNISTD_H */ 69 | 70 | /* Define to 1 if you have the `waitpid' function. */ 71 | /* #undef HAVE_WAITPID */ 72 | 73 | /* Define to disable debugging assertions. */ 74 | /* #undef NDEBUG */ 75 | 76 | /* Define to optimize for accuracy over speed. */ 77 | /* #undef OPT_ACCURACY */ 78 | 79 | /* Define to optimize for speed over accuracy. */ 80 | /* #undef OPT_SPEED */ 81 | 82 | /* Define to enable a fast subband synthesis approximation optimization. */ 83 | /* #undef OPT_SSO */ 84 | 85 | /* Define to influence a strict interpretation of the ISO/IEC standards, even 86 | if this is in opposition with best accepted practices. */ 87 | /* #undef OPT_STRICT */ 88 | 89 | /* Name of package */ 90 | #define PACKAGE "libmad" 91 | 92 | /* Define to the address where bug reports for this package should be sent. */ 93 | #define PACKAGE_BUGREPORT "support@underbit.com" 94 | 95 | /* Define to the full name of this package. */ 96 | #define PACKAGE_NAME "MPEG Audio Decoder" 97 | 98 | /* Define to the full name and version of this package. */ 99 | #define PACKAGE_STRING "MPEG Audio Decoder 0.15.1b" 100 | 101 | /* Define to the one symbol short name of this package. */ 102 | #define PACKAGE_TARNAME "libmad" 103 | 104 | /* Define to the version of this package. */ 105 | #define PACKAGE_VERSION "0.15.1b" 106 | 107 | /* The size of a `int', as computed by sizeof. */ 108 | #define SIZEOF_INT 4 109 | 110 | /* The size of a `long', as computed by sizeof. */ 111 | #define SIZEOF_LONG 4 112 | 113 | /* The size of a `long long', as computed by sizeof. */ 114 | #define SIZEOF_LONG_LONG 8 115 | 116 | /* Define to 1 if you have the ANSI C header files. */ 117 | #define STDC_HEADERS 1 118 | 119 | /* Version number of package */ 120 | #define VERSION "0.15.1b" 121 | 122 | /* Define to empty if `const' does not conform to ANSI C. */ 123 | /* #undef const */ 124 | 125 | /* Define as `__inline' if that's what the C compiler calls it, or to nothing 126 | if it is not supported. */ 127 | #define inline __inline 128 | 129 | /* Define to `int' if does not define. */ 130 | /* #undef pid_t */ 131 | 132 | #define FPM_DEFAULT 1 133 | 134 | #ifdef _MSC_VER 135 | #pragma warning (disable:4018) 136 | #pragma warning (disable:4146) 137 | #pragma warning (disable:4244) 138 | #pragma warning (disable:4996) 139 | #endif 140 | -------------------------------------------------------------------------------- /libmad/libmad_global.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_GLOBAL_H 23 | # define LIBMAD_GLOBAL_H 24 | 25 | /* conditional debugging */ 26 | 27 | # if defined(DEBUG) && defined(NDEBUG) 28 | # error "cannot define both DEBUG and NDEBUG" 29 | # endif 30 | 31 | # if defined(DEBUG) 32 | # include 33 | # endif 34 | 35 | /* conditional features */ 36 | 37 | # if defined(OPT_SPEED) && defined(OPT_ACCURACY) 38 | # error "cannot optimize for both speed and accuracy" 39 | # endif 40 | 41 | # if defined(OPT_SPEED) && !defined(OPT_SSO) 42 | # define OPT_SSO 43 | # endif 44 | 45 | # if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \ 46 | defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK) 47 | # define USE_ASYNC 48 | # endif 49 | 50 | # if !defined(HAVE_ASSERT_H) 51 | # if defined(NDEBUG) 52 | # define assert(x) /* nothing */ 53 | # else 54 | # define assert(x) do { if (!(x)) abort(); } while (0) 55 | # endif 56 | # endif 57 | 58 | # endif 59 | -------------------------------------------------------------------------------- /libmad/music_mad.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2004 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #include "mad.h" 24 | #include "SDL_rwops.h" 25 | #include "SDL_audio.h" 26 | 27 | #define MAD_INPUT_BUFFER_SIZE (5*8192) 28 | #define MAD_OUTPUT_BUFFER_SIZE 8192 29 | 30 | enum { 31 | MS_input_eof = 0x0001, 32 | MS_input_error = 0x0001, 33 | MS_decode_eof = 0x0002, 34 | MS_decode_error = 0x0004, 35 | MS_error_flags = 0x000f, 36 | 37 | MS_playing = 0x0100, 38 | MS_cvt_decoded = 0x0200, 39 | }; 40 | 41 | typedef struct { 42 | SDL_RWops *rw; 43 | struct mad_stream stream; 44 | struct mad_frame frame; 45 | struct mad_synth synth; 46 | int frames_read; 47 | mad_timer_t next_frame_start; 48 | int volume; 49 | int status; 50 | int output_begin, output_end; 51 | SDL_AudioSpec mixer; 52 | SDL_AudioCVT cvt; 53 | 54 | unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD]; 55 | unsigned char output_buffer[MAD_OUTPUT_BUFFER_SIZE]; 56 | } mad_data; 57 | 58 | mad_data *mad_openFile(const char *filename, SDL_AudioSpec *mixer); 59 | mad_data *mad_openFileRW(SDL_RWops *rw, SDL_AudioSpec *mixer); 60 | void mad_closeFile(mad_data *mp3_mad); 61 | 62 | void mad_start(mad_data *mp3_mad); 63 | void mad_stop(mad_data *mp3_mad); 64 | int mad_isPlaying(mad_data *mp3_mad); 65 | 66 | void mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len); 67 | void mad_seek(mad_data *mp3_mad, double position); 68 | void mad_setVolume(mad_data *mp3_mad, int volume); 69 | -------------------------------------------------------------------------------- /libmad/qc_table.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: qc_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $ 20 | */ 21 | 22 | /* 23 | * These are the Layer II classes of quantization. 24 | * The table is derived from Table B.4 of ISO/IEC 11172-3. 25 | */ 26 | 27 | { 3, 2, 5, 28 | MAD_F(0x15555555) /* 1.33333333333 => 1.33333333209, e 0.00000000124 */, 29 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, 30 | { 5, 3, 7, 31 | MAD_F(0x1999999a) /* 1.60000000000 => 1.60000000149, e -0.00000000149 */, 32 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, 33 | { 7, 0, 3, 34 | MAD_F(0x12492492) /* 1.14285714286 => 1.14285714179, e 0.00000000107 */, 35 | MAD_F(0x04000000) /* 0.25000000000 => 0.25000000000, e 0.00000000000 */ }, 36 | { 9, 4, 10, 37 | MAD_F(0x1c71c71c) /* 1.77777777777 => 1.77777777612, e 0.00000000165 */, 38 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, 39 | { 15, 0, 4, 40 | MAD_F(0x11111111) /* 1.06666666666 => 1.06666666642, e 0.00000000024 */, 41 | MAD_F(0x02000000) /* 0.12500000000 => 0.12500000000, e 0.00000000000 */ }, 42 | { 31, 0, 5, 43 | MAD_F(0x10842108) /* 1.03225806452 => 1.03225806355, e 0.00000000097 */, 44 | MAD_F(0x01000000) /* 0.06250000000 => 0.06250000000, e 0.00000000000 */ }, 45 | { 63, 0, 6, 46 | MAD_F(0x10410410) /* 1.01587301587 => 1.01587301493, e 0.00000000094 */, 47 | MAD_F(0x00800000) /* 0.03125000000 => 0.03125000000, e 0.00000000000 */ }, 48 | { 127, 0, 7, 49 | MAD_F(0x10204081) /* 1.00787401575 => 1.00787401572, e 0.00000000003 */, 50 | MAD_F(0x00400000) /* 0.01562500000 => 0.01562500000, e 0.00000000000 */ }, 51 | { 255, 0, 8, 52 | MAD_F(0x10101010) /* 1.00392156863 => 1.00392156839, e 0.00000000024 */, 53 | MAD_F(0x00200000) /* 0.00781250000 => 0.00781250000, e 0.00000000000 */ }, 54 | { 511, 0, 9, 55 | MAD_F(0x10080402) /* 1.00195694716 => 1.00195694715, e 0.00000000001 */, 56 | MAD_F(0x00100000) /* 0.00390625000 => 0.00390625000, e 0.00000000000 */ }, 57 | { 1023, 0, 10, 58 | MAD_F(0x10040100) /* 1.00097751711 => 1.00097751617, e 0.00000000094 */, 59 | MAD_F(0x00080000) /* 0.00195312500 => 0.00195312500, e 0.00000000000 */ }, 60 | { 2047, 0, 11, 61 | MAD_F(0x10020040) /* 1.00048851979 => 1.00048851967, e 0.00000000012 */, 62 | MAD_F(0x00040000) /* 0.00097656250 => 0.00097656250, e 0.00000000000 */ }, 63 | { 4095, 0, 12, 64 | MAD_F(0x10010010) /* 1.00024420024 => 1.00024420023, e 0.00000000001 */, 65 | MAD_F(0x00020000) /* 0.00048828125 => 0.00048828125, e 0.00000000000 */ }, 66 | { 8191, 0, 13, 67 | MAD_F(0x10008004) /* 1.00012208522 => 1.00012208521, e 0.00000000001 */, 68 | MAD_F(0x00010000) /* 0.00024414063 => 0.00024414062, e 0.00000000000 */ }, 69 | { 16383, 0, 14, 70 | MAD_F(0x10004001) /* 1.00006103888 => 1.00006103888, e -0.00000000000 */, 71 | MAD_F(0x00008000) /* 0.00012207031 => 0.00012207031, e -0.00000000000 */ }, 72 | { 32767, 0, 15, 73 | MAD_F(0x10002000) /* 1.00003051851 => 1.00003051758, e 0.00000000093 */, 74 | MAD_F(0x00004000) /* 0.00006103516 => 0.00006103516, e 0.00000000000 */ }, 75 | { 65535, 0, 16, 76 | MAD_F(0x10001000) /* 1.00001525902 => 1.00001525879, e 0.00000000023 */, 77 | MAD_F(0x00002000) /* 0.00003051758 => 0.00003051758, e 0.00000000000 */ } 78 | -------------------------------------------------------------------------------- /libmad/stream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: stream.c,v 1.12 2004/02/05 09:02:39 rob Exp $ 20 | */ 21 | 22 | # include "libmad_config.h" 23 | 24 | # include "libmad_global.h" 25 | 26 | # include 27 | 28 | # include "bit.h" 29 | # include "stream.h" 30 | 31 | /* 32 | * NAME: stream->init() 33 | * DESCRIPTION: initialize stream struct 34 | */ 35 | void mad_stream_init(struct mad_stream *stream) 36 | { 37 | stream->buffer = 0; 38 | stream->bufend = 0; 39 | stream->skiplen = 0; 40 | 41 | stream->sync = 0; 42 | stream->freerate = 0; 43 | 44 | stream->this_frame = 0; 45 | stream->next_frame = 0; 46 | mad_bit_init(&stream->ptr, 0); 47 | 48 | mad_bit_init(&stream->anc_ptr, 0); 49 | stream->anc_bitlen = 0; 50 | 51 | stream->main_data = 0; 52 | stream->md_len = 0; 53 | 54 | stream->options = 0; 55 | stream->error = MAD_ERROR_NONE; 56 | } 57 | 58 | /* 59 | * NAME: stream->finish() 60 | * DESCRIPTION: deallocate any dynamic memory associated with stream 61 | */ 62 | void mad_stream_finish(struct mad_stream *stream) 63 | { 64 | if (stream->main_data) { 65 | free(stream->main_data); 66 | stream->main_data = 0; 67 | } 68 | 69 | mad_bit_finish(&stream->anc_ptr); 70 | mad_bit_finish(&stream->ptr); 71 | } 72 | 73 | /* 74 | * NAME: stream->buffer() 75 | * DESCRIPTION: set stream buffer pointers 76 | */ 77 | void mad_stream_buffer(struct mad_stream *stream, 78 | unsigned char const *buffer, unsigned long length) 79 | { 80 | stream->buffer = buffer; 81 | stream->bufend = buffer + length; 82 | 83 | stream->this_frame = buffer; 84 | stream->next_frame = buffer; 85 | 86 | stream->sync = 1; 87 | 88 | mad_bit_init(&stream->ptr, buffer); 89 | } 90 | 91 | /* 92 | * NAME: stream->skip() 93 | * DESCRIPTION: arrange to skip bytes before the next frame 94 | */ 95 | void mad_stream_skip(struct mad_stream *stream, unsigned long length) 96 | { 97 | stream->skiplen += length; 98 | } 99 | 100 | /* 101 | * NAME: stream->sync() 102 | * DESCRIPTION: locate the next stream sync word 103 | */ 104 | int mad_stream_sync(struct mad_stream *stream) 105 | { 106 | register unsigned char const *ptr, *end; 107 | 108 | ptr = mad_bit_nextbyte(&stream->ptr); 109 | end = stream->bufend; 110 | 111 | while (ptr < end - 1 && 112 | !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) 113 | ++ptr; 114 | 115 | if (end - ptr < MAD_BUFFER_GUARD) 116 | return -1; 117 | 118 | mad_bit_init(&stream->ptr, ptr); 119 | 120 | return 0; 121 | } 122 | 123 | /* 124 | * NAME: stream->errorstr() 125 | * DESCRIPTION: return a string description of the current error condition 126 | */ 127 | char const *mad_stream_errorstr(struct mad_stream const *stream) 128 | { 129 | switch (stream->error) { 130 | case MAD_ERROR_NONE: return "no error"; 131 | 132 | case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)"; 133 | case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer"; 134 | 135 | case MAD_ERROR_NOMEM: return "not enough memory"; 136 | 137 | case MAD_ERROR_LOSTSYNC: return "lost synchronization"; 138 | case MAD_ERROR_BADLAYER: return "reserved header layer value"; 139 | case MAD_ERROR_BADBITRATE: return "forbidden bitrate value"; 140 | case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value"; 141 | case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value"; 142 | 143 | case MAD_ERROR_BADCRC: return "CRC check failed"; 144 | case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value"; 145 | case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index"; 146 | case MAD_ERROR_BADMODE: return "bad bitrate/mode combination"; 147 | case MAD_ERROR_BADFRAMELEN: return "bad frame length"; 148 | case MAD_ERROR_BADBIGVALUES: return "bad big_values count"; 149 | case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type"; 150 | case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info"; 151 | case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer"; 152 | case MAD_ERROR_BADPART3LEN: return "bad audio data length"; 153 | case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select"; 154 | case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun"; 155 | case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS"; 156 | } 157 | 158 | return 0; 159 | } 160 | -------------------------------------------------------------------------------- /libmad/stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_STREAM_H 23 | # define LIBMAD_STREAM_H 24 | 25 | # include "bit.h" 26 | 27 | # define MAD_BUFFER_GUARD 8 28 | # define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) 29 | 30 | enum mad_error { 31 | MAD_ERROR_NONE = 0x0000, /* no error */ 32 | 33 | MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ 34 | MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ 35 | 36 | MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ 37 | 38 | MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ 39 | MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ 40 | MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ 41 | MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ 42 | MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ 43 | 44 | MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ 45 | MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ 46 | MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ 47 | MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ 48 | MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ 49 | MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ 50 | MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ 51 | MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ 52 | MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ 53 | MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ 54 | MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ 55 | MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ 56 | MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ 57 | }; 58 | 59 | # define MAD_RECOVERABLE(error) ((error) & 0xff00) 60 | 61 | struct mad_stream { 62 | unsigned char const *buffer; /* input bitstream buffer */ 63 | unsigned char const *bufend; /* end of buffer */ 64 | unsigned long skiplen; /* bytes to skip before next frame */ 65 | 66 | int sync; /* stream sync found */ 67 | unsigned long freerate; /* free bitrate (fixed) */ 68 | 69 | unsigned char const *this_frame; /* start of current frame */ 70 | unsigned char const *next_frame; /* start of next frame */ 71 | struct mad_bitptr ptr; /* current processing bit pointer */ 72 | 73 | struct mad_bitptr anc_ptr; /* ancillary bits pointer */ 74 | unsigned int anc_bitlen; /* number of ancillary bits */ 75 | 76 | unsigned char (*main_data)[MAD_BUFFER_MDLEN]; 77 | /* Layer III main_data() */ 78 | unsigned int md_len; /* bytes in main_data */ 79 | 80 | int options; /* decoding options (see below) */ 81 | enum mad_error error; /* error code (see above) */ 82 | }; 83 | 84 | enum { 85 | MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ 86 | MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ 87 | # if 0 /* not yet implemented */ 88 | MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ 89 | MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ 90 | MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ 91 | # endif 92 | }; 93 | 94 | void mad_stream_init(struct mad_stream *); 95 | void mad_stream_finish(struct mad_stream *); 96 | 97 | # define mad_stream_options(stream, opts) \ 98 | ((void) ((stream)->options = (opts))) 99 | 100 | void mad_stream_buffer(struct mad_stream *, 101 | unsigned char const *, unsigned long); 102 | void mad_stream_skip(struct mad_stream *, unsigned long); 103 | 104 | int mad_stream_sync(struct mad_stream *); 105 | 106 | char const *mad_stream_errorstr(struct mad_stream const *); 107 | 108 | # endif 109 | -------------------------------------------------------------------------------- /libmad/synth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_SYNTH_H 23 | # define LIBMAD_SYNTH_H 24 | 25 | # include "fixed.h" 26 | # include "frame.h" 27 | 28 | struct mad_pcm { 29 | unsigned int samplerate; /* sampling frequency (Hz) */ 30 | unsigned short channels; /* number of channels */ 31 | unsigned short length; /* number of samples per channel */ 32 | mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ 33 | }; 34 | 35 | struct mad_synth { 36 | mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ 37 | /* [ch][eo][peo][s][v] */ 38 | 39 | unsigned int phase; /* current processing phase */ 40 | 41 | struct mad_pcm pcm; /* PCM output */ 42 | }; 43 | 44 | /* single channel PCM selector */ 45 | enum { 46 | MAD_PCM_CHANNEL_SINGLE = 0 47 | }; 48 | 49 | /* dual channel PCM selector */ 50 | enum { 51 | MAD_PCM_CHANNEL_DUAL_1 = 0, 52 | MAD_PCM_CHANNEL_DUAL_2 = 1 53 | }; 54 | 55 | /* stereo PCM selector */ 56 | enum { 57 | MAD_PCM_CHANNEL_STEREO_LEFT = 0, 58 | MAD_PCM_CHANNEL_STEREO_RIGHT = 1 59 | }; 60 | 61 | void mad_synth_init(struct mad_synth *); 62 | 63 | # define mad_synth_finish(synth) /* nothing */ 64 | 65 | void mad_synth_mute(struct mad_synth *); 66 | 67 | void mad_synth_frame(struct mad_synth *, struct mad_frame const *); 68 | 69 | # endif 70 | -------------------------------------------------------------------------------- /libmad/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libmad - MPEG audio decoder library 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $ 20 | */ 21 | 22 | # ifndef LIBMAD_TIMER_H 23 | # define LIBMAD_TIMER_H 24 | 25 | typedef struct { 26 | signed long seconds; /* whole seconds */ 27 | unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */ 28 | } mad_timer_t; 29 | 30 | extern mad_timer_t const mad_timer_zero; 31 | 32 | # define MAD_TIMER_RESOLUTION 352800000UL 33 | 34 | enum mad_units { 35 | MAD_UNITS_HOURS = -2, 36 | MAD_UNITS_MINUTES = -1, 37 | MAD_UNITS_SECONDS = 0, 38 | 39 | /* metric units */ 40 | 41 | MAD_UNITS_DECISECONDS = 10, 42 | MAD_UNITS_CENTISECONDS = 100, 43 | MAD_UNITS_MILLISECONDS = 1000, 44 | 45 | /* audio sample units */ 46 | 47 | MAD_UNITS_8000_HZ = 8000, 48 | MAD_UNITS_11025_HZ = 11025, 49 | MAD_UNITS_12000_HZ = 12000, 50 | 51 | MAD_UNITS_16000_HZ = 16000, 52 | MAD_UNITS_22050_HZ = 22050, 53 | MAD_UNITS_24000_HZ = 24000, 54 | 55 | MAD_UNITS_32000_HZ = 32000, 56 | MAD_UNITS_44100_HZ = 44100, 57 | MAD_UNITS_48000_HZ = 48000, 58 | 59 | /* video frame/field units */ 60 | 61 | MAD_UNITS_24_FPS = 24, 62 | MAD_UNITS_25_FPS = 25, 63 | MAD_UNITS_30_FPS = 30, 64 | MAD_UNITS_48_FPS = 48, 65 | MAD_UNITS_50_FPS = 50, 66 | MAD_UNITS_60_FPS = 60, 67 | 68 | /* CD audio frames */ 69 | 70 | MAD_UNITS_75_FPS = 75, 71 | 72 | /* video drop-frame units */ 73 | 74 | MAD_UNITS_23_976_FPS = -24, 75 | MAD_UNITS_24_975_FPS = -25, 76 | MAD_UNITS_29_97_FPS = -30, 77 | MAD_UNITS_47_952_FPS = -48, 78 | MAD_UNITS_49_95_FPS = -50, 79 | MAD_UNITS_59_94_FPS = -60 80 | }; 81 | 82 | # define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero)) 83 | 84 | int mad_timer_compare(mad_timer_t, mad_timer_t); 85 | 86 | # define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero) 87 | 88 | void mad_timer_negate(mad_timer_t *); 89 | mad_timer_t mad_timer_abs(mad_timer_t); 90 | 91 | void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long); 92 | void mad_timer_add(mad_timer_t *, mad_timer_t); 93 | void mad_timer_multiply(mad_timer_t *, signed long); 94 | 95 | signed long mad_timer_count(mad_timer_t, enum mad_units); 96 | unsigned long mad_timer_fraction(mad_timer_t, unsigned long); 97 | void mad_timer_string(mad_timer_t, char *, char const *, 98 | enum mad_units, enum mad_units, unsigned long); 99 | 100 | # endif 101 | -------------------------------------------------------------------------------- /magicmenu.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef MAGICMENU_H 23 | #define MAGICMENU_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | WORD 31 | PAL_MagicSelectionMenuUpdate( 32 | VOID 33 | ); 34 | 35 | VOID 36 | PAL_MagicSelectionMenuInit( 37 | WORD wPlayerRole, 38 | BOOL fInBattle, 39 | WORD wDefaultMagic 40 | ); 41 | 42 | WORD 43 | PAL_MagicSelectionMenu( 44 | WORD wPlayerRole, 45 | BOOL fInBattle, 46 | WORD wDefaultMagic 47 | ); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef MAIN_H 23 | #define MAIN_H 24 | 25 | #include "common.h" 26 | #include "util.h" 27 | #include "palcommon.h" 28 | #include "font.h" 29 | #include "global.h" 30 | #include "map.h" 31 | #include "res.h" 32 | #include "scene.h" 33 | #include "rixplay.h" 34 | #include "sound.h" 35 | #include "video.h" 36 | #include "input.h" 37 | #include "text.h" 38 | #include "ui.h" 39 | #include "uigame.h" 40 | #include "uibattle.h" 41 | #include "magicmenu.h" 42 | #include "itemmenu.h" 43 | #include "palette.h" 44 | #include "rngplay.h" 45 | #include "ending.h" 46 | #include "script.h" 47 | #include "battle.h" 48 | #include "fight.h" 49 | #include "play.h" 50 | #include "game.h" 51 | 52 | #ifdef PAL_HAS_NATIVEMIDI 53 | #include "midi.h" 54 | #endif 55 | 56 | VOID 57 | PAL_Shutdown( 58 | VOID 59 | ); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /main_PSP.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Pal_Bazzi. 4 | // 5 | // All rights reserved. 6 | // 7 | // This file is part of SDLPAL. 8 | // 9 | // SDLPAL is free software: you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // This program is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with this program. If not, see . 21 | // 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #define PSP_HEAP_MEMSIZE 12288 32 | 33 | PSP_MODULE_INFO("SDLPAL", 0, 1, 1); 34 | PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER); 35 | PSP_HEAP_SIZE_KB(PSP_HEAP_MEMSIZE); 36 | 37 | // 38 | //Exit callback 39 | // 40 | int PSPExitCallback(int arg1, int arg2, void *common) 41 | { 42 | exit(0); 43 | return 0; 44 | } 45 | 46 | // 47 | //Reopen MKF files when resume from suspend 48 | // 49 | int PSPSuspendCallback(int arg1, int pwrflags, void *common) 50 | { 51 | if (pwrflags & PSP_POWER_CB_RESUME_COMPLETE) 52 | { 53 | UTIL_CloseFile(gpGlobals->f.fpFBP); 54 | UTIL_CloseFile(gpGlobals->f.fpMGO); 55 | UTIL_CloseFile(gpGlobals->f.fpBALL); 56 | UTIL_CloseFile(gpGlobals->f.fpDATA); 57 | UTIL_CloseFile(gpGlobals->f.fpF); 58 | UTIL_CloseFile(gpGlobals->f.fpFIRE); 59 | UTIL_CloseFile(gpGlobals->f.fpRGM); 60 | UTIL_CloseFile(gpGlobals->f.fpSSS); 61 | gpGlobals->f.fpFBP = UTIL_OpenRequiredFile("fbp.mkf"); 62 | gpGlobals->f.fpDATA = UTIL_OpenRequiredFile("data.mkf"); 63 | gpGlobals->f.fpFIRE = UTIL_OpenRequiredFile("fire.mkf"); 64 | gpGlobals->f.fpSSS = UTIL_OpenRequiredFile("sss.mkf"); 65 | gpGlobals->lpObjectDesc = PAL_LoadObjectDesc(va("%s%s", PAL_PREFIX, "desc.dat")); 66 | SOUND_ReloadVOC(); 67 | } 68 | int cbid; 69 | cbid = sceKernelCreateCallback("suspend Callback", PSPSuspendCallback, NULL); 70 | scePowerRegisterCallback(0, cbid); 71 | return 0; 72 | } 73 | 74 | // 75 | //setup callbacks thread 76 | // 77 | int PSPRegisterCallbackThread(SceSize args, void *argp) 78 | { 79 | int cbid; 80 | cbid = sceKernelCreateCallback("Exit Callback", PSPExitCallback, NULL); 81 | sceKernelRegisterExitCallback(cbid); 82 | cbid = sceKernelCreateCallback("suspend Callback", PSPSuspendCallback, NULL); 83 | scePowerRegisterCallback(0, cbid); 84 | sceKernelSleepThreadCB(); 85 | return 0; 86 | } 87 | 88 | // 89 | //setup exit callback 90 | // 91 | int PSPSetupCallbacks(void) 92 | { 93 | int thid = 0; 94 | thid = sceKernelCreateThread("update_thread", PSPRegisterCallbackThread, 0x11, 0xFA0, 0, 0); 95 | if(thid >= 0) 96 | sceKernelStartThread(thid, 0, 0); 97 | return thid; 98 | } 99 | 100 | // 101 | //Init on PSP 102 | // 103 | void sdlpal_psp_init(void) 104 | { 105 | // Init Debug Screen 106 | pspDebugScreenInit(); 107 | 108 | // PSP set callbacks 109 | PSPSetupCallbacks(); 110 | 111 | // Register sceKernelExitGame() to be called when we exit 112 | atexit(sceKernelExitGame); 113 | 114 | // set PSP CPU clock 115 | scePowerSetClockFrequency(333 , 333 , 166); 116 | } 117 | -------------------------------------------------------------------------------- /map.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef _MAP_H 23 | #define _MAP_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | #include "common.h" 31 | 32 | // 33 | // Map format: 34 | // 35 | // +----------------------------------------------> x 36 | // | * * * * * * * * * * ... * * * * * * * * * * (y = 0, h = 0) 37 | // | * * * * * * * * * * ... * * * * * * * * * * (y = 0, h = 1) 38 | // | * * * * * * * * * * ... * * * * * * * * * * (y = 1, h = 0) 39 | // | * * * * * * * * * * ... * * * * * * * * * * (y = 1, h = 1) 40 | // | * * * * * * * * * * ... * * * * * * * * * * (y = 2, h = 0) 41 | // | * * * * * * * * * * ... * * * * * * * * * * (y = 2, h = 1) 42 | // | ............................................ 43 | // v 44 | // y 45 | // 46 | // Note: 47 | // 48 | // Tiles are in diamond shape (32x15). 49 | // 50 | // Each tile is represented with a DWORD value, which contains information 51 | // about the tile bitmap, block flag, height, etc. 52 | // 53 | // Bottom layer sprite index: 54 | // (d & 0xFF) | ((d >> 4) & 0x100) 55 | // 56 | // Top layer sprite index: 57 | // d >>= 16; 58 | // ((d & 0xFF) | ((d >> 4) & 0x100)) - 1) 59 | // 60 | // Block flag (player cannot walk through this tile): 61 | // d & 0x2000 62 | // 63 | 64 | typedef struct tagPALMAP 65 | { 66 | DWORD Tiles[128][64][2]; 67 | LPSPRITE pTileSprite; 68 | INT iMapNum; 69 | } PALMAP, *LPPALMAP; 70 | 71 | typedef const PALMAP *LPCPALMAP; 72 | 73 | LPPALMAP 74 | PAL_LoadMap( 75 | INT iMapNum, 76 | FILE *fpMapMKF, 77 | FILE *fpGopMKF 78 | ); 79 | 80 | VOID 81 | PAL_FreeMap( 82 | LPPALMAP lpMap 83 | ); 84 | 85 | LPCBITMAPRLE 86 | PAL_MapGetTileBitmap( 87 | BYTE x, 88 | BYTE y, 89 | BYTE h, 90 | BYTE ucLayer, 91 | LPCPALMAP lpMap 92 | ); 93 | 94 | BOOL 95 | PAL_MapTileIsBlocked( 96 | BYTE x, 97 | BYTE y, 98 | BYTE h, 99 | LPCPALMAP lpMap 100 | ); 101 | 102 | BYTE 103 | PAL_MapGetTileHeight( 104 | BYTE x, 105 | BYTE y, 106 | BYTE h, 107 | BYTE ucLayer, 108 | LPCPALMAP lpMap 109 | ); 110 | 111 | VOID 112 | PAL_MapBlitToSurface( 113 | LPCPALMAP lpMap, 114 | SDL_Surface *lpSurface, 115 | const SDL_Rect *lpSrcRect, 116 | BYTE ucLayer 117 | ); 118 | 119 | // 120 | // Convert map location to the real location 121 | // 122 | #define PAL_XYH_TO_POS(x, y, h) \ 123 | PAL_POS((x) * 32 + (h) * 16, (y) * 16 + (h) * 8) 124 | 125 | // 126 | // Convert real location to map location 127 | // 128 | #define PAL_POS_TO_XYH(pos, x, y, h) \ 129 | { \ 130 | (h) = (BYTE)(((PAL_X(pos) % 32) != 0) ? 1 : 0); \ 131 | (x) = (BYTE)(PAL_X(pos) / 32); \ 132 | (y) = (BYTE)(PAL_Y(pos) / 16); \ 133 | } 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /midi.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2011, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #include "main.h" 23 | 24 | #if !defined (CYGWIN) && !defined (DINGOO) && !defined (GEKKO) && !defined (GPH) && !defined(__N3DS__) 25 | 26 | static INT iMidCurrent = -1; 27 | static BOOL fMidLoop = FALSE; 28 | 29 | static NativeMidiSong *g_pMid = NULL; 30 | 31 | VOID 32 | MIDI_Play( 33 | INT iNumRIX, 34 | BOOL fLoop 35 | ) 36 | /*++ 37 | Purpose: 38 | 39 | Start playing the specified music in MIDI format. 40 | 41 | Parameters: 42 | 43 | [IN] iNumRIX - number of the music. 0 to stop playing current music. 44 | 45 | [IN] fLoop - Whether the music should be looped or not. 46 | 47 | Return value: 48 | 49 | None. 50 | 51 | --*/ 52 | { 53 | FILE *fp; 54 | unsigned char *buf; 55 | int size; 56 | SDL_RWops *rw; 57 | #ifdef PAL_WIN95 58 | char filename[1024]; 59 | #endif 60 | 61 | if (g_pMid != NULL && iNumRIX == iMidCurrent && native_midi_active()) 62 | { 63 | return; 64 | } 65 | 66 | SOUND_PlayCDA(-1); 67 | native_midi_freesong(g_pMid); 68 | g_pMid = NULL; 69 | iMidCurrent = -1; 70 | 71 | if (g_fNoMusic || iNumRIX <= 0) 72 | { 73 | return; 74 | } 75 | 76 | #ifdef PAL_WIN95 77 | sprintf(filename, "%s/musics/%.3d.mid", PAL_PREFIX, iNumRIX); 78 | 79 | g_pMid = native_midi_loadsong(filename); 80 | if (g_pMid != NULL) 81 | { 82 | native_midi_start(g_pMid); 83 | 84 | iMidCurrent = iNumRIX; 85 | fMidLoop = fLoop; 86 | } 87 | #else 88 | fp = UTIL_OpenFile("midi.mkf"); 89 | if (fp == NULL) 90 | { 91 | return; 92 | } 93 | 94 | if (iNumRIX > PAL_MKFGetChunkCount(fp)) 95 | { 96 | fclose(fp); 97 | return; 98 | } 99 | 100 | size = PAL_MKFGetChunkSize(iNumRIX, fp); 101 | if (size <= 0) 102 | { 103 | fclose(fp); 104 | return; 105 | } 106 | 107 | buf = (unsigned char *)UTIL_malloc(size); 108 | 109 | PAL_MKFReadChunk((LPBYTE)buf, size, iNumRIX, fp); 110 | fclose(fp); 111 | 112 | rw = SDL_RWFromConstMem((const void *)buf, size); 113 | 114 | g_pMid = native_midi_loadsong_RW(rw); 115 | if (g_pMid != NULL) 116 | { 117 | native_midi_start(g_pMid); 118 | 119 | iMidCurrent = iNumRIX; 120 | fMidLoop = fLoop; 121 | } 122 | 123 | SDL_RWclose(rw); 124 | free(buf); 125 | #endif 126 | } 127 | 128 | VOID 129 | MIDI_CheckLoop( 130 | VOID 131 | ) 132 | { 133 | if (fMidLoop && g_pMid != NULL && !native_midi_active()) 134 | { 135 | MIDI_Play(iMidCurrent, TRUE); 136 | } 137 | } 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /midi.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2011, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef PAL_MIDI_H 23 | #define PAL_MIDI_H 24 | 25 | #include "common.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif 31 | 32 | #include "native_midi/native_midi.h" 33 | 34 | VOID 35 | MIDI_Play( 36 | INT iNumRIX, 37 | BOOL fLoop 38 | ); 39 | 40 | VOID 41 | MIDI_CheckLoop( 42 | VOID 43 | ); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /native_midi/native_midi.h: -------------------------------------------------------------------------------- 1 | /* 2 | native_midi: Hardware Midi support for the SDL_mixer library 3 | Copyright (C) 2000 Florian 'Proff' Schulze 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Florian 'Proff' Schulze 20 | florian.proff.schulze@gmx.net 21 | */ 22 | 23 | #ifndef _NATIVE_MIDI_H_ 24 | #define _NATIVE_MIDI_H_ 25 | 26 | #include 27 | 28 | typedef struct _NativeMidiSong NativeMidiSong; 29 | 30 | int native_midi_detect(); 31 | NativeMidiSong *native_midi_loadsong(const char *midifile); 32 | NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw); 33 | void native_midi_freesong(NativeMidiSong *song); 34 | void native_midi_start(NativeMidiSong *song); 35 | void native_midi_stop(); 36 | int native_midi_active(); 37 | void native_midi_setvolume(int volume); 38 | const char *native_midi_error(void); 39 | 40 | #endif /* _NATIVE_MIDI_H_ */ 41 | -------------------------------------------------------------------------------- /native_midi/native_midi_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | native_midi: Hardware Midi support for the SDL_mixer library 3 | Copyright (C) 2000,2001 Florian 'Proff' Schulze & Max Horn 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Florian 'Proff' Schulze 20 | florian.proff.schulze@gmx.net 21 | 22 | Max Horn 23 | max@quendi.de 24 | */ 25 | 26 | #ifndef _NATIVE_MIDI_COMMON_H_ 27 | #define _NATIVE_MIDI_COMMON_H_ 28 | 29 | #include "SDL.h" 30 | 31 | /* Midi Status Bytes */ 32 | #define MIDI_STATUS_NOTE_OFF 0x8 33 | #define MIDI_STATUS_NOTE_ON 0x9 34 | #define MIDI_STATUS_AFTERTOUCH 0xA 35 | #define MIDI_STATUS_CONTROLLER 0xB 36 | #define MIDI_STATUS_PROG_CHANGE 0xC 37 | #define MIDI_STATUS_PRESSURE 0xD 38 | #define MIDI_STATUS_PITCH_WHEEL 0xE 39 | #define MIDI_STATUS_SYSEX 0xF 40 | 41 | /* We store the midi events in a linked list; this way it is 42 | easy to shuffle the tracks together later on; and we are 43 | flexible in the size of each elemnt. 44 | */ 45 | typedef struct MIDIEvent 46 | { 47 | Uint32 time; /* Time at which this midi events occurs */ 48 | Uint8 status; /* Status byte */ 49 | Uint8 data[2]; /* 1 or 2 bytes additional data for most events */ 50 | 51 | Uint32 extraLen; /* For some SysEx events, we need additional storage */ 52 | Uint8 *extraData; 53 | 54 | struct MIDIEvent *next; 55 | } MIDIEvent; 56 | 57 | 58 | /* Load a midifile to memory, converting it to a list of MIDIEvents. 59 | This function returns a linked lists of MIDIEvents, 0 if an error occured. 60 | */ 61 | MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division); 62 | 63 | /* Release a MIDIEvent list after usage. */ 64 | void FreeMIDIEventList(MIDIEvent *head); 65 | 66 | 67 | #endif /* _NATIVE_MIDI_COMMON_H_ */ 68 | -------------------------------------------------------------------------------- /palcommon.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef _PALUTILS_H 23 | #define _PALUTILS_H 24 | 25 | #include "common.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif 31 | 32 | typedef LPBYTE LPSPRITE, LPBITMAPRLE; 33 | typedef LPCBYTE LPCSPRITE, LPCBITMAPRLE; 34 | 35 | typedef DWORD PAL_POS; 36 | 37 | #define PAL_XY(x, y) (PAL_POS)(((((WORD)(y)) << 16) & 0xFFFF0000) | (((WORD)(x)) & 0xFFFF)) 38 | #define PAL_X(xy) (SHORT)((xy) & 0xFFFF) 39 | #define PAL_Y(xy) (SHORT)(((xy) >> 16) & 0xFFFF) 40 | 41 | typedef enum tagPALDIRECTION 42 | { 43 | kDirSouth = 0, 44 | kDirWest, 45 | kDirNorth, 46 | kDirEast, 47 | kDirUnknown 48 | } PALDIRECTION, *LPPALDIRECTION; 49 | 50 | INT 51 | PAL_RLEBlitToSurface( 52 | LPCBITMAPRLE lpBitmapRLE, 53 | SDL_Surface *lpDstSurface, 54 | PAL_POS pos 55 | ); 56 | 57 | INT 58 | PAL_RLEBlitWithColorShift( 59 | LPCBITMAPRLE lpBitmapRLE, 60 | SDL_Surface *lpDstSurface, 61 | PAL_POS pos, 62 | INT iColorShift 63 | ); 64 | 65 | INT 66 | PAL_RLEBlitMonoColor( 67 | LPCBITMAPRLE lpBitmapRLE, 68 | SDL_Surface *lpDstSurface, 69 | PAL_POS pos, 70 | BYTE bColor, 71 | INT iColorShift 72 | ); 73 | 74 | INT 75 | PAL_FBPBlitToSurface( 76 | LPBYTE lpBitmapFBP, 77 | SDL_Surface *lpDstSurface 78 | ); 79 | 80 | UINT 81 | PAL_RLEGetWidth( 82 | LPCBITMAPRLE lpBitmapRLE 83 | ); 84 | 85 | UINT 86 | PAL_RLEGetHeight( 87 | LPCBITMAPRLE lpBitmapRLE 88 | ); 89 | 90 | WORD 91 | PAL_SpriteGetNumFrames( 92 | LPCSPRITE lpSprite 93 | ); 94 | 95 | LPCBITMAPRLE 96 | PAL_SpriteGetFrame( 97 | LPCSPRITE lpSprite, 98 | INT iFrameNum 99 | ); 100 | 101 | INT 102 | PAL_MKFGetChunkCount( 103 | FILE *fp 104 | ); 105 | 106 | INT 107 | PAL_MKFGetChunkSize( 108 | UINT uiChunkNum, 109 | FILE *fp 110 | ); 111 | 112 | INT 113 | PAL_MKFReadChunk( 114 | LPBYTE lpBuffer, 115 | UINT uiBufferSize, 116 | UINT uiChunkNum, 117 | FILE *fp 118 | ); 119 | 120 | INT 121 | PAL_MKFGetDecompressedSize( 122 | UINT uiChunkNum, 123 | FILE *fp 124 | ); 125 | 126 | INT 127 | PAL_MKFDecompressChunk( 128 | LPBYTE lpBuffer, 129 | UINT uiBufferSize, 130 | UINT uiChunkNum, 131 | FILE *fp 132 | ); 133 | 134 | VOID 135 | PAL_MakeColorShiftTable( 136 | LPBYTE lpTable, 137 | SHORT iColorShift 138 | ); 139 | 140 | // From yj1.c: 141 | INT 142 | Decompress( 143 | LPCVOID Source, 144 | LPVOID Destination, 145 | INT DestSize 146 | ); 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | 152 | #endif // _PALUTILS_H 153 | -------------------------------------------------------------------------------- /palette.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef PALETTE_H 23 | #define PALETTE_H 24 | 25 | #include "common.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif 31 | 32 | SDL_Color * 33 | PAL_GetPalette( 34 | INT iPaletteNum, 35 | BOOL fNight 36 | ); 37 | 38 | VOID 39 | PAL_SetPalette( 40 | INT iPaletteNum, 41 | BOOL fNight 42 | ); 43 | 44 | VOID 45 | PAL_FadeOut( 46 | INT iDelay 47 | ); 48 | 49 | VOID 50 | PAL_FadeIn( 51 | INT iPaletteNum, 52 | BOOL fNight, 53 | INT iDelay 54 | ); 55 | 56 | VOID 57 | PAL_SceneFade( 58 | INT iPaletteNum, 59 | BOOL fNight, 60 | INT iStep 61 | ); 62 | 63 | VOID 64 | PAL_PaletteFade( 65 | INT iPaletteNum, 66 | BOOL fNight, 67 | INT iDelay 68 | ); 69 | 70 | VOID 71 | PAL_ColorFade( 72 | INT iDelay, 73 | BYTE bColor, 74 | BOOL fFrom 75 | ); 76 | 77 | VOID 78 | PAL_FadeToRed( 79 | VOID 80 | ); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /play.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef PLAY_H 23 | #define PLAY_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | VOID 31 | PAL_GameUpdate( 32 | BOOL fTrigger 33 | ); 34 | 35 | VOID 36 | PAL_GameUseItem( 37 | VOID 38 | ); 39 | 40 | VOID 41 | PAL_GameEquipItem( 42 | VOID 43 | ); 44 | 45 | VOID 46 | PAL_StartFrame( 47 | VOID 48 | ); 49 | 50 | VOID 51 | PAL_WaitForKey( 52 | WORD wTimeOut 53 | ); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /private.c: -------------------------------------------------------------------------------- 1 | #ifdef CYGWIN 2 | SDLPAL_ICON ICON DISCARDABLE "sdlpal.ico" 3 | #endif 4 | -------------------------------------------------------------------------------- /res.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef RES_H 23 | #define RES_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | typedef enum tagLOADRESFLAG 31 | { 32 | kLoadScene = (1 << 0), // load a scene 33 | kLoadPlayerSprite = (1 << 1), // load player sprites 34 | } LOADRESFLAG, *LPLOADRESFLAG; 35 | 36 | VOID 37 | PAL_InitResources( 38 | VOID 39 | ); 40 | 41 | VOID 42 | PAL_FreeResources( 43 | VOID 44 | ); 45 | 46 | VOID 47 | PAL_SetLoadFlags( 48 | BYTE bFlags 49 | ); 50 | 51 | VOID 52 | PAL_LoadResources( 53 | VOID 54 | ); 55 | 56 | LPPALMAP 57 | PAL_GetCurrentMap( 58 | VOID 59 | ); 60 | 61 | LPSPRITE 62 | PAL_GetPlayerSprite( 63 | BYTE bPlayerIndex 64 | ); 65 | 66 | LPSPRITE 67 | PAL_GetBattleSprite( 68 | BYTE bPlayerIndex 69 | ); 70 | 71 | LPSPRITE 72 | PAL_GetEventObjectSprite( 73 | WORD wEventObjectID 74 | ); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /rixplay.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef RIX_PLAY_H 23 | #define RIX_PLAY_H 24 | 25 | #include "common.h" 26 | 27 | #ifdef __cplusplus 28 | 29 | extern "C" 30 | { 31 | #endif 32 | 33 | VOID 34 | RIX_FillBuffer( 35 | LPBYTE stream, 36 | INT len 37 | ); 38 | 39 | INT 40 | RIX_Init( 41 | LPCSTR szFileName 42 | ); 43 | 44 | VOID 45 | RIX_Shutdown( 46 | VOID 47 | ); 48 | 49 | VOID 50 | RIX_Play( 51 | INT iNumRIX, 52 | BOOL fLoop, 53 | FLOAT flFadeTime 54 | ); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /rngplay.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef RNGPLAY_H 23 | #define RNGPLAY_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | #include "common.h" 31 | 32 | VOID 33 | PAL_RNGPlay( 34 | INT iNumRNG, 35 | INT iStartFrame, 36 | INT iNumFrames, 37 | INT iSpeed 38 | ); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /scene.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef _SCENE_H 23 | #define _SCENE_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | VOID 31 | PAL_ApplyWave( 32 | SDL_Surface *lpSurface 33 | ); 34 | 35 | VOID 36 | PAL_MakeScene( 37 | VOID 38 | ); 39 | 40 | BOOL 41 | PAL_CheckObstacle( 42 | PAL_POS pos, 43 | BOOL fCheckEventObjects, 44 | WORD wSelfObject 45 | ); 46 | 47 | VOID 48 | PAL_UpdatePartyGestures( 49 | BOOL fWalking 50 | ); 51 | 52 | VOID 53 | PAL_UpdateParty( 54 | VOID 55 | ); 56 | 57 | VOID 58 | PAL_NPCWalkOneStep( 59 | WORD wEventObjectID, 60 | INT iSpeed 61 | ); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /script.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef SCRIPT_H 23 | #define SCRIPT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | WORD 31 | PAL_RunTriggerScript( 32 | WORD wScriptEntry, 33 | WORD wEventObjectID 34 | ); 35 | 36 | WORD 37 | PAL_RunAutoScript( 38 | WORD wScriptEntry, 39 | WORD wEventObjectID 40 | ); 41 | 42 | extern BOOL g_fScriptSuccess; 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /sdlpal.cproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | {97ADEBD0-5333-4E9D-A9F7-6F3F226ECA5C} 8 | 9 | 10 | 11 | C 12 | Bin 13 | 2.0 14 | 15 | 16 | true 17 | bin\Debug 18 | DEBUG MONODEVELOP 19 | . 20 | sdlpal 21 | Bin 22 | `sdl-config --libs` -lm 23 | `sdl-config --cflags` 24 | 25 | 26 | stdc++ 27 | 28 | 29 | 30 | 31 | bin\Release 32 | MONODEVELOP 33 | . 34 | 3 35 | sdlpal 36 | Bin 37 | `sdl-config --libs` -lm 38 | `sdl-config --cflags` 39 | 40 | 41 | stdc++ 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /sdlpal.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/sdlpal.icns -------------------------------------------------------------------------------- /sdlpal.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/sdlpal.ico -------------------------------------------------------------------------------- /sdlpal.rc: -------------------------------------------------------------------------------- 1 | 101 ICON "sdlpal.ico" 2 | -------------------------------------------------------------------------------- /sdlpal.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdlpal", "sdlpal.vcxproj", "{837BDF47-9375-4C30-866B-07E262E94A01}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {837BDF47-9375-4C30-866B-07E262E94A01}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {837BDF47-9375-4C30-866B-07E262E94A01}.Debug|Win32.Build.0 = Debug|Win32 14 | {837BDF47-9375-4C30-866B-07E262E94A01}.Release|Win32.ActiveCfg = Release|Win32 15 | {837BDF47-9375-4C30-866B-07E262E94A01}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /sdlpal.wpj: -------------------------------------------------------------------------------- 1 | 40 2 | projectIdent 3 | 0 4 | VpeMain 5 | 1 6 | WRect 7 | 832 8 | 273 9 | 7680 10 | 9147 11 | 2 12 | MProject 13 | 3 14 | MCommand 15 | 0 16 | 4 17 | MCommand 18 | 0 19 | 1 20 | 5 21 | WFileName 22 | 10 23 | sdlpal.tgt 24 | 6 25 | WVList 26 | 1 27 | 7 28 | VComponent 29 | 8 30 | WRect 31 | 192 32 | 22 33 | 5632 34 | 4141 35 | 0 36 | 0 37 | 9 38 | WFileName 39 | 10 40 | sdlpal.tgt 41 | 75 42 | 89 43 | 7 44 | -------------------------------------------------------------------------------- /sdlpal.xpm: -------------------------------------------------------------------------------- 1 | static char *sdlpal_xpm[] = { 2 | "32 32 30 1", 3 | " c #000000", 4 | ". c #000040", 5 | "+ c #0000E7", 6 | "@ c #000087", 7 | "# c #000048", 8 | "$ c #000030", 9 | "% c #0000FF", 10 | "& c #0000DF", 11 | "* c #00007F", 12 | "= c #00008F", 13 | "- c #000028", 14 | "; c #000090", 15 | "> c #DFDFFF", 16 | ", c #FFFFFF", 17 | "' c #4040D7", 18 | ") c #000078", 19 | "! c #000080", 20 | "~ c #CFCFFF", 21 | "{ c #8888FF", 22 | "] c #3030FF", 23 | "^ c #7878FF", 24 | "/ c #000088", 25 | "( c #000070", 26 | "_ c #8080FF", 27 | ": c #0000CF", 28 | "< c #2828FF", 29 | "[ c #D7D7FF", 30 | "} c #0000D7", 31 | "| c #F7F7FF", 32 | "1 c #00009F", 33 | " ", 34 | " ", 35 | " ", 36 | " .+@#", 37 | " $%& ", 38 | " $@******************=-+; ", 39 | " $%%%%%%%%%%>,,,,,,,,,'. ", 40 | " )%%%%%%%%%%,,,,,,,,,,! ", 41 | " %%%%%%%%%%>,,,,,,,,,~$ ", 42 | " !%%%%%%%%%%,,,,,,,,,,{ ", 43 | " %%%%%%%%%%],,,,,,,,,,! ", 44 | " %%%%%%%%%%{,,,,,,,,,^ ", 45 | " $%%%%%%%%%%^,,,,,,,,,] ", 46 | " /%%%%%%%%%%~,,,,,,,,,( ", 47 | " !%%%%%%%%%%,,,,,,,,,,! ", 48 | " !%%%%%%%%%],,,,,,,,,,/ ", 49 | " !%%%%%%%%%{,,,,,,,,,~$ ", 50 | " (%%%%%%%%%_,,,,,,,,,^ ", 51 | " %%%%%%%%%%_,,,,,,,,,_ ", 52 | " %%%%%%%%%%_,,,,,,,,,_ ", 53 | " $%%%%%%%%%%^,,,,,,,,,{ ", 54 | " /%%%%%%%%%%~,,,,,,,,,] ", 55 | " )%%%%%%%%%%,,,,,,,,,,: ", 56 | " :%%%%%%%%%%,,,,,,,,,~/ ", 57 | " %%%%%%%%%%<,,,,,,,,,{ ", 58 | " -%%%%%%%%%%[,,,,,,,,,) ", 59 | " }%%%%%%%%%<,,,,,,,,,>$ ", 60 | " ;%%%%%%%%%%|,,,,,,,,,! ", 61 | " 1*******************= ", 62 | " ", 63 | " ", 64 | " "}; 65 | -------------------------------------------------------------------------------- /sound.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef SOUND_H 23 | #define SOUND_H 24 | 25 | #include "common.h" 26 | 27 | #ifndef PAL_SAMPLE_RATE 28 | #define PAL_SAMPLE_RATE 44100 /*49716*/ 29 | #endif 30 | 31 | #ifndef PAL_CHANNELS 32 | #define PAL_CHANNELS 1 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | extern "C" 37 | { 38 | #endif 39 | 40 | INT 41 | SOUND_OpenAudio( 42 | VOID 43 | ); 44 | 45 | VOID 46 | SOUND_CloseAudio( 47 | VOID 48 | ); 49 | 50 | VOID 51 | SOUND_PlayChannel( 52 | INT iSoundNum, 53 | INT iChannel 54 | ); 55 | 56 | #ifdef __SYMBIAN32__ 57 | VOID 58 | SOUND_AdjustVolume( 59 | INT iDirectory 60 | ); 61 | #endif 62 | 63 | VOID 64 | PAL_PlayMUS( 65 | INT iNumRIX, 66 | BOOL fLoop, 67 | FLOAT flFadeTime 68 | ); 69 | 70 | BOOL 71 | SOUND_PlayCDA( 72 | INT iNumTrack 73 | ); 74 | 75 | #ifdef PAL_CLASSIC 76 | extern int g_iCurrChannel; 77 | #define SOUND_Play(i) SOUND_PlayChannel((i), (g_iCurrChannel ^= 1)) 78 | #else 79 | #define SOUND_Play(i) SOUND_PlayChannel((i), 0) 80 | #endif 81 | 82 | extern BOOL g_fNoSound; 83 | extern BOOL g_fNoMusic; 84 | #ifdef PAL_HAS_NATIVEMIDI 85 | extern BOOL g_fUseMidi; 86 | #endif 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /text.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef _TEXT_H 23 | #define _TEXT_H 24 | 25 | typedef enum tagDIALOGPOSITION 26 | { 27 | kDialogUpper = 0, 28 | kDialogCenter, 29 | kDialogLower, 30 | kDialogCenterWindow 31 | } DIALOGLOCATION; 32 | 33 | #define PAL_ADDITIONAL_WORD_FIRST 10000 34 | 35 | INT 36 | PAL_InitText( 37 | VOID 38 | ); 39 | 40 | VOID 41 | PAL_FreeText( 42 | VOID 43 | ); 44 | 45 | LPCSTR 46 | PAL_GetWord( 47 | WORD wNumWord 48 | ); 49 | 50 | LPCSTR 51 | PAL_GetMsg( 52 | WORD wNumMsg 53 | ); 54 | 55 | VOID 56 | PAL_DrawText( 57 | LPCSTR lpszText, 58 | PAL_POS pos, 59 | BYTE bColor, 60 | BOOL fShadow, 61 | BOOL fUpdate 62 | ); 63 | 64 | VOID 65 | PAL_DialogSetDelayTime( 66 | INT iDelayTime 67 | ); 68 | 69 | VOID 70 | PAL_StartDialog( 71 | BYTE bDialogLocation, 72 | BYTE bFontColor, 73 | INT iNumCharFace, 74 | BOOL fPlayingRNG 75 | ); 76 | 77 | VOID 78 | PAL_ShowDialogText( 79 | LPCSTR szText 80 | ); 81 | 82 | VOID 83 | PAL_ClearDialog( 84 | BOOL fWaitForKey 85 | ); 86 | 87 | VOID 88 | PAL_EndDialog( 89 | VOID 90 | ); 91 | 92 | BOOL 93 | PAL_IsInDialog( 94 | VOID 95 | ); 96 | 97 | BOOL 98 | PAL_DialogIsPlayingRNG( 99 | VOID 100 | ); 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /uibattle.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef UIBATTLE_H 23 | #define UIBATTLE_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | #include "ui.h" 31 | 32 | typedef enum tagBATTLEUISTATE 33 | { 34 | kBattleUIWait, 35 | kBattleUISelectMove, 36 | kBattleUISelectTargetEnemy, 37 | kBattleUISelectTargetPlayer, 38 | kBattleUISelectTargetEnemyAll, 39 | kBattleUISelectTargetPlayerAll, 40 | } BATTLEUISTATE; 41 | 42 | typedef enum tagBATTLEMENUSTATE 43 | { 44 | kBattleMenuMain, 45 | kBattleMenuMagicSelect, 46 | kBattleMenuUseItemSelect, 47 | kBattleMenuThrowItemSelect, 48 | kBattleMenuMisc, 49 | kBattleMenuMiscItemSubMenu, 50 | } BATTLEMENUSTATE; 51 | 52 | typedef enum tagBATTLEUIACTION 53 | { 54 | kBattleUIActionAttack, 55 | kBattleUIActionMagic, 56 | kBattleUIActionCoopMagic, 57 | kBattleUIActionMisc, 58 | } BATTLEUIACTION; 59 | 60 | #define SPRITENUM_BATTLEICON_ATTACK 40 61 | #define SPRITENUM_BATTLEICON_MAGIC 41 62 | #define SPRITENUM_BATTLEICON_COOPMAGIC 42 63 | #define SPRITENUM_BATTLEICON_MISCMENU 43 64 | 65 | #define SPRITENUM_BATTLE_ARROW_CURRENTPLAYER 69 66 | #define SPRITENUM_BATTLE_ARROW_CURRENTPLAYER_RED 68 67 | 68 | #define SPRITENUM_BATTLE_ARROW_SELECTEDPLAYER 67 69 | #define SPRITENUM_BATTLE_ARROW_SELECTEDPLAYER_RED 66 70 | 71 | #define BATTLEUI_LABEL_ITEM 5 72 | #define BATTLEUI_LABEL_DEFEND 58 73 | #define BATTLEUI_LABEL_AUTO 56 74 | #define BATTLEUI_LABEL_INVENTORY 57 75 | #define BATTLEUI_LABEL_FLEE 59 76 | #define BATTLEUI_LABEL_STATUS 60 77 | 78 | #define BATTLEUI_LABEL_USEITEM 23 79 | #define BATTLEUI_LABEL_THROWITEM 24 80 | 81 | #define TIMEMETER_COLOR_DEFAULT 0x1B 82 | #define TIMEMETER_COLOR_SLOW 0x5B 83 | #define TIMEMETER_COLOR_HASTE 0x2A 84 | 85 | #define BATTLEUI_MAX_SHOWNUM 16 86 | 87 | typedef struct tagSHOWNUM 88 | { 89 | WORD wNum; 90 | PAL_POS pos; 91 | DWORD dwTime; 92 | NUMCOLOR color; 93 | } SHOWNUM; 94 | 95 | typedef struct tagBATTLEUI 96 | { 97 | BATTLEUISTATE state; 98 | BATTLEMENUSTATE MenuState; 99 | 100 | CHAR szMsg[256]; // message to be shown on the screen 101 | CHAR szNextMsg[256]; // next message to be shown on the screen 102 | DWORD dwMsgShowTime; // the end time of showing the message 103 | WORD wNextMsgDuration; // duration of the next message 104 | 105 | WORD wCurPlayerIndex; // index of the current player 106 | WORD wSelectedAction; // current selected action 107 | WORD wSelectedIndex; // current selected index of player or enemy 108 | WORD wPrevEnemyTarget; // previous enemy target 109 | 110 | WORD wActionType; // type of action to be performed 111 | WORD wObjectID; // object ID of the item or magic to use 112 | 113 | BOOL fAutoAttack; // TRUE if auto attack 114 | 115 | SHOWNUM rgShowNum[BATTLEUI_MAX_SHOWNUM]; 116 | } BATTLEUI; 117 | 118 | VOID 119 | PAL_PlayerInfoBox( 120 | PAL_POS pos, 121 | WORD wPlayerRole, 122 | INT iTimeMeter, 123 | BYTE bTimeMeterColor, 124 | BOOL fUpdate 125 | ); 126 | 127 | VOID 128 | PAL_BattleUIShowText( 129 | LPCSTR lpszText, 130 | WORD wDuration 131 | ); 132 | 133 | VOID 134 | PAL_BattleUIPlayerReady( 135 | WORD wPlayerIndex 136 | ); 137 | 138 | VOID 139 | PAL_BattleUIUpdate( 140 | VOID 141 | ); 142 | 143 | VOID 144 | PAL_BattleUIShowNum( 145 | WORD wNum, 146 | PAL_POS pos, 147 | NUMCOLOR color 148 | ); 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | #endif 154 | -------------------------------------------------------------------------------- /uigame.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef UIGAME_H 23 | #define UIGAME_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | #include "ui.h" 31 | 32 | VOID 33 | PAL_DrawOpeningMenuBackground( 34 | VOID 35 | ); 36 | 37 | INT 38 | PAL_OpeningMenu( 39 | VOID 40 | ); 41 | 42 | INT 43 | PAL_SaveSlotMenu( 44 | WORD wDefaultSlot 45 | ); 46 | 47 | BOOL 48 | PAL_ConfirmMenu( 49 | VOID 50 | ); 51 | 52 | BOOL 53 | PAL_SwitchMenu( 54 | BOOL fEnabled 55 | ); 56 | 57 | VOID 58 | PAL_InGameMagicMenu( 59 | VOID 60 | ); 61 | 62 | VOID 63 | PAL_InGameMenu( 64 | VOID 65 | ); 66 | 67 | VOID 68 | PAL_PlayerStatus( 69 | VOID 70 | ); 71 | 72 | WORD 73 | PAL_ItemUseMenu( 74 | WORD wItemToUse 75 | ); 76 | 77 | VOID 78 | PAL_BuyMenu( 79 | WORD wStoreNum 80 | ); 81 | 82 | VOID 83 | PAL_SellMenu( 84 | VOID 85 | ); 86 | 87 | VOID 88 | PAL_EquipItemMenu( 89 | WORD wItem 90 | ); 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | #endif 96 | -------------------------------------------------------------------------------- /util.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | 3 | // 4 | // Copyright (c) 2009, Wei Mingzhi . 5 | // All rights reserved. 6 | // 7 | // This file is part of SDLPAL. 8 | // 9 | // SDLPAL is free software: you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // This program is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with this program. If not, see . 21 | // 22 | 23 | #ifndef UTIL_H 24 | #define UTIL_H 25 | 26 | #include "common.h" 27 | 28 | //#define ENABLE_LOG 1 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | 35 | void 36 | trim( 37 | char *str 38 | ); 39 | 40 | char *va( 41 | const char *format, 42 | ... 43 | ); 44 | 45 | int 46 | RandomLong( 47 | int from, 48 | int to 49 | ); 50 | 51 | float 52 | RandomFloat( 53 | float from, 54 | float to 55 | ); 56 | 57 | void 58 | UTIL_Delay( 59 | unsigned int ms 60 | ); 61 | 62 | void 63 | TerminateOnError( 64 | const char *fmt, 65 | ... 66 | ); 67 | 68 | void * 69 | UTIL_malloc( 70 | size_t buffer_size 71 | ); 72 | 73 | void * 74 | UTIL_calloc( 75 | size_t n, 76 | size_t size 77 | ); 78 | 79 | FILE * 80 | UTIL_OpenRequiredFile( 81 | LPCSTR lpszFileName 82 | ); 83 | 84 | FILE * 85 | UTIL_OpenFile( 86 | LPCSTR lpszFileName 87 | ); 88 | 89 | VOID 90 | UTIL_CloseFile( 91 | FILE *fp 92 | ); 93 | 94 | #ifdef __IOS__ 95 | 96 | LPCSTR 97 | UTIL_IOS_BasePath( 98 | VOID 99 | ); 100 | 101 | LPCSTR 102 | UTIL_IOS_SavePath( 103 | VOID 104 | ); 105 | 106 | #endif 107 | 108 | #define _PATH_LOG PAL_PREFIX "log.txt" 109 | #define LOG_EMERG 0 /* system is unusable */ 110 | #define LOG_ALERT 1 /* action must be taken immediately */ 111 | #define LOG_CRIT 2 /* critical conditions */ 112 | #define LOG_ERR 3 /* error conditions */ 113 | #define LOG_WARNING 4 /* warning conditions */ 114 | #define LOG_NOTICE 5 /* normal but significant condition */ 115 | #define LOG_INFO 6 /* informational */ 116 | #define LOG_DEBUG 7 /* debug-level messages */ 117 | #define LOG_LAST_PRIORITY 8 /* last level */ 118 | 119 | #ifdef ENABLE_LOG 120 | 121 | FILE * 122 | UTIL_OpenLog( 123 | VOID 124 | ); 125 | 126 | VOID 127 | UTIL_CloseLog( 128 | VOID 129 | ); 130 | 131 | VOID 132 | UTIL_WriteLog( 133 | int Priority, 134 | const char *Fmt, 135 | ... 136 | ); 137 | 138 | #else 139 | 140 | #define UTIL_OpenLog() ((void)(0)) 141 | #define UTIL_CloseLog() ((void)(0)) 142 | #ifdef _MSC_VER 143 | __forceinline VOID UTIL_WriteLog(int i, const char *p, ...) {} 144 | #else 145 | #define UTIL_WriteLog(...) ((void)(0)) 146 | #endif 147 | 148 | #endif 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /video.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */ 2 | // 3 | // Copyright (c) 2009, Wei Mingzhi . 4 | // All rights reserved. 5 | // 6 | // This file is part of SDLPAL. 7 | // 8 | // SDLPAL is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with this program. If not, see . 20 | // 21 | 22 | #ifndef VIDEO_H 23 | #define VIDEO_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | #include "common.h" 31 | 32 | extern SDL_Surface *gpScreen; 33 | extern SDL_Surface *gpScreenBak; 34 | extern volatile BOOL g_bRenderPaused; 35 | 36 | INT 37 | #ifdef GEKKO // Rikku2000: Crash on compile, allready define on WIISDK 38 | VIDEO_Init_GEKKO( 39 | #else 40 | VIDEO_Init( 41 | #endif 42 | WORD wScreenWidth, 43 | WORD wScreenHeight, 44 | BOOL fFullScreen 45 | ); 46 | 47 | VOID 48 | VIDEO_Shutdown( 49 | VOID 50 | ); 51 | 52 | VOID 53 | VIDEO_UpdateScreen( 54 | const SDL_Rect *lpRect 55 | ); 56 | 57 | VOID 58 | VIDEO_SetPalette( 59 | SDL_Color rgPalette[256] 60 | ); 61 | 62 | VOID 63 | VIDEO_Resize( 64 | INT w, 65 | INT h 66 | ); 67 | 68 | SDL_Color * 69 | VIDEO_GetPalette( 70 | VOID 71 | ); 72 | 73 | VOID 74 | VIDEO_ToggleFullscreen( 75 | VOID 76 | ); 77 | 78 | VOID 79 | VIDEO_SaveScreenshot( 80 | VOID 81 | ); 82 | 83 | VOID 84 | VIDEO_BackupScreen( 85 | VOID 86 | ); 87 | 88 | VOID 89 | VIDEO_RestoreScreen( 90 | VOID 91 | ); 92 | 93 | VOID 94 | VIDEO_ShakeScreen( 95 | WORD wShakeTime, 96 | WORD wShakeLevel 97 | ); 98 | 99 | VOID 100 | VIDEO_SwitchScreen( 101 | WORD wSpeed 102 | ); 103 | 104 | VOID 105 | VIDEO_FadeScreen( 106 | WORD wSpeed 107 | ); 108 | 109 | #if SDL_VERSION_ATLEAST(2,0,0) 110 | // 111 | // For compatibility with SDL2. 112 | // 113 | VOID 114 | SDL_WM_SetCaption( 115 | LPCSTR lpszCaption, 116 | LPVOID lpReserved 117 | ); 118 | #endif 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /winphone/Assets/AlignmentGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/AlignmentGrid.png -------------------------------------------------------------------------------- /winphone/Assets/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/ApplicationIcon.png -------------------------------------------------------------------------------- /winphone/Assets/Data/README.txt: -------------------------------------------------------------------------------- 1 | Copy the data files here. -------------------------------------------------------------------------------- /winphone/Assets/Tiles/FlipCycleTileLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/Tiles/FlipCycleTileLarge.png -------------------------------------------------------------------------------- /winphone/Assets/Tiles/FlipCycleTileMedium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/Tiles/FlipCycleTileMedium.png -------------------------------------------------------------------------------- /winphone/Assets/Tiles/FlipCycleTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/Tiles/FlipCycleTileSmall.png -------------------------------------------------------------------------------- /winphone/Assets/Tiles/IconicTileMediumLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/Tiles/IconicTileMediumLarge.png -------------------------------------------------------------------------------- /winphone/Assets/Tiles/IconicTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weimzh/sdlpal/cf18dee02f5eb5cd4687344e603ffa8589d7f5a3/winphone/Assets/Tiles/IconicTileSmall.png -------------------------------------------------------------------------------- /winphone/SDL2/README.txt: -------------------------------------------------------------------------------- 1 | Download SDL2 source code from http://libsdl.org/ and extract here. -------------------------------------------------------------------------------- /winphone/SDLPal.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLPal", "SDLPal.vcxproj", "{F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-WinPhone80", "SDL2\VisualC-WinRT\WinPhone80_VS2012\SDL-WinPhone80.vcxproj", "{33048AF1-031A-4CE6-B61E-FAD2DB832E9E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|ARM = Debug|ARM 13 | Debug|Win32 = Debug|Win32 14 | Release|ARM = Release|ARM 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Debug|ARM.Build.0 = Debug|ARM 20 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Debug|Win32.Build.0 = Debug|Win32 23 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Debug|Win32.Deploy.0 = Debug|Win32 24 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Release|ARM.ActiveCfg = Release|ARM 25 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Release|ARM.Build.0 = Release|ARM 26 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Release|ARM.Deploy.0 = Release|ARM 27 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Release|Win32.ActiveCfg = Release|Win32 28 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Release|Win32.Build.0 = Release|Win32 29 | {F59B48BC-5646-4F8B-90B2-4B09A9D94C5C}.Release|Win32.Deploy.0 = Release|Win32 30 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Debug|ARM.ActiveCfg = Debug|ARM 31 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Debug|ARM.Build.0 = Debug|ARM 32 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Debug|Win32.Build.0 = Debug|Win32 34 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Release|ARM.ActiveCfg = Release|ARM 35 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Release|ARM.Build.0 = Release|ARM 36 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Release|Win32.ActiveCfg = Release|Win32 37 | {33048AF1-031A-4CE6-B61E-FAD2DB832E9E}.Release|Win32.Build.0 = Release|Win32 38 | EndGlobalSection 39 | GlobalSection(SolutionProperties) = preSolution 40 | HideSolutionNode = FALSE 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /winphone/WMAppManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Assets\ApplicationIcon.png 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Assets\Tiles\FlipCycleTileSmall.png 20 | 0 21 | Assets\Tiles\FlipCycleTileMedium.png 22 | SDLPal 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /winphone/WinPhoneUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const char * 5 | GetRootPath() 6 | { 7 | static char buf[1024] = ""; 8 | if (buf[0] == '\0') 9 | { 10 | Platform::String^ localfolder = Windows::Storage::ApplicationData::Current->LocalFolder->Path; 11 | const char16 *begin = localfolder->Begin(); 12 | WideCharToMultiByte(CP_ACP, 0, begin, -1, buf, 1024, NULL, FALSE); 13 | } 14 | return buf; 15 | } 16 | 17 | static const char * 18 | GetInstallPath() 19 | { 20 | static char buf[1024] = ""; 21 | if (buf[0] == '\0') 22 | { 23 | Platform::String^ installfolder = Windows::ApplicationModel::Package::Current->InstalledLocation->Path; 24 | const char16 *begin = installfolder->Begin(); 25 | WideCharToMultiByte(CP_ACP, 0, begin, -1, buf, 1024, NULL, FALSE); 26 | } 27 | return buf; 28 | } 29 | 30 | extern "C" FILE * 31 | MY_fopen(const char *path, const char *mode) 32 | { 33 | const char *p = GetRootPath(); 34 | char buf[1024]; 35 | _snprintf_s(buf, 1024, "%s\\%s", p, path); 36 | FILE *fp = _fsopen(buf, mode, 0x40); 37 | if (fp == NULL) 38 | { 39 | p = GetInstallPath(); 40 | _snprintf_s(buf, 1024, "%s\\%s", p, path); 41 | fp = _fsopen(buf, mode, 0x40); 42 | } 43 | if (fp == NULL) 44 | { 45 | p = GetRootPath(); 46 | _snprintf_s(buf, 1024, "%s\\Shared\\%s", p, path); 47 | fp = _fsopen(buf, mode, 0x40); 48 | } 49 | return fp; 50 | } 51 | --------------------------------------------------------------------------------