View previous topic :: View next topic |
Author |
Message |
the_darkside_986
Joined: 18 Jul 2006 Posts: 9
|
Posted: Thu Jul 31, 2008 1:20 pm Post subject: [TUTORIAL]How to program in D on the PSP!!! |
|
|
The free, open-source GNU D compiler (dgcc) has been ported to MIPS and is known to compile under the psptoolchain now! This started because I asked someone on D.GNU how to compile it for the PSP and someone described a howto. I've posted the instructions here: http://forums.qj.net/showthread.php?t=142864 if anyone is interested.
There are still a few kinks to work out, but once things are smoother I think it would be nice to see this as a part of the standard toolchain distribution.
For those who have never heard of D, it is a powerful new systems programming language that compiles purely to native code, but has powerful language features of high level languages. These links explain it better than I can:
http://www.digitalmars.com/d/
http://www.digitalmars.com/d/1.0/overview.html
http://www.digitalmars.com/d/1.0/comparison.html
For now, developers will be limited to mostly using the standard C library (in std.c.* modules) and the PSPSDK headers (download link is in the QJ post, I converted them myself to D) until I can rewrite D's standard library, Phobos, to have proper PSP implementations of various classes and functions, which should be easy and straightforward. But I personally prefer using the SDK functions anyway.
Enjoy. |
|
Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Jul 31, 2008 1:57 pm Post subject: |
|
|
Cool! I'll have to try that out. I've been watching D since it was first introduced. It's a very nifty language. :)
EDIT: Got gdc compiled and installed. Example 2 works fine on my Slim running 4.01 M33-2. :D |
|
Back to top |
|
 |
Maxiime
Joined: 19 Jun 2008 Posts: 18
|
Posted: Mon Aug 04, 2008 7:18 am Post subject: |
|
|
Wow:p
Nice. I'll try it out tomoro. (1h AM here)
Cyaa |
|
Back to top |
|
 |
KickinAezz
Joined: 03 Jun 2007 Posts: 328
|
Posted: Mon Aug 04, 2008 10:33 am Post subject: |
|
|
D has great future!
I donot know why people seem so uninterested... _________________ Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming. |
|
Back to top |
|
 |
whistler
Joined: 04 Mar 2008 Posts: 40
|
Posted: Mon Aug 04, 2008 11:41 pm Post subject: |
|
|
finally managed to compile psp-gdc and i have tested the demonstration eboot on 401m33 :)
great work |
|
Back to top |
|
 |
Maxiime
Joined: 19 Jun 2008 Posts: 18
|
Posted: Tue Aug 05, 2008 7:22 am Post subject: |
|
|
Post this on a psp site like pspgen, qj etc.
Ps: tested it. works great! tnx
Cya! |
|
Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Tue Aug 05, 2008 6:08 pm Post subject: |
|
|
Quote: | Post this on a psp site like pspgen, qj etc. |
Some people here (me at first) don't like redirects like this. Please, don't...
(and that "cya", too....is it necessary? :P ) |
|
Back to top |
|
 |
Wraggster
Joined: 26 Aug 2005 Posts: 121
|
Posted: Wed Aug 06, 2008 12:44 am Post subject: |
|
|
anychance of posting the tutorial in full here _________________ Webmaster of http://www.dcemu.co.uk
DCEMU The Worlds Only Homebrew & Gaming Network of Sites. |
|
Back to top |
|
 |
Moneyslap03
Joined: 11 May 2008 Posts: 14
|
Posted: Wed Aug 06, 2008 2:33 am Post subject: |
|
|
thanks im setting up now and Wraggster didnt know you were signed up here its mike03$$$ from dcemu |
|
Back to top |
|
 |
