annotate src/xs_sidplay1.cc @ 527:fe8b41abd923

Now everything necessary should be using the VFS functions.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Feb 2007 18:09:04 +0000
parents fa95d942f226
children d837d2f06456
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 libSIDPlay v1 support
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
324
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 270
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 270
diff changeset
7 (C) Copyright 1999-2005 Tecnic Software productions (TNSP)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
412
7f694e5a1493 Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 411
diff changeset
19 You should have received a copy of the GNU General Public License along
7f694e5a1493 Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 411
diff changeset
20 with this program; if not, write to the Free Software Foundation, Inc.,
7f694e5a1493 Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 411
diff changeset
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
23 #include "xmms-sid.h"
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
24
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 #ifdef HAVE_SIDPLAY1
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
460
9e683fb666ba Updates
Matti Hamalainen <ccr@tnsp.org>
parents: 445
diff changeset
27 #include <stdio.h>
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
28 #include "xs_sidplay1.h"
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
29 #include "xs_config.h"
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #include <sidplay/player.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <sidplay/myendian.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #include <sidplay/fformat.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
526
fa95d942f226 Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 467
diff changeset
36 /* Maximum audio frequency supported by libSIDPlay v1 */
fa95d942f226 Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 467
diff changeset
37 #define SIDPLAY1_MAX_FREQ (48000)
fa95d942f226 Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 467
diff changeset
38
fa95d942f226 Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 467
diff changeset
39
396
0a60ef2b5ab0 Cleanups
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
40 typedef struct {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
41 emuEngine *currEng;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
42 emuConfig currConfig;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
43 sidTune *currTune;
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
44 guint8 *buf;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
45 size_t bufSize;
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
46 } t_xs_sidplay1;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
47
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
48
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
49 /* We need to 'export' all this pseudo-C++ crap */
396
0a60ef2b5ab0 Cleanups
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
50 extern "C" {
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
51
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
52
467
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
53 /* Return song information
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
54 */
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
55 #define TFUNCTION xs_sidplay1_getinfo
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
56 #define TFUNCTION2 xs_sidplay1_updateinfo
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
57 #define TTUNEINFO sidTuneInfo
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
58 #define TTUNE sidTune
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
59 #define TENGINE t_xs_sidplay1
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
60 #include "xs_sidplay.h"
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
61
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
62
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
63 /* Check if we can play the given file
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
64 */
526
fa95d942f226 Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 467
diff changeset
65 gboolean xs_sidplay1_probe(t_xs_file *f)
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
66 {
467
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
67 gchar tmpBuf[4];
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
68
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
69 if (!f) return FALSE;
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
70
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
71 if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4)
411
a26263683929 Indentation
Matti Hamalainen <ccr@tnsp.org>
parents: 402
diff changeset
72 return FALSE;
467
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
73
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
74 if (!strncmp(tmpBuf, "PSID", 4))
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
75 return TRUE;
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
76 else
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
77 return FALSE;
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
78 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
79
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
80
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
81 /* Initialize SIDPlay1
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
82 */
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
83 gboolean xs_sidplay1_init(t_xs_status * myStatus)
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
84 {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
85 gint tmpFreq;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
86 t_xs_sidplay1 *myEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
87 assert(myStatus);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
88
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
89 /* Allocate internal structures */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
90 myEngine = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1));
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
91 if (!myEngine) return FALSE;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
92
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
93 /* Initialize engine */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
94 myEngine->currEng = new emuEngine();
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
95 if (!myEngine->currEng) {
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
96 xs_error(_("[SIDPlay1] Could not initialize emulation engine.\n"));
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
97 g_free(myEngine);
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
98 return FALSE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
99 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
100
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
101 /* Verify endianess */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
102 if (!myEngine->currEng->verifyEndianess()) {
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
103 xs_error(_("[SIDPlay1] Endianess verification failed.\n"));
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
104 delete myEngine->currEng;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
105 g_free(myEngine);
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
106 return FALSE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
107 }
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
108
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
109 myStatus->sidEngine = myEngine;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
111 /* Get current configuration */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
112 myEngine->currEng->getConfig(myEngine->currConfig);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
114 /* Configure channel parameters */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
115 switch (myStatus->audioChannels) {
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
117 case XS_CHN_AUTOPAN:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
118 myEngine->currConfig.channels = SIDEMU_STEREO;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
119 myEngine->currConfig.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
120 myEngine->currConfig.volumeControl = SIDEMU_FULLPANNING;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
121 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
123 case XS_CHN_STEREO:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
124 myEngine->currConfig.channels = SIDEMU_STEREO;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
125 myEngine->currConfig.autoPanning = SIDEMU_NONE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
126 myEngine->currConfig.volumeControl = SIDEMU_NONE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
127 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
129 case XS_CHN_MONO:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
130 default:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
131 myEngine->currConfig.channels = SIDEMU_MONO;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
132 myEngine->currConfig.autoPanning = SIDEMU_NONE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
133 myEngine->currConfig.volumeControl = SIDEMU_NONE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
134 myStatus->audioChannels = XS_CHN_MONO;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
135 break;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
136 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
139 /* Memory mode settings */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
140 switch (xs_cfg.memoryMode) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
141 case XS_MPU_TRANSPARENT_ROM:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
142 myEngine->currConfig.memoryMode = MPU_TRANSPARENT_ROM;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
143 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
145 case XS_MPU_PLAYSID_ENVIRONMENT:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
146 myEngine->currConfig.memoryMode = MPU_PLAYSID_ENVIRONMENT;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
147 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
149 case XS_MPU_BANK_SWITCHING:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
150 default:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
151 myEngine->currConfig.memoryMode = MPU_BANK_SWITCHING;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
152 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
153 break;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
154 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
157 /* Audio parameters sanity checking and setup */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
158 myEngine->currConfig.bitsPerSample = myStatus->audioBitsPerSample;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
159 tmpFreq = myStatus->audioFrequency;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
160
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
161 if (myStatus->oversampleEnable) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
162 if ((tmpFreq * myStatus->oversampleFactor) > SIDPLAY1_MAX_FREQ) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
163 myStatus->oversampleEnable = FALSE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
164 } else {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
165 tmpFreq = (tmpFreq * myStatus->oversampleFactor);
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
166 }
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
167 } else {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
168 if (tmpFreq > SIDPLAY1_MAX_FREQ)
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
169 tmpFreq = SIDPLAY1_MAX_FREQ;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
170 }
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
171
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
172 myEngine->currConfig.frequency = tmpFreq;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
173
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
174 switch (myStatus->audioBitsPerSample) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
175 case XS_RES_8BIT:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
176 switch (myStatus->audioFormat) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
177 case FMT_S8:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
178 myStatus->audioFormat = FMT_S8;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
179 myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
180 break;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
181
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
182 case FMT_U8:
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
183 default:
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
184 myStatus->audioFormat = FMT_U8;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
185 myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
186 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
187 }
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
188 break;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
189
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
190 case XS_RES_16BIT:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
191 default:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
192 switch (myStatus->audioFormat) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
193 case FMT_U16_NE:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
194 case FMT_U16_LE:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
195 case FMT_U16_BE:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
196 myStatus->audioFormat = FMT_U16_NE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
197 myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
198 break;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
199
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
200 case FMT_S16_NE:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
201 case FMT_S16_LE:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
202 case FMT_S16_BE:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
203 default:
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
204 myStatus->audioFormat = FMT_S16_NE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
205 myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
206 break;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
207 }
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
208 break;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
209 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
210
368
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
211 /* Clockspeed settings */
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
212 switch (xs_cfg.clockSpeed) {
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
213 case XS_CLOCK_NTSC:
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
214 myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_NTSC;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
215 break;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
216
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
217 case XS_CLOCK_PAL:
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
218 default:
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
219 myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_PAL;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
220 xs_cfg.clockSpeed = XS_CLOCK_PAL;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
221 break;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
222 }
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
223
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
224 myEngine->currConfig.forceSongSpeed = xs_cfg.forceSpeed;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
225
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
226
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
227 /* Configure rest of the emulation */
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
228 /* if (xs_cfg.forceModel) */
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
229 myEngine->currConfig.mos8580 = xs_cfg.mos8580;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
230 myEngine->currConfig.emulateFilter = xs_cfg.emulateFilters;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
231 myEngine->currConfig.filterFs = xs_cfg.filterFs;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
232 myEngine->currConfig.filterFm = xs_cfg.filterFm;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
233 myEngine->currConfig.filterFt = xs_cfg.filterFt;
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
234
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
235
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
236 /* Now set the emulator configuration */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
237 if (!myEngine->currEng->setConfig(myEngine->currConfig)) {
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
238 xs_error(_("[SIDPlay1] Emulator engine configuration failed!\n"));
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
239 return FALSE;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
240 }
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
241
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
242 /* Create sidtune object */
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
243 myEngine->currTune = new sidTune(0);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
244 if (!myEngine->currTune) {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
245 xs_error(_("[SIDPlay1] Could not initialize SIDTune object.\n"));
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
246 return FALSE;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
247 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
248
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
249 return TRUE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
250 }
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
251
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
252
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
253 /* Close SIDPlay1 engine
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
254 */
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
255 void xs_sidplay1_close(t_xs_status * myStatus)
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
256 {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
257 t_xs_sidplay1 *myEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
258 assert(myStatus);
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
259
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
260 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
261
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
262 /* Free internals */
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
263 if (myEngine->currEng) {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
264 delete myEngine->currEng;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
265 myEngine->currEng = NULL;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
266 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
267
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
268 if (myEngine->currTune) {
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
269 delete myEngine->currTune;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
270 myEngine->currTune = NULL;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
271 }
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
272
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
273 xs_sidplay1_delete(myStatus);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
274
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
275 g_free(myEngine);
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
276 myStatus->sidEngine = NULL;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
277 }
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
278
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
279
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
280 /* Initialize current song and sub-tune
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
281 */
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
282 gboolean xs_sidplay1_initsong(t_xs_status * myStatus)
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
283 {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
284 t_xs_sidplay1 *myEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
285 assert(myStatus);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
286
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
287 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
288 if (!myEngine) return FALSE;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
289
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
290 if (!myEngine->currTune) {
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
291 xs_error(_("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n"));
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
292 return FALSE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
293 }
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
294
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
295 if (!myEngine->currTune->getStatus()) {
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
296 xs_error(_("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n"));
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
297 return FALSE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
298 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
299
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
300 myStatus->isInitialized = TRUE;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
301
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
302 return sidEmuInitializeSong(*myEngine->currEng, *myEngine->currTune, myStatus->currSong);
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
303 }
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
304
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
305
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
306 /* Emulate and render audio data to given buffer
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
307 */
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
308 guint xs_sidplay1_fillbuffer(t_xs_status * myStatus, gchar * audioBuffer, guint audioBufSize)
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
309 {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
310 t_xs_sidplay1 *myEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
311 assert(myStatus);
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
312
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
313 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
314 if (!myEngine) return 0;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
315
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
316 sidEmuFillBuffer(*myEngine->currEng, *myEngine->currTune, audioBuffer, audioBufSize);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
317
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
318 return audioBufSize;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
319 }
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
320
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
321
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
322 /* Load a given SID-tune file
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
323 */
460
9e683fb666ba Updates
Matti Hamalainen <ccr@tnsp.org>
parents: 445
diff changeset
324 gboolean xs_sidplay1_load(t_xs_status * myStatus, gchar * pcFilename)
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
325 {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
326 t_xs_sidplay1 *myEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
327 assert(myStatus);
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
328 myStatus->isInitialized = FALSE;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
329
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
330 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
368
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
331 if (!myEngine) return FALSE;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
332
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
333 /* Try to get the tune */
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
334 if (!pcFilename) return FALSE;
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
335
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
336 if (xs_fload_buffer(pcFilename, &(myEngine->buf), &(myEngine->bufSize)) != 0)
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
337 return FALSE;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
338
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
339 if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize))
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
340 return FALSE;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
342 return TRUE;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
343 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
346 /* Delete INTERNAL information
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
347 */
460
9e683fb666ba Updates
Matti Hamalainen <ccr@tnsp.org>
parents: 445
diff changeset
348 void xs_sidplay1_delete(t_xs_status * myStatus)
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
349 {
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
350 t_xs_sidplay1 *myEngine;
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
351 assert(myStatus);
74
8cb66a3f75f7 Testing
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
352
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
353 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
368
3e55874170eb Cleanups, additional engine NULL check.
Matti Hamalainen <ccr@tnsp.org>
parents: 364
diff changeset
354 if (!myEngine) return;
527
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
355
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
356 g_free(myEngine->buf);
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
357 myEngine->buf = NULL;
fe8b41abd923 Now everything necessary should be using the VFS functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 526
diff changeset
358 myEngine->bufSize = 0;
364
421e4fc13bce More and more of indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
359 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
360
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
361
467
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
362 } /* extern "C" */
9dafc55c4270 Beginnings of vfs portability.
Matti Hamalainen <ccr@tnsp.org>
parents: 460
diff changeset
363 #endif /* HAVE_SIDPLAY1 */