diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-09-05 00:15:08 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-09-05 00:15:08 +0800 |
commit | bd659aa88ef3ee8389378e37f57460fb88b2e435 (patch) | |
tree | 51a13a632fc284465d40ee342d2a9ca6eccd6bff /csrc/drawing.c | |
parent | a9ca764ffc33c8eb909137b3533689d9ebd8f5aa (diff) | |
download | rich4-bd659aa88ef3ee8389378e37f57460fb88b2e435.tar.xz |
some drawing functions
Diffstat (limited to 'csrc/drawing.c')
-rw-r--r-- | csrc/drawing.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/csrc/drawing.c b/csrc/drawing.c new file mode 100644 index 0000000..5aaf6cf --- /dev/null +++ b/csrc/drawing.c @@ -0,0 +1,109 @@ +#include <windows.h> +#include "player_info.h" + +void fcn_417191(int a0) +{ + RECT r0; + r0.left = dw_48bdec; + r0.top = dw_48bde8; + r0.right = r0.left + dw_48bdd8; + r0.bottom = r0.top + dw_48bddc; + + GetCursorPos_35d(&r0); /* fcn_4021f8.c */ + + if (dw_48bdec != dw_475284 || dw_48bde8 != dw_475288) { + dw_48bdec = dw_475284; + dw_48bde8 = dw_475288; + IDirectDrawSurface_BltFast(pddrawsf1, r0.left, r0.top, pddrawsf2, &r0, 0x10); + } + + if (a0 == 0) { + if (b_46cafd != 0) + return; + + GetCursorPos_250(&r0); + return; + } + + ebx = 0; + if (players[current_player].days_stopping != 0) + ebx = 2; + if (players[current_player].days_tortoise_walking != 0) + ebx = 4; + + IDirectDrawSurface_Lock(pddrawsf1, 0, &sfdesc1, 1, 0); + w_46caec = sfdesc1.DUMMYUNIONNAME1.lPitch / 2; + dw_46caf4 = sfdesc1.lpSurface; + + edx = dw_48bdd4 + ebx; + edx = edx * 12 + dw_48be04 + 12; + + fcn.004562a5(0x46caec, edx, dw_475284, dw_475288); + + eax = players[current_player].traffic_method & 3; + switch (eax) { + case 0: + eax = dw_475288 + 0x1a; + if (players[current_player].days_stopping == 0) { + fcn.004562a5(0x46caec, dw_48be04+0x60, dw_475284+7, eax); + } else { + fcn.004562a5(0x46caec, dw_48be04+0x54, dw_475284+8, eax); + } + break; + case 1: + for (ebx = 0; ebx < 2; ebx++) { + edx = players[current_player].ndices - 1; + if (ebx <= edx && players[current_player].days_stopping == 0) { + eax_1 = ebx * 19 + dw_475288 + 0x10; + edx = (ebx * 2 + 7) * 12; + eax_2 = dw_48be04 + 0xc + edx; + fcn.004562a5(0x46caec, eax_2, dw_475284 + 7, eax_1); + } else { + eax_1 = ebx*19 + dw_475288 + 0x10; + eax_2 = (ebx * 2 + 6) * 12 + dw_48be04 + 0xc; + fcn.004562a5(0x46caec, eax_2, dw_475284 + 8, eax_1); + } + } + break; + case 2: + for (ebx = 0; ebx < 3; ebx++) { + edx = players[current_player].ndices - 1; + if (ebx <= edx && players[current_player].days_stopping == 0) { + a4 = ebx * 16 + dw_475288 + 9; + a3 = dw_475284 + 7; + a2 = (ebx * 2 + 7) * 12 + dw_48be04 + 0xc; + fcn.004562a5(0x46caec, a2, a3, a4); + } else { + a4 = ebx * 16 + dw_475288 + 9; + a3 = dw_475284 + 8; + a2 = (ebx * 2 + 6) * 12 + dw_48be04 + 0xc; + fcn.004562a5(0x46caec, a2, a3, a4); + } + } + break; + default: + break; + } + IDirectDrawSurface_Unlock(pddrawsf1, NULL); + GetCursorPos_250(&r0); + w_46caec = 0x280; +} + +void IntersectRect_4cd(RECT *r0) +{ + RECT result_rect; + RECT o_rect; + if (b_46cafd == 0) + return; + + o_rect.left = dw_475284; + o_rect.top = dw_475288; + o_rect.right = o_rect.left + dw_48bdd8; + o_rect.bottom = o_rect.top + dw_48bddc; + + int ret = IntersectRect(&result_rect, &o_rect, r0); + if (ret == 0) // do not intersect + return; + + fcn_417191(1); +} |