comparison src/xs_sidplay.h @ 402:f997b79a7251

More work on merging of improved STIL/SLDB handling code with completely dynamic memory allocation.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 01 Jun 2006 02:18:02 +0000
parents 684d09ff564b
children 7f694e5a1493
comparison
equal deleted inserted replaced
401:30da794755f7 402:f997b79a7251
1 /* 1 /* Here comes the really ugly code... Get all SID-tune information
2 * Here comes the really ugly code... 2 * for all sub-tunes, including name, length, etc.
3 * Get all SID-tune information (for all sub-tunes)
4 * including name, length, etc.
5 */ 3 */
6 t_xs_tuneinfo *TFUNCTION(gchar * pcFilename) 4 t_xs_tuneinfo *TFUNCTION(gchar * pcFilename)
7 { 5 {
8 t_xs_sldb_node *tuneLength = NULL;
9 t_xs_tuneinfo *pResult; 6 t_xs_tuneinfo *pResult;
10 TTUNEINFO tuneInfo; 7 TTUNEINFO tuneInfo;
11 TTUNE *testTune; 8 TTUNE *testTune;
12 gboolean haveInfo = TRUE; 9 gboolean haveInfo = TRUE;
13 gint i;
14 10
15 /* Check if the tune exists and is readable */ 11 /* Check if the tune exists and is readable */
16 if ((testTune = new TTUNE(pcFilename)) == NULL) 12 if ((testTune = new TTUNE(pcFilename)) == NULL)
17 return NULL; 13 return NULL;
18 14
28 #ifdef _XS_SIDPLAY2_H 24 #ifdef _XS_SIDPLAY2_H
29 testTune->getInfo(tuneInfo); 25 testTune->getInfo(tuneInfo);
30 haveInfo = TRUE; 26 haveInfo = TRUE;
31 #endif 27 #endif
32 28
33 /* Get length information (NOTE: Do not free this!) */
34 tuneLength = xs_songlen_get(pcFilename);
35
36 /* Allocate tuneinfo structure */ 29 /* Allocate tuneinfo structure */
37 pResult = xs_tuneinfo_new(pcFilename, 30 pResult = xs_tuneinfo_new(pcFilename,
38 tuneInfo.songs, tuneInfo.startSong, 31 tuneInfo.songs, tuneInfo.startSong,
39 tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2], 32 tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2],
40 tuneInfo.loadAddr, tuneInfo.initAddr, tuneInfo.playAddr, tuneInfo.dataFileLen); 33 tuneInfo.loadAddr, tuneInfo.initAddr, tuneInfo.playAddr,
41 34 tuneInfo.dataFileLen, tuneInfo.formatString);
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 35
65 delete testTune; 36 delete testTune;
66 37
67 return pResult; 38 return pResult;
68 } 39 }