PANDORA: OSD and a few other things

This commit is contained in:
ptitSeb 2014-01-12 15:54:00 +01:00
parent a15a5257b1
commit 72668d2267
10 changed files with 232 additions and 19 deletions

10
core/hw/aica/sgc_if.cpp Normal file → Executable file
View File

@ -17,6 +17,7 @@
#endif
//Sound generation, mixin, and channel regs emulation
bool NoSound = false; // global switch to kill sound (and some of the cpu part of it)
//x.15
s32 volume_lut[16];
@ -1180,7 +1181,6 @@ void AICA_Sample32()
{
return;
}
memset(mxlr,0,sizeof(mxlr));
//Generate 32 samples for each channel, before moving to next channel
@ -1288,8 +1288,7 @@ void AICA_Sample32()
pl=mixl;
pr=mixr;
WriteSample(mixr,mixl);
if (!NoSound) WriteSample(mixr,mixl);
}
}
@ -1334,6 +1333,11 @@ void AICA_Sample()
VOLPAN( (*(s16*)&DSPData->EFREG[i]) ,dsp_out_vol[i].EFSDL,dsp_out_vol[i].EFPAN,mixl,mixr);
}
}
if (NoSound)
{
return;
}
//Mono !
if (CommonData->Mono)

View File

@ -14,20 +14,14 @@ int max_idx,max_mvo,max_op,max_pt,max_tr,max_vtx,max_modt, ovrn;
TA_context* _pvrrc;
void SetREP(TA_context* cntx);
int frameskip;
int frameskip=0;
bool FrameSkipping=false; // global switch to enable/disable frameskip
bool rend_single_frame()
{
//wait render start only if no frame pending
_pvrrc = DequeueRender();
/* if (_pvrrc) {
if (!pvrrc.isRTT) {
frameskip++;
if (frameskip>4) frameskip = 0;
}
} else frameskip = 0;*/
while (!_pvrrc)
{
rs.Wait();
@ -36,10 +30,10 @@ bool rend_single_frame()
bool do_swp=false;
if (!pvrrc.isRTT) {
frameskip=1-frameskip;
//frameskip=(frameskip+1)%3;
}
/* if (FrameSkipping)
if (!pvrrc.isRTT) {
frameskip=1-frameskip;
} else frameskip=0;*/
if (!frameskip || pvrrc.isRTT)
@ -116,6 +110,10 @@ void rend_start_render()
if (ctx)
{
if (FrameSkipping && frameskip) {
frameskip=1-frameskip;
tactx_Recycle(ctx);
} else
if (!ctx->rend.Overrun)
{
//printf("REP: %.2f ms\n",render_end_pending_cycles/200000.0);

8
core/hw/pvr/spg.cpp Normal file → Executable file
View File

@ -179,12 +179,18 @@ int spg_line_sched(int tag, int cycl, int jit)
full_rps=(spd_fps+fskip/ts);
#ifdef TARGET_PANDORA
sprintf(fpsStr,"CPU: %4.2f V: %4.2f (%s%s%4.2f) R: %4.2f+%4.2f",
spd_cpu*100/200,spd_vbs,
mode,res,fullvbs,
spd_fps,fskip/ts);
#else
sprintf(fpsStr,"%s/%c - %4.2f (%4.2f) - %4.2f - V: %4.2f (%.2f, %s%s%4.2f) R: %4.2f+%4.2f VTX: %4.2f%c",
VER_SHORTNAME,'n',mspdf,speed_load_mspdf,spd_cpu*100/200,spd_vbs,
spd_vbs/full_rps,mode,res,fullvbs,
spd_fps,fskip/ts
,mv,mv_c);
#endif
fskip=0;
os_SetWindowText(fpsStr);

0
core/oslib/audiostream.cpp Normal file → Executable file
View File

0
core/oslib/oslib.h Normal file → Executable file
View File

2
core/rend/gles/gldraw.cpp Normal file → Executable file
View File

@ -747,7 +747,9 @@ void GenSorted()
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl.vbo.idxs2); glCheck();
glBufferData(GL_ELEMENT_ARRAY_BUFFER,vidx_sort.size()*2,&vidx_sort[0],GL_STREAM_DRAW);
#if PRINT_SORT_STATS
if (tess_gen) printf("Generated %.2fK Triangles !\n",tess_gen/1000.0);
#endif
}
}

View File

@ -610,6 +610,9 @@ bool CompilePipelineShader( PipelineShader* s)
}
GLuint osd_tex;
#ifdef TARGET_PANDORA
GLuint osd_font;
#endif
bool gl_create_resources()
{
@ -686,6 +689,9 @@ bool gl_create_resources()
int w, h;
osd_tex=loadPNG(GetPath("/data/buttons.png"),w,h);
#ifdef TARGET_PANDORA
osd_font=loadPNG(GetPath("/font2.png"),w,h);
#endif
return true;
}
@ -898,11 +904,120 @@ static void ClearBG()
void DrawButton2(float* xy, bool state) { DrawButton(xy,state?0:255); }
#ifdef TARGET_PANDORA
static void DrawCenteredText(float yy, float scale, int transparency, const char* text)
// Draw a centered text. Font is loaded from font2.png file. Each char is 16*16 size, so scale it down so it's not too big
// Transparency 255=opaque, 0=not visible
{
Vertex vtx;
vtx.z=1;
float w=float(strlen(text)*14)*scale;
float x=320-w/2.0f;
float y=yy;
float h=16.0f*scale;
w=14.0f*scale;
float step=32.0f/512.0f;
float step2=4.0f/512.0f;
if (transparency<0) transparency=0;
if (transparency>255) transparency=255;
for (int i=0; i<strlen(text); i++) {
int c=text[i];
float u=float(c%16);
float v=float(c/16);
vtx.col[0]=vtx.col[1]=vtx.col[2]=255;
vtx.col[3]=transparency;
vtx.x=x; vtx.y=y;
vtx.u=u*step+step2; vtx.v=v*step+step2;
*pvrrc.verts.Append()=vtx;
vtx.x=x+w; vtx.y=y;
vtx.u=u*step+step-step2; vtx.v=v*step+step2;
*pvrrc.verts.Append()=vtx;
vtx.x=x; vtx.y=y+h;
vtx.u=u*step+step2; vtx.v=v*step+step-step2;
*pvrrc.verts.Append()=vtx;
vtx.x=x+w; vtx.y=y+h;
vtx.u=u*step+step-step2; vtx.v=v*step+step-step2;
*pvrrc.verts.Append()=vtx;
x+=w;
osd_count+=4;
}
}
static void DrawRightedText(float yy, float scale, int transparency, const char* text)
// Draw a text right justified. Font is loaded from font2.png file. Each char is 16*16 size, so scale it down so it's not too big
// Transparency 255=opaque, 0=not visible
{
Vertex vtx;
vtx.z=1;
float w=float(strlen(text)*14)*scale;
float x=640-w;
float y=yy;
float h=16.0f*scale;
w=14.0f*scale;
float step=32.0f/512.0f;
float step2=4.0f/512.0f;
if (transparency<0) transparency=0;
if (transparency>255) transparency=255;
for (int i=0; i<strlen(text); i++) {
int c=text[i];
float u=float(c%16);
float v=float(c/16);
vtx.col[0]=vtx.col[1]=vtx.col[2]=255;
vtx.col[3]=transparency;
vtx.x=x; vtx.y=y;
vtx.u=u*step+step2; vtx.v=v*step+step2;
*pvrrc.verts.Append()=vtx;
vtx.x=x+w; vtx.y=y;
vtx.u=u*step+step-step2; vtx.v=v*step+step2;
*pvrrc.verts.Append()=vtx;
vtx.x=x; vtx.y=y+h;
vtx.u=u*step+step2; vtx.v=v*step+step-step2;
*pvrrc.verts.Append()=vtx;
vtx.x=x+w; vtx.y=y+h;
vtx.u=u*step+step-step2; vtx.v=v*step+step-step2;
*pvrrc.verts.Append()=vtx;
x+=w;
osd_count+=4;
}
}
#endif
#ifdef TARGET_PANDORA
char OSD_Info[128];
int OSD_Delay=0;
char OSD_Counters[256];
int OSD_Counter=0;
#endif
static void OSD_HOOK()
{
osd_base=pvrrc.verts.used();
osd_count=0;
#ifndef TARGET_PANDORA
DrawButton2(vjoy_pos[0],kcode[0]&key_CONT_DPAD_LEFT);
DrawButton2(vjoy_pos[1],kcode[0]&key_CONT_DPAD_UP);
DrawButton2(vjoy_pos[2],kcode[0]&key_CONT_DPAD_RIGHT);
@ -921,15 +1036,29 @@ static void OSD_HOOK()
DrawButton2(vjoy_pos[11],1);
DrawButton2(vjoy_pos[12],0);
#endif
#ifdef TARGET_PANDORA
if (OSD_Delay) {
DrawCenteredText(400, 1.0f, (OSD_Delay<255)?OSD_Delay:255, OSD_Info);
OSD_Delay--; //*TODO* Delay should be in ms, not in ticks...
}
if (OSD_Counter) {
DrawRightedText(20, 1.0f, 255, OSD_Counters);
}
#endif
}
extern GLuint osd_tex;
#ifdef TARGET_PANDORA
extern GLuint osd_font;
#endif
#define OSD_TEX_W 512
#define OSD_TEX_H 256
void OSD_DRAW()
{
#ifndef TARGET_PANDORA
if (osd_tex)
{
float u=0;
@ -973,6 +1102,34 @@ void OSD_DRAW()
for (int i=0;i<dfa;i++)
glDrawArrays(GL_TRIANGLE_STRIP,osd_base+i*4,4);
}
#endif
#ifdef TARGET_PANDORA
if (osd_font)
{
float u=0;
float v=0;
verify(glIsProgram(gl.OSD_SHADER.program));
glBindTexture(GL_TEXTURE_2D,osd_font);
glUseProgram(gl.OSD_SHADER.program);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(false);
glDepthFunc(GL_ALWAYS);
glDisable(GL_CULL_FACE);
glDisable(GL_SCISSOR_TEST);
int dfa=osd_count/4;
for (int i=0;i<dfa;i++)
glDrawArrays(GL_TRIANGLE_STRIP,osd_base+i*4,4);
}
#endif
}
bool RenderFrame()

