changeset 479:99f05a74de5b

Improvements in titlestring handling and information passing in xs_tuneinfo_t
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 26 Jan 2007 12:55:00 +0000
parents 22cd8161c9e7
children 5abdb806a03f
files src/xs_config.h src/xs_sidplay.h src/xs_title.c
diffstat 3 files changed, 125 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_config.h	Fri Jan 26 12:54:01 2007 +0000
+++ b/src/xs_config.h	Fri Jan 26 12:55:00 2007 +0000
@@ -35,7 +35,10 @@
 
 enum XS_CLOCK {
 	XS_CLOCK_PAL = 1,
-	XS_CLOCK_NTSC
+	XS_CLOCK_NTSC,
+	XS_CLOCK_VBI,
+	XS_CLOCK_CIA,
+	XS_CLOCK_ANY
 };
 
 
@@ -58,7 +61,8 @@
 enum XS_SIDMODEL {
 	XS_SIDMODEL_UNKNOWN = 0,
 	XS_SIDMODEL_6581,
-	XS_SIDMODEL_8580
+	XS_SIDMODEL_8580,
+	XS_SIDMODEL_ANY
 };
 
 
--- a/src/xs_sidplay.h	Fri Jan 26 12:54:01 2007 +0000
+++ b/src/xs_sidplay.h	Fri Jan 26 12:55:00 2007 +0000
@@ -1,42 +1,79 @@
-/* Here comes the really ugly code... Get all SID-tune information
- * for all sub-tunes, including name, length, etc.
+/*
+   XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
+
+   libSIDPlay skeleton functions used both by v1 and 2 of the backends
+
+   Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
+   (C) Copyright 2005-2007 Tecnic Software productions (TNSP)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation, Inc.,
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+
+/* This function gets most of the information, though we do miss some
+ * (those variables that are only set by libSIDPlay when tune is initialized).
+ * Rest of the information is acquired in TFUNCTION2()
+ *
+ * NOTICE! FIXME?! It might be faster to use a SID-parser of our own here,
+ * thought it might make us bit incompatible ...
  */
-t_xs_tuneinfo *TFUNCTION(gchar *pcFilename)
+t_xs_tuneinfo *TFUNCTION(gchar *sidFilename)
 {
 	t_xs_tuneinfo *pResult;
-	TTUNEINFO tuneInfo;
-	TTUNE *testTune;
+	TTUNEINFO myInfo;
+	TTUNE *myTune;
 
 	/* Check if the tune exists and is readable */
-	if ((testTune = new TTUNE(pcFilename)) == NULL)
+	if ((myTune = new TTUNE(sidFilename)) == NULL)
 		return NULL;
 
-	if (!testTune->getStatus()) {
-		delete testTune;
+	if (!myTune->getStatus()) {
+		delete myTune;
 		return NULL;
 	}
 
 	/* Get general tune information */
 #ifdef _XS_SIDPLAY1_H
-	testTune->getInfo(tuneInfo);
+	myTune->getInfo(myInfo);
 #endif
 #ifdef _XS_SIDPLAY2_H
-	tuneInfo = testTune->getInfo();
+	myInfo = myTune->getInfo();
 #endif
 
-	/* Allocate tuneinfo structure */
-	pResult = xs_tuneinfo_new(pcFilename,
-		tuneInfo.songs, tuneInfo.startSong,
-		tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2],
-		tuneInfo.loadAddr, tuneInfo.initAddr, tuneInfo.playAddr,
-		tuneInfo.dataFileLen, tuneInfo.formatString, -1);
+	/* Allocate tuneinfo structure and set information */
+	pResult = xs_tuneinfo_new(sidFilename,
+		myInfo.songs, myInfo.startSong,
+		myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2],
+		myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr,
+		myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel);
+	
+	/* NOTICE! libSIDPlay[12] headers specifically state that sidModel,
+	 * songSpeed and clockSpeed are "undefined" before song initialization,
+	 * but in practice sidModel is known after getInfo() invocation...
+	 * This of course does not take the sub-tune specific changes into account,
+	 * but at least we have a reasonable guesstimate.
+	 */
 
-	delete testTune;
+	delete myTune;
 
 	return pResult;
 }
 
 
