static void flip(glw_ps3_t *gp, s32 buffer) { gcmSetFlip(gp->gr.gr_be.be_ctx, buffer); realityFlushBuffer(gp->gr.gr_be.be_ctx); gcmSetWaitFlip(gp->gr.gr_be.be_ctx); }
void videoFinish ( videoData *vdata ) { dbgprintf ( "video finishing" ) ; static s32 i ; /* make sure no flip is in progress */ gcmSetWaitFlip ( vdata->context ) ; /* free rsx buffers */ for ( i = 0 ; i < MAX_BUFFERS ; i++ ) { rsxFree ( vdata->rsx_buffers[i].ptr ) ; } /* finish rsx context */ rsxFinish ( vdata->context, 1 ) ; /* free host_addr memory */ free ( vdata->host_addr ) ; /* destroy semaphore */ sysSemDestroy ( vdata->sem ) ; /* destroy cond */ sysCondDestroy ( vdata->cond ) ; /* destroy mutex */ sysMutexDestroy ( vdata->mutex ) ; }
void program_exit_callback() { gcmSetWaitFlip(context); rsxFinish(context,1); shutdown_spu(); }
/* Enqueue a flip command in RSX command buffer. Setup next screen to be drawn to. */ void flip(displayData *vdat) { s32 status = gcmSetFlip(vdat->context, vdat->curr_fb); assert(status == 0); rsxFlushBuffer(vdat->context); gcmSetWaitFlip(vdat->context); vdat->curr_fb = !vdat->curr_fb; ++vdat->framecnt; }
int flip(gcmContextData *context, s32 buffer){ if(gcmSetFlip(context, buffer) == 0) { rsxFlushBuffer(context); // Prevent the RSX from continuing until the flip has finished. gcmSetWaitFlip(context); return TRUE; } return FALSE; }
int main() { sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, sysutil_callback, NULL); void *host_addr = memalign(1024*1024, HOST_SIZE); init_screen(host_addr, HOST_SIZE); setRenderTarget(curr_fb); int payload = payload_status(); /* char dlgmsg[256]; sprintf(dlgmsg, "Payload: %d", payload); showDialog(dlgmsg); */ if(payload == ZERO_PAYLOAD) { s32 fd = 0; int bdemu = bdemu_version(&fd); if(bdemu == 0) { //Wrong or inexistent file. lv2buzzer(0x1004, 0xa, 0x1b6); showDialog("Couldn't find correct \"BDEMU.BIN\"."); } else { int fw_version = get_version(); if(fw_version == FW_355_VALUE) { if(bdemu == 2) { payload_sky(fd); } else { payload_dean(fd); } } else if(fw_version == FW_341_VALUE && bdemu == 2) { payload_hermes(fd); } else { lv2buzzer(0x1004, 0xa, 0x1b6); showDialog("BDEMU.BIN doesn't suppoort your firmware."); } } } msgDialogAbort(); gcmSetWaitFlip(context); rsxFinish(context, 1); //Launch Application on exit. sysProcessExitSpawn2(APP_LAUNCH, NULL, NULL, NULL, 0, 1001, SYS_PROCESS_SPAWN_STACK_SIZE_1M); return 0; }
void NoRSX::NoRSX_Exit(){ gcmSetWaitFlip(context); for (int i=0;i<2;i++) rsxFree (buffers[i].ptr); rsxFree(buffer); rsxFinish (context, 1); free (host_addr); UnregisterCallBack(EVENT_SLOT0); already_done=1; return; }
void endScreen () { int i; gcmSetWaitFlip (context); for (i = 0; i < MAX_BUFFERS; i++) rsxFree (buffers[i].ptr); rsxFinish (context, 1); free (host_addr); }
void flip() { if(!first_fb) waitflip(); else gcmResetFlipStatus(); gcmSetFlip(context,curr_fb); rsxFlushBuffer(context); gcmSetWaitFlip(context); curr_fb ^= 1; setRenderTarget(curr_fb); first_fb = 0; }
static void psl1ght_displaytarget_display(struct sw_winsys *ws, struct sw_displaytarget *dt, void *context_private) { struct psl1ght_sw_winsys *psl1ght = psl1ght_sw_winsys(ws); struct psl1ght_sw_displaytarget *psdt = psl1ght_sw_displaytarget(dt); if (psdt->bufferId == NO_BUFFER) { if (!psl1ght_displaytarget_set_buffer(psl1ght, psdt)) return; } gcmResetFlipStatus(); if (!gcmSetFlip(psl1ght->ctx, psdt->bufferId)) { rsxFlushBuffer(psl1ght->ctx); gcmSetWaitFlip(psl1ght->ctx); } }
void flip(s32 buffer) { assert(gcmSetFlip(context, buffer) == 0); realityFlushBuffer(context); gcmSetWaitFlip(context); // Prevent the RSX from continuing until the flip has finished. }
s32 main(s32 argc, const char* argv[]) { gcmContextData *context; void *host_addr = NULL; rsxBuffer buffers[MAX_BUFFERS]; int currentBuffer = 0; padInfo padinfo ; padData paddata ; u16 width; u16 height; int i; long frame = 0; /* to keep track of how many frames we have rendered */ atexit(unload_modules); if(sysModuleLoad(SYSMODULE_FS) != 0) return 0; else module_flag |= 1; if(sysModuleLoad(SYSMODULE_PNGDEC) != 0) return 0; else module_flag |= 2; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary * to be our shared IO memory with the RSX. */ host_addr = memalign ( 1024*1024, HOST_SIZE ) ; context = screenInit ( host_addr, HOST_SIZE ) ; getResolution( &width, &height ) ; for (i = 0; i < MAX_BUFFERS; i++) makeBuffer( &buffers[i], width, height, i ) ; flip( context, MAX_BUFFERS - 1 ) ; setRenderTarget(context, &buffers[currentBuffer]) ; sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandler, NULL); ioPadInit(7) ; /* png bitmap buffer */ pngData png1; #if USE_PNG_FROM_FILE == true const char *filename = PNG_FILE; /* load png from file */ pngLoadFromFile(filename, &png1); #endif #if USE_PNG_FROM_FILE == false /* load png from memory */ pngLoadFromBuffer((void *)psl1ght_png, psl1ght_png_size, &png1); #endif /* Ok, everything is setup. Now for the main loop. */ exitapp = 1; while(exitapp) { /* Check the pads. */ ioPadGetInfo(&padinfo); for(i=0; i<MAX_PADS; i++){ if(padinfo.status[i]){ ioPadGetData(i, &paddata); if(paddata.BTN_CROSS){ exitapp = 0; goto end; } } } waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer drawFrame(&buffers[currentBuffer], frame++); // Draw into the unused buffer if(png1.bmp_out) { static int x=0, y=0, dx=2, dy=2; u32 *scr = (u32 *)buffers[currentBuffer].ptr; u32 *png= (void *)png1.bmp_out; int n, m; /* update x, y coordinates */ x+=dx; y+=dy; /* */ if(x < 0) { x=0; dx=1; } /* screen width to png width */ if(x > (buffers[currentBuffer].width - png1.width)) { x=(buffers[currentBuffer].width - png1.width); dx=-2; } /* */ if(y < 0) { y=0; dy=1; } /* screen height to png height */ if(y > (buffers[currentBuffer].height - png1.height)) { y = (buffers[currentBuffer].height - png1.height); dy=-2; } /* update screen buffer from coordinates */ scr += y * buffers[currentBuffer].width + x; // draw PNG for(n=0;n<png1.height;n++) { if((y+n)>=buffers[currentBuffer].height) break; for(m=0;m<png1.width;m++) { if((x+m)>=buffers[currentBuffer].width) break; scr[m]=png[m]; } png+=png1.pitch>>2; scr+=buffers[currentBuffer].width; } } flip(context, buffers[currentBuffer].id); /* Flip buffer onto screen */ currentBuffer = !currentBuffer; setRenderTarget(context, &buffers[currentBuffer]) ; /* change buffer */ sysUtilCheckCallback(); /* check user attention span */ } end: gcmSetWaitFlip(context); for (i=0; i < MAX_BUFFERS; i++) rsxFree (buffers[i].ptr); rsxFinish (context, 1); free (host_addr); ioPadEnd(); return 0; }
void flip(s32 buffer) { assert(gcmSetFlip(context, buffer) == 0); realityFlushBuffer(context); gcmSetWaitFlip(context); }
int main(s32 argc, const char* argv[]) { //Mutex. sys_mutex_attr_t attr; memset(&attr, 0, sizeof(attr)); attr.attr_protocol = SYS_MUTEX_PROTOCOL_FIFO; attr.attr_recursive = SYS_MUTEX_ATTR_NOT_RECURSIVE; attr.attr_pshared = SYS_MUTEX_ATTR_PSHARED; attr.attr_adaptive = SYS_MUTEX_ATTR_NOT_ADAPTIVE; strcpy(attr.name, "mutex"); sysMutexCreate(&thread_mutex, &attr); //Threads. THREADS_RUNNING = 2; sys_ppu_thread_t pad_id, program_id; sysThreadCreate(&pad_id, pad_thread, (void*) &GLOBAL_EXIT, 1500, 0x400, 0, "pad"); sysThreadCreate(&program_id, program_thread, (void*) &GLOBAL_EXIT, 1337, 0x400, 0, "program"); //Create buffers. gcmContextData *context; void *host_addr = NULL; rsxBuffer buffers[MAX_BUFFERS]; int currentBuffer = 0; //Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. host_addr = memalign(1024*1024, HOST_SIZE); context = initScreen(host_addr, HOST_SIZE); //Get resolution. u16 width, height; getResolution(&width, &height); //Create buffers. int i; for(i = 0; i < MAX_BUFFERS; i++) { makeBuffer(&buffers[i], width, height, i); } flip(context, MAX_BUFFERS - 1); //Main loop. while(THREADS_RUNNING > 0) { //Prepare buffer. setRenderTarget(context, &buffers[currentBuffer]); waitFlip(); //Flip buffer onto screen. flip(context, buffers[currentBuffer].id); //Change buffer. currentBuffer++; if(currentBuffer >= MAX_BUFFERS) { currentBuffer = 0; } } //Free buffers. gcmSetWaitFlip(context); for(i = 0; i < MAX_BUFFERS; i++) { rsxFree(buffers[i].ptr); } rsxFinish(context, 1); free(host_addr); //Mutex destroy. sysMutexDestroy(thread_mutex); return 0; }
int main (s32 argc, const char* argv[]) { gcmContextData *context; void *host_addr = NULL; rsxBuffer buffers[MAX_BUFFERS]; int currentBuffer = 0; padInfo padinfo; padData paddata; u16 width; u16 height; int frame = 0; int i; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary * to be our shared IO memory with the RSX. */ host_addr = memalign (1024*1024, HOST_SIZE); context = initScreen (host_addr, HOST_SIZE); ioPadInit (7); getResolution(&width, &height); for (i = 0; i < MAX_BUFFERS; i++) makeBuffer (&buffers[i], width, height, i); flip(context, MAX_BUFFERS - 1); DEBUG ("Starting Cairo test\n"); while (1) { ioPadGetInfo (&padinfo); for(i = 0; i < MAX_PADS; i++) { if(padinfo.status[i]) { ioPadGetData (i, &paddata); if(paddata.BTN_START) { goto end; } } } setRenderTarget(context, &buffers[currentBuffer]); DEBUG ("Drawing frame %d\n", frame); waitFlip (); drawFrame (&buffers[currentBuffer], frame++); /* Draw into the unused buffer */ flip (context, buffers[currentBuffer].id); /* Flip buffer onto screen */ currentBuffer++; if (currentBuffer >= MAX_BUFFERS) currentBuffer = 0; } end: gcmSetWaitFlip(context); for (i = 0; i < MAX_BUFFERS; i++) rsxFree (buffers[i].ptr); rsxFinish (context, 1); free (host_addr); ioPadEnd(); return 0; }