mirror of
https://github.com/libretro/RetroArch
synced 2024-12-29 12:31:05 +00:00
(PSP1) Add preliminary PSP1 video driver
This commit is contained in:
parent
775ac2a189
commit
728b775905
@ -37,7 +37,8 @@ enum
|
||||
VIDEO_WII,
|
||||
VIDEO_XENON360,
|
||||
VIDEO_XDK_D3D,
|
||||
VIDEO_PSP2_GXM,
|
||||
VIDEO_PSP1,
|
||||
VIDEO_PSP2,
|
||||
VIDEO_D3D9,
|
||||
VIDEO_VG,
|
||||
VIDEO_NULL,
|
||||
@ -86,6 +87,10 @@ enum
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_D3D9
|
||||
#elif defined(HAVE_VG)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_VG
|
||||
#elif defined(SN_TARGET_PSP2)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_PSP2
|
||||
#elif defined(PSP)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_PSP1
|
||||
#elif defined(HAVE_XVIDEO)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_XVIDEO
|
||||
#elif defined(HAVE_SDL)
|
||||
|
@ -164,6 +164,8 @@ VIDEO DRIVER
|
||||
#include "../../gx/gx_video.c"
|
||||
#elif defined(SN_TARGET_PSP2)
|
||||
#include "../../psp2/psp2_video.c"
|
||||
#elif defined(PSP)
|
||||
#include "../../psp1/psp1_video.c"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
|
5
driver.c
5
driver.c
@ -99,7 +99,10 @@ static const video_driver_t *video_drivers[] = {
|
||||
&video_d3d9,
|
||||
#endif
|
||||
#ifdef SN_TARGET_PSP2
|
||||
&video_psp2_gxm,
|
||||
&video_psp2,
|
||||
#endif
|
||||
#ifdef PSP
|
||||
&video_psp1,
|
||||
#endif
|
||||
#ifdef HAVE_SDL
|
||||
&video_sdl,
|
||||
|
3
driver.h
3
driver.h
@ -290,7 +290,8 @@ extern const audio_driver_t audio_ps3;
|
||||
extern const audio_driver_t audio_gx;
|
||||
extern const audio_driver_t audio_null;
|
||||
extern const video_driver_t video_gl;
|
||||
extern const video_driver_t video_psp2_gxm;
|
||||
extern const video_driver_t video_psp1;
|
||||
extern const video_driver_t video_psp2;
|
||||
extern const video_driver_t video_d3d9;
|
||||
extern const video_driver_t video_gx;
|
||||
extern const video_driver_t video_xenon360;
|
||||
|
187
psp1/psp1_video.c
Normal file
187
psp1/psp1_video.c
Normal file
@ -0,0 +1,187 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <pspkernel.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspgpu.h>
|
||||
|
||||
#include "../psp/sdk_defines.h"
|
||||
#include "../general.h"
|
||||
#include "../driver.h"
|
||||
|
||||
#define PSP_SCREEN_WIDTH 480
|
||||
#define PSP_SCREEN_HEIGHT 272
|
||||
#define PSP_LINE_SIZE 512
|
||||
|
||||
typedef struct psp1_video
|
||||
{
|
||||
bool rgb32;
|
||||
unsigned tex_w;
|
||||
unsigned tex_h;
|
||||
} psp1_video_t;
|
||||
|
||||
static unsigned int __attribute__((aligned(16))) list[262144];
|
||||
|
||||
|
||||
static void init_texture(void *data, const video_info_t *video)
|
||||
{
|
||||
sceGuInit();
|
||||
sceGuStart(GU_DIRECT, list);
|
||||
|
||||
sceGuDrawBuffer(vid->rgb32 ? GU_PSM_8888 : GU_PSM_5650, (void*)0, PSP_LINE_SIZE);
|
||||
sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)0x88000, PSP_LINE_SIZE);
|
||||
sceGuClear(GU_COLOR_BUFFER_BIT);
|
||||
|
||||
sceGuOffset(2048 - (PSP_SCREEN_WIDTH / 2), 2048 - (PSP_SCREEN_HEIGHT / 2));
|
||||
sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
|
||||
|
||||
/* FIXME - we will want to disable all this */
|
||||
sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
|
||||
sceGuEnable(GU_SCISSOR_TEST);
|
||||
sceGuTexMode(vid->rgb32 ? GU_PSM_8888 : GU_PSM_5650, 0, 0, GU_FALSE);
|
||||
sceGuTxFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
|
||||
sceGuTexFilter(GU_LINEAR, GU_LINEAR);
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
|
||||
sceGuFrontFace(GU_CW);
|
||||
sceGuDisable(GU_BLEND);
|
||||
|
||||
sceGuFinish();
|
||||
sceGuSync(0, 0);
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
sceGuDisplay(GU_TRUE);
|
||||
|
||||
vid->rgb32 = video->rgb32;
|
||||
}
|
||||
|
||||
static void *psp_gfx_init(const video_info_t *video,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
(void)video;
|
||||
|
||||
if (driver.video_data)
|
||||
{
|
||||
psp1_video_t *vid = (psp1_video_t*)driver.video_data;
|
||||
|
||||
/* Reinitialize textures here */
|
||||
init_texture(vid, video);
|
||||
|
||||
return driver.video_data;
|
||||
}
|
||||
|
||||
psp1_video_t *vid = (psp1_video_t*)calloc(1, sizeof(psp1_video_t));
|
||||
|
||||
if (!vid)
|
||||
goto error;
|
||||
|
||||
init_texture(vid, video);
|
||||
|
||||
vid->tex_w = 512;
|
||||
vid->tex_h = 512;
|
||||
|
||||
return vid;
|
||||
error:
|
||||
RARCH_ERR("PSP1 video could not be initialized.\n");
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
static bool psp_gfx_frame(void *data, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
(void)width;
|
||||
(void)height;
|
||||
(void)pitch;
|
||||
(void)msg;
|
||||
|
||||
if(!frame)
|
||||
return true;
|
||||
|
||||
psp1_video_t *vid = (psp1_video_t*)data;
|
||||
|
||||
sceKernelDcacheWritebackInvalidateAll();
|
||||
|
||||
sceGuStart(GU_DIRECT, list);
|
||||
|
||||
sceGumMatrixMode(GU_PROJECTION);
|
||||
sceGumLoadIdentity();
|
||||
sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);
|
||||
|
||||
sceGumMatrixMode(GU_VIEW);
|
||||
sceGumLoadIdentity();
|
||||
|
||||
sceGuClearColor(GU_COLOR(0.0f,0.0f,0.0f,1.0f));
|
||||
sceGuClearDepth(0);
|
||||
|
||||
sceGuFinish();
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
sceDisplaySetFrameBuf(frame, pitch,
|
||||
vid->rgb32 ? PSP_DISPLAY_PIXEL_FORMAT_8888 : PSP_DISPLAY_PIXEL_FORMAT_565,
|
||||
PSP_DISPLAY_SETBUF_IMMEDIATE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void psp_gfx_set_nonblock_state(void *data, bool toggle)
|
||||
{
|
||||
(void)data;
|
||||
(void)toggle;
|
||||
}
|
||||
|
||||
static bool psp_gfx_alive(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool psp_gfx_focus(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void psp_gfx_free(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
sceGuTerm();
|
||||
}
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
static void psp_gfx_start(void) {}
|
||||
static void psp_gfx_restart(void) {}
|
||||
static void psp_gfx_stop(void) {}
|
||||
#endif
|
||||
|
||||
const video_driver_t video_psp1 = {
|
||||
psp_gfx_init,
|
||||
psp_gfx_frame,
|
||||
psp_gfx_set_nonblock_state,
|
||||
psp_gfx_alive,
|
||||
psp_gfx_focus,
|
||||
NULL,
|
||||
psp_gfx_free,
|
||||
"psp1",
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
psp_gfx_start,
|
||||
psp_gfx_stop,
|
||||
psp_gfx_restart,
|
||||
#endif
|
||||
};
|
||||
|
@ -518,7 +518,7 @@ static void psp2_gfx_restart(void) {}
|
||||
static void psp2_gfx_stop(void) {}
|
||||
#endif
|
||||
|
||||
const video_driver_t video_psp2_gxm = {
|
||||
const video_driver_t video_psp2 = {
|
||||
psp2_gfx_init,
|
||||
psp2_gfx_frame,
|
||||
psp2_gfx_set_nonblock_state,
|
||||
@ -526,7 +526,7 @@ const video_driver_t video_psp2_gxm = {
|
||||
psp2_gfx_focus,
|
||||
NULL,
|
||||
psp2_gfx_free,
|
||||
"psp2_gxm",
|
||||
"psp2",
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
psp2_gfx_start,
|
||||
|
@ -90,8 +90,10 @@ const char *config_get_default_video(void)
|
||||
return "xdk_d3d";
|
||||
case VIDEO_D3D9:
|
||||
return "d3d9";
|
||||
case VIDEO_PSP2_GXM:
|
||||
return "psp2_gxm";
|
||||
case VIDEO_PSP1:
|
||||
return "psp1";
|
||||
case VIDEO_PSP2:
|
||||
return "psp2";
|
||||
case VIDEO_XVIDEO:
|
||||
return "xvideo";
|
||||
case VIDEO_SDL:
|
||||
|
Loading…
Reference in New Issue
Block a user