ScummVM logo Forum Index - ScummVM website - Contact us - Buy Supported Games: GOG.comDotEmu  Rules - Search - Register - Login curved edge
Folder Forum Index > PlayStation 2 Port > Enhancing mass: support and some other notes
Enhancing mass: support and some other notes
  Author    Thread Reply to topic
vetoed615



Joined: 08 Jul 2008
Posts: 6
Enhancing mass: support and some other notes 

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.php?func=detail&aid=1906077&group_id=37116&atid=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/savefilemgr_usb.zip.html

code:

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(access <= 0) access = fioDopen("mass:");
         fioDclose(access);
      }

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




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
 Reply with quote  
Post Tue Jul 15, 2008 7:03 am 
 View user's profile Send private message
fingolfin



Joined: 21 Sep 2005
Posts: 1466
 

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...

 Reply with quote  
Post Tue Jul 15, 2008 8:05 am 
 View user's profile Send private message
  Display posts from previous:      
Reply to topic

Forum Jump:
 



Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Powered by phpBB © 2001, 2006 phpBB Group
Forum design by ScummVM team, icons by raina
curved edge   curved edge