| View previous topic :: View next topic |
| Author |
Message |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 2:38 am Post subject: ScummVM porting thread |
|
|
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 |
|
 |
pcostabel
Joined: 25 Jun 2005 Posts: 11
|
Posted: Sat Jun 25, 2005 3:46 am Post subject: |
|
|
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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 3:58 am Post subject: |
|
|
| 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 |
|
 |
pcostabel
Joined: 25 Jun 2005 Posts: 11
|
Posted: Sat Jun 25, 2005 5:38 am Post subject: |
|
|
| 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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 5:47 am Post subject: |
|
|
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 |
|
 |
pcostabel
Joined: 25 Jun 2005 Posts: 11
|
Posted: Sat Jun 25, 2005 5:50 am Post subject: |
|
|
| 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 |
|
 |
cwbowron

Joined: 06 May 2005 Posts: 76 Location: East Lansing, MI
|
Posted: Sat Jun 25, 2005 5:53 am Post subject: |
|
|
| 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
rather than
Last edited by cwbowron on Sat Jun 25, 2005 5:54 am; edited 1 time in total |
|
| Back to top |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 5:54 am Post subject: |
|
|
| 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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 5:58 am Post subject: |
|
|
| 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
rather than
|
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 |
|
 |
cwbowron

Joined: 06 May 2005 Posts: 76 Location: East Lansing, MI
|
Posted: Sat Jun 25, 2005 6:00 am Post subject: |
|
|
| 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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 6:03 am Post subject: |
|
|
| 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 |
|
 |
pcostabel
Joined: 25 Jun 2005 Posts: 11
|
Posted: Sat Jun 25, 2005 6:42 am Post subject: |
|
|
| You still have to modify startup.s this way. Might as well change the register names directly. |
|
| Back to top |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 3:42 pm Post subject: |
|
|
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 |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Jun 25, 2005 5:04 pm Post subject: |
|
|
| 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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Sat Jun 25, 2005 6:17 pm Post subject: |
|
|
| 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 |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Jun 25, 2005 6:48 pm Post subject: |
|
|
| Yup, it will be fixed when pspsdk is released which is really, really, really RSN :). |
|
| Back to top |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Mon Jun 27, 2005 12:14 am Post subject: |
|
|
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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Mon Jun 27, 2005 1:30 am Post subject: |
|
|
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 |
|
 |
jboldiga
Joined: 20 Jun 2005 Posts: 27
|
|
| Back to top |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Mon Jun 27, 2005 12:19 pm Post subject: |
|
|
Excellent! :) |
|
| Back to top |
|
 |
joostp
Joined: 17 Jun 2005 Posts: 29
|
Posted: Mon Jun 27, 2005 9:27 pm Post subject: |
|
|
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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Mon Jun 27, 2005 9:40 pm Post subject: |
|
|
| 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 |
|
 |
joostp
Joined: 17 Jun 2005 Posts: 29
|
Posted: Mon Jun 27, 2005 9:47 pm Post subject: |
|
|
| 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 |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Mon Jun 27, 2005 11:00 pm Post subject: |
|
|
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 |
|
 |
pcostabel
Joined: 25 Jun 2005 Posts: 11
|
Posted: Tue Jun 28, 2005 2:46 am Post subject: |
|
|
| I'd love to help on this project. Is there a TODO list yet? |
|
| Back to top |
|
 |
TommyBear
Joined: 24 Jun 2005 Posts: 50
|
Posted: Tue Jun 28, 2005 8:31 pm Post subject: |
|
|
| 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 |
|
 |
|