[Scummvm-cvs-logs] SF.net SVN: scummvm: [22584] scummvm/trunk/backends/gp32

wonst719 at users.sourceforge.net wonst719 at users.sourceforge.net
Tue May 23 07:31:21 CEST 2006


Revision: 22584
Author:   wonst719
Date:     2006-05-23 07:30:13 -0700 (Tue, 23 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22584&view=rev

Log Message:
-----------
Update GP32 port. It still doesn't work very well...

Modified Paths:
--------------
    scummvm/trunk/backends/gp32/Makefile
    scummvm/trunk/backends/gp32/gp-fs.cpp
    scummvm/trunk/backends/gp32/gp32_launcher.cpp
    scummvm/trunk/backends/gp32/gp32_osys.cpp
    scummvm/trunk/backends/gp32/gp32std.cpp
    scummvm/trunk/backends/gp32/gp32std_input.cpp
Modified: scummvm/trunk/backends/gp32/Makefile
===================================================================
--- scummvm/trunk/backends/gp32/Makefile	2006-05-23 14:19:38 UTC (rev 22583)
+++ scummvm/trunk/backends/gp32/Makefile	2006-05-23 14:30:13 UTC (rev 22584)
@@ -28,7 +28,7 @@
 			-mno-thumb-interwork \
 			-I$(GPSDK)/include \
 			-g \
-			-O2 \
+			-O \
 			-fomit-frame-pointer
 #			-ffast-math \
 #			-fshort-double

Modified: scummvm/trunk/backends/gp32/gp-fs.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp-fs.cpp	2006-05-23 14:19:38 UTC (rev 22583)
+++ scummvm/trunk/backends/gp32/gp-fs.cpp	2006-05-23 14:30:13 UTC (rev 22584)
@@ -46,8 +46,64 @@
 
 	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
 	virtual AbstractFilesystemNode *parent() const;
+	virtual AbstractFilesystemNode *child(const String &name) const;
 };
 
+#define MAX_PATH_SIZE 256
+
+const char gpRootPath[] = "gp:\\";
+//char gpCurrentPath[MAX_PATH_SIZE] = "gp:\\";		// must end with '\'
+
+int gpMakePath(const char *path, char *convPath) {
+	// copy root or current directory
+	const char *p;
+	if ((*path == '/') || (*path == '\\')) {
+		path++;
+		p = gpRootPath;
+		while (*p)
+			*convPath++ = *p++;
+	}// else
+	//	p = gpCurrentPath;
+
+	//while (*p)
+	//	*convPath++ = *p++;
+
+	// add filenames/directories. remove "." & "..", replace "/" with "\"
+	do {
+		switch (*path) {
+		case 0:
+		case '/':
+		case '\\':
+			if (*(convPath - 1) == '\\') {
+				// already ends with '\'
+			} else if ((*(convPath - 2) == '\\') && (*(convPath - 1) == '.')) {
+				convPath--;	// remove '.' and end with '\'
+			} else if ((*(convPath - 3) == '\\') && (*(convPath - 2) == '.') && (*(convPath - 1) == '.')) {
+				convPath -= 3;	// remove "\.."
+				if (*(convPath - 1) == ':')
+					*convPath++ = '\\';	// "gp:" -> "gp:\"
+				else
+					while (*(convPath - 1) != '\\')
+						convPath--;	// remove one directory and end with '\'
+			} else {
+				*convPath++ = '\\';	// just add '\'
+			}
+			break;
+
+		default:
+			*convPath++ = *path;
+			break;
+		}
+	} while (*path++);
+
+	*convPath = '\\';
+
+	//  *--convPath = 0;	// remove last '\' and null-terminate
+	*convPath = 0;	// remove last '\' and null-terminate
+
+	return 0;
+}
+
 AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
 	return AbstractFilesystemNode::getRoot();
 }
