KINGx - Das inoffizielle PlayStation Forum & News Portal

Normale Version: [TuT] Hello World in D !
Sie sehen gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.


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 Wink
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:

Danach folgt unsere Makefile:

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 Smile
Ich habe es mit Hilfe vom PSPSDK Sample gelernt Wink

Mit Freundlichen Grüßen
emink123

Gutes TuT
Das mit dem "D"musst du mir nochmal erläutern ?

@Hybrido: hast du es überhaupt gelesen ?
Emink hast im Prinzip nur den Code hin geklatscht Wink
Kannst es ja noch weiter erläutern Wink

Italia-boy: Info über D Wink
Jaja...
Hybridoo will doch nur den Counter erhöhen, dass er "King" wird Big Grin

BtT: Und es ist wirklich kein Scherz?
Das ist die Programmiersprache D für PSP Wink

EmInK123 :
Ich habe es mit Hilfe vom PSPSDK Sample gelernt Wink


Rolleyes

@der über mir
Ja,es ist wirklich kein scherz !

Aber da ist mir C / C++ doch viel einfacher und verständlicher Big Grin Big Grin
Oke hab mich informiert und hab das gefunden (Deutsch) http://www.steinmole.de/d/d_buch.pdf

Edit: Hat jemand die .pdf für das normale C ?
Gut,
hoffe ihr lernt alle D xD
Keine C Homebrews mehr Tongue

mfg
Ich habe es Durchgelesen.Ich kann nun mal schnell lesen.
Referenz-URLs