changeset 468:6963982fcbb6

New songinfo system.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 25 Jan 2007 03:46:04 +0000
parents 9dafc55c4270
children d600f45c92d2
files src/xs_sidplay.h
diffstat 1 files changed, 50 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_sidplay.h	Thu Jan 25 03:46:02 2007 +0000
+++ b/src/xs_sidplay.h	Thu Jan 25 03:46:04 2007 +0000
@@ -29,7 +29,7 @@
 		tuneInfo.songs, tuneInfo.startSong,
 		tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2],
 		tuneInfo.loadAddr, tuneInfo.initAddr, tuneInfo.playAddr,
-		tuneInfo.dataFileLen, tuneInfo.formatString, -1, -1, -1);
+		tuneInfo.dataFileLen, tuneInfo.formatString, -1);
 
 	delete testTune;
 
@@ -39,36 +39,63 @@
 
 gboolean TFUNCTION2(t_xs_status *myStatus)
 {
-	TTUNEINFO tuneInfo;
-#ifdef _XS_SIDPLAY1_H
-	t_xs_sidplay1 *myEngine;
-#endif
-#ifdef _XS_SIDPLAY2_H
-	t_xs_sidplay2 *myEngine;
-#endif
+	TTUNEINFO myInfo;
+	TTUNE *myTune;
+	TENGINE *myEngine;
+	t_xs_tuneinfo *i;
+	
+	/* Check if we have required structures initialized */
+	if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine)
+		return FALSE;
 
-	if (!myStatus || !myStatus->tuneInfo)
+	myEngine = (TENGINE *) myStatus->sidEngine;
+	myTune = myEngine->currTune;
+	if (!myTune)
 		return FALSE;
 
-	/* Get general tune information */
+	/* Get currently playing tune information */
 #ifdef _XS_SIDPLAY1_H
-	testTune->getInfo(tuneInfo);
+	myTune->getInfo(myInfo);
 #endif
 #ifdef _XS_SIDPLAY2_H
-	tuneInfo = testTune->getInfo();
+	myInfo = myTune->getInfo();
 #endif
 
-	if (!tuneInfo)
-		return FALSE;
-	
-	
-	/* 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,
-		tuneInfo.sidModel, tuneInfo.songSpeed, tuneInfo.clockSpeed);
+	/* 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;
+
+	if ((myStatus->currSong >= 1) && (myStatus->currSong < i->nsubTunes)) {
+		t_xs_subtuneinfo *t = &(i->subTunes[myStatus->currSong - 1]);
+		
+		switch (myInfo.songSpeed) {
+		case SIDTUNE_SPEED_VBI:
+			switch (myInfo.clockSpeed) {
+			case SIDTUNE_CLOCK_PAL:
+				t->tuneSpeed = 50;
+				break;
+			
+			case SIDTUNE_CLOCK_NTSC:
+				t->tuneSpeed = 60;
+				break;
+			
+			default:
+				t->tuneSpeed = -1;
+				break;
+			}
+			break;
+			
+		case SIDTUNE_SPEED_CIA_1A:
+			t->tuneSpeed = 60;
+			break;
+			
+		default:
+			t->tuneSpeed = -1;
+			break;
+		}
+	}
 
 	return TRUE;
 }