01.04.2011, 16:28
Hallo,
ja ihr hört richtig,ein Hello World für die PSP in D !
Da sich keiner so richtig damit beschäftigt hat,mach ich es mal
Vorraus möchte ich sagen,dass dies kein April scherz ist !
Vorraussetzungen
- PSPSDK
- Meine Dateien
- Etwas wissen in D / C
- Ein kluges Köpfchen
Tutorial
Als erstes kommt die "verlinkung" der C Befehle:
Code:
extern (C) void pspDebugScreenInit();
extern (C) void pspDebugScreenPrintf(char*,...);
extern (C) int SetupCallbacks();
extern (C) int sceKernelSleepThread();
import std.string;
Dies folgt nach folgendem Schema:
Code:
extern (C) Code
Danach folgt eine Klasse die Helloworld heißt:
Code:
class Helloworld
{
public:
void hellod()
{
pspDebugScreenPrintf(toStringz(m_msg));
}
char[] m_msg = "Hello World (in d)\n--------------------------------------------------------------------\n\n\n\n\n\n\n\n\n\n\n\n\nEnter your Text here\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n--------------------------------------------------------------------by emink123";
}
Danach folgt unser C-Code:
int main()
{
SetupCallbacks();
pspDebugScreenInit();
auto hello = new Helloworld();
hello.hellod();
sceKernelSleepThread();
return 0;
}
Der ganze Code:
Code (anzeigen)
Code:
extern (C) void pspDebugScreenInit();
extern (C) void pspDebugScreenPrintf(char*,...);
extern (C) int SetupCallbacks();
extern (C) int sceKernelSleepThread();
import std.string;
class Helloworld
{
public:
void hellod()
{
pspDebugScreenPrintf(toStringz(m_msg));
}
char[] m_msg = "Hello World (in d)\n--------------------------------------------------------------------\n\n\n\n\n\n\n\n\n\n\n\n\nEnter your Text here\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n--------------------------------------------------------------------by emink123";
}
int main()
{
SetupCallbacks();
pspDebugScreenInit();
auto hello = new Helloworld();
hello.hellod();
sceKernelSleepThread();
return 0;
}
Code:
TARGET = HELLOD
OBJS = module.o main.o
CFLAGS = -O2 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lgphobos -lm
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World tut by emink123
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Und zu guter letzt die module.c,die wichtig ist,damit alles Perfekt läuft:
Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsuspend.h>
PSP_MODULE_INFO("Blit Sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
/* 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;
}
Hoffe,ihr mein Tutorial hat euch einwenig weitergeholfen
Ich habe es mit Hilfe vom PSPSDK Sample gelernt
Mit Freundlichen Grüßen
emink123