Add Windows native implementaton of MAKO

The MIDI synthesizer bundled with SDL_Mixer doesn't sound as good as
Windows' built-in software synthesizer.

This adds Windows native implementation of MAKO as win/mako.cpp. It
plays MIDI by writing out SMF to a temporary file and play it with MCI.
CD emulation (--playlist) is also implemented using MCI.
The PCM implementation is copyed from TOTO's original Win32 impl.

This removes SDL_mixer dependency in Windows.

Fixes #1.
This commit is contained in:
kichikuou
2020-05-16 17:36:23 +09:00
parent b475c465fd
commit 9f5f4e6843
5 changed files with 349 additions and 23 deletions
+9 -3
View File
@@ -16,12 +16,18 @@
#define MIX_INIT_MID MIX_INIT_FLUIDSYNTH
#endif
namespace {
std::vector<uint8> smf;
Mix_Music *mix_music;
Mix_Chunk *mix_chunk;
} // namespace
MAKO::MAKO(NACT* parent, const char* playlist) :
current_music(0),
next_loop(0),
nact(parent),
mix_music(NULL),
mix_chunk(NULL)
nact(parent)
{
int mix_init_flags = MIX_INIT_MID;
+4 -7
View File
@@ -14,10 +14,6 @@
#include "../common.h"
#include "nact.h"
#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
#include <SDL_mixer.h>
#endif
class MAKO
{
public:
@@ -33,6 +29,10 @@ public:
void stop_pcm();
bool check_pcm();
#ifdef _WIN32
void on_mci_notify(SDL_SysWMmsg* msg);
#endif
// AMUS.DAT, AMSE.DAT
char amus[16];
char amse[16];
@@ -48,9 +48,6 @@ private:
bool load_playlist(const char* path);
std::vector<const char*> playlist;
std::vector<uint8> smf;
Mix_Music *mix_music;
Mix_Chunk *mix_chunk;
#endif
};
+16 -3
View File
@@ -4,13 +4,19 @@
[ NACT - input ]
*/
#ifdef _WIN32
#include <windows.h>
#undef ERROR
#endif
#include <SDL_syswm.h>
#include "nact.h"
#include "ags.h"
#include "mako.h"
#include "texthook.h"
static int mousex, mousey, fingers;
static bool pump_events(AGS* ags)
static bool pump_events(AGS* ags, MAKO* mako)
{
SDL_Event e;
while (SDL_PollEvent(&e)) {
@@ -34,6 +40,13 @@ static bool pump_events(AGS* ags)
case SDL_APP_DIDENTERFOREGROUND:
ags->flush_screen(false);
break;
#ifdef _WIN32
case SDL_SYSWMEVENT:
if (e.syswm.msg->msg.win.msg == MM_MCINOTIFY)
mako->on_mci_notify(e.syswm.msg);
break;
#endif
}
}
return false;
@@ -45,7 +58,7 @@ uint8 NACT::get_key()
texthook_keywait();
if (pump_events(ags))
if (pump_events(ags, mako))
terminate = true;
// キーボード&マウス
@@ -90,7 +103,7 @@ uint8 NACT::get_key()
void NACT::get_cursor(int* x, int* y)
{
if (pump_events(ags))
if (pump_events(ags, mako))
terminate = true;
*x = mousex;
*y = mousey;