gosu 0.15.2 → 1.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +138 -0
- data/dependencies/SDL/include/SDL_assert.h +293 -0
- data/dependencies/SDL/include/SDL_atomic.h +295 -0
- data/dependencies/SDL/include/SDL_audio.h +859 -0
- data/dependencies/SDL/include/SDL_bits.h +121 -0
- data/dependencies/SDL/include/SDL_blendmode.h +123 -0
- data/dependencies/SDL/include/SDL_clipboard.h +71 -0
- data/dependencies/SDL/include/SDL_config.h +55 -0
- data/dependencies/SDL/include/SDL_config_android.h +182 -0
- data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
- data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
- data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
- data/dependencies/SDL/include/SDL_config_os2.h +188 -0
- data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
- data/dependencies/SDL/include/SDL_config_psp.h +165 -0
- data/dependencies/SDL/include/SDL_config_windows.h +288 -0
- data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
- data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
- data/dependencies/SDL/include/SDL_copying.h +20 -0
- data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
- data/dependencies/SDL/include/SDL_egl.h +1676 -0
- data/dependencies/SDL/include/SDL_endian.h +263 -0
- data/dependencies/SDL/include/SDL_error.h +112 -0
- data/dependencies/SDL/include/SDL_events.h +827 -0
- data/dependencies/SDL/include/SDL_filesystem.h +136 -0
- data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
- data/dependencies/SDL/include/SDL_gesture.h +87 -0
- data/dependencies/SDL/include/SDL_haptic.h +1247 -0
- data/dependencies/SDL/include/SDL_hints.h +1578 -0
- data/dependencies/SDL/include/SDL_joystick.h +499 -0
- data/dependencies/SDL/include/SDL_keyboard.h +217 -0
- data/dependencies/SDL/include/SDL_keycode.h +351 -0
- data/dependencies/SDL/include/SDL_loadso.h +81 -0
- data/dependencies/SDL/include/SDL_locale.h +101 -0
- data/dependencies/SDL/include/SDL_log.h +211 -0
- data/dependencies/SDL/include/SDL_main.h +180 -0
- data/dependencies/SDL/include/SDL_messagebox.h +146 -0
- data/dependencies/SDL/include/SDL_metal.h +117 -0
- data/dependencies/SDL/include/SDL_misc.h +75 -0
- data/dependencies/SDL/include/SDL_mouse.h +302 -0
- data/dependencies/SDL/include/SDL_mutex.h +251 -0
- data/dependencies/SDL/include/SDL_name.h +33 -0
- data/dependencies/SDL/include/SDL_opengl.h +2183 -0
- data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
- data/dependencies/SDL/include/SDL_opengles.h +39 -0
- data/dependencies/SDL/include/SDL_opengles2.h +52 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
- data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
- data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
- data/dependencies/SDL/include/SDL_pixels.h +479 -0
- data/dependencies/SDL/include/SDL_platform.h +198 -0
- data/dependencies/SDL/include/SDL_power.h +75 -0
- data/dependencies/SDL/include/SDL_quit.h +58 -0
- data/dependencies/SDL/include/SDL_rect.h +174 -0
- data/dependencies/SDL/include/SDL_render.h +1158 -0
- data/dependencies/SDL/include/SDL_revision.h +2 -0
- data/dependencies/SDL/include/SDL_rwops.h +283 -0
- data/dependencies/SDL/include/SDL_scancode.h +413 -0
- data/dependencies/SDL/include/SDL_sensor.h +267 -0
- data/dependencies/SDL/include/SDL_shape.h +144 -0
- data/dependencies/SDL/include/SDL_stdinc.h +647 -0
- data/dependencies/SDL/include/SDL_surface.h +563 -0
- data/dependencies/SDL/include/SDL_system.h +325 -0
- data/dependencies/SDL/include/SDL_syswm.h +354 -0
- data/dependencies/SDL/include/SDL_test.h +69 -0
- data/dependencies/SDL/include/SDL_test_assert.h +105 -0
- data/dependencies/SDL/include/SDL_test_common.h +218 -0
- data/dependencies/SDL/include/SDL_test_compare.h +69 -0
- data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
- data/dependencies/SDL/include/SDL_test_font.h +81 -0
- data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
- data/dependencies/SDL/include/SDL_test_harness.h +134 -0
- data/dependencies/SDL/include/SDL_test_images.h +78 -0
- data/dependencies/SDL/include/SDL_test_log.h +67 -0
- data/dependencies/SDL/include/SDL_test_md5.h +129 -0
- data/dependencies/SDL/include/SDL_test_memory.h +63 -0
- data/dependencies/SDL/include/SDL_test_random.h +115 -0
- data/dependencies/SDL/include/SDL_thread.h +366 -0
- data/dependencies/SDL/include/SDL_timer.h +115 -0
- data/dependencies/SDL/include/SDL_touch.h +102 -0
- data/dependencies/SDL/include/SDL_types.h +29 -0
- data/dependencies/SDL/include/SDL_version.h +162 -0
- data/dependencies/SDL/include/SDL_video.h +1282 -0
- data/dependencies/SDL/include/SDL_vulkan.h +276 -0
- data/dependencies/SDL/include/begin_code.h +166 -0
- data/dependencies/SDL/include/close_code.h +40 -0
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.c +795 -0
- data/dependencies/SDL_sound/SDL_sound.h +725 -0
- data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
- data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
- data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
- data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
- data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
- data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
- data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
- data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
- data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
- data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
- data/dependencies/SDL_sound/dr_flac.h +5906 -0
- data/dependencies/SDL_sound/dr_mp3.h +2832 -0
- data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
- data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
- data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
- data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
- data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
- data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
- data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
- data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
- data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
- data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
- data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
- data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
- data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
- data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
- data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
- data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
- data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
- data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
- data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
- data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
- data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
- data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
- data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
- data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
- data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +143 -78
- data/dependencies/al_soft/AL/al.h +655 -0
- data/dependencies/al_soft/AL/alc.h +270 -0
- data/dependencies/al_soft/AL/alext.h +585 -0
- data/dependencies/al_soft/AL/efx-creative.h +3 -0
- data/dependencies/al_soft/AL/efx-presets.h +402 -0
- data/dependencies/al_soft/AL/efx.h +762 -0
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/{src → dependencies/stb}/stb_image.h +330 -127
- data/{src → dependencies/stb}/stb_image_write.h +156 -85
- data/{src → dependencies/stb}/stb_truetype.h +192 -69
- data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
- data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
- data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
- data/ext/gosu/extconf.rb +53 -39
- data/{Gosu → include/Gosu}/Audio.hpp +6 -8
- data/include/Gosu/Bitmap.hpp +100 -0
- data/{Gosu → include/Gosu}/Buttons.hpp +104 -44
- data/{Gosu → include/Gosu}/Color.hpp +0 -0
- data/{Gosu → include/Gosu}/Directories.hpp +0 -0
- data/{Gosu → include/Gosu}/Font.hpp +1 -1
- data/{Gosu → include/Gosu}/Fwd.hpp +0 -5
- data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
- data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
- data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
- data/{Gosu → include/Gosu}/IO.hpp +0 -0
- data/{Gosu → include/Gosu}/Image.hpp +7 -6
- data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
- data/{Gosu → include/Gosu}/Input.hpp +39 -51
- data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
- data/{Gosu → include/Gosu}/Math.hpp +0 -0
- data/{Gosu → include/Gosu}/Platform.hpp +0 -0
- data/{Gosu → include/Gosu}/Text.hpp +0 -0
- data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
- data/{Gosu → include/Gosu}/Timing.hpp +0 -0
- data/{Gosu → include/Gosu}/Utility.hpp +15 -4
- data/{Gosu → include/Gosu}/Version.hpp +3 -3
- data/{Gosu → include/Gosu}/Window.hpp +46 -34
- data/lib/OpenAL32.dll +0 -0
- data/lib/SDL2.dll +0 -0
- data/lib/gosu.rb +0 -3
- data/lib/gosu/patches.rb +0 -23
- data/lib/gosu/preview.rb +1 -3
- data/lib/gosu/swig_patches.rb +14 -12
- data/lib64/OpenAL32.dll +0 -0
- data/lib64/SDL2.dll +0 -0
- data/rdoc/gosu.rb +112 -23
- data/src/Audio.cpp +50 -224
- data/src/AudioFile.hpp +20 -37
- data/src/AudioFileAudioToolbox.cpp +237 -0
- data/src/AudioFileSDLSound.cpp +147 -0
- data/src/AudioImpl.cpp +3 -12
- data/src/AudioImpl.hpp +3 -1
- data/src/Bitmap.cpp +85 -83
- data/src/BitmapIO.cpp +52 -58
- data/src/Font.cpp +3 -1
- data/src/Graphics.cpp +7 -4
- data/src/Image.cpp +13 -16
- data/src/Input.cpp +412 -164
- data/src/LargeImageData.cpp +1 -1
- data/src/MarkupParser.cpp +2 -1
- data/src/Resolution.cpp +8 -8
- data/src/RubyGosu.cxx +1017 -196
- data/src/RubyGosu.h +4 -2
- data/src/TexChunk.cpp +1 -1
- data/src/TextBuilder.cpp +3 -1
- data/src/Texture.cpp +1 -1
- data/src/TrueTypeFont.cpp +1 -1
- data/src/TrueTypeFontWin.cpp +3 -3
- data/src/Utility.cpp +11 -7
- data/src/Window.cpp +90 -62
- data/src/WindowUIKit.cpp +21 -9
- metadata +194 -65
- data/Gosu/AutoLink.hpp +0 -14
- data/Gosu/Bitmap.hpp +0 -113
- data/Gosu/Channel.h +0 -25
- data/Gosu/Color.h +0 -38
- data/Gosu/Font.h +0 -36
- data/Gosu/Gosu.h +0 -79
- data/Gosu/Image.h +0 -54
- data/Gosu/Sample.h +0 -19
- data/Gosu/Song.h +0 -24
- data/Gosu/TextInput.h +0 -30
- data/Gosu/Window.h +0 -61
- data/lib/gosu/zen.rb +0 -89
- data/src/AudioToolboxFile.hpp +0 -210
- data/src/ChannelWrapper.cpp +0 -50
- data/src/ColorWrapper.cpp +0 -126
- data/src/Constants.cpp +0 -287
- data/src/FontWrapper.cpp +0 -74
- data/src/GosuWrapper.cpp +0 -232
- data/src/ImageWrapper.cpp +0 -168
- data/src/MPEGFile.hpp +0 -90
- data/src/OggFile.hpp +0 -92
- data/src/SampleWrapper.cpp +0 -30
- data/src/SndFile.hpp +0 -174
- data/src/SongWrapper.cpp +0 -52
- data/src/TextInputWrapper.cpp +0 -101
- data/src/WinMain.cpp +0 -64
- data/src/WindowWrapper.cpp +0 -289
@@ -0,0 +1,25 @@
|
|
1
|
+
#ifndef LOAD_PAT_H
|
2
|
+
#define LOAD_PAT_H
|
3
|
+
|
4
|
+
#ifdef __cplusplus
|
5
|
+
extern "C" {
|
6
|
+
#endif
|
7
|
+
|
8
|
+
void pat_init_patnames(void);
|
9
|
+
void pat_resetsmp(void);
|
10
|
+
int pat_numinstr(void);
|
11
|
+
int pat_numsmp(void);
|
12
|
+
int pat_smptogm(int smp);
|
13
|
+
int pat_gmtosmp(int gm);
|
14
|
+
int pat_gm_drumnr(int n);
|
15
|
+
int pat_gm_drumnote(int n);
|
16
|
+
const char *pat_gm_name(int gm);
|
17
|
+
int pat_modnote(int midinote);
|
18
|
+
int pat_smplooped(int smp);
|
19
|
+
BOOL PAT_Load_Instruments(void *c);
|
20
|
+
|
21
|
+
#ifdef __cplusplus
|
22
|
+
}
|
23
|
+
#endif
|
24
|
+
|
25
|
+
#endif
|
@@ -0,0 +1,350 @@
|
|
1
|
+
/*
|
2
|
+
* This source code is public domain.
|
3
|
+
*
|
4
|
+
* Authors: Olivier Lapicque <olivierl@jps.net>
|
5
|
+
*/
|
6
|
+
|
7
|
+
///////////////////////////////////////////////////
|
8
|
+
//
|
9
|
+
// PSM module loader
|
10
|
+
//
|
11
|
+
///////////////////////////////////////////////////
|
12
|
+
#include "libmodplug.h"
|
13
|
+
|
14
|
+
#define PSM_ID_NEW 0x204d5350
|
15
|
+
#define PSM_ID_OLD 0xfe4d5350
|
16
|
+
#define IFFID_FILE 0x454c4946
|
17
|
+
#define IFFID_TITL 0x4c544954
|
18
|
+
#define IFFID_SDFT 0x54464453
|
19
|
+
#define IFFID_PBOD 0x444f4250
|
20
|
+
#define IFFID_SONG 0x474e4f53
|
21
|
+
#define IFFID_PATT 0x54544150
|
22
|
+
#define IFFID_DSMP 0x504d5344
|
23
|
+
#define IFFID_OPLH 0x484c504f
|
24
|
+
|
25
|
+
#pragma pack(1)
|
26
|
+
|
27
|
+
typedef struct _PSMCHUNK
|
28
|
+
{
|
29
|
+
DWORD id;
|
30
|
+
DWORD len;
|
31
|
+
DWORD listid;
|
32
|
+
} PSMCHUNK;
|
33
|
+
|
34
|
+
void swap_PSMCHUNK(PSMCHUNK* p){
|
35
|
+
p->id = bswapLE32(p->id);
|
36
|
+
p->len = bswapLE32(p->len);
|
37
|
+
p->listid = bswapLE32(p->listid);
|
38
|
+
}
|
39
|
+
|
40
|
+
typedef struct _PSMSONGHDR
|
41
|
+
{
|
42
|
+
CHAR songname[8]; // "MAINSONG"
|
43
|
+
BYTE reserved1;
|
44
|
+
BYTE reserved2;
|
45
|
+
BYTE channels;
|
46
|
+
} PSMSONGHDR;
|
47
|
+
|
48
|
+
typedef struct _PSMPATTERN
|
49
|
+
{
|
50
|
+
DWORD size;
|
51
|
+
DWORD name;
|
52
|
+
WORD rows;
|
53
|
+
WORD reserved1;
|
54
|
+
BYTE data[4];
|
55
|
+
} PSMPATTERN;
|
56
|
+
|
57
|
+
void swap_PSMPATTERN(PSMPATTERN* p){
|
58
|
+
p->size = bswapLE32(p->size);
|
59
|
+
p->name = bswapLE32(p->name);
|
60
|
+
p->rows = bswapLE16(p->rows);
|
61
|
+
}
|
62
|
+
|
63
|
+
typedef struct _PSMSAMPLE
|
64
|
+
{
|
65
|
+
BYTE flags;
|
66
|
+
CHAR songname[8];
|
67
|
+
DWORD smpid;
|
68
|
+
CHAR samplename[34];
|
69
|
+
DWORD reserved1;
|
70
|
+
BYTE reserved2;
|
71
|
+
BYTE insno;
|
72
|
+
BYTE reserved3;
|
73
|
+
DWORD length;
|
74
|
+
DWORD loopstart;
|
75
|
+
DWORD loopend;
|
76
|
+
WORD reserved4;
|
77
|
+
BYTE defvol;
|
78
|
+
DWORD reserved5;
|
79
|
+
DWORD samplerate;
|
80
|
+
BYTE reserved6[19];
|
81
|
+
} PSMSAMPLE;
|
82
|
+
|
83
|
+
void swap_PSMSAMPLE(PSMSAMPLE* p){
|
84
|
+
p->smpid = bswapLE32(p->smpid);
|
85
|
+
p->length = bswapLE32(p->length);
|
86
|
+
p->loopstart = bswapLE32(p->loopstart);
|
87
|
+
p->loopend = bswapLE32(p->loopend);
|
88
|
+
p->samplerate = bswapLE32(p->samplerate);
|
89
|
+
}
|
90
|
+
|
91
|
+
#pragma pack()
|
92
|
+
|
93
|
+
|
94
|
+
BOOL CSoundFile_ReadPSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
95
|
+
//-----------------------------------------------------------
|
96
|
+
{
|
97
|
+
PSMCHUNK *pfh = (PSMCHUNK *)lpStream;
|
98
|
+
DWORD dwMemPos, dwSongPos;
|
99
|
+
DWORD smpnames[MAX_SAMPLES];
|
100
|
+
DWORD patptrs[MAX_PATTERNS];
|
101
|
+
BYTE samplemap[MAX_SAMPLES];
|
102
|
+
UINT nPatterns;
|
103
|
+
|
104
|
+
// Swap chunk
|
105
|
+
swap_PSMCHUNK(pfh);
|
106
|
+
|
107
|
+
// Chunk0: "PSM ",filesize,"FILE"
|
108
|
+
if (dwMemLength < 256) return FALSE;
|
109
|
+
if (pfh->id == PSM_ID_OLD)
|
110
|
+
{
|
111
|
+
return FALSE;
|
112
|
+
}
|
113
|
+
if ((pfh->id != PSM_ID_NEW) || (pfh->len+12 > dwMemLength) || (pfh->listid != IFFID_FILE)) return FALSE;
|
114
|
+
_this->m_nType = MOD_TYPE_PSM;
|
115
|
+
_this->m_nChannels = 16;
|
116
|
+
_this->m_nSamples = 0;
|
117
|
+
nPatterns = 0;
|
118
|
+
dwMemPos = 12;
|
119
|
+
dwSongPos = 0;
|
120
|
+
for (UINT iChPan=0; iChPan<16; iChPan++)
|
121
|
+
{
|
122
|
+
UINT pan = (((iChPan & 3) == 1) || ((iChPan&3)==2)) ? 0xC0 : 0x40;
|
123
|
+
_this->ChnSettings[iChPan].nPan = pan;
|
124
|
+
}
|
125
|
+
while (dwMemPos+8 < dwMemLength)
|
126
|
+
{
|
127
|
+
PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
|
128
|
+
swap_PSMCHUNK(pchunk);
|
129
|
+
if ((pchunk->len >= dwMemLength - 8) || (dwMemPos + pchunk->len + 8 > dwMemLength)) break;
|
130
|
+
dwMemPos += 8;
|
131
|
+
PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
|
132
|
+
ULONG len = pchunk->len;
|
133
|
+
if (len) switch(pchunk->id)
|
134
|
+
{
|
135
|
+
// "PBOD": Pattern
|
136
|
+
case IFFID_PBOD:
|
137
|
+
if ((len >= 12) && (nPatterns < MAX_PATTERNS))
|
138
|
+
{
|
139
|
+
patptrs[nPatterns++] = dwMemPos-8;
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
// "SONG": Song description
|
143
|
+
case IFFID_SONG:
|
144
|
+
if ((len >= sizeof(PSMSONGHDR)+8) && (!dwSongPos))
|
145
|
+
{
|
146
|
+
dwSongPos = dwMemPos - 8;
|
147
|
+
}
|
148
|
+
break;
|
149
|
+
// "DSMP": Sample Data
|
150
|
+
case IFFID_DSMP:
|
151
|
+
if ((len >= sizeof(PSMSAMPLE)) && (_this->m_nSamples+1 < MAX_SAMPLES))
|
152
|
+
{
|
153
|
+
_this->m_nSamples++;
|
154
|
+
MODINSTRUMENT *pins = &_this->Ins[_this->m_nSamples];
|
155
|
+
PSMSAMPLE *psmp = (PSMSAMPLE *)pdata;
|
156
|
+
swap_PSMSAMPLE(psmp);
|
157
|
+
smpnames[_this->m_nSamples] = psmp->smpid;
|
158
|
+
samplemap[_this->m_nSamples-1] = (BYTE)_this->m_nSamples;
|
159
|
+
// Init sample
|
160
|
+
pins->nGlobalVol = 0x40;
|
161
|
+
pins->nC4Speed = psmp->samplerate;
|
162
|
+
pins->nLength = psmp->length;
|
163
|
+
pins->nLoopStart = psmp->loopstart;
|
164
|
+
pins->nLoopEnd = psmp->loopend;
|
165
|
+
pins->nPan = 128;
|
166
|
+
pins->nVolume = (psmp->defvol+1) * 2;
|
167
|
+
pins->uFlags = (psmp->flags & 0x80) ? CHN_LOOP : 0;
|
168
|
+
if (pins->nLoopStart > 0) pins->nLoopStart--;
|
169
|
+
// Point to sample data
|
170
|
+
pdata += 0x60;
|
171
|
+
len -= 0x60;
|
172
|
+
// Load sample data
|
173
|
+
if ((pins->nLength > 3) && (len > 3))
|
174
|
+
{
|
175
|
+
CSoundFile_ReadSample(_this, pins, RS_PCM8D, (LPCSTR)pdata, len);
|
176
|
+
} else
|
177
|
+
{
|
178
|
+
pins->nLength = 0;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
break;
|
182
|
+
}
|
183
|
+
dwMemPos += pchunk->len;
|
184
|
+
}
|
185
|
+
// Step #1: convert song structure
|
186
|
+
PSMSONGHDR *pSong = (PSMSONGHDR *)(lpStream+dwSongPos+8);
|
187
|
+
if ((!dwSongPos) || (pSong->channels < 2) || (pSong->channels > 32)) return TRUE;
|
188
|
+
_this->m_nChannels = pSong->channels;
|
189
|
+
// Valid song header -> convert attached chunks
|
190
|
+
{
|
191
|
+
DWORD dwSongEnd = dwSongPos + 8 + *(DWORD *)(lpStream+dwSongPos+4);
|
192
|
+
dwMemPos = dwSongPos + 8 + 11; // sizeof(PSMCHUNK)+sizeof(PSMSONGHDR)
|
193
|
+
while (dwMemPos + 8 < dwSongEnd)
|
194
|
+
{
|
195
|
+
PSMCHUNK *pchunk = (PSMCHUNK *)(lpStream+dwMemPos);
|
196
|
+
swap_PSMCHUNK(pchunk);
|
197
|
+
dwMemPos += 8;
|
198
|
+
if ((pchunk->len > dwSongEnd) || (dwMemPos + pchunk->len > dwSongEnd)) break;
|
199
|
+
PUCHAR pdata = (PUCHAR)(lpStream+dwMemPos);
|
200
|
+
ULONG len = pchunk->len;
|
201
|
+
switch(pchunk->id)
|
202
|
+
{
|
203
|
+
case IFFID_OPLH:
|
204
|
+
if (len >= 0x20)
|
205
|
+
{
|
206
|
+
UINT pos = len - 3;
|
207
|
+
while (pos > 5)
|
208
|
+
{
|
209
|
+
BOOL bFound = FALSE;
|
210
|
+
pos -= 5;
|
211
|
+
DWORD dwName = *(DWORD *)(pdata+pos);
|
212
|
+
for (UINT i=0; i<nPatterns; i++)
|
213
|
+
{
|
214
|
+
DWORD dwPatName = ((PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
|
215
|
+
if (dwName == dwPatName)
|
216
|
+
{
|
217
|
+
bFound = TRUE;
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
if ((!bFound) && (pdata[pos+1] > 0) && (pdata[pos+1] <= 0x10)
|
222
|
+
&& (pdata[pos+3] > 0x40) && (pdata[pos+3] < 0xC0))
|
223
|
+
{
|
224
|
+
_this->m_nDefaultSpeed = pdata[pos+1];
|
225
|
+
_this->m_nDefaultTempo = pdata[pos+3];
|
226
|
+
break;
|
227
|
+
}
|
228
|
+
}
|
229
|
+
UINT iOrd = 0;
|
230
|
+
while ((pos+5<len) && (iOrd < MAX_ORDERS))
|
231
|
+
{
|
232
|
+
DWORD dwName = *(DWORD *)(pdata+pos);
|
233
|
+
for (UINT i=0; i<nPatterns; i++)
|
234
|
+
{
|
235
|
+
DWORD dwPatName = ((PSMPATTERN *)(lpStream+patptrs[i]+8))->name;
|
236
|
+
if (dwName == dwPatName)
|
237
|
+
{
|
238
|
+
_this->Order[iOrd++] = i;
|
239
|
+
break;
|
240
|
+
}
|
241
|
+
}
|
242
|
+
pos += 5;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
break;
|
246
|
+
}
|
247
|
+
dwMemPos += pchunk->len;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
// Step #2: convert patterns
|
252
|
+
for (UINT nPat=0; nPat<nPatterns; nPat++)
|
253
|
+
{
|
254
|
+
PSMPATTERN *pPsmPat = (PSMPATTERN *)(lpStream+patptrs[nPat]+8);
|
255
|
+
swap_PSMPATTERN(pPsmPat);
|
256
|
+
ULONG len = *(DWORD *)(lpStream+patptrs[nPat]+4) - 12;
|
257
|
+
UINT nRows = pPsmPat->rows;
|
258
|
+
if (len > pPsmPat->size) len = pPsmPat->size;
|
259
|
+
if ((nRows < 64) || (nRows > 256)) nRows = 64;
|
260
|
+
_this->PatternSize[nPat] = nRows;
|
261
|
+
if ((_this->Patterns[nPat] = CSoundFile_AllocatePattern(nRows, _this->m_nChannels)) == NULL) break;
|
262
|
+
MODCOMMAND *m = _this->Patterns[nPat];
|
263
|
+
BYTE *p = pPsmPat->data;
|
264
|
+
UINT pos = 0;
|
265
|
+
UINT row = 0;
|
266
|
+
UINT oldch = 0;
|
267
|
+
BOOL bNewRow = FALSE;
|
268
|
+
while ((row < nRows) && (pos+1 < len))
|
269
|
+
{
|
270
|
+
UINT flags = p[pos++];
|
271
|
+
UINT ch = p[pos++];
|
272
|
+
|
273
|
+
if (((flags & 0xf0) == 0x10) && (ch <= oldch) /*&& (!bNewRow)*/)
|
274
|
+
{
|
275
|
+
if ((pos+1<len) && (!(p[pos] & 0x0f)) && (p[pos+1] < _this->m_nChannels))
|
276
|
+
{
|
277
|
+
row++;
|
278
|
+
m += _this->m_nChannels;
|
279
|
+
oldch = ch;
|
280
|
+
continue;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
if ((pos >= len) || (row >= nRows)) break;
|
284
|
+
if (!(flags & 0xf0))
|
285
|
+
{
|
286
|
+
row++;
|
287
|
+
m += _this->m_nChannels;
|
288
|
+
bNewRow = TRUE;
|
289
|
+
oldch = ch;
|
290
|
+
continue;
|
291
|
+
}
|
292
|
+
bNewRow = FALSE;
|
293
|
+
if (ch >= _this->m_nChannels)
|
294
|
+
{
|
295
|
+
ch = 0;
|
296
|
+
}
|
297
|
+
// Note + Instr
|
298
|
+
if ((flags & 0x40) && (pos+1 < len))
|
299
|
+
{
|
300
|
+
UINT note = p[pos++];
|
301
|
+
UINT nins = p[pos++];
|
302
|
+
if ((note) && (note < 0x80)) note = (note>>4)*12+(note&0x0f)+12+1;
|
303
|
+
m[ch].instr = samplemap[nins];
|
304
|
+
m[ch].note = note;
|
305
|
+
}
|
306
|
+
// Volume
|
307
|
+
if ((flags & 0x20) && (pos < len))
|
308
|
+
{
|
309
|
+
m[ch].volcmd = VOLCMD_VOLUME;
|
310
|
+
m[ch].vol = p[pos++] / 2;
|
311
|
+
}
|
312
|
+
// Effect
|
313
|
+
if ((flags & 0x10) && (pos+1 < len))
|
314
|
+
{
|
315
|
+
UINT command = p[pos++];
|
316
|
+
UINT param = p[pos++];
|
317
|
+
// Convert effects
|
318
|
+
switch(command)
|
319
|
+
{
|
320
|
+
// 01: fine volslide up
|
321
|
+
case 0x01: command = CMD_VOLUMESLIDE; param |= 0x0f; break;
|
322
|
+
// 04: fine volslide down
|
323
|
+
case 0x04: command = CMD_VOLUMESLIDE; param>>=4; param |= 0xf0; break;
|
324
|
+
// 0C: portamento up
|
325
|
+
case 0x0C: command = CMD_PORTAMENTOUP; param = (param+1)/2; break;
|
326
|
+
// 0E: portamento down
|
327
|
+
case 0x0E: command = CMD_PORTAMENTODOWN; param = (param+1)/2; break;
|
328
|
+
// 33: Position Jump
|
329
|
+
case 0x33: command = CMD_POSITIONJUMP; break;
|
330
|
+
// 34: Pattern break
|
331
|
+
case 0x34: command = CMD_PATTERNBREAK; break;
|
332
|
+
// 3D: speed
|
333
|
+
case 0x3D: command = CMD_SPEED; break;
|
334
|
+
// 3E: tempo
|
335
|
+
case 0x3E: command = CMD_TEMPO; break;
|
336
|
+
// Unknown
|
337
|
+
default:
|
338
|
+
command = param = 0;
|
339
|
+
}
|
340
|
+
m[ch].command = (BYTE)command;
|
341
|
+
m[ch].param = (BYTE)param;
|
342
|
+
}
|
343
|
+
oldch = ch;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
// Done (finally!)
|
348
|
+
return TRUE;
|
349
|
+
}
|
350
|
+
|
@@ -0,0 +1,204 @@
|
|
1
|
+
/*
|
2
|
+
* This source code is public domain.
|
3
|
+
*
|
4
|
+
* Authors: Olivier Lapicque <olivierl@jps.net>,
|
5
|
+
* Adam Goode <adam@evdebs.org> (endian and char fixes for PPC)
|
6
|
+
*/
|
7
|
+
|
8
|
+
//////////////////////////////////////////////
|
9
|
+
// PTM PolyTracker module loader //
|
10
|
+
//////////////////////////////////////////////
|
11
|
+
#include "libmodplug.h"
|
12
|
+
|
13
|
+
#pragma pack(1)
|
14
|
+
|
15
|
+
typedef struct PTMFILEHEADER
|
16
|
+
{
|
17
|
+
CHAR songname[28]; // name of song, asciiz string
|
18
|
+
CHAR eof; // 26
|
19
|
+
BYTE version_lo; // 03 version of file, currently 0203h
|
20
|
+
BYTE version_hi; // 02
|
21
|
+
BYTE reserved1; // reserved, set to 0
|
22
|
+
WORD norders; // number of orders (0..256)
|
23
|
+
WORD nsamples; // number of instruments (1..255)
|
24
|
+
WORD npatterns; // number of patterns (1..128)
|
25
|
+
WORD nchannels; // number of channels (voices) used (1..32)
|
26
|
+
WORD fileflags; // set to 0
|
27
|
+
WORD reserved2; // reserved, set to 0
|
28
|
+
DWORD ptmf_id; // song identification, 'PTMF' or 0x464d5450
|
29
|
+
BYTE reserved3[16]; // reserved, set to 0
|
30
|
+
BYTE chnpan[32]; // channel panning settings, 0..15, 0 = left, 7 = middle, 15 = right
|
31
|
+
BYTE orders[256]; // order list, valid entries 0..nOrders-1
|
32
|
+
WORD patseg[128]; // pattern offsets (*16)
|
33
|
+
} PTMFILEHEADER, *LPPTMFILEHEADER;
|
34
|
+
|
35
|
+
#define SIZEOF_PTMFILEHEADER 608
|
36
|
+
|
37
|
+
|
38
|
+
typedef struct PTMSAMPLE
|
39
|
+
{
|
40
|
+
BYTE sampletype; // sample type (bit array)
|
41
|
+
CHAR filename[12]; // name of external sample file
|
42
|
+
BYTE volume; // default volume
|
43
|
+
WORD nC4Spd; // C4 speed
|
44
|
+
WORD sampleseg; // sample segment (used internally)
|
45
|
+
WORD fileofs[2]; // offset of sample data
|
46
|
+
WORD length[2]; // sample size (in bytes)
|
47
|
+
WORD loopbeg[2]; // start of loop
|
48
|
+
WORD loopend[2]; // end of loop
|
49
|
+
WORD gusdata[8];
|
50
|
+
char samplename[28]; // name of sample, asciiz // changed from CHAR
|
51
|
+
DWORD ptms_id; // sample identification, 'PTMS' or 0x534d5450
|
52
|
+
} PTMSAMPLE;
|
53
|
+
|
54
|
+
#define SIZEOF_PTMSAMPLE 80
|
55
|
+
|
56
|
+
#pragma pack()
|
57
|
+
|
58
|
+
|
59
|
+
static uint32_t BS2WORD(uint16_t w[2]) {
|
60
|
+
uint32_t u32 = (w[1] << 16) + w[0];
|
61
|
+
return(bswapLE32(u32));
|
62
|
+
}
|
63
|
+
|
64
|
+
BOOL CSoundFile_ReadPTM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLength)
|
65
|
+
//---------------------------------------------------------------
|
66
|
+
{
|
67
|
+
DWORD dwMemPos;
|
68
|
+
UINT nOrders;
|
69
|
+
|
70
|
+
if ((!lpStream) || (dwMemLength < sizeof(PTMFILEHEADER))) return FALSE;
|
71
|
+
PTMFILEHEADER pfh;
|
72
|
+
SDL_memcpy(&pfh, lpStream, sizeof (pfh));
|
73
|
+
|
74
|
+
pfh.norders = bswapLE16(pfh.norders);
|
75
|
+
pfh.nsamples = bswapLE16(pfh.nsamples);
|
76
|
+
pfh.npatterns = bswapLE16(pfh.npatterns);
|
77
|
+
pfh.nchannels = bswapLE16(pfh.nchannels);
|
78
|
+
pfh.fileflags = bswapLE16(pfh.fileflags);
|
79
|
+
pfh.reserved2 = bswapLE16(pfh.reserved2);
|
80
|
+
pfh.ptmf_id = bswapLE32(pfh.ptmf_id);
|
81
|
+
for (UINT j=0; j<128; j++)
|
82
|
+
{
|
83
|
+
pfh.patseg[j] = bswapLE16(pfh.patseg[j]);
|
84
|
+
}
|
85
|
+
|
86
|
+
if ((pfh.ptmf_id != 0x464d5450) || (!pfh.nchannels)
|
87
|
+
|| (pfh.nchannels > 32)
|
88
|
+
|| (pfh.norders > 256) || (!pfh.norders)
|
89
|
+
|| (!pfh.nsamples) || (pfh.nsamples > 255)
|
90
|
+
|| (!pfh.npatterns) || (pfh.npatterns > 128)
|
91
|
+
|| (SIZEOF_PTMFILEHEADER+pfh.nsamples*SIZEOF_PTMSAMPLE >= (int)dwMemLength)) return FALSE;
|
92
|
+
_this->m_nType = MOD_TYPE_PTM;
|
93
|
+
_this->m_nChannels = pfh.nchannels;
|
94
|
+
_this->m_nSamples = (pfh.nsamples < MAX_SAMPLES) ? pfh.nsamples : MAX_SAMPLES-1;
|
95
|
+
dwMemPos = SIZEOF_PTMFILEHEADER;
|
96
|
+
nOrders = (pfh.norders < MAX_ORDERS) ? pfh.norders : MAX_ORDERS-1;
|
97
|
+
SDL_memcpy(_this->Order, pfh.orders, nOrders);
|
98
|
+
for (UINT ipan=0; ipan<_this->m_nChannels; ipan++)
|
99
|
+
{
|
100
|
+
_this->ChnSettings[ipan].nVolume = 64;
|
101
|
+
_this->ChnSettings[ipan].nPan = ((pfh.chnpan[ipan] & 0x0F) << 4) + 4;
|
102
|
+
}
|
103
|
+
for (UINT ismp=0; ismp<_this->m_nSamples; ismp++, dwMemPos += SIZEOF_PTMSAMPLE)
|
104
|
+
{
|
105
|
+
MODINSTRUMENT *pins = &_this->Ins[ismp+1];
|
106
|
+
PTMSAMPLE *psmp = (PTMSAMPLE *)(lpStream+dwMemPos);
|
107
|
+
pins->nGlobalVol = 64;
|
108
|
+
pins->nPan = 128;
|
109
|
+
pins->nVolume = psmp->volume << 2;
|
110
|
+
pins->nC4Speed = bswapLE16(psmp->nC4Spd) << 1;
|
111
|
+
pins->uFlags = 0;
|
112
|
+
if ((psmp->sampletype & 3) == 1)
|
113
|
+
{
|
114
|
+
UINT smpflg = RS_PCM8D;
|
115
|
+
pins->nLength = BS2WORD(psmp->length);
|
116
|
+
pins->nLoopStart = BS2WORD(psmp->loopbeg);
|
117
|
+
pins->nLoopEnd = BS2WORD(psmp->loopend);
|
118
|
+
DWORD samplepos = BS2WORD(psmp->fileofs);
|
119
|
+
if (psmp->sampletype & 4) pins->uFlags |= CHN_LOOP;
|
120
|
+
if (psmp->sampletype & 8) pins->uFlags |= CHN_PINGPONGLOOP;
|
121
|
+
if (psmp->sampletype & 16)
|
122
|
+
{
|
123
|
+
pins->uFlags |= CHN_16BIT;
|
124
|
+
pins->nLength >>= 1;
|
125
|
+
pins->nLoopStart >>= 1;
|
126
|
+
pins->nLoopEnd >>= 1;
|
127
|
+
smpflg = RS_PTM8DTO16;
|
128
|
+
}
|
129
|
+
if ((pins->nLength) && (samplepos) && (samplepos < dwMemLength))
|
130
|
+
{
|
131
|
+
CSoundFile_ReadSample(_this, pins, smpflg, (LPSTR)(lpStream+samplepos), dwMemLength-samplepos);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
// Reading Patterns
|
136
|
+
for (UINT ipat=0; ipat<pfh.npatterns; ipat++)
|
137
|
+
{
|
138
|
+
dwMemPos = ((UINT)pfh.patseg[ipat]) << 4;
|
139
|
+
if ((!dwMemPos) || (dwMemPos >= dwMemLength)) continue;
|
140
|
+
_this->PatternSize[ipat] = 64;
|
141
|
+
if ((_this->Patterns[ipat] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL) break;
|
142
|
+
//
|
143
|
+
MODCOMMAND *m = _this->Patterns[ipat];
|
144
|
+
for (UINT row=0; ((row < 64) && (dwMemPos < dwMemLength)); )
|
145
|
+
{
|
146
|
+
UINT b = lpStream[dwMemPos++];
|
147
|
+
|
148
|
+
if (dwMemPos >= dwMemLength) break;
|
149
|
+
if (b)
|
150
|
+
{
|
151
|
+
UINT nChn = b & 0x1F;
|
152
|
+
|
153
|
+
if (b & 0x20)
|
154
|
+
{
|
155
|
+
if (dwMemPos + 2 > dwMemLength) break;
|
156
|
+
m[nChn].note = lpStream[dwMemPos++];
|
157
|
+
m[nChn].instr = lpStream[dwMemPos++];
|
158
|
+
}
|
159
|
+
if (b & 0x40)
|
160
|
+
{
|
161
|
+
if (dwMemPos + 2 > dwMemLength) break;
|
162
|
+
m[nChn].command = lpStream[dwMemPos++];
|
163
|
+
m[nChn].param = lpStream[dwMemPos++];
|
164
|
+
if ((m[nChn].command == 0x0E) && ((m[nChn].param & 0xF0) == 0x80))
|
165
|
+
{
|
166
|
+
m[nChn].command = CMD_S3MCMDEX;
|
167
|
+
} else
|
168
|
+
if (m[nChn].command < 0x10)
|
169
|
+
{
|
170
|
+
CSoundFile_ConvertModCommand(_this, &m[nChn]);
|
171
|
+
} else
|
172
|
+
{
|
173
|
+
switch(m[nChn].command)
|
174
|
+
{
|
175
|
+
case 16:
|
176
|
+
m[nChn].command = CMD_GLOBALVOLUME;
|
177
|
+
break;
|
178
|
+
case 17:
|
179
|
+
m[nChn].command = CMD_RETRIG;
|
180
|
+
break;
|
181
|
+
case 18:
|
182
|
+
m[nChn].command = CMD_FINEVIBRATO;
|
183
|
+
break;
|
184
|
+
default:
|
185
|
+
m[nChn].command = 0;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (b & 0x80)
|
190
|
+
{
|
191
|
+
if (dwMemPos >= dwMemLength) break;
|
192
|
+
m[nChn].volcmd = VOLCMD_VOLUME;
|
193
|
+
m[nChn].vol = lpStream[dwMemPos++];
|
194
|
+
}
|
195
|
+
} else
|
196
|
+
{
|
197
|
+
row++;
|
198
|
+
m += _this->m_nChannels;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
return TRUE;
|
203
|
+
}
|
204
|
+
|