From b331fec7eb4f612a8f7ff36a7a463a206aa4ca8f Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Thu, 27 Sep 2018 09:55:14 +0800 Subject: move animation --- csrc/cards.c | 35 +++++++++-------------- csrc/drawing.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 22 deletions(-) (limited to 'csrc') diff --git a/csrc/cards.c b/csrc/cards.c index 267091e..bb050c0 100644 --- a/csrc/cards.c +++ b/csrc/cards.c @@ -172,8 +172,7 @@ int average_cash_card2() players[current_player].cash = esi; players[ebp].cash = esi; if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - players[current_player].f8, players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, players[ebp].f8, players[ebp].f10, 100); } fcn.0041d433(current_player); @@ -361,8 +360,7 @@ int swap_land_card() } // 44277f if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, (int)(int16_t)word [esi], (int)(int16_t)word [esi + 2], 100); } // 4427bb @@ -436,8 +434,7 @@ int swap_land_card() } // 4429cd if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, (int)(int16_t)word [esi], (int)(int16_t)word [esi + 2], 100); } // 442a09 @@ -528,8 +525,7 @@ int swap_house_card() } } if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, (int)(int16_t)word [ebp], (int)(int16_t)word [ebp + 2], 100); } fcn.00451985(); @@ -601,8 +597,7 @@ int swap_house_card() } } if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, (int)(int16_t)word [ebp], (int)(int16_t)word [ebp + 2], 100); } fcn.00451985(); @@ -662,10 +657,8 @@ int turn_back_card() player_say(current_player, 3, edi); edx = esi = fcn.0040d293(ebx); if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, - (uint32_t)players[edx].f8, (uint32_t)players[edx].f10, 100); - + move_animation(0, players[current_player].f8, players[current_player].f10, + players[edx].f8, players[edx].f10, 100); } // 443024 fcn.0040c78c(esi); @@ -914,8 +907,7 @@ int angel_card() } } // 4435e4 - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, (int32_t)(int16_t)[edi], (int32_t)(int16_t)[edi+2], 100); fcn.00451985(); player_action_2(0, 0, 1); @@ -931,8 +923,7 @@ int angel_card() ebx = dw_498e88 + eax; fcn.00456c0a(dw_474938, 0x2f440, ebp, 0xffff); if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, - (uint32_t)players[current_player].f8, (uint32_t)players[current_player].f10, + move_animation(0, players[current_player].f8, players[current_player].f10, (int32_t)(int16_t)[ebx], (int32_t)(int16_t)[ebx+2], 100); } fcn.00451985(); @@ -967,7 +958,7 @@ int stop_card() player_say(current_player, 3, card_strings[c][0][13]); } if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, + move_animation(0, players[current_player].f8, players[current_player].f10, players[selected_player].f8, players[selected_player].f10, 100); } @@ -1030,7 +1021,7 @@ int sleep_walking_card() player_say(current_player, 3, card_strings[c][0][15]); int selected_player = fcn.0040d293(esi); if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, + move_animation(0, players[current_player].f8, players[current_player].f10, players[selected_player].f8, players[selected_player].f10, 100); } @@ -1148,7 +1139,7 @@ int invite_god_card () player_action_2(0, 0, 1); int _eax = edi * 40 + dw_498e80; - sub.WINMM.dll_timeGetTime_669(esi, + move_animation(esi, (int16_t) word [eax], (int16_t) word [eax + 2], players[current_player].f8, players[current_player].f10, 0); @@ -1176,7 +1167,7 @@ int tortoise_walking_card() player_say(current_player, 3, card_strings[c][0][29]); } if (players[current_player].who_plays != 1) { - sub.WINMM.dll_timeGetTime_669(0, + move_animation(0, players[current_player].f8, players[current_player].f10, players[selected_player].f8, players[selected_player].f10, 100); } diff --git a/csrc/drawing.c b/csrc/drawing.c index d115738..32f171c 100644 --- a/csrc/drawing.c +++ b/csrc/drawing.c @@ -352,3 +352,92 @@ void player_say(int p, int t, const char *s) IDirectDrawSurface_BltFast(pddrawsf1, r0.left, r0.top, pddrawsf2, &r0, DDBLTFAST_WAIT); free(edi); } + +void move_animation(int obj, int x1, int y1, int x2, int y2, int T) +{ + /* push 4 regs, sub esp, 0x68 */ + if (obj != 0) { + eax = (obj - 1) * 3; + ecx = byte [eax*8 + 0x496d09]; + ebp = (8 - dword [0x499088] + ecx) & 7; + edi = byte [eax*8 + 0x496d08]; + edi = dword [edi*4 + 0x49692c]; + eax = ebp * 12; + ebx = edi + 12 + eax; + } else { + ebp = 0; + edi = dword [0x49697c]; + ebx = edi + 12; + } + + int x3, y3, x4, y4; /* sp + 0x30,0x34,0x38,0x3c */ + fcn.00409a23(&x1, &y1, &x3, &y3); + fcn.00409a23(&x2, &y2, &x4, &y4); + int distx = x4 - x3; + int disty = y4 - y3; + + if (edx == 0 && ecx == 0) { + return; + } + + int dist = trunc(1 + sqrtf(disty * disty + distx * distx)); /* @ sp + 0x60 */ + float dx = distx / (float)dist; /* @ sp+0x48 */ + float dy = disty / (float)dist; /* @sp+0x44 */ + float curx = x3 + dx; /* @ sp+0x58 */ + float cury = y3 + dy; /* @ sp+0x5c */ + + RECT r0, r1, r2; /* @ sp, sp+0x10, sp+0x20 */ + r0.left = -1000; + IDirectDrawSurface_Lock(pddrawsf2, NULL, &sfdesc1, 1, 0); + st_46caec.f8 = sfdesc1.lpSurface; + struct st * st0 = fcn_00451a97(&st_46caec, NULL, 0, 40, 440, 440); /* st0 @ sp+0x4c */ + IDirectDrawSurface_Unlock(pddrawsf2, NULL); + + while (dist != 0) { + esi = timeGetTime(); + int icurx = trunc(curx); /* @ sp+0x54 */ + int icury = trunc(cury); /* @ sp+0x50 */ + IDirectDrawSurface_Lock(pddrawsf2, NULL, &sfdesc1, 1, 0); + if (r0.left != -1000) { + fcn.00456469(sfdesc1.lpSurface, st0, r0.left, r0.top, r0.left, r0.top - 40, r0.right - r0.left, r0.bottom - r0.top); + } + fcn.00456770(sfdesc1.lpSurface, edi, ebp, icurx, icury); + IDirectDrawSurface_Unlock(pddrawsf2, NULL); + r2.left = icurx - (s16)word [ebx + 4]; + r2.top = icury - (s16) word [ebx + 6]; + r2.right = r2.left + (s16)word[ebx]; + r2.bottom = r2.top + (s16) word [ebx+2]; + if (r0.left != -1000) { + fcn.00452808(&r2, &r0, &r1); + } else { + memcpy(&r1, &r2, sizeof(RECT)); + } + if (r1.right > 0 && r1.top < 480) { + if (r1.left < 0) { + r1.left = 0; + } + if (r1.bottom > 480) { + r1.bottom = 480; + } + IDirectDrawSurface_BltFast(pddrawsf1, r1.left, r1.top, pddrawsf2, &r1, DDBLTFAST_WAIT); + } + memcpy(&r0, &r2, sizeof(RECT)); + eax = timeGetTime() - esi; + if (eax < 24) { + sub.WINMM.dll_timeGetTime_85e(24 - eax); + } + curx += dx; + cury += dy; + dist--; + } + // 40e9bd + sub.WINMM.dll_timeGetTime_85e(T); + if (obj == 0) { + IDirectDrawSurface_Lock(pddrawsf2, NULL, &sfdesc1, 1, 0); + fcn.00456469(sfdesc1.lpSurface, st0, r0.left, r0.top, r0.left, r0.top - 40, r0.right - r0.left, r0.bottom - r0.top); + IDirectDrawSurface_Unlock(pddrawsf2, NULL); + IDirectDrawSurface_BltFast(pddrawsf1, r0.left, r0.top, pddrawsf2, &r0, DDBLTFAST_WAIT); + } + // 0x40ea4d + free(st0); +} -- cgit v1.2.3