872
|
1 /*
|
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
|
|
3
|
|
4 Backend handling
|
|
5
|
|
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
|
|
7 (C) Copyright 1999-2012 Tecnic Software productions (TNSP)
|
|
8
|
|
9 This program is free software; you can redistribute it and/or modify
|
|
10 it under the terms of the GNU General Public License as published by
|
|
11 the Free Software Foundation; either version 2 of the License, or
|
|
12 (at your option) any later version.
|
|
13
|
|
14 This program is distributed in the hope that it will be useful,
|
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 GNU General Public License for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License along
|
|
20 with this program; if not, write to the Free Software Foundation, Inc.,
|
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
22 */
|
|
23 #include "xs_backend.h"
|
|
24 #include "xs_config.h"
|
|
25
|
|
26 /* List of emulator engines
|
|
27 */
|
|
28 #ifdef HAVE_SIDPLAY1
|
|
29 # include "xs_sidplay1.h"
|
|
30 #endif
|
|
31 #ifdef HAVE_SIDPLAY2
|
|
32 # include "xs_sidplay2.h"
|
|
33 #endif
|
|
34 #ifdef HAVE_SIDPLAYFP
|
|
35 # include "xs_sidplayfp.h"
|
|
36 #endif
|
|
37
|
|
38
|
|
39 static XSEngine xs_enginelist[] =
|
|
40 {
|
|
41 #ifdef HAVE_SIDPLAY1
|
|
42 {
|
|
43 XS_ENG_SIDPLAY1,
|
|
44 xs_sidplay1_probe,
|
|
45 xs_sidplay1_init, xs_sidplay1_close,
|
|
46 xs_sidplay1_initsong, xs_sidplay1_fillbuffer,
|
|
47 xs_sidplay1_load, xs_sidplay1_delete,
|
|
48 xs_sidplay1_getinfo, xs_sidplay1_updateinfo,
|
|
49 NULL
|
|
50 },
|
|
51 #endif
|
|
52 #ifdef HAVE_SIDPLAY2
|
|
53 {
|
|
54 XS_ENG_SIDPLAY2,
|
|
55 xs_sidplay2_probe,
|
|
56 xs_sidplay2_init, xs_sidplay2_close,
|
|
57 xs_sidplay2_initsong, xs_sidplay2_fillbuffer,
|
|
58 xs_sidplay2_load, xs_sidplay2_delete,
|
|
59 xs_sidplay2_getinfo, xs_sidplay2_updateinfo,
|
|
60 xs_sidplay2_flush
|
|
61 },
|
|
62 #endif
|
|
63 #ifdef HAVE_SIDPLAYFP
|
|
64 {
|
|
65 XS_ENG_SIDPLAYFP,
|
|
66 xs_sidplayfp_probe,
|
|
67 xs_sidplayfp_init, xs_sidplayfp_close,
|
|
68 xs_sidplayfp_initsong, xs_sidplayfp_fillbuffer,
|
|
69 xs_sidplayfp_load, xs_sidplayfp_delete,
|
|
70 xs_sidplayfp_getinfo, xs_sidplayfp_updateinfo,
|
|
71 xs_sidplayfp_flush
|
|
72 },
|
|
73 #endif
|
|
74 };
|
|
75
|
|
76 static const gint xs_nenginelist = sizeof(xs_enginelist) / sizeof(xs_enginelist[0]);
|
|
77
|
|
78
|
876
|
79 static const XSROMImageData xs_rom_images[XS_C64_ROM_IMAGES] =
|
|
80 {
|
|
81 { "Kernal", "kernal", 8192 },
|
|
82 { "Basic", "basic", 8192 },
|
|
83 { "Chargen", "chargen", 4096 },
|
|
84 };
|
|
85
|
|
86
|
873
|
87 gboolean xs_init_emu_backend(XSEngineState *state, gint *preferred)
|
872
|
88 {
|
|
89 gint engine;
|
|
90 gboolean initialized = FALSE;
|
|
91
|
|
92 XSDEBUG("trying emulator engine #%i...\n", *preferred);
|
|
93
|
|
94 for (engine = 0; engine < xs_nenginelist && !initialized; engine++)
|
|
95 {
|
|
96 if (xs_enginelist[engine].plrIdent == *preferred &&
|
|
97 xs_enginelist[engine].plrInit(state))
|
|
98 {
|
|
99 initialized = TRUE;
|
|
100 state->engine = &xs_enginelist[engine];
|
|
101 }
|
|
102 }
|
|
103
|
|
104 XSDEBUG("init#1: %s, %i\n", initialized ? "OK" : "FAILED", *preferred);
|
|
105 return initialized;
|
|
106 }
|
876
|
107
|
|
108
|
|
109 gboolean xs_load_rom_images(guint8 **roms)
|
|
110 {
|
|
111 gint i;
|
|
112
|
|
113 XSDEBUG("Loading C64 ROM images ...\n");
|
|
114
|
|
115 for (i = 0; i < XS_C64_ROM_IMAGES; i++)
|
|
116 {
|
|
117 const XSROMImageData *rom = &xs_rom_images[i];
|
|
118 size_t size = 0;
|
|
119
|
|
120 XSDEBUG("Trying ROM '%s' from '%s%s', %d bytes.\n",
|
|
121 rom->name, xs_cfg.romPath, rom->filename, rom->size);
|
|
122
|
|
123 if (!xs_fload_buffer_path(xs_cfg.romPath, rom->filename,
|
|
124 &roms[i], &size, rom->size, TRUE))
|
|
125 {
|
|
126 xs_error("Failed to load required %s ROM image '%s%s'.\n",
|
|
127 rom->name, xs_cfg.romPath, rom->filename);
|
|
128 return FALSE;
|
|
129 }
|
|
130
|
|
131 if (size < rom->size)
|
|
132 {
|
|
133 xs_error("ROM image %s '%s%s' size does not match: %d != %d\n",
|
|
134 rom->name, xs_cfg.romPath, rom->filename,
|
|
135 size, rom->size);
|
|
136 return FALSE;
|
|
137 }
|
|
138 }
|
|
139
|
|
140 return TRUE;
|
|
141 }
|