Enhancing mass: support and some other notes

Subforum for discussion and help with ScummVM's PlayStation 2 port

Moderator: ScummVM Team

Post Reply
vetoed615
Posts: 6
Joined: Tue Jul 08, 2008 2:15 pm

Enhancing mass: support and some other notes

Post by vetoed615 »

Information for the port maintainers:
- Do not treat mass: as a read-only device. On the contrary, it's better to keep all the savefiles and the configuration file there when it's available.
- Calling driveStop() on a slim PS2 with no disc in drive results in that - http://sourceforge.net/tracker/index.ph ... tid=418820.
- PAL_NTSC_FLAG doesn't work with a slim PS2.
- SD TVs have a significant overscan (dispPosY = 88, _tvHeight = 480 for me, and that's PAL) - so that should be configurable or it should default to some safe values.
- Checking for EISDIR won't work with mass:.
- Quit should call mc0:/BOOT/BOOT.ELF.
- TocManager is buggy and the whole caching system needs a rewrite.

Some fixes:
Ps2UsbSaveFileManager, to be used instead of Ps2SaveFileManager when launched from mass: (needs an intermediate abstract class). http://rapidshare.com/files/129739353/s ... b.zip.html

Code: Select all

backends\fs\ps2\ps2-fs.cpp:
	in class Ps2FilesystemNode : public AbstractFilesystemNode
		virtual bool isWritable() const {
			if (_path[0] == 'm') // mass and mc
				return true;
			else
				return false;
		}
	
	in bool Ps2FilesystemNode::getDirectoryFlag(const char *path)
		else if (strncmp(path, "mass:", 5) == 0) {
			fd = fio.dopen(path);
			if (fd >= 0) {
				dbg_printf("Node is a dir\n");
				fio.dclose(fd);
				return true;
			} else
				dbg_printf("Node is not a dir (%d)\n", fd);


base\commandLine.cpp:
	In void registerDefaults()
		#ifdef __PLAYSTATION2__
		#include "backends/platform/ps2/systemps2.h"
			char savePath[MAXPATHLEN];
			((OSystem_PS2*)g_system)->makeSavePath(savePath);
			ConfMan.registerDefault("savepath", savePath);
		#endif //#ifdef __PLAYSTATION2__


gui\options.cpp:
	remove __PLAYSTATION2__ from #if !( defined(__DC__) || defined(__GP32__) || defined(__PLAYSTATION2__) )


backends\platform\ps2\irxboot.h:
	add MASS to enum BootDevice


backends\platform\ps2\irxboot.cpp:
	to detectBootPath():
		if (strncasecmp(elfPath, "mass", 4) == 0)
			device = MASS;


backends\platform\ps2\systemps2.h:
	to class OSystem_PS2 : public OSystem
		void loadBootElf();
		void makeSavePath(char *dest);
		char szElfPath[0x100];


backends\platform\ps2\systemps2.cpp
	at the end of OSystem_PS2::startIrxModules():
		if(_usbMassLoaded) {
			int access = 0;
			while&#40;access <= 0&#41; access = fioDopen&#40;"mass&#58;"&#41;;
			fioDclose&#40;access&#41;;
		&#125;

	in OSystem_PS2&#58;&#58;OSystem_PS2&#40;&#41;&#58;
		int numModules = loadIrxModules&#40;_bootDevice, szElfPath, &modules&#41;;
	
	at the end of OSystem_PS2&#58;&#58;OSystem_PS2&#40;&#41;&#58;
		assert&#40;mcInit&#40;MC_TYPE_MC&#41; >= 0&#41;;
	
	at the end of OSystem_PS2&#58;&#58;quit&#40;&#41;
		loadBootElf&#40;&#41;;
	
	void OSystem_PS2&#58;&#58;makeConfigPath&#40;char *dest&#41; &#123;
		switch &#40;_bootDevice&#41; &#123;
		case CDROM&#58;
			strcpy&#40;dest, "cdfs&#58;/ScummVM.ini"&#41;;
			break;
	
		case HOST&#58;
		case MASS&#58;
			sprintf&#40;dest, "%sscummvm.ini", szElfPath&#41;;
			break;
	
		case OTHER&#58;
		case UNKNOWN&#58;
		default&#58;
			strcpy&#40;dest, "mc0&#58;ScummVM/scummvm.ini"&#41;;
		&#125;
	&#125;
	
	void OSystem_PS2&#58;&#58;makeSavePath&#40;char *dest&#41; &#123;
		switch &#40;_bootDevice&#41; &#123;
		case HOST&#58;
		case MASS&#58;
			strcpy&#40;dest, szElfPath&#41;;
			break;
	
		case CDROM&#58;
		case OTHER&#58;
		case UNKNOWN&#58;
		default&#58;
			strcpy&#40;dest, "mc0&#58;ScummVM"&#41;;
		&#125;
	&#125;
	
	typedef struct &#123; // struct definition for ELF object header
		u8	ident&#91;16&#93;;
		u16	type;
		u16	machine;
		u32	version;
		u32	entry;
		u32	phoff;
		u32	shoff;
		u32	flags;
		u16	ehsize;
		u16	phentsize;
		u16	phnum;
		u16	shentsize;
		u16	shnum;
		u16	shstrndx;
	&#125; elf_header_t;
	
	typedef struct &#123; // struct definition for ELF program section header
		u32	type;
		u32	offset;
		void*	vaddr;
		u32	paddr;
		u32	filesz;
		u32	memsz;
		u32	flags;
		u32	align;
	&#125; elf_pheader_t;
	
	
	void OSystem_PS2&#58;&#58;loadBootElf&#40;void&#41; &#123; 
		char* filename = "mc0&#58;/BOOT/BOOT.ELF";
		u8* boot_elf;
		elf_header_t* eh;
		elf_pheader_t* eph;
		int hFile = 0;
		int nSize, i;
		int argc;
		char* argv&#91;1&#93;;
	
		boot_elf = &#40;u8*&#41; 0x1800000;
		eh = &#40;elf_header_t*&#41; boot_elf;
	
		hFile = fioOpen&#40;filename, O_RDONLY&#41;;
		if&#40;hFile < 0&#41;
			LoadExecPS2&#40;"rom0&#58;OSDSYS", 0, NULL&#41;;
	
		fioRead&#40;hFile, boot_elf, 52&#41;;
		if&#40;&#40;_lw&#40;&#40;u32&#41; &eh->ident&#41; != 0x464c457f&#41; || eh->type != 2&#41;
			LoadExecPS2&#40;"rom0&#58;OSDSYS", 0, NULL&#41;;
	
		fioLseek&#40;hFile, eh->phoff, SEEK_SET&#41;;
	
		eph = &#40;elf_pheader_t*&#41; &#40;boot_elf + eh->phoff&#41;;
		nSize = eh->phnum * eh->phentsize;
	
		fioRead&#40;hFile, &#40;void*&#41; eph, nSize&#41;;
	
		for&#40;i = 0; i < eh->phnum; i++&#41; &#123;
			if&#40;eph&#91;i&#93;.type != 1&#41;
				continue;
				
			fioLseek&#40;hFile, eph&#91;i&#93;.offset, SEEK_SET&#41;;
			fioRead&#40;hFile, eph&#91;i&#93;.vaddr, eph&#91;i&#93;.filesz&#41;;
			
			if&#40;eph&#91;i&#93;.memsz > eph&#91;i&#93;.filesz&#41;
				memset&#40;&#40;unsigned char*&#41;eph&#91;i&#93;.vaddr + eph&#91;i&#93;.filesz, 0, eph&#91;i&#93;.memsz - eph&#91;i&#93;.filesz&#41;;
		&#125;
	
		fioClose&#40;hFile&#41;;
		fioExit&#40;&#41;;
	
		padEnd&#40;&#41;;
		cdvdInit&#40;CDVD_EXIT&#41;;
		SifIopReset&#40;NULL, 0&#41;;
		SifExitRpc&#40;&#41;;
		while &#40;!SifIopSync&#40;&#41;&#41;;
		SifInitRpc&#40;0&#41;;
		cdvdExit&#40;&#41;;
		SifExitRpc&#40;&#41;;
		FlushCache&#40;0&#41;;
		SifLoadFileExit&#40;&#41;;
	
		argc = 1;
		argv&#91;0&#93; = filename;
		ExecPS2&#40;&#40;void*&#41; eh->entry, 0, argc, argv&#41;;
	&#125;


And here is an updated version based on the 0.11.1. But it's PAL only, mass: only and scumm, saga and sky engines only. http://rapidshare.com/files/129737311/scummvm.zip.html
fingolfin
Retired
Posts: 1452
Joined: Wed Sep 21, 2005 4:12 pm

Post by fingolfin »

May I suggest that you email the PS2 maintainer, and discuss this with him? Much better than to post here, where he will probably never ever see what you wrote...
Post Reply