summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-10-04 17:34:00 +0800
committerIru Cai <mytbk920423@gmail.com>2018-10-04 17:34:00 +0800
commitd999645d973846eddacc66d414a62bc83f3fdfab (patch)
tree2860c1778af80836b65b19f4b670db2e9fad1ab4
parent287472628b86043c3fffef88b02b6002c5e6d8a5 (diff)
downloadrich4-d999645d973846eddacc66d414a62bc83f3fdfab.tar.xz
rewrite cursor functions using known structs
-rw-r--r--csrc/fcn_4021f8.c20
-rw-r--r--csrc/media_init.c2
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 = &current_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 = &current_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 = &current_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 = &current_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);