+/* Updates the information of currently playing tune
+ */
 gboolean TFUNCTION2(t_xs_status *myStatus)
 {
 	TTUNEINFO myInfo;
@@ -61,23 +98,39 @@
 	myInfo = myTune->getInfo();
 #endif
 
-	/* Here we assume that libSIDPlay[12] headers define SIDTUNE_SIDMODEL_*
-	 * similarly to our enums in xs_config.h ...
+	/* NOTICE! Here we assume that libSIDPlay[12] headers define
+	 * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ...
 	 */
 	i = myStatus->tuneInfo;
 	i->sidModel = myInfo.sidModel;
 
-XSDEBUG("%s[%d]: %d, %d\n", i->sidFilename, myStatus->currSong, myInfo.songSpeed, myInfo.clockSpeed);
-
 	if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) {
 		gint tmpSpeed = -1;
 		
 		switch (myInfo.clockSpeed) {
-		case SIDTUNE_CLOCK_PAL: tmpSpeed = 50; break;
-		case SIDTUNE_CLOCK_NTSC: tmpSpeed = 60; break;
+		case SIDTUNE_CLOCK_PAL:
+			tmpSpeed = XS_CLOCK_PAL;
+			break;
+		case SIDTUNE_CLOCK_NTSC:
+			tmpSpeed = XS_CLOCK_NTSC;
+			break;
+		case SIDTUNE_CLOCK_ANY:
+			tmpSpeed = XS_CLOCK_ANY;
+			break;
+		case SIDTUNE_CLOCK_UNKNOWN:
+			switch (myInfo.songSpeed) {
+			case SIDTUNE_SPEED_VBI:
+				tmpSpeed = XS_CLOCK_VBI;
+				break;
+			case SIDTUNE_SPEED_CIA_1A:
+				tmpSpeed = XS_CLOCK_CIA;
+				break;
+			default:
+				tmpSpeed = myInfo.songSpeed;
+				break;
+			}
 		default:
-			if (myInfo.songSpeed != 0)
-				tmpSpeed = myInfo.songSpeed;
+			tmpSpeed = myInfo.clockSpeed;
 			break;
 		}
 			
--- a/src/xs_title.c	Fri Jan 26 12:54:01 2007 +0000
+++ b/src/xs_title.c	Fri Jan 26 12:55:00 2007 +0000
@@ -152,16 +152,54 @@
 					case XS_SIDMODEL_8580:
 						VPUTSTR("8580");
 						break;
+					case XS_SIDMODEL_ANY:
+						VPUTSTR("ANY");
+						break;
 					default:
 						VPUTSTR("?");
 						break;
 					}
 					break;
 				case 'S':
+					if (subInfo) {
+						gint i;
+						switch (subInfo->tuneSpeed) {
+						case XS_CLOCK_PAL: i = 50; break;
+						case XS_CLOCK_NTSC: i = 60; break;
+						case XS_CLOCK_ANY: i = -1; break;
+						default: i = subInfo->tuneSpeed;
+						}
+						if (i > 0) {
+							g_snprintf(tmpStr, XS_BUF_SIZE, "%i", i);
+							VPUTSTR(tmpStr);
+						} else
+							VPUTSTR("?");
+					} else
+						VPUTSTR("?");
+					break;
+				case 'C':
 					if (subInfo && (subInfo->tuneSpeed > 0)) {
-						g_snprintf(tmpStr, XS_BUF_SIZE,
-							"%i", subInfo->tuneSpeed);
-						VPUTSTR(tmpStr);
+						switch (subInfo->tuneSpeed) {
+						case XS_CLOCK_PAL:
+							VPUTSTR("PAL");
+							break;
+						case XS_CLOCK_NTSC:
+							VPUTSTR("NTSC");
+							break;
+						case XS_CLOCK_ANY:
+							VPUTSTR("ANY");
+							break;
+						case XS_CLOCK_VBI:
+							VPUTSTR("VBI");
+							break;
+						case XS_CLOCK_CIA:
+							VPUTSTR("CIA");
+							break;
+						default:
+							g_snprintf(tmpStr, XS_BUF_SIZE,
+							"%iHz", subInfo->tuneSpeed);
+							VPUTSTR(tmpStr);
+						}
 					} else
 						VPUTSTR("?");
 					break;