forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ScummVM porting thread

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 2:38 am    Post subject: ScummVM porting thread Reply with quote

Hi Guys,

Well seeing I've finally gotten that damn toolchain script to work correctly, I've started setting my sights on some stuff to port. I'm starting with ScummVM because I've some work on it before... okay so here we go:

I've gotten the latest snapshot of ScummVM because it contains the PS2 port. I don't know how much of it will be useful to me but anyway. My question is this; in common/scummsys.h you'll find platform specific define. For the playstation 2 we have this:

Code:

   #define SCUMM_NEED_ALIGNMENT
   #define SCUMM_LITTLE_ENDIAN

   #define scumm_stricmp strcasecmp
   #define scumm_strnicmp strncasecmp

   typedef unsigned char byte;
   typedef unsigned char uint8;
   typedef unsigned short uint16;
   typedef unsigned int uint32;
   typedef unsigned int uint;
   typedef unsigned long uint64;
   typedef signed char int8;
   typedef signed short int16;
   typedef signed int int32;
   typedef signed long int64;

   #define START_PACK_STRUCTS pack (push, 1)
   #define END_PACK_STRUCTS    pack(pop)

   #include "backends/ps2/fileio.h"

   #define fopen(a, b)         ps2_fopen(a, b)
   #define fclose(a)         ps2_fclose(a)
   #define fflush(a)         ps2_fflush(a)
   #define fseek(a, b, c)      ps2_fseek(a, b, c)
   #define ftell(a)         ps2_ftell(a)
   #define feof(a)            ps2_feof(a)
   #define fread(a, b, c, d)   ps2_fread(a, b, c, d)
   #define fwrite(a, b, c, d)   ps2_fwrite(a, b, c, d)
   #define fgetc(a)         ps2_fgetc(a)
   #define fgets(a, b, c)      ps2_fgets(a, b, c)
   #define fputc(a, b)         ps2_fputc(a, b)
   #define fputs(a, b)         ps2_fputs(a, b)
   #define fprintf            ps2_fprintf
   #define fsize(a)         ps2_fsize(a)

   extern void ps2_disableHandleCaching(void);


How much of this (barring the fileio stuff) is applicable to the PSP? And speaking of fileio I'll probably need some memorystick code, but I should be able to get that from some of the HB emulators out there...

Tommy.
Back to top
View user's profile Send private message Send e-mail
pcostabel



Joined: 25 Jun 2005
Posts: 11

PostPosted: Sat Jun 25, 2005 3:46 am    Post subject: Reply with quote

Hi,

I was working on the same thing, so I'd be glad to help.
I got ScummVM to compile using the latest toolchain with a null backend by changing config.mak to point to the psp bins and some other minor fixes.
I haven't used the PS2 specific defines, the UNIX defines mostly work.
Now I only need to implement the stdio stuff to get it to link.
I'm not sure if the sdk that is supposedly being released in a few days will have implementations for the stdio functions. If not, it should be pretty easy to write stubs that call the corresponding sce functions.

Since you worked on ScummVM before, what is the proper way of implementing a new backend? I was going to add a directory in the backend subdir and implement the missing functions based on the null backend, but I'm not sure where in the configure/makefile files I should add a new platform...
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 3:58 am    Post subject: Reply with quote

pcostabel wrote:

Since you worked on ScummVM before, what is the proper way of implementing a new backend? I was going to add a directory in the backend subdir and implement the missing functions based on the null backend, but I'm not sure where in the configure/makefile files I should add a new platform...


Well I've never had to write a new backend, most of my work was on the existing win32 layer. But yes that is exactly what the null backend is for. Create a new folder like you said called psp under backends. If you have it compiling the null backend on the psp-gcc, then that is fantastic and we could started on implementing the stdio and actual engine functionality.... we should hook up and start working on it :)
Back to top
View user's profile Send private message Send e-mail
pcostabel



Joined: 25 Jun 2005
Posts: 11

PostPosted: Sat Jun 25, 2005 5:38 am    Post subject: Reply with quote

TommyBear wrote:
If you have it compiling the null backend on the psp-gcc, then that is fantastic and we could started on implementing the stdio and actual engine functionality.... we should hook up and start working on it :)


