Implement some mus_wav_* functions

This commit is contained in:
kichikuou
2019-01-27 19:14:45 +09:00
parent 8c2d51d510
commit aeba63e0cd
6 changed files with 41 additions and 14 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ LFLAGS += -s EXTRA_EXPORTED_RUNTIME_METHODS="['getValue','getMemory','addRunDepe
JSLIB := --js-library emscripten/library.js
SYNCLIST := -s EMTERPRETIFY_SYNCLIST="['_muspcm_load_no','_muspcm_load_mixlr','_wait_vsync','_load_mincho_font']"
SYNCLIST := -s EMTERPRETIFY_SYNCLIST="['_muspcm_load_no','_muspcm_load_mixlr','_muspcm_waitend','_wait_vsync','_load_mincho_font']"
WASMFLAGS := -s WASM=1 -s "BINARYEN_TRAP_MODE='allow'"
ASMJSFLAGS := -s WASM=0
+6
View File
@@ -27,6 +27,9 @@ mergeInto(LibraryManager.library, {
muspcm_load_mixlr: function(slot, noL, noR) { // emterpreter sync
return xsystem35.audio.pcm_load_mixlr(slot, noL, noR);
},
muspcm_unload: function(slot) {
return xsystem35.audio.pcm_unload(slot);
},
muspcm_start: function(slot, loop) {
return xsystem35.audio.pcm_start(slot, loop);
},
@@ -56,5 +59,8 @@ mergeInto(LibraryManager.library, {
},
muspcm_isplaying: function(slot) {
return xsystem35.audio.pcm_isplaying(slot);
},
muspcm_waitend: function(slot) { // emterpreter sync
return xsystem35.audio.pcm_waitend(slot);
}
});
+1 -1
View File
@@ -1 +1 @@
-s EMTERPRETIFY_WHITELIST='["_ags_eCopyArea", "_ags_fadeIn", "_ags_fadeOut", "_ags_fader", "_ags_whiteIn", "_ags_whiteOut", "_checkMessage", "_check_command", "_commandCD", "_commandCE", "_commandH", "_commandHH", "_commandIK", "_commandMP", "_commandPF", "_commandPW", "_commandSM", "_commandSP", "_commandSQ", "_commandVA", "_commandY", "_commandZT20", "_commandZT21", "_commandZZ13", "_commands2F1E", "_commands2F21", "_commands2F7C", "_commands2F7D", "_commands2F7E", "_commands2F7F", "_eCopyArea1", "_eCopyArea11", "_eCopyArea12", "_eCopyArea13", "_eCopyArea14", "_eCopyArea15", "_eCopyArea16", "_eCopyArea17", "_eCopyArea18", "_eCopyArea19", "_eCopyArea2", "_eCopyArea20", "_eCopyArea21", "_eCopyArea22", "_eCopyArea23", "_eCopyArea24", "_eCopyArea25", "_eCopyArea26", "_eCopyArea3", "_eCopyArea33", "_eCopyArea34", "_eCopyArea39", "_eCopyArea4", "_eCopyArea40", "_eCopyArea48", "_eCopyArea49", "_eCopyArea5", "_eCopyArea5sp", "_eCopyArea6", "_eCopyArea7", "_eCopyArea8", "_eCopyArea9", "_main", "_msg_putMessage", "_mus_pcm_load", "_mus_pcm_mix", "_mus_pcm_start", "_nact_main", "_sdl_keywait", "_sdl_sleep", "_sdl_wait_vsync", "_sel_select", "_sys_addMsg", "_sys_hit_any_key", "_sys_key_releasewait"]'
-s EMTERPRETIFY_WHITELIST='["_ags_eCopyArea", "_ags_fadeIn", "_ags_fadeOut", "_ags_fader", "_ags_whiteIn", "_ags_whiteOut", "_checkMessage", "_check_command", "_commandCD", "_commandCE", "_commandH", "_commandHH", "_commandIK", "_commandMP", "_commandPF", "_commandPW", "_commandSM", "_commandSP", "_commandSQ", "_commandVA", "_commandY", "_commandZT20", "_commandZT21", "_commandZZ13", "_commands2F0A", "_commands2F1E", "_commands2F21", "_commands2F2F", "_commands2F7C", "_commands2F7D", "_commands2F7E", "_commands2F7F", "_eCopyArea1", "_eCopyArea11", "_eCopyArea12", "_eCopyArea13", "_eCopyArea14", "_eCopyArea15", "_eCopyArea16", "_eCopyArea17", "_eCopyArea18", "_eCopyArea19", "_eCopyArea2", "_eCopyArea20", "_eCopyArea21", "_eCopyArea22", "_eCopyArea23", "_eCopyArea24", "_eCopyArea25", "_eCopyArea26", "_eCopyArea3", "_eCopyArea33", "_eCopyArea34", "_eCopyArea39", "_eCopyArea4", "_eCopyArea40", "_eCopyArea48", "_eCopyArea49", "_eCopyArea5", "_eCopyArea5sp", "_eCopyArea6", "_eCopyArea7", "_eCopyArea8", "_eCopyArea9", "_main", "_msg_putMessage", "_mus_pcm_load", "_mus_pcm_mix", "_mus_pcm_start", "_mus_wav_load", "_mus_wav_waitend", "_nact_main", "_sdl_keywait", "_sdl_sleep", "_sdl_wait_vsync", "_sel_select", "_sys_addMsg", "_sys_hit_any_key", "_sys_key_releasewait"]'
+22 -12
View File
@@ -267,7 +267,7 @@ boolean mus_pcm_get_state() {
* 1: する
*/
int mus_mixer_fadeout_start(int device, int time, int volume, int stop) {
printf("%s not implemented\n", __func__);
printf("%s(%d, %d, %d, %d) not implemented\n", __func__, device, time, volume, stop);
return NG;
}
@@ -279,7 +279,7 @@ int mus_mixer_fadeout_start(int device, int time, int volume, int stop) {
* FALSE -> フェード中でない
*/
boolean mus_mixer_fadeout_get_state(int device) {
printf("%s not implemented\n", __func__);
printf("%s(%d) not implemented\n", __func__, device);
return FALSE;
}
@@ -309,8 +309,10 @@ int mus_mixer_get_level(int device) {
* num: ファイル番号 (1-65535)
*/
int mus_wav_load(int ch, int num) {
printf("%s not implemented\n", __func__);
return NG;
if (!prv.pcm_valid) return NG;
if (ch < 0 || ch > 128) return NG;
return muspcm_load_no(ch + 1, num);
}
/*
@@ -318,8 +320,10 @@ int mus_wav_load(int ch, int num) {
* ch : channel
*/
int mus_wav_unload(int ch) {
printf("%s not implemented\n", __func__);
return NG;
if (!prv.pcm_valid) return NG;
if (ch < 0 || ch > 128) return NG;
return muspcm_unload(ch + 1);
}
/*
@@ -329,8 +333,10 @@ int mus_wav_unload(int ch) {
* loop: 繰り返し回数 (0の場合は無限, それ以外は1回のみ)
*/
int mus_wav_play(int ch, int loop) {
printf("%s not implemented\n", __func__);
return NG;
if (!prv.pcm_valid) return NG;
if (ch < 0 || ch > 128) return NG;
return muspcm_start(ch + 1, loop);
}
/*
@@ -338,8 +344,10 @@ int mus_wav_play(int ch, int loop) {
* ch: channel
*/
int mus_wav_stop(int ch) {
printf("%s not implemented\n", __func__);
return NG;
if (!prv.pcm_valid) return NG;
if (ch < 0 || ch > 128) return NG;
return muspcm_stop(ch + 1);
}
/*
@@ -393,8 +401,10 @@ boolean mus_wav_fadeout_get_state(int ch) {
* ch: channel (0-127)
*/
int mus_wav_waitend(int ch) {
printf("%s not implemented\n", __func__);
return NG;
if (!prv.pcm_valid) return NG;
if (ch < 0 || ch > 128) return NG;
return muspcm_waitend(ch + 1);
}
/*
+2
View File
@@ -28,6 +28,7 @@ extern int muspcm_init(void);
extern int muspcm_exit(void);
extern int muspcm_load_no(int slot, int no);
extern int muspcm_load_mixlr(int slot, int noL, int noR);
extern int muspcm_unload(int slot);
extern int muspcm_start(int slot, int loop);
extern int muspcm_stop(int slot);
extern int muspcm_fadeout(int slot, int msec);
@@ -37,5 +38,6 @@ extern int muspcm_getpos(int slot);
extern int muspcm_setvol(int dev, int slot, int lv);
extern int muspcm_getwavelen(int slot);
extern boolean muspcm_isplaying(int slot);
extern int muspcm_waitend(int slot);
#endif /* __MUSIC_PCM_H__ */
+9
View File
@@ -179,6 +179,10 @@ int muspcm_load_mixlr(int slot, int noL, int noR) {
return load_chunk(slot, chunk);
}
int muspcm_unload(int slot) {
return unload(slot);
}
static int load_chunk(int slot, Mix_Chunk *chunk) {
if (IS_LOADED(slot)) unload(slot);
@@ -321,6 +325,11 @@ boolean muspcm_isplaying(int slot) {
return obj->playing;
}
// 指定のチャンネルの再生が終了するまで待つ
int muspcm_waitend(int slot) {
printf("%s not implemented\n", __func__);
return NG;
}
static int load_wai() {
struct stat sbuf;