View File

@ -69,6 +69,8 @@ s8 joyx[4],joyy[4];
u8 rt[4],lt[4];
extern bool KillTex;
extern bool FrameSkipping;
extern bool NoSound;
extern void dc_term();
enum DCPad {
@ -122,6 +124,10 @@ const u32 JMapAxis_360[MAP_SIZE] =
const u32* JMapBtn=JMapBtn_USB;
const u32* JMapAxis=JMapAxis_USB;
#ifdef TARGET_PANDORA
u32 JSensitivity[256]; // To have less sensitive value on nubs
#endif
void SetupInput()
{
@ -160,6 +166,19 @@ void SetupInput()
printf("Using Xbox 360 map\n");
}
} else printf("SDK: No Joystick Found\n");
#ifdef TARGET_PANDORA
float v;
int j;
for (int i=0; i<128; i++) {
v=((float)i)/127.0f;
v=(v+v*v)/2.0f;
j=(int)(v*127.0f);
if (j>127) j=127;
JSensitivity[128-i]=-j;
JSensitivity[128+i]=j;
}
#endif
SDL_ShowCursor( 0 );
if (SDL_WM_GrabInput( SDL_GRAB_ON ) != SDL_GRAB_ON)
@ -167,6 +186,11 @@ void SetupInput()
}
extern char OSD_Info[128];
extern int OSD_Delay;
extern char OSD_Counters[256];
extern int OSD_Counter;
bool HandleEvents(u32 port) {
static int keys[13];
@ -174,6 +198,7 @@ bool HandleEvents(u32 port) {
SDL_Event event;
int k, value;
int xx, yy;
char *num_mode[] = {"Off", "Up/Down => RT/LT", "Left/Right => LT/RT", "U/D/L/R => A/B/X/Y"};
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
@ -201,8 +226,11 @@ bool HandleEvents(u32 port) {
case SDLK_RCTRL: keys[10]=value; break;
case SDLK_LALT: keys[12]=value; break;
case SDLK_k: if (value) KillTex=true; break;
case SDLK_n: if (value) mouse_use=(mouse_use+1)%4; printf("Nub mode %i\n", mouse_use); break; //*TODO* Do some feedback on OSD
#else
case SDLK_n: if (value) {mouse_use=(mouse_use+1)%4; snprintf(OSD_Info, 128, "Right Nub mode: %s\n", num_mode[mouse_use]); OSD_Delay=300;}; break;
case SDLK_f: if (value) {FrameSkipping=!FrameSkipping; snprintf(OSD_Info, 128, "FrameSkipping %s\n", (FrameSkipping)?"On":"Off"); OSD_Delay=300;};break;
case SDLK_s: if (value) {NoSound=!NoSound; snprintf(OSD_Info, 128, "Sound %s\n", (NoSound)?"Off":"On"); OSD_Delay=300;};break;
case SDLK_c: if (value) {OSD_Counter=1-OSD_Counter;};break;
#else
#error *TODO*
#endif
}
@ -245,6 +273,9 @@ bool HandleEvents(u32 port) {
//printf("AXIS %d,%d\n",JE.number,JE.value);
s8 v=(s8)(value/256); //-127 ... + 127 range
#ifdef TARGET_PANDORA
v=JSensitivity[128+v];
#endif
if (mt==0)
{
@ -358,7 +389,12 @@ void os_DoEvents()
void os_SetWindowText(const char * text)
{
#ifndef TARGET_PANDORA
SDL_WM_SetCaption(text, NULL); // *TODO* Set Icon also...
#endif
#ifdef TARGET_PANDORA
strncpy(OSD_Counters, text, 256);
#endif
}
@ -461,6 +497,7 @@ int main(int argc, wchar* argv[])
printf("common linux setup done\n");
settings.profile.run_counts=0;
FrameSkipping=true;
dc_init(argc,argv);

View File

@ -6,12 +6,21 @@ FOR_PANDORA :=1
USE_SDL :=1
USE_OSS :=1
USE_CCACHE :=1
#PGO_MAKE :=1
PGO_USE :=1
RZDCY_SRC_DIR = ../../core
include $(RZDCY_SRC_DIR)/core.mk
CC_PREFIX ?=
ifdef USE_CCACHE
CC_PREFIX =ccache ${CC_PREFIX}
endif
CXX=${CC_PREFIX}g++
CC=${CC_PREFIX}gcc
AS=${CC_PREFIX}as

BIN
shell/pandora/font2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB