維尼的蜂巢

RealTime??!! It’s amazing!!!!

用psp說helloworld 二月 21, 2008

Filed under: psp — kevinlin @ 12:54 上午

環境是用cygwin+toolchain

當然要用跟nds一樣的devkitPSP也是可以,不過我想試試看用windows跑gcc是怎樣.

很多東西靠著PSPSDK就能完成了,自己不用作什麼事情,比NDS好寫多了,但是文件一樣少,真的認真要開發,應該還是要官方授權

HelloWorld:

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <string>
PSP_MODULE_INFO("HelloWorld", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
      sceKernelExitGame();
      return 0;
}
/* Callback thread */
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;
}
int main(int argc, char **argv)
{ 
 pspDebugScreenInit();
 SetupCallbacks(); 
 std::string str;
 str = "Hello World";
 printf(str.c_str()); 
 sceKernelSleepThread(); 
 return 0;
}

helloworld可是pspSDK好像下載到舊版,執行出錯,沒關係有空再弄

 

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s