269
|
1 /*
|
|
2 * Here comes the really ugly code...
|
|
3 * Get all SID-tune information (for all sub-tunes)
|
|
4 * including name, length, etc.
|
|
5 */
|
|
6 t_xs_tuneinfo *TFUNCTION(gchar * pcFilename)
|
|
7 {
|
|
8 t_xs_sldb_node *tuneLength = NULL;
|
|
9 t_xs_tuneinfo *pResult;
|
|
10 TTUNEINFO tuneInfo;
|
|
11 TTUNE *testTune;
|
|
12 gboolean haveInfo = TRUE;
|
|
13 gint i;
|
|
14
|
|
15 /* Check if the tune exists and is readable */
|
|
16 if ((testTune = new TTUNE(pcFilename)) == NULL)
|
|
17 return NULL;
|
|
18
|
|
19 if (!testTune->getStatus()) {
|
|
20 delete testTune;
|
|
21 return NULL;
|
|
22 }
|
|
23
|
|
24 /* Get general tune information */
|
|
25 #ifdef _XS_SIDPLAY1_H
|
|
26 haveInfo = testTune->getInfo(tuneInfo);
|
|
27 #endif
|
|
28 #ifdef _XS_SIDPLAY2_H
|
|
29 testTune->getInfo(tuneInfo);
|
|
30 haveInfo = TRUE;
|
|
31 #endif
|
|
32
|
|
33 /* Get length information (NOTE: Do not free this!) */
|
|
34 tuneLength = xs_songlen_get(pcFilename);
|
|
35
|
|
36 /* Allocate tuneinfo structure */
|
|
37 pResult = xs_tuneinfo_new(pcFilename,
|
|
38 tuneInfo.songs, tuneInfo.startSong,
|
|
39 tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2],
|
|
40 tuneInfo.loadAddr, tuneInfo.initAddr, tuneInfo.playAddr, tuneInfo.dataFileLen);
|
|
41
|
|
42 if (!pResult) {
|
|
43 delete testTune;
|
|
44 return NULL;
|
|
45 }
|
|
46
|
|
47 /* Get information for subtunes */
|
|
48 for (i = 0; i < pResult->nsubTunes; i++) {
|
|
49 /* Make the title */
|
|
50 if (haveInfo) {
|
|
51 pResult->subTunes[i].tuneTitle =
|
|
52 xs_make_titlestring(pcFilename, i + 1, pResult->nsubTunes, tuneInfo.sidModel,
|
|
53 tuneInfo.formatString, tuneInfo.infoString[0],
|
|
54 tuneInfo.infoString[1], tuneInfo.infoString[2]);
|
|
55 } else
|
|
56 pResult->subTunes[i].tuneTitle = g_strdup(pcFilename);
|
|
57
|
|
58 /* Get song length */
|
|
59 if (tuneLength && (i < tuneLength->nLengths))
|
|
60 pResult->subTunes[i].tuneLength = tuneLength->sLengths[i];
|
|
61 else
|
|
62 pResult->subTunes[i].tuneLength = -1;
|
|
63 }
|
|
64
|
|
65 delete testTune;
|
|
66
|
|
67 return pResult;
|
|
68 }
|
|
69
|
|
70 /* Undefine these */
|
|
71 #undef TFUNCTION
|
|
72 #undef TTUNEINFO
|
|
73 #undef TTUNE
|