6 #include <pspiofilemgr.h>
7 #include <pspdisplay.h>
11 #include "../common/lprintf.h"
13 PSP_MODULE_INFO("PicoDrive", 0, 1, 34);
15 void *psp_screen = PSP_VRAM_BASE0;
16 static int current_screen = 0; /* front bufer */
18 static SceUID logfd = -1;
21 static int exit_callback(int arg1, int arg2, void *common)
28 static int callback_thread(SceSize args, void *argp)
32 lprintf("callback_thread started with id %i\n", sceKernelGetThreadId());
34 cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
35 sceKernelRegisterExitCallback(cbid);
37 sceKernelSleepThreadCB();
46 lprintf("entered psp_init, threadId %i\n", sceKernelGetThreadId());
48 thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, 0);
51 sceKernelStartThread(thid, 0, 0);
55 sceDisplaySetMode(0, 480, 272);
56 sceDisplaySetFrameBuf(PSP_VRAM_BASE1, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
58 psp_screen = PSP_VRAM_BASE0;
64 sceCtrlSetSamplingCycle(0);
65 sceCtrlSetSamplingMode(0);
72 //sceKernelSleepThread();
76 void psp_video_flip(int wait_vsync)
78 if (wait_vsync) sceDisplayWaitVblankStart();
79 sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
81 psp_screen = current_screen ? PSP_VRAM_BASE0 : PSP_VRAM_BASE1;
84 void *psp_video_get_active_fb(void)
86 return current_screen ? PSP_VRAM_BASE1 : PSP_VRAM_BASE0;
89 void psp_video_switch_to_single(void)
91 psp_screen = PSP_VRAM_BASE0;
92 sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
96 void psp_msleep(int ms)
98 sceKernelDelayThread(ms * 1000);
101 unsigned int psp_pad_read(int blocking)
105 sceCtrlReadBufferPositive(&pad, 1);
106 else sceCtrlPeekBufferPositive(&pad, 1);
112 #define LOG_FILE "log.log"
114 void lprintf_f(const char *fmt, ...)
121 logfd = sceIoOpen(LOG_FILE, PSP_O_WRONLY|PSP_O_APPEND, 0777);
127 vsnprintf(buff, sizeof(buff), fmt, vl);
130 sceIoWrite(logfd, buff, strlen(buff));
131 //sceKernelDelayThread(200 * 1000);