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,232 @@
|
|
1
|
+
/*
|
2
|
+
* This source code is public domain.
|
3
|
+
*
|
4
|
+
* Authors: Olivier Lapicque <olivierl@jps.net>
|
5
|
+
*/
|
6
|
+
|
7
|
+
//////////////////////////////////////////////
|
8
|
+
// DSIK Internal Format (DSM) module loader //
|
9
|
+
//////////////////////////////////////////////
|
10
|
+
#include "libmodplug.h"
|
11
|
+
|
12
|
+
#pragma pack(1)
|
13
|
+
|
14
|
+
#define DSMID_RIFF 0x46464952 // "RIFF"
|
15
|
+
#define DSMID_DSMF 0x464d5344 // "DSMF"
|
16
|
+
#define DSMID_SONG 0x474e4f53 // "SONG"
|
17
|
+
#define DSMID_INST 0x54534e49 // "INST"
|
18
|
+
#define DSMID_PATT 0x54544150 // "PATT"
|
19
|
+
|
20
|
+
|
21
|
+
typedef struct DSMNOTE
|
22
|
+
{
|
23
|
+
BYTE note,ins,vol,cmd,inf;
|
24
|
+
} DSMNOTE;
|
25
|
+
|
26
|
+
|
27
|
+
typedef struct DSMINST
|
28
|
+
{
|
29
|
+
DWORD id_INST;
|
30
|
+
DWORD inst_len;
|
31
|
+
CHAR filename[13];
|
32
|
+
BYTE flags;
|
33
|
+
BYTE flags2;
|
34
|
+
BYTE volume;
|
35
|
+
DWORD length;
|
36
|
+
DWORD loopstart;
|
37
|
+
DWORD loopend;
|
38
|
+
DWORD reserved1;
|
39
|
+
WORD c2spd;
|
40
|
+
WORD reserved2;
|
41
|
+
CHAR samplename[28];
|
42
|
+
} DSMINST;
|
43
|
+
|
44
|
+
|
45
|
+
typedef struct DSMFILEHEADER
|
46
|
+
{
|
47
|
+
DWORD id_RIFF; // "RIFF"
|
48
|
+
DWORD riff_len;
|
49
|
+
DWORD id_DSMF; // "DSMF"
|
50
|
+
DWORD id_SONG; // "SONG"
|
51
|
+
DWORD song_len;
|
52
|
+
} DSMFILEHEADER;
|
53
|
+
|
54
|
+
|
55
|
+
typedef struct DSMSONG
|
56
|
+
{
|
57
|
+
CHAR songname[28];
|
58
|
+
WORD reserved1;
|
59
|
+
WORD flags;
|
60
|
+
DWORD reserved2;
|
61
|
+
WORD numord;
|
62
|
+
WORD numsmp;
|
63
|
+
WORD numpat;
|
64
|
+
WORD numtrk;
|
65
|
+
BYTE globalvol;
|
66
|
+
BYTE mastervol;
|
67
|
+
BYTE speed;
|
68
|
+
BYTE bpm;
|
69
|
+
BYTE panpos[16];
|
70
|
+
BYTE orders[128];
|
71
|
+
} DSMSONG;
|
72
|
+
|
73
|
+
typedef struct DSMPATT
|
74
|
+
{
|
75
|
+
DWORD id_PATT;
|
76
|
+
DWORD patt_len;
|
77
|
+
BYTE dummy1;
|
78
|
+
BYTE dummy2;
|
79
|
+
} DSMPATT;
|
80
|
+
|
81
|
+
#pragma pack()
|
82
|
+
|
83
|
+
|
84
|
+
BOOL CSoundFile_ReadDSM(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
|
85
|
+
//-----------------------------------------------------------
|
86
|
+
{
|
87
|
+
DSMFILEHEADER *pfh = (DSMFILEHEADER *)lpStream;
|
88
|
+
DSMSONG *psong;
|
89
|
+
DWORD dwMemPos;
|
90
|
+
UINT nPat, nSmp;
|
91
|
+
|
92
|
+
if ((!lpStream) || (dwMemLength < 1024) || (pfh->id_RIFF != DSMID_RIFF)
|
93
|
+
|| (pfh->riff_len + 8 > dwMemLength) || (pfh->riff_len < 1024)
|
94
|
+
|| (pfh->id_DSMF != DSMID_DSMF) || (pfh->id_SONG != DSMID_SONG)
|
95
|
+
|| (pfh->song_len > dwMemLength)) return FALSE;
|
96
|
+
psong = (DSMSONG *)(lpStream + sizeof(DSMFILEHEADER));
|
97
|
+
dwMemPos = sizeof(DSMFILEHEADER) + pfh->song_len;
|
98
|
+
_this->m_nType = MOD_TYPE_DSM;
|
99
|
+
_this->m_nChannels = psong->numtrk;
|
100
|
+
if (_this->m_nChannels < 4) _this->m_nChannels = 4;
|
101
|
+
if (_this->m_nChannels > 16) _this->m_nChannels = 16;
|
102
|
+
_this->m_nSamples = psong->numsmp;
|
103
|
+
if (_this->m_nSamples >= MAX_SAMPLES) _this->m_nSamples = MAX_SAMPLES - 1;
|
104
|
+
_this->m_nDefaultSpeed = psong->speed;
|
105
|
+
_this->m_nDefaultTempo = psong->bpm;
|
106
|
+
_this->m_nDefaultGlobalVolume = psong->globalvol << 2;
|
107
|
+
if ((!_this->m_nDefaultGlobalVolume) || (_this->m_nDefaultGlobalVolume > 256)) _this->m_nDefaultGlobalVolume = 256;
|
108
|
+
_this->m_nSongPreAmp = psong->mastervol & 0x7F;
|
109
|
+
for (UINT iOrd=0; iOrd<sizeof(psong->orders); iOrd++)
|
110
|
+
{
|
111
|
+
_this->Order[iOrd] = (BYTE)((iOrd < psong->numord) ? psong->orders[iOrd] : 0xFF);
|
112
|
+
}
|
113
|
+
for (UINT iPan=0; iPan<16; iPan++)
|
114
|
+
{
|
115
|
+
_this->ChnSettings[iPan].nPan = 0x80;
|
116
|
+
if (psong->panpos[iPan] <= 0x80)
|
117
|
+
{
|
118
|
+
_this->ChnSettings[iPan].nPan = psong->panpos[iPan] << 1;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
nPat = 0;
|
122
|
+
nSmp = 1;
|
123
|
+
while (dwMemPos < dwMemLength - 8)
|
124
|
+
{
|
125
|
+
DSMPATT *ppatt = (DSMPATT *)(lpStream + dwMemPos);
|
126
|
+
DSMINST *pins = (DSMINST *)(lpStream+dwMemPos);
|
127
|
+
// Reading Patterns
|
128
|
+
if (ppatt->id_PATT == DSMID_PATT)
|
129
|
+
{
|
130
|
+
dwMemPos += 8;
|
131
|
+
if (dwMemPos + ppatt->patt_len >= dwMemLength) break;
|
132
|
+
DWORD dwPos = dwMemPos;
|
133
|
+
dwMemPos += ppatt->patt_len;
|
134
|
+
MODCOMMAND *m = CSoundFile_AllocatePattern(64, _this->m_nChannels);
|
135
|
+
if (!m) break;
|
136
|
+
_this->PatternSize[nPat] = 64;
|
137
|
+
_this->Patterns[nPat] = m;
|
138
|
+
UINT row = 0;
|
139
|
+
while ((row < 64) && (dwPos + 2 <= dwMemPos))
|
140
|
+
{
|
141
|
+
UINT flag = lpStream[dwPos++];
|
142
|
+
if (flag)
|
143
|
+
{
|
144
|
+
UINT ch = (flag & 0x0F) % _this->m_nChannels;
|
145
|
+
if (flag & 0x80)
|
146
|
+
{
|
147
|
+
UINT note = lpStream[dwPos++];
|
148
|
+
if (note)
|
149
|
+
{
|
150
|
+
if (note <= 12*9) note += 12;
|
151
|
+
m[ch].note = (BYTE)note;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
if (flag & 0x40)
|
155
|
+
{
|
156
|
+
m[ch].instr = lpStream[dwPos++];
|
157
|
+
}
|
158
|
+
if (flag & 0x20)
|
159
|
+
{
|
160
|
+
m[ch].volcmd = VOLCMD_VOLUME;
|
161
|
+
m[ch].vol = lpStream[dwPos++];
|
162
|
+
}
|
163
|
+
if (flag & 0x10)
|
164
|
+
{
|
165
|
+
UINT command = lpStream[dwPos++];
|
166
|
+
UINT param = lpStream[dwPos++];
|
167
|
+
switch(command)
|
168
|
+
{
|
169
|
+
// 4-bit Panning
|
170
|
+
case 0x08:
|
171
|
+
switch(param & 0xF0)
|
172
|
+
{
|
173
|
+
case 0x00: param <<= 4; break;
|
174
|
+
case 0x10: command = 0x0A; param = (param & 0x0F) << 4; break;
|
175
|
+
case 0x20: command = 0x0E; param = (param & 0x0F) | 0xA0; break;
|
176
|
+
case 0x30: command = 0x0E; param = (param & 0x0F) | 0x10; break;
|
177
|
+
case 0x40: command = 0x0E; param = (param & 0x0F) | 0x20; break;
|
178
|
+
default: command = 0;
|
179
|
+
}
|
180
|
+
break;
|
181
|
+
// Portamentos
|
182
|
+
case 0x11:
|
183
|
+
case 0x12:
|
184
|
+
command &= 0x0F;
|
185
|
+
break;
|
186
|
+
// 3D Sound (?)
|
187
|
+
case 0x13:
|
188
|
+
command = 'X' - 55;
|
189
|
+
param = 0x91;
|
190
|
+
break;
|
191
|
+
default:
|
192
|
+
// Volume + Offset (?)
|
193
|
+
command = ((command & 0xF0) == 0x20) ? 0x09 : 0;
|
194
|
+
}
|
195
|
+
m[ch].command = (BYTE)command;
|
196
|
+
m[ch].param = (BYTE)param;
|
197
|
+
if (command) CSoundFile_ConvertModCommand(_this, &m[ch]);
|
198
|
+
}
|
199
|
+
} else
|
200
|
+
{
|
201
|
+
m += _this->m_nChannels;
|
202
|
+
row++;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
nPat++;
|
206
|
+
} else
|
207
|
+
// Reading Samples
|
208
|
+
if ((nSmp <= _this->m_nSamples) && (pins->id_INST == DSMID_INST))
|
209
|
+
{
|
210
|
+
if (dwMemPos + pins->inst_len >= dwMemLength - 8) break;
|
211
|
+
DWORD dwPos = dwMemPos + sizeof(DSMINST);
|
212
|
+
dwMemPos += 8 + pins->inst_len;
|
213
|
+
MODINSTRUMENT *psmp = &_this->Ins[nSmp];
|
214
|
+
psmp->nGlobalVol = 64;
|
215
|
+
psmp->nC4Speed = pins->c2spd;
|
216
|
+
psmp->uFlags = (WORD)((pins->flags & 1) ? CHN_LOOP : 0);
|
217
|
+
psmp->nLength = pins->length;
|
218
|
+
psmp->nLoopStart = pins->loopstart;
|
219
|
+
psmp->nLoopEnd = pins->loopend;
|
220
|
+
psmp->nVolume = (WORD)(pins->volume << 2);
|
221
|
+
if (psmp->nVolume > 256) psmp->nVolume = 256;
|
222
|
+
UINT smptype = (pins->flags & 2) ? RS_PCM8S : RS_PCM8U;
|
223
|
+
CSoundFile_ReadSample(_this, psmp, smptype, (LPCSTR)(lpStream+dwPos), dwMemLength - dwPos);
|
224
|
+
nSmp++;
|
225
|
+
} else
|
226
|
+
{
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
return TRUE;
|
231
|
+
}
|
232
|
+
|
@@ -0,0 +1,253 @@
|
|
1
|
+
/*
|
2
|
+
* This source code is public domain.
|
3
|
+
*
|
4
|
+
* Authors: Olivier Lapicque <olivierl@jps.net>
|
5
|
+
*/
|
6
|
+
|
7
|
+
////////////////////////////////////////
|
8
|
+
// Farandole (FAR) module loader //
|
9
|
+
////////////////////////////////////////
|
10
|
+
#include "libmodplug.h"
|
11
|
+
|
12
|
+
#define FARFILEMAGIC 0xFE524146 // "FAR"
|
13
|
+
|
14
|
+
#pragma pack(1)
|
15
|
+
|
16
|
+
typedef struct FARHEADER1
|
17
|
+
{
|
18
|
+
DWORD id; // file magic FAR=
|
19
|
+
CHAR songname[40]; // songname
|
20
|
+
CHAR magic2[3]; // 13,10,26
|
21
|
+
WORD headerlen; // remaining length of header in bytes
|
22
|
+
BYTE version; // 0xD1
|
23
|
+
BYTE onoff[16];
|
24
|
+
BYTE edit1[9];
|
25
|
+
BYTE speed;
|
26
|
+
BYTE panning[16];
|
27
|
+
BYTE edit2[4];
|
28
|
+
WORD stlen;
|
29
|
+
} FARHEADER1;
|
30
|
+
|
31
|
+
typedef struct FARHEADER2
|
32
|
+
{
|
33
|
+
BYTE orders[256];
|
34
|
+
BYTE numpat;
|
35
|
+
BYTE snglen;
|
36
|
+
BYTE loopto;
|
37
|
+
WORD patsiz[256];
|
38
|
+
} FARHEADER2;
|
39
|
+
|
40
|
+
typedef struct FARSAMPLE
|
41
|
+
{
|
42
|
+
CHAR samplename[32];
|
43
|
+
DWORD length;
|
44
|
+
BYTE finetune;
|
45
|
+
BYTE volume;
|
46
|
+
DWORD reppos;
|
47
|
+
DWORD repend;
|
48
|
+
BYTE type;
|
49
|
+
BYTE loop;
|
50
|
+
} FARSAMPLE;
|
51
|
+
|
52
|
+
#pragma pack()
|
53
|
+
|
54
|
+
|
55
|
+
BOOL CSoundFile_ReadFAR(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLength)
|
56
|
+
//---------------------------------------------------------------
|
57
|
+
{
|
58
|
+
const FARHEADER1 *pmh1 = (const FARHEADER1 *)lpStream;
|
59
|
+
const FARHEADER2 *pmh2;
|
60
|
+
DWORD dwMemPos = sizeof(FARHEADER1);
|
61
|
+
UINT headerlen, stlen;
|
62
|
+
BYTE samplemap[8];
|
63
|
+
|
64
|
+
if ((!lpStream) || (dwMemLength < 1024) || (bswapLE32(pmh1->id) != FARFILEMAGIC)
|
65
|
+
|| (pmh1->magic2[0] != 13) || (pmh1->magic2[1] != 10) || (pmh1->magic2[2] != 26)) return FALSE;
|
66
|
+
headerlen = bswapLE16(pmh1->headerlen);
|
67
|
+
stlen = bswapLE16( pmh1->stlen );
|
68
|
+
if ((headerlen >= dwMemLength) || (dwMemPos + stlen + sizeof(FARHEADER2) >= dwMemLength)) return FALSE;
|
69
|
+
// Globals
|
70
|
+
_this->m_nType = MOD_TYPE_FAR;
|
71
|
+
_this->m_nChannels = 16;
|
72
|
+
_this->m_nInstruments = 0;
|
73
|
+
_this->m_nSamples = 0;
|
74
|
+
_this->m_nSongPreAmp = 0x20;
|
75
|
+
_this->m_nDefaultSpeed = pmh1->speed;
|
76
|
+
_this->m_nDefaultTempo = 80;
|
77
|
+
_this->m_nDefaultGlobalVolume = 256;
|
78
|
+
|
79
|
+
// Channel Setting
|
80
|
+
for (UINT nchpan=0; nchpan<16; nchpan++)
|
81
|
+
{
|
82
|
+
_this->ChnSettings[nchpan].dwFlags = 0;
|
83
|
+
_this->ChnSettings[nchpan].nPan = ((pmh1->panning[nchpan] & 0x0F) << 4) + 8;
|
84
|
+
_this->ChnSettings[nchpan].nVolume = 64;
|
85
|
+
}
|
86
|
+
// Reading comment
|
87
|
+
if (stlen)
|
88
|
+
{
|
89
|
+
dwMemPos += stlen;
|
90
|
+
}
|
91
|
+
// Reading orders
|
92
|
+
if (sizeof(FARHEADER2) > dwMemLength - dwMemPos) return TRUE;
|
93
|
+
pmh2 = (const FARHEADER2 *)(lpStream + dwMemPos);
|
94
|
+
dwMemPos += sizeof(FARHEADER2);
|
95
|
+
if (dwMemPos >= dwMemLength) return TRUE;
|
96
|
+
for (UINT iorder=0; iorder<MAX_ORDERS; iorder++)
|
97
|
+
{
|
98
|
+
_this->Order[iorder] = (iorder <= pmh2->snglen) ? pmh2->orders[iorder] : 0xFF;
|
99
|
+
}
|
100
|
+
_this->m_nRestartPos = pmh2->loopto;
|
101
|
+
// Reading Patterns
|
102
|
+
dwMemPos += headerlen - (869 + stlen);
|
103
|
+
if (dwMemPos >= dwMemLength) return TRUE;
|
104
|
+
|
105
|
+
// end byteswap of pattern data
|
106
|
+
|
107
|
+
WORD *patsiz = (WORD *)pmh2->patsiz;
|
108
|
+
for (UINT ipat=0; ipat<256; ipat++) if (patsiz[ipat])
|
109
|
+
{
|
110
|
+
UINT patlen = bswapLE16(patsiz[ipat]);
|
111
|
+
if ((ipat >= MAX_PATTERNS) || (patlen < 2))
|
112
|
+
{
|
113
|
+
dwMemPos += patlen;
|
114
|
+
continue;
|
115
|
+
}
|
116
|
+
if (dwMemPos + patlen >= dwMemLength) return TRUE;
|
117
|
+
UINT rows = (patlen - 2) >> 6;
|
118
|
+
if (!rows)
|
119
|
+
{
|
120
|
+
dwMemPos += patlen;
|
121
|
+
continue;
|
122
|
+
}
|
123
|
+
if (rows > 256) rows = 256;
|
124
|
+
if (rows < 16) rows = 16;
|
125
|
+
_this->PatternSize[ipat] = rows;
|
126
|
+
if ((_this->Patterns[ipat] = CSoundFile_AllocatePattern(rows, _this->m_nChannels)) == NULL) return TRUE;
|
127
|
+
MODCOMMAND *m = _this->Patterns[ipat];
|
128
|
+
UINT patbrk = lpStream[dwMemPos];
|
129
|
+
const BYTE *p = lpStream + dwMemPos + 2;
|
130
|
+
UINT max = rows*16*4;
|
131
|
+
if (max > patlen-2) max = patlen-2;
|
132
|
+
for (UINT len=0; len<max; len += 4, m++)
|
133
|
+
{
|
134
|
+
BYTE note = p[len];
|
135
|
+
BYTE ins = p[len+1];
|
136
|
+
BYTE vol = p[len+2];
|
137
|
+
BYTE eff = p[len+3];
|
138
|
+
if (note)
|
139
|
+
{
|
140
|
+
m->instr = ins + 1;
|
141
|
+
m->note = note + 36;
|
142
|
+
}
|
143
|
+
if (vol & 0x0F)
|
144
|
+
{
|
145
|
+
m->volcmd = VOLCMD_VOLUME;
|
146
|
+
m->vol = (vol & 0x0F) << 2;
|
147
|
+
if (m->vol <= 4) m->vol = 0;
|
148
|
+
}
|
149
|
+
switch(eff & 0xF0)
|
150
|
+
{
|
151
|
+
// 1.x: Portamento Up
|
152
|
+
case 0x10:
|
153
|
+
m->command = CMD_PORTAMENTOUP;
|
154
|
+
m->param = eff & 0x0F;
|
155
|
+
break;
|
156
|
+
// 2.x: Portamento Down
|
157
|
+
case 0x20:
|
158
|
+
m->command = CMD_PORTAMENTODOWN;
|
159
|
+
m->param = eff & 0x0F;
|
160
|
+
break;
|
161
|
+
// 3.x: Tone-Portamento
|
162
|
+
case 0x30:
|
163
|
+
m->command = CMD_TONEPORTAMENTO;
|
164
|
+
m->param = (eff & 0x0F) << 2;
|
165
|
+
break;
|
166
|
+
// 4.x: Retrigger
|
167
|
+
case 0x40:
|
168
|
+
m->command = CMD_RETRIG;
|
169
|
+
m->param = 6 / (1+(eff&0x0F)) + 1;
|
170
|
+
break;
|
171
|
+
// 5.x: Set Vibrato Depth
|
172
|
+
case 0x50:
|
173
|
+
m->command = CMD_VIBRATO;
|
174
|
+
m->param = (eff & 0x0F);
|
175
|
+
break;
|
176
|
+
// 6.x: Set Vibrato Speed
|
177
|
+
case 0x60:
|
178
|
+
m->command = CMD_VIBRATO;
|
179
|
+
m->param = (eff & 0x0F) << 4;
|
180
|
+
break;
|
181
|
+
// 7.x: Vol Slide Up
|
182
|
+
case 0x70:
|
183
|
+
m->command = CMD_VOLUMESLIDE;
|
184
|
+
m->param = (eff & 0x0F) << 4;
|
185
|
+
break;
|
186
|
+
// 8.x: Vol Slide Down
|
187
|
+
case 0x80:
|
188
|
+
m->command = CMD_VOLUMESLIDE;
|
189
|
+
m->param = (eff & 0x0F);
|
190
|
+
break;
|
191
|
+
// A.x: Port to vol
|
192
|
+
case 0xA0:
|
193
|
+
m->volcmd = VOLCMD_VOLUME;
|
194
|
+
m->vol = ((eff & 0x0F) << 2) + 4;
|
195
|
+
break;
|
196
|
+
// B.x: Set Balance
|
197
|
+
case 0xB0:
|
198
|
+
m->command = CMD_PANNING8;
|
199
|
+
m->param = (eff & 0x0F) << 4;
|
200
|
+
break;
|
201
|
+
// F.x: Set Speed
|
202
|
+
case 0xF0:
|
203
|
+
m->command = CMD_SPEED;
|
204
|
+
m->param = eff & 0x0F;
|
205
|
+
break;
|
206
|
+
default:
|
207
|
+
if ((patbrk) && (patbrk+1 == (len >> 6)) && (patbrk+1 != rows-1))
|
208
|
+
{
|
209
|
+
m->command = CMD_PATTERNBREAK;
|
210
|
+
patbrk = 0;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
dwMemPos += patlen;
|
215
|
+
}
|
216
|
+
// Reading samples
|
217
|
+
if (dwMemPos + 8 >= dwMemLength) return TRUE;
|
218
|
+
SDL_memcpy(samplemap, lpStream+dwMemPos, 8);
|
219
|
+
dwMemPos += 8;
|
220
|
+
MODINSTRUMENT *pins = &_this->Ins[1];
|
221
|
+
for (UINT ismp=0; ismp<64; ismp++, pins++) if (samplemap[ismp >> 3] & (1 << (ismp & 7)))
|
222
|
+
{
|
223
|
+
if (dwMemPos + sizeof(FARSAMPLE) > dwMemLength) return TRUE;
|
224
|
+
const FARSAMPLE *pfs = (const FARSAMPLE*)(lpStream + dwMemPos);
|
225
|
+
dwMemPos += sizeof(FARSAMPLE);
|
226
|
+
_this->m_nSamples = ismp + 1;
|
227
|
+
const DWORD length = bswapLE32( pfs->length ) ; /* endian fix - Toad */
|
228
|
+
pins->nLength = length ;
|
229
|
+
pins->nLoopStart = bswapLE32(pfs->reppos) ;
|
230
|
+
pins->nLoopEnd = bswapLE32(pfs->repend) ;
|
231
|
+
pins->nFineTune = 0;
|
232
|
+
pins->nC4Speed = 8363*2;
|
233
|
+
pins->nGlobalVol = 64;
|
234
|
+
pins->nVolume = pfs->volume << 4;
|
235
|
+
pins->uFlags = 0;
|
236
|
+
if ((pins->nLength > 3) && (dwMemPos + 4 < dwMemLength))
|
237
|
+
{
|
238
|
+
if (pfs->type & 1)
|
239
|
+
{
|
240
|
+
pins->uFlags |= CHN_16BIT;
|
241
|
+
pins->nLength >>= 1;
|
242
|
+
pins->nLoopStart >>= 1;
|
243
|
+
pins->nLoopEnd >>= 1;
|
244
|
+
}
|
245
|
+
if ((pfs->loop & 8) && (pins->nLoopEnd > 4)) pins->uFlags |= CHN_LOOP;
|
246
|
+
CSoundFile_ReadSample(_this, pins, (pins->uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S,
|
247
|
+
(LPSTR)(lpStream+dwMemPos), dwMemLength - dwMemPos);
|
248
|
+
}
|
249
|
+
dwMemPos += length;
|
250
|
+
}
|
251
|
+
return TRUE;
|
252
|
+
}
|
253
|
+
|