annotate src/xs_sidplayfp.cpp @ 853:1f97cd026465

Don't disable plain reSID backend for FP.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 Nov 2012 23:39:48 +0200
parents 4c4978e11ec0
children 011ba70e271e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
4 libSIDPlay2-FP support
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 (C) Copyright 1999-2012 Tecnic Software productions (TNSP)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License along
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 with this program; if not, write to the Free Software Foundation, Inc.,
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 #include "xmms-sid.h"
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
25 #ifdef HAVE_SIDPLAYFP
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
27 #include "xs_sidplayfp.h"
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
28 #include "xs_slsup.h"
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 #include "xs_config.h"
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
32 #ifdef HAVE_SIDPLAYFP_V1
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 # include <sidplayfp/SidTune.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 # include <sidplayfp/sidplayfp.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 # include <sidplayfp/event.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 # include <sidplayfp/SidConfig.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 # include <sidplayfp/SidTuneInfo.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #else
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 # include <sidplayfp/sidplay2.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 # include <sidplayfp/SidTuneMod.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 # include <sidplayfp/event.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 class XSSIDPlayFP {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 public:
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
47 #ifdef HAVE_SIDPLAYFP_V1
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 sidplayfp emu;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 SidConfig config;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 #else
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 sidplay2 emu;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 sid2_config_t config;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 #endif
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
54 SidTuneMod tune;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 XSSIDPlayFP(void);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 virtual ~XSSIDPlayFP(void);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 };
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
61 #ifdef HAVE_RESID_FP_BUILDER
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 # include <sidplayfp/builders/residfp.h>
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
63 #endif
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
64
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
65 #ifdef HAVE_RESID_FP_BUILDER
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 # include <sidplayfp/builders/resid.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 #ifdef HAVE_HARDSID_BUILDER
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 # include <sidplayfp/builders/hardsid.h>
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 XSSIDPlayFP::XSSIDPlayFP(void) : tune(0)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 XSSIDPlayFP::~XSSIDPlayFP(void)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 emu.load(NULL);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 /* We need to 'export' all this pseudo-C++ crap */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 extern "C" {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 /* Return song information
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 #define TFUNCTION xs_sidplayfp_getinfo
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 #define TFUNCTION2 xs_sidplayfp_updateinfo
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 #define TENGINE XSSIDPlayFP
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 #define TTUNEINFO SidTuneInfo
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 #define TTUNE SidTune
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
97 #ifdef HAVE_SIDPLAYFP_V1
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 #define sid2_mono SidConfig::MONO
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 #define sid2_stereo SidConfig::STEREO
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 #define SID2_MOS8580 SidConfig::MOS8580
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 #define SID2_MOS6581 SidConfig::MOS6581
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 #define SID2_CLOCK_PAL SidConfig::CLOCK_PAL
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 #define SID2_CLOCK_NTSC SidConfig::CLOCK_NTSC
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 #define SIDTUNE_CLOCK_UNKNOWN SidTuneInfo::CLOCK_UNKNOWN
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 #define SIDTUNE_CLOCK_PAL SidTuneInfo::CLOCK_PAL
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 #define SIDTUNE_CLOCK_NTSC SidTuneInfo::CLOCK_NTSC
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 #define SIDTUNE_CLOCK_ANY SidTuneInfo::CLOCK_ANY
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 #define SIDTUNE_SPEED_VBI SidTuneInfo::SPEED_VBI
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 #define SIDTUNE_SPEED_CIA_1A SidTuneInfo::SPEED_CIA_1A
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 #include "xs_sidplay.h"
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 /* Check if we can play the given file
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 gboolean xs_sidplayfp_probe(XSFile *f)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 gchar tmpBuf[5];
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 if (!f) return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4))
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 return TRUE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 else
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
133 /* Initialize SIDPlayFP
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 gboolean xs_sidplayfp_init(XSEngineState * state)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 XSSIDPlayFP *engine;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 assert(state);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
140 XSDEBUG("SIDPlayFP backend initializing.\n");
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
141
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 /* Allocate internal structures */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 engine = new XSSIDPlayFP();
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 state->internal = engine;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 if (!engine)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 /* Get current configuration */
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
149 XSDEBUG("SIDPlayFP emulation configuration\n");
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 engine->config = engine->emu.config();
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 /* Configure channels and stuff */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 engine->config.playback = (state->audioChannels == XS_CHN_MONO) ? sid2_mono : sid2_stereo;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 /* Audio parameters sanity checking and setup */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 state->audioBitsPerSample = XS_RES_16BIT;
851
4c4978e11ec0 Oops. Remember to set output audio format for FP backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 849
diff changeset
157 state->audioFormat = FMT_S16_NE;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 engine->config.samplingMethod = SID2_RESAMPLE_INTERPOLATE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 engine->config.frequency = state->audioFrequency;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
161 /* Clockspeed settings */
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
162 switch (xs_cfg.clockSpeed)
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
163 {
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
164 case XS_CLOCK_NTSC:
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
165 engine->config.clockDefault = SID2_CLOCK_NTSC;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
166 break;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
167
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
168 default:
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
169 case XS_CLOCK_PAL:
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
170 engine->config.clockDefault = SID2_CLOCK_PAL;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
171 xs_cfg.clockSpeed = XS_CLOCK_PAL;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
172 break;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
173 }
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
174
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
175
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
176 /* Configure rest of the emulation */
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
177 engine->config.sidDefault = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
178 engine->config.clockForced = xs_cfg.forceSpeed;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
179
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
180 #ifndef HAVE_SIDPLAYFP_V1
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
181 engine->config.sidSamples = TRUE;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
182 engine->config.sidModel = xs_cfg.forceModel ? engine->config.sidDefault : SID2_MODEL_CORRECT;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
183 engine->config.clockSpeed = xs_cfg.forceSpeed ? engine->config.clockDefault : SID2_CLOCK_CORRECT;
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
184 #endif
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
185
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 /* Initialize builder object */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 switch (xs_cfg.sid2Builder)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 #ifdef HAVE_RESID_BUILDER
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 case XS_BLD_RESID:
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder");
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
195 #ifdef HAVE_SIDPLAYFP_V1
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 if (rs && rs->getStatus())
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 #else
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
200 if (rs && *rs)
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 engine->config.sidEmulation = rs;
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
203 if (!(*rs)) return FALSE;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 rs->create((engine->emu.info()).maxsids);
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
205 if (!(*rs)) return FALSE;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 rs->bias(0.0f);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 }
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
208 #endif // HAVE_SIDPLAYFP_V1
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 break;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 #endif // HAVE_RESID_BUILDER
853
1f97cd026465 Don't disable plain reSID backend for FP.
Matti Hamalainen <ccr@tnsp.org>
parents: 851
diff changeset
212
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 #ifdef HAVE_RESID_FP_BUILDER
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 case XS_BLD_RESID_FP:
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 ReSIDfpBuilder *rs = new ReSIDfpBuilder("ReSID builder FP!");
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
218 if (rs && *rs)
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 engine->config.sidEmulation = rs;
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
221 if (!(*rs)) return FALSE;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 rs->create((engine->emu.info()).maxsids);
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
223 if (!(*rs)) return FALSE;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 rs->filter6581Curve(0.0);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 rs->filter8580Curve(0.0);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 break;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 #ifdef HAVE_HARDSID_BUILDER
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 case XS_BLD_HARDSID:
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder (FP)");
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 engine->config.sidEmulation = (sidbuilder *) hs;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 if (hs)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 hs->create((engine->emu.info()).maxsids);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 if (!*hs)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 xs_error("hardSID->create() failed.\n");
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 break;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 default:
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
251 xs_error("[SIDPlayFP] Invalid or unsupported builder selected.\n");
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
252 return FALSE;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 if (!engine->config.sidEmulation)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 {
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
257 xs_error("[SIDPlayFP] Could not initialize SIDBuilder object.\n");
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 // Setup filter
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 engine->config.sidEmulation->filter(xs_cfg.emulateFilters);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 if (!*(engine->config.sidEmulation))
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 xs_error("builder->filter(%d) failed.\n", xs_cfg.emulateFilters);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 XSDEBUG("%s\n", engine->config.sidEmulation->credits());
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 return TRUE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
276 /* Close SIDPlayFP engine
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 void xs_sidplayfp_close(XSEngineState * state)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
282 XSDEBUG("SIDPlayFP backend shutdown.\n");
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
283
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 xs_sidplayfp_delete(state);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 if (engine)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 delete engine;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 engine = NULL;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 state->internal = NULL;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 /* Initialize current song and sub-tune
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 gboolean xs_sidplayfp_initsong(XSEngineState * state)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 if (!engine)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 if (!engine->tune.selectSong(state->currSong))
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 {
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
307 xs_error("[SIDPlayFP] tune.selectSong() failed\n");
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 if (engine->emu.load(&(engine->tune)) < 0)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 {
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
313 xs_error("[SIDPlayFP] emu.load() failed\n");
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 if (engine->emu.config(engine->config) < 0)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 {
847
5b93bd8c7814 Cleanups, adjust backend configuration sequences, more error checking,
Matti Hamalainen <ccr@tnsp.org>
parents: 838
diff changeset
319 xs_error("[SIDPlayFP] Emulator engine configuration failed!\n");
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 return TRUE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 /* Emulate and render audio data to given buffer
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 guint xs_sidplayfp_fillbuffer(XSEngineState * state, gchar * audioBuffer, guint audioBufSize)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 if (!engine)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 return 0;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 #if 1
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 int nsamples = audioBufSize / sizeof(short);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 return engine->emu.play((short *) audioBuffer, nsamples) * sizeof(short);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 #else
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 int nsamples = audioBufSize / sizeof(short);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 fprintf(stderr, "%p, %d -> %d\n", audioBuffer, audioBufSize, nsamples);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 return 0;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 /* Load a given SID-tune file
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 gboolean xs_sidplayfp_load(XSEngineState * state, gchar * filename)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 if (!engine || !filename)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 engine->tune.load(filename);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 if (!engine->tune)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 xs_error("Could not load file '%s': %s\n",
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 filename, (engine->tune.getInfo()).statusString);
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 return FALSE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 }
849
2663b1ac9ce6 Improve debugging.
Matti Hamalainen <ccr@tnsp.org>
parents: 847
diff changeset
363
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 return TRUE;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 /* Delete INTERNAL information
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 void xs_sidplayfp_delete(XSEngineState * state)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 {
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
372 (void) state;
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
373 // XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
835
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 /* Hardware backend flushing
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 */
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 void xs_sidplayfp_flush(XSEngineState * state)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 #ifdef HAVE_HARDSID_BUILDER
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 if (xs_cfg.sid2Builder == XS_BLD_HARDSID)
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 {
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 ((HardSIDBuilder *) engine->config.sidEmulation)->flush();
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 #endif
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 }
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391
d508c7c4bc69 Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 } /* extern "C" */
838
ae1f6418d093 libSIDPlay2-FP backend interface is now in a separate module. Configuration
Matti Hamalainen <ccr@tnsp.org>
parents: 835
diff changeset
393 #endif /* HAVE_SIDPLAYFP */