aboutsummaryrefslogtreecommitdiff
path: root/lib/nosefart/NoseFartDLL.cpp
blob: 6a2edfb2950033b38a345915bedb913d05c73bc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 *      Copyright (C) 2008-2010 Team XBMC
 *      http://www.xbmc.org
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with XBMC; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#if defined(__linux__) || defined(__FreeBSD__)
#define __declspec(x) 
#endif
extern "C" 
{

#include "src/types.h"
#include "src/log.h"
#include "src/version.h"
#include "src/machine/nsf.h"

  __declspec(dllexport) void* DLL_LoadNSF(const char* szFileName)
  {
    nsf_init();
    log_init();
    nsf_t* result = nsf_load(const_cast<char*>(szFileName),NULL,0);
    return result;
  }

  void __declspec(dllexport) DLL_FreeNSF(void* nsf)
  {
    nsf_t* pNsf = (nsf_t*)nsf;
    nsf_free(&pNsf);
  }

  __declspec(dllexport) char* DLL_GetTitle(void* nsf)
  {
    return (char*)((nsf_t*)nsf)->song_name;
  }
  
  __declspec(dllexport) char* DLL_GetArtist(void* nsf)
  {
    return (char*)((nsf_t*)nsf)->artist_name;
  }
  
  int __declspec(dllexport) DLL_StartPlayback(void* nsf, int track)
  {
    nsf_playtrack((nsf_t*)nsf,track,48000,16,false);
    for (int i = 0; i < 6; i++)
      nsf_setchan((nsf_t*)nsf,i,true);
    return 1;
  }

  long __declspec(dllexport) DLL_FillBuffer(void* nsf, char* buffer, int size)
  {
    nsf_t* pNsf = (nsf_t*)nsf;
    nsf_frame(pNsf);
    pNsf->process(buffer,size);
    return size*2;
  }

  void __declspec(dllexport) DLL_FrameAdvance(void* nsf)
  {
    nsf_frame((nsf_t*)nsf);
  }

  int __declspec(dllexport) DLL_GetPlaybackRate(void* nsf)
  {
    return ((nsf_t*)nsf)->playback_rate;
  }

  int __declspec(dllexport) DLL_GetNumberOfSongs(void* nsf)
  {
    return (int)((nsf_t*)nsf)->num_songs;
  }
}