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,325 @@
|
|
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
|
+
#include "libmodplug.h"
|
9
|
+
#include "tables.h"
|
10
|
+
|
11
|
+
//////////////////////////////////////////////////////
|
12
|
+
// ScreamTracker S3M file support
|
13
|
+
|
14
|
+
#pragma pack(1)
|
15
|
+
typedef struct tagS3MSAMPLESTRUCT
|
16
|
+
{
|
17
|
+
BYTE type;
|
18
|
+
CHAR dosname[12];
|
19
|
+
BYTE hmem;
|
20
|
+
WORD memseg;
|
21
|
+
DWORD length;
|
22
|
+
DWORD loopbegin;
|
23
|
+
DWORD loopend;
|
24
|
+
BYTE vol;
|
25
|
+
BYTE bReserved;
|
26
|
+
BYTE pack;
|
27
|
+
BYTE flags;
|
28
|
+
DWORD finetune;
|
29
|
+
DWORD dwReserved;
|
30
|
+
WORD intgp;
|
31
|
+
WORD int512;
|
32
|
+
DWORD lastused;
|
33
|
+
CHAR name[28];
|
34
|
+
CHAR scrs[4];
|
35
|
+
} S3MSAMPLESTRUCT;
|
36
|
+
|
37
|
+
|
38
|
+
typedef struct tagS3MFILEHEADER
|
39
|
+
{
|
40
|
+
CHAR name[28];
|
41
|
+
BYTE b1A;
|
42
|
+
BYTE type;
|
43
|
+
WORD reserved1;
|
44
|
+
WORD ordnum;
|
45
|
+
WORD insnum;
|
46
|
+
WORD patnum;
|
47
|
+
WORD flags;
|
48
|
+
WORD cwtv;
|
49
|
+
WORD version;
|
50
|
+
DWORD scrm; // "SCRM" = 0x4D524353
|
51
|
+
BYTE globalvol;
|
52
|
+
BYTE speed;
|
53
|
+
BYTE tempo;
|
54
|
+
BYTE mastervol;
|
55
|
+
BYTE ultraclicks;
|
56
|
+
BYTE panning_present;
|
57
|
+
BYTE reserved2[8];
|
58
|
+
WORD special;
|
59
|
+
BYTE channels[32];
|
60
|
+
} S3MFILEHEADER;
|
61
|
+
|
62
|
+
|
63
|
+
void CSoundFile_S3MConvert(MODCOMMAND *m, BOOL bIT)
|
64
|
+
//--------------------------------------------------------
|
65
|
+
{
|
66
|
+
UINT command = m->command;
|
67
|
+
UINT param = m->param;
|
68
|
+
switch (command + 0x40)
|
69
|
+
{
|
70
|
+
case 'A': command = CMD_SPEED; break;
|
71
|
+
case 'B': command = CMD_POSITIONJUMP; break;
|
72
|
+
case 'C': command = CMD_PATTERNBREAK; if (!bIT) param = (param >> 4) * 10 + (param & 0x0F); break;
|
73
|
+
case 'D': command = CMD_VOLUMESLIDE; break;
|
74
|
+
case 'E': command = CMD_PORTAMENTODOWN; break;
|
75
|
+
case 'F': command = CMD_PORTAMENTOUP; break;
|
76
|
+
case 'G': command = CMD_TONEPORTAMENTO; break;
|
77
|
+
case 'H': command = CMD_VIBRATO; break;
|
78
|
+
case 'I': command = CMD_TREMOR; break;
|
79
|
+
case 'J': command = CMD_ARPEGGIO; break;
|
80
|
+
case 'K': command = CMD_VIBRATOVOL; break;
|
81
|
+
case 'L': command = CMD_TONEPORTAVOL; break;
|
82
|
+
case 'M': command = CMD_CHANNELVOLUME; break;
|
83
|
+
case 'N': command = CMD_CHANNELVOLSLIDE; break;
|
84
|
+
case 'O': command = CMD_OFFSET; break;
|
85
|
+
case 'P': command = CMD_PANNINGSLIDE; break;
|
86
|
+
case 'Q': command = CMD_RETRIG; break;
|
87
|
+
case 'R': command = CMD_TREMOLO; break;
|
88
|
+
case 'S': command = CMD_S3MCMDEX; break;
|
89
|
+
case 'T': command = CMD_TEMPO; break;
|
90
|
+
case 'U': command = CMD_FINEVIBRATO; break;
|
91
|
+
case 'V': command = CMD_GLOBALVOLUME; break;
|
92
|
+
case 'W': command = CMD_GLOBALVOLSLIDE; break;
|
93
|
+
case 'X': command = CMD_PANNING8; break;
|
94
|
+
case 'Y': command = CMD_PANBRELLO; break;
|
95
|
+
case 'Z': command = CMD_MIDI; break;
|
96
|
+
default: command = 0;
|
97
|
+
}
|
98
|
+
m->command = command;
|
99
|
+
m->param = param;
|
100
|
+
}
|
101
|
+
|
102
|
+
static DWORD boundInput(DWORD input, DWORD smin, DWORD smax)
|
103
|
+
{
|
104
|
+
if (input > smax) input = smax;
|
105
|
+
else if (input < smin) input = 0;
|
106
|
+
return(input);
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
BOOL CSoundFile_ReadS3M(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLength)
|
111
|
+
//---------------------------------------------------------------
|
112
|
+
{
|
113
|
+
UINT insnum,patnum,nins,npat;
|
114
|
+
DWORD insfile[MAX_SAMPLES];
|
115
|
+
WORD ptr[256];
|
116
|
+
DWORD dwMemPos;
|
117
|
+
BYTE insflags[MAX_SAMPLES], inspack[MAX_SAMPLES];
|
118
|
+
|
119
|
+
if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER)+sizeof(S3MSAMPLESTRUCT)+64)) return FALSE;
|
120
|
+
S3MFILEHEADER psfh;
|
121
|
+
SDL_memcpy(&psfh, lpStream, sizeof (psfh));
|
122
|
+
|
123
|
+
psfh.reserved1 = bswapLE16(psfh.reserved1);
|
124
|
+
psfh.ordnum = bswapLE16(psfh.ordnum);
|
125
|
+
psfh.insnum = bswapLE16(psfh.insnum);
|
126
|
+
psfh.patnum = bswapLE16(psfh.patnum);
|
127
|
+
psfh.flags = bswapLE16(psfh.flags);
|
128
|
+
psfh.cwtv = bswapLE16(psfh.cwtv);
|
129
|
+
psfh.version = bswapLE16(psfh.version);
|
130
|
+
psfh.scrm = bswapLE32(psfh.scrm);
|
131
|
+
psfh.special = bswapLE16(psfh.special);
|
132
|
+
|
133
|
+
if (psfh.scrm != 0x4D524353) return FALSE;
|
134
|
+
dwMemPos = 0x60;
|
135
|
+
_this->m_nType = MOD_TYPE_S3M;
|
136
|
+
// Speed
|
137
|
+
_this->m_nDefaultSpeed = psfh.speed;
|
138
|
+
if (_this->m_nDefaultSpeed < 1) _this->m_nDefaultSpeed = 6;
|
139
|
+
if (_this->m_nDefaultSpeed > 0x1F) _this->m_nDefaultSpeed = 0x1F;
|
140
|
+
// Tempo
|
141
|
+
_this->m_nDefaultTempo = psfh.tempo;
|
142
|
+
if (_this->m_nDefaultTempo < 40) _this->m_nDefaultTempo = 40;
|
143
|
+
if (_this->m_nDefaultTempo > 240) _this->m_nDefaultTempo = 240;
|
144
|
+
// Global Volume
|
145
|
+
_this->m_nDefaultGlobalVolume = psfh.globalvol << 2;
|
146
|
+
if ((!_this->m_nDefaultGlobalVolume) || (_this->m_nDefaultGlobalVolume > 256)) _this->m_nDefaultGlobalVolume = 256;
|
147
|
+
_this->m_nSongPreAmp = psfh.mastervol & 0x7F;
|
148
|
+
// Channels
|
149
|
+
_this->m_nChannels = 4;
|
150
|
+
for (UINT ich=0; ich<32; ich++)
|
151
|
+
{
|
152
|
+
_this->ChnSettings[ich].nPan = 128;
|
153
|
+
_this->ChnSettings[ich].nVolume = 64;
|
154
|
+
|
155
|
+
_this->ChnSettings[ich].dwFlags = CHN_MUTE;
|
156
|
+
if (psfh.channels[ich] != 0xFF)
|
157
|
+
{
|
158
|
+
_this->m_nChannels = ich+1;
|
159
|
+
UINT b = psfh.channels[ich] & 0x0F;
|
160
|
+
_this->ChnSettings[ich].nPan = (b & 8) ? 0xC0 : 0x40;
|
161
|
+
_this->ChnSettings[ich].dwFlags = 0;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
if (_this->m_nChannels < 4) _this->m_nChannels = 4;
|
165
|
+
if ((psfh.cwtv < 0x1320) || (psfh.flags & 0x40)) _this->m_dwSongFlags |= SONG_FASTVOLSLIDES;
|
166
|
+
// Reading pattern order
|
167
|
+
UINT iord = psfh.ordnum;
|
168
|
+
if (iord<1) iord = 1;
|
169
|
+
if (iord > MAX_ORDERS) iord = MAX_ORDERS;
|
170
|
+
if (iord)
|
171
|
+
{
|
172
|
+
SDL_memcpy(_this->Order, lpStream+dwMemPos, iord);
|
173
|
+
dwMemPos += iord;
|
174
|
+
}
|
175
|
+
if ((iord & 1) && (lpStream[dwMemPos] == 0xFF)) dwMemPos++;
|
176
|
+
// Reading file pointers
|
177
|
+
insnum = nins = psfh.insnum;
|
178
|
+
if (insnum >= MAX_SAMPLES) insnum = MAX_SAMPLES-1;
|
179
|
+
_this->m_nSamples = insnum;
|
180
|
+
patnum = npat = psfh.patnum;
|
181
|
+
if (patnum > MAX_PATTERNS) patnum = MAX_PATTERNS;
|
182
|
+
SDL_memset(ptr, 0, sizeof(ptr));
|
183
|
+
|
184
|
+
// Ignore file if it has a corrupted header.
|
185
|
+
if (nins+npat > 256) return FALSE;
|
186
|
+
|
187
|
+
if (nins+npat)
|
188
|
+
{
|
189
|
+
SDL_memcpy(ptr, lpStream+dwMemPos, 2*(nins+npat));
|
190
|
+
dwMemPos += 2*(nins+npat);
|
191
|
+
for (UINT j = 0; j < (nins+npat); ++j) {
|
192
|
+
ptr[j] = bswapLE16(ptr[j]);
|
193
|
+
}
|
194
|
+
if (psfh.panning_present == 252)
|
195
|
+
{
|
196
|
+
const BYTE *chnpan = lpStream+dwMemPos;
|
197
|
+
for (UINT i=0; i<32; i++) if (chnpan[i] & 0x20)
|
198
|
+
{
|
199
|
+
_this->ChnSettings[i].nPan = ((chnpan[i] & 0x0F) << 4) + 8;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
if (!_this->m_nChannels) return TRUE;
|
204
|
+
// Reading instrument headers
|
205
|
+
SDL_memset(insfile, 0, sizeof(insfile));
|
206
|
+
for (UINT iSmp=1; iSmp<=insnum; iSmp++)
|
207
|
+
{
|
208
|
+
UINT nInd = ((DWORD)ptr[iSmp-1])*16;
|
209
|
+
if ((!nInd) || (nInd + 0x50 > dwMemLength)) {
|
210
|
+
// initialize basic variables.
|
211
|
+
insflags[iSmp-1] = 0;
|
212
|
+
inspack[iSmp-1] = 0;
|
213
|
+
continue;
|
214
|
+
}
|
215
|
+
S3MSAMPLESTRUCT pSmp;
|
216
|
+
SDL_memcpy(&pSmp, lpStream+nInd, 0x50);
|
217
|
+
insflags[iSmp-1] = pSmp.flags;
|
218
|
+
inspack[iSmp-1] = pSmp.pack;
|
219
|
+
if ((pSmp.type==1) && (pSmp.scrs[2]=='R') && (pSmp.scrs[3]=='S'))
|
220
|
+
{
|
221
|
+
_this->Ins[iSmp].nLength = boundInput(bswapLE32(pSmp.length), 4, MAX_SAMPLE_LENGTH);
|
222
|
+
_this->Ins[iSmp].nLoopStart = boundInput(bswapLE32(pSmp.loopbegin), 4, _this->Ins[iSmp].nLength - 1);
|
223
|
+
_this->Ins[iSmp].nLoopEnd = boundInput(bswapLE32(pSmp.loopend), 4, _this->Ins[iSmp].nLength);
|
224
|
+
_this->Ins[iSmp].nVolume = boundInput(pSmp.vol, 0, 64) << 2;
|
225
|
+
_this->Ins[iSmp].nGlobalVol = 64;
|
226
|
+
if (pSmp.flags&1) _this->Ins[iSmp].uFlags |= CHN_LOOP;
|
227
|
+
UINT j = bswapLE32(pSmp.finetune);
|
228
|
+
if (!j) j = 8363;
|
229
|
+
if (j < 1024) j = 1024;
|
230
|
+
_this->Ins[iSmp].nC4Speed = j;
|
231
|
+
insfile[iSmp] = (pSmp.hmem << 20) + (bswapLE16(pSmp.memseg) << 4);
|
232
|
+
// offset is invalid - ignore this sample.
|
233
|
+
if (insfile[iSmp] > dwMemLength) insfile[iSmp] = 0;
|
234
|
+
else if (insfile[iSmp]) {
|
235
|
+
// ignore duplicate samples.
|
236
|
+
for (int z=iSmp-1; z>=0; z--)
|
237
|
+
if (insfile[iSmp] == insfile[z])
|
238
|
+
insfile[iSmp] = 0;
|
239
|
+
}
|
240
|
+
if ((_this->Ins[iSmp].nLoopStart >= _this->Ins[iSmp].nLoopEnd) || (_this->Ins[iSmp].nLoopEnd - _this->Ins[iSmp].nLoopStart < 8))
|
241
|
+
_this->Ins[iSmp].nLoopStart = _this->Ins[iSmp].nLoopEnd = 0;
|
242
|
+
_this->Ins[iSmp].nPan = 0x80;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
// Reading patterns
|
246
|
+
for (UINT iPat=0; iPat<patnum; iPat++)
|
247
|
+
{
|
248
|
+
UINT nInd = ((DWORD)ptr[nins+iPat]) << 4;
|
249
|
+
if (nInd + 0x40 > dwMemLength) continue;
|
250
|
+
WORD len = bswapLE16(*((WORD *)(lpStream+nInd)));
|
251
|
+
nInd += 2;
|
252
|
+
_this->PatternSize[iPat] = 64;
|
253
|
+
if ((!len) || (nInd + len > dwMemLength - 6)
|
254
|
+
|| ((_this->Patterns[iPat] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL)) continue;
|
255
|
+
LPBYTE src = (LPBYTE)(lpStream+nInd);
|
256
|
+
// Unpacking pattern
|
257
|
+
MODCOMMAND *p = _this->Patterns[iPat];
|
258
|
+
UINT row = 0;
|
259
|
+
UINT j = 0;
|
260
|
+
while (j < len)
|
261
|
+
{
|
262
|
+
BYTE b = src[j++];
|
263
|
+
if (!b)
|
264
|
+
{
|
265
|
+
if (++row >= 64) break;
|
266
|
+
} else
|
267
|
+
{
|
268
|
+
UINT chn = b & 0x1F;
|
269
|
+
if (chn < _this->m_nChannels)
|
270
|
+
{
|
271
|
+
MODCOMMAND *m = &p[row*_this->m_nChannels+chn];
|
272
|
+
if (b & 0x20)
|
273
|
+
{
|
274
|
+
m->note = src[j++];
|
275
|
+
if (m->note < 0xF0) m->note = (m->note & 0x0F) + 12*(m->note >> 4) + 13;
|
276
|
+
else if (m->note == 0xFF) m->note = 0;
|
277
|
+
m->instr = src[j++];
|
278
|
+
}
|
279
|
+
if (b & 0x40)
|
280
|
+
{
|
281
|
+
UINT vol = src[j++];
|
282
|
+
if ((vol >= 128) && (vol <= 192))
|
283
|
+
{
|
284
|
+
vol -= 128;
|
285
|
+
m->volcmd = VOLCMD_PANNING;
|
286
|
+
} else
|
287
|
+
{
|
288
|
+
if (vol > 64) vol = 64;
|
289
|
+
m->volcmd = VOLCMD_VOLUME;
|
290
|
+
}
|
291
|
+
m->vol = vol;
|
292
|
+
}
|
293
|
+
if (b & 0x80)
|
294
|
+
{
|
295
|
+
m->command = src[j++];
|
296
|
+
m->param = src[j++];
|
297
|
+
if (m->command) CSoundFile_S3MConvert(m, FALSE);
|
298
|
+
}
|
299
|
+
} else
|
300
|
+
{
|
301
|
+
if (b & 0x20) j += 2;
|
302
|
+
if (b & 0x40) j++;
|
303
|
+
if (b & 0x80) j += 2;
|
304
|
+
}
|
305
|
+
if (j >= len) break;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
// Reading samples
|
310
|
+
for (UINT iRaw=1; iRaw<=insnum; iRaw++) if ((_this->Ins[iRaw].nLength) && (insfile[iRaw]))
|
311
|
+
{
|
312
|
+
UINT flags = (psfh.version == 1) ? RS_PCM8S : RS_PCM8U;
|
313
|
+
if (insflags[iRaw-1] & 4) flags += 5;
|
314
|
+
if (insflags[iRaw-1] & 2) flags |= RSF_STEREO;
|
315
|
+
if (inspack[iRaw-1] == 4) flags = RS_ADPCM4;
|
316
|
+
dwMemPos = insfile[iRaw];
|
317
|
+
if (dwMemPos < dwMemLength)
|
318
|
+
dwMemPos += CSoundFile_ReadSample(_this, &_this->Ins[iRaw], flags, (LPSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
|
319
|
+
}
|
320
|
+
_this->m_nMinPeriod = 64;
|
321
|
+
_this->m_nMaxPeriod = 32767;
|
322
|
+
if (psfh.flags & 0x10) _this->m_dwSongFlags |= SONG_AMIGALIMITS;
|
323
|
+
return TRUE;
|
324
|
+
}
|
325
|
+
|
@@ -0,0 +1,180 @@
|
|
1
|
+
/*
|
2
|
+
* This source code is public domain.
|
3
|
+
*
|
4
|
+
* Authors: Olivier Lapicque <olivierl@jps.net>
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include "libmodplug.h"
|
8
|
+
|
9
|
+
#pragma pack(1)
|
10
|
+
|
11
|
+
typedef struct tagSTMNOTE
|
12
|
+
{
|
13
|
+
BYTE note;
|
14
|
+
BYTE insvol;
|
15
|
+
BYTE volcmd;
|
16
|
+
BYTE cmdinf;
|
17
|
+
} STMNOTE;
|
18
|
+
|
19
|
+
|
20
|
+
// Raw STM sampleinfo struct:
|
21
|
+
typedef struct tagSTMSAMPLE
|
22
|
+
{
|
23
|
+
CHAR filename[14]; // Can't have long comments - just filename comments :)
|
24
|
+
WORD reserved; // ISA in memory when in ST 2
|
25
|
+
WORD length; // Sample length
|
26
|
+
WORD loopbeg; // Loop start point
|
27
|
+
WORD loopend; // Loop end point
|
28
|
+
BYTE volume; // Volume
|
29
|
+
BYTE reserved2; // More reserved crap
|
30
|
+
WORD c2spd; // Good old c2spd
|
31
|
+
BYTE reserved3[6]; // Yet more of PSi's reserved crap
|
32
|
+
} STMSAMPLE;
|
33
|
+
|
34
|
+
|
35
|
+
// Raw STM header struct:
|
36
|
+
typedef struct tagSTMHEADER
|
37
|
+
{
|
38
|
+
char songname[20]; // changed from CHAR
|
39
|
+
char trackername[8]; // !SCREAM! for ST 2.xx // changed from CHAR
|
40
|
+
CHAR unused; // 0x1A
|
41
|
+
CHAR filetype; // 1=song, 2=module (only 2 is supported, of course) :)
|
42
|
+
CHAR ver_major; // Like 2
|
43
|
+
CHAR ver_minor; // "ditto"
|
44
|
+
BYTE inittempo; // initspeed= stm inittempo>>4
|
45
|
+
BYTE numpat; // number of patterns
|
46
|
+
BYTE globalvol; // <- WoW! a RiGHT TRiANGLE =8*)
|
47
|
+
BYTE reserved[13]; // More of PSi's internal crap
|
48
|
+
STMSAMPLE sample[31]; // STM sample data
|
49
|
+
BYTE patorder[128]; // Docs say 64 - actually 128
|
50
|
+
} STMHEADER;
|
51
|
+
|
52
|
+
#pragma pack()
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
BOOL CSoundFile_ReadSTM(CSoundFile *_this, const BYTE *lpStream, DWORD dwMemLength)
|
57
|
+
//---------------------------------------------------------------
|
58
|
+
{
|
59
|
+
const STMHEADER *phdr = (STMHEADER *)lpStream;
|
60
|
+
DWORD dwMemPos = 0;
|
61
|
+
|
62
|
+
if ((!lpStream) || (dwMemLength < sizeof(STMHEADER))) return FALSE;
|
63
|
+
if ((phdr->filetype != 2) || (phdr->unused != 0x1A)
|
64
|
+
|| ((SDL_strncasecmp(phdr->trackername, "!SCREAM!", 8))
|
65
|
+
&& (SDL_strncasecmp(phdr->trackername, "BMOD2STM", 8)))) return FALSE;
|
66
|
+
// Read STM header
|
67
|
+
_this->m_nType = MOD_TYPE_STM;
|
68
|
+
_this->m_nSamples = 31;
|
69
|
+
_this->m_nChannels = 4;
|
70
|
+
_this->m_nInstruments = 0;
|
71
|
+
_this->m_nMinPeriod = 64;
|
72
|
+
_this->m_nMaxPeriod = 0x7FFF;
|
73
|
+
_this->m_nDefaultSpeed = phdr->inittempo >> 4;
|
74
|
+
if (_this->m_nDefaultSpeed < 1) _this->m_nDefaultSpeed = 1;
|
75
|
+
_this->m_nDefaultTempo = 125;
|
76
|
+
_this->m_nDefaultGlobalVolume = phdr->globalvol << 2;
|
77
|
+
if (_this->m_nDefaultGlobalVolume > 256) _this->m_nDefaultGlobalVolume = 256;
|
78
|
+
SDL_memcpy(_this->Order, phdr->patorder, 128);
|
79
|
+
// Setting up channels
|
80
|
+
for (UINT nSet=0; nSet<4; nSet++)
|
81
|
+
{
|
82
|
+
_this->ChnSettings[nSet].dwFlags = 0;
|
83
|
+
_this->ChnSettings[nSet].nVolume = 64;
|
84
|
+
_this->ChnSettings[nSet].nPan = (nSet & 1) ? 0x40 : 0xC0;
|
85
|
+
}
|
86
|
+
// Reading samples
|
87
|
+
for (UINT nIns=0; nIns<31; nIns++)
|
88
|
+
{
|
89
|
+
MODINSTRUMENT *pIns = &_this->Ins[nIns+1];
|
90
|
+
const STMSAMPLE *pStm = &phdr->sample[nIns]; // STM sample data
|
91
|
+
pIns->nC4Speed = bswapLE16(pStm->c2spd);
|
92
|
+
pIns->nGlobalVol = 64;
|
93
|
+
pIns->nVolume = pStm->volume << 2;
|
94
|
+
if (pIns->nVolume > 256) pIns->nVolume = 256;
|
95
|
+
pIns->nLength = bswapLE16(pStm->length);
|
96
|
+
if ((pIns->nLength < 4) || (!pIns->nVolume)) pIns->nLength = 0;
|
97
|
+
pIns->nLoopStart = bswapLE16(pStm->loopbeg);
|
98
|
+
pIns->nLoopEnd = bswapLE16(pStm->loopend);
|
99
|
+
if ((pIns->nLoopEnd > pIns->nLoopStart) && (pIns->nLoopEnd != 0xFFFF)) pIns->uFlags |= CHN_LOOP;
|
100
|
+
}
|
101
|
+
dwMemPos = sizeof(STMHEADER);
|
102
|
+
for (UINT nOrd=0; nOrd<MAX_ORDERS; nOrd++) if (_this->Order[nOrd] >= 99) _this->Order[nOrd] = 0xFF;
|
103
|
+
UINT nPatterns = phdr->numpat;
|
104
|
+
for (UINT nPat=0; nPat<nPatterns; nPat++)
|
105
|
+
{
|
106
|
+
if (dwMemPos + 64*4*4 > dwMemLength) return TRUE;
|
107
|
+
_this->PatternSize[nPat] = 64;
|
108
|
+
if ((_this->Patterns[nPat] = CSoundFile_AllocatePattern(64, _this->m_nChannels)) == NULL) return TRUE;
|
109
|
+
MODCOMMAND *m = _this->Patterns[nPat];
|
110
|
+
const STMNOTE *p = (const STMNOTE *)(lpStream + dwMemPos);
|
111
|
+
for (UINT n=0; n<64*4; n++, p++, m++)
|
112
|
+
{
|
113
|
+
UINT note,ins,vol,cmd;
|
114
|
+
// extract the various information from the 4 bytes that
|
115
|
+
// make up a single note
|
116
|
+
note = p->note;
|
117
|
+
ins = p->insvol >> 3;
|
118
|
+
vol = (p->insvol & 0x07) + (p->volcmd >> 1);
|
119
|
+
cmd = p->volcmd & 0x0F;
|
120
|
+
if ((ins) && (ins < 32)) m->instr = ins;
|
121
|
+
// special values of [SBYTE0] are handled here ->
|
122
|
+
// we have no idea if these strange values will ever be encountered
|
123
|
+
// but it appears as though stms sound correct.
|
124
|
+
if ((note == 0xFE) || (note == 0xFC)) m->note = 0xFE; else
|
125
|
+
// if note < 251, then all three bytes are stored in the file
|
126
|
+
if (note < 0xFC) m->note = (note >> 4)*12 + (note&0xf) + 37;
|
127
|
+
if (vol <= 64) { m->volcmd = VOLCMD_VOLUME; m->vol = vol; }
|
128
|
+
m->param = p->cmdinf;
|
129
|
+
switch(cmd)
|
130
|
+
{
|
131
|
+
// Axx set speed to xx
|
132
|
+
case 1: m->command = CMD_SPEED; m->param >>= 4; break;
|
133
|
+
// Bxx position jump
|
134
|
+
case 2: m->command = CMD_POSITIONJUMP; break;
|
135
|
+
// Cxx patternbreak to row xx
|
136
|
+
case 3: m->command = CMD_PATTERNBREAK; m->param = (m->param & 0xF0) * 10 + (m->param & 0x0F); break;
|
137
|
+
// Dxy volumeslide
|
138
|
+
case 4: m->command = CMD_VOLUMESLIDE; break;
|
139
|
+
// Exy toneslide down
|
140
|
+
case 5: m->command = CMD_PORTAMENTODOWN; break;
|
141
|
+
// Fxy toneslide up
|
142
|
+
case 6: m->command = CMD_PORTAMENTOUP; break;
|
143
|
+
// Gxx Tone portamento,speed xx
|
144
|
+
case 7: m->command = CMD_TONEPORTAMENTO; break;
|
145
|
+
// Hxy vibrato
|
146
|
+
case 8: m->command = CMD_VIBRATO; break;
|
147
|
+
// Ixy tremor, ontime x, offtime y
|
148
|
+
case 9: m->command = CMD_TREMOR; break;
|
149
|
+
// Jxy arpeggio
|
150
|
+
case 10: m->command = CMD_ARPEGGIO; break;
|
151
|
+
// Kxy Dual command H00 & Dxy
|
152
|
+
case 11: m->command = CMD_VIBRATOVOL; break;
|
153
|
+
// Lxy Dual command G00 & Dxy
|
154
|
+
case 12: m->command = CMD_TONEPORTAVOL; break;
|
155
|
+
// Xxx amiga command 8xx
|
156
|
+
case 0x18: m->command = CMD_PANNING8; break;
|
157
|
+
default:
|
158
|
+
m->command = m->param = 0;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
dwMemPos += 64*4*4;
|
162
|
+
}
|
163
|
+
// Reading Samples
|
164
|
+
for (UINT nSmp=1; nSmp<=31; nSmp++)
|
165
|
+
{
|
166
|
+
MODINSTRUMENT *pIns = &_this->Ins[nSmp];
|
167
|
+
dwMemPos = (dwMemPos + 15) & (~15);
|
168
|
+
if (pIns->nLength)
|
169
|
+
{
|
170
|
+
UINT nPos = ((UINT)phdr->sample[nSmp-1].reserved) << 4;
|
171
|
+
if ((nPos >= sizeof(STMHEADER)) && (nPos+pIns->nLength <= dwMemLength)) dwMemPos = nPos;
|
172
|
+
if (dwMemPos < dwMemLength)
|
173
|
+
{
|
174
|
+
dwMemPos += CSoundFile_ReadSample(_this, pIns, RS_PCM8S, (LPSTR)(lpStream+dwMemPos),dwMemLength-dwMemPos);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
return TRUE;
|
179
|
+
}
|
180
|
+
|