mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-22 10:39:18 +01:00
some spiffy new audio/video code!
This commit is contained in:
parent
375a5b42ba
commit
f5e8484dc8
@ -62,11 +62,10 @@ static void AudioPlayer()
|
||||
{
|
||||
if (!ConfigRequested)
|
||||
{
|
||||
whichab ^= 1;
|
||||
int len = MIXER_GetSamples(soundbuffer[whichab], 3200);
|
||||
DCFlushRange(soundbuffer[whichab],len);
|
||||
AUDIO_InitDMA((u32)soundbuffer[whichab],len);
|
||||
AUDIO_StartDMA();
|
||||
whichab ^= 1;
|
||||
IsPlaying = 1;
|
||||
}
|
||||
else
|
||||
@ -106,6 +105,13 @@ SwitchAudioMode(int mode)
|
||||
ASND_Pause(1);
|
||||
AUDIO_StopDMA();
|
||||
AUDIO_RegisterDMACallback(AudioPlayer);
|
||||
|
||||
memset(soundbuffer[0],0,3840);
|
||||
memset(soundbuffer[1],0,3840);
|
||||
DCFlushRange(soundbuffer[0],3840);
|
||||
DCFlushRange(soundbuffer[1],3840);
|
||||
AUDIO_InitDMA((u32)soundbuffer[whichab],3200);
|
||||
AUDIO_StartDMA();
|
||||
#endif
|
||||
}
|
||||
else // menu
|
||||
|
@ -323,12 +323,28 @@ class GuiElement
|
||||
//!Considers alpha, alphaDyn, and the parent element's GetAlpha() value
|
||||
//!\return alpha
|
||||
int GetAlpha();
|
||||
//!Sets the element's scale
|
||||
//!Sets the element's x and y scale
|
||||
//!\param s scale (1 is 100%)
|
||||
void SetScale(float s);
|
||||
//!Sets the element's x scale
|
||||
//!\param s scale (1 is 100%)
|
||||
void SetScaleX(float s);
|
||||
//!Sets the element's y scale
|
||||
//!\param s scale (1 is 100%)
|
||||
void SetScaleY(float s);
|
||||
//!Sets the element's x and y scale, using the provided max width/height
|
||||
//!\param w Maximum width
|
||||
//!\param h Maximum height
|
||||
void SetScale(int w, int h);
|
||||
//!Gets the element's current scale
|
||||
//!Considers scale, scaleDyn, and the parent element's GetScale() value
|
||||
float GetScale();
|
||||
//!Gets the element's current x scale
|
||||
//!Considers scale, scaleDyn, and the parent element's GetScale() value
|
||||
float GetScaleX();
|
||||
//!Gets the element's current y scale
|
||||
//!Considers scale, scaleDyn, and the parent element's GetScale() value
|
||||
float GetScaleY();
|
||||
//!Set a new GuiTrigger for the element
|
||||
//!\param t Pointer to GuiTrigger
|
||||
void SetTrigger(GuiTrigger * t);
|
||||
@ -420,7 +436,8 @@ class GuiElement
|
||||
int yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
|
||||
int alpha; //!< Element alpha value (0-255)
|
||||
int alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
|
||||
f32 scale; //!< Element scale (1 = 100%)
|
||||
f32 xscale; //!< Element X scale (1 = 100%)
|
||||
f32 yscale; //!< Element Y scale (1 = 100%)
|
||||
f32 scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
|
||||
int effects; //!< Currently enabled effect(s). 0 when no effects are enabled
|
||||
int effectAmount; //!< Effect amount. Used by different effects for different purposes
|
||||
|
@ -24,7 +24,8 @@ GuiElement::GuiElement()
|
||||
width = 0;
|
||||
height = 0;
|
||||
alpha = 255;
|
||||
scale = 1;
|
||||
xscale = 1;
|
||||
yscale = 1;
|
||||
state = STATE_DEFAULT;
|
||||
stateChan = -1;
|
||||
trigger[0] = NULL;
|
||||
@ -92,12 +93,13 @@ int GuiElement::GetLeft()
|
||||
x = pLeft;
|
||||
break;
|
||||
case ALIGN_CENTRE:
|
||||
x = pLeft + (pWidth>>1) - (width>>1);
|
||||
x = pLeft + pWidth/2.0 - (width*xscale)/2.0;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = pLeft + pWidth - width;
|
||||
x = pLeft + pWidth - width*xscale;
|
||||
break;
|
||||
}
|
||||
x += (width*(xscale - 1))/2.0; // correct offset for scaled images
|
||||
return x + xoffset;
|
||||
}
|
||||
|
||||
@ -122,12 +124,13 @@ int GuiElement::GetTop()
|
||||
y = pTop;
|
||||
break;
|
||||
case ALIGN_MIDDLE:
|
||||
y = pTop + (pHeight>>1) - (height>>1);
|
||||
y = pTop + pHeight/2.0 - (height*yscale)/2.0;
|
||||
break;
|
||||
case ALIGN_BOTTOM:
|
||||
y = pTop + pHeight - height;
|
||||
y = pTop + pHeight - height*yscale;
|
||||
break;
|
||||
}
|
||||
y += (height*(yscale - 1))/2.0; // correct offset for scaled images
|
||||
return y + yoffset;
|
||||
}
|
||||
|
||||
@ -218,12 +221,36 @@ int GuiElement::GetAlpha()
|
||||
|
||||
void GuiElement::SetScale(float s)
|
||||
{
|
||||
scale = s;
|
||||
xscale = s;
|
||||
yscale = s;
|
||||
}
|
||||
|
||||
void GuiElement::SetScaleX(float s)
|
||||
{
|
||||
xscale = s;
|
||||
}
|
||||
|
||||
void GuiElement::SetScaleY(float s)
|
||||
{
|
||||
yscale = s;
|
||||
}
|
||||
|
||||
void GuiElement::SetScale(int mw, int mh)
|
||||
{
|
||||
xscale = 1.0f;
|
||||
if(width > mw || height > mh)
|
||||
{
|
||||
if(width/(height*1.0) > mw/(mh*1.0))
|
||||
xscale = mw/(width*1.0);
|
||||
else
|
||||
xscale = mh/(height*1.0);
|
||||
}
|
||||
yscale = xscale;
|
||||
}
|
||||
|
||||
float GuiElement::GetScale()
|
||||
{
|
||||
float s = scale * scaleDyn;
|
||||
float s = xscale * scaleDyn;
|
||||
|
||||
if(parentElement)
|
||||
s *= parentElement->GetScale();
|
||||
@ -231,6 +258,26 @@ float GuiElement::GetScale()
|
||||
return s;
|
||||
}
|
||||
|
||||
float GuiElement::GetScaleX()
|
||||
{
|
||||
float s = xscale * scaleDyn;
|
||||
|
||||
if(parentElement)
|
||||
s *= parentElement->GetScale();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
float GuiElement::GetScaleY()
|
||||
{
|
||||
float s = yscale * scaleDyn;
|
||||
|
||||
if(parentElement)
|
||||
s *= parentElement->GetScaleY();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int GuiElement::GetState()
|
||||
{
|
||||
return state;
|
||||
|
@ -226,7 +226,8 @@ void GuiImage::Draw()
|
||||
if(!image || !this->IsVisible() || tile == 0)
|
||||
return;
|
||||
|
||||
float currScale = this->GetScale();
|
||||
float currScaleX = this->GetScaleX();
|
||||
float currScaleY = this->GetScaleY();
|
||||
int currLeft = this->GetLeft();
|
||||
int thisTop = this->GetTop();
|
||||
|
||||
@ -235,16 +236,12 @@ void GuiImage::Draw()
|
||||
int alpha = this->GetAlpha();
|
||||
for(int i=0; i<tile; ++i)
|
||||
{
|
||||
Menu_DrawImg(currLeft+width*i, thisTop, width, height, image, imageangle, currScale, currScale, alpha);
|
||||
Menu_DrawImg(currLeft+width*i, thisTop, width, height, image, imageangle, currScaleX, currScaleY, alpha);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// temporary (maybe), used to correct offset for scaled images
|
||||
if(scale != 1)
|
||||
currLeft += (width*(scale - 1))/2;
|
||||
|
||||
Menu_DrawImg(currLeft, thisTop, width, height, image, imageangle, currScale, currScale, this->GetAlpha());
|
||||
Menu_DrawImg(currLeft, thisTop, width, height, image, imageangle, currScaleX, currScaleY, this->GetAlpha());
|
||||
}
|
||||
|
||||
if(stripe > 0)
|
||||
|
@ -375,7 +375,7 @@ ProgressWindow(char *title, char *msg)
|
||||
}
|
||||
|
||||
// wait to see if progress flag changes soon
|
||||
progsleep = 400000;
|
||||
progsleep = 800000;
|
||||
|
||||
while(progsleep > 0)
|
||||
{
|
||||
@ -4223,9 +4223,11 @@ MainMenu (int menu)
|
||||
|
||||
if(gameScreenTex)
|
||||
{
|
||||
gameScreenImg = new GuiImage(gameScreenTex, screenwidth, screenheight);
|
||||
gameScreenImg = new GuiImage(gameScreenTex, vmode->fbWidth, vmode->efbHeight);
|
||||
gameScreenImg->SetAlpha(192);
|
||||
gameScreenImg->ColorStripe(30);
|
||||
gameScreenImg->SetScaleX(screenwidth/(float)vmode->fbWidth);
|
||||
gameScreenImg->SetScaleY(screenheight/(float)vmode->efbHeight);
|
||||
mainWindow->Append(gameScreenImg);
|
||||
bgImg->SetVisible(false);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ bool SaveBatteryOrState(char * filepath, int action, bool silent)
|
||||
|
||||
if (pngContext != NULL)
|
||||
{
|
||||
imgSize = PNGU_EncodeFromGXTexture(pngContext, screenwidth, screenheight, gameScreenTex2, 0);
|
||||
imgSize = PNGU_EncodeFromGXTexture(pngContext, vmode->fbWidth, vmode->efbHeight, gameScreenTex2, 0);
|
||||
PNGU_ReleaseImageContext(pngContext);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ u32 FrameTimer = 0;
|
||||
|
||||
/*** External 2D Video ***/
|
||||
/*** 2D Video Globals ***/
|
||||
static GXRModeObj *vmode = NULL; // Graphics Mode Object
|
||||
GXRModeObj *vmode = NULL; // Graphics Mode Object
|
||||
unsigned int *xfb[2] = { NULL, NULL }; // Framebuffers
|
||||
int whichfb = 0; // Frame buffer toggle
|
||||
|
||||
@ -304,22 +304,6 @@ static GXRModeObj * FindVideoMode()
|
||||
break;
|
||||
}
|
||||
|
||||
// configure original modes (not implemented)
|
||||
switch (mode->viTVMode >> 2)
|
||||
{
|
||||
case VI_PAL:
|
||||
// 576 lines (PAL 50hz)
|
||||
break;
|
||||
|
||||
case VI_NTSC:
|
||||
// 480 lines (NTSC 60hz)
|
||||
break;
|
||||
|
||||
default:
|
||||
// 480 lines (PAL 60Hz)
|
||||
break;
|
||||
}
|
||||
|
||||
// check for progressive scan
|
||||
if (mode->viTVMode == VI_TVMODE_NTSC_PROG)
|
||||
progressive = true;
|
||||
@ -327,11 +311,45 @@ static GXRModeObj * FindVideoMode()
|
||||
progressive = false;
|
||||
|
||||
#ifdef HW_RVL
|
||||
// widescreen fix
|
||||
if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
bool pal = false;
|
||||
|
||||
if (mode == &TVPal528IntDf)
|
||||
pal = true;
|
||||
|
||||
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
{
|
||||
mode->viWidth = 678;
|
||||
mode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678) / 2;
|
||||
mode->fbWidth = 640;
|
||||
mode->efbHeight = 456;
|
||||
mode->viWidth = 686;
|
||||
|
||||
if (pal)
|
||||
{
|
||||
mode->xfbHeight = 542;
|
||||
mode->viHeight = 542;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode->xfbHeight = 456;
|
||||
mode->viHeight = 456;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pal)
|
||||
mode = &TVPal574IntDfScale;
|
||||
|
||||
mode->viWidth = 672;
|
||||
}
|
||||
|
||||
if (pal)
|
||||
{
|
||||
mode->viXOrigin = (VI_MAX_WIDTH_PAL - mode->viWidth) / 2;
|
||||
mode->viYOrigin = (VI_MAX_HEIGHT_PAL - mode->viHeight) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode->viXOrigin = (VI_MAX_WIDTH_NTSC - mode->viWidth) / 2;
|
||||
mode->viYOrigin = (VI_MAX_HEIGHT_NTSC - mode->viHeight) / 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -25,6 +25,7 @@ void Menu_Render();
|
||||
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF );
|
||||
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
|
||||
|
||||
extern GXRModeObj *vmode;
|
||||
extern int screenheight;
|
||||
extern int screenwidth;
|
||||
extern s32 CursorX, CursorY;
|
||||
|
Loading…
Reference in New Issue
Block a user