annotate src/xs_sidplay1.cc @ 324:dd201740a720

Changed copyright text.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Jan 2005 04:11:02 +0000
parents 583f5651abff
children b1a858b8cb1a
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
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 along with this program; if not, write to the Free Software
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
27 #include "xs_sidplay1.h"
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
28 #include <stdio.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"
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
30 #include "xs_length.h"
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
31 #include "xs_title.h"
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #include <sidplay/player.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #include <sidplay/myendian.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 #include <sidplay/fformat.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
37 /* Maximum audio frequency supported by libSIDPlay v1 */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
38 #define SIDPLAY1_MAX_FREQ (48000)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
40 typedef struct {
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
41 emuEngine *currEng;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
42 emuConfig currConfig;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
43 sidTune *currTune;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
44 } t_xs_sidplay1;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
45
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
46
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
47 /* We need to 'export' all this pseudo-C++ crap */
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
48 extern "C" {
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
49
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
50
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
51 /* 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
52 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
53 gboolean xs_sidplay1_isourfile(gchar *pcFilename)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
54 {
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
55 sidTune *testTune = new sidTune(pcFilename);
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
56
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
57 if (!testTune) return FALSE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
58 if (!testTune->getStatus())
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
59 {
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
60 delete testTune;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
61 return FALSE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
62 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
63
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
64 delete testTune;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
65 return TRUE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
66 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
67
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
68
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
69 /* Initialize SIDPlay1
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
70 */
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
71 gboolean xs_sidplay1_init(t_xs_status *myStatus)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 {
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
73 gint tmpFreq;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
74 t_xs_sidplay1 *myEngine;
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
75 assert(myStatus);
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
76
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
77 /* Allocate internal structures */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
78 myEngine = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1));
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
79 if (!myEngine) return FALSE;
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
80
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
81 /* Initialize engine */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
82 myEngine->currEng = new emuEngine();
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
83 if (!myEngine->currEng)
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
84 {
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
85 XSERR("Could not initialize libSIDPlay1 emulation engine\n");
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
86 g_free(myEngine);
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
87 return FALSE;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
88 }
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
89
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
90 /* Verify endianess */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
91 if (!myEngine->currEng->verifyEndianess())
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
92 {
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
93 XSERR("Endianess verification failed\n");
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
94 delete myEngine->currEng;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
95 g_free(myEngine);
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
96 return FALSE;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
97 }
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
98
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
99 myStatus->sidEngine = myEngine;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 /* Get current configuration */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
102 myEngine->currEng->getConfig(myEngine->currConfig);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
104 /* Configure channel parameters */
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
105 switch (myStatus->audioChannels) {
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 case XS_CHN_AUTOPAN:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
108 myEngine->currConfig.channels = SIDEMU_STEREO;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
109 myEngine->currConfig.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
110 myEngine->currConfig.volumeControl = SIDEMU_FULLPANNING;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 case XS_CHN_STEREO:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
114 myEngine->currConfig.channels = SIDEMU_STEREO;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
115 myEngine->currConfig.autoPanning = SIDEMU_NONE;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
116 myEngine->currConfig.volumeControl = SIDEMU_NONE;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 case XS_CHN_MONO:
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 default:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
121 myEngine->currConfig.channels = SIDEMU_MONO;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
122 myEngine->currConfig.autoPanning = SIDEMU_NONE;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
123 myEngine->currConfig.volumeControl = SIDEMU_NONE;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
124 myStatus->audioChannels = XS_CHN_MONO;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 /* Memory mode settings */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 switch (xs_cfg.memoryMode) {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 case XS_MPU_TRANSPARENT_ROM:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
132 myEngine->currConfig.memoryMode = MPU_TRANSPARENT_ROM;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 case XS_MPU_PLAYSID_ENVIRONMENT:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
136 myEngine->currConfig.memoryMode = MPU_PLAYSID_ENVIRONMENT;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
139 case XS_MPU_BANK_SWITCHING:
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 default:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
141 myEngine->currConfig.memoryMode = MPU_BANK_SWITCHING;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
142 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 /* Clockspeed settings */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 switch (xs_cfg.clockSpeed) {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 case XS_CLOCK_NTSC:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
150 myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_NTSC;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 case XS_CLOCK_PAL:
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 default:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
155 myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_PAL;
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
156 xs_cfg.clockSpeed = XS_CLOCK_PAL;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 break;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 /* Configure rest of the emulation */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
162 myEngine->currConfig.mos8580 = xs_cfg.mos8580;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
163 myEngine->currConfig.emulateFilter = xs_cfg.emulateFilters;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
164 myEngine->currConfig.filterFs = xs_cfg.filterFs;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
165 myEngine->currConfig.filterFm = xs_cfg.filterFm;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
166 myEngine->currConfig.filterFt = xs_cfg.filterFt;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
168
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
169 /* Audio parameters sanity checking and setup */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
170 myEngine->currConfig.bitsPerSample = myStatus->audioBitsPerSample;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
171 tmpFreq = myStatus->audioFrequency;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
172
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
173 if (myStatus->oversampleEnable)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
174 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
175 if ((tmpFreq * myStatus->oversampleFactor) > SIDPLAY1_MAX_FREQ)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
176 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
177 myStatus->oversampleEnable = FALSE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
178 } else {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
179 tmpFreq = (tmpFreq * myStatus->oversampleFactor);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
180 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
181 } else {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
182 if (tmpFreq > SIDPLAY1_MAX_FREQ)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
183 tmpFreq = SIDPLAY1_MAX_FREQ;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
184 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
185
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
186 myEngine->currConfig.frequency = tmpFreq;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
187
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
188 switch (myStatus->audioBitsPerSample) {
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
189 case XS_RES_8BIT:
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
190 switch (myStatus->audioFormat) {
135
a3f522cbe787 Fixes in audio format selection/emuengine configuration.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
191 case FMT_S8:
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
192 myStatus->audioFormat = FMT_S8;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
193 myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
194 break;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
195
135
a3f522cbe787 Fixes in audio format selection/emuengine configuration.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
196 case FMT_U8:
a3f522cbe787 Fixes in audio format selection/emuengine configuration.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
197 default:
a3f522cbe787 Fixes in audio format selection/emuengine configuration.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
198 myStatus->audioFormat = FMT_U8;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
199 myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
200 break;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
201 }
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
202 break;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
203
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
204 case XS_RES_16BIT:
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
205 default:
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
206 switch (myStatus->audioFormat) {
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
207 case FMT_U16_NE:
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
208 case FMT_U16_LE:
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
209 case FMT_U16_BE:
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
210 myStatus->audioFormat = FMT_U16_NE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
211 myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
212 break;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
213
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
214 case FMT_S16_NE:
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
215 case FMT_S16_LE:
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
216 case FMT_S16_BE:
135
a3f522cbe787 Fixes in audio format selection/emuengine configuration.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
217 default:
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
218 myStatus->audioFormat = FMT_S16_NE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
219 myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
220 break;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
221 }
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
222 break;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
223 }
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
224
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 /* Now set the emulator configuration */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
226 if (!myEngine->currEng->setConfig(myEngine->currConfig))
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
227 {
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
228 XSERR("Emulator engine configuration failed!\n");
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
229 return FALSE;
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
230 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
232 return TRUE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
233 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
234
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
235
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
236 /* Close SIDPlay1 engine
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
237 */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
238 void xs_sidplay1_close(t_xs_status *myStatus)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
239 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
240 t_xs_sidplay1 *myEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
241 assert(myStatus);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
242
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
243 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
244
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
245 /* Free internals */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
246 if (myEngine->currEng)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
247 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
248 delete myEngine->currEng;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
249 myEngine->currEng = NULL;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
250 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
251
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
252 g_free(myEngine);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
253 myStatus->sidEngine = NULL;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
254 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
255
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
256
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
257 /* Initialize current song and sub-tune
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
258 */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
259 gboolean xs_sidplay1_initsong(t_xs_status *myStatus)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
260 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
261 t_xs_sidplay1 *myEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
262 assert(myStatus);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
263
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
264 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
265 if (!myEngine) return FALSE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
266
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
267 if (!myEngine->currTune)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
268 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
269 XSERR("Tune was NULL\n");
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
270 return FALSE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
271 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
272
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
273 if (!myEngine->currTune->getStatus())
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
274 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
275 XSERR("Tune status check failed\n");
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
276 return FALSE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
277 }
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 return sidEmuInitializeSong(
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
280 *myEngine->currEng,
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
281 *myEngine->currTune,
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
282 myStatus->currSong);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
283 }
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
284
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
285
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
286 /* 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
287 */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
288 guint xs_sidplay1_fillbuffer(t_xs_status *myStatus, gchar *audioBuffer, guint audioBufSize)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
289 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
290 t_xs_sidplay1 *myEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
291 assert(myStatus);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
292
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
293 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
294 if (!myEngine) return 0;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
295
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
296 sidEmuFillBuffer(
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
297 *myEngine->currEng,
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
298 *myEngine->currTune,
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
299 audioBuffer,
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
300 audioBufSize);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
301
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
302 return audioBufSize;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
303 }
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 /* Load a given SID-tune file
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
307 */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
308 gboolean xs_sidplay1_loadsid(t_xs_status *myStatus, gchar *pcFilename)
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
309 {
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
310 t_xs_sidplay1 *myEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
311 sidTune *newTune;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
312 assert(myStatus);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
313
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
314 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
315
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
316 /* Try to get the tune */
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
317 if (!pcFilename) return FALSE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
318
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
319 newTune = new sidTune(pcFilename);
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
320 if (!newTune) return FALSE;
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
321
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
322 myEngine->currTune = newTune;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
324 return TRUE;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
328 /* Delete INTERNAL information
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
329 */
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
330 void xs_sidplay1_deletesid(t_xs_status *myStatus)
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
331 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
332 t_xs_sidplay1 *myEngine;
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
333 assert(myStatus);
74
8cb66a3f75f7 Testing
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
334
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
335 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
336 if (!myEngine) return;
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
337
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
338 if (myEngine->currTune)
74
8cb66a3f75f7 Testing
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
339 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
340 delete myEngine->currTune;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
341 myEngine->currTune = NULL;
74
8cb66a3f75f7 Testing
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
342 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
343 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
344
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
345
270
583f5651abff Cleanups, moved engine configuration to initialization function.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
346 /* Return song information
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
347 */
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
348 #define TFUNCTION xs_sidplay1_getsidinfo
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
349 #define TTUNEINFO sidTuneInfo
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
350 #define TTUNE sidTune
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
351 #include "xs_sidplay.h"
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
352
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
353 } /* extern "C" */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 #endif /* HAVE_SIDPLAY1 */