From d999645d973846eddacc66d414a62bc83f3fdfab Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Thu, 4 Oct 2018 17:34:00 +0800 Subject: rewrite cursor functions using known structs --- csrc/fcn_4021f8.c | 20 ++++++++------------ csrc/media_init.c | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/csrc/fcn_4021f8.c b/csrc/fcn_4021f8.c index f5b81bf..0e4b08c 100644 --- a/csrc/fcn_4021f8.c +++ b/csrc/fcn_4021f8.c @@ -49,11 +49,9 @@ void GetCursorPos_35d(RECT *rect) GetCursorPos(&p); if (rect != NULL) { - eax = ¤t_cursors[w_48a172]; - edx = *(int16_t*)(eax + 4); /* sign extend */ - edx = p.x - edx; - eax = *(int16_t*)(eax + 6); - eax = p.y - eax; + struct graph_st *csor = ¤t_cursors[w_48a172]; + edx = p.x - csor->x; + eax = p.y - csor->y; ecx = edx + 0x20; esi = eax + 0x20; if (edx >= rect->right || ecx <= rect->left || eax >= rect->bottom || esi <= rect->top) { @@ -73,7 +71,7 @@ void GetCursorPos_35d(RECT *rect) } b_48a17a = 1; IDirectDrawSurface_Lock(pddrawsf1, NULL, &sfdesc2, 1, 0); - st_46cb14.f8 = dw_48a11c; + st_46cb14.gdata = sfdesc2.lpSurface; fcn_00401f5e(); IDirectDrawSurface_Unlock(pddrawsf1, NULL); b_48a17a = 0; @@ -96,11 +94,9 @@ void GetCursorPos_250(RECT *rect) GetCursorPos(&p); if (rect != NULL) { - eax = ¤t_cursors[w_48a172]; - edx = *(int16_t*)(eax + 4); /* sign extend */ - edx = p.x - edx; - eax = *(int16_t*)(eax + 6); - eax = p.y - eax; + struct graph_st *csor = ¤t_cursors[w_48a172]; + edx = p.x - csor->x; + eax = p.y - csor->y; ecx = edx + 0x20; esi = eax + 0x20; if (edx >= rect->right || ecx <= rect->left || eax >= rect->bottom || esi <= rect->top) { @@ -120,7 +116,7 @@ void GetCursorPos_250(RECT *rect) } b_48a17a = 1; IDirectDrawSurface_Lock(pddrawsf1, NULL, &sfdesc2, 1, 0); - st_46cb14.f8 = dw_48a11c; + st_46cb14.gdata = sfdesc2.lpSurface; fcn_00401e59(p.x, p.y); IDirectDrawSurface_Unlock(pddrawsf1, NULL); b_48a17a = 0; diff --git a/csrc/media_init.c b/csrc/media_init.c index 56367fb..da6f479 100644 --- a/csrc/media_init.c +++ b/csrc/media_init.c @@ -104,7 +104,7 @@ void CALLBACK *timeProc( IDirectDraw_WaitForVerticalBlank(pddraw, 1, NULL); } IDirectDrawSurface_Lock(pddrawsf1, NULL, &sfdesc2, 1, NULL); - st_46cb14.f8 = dw_48a11c; + st_46cb14.gdata = sfdesc2.lpSurface; fcn_00401f5e(); fcn_00401e59(p.x, p.y); IDirectDrawSurface_Unlock(pddrawsf1, NULL); -- cgit v1.2.3