[Scummvm-cvs-logs] SF.net SVN: scummvm: [24352] scummvm/branches/branch-0-9-0/backends/ds/arm9 /source

agent-q at users.sourceforge.net agent-q at users.sourceforge.net
Tue Oct 17 00:43:51 CEST 2006


Revision: 24352
          http://svn.sourceforge.net/scummvm/?rev=24352&view=rev
Author:   agent-q
Date:     2006-10-16 15:43:43 -0700 (Mon, 16 Oct 2006)

Log Message:
-----------
Beta5: Various bugfixes.

Modified Paths:
--------------
    scummvm/branches/branch-0-9-0/backends/ds/arm9/source/cdaudio.cpp
    scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsmain.cpp
    scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.cpp
    scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.h
    scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.cpp
    scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.h

Modified: scummvm/branches/branch-0-9-0/backends/ds/arm9/source/cdaudio.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/backends/ds/arm9/source/cdaudio.cpp	2006-10-16 22:20:46 UTC (rev 24351)
+++ scummvm/branches/branch-0-9-0/backends/ds/arm9/source/cdaudio.cpp	2006-10-16 22:43:43 UTC (rev 24352)
@@ -133,8 +133,14 @@
 	
 	
 	char str[100];
-	sprintf(str, "/track%d.wav", track);
-	path = path + str;
+
+	if (path[strlen(path.c_str()) - 1] == '/') {
+		sprintf(str, "track%d.wav", track);
+		path = path + str;
+	} else {
+		sprintf(str, "/track%d.wav", track);
+		path = path + str;
+	}
 	
 	
 	//1820160
@@ -459,10 +465,14 @@
 	consolePrintf("Attempted to open cd drive\n");
 
 	Common::String path = ConfMan.get("path");
-	path = path + "/track2.wav";
 	// 6577 153 154
+	if (path[strlen(path.c_str()) - 1] == '/') {
+		path = path + "track2.wav";
+	} else {
+		path = path + "/track2.wav";
+	}
 	consolePrintf("Looking for %s...", path.c_str());
-	
+
 	FILE* file;
 	if ((file = DS::std_fopen(path.c_str(), "r"))) {
 		consolePrintf("Success!\n");

Modified: scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsmain.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsmain.cpp	2006-10-16 22:20:46 UTC (rev 24351)
+++ scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsmain.cpp	2006-10-16 22:43:43 UTC (rev 24352)
@@ -56,6 +56,8 @@
 //#include "compact_flash.h"
 #include "dsoptions.h"
 #include "user_debugger.h"
+#include "ramsave.h"
+#include "disc_io.h"
 
 namespace DS {
 
@@ -1917,8 +1919,12 @@
 		swiWaitForVBlank();			// Allow you to read error before the power
 	}								// is turned off.
 
-	IPC->reset = true;				// Send message to ARM7 to turn power off
-	while (true);		// Stop the program continuing beyond this point
+	if (ConfMan.hasKey("disablepoweroff", "ds") && ConfMan.getBool("disablepoweroff", "ds")) {
+		while (true);
+	} else {
+		IPC->reset = true;				// Send message to ARM7 to turn power off
+		while (true);		// Stop the program continuing beyond this point
+	}
 }
 
 /////////////////
@@ -2012,7 +2018,7 @@
 	consolePrintf("---------------------------\n");
 	consolePrintf("ScummVM DS\n");
 	consolePrintf("Ported by Neil Millstone\n");
-	consolePrintf("Version 0.9.1beta3 ");
+	consolePrintf("Version 0.9.1beta4 ");
 #if defined(DS_BUILD_A)
 	consolePrintf("build A\n");
 	consolePrintf("Supports: Lucasarts SCUMM\n");
@@ -2030,23 +2036,48 @@
 	consolePrintf("D-pad left:  Left mouse button\n");
 	consolePrintf("D-pad right: Right mouse button\n");
 	consolePrintf("D-pad up:    Hover mouse\n");
-	consolePrintf("D-pad down:  Skip dialog line\n");
 	consolePrintf("B button:    Skip cutscenes\n");
 	consolePrintf("Select:		DS Options menu\n");
 	consolePrintf("Start:       Game menu\n");
 	consolePrintf("Y (in game): Toggle console\n");
 	consolePrintf("X:           Toggle keyboard\n");
 	consolePrintf("A:			Swap screens\n");
-	consolePrintf("L+R (on start): Clear SRAM\n\n");
+	consolePrintf("L+R (on start): Clear SRAM\n");
 
 #if defined(DS_BUILD_A)
 	consolePrintf("For a complete key list see the\n");
 	consolePrintf("help screen.\n\n");
 #endif
 