I guess the first thing to do would be to get CVS access to the project and create a psp branch...
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 5:47 am    Post subject: Reply with quote

Yep. BTW a little OT, but I'm having great difficulty getting my startup.s to preprocess using the regdef defines. Have you gotten this working? I know people keep saying to replace the defines with the literals, but that is not the correct way.

I've included the header using:
.include "/usr/local/pspdev/psp/include/machine/regdef.h"

hmmmmm... I'd rather not hack the startup.s file.

Tommy.
Back to top
View user's profile Send private message Send e-mail
pcostabel



Joined: 25 Jun 2005
Posts: 11

PostPosted: Sat Jun 25, 2005 5:50 am    Post subject: Reply with quote

regdef.h is in C preprocessor format, while startup.s is processed by the assembler preprocessor. In theory renaming it startup.S the assemblre should run cpp on it, but somehow it didn't work for me. I just modified it as everybody else. Keep in mind that startup.s is meant to be modifid to add stubs for the sce functions anyways.
Back to top
View user's profile Send private message
cwbowron



Joined: 06 May 2005
Posts: 76
Location: East Lansing, MI

PostPosted: Sat Jun 25, 2005 5:53 am    Post subject: Reply with quote

TommyBear wrote:
Yep. BTW a little OT, but I'm having great difficulty getting my startup.s to preprocess using the regdef defines. Have you gotten this working? I know people keep saying to replace the defines with the literals, but that is not the correct way.

I've included the header using:
.include "/usr/local/pspdev/psp/include/machine/regdef.h"


I grabbed all the #defines in the regdef.h and removed the $ from the macro and copied the modified text into the startup file so they looked like this

Code:

#define zero   0


rather than

Code:

#define zero   $0


Last edited by cwbowron on Sat Jun 25, 2005 5:54 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 5:54 am    Post subject: Reply with quote

pcostabel wrote:
regdef.h is in C preprocessor format, while startup.s is processed by the assembler preprocessor. In theory renaming it startup.S the assemblre should run cpp on it, but somehow it didn't work for me. I just modified it as everybody else. Keep in mind that startup.s is meant to be modifid to add stubs for the sce functions anyways.


Yes I'm aware of that the stubs go in there but oh what the hell... here we go :)
Back to top
View user's profile Send private message Send e-mail
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 5:58 am    Post subject: Reply with quote

cwbowron wrote:
TommyBear wrote:
Yep. BTW a little OT, but I'm having great difficulty getting my startup.s to preprocess using the regdef defines. Have you gotten this working? I know people keep saying to replace the defines with the literals, but that is not the correct way.

I've included the header using:
.include "/usr/local/pspdev/psp/include/machine/regdef.h"


I grabbed all the #defines in the regdef.h and removed the $ from the macro and copied the modified text into the startup file so they looked like this

Code:

#define zero   0


rather than

Code:

#define zero   $0


uhhh isn't # a comment in assembler? Or did you get gcc to treat it a CPP? What does your gcc call look like?


Last edited by TommyBear on Sat Jun 25, 2005 6:00 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
cwbowron



Joined: 06 May 2005
Posts: 76
Location: East Lansing, MI

PostPosted: Sat Jun 25, 2005 6:00 am    Post subject: Reply with quote

TommyBear wrote:

uhhh isn't # a comment in assembler? Or did you get gcc to treat it a CPP?


I used gcc -xassembler-with-cpp when compiling.

the problem with the original #define's seemed to be the resulting double $$'s in the register names because of the $ in the macros.
Back to top
View user's profile Send private message Visit poster's website
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 6:03 am    Post subject: Reply with quote

cwbowron wrote:
TommyBear wrote:

uhhh isn't # a comment in assembler? Or did you get gcc to treat it a CPP?


I used gcc -xassembler-with-cpp when compiling.

the problem with the original #define's seemed to be the resulting double $$'s in the register names because of the $ in the macros.


Ahhh we have a winner ladies and gentlemen! :) Thank you sir!
Back to top
View user's profile Send private message Send e-mail
pcostabel



Joined: 25 Jun 2005
Posts: 11

