From 3fd5d1e8fb0e6cb26038b3daeebee64a0dc04dfe Mon Sep 17 00:00:00 2001 From: kichikuou Date: Mon, 19 Sep 2016 14:12:09 +0900 Subject: [PATCH] CDDA support for emscripten --- Makefile.common | 3 ++- src/emscripten/mako.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/sys/mako.h | 9 ++++----- 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/emscripten/mako.cpp diff --git a/Makefile.common b/Makefile.common index e386d5d..b7f9548 100644 --- a/Makefile.common +++ b/Makefile.common @@ -31,4 +31,5 @@ LINUXOBJS := \ src/linux/mako_linux.o EMOBJS := \ - src/linux/nact_linux.o + src/linux/nact_linux.o \ + src/emscripten/mako.o diff --git a/src/emscripten/mako.cpp b/src/emscripten/mako.cpp new file mode 100644 index 0000000..57773d2 --- /dev/null +++ b/src/emscripten/mako.cpp @@ -0,0 +1,36 @@ +/* + ALICE SOFT SYSTEM 3 for Emscripten + [ MAKO ] +*/ + +#include +#include "mako.h" + +MAKO::MAKO(NACT* parent) + : current_music(0) + , next_loop(0) +{ + for (int i = 1; i <= 99; i++) + cd_track[i] = i; +} + +void MAKO::play_music(int page) +{ + if (current_music == page) + return; + + current_music = page; + int loop_count = next_loop; + next_loop = 0; + + EM_ASM_ARGS({ xsystem35.cdPlayer.play($0, $1); }, + cd_track[page] + 1, loop_count); +} + +void MAKO::stop_music() +{ + if (current_music) + EM_ASM( xsystem35.cdPlayer.stop(); ); + + current_music = 0; +} diff --git a/src/sys/mako.h b/src/sys/mako.h index 54df605..2fe9606 100644 --- a/src/sys/mako.h +++ b/src/sys/mako.h @@ -132,11 +132,11 @@ public: class MAKO { public: - MAKO(NACT* parent) {} + MAKO(NACT* parent); - void play_music(int page) { playing = true; } - void stop_music() { playing = false; } - bool check_music() { return playing; } + void play_music(int page); + void stop_music(); + bool check_music() { return current_music != 0; } void get_mark(int* mark, int* loop) {} void notify_mci(int status) {} @@ -157,7 +157,6 @@ public: _TCHAR amus[16]; _TCHAR amse[16]; - bool playing; int current_music; int next_loop; // Y19 int cd_track[100]; // Z