extern "C" int main(int argc, char *argv[]) { // Let's not bother debugging to the display, since we'll just mess it up anyway. HAS_DISPLAY = 0; sceDisplaySetMode(0, 480, 272); sceDisplaySetFrameBuf(0, 0, 0, 1); sceDisplaySetFrameBuf(0, 0, 0, 0); checkpointNext("While off:"); sceDisplayWaitVblankStart(); testStateScenarios(); sceDisplaySetFrameBuf((void *)0x04000000, 512, 3, 1); sceDisplaySetFrameBuf((void *)0x04000000, 512, 3, 0); checkpointNext("While on:"); sceDisplayWaitVblankStart(); testStateScenarios(); sceDisplaySetFrameBuf(0, 0, 0, 1); checkpointNext("Latched off"); testIsState(" Latched off"); return 0; }
static int pmp_show_thread(SceSize input_length, void *input) { volatile struct pmp_play_struct *p = *((void **) input); unsigned int current_buffer_number = 0; while (p->return_request == 0) { if (pmp_wait(p, p->semaphore_can_show, "pmp_show_thread: sceKernelWaitSema failed on semaphore_can_show") == 0) { break; } sceDisplayWaitVblankStart(); sceDisplaySetFrameBuf(p->decoder.output_frame_buffers[current_buffer_number].video_frame, p->decoder.output_texture_width, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_IMMEDIATE); if (sceKernelSignalSema(p->semaphore_show_done, 1) < 0) { p->return_result = "pmp_show_thread: sceKernelSignalSema failed on semaphore_show_done"; p->return_request = 1; break; } current_buffer_number = (current_buffer_number + 1) % p->decoder.number_of_frame_buffers; } return(0); }
void psp_init(void) { SceUID thid; char buff[128], *r; /* fw 1.5 sometimes returns 8002032c, although getcwd works */ r = getcwd(buff, sizeof(buff)); if (r) sceIoChdir(buff); main_thread_id = sceKernelGetThreadId(); lprintf("running on %08x kernel\n", sceKernelDevkitVersion()), lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id, sceKernelGetThreadCurrentPriority()); thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, NULL); if (thid >= 0) { sceKernelStartThread(thid, 0, 0); } /* video */ sceDisplaySetMode(0, 480, 272); sceDisplaySetFrameBuf(VRAM_FB1, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME); current_screen = 1; psp_screen = VRAM_FB0; /* gu */ sceGuInit(); sceGuStart(GU_DIRECT, guCmdList); sceGuDrawBuffer(GU_PSM_5650, (void *)VRAMOFFS_FB0, 512); sceGuDispBuffer(480, 272, (void *)VRAMOFFS_FB1, 512); // don't care sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); sceGuDepthBuffer((void *)VRAMOFFS_DEPTH, 512); sceGuOffset(2048 - (480 / 2), 2048 - (272 / 2)); sceGuViewport(2048, 2048, 480, 272); sceGuDepthRange(0xc350, 0x2710); sceGuScissor(0, 0, 480, 272); sceGuEnable(GU_SCISSOR_TEST); sceGuDepthMask(0xffff); sceGuDisable(GU_DEPTH_TEST); sceGuFrontFace(GU_CW); sceGuEnable(GU_TEXTURE_2D); sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB); sceGuAmbientColor(0xffffffff); sceGuColor(0xffffffff); sceGuFinish(); sceGuSync(0, 0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); /* input */ sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); }
void psp_video_flip(int wait_vsync) { if (wait_vsync) sceDisplayWaitVblankStart(); sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, wait_vsync ? PSP_DISPLAY_SETBUF_IMMEDIATE : PSP_DISPLAY_SETBUF_NEXTFRAME); current_screen ^= 1; psp_screen = current_screen ? VRAM_FB0 : VRAM_FB1; }
void GraphicsSwapBuffers() { #if defined(_WIN32) BitBlt(curDc, 0, 0, curSurface.width, curSurface.height, backDc, 0, 0, SRCCOPY); #elif defined(PLATFORM_PSP2) sceDisplaySetFrameBuf(&fb[cur_fb], PSP2_DISPLAY_SETBUF_NEXTFRAME); cur_fb ^= 1; #endif }
void pgScreenFrame(long mode,long frame) { pg_screenmode=mode; frame=(frame?1:0); pg_showframe=frame; if (mode==0) { //screen off pg_drawframe=frame; sceDisplaySetFrameBuf(0,0,0,1); } else if (mode==1) { //show/draw same pg_drawframe=frame; sceDisplaySetFrameBuf(pg_vramtop+(pg_showframe?FRAMESIZE:0),LINESIZE,PIXELSIZE,1); } else if (mode==2) { //show/draw different pg_drawframe=(frame?0:1); sceDisplaySetFrameBuf(pg_vramtop+(pg_showframe?FRAMESIZE:0),LINESIZE,PIXELSIZE,1); } }
/** * display_init: Initialize the PSP display. * * [Parameters] * None * [Return value] * Nonzero on success, zero on error */ int display_init(void) { /* Have we already initialized? */ static int initted = 0; if (initted) { return 1; } /* Clear out VRAM */ memset(sceGeEdramGetAddr(), 0, sceGeEdramGetSize()); sceKernelDcacheWritebackInvalidateAll(); /* Set display mode */ int32_t res = sceDisplaySetMode(0, DISPLAY_WIDTH, DISPLAY_HEIGHT); if (res < 0) { DMSG("sceDisplaySetMode() failed: %s", psp_strerror(res)); return 0; } display_width = DISPLAY_WIDTH; display_height = DISPLAY_HEIGHT; display_mode = PSP_DISPLAY_PIXEL_FORMAT_8888; display_bpp = 32; /* Initialize VRAM pointers */ uint8_t *vram_addr = sceGeEdramGetAddr(); uint32_t vram_size = sceGeEdramGetSize(); const uint32_t frame_size = DISPLAY_STRIDE * DISPLAY_HEIGHT * (display_bpp/8); int i; for (i = 0; i < lenof(surfaces); i++) { surfaces[i] = vram_addr + i*frame_size; } vram_spare_ptr = (uint8_t *)(vram_addr + lenof(surfaces)*frame_size); vram_next_alloc = vram_spare_ptr; vram_top = vram_addr + vram_size; displayed_surface = 0; work_surface = 1; swap_pending = 0; /* Set the currently-displayed buffer */ sceDisplaySetFrameBuf(surfaces[displayed_surface], DISPLAY_STRIDE, display_mode, PSP_DISPLAY_SETBUF_IMMEDIATE); /* Set up the GU library */ guInit(); guStart(GU_DIRECT, display_list); guDispBuffer(DISPLAY_WIDTH, DISPLAY_HEIGHT, surfaces[displayed_surface], DISPLAY_STRIDE); guFinish(); guSync(0, 0); /* Success */ initted = 1; return 1; }
void* swapBuffer() { while((sceKernelGetSystemTimeWide())<next) if(ot->gui)Draw(4); else sceDisplayWaitVblankStart(); next+=delay; /* if(ot->gui){ Draw(8); return (void*)(ot->lcd->curr?ot->lcd->disp:ot->lcd->draw);//+lcd.vram }else{*/ if(ot->lcd->curr^=1) { sceDisplaySetFrameBuf((void*)ot->lcd->draw,ot->lcd->size,ot->lcd->type,0); sceDisplaySetFrameBuf((void*)ot->lcd->disp,ot->lcd->size,ot->lcd->type,1); return (void*)ot->lcd->disp+ot->lcd->vram; } sceDisplaySetFrameBuf((void*)ot->lcd->disp,ot->lcd->size,ot->lcd->type,0); sceDisplaySetFrameBuf((void*)ot->lcd->draw,ot->lcd->size,ot->lcd->type,1); return (void*)ot->lcd->draw+ot->lcd->vram; // } /* // return (void*)0x44000000; */ }
void sceGuDispBuffer(int width, int height, void* dispbp, int dispbw) { gu_draw_buffer.width = width; gu_draw_buffer.height = height; gu_draw_buffer.disp_buffer = dispbp; if (!gu_draw_buffer.frame_width || (gu_draw_buffer.frame_width != dispbw)) gu_draw_buffer.frame_width = dispbw; drawRegion(0,0,gu_draw_buffer.width,gu_draw_buffer.height); sceDisplaySetMode(0,gu_draw_buffer.width,gu_draw_buffer.height); if (gu_display_on) sceDisplaySetFrameBuf((void*)(((unsigned int)ge_edram_address) + ((unsigned int)gu_draw_buffer.disp_buffer)), dispbw, gu_draw_buffer.pixel_size, PSP_DISPLAY_SETBUF_NEXTFRAME); }
static void display_callback(const void *callback_data) { SceDisplayFrameBuf framebuf; const vita2d_display_data *display_data = (const vita2d_display_data *)callback_data; memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); framebuf.size = sizeof(SceDisplayFrameBuf); framebuf.base = display_data->address; framebuf.pitch = DISPLAY_STRIDE_IN_PIXELS; framebuf.pixelformat = DISPLAY_PIXEL_FORMAT; framebuf.width = DISPLAY_WIDTH; framebuf.height = DISPLAY_HEIGHT; sceDisplaySetFrameBuf(&framebuf, PSP2_DISPLAY_SETBUF_NEXTFRAME); if (vblank_wait) { sceDisplayWaitVblankStart(); } }
/** * do_buffer_swap: Perform a display buffer swap (call guSync(), swap the * display and work surfaces, wait for the following vertical blank, and * calculate the length of time between this newly displayed frame and the * previous one). Called either from the buffer swap thread or (if the * swap thread fails to start) from the main thread. * * [Parameters] * None * [Return value] * None */ static void do_buffer_swap(void) { guSync(0, 0); sceDisplaySetFrameBuf(surfaces[work_surface], DISPLAY_STRIDE, display_mode, PSP_DISPLAY_SETBUF_NEXTFRAME); displayed_surface = work_surface; work_surface = (work_surface + 1) % lenof(surfaces); sceDisplayWaitVblankStart(); /* Update the frame length variables. If this is the first frame * we've drawn (signaled by last_frame_start == 0), just set a frame * length of 1 (1/60 sec) since we have nothing to compare it against. */ const uint32_t now = sceKernelGetSystemTimeLow(); const uint32_t last_frame_time = now - last_frame_start; const uint32_t time_unit = (1001000+30)/60; if (last_frame_start != 0) { last_frame_length = (last_frame_time + time_unit/2) / time_unit; } else { last_frame_length = 1; } /* Make sure we don't accidentally signal the next frame as the * first frame drawn. */ last_frame_start = (now != 0) ? now : 1; }
//////////////////////////////////////////////////////////////////////////////////// // This is just a quick and easy procedure to wait for a PSP to join, the following // is what is done in Lumines: // // - Wait for a PSP to join // - Add the PSP to the list of machines available // - Wait for the user to select a PSP // - Call sceMatchingSelectTarget // - The other PSP will receive MATCHING_SELECTED event // - The other PSP displays a message to accept or cancel // - If accepted the other PSP calls sceMatchingSelectTarget // - The first PSP receives MATCHING_ESTABLISHED // // In lumines they then close the connection and start a new adhoc connection // with just those two machines in it. /////////////////////////////////////////////////////////////////////////////////// int adhocSelect(void) { SceCtrlData m_PspPad; int err = 0; char mac[10]; char name[256]; int waitAccept = 0; int currentState = PSP_LISTING; int oldButtons = 0; char tempStr[100]; char str[256]; sceDisplaySetMode( 0, SCREEN_WIDTH, SCREEN_HEIGHT ); sceDisplaySetFrameBuf( (char*)VRAM_ADDR, 512, 1, 1 ); pgFillAllvram(0);pgScreenFrame(2,0); for(;;) { sceCtrlReadBufferPositive(&m_PspPad, 1); //pspDebugScreenSetTextColor(0xFFFF); switch(currentState) { case PSP_LISTING: { //pspDebugScreenInit(); //pspDebugScreenPrintf("Select a server to connect to, or triangle to return\n\n\n"); pgFillAllvram(0);pgScreenFrame(2,0); mh_print(0,0,"Select a server to connect to, or triangle to return",0xFFFF); DisplayPspList(); pgScreenFlipV(); g_Server = 0; if(m_PspPad.Buttons != oldButtons) { if(m_PspPad.Buttons & PSP_CTRL_UP) { UpList(); } if(m_PspPad.Buttons & PSP_CTRL_DOWN) { DownList(); } if(m_PspPad.Buttons & PSP_CTRL_CROSS) { if(GetPspEntry(mac, name) > 0) { currentState = PSP_SELECTING; sceNetAdhocMatchingSelectTarget(matchingId, mac, 0, 0); } } if(m_PspPad.Buttons & PSP_CTRL_TRIANGLE) return -1; } if(matchChanged) { if(g_matchEvent == MATCHING_SELECTED) { memcpy(mac, g_mac, 6); strcpy(name, g_matchOptData); currentState = PSP_SELECTED; } } break; } case PSP_SELECTING: { //pspDebugScreenInit(); pgFillAllvram(0);pgScreenFrame(2,0); sceNetEtherNtostr(mac, tempStr); //printf("Waiting for %s to accept the connection\nTo cancel press O\n", tempStr); sprintf(str,"Waiting for %s to accept the connection\nTo cancel press O\n", tempStr); mh_print(0,0,str,0xFFFF); pgScreenFlipV(); if(m_PspPad.Buttons != oldButtons) { if(m_PspPad.Buttons & PSP_CTRL_CIRCLE) { sceNetAdhocMatchingCancelTarget(matchingId, mac); currentState = PSP_LISTING; } } if(matchChanged) { if(g_matchEvent == MATCHING_SELECTED) { sceNetAdhocMatchingCancelTarget(matchingId, mac); } else if(g_matchEvent == MATCHING_ESTABLISHED) { currentState = PSP_ESTABLISHED; } else if(g_matchEvent == MATCHING_REJECTED) { currentState = PSP_LISTING; } } break; } case PSP_SELECTED: { g_Server = 1; //pspDebugScreenInit(); pgFillAllvram(0);pgScreenFrame(2,0); sceNetEtherNtostr(mac, tempStr); sprintf(str,"%s has requested a connection\nTo accept the connection press X, to cancel press O\n", tempStr); mh_print(0,0,str,0xFFFF); pgScreenFlipV(); if(m_PspPad.Buttons != oldButtons) { if(m_PspPad.Buttons & PSP_CTRL_CIRCLE) { sceNetAdhocMatchingCancelTarget(matchingId, mac); currentState = PSP_LISTING; } if(m_PspPad.Buttons & PSP_CTRL_CROSS) { sceNetAdhocMatchingSelectTarget(matchingId, mac, 0, 0); currentState = PSP_WAIT_EST; } } if(matchChanged) { if(g_matchEvent == MATCHING_CANCELED) { currentState = PSP_LISTING; } } break; } case PSP_WAIT_EST: { if(matchChanged) { if(g_matchEvent == MATCHING_ESTABLISHED) { currentState = PSP_ESTABLISHED; } } break; } } matchChanged = 0; oldButtons = m_PspPad.Buttons; if(currentState == PSP_ESTABLISHED) break; sceDisplayWaitVblankStart(); } char macAddr[10]; char *tempMac; if(g_Server) { sceWlanGetEtherAddr(macAddr); tempMac = macAddr; } else { tempMac = mac; } sceNetEtherNtostr(tempMac, tempStr); char ssid[10]; sprintf(ssid, "%c%c%c%c%c%c", tempStr[9], tempStr[10], tempStr[12], tempStr[13], tempStr[15], tempStr[16]); adhocReconnect(ssid); // We only get here if both PSP's have agreed to connect //pspDebugScreenInit(); //pspDebugScreenPrintf("Connected\n"); pgFillAllvram(0);pgScreenFrame(2,0); mh_print(0,0,"Connected",0xFFFF); pgScreenFlipV(); return 0; }
void pgScreenFlip() { pg_showframe=(pg_showframe?0:1); pg_drawframe=(pg_drawframe?0:1); sceDisplaySetFrameBuf(pg_vramtop+(pg_showframe?FRAMESIZE:0),LINESIZE,PIXELSIZE,0); }
extern "C" int main(int argc, char *argv[]) { init(); schedf("framebuf: %08x\n", sceDisplaySetFrameBuf(sceGeEdramGetAddr(), 512, GU_PSM_8888, PSP_DISPLAY_SETBUF_IMMEDIATE)); schedf("dispmode: %08x\n", sceDisplaySetMode(0, 480, 272)); checkpointNext("Common:"); testBlendFunc(" One + Zero", 0x44444444, 0xEEDDCCBB, GU_ADD, GU_FIX, GU_FIX, 0xFFFFFFFF, 0x00000000); testBlendFunc(" Zero + One", 0x44444444, 0xEEDDCCBB, GU_ADD, GU_FIX, GU_FIX, 0x00000000, 0xFFFFFFFF); testBlendFunc(" Alpha + Inverse alpha", 0x44444444, 0xEEDDCCBB, GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0x80808080, 0x80808080); checkpointNext("Doubling:"); testBlendFunc(" Double source alpha + Zero", 0x40404040, 0x80808080, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double source alpha + Zero", 0x40404040, 0x80909090, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double source alpha + Zero", 0x40404040, 0x90808080, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x80808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x80909090, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double source alpha + Zero", 0x40404040, 0x40808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x40404040, 0x80808080, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x90404040, 0x80808080, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x40404040, 0x80909090, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); checkpointNext("Factors:"); testBlendFunc(" Dest color + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DST_COLOR, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse dest color + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DST_COLOR, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double src alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Double dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Inverse double dest alpha + Zero", 0x50404040, 0x90808080, GU_ADD, GU_ONE_MINUS_DOUBLE_DST_ALPHA, GU_FIX, 0x00000000, 0x00000000); testBlendFunc(" Fix + Zero", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_FIX, 0x90808080, 0x00000000); testBlendFunc(" Zero + Src color", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_SRC_COLOR, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse dest color", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_COLOR, 0x00000000, 0x00000000); testBlendFunc(" Zero + Src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_DST_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_DST_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Double src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_DOUBLE_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse double src alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_DOUBLE_SRC_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Double dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_DOUBLE_DST_ALPHA, 0x00000000, 0x00000000); testBlendFunc(" Zero + Inverse double dest alpha", 0x50404040, 0x90808080, GU_ADD, GU_FIX, GU_ONE_MINUS_DOUBLE_DST_ALPHA, 0x00000000, 0x00000000); checkpointNext("Add:"); testBlendFunc(" F0 + 0F", 0xFFFFFFFF, 0xFFFFFFFF, GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); testBlendFunc(" 0F + F0", 0xFFFFFFFF, 0xFFFFFFFF, GU_ADD, GU_FIX, GU_FIX, 0x0F0F0F0F, 0xF0F0F0F0); checkpointNext("Subtract:"); testBlendFunc(" F0 - 0F", 0xFFFFFFFF, 0xFFFFFFFF, GU_SUBTRACT, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); testBlendFunc(" 0F - F0", 0xFFFFFFFF, 0xFFFFFFFF, GU_SUBTRACT, GU_FIX, GU_FIX, 0x0F0F0F0F, 0xF0F0F0F0); checkpointNext("Reverse subtract:"); testBlendFunc(" Reverse F0 - 0F", 0xFFFFFFFF, 0xFFFFFFFF, GU_REVERSE_SUBTRACT, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); testBlendFunc(" Reverse 0F - F0", 0xFFFFFFFF, 0xFFFFFFFF, GU_REVERSE_SUBTRACT, GU_FIX, GU_FIX, 0x0F0F0F0F, 0xF0F0F0F0); checkpointNext("Min:"); testBlendFunc(" Min 0F, F0", 0xF0F0F0F0, 0x0F0F0F0F, GU_MIN, GU_FIX, GU_FIX, 0x80808080, 0x80808080); testBlendFunc(" Min F0, 0F", 0x0F0F0F0F, 0xF0F0F0F0, GU_MIN, GU_FIX, GU_FIX, 0x80808080, 0x80808080); checkpointNext("Max:"); testBlendFunc(" Max 0F, F0", 0xF0F0F0F0, 0x0F0F0F0F, GU_MAX, GU_FIX, GU_FIX, 0x80808080, 0x80808080); testBlendFunc(" Max F0, 0F", 0x0F0F0F0F, 0xF0F0F0F0, GU_MAX, GU_FIX, GU_FIX, 0x80808080, 0x80808080); checkpointNext("Absolute difference:"); testBlendFunc(" Abs 0F - F0", 0xF0F0F0F0, 0x0F0F0F0F, GU_ABS, GU_FIX, GU_FIX, 0x80808080, 0x80808080); testBlendFunc(" Abs F0 - 0F", 0x0F0F0F0F, 0xF0F0F0F0, GU_ABS, GU_FIX, GU_FIX, 0x80808080, 0x80808080); sceGuTerm(); return 0; }
int psp_initadhocgame(void){ int retval; //testing net stuff //pspDebugScreenInit(); sprintf(str_id,"%s\/%s",os9x_nickname,shortrom_filename); if((adhocInit(str_id) >= 0) && (adhocSelect() >=0)) { //init adhoc unsigned int length; uint8 *buffer; int err = 0; int i=0; if (g_Server) os9x_conId = 1; else os9x_conId = 2; //buffer=(uint8*)malloc(256); //sceKernelDelayThread(1000000); //wait //pspDebugScreenInit(); if (os9x_conId==1) { //server //send settings is now done in psp.cpp /*save_buffer_settings(buffer); sceKernelDelayThread(3000000); //wait printf("Sending settings data to the client\n"); err = adhocSendRecvAck(buffer, 256); if (!err) printf("Done sending data\n"); else { printf("Error %d!",err); retval=-2; sceKernelDelayThread(1000000); //wait }*/ //server is pl1 os9x_netpadindex=0; } else { //client /*int size = 0; // receive the settings data printf("Waiting for settings data\n"); length = 256; err = adhocRecvSendAck(buffer, &length); if (!err) { printf("Received data from server %d bytes\n",length); load_buffer_settings(buffer); } else { printf("Error %d!",err); retval=-3; sceKernelDelayThread(1000000); //wait }*/ //client is pl2 os9x_netpadindex=1; } retval=0; //free(buffer); } else retval=-1; sceDisplaySetMode( 0, SCREEN_WIDTH, SCREEN_HEIGHT ); sceDisplaySetFrameBuf( (char*)VRAM_ADDR, 512, 1, 1 ); pgScreenFrame(2,0); return retval; }
void psp_video_switch_to_single(void) { psp_screen = VRAM_FB0; sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME); current_screen = 0; }
void frame_end(void) { g_display_flip = !g_display_flip; sceDisplaySetFrameBuf(get_display_buffer(), 512, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_NEXTFRAME); sceDisplayWaitVblank(); }
int main(void){ void* base; SceUID memblock = sceKernelAllocMemBlock("camera", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, 256 * 1024 * 5, NULL); sceKernelGetMemBlockBase(memblock, &base); SceDisplayFrameBuf dbuf = { sizeof(SceDisplayFrameBuf), base, DISPLAY_WIDTH, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT}; int cur_res = 1;// 1-8 (maybe more) int cur_cam = 0;//front:0, back:1 int cur_fps = 6; int cur_fmt = 5; sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG); SceCtrlData ctrl_peek;SceCtrlData ctrl_press; do{ int cur_sat=0,cur_rev=0,cur_efx=0,cur_iso=0,cur_zom=10,cur_nim=0,cur_wbl=0; size_t res_table[][2] = {{0,0},{640,480},{320,240},{160,120},{352,288},{176,144},{480,272},{640,360},{640,360}}; size_t fps_table[] = {3,5,7,10,15,20,30}; sceCameraOpen(cur_cam, &(SceCameraInfo){ .size = sizeof(SceCameraInfo), .format = cur_fmt,//422_TO_ABGR .resolution = cur_res, .framerate = fps_table[cur_fps], .sizeIBase = 4*res_table[cur_res][0]*res_table[cur_res][1], .pitch = 4*(DISPLAY_WIDTH-res_table[cur_res][0]), .pIBase = base, }); sceCameraStart(cur_cam); do{ ctrl_press = ctrl_peek; sceCtrlPeekBufferPositive(0, &ctrl_peek, 1); ctrl_press.buttons = ctrl_peek.buttons & ~ctrl_press.buttons; sceCameraSetBrightness(cur_cam, ctrl_press.rx); sceCameraSetContrast(cur_cam, ctrl_press.ry-100); sceCameraSetEV(cur_cam, (ctrl_press.lx-128)/7);//-20...20 sceCameraSetGain(cur_cam, (ctrl_press.ly<100)?ctrl_press.ly/6:0);//0..16 //don't seem to work if(ctrl_press.buttons & SCE_CTRL_TRIANGLE) sceCameraSetSaturation(cur_cam, cur_sat=((cur_sat+5)%45)); if(ctrl_press.buttons & SCE_CTRL_CIRCLE) sceCameraSetReverse(cur_cam, cur_rev=((cur_rev+1)%4)); if(ctrl_press.buttons & SCE_CTRL_CROSS) sceCameraSetISO(cur_cam,(int[]){1,100,200,400}[cur_iso=((cur_iso+1)%4)]); if(ctrl_press.buttons & SCE_CTRL_SQUARE) sceCameraSetEffect(cur_cam, cur_efx=((cur_efx+1)%7)); if(ctrl_press.buttons & SCE_CTRL_LTRIGGER) sceCameraSetWhiteBalance(cur_cam, cur_wbl=((cur_wbl+1)%4)); if(ctrl_press.buttons & SCE_CTRL_RTRIGGER) sceCameraSetNightmode(cur_cam, cur_nim=((cur_nim+1)%4)); if(ctrl_press.buttons & SCE_CTRL_SELECT) sceCameraSetZoom(cur_cam, cur_zom=((cur_zom+1)%41)); /* TODO: find more button combo to trigg : sceCameraSetAntiFlicker(int cur_cam, int mode); sceCameraSetBacklight(int cur_cam, int mode); */ if(sceCameraIsActive(cur_cam)>0){ SceCameraRead read = {sizeof(SceCameraRead),0/*<Blocking*/}; sceCameraRead(cur_cam, &read); sceDisplaySetFrameBuf(&dbuf, SCE_DISPLAY_SETBUF_NEXTFRAME); } }while(!(ctrl_press.buttons & (SCE_CTRL_UP|SCE_CTRL_DOWN|SCE_CTRL_LEFT|SCE_CTRL_RIGHT|SCE_CTRL_START))); sceCameraStop(cur_cam); sceCameraClose(cur_cam); if(ctrl_press.buttons & SCE_CTRL_UP) cur_res=(cur_res+1)%ARRAYSIZE(res_table); if(ctrl_press.buttons & SCE_CTRL_DOWN) cur_cam=(cur_cam+1)%2; if(ctrl_press.buttons & SCE_CTRL_LEFT) cur_fps=(cur_fps+1)%ARRAYSIZE(fps_table); //may overflow the drawbuffer => TODO:reallocate drawbuff on format change //if(ctrl_press.buttons & SCE_CTRL_RIGHT) // cur_fmt=(cur_fmt+1)%9; }while(!(ctrl_press.buttons & SCE_CTRL_START));