[TUTORIAL]How to program in D on the PSP!!!
-
- Posts: 9
- Joined: Tue Jul 18, 2006 3:29 pm
[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.
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.
-
- Posts: 328
- Joined: Sun Jun 03, 2007 10:05 pm
-
- Posts: 14
- Joined: Sun May 11, 2008 11:06 pm
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?
Anyway just skiming through right now 'bout to get more sleep. So is the full tango library working and GC tested?
-
- Posts: 203
- Joined: Sat Jul 05, 2008 8:03 am
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
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
-
- Posts: 203
- Joined: Sat Jul 05, 2008 8:03 am
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;
}
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;
}
-
- Posts: 9
- Joined: Tue Jul 18, 2006 3:29 pm
sauron_le_noir wrote:here is the makefile and the hello source adapted.
--->8--->8--->8---
Nom de diou ! utilise les tagspour entourer tes codes. C'est illisible sans l'indentation !Code: Select all
[CODE/]
Makefile:Code: Select all
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:module.c :Code: Select all
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; }
Code: Select all
#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; }
-
- Posts: 9
- Joined: Tue Jul 18, 2006 3:29 pm
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.