KINGx - Das inoffizielle PlayStation Forum & News Portal
[TuT] Hello World in D ! - Druckversion

+- KINGx - Das inoffizielle PlayStation Forum & News Portal (http://www.kingx.de/forum)
+-- Forum:    PS Vita / PSP (/forumdisplay.php?fid=1)
+--- Forum: Homebrew (/forumdisplay.php?fid=8)
+---- Forum: Development (/forumdisplay.php?fid=34)
+----- Forum: Dev-Tutorials (/forumdisplay.php?fid=59)
+----- Thema: [TuT] Hello World in D ! (/showthread.php?tid=39110)


[TuT] Hello World in D ! - 3m!n - 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 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


RE: [TuT] Hello World in D ! - HyBriDo - 01.04.2011 16:31

Gutes TuT


RE: [TuT] Hello World in D ! - Italia-boy - 01.04.2011 16:32

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

@Hybrido: hast du es überhaupt gelesen ?


RE: [TuT] Hello World in D ! - dark-awesome - 01.04.2011 16:35

Emink hast im Prinzip nur den Code hin geklatscht Wink
Kannst es ja noch weiter erläutern Wink

Italia-boy: Info über D Wink


RE: [TuT] Hello World in D ! - Mobai - 01.04.2011 16:37

Jaja...
Hybridoo will doch nur den Counter erhöhen, dass er "King" wird Big Grin

BtT: Und es ist wirklich kein Scherz?


RE: [TuT] Hello World in D ! - 3m!n - 01.04.2011 16:37

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 !


RE: [TuT] Hello World in D ! - dark-awesome - 01.04.2011 16:39

Aber da ist mir C / C++ doch viel einfacher und verständlicher Big Grin Big Grin


RE: [TuT] Hello World in D ! - Italia-boy - 01.04.2011 16:41

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 ?


RE: [TuT] Hello World in D ! - 3m!n - 01.04.2011 16:42

Gut,
hoffe ihr lernt alle D xD
Keine C Homebrews mehr Tongue

mfg


RE: [TuT] Hello World in D ! - HyBriDo - 09.04.2011 08:15

Ich habe es Durchgelesen.Ich kann nun mal schnell lesen.