From 5d2e73ae25e6b74efdd2e0fe6eaeb6d4664ae7f3 Mon Sep 17 00:00:00 2001 From: hexdec Date: Wed, 13 Aug 2014 02:16:28 +0200 Subject: [PATCH 01/14] Initial work on 0x006BEF1B. --- src/window_peep.c | 63 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 049a36142b..838f3e6de4 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -174,6 +174,64 @@ void window_peep_open(rct_peep* peep){ RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } +rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) +{ + int v3 = eax; // push eax + + ecx = 262167; // mov ecx, 40017h + int ebx = 0xB400BE; // mov ebx, offset unk_B400BE + edx = 0x992AEC; // mov edx, offset off_992AEC + + int esi, edi; + RCT2_CALLFUNC_X(0x6EA9B1, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); // sub_6EA9B1(262167, off_992AEC); + + rct_window* w = (rct_window*)esi; + + w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); + w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); + w->number = v3; + w->page = 0; + w->var_482 = 0; + w->frame_no = 0; + + RCT2_GLOBAL(esi + 1174, sint16) = 0; // ?? + + //RCT2_GLOBAL(esi + 40, uint32) = 0x9AF81C; + //RCT2_GLOBAL(esi + 8, uint32) = RCT2_GLOBAL(0x9929B0, uint32); + //RCT2_GLOBAL(esi + 60, uint16) = v3; + //RCT2_GLOBAL(esi + 1162, sint16) = 0; // page + //RCT2_GLOBAL(esi + 1154, sint16) = 0; + //RCT2_GLOBAL(esi + 1166, sint16) = 0; // frame_no + + + eax = v3; // pop eax + + RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); // sub_6BED21(); + + w->min_width = 190; + w->min_height = 180; + w->max_width = 500; + w->max_height = 450; + + // RCT2_GLOBAL(esi + 52, sint16) = 190; // mix_width + // RCT2_GLOBAL(esi + 56, sint16) = 180; // min_height + // RCT2_GLOBAL(esi + 54, sint16) = 500; // max_width + // RCT2_GLOBAL(esi + 58, sint16) = 450; // max_height + + RCT2_GLOBAL(esi + 62, uint16) = RCT2_GLOBAL(esi + 62, uint16) | 8; // flags???? + + w->colours[0] = 1; + w->colours[1] = 4; + w->colours[2] = 4; + + // Colours + // RCT2_GLOBAL(esi + 1210, uint8) = 1; + // RCT2_GLOBAL(esi + 1211, uint8) = 4; + // RCT2_GLOBAL(esi + 1212, uint8) = 4; + + return w; +} + /** * * rct2: 0x006BEE98 @@ -188,8 +246,9 @@ void window_staff_peep_open(rct_peep* peep) ecx = WC_PEEP; edx = peep->sprite_index; - RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); - w = (rct_window*)esi; + //RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); + w = sub_6BEF1B(eax, ecx, edx, peep); + //w = (rct_window*)esi; } int PEEP_BACKGROUND_IDX = 0; From 67e0afca70a724b3e936c74eabb2deca13f7495b Mon Sep 17 00:00:00 2001 From: hexdec Date: Wed, 13 Aug 2014 02:23:59 +0200 Subject: [PATCH 02/14] Removed comments, removed v3 variable. --- src/window_peep.c | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 838f3e6de4..c60d1b89f4 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -174,61 +174,46 @@ void window_peep_open(rct_peep* peep){ RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } +/** + * Create the window for a specific peep. + * + * rct2: 0x006BEF1B + */ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) { - int v3 = eax; // push eax - - ecx = 262167; // mov ecx, 40017h - int ebx = 0xB400BE; // mov ebx, offset unk_B400BE - edx = 0x992AEC; // mov edx, offset off_992AEC + ecx = 262167; + int ebx = 0xB400BE; + edx = 0x992AEC; - int esi, edi; - RCT2_CALLFUNC_X(0x6EA9B1, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); // sub_6EA9B1(262167, off_992AEC); + // Get ESI. + int _eax = eax, esi, edi; + RCT2_CALLFUNC_X(0x6EA9B1, &_eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); + // Create the window from the ESI. rct_window* w = (rct_window*)esi; w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); - w->number = v3; + w->number = eax; w->page = 0; w->var_482 = 0; w->frame_no = 0; RCT2_GLOBAL(esi + 1174, sint16) = 0; // ?? - - //RCT2_GLOBAL(esi + 40, uint32) = 0x9AF81C; - //RCT2_GLOBAL(esi + 8, uint32) = RCT2_GLOBAL(0x9929B0, uint32); - //RCT2_GLOBAL(esi + 60, uint16) = v3; - //RCT2_GLOBAL(esi + 1162, sint16) = 0; // page - //RCT2_GLOBAL(esi + 1154, sint16) = 0; - //RCT2_GLOBAL(esi + 1166, sint16) = 0; // frame_no - - eax = v3; // pop eax - - RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); // sub_6BED21(); + RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); w->min_width = 190; w->min_height = 180; w->max_width = 500; w->max_height = 450; - // RCT2_GLOBAL(esi + 52, sint16) = 190; // mix_width - // RCT2_GLOBAL(esi + 56, sint16) = 180; // min_height - // RCT2_GLOBAL(esi + 54, sint16) = 500; // max_width - // RCT2_GLOBAL(esi + 58, sint16) = 450; // max_height - RCT2_GLOBAL(esi + 62, uint16) = RCT2_GLOBAL(esi + 62, uint16) | 8; // flags???? w->colours[0] = 1; w->colours[1] = 4; w->colours[2] = 4; - // Colours - // RCT2_GLOBAL(esi + 1210, uint8) = 1; - // RCT2_GLOBAL(esi + 1211, uint8) = 4; - // RCT2_GLOBAL(esi + 1212, uint8) = 4; - return w; } @@ -247,8 +232,9 @@ void window_staff_peep_open(rct_peep* peep) edx = peep->sprite_index; //RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); - w = sub_6BEF1B(eax, ecx, edx, peep); //w = (rct_window*)esi; + + w = sub_6BEF1B(eax, ecx, edx, peep); } int PEEP_BACKGROUND_IDX = 0; From 3f10c76344b5895a95acfbbd42372281fd78db60 Mon Sep 17 00:00:00 2001 From: hexdec Date: Wed, 13 Aug 2014 21:22:59 +0200 Subject: [PATCH 03/14] Cleaned up more code in sub_6BEF1B. --- src/window_peep.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index c60d1b89f4..cbf2b791c6 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -182,15 +182,16 @@ void window_peep_open(rct_peep* peep){ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) { ecx = 262167; - int ebx = 0xB400BE; - edx = 0x992AEC; + int ebx = 0xB400BE; // mov ebx, offset unk_B400BE + edx = 0x992AEC; // mov edx, offset off_992AEC - // Get ESI. - int _eax = eax, esi, edi; - RCT2_CALLFUNC_X(0x6EA9B1, &_eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); + int window_id; // esi + + int _eax = eax, edi; + RCT2_CALLFUNC_X(0x6EA9B1, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); // Create the window from the ESI. - rct_window* w = (rct_window*)esi; + rct_window* w = (rct_window*)window_id; w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); @@ -199,18 +200,19 @@ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) w->var_482 = 0; w->frame_no = 0; - RCT2_GLOBAL(esi + 1174, sint16) = 0; // ?? + RCT2_GLOBAL(window_id + 0x496, uint16) = 0; // missing var_494 should perhaps be uint16? - RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); + RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); w->min_width = 190; w->min_height = 180; w->max_width = 500; w->max_height = 450; - RCT2_GLOBAL(esi + 62, uint16) = RCT2_GLOBAL(esi + 62, uint16) | 8; // flags???? + w->flags |= 1 << 8; - w->colours[0] = 1; + //w->colours[0] = 1; + w->colours[0] = 16; w->colours[1] = 4; w->colours[2] = 4; From 6217440bc9cecfe6911ee607ba242679e9892fe5 Mon Sep 17 00:00:00 2001 From: hexdec Date: Wed, 13 Aug 2014 23:39:21 +0200 Subject: [PATCH 04/14] Added sub_6BED21 (called from sub_6BEF1B). --- src/window_peep.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index cbf2b791c6..91d9d2bfe8 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -174,6 +174,61 @@ void window_peep_open(rct_peep* peep){ RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } +void sub_6BED21(rct_window* w) +{ + int eax = 0 | 0x80; + uint32 esi = 0x10E63BC + (w->number << 8); + + if (RCT2_GLOBAL(esi + 0x2F, uint8) == 2) { // Staff type? + eax |= 0x20; + } + + //RCT2_CALLFUNC_X(0x698827, 0, 0, 0, 0, 0, 0, 0); + // sub_698827 + // This is here due to needing the Carry Flag. + + int CF = 0; + int _eax = RCT2_GLOBAL(esi + 0x2B, uint8); // State? + int res = RCT2_GLOBAL(0x982004 + _eax, uint8) & 1; + + if (res == 0) { + CF = 1; + } else { + eax = eax & eax; + } + + // end sub_698827 + + // pop esi + if (CF == 1) + goto loc_6BED50; + +loc_6BED47: + + CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr [esi+10h], 0Ah + if (CF == 1) { + goto loc_6BED66; //jb short loc_6BED66 + } + goto loc_6BED6B; //jmp short loc_6BED6B + +loc_6BED50: + if (w->page != 0) //cmp word ptr [esi+48Ah], 0 + goto loc_6BED47; //jnz short loc_6BED47 + + eax |= 0x400; //or eax, 400h + + CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr[esi + 10h], 0Ah + if (CF == 1) { + goto loc_6BED6B; //jb short loc_6BED6B + } + +loc_6BED66: + RCT2_CALLFUNC_X(0x6EB13A, 0, 0, 0, 0, 0, 0, 0); + +loc_6BED6B: + w->disabled_widgets = eax; +} + /** * Create the window for a specific peep. * @@ -188,7 +243,7 @@ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) int window_id; // esi int _eax = eax, edi; - RCT2_CALLFUNC_X(0x6EA9B1, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); + RCT2_CALLFUNC_X(0x6EA9B1, &_eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); // Create the window from the ESI. rct_window* w = (rct_window*)window_id; @@ -202,7 +257,8 @@ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) RCT2_GLOBAL(window_id + 0x496, uint16) = 0; // missing var_494 should perhaps be uint16? - RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); + //RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); + sub_6BED21(w); w->min_width = 190; w->min_height = 180; From 31440c9da7d49c10845e998d057ea79cf4212ea9 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 14 Aug 2014 00:01:17 +0200 Subject: [PATCH 05/14] Removed goto in sub_6BED21. --- src/window_peep.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 91d9d2bfe8..155e954a02 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -199,33 +199,23 @@ void sub_6BED21(rct_window* w) // end sub_698827 + int a = 0; + // pop esi - if (CF == 1) - goto loc_6BED50; + if (CF == 1 && w->page == 0) { + eax |= 0x400; //or eax, 400h -loc_6BED47: - - CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr [esi+10h], 0Ah - if (CF == 1) { - goto loc_6BED66; //jb short loc_6BED66 - } - goto loc_6BED6B; //jmp short loc_6BED6B - -loc_6BED50: - if (w->page != 0) //cmp word ptr [esi+48Ah], 0 - goto loc_6BED47; //jnz short loc_6BED47 - - eax |= 0x400; //or eax, 400h - - CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr[esi + 10h], 0Ah - if (CF == 1) { - goto loc_6BED6B; //jb short loc_6BED6B + a = w->disabled_widgets & (1 << 0xA); //bt dword ptr[esi + 10h], 0Ah + } -loc_6BED66: - RCT2_CALLFUNC_X(0x6EB13A, 0, 0, 0, 0, 0, 0, 0); + if (a != 1) { + CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr [esi+10h], 0Ah + if (CF == 1) { + RCT2_CALLFUNC_X(0x6EB13A, 0, 0, 0, 0, (int)w, 0, 0); + } + } -loc_6BED6B: w->disabled_widgets = eax; } From 229dedbb64d44daf7dce59438244c24b1aa650a8 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 14 Aug 2014 00:07:47 +0200 Subject: [PATCH 06/14] Changed hardcode address to RCT2_ADDRESS_SPRITE_LIST. --- src/window_peep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 155e954a02..81fc75f571 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -177,7 +177,7 @@ void window_peep_open(rct_peep* peep){ void sub_6BED21(rct_window* w) { int eax = 0 | 0x80; - uint32 esi = 0x10E63BC + (w->number << 8); + uint32 esi = RCT2_ADDRESS_SPRITE_LIST + (w->number << 8); if (RCT2_GLOBAL(esi + 0x2F, uint8) == 2) { // Staff type? eax |= 0x20; @@ -209,7 +209,7 @@ void sub_6BED21(rct_window* w) } - if (a != 1) { + if (a == 0) { CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr [esi+10h], 0Ah if (CF == 1) { RCT2_CALLFUNC_X(0x6EB13A, 0, 0, 0, 0, (int)w, 0, 0); From af06b5aae21276c024dbd2d6eac2b1db8f5e4e9b Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 14 Aug 2014 00:18:33 +0200 Subject: [PATCH 07/14] Changed sub_6EBED21 to use peep as a parameter. --- src/window_peep.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 81fc75f571..b37b52e120 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -174,12 +174,11 @@ void window_peep_open(rct_peep* peep){ RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } -void sub_6BED21(rct_window* w) +void sub_6BED21(rct_window* w, rct_peep* peep) { int eax = 0 | 0x80; - uint32 esi = RCT2_ADDRESS_SPRITE_LIST + (w->number << 8); - if (RCT2_GLOBAL(esi + 0x2F, uint8) == 2) { // Staff type? + if (peep->staff_type == 2) { eax |= 0x20; } @@ -188,8 +187,7 @@ void sub_6BED21(rct_window* w) // This is here due to needing the Carry Flag. int CF = 0; - int _eax = RCT2_GLOBAL(esi + 0x2B, uint8); // State? - int res = RCT2_GLOBAL(0x982004 + _eax, uint8) & 1; + int res = RCT2_GLOBAL(0x982004 + peep->state, uint8) & 1; if (res == 0) { CF = 1; @@ -248,7 +246,7 @@ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) RCT2_GLOBAL(window_id + 0x496, uint16) = 0; // missing var_494 should perhaps be uint16? //RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); - sub_6BED21(w); + sub_6BED21(w, peep); w->min_width = 190; w->min_height = 180; From db42345d947c7ddb13be723101bd305fe8e69ec7 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 14 Aug 2014 00:32:18 +0200 Subject: [PATCH 08/14] Used proper function for window_invalidate. --- src/window_peep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_peep.c b/src/window_peep.c index b37b52e120..0965613bdd 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -210,7 +210,7 @@ void sub_6BED21(rct_window* w, rct_peep* peep) if (a == 0) { CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr [esi+10h], 0Ah if (CF == 1) { - RCT2_CALLFUNC_X(0x6EB13A, 0, 0, 0, 0, (int)w, 0, 0); + window_invalidate(w); } } From 5c1a19e1de922bd52ee74870d5678c7e83f00940 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 14 Aug 2014 15:28:22 +0200 Subject: [PATCH 09/14] Changed sub_6BEF1B to use window_create_auto_pos rather than the subfunction. --- src/window_peep.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 0965613bdd..48bdefe840 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -224,17 +224,10 @@ void sub_6BED21(rct_window* w, rct_peep* peep) */ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) { - ecx = 262167; - int ebx = 0xB400BE; // mov ebx, offset unk_B400BE - edx = 0x992AEC; // mov edx, offset off_992AEC + ecx = 0x38ae7; // class and flags + edx = 0x992AEC; // event handler - int window_id; // esi - - int _eax = eax, edi; - RCT2_CALLFUNC_X(0x6EA9B1, &_eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); - - // Create the window from the ESI. - rct_window* w = (rct_window*)window_id; + rct_window* w = window_create_auto_pos(190, 180, edx, ecx, 0); w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); @@ -243,9 +236,8 @@ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) w->var_482 = 0; w->frame_no = 0; - RCT2_GLOBAL(window_id + 0x496, uint16) = 0; // missing var_494 should perhaps be uint16? + RCT2_GLOBAL((int*)w + 0x496, uint16) = 0; // missing var_494 should perhaps be uint16? - //RCT2_CALLFUNC_X(0x6BED21, &eax, &ebx, &ecx, &edx, &window_id, &edi, (int*)peep); sub_6BED21(w, peep); w->min_width = 190; @@ -255,8 +247,7 @@ rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) w->flags |= 1 << 8; - //w->colours[0] = 1; - w->colours[0] = 16; + w->colours[0] = 1; w->colours[1] = 4; w->colours[2] = 4; @@ -289,7 +280,8 @@ void window_staff_peep_open(rct_peep* peep) w->var_020 = RCT2_GLOBAL(0x9929BC, uint32); w->event_handlers = (uint32*)RCT2_GLOBAL(0x9929A4, uint32); w->pressed_widgets = 0; - RCT2_CALLPROC_X(0x006BED21, 0, 0, 0, 0, (int)w, 0, 0); + sub_6BED21(w, peep); + //RCT2_CALLPROC_X(0x006BED21, 0, 0, 0, 0, (int)w, 0, 0); window_init_scroll_widgets(w); RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED) { From 593841060fca8f85222f5c42fa3cd2f03073ec77 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 14 Aug 2014 15:33:57 +0200 Subject: [PATCH 10/14] Removed unused parameters, fixed warning. --- src/window_peep.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 48bdefe840..34fd46a445 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -222,12 +222,14 @@ void sub_6BED21(rct_window* w, rct_peep* peep) * * rct2: 0x006BEF1B */ -rct_window* sub_6BEF1B(int eax, int ecx, int edx, rct_peep* peep) +rct_window* sub_6BEF1B(rct_peep* peep) { - ecx = 0x38ae7; // class and flags - edx = 0x992AEC; // event handler + int eax = peep->sprite_index; + + int ecx = 0x38ae7; // class and flags + int edx = 0x992AEC; // event handler - rct_window* w = window_create_auto_pos(190, 180, edx, ecx, 0); + rct_window* w = window_create_auto_pos(190, 180, (uint32*)edx, ecx, 0); w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); @@ -262,16 +264,16 @@ void window_staff_peep_open(rct_peep* peep) { rct_window* w = window_bring_to_front_by_id(WC_PEEP, peep->sprite_index); if (!w) { - int eax, ebx, ecx, edx, esi, edi; + //int eax, ebx, ecx, edx, esi, edi; - eax = peep->sprite_index; - ecx = WC_PEEP; - edx = peep->sprite_index; + //eax = peep->sprite_index; + //ecx = WC_PEEP; + //edx = peep->sprite_index; //RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); //w = (rct_window*)esi; - w = sub_6BEF1B(eax, ecx, edx, peep); + w = sub_6BEF1B(peep); } int PEEP_BACKGROUND_IDX = 0; From d3a55efd30dffcb08efba7d4b3adbf2259d2e857 Mon Sep 17 00:00:00 2001 From: hexdec Date: Sun, 17 Aug 2014 01:34:05 +0200 Subject: [PATCH 11/14] Added window_peep_staff_events. --- src/window_peep.c | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index e21585c964..ca67c1e58d 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -112,6 +112,38 @@ void* window_peep_page_events[] = { window_peep_overview_events }; +// 0x992AEC +static void* window_peep_staff_events[] = { + (void*)0x6BDFF8, + (void*)0x6BDF55, + (void*)0x6BE558, + (void*)0x6BDF98, + (void*)0x6BDFA3, + window_peep_emptysub, + (void*)0x6BE602, + window_peep_emptysub, + window_peep_emptysub, + (void*)0x6BDFD8, + (void*)0x6BDFC3, + window_peep_emptysub, + window_peep_emptysub, + (void*)0x6BDFAE, + window_peep_emptysub, + window_peep_emptysub, + window_peep_emptysub, + window_peep_emptysub, + window_peep_emptysub, + (void*)0x6BDFED, + (void*)0x6BE5FC, + window_peep_emptysub, + window_peep_emptysub, + window_peep_emptysub, + window_peep_emptysub, + (void*)0x6BDD91, + (void*)0x6BDEAF, + window_peep_emptysub +}; + uint32 window_peep_page_enabled_widgets[] = { (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | @@ -174,6 +206,10 @@ void window_peep_open(rct_peep* peep){ RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } +/** + * rct2: 0x006BED21 + * + */ void sub_6BED21(rct_window* w, rct_peep* peep) { int eax = 0 | 0x80; @@ -225,11 +261,9 @@ void sub_6BED21(rct_window* w, rct_peep* peep) rct_window* sub_6BEF1B(rct_peep* peep) { int eax = peep->sprite_index; - int ecx = 0x38ae7; // class and flags - int edx = 0x992AEC; // event handler - rct_window* w = window_create_auto_pos(190, 180, (uint32*)edx, ecx, 0); + rct_window* w = window_create_auto_pos(190, 180, (uint32*)window_peep_staff_events, ecx, 0); w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); @@ -238,7 +272,7 @@ rct_window* sub_6BEF1B(rct_peep* peep) w->var_482 = 0; w->frame_no = 0; - RCT2_GLOBAL((int*)w + 0x496, uint16) = 0; // missing var_494 should perhaps be uint16? + RCT2_GLOBAL((int*)w + 0x496, uint16) = 0; // missing, var_494 should perhaps be uint16? sub_6BED21(w, peep); @@ -247,7 +281,7 @@ rct_window* sub_6BEF1B(rct_peep* peep) w->max_width = 500; w->max_height = 450; - w->flags |= 1 << 8; + w->flags = 8; w->colours[0] = 1; w->colours[1] = 4; From aa0709c439810c9b2987d599ff642af6c14f5531 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 17 Aug 2014 11:01:34 +0100 Subject: [PATCH 12/14] Fixed clicking on peep causing hybrid --- src/window_peep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/window_peep.c b/src/window_peep.c index 72be7b5007..44ed2e0bc7 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -129,7 +129,8 @@ uint32 window_peep_page_enabled_widgets[] = { void window_peep_open(rct_peep* peep){ if (peep->type == PEEP_TYPE_STAFF){ - RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); + window_staff_peep_open(peep); + return; } rct_window* window; From b0d39bbf0eeef84bc11c381a707d9d3fbc2244a1 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 17 Aug 2014 11:45:43 +0100 Subject: [PATCH 13/14] Added sepearte file for staff_peep_window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/window_peep.c | 32 ------ src/window_staff_peep.c | 157 ++++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 32 deletions(-) create mode 100644 src/window_staff_peep.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 55b64865eb..ce7c4ed569 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -123,6 +123,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 65ac515497..6ae0ef6755 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -368,6 +368,9 @@ Windows + + Windows + diff --git a/src/window_peep.c b/src/window_peep.c index 44ed2e0bc7..570e8cddcf 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -174,35 +174,3 @@ void window_peep_open(rct_peep* peep){ window_init_scroll_widgets(window); RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } - -/** -* -* rct2: 0x006BEE98 -*/ -void window_staff_peep_open(rct_peep* peep) -{ - rct_window* w = window_bring_to_front_by_id(WC_PEEP, peep->sprite_index); - if (!w) { - int eax, ebx, ecx, edx, esi, edi; - - eax = peep->sprite_index; - ecx = WC_PEEP; - edx = peep->sprite_index; - - RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); - w = (rct_window*)esi; - } - - int PEEP_BACKGROUND_IDX = 0; - w->widgets = RCT2_GLOBAL(0x992998, rct_widget*); - w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); - w->var_020 = RCT2_GLOBAL(0x9929BC, uint32); - w->event_handlers = (uint32*)RCT2_GLOBAL(0x9929A4, uint32); - w->pressed_widgets = 0; - RCT2_CALLPROC_X(0x006BED21, 0, 0, 0, 0, (int)w, 0, 0); - window_init_scroll_widgets(w); - RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); - if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED) { - RCT2_CALLPROC_X(w->event_handlers[1], 0, 0, 0, 10, (int)w, 0, 0); - } -} \ No newline at end of file diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c new file mode 100644 index 0000000000..774569b0f2 --- /dev/null +++ b/src/window_staff_peep.c @@ -0,0 +1,157 @@ +/***************************************************************************** +* Copyright (c) 2014 Ted John, Duncan Frost +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "addresses.h" +#include "game.h" +#include "peep.h" +#include "string_ids.h" +#include "sprite.h" +#include "sprites.h" +#include "widget.h" +#include "window.h" +#include "window_dropdown.h" + +enum WINDOW_STAFF_PEEP_PAGE { + WINDOW_STAFF_PEEP_OVERVIEW, + WINDOW_STAFF_PEEP_OPTIONS, + WINDOW_STAFF_PEEP_STATISTICS, +}; + +enum WINDOW_STAFF_PEEP_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_RESIZE, + WIDX_TAB_1, + WIDX_TAB_2, + WIDX_TAB_3, + WIDX_TAB_4, + WIDX_VIEWPORT, + WIDX_BTM_LABEL, + WIDX_PATROL, + WIDX_RENAME, + WIDX_LOCATE, + WIDX_FIRE +}; + +void window_staff_peep_emptysub(){}; + +rct_widget window_staff_peep_overview_widgets[] = { + { WWT_FRAME, 0, 0, 189, 0, 179, 0x0FFFFFFFF, STR_NONE }, // Panel / Background + { WWT_CAPTION, 0, 1, 188, 1, 14, 0x361, STR_WINDOW_TITLE_TIP }, // Title + { WWT_CLOSEBOX, 0, 177, 187, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP }, // Close x button + { WWT_RESIZE, 1, 0, 189, 43, 179, 0x0FFFFFFFF, STR_NONE }, // Resize + { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1939 }, // Tab 1 + { WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1945}, // Tab 2 + { WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 2348}, // Tab 3 + { WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, STR_NONE}, // Tab 4 + { WWT_VIEWPORT, 1, 3, 164, 47, 166, 0x0FFFFFFFF, STR_NONE}, // Viewport + { WWT_12, 1, 3, 164, 167, 177, 0x0FFFFFFFF, STR_NONE }, // Label at bottom of viewport + { WWT_FLATBTN, 1, 165, 188, 45, 68, 0x1436, 1706}, // Pickup Button + { WWT_FLATBTN, 1, 165, 188, 69, 92, 0x1437, 1708}, // Patrol Button + { WWT_FLATBTN, 1, 165, 188, 93, 116, 0x1430, 1056}, // Rename Button + { WWT_FLATBTN, 1, 165, 188, 117, 140, 0x142F, 1027}, // Locate Button + { WWT_FLATBTN, 1, 165, 188, 141, 164, 0x142D, 1705}, // Fire Button + { WIDGETS_END }, +}; + +rct_widget *window_staff_peep_page_widgets[] = { + window_staff_peep_overview_widgets +}; + +static void* window_staff_peep_overview_events[] = { + (void*)0x6BDFF8, + (void*)0x6BDF55, + (void*)0x6BE558, + (void*)0x6BDF98, + (void*)0x6BDFA3, + window_staff_peep_emptysub, + (void*)0x6BE602, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDFD8, + (void*)0x6BDFC3, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDFAE, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDFED, + (void*)0x6BE5FC, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDD91, //Invalidate + (void*)0x6BDEAF, //Paint + (void*)0x6BE62A +}; + +void* window_staff_peep_page_events[] = { + window_staff_peep_overview_events +}; + +uint32 window_staff_peep_page_enabled_widgets[] = { + (1 << WIDX_CLOSE) | + (1 << WIDX_TAB_1) | + (1 << WIDX_TAB_2) | + (1 << WIDX_TAB_3) | + (1 << WIDX_PATROL) | + (1 << WIDX_RENAME) | + (1 << WIDX_LOCATE) | + (1 << WIDX_FIRE) | + (1 << 14) +}; + +/** +* +* rct2: 0x006BEE98 +*/ +void window_staff_peep_open(rct_peep* peep) +{ + rct_window* w = window_bring_to_front_by_id(WC_PEEP, peep->sprite_index); + if (!w) { + int eax, ebx, ecx, edx, esi, edi; + + eax = peep->sprite_index; + ecx = WC_PEEP; + edx = peep->sprite_index; + + RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); + w = (rct_window*)esi; + } + w->page = 0; + window_invalidate(w); + + w->widgets = window_staff_peep_overview_widgets; + w->enabled_widgets = window_staff_peep_page_enabled_widgets[0]; + w->var_020 = RCT2_GLOBAL(0x9929BC, uint32); + w->event_handlers = window_staff_peep_page_events[0]; + w->pressed_widgets = 0; + RCT2_CALLPROC_X(0x006BED21, 0, 0, 0, 0, (int)w, 0, 0); + window_init_scroll_widgets(w); + RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); + if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED) { + RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_UP], 0, 0, 0, 10, (int)w, 0, 0); + } +} \ No newline at end of file From ea43709c27320e1a92a5f2e969d1c2d9685ca919 Mon Sep 17 00:00:00 2001 From: hexdec Date: Sun, 17 Aug 2014 21:11:26 +0200 Subject: [PATCH 14/14] Fixed using wrong class & flag. --- src/window_staff_peep.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 8c5832334a..0d68899aa7 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -180,14 +180,11 @@ void sub_6BED21(rct_window* w, rct_peep* peep) */ rct_window* sub_6BEF1B(rct_peep* peep) { - int eax = peep->sprite_index; - int ecx = 0x38ae7; // class and flags - - rct_window* w = window_create_auto_pos(190, 180, (uint32*)window_staff_peep_overview_events, ecx, 0); + rct_window* w = window_create_auto_pos(190, 180, (uint32*)window_staff_peep_overview_events, WC_PEEP, (uint16)0x400); w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*); w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); - w->number = eax; + w->number = peep->sprite_index; w->page = 0; w->var_482 = 0; w->frame_no = 0;