Page 1 of 1

New Starsim version (tutorial and test program)

Posted: Wed Dec 29, 2004 12:23 am
by Shine
I've updated the Starsim demo, you can download it from http://www.frank-buss.de/ps2/index.html

A screenshot (the code for generating screenshots like this is integrated):

Image

The original version uses DMA transfer for writing the general GS registers and lots of assembler for VSync counting, DMA handling and graphics initialization. This might be fast, but it is not good for learning the PS2.

My version uses only one assembler function for writing to a general GS register, which could be written in C, too, but the compiler doesn't generate nice code for the 128 bit operations, so I've implemented it in assember. All the rest is C and easy to understand. No DMA transfer and no interrupt handler are used. You can use this program for learning and quick testing how to use the GS registers, without the need to think about how to setup the GIF tag etc. When you know how to program the GS, you can optimize it later with DMA memory transfer.

Another change is the resolution. For PAL for example I've read that the number of visible lines is 576, which the program now uses and now the stars fills my whole TV screen :-)

Posted: Fri Jan 28, 2005 3:26 pm
by Neil Stevens
Not quite working here. It compiles but doesn't link:

Code: Select all

ee-gcc -D_EE -O2 -G0 -Wall  -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -I/usr/local/ps2dev/ee/include 
-I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -c main.c -o main.o
ee-gcc -D_EE -O2 -G0 -Wall  -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -I/usr/local/ps2dev/ee/include -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -c gs.c -o gs.o
ee-gcc -D_EE -O2 -G0 -Wall  -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -I/usr/local/ps2dev/ee/include -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -c hershey.c -o hershey.o
ee-gcc -D_EE -O2 -G0 -Wall  -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -I/usr/local/ps2dev/ee/include -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -c screenshot.c -o screenshot.o
ee-gcc -xassembler-with-cpp -c  setgsreg.s -o setgsreg.o
ee-gcc -mno-crt0 -T/usr/local/ps2dev/ps2sdk/ee/startup/linkfile -L/usr/local/ps2dev/ps2sdk/ee/lib  \
        -o starsim.elf /usr/local/ps2dev/ps2sdk/ee/startup/crt0.o main.o gs.o hershey.o screenshot.o setgsreg.o -L/usr/local/ps2dev/ee/lib -L/usr/local/ps2dev/ps2sdk/ee/lib -lkernel -lsyscall -lc
/usr/local/ps2dev/ps2sdk/ee/lib/libc.a(__alloc_internals.o)(.text+0xa8): In function `_ps2sdk_alloc_unlock':
src/alloc.c: undefined reference to `SignalSema'
/usr/local/ps2dev/ps2sdk/ee/lib/libc.a(npmPuts.o)(.text+0xb4): In function `npm_puts_init':
src/xprintf.c: undefined reference to `SignalSema'
/usr/local/ps2dev/ps2sdk/ee/lib/libc.a(npmPuts.o)(.text+0x178): In function `npmPuts':
src/xprintf.c: undefined reference to `SignalSema'
/usr/local/ps2dev/ps2sdk/ee/lib/libc.a(sbrk.o)(.text+0x44): In function `ps2_sbrk':
src/sbrk.c: undefined reference to `EndOfHeap'
collect2: ld returned 1 exit status
gmake: *** [starsim.elf] Error 1
Do I just have an old version of the libraries?

Posted: Fri Jan 28, 2005 9:29 pm
by cory1492
It looks like the sample is using the old ps2lib...

edit: I added the ps2lib (partially built with make) from the cvs and a new environment variable PS2LIB pointing to it and the starsim builds fine. now to test it out and see if I had enough of the lib built for it to function fully...

Thanks for the new code to gawk at!

Posted: Fri Jan 28, 2005 10:38 pm
by Shine
cory1492 wrote:It looks like the sample is using the old ps2lib...
I don't know. I have downloaded this packet for Windows: http://ps2dev.org/kb.x?T=1081 With this tool chain and library versions it compiles without problems. Perhaps it is not up-to-date.

Posted: Fri Jan 28, 2005 11:09 pm
by cory1492
yeah, the more up to the minute one is at http://www.oopo.net/consoledev/ and I use that with cygwin. Like I mentioned, adding ps2lib and the PS2LIB environment variable seems to have fixed the compile errors mentioned above.

Posted: Sat Jan 29, 2005 10:25 am
by Neil Stevens
I also built my toolchain and libs from http://www.oopo.net/consoledev/ , but I might have had something old. I'll build the latest from there and see what happens.

Posted: Sat Jan 29, 2005 5:36 pm
by Neil Stevens
Drat.. I rebuilt tonight with the latest ps2toolchain tarball and I'm still getting the same link errors. Either I'm too new (and need some compatibility layer somewhere) or too old (and need CVS versions), heh.

Posted: Sat Jan 29, 2005 5:46 pm
by Drakonite
You need to add an -lkernel to the end of the linker line.

Posted: Sat Jan 29, 2005 5:47 pm
by Neil Stevens
Thanks to Drakonite on IRC, it was pointed out to me that libkernel has to be linked in LAST, though my copy of Makefile.eeglobal did NOT have it last. Fixing that made everything OK.

So the thing links and runs nice and pretty here in NTSC land.

Edit: Heh.. so Drakonite was lurking here too as I commented on IRC.. nice timing!

Posted: Sat Jan 29, 2005 5:49 pm
by Shine
Neil Stevens wrote:Drat.. I rebuilt tonight with the latest ps2toolchain tarball and I'm still getting the same link errors. Either I'm too new (and need some compatibility layer somewhere) or too old (and need CVS versions), heh.
You can try to remove the SifInitRpc, all nprintfs and the screenshot.c/.h, because this is not needed to run the demo.