diff options
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/amd64/Makefile | 1 | ||||
| -rw-r--r-- | win32/fmplayer.mak | 4 | ||||
| -rw-r--r-- | win32/main.c | 25 | ||||
| -rw-r--r-- | win32/wavewrite.c | 6 | ||||
| -rw-r--r-- | win32/x86/Makefile | 1 | 
5 files changed, 31 insertions, 6 deletions
| diff --git a/win32/amd64/Makefile b/win32/amd64/Makefile index 22ef073..97e46dc 100644 --- a/win32/amd64/Makefile +++ b/win32/amd64/Makefile @@ -4,6 +4,7 @@ vpath %.c ../../libopna  vpath %.c ../../fmdsp  vpath %.c ../../tonedata  vpath %.c ../../common +vpath %.c ../../fft  vpath %.rc ..  include ../fmplayer.mak diff --git a/win32/fmplayer.mak b/win32/fmplayer.mak index 9a514b2..d62861c 100644 --- a/win32/fmplayer.mak +++ b/win32/fmplayer.mak @@ -21,11 +21,13 @@ LIBOPNA_OBJS=opna \  FMDSP_OBJS=fmdsp \             fmdsp-vramlookup-c \             font_rom \ -           font_fmdsp_small +           font_fmdsp_small \ +           fmdsp_platform_win  TONEDATA_OBJS=tonedata  SSEOBJBASE=opnassg-sinc-sse2 \             fmdsp-vramlookup-ssse3  OBJBASE=main \ +        fft \          toneview \          oscilloview \          wavesave \ diff --git a/win32/main.c b/win32/main.c index 66a1bf0..c1df7a7 100644 --- a/win32/main.c +++ b/win32/main.c @@ -22,6 +22,7 @@  #include "about.h"  #include "common/fmplayer_common.h"  #include "wavesave.h" +#include "fft/fft.h"  enum {    ID_OPENFILE = 0x10, @@ -74,7 +75,12 @@ static struct {    HBITMAP bitmap_vram;    uint8_t *vram32;    bool drum_loaded; -} g; +  atomic_flag at_fftdata_flag; +  struct fmplayer_fft_data at_fftdata; +  struct fmplayer_fft_input_data fftdata; +} g = { +  .at_fftdata_flag = ATOMIC_FLAG_INIT, +};  HWND g_currentdlg; @@ -92,6 +98,11 @@ static void sound_cb(void *p, int16_t *buf, unsigned frames) {      memcpy(oscilloview_g.oscillodata, g.oscillodata_audiothread, sizeof(oscilloview_g.oscillodata));      atomic_flag_clear_explicit(&oscilloview_g.flag, memory_order_release);    } +  if (!atomic_flag_test_and_set_explicit( +    &g.at_fftdata_flag, memory_order_acquire)) { +    fft_write(&g.at_fftdata, buf, frames); +    atomic_flag_clear_explicit(&g.at_fftdata_flag, memory_order_release); +  }  }  static bool loadfontrom(void) { @@ -170,6 +181,7 @@ static void openfile(HWND hwnd, const wchar_t *path) {    if (!g.sound) goto err;    g.sound->pause(g.sound, 0);    g.paused = false; +  g.work.paused = false;    wchar_t *pathcpy = HeapAlloc(g.heap, 0, (lstrlen(path)+1)*sizeof(wchar_t));    if (pathcpy) {      lstrcpy(pathcpy, path); @@ -333,6 +345,7 @@ static bool proc_key(UINT vk, bool down, int repeat) {          case VK_F7:            if (g.sound) {              g.paused = !g.paused; +            g.work.paused = g.paused;              g.sound->pause(g.sound, g.paused);            }            return true; @@ -549,6 +562,7 @@ static void on_command(HWND hwnd, int id, HWND hwnd_c, UINT code) {    case ID_PAUSE:      if (g.sound) {        g.paused = !g.paused; +      g.work.paused = g.paused;        g.sound->pause(g.sound, g.paused);      }      break; @@ -611,7 +625,12 @@ static void on_destroy(HWND hwnd) {  }  static void on_paint(HWND hwnd) { -  fmdsp_update(&g.fmdsp, &g.work, &g.opna, g.vram); +  if (!atomic_flag_test_and_set_explicit( +    &g.at_fftdata_flag, memory_order_acquire)) { +    memcpy(&g.fftdata.fdata, &g.at_fftdata, sizeof(g.fftdata)); +    atomic_flag_clear_explicit(&g.at_fftdata_flag, memory_order_release); +  } +  fmdsp_update(&g.fmdsp, &g.work, &g.opna, g.vram, &g.fftdata);    fmdsp_vrampalette(&g.fmdsp, g.vram, g.vram32, PC98_W*4);    PAINTSTRUCT ps;    HDC dc = BeginPaint(hwnd, &ps); @@ -738,6 +757,8 @@ int CALLBACK wWinMain(HINSTANCE hinst, HINSTANCE hpinst,    if (__builtin_cpu_supports("sse2")) opna_ssg_sinc_calc_func = opna_ssg_sinc_calc_sse2;    if (__builtin_cpu_supports("ssse3")) fmdsp_vramlookup_func = fmdsp_vramlookup_ssse3; +  fft_init_table(); +    const wchar_t *argfile = 0;    {      wchar_t *cmdline = GetCommandLine(); diff --git a/win32/wavewrite.c b/win32/wavewrite.c index 7c2d6da..37f6145 100644 --- a/win32/wavewrite.c +++ b/win32/wavewrite.c @@ -3,6 +3,7 @@  #define WIN32_LEAN_AND_MEAN  #include <windows.h>  #include <stdlib.h> +#include <stdio.h>  struct wavefile {    HANDLE file; @@ -67,17 +68,16 @@ size_t wavewrite_write(struct wavefile *wavefile, const int16_t *buf, size_t fra  }  void wavewrite_close(struct wavefile *wavefile) { -  LONG fp;    uint32_t size;    DWORD written; -  if ((SetFilePointer(wavefile->file, 40, &fp, FILE_BEGIN) == INVALID_SET_FILE_POINTER) || (fp != 40)) { +  if (SetFilePointer(wavefile->file, 40, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {      goto cleanup;    }    size = wavefile->written_frames * 4;    if (!WriteFile(wavefile->file, &size, sizeof(size), &written, 0) || (written != sizeof(size))) {      goto cleanup;    } -  if ((SetFilePointer(wavefile->file, 4, &fp, FILE_BEGIN) == INVALID_SET_FILE_POINTER) || (fp != 4)) { +  if (SetFilePointer(wavefile->file, 4, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {      goto cleanup;    }    size += 4 + 8 + 16 + 8; diff --git a/win32/x86/Makefile b/win32/x86/Makefile index 6146d28..ea2e16e 100644 --- a/win32/x86/Makefile +++ b/win32/x86/Makefile @@ -4,6 +4,7 @@ vpath %.c ../../libopna  vpath %.c ../../fmdsp  vpath %.c ../../tonedata  vpath %.c ../../common +vpath %.c ../../fft  vpath %.rc ..  include ../fmplayer.mak | 
