commit
8295a173b8
|
@ -1,6 +1,6 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
/* RetroArch - A frontend for libretro.
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* 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-
|
* 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.
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
@ -28,37 +28,39 @@ typedef struct psp1_audio
|
||||||
uint32_t* buffer;
|
uint32_t* buffer;
|
||||||
uint32_t* zeroBuffer;
|
uint32_t* zeroBuffer;
|
||||||
SceUID thread;
|
SceUID thread;
|
||||||
int rate;
|
int rate;
|
||||||
uint16_t readPos;
|
volatile uint16_t readPos;
|
||||||
uint16_t writePos;
|
volatile uint16_t writePos;
|
||||||
} psp1_audio_t;
|
} psp1_audio_t;
|
||||||
|
|
||||||
#define AUDIO_OUT_COUNT 128
|
#define AUDIO_OUT_COUNT 128u
|
||||||
|
#define AUDIO_BUFFER_SIZE (1u<<11u)
|
||||||
#define AUDIO_BUFFER_SIZE (1u<<12u)
|
|
||||||
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
|
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
|
||||||
|
|
||||||
static int audioMainLoop(SceSize args, void* argp)
|
static int audioMainLoop(SceSize args, void* argp)
|
||||||
{
|
{
|
||||||
psp1_audio_t* psp = *((psp1_audio_t**)argp);
|
psp1_audio_t* psp = *((psp1_audio_t**)argp);
|
||||||
|
|
||||||
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
|
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
|
||||||
|
|
||||||
while (psp->running)
|
while (psp->running)
|
||||||
{
|
{
|
||||||
if (((uint16_t)(psp->writePos - psp->readPos) & AUDIO_BUFFER_SIZE_MASK) < (uint16_t)AUDIO_OUT_COUNT * 2)
|
uint16_t readPos = psp->readPos; // get a non volatile copy
|
||||||
|
|
||||||
|
if (((uint16_t)(psp->writePos - readPos) & AUDIO_BUFFER_SIZE_MASK) < (AUDIO_OUT_COUNT * 2))
|
||||||
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, psp->zeroBuffer);
|
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, psp->zeroBuffer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, psp->buffer + psp->readPos);
|
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, psp->buffer + readPos);
|
||||||
psp->readPos += AUDIO_OUT_COUNT;
|
readPos += AUDIO_OUT_COUNT;
|
||||||
psp->readPos &= AUDIO_BUFFER_SIZE_MASK;
|
readPos &= AUDIO_BUFFER_SIZE_MASK;
|
||||||
|
psp->readPos = readPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sceAudioSRCChRelease();
|
sceAudioSRCChRelease();
|
||||||
sceKernelExitThread(0);
|
sceKernelExitThread(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *psp_audio_init(const char *device, unsigned rate, unsigned latency)
|
static void *psp_audio_init(const char *device, unsigned rate, unsigned latency)
|
||||||
|
@ -71,17 +73,21 @@ static void *psp_audio_init(const char *device, unsigned rate, unsigned latency)
|
||||||
if (!psp)
|
if (!psp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
psp->buffer = (uint32_t*)calloc(AUDIO_BUFFER_SIZE, sizeof(uint32_t));
|
psp->buffer = (uint32_t*)memalign(64, AUDIO_BUFFER_SIZE * sizeof(uint32_t)); // cache aligned, not necessary but helpful
|
||||||
|
memset(psp->buffer, 0, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
|
||||||
|
|
||||||
|
psp->zeroBuffer = (uint32_t*)memalign(64, AUDIO_OUT_COUNT * sizeof(uint32_t));
|
||||||
|
memset(psp->zeroBuffer, 0, AUDIO_OUT_COUNT * sizeof(uint32_t));
|
||||||
|
|
||||||
psp->readPos = 0;
|
psp->readPos = 0;
|
||||||
psp->writePos = 0;
|
psp->writePos = 0;
|
||||||
psp->zeroBuffer = (uint32_t*)calloc(AUDIO_OUT_COUNT, sizeof(uint32_t));
|
|
||||||
psp->rate = rate;
|
psp->rate = rate;
|
||||||
psp->thread = sceKernelCreateThread ("audioMainLoop", audioMainLoop, 0x12, 0x10000, 0, NULL);
|
psp->thread = sceKernelCreateThread ("audioMainLoop", audioMainLoop, 0x08, 0x10000, 0, NULL);
|
||||||
psp->nonblocking = false;
|
psp->nonblocking = false;
|
||||||
|
|
||||||
psp->running = true;
|
psp->running = true;
|
||||||
sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp);
|
sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp);
|
||||||
|
|
||||||
return psp;
|
return psp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +101,7 @@ static void psp_audio_free(void *data)
|
||||||
SceUInt timeout = 100000;
|
SceUInt timeout = 100000;
|
||||||
sceKernelWaitThreadEnd(psp->thread, &timeout);
|
sceKernelWaitThreadEnd(psp->thread, &timeout);
|
||||||
sceKernelDeleteThread(psp->thread);
|
sceKernelDeleteThread(psp->thread);
|
||||||
|
|
||||||
free(psp->buffer);
|
free(psp->buffer);
|
||||||
free(psp->zeroBuffer);
|
free(psp->zeroBuffer);
|
||||||
free(psp);
|
free(psp);
|
||||||
|
@ -105,30 +111,27 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
uint16_t sampleCount;
|
uint16_t sampleCount;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp1_audio_t* psp = (psp1_audio_t*)data;
|
||||||
|
uint16_t writePos = psp->writePos;
|
||||||
|
|
||||||
sampleCount= size / sizeof(uint32_t);
|
sampleCount= size / sizeof(uint32_t);
|
||||||
|
|
||||||
printf("size: %i sampleCount %i\n",(int)size , (int) sampleCount);
|
// if (psp->nonblocking)
|
||||||
|
// {
|
||||||
if (psp->nonblocking)
|
// /* TODO */
|
||||||
|
// }
|
||||||
|
|
||||||
|
if((writePos + sampleCount) > AUDIO_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
/* TODO */
|
memcpy(psp->buffer + writePos, buf, (AUDIO_BUFFER_SIZE - writePos) * sizeof(uint32_t));
|
||||||
|
memcpy(psp->buffer, (uint32_t*) buf + (AUDIO_BUFFER_SIZE - writePos), (writePos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
memcpy(psp->buffer + writePos, buf, size);
|
||||||
if((psp->writePos + sampleCount) > AUDIO_BUFFER_SIZE)
|
|
||||||
{
|
writePos += sampleCount;
|
||||||
memcpy(psp->buffer + psp->writePos, buf, (AUDIO_BUFFER_SIZE - psp->writePos) * sizeof(uint32_t));
|
writePos &= AUDIO_BUFFER_SIZE_MASK;
|
||||||
memcpy(psp->buffer, buf, (psp->writePos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t));
|
psp->writePos = writePos;
|
||||||
}
|
|
||||||
else
|
|
||||||
memcpy(psp->buffer + psp->writePos, buf, size);
|
|
||||||
|
|
||||||
psp->writePos += sampleCount;
|
|
||||||
psp->writePos &= AUDIO_BUFFER_SIZE_MASK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return sampleCount;
|
return sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,18 +139,18 @@ static bool psp_audio_stop(void *data)
|
||||||
{
|
{
|
||||||
SceKernelThreadRunStatus runStatus;
|
SceKernelThreadRunStatus runStatus;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp1_audio_t* psp = (psp1_audio_t*)data;
|
||||||
|
|
||||||
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
||||||
|
|
||||||
if (sceKernelReferThreadRunStatus(psp->thread, &runStatus) < 0) // error
|
if (sceKernelReferThreadRunStatus(psp->thread, &runStatus) < 0) // error
|
||||||
return false;
|
return false;
|
||||||
if (runStatus.status == PSP_THREAD_STOPPED)
|
if (runStatus.status == PSP_THREAD_STOPPED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
psp->running = false;
|
psp->running = false;
|
||||||
SceUInt timeout = 100000;
|
SceUInt timeout = 100000;
|
||||||
sceKernelWaitThreadEnd(psp->thread, &timeout);
|
sceKernelWaitThreadEnd(psp->thread, &timeout);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,16 +158,16 @@ static bool psp_audio_start(void *data)
|
||||||
{
|
{
|
||||||
SceKernelThreadRunStatus runStatus;
|
SceKernelThreadRunStatus runStatus;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp1_audio_t* psp = (psp1_audio_t*)data;
|
||||||
|
|
||||||
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
||||||
|
|
||||||
if (sceKernelReferThreadRunStatus(psp->thread, &runStatus) < 0) // error
|
if (sceKernelReferThreadRunStatus(psp->thread, &runStatus) < 0) // error
|
||||||
return false;
|
return false;
|
||||||
if (runStatus.status != PSP_THREAD_STOPPED)
|
if (runStatus.status != PSP_THREAD_STOPPED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
psp->running = true;
|
psp->running = true;
|
||||||
|
|
||||||
sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp);
|
sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -185,7 +188,8 @@ static bool psp_audio_use_float(void *data)
|
||||||
static size_t psp_write_avail(void *data)
|
static size_t psp_write_avail(void *data)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return AUDIO_OUT_COUNT;
|
psp1_audio_t* psp = (psp1_audio_t*)data;
|
||||||
|
return ((uint16_t)(psp->writePos - psp->readPos) & AUDIO_BUFFER_SIZE_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t psp_buffer_size(void *data)
|
static size_t psp_buffer_size(void *data)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Frame buffer */
|
/* Frame buffer */
|
||||||
#define SCEGU_VRAM_TOP 0x04000000
|
#define SCEGU_VRAM_TOP 0x44000000
|
||||||
/* 16bit mode */
|
/* 16bit mode */
|
||||||
#define SCEGU_VRAM_BUFSIZE (SCEGU_VRAM_WIDTH*SCEGU_SCR_HEIGHT*2)
|
#define SCEGU_VRAM_BUFSIZE (SCEGU_VRAM_WIDTH*SCEGU_SCR_HEIGHT*2)
|
||||||
#define SCEGU_VRAM_BP_0 (void *)(SCEGU_VRAM_TOP)
|
#define SCEGU_VRAM_BP_0 (void *)(SCEGU_VRAM_TOP)
|
||||||
|
@ -64,48 +64,48 @@ typedef struct psp1_rgui_frame
|
||||||
int pixel_size;
|
int pixel_size;
|
||||||
|
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
|
|
||||||
unsigned buffer_width;
|
unsigned buffer_width;
|
||||||
unsigned buffer_Height;
|
unsigned buffer_Height;
|
||||||
void* buffer;
|
void* buffer;
|
||||||
|
|
||||||
float alpha;
|
float alpha;
|
||||||
uint32_t alpha_source;
|
uint32_t alpha_source;
|
||||||
uint32_t alpha_dest;
|
uint32_t alpha_dest;
|
||||||
|
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
psp1_copy_frame_func copy_frame;
|
psp1_copy_frame_func copy_frame;
|
||||||
|
|
||||||
} psp1_rgui_frame_t;
|
} psp1_rgui_frame_t;
|
||||||
|
|
||||||
typedef struct psp1_video
|
typedef struct psp1_video
|
||||||
{
|
{
|
||||||
void* displayList;
|
void* displayList;
|
||||||
void* frameBuffers[2];
|
void* frameBuffers[2];
|
||||||
unsigned int drawBuffer_ID;
|
unsigned int drawBuffer_ID;
|
||||||
bool vsync;
|
bool vsync;
|
||||||
|
|
||||||
bool rgb32;
|
bool rgb32;
|
||||||
int pixel_format;
|
int pixel_format;
|
||||||
int pixel_size;
|
int pixel_size;
|
||||||
unsigned buffer_width;
|
unsigned buffer_width;
|
||||||
unsigned buffer_Height;
|
unsigned buffer_Height;
|
||||||
void* buffer;
|
void* buffer;
|
||||||
|
|
||||||
psp1_copy_frame_func copy_frame;
|
psp1_copy_frame_func copy_frame;
|
||||||
|
|
||||||
psp1_rgui_frame_t rgui;
|
psp1_rgui_frame_t rgui;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
bool force_aspect;
|
bool force_aspect;
|
||||||
bool smooth;
|
bool smooth;
|
||||||
unsigned input_scale; // Maximum input size: RARCH_SCALE_BASE * input_scale
|
unsigned input_scale; // Maximum input size: RARCH_SCALE_BASE * input_scale
|
||||||
int rotation;
|
int rotation;
|
||||||
|
|
||||||
} psp1_video_t;
|
} psp1_video_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,11 +120,11 @@ typedef struct psp1_vertex
|
||||||
static void copy_frame_ARGB8888_to_ABGR8888(const void *in_frame, unsigned in_buffer_width,
|
static void copy_frame_ARGB8888_to_ABGR8888(const void *in_frame, unsigned in_buffer_width,
|
||||||
void *out_frame, unsigned out_buffer_width,
|
void *out_frame, unsigned out_buffer_width,
|
||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
const uint32_t *in_p = (const uint32_t*)in_frame;
|
const uint32_t *in_p = (const uint32_t*)in_frame;
|
||||||
uint32_t *out_p = (uint32_t*)out_frame;
|
uint32_t *out_p = (uint32_t*)out_frame;
|
||||||
|
|
||||||
for(y = 0; y < height; y++)
|
for(y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
|
@ -142,11 +142,11 @@ static void copy_frame_ARGB8888_to_ABGR8888(const void *in_frame, unsigned in_bu
|
||||||
static void copy_frame_RGB5650_to_BGR5650(const void *in_frame, unsigned in_buffer_width,
|
static void copy_frame_RGB5650_to_BGR5650(const void *in_frame, unsigned in_buffer_width,
|
||||||
void *out_frame, unsigned out_buffer_width,
|
void *out_frame, unsigned out_buffer_width,
|
||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
const uint16_t *in_p = (const uint16_t*)in_frame;
|
const uint16_t *in_p = (const uint16_t*)in_frame;
|
||||||
uint16_t *out_p = (uint16_t*)out_frame;
|
uint16_t *out_p = (uint16_t*)out_frame;
|
||||||
|
|
||||||
for(y = 0; y < height; y++)
|
for(y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
|
@ -162,11 +162,11 @@ static void copy_frame_RGB5650_to_BGR5650(const void *in_frame, unsigned in_buff
|
||||||
static void copy_frame_XBGR16(const void *in_frame, unsigned in_buffer_width,
|
static void copy_frame_XBGR16(const void *in_frame, unsigned in_buffer_width,
|
||||||
void *out_frame, unsigned out_buffer_width,
|
void *out_frame, unsigned out_buffer_width,
|
||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
const uint16_t *in_p = (const uint16_t*)in_frame;
|
const uint16_t *in_p = (const uint16_t*)in_frame;
|
||||||
uint16_t *out_p = (uint16_t*)out_frame;
|
uint16_t *out_p = (uint16_t*)out_frame;
|
||||||
|
|
||||||
for(y = 0; y < height; y++)
|
for(y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
|
@ -188,12 +188,12 @@ static void *psp_init(const video_info_t *video,
|
||||||
{
|
{
|
||||||
// first time init
|
// first time init
|
||||||
psp = (psp1_video_t*)calloc(1, sizeof(psp1_video_t));
|
psp = (psp1_video_t*)calloc(1, sizeof(psp1_video_t));
|
||||||
|
|
||||||
if (!psp)
|
if (!psp)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!psp->displayList) // either first time init or psp_free was called
|
if(!psp->displayList) // either first time init or psp_free was called
|
||||||
{
|
{
|
||||||
sceGuInit();
|
sceGuInit();
|
||||||
|
@ -202,50 +202,50 @@ static void *psp_init(const video_info_t *video,
|
||||||
psp->buffer_width = 512;
|
psp->buffer_width = 512;
|
||||||
psp->buffer_Height = 512;
|
psp->buffer_Height = 512;
|
||||||
psp->rgui.buffer_width = 512;
|
psp->rgui.buffer_width = 512;
|
||||||
psp->rgui.buffer_Height = 256;
|
psp->rgui.buffer_Height = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
psp->width = video->width;
|
psp->width = video->width;
|
||||||
psp->height = video->height;
|
psp->height = video->height;
|
||||||
psp->vsync = video->vsync;
|
psp->vsync = video->vsync;
|
||||||
psp->force_aspect = video->force_aspect;
|
psp->force_aspect = video->force_aspect;
|
||||||
psp->smooth = video->smooth;
|
psp->smooth = video->smooth;
|
||||||
psp->input_scale = video->input_scale;
|
psp->input_scale = video->input_scale;
|
||||||
|
|
||||||
|
|
||||||
psp->rgb32 = video->rgb32;
|
psp->rgb32 = video->rgb32;
|
||||||
psp->pixel_format = psp->rgb32 ? GU_PSM_8888 : GU_PSM_5650;
|
psp->pixel_format = psp->rgb32 ? GU_PSM_8888 : GU_PSM_5650;
|
||||||
psp->pixel_size = psp->rgb32 ? 4 : 2;
|
psp->pixel_size = psp->rgb32 ? 4 : 2;
|
||||||
psp->copy_frame = psp->rgb32 ? copy_frame_ARGB8888_to_ABGR8888 : copy_frame_RGB5650_to_BGR5650;
|
psp->copy_frame = psp->rgb32 ? copy_frame_ARGB8888_to_ABGR8888 : copy_frame_RGB5650_to_BGR5650;
|
||||||
|
|
||||||
if (psp->buffer)
|
if (psp->buffer)
|
||||||
free(TO_CACHED_PTR(psp->buffer));
|
free(TO_CACHED_PTR(psp->buffer));
|
||||||
psp->buffer = memalign(16, psp->buffer_width * psp->buffer_Height * psp->pixel_size);
|
psp->buffer = memalign(16, psp->buffer_width * psp->buffer_Height * psp->pixel_size);
|
||||||
psp->buffer = TO_UNCACHED_PTR(psp->buffer);
|
psp->buffer = TO_UNCACHED_PTR(psp->buffer);
|
||||||
|
|
||||||
//init rgui to 16-bit pixel format since it can't be empty when psp_set_texture_frame is called
|
//init rgui to 16-bit pixel format since it can't be empty when psp_set_texture_frame is called
|
||||||
psp->rgui.rgb32 = video->rgb32;
|
psp->rgui.rgb32 = video->rgb32;
|
||||||
psp->rgui.pixel_format = psp->rgui.rgb32 ? GU_PSM_8888 : GU_PSM_4444;
|
psp->rgui.pixel_format = psp->rgui.rgb32 ? GU_PSM_8888 : GU_PSM_4444;
|
||||||
psp->rgui.pixel_size = psp->rgui.rgb32 ? 4 : 2;
|
psp->rgui.pixel_size = psp->rgui.rgb32 ? 4 : 2;
|
||||||
psp->rgui.copy_frame = psp->rgui.rgb32 ? copy_frame_ARGB8888_to_ABGR8888 : copy_frame_XBGR16;
|
psp->rgui.copy_frame = psp->rgui.rgb32 ? copy_frame_ARGB8888_to_ABGR8888 : copy_frame_XBGR16;
|
||||||
psp->frameBuffers[0]=psp->rgui.rgb32 ? SCEGU_VRAM_BP32_0 : SCEGU_VRAM_BP_0;
|
psp->frameBuffers[0]=psp->rgui.rgb32 ? SCEGU_VRAM_BP32_0 : SCEGU_VRAM_BP_0;
|
||||||
psp->frameBuffers[1]=psp->rgui.rgb32 ? SCEGU_VRAM_BP32_1 : SCEGU_VRAM_BP_1;
|
psp->frameBuffers[1]=psp->rgui.rgb32 ? SCEGU_VRAM_BP32_1 : SCEGU_VRAM_BP_1;
|
||||||
psp->drawBuffer_ID=0;
|
psp->drawBuffer_ID=0;
|
||||||
|
|
||||||
if (psp->rgui.buffer)
|
if (psp->rgui.buffer)
|
||||||
free(TO_CACHED_PTR(psp->rgui.buffer));
|
free(TO_CACHED_PTR(psp->rgui.buffer));
|
||||||
psp->rgui.buffer = memalign(16, psp->rgui.buffer_width * psp->rgui.buffer_Height * psp->rgui.pixel_size);
|
psp->rgui.buffer = memalign(16, psp->rgui.buffer_width * psp->rgui.buffer_Height * psp->rgui.pixel_size);
|
||||||
psp->rgui.buffer = TO_UNCACHED_PTR(psp->rgui.buffer);
|
psp->rgui.buffer = TO_UNCACHED_PTR(psp->rgui.buffer);
|
||||||
|
|
||||||
psp->rgui.active = false;
|
psp->rgui.active = false;
|
||||||
psp->rgui.alpha = 0.0;
|
psp->rgui.alpha = 0.0;
|
||||||
psp->rgui.alpha_source = 0x00000000;
|
psp->rgui.alpha_source = 0x00000000;
|
||||||
psp->rgui.alpha_dest = 0xFFFFFFFF;
|
psp->rgui.alpha_dest = 0xFFFFFFFF;
|
||||||
|
|
||||||
// need to invalidate cache before using uncached pointers, to avoid unwanted cache writebacks. TODO: check up/downsides of using sceKernelDcacheInvalidateRange here instead
|
// need to invalidate cache before using uncached pointers, to avoid unwanted cache writebacks. TODO: check up/downsides of using sceKernelDcacheInvalidateRange here instead
|
||||||
sceKernelDcacheWritebackInvalidateAll();
|
sceKernelDcacheWritebackInvalidateAll();
|
||||||
|
|
||||||
sceDisplayWaitVblankStart(); // TODO : check if necessary
|
sceDisplayWaitVblankStart(); // TODO : check if necessary
|
||||||
sceGuDisplay(GU_FALSE);
|
sceGuDisplay(GU_FALSE);
|
||||||
|
|
||||||
sceGuStart(GU_DIRECT, psp->displayList);
|
sceGuStart(GU_DIRECT, psp->displayList);
|
||||||
|
@ -257,21 +257,21 @@ static void *psp_init(const video_info_t *video,
|
||||||
sceGuEnable(GU_SCISSOR_TEST);
|
sceGuEnable(GU_SCISSOR_TEST);
|
||||||
sceGuTexMode(psp->pixel_format, 0, 0, GU_FALSE);
|
sceGuTexMode(psp->pixel_format, 0, 0, GU_FALSE);
|
||||||
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
|
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
|
||||||
sceGuTexFilter(GU_LINEAR, GU_LINEAR); // TODO , move this to display list
|
sceGuTexFilter(GU_LINEAR, GU_LINEAR); // TODO , move this to display list
|
||||||
sceGuTexWrap (GU_CLAMP, GU_CLAMP);
|
sceGuTexWrap (GU_CLAMP, GU_CLAMP);
|
||||||
|
|
||||||
sceGuEnable(GU_TEXTURE_2D);
|
sceGuEnable(GU_TEXTURE_2D);
|
||||||
sceGuDisable(GU_BLEND);
|
sceGuDisable(GU_BLEND);
|
||||||
sceGuDisable(GU_DEPTH_TEST);
|
sceGuDisable(GU_DEPTH_TEST);
|
||||||
sceGuFinish();
|
sceGuFinish();
|
||||||
sceGuSync(0, 0);
|
sceGuSync(0, 0);
|
||||||
|
|
||||||
sceDisplayWaitVblankStart(); // TODO : check if necessary
|
sceDisplayWaitVblankStart(); // TODO : check if necessary
|
||||||
sceGuDisplay(GU_TRUE);
|
sceGuDisplay(GU_TRUE);
|
||||||
|
|
||||||
pspDebugScreenSetColorMode(psp->pixel_format);
|
pspDebugScreenSetColorMode(psp->pixel_format);
|
||||||
pspDebugScreenSetBase(psp->frameBuffers[psp->drawBuffer_ID]);
|
pspDebugScreenSetBase(psp->frameBuffers[psp->drawBuffer_ID]);
|
||||||
|
|
||||||
if (input && input_data)
|
if (input && input_data)
|
||||||
{
|
{
|
||||||
pspinput = input_psp.init();
|
pspinput = input_psp.init();
|
||||||
|
@ -279,7 +279,7 @@ static void *psp_init(const video_info_t *video,
|
||||||
*input_data = pspinput;
|
*input_data = pspinput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return psp;
|
return psp;
|
||||||
error:
|
error:
|
||||||
RARCH_ERR("PSP1 video could not be initialized.\n");
|
RARCH_ERR("PSP1 video could not be initialized.\n");
|
||||||
|
@ -292,74 +292,74 @@ static bool psp_frame(void *data, const void *frame,
|
||||||
unsigned width, unsigned height, unsigned pitch, const char *msg)
|
unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||||
{
|
{
|
||||||
psp1_vertex_t *v;
|
psp1_vertex_t *v;
|
||||||
|
|
||||||
psp1_video_t *psp = (psp1_video_t*)data;
|
psp1_video_t *psp = (psp1_video_t*)data;
|
||||||
|
|
||||||
sceGuSync(0, 0);
|
sceGuSync(0, 0);
|
||||||
|
|
||||||
if (msg) // TODO: fix flickering text
|
if (msg) // TODO: fix flickering text
|
||||||
{
|
{
|
||||||
pspDebugScreenSetBase(psp->frameBuffers[psp->drawBuffer_ID]);
|
pspDebugScreenSetBase(psp->frameBuffers[psp->drawBuffer_ID]);
|
||||||
pspDebugScreenSetXY(0,0);
|
pspDebugScreenSetXY(0,0);
|
||||||
pspDebugScreenPuts(msg);
|
pspDebugScreenPuts(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psp->vsync)
|
if (psp->vsync)
|
||||||
sceDisplayWaitVblankStart();
|
sceDisplayWaitVblankStart();
|
||||||
|
|
||||||
sceGuSwapBuffers();
|
sceGuSwapBuffers();
|
||||||
psp->drawBuffer_ID^=1;
|
psp->drawBuffer_ID^=1;
|
||||||
|
|
||||||
/* frame dupes. */
|
/* frame dupes. */
|
||||||
if (frame == NULL)
|
if (frame == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
psp->copy_frame(frame, pitch / psp->pixel_size, psp->buffer, psp->buffer_width, width, height);
|
psp->copy_frame(frame, pitch / psp->pixel_size, psp->buffer, psp->buffer_width, width, height);
|
||||||
|
|
||||||
sceGuStart(GU_DIRECT, psp->displayList);
|
sceGuStart(GU_DIRECT, psp->displayList);
|
||||||
sceGuClear(GU_COLOR_BUFFER_BIT);
|
sceGuClear(GU_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
v = (psp1_vertex_t*)sceGuGetMemory(4 * sizeof(psp1_vertex_t));
|
v = (psp1_vertex_t*)sceGuGetMemory(4 * sizeof(psp1_vertex_t));
|
||||||
|
|
||||||
v[0].x = (SCEGU_SCR_WIDTH - width * SCEGU_SCR_HEIGHT / height) / 2;
|
v[0].x = (SCEGU_SCR_WIDTH - width * SCEGU_SCR_HEIGHT / height) / 2;
|
||||||
v[0].y = 0;
|
v[0].y = 0;
|
||||||
v[0].u = 0;
|
v[0].u = 0;
|
||||||
v[0].v = 0;
|
v[0].v = 0;
|
||||||
|
|
||||||
v[1].x = (SCEGU_SCR_WIDTH + width * SCEGU_SCR_HEIGHT / height) / 2;
|
v[1].x = (SCEGU_SCR_WIDTH + width * SCEGU_SCR_HEIGHT / height) / 2;
|
||||||
v[1].y = SCEGU_SCR_HEIGHT;
|
v[1].y = SCEGU_SCR_HEIGHT;
|
||||||
v[1].u = width;
|
v[1].u = width;
|
||||||
v[1].v = height;
|
v[1].v = height;
|
||||||
|
|
||||||
sceGuTexMode(psp->pixel_format, 0, 0, GU_FALSE);
|
sceGuTexMode(psp->pixel_format, 0, 0, GU_FALSE);
|
||||||
sceGuTexImage(0, psp->buffer_width, psp->buffer_Height, psp->buffer_width, psp->buffer);
|
sceGuTexImage(0, psp->buffer_width, psp->buffer_Height, psp->buffer_width, psp->buffer);
|
||||||
// sceGuTexFilter(GU_LINEAR, GU_LINEAR);
|
// sceGuTexFilter(GU_LINEAR, GU_LINEAR);
|
||||||
|
|
||||||
sceGuDisable(GU_BLEND);
|
sceGuDisable(GU_BLEND);
|
||||||
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_5650 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, v);
|
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_5650 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, v);
|
||||||
|
|
||||||
if (psp->rgui.active)
|
if (psp->rgui.active)
|
||||||
{
|
{
|
||||||
v[2].x = 0;
|
v[2].x = 0;
|
||||||
v[2].y = 0;
|
v[2].y = 0;
|
||||||
v[2].u = 0;
|
v[2].u = 0;
|
||||||
v[2].v = 0;
|
v[2].v = 0;
|
||||||
|
|
||||||
v[3].x = SCEGU_SCR_WIDTH;
|
v[3].x = SCEGU_SCR_WIDTH;
|
||||||
v[3].y = SCEGU_SCR_HEIGHT;
|
v[3].y = SCEGU_SCR_HEIGHT;
|
||||||
v[3].u = psp->rgui.width;
|
v[3].u = psp->rgui.width;
|
||||||
v[3].v = psp->rgui.height;
|
v[3].v = psp->rgui.height;
|
||||||
|
|
||||||
sceGuTexMode(psp->rgui.pixel_format, 0, 0, GU_FALSE);
|
sceGuTexMode(psp->rgui.pixel_format, 0, 0, GU_FALSE);
|
||||||
sceGuTexImage(0, psp->rgui.buffer_width, psp->rgui.buffer_Height, psp->rgui.buffer_width, psp->rgui.buffer);
|
sceGuTexImage(0, psp->rgui.buffer_width, psp->rgui.buffer_Height, psp->rgui.buffer_width, psp->rgui.buffer);
|
||||||
// sceGuTexFilter(GU_LINEAR, GU_LINEAR);
|
// sceGuTexFilter(GU_LINEAR, GU_LINEAR);
|
||||||
|
|
||||||
sceGuEnable(GU_BLEND);
|
sceGuEnable(GU_BLEND);
|
||||||
sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, psp->rgui.alpha_source, psp->rgui.alpha_dest);
|
sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, psp->rgui.alpha_source, psp->rgui.alpha_dest);
|
||||||
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_5650 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, v + 2);
|
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_5650 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, v + 2);
|
||||||
}
|
}
|
||||||
sceGuFinish();
|
sceGuFinish();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,16 +384,16 @@ static bool psp_focus(void *data)
|
||||||
static void psp_free(void *data)
|
static void psp_free(void *data)
|
||||||
{
|
{
|
||||||
psp1_video_t *psp = (psp1_video_t*)data;
|
psp1_video_t *psp = (psp1_video_t*)data;
|
||||||
|
|
||||||
if (psp->displayList)
|
if (psp->displayList)
|
||||||
free(psp->displayList);
|
free(psp->displayList);
|
||||||
if (psp->buffer)
|
if (psp->buffer)
|
||||||
free(TO_CACHED_PTR(psp->buffer));
|
free(TO_CACHED_PTR(psp->buffer));
|
||||||
if (psp->rgui.buffer)
|
if (psp->rgui.buffer)
|
||||||
free(TO_CACHED_PTR(psp->rgui.buffer));
|
free(TO_CACHED_PTR(psp->rgui.buffer));
|
||||||
|
|
||||||
memset(psp, 0, sizeof(psp1_video_t));
|
memset(psp, 0, sizeof(psp1_video_t));
|
||||||
|
|
||||||
sceGuTerm();
|
sceGuTerm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,26 +411,26 @@ static void psp_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||||
unsigned width, unsigned height, float alpha)
|
unsigned width, unsigned height, float alpha)
|
||||||
{
|
{
|
||||||
psp1_video_t *psp = (psp1_video_t*)data;
|
psp1_video_t *psp = (psp1_video_t*)data;
|
||||||
|
|
||||||
if (psp->rgui.rgb32 != rgb32)
|
if (psp->rgui.rgb32 != rgb32)
|
||||||
{
|
{
|
||||||
psp->rgui.rgb32 = rgb32;
|
psp->rgui.rgb32 = rgb32;
|
||||||
psp->rgui.pixel_format = psp->rgui.rgb32 ? GU_PSM_8888 : GU_PSM_4444;
|
psp->rgui.pixel_format = psp->rgui.rgb32 ? GU_PSM_8888 : GU_PSM_4444;
|
||||||
psp->rgui.pixel_size = psp->rgui.rgb32 ? 4 : 2;
|
psp->rgui.pixel_size = psp->rgui.rgb32 ? 4 : 2;
|
||||||
psp->rgui.copy_frame = psp->rgui.rgb32 ? copy_frame_ARGB8888_to_ABGR8888 : copy_frame_XBGR16;
|
psp->rgui.copy_frame = psp->rgui.rgb32 ? copy_frame_ARGB8888_to_ABGR8888 : copy_frame_XBGR16;
|
||||||
|
|
||||||
if (psp->rgui.buffer)
|
if (psp->rgui.buffer)
|
||||||
free(TO_CACHED_PTR(psp->rgui.buffer));
|
free(TO_CACHED_PTR(psp->rgui.buffer));
|
||||||
psp->rgui.buffer = memalign(16, psp->rgui.buffer_width * psp->rgui.buffer_Height * psp->rgui.pixel_size);
|
psp->rgui.buffer = memalign(16, psp->rgui.buffer_width * psp->rgui.buffer_Height * psp->rgui.pixel_size);
|
||||||
psp->rgui.buffer = TO_UNCACHED_PTR(psp->rgui.buffer);
|
psp->rgui.buffer = TO_UNCACHED_PTR(psp->rgui.buffer);
|
||||||
sceKernelDcacheWritebackInvalidateAll();
|
sceKernelDcacheWritebackInvalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
psp->rgui.width = width;
|
psp->rgui.width = width;
|
||||||
psp->rgui.height = height;
|
psp->rgui.height = height;
|
||||||
psp->rgui.copy_frame(frame, width, psp->rgui.buffer, psp->rgui.buffer_width, width, height);
|
psp->rgui.copy_frame(frame, width, psp->rgui.buffer, psp->rgui.buffer_width, width, height);
|
||||||
|
|
||||||
psp->rgui.alpha = alpha;
|
psp->rgui.alpha = alpha;
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
mask = alpha*255.0;
|
mask = alpha*255.0;
|
||||||
mask &= 0xFF;
|
mask &= 0xFF;
|
||||||
|
@ -443,7 +443,7 @@ static void psp_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||||
static void psp_set_texture_enable(void *data, bool state, bool full_screen)
|
static void psp_set_texture_enable(void *data, bool state, bool full_screen)
|
||||||
{
|
{
|
||||||
(void) full_screen;
|
(void) full_screen;
|
||||||
|
|
||||||
psp1_video_t *psp = (psp1_video_t*)data;
|
psp1_video_t *psp = (psp1_video_t*)data;
|
||||||
psp->rgui.active = state;
|
psp->rgui.active = state;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue