fix SF [ 2217044 ] Rotation bug - 90 and 270 crash the emu
also repair the mouse x/y transform which suffered from similar bugs and rendered rotate modes unusable. change a typo in a function name "releasTouch"
This commit is contained in:
parent
7ec884d485
commit
3612ceda11
|
@ -254,7 +254,7 @@ void NDS_setTouchPos(u16 x, u16 y)
|
||||||
MMU.ARM7_REG[0x136] &= 0xBF;
|
MMU.ARM7_REG[0x136] &= 0xBF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NDS_releasTouch(void)
|
void NDS_releaseTouch(void)
|
||||||
{
|
{
|
||||||
nds.touchX = 0;
|
nds.touchX = 0;
|
||||||
nds.touchY = 0;
|
nds.touchY = 0;
|
||||||
|
|
|
@ -186,7 +186,7 @@ BOOL NDS_SetROM(u8 * rom, u32 mask);
|
||||||
NDS_header * NDS_getROMHeader(void);
|
NDS_header * NDS_getROMHeader(void);
|
||||||
|
|
||||||
void NDS_setTouchPos(u16 x, u16 y);
|
void NDS_setTouchPos(u16 x, u16 y);
|
||||||
void NDS_releasTouch(void);
|
void NDS_releaseTouch(void);
|
||||||
|
|
||||||
int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize,
|
int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize,
|
||||||
const char *cflash_disk_image_file);
|
const char *cflash_disk_image_file);
|
||||||
|
|
|
@ -767,7 +767,7 @@ int main(int argc, char ** argv) {
|
||||||
if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y);
|
if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y);
|
||||||
if(mouse.click)
|
if(mouse.click)
|
||||||
{
|
{
|
||||||
NDS_releasTouch();
|
NDS_releaseTouch();
|
||||||
mouse.click = FALSE;
|
mouse.click = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton
|
||||||
gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
|
gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
|
||||||
int scr = dyn_CAST(int,user_data);
|
int scr = dyn_CAST(int,user_data);
|
||||||
if ((scr==1) ^ ScreenInvert) {
|
if ((scr==1) ^ ScreenInvert) {
|
||||||
if (click) NDS_releasTouch();
|
if (click) NDS_releaseTouch();
|
||||||
click = FALSE;
|
click = FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -902,7 +902,7 @@ static gboolean Stylus_Press(GtkWidget *w, GdkEventButton *e, gpointer data)
|
||||||
}
|
}
|
||||||
static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data)
|
static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data)
|
||||||
{
|
{
|
||||||
if(click) NDS_releasTouch();
|
if(click) NDS_releaseTouch();
|
||||||
click = FALSE;
|
click = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,27 +462,25 @@ void ScaleScreen(HWND hwnd, float factor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void translateXY(s32 *x, s32*y)
|
void translateXY(s32& x, s32& y)
|
||||||
{
|
{
|
||||||
s32 tmp;
|
s32 tx=x, ty=y;
|
||||||
switch(GPU_rotation)
|
switch(GPU_rotation)
|
||||||
{
|
{
|
||||||
case 90:
|
case 90:
|
||||||
tmp = *x;
|
x = ty;
|
||||||
*x = *y;
|
y = 191-tx;
|
||||||
*y = 192*2 -tmp;
|
|
||||||
break;
|
break;
|
||||||
case 180:
|
case 180:
|
||||||
*x = 256-*x;
|
x = 255-tx;
|
||||||
*y = 192*2-*y;
|
y = 383-ty;
|
||||||
|
y -= 192;
|
||||||
break;
|
break;
|
||||||
case 270:
|
case 270:
|
||||||
tmp = *x;
|
x = 255-ty;
|
||||||
*x = 255-*y;
|
y = (tx-192);
|
||||||
*y = tmp;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*y-=192;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// END Rotation definitions
|
// END Rotation definitions
|
||||||
|
@ -562,7 +560,6 @@ void Display()
|
||||||
case 90:
|
case 90:
|
||||||
{
|
{
|
||||||
u32 start;
|
u32 start;
|
||||||
memset(buffer,0,384*ddsd.lPitch);
|
|
||||||
for (j=0; j<256; j++)
|
for (j=0; j<256; j++)
|
||||||
{
|
{
|
||||||
start=98304+j;
|
start=98304+j;
|
||||||
|
@ -589,7 +586,6 @@ void Display()
|
||||||
case 270:
|
case 270:
|
||||||
{
|
{
|
||||||
u32 start;
|
u32 start;
|
||||||
memset(buffer,0,384*ddsd.lPitch);
|
|
||||||
for (j=0; j<256; j++)
|
for (j=0; j<256; j++)
|
||||||
{
|
{
|
||||||
start=256-j;
|
start=256-j;
|
||||||
|
@ -1546,13 +1542,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
if (wParam & MK_LBUTTON)
|
if (wParam & MK_LBUTTON)
|
||||||
{
|
{
|
||||||
RECT r ;
|
RECT r ;
|
||||||
s32 x = (s32)((s16)LOWORD(lParam));
|
s32 x = (s32)((s16)LOWORD(lParam));
|
||||||
s32 y = (s32)((s16)HIWORD(lParam));
|
s32 y = (s32)((s16)HIWORD(lParam));
|
||||||
GetClientRect(hwnd,&r) ;
|
GetClientRect(hwnd,&r) ;
|
||||||
/* translate from scaling (screen reoltution to 256x384 or 512x192) */
|
// translate from scaling (screen resolution to 256x384 or 512x192)
|
||||||
switch (GPU_rotation)
|
switch (GPU_rotation)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1562,13 +1559,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
break ;
|
break ;
|
||||||
case 90:
|
case 90:
|
||||||
case 270:
|
case 270:
|
||||||
x = (x*512) / (r.right - r.left) ;
|
x = (x*384) / (r.right - r.left) ;
|
||||||
y = (y*192) / (r.bottom - r.top) ;
|
y = (y*256) / (r.bottom - r.top) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
/* translate for rotation */
|
//translate for rotation
|
||||||
if (GPU_rotation != 0)
|
if (GPU_rotation != 0)
|
||||||
translateXY(&x,&y);
|
translateXY(x,y);
|
||||||
else
|
else
|
||||||
y-=192;
|
y-=192;
|
||||||
if(x<0) x = 0; else if(x>255) x = 255;
|
if(x<0) x = 0; else if(x>255) x = 255;
|
||||||
|
@ -1576,48 +1573,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
NDS_setTouchPos(x, y);
|
NDS_setTouchPos(x, y);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NDS_releasTouch();
|
NDS_releaseTouch();
|
||||||
return 0;
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
if(HIWORD(lParam)>=192)
|
|
||||||
{
|
|
||||||
RECT r ;
|
|
||||||
s32 x = (s32)((s16)LOWORD(lParam));
|
|
||||||
s32 y = (s32)((s16)HIWORD(lParam));
|
|
||||||
GetClientRect(hwnd,&r) ;
|
|
||||||
/* translate from scaling (screen reoltution to 256x384 or 512x192) */
|
|
||||||
switch (GPU_rotation)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 180:
|
|
||||||
x = (x*256) / (r.right - r.left) ;
|
|
||||||
y = (y*384) / (r.bottom - r.top) ;
|
|
||||||
break ;
|
|
||||||
case 90:
|
|
||||||
case 270:
|
|
||||||
x = (x*512) / (r.right - r.left) ;
|
|
||||||
y = (y*192) / (r.bottom - r.top) ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
/* translate for rotation */
|
|
||||||
if (GPU_rotation != 0)
|
|
||||||
translateXY(&x,&y);
|
|
||||||
else
|
|
||||||
y-=192;
|
|
||||||
if(y>=0)
|
|
||||||
{
|
|
||||||
SetCapture(hwnd);
|
|
||||||
if(x<0) x = 0; else if(x>255) x = 255;
|
|
||||||
if(y<0) y = 0; else if(y>192) y = 192;
|
|
||||||
NDS_setTouchPos(x, y);
|
|
||||||
click = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
if(click)
|
if(click)
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
NDS_releasTouch();
|
NDS_releaseTouch();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
Loading…
Reference in New Issue