@@ -68,14 +124,20 @@
 }
 
 GP32FilesystemNode::GP32FilesystemNode(const String &path) {
-	_path = path;
-	const char *dsplName = NULL, *pos = path.c_str();
+	const char *dsplName = NULL, *pos = NULL;
+	char convPath[256];
+
+	gpMakePath(path.c_str(), convPath);
+
+	_path = convPath;
+
+	pos = convPath;
 	while (*pos)
 		if (*pos++ == '\\')
 			dsplName = pos;
-			
-	BP("path name: %s", path.c_str());
 
+	BP("FS: path name: %s", path.c_str());
+
 	if (strcmp(path.c_str(), "gp:\\") == 0) {
 		_isRoot = true;
 		_displayName = "GP32 Root";
@@ -89,9 +151,13 @@
 	assert(_isDirectory);
 
 	GPDIRENTRY dirEntry;
+	GPFILEATTR attr;
+
+	GP32FilesystemNode entry;
+
 	uint32 read;
 
-	if (mode == AbstractFilesystemNode::kListAll)
+	if (mode == FilesystemNode::kListAll)
 		LP("listDir(kListAll)");
 	else
 		LP("listDir(kListDirectoriesOnly)");
@@ -102,19 +168,16 @@
 	while (GpDirEnumList(listDir.c_str(), startIdx++, 1, &dirEntry, &read)  == SM_OK) {
 		if (dirEntry.name[0] == '.')
 			continue;
-		GP32FilesystemNode entry;
 		entry._displayName = dirEntry.name;
 		entry._path = _path;
 		entry._path += dirEntry.name;
 
-		GPFILEATTR attr;
-		String fileName(entry._path);
-		GpFileAttr(fileName.c_str(), &attr);
-		entry._isDirectory = attr.attr & (1<<4);
+		GpFileAttr(entry._path.c_str(), &attr);
+		entry._isDirectory = attr.attr & (1 << 4);
 
 		// Honor the chosen mode
-		if ((mode == kListFilesOnly && entry._isDirectory) ||
-			(mode == kListDirectoriesOnly && !entry._isDirectory))
+		if ((mode == FilesystemNode::kListFilesOnly && entry._isDirectory) ||
+			(mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory))
 			continue;
 
 		if (entry._isDirectory)
@@ -126,58 +189,45 @@
 
 	return true;
 }
-/*
-AbstractFilesystemNode *GP32FilesystemNode::parent() const {
-	if (_isRoot)
-		return new GP32FilesystemNode(this);
 
-	GP32FilesystemNode *p = new GP32FilesystemNode();
-
-	const char *slash = NULL;
-	const char *cnt = _path.c_str();
-
-	while (*cnt) {
-		if (*cnt == '\\')
-			slash = cnt;
-		cnt++;
-	}
-
-	p->_path = String(_path.c_str(), slash - _path.c_str());
-	p->_isDirectory = true;
-	p->_displayName = slash + 1;
-	return p;
-}
-*/
-
 const char *lastPathComponent(const Common::String &str) {
 	const char *start = str.c_str();
 	const char *cur = start + str.size() - 2;
 
-	while (cur > start && *cur != '\\') { //ph0x
+	while (cur > start && *cur != '\\') {
 		--cur;
 	}
 
-	return cur+1;
+	return cur + 1;
 }
 
 AbstractFilesystemNode *GP32FilesystemNode::parent() const {
+	if(_isRoot)
+		return 0;
 
 	GP32FilesystemNode *p = new GP32FilesystemNode();
-
-	// Root node is its own parent. Still we can't just return this
-	// as the GUI code will call delete on the old node.
-	if (_path != "gp:\\") {
+	if (_path.size() > 4) {
 		const char *start = _path.c_str();
 		const char *end = lastPathComponent(_path);
 
-		p->_path = Common::String(start, end - start);
+		p->_path = String(start, end - start);
+		p->_isDirectory = true;
 		p->_displayName = lastPathComponent(p->_path);
-		p->_isRoot = true;
-	} else {
 		p->_isRoot = false;
-		p->_path = _path;
-		p->_displayName = _displayName;
 	}
-	p->_isDirectory = true;
+
 	return p;
 }
+
+AbstractFilesystemNode *GP32FilesystemNode::child(const String &name) const {
+	// FIXME: Pretty lame implementation! We do no error checking to speak
+	// of, do not check if this is a special node, etc.
+	assert(_isDirectory);
+	String newPath(_path);
+	if (_path.lastChar() != '\\')
+		newPath += '\\';
+	newPath += name;
+	GP32FilesystemNode *p = new GP32FilesystemNode(newPath);
+
+	return p;
+}

Modified: scummvm/trunk/backends/gp32/gp32_launcher.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp32_launcher.cpp	2006-05-23 14:19:38 UTC (rev 22583)
+++ scummvm/trunk/backends/gp32/gp32_launcher.cpp	2006-05-23 14:30:13 UTC (rev 22584)
@@ -52,7 +52,7 @@
 	g_vars.fmQuality = currentSetting[2];
 	g_vars.sampleRate = sampleTable[currentSetting[3]];
 
-	if (!file.open("scummvm.cfg", Common::File::kFileWriteMode, "gp:\\gpetc\\")) {
+	if (!file.open("gp:\\gpetc\\scummvm.cfg", Common::File::kFileWriteMode)) {
 		return;
 	}
 	file.writeByte(currentSetting[0]);
@@ -64,14 +64,14 @@
 
 void readConfigVars() {
 	Common::File file;
-	if (!file.exists("scummvm.cfg", "gp:\\gpetc\\")) {
+	if (!file.exists("gp:\\gpetc\\scummvm.cfg")) {
 		currentSetting[0] = 2;
 		currentSetting[1] = 5;
 		currentSetting[2] = 1;
 		currentSetting[3] = 1;
 		writeConfigVars();
 	} else {
-		if (!file.open("scummvm.cfg", Common::File::kFileReadMode, "gp:\\gpetc\\")) {
+		if (!file.open("gp:\\gpetc\\scummvm.cfg", Common::File::kFileReadMode)) {
 			return;
 		}
 		currentSetting[0] = file.readByte();

Modified: scummvm/trunk/backends/gp32/gp32_osys.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp32_osys.cpp	2006-05-23 14:19:38 UTC (rev 22583)
+++ scummvm/trunk/backends/gp32/gp32_osys.cpp	2006-05-23 14:30:13 UTC (rev 22584)
@@ -136,12 +136,12 @@
 }
 
 int16 OSystem_GP32::getHeight() {
-	NP("OSys::getHeight()");
+	//NP("OSys::getHeight()");
 	return _screenHeight;
 }
 
 int16 OSystem_GP32::getWidth() {
-	NP("OSys::getWidth()");
+	//NP("OSys::getWidth()");
 	return _screenWidth;
 }
 
@@ -209,6 +209,7 @@
 void OSystem_GP32::updateScreen() {
 	uint16 *buffer;
 	//TODO: adjust shakePos
+	NP("updateScreen");
 
 	// draw gamescreen
 	buffer = &_tmpScreen[240 - _screenHeight];
@@ -244,13 +245,12 @@
 						gpd_drawPixel16(_tmpScreen, mX + x, mY + y, _currentPalette[_mouseBuf[y * _mouseWidth + x]]);
 			}
 		}
-		
+
 	//TODO: draw softkeyboard
-
-	gp_flipScreen();
-	_hwScreen = frameBuffer1;
-	_tmpScreen = frameBuffer2;
-	//memcpy(_hwScreen, _tmpScreen, LCD_WIDTH * LCD_HEIGHT * sizeof(uint16));
+	//gp_flipScreen();
+	//_hwScreen = frameBuffer1;
+	//_tmpScreen = frameBuffer2;
+	memcpy(_hwScreen, _tmpScreen, LCD_WIDTH * LCD_HEIGHT * sizeof(uint16));
 }
 
 void OSystem_GP32::setShakePos(int shakeOffset) {
@@ -258,11 +258,13 @@
 }
 
 void OSystem_GP32::showOverlay() {
+	NP("OSys::showOverlay()");
 	_overlayVisible = true;
 	clearOverlay();
 }
 
 void OSystem_GP32::hideOverlay() {
+	NP("OSys::hideOverlay()");
 	_overlayVisible = false;
 	clearOverlay();
 	_forceFull = true;
@@ -295,6 +297,7 @@
 }
 
 void OSystem_GP32::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
+	NP("OSys::copyRectToOverlay()");
 	OverlayColor *dst = (OverlayColor *)_overlayBuffer + y * _overlayWidth + x;
 	do {
 		memcpy(dst, buf, w * sizeof(uint16));
@@ -304,12 +307,12 @@
 }
 
 int16 OSystem_GP32::getOverlayHeight() {
-	NP("OSys::getOverlayHeight()");
+	//NP("OSys::getOverlayHeight()");
 	return getHeight();
 }
 
 int16 OSystem_GP32::getOverlayWidth() {
-	NP("OSys::getOverlayWidth()");
+	//NP("OSys::getOverlayWidth()");
 	return getWidth();
 }
 
@@ -343,7 +346,7 @@
 }
 
 void OSystem_GP32::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
-	//NP("OSys::setMouseCursor()");
+	NP("OSys::setMouseCursor()");
 	_mouseWidth = w;
 	_mouseHeight = h;
 
@@ -443,6 +446,7 @@
 }
 
 bool OSystem_GP32::pollEvent(Event &event) {
+	NP("OSys::pollEvent()");
 	GP32BtnEvent ev;
 
 	handleKbdMouse();
@@ -629,20 +633,20 @@
 }
 
 OSystem::MutexRef OSystem_GP32::createMutex() {
-	NP("OSys::createMutex()");
+//	NP("OSys::createMutex()");
 	return NULL;
 }
 
 void OSystem_GP32::lockMutex(MutexRef mutex) {
-	NP("OSys::lockMutex()");
+//	NP("OSys::lockMutex()");
 }
 
 void OSystem_GP32::unlockMutex(MutexRef mutex) {
-	NP("OSys::unlockMutex()");
+//	NP("OSys::unlockMutex()");
 }
 
 void OSystem_GP32::deleteMutex(MutexRef mutex) {
-	NP("OSys::deleteMutex()");
+//	NP("OSys::deleteMutex()");
 }
 
 bool OSystem_GP32::setSoundCallback(SoundProc proc, void *param) {
@@ -650,8 +654,8 @@
 
 	GPSOUNDBUF gpSoundBuf;
 
-	ConfMan.set("FM_medium_quality", (g_vars.fmQuality == FM_QUALITY_MED));
-	ConfMan.set("FM_high_quality", (g_vars.fmQuality == FM_QUALITY_HI));
+	ConfMan.setBool("FM_medium_quality", (g_vars.fmQuality == FM_QUALITY_MED));
+	ConfMan.setBool("FM_high_quality", (g_vars.fmQuality == FM_QUALITY_HI));
 	//ConfMan.set("output_rate", (int)g_vars.sampleRate);
 
 	if (ConfMan.hasKey("output_rate"))

Modified: scummvm/trunk/backends/gp32/gp32std.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp32std.cpp	2006-05-23 14:19:38 UTC (rev 22583)
+++ scummvm/trunk/backends/gp32/gp32std.cpp	2006-05-23 14:30:13 UTC (rev 22584)
@@ -57,7 +57,7 @@
 
 	if (debnext == DEBUG_MAX)
 		debnext = 0;
-	gp_fillRect(frameBuffer1, 0, 243 - (DEBUG_MAX * 8) - 4, 320, (DEBUG_MAX * 10), 0);
+	gp_fillRect(frameBuffer1, 0, 243 - (DEBUG_MAX * 8) - 4, 320, (DEBUG_MAX * 8), 0);
 	
 	for (deb = debnext, deba = 0; deb < DEBUG_MAX; deb++, deba++) {
 		//gp_fillRect(frameBuffer1, 0, (243 - (DEBUG_MAX * 8) - 4) + 8 * deba, 320, 8, 0);
@@ -73,80 +73,17 @@
 
 //////////////////
 //File functions
-// FOR LATER USE
-/*
-#define SM_PATH_SIZE		256
 
-const char smRootPath[] = "gp:\\";
-char smCurrentPath[SM_PATH_SIZE] = "gp:\\";		// must end with '\'
-
-int smMakePath(const char *path, char *smPath) {
-  // copy root or current directory
-  {
-    const char *p;
-    if ((*path == '/') || (*path == '\\'))
-    {
-      path++;
-      p = smRootPath;
-    }
-    else
-      p = smCurrentPath;
-    while (*p) *smPath++ = *p++;
-  }
-
-  // add filenames/directories. remove "." & ".."
-  do
-  {
-    switch (*path)
-    {
-    case 0:
-    case '/':
-    case '\\':
-      if (*(smPath-1) == '\\')
-      {
-        // already ends with '\'
-      }
-      else if ((*(smPath-1) == '.') && (*(smPath-2) == '\\'))
-      {
-        smPath--;	// remove '.' and end with '\'
-      }
-      else if ((*(smPath-1) == '.') && (*(smPath-2) == '.') && (*(smPath-3) == '\\'))
-      {
-        smPath -= 3;	// remove "\.."
-        if (*(smPath-1) == ':') *smPath++ = '\\';	// "dev0:" -> "dev0:\"
-        else while (*(smPath-1) != '\\') smPath--;	// remove one directory and end with '\'
-      }
-      else
-      {
-        *smPath++ = '\\';	// just add '\'
-      }
-      break;
-
-    default:
-      *smPath++ = *path;
-      break;
-    }
-  }
-  while (*path++);
-  
-  *smPath = '\\';
-
-//  *--smPath = 0;	// remove last '\' and null-terminate
-  *smPath = 0;	// remove last '\' and null-terminate
-
-  return 0;
-}
-*/
 GPFILE *gp_fopen(const char *fileName, const char *openMode) {
 	//FIXME: allocation, mode, malloc -> new
 	uint32 mode;
 	GPFILE *file;
 	ERR_CODE err;
-	char s[256];
+	char tempPath[256];
 
 	if (!strchr(fileName, '.')) {
-		sprintf(s, "%s.", fileName);
-		fileName = s;
+		sprintf(tempPath, "%s.", fileName);
+		fileName = tempPath;
 	}
 
 	file = (GPFILE *)malloc(sizeof(GPFILE));
@@ -388,14 +325,21 @@
 // GP32 stuff
 //////////////////////////////////////////////////
 static char usedMemStr[16];
-int gUsedMem = 0;
+int gUsedMem = 1024 * 1024;
 
+//#define CLEAN_MEMORY_WITH_0xE7
+//#define CHECK_FREE_MEMORY
+
 void *operator new(size_t size) {
 //	printf("BP:operator new(%d)", size);
+	void *ptr = malloc(size);
 
-	void *ptr = memset(malloc(size), 0xE7, size);
-
-#if 0
+#if defined(CLEAN_MEMORY_WITH_0xE7)
+	if(ptr != NULL) {
+		memset(ptr, 0xE7, size);
+	}
+#endif
+#if defined(CHECK_FREE_MEMORY)
 	// Check free memory.
 	gUsedMem = ((int)(ptr) + size) - 0xc000000;
 
@@ -404,7 +348,7 @@
 	gp_fillRect(frameBuffer1, 0, 0, 64, 12, 0);
 	gp_textOut(frameBuffer1, 0, 0, usedMemStr, 0xfffff);
 #endif
-	
+
 	return ptr;
 }
 

Modified: scummvm/trunk/backends/gp32/gp32std_input.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp32std_input.cpp	2006-05-23 14:19:38 UTC (rev 22583)
+++ scummvm/trunk/backends/gp32/gp32std_input.cpp	2006-05-23 14:30:13 UTC (rev 22584)
@@ -200,7 +200,7 @@
 	}
 
 	eventQueue.get(ev);
-//	GPDEBUG("Event poll %d %d", ev->type, ev->button);
+	GPDEBUG("Event poll %d %d", ev->type, ev->button);
 
 	return true;
 }


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