//Dessine une tile de la texture sélectionnée. Eviter d'utiliser à l'extérieur. void oslDrawTextTile(int u, int v, int x, int y, int tX, int tY) { int color = oslBlendColor(osl_textColor); //If enabled, draw the background if (osl_textBkColor & 0xff000000) oslDrawTextTileBack(x, y, tX, tY); tX += osl_curFont->addedSpace; OSL_FAST_VERTEX_COLOR32 *vertices; vertices = (OSL_FAST_VERTEX_COLOR32*)sceGuGetMemory(2 * sizeof(OSL_FAST_VERTEX_COLOR32)); vertices[0].u = u; vertices[0].v = v; vertices[0].color = color; vertices[0].x = x; vertices[0].y = y; vertices[0].z = 0; vertices[1].u = u+tX; vertices[1].v = v+tY; vertices[1].color = color; vertices[1].x = x+tX; vertices[1].y = y+tY; vertices[1].z = 0; int wasEnable = osl_textureEnabled; oslEnableTexturing(); sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices); sceKernelDcacheWritebackRange(vertices, 2 * sizeof(OSL_FAST_VERTEX_COLOR32)); //SAKYA if (!wasEnable) oslDisableTexturing(); }
void ya2d_drawRotateTexture(ya2d_Texture *texp, int x, int y, float angle) { if(!texp->data) return; sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(texp->texPSM, 0, 0, texp->isSwizzled); sceGuTexFunc(GU_TFX_REPLACE, texp->hasAlpha ? GU_TCC_RGBA : GU_TCC_RGB); ya2d_setTexture(texp); sceGumPushMatrix(); sceGumLoadIdentity(); { ScePspFVector3 pos = {x + (float)texp->centerX, y + (float)texp->centerY, 0.0f}; sceGumTranslate(&pos); sceGumRotateZ(angle); } ya2d_FloatTextureVertex *vertices = (ya2d_FloatTextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_FloatTextureVertex)); vertices[0] = (ya2d_FloatTextureVertex){0.0f, 0.0f, (float)-texp->centerX, (float)-texp->centerY, 0.0f}; vertices[1] = (ya2d_FloatTextureVertex){0.0f, 1.0f, (float)-texp->centerX, (float)texp->centerY, 0.0f}; vertices[2] = (ya2d_FloatTextureVertex){1.0f, 0.0f, (float)texp->centerX, (float)-texp->centerY, 0.0f}; vertices[3] = (ya2d_FloatTextureVertex){1.0f, 1.0f, (float)texp->centerX, (float)texp->centerY, 0.0f}; sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, vertices); sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_FloatTextureVertex)); sceGumPopMatrix(); }
void oslDrawTextTileBack(int x, int y, int tX, int tY) { int color = oslBlendColor(osl_textBkColor); OSL_LINE_VERTEX_COLOR32 *vertices; vertices = (OSL_LINE_VERTEX_COLOR32*)sceGuGetMemory(2 * sizeof(OSL_LINE_VERTEX_COLOR32)); // x += osl_curFont->addedSpace; //<-- STAS: tX seems to be more appropiate here :-) tX += osl_curFont->addedSpace; //<-- STAS END --> vertices[0].color = color; vertices[0].x = x; vertices[0].y = y; vertices[0].z = 0; vertices[1].color = color; vertices[1].x = x+tX; vertices[1].y = y+tY; vertices[1].z = 0; int wasEnable = osl_textureEnabled; oslDisableTexturing(); sceGuDrawArray(GU_SPRITES,GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices); sceKernelDcacheWritebackRange(vertices, 2 * sizeof(OSL_LINE_VERTEX_COLOR32)); //SAKYA if (wasEnable) oslEnableTexturing(); }
void nextBoxHasColor(int *x, int *y, HasColorMode mode) { VertexColor *sendVertices = mode & HASCOLOR_RGBA_TRANSPARENT ? transparentColorVertices : colorVertices; sendVertices[0].x = *x; sendVertices[0].y = *y; sendVertices[1].x = *x + 40; sendVertices[1].y = *y + 20; *x += 47; if (*x >= 470) { *x = 10; *y += 26; } sceKernelDcacheWritebackRange(sendVertices, sizeof(colorVertices)); sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE); sceGuTexFunc(GU_TFX_DECAL, mode & HASCOLOR_RGB ? GU_TCC_RGB : GU_TCC_RGBA); sceGuTexImage(0, 4, 4, 16, imageData); sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, sendVertices); sceGuFinish(); sceGuSync(GU_SYNC_LIST, GU_SYNC_WHAT_DONE); sceGuSync(0, 0); sceGuStart(GU_DIRECT, list); }
void ya2d_drawTexture(ya2d_Texture *texp, int x, int y) { if(!texp->data) return; sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(texp->texPSM, 0, 0, texp->isSwizzled); sceGuTexFunc(GU_TFX_REPLACE, texp->hasAlpha ? GU_TCC_RGBA : GU_TCC_RGB); ya2d_setTexture(texp); if(texp->textureWidth <= YA2D_TEXTURE_SLICE) { ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_TextureVertex)); vertices[0] = (ya2d_TextureVertex){0, 0, x, y, 0}; vertices[1] = (ya2d_TextureVertex){0, texp->textureHeight, x, y+texp->textureHeight, 0}; vertices[2] = (ya2d_TextureVertex){texp->textureWidth, 0, x+texp->textureWidth, y, 0}; vertices[3] = (ya2d_TextureVertex){texp->textureWidth, texp->textureHeight, x+texp->textureWidth, y+texp->textureHeight, 0}; sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices); sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_TextureVertex)); } else //Fast draw for big textures { int i; for(i = 0; i < texp->textureWidth; i+= YA2D_TEXTURE_SLICE) { /* ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_TextureVertex)); vertices[0] = (ya2d_TextureVertex){i, 0, x+i, y, 0}; vertices[1] = (ya2d_TextureVertex){i+YA2D_TEXTURE_SLICE, 0, x+i+YA2D_TEXTURE_SLICE, y, 0}; vertices[2] = (ya2d_TextureVertex){i, texp->textureHeight, x+i, y+texp->textureHeight, 0}; vertices[3] = (ya2d_TextureVertex){i+YA2D_TEXTURE_SLICE, texp->textureHeight, x+i+YA2D_TEXTURE_SLICE, y+texp->textureHeight, 0}; sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices); sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_TextureVertex)); */ ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(2 * sizeof(ya2d_TextureVertex)); vertices[0] = (ya2d_TextureVertex){i, 0, x+i, y, 0}; vertices[1] = (ya2d_TextureVertex){i+YA2D_TEXTURE_SLICE, texp->textureHeight, x+i+YA2D_TEXTURE_SLICE, y+texp->textureHeight, 0}; sceGumDrawArray(GU_SPRITES, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 2, 0, vertices); sceKernelDcacheWritebackRange(vertices, 2 * sizeof(ya2d_TextureVertex)); } } }
void ya2d_drawFillRect(int x, int y, int w, int h, u32 color) { sceGuDisable(GU_TEXTURE_2D); ya2d_FastVertex *vertices = (ya2d_FastVertex *)sceGuGetMemory(4 * sizeof(ya2d_FastVertex)); vertices[0] = (ya2d_FastVertex){color, x, y}; vertices[1] = (ya2d_FastVertex){color, x, y+h}; vertices[2] = (ya2d_FastVertex){color, x+w, y}; vertices[3] = (ya2d_FastVertex){color, x+w, y+h}; sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices); sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_FastVertex)); }
// OK int sceUsbAcc_internal_2A100C1F(struct UsbdDeviceReq *lpReq) // at 0x00000154 { u8 *lpData = lpReq->data; if (!g_bAttached) { return (0x80243007); } if ((lpData[3] < 61) == 0) { return (0x80243002); } sceKernelDcacheWritebackRange(lpData, lpReq->size); lpReq->endp = &g_endp; lpReq->size= lpData[3] + 4; return (sceUsbbdReqSend(lpReq)); }
static void psp_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { psp1_video_t *psp = (psp1_video_t*)data; (void) rgb32; (void) alpha; #ifdef DEBUG /* psp->menu.frame buffer size is (480 * 272)*2 Bytes */ rarch_assert((width*height) < (480 * 272)); #endif psp_set_screen_coords(psp->menu.frame_coords, 0, 0, SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT, 0); psp_set_tex_coords(psp->menu.frame_coords, width, height); sceKernelDcacheWritebackRange(frame, width * height * 2); sceGuStart(GU_DIRECT, psp->main_dList); sceGuCopyImage(GU_PSM_4444, 0, 0, width, height, width, (void*)frame, 0, 0, width, psp->menu.frame); sceGuFinish(); sceGuStart(GU_SEND, psp->menu.dList); sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE); sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB); sceGuTexFilter(GU_LINEAR, GU_LINEAR); sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->menu.frame); sceGuEnable(GU_BLEND); #if 0 /* default blending */ sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); #endif sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); ; sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, psp->menu.frame_coords); sceGuFinish(); }
void nextBox(int *x, int *y) { vertices[0].x = *x; vertices[0].y = *y; vertices[1].x = *x + 40; vertices[1].y = *y + 20; *x += 47; if (*x >= 470) { *x = 10; *y += 26; } sceKernelDcacheWritebackRange(vertices, sizeof(vertices)); sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE); sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGBA); sceGuTexImage(0, 4, 4, 16, imageData); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, vertices); sceGuFinish(); sceGuSync(GU_SYNC_LIST, GU_SYNC_WHAT_DONE); sceGuSync(0, 0); sceGuStart(GU_DIRECT, list); }
static bool psp_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { static char fps_txt[128], fps_text_buf[128]; psp1_video_t *psp = (psp1_video_t*)data; #ifdef DISPLAY_FPS static uint64_t currentTick,lastTick; static float fps=0.0; static int frames; #endif if (!width || !height) return false; if (((uint32_t)frame&0x04000000) || (frame == RETRO_HW_FRAME_BUFFER_VALID)) psp->hw_render = true; else if (frame) psp->hw_render = false; if (!psp->hw_render) sceGuSync(0, 0); /* let the core decide when to sync when HW_RENDER */ pspDebugScreenSetBase(psp->draw_buffer); pspDebugScreenSetXY(0,0); video_monitor_get_fps(fps_txt, sizeof(fps_txt), g_settings.fps_show ? fps_text_buf : NULL, g_settings.fps_show ? sizeof(fps_text_buf) : 0); if(g_settings.fps_show) { pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0); pspDebugScreenPuts(fps_text_buf); pspDebugScreenSetXY(0,1); } if (msg) pspDebugScreenPuts(msg); if ((psp->vsync)&&(psp->vblank_not_reached)) sceDisplayWaitVblankStart(); psp->vblank_not_reached = true; #ifdef DISPLAY_FPS frames++; sceRtcGetCurrentTick(¤tTick); uint32_t diff = currentTick - lastTick; if(diff > 1000000) { fps = (float)frames * 1000000.0 / diff; lastTick = currentTick; frames = 0; } pspDebugScreenSetXY(0,0); pspDebugScreenPrintf("%f", fps); #endif psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers()); g_extern.frame_count++; RARCH_PERFORMANCE_INIT(psp_frame_run); RARCH_PERFORMANCE_START(psp_frame_run); if (psp->should_resize) psp_update_viewport(psp); psp_set_tex_coords(psp->frame_coords, width, height); sceGuStart(GU_DIRECT, psp->main_dList); sceGuTexFilter(psp->tex_filter, psp->tex_filter); sceGuClear(GU_COLOR_BUFFER_BIT); /* frame in VRAM ? texture/palette was * set in core so draw directly */ if (psp->hw_render) sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); else { if (frame) { sceKernelDcacheWritebackRange(frame,pitch * height); sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2, 0, width, height, pitch >> psp->bpp_log2, (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture); } sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture); sceGuCallList(psp->frame_dList); } sceGuFinish(); RARCH_PERFORMANCE_STOP(psp_frame_run); if(psp->menu.active) { sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage)); sceGuSync(0, 0); } return true; }
void retro_run(void) { int i; bool updated = false; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) check_variables(); input_poll_cb(); for (i=0; i < 130; i++) KBD_RES(i); for (i=0; i < sizeof(keymap)/sizeof(keymap_t); i++) if (input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0, keymap[i].retro)) KBD_SET(keymap[i].fmsx); joystate = 0; for (i = 0; i < sizeof(joymap) / sizeof(keymap_t); i++) { if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, joymap[i].retro)) { if (i < joy_keyboard_begin) JOY_SET(joymap[i].fmsx); else KBD_SET(joymap[i].fmsx); } } RETRO_PERFORMANCE_INIT(core_retro_run); RETRO_PERFORMANCE_START(core_retro_run); RunZ80(&CPU); RenderAndPlayAudio(SND_RATE / 60); RETRO_PERFORMANCE_STOP(core_retro_run); fflush(stdout); #ifdef PSP static unsigned int __attribute__((aligned(16))) d_list[32]; void* const texture_vram_p = (void*) (0x44200000 - (640 * 480)); // max VRAM address - frame size sceKernelDcacheWritebackRange(XBuf, 256*240 ); sceGuStart(GU_DIRECT, d_list); sceGuCopyImage(GU_PSM_5650, 0, 0, image_buffer_width, image_buffer_height, image_buffer_width, image_buffer, 0, 0, image_buffer_width, texture_vram_p); sceGuTexSync(); sceGuTexImage(0, 512, 256, image_buffer_width, texture_vram_p); sceGuTexMode(GU_PSM_5650, 0, 0, GU_FALSE); sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB); sceGuDisable(GU_BLEND); sceGuFinish(); video_cb(texture_vram_p, image_buffer_width, image_buffer_height, image_buffer_width * sizeof(uint16_t)); #else video_cb(image_buffer, image_buffer_width, image_buffer_height, image_buffer_width * sizeof(uint16_t)); #endif }
// OK int RecvCtrl(int arg1, int arg2, struct DeviceRequest *lpDevReq) // 0x1DC { /*s0 = a2; s1 = &g_usbDevReq; asm("lwl $v0, 3($s0)"); asm("lwr $v0, 0($s0)"); asm("lwl $v1, 7($s0)"); asm("lwr $v1, 4($s0)"); asm("swl $v0, -5($s1)"); asm("swr $v0, -8($s1)"); asm("swl $v1, -1($s1)"); asm("swr $v1, -4($s1)");*/ g_devReq = *lpDevReq; if (arg2 < 0) { return (-1); } static struct DeviceRequest devReq[] = // 0x00000 + 3084, 0x0C0C { { 0xC1, 0x01, 0x0000, 0x0000, 0x0000 }, { 0x41, 0x01, 0x0000, 0x0000, 0x0000 }, }; int i; for (i = 0; i < 2; i++) { if (lpDevReq->bmRequestType == devReq[i].bmRequestType) { if (lpDevReq->bRequest == devReq[i].bRequest) { break; } } } if (i == 2) { return (-1); } if (lpDevReq->bmRequestType < 0) { if (lpDevReq->bRequest != 1) { return (-1); } if (sceUsbBus_driver_48CCE3C1()) { if (g_type == (g_type & lpDevReq->wValue)) { *(s8*)(g_usbDevReq.data +0) = 0; sceUsbBus_driver_FBA2072B(); } } else { *(s8*)(g_usbDevReq.data + 0) = lpDevReq->bRequest; } g_usbDevReq.size = 1; sceKernelDcacheWritebackRange(g_usbDevReq.data, 1); sceUsbbdReqSend(&g_usbDevReq); return (0); } if (lpDevReq->bRequest != 1) { return (-1); } sceKernelDcacheInvalidateRange(g_usbDevReq.data, 64); g_usbDevReq.size = 64; sceUsbbdReqRecv(&g_usbDevReq); return (0); }
static bool psp_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { static char fps_txt[128], fps_text_buf[128]; psp1_video_t *psp = (psp1_video_t*)data; #ifdef DISPLAY_FPS static uint64_t currentTick,lastTick; static float fps=0.0; static int frames; #endif if (!width || !height) return false; sceGuSync(0, 0); pspDebugScreenSetBase(psp->draw_buffer); pspDebugScreenSetXY(0,0); if(g_settings.fps_show) { gfx_get_fps(fps_txt, sizeof(fps_txt), fps_text_buf, sizeof(fps_text_buf)); pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0); pspDebugScreenPuts(fps_text_buf); pspDebugScreenSetXY(0,1); } else gfx_get_fps(fps_txt, sizeof(fps_txt), NULL, 0); if (msg) pspDebugScreenPuts(msg); if (psp->vsync) sceDisplayWaitVblankStart(); #ifdef DISPLAY_FPS frames++; sceRtcGetCurrentTick(¤tTick); uint32_t diff = currentTick - lastTick; if(diff > 1000000) { fps = (float)frames * 1000000.0 / diff; lastTick = currentTick; frames = 0; } pspDebugScreenSetXY(0,0); pspDebugScreenPrintf("%f", fps); #endif psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers()); g_extern.frame_count++; psp->frame_coords->v0.x = (SCEGU_SCR_WIDTH - width * SCEGU_SCR_HEIGHT / height) / 2; // psp->frame_coords->v0.y = 0; // psp->frame_coords->v0.u = 0; // psp->frame_coords->v0.v = 0; psp->frame_coords->v1.x = (SCEGU_SCR_WIDTH + width * SCEGU_SCR_HEIGHT / height) / 2; // psp->frame_coords->v1.y = SCEGU_SCR_HEIGHT; psp->frame_coords->v1.u = width; psp->frame_coords->v1.v = height; sceGuStart(GU_DIRECT, psp->main_dList); if ((uint32_t)frame&0x04000000) // frame in VRAM ? texture/palette was set in core so draw directly { sceGuClear(GU_COLOR_BUFFER_BIT); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_4444 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, (void*)(psp->frame_coords)); } else { if (frame!=NULL) { sceKernelDcacheWritebackRange(frame,pitch * height); sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2, 0, width, height, pitch >> psp->bpp_log2, (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture); } sceGuClear(GU_COLOR_BUFFER_BIT); sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture); sceGuCallList(psp->frame_dList); }
virtual void flushDataCache(void *ptr, uint32 len) const { sceKernelDcacheWritebackRange(ptr, len); sceKernelIcacheInvalidateRange(ptr, len); }