mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-13 01:28:14 +03:00
Implement S3xMusic HLL
Used in Ore no Shita de Agake. Since the musbgm_* interface does not allow multiple channels, this implementation uses musbgm_* for channel 0 and muspcm_* for channel 1.
This commit is contained in:
@@ -44,9 +44,9 @@ int musbgm_reset(void) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
EM_JS(int, musbgm_play, (int no, int time, int vol), {
|
||||
EM_JS(int, musbgm_play, (int no, int time, int vol, int loop_count), {
|
||||
xsystem35.cdPlayer.fade(time * 10, vol / 100);
|
||||
xsystem35.cdPlayer.play(no, 1);
|
||||
xsystem35.cdPlayer.play(no, loop_count == 0);
|
||||
return xsystem35.Status.OK;
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
int musbgm_init(DRIFILETYPE type, int base_no);
|
||||
int musbgm_exit(void);
|
||||
int musbgm_reset(void);
|
||||
int musbgm_play(int no, int time, int vol);
|
||||
int musbgm_play(int no, int time, int vol, int loop_count);
|
||||
int musbgm_stop(int no, int time);
|
||||
int musbgm_fade(int no, int time, int vol);
|
||||
int musbgm_getpos(int no);
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ int musbgm_reset(void) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int musbgm_play(int no, int time, int vol) {
|
||||
int musbgm_play(int no, int time, int vol, int loop_count) {
|
||||
if (current_no)
|
||||
musbgm_stop(current_no, 0);
|
||||
|
||||
@@ -107,7 +107,7 @@ int musbgm_play(int no, int time, int vol) {
|
||||
// understands loop info in the WAVE's "smpl" chunk.
|
||||
|
||||
Mix_VolumeMusic(vol * MIX_MAX_VOLUME / 100);
|
||||
if (Mix_FadeInMusic(mix_music, -1, time * 10) != 0) {
|
||||
if (Mix_FadeInMusic(mix_music, loop_count == 0 ? -1 : loop_count, time * 10) != 0) {
|
||||
free_music();
|
||||
return NG;
|
||||
}
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ static int cdrom_bgm_reset(void) {
|
||||
}
|
||||
|
||||
static int cdrom_bgm_start(int trk, int loop) {
|
||||
if (musbgm_play(trk, 0, 100) != OK)
|
||||
if (musbgm_play(trk, 0, 100, loop) != OK)
|
||||
return NG;
|
||||
current_track = trk;
|
||||
return OK;
|
||||
|
||||
@@ -28,6 +28,7 @@ extern int muspcm_init(int audio_buffer_size);
|
||||
extern int muspcm_exit(void);
|
||||
extern int muspcm_reset(void);
|
||||
extern int muspcm_load_no(int slot, int no);
|
||||
extern int muspcm_load_bgm(int slot, int no);
|
||||
extern int muspcm_load_mixlr(int slot, int noL, int noR);
|
||||
extern int muspcm_load_data(int slot, uint8_t *buf, uint32_t len);
|
||||
extern int muspcm_unload(int slot);
|
||||
|
||||
@@ -40,6 +40,10 @@ EM_ASYNC_JS(int, muspcm_load_no, (int slot, int no), {
|
||||
return await xsystem35.audio.pcm_load(slot, no);
|
||||
});
|
||||
|
||||
EM_ASYNC_JS(int, muspcm_load_bgm, (int slot, int no), {
|
||||
return await xsystem35.audio.pcm_load_bgm(slot, no);
|
||||
});
|
||||
|
||||
EM_ASYNC_JS(int, muspcm_load_data, (int slot, uint8_t *buf, uint32_t len), {
|
||||
return await xsystem35.audio.pcm_load_data(slot, buf, len);
|
||||
});
|
||||
|
||||
+18
-5
@@ -62,8 +62,8 @@ static mmap_t *wai_map;
|
||||
* 指定の番号の .WAV|.OGG をロードする。
|
||||
* @param no: DRIファイル番号
|
||||
*/
|
||||
static Mix_Chunk *load_asset(int no) {
|
||||
dridata *dfile = ald_getdata(DRIFILE_WAVE, no -1);
|
||||
static Mix_Chunk *load_asset(DRIFILETYPE type, int no) {
|
||||
dridata *dfile = ald_getdata(type, no -1);
|
||||
if (dfile == NULL) {
|
||||
WARNING("DRIFILE_WAVE fail to open %d", no -1);
|
||||
return NULL;
|
||||
@@ -99,8 +99,8 @@ static int load_chunk(int slot, Mix_Chunk *chunk) {
|
||||
* @return : 合成後の Mix_Chunk
|
||||
*/
|
||||
static Mix_Chunk *pcm_mixlr(int noL, int noR) {
|
||||
Mix_Chunk *chunkL = load_asset(noL);
|
||||
Mix_Chunk *chunkR = load_asset(noR);
|
||||
Mix_Chunk *chunkL = load_asset(DRIFILE_WAVE, noL);
|
||||
Mix_Chunk *chunkR = load_asset(DRIFILE_WAVE, noR);
|
||||
if (chunkL == NULL || chunkR == NULL) {
|
||||
if (chunkL)
|
||||
Mix_FreeChunk(chunkL);
|
||||
@@ -163,7 +163,7 @@ int muspcm_load_no(int slot, int no) {
|
||||
if ((unsigned)slot >= PCM_SLOTS)
|
||||
return NG;
|
||||
|
||||
Mix_Chunk *chunk = load_asset(no);
|
||||
Mix_Chunk *chunk = load_asset(DRIFILE_WAVE, no);
|
||||
if (chunk == NULL) {
|
||||
return NG;
|
||||
}
|
||||
@@ -179,6 +179,19 @@ int muspcm_load_no(int slot, int no) {
|
||||
return load_chunk(slot, chunk);
|
||||
}
|
||||
|
||||
int muspcm_load_bgm(int slot, int no) {
|
||||
if ((unsigned)slot >= PCM_SLOTS)
|
||||
return NG;
|
||||
|
||||
Mix_Chunk *chunk = load_asset(DRIFILE_BGM, no);
|
||||
if (chunk == NULL) {
|
||||
return NG;
|
||||
}
|
||||
prv.vol_pcm_sub[slot] = 0;
|
||||
|
||||
return load_chunk(slot, chunk);
|
||||
}
|
||||
|
||||
int muspcm_load_mixlr(int slot, int noL, int noR) {
|
||||
if ((unsigned)slot >= PCM_SLOTS)
|
||||
return NG;
|
||||
|
||||
Reference in New Issue
Block a user