+	
+	// Do M3 detection selectioon
+	int extraData = DSSaveFileManager::getExtraData();
+	bool present = DSSaveFileManager::isExtraDataPresent();
 
+	swiWaitForVBlank();
 
+	if ((present) && (extraData & 0x00000001)) {
 
+		if (keysHeld() & KEY_L) {
+			extraData &= ~0x00000001;
+			consolePrintf("M3 SD Detection: OFF\n");
+			DSSaveFileManager::setExtraData(extraData);
+		} else {
+			consolePrintf("M3 SD Detection: ON\n");
+			consolePrintf("Hold L on startup to disable.\n");
+		}
+
+	} else if (keysHeld() & KEY_L) {
+		consolePrintf("M3 SD Detection: ON\n");
+		extraData |= 0x00000001;
+		DSSaveFileManager::setExtraData(extraData);
+	} else {
+		consolePrintf("M3 SD Detection: OFF\n");
+		consolePrintf("Hold L on startup to enable.\n");
+	}
+
+	disc_setM3SDEnable(extraData & 0x00000001);
+
 	// Create a file system node to force search for a zip file in GBA rom space
 	DSFileSystemNode* node = new DSFileSystemNode();
 	if (!node->getZip() || (!node->getZip()->isReady())) {

Modified: scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.cpp	2006-10-16 22:20:46 UTC (rev 24351)
+++ scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.cpp	2006-10-16 22:43:43 UTC (rev 24352)
@@ -36,8 +36,8 @@
 
 namespace DS {
 
-DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 20, 320 - 40, 200 - 40) {
-	addButton(this, 10, 140, "Close", GUI::kCloseCmd, 'C');
+DSOptionsDialog::DSOptionsDialog() : GUI::Dialog(20, 0, 320 - 40, 200 - 20) {
+	addButton(this, 10, 160, "Close", GUI::kCloseCmd, 'C');
 	
 #ifdef DS_SCUMM_BUILD
 	if (!DS::isGBAMPAvailable()) {
@@ -45,31 +45,32 @@
 	}
 #endif
 
-	new GUI::StaticTextWidget(this, 80, 10, 130, 20, "ScummVM DS Options", GUI::kTextAlignCenter);
+	new GUI::StaticTextWidget(this, 80, 10, 130, 15, "ScummVM DS Options", GUI::kTextAlignCenter);
 
-	_leftHandedCheckbox = new GUI::CheckboxWidget(this, 20, 30, 200, 20, "Left handed mode", 0, 'L');
-	_indyFightCheckbox = new GUI::CheckboxWidget(this, 20, 45, 200, 20, "Indy fighting controls", 0, 'I');
-	_unscaledCheckbox = new GUI::CheckboxWidget(this, 20, 60, 200, 20, "Unscaled main screen", 0, 'S');
-	_twoHundredPercentCheckbox = new GUI::CheckboxWidget(this, 20, 75, 230, 20, "Zoomed screen at fixed 200% zoom", 0, 'T');
-	_highQualityAudioCheckbox = new GUI::CheckboxWidget(this, 20, 90, 250, 20, "High quality audio (slower) (reboot)", 0, 'T');
+	_leftHandedCheckbox = new GUI::CheckboxWidget(this, 20, 25, 200, 20, "Left handed mode", 0, 'L');
+	_indyFightCheckbox = new GUI::CheckboxWidget(this, 20, 40, 200, 20, "Indy fighting controls", 0, 'I');
+	_unscaledCheckbox = new GUI::CheckboxWidget(this, 20, 55, 200, 20, "Unscaled main screen", 0, 'S');
+	_twoHundredPercentCheckbox = new GUI::CheckboxWidget(this, 20, 70, 230, 20, "Zoomed screen at fixed 200% zoom", 0, 'T');
+	_highQualityAudioCheckbox = new GUI::CheckboxWidget(this, 20, 85, 250, 20, "High quality audio (slower) (reboot)", 0, 'T');
+	_disablePowerOff = new GUI::CheckboxWidget(this, 20, 100, 250, 20, "Disable power off on quit", 0, 'T');
 
-	new GUI::StaticTextWidget(this, 20, 110, 110, 15, "Touch X Offset", GUI::kTextAlignLeft);
-	_touchX = new GUI::SliderWidget(this, 130, 110, 130, 12, 1);
+	new GUI::StaticTextWidget(this, 20, 130, 110, 15, "Touch X Offset", GUI::kTextAlignLeft);
+	_touchX = new GUI::SliderWidget(this, 130, 130, 130, 12, 1);
 	_touchX->setMinValue(-8);
 	_touchX->setMaxValue(+8);
 	_touchX->setValue(0);
 	_touchX->setFlags(GUI::WIDGET_CLEARBG);
 
-	new GUI::StaticTextWidget(this, 20, 125, 110, 15, "Touch Y Offset", GUI::kTextAlignLeft);
-	_touchY = new GUI::SliderWidget(this, 130, 125, 130, 12, 2);
+	new GUI::StaticTextWidget(this, 20, 145, 110, 15, "Touch Y Offset", GUI::kTextAlignLeft);
+	_touchY = new GUI::SliderWidget(this, 130, 145, 130, 12, 2);
 	_touchY->setMinValue(-8);
 	_touchY->setMaxValue(+8);
 	_touchY->setValue(0);
 	_touchY->setFlags(GUI::WIDGET_CLEARBG);
 
-	new GUI::StaticTextWidget(this, 130 + 65 - 10, 140, 20, 15, "0", GUI::kTextAlignCenter);
-	new GUI::StaticTextWidget(this, 130 + 130 - 10, 140, 20, 15, "8", GUI::kTextAlignCenter);
-	new GUI::StaticTextWidget(this, 130 - 10, 140, 20, 15, "-8", GUI::kTextAlignCenter);
+	new GUI::StaticTextWidget(this, 130 + 65 - 10, 160, 20, 15, "0", GUI::kTextAlignCenter);
+	new GUI::StaticTextWidget(this, 130 + 130 - 10, 160, 20, 15, "8", GUI::kTextAlignCenter);
+	new GUI::StaticTextWidget(this, 130 - 10, 160, 20, 15, "-8", GUI::kTextAlignCenter);
 
 #ifdef DS_SCUMM_BUILD
 	_delDialog = new Scumm::SaveLoadChooser("Delete game:", "Delete", false, Scumm::g_scumm);
@@ -99,6 +100,12 @@
 		_highQualityAudioCheckbox->setState(false);
 	}
 
+	if (ConfMan.hasKey("disablepoweroff", "ds")) {
+		_disablePowerOff->setState(ConfMan.getBool("disablepoweroff", "ds"));
+	} else {
+		_disablePowerOff->setState(false);
+	}
+
 	_indyFightCheckbox->setState(DS::getIndyFightState());
 
 	if (ConfMan.hasKey("xoffset", "ds")) {
@@ -120,6 +127,7 @@
 	ConfMan.setBool("unscaled", _unscaledCheckbox->getState(), "ds");
 	ConfMan.setBool("twohundredpercent", _twoHundredPercentCheckbox->getState(), "ds");
 	ConfMan.setBool("22khzaudio", _highQualityAudioCheckbox->getState(), "ds");
+	ConfMan.setBool("disablepoweroff", _disablePowerOff->getState(), "ds");
 	ConfMan.setInt("xoffset", _touchX->getValue(), "ds");
 	ConfMan.setInt("yoffset", _touchY->getValue(), "ds");
 	DS::setOptions();

Modified: scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.h
===================================================================
--- scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.h	2006-10-16 22:20:46 UTC (rev 24351)
+++ scummvm/branches/branch-0-9-0/backends/ds/arm9/source/dsoptions.h	2006-10-16 22:43:43 UTC (rev 24352)
@@ -50,6 +50,7 @@
 	GUI::CheckboxWidget* _twoHundredPercentCheckbox;
 	GUI::CheckboxWidget* _indyFightCheckbox;
 	GUI::CheckboxWidget* _highQualityAudioCheckbox;
+	GUI::CheckboxWidget* _disablePowerOff;
 #ifdef DS_SCUMM_BUILD
 	Scumm::SaveLoadChooser* _delDialog;
 #endif

Modified: scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.cpp	2006-10-16 22:20:46 UTC (rev 24351)
+++ scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.cpp	2006-10-16 22:43:43 UTC (rev 24352)
@@ -25,6 +25,7 @@
 #include "compressor/lz.h"
 
 #define CART_RAM ((vu8 *) (0x0A000000))
+#define SRAM_SAVE_MAX (65533)
 
 DSSaveFile::DSSaveFile() {
 	ptr = 0;
@@ -82,8 +83,7 @@
 	for (int t = 0; t < (int) sizeof(newSave); t++) {
 		((char *) (&newSave))[t] = *(address + t);
 	}
-	
-	
+
 	if (newSave.magic == 0xBEEFCAFE) {
 		newSave.isValid = true;
 
@@ -101,6 +101,7 @@
 		this->saveData = saveData;
 		ownsData = true;
 		ptr = 0;
+
 		return true;
 	}
 	
@@ -314,7 +315,7 @@
 		gbaSave[r].deleteFile();
 	}
 
-	sramBytesFree = 65533;
+	sramBytesFree = SRAM_SAVE_MAX;
 
 	// Try to find saves in save RAM
 	for (int r = 0; r < 8; r++) {
@@ -327,7 +328,7 @@
 }
 
 void DSSaveFileManager::formatSram() {
-	for (int r = 0; r < 65533; r++) {
+	for (int r = 0; r < SRAM_SAVE_MAX; r++) {
 		*(CART_RAM + r) = 0;
 	}
 	
@@ -421,6 +422,7 @@
 void DSSaveFileManager::flushToSaveRAM() {
 	int cartAddr = 1;
 	int s;
+	int extraData = DSSaveFileManager::getExtraData();
 	
 	*((u16 *) (0x4000204)) |= 0x3;
 	
@@ -434,13 +436,13 @@
 		}
 	}
 	
-	if (size <= 65533) {
+	if (size <= SRAM_SAVE_MAX) {
 
-		for (int r = 0; r < 65533; r++) {
+		for (int r = 0; r < SRAM_SAVE_MAX; r++) {
 			*(CART_RAM + r) = 0;
 		}
 		
-		sramBytesFree = 65533;
+		sramBytesFree = SRAM_SAVE_MAX;
 		
 		for (int r = 0; (r < 8); r++) {
 			if (gbaSave[r].isValid() && (!gbaSave[r].isTemp())) {
@@ -459,5 +461,40 @@
 		loadAllFromSRAM();
 		
 	}
+
+	DSSaveFileManager::setExtraData(extraData);
 //	consolePrintf("SRAM free: %d bytes\n", getBytesFree());
 }
+
+void DSSaveFileManager::setExtraData(int data) {
+	// Offset of extra data is 31.  This overlaps the padding and reserved bytes of the first save entry.
+	// which have not been used up until now.  So it should be safe.
+
+	vu8* sram = CART_RAM + 31;
+
+	*(sram + 0) = 0xF0;		// This is an identifier to check
+	*(sram + 1) = 0x0D;		// that extra data is present.
+
+	*(sram + 2) = (data & 0xFF000000) >> 24;		// Now write the actual data
+	*(sram + 3) = (data & 0x00FF0000) >> 16;		// taking care to use single
+	*(sram + 4) = (data & 0x0000FF00) >> 8;			// byte writes (it's an 8-bit bus)
+	*(sram + 5) = (data & 0x000000FF);
+}
+
+bool DSSaveFileManager::isExtraDataPresent() {
+	vu8* sram = CART_RAM + 31;
+
+	// Check for the identifier
+	return ((*(sram + 0) == 0xF0) && (*(sram + 1) == 0x0D));
+}
+
+int DSSaveFileManager::getExtraData() {
+	vu8* sram = CART_RAM + 31;
+
+	if (isExtraDataPresent()) {
+		int value = (*(sram + 2) << 24) | (*(sram + 3) << 16) | (*(sram + 4) << 8) | (*(sram + 5));
+		return value;
+	} else {
+		return 0;
+	}
+}

Modified: scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.h
===================================================================
--- scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.h	2006-10-16 22:20:46 UTC (rev 24351)
+++ scummvm/branches/branch-0-9-0/backends/ds/arm9/source/ramsave.h	2006-10-16 22:43:43 UTC (rev 24352)
@@ -35,14 +35,14 @@
 	bool saveCompressed;
 
 	struct SCUMMSave {
-		u32 magic;
-		bool isValid;
-		bool pad;
-		char name[16];
-		u32 size;
-		u32 compressedSize;
-		u16 pad2;
-		u32 reserved;
+		u32 magic;		// 4
+		bool isValid;	// 5
+		bool pad;		// 6
+		char name[16];	// 22
+		u32 size;		// 26
+		u32 compressedSize; // 30
+		u16 extraMagic;	// 32
+		u32 reserved;	// 36
 	} __attribute__ ((packed));
 	
 	SCUMMSave save;
@@ -89,6 +89,7 @@
 	
 	bool loadFromSaveRAM(vu8* address);
 	int saveToSaveRAM(vu8* address);
+
 	
 	
 	void deleteFile();
@@ -134,6 +135,10 @@
 	
 	void loadAllFromSRAM();
 
+	static bool isExtraDataPresent();
+	static int getExtraData();
+	static void setExtraData(int data);
+
 protected:
 	Common::SaveFile *makeSaveFile(const char *filename, bool saveOrLoad);
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list