ScummVM porting thread

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

ScummVM porting thread

Post by TommyBear »

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: Select all

	#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.
pcostabel
Posts: 11
Joined: Sat Jun 25, 2005 1:19 am

Post by pcostabel »

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...
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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 :)
pcostabel
Posts: 11
Joined: Sat Jun 25, 2005 1:19 am

Post by pcostabel »

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...
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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.
pcostabel
Posts: 11
Joined: Sat Jun 25, 2005 1:19 am

Post by pcostabel »

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.
User avatar
cwbowron
Posts: 76
Joined: Fri May 06, 2005 4:22 am
Location: East Lansing, MI
Contact:

Post by cwbowron »

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: Select all

#define zero	0
rather than

Code: Select all

#define zero	$0
Last edited by cwbowron on Sat Jun 25, 2005 5:54 am, edited 1 time in total.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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 :)
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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: Select all

#define zero	0
rather than

Code: Select all

#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.
User avatar
cwbowron
Posts: 76
Joined: Fri May 06, 2005 4:22 am
Location: East Lansing, MI
Contact:

Post by cwbowron »

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.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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!
pcostabel
Posts: 11
Joined: Sat Jun 25, 2005 1:19 am

Post by pcostabel »

You still have to modify startup.s this way. Might as well change the register names directly.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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: Select all

/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 :)
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Yup, it will be fixed when pspsdk is released which is really, really, really RSN :).
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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: Select all

/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
jboldiga
Posts: 27
Joined: Mon Jun 20, 2005 10:16 am

Post by jboldiga »

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
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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! :)
joostp
Posts: 29
Joined: Fri Jun 17, 2005 8:43 pm

Post by joostp »

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.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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.
joostp
Posts: 29
Joined: Fri Jun 17, 2005 8:43 pm

Post by joostp »

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.
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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.
pcostabel
Posts: 11
Joined: Sat Jun 25, 2005 1:19 am

Post by pcostabel »

I'd love to help on this project. Is there a TODO list yet?
TommyBear
Posts: 50
Joined: Fri Jun 24, 2005 11:21 pm

Post by TommyBear »

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