Viper8896
Joined: 26 Jan 2006 Posts: 110
|
Posted: Sun Aug 10, 2008 8:58 pm Post subject: |
|
|
I've been really wanting to get D working on the psp but bother as I thought there may be a few difficulties causing me to loose sleep. So I decided to posted this ;) hoping other dev's would rush in and try to 'win the race' (while not even playing) and it seemed to work brilliantly.
Anyway just skiming through right now 'bout to get more sleep. So is the full tango library working and GC tested? |
|
Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Tue Aug 12, 2008 1:32 am Post subject: |
|
|
gcc patched and D compiled without problem but when generating libpspsdkA.o
i have the following error with the makefile provide
../../../libphobos/internal/cmain.d:5: référence indéfinie vers « _Dmain »
../../../libphobos/internal/cmain.d:5: référence indéfinie vers « _Dmain »
is this the main entry that must been written in C?
if have created a new makefile
just do make copyheader it copy all the *.d to $(SRCS) $(PSPSDK)/include/pspsdk
after this
make it compile create the libpspsdkD and copy it to $(PSPDIR)/lib
here is the makefile
PSPSDK=$(shell psp-config --pspsdk-path)
PSPDIR=$(shell psp-config --psp-prefix)
TARGET_LIB = libpspsdkD.a
$(SRCS):
echo $@
SRCS = csystime.d pspatrac3.d pspaudiocodec.d pspaudio.d pspaudio_kernel.d pspaudiolib.d \
pspchnnlsv.d pspctrl.d pspctrl_kernel.d pspdconfig.d pspdebug.d pspdebugkb.d pspdisplay.d \
pspdisplay_kernel.d pspexception.d pspfpu.d pspge.d pspgu.d pspgum.d psphprm.d psphttp.d \
pspidstorage.d pspimpose_driver.d pspinit.d pspintrman.d pspintrman_kernel.d pspiofilemgr.d \
pspiofilemgr_dirent.d pspiofilemgr_fcntl.d pspiofilemgr_kernel.d pspiofilemgr_stat.d pspjpeg.d \
pspkdebug.d pspkernel.d pspkerneltypes.d pspkerror.d psploadcore.d psploadexec.d \
psploadexec_kernel.d pspmoduleexport.d pspmoduleinfo.d pspmodulemgr.d pspmodulemgr_kernel.d \
pspmpegbase.d pspmpeg.d pspmscm.d pspnand_driver.d pspnet_adhocctl.d pspnet_adhoc.d pspnet_adhocmatching.d \
pspnet_apctl.d pspnet.d pspnet_inet.d pspnet_resolver.d pspopenpsid.d psppower.d \
pspprof.d pspreg.d psprtc.d pspsdk.d pspsircs.d pspssl.d pspstdio.d pspstdio_kernel.d pspsuspend.d \
pspsysclib.d pspsyscon.d pspsysevent.d pspsysmem.d pspsysmem_kernel.d pspsysreg.d \
pspsystimer.d pspthreadman.d pspthreadman_kernel.d psptypes.d pspumd.d pspusbacc.d \
pspusbbus.d pspusbcam.d pspusb.d pspusbstor.d pspuser.d psputility_avmodules.d \
psputility.d psputility_gamesharing.d psputility_htmlviewer.d psputility_modules.d \
psputility_msgdialog.d psputility_netconf.d psputility_netmodules.d psputility_netparam.d \
psputility_osk.d psputility_savedata.d psputility_sysparam.d psputility_usbmodules.d \
psputils.d psputilsforkernel.d pspvfpu.d pspvideocodec.d pspwlan.d
OBJS = csystime.o pspatrac3.o pspaudiocodec.o pspaudio.o pspaudio_kernel.o pspaudiolib.o \
pspchnnlsv.o pspctrl.o pspctrl_kernel.o pspdconfig.o pspdebug.o pspdebugkb.o pspdisplay.o \
pspdisplay_kernel.o pspexception.o pspfpu.o pspge.o pspgu.o pspgum.o psphprm.o psphttp.o \
pspidstorage.o pspimpose_driver.o pspinit.o pspintrman.o pspintrman_kernel.o pspiofilemgr.o \
pspiofilemgr_dirent.o pspiofilemgr_fcntl.o pspiofilemgr_kernel.o pspiofilemgr_stat.o pspjpeg.o \
pspkdebug.o pspkernel.o pspkerneltypes.o pspkerror.o psploadcore.o psploadexec.o \
psploadexec_kernel.o pspmoduleexport.o pspmoduleinfo.o pspmodulemgr.o pspmodulemgr_kernel.o \
pspmpegbase.o pspmpeg.o pspmscm.o pspnand_driver.o pspnet_adhocctl.o pspnet_adhoc.o pspnet_adhocmatching.o \
pspnet_apctl.o pspnet.o pspnet_inet.o pspnet_resolver.o pspopenpsid.o psppower.o \
pspprof.o pspreg.o psprtc.o pspsdk.o pspsircs.o pspssl.o pspstdio.o pspstdio_kernel.o pspsuspend.o \
pspsysclib.o pspsyscon.o pspsysevent.o pspsysmem.o pspsysmem_kernel.o pspsysreg.o \
pspsystimer.o pspthreadman.o pspthreadman_kernel.o psptypes.o pspumd.o pspusbacc.o \
pspusbbus.o pspusbcam.o pspusb.o pspusbstor.o pspuser.o psputility_avmodules.o \
psputility.o psputility_gamesharing.o psputility_htmlviewer.o psputility_modules.o \
psputility_msgdialog.o psputility_netconf.o psputility_netmodules.o psputility_netparam.o \
psputility_osk.o psputility_savedata.o psputility_sysparam.o psputility_usbmodules.o \
psputils.o psputilsforkernel.o pspvfpu.o pspvideocodec.o pspwlan.o
DFLAGS = -I $(PSPSDK)/include
include $(PSPSDK)/lib/build.mak
install: $(TARGET_LIB)
cp $(TARGET_LIB) $(PSPSDK)/lib
copyheader: $(SRCS)
mkdir -p $(PSPSDK)/include/pspsdk
cp -f $(SRCS) $(PSPSDK)/include/pspsdk |
|
Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Tue Aug 12, 2008 4:03 am Post subject: |
|
|
here is the makefile and the hello source adapted.
Makefile:
TARGET = hello
OBJS = module.o main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lgphobos -lm -lpspsdkD
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World
PSPSDK=$(shell psp-config --pspsdk-path)
DFLAGS = -I $(PSPSDK)/include
include $(PSPSDK)/lib/build.mak
main.d:
extern (C) int SetupCallbacks();
extern (C) int sceKernelSleepThread();
import pspsdk.pspdebug;
import std.string;
class HelloPsp
{
public:
void sayHello()
{
pspDebugScreenPrintf(toStringz(m_msg));
}
char[] m_msg = "Hello D on Psp\n";
}
int main()
{
SetupCallbacks();
pspDebugScreenInit();
auto hello = new HelloPsp();
hello.sayHello();
sceKernelSleepThread();
return 0;
}
module.c :
#include <pspkernel.h>
#include <pspdebug.h>
PSP_MODULE_INFO("d test prog", 0, 1, 1);
/* Exit callback */
static int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
static int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
} |
|
Back to top |
|
 |