PostPosted: Sat Jun 25, 2005 6:42 am    Post subject: Reply with quote

You still have to modify startup.s this way. Might as well change the register names directly.
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 3:42 pm    Post subject: Reply with quote

Where the hell does atan2 live? It's part of the standard math.h but I can't find the library that implements it. Getting undefined atan2 when compiling the actor.cpp.

I've been using psp-gcc to link so I assume it is including libgcc.a which includes atan2??? grrrrrrrrrrrrrrr
Back to top
View user's profile Send private message Send e-mail
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sat Jun 25, 2005 5:04 pm    Post subject: Reply with quote

TommyBear wrote:
Where the hell does atan2 live? It's part of the standard math.h but I can't find the library that implements it. Getting undefined atan2 when compiling the actor.cpp.


-lm.
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Sat Jun 25, 2005 6:17 pm    Post subject: Reply with quote

mrbrown wrote:
TommyBear wrote:
Where the hell does atan2 live? It's part of the standard math.h but I can't find the library that implements it. Getting undefined atan2 when compiling the actor.cpp.


-lm.


Yep, thankfully all this is coming back to me now :) -l* = lib*.a lol. Now I've hit that lovely:

Code:

/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(abort.o): In function `abort':
../../../../../newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(sbrkr.o): In function `_sbrk_r':
../../../../../newlib/libc/reent/sbrkr.c:60: undefined reference to `sbrk'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(signalr.o): In function `_kill_r':
../../../../../newlib/libc/reent/signalr.c:61: undefined reference to `kill'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(signalr.o): In function `_getpid_r':
../../../../../newlib/libc/reent/signalr.c:96: undefined reference to `getpid'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(makebuf.o): In function `__smakebuf':
../../../../../newlib/libc/stdio/makebuf.c:96: undefined reference to `isatty'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(writer.o): In function `_write_r':
../../../../../newlib/libc/reent/writer.c:58: undefined reference to `write'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(closer.o): In function `_close_r':
../../../../../newlib/libc/reent/closer.c:53: undefined reference to `close'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(fstatr.o): In function `_fstat_r':
../../../../../newlib/libc/reent/fstatr.c:62: undefined reference to `fstat'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(lseekr.o): In function `_lseek_r':
../../../../../newlib/libc/reent/lseekr.c:58: undefined reference to `lseek'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(readr.o): In function `_read_r':
../../../../../newlib/libc/reent/readr.c:58: undefined reference to `read'


You're going to fix this soon, aren't you mr brown ;) I feel lazy and I don't want to write stubs :)
Back to top
View user's profile Send private message Send e-mail
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sat Jun 25, 2005 6:48 pm    Post subject: Reply with quote

Yup, it will be fixed when pspsdk is released which is really, really, really RSN :).
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Mon Jun 27, 2005 12:14 am    Post subject: Reply with quote

Ok... I've finally finished the last bit of work for work (we are in a bit of a crunch at the moment), and I'm getting ready to work on a port of ScummVM to PSP.

I've created a psp folder under the backends part of SVM and created a makefile. Currently I'm building the latest toolchain psptoolchain-20050625.tgz and I'm going to start compiling up all the scumm files.

Now the way ScummVM works is that the backends implement the standard fileio stuff like fgets etc and also implement a OEngine interface to draw rects, pixels, blits etc and show/hide the mouse etc. I will be implementing all the PSP specific stuff in here obviously.

This means I'm going to be annoying the hell out of everyone here for info\help (that I can't get out of HB stuff out there already). I will also be releasing the source every now and then in case people want to help\comment etc. Later on this source will hopefully be accepted as a patch by the ScummVM guys....

cya!

Tommy.
Back to top
View user's profile Send private message Send e-mail
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Mon Jun 27, 2005 1:30 am    Post subject: Reply with quote

Does any one know what lib malloc, free etc live in? I need to include stdc++ and I get a whole bunch of undefines for libgcc.a:

Code:

/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/libstdc++.a(del_op.o): In function `operator delete(void*)':
../../../../libstdc++-v3/libsupc++/del_op.cc:49: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__register_frame':
../../gcc/unwind-dw2-fde.c:119: undefined reference to `malloc'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__register_frame_table':
../../gcc/unwind-dw2-fde.c:157: undefined reference to `malloc'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__deregister_frame_info_bases':
../../gcc/unwind-dw2-fde.c:201: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__deregister_frame':
../../gcc/unwind-dw2-fde.c:234: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `start_fde_sort':
../../gcc/unwind-dw2-fde.c:402: undefined reference to `malloc'
../../gcc/unwind-dw2-fde.c:405: undefined reference to `malloc'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `end_fde_sort':
../../gcc/unwind-dw2-fde.c:586: undefined reference to `free'
collect2: ld returned 1 exit status
Back to top
View user's profile Send private message Send e-mail
jboldiga



Joined: 20 Jun 2005
Posts: 27

PostPosted: Mon Jun 27, 2005 4:02 am    Post subject: Reply with quote

I believe you have to write your own mem routines. Here is a link to Yoshihiro's:

http://forums.ps2dev.org/viewtopic.php?t=1983
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Mon Jun 27, 2005 12:19 pm    Post subject: Reply with quote

jboldiga wrote:
I believe you have to write your own mem routines. Here is a link to Yoshihiro's:

http://forums.ps2dev.org/viewtopic.php?t=1983


Excellent! :)
Back to top
View user's profile Send private message Send e-mail
joostp



Joined: 17 Jun 2005
Posts: 29

PostPosted: Mon Jun 27, 2005 9:27 pm    Post subject: Reply with quote

Good to see people interested in (working on) a port of ScummVM.

I was also planning on doing it once pspsdk is out, maybe hack up an initial version next weekend if noone has done anything substantial by then (it's a waste to duplicate effort).

Maybe we could set up a repository somewhere and collaborate on it (not that a basic port/backend would be very much work), and then I can merge it into ScummVM's CVS once it's mature enough.
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Mon Jun 27, 2005 9:40 pm    Post subject: Reply with quote

joostp wrote:
Good to see people interested in (working on) a port of ScummVM.

I was also planning on doing it once pspsdk is out, maybe hack up an initial version next weekend if noone has done anything substantial by then (it's a waste to duplicate effort).

Maybe we could set up a repository somewhere and collaborate on it (not that a basic port/backend would be very much work), and then I can merge it into ScummVM's CVS once it's mature enough.


Sure, I can do that. I have an SVN server. If you have access to SVN tools I can set up a repository.... what do you think?

Tommy.
Back to top
View user's profile Send private message Send e-mail
joostp



Joined: 17 Jun 2005
Posts: 29

PostPosted: Mon Jun 27, 2005 9:47 pm    Post subject: Reply with quote

TommyBear wrote:

Sure, I can do that. I have an SVN server. If you have access to SVN tools I can set up a repository.... what do you think?
Tommy.


Sounds good.
Maybe it would be convenient if you could stop by on IRC, #scummvm on FreeNode so we can discuss some things.
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Mon Jun 27, 2005 11:00 pm    Post subject: Reply with quote

Hi Guys,

ScummVM-PSP has a repository now and we are starting work on it. If anyone here wishes to contribute in any way... tell me here, PM me, there's IRC #scummvm on FreeNode, or email me through my profile etc.

The code is non-existant at the moment but that will change very soon! :)

Tommy.
Back to top
View user's profile Send private message Send e-mail
pcostabel



Joined: 25 Jun 2005
Posts: 11

PostPosted: Tue Jun 28, 2005 2:46 am    Post subject: Reply with quote

I'd love to help on this project. Is there a TODO list yet?
Back to top
View user's profile Send private message
TommyBear



Joined: 24 Jun 2005
Posts: 50

PostPosted: Tue Jun 28, 2005 8:31 pm    Post subject: Reply with quote

pcostabel wrote:
I'd love to help on this project. Is there a TODO list yet?


Hehehe yes :) Write something! Seriously though, there is a TODO in the SVN repository set up for the project email me if you want to help out... But at the moment we are waiting for the official ps2dev.org pspdevkit to be released so we use something a little more concise and supported to base the project on.

Tommy.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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, 2005 phpBB Group