mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
begin work on rotation
This commit is contained in:
parent
bb87a709be
commit
34513063ab
@ -63,12 +63,15 @@ u32 ScreenBuffer[256*384];
|
|||||||
int ScreenGap = 0;
|
int ScreenGap = 0;
|
||||||
int ScreenLayout = 0;
|
int ScreenLayout = 0;
|
||||||
int ScreenSizing = 0;
|
int ScreenSizing = 0;
|
||||||
|
int ScreenRotation = 0;
|
||||||
|
|
||||||
int MainScreenPos[3];
|
int MainScreenPos[3];
|
||||||
int AutoScreenSizing;
|
int AutoScreenSizing;
|
||||||
|
|
||||||
uiRect TopScreenRect;
|
uiRect TopScreenRect;
|
||||||
uiRect BottomScreenRect;
|
uiRect BottomScreenRect;
|
||||||
|
uiDrawMatrix TopScreenTrans;
|
||||||
|
uiDrawMatrix BottomScreenTrans;
|
||||||
|
|
||||||
bool Touching = false;
|
bool Touching = false;
|
||||||
|
|
||||||
@ -299,8 +302,22 @@ void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params)
|
|||||||
|
|
||||||
uiDrawBitmapUpdate(ScreenBitmap, ScreenBuffer);
|
uiDrawBitmapUpdate(ScreenBitmap, ScreenBuffer);
|
||||||
|
|
||||||
|
uiDrawSave(params->Context);
|
||||||
|
uiDrawTransform(params->Context, &TopScreenTrans);
|
||||||
uiDrawBitmapDraw(params->Context, ScreenBitmap, &top, &TopScreenRect);
|
uiDrawBitmapDraw(params->Context, ScreenBitmap, &top, &TopScreenRect);
|
||||||
|
uiDrawRestore(params->Context);
|
||||||
|
|
||||||
|
/*uiDrawMatrix blirg;
|
||||||
|
uiDrawMatrixSetIdentity(&blirg);
|
||||||
|
uiDrawMatrixTranslate(&blirg, -BottomScreenRect.X, -BottomScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&blirg, 0, 0, -M_PI/2.0f);//3.14);
|
||||||
|
uiDrawMatrixTranslate(&blirg, BottomScreenRect.X, BottomScreenRect.Y+BottomScreenRect.Height);
|
||||||
|
//uiDrawMatrixScale(&blirg, 128, 192, 2, 2);
|
||||||
|
uiDrawTransform(params->Context, &blirg);*/
|
||||||
|
uiDrawSave(params->Context);
|
||||||
|
uiDrawTransform(params->Context, &BottomScreenTrans);
|
||||||
uiDrawBitmapDraw(params->Context, ScreenBitmap, &bot, &BottomScreenRect);
|
uiDrawBitmapDraw(params->Context, ScreenBitmap, &bot, &BottomScreenRect);
|
||||||
|
uiDrawRestore(params->Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAreaMouseEvent(uiAreaHandler* handler, uiArea* area, uiAreaMouseEvent* evt)
|
void OnAreaMouseEvent(uiAreaHandler* handler, uiArea* area, uiAreaMouseEvent* evt)
|
||||||
@ -378,10 +395,16 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
|||||||
void SetupScreenRects(int width, int height)
|
void SetupScreenRects(int width, int height)
|
||||||
{
|
{
|
||||||
bool horizontal = false;
|
bool horizontal = false;
|
||||||
|
bool sideways = false;
|
||||||
|
ScreenRotation = 3; // TEST 1=90 CW 2=180 3=270
|
||||||
|
if (ScreenRotation == 1 || ScreenRotation == 3)
|
||||||
|
sideways = true;
|
||||||
|
|
||||||
if (ScreenLayout == 2) horizontal = true;
|
if (ScreenLayout == 2) horizontal = true;
|
||||||
else if (ScreenLayout == 0)
|
else if (ScreenLayout == 0)
|
||||||
{
|
{
|
||||||
// TODO: make it horizontal if rotation is used, whenever that is implemented
|
if (sideways)
|
||||||
|
horizontal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sizemode;
|
int sizemode;
|
||||||
@ -390,12 +413,30 @@ void SetupScreenRects(int width, int height)
|
|||||||
else
|
else
|
||||||
sizemode = ScreenSizing;
|
sizemode = ScreenSizing;
|
||||||
|
|
||||||
// blarg.
|
int screenW, screenH;
|
||||||
// should be changed if rotation is used
|
if (sideways)
|
||||||
// (also TODO: swap top/bottom screen if needed)
|
{
|
||||||
int screenW = 256;
|
screenW = 192;
|
||||||
int screenH = 192;
|
screenH = 256;
|
||||||
horizontal = true; // TEST
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screenW = 256;
|
||||||
|
screenH = 192;
|
||||||
|
}
|
||||||
|
|
||||||
|
uiRect *topscreen, *bottomscreen;
|
||||||
|
if (ScreenRotation == 1 || ScreenRotation == 2)
|
||||||
|
{
|
||||||
|
topscreen = &BottomScreenRect;
|
||||||
|
bottomscreen = &TopScreenRect;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
topscreen = &TopScreenRect;
|
||||||
|
bottomscreen = &BottomScreenRect;
|
||||||
|
}
|
||||||
|
//horizontal = true; // TEST
|
||||||
if (horizontal)
|
if (horizontal)
|
||||||
{
|
{
|
||||||
// side-by-side
|
// side-by-side
|
||||||
@ -430,30 +471,30 @@ horizontal = true; // TEST
|
|||||||
|
|
||||||
if (sizemode == 2)
|
if (sizemode == 2)
|
||||||
{
|
{
|
||||||
TopScreenRect.Width = screenW;
|
topscreen->Width = screenW;
|
||||||
TopScreenRect.Height = screenH;
|
topscreen->Height = screenH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TopScreenRect.Width = (sizemode==0) ? (width / 2) : (width - screenW);
|
topscreen->Width = (sizemode==0) ? (width / 2) : (width - screenW);
|
||||||
TopScreenRect.Height = heightreq;
|
topscreen->Height = heightreq;
|
||||||
}
|
}
|
||||||
TopScreenRect.X = startX;
|
topscreen->X = startX;
|
||||||
TopScreenRect.Y = ((height - heightreq) / 2) + (heightreq - TopScreenRect.Height);
|
topscreen->Y = ((height - heightreq) / 2) + (heightreq - topscreen->Height);
|
||||||
|
|
||||||
BottomScreenRect.X = TopScreenRect.X + TopScreenRect.Width + ScreenGap;
|
bottomscreen->X = topscreen->X + topscreen->Width + ScreenGap;
|
||||||
|
|
||||||
if (sizemode == 1)
|
if (sizemode == 1)
|
||||||
{
|
{
|
||||||
BottomScreenRect.Width = screenW;
|
bottomscreen->Width = screenW;
|
||||||
BottomScreenRect.Height = screenH;
|
bottomscreen->Height = screenH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BottomScreenRect.Width = width - TopScreenRect.Width;
|
bottomscreen->Width = width - topscreen->Width;
|
||||||
BottomScreenRect.Height = heightreq;
|
bottomscreen->Height = heightreq;
|
||||||
}
|
}
|
||||||
BottomScreenRect.Y = ((height - heightreq) / 2) + (heightreq - BottomScreenRect.Height);
|
bottomscreen->Y = ((height - heightreq) / 2) + (heightreq - bottomscreen->Height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -489,30 +530,86 @@ horizontal = true; // TEST
|
|||||||
|
|
||||||
if (sizemode == 2)
|
if (sizemode == 2)
|
||||||
{
|
{
|
||||||
TopScreenRect.Width = screenW;
|
topscreen->Width = screenW;
|
||||||
TopScreenRect.Height = screenH;
|
topscreen->Height = screenH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TopScreenRect.Width = widthreq;
|
topscreen->Width = widthreq;
|
||||||
TopScreenRect.Height = (sizemode==0) ? (height / 2) : (height - screenH);
|
topscreen->Height = (sizemode==0) ? (height / 2) : (height - screenH);
|
||||||
}
|
}
|
||||||
TopScreenRect.Y = startY;
|
topscreen->Y = startY;
|
||||||
TopScreenRect.X = (width - TopScreenRect.Width) / 2;
|
topscreen->X = (width - topscreen->Width) / 2;
|
||||||
|
|
||||||
BottomScreenRect.Y = TopScreenRect.Y + TopScreenRect.Height + ScreenGap;
|
bottomscreen->Y = topscreen->Y + topscreen->Height + ScreenGap;
|
||||||
|
|
||||||
if (sizemode == 1)
|
if (sizemode == 1)
|
||||||
{
|
{
|
||||||
BottomScreenRect.Width = screenW;
|
bottomscreen->Width = screenW;
|
||||||
BottomScreenRect.Height = screenH;
|
bottomscreen->Height = screenH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BottomScreenRect.Width = widthreq;
|
bottomscreen->Width = widthreq;
|
||||||
BottomScreenRect.Height = height - TopScreenRect.Height;
|
bottomscreen->Height = height - topscreen->Height;
|
||||||
}
|
}
|
||||||
BottomScreenRect.X = (width - BottomScreenRect.Width) / 2;
|
bottomscreen->X = (width - bottomscreen->Width) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup matrices for potential rotation
|
||||||
|
|
||||||
|
uiDrawMatrixSetIdentity(&TopScreenTrans);
|
||||||
|
uiDrawMatrixSetIdentity(&BottomScreenTrans);
|
||||||
|
|
||||||
|
switch (ScreenRotation)
|
||||||
|
{
|
||||||
|
case 1: // 90°
|
||||||
|
{
|
||||||
|
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, M_PI/2.0f);
|
||||||
|
uiDrawMatrixScale(&TopScreenTrans, 0, 0,
|
||||||
|
TopScreenRect.Width/(double)TopScreenRect.Height,
|
||||||
|
TopScreenRect.Height/(double)TopScreenRect.Width);
|
||||||
|
uiDrawMatrixTranslate(&TopScreenTrans, TopScreenRect.X+TopScreenRect.Width, TopScreenRect.Y);
|
||||||
|
|
||||||
|
uiDrawMatrixTranslate(&BottomScreenTrans, -BottomScreenRect.X, -BottomScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&BottomScreenTrans, 0, 0, M_PI/2.0f);
|
||||||
|
uiDrawMatrixScale(&BottomScreenTrans, 0, 0,
|
||||||
|
BottomScreenRect.Width/(double)BottomScreenRect.Height,
|
||||||
|
BottomScreenRect.Height/(double)BottomScreenRect.Width);
|
||||||
|
uiDrawMatrixTranslate(&BottomScreenTrans, BottomScreenRect.X+BottomScreenRect.Width, BottomScreenRect.Y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // 180°
|
||||||
|
{
|
||||||
|
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, M_PI);
|
||||||
|
uiDrawMatrixTranslate(&TopScreenTrans, TopScreenRect.X+TopScreenRect.Width, TopScreenRect.Y+TopScreenRect.Height);
|
||||||
|
|
||||||
|
uiDrawMatrixTranslate(&BottomScreenTrans, -BottomScreenRect.X, -BottomScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&BottomScreenTrans, 0, 0, M_PI);
|
||||||
|
uiDrawMatrixTranslate(&BottomScreenTrans, BottomScreenRect.X+BottomScreenRect.Width, BottomScreenRect.Y+BottomScreenRect.Height);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // 270°
|
||||||
|
{
|
||||||
|
uiDrawMatrixTranslate(&TopScreenTrans, -TopScreenRect.X, -TopScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&TopScreenTrans, 0, 0, -M_PI/2.0f);
|
||||||
|
uiDrawMatrixScale(&TopScreenTrans, 0, 0,
|
||||||
|
TopScreenRect.Width/(double)TopScreenRect.Height,
|
||||||
|
TopScreenRect.Height/(double)TopScreenRect.Width);
|
||||||
|
uiDrawMatrixTranslate(&TopScreenTrans, TopScreenRect.X, TopScreenRect.Y+TopScreenRect.Height);
|
||||||
|
|
||||||
|
uiDrawMatrixTranslate(&BottomScreenTrans, -BottomScreenRect.X, -BottomScreenRect.Y);
|
||||||
|
uiDrawMatrixRotate(&BottomScreenTrans, 0, 0, -M_PI/2.0f);
|
||||||
|
uiDrawMatrixScale(&BottomScreenTrans, 0, 0,
|
||||||
|
BottomScreenRect.Width/(double)BottomScreenRect.Height,
|
||||||
|
BottomScreenRect.Height/(double)BottomScreenRect.Width);
|
||||||
|
uiDrawMatrixTranslate(&BottomScreenTrans, BottomScreenRect.X, BottomScreenRect.Y+BottomScreenRect.Height);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user