the_darkside_986
Joined: 18 Jul 2006 Posts: 9
|
Posted: Tue Aug 12, 2008 4:33 am Post subject: |
|
|
Yeah sorry about that I forgot to fix the Makefile before posting it. This is the latest version on the QJ thread's first page, right? I just fixed it and re-posted it the other day. There were some problems with pspgu headers (as usual for me). |
|
Back to top |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Tue Aug 12, 2008 5:20 am Post subject: |
|
|
sauron_le_noir wrote: | here is the makefile and the hello source adapted.
--->8--->8--->8---
Nom de diou ! utilise les tags [CODE/] pour entourer tes codes. C'est illisible sans l'indentation !
Makefile:
Code: |
TARGET = hello
OBJS = module.o main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lgphobos -lm -lpspsdkD
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World
PSPSDK=$(shell psp-config --pspsdk-path)
DFLAGS = -I $(PSPSDK)/include
include $(PSPSDK)/lib/build.mak
|
main.d:
Code: |
extern (C) int SetupCallbacks();
extern (C) int sceKernelSleepThread();
import pspsdk.pspdebug;
import std.string;
class HelloPsp
{
public:
void sayHello()
{
pspDebugScreenPrintf(toStringz(m_msg));
}
char[] m_msg = "Hello D on Psp\n";
}
int main()
{
SetupCallbacks();
pspDebugScreenInit();
auto hello = new HelloPsp();
hello.sayHello();
sceKernelSleepThread();
return 0;
}
|
module.c :
Code: |
#include <pspkernel.h>
#include <pspdebug.h>
PSP_MODULE_INFO("d test prog", 0, 1, 1);
/* Exit callback */
static int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
static int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
|
|
|
|
Back to top |
|
 |
Heimdall
Joined: 10 Nov 2005 Posts: 259 Location: Netherlands
|
Posted: Tue Aug 12, 2008 6:52 am Post subject: |
|
|
any ideas if it can be aplyed to gcc 4.3? |
|
Back to top |
|
 |
the_darkside_986
Joined: 18 Jul 2006 Posts: 9
|
Posted: Tue Aug 12, 2008 11:46 pm Post subject: 4.3 |
|
|
Probably not, I've had problems with gdc compiled against 4.2, so 4.3 probably has the same issues or more unless that has been patched in svn yet. |
|
Back to top |
|
 |
Heimdall
Joined: 10 Nov 2005 Posts: 259 Location: Netherlands
|
Posted: Tue Aug 31, 2010 1:36 am Post subject: |
|
|
I finally got this to work (for now only on Linux the windows build is broken) meaning that the next release of minpspw will come with support for the D programming language!
http://www.jetdrone.com/minpspw |
|
Back to top |
|
 |
|