From 1af884da0d3760b882b7d75e0bd968922798070b Mon Sep 17 00:00:00 2001 From: King_Hual Date: Mon, 15 Sep 2014 21:21:38 +0300 Subject: [PATCH 01/31] Identified some addresses and structure fields, decompiled most of sub_6C0C3F. --- src/addresses.h | 6 ++++++ src/editor.c | 8 +++++--- src/marketing.c | 4 ++-- src/peep.c | 16 ++++++++-------- src/peep.h | 2 +- src/scenario.h | 2 +- src/staff.c | 29 ++++++++++++++++++++++++++--- src/staff.h | 2 ++ src/window_staff.c | 2 +- src/window_staff_peep.c | 8 +++++--- 10 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 51fbda55ee..38bfa24779 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -423,6 +423,12 @@ #define RCT2_ADDRESS_COMMON_FORMAT_ARGS 0x013CE952 +#define RCT2_ADDRESS_STAFF_MODE_ARRAY 0x013CA672 + +#define RCT2_STAFF_MODE_NONE 0 +#define RCT2_STAFF_MODE_NORMAL 1 +#define RCT2_STAFF_MODE_PATROL 3 + static void RCT2_CALLPROC_EBPSAFE(int address) { #ifdef _MSC_VER diff --git a/src/editor.c b/src/editor.c index db3ead3c26..5a3265e873 100644 --- a/src/editor.c +++ b/src/editor.c @@ -34,6 +34,7 @@ #include "audio.h" #include "sprite.h" #include "string_ids.h" +#include "staff.h" static void set_all_land_owned(); @@ -182,10 +183,11 @@ static void set_all_land_owned() */ void sub_6BD3A4() { for (short i = 0; i < 200; i++) { - RCT2_ADDRESS(0x013CA672, uint8)[i] = 0; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = RCT2_STAFF_MODE_NONE; } for (short i = 200; i < 204; i++) { - RCT2_ADDRESS(0x013CA672, uint8)[i] = 1; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = RCT2_STAFF_MODE_NORMAL; } - RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + //RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + sub_6C0C3F(); } diff --git a/src/marketing.c b/src/marketing.c index 5d94454cae..af6179fc1c 100644 --- a/src/marketing.c +++ b/src/marketing.c @@ -113,7 +113,7 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) peep->item_standard_flags |= PEEP_ITEM_VOUCHER; peep->var_F0 = 1; peep->var_F1 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; - peep->var_C5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->staff_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: @@ -128,7 +128,7 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) case ADVERTISING_CAMPAIGN_PARK: break; case ADVERTISING_CAMPAIGN_RIDE: - peep->var_C5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->staff_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; } diff --git a/src/peep.c b/src/peep.c index aa2d252b6a..629426280a 100644 --- a/src/peep.c +++ b/src/peep.c @@ -177,31 +177,31 @@ void peep_problem_warnings_update() break; case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 - if (peep->var_C5 == -1){ + if (peep->staff_id == -1){ hunger_counter++; break; } - ride = &g_ride_list[peep->var_C5]; + ride = &g_ride_list[peep->staff_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x80000)) hunger_counter++; break; case PEEP_THOUGHT_TYPE_THIRSTY: - if (peep->var_C5 == -1){ + if (peep->staff_id == -1){ thirst_counter++; break; } - ride = &g_ride_list[peep->var_C5]; + ride = &g_ride_list[peep->staff_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x1000000)) thirst_counter++; break; case PEEP_THOUGHT_TYPE_BATHROOM: - if (peep->var_C5 == -1){ + if (peep->staff_id == -1){ bathroom_counter++; break; } - ride = &g_ride_list[peep->var_C5]; + ride = &g_ride_list[peep->staff_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x2000000)) bathroom_counter++; break; @@ -447,8 +447,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum break; case PEEP_STATE_WALKING: case 0x14: - if (peep->var_C5 != 0xFF){ - ride = g_ride_list[peep->var_C5]; + if (peep->staff_id != 0xFF){ + ride = g_ride_list[peep->staff_id]; *argument_1 = STR_HEADING_FOR | (ride.name << 16); *argument_2 = ride.name_arguments; } diff --git a/src/peep.h b/src/peep.h index 30a34cb7bb..a938440268 100644 --- a/src/peep.h +++ b/src/peep.h @@ -386,7 +386,7 @@ typedef struct { uint16 var_AE; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 uint8 var_C4; // 0xC4 - uint8 var_C5; + uint8 staff_id; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 diff --git a/src/scenario.h b/src/scenario.h index cbd5b5d764..6f0fdd33f7 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -330,7 +330,7 @@ typedef struct { uint8 ride_measurements[0x25860]; uint32 dword_13B0E6C; uint16 word_13B0E70; - uint32 dword_13B0E72[0x6600]; + uint32 dword_13B0E72[0x6600]; // 512 bytes per staff peep uint8 byte_13CA672[116]; uint8 byte_13CA6E6[84]; uint8 byte_13CA73A[4]; diff --git a/src/staff.c b/src/staff.c index ce46f47525..a5e00f758d 100644 --- a/src/staff.c +++ b/src/staff.c @@ -99,7 +99,7 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int i; for (i = 0; i < STAFF_MAX_COUNT; i++) { - if (!(RCT2_ADDRESS(0x013CA672, uint8)[i] & 1)) + if (!(RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] & 1)) break; } @@ -220,9 +220,9 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, RCT2_CALLPROC_X(0x00699115, (uint32)ebp & 0xFFFFFF3F, 0, 0, 0, (int)newPeep, 0, (*ebp << 25) | (*ebp >> 6)); - newPeep->var_C5 = newStaffId; + newPeep->staff_id = newStaffId; - RCT2_ADDRESS(0x013CA672, uint8)[newStaffId] = 1; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[newStaffId] = RCT2_STAFF_MODE_NORMAL; for (int edi = 0; edi < 0x80; edi++) { int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; @@ -267,4 +267,27 @@ uint16 hire_new_staff_member(uint8 staff_type) return 0xFFFF; return edi; +} + +void sub_6C0C3F() +{ + register rct_peep* peep; + + for (register uint8 staff_type = 0; staff_type < STAFF_TYPE_COUNT; ++staff_type) + { + for (register uint8 i = 0; i < 128; ++i) + RCT2_ADDRESS(0x13B0E72 + (staff_type + STAFF_MAX_COUNT) * 512, uint32)[i] = 0; + + for (register uint16 sprite_index = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_index != SPRITE_INDEX_NULL; sprite_index = peep->next) + { + peep = GET_PEEP(sprite_index); + + if (peep->type == PEEP_TYPE_STAFF && staff_type == peep->staff_type) + { + for (register uint8 i = 0; i < 128; ++i) + RCT2_ADDRESS(0x13B0E72 + (staff_type + STAFF_MAX_COUNT) * 512, uint32)[i] |= RCT2_ADDRESS(0x13B0E72 + (peep->staff_id * 512) * 512, uint32)[i]; + + } + } + } } \ No newline at end of file diff --git a/src/staff.h b/src/staff.h index 533c0b4a8f..fbe54902a0 100644 --- a/src/staff.h +++ b/src/staff.h @@ -24,6 +24,7 @@ #include "rct2.h" #define STAFF_MAX_COUNT 0xC8 +#define STAFF_TYPE_COUNT 0x04 enum STAFF_TYPE { STAFF_TYPE_HANDYMAN, @@ -37,5 +38,6 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, void update_staff_colour(uint8 staff_type, uint16 color); uint16 hire_new_staff_member(uint8 staff_type); +void sub_6C0C3F(); #endif \ No newline at end of file diff --git a/src/window_staff.c b/src/window_staff.c index eed1574ee7..57cc1c1e2a 100644 --- a/src/window_staff.c +++ b/src/window_staff.c @@ -626,7 +626,7 @@ void window_staff_scrollpaint() gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 175, y - 1, 305); // True if a patrol path is set for the worker - if (RCT2_ADDRESS(0x013CA672, uint8)[peep->var_C5] & 2) { + if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[peep->staff_id] & 2) { gfx_draw_sprite(dpi, 0x13FD, 110, y - 1, 0); } diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 555818c920..f67a8daaab 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -28,6 +28,7 @@ #include "widget.h" #include "window.h" #include "window_dropdown.h" +#include "staff.h" enum WINDOW_STAFF_PEEP_PAGE { WINDOW_STAFF_PEEP_OVERVIEW, @@ -543,7 +544,7 @@ void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_wi rct_peep* peep = GET_PEEP(w->number); // Disable clear patrol area if no area is set. - if (!(RCT2_ADDRESS(0x013CA672, uint8)[peep->var_C5] & 2)) { + if (!(RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[peep->staff_id] & 2)) { RCT2_GLOBAL(0x009DED34, sint32) |= 1 << 1; } } @@ -563,17 +564,18 @@ void window_staff_peep_overview_dropdown() // Clear patrol if (dropdownIndex == 1) { rct_peep* peep = GET_PEEP(w->number); - int edi = peep->var_C5; + int edi = peep->staff_id; int ebx = edi << 9; for (int i = 0; i < 128; i++) { RCT2_GLOBAL(0x13B0E72 + ebx + i * 4, uint32) = 0; } - RCT2_GLOBAL(0x13CA672 + edi, uint16) &= 0xFD; // bug?? + RCT2_GLOBAL(RCT2_ADDRESS_STAFF_MODE_ARRAY + edi, uint16) &= 0xFD; // bug?? window_invalidate(w); RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + //sub_6C0C3F(); } else { if (!tool_set(w, widgetIndex, 22)) { From 52232ed819707e29437f2bc1efed22282fcc461d Mon Sep 17 00:00:00 2001 From: King_Hual Date: Mon, 15 Sep 2014 21:38:32 +0300 Subject: [PATCH 02/31] window_staff_peep_overview_dropdown uses sub_6C0C3F --- src/window_staff_peep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index f67a8daaab..59da317802 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -574,8 +574,8 @@ void window_staff_peep_overview_dropdown() RCT2_GLOBAL(RCT2_ADDRESS_STAFF_MODE_ARRAY + edi, uint16) &= 0xFD; // bug?? window_invalidate(w); - RCT2_CALLPROC_EBPSAFE(0x006C0C3F); - //sub_6C0C3F(); + //RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + sub_6C0C3F(); } else { if (!tool_set(w, widgetIndex, 22)) { From ec9177123c8d022580aa6775a36563273392d069 Mon Sep 17 00:00:00 2001 From: King_Hual Date: Mon, 15 Sep 2014 21:47:54 +0300 Subject: [PATCH 03/31] Changed staff modes to enum --- src/addresses.h | 6 +----- src/editor.c | 4 ++-- src/staff.c | 2 +- src/staff.h | 6 ++++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 38bfa24779..68a4bcacef 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -423,11 +423,7 @@ #define RCT2_ADDRESS_COMMON_FORMAT_ARGS 0x013CE952 -#define RCT2_ADDRESS_STAFF_MODE_ARRAY 0x013CA672 - -#define RCT2_STAFF_MODE_NONE 0 -#define RCT2_STAFF_MODE_NORMAL 1 -#define RCT2_STAFF_MODE_PATROL 3 +#define RCT2_ADDRESS_STAFF_MODE_ARRAY 0x013CA672 static void RCT2_CALLPROC_EBPSAFE(int address) { diff --git a/src/editor.c b/src/editor.c index 5a3265e873..138eeb1162 100644 --- a/src/editor.c +++ b/src/editor.c @@ -183,10 +183,10 @@ static void set_all_land_owned() */ void sub_6BD3A4() { for (short i = 0; i < 200; i++) { - RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = RCT2_STAFF_MODE_NONE; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = STAFF_MODE_NONE; } for (short i = 200; i < 204; i++) { - RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = RCT2_STAFF_MODE_NORMAL; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = STAFF_MODE_WALK; } //RCT2_CALLPROC_EBPSAFE(0x006C0C3F); sub_6C0C3F(); diff --git a/src/staff.c b/src/staff.c index a5e00f758d..3871dfb080 100644 --- a/src/staff.c +++ b/src/staff.c @@ -222,7 +222,7 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->staff_id = newStaffId; - RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[newStaffId] = RCT2_STAFF_MODE_NORMAL; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[newStaffId] = STAFF_MODE_WALK; for (int edi = 0; edi < 0x80; edi++) { int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; diff --git a/src/staff.h b/src/staff.h index fbe54902a0..b8ef29af0c 100644 --- a/src/staff.h +++ b/src/staff.h @@ -26,6 +26,12 @@ #define STAFF_MAX_COUNT 0xC8 #define STAFF_TYPE_COUNT 0x04 +enum STAFF_MODE { + STAFF_MODE_NONE, + STAFF_MODE_WALK, + STAFF_MODE_PATROL = 3 +}; + enum STAFF_TYPE { STAFF_TYPE_HANDYMAN, STAFF_TYPE_MECHANIC, From 64c5bcb6cba38c4f3d8ddfa74857e35ceaacb992 Mon Sep 17 00:00:00 2001 From: Duncan Date: Mon, 8 Sep 2014 12:45:38 +0100 Subject: [PATCH 04/31] Added window_peep_overview_tab_paint Looks to be used by staff window as well. Not tested. --- src/window_peep.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/window_peep.c b/src/window_peep.c index a85331101c..1bdea23fd4 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -752,6 +752,64 @@ void window_peep_viewport_init(rct_window* w){ window_invalidate(w); } +/* rct2: 0x6983dd */ +void winodw_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1<widgets[WIDX_TAB_1]; + int width = widget->right - widget->left - 1; + int height = widget->bottom - widget->top - 1; + int x = widget->left + 1 + w->x; + int y = widget->top + 1 + w->y; + if (w->page == WINDOW_PEEP_OVERVIEW) height++; + + rct_drawpixelinfo* clip_dpi = clip_drawpixelinfo(dpi, x, width, y, height ); + if (!clip_dpi) return; + + x = 14; + y = 20; + + rct_peep* peep = GET_PEEP(w->number); + + if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER) + y++; + + int ebx = *(RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2]) + 1; + + int eax = 0; + + if (w->page == WINDOW_PEEP_OVERVIEW){ + eax = *((uint16*)w + 496 / 2); + eax &= 0xFFFC; + } + ebx += eax; + + int sprite_id = ebx | (peep->tshirt_colour << 19) | (peep->trouser_colour << 24) | 0xA0000000; + gfx_draw_sprite( clip_dpi, sprite_id, x, y, 0); + + // If holding a balloon + if (ebx >= 0x2A1D && ebx < 0x2A3D){ + ebx += 32; + ebx |= (peep->balloon_colour << 19) | 0x20000000; + gfx_draw_sprite( clip_dpi, ebx, x, y, 0); + } + + // If holding umbrella + if (ebx >= 0x2BBD && ebx < 0x2BDD){ + ebx += 32; + ebx |= (peep->umbrella_colour << 19) | 0x20000000; + gfx_draw_sprite(clip_dpi, ebx, x, y, 0); + } + + // If wearing hat + if (ebx >= 0x29DD && ebx < 0x29FD){ + ebx += 32; + ebx |= (peep->hat_colour << 19) | 0x20000000; + gfx_draw_sprite( clip_dpi, ebx, x, y, 0); + } +} + /* rct2: 0x696887 */ void window_peep_overview_paint(){ rct_window *w; @@ -763,6 +821,7 @@ void window_peep_overview_paint(){ return; window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); //6983dd //698597 //6985d8 From 5f31f36f41f2466bec840e45f10c41d9e1fe0f5d Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 8 Sep 2014 18:21:01 +0100 Subject: [PATCH 05/31] Moved get_peep_face_sprite to peep.c added stats_tab paint --- src/peep.c | 74 ++++++++++++++++++++++++- src/peep.h | 3 ++ src/window_guest_list.c | 82 ++-------------------------- src/window_peep.c | 89 ++++++++++++++----------------- src/window_title_scenarioselect.c | 2 + 5 files changed, 123 insertions(+), 127 deletions(-) diff --git a/src/peep.c b/src/peep.c index 629426280a..e069820e6a 100644 --- a/src/peep.c +++ b/src/peep.c @@ -26,6 +26,7 @@ #include "rct2.h" #include "ride.h" #include "sprite.h" +#include "sprites.h" #include "window.h" static void peep_update(rct_peep *peep); @@ -586,4 +587,75 @@ void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, ui */ int peep_can_be_picked_up(rct_peep* peep){ return RCT2_ADDRESS(0x982004, uint8)[peep->state] & 1; -} \ No newline at end of file +} + +/** +* Function split into large and small sprite +* rct2: 0x00698721 +*/ +int get_peep_face_sprite_small(rct_peep *peep) +{ + int sprite; + sprite = SPR_PEEP_SMALL_FACE_ANGRY; + + if (peep->var_F3) return sprite; + sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_SICK; + + if (peep->nausea > 200) return sprite; + sprite--; //VERY_SICK + + if (peep->nausea > 170) return sprite; + sprite--; //SICK + + if (peep->nausea > 140) return sprite; + sprite = SPR_PEEP_SMALL_FACE_VERY_TIRED; + + if (peep->energy < 46) return sprite; + sprite--; //TIRED + + if (peep->energy < 70) return sprite; + sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY; + + //There are 7 different happiness based faces + for (int i = 37; peep->happiness >= i; i += 37) + { + sprite++; + } + + return sprite; +} + +/** +* Function split into large and small sprite +* rct2: 0x00698721 +*/ +int get_peep_face_sprite_large(rct_peep* peep){ + int sprite; + sprite = SPR_PEEP_LARGE_FACE_ANGRY; + + if (peep->var_F3) return sprite; + sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_SICK; + + if (peep->nausea > 200) return sprite; + sprite = SPR_PEEP_LARGE_FACE_VERY_SICK; + + if (peep->nausea > 170) return sprite; + sprite = SPR_PEEP_LARGE_FACE_SICK; + + if (peep->nausea > 140) return sprite; + sprite = SPR_PEEP_LARGE_FACE_VERY_TIRED; + + if (peep->energy < 46) return sprite; + sprite--; //TIRED + + if (peep->energy < 70) return sprite; + sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY; + + //There are 7 different happiness based faces + for (int i = 37; peep->happiness >= i; i += 37) + { + sprite++; + } + + return sprite; +} diff --git a/src/peep.h b/src/peep.h index a938440268..b797615112 100644 --- a/src/peep.h +++ b/src/peep.h @@ -445,5 +445,8 @@ void peep_applause(); rct_peep *peep_generate(int x, int y, int z); void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2); void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2); +int get_peep_face_sprite_small(rct_peep *peep); +int get_peep_face_sprite_large(rct_peep *peep); + #endif diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 217e7ebb26..97223cb97a 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -132,8 +132,7 @@ static uint8 _window_guest_list_groups_guest_faces[240 * 58]; static int window_guest_list_is_peep_in_filter(rct_peep* peep); static void window_guest_list_find_groups(); -static int get_guest_face_sprite_small(rct_peep *peep); -static int get_guest_face_sprite_large(rct_peep *peep); + static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2); /** @@ -626,7 +625,7 @@ static void window_guest_list_scrollpaint() switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: // Guest face - gfx_draw_sprite(dpi, get_guest_face_sprite_small(peep), 118, y, 0); + gfx_draw_sprite(dpi, get_peep_face_sprite_small(peep), 118, y, 0); // Tracking icon if (peep->flags & PEEP_FLAGS_TRACKING) @@ -802,7 +801,7 @@ static void window_guest_list_find_groups() RCT2_ADDRESS(0x00F1AF26, uint8)[groupIndex] = groupIndex; faceIndex = groupIndex * 56; - _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep) - 5486; + _window_guest_list_groups_guest_faces[faceIndex++] = get_peep_face_sprite_small(peep) - 5486; // Find more peeps that belong to same group FOR_ALL_GUESTS(spriteIndex2, peep2) { @@ -822,7 +821,7 @@ static void window_guest_list_find_groups() // Add face sprite, cap at 56 though if (_window_guest_list_groups_num_guests[groupIndex] >= 56) continue; - _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep2) - 5486; + _window_guest_list_groups_guest_faces[faceIndex++] = get_peep_face_sprite_small(peep2) - 5486; } if (RCT2_GLOBAL(0x00F1EDF6, uint16) == 0) { @@ -872,75 +871,4 @@ static void window_guest_list_find_groups() nextPeep: ; } -} - -/** - * Function split into large and small sprite - * rct2: 0x00698721 - */ -static int get_guest_face_sprite_small(rct_peep *peep) -{ - int sprite; - sprite = SPR_PEEP_SMALL_FACE_ANGRY; - - if (peep->var_F3) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_SICK; - - if (peep->nausea > 200) return sprite; - sprite--; //VERY_SICK - - if (peep->nausea > 170) return sprite; - sprite--; //SICK - - if (peep->nausea > 140) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_TIRED; - - if (peep->energy < 46) return sprite; - sprite--; //TIRED - - if (peep->energy < 70) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY; - - //There are 7 different happiness based faces - for (int i = 37; peep->happiness >= i; i += 37) - { - sprite++; - } - - return sprite; -} - -/** -* Function split into large and small sprite -* rct2: 0x00698721 -*/ -static int get_guest_face_sprite_large(rct_peep* peep){ - int sprite; - sprite = SPR_PEEP_LARGE_FACE_ANGRY; - - if (peep->var_F3) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_SICK; - - if (peep->nausea > 200) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_SICK; - - if (peep->nausea > 170) return sprite; - sprite = SPR_PEEP_LARGE_FACE_SICK; - - if (peep->nausea > 140) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_TIRED; - - if (peep->energy < 46) return sprite; - sprite--; //TIRED - - if (peep->energy < 70) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY; - - //There are 7 different happiness based faces - for (int i = 37; peep->happiness >= i; i += 37) - { - sprite++; - } - - return sprite; -} +} \ No newline at end of file diff --git a/src/window_peep.c b/src/window_peep.c index 1bdea23fd4..5ad6e93990 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -24,6 +24,7 @@ #include "ride.h" #include "peep.h" #include "string_ids.h" +#include "staff.h" #include "sprite.h" #include "sprites.h" #include "viewport.h" @@ -752,8 +753,11 @@ void window_peep_viewport_init(rct_window* w){ window_invalidate(w); } -/* rct2: 0x6983dd */ -void winodw_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ +/** + * rct2: 0x6983dd + * used by window_staff as well + */ +void window_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ if (w->disabled_widgets & (1<page == WINDOW_PEEP_OVERVIEW){ - eax = *((uint16*)w + 496 / 2); + eax = w->var_494>>16; eax &= 0xFFFC; } ebx += eax; - int sprite_id = ebx | (peep->tshirt_colour << 19) | (peep->trouser_colour << 24) | 0xA0000000; + int sprite_id = ebx | (peep->tshirt_colour << 19) | (peep->trousers_colour << 24) | 0xA0000000; gfx_draw_sprite( clip_dpi, sprite_id, x, y, 0); // If holding a balloon @@ -810,6 +814,35 @@ void winodw_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ } } +/* rct2: 0x6983dd */ +void window_peep_stats_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_2)) + return; + + rct_widget* widget = &w->widgets[WIDX_TAB_2]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + rct_peep* peep = GET_PEEP(w->number); + int image_id = get_peep_face_sprite_large(peep); + if (w->page == WINDOW_PEEP_STATS){ + // If currently viewing this tab animate tab + // if it is very sick or angry. + switch (image_id){ + case SPR_PEEP_LARGE_FACE_VERY_VERY_SICK: + image_id += (w->frame_no / 4) & 0xF; + break; + case SPR_PEEP_LARGE_FACE_VERY_SICK: + image_id += (w->frame_no / 8) & 0x3; + break; + case SPR_PEEP_LARGE_FACE_ANGRY: + image_id += (w->frame_no / 8) & 0x3; + break; + } + } + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + /* rct2: 0x696887 */ void window_peep_overview_paint(){ rct_window *w; @@ -817,11 +850,12 @@ void window_peep_overview_paint(){ //rct_widget *labelWidget; window_paint_get_registers(w, dpi); - RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0); - return; + //RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0); + //return; window_draw_widgets(w, dpi); window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); //6983dd //698597 //6985d8 @@ -938,46 +972,3 @@ void window_peep_overview_invalidate(){ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); } - -void window_peep_overview_tab_paint( rct_window* w, rct_drawpixelinfo* dpi){ - - if ( w->disabled_widgets & (1ULL<widgets[WIDX_TAB_1].left + 1 + w->x; - //cx - int y = w->widgets[WIDX_TAB_1].top + 1 + w->y; - //bx - int width = w->widgets[WIDX_TAB_1].right - 1 - w->widgets[WIDX_TAB_1].left; - //dx - int height = w->widgets[WIDX_TAB_1].bottom - 1 - w->widgets[WIDX_TAB_1].top; - - if (w->page == WINDOW_PEEP_OVERVIEW){ - height++; - } - - rct_drawpixelinfo* cliped_dpi = clip_drawpixelinfo( dpi, x, width, y, height ); - - if (!cliped_dpi) return; - - int cx = 14; - int dx = 20; - - //ebp - rct_peep* peep = GET_PEEP(w->number); - - - if (peep->type == 1 && peep->staff_type == 3) - dx++; - int eax = RCT2_GLOBAL(peep->sprite_type*8 + 0x982708, uint32); - int ebx = *(uint32*)eax; - ebx++; - eax = 0; - - if (w->page == WINDOW_PEEP_OVERVIEW){ - int ax = *((uint16*)w + 496 / 2); - ax &= ~((1<<0)|(1<<1)); - } - ebx += eax; - //698474 -} diff --git a/src/window_title_scenarioselect.c b/src/window_title_scenarioselect.c index 38246736e7..870a17f795 100644 --- a/src/window_title_scenarioselect.c +++ b/src/window_title_scenarioselect.c @@ -223,6 +223,7 @@ static void window_scenarioselect_scrollgetsize() } +/* rct2: 0x6780FE */ static void window_scenarioselect_scrollmousedown() { int i; @@ -249,6 +250,7 @@ static void window_scenarioselect_scrollmousedown() } } +/* rct2: 0x678162 */ static void window_scenarioselect_scrollmouseover() { int i; From fe6f5a49da48e00ff580c9fa7616d9d711d561ce Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 8 Sep 2014 18:22:51 +0100 Subject: [PATCH 06/31] Fixed comment for correct address --- 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 5ad6e93990..29717a384c 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -814,7 +814,7 @@ void window_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ } } -/* rct2: 0x6983dd */ +/* rct2: 0x69869b */ void window_peep_stats_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ if (w->disabled_widgets & (1 << WIDX_TAB_2)) return; From ca1904084efe8cfb2d6d8ac5670366cab55efc10 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 9 Sep 2014 12:29:55 +0100 Subject: [PATCH 07/31] Added final window_peep tab paint functions Not tested. --- src/window_peep.c | 77 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 29717a384c..f0e3ab4cfc 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -843,25 +843,84 @@ void window_peep_stats_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ gfx_draw_sprite(dpi, image_id, x, y, 0); } +/* rct2: 0x69861F */ +void window_peep_rides_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_3)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_3]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = SPR_TAB_RIDE_0; + + if ( w->page == WINDOW_PEEP_RIDES ){ + image_id += (w->frame_no / 4) & 0xF; + } + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x698597 */ +void window_peep_finance_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_4)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_4]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = SPR_TAB_FINANCES_SUMMARY_0; + + if ( w->page == WINDOW_PEEP_FINANCE ){ + image_id += (w->frame_no / 2) & 0x7; + } + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x6985D8 */ +void window_peep_thoughts_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_5)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_5]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = 5269; + + if ( w->page == WINDOW_PEEP_THOUGHTS ){ + image_id += (w->frame_no / 2) & 0x7; + } + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x698661 */ +void window_peep_inventory_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_6)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_6]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = 5326; + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + /* rct2: 0x696887 */ void window_peep_overview_paint(){ rct_window *w; rct_drawpixelinfo *dpi; - //rct_widget *labelWidget; window_paint_get_registers(w, dpi); - //RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0); - //return; window_draw_widgets(w, dpi); window_peep_overview_tab_paint(w, dpi); window_peep_stats_tab_paint(w, dpi); - //6983dd - //698597 - //6985d8 - //69861f - //69869b - //698661 + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); // Draw the viewport no sound sprite if (w->viewport){ From 9d8caf1e8ab777b3b9cbf09dee9f400154ae4c30 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 9 Sep 2014 12:53:10 +0100 Subject: [PATCH 08/31] Added window_peep_overview_update Not tested will not work at present missing two function calls. --- src/window_peep.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/window_peep.c b/src/window_peep.c index f0e3ab4cfc..33d3b319ab 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -178,6 +178,7 @@ void window_peep_overview_mouse_up(); void window_peep_overview_paint(); void window_peep_overview_invalidate(); void window_peep_overview_viewport_init_wrapper(); +void window_peep_overview_update(rct_window* w); static void* window_peep_overview_events[] = { window_peep_close, @@ -186,7 +187,7 @@ static void* window_peep_overview_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*)0x696F45, + window_peep_overview_update, window_peep_emptysub, window_peep_emptysub, (void*)0x696A5F, @@ -1031,3 +1032,35 @@ void window_peep_overview_invalidate(){ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); } + +/* rct2: 0x696F45 */ +void window_peep_overview_update(rct_window* w){ + int var_496 = w->var_494 >> 16; + var_496++; + var_496 %= 24; + w->var_494 &= 0x0000FFFF; + w->var_494 |= var_496; + + + window_invalidate_by_id( 0x497, w->number); + window_invalidate_by_id( 0x597, w->number); + + w->list_information_type += 2; + + if (w->var_494 & 0xFFFF == 0xFFFF) + w->var_494&=0xFFFF0000; + else + w->var_494++; + + if (w->var_494 & 0xFFFF >= 3840){ + if (w->var_494 & 0x3FF){ + //call 6e37dc + if (ax <= 0x2AAA){ + rct_peep* peep = GET_PEEP(w->number); + ax = 0xFF47; + //call 699F5A + } + } + } + +} From efc9c4915b1db1d08376797cd65ce0e584377d9d Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 9 Sep 2014 17:02:14 +0100 Subject: [PATCH 09/31] Added comment noting data location --- src/ride_data.c | 1 + src/window_peep.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ride_data.c b/src/ride_data.c index aefda2a666..086ee8870a 100644 --- a/src/ride_data.c +++ b/src/ride_data.c @@ -491,6 +491,7 @@ const bool rideUnknownData2[0x60] = { true, // 59 LIM Launched Roller Coaster }; +/* Data at 0x0097E3B8 */ const uint8 rideUnknownData3[0x60] = { 10, // 00 Spiral Roller coaster 10, // 01 Stand Up Coaster diff --git a/src/window_peep.c b/src/window_peep.c index 33d3b319ab..aa905d97ea 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -778,7 +778,7 @@ void window_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ rct_peep* peep = GET_PEEP(w->number); if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER) - y++; + y++; int ebx = *(RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2]) + 1; From 08e37a04359c1da516770835c71909ba7be447d0 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 9 Sep 2014 17:33:20 +0100 Subject: [PATCH 10/31] Rewrote get_peep_face_sprite. Fixed mistakes in peep update --- src/peep.c | 125 +++++++++++++++++++++++++++------------------- src/window_peep.c | 19 +++---- 2 files changed, 84 insertions(+), 60 deletions(-) diff --git a/src/peep.c b/src/peep.c index e069820e6a..e2619a5e5b 100644 --- a/src/peep.c +++ b/src/peep.c @@ -589,73 +589,96 @@ int peep_can_be_picked_up(rct_peep* peep){ return RCT2_ADDRESS(0x982004, uint8)[peep->state] & 1; } -/** -* Function split into large and small sprite -* rct2: 0x00698721 -*/ -int get_peep_face_sprite_small(rct_peep *peep) -{ - int sprite; - sprite = SPR_PEEP_SMALL_FACE_ANGRY; +enum{ + PEEP_FACE_OFFSET_ANGRY = 0, + PEEP_FACE_OFFSET_VERY_VERY_SICK, + PEEP_FACE_OFFSET_VERY_SICK, + PEEP_FACE_OFFSET_SICK, + PEEP_FACE_OFFSET_VERY_TIRED, + PEEP_FACE_OFFSET_TIRED, + PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY, + PEEP_FACE_OFFSET_VERY_UNHAPPY, + PEEP_FACE_OFFSET_UNHAPPY, + PEEP_FACE_OFFSET_NORMAL, + PEEP_FACE_OFFSET_HAPPY, + PEEP_FACE_OFFSET_VERY_HAPPY, + PEEP_FACE_OFFSET_VERY_VERY_HAPPY, +}; - if (peep->var_F3) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_SICK; +const int face_sprite_small[] = { + SPR_PEEP_SMALL_FACE_ANGRY, + SPR_PEEP_SMALL_FACE_VERY_VERY_SICK, + SPR_PEEP_SMALL_FACE_VERY_SICK, + SPR_PEEP_SMALL_FACE_SICK, + SPR_PEEP_SMALL_FACE_VERY_TIRED, + SPR_PEEP_SMALL_FACE_TIRED, + SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY, + SPR_PEEP_SMALL_FACE_VERY_UNHAPPY, + SPR_PEEP_SMALL_FACE_UNHAPPY, + SPR_PEEP_SMALL_FACE_NORMAL, + SPR_PEEP_SMALL_FACE_HAPPY, + SPR_PEEP_SMALL_FACE_VERY_HAPPY, + SPR_PEEP_SMALL_FACE_VERY_VERY_HAPPY, +}; - if (peep->nausea > 200) return sprite; - sprite--; //VERY_SICK +const int face_sprite_large[] = { + SPR_PEEP_LARGE_FACE_ANGRY, + SPR_PEEP_LARGE_FACE_VERY_VERY_SICK, + SPR_PEEP_LARGE_FACE_VERY_SICK, + SPR_PEEP_LARGE_FACE_SICK, + SPR_PEEP_LARGE_FACE_VERY_TIRED, + SPR_PEEP_LARGE_FACE_TIRED, + SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY, + SPR_PEEP_LARGE_FACE_VERY_UNHAPPY, + SPR_PEEP_LARGE_FACE_UNHAPPY, + SPR_PEEP_LARGE_FACE_NORMAL, + SPR_PEEP_LARGE_FACE_HAPPY, + SPR_PEEP_LARGE_FACE_VERY_HAPPY, + SPR_PEEP_LARGE_FACE_VERY_VERY_HAPPY, +}; - if (peep->nausea > 170) return sprite; - sprite--; //SICK +int get_face_sprite_offset(rct_peep *peep){ - if (peep->nausea > 140) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_TIRED; + // ANGRY + if (peep->var_F3) return PEEP_FACE_OFFSET_ANGRY; - if (peep->energy < 46) return sprite; - sprite--; //TIRED + // VERY_VERY_SICK + if (peep->nausea > 200) return PEEP_FACE_OFFSET_VERY_VERY_SICK; - if (peep->energy < 70) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY; + // VERY_SICK + if (peep->nausea > 170) return PEEP_FACE_OFFSET_VERY_SICK; + // SICK + if (peep->nausea > 140) return PEEP_FACE_OFFSET_SICK; + + // VERY_TIRED + if (peep->energy < 46) return PEEP_FACE_OFFSET_VERY_TIRED; + + // TIRED + if (peep->energy < 70) return PEEP_FACE_OFFSET_TIRED; + + int offset = PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY; //There are 7 different happiness based faces for (int i = 37; peep->happiness >= i; i += 37) { - sprite++; + offset++; } - return sprite; + return offset; } /** * Function split into large and small sprite * rct2: 0x00698721 */ -int get_peep_face_sprite_large(rct_peep* peep){ - int sprite; - sprite = SPR_PEEP_LARGE_FACE_ANGRY; - - if (peep->var_F3) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_SICK; - - if (peep->nausea > 200) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_SICK; - - if (peep->nausea > 170) return sprite; - sprite = SPR_PEEP_LARGE_FACE_SICK; - - if (peep->nausea > 140) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_TIRED; - - if (peep->energy < 46) return sprite; - sprite--; //TIRED - - if (peep->energy < 70) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY; - - //There are 7 different happiness based faces - for (int i = 37; peep->happiness >= i; i += 37) - { - sprite++; - } - - return sprite; +int get_peep_face_sprite_small(rct_peep *peep){ + return face_sprite_small[get_face_sprite_offset(peep)]; +} + +/** +* Function split into large and small sprite +* rct2: 0x00698721 +*/ +int get_peep_face_sprite_large(rct_peep *peep){ + return face_sprite_large[get_face_sprite_offset(peep)]; } diff --git a/src/window_peep.c b/src/window_peep.c index aa905d97ea..3eab4b2ae0 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -23,6 +23,7 @@ #include "map.h" #include "ride.h" #include "peep.h" +#include "scenario.h" #include "string_ids.h" #include "staff.h" #include "sprite.h" @@ -1039,7 +1040,7 @@ void window_peep_overview_update(rct_window* w){ var_496++; var_496 %= 24; w->var_494 &= 0x0000FFFF; - w->var_494 |= var_496; + w->var_494 |= var_496 << 16; window_invalidate_by_id( 0x497, w->number); @@ -1047,18 +1048,18 @@ void window_peep_overview_update(rct_window* w){ w->list_information_type += 2; - if (w->var_494 & 0xFFFF == 0xFFFF) - w->var_494&=0xFFFF0000; + if ((w->var_494 & 0xFFFF) == 0xFFFF) + w->var_494 &= 0xFFFF0000; else w->var_494++; - if (w->var_494 & 0xFFFF >= 3840){ - if (w->var_494 & 0x3FF){ - //call 6e37dc - if (ax <= 0x2AAA){ + // Create the "I have the strangest feeling I am being watched thought" + if ((w->var_494 & 0xFFFF) >= 3840){ + if (!(w->var_494 & 0x3FF)){ + int rand = scenario_rand() & 0xFFFF; + if (rand <= 0x2AAA){ rct_peep* peep = GET_PEEP(w->number); - ax = 0xFF47; - //call 699F5A + RCT2_CALLPROC_X(0x699F5A, 0xFF47, 0, 0, 0, (int)peep, 0, 0); } } } From e8251daad596d936ad9a60ed888baa9ec161dbb5 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 9 Sep 2014 18:08:34 +0100 Subject: [PATCH 11/31] Added peep_text_input --- src/window.h | 12 ++++++++++++ src/window_peep.c | 29 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/window.h b/src/window.h index 6b638dbe1f..9c534d6771 100644 --- a/src/window.h +++ b/src/window.h @@ -491,6 +491,12 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct __asm mov dropdownIndex, ax \ __asm mov widgetIndex, dx \ __asm mov w, esi + + #define window_text_input_get_registers(w, widgetIndex, _cl, text) \ + __asm mov widgetIndex, dx \ + __asm mov _cl, cl \ + __asm mov w, esi \ + __asm mov text, edi #define window_scrollmouse_get_registers(w, x, y) \ __asm mov x, cx \ @@ -519,6 +525,12 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct __asm__ ( "mov %["#widgetIndex"], dx " : [widgetIndex] "+m" (widgetIndex) ); \ __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); + #define window_text_input_get_registers(w, widgetIndex, _cl, text) \ + __asm__ ( "mov %[_cl], cl " : [_cl] "+m" (_cl) ); \ + __asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \ + __asm__ ( "mov %[w], esi " : [w] "+m" (w) ); \ + __asm__ ( "mov %[text], edi " : [text] "+m" (text) ); + #define window_scrollmouse_get_registers(w, x, y) \ __asm__ ( "mov %["#x"], cx " : [x] "+m" (x) ); \ __asm__ ( "mov %["#y"], dx " : [y] "+m" (y) ); \ diff --git a/src/window_peep.c b/src/window_peep.c index 3eab4b2ae0..90c9378124 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -180,6 +180,7 @@ void window_peep_overview_paint(); void window_peep_overview_invalidate(); void window_peep_overview_viewport_init_wrapper(); void window_peep_overview_update(rct_window* w); +void window_peep_overview_text_input(); static void* window_peep_overview_events[] = { window_peep_close, @@ -191,17 +192,17 @@ static void* window_peep_overview_events[] = { window_peep_overview_update, window_peep_emptysub, window_peep_emptysub, - (void*)0x696A5F, - (void*)0x696A54, + (void*)0x696A5F,//tool_update + (void*)0x696A54,//tool_down window_peep_emptysub, window_peep_emptysub, - (void*)0x696A49, + (void*)0x696A49,//tool_abort window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*)0x696A6A, + window_peep_overview_text_input,//text_input window_peep_overview_viewport_init_wrapper, window_peep_emptysub, window_peep_emptysub, @@ -1065,3 +1066,23 @@ void window_peep_overview_update(rct_window* w){ } } + +/* rct2:0x696A6A */ +void window_peep_overview_text_input(){ + short widgetIndex; + rct_window *w; + char _cl; + uint32* text; + + window_text_input_get_registers(w, widgetIndex, _cl, text); + + if (widgetIndex != WIDX_RENAME)return; + + if (!_cl) return; + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = 0x5AE; + + game_do_command(1, 1, w->number, *text, 22, *(text + 2), *(text + 1)); + game_do_command(2, 1, 0, *(text + 3), 22, *(text + 5), *(text + 4)); + game_do_command(0, 1, 0, *(text + 6), 22, *(text + 8), *(text + 7)); +} \ No newline at end of file From 463fe459aa12f68b2a73a49c744288460dfc1543 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 9 Sep 2014 20:07:35 +0100 Subject: [PATCH 12/31] Add notes to game_do_command. Explode magic number into parts --- src/game.c | 2 +- src/window_peep.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game.c b/src/game.c index 621ba79b3c..00ec7cf776 100644 --- a/src/game.c +++ b/src/game.c @@ -925,7 +925,7 @@ static uint32 game_do_command_table[58] = { 0x006A67C0, 0x00663CCD, // 20 0x006B53E9, - 0x00698D6C, + 0x00698D6C, // text input 0x0068C542, 0x0068C6D1, 0x0068BC01, diff --git a/src/window_peep.c b/src/window_peep.c index 90c9378124..deae643ba7 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -1044,8 +1044,8 @@ void window_peep_overview_update(rct_window* w){ w->var_494 |= var_496 << 16; - window_invalidate_by_id( 0x497, w->number); - window_invalidate_by_id( 0x597, w->number); + window_invalidate_by_id((WIDX_TAB_1 << 8) | 0x80 | WC_PEEP, w->number); + window_invalidate_by_id((WIDX_TAB_2 << 8) | 0x80 | WC_PEEP, w->number); w->list_information_type += 2; From eff832e3392d40823b4e3944ec8eeabb9c2d211b Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 11:03:46 +0100 Subject: [PATCH 13/31] Added window_peep_overview_tool_update --- src/window_peep.c | 75 +++++++++++++++++++++++++++++++++++------ src/window_staff_peep.c | 2 +- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index deae643ba7..8abf081910 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -173,26 +173,27 @@ void window_peep_set_page(rct_window* w, int page); void window_peep_disable_widgets(rct_window* w); void window_peep_viewport_init(rct_window* w); -void window_peep_close(); -void window_peep_resize(); +void window_peep_overview_close(); +void window_peep_overview_resize(); void window_peep_overview_mouse_up(); void window_peep_overview_paint(); void window_peep_overview_invalidate(); void window_peep_overview_viewport_init_wrapper(); void window_peep_overview_update(rct_window* w); void window_peep_overview_text_input(); +void window_peep_overview_tool_update(); static void* window_peep_overview_events[] = { - window_peep_close, + window_peep_overview_close, window_peep_overview_mouse_up, - window_peep_resize, + window_peep_overview_resize, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, window_peep_overview_update, window_peep_emptysub, window_peep_emptysub, - (void*)0x696A5F,//tool_update + window_peep_overview_tool_update,//tool_update (void*)0x696A54,//tool_down window_peep_emptysub, window_peep_emptysub, @@ -511,7 +512,7 @@ void window_peep_disable_widgets(rct_window* w){ } /* rct2: 0x00696A75 */ -void window_peep_close(){ +void window_peep_overview_close(){ rct_window* w; window_get_register(w); @@ -524,7 +525,7 @@ void window_peep_close(){ } /* rct2: 0x00696FBE */ -void window_peep_resize(){ +void window_peep_overview_resize(){ rct_window* w; window_get_register(w); @@ -532,7 +533,7 @@ void window_peep_resize(){ window_peep_disable_widgets(w); RCT2_CALLPROC_EBPSAFE(w->event_handlers[WE_INVALIDATE]); - window_invalidate_by_id(0xA97, w->number); + widget_invalidate(WC_PEEP, w->number, WIDX_MARQUEE); window_set_resize(w, 192, 159, 500, 450); @@ -1043,9 +1044,8 @@ void window_peep_overview_update(rct_window* w){ w->var_494 &= 0x0000FFFF; w->var_494 |= var_496 << 16; - - window_invalidate_by_id((WIDX_TAB_1 << 8) | 0x80 | WC_PEEP, w->number); - window_invalidate_by_id((WIDX_TAB_2 << 8) | 0x80 | WC_PEEP, w->number); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_1); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); w->list_information_type += 2; @@ -1085,4 +1085,57 @@ void window_peep_overview_text_input(){ game_do_command(1, 1, w->number, *text, 22, *(text + 2), *(text + 1)); game_do_command(2, 1, 0, *(text + 3), 22, *(text + 5), *(text + 4)); game_do_command(0, 1, 0, *(text + 6), 22, *(text + 8), *(text + 7)); +} + +/* rct2: 0x696A5F */ +void window_peep_overview_tool_update(){ + short widgetIndex; + rct_window* w; + short x, y; + + window_tool_get_registers(w, widgetIndex, x, y); + + if (widgetIndex != WIDX_PICKUP) return; + + RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, (int)w, 0, 0); + + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + int temp_y = y + 16; + + int eax = x, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0; + RCT2_CALLFUNC_X(0x689726, &eax, &temp_y, &ecx, &edx, &esi, &edi, &ebp); + if (eax != 0x8000){ + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 1; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = eax; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = eax; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = temp_y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = temp_y; + RCT2_CALLPROC_X(0x0068AAE1, eax, temp_y, 0, 0, (int)w, 0, 0); + } + + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1; + eax = x; + int ebx = y; + edx = 0; + RCT2_CALLFUNC_X(0x00685ADC, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + if ((ebx & 0xFF) == 0) return; + + x--; + y += 16; + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_Y, uint16) = y; + w->var_492++; + if (w->var_492 >= 48)w->var_492 = 0; + + rct_peep* peep; + peep = GET_PEEP(w->number); + ebx = (RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2])[22]; + ebx += w->var_492 >> 2; + + ebp = peep->tshirt_colour << 19; + ecx = peep->trousers_colour << 24; + + ebx |= ebp | ecx | 0xA0000000; + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, uint32) = ebx; } \ No newline at end of file diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 59da317802..1b899f99b0 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -333,7 +333,7 @@ void window_staff_peep_disable_widgets(rct_window* w) } /** - * Same as window_peep_close. + * Same as window_peep_overview_close. * rct2: 0x006BDFF8 */ void window_staff_peep_overview_close() From fc5ff967410257e25b056e78a8bc709b84f3ab1c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 12:49:18 +0100 Subject: [PATCH 14/31] Added window_peep_overview_tool_down. Modified RCT2_CALLPROC_X to return the flags register. --- src/addresses.h | 3 +- src/map.h | 1 + src/peep.h | 2 +- src/window_peep.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 68a4bcacef..5a258b87d6 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -440,7 +440,7 @@ static void RCT2_CALLPROC_EBPSAFE(int address) #endif } -static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, int _esi, int _edi, int _ebp) +static int RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, int _esi, int _edi, int _ebp) { #ifdef _MSC_VER __asm { @@ -453,6 +453,7 @@ static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, mov edi, _edi mov ebp, _ebp call [esp] + lahf add esp, 4 } #else diff --git a/src/map.h b/src/map.h index 6c2cbf8b32..1546d9e3fe 100644 --- a/src/map.h +++ b/src/map.h @@ -195,6 +195,7 @@ typedef struct { void map_init(); void map_update_tile_pointers(); +rct_map_element *map_get_surface_element_at(int x, int y); int map_element_height(int x, int y); void sub_68B089(); int map_coord_is_connected(uint16 coordinate, uint8 height, uint8 face_direction); diff --git a/src/peep.h b/src/peep.h index b797615112..3e20e439b3 100644 --- a/src/peep.h +++ b/src/peep.h @@ -342,7 +342,7 @@ typedef struct { uint8 energy; // 0x38 uint8 energy_growth_rate; // 0x39 uint8 happiness; // 0x3A - uint8 happiness_growth_rate; // 0x3B + sint8 happiness_growth_rate; // 0x3B uint8 nausea; // 0x3C uint8 nausea_growth_rate; // 0x3D uint8 hunger; // 0x3E diff --git a/src/window_peep.c b/src/window_peep.c index 8abf081910..d3dc10a4ca 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -32,6 +32,7 @@ #include "widget.h" #include "window.h" #include "window_dropdown.h" +#include "window_error.h" enum WINDOW_PEEP_PAGE { WINDOW_PEEP_OVERVIEW, @@ -182,6 +183,7 @@ void window_peep_overview_viewport_init_wrapper(); void window_peep_overview_update(rct_window* w); void window_peep_overview_text_input(); void window_peep_overview_tool_update(); +void window_peep_overview_tool_down(); static void* window_peep_overview_events[] = { window_peep_overview_close, @@ -194,7 +196,7 @@ static void* window_peep_overview_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_overview_tool_update,//tool_update - (void*)0x696A54,//tool_down + window_peep_overview_tool_down,//tool_down window_peep_emptysub, window_peep_emptysub, (void*)0x696A49,//tool_abort @@ -1138,4 +1140,86 @@ void window_peep_overview_tool_update(){ ebx |= ebp | ecx | 0xA0000000; RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, uint32) = ebx; +} + +/* rct2: 0x664F72 */ +int sub_664F72(int x, int y, int edx){ + if (x > 0x1FFF || y > 0x1FFF){ + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; + return 1; + } + + rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32); + if (map_element->properties.surface.ownership & 0x20) return 0; + if (!(map_element->properties.surface.ownership & 0x10)){ + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; + return 1; + } + + edx >>= 3; + if ((edx & 0xFF) < map_element->base_height)return 0; + edx = (edx & 0xFF) - 2; + if (edx > map_element->base_height)return 0; + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; + return 1; +} + +/* rct2: 0x696A54 */ +void window_peep_overview_tool_down(){ + short widgetIndex; + rct_window* w; + short x, y; + + window_tool_get_registers(w, widgetIndex, x, y); + + if (widgetIndex != WIDX_PICKUP) return; + + int eax = x, ebx = y, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0; + ebx += 16; + RCT2_CALLFUNC_X(0x689726, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + + if (eax == 0x8000)return; + + eax += 16; + ecx = ebx + 16; + edx = ((uint8*)edx)[2] * 8 + 16; + int _eax = eax & 0xFFE0, _ebx = ebx & 0xFFE0; + if (sub_664F72(eax & 0xFFE0, ebx & 0xFFE0, edx)){ + window_error_open(0x785,-1); + return; + } + int _edx = edx>>3; + _edx &= 0xFFFF00FF; + _edx |= edx << 8; + _edx += 0x100; + int flags = RCT2_CALLPROC_X(0x68B93A, eax & 0xFFE0, 0xF, ebx & 0xFFE0, _edx, (int)w, 0, 0); + + if (flags & 0x100){ + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) != 0x3A5 ){ + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) != 0x49B){ + window_error_open(0x785, -1); + return; + } + } + } + + rct_peep* peep = GET_PEEP(w->number); + RCT2_CALLPROC_X(0x0069E9D3, eax, 0, ebx, edx, (int)peep, 0, 0); + RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); + RCT2_CALLPROC_X(0x0069A409, 0, 0, 0, 0, (int)peep, 0, 0); + peep->state = 0; + RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0); + peep->var_71 = 0xFF; + peep->var_6D = 0; + peep->var_70 = 0; + peep->var_6E = 0xFF; + peep->var_C4 = 0; + + peep->happiness_growth_rate -= 10; + if (peep->happiness_growth_rate < 0)peep->happiness_growth_rate = 0; + + RCT2_CALLPROC_X(0x00693B58, 0, 0, 0, 0, (int)peep, 0, 0); + tool_cancel(); + RCT2_GLOBAL(0x9DE550, sint32) = -1; } \ No newline at end of file From 7f6d9c9a7e52e309bb6ca9c874608126b1870b5f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 12:51:28 +0100 Subject: [PATCH 15/31] Add flags to gcc assembler --- src/addresses.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/addresses.h b/src/addresses.h index 5a258b87d6..665747655f 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -470,6 +470,7 @@ static int RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, mov edi, %[_edi] \n\ mov ebp, %[_ebp] \n\ call [esp] \n\ + lahf \n\ add esp, 4 \n\ pop ebp \n\ pop ebx \n\ From a8ea0c83a214c29b67d9eeb780e259557fc50900 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 13:58:25 +0100 Subject: [PATCH 16/31] Added window_peep_abort tool. Fixed bug with pickup --- src/window_peep.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index d3dc10a4ca..f8e5d7b911 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -184,6 +184,7 @@ void window_peep_overview_update(rct_window* w); void window_peep_overview_text_input(); void window_peep_overview_tool_update(); void window_peep_overview_tool_down(); +void window_peep_overview_tool_abort(); static void* window_peep_overview_events[] = { window_peep_overview_close, @@ -199,7 +200,7 @@ static void* window_peep_overview_events[] = { window_peep_overview_tool_down,//tool_down window_peep_emptysub, window_peep_emptysub, - (void*)0x696A49,//tool_abort + window_peep_overview_tool_abort,//tool_abort window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -584,7 +585,7 @@ void window_peep_overview_mouse_up(){ return; } - w->var_48C = peep->sprite_identifier; + w->var_48C = peep->x; RCT2_CALLPROC_X(0x0069A512, 0, 0, 0, 0, (int)peep, 0, 0); RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); @@ -1222,4 +1223,33 @@ void window_peep_overview_tool_down(){ RCT2_CALLPROC_X(0x00693B58, 0, 0, 0, 0, (int)peep, 0, 0); tool_cancel(); RCT2_GLOBAL(0x9DE550, sint32) = -1; +} + +/* rct2: 0x696A49 */ +void window_peep_overview_tool_abort(){ + short widgetIndex; + rct_window* w; + short x, y; + + window_tool_get_registers(w, widgetIndex, x, y); + if (widgetIndex != WIDX_PICKUP) return; + + rct_peep* peep = GET_PEEP(w->number); + if (peep->state != PEEP_STATE_PICKED) return; + + RCT2_CALLPROC_X(0x0069E9D3, w->var_48C, 0, peep->y, peep->z + 8, (int)peep, 0, 0); + RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); + + if (peep->x != 0x8000){ + RCT2_CALLPROC_X(0x0069A409, 0, 0, 0, 0, (int)peep, 0, 0); + peep->state = 0; + RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0); + peep->var_71 = 0xFF; + peep->var_6D = 0; + peep->var_70 = 0; + peep->var_6E = 0; + peep->var_C4 = 0; + } + + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1; } \ No newline at end of file From af9df0231192b5e3b55edba34f2f8daa2d5fc563 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 14:11:44 +0100 Subject: [PATCH 17/31] Added window_peep_not_overview_mouse_up a combination function for all peep pages --- src/window_peep.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index f8e5d7b911..9fdf7fe939 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -217,9 +217,11 @@ static void* window_peep_overview_events[] = { window_peep_emptysub }; +void window_peep_not_overview_mouse_up(); + static void* window_peep_stats_events[] = { window_peep_emptysub, - (void*) 0x0069744F, //mouse_up + window_peep_not_overview_mouse_up, //mouse_up (void*) 0x00697488, //resize window_peep_emptysub, window_peep_emptysub, @@ -250,7 +252,7 @@ static void* window_peep_stats_events[] = { static void* window_peep_rides_events[] = { window_peep_emptysub, - (void*) 0x00697795, //mouse_up + window_peep_not_overview_mouse_up, //mouse_up (void*) 0x006978F4, //resize window_peep_emptysub, window_peep_emptysub, @@ -281,7 +283,7 @@ static void* window_peep_rides_events[] = { static void* window_peep_finance_events[] = { window_peep_emptysub, - (void*) 0x00697BDD, //mouse_up + window_peep_not_overview_mouse_up, //mouse_up (void*) 0x00697C16, //resize window_peep_emptysub, window_peep_emptysub, @@ -312,7 +314,7 @@ static void* window_peep_finance_events[] = { static void* window_peep_thoughts_events[] = { window_peep_emptysub, - (void*) 0x00697E18, //mouse_up + window_peep_not_overview_mouse_up, //mouse_up (void*) 0x00697E33, //resize window_peep_emptysub, window_peep_emptysub, @@ -343,7 +345,7 @@ static void* window_peep_thoughts_events[] = { static void* window_peep_inventory_events[] = { window_peep_emptysub, - (void*) 0x00698279, //mouse_up + window_peep_not_overview_mouse_up, //mouse_up (void*) 0x00698294, //resize window_peep_emptysub, window_peep_emptysub, @@ -608,6 +610,7 @@ void window_peep_overview_mouse_up(){ } } +/* rct2: 0x696AA0 */ void window_peep_set_page(rct_window* w, int page){ if (RCT2_GLOBAL(0x9DE518,uint32) & (1 << 3)) { @@ -1252,4 +1255,27 @@ void window_peep_overview_tool_abort(){ } RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1; +} + +/* rct2:0x69744F, 0x697795, 0x697BDD, 0x697E18, 0x698279 + * This is a combination of 5 functions that were identical + */ +void window_peep_not_overview_mouse_up(){ + short widgetIndex; + rct_window* w; + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex){ + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_TAB_1: + case WIDX_TAB_2: + case WIDX_TAB_3: + case WIDX_TAB_4: + case WIDX_TAB_5: + case WIDX_TAB_6: + window_peep_set_page(w, widgetIndex - WIDX_TAB_1); + break; + } } \ No newline at end of file From ef73084153af85b14c1570a42779fc08596a97bb Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 14:30:21 +0100 Subject: [PATCH 18/31] Added window_peep_unknown_05 and stats_resize. Added note about unknown 05 --- src/window.h | 7 ++++++- src/window_peep.c | 48 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/window.h b/src/window.h index 9c534d6771..4acc523d48 100644 --- a/src/window.h +++ b/src/window.h @@ -234,7 +234,12 @@ typedef enum { WE_RESIZE = 2, WE_MOUSE_DOWN = 3, WE_DROPDOWN = 4, - WE_UNKNOWN_05 = 5, + WE_UNKNOWN_05 = 5, + // Unknown 05: Used to update tabs that are not being animated + // see window_peep. When the overview tab is not highlighted the + // items being carried such as hats/balloons still need to be shown + // and removed. Probably called after anything that affects items + // being carried. WE_UPDATE = 6, WE_UNKNOWN_07 = 7, WE_UNKNOWN_08 = 8, diff --git a/src/window_peep.c b/src/window_peep.c index 9fdf7fe939..ddb937f960 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -217,15 +217,19 @@ static void* window_peep_overview_events[] = { window_peep_emptysub }; -void window_peep_not_overview_mouse_up(); +void window_peep_mouse_up(); +void window_peep_unknown_05(); + +void window_peep_stats_resize(); + static void* window_peep_stats_events[] = { window_peep_emptysub, - window_peep_not_overview_mouse_up, //mouse_up - (void*) 0x00697488, //resize + window_peep_mouse_up, //mouse_up + window_peep_stats_resize, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x006974ED, + window_peep_unknown_05, (void*) 0x0069746A, window_peep_emptysub, window_peep_emptysub, @@ -252,11 +256,11 @@ static void* window_peep_stats_events[] = { static void* window_peep_rides_events[] = { window_peep_emptysub, - window_peep_not_overview_mouse_up, //mouse_up + window_peep_mouse_up, //mouse_up (void*) 0x006978F4, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697959, + window_peep_unknown_05, (void*) 0x006977B0, window_peep_emptysub, window_peep_emptysub, @@ -283,11 +287,11 @@ static void* window_peep_rides_events[] = { static void* window_peep_finance_events[] = { window_peep_emptysub, - window_peep_not_overview_mouse_up, //mouse_up + window_peep_mouse_up, //mouse_up (void*) 0x00697C16, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697C7B, + window_peep_unknown_05, (void*) 0x00697BF8, window_peep_emptysub, window_peep_emptysub, @@ -314,11 +318,11 @@ static void* window_peep_finance_events[] = { static void* window_peep_thoughts_events[] = { window_peep_emptysub, - window_peep_not_overview_mouse_up, //mouse_up + window_peep_mouse_up, //mouse_up (void*) 0x00697E33, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697ED2, + window_peep_unknown_05, (void*) 0x00697EB4, window_peep_emptysub, window_peep_emptysub, @@ -345,11 +349,11 @@ static void* window_peep_thoughts_events[] = { static void* window_peep_inventory_events[] = { window_peep_emptysub, - window_peep_not_overview_mouse_up, //mouse_up + window_peep_mouse_up, //mouse_up (void*) 0x00698294, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00698333, + window_peep_unknown_05, (void*) 0x00698315, window_peep_emptysub, window_peep_emptysub, @@ -1260,7 +1264,7 @@ void window_peep_overview_tool_abort(){ /* rct2:0x69744F, 0x697795, 0x697BDD, 0x697E18, 0x698279 * This is a combination of 5 functions that were identical */ -void window_peep_not_overview_mouse_up(){ +void window_peep_mouse_up(){ short widgetIndex; rct_window* w; window_widget_get_registers(w, widgetIndex); @@ -1278,4 +1282,22 @@ void window_peep_not_overview_mouse_up(){ window_peep_set_page(w, widgetIndex - WIDX_TAB_1); break; } +} + +/* rct2: 0x697488 */ +void window_peep_stats_resize(){ + rct_window* w; + window_get_register(w); + + window_set_resize(w, 192, 162, 192, 162); +} + +/* rct2: 0x6974ED, 0x00697959, 0x00697C7B, 0x00697ED2, 0x00698333 + * This is a combination of 5 functions that were identical + */ +void window_peep_unknown_05(){ + rct_window* w; + window_get_register(w); + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_1); } \ No newline at end of file From e23d52b4568bf3278fde0da66a3c9f22881a17ae Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 14:58:51 +0100 Subject: [PATCH 19/31] Added window_peep_stats_invalidate and resize --- src/peep.h | 2 +- src/window_peep.c | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/peep.h b/src/peep.h index 3e20e439b3..90ff4b40c1 100644 --- a/src/peep.h +++ b/src/peep.h @@ -351,7 +351,7 @@ typedef struct { uint8 pad_41[0x2]; uint8 intensity; // 0x43 uint8 nausea_tolerance; // 0x44 - uint8 var_45; + uint8 var_45; // Some sort of flags? money16 paid_on_drink; // 0x46 uint8 pad_48[0x10]; uint32 item_extra_flags; // 0x58 diff --git a/src/window_peep.c b/src/window_peep.c index ddb937f960..9f6906f8a3 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -221,7 +221,8 @@ void window_peep_mouse_up(); void window_peep_unknown_05(); void window_peep_stats_resize(); - +void window_peep_stats_update(); +void window_peep_stats_invalidate(); static void* window_peep_stats_events[] = { window_peep_emptysub, @@ -230,7 +231,7 @@ static void* window_peep_stats_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_unknown_05, - (void*) 0x0069746A, + window_peep_stats_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -249,7 +250,7 @@ static void* window_peep_stats_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x0069707D, //invalidate + window_peep_stats_invalidate, //invalidate (void*) 0x0069711D, //paint window_peep_emptysub }; @@ -1300,4 +1301,46 @@ void window_peep_unknown_05(){ window_get_register(w); widget_invalidate(WC_PEEP, w->number, WIDX_TAB_1); +} + +/* rct2: 0x69746A */ +void window_peep_stats_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + rct_peep* peep = GET_PEEP(w->number); + peep->var_45 &= ~(1<<1); + + window_invalidate(w); +} + +/* rct2: 0x69707D */ +void window_peep_stats_invalidate(){ + rct_window* w; + window_get_register(w); + + if (w->widgets != window_peep_page_widgets[w->page]) { + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_stats_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_stats_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_stats_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_stats_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_stats_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_stats_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_stats_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); } \ No newline at end of file From b6e4d131398610e2e269c27dae177c6ddf423243 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 13 Sep 2014 15:43:25 +0100 Subject: [PATCH 20/31] Started adding peep_stats_paint. --- src/window_peep.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/window_peep.c b/src/window_peep.c index 9f6906f8a3..c17b9ad272 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -223,6 +223,7 @@ void window_peep_unknown_05(); void window_peep_stats_resize(); void window_peep_stats_update(); void window_peep_stats_invalidate(); +void window_peep_stats_paint(); static void* window_peep_stats_events[] = { window_peep_emptysub, @@ -251,7 +252,7 @@ static void* window_peep_stats_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_stats_invalidate, //invalidate - (void*) 0x0069711D, //paint + window_peep_stats_paint, //paint window_peep_emptysub }; @@ -1343,4 +1344,39 @@ void window_peep_stats_invalidate(){ window_peep_stats_widgets[WIDX_CLOSE].right = w->width - 3; window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x0069711D */ +void window_peep_stats_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + //ebx + rct_peep* peep = GET_PEEP(w->number); + + // Not sure why this is not stats widgets + //cx + int x = w->x + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].top + 4; + + gfx_draw_string_left(dpi, 1662, (void*)0x13CE952, 0, x, y); + + int happiness = peep->happiness; + if (happiness < 10)happiness = 10; + int ebp = 14; + if (happiness < 50){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, happiness, (int)peep, x, y, (int)w, (int)dpi, ebp); } \ No newline at end of file From a320e17a2642dde43216f602477732c910d0107f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 12:50:15 +0100 Subject: [PATCH 21/31] Finished window_peep_stats_paint. Fixed issue with trailing colon. Fixed incorrect peep.h mapping for time in park. --- src/peep.h | 4 +- src/string_ids.c | 4 +- src/window_peep.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 4 deletions(-) diff --git a/src/peep.h b/src/peep.h index 90ff4b40c1..95082506d1 100644 --- a/src/peep.h +++ b/src/peep.h @@ -380,8 +380,8 @@ typedef struct { uint32 id; // 0x9C money32 cash_in_pocket; // 0xA0 money32 cash_spent; // 0xA4 - uint8 var_A8; // 0xA8 - sint32 time_in_park; // 0xA9 + sint32 time_in_park; // 0xA8 + uint8 var_AC; // 0xAC uint8 var_AD; // creation/hire time? uint16 var_AE; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 diff --git a/src/string_ids.c b/src/string_ids.c index bbd2b709cf..3e1277ab64 100644 --- a/src/string_ids.c +++ b/src/string_ids.c @@ -1508,7 +1508,7 @@ void format_string_code(unsigned char format_code, char **dest, char **args) } format_integer(dest, value % 60); - strcpy(*dest, value % 60 == 1 ? "sec:" : "secs:"); + strcpy(*dest, value % 60 == 1 ? "sec" : "secs"); *dest += strlen(*dest); break; case FORMAT_REALTIME: @@ -1523,7 +1523,7 @@ void format_string_code(unsigned char format_code, char **dest, char **args) } format_integer(dest, value % 60); - strcpy(*dest, value % 60 == 1 ? "min:" : "mins:"); + strcpy(*dest, value % 60 == 1 ? "min" : "mins"); *dest += strlen(*dest); break; case FORMAT_LENGTH: diff --git a/src/window_peep.c b/src/window_peep.c index c17b9ad272..ca81e4e205 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -1370,6 +1370,7 @@ void window_peep_stats_paint(){ //dx int y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].top + 4; + //Happiness gfx_draw_string_left(dpi, 1662, (void*)0x13CE952, 0, x, y); int happiness = peep->happiness; @@ -1379,4 +1380,124 @@ void window_peep_stats_paint(){ ebp |= 0x80000000; } RCT2_CALLPROC_X(0x6974FC, happiness, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Energy + y += 10; + gfx_draw_string_left(dpi, 1664, (void*)0x13CE952, 0, x, y); + + int energy = ((peep->energy - 32) * 85) / 32; + ebp = 14; + if (energy < 50){ + ebp |= 0x80000000; + } + if (energy < 10)energy = 10; + RCT2_CALLPROC_X(0x6974FC, energy, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Hunger + y += 10; + gfx_draw_string_left(dpi, 1665, (void*)0x13CE952, 0, x, y); + + int hunger = peep->hunger; + if (hunger > 190) hunger = 190; + + hunger -= 32; + if (hunger < 0) hunger = 0; + hunger *= 51; + hunger /= 32; + hunger = 0xFF & ~hunger; + + ebp = 28; + if (hunger > 170){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, hunger, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Thirst + y += 10; + gfx_draw_string_left(dpi, 1666, (void*)0x13CE952, 0, x, y); + + int thirst = peep->thirst; + if (thirst > 190) thirst = 190; + + thirst -= 32; + if (thirst < 0) thirst = 0; + thirst *= 51; + thirst /= 32; + thirst = 0xFF & ~thirst; + + ebp = 28; + if (thirst > 170){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, thirst, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Nausea + y += 10; + gfx_draw_string_left(dpi, 1663, (void*)0x13CE952, 0, x, y); + + int nausea = peep->nausea - 32; + + if (nausea < 0) nausea = 0; + nausea *= 36; + nausea /= 32; + + ebp = 28; + if (nausea > 120){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, nausea, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Bathroom + y += 10; + gfx_draw_string_left(dpi, 1667, (void*)0x13CE952, 0, x, y); + + int bathroom = peep->bathroom - 32; + if (bathroom > 210) bathroom = 210; + + bathroom -= 32; + if (bathroom < 0) bathroom = 0; + bathroom *= 45; + bathroom /= 32; + + ebp = 28; + if (bathroom > 160){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, bathroom, (int)peep, x, y, (int)w, (int)dpi, ebp); + + // Time in park + y += 11; + if (peep->time_in_park != -1){ + int eax = RCT2_GLOBAL(0xF663AC, uint32); + eax -= peep->time_in_park; + eax >>= 11; + RCT2_GLOBAL(0x13CE952, uint16) = eax & 0xFFFF; + gfx_draw_string_left(dpi, 1458, (void*)0x13CE952, 0, x, y); + } + + y += 19; + gfx_fill_rect_inset(dpi, x, y - 6, x + 179, y - 5, w->colours[1], 32); + + // Preferred Ride + gfx_draw_string_left(dpi, 1657, (void*)0, 0, x, y); + y += 10; + + // Intensity + int intensity = peep->intensity / 16; + RCT2_GLOBAL(0x13CE952, uint16) = intensity; + int string_id = 1658; + if (peep->intensity & 0xF){ + RCT2_GLOBAL(0x13CE952, uint16) = peep->intensity & 0xF; + RCT2_GLOBAL(0x13CE954, uint16) = intensity; + string_id = 1659; + if (intensity == 15) string_id = 1660; + } + + gfx_draw_string_left(dpi, string_id, (void*)0x13CE952, 0, x + 4, y); + + // Nausea tolerance + y += 10; + int nausea_tolerance = peep->nausea_tolerance & 0x3; + RCT2_GLOBAL(0x13CE952, uint16) = nausea_tolerance + 2368; + gfx_draw_string_left(dpi, 1661, (void*)0x13CE952, 0, x, y); } \ No newline at end of file From 9cfd0fba19f8e6383d964f91082978c25c2c6b5c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 13:50:39 +0100 Subject: [PATCH 22/31] Added window_peep_rides_resize and update. Added not on use of peep rides been on --- src/peep.h | 4 +++- src/window_peep.c | 53 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/peep.h b/src/peep.h index 95082506d1..0f6c5c86ed 100644 --- a/src/peep.h +++ b/src/peep.h @@ -376,7 +376,9 @@ typedef struct { uint8 pad_77; uint8 var_78; uint8 pad_79[0x03]; - uint8 rides_been_on[32]; // 0x7C + uint8 rides_been_on[32]; // 0x7C + // 255 bit bitmap of every ride the peep has been on see + // window_peep_rides_update for how to use. uint32 id; // 0x9C money32 cash_in_pocket; // 0xA0 money32 cash_spent; // 0xA4 diff --git a/src/window_peep.c b/src/window_peep.c index ca81e4e205..3ba098ad4d 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -256,14 +256,17 @@ static void* window_peep_stats_events[] = { window_peep_emptysub }; +void window_peep_rides_resize(); +void window_peep_rides_update(); + static void* window_peep_rides_events[] = { window_peep_emptysub, window_peep_mouse_up, //mouse_up - (void*) 0x006978F4, //resize + window_peep_rides_resize, //resize window_peep_emptysub, window_peep_emptysub, window_peep_unknown_05, - (void*) 0x006977B0, + window_peep_rides_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -1468,7 +1471,7 @@ void window_peep_stats_paint(){ // Time in park y += 11; if (peep->time_in_park != -1){ - int eax = RCT2_GLOBAL(0xF663AC, uint32); + int eax = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32); eax -= peep->time_in_park; eax >>= 11; RCT2_GLOBAL(0x13CE952, uint16) = eax & 0xFFFF; @@ -1500,4 +1503,48 @@ void window_peep_stats_paint(){ int nausea_tolerance = peep->nausea_tolerance & 0x3; RCT2_GLOBAL(0x13CE952, uint16) = nausea_tolerance + 2368; gfx_draw_string_left(dpi, 1661, (void*)0x13CE952, 0, x, y); +} + +/* rct2: 0x006978F4 */ +void window_peep_rides_resize(){ + rct_window* w; + window_get_register(w); + + window_set_resize(w, 192, 128, 500, 400); +} + +/* rct2: 0x6977B0 */ +void window_peep_rides_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_3); + + rct_peep* peep = GET_PEEP(w->number); + + // Every 2048 ticks do a full window_invalidate + int number_of_ticks = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) - peep->time_in_park; + if (!(number_of_ticks & 0x7FF)) window_invalidate(w); + + uint8 curr_list_position = 0; + for (uint8 ride_id = 0; ride_id < 255; ++ride_id){ + // Offset to the ride_id bit in peep_rides_been_on + uint8 ride_id_bit = ride_id & 0x3; + uint8 ride_id_offset = ride_id / 8; + if (peep->rides_been_on[ride_id_offset] & (1 << ride_id_bit)){ + rct_ride* ride = GET_RIDE(ride_id); + if (RCT2_ADDRESS(0x97C3AF, uint8)[ride->type] == 0){ + w->list_item_positions[curr_list_position] = ride_id; + curr_list_position++; + } + } + } + // If there are new items + if (w->no_list_items != curr_list_position){ + w->no_list_items = curr_list_position; + window_invalidate(w); + } } \ No newline at end of file From 809a21f0030e19eaf5353cd9b56acfde7a7ccd7b Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 14:15:32 +0100 Subject: [PATCH 23/31] Added window_peep_rides_scroll_get_size and tooltip --- src/window_peep.c | 55 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 3ba098ad4d..12577c3d3d 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -258,6 +258,8 @@ static void* window_peep_stats_events[] = { void window_peep_rides_resize(); void window_peep_rides_update(); +void window_peep_rides_tooltip(); +void window_peep_rides_scroll_get_size(); static void* window_peep_rides_events[] = { window_peep_emptysub, @@ -275,19 +277,19 @@ static void* window_peep_rides_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x0069784E, - (void*) 0x006978CC, + window_peep_rides_scroll_get_size, //scroll_get_size + (void*) 0x006978CC, //scroll_mouse_down window_peep_emptysub, - (void*) 0x0069789C, + (void*) 0x0069789C, //scroll_mouse_over window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697844, + window_peep_rides_tooltip, //tooltip window_peep_emptysub, window_peep_emptysub, (void*) 0x0069757A, //invalidate (void*) 0x00697637, //paint - (void*) 0x006976FC + (void*) 0x006976FC //scroll_paint }; static void* window_peep_finance_events[] = { @@ -1547,4 +1549,47 @@ void window_peep_rides_update(){ w->no_list_items = curr_list_position; window_invalidate(w); } +} + +/* rct2: 0x697844 */ +void window_peep_rides_tooltip(){ + RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST; +} + +/* rct2: 0x69784E */ +void window_peep_rides_scroll_get_size(){ + rct_window *w; + + window_get_register(w); + + int height = w->no_list_items * 10; + + if (w->selected_list_item != -1){ + w->selected_list_item = -1; + window_invalidate(w); + } + + int visable_height = height + - window_peep_rides_widgets[WIDX_RIDE_SCROLL].bottom + + window_peep_rides_widgets[WIDX_RIDE_SCROLL].top + + 21; + + if (visable_height < 0) visable_height = 0; + + if (visable_height < w->scrolls[0].v_top){ + w->scrolls[0].v_top = visable_height; + window_invalidate(w); + } + +#ifdef _MSC_VER + __asm mov ecx, 0 +#else + __asm__("mov ecx, 0 "); +#endif + +#ifdef _MSC_VER + __asm mov edx, height +#else + __asm__("mov edx, %[height] " : [height] "+m" (height)); +#endif } \ No newline at end of file From 5498e3cb90bfb4f59d5c6c00d41a2fa105cfced6 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 14:33:20 +0100 Subject: [PATCH 24/31] Added window_peep_rides_scroll_mouse_down and over --- src/window_peep.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 12577c3d3d..d8020fadd8 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -260,6 +260,8 @@ void window_peep_rides_resize(); void window_peep_rides_update(); void window_peep_rides_tooltip(); void window_peep_rides_scroll_get_size(); +void window_peep_rides_scroll_mouse_down(); +void window_peep_rides_scroll_mouse_over(); static void* window_peep_rides_events[] = { window_peep_emptysub, @@ -278,9 +280,9 @@ static void* window_peep_rides_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_rides_scroll_get_size, //scroll_get_size - (void*) 0x006978CC, //scroll_mouse_down + window_peep_rides_scroll_mouse_down, //scroll_mouse_down window_peep_emptysub, - (void*) 0x0069789C, //scroll_mouse_over + window_peep_rides_scroll_mouse_over, //scroll_mouse_over window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -1592,4 +1594,35 @@ void window_peep_rides_scroll_get_size(){ #else __asm__("mov edx, %[height] " : [height] "+m" (height)); #endif +} + +/* rct2: 0x006978CC */ +void window_peep_rides_scroll_mouse_down(){ + int index; + short x, y; + rct_window *w; + + window_scrollmouse_get_registers(w, x, y); + + index = y / 10; + if (index >= w->no_list_items) return; + + window_ride_main_open(w->list_item_positions[index]); +} + +/* rct2: 0x0069789C */ +void window_peep_rides_scroll_mouse_over(){ + int index; + short x, y; + rct_window *w; + + window_scrollmouse_get_registers(w, x, y); + + index = y / 10; + if (index >= w->no_list_items)return; + + if (index == w->selected_list_item)return; + w->selected_list_item = index; + + window_invalidate(w); } \ No newline at end of file From ce1a4fe473bb87e8f446826bf7929661d69af77b Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 15:46:50 +0100 Subject: [PATCH 25/31] Added window_peep_rides_invalidate and paint --- src/window_peep.c | 80 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index d8020fadd8..bd310a322b 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -262,6 +262,8 @@ void window_peep_rides_tooltip(); void window_peep_rides_scroll_get_size(); void window_peep_rides_scroll_mouse_down(); void window_peep_rides_scroll_mouse_over(); +void window_peep_rides_invalidate(); +void window_peep_rides_paint(); static void* window_peep_rides_events[] = { window_peep_emptysub, @@ -289,8 +291,8 @@ static void* window_peep_rides_events[] = { window_peep_rides_tooltip, //tooltip window_peep_emptysub, window_peep_emptysub, - (void*) 0x0069757A, //invalidate - (void*) 0x00697637, //paint + window_peep_rides_invalidate, //invalidate + window_peep_rides_paint, //paint (void*) 0x006976FC //scroll_paint }; @@ -1625,4 +1627,78 @@ void window_peep_rides_scroll_mouse_over(){ w->selected_list_item = index; window_invalidate(w); +} + +/* rct2: 0x0069757A */ +void window_peep_rides_invalidate(){ + rct_window* w; + window_get_register(w); + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + int width = w->width; + int height = w->height; + + window_peep_rides_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_rides_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_rides_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_rides_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_rides_widgets[WIDX_CLOSE].right = w->width - 3; + + window_peep_rides_widgets[WIDX_RIDE_SCROLL].right = w->width - 4; + window_peep_rides_widgets[WIDX_RIDE_SCROLL].bottom = w->height - 15; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697637 */ +void window_peep_rides_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].left + 2; + //dx + int y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].top + 2; + + gfx_draw_string_left(dpi, 2292, (void*)0, 0, x, y); + + y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].bottom - 12; + + int ride_string_id = 3094; + int ride_string_arguments = 0; + if (peep->favourite_ride != 0xFF){ + rct_ride* ride = GET_RIDE(peep->favourite_ride); + ride_string_arguments = ride->name_arguments; + ride_string_id = ride->name; + } + RCT2_GLOBAL(0x13CE952, uint16) = ride_string_id; + RCT2_GLOBAL(0x13CE954, uint32) = ride_string_arguments; + + gfx_draw_string_left_clipped(dpi, 3093, (void*)0x13CE952, 0, x, y, w->width - 14); } \ No newline at end of file From b34a65cafaeeb012d16ed743d43eccd783345905 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 20:06:32 +0100 Subject: [PATCH 26/31] Added window_peep_rides_scroll_paint. Peep rides finished --- src/window_peep.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/window_peep.c b/src/window_peep.c index bd310a322b..156b76ec4b 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -264,6 +264,7 @@ void window_peep_rides_scroll_mouse_down(); void window_peep_rides_scroll_mouse_over(); void window_peep_rides_invalidate(); void window_peep_rides_paint(); +void window_peep_rides_scroll_paint(); static void* window_peep_rides_events[] = { window_peep_emptysub, @@ -293,7 +294,7 @@ static void* window_peep_rides_events[] = { window_peep_emptysub, window_peep_rides_invalidate, //invalidate window_peep_rides_paint, //paint - (void*) 0x006976FC //scroll_paint + window_peep_rides_scroll_paint //scroll_paint }; static void* window_peep_finance_events[] = { @@ -1701,4 +1702,36 @@ void window_peep_rides_paint(){ RCT2_GLOBAL(0x13CE954, uint32) = ride_string_arguments; gfx_draw_string_left_clipped(dpi, 3093, (void*)0x13CE952, 0, x, y, w->width - 14); +} + +/* rct2: 0x006976FC */ +void window_peep_rides_scroll_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + // ax + int left = dpi->x; + // bx + int right = dpi->x + dpi->width - 1; + // cx + int top = dpi->y; + // dx + int bottom = dpi->y + dpi->height - 1; + + int colour = RCT2_ADDRESS(0x141FC48, uint8)[w->colours[1] * 8]; + gfx_fill_rect(dpi, left, top, right, bottom, colour); + + for (int list_index = 0; list_index < w->no_list_items; list_index++){ + int y = list_index * 10; + int string_format = 1191; + if (list_index == w->selected_list_item){ + gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x2000031); + string_format = 1193; + } + rct_ride* ride = GET_RIDE(w->list_item_positions[list_index]); + + gfx_draw_string_left(dpi, string_format, (void*)&ride->name, 0, 0, y - 1); + } } \ No newline at end of file From a309fa3e3032d411f67f35b806e937c397ad8c9d Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 21:21:54 +0100 Subject: [PATCH 27/31] Finished window_peep_finance events. Added note to peep.h --- src/peep.h | 2 +- src/window_peep.c | 150 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 144 insertions(+), 8 deletions(-) diff --git a/src/peep.h b/src/peep.h index 0f6c5c86ed..af24e1fc37 100644 --- a/src/peep.h +++ b/src/peep.h @@ -332,7 +332,7 @@ typedef struct { uint8 pad_2C; uint8 sprite_type; // 0x2D uint8 type; // 0x2E - uint8 staff_type; // 0x2F + uint8 staff_type; // 0x2F Also used for no_of_rides uint8 tshirt_colour; // 0x30 uint8 trousers_colour; // 0x31 uint16 var_32; diff --git a/src/window_peep.c b/src/window_peep.c index 156b76ec4b..c1b974663d 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -297,14 +297,19 @@ static void* window_peep_rides_events[] = { window_peep_rides_scroll_paint //scroll_paint }; +void window_peep_finance_resize(); +void window_peep_finance_update(); +void window_peep_finance_invalidate(); +void window_peep_finance_paint(); + static void* window_peep_finance_events[] = { window_peep_emptysub, window_peep_mouse_up, //mouse_up - (void*) 0x00697C16, //resize + window_peep_finance_resize, //resize window_peep_emptysub, window_peep_emptysub, window_peep_unknown_05, - (void*) 0x00697BF8, + window_peep_finance_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -323,8 +328,8 @@ static void* window_peep_finance_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697968, //invalidate - (void*) 0x00697A08, //paint + window_peep_finance_invalidate, //invalidate + window_peep_finance_paint, //paint window_peep_emptysub }; @@ -1645,9 +1650,6 @@ void window_peep_rides_invalidate(){ RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; RCT2_GLOBAL(0x13CE954, uint32) = peep->id; - int width = w->width; - int height = w->height; - window_peep_rides_widgets[WIDX_BACKGROUND].right = w->width - 1; window_peep_rides_widgets[WIDX_BACKGROUND].bottom = w->height - 1; @@ -1734,4 +1736,138 @@ void window_peep_rides_scroll_paint(){ gfx_draw_string_left(dpi, string_format, (void*)&ride->name, 0, 0, y - 1); } +} + +/* rct2: 0x006C1B2F */ +void window_peep_finance_resize(){ + rct_window* w; + window_get_register(w); + + window_set_resize(w, 210, 134, 210, 134); +} + +/* rct2: 0x00697BF8 */ +void window_peep_finance_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_4); +} + +/* rct2: 0x00697968 */ +void window_peep_finance_invalidate(){ + rct_window* w; + window_get_register(w); + + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_finance_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_finance_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_finance_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_finance_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_finance_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697A08 */ +void window_peep_finance_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + // Not sure why this is not stats widgets + //cx + int x = w->x + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].top + 4; + + // Cash in pocket + RCT2_GLOBAL(0x13CE952, money32) = peep->cash_in_pocket; + gfx_draw_string_left(dpi, 1457, (void*)0x13CE952, 0, x, y); + + // Cash spent + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->cash_spent; + gfx_draw_string_left(dpi, 1456, (void*)0x13CE952, 0, x, y); + + y += 20; + gfx_fill_rect_inset(dpi, x, y - 6, x + 179, y - 5, w->colours[1], 32); + + // Paid to enter + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_to_enter; + gfx_draw_string_left(dpi, 2296, (void*)0x13CE952, 0, x, y); + + // Paid on rides + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_rides; + RCT2_GLOBAL(0x13CE956, uint16) = peep->staff_type; + if (peep->staff_type != 1){ + gfx_draw_string_left(dpi, 2298, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2297, (void*)0x13CE952, 0, x, y); + } + + // Paid on food + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_food; + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_food; + if (peep->no_of_food != 1){ + gfx_draw_string_left(dpi, 2300, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2299, (void*)0x13CE952, 0, x, y); + } + + // Paid on drinks + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_drink; + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_drinks; + if (peep->no_of_drinks != 1){ + gfx_draw_string_left(dpi, 2302, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2301, (void*)0x13CE952, 0, x, y); + } + + // Paid on souvenirs + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_souvenirs; + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_souvenirs; + if (peep->no_of_souvenirs != 1){ + gfx_draw_string_left(dpi, 2304, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2303, (void*)0x13CE952, 0, x, y); + } } \ No newline at end of file From a730c4d106d97fe458c959ba66bc1f960087f5be Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 14 Sep 2014 21:56:45 +0100 Subject: [PATCH 28/31] Added window_peep_thoughts events. --- src/peep.h | 8 ++-- src/window_peep.c | 115 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 9 deletions(-) diff --git a/src/peep.h b/src/peep.h index af24e1fc37..baaceb22ad 100644 --- a/src/peep.h +++ b/src/peep.h @@ -296,10 +296,10 @@ enum PEEP_ITEM { }; typedef struct { - uint8 type; - uint8 item; - uint8 var_2; - uint8 var_3; + uint8 type; //0 + uint8 item; //1 + uint8 var_2; //2 + uint8 var_3; //3 } rct_peep_thought; typedef struct { diff --git a/src/window_peep.c b/src/window_peep.c index c1b974663d..09aecd6325 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -333,14 +333,19 @@ static void* window_peep_finance_events[] = { window_peep_emptysub }; +void window_peep_thoughts_resize(); +void window_peep_thoughts_update(); +void window_peep_thoughts_invalidate(); +void window_peep_thoughts_paint(); + static void* window_peep_thoughts_events[] = { window_peep_emptysub, window_peep_mouse_up, //mouse_up - (void*) 0x00697E33, //resize + window_peep_thoughts_resize, //resize window_peep_emptysub, window_peep_emptysub, window_peep_unknown_05, - (void*) 0x00697EB4, + window_peep_thoughts_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -359,8 +364,8 @@ static void* window_peep_thoughts_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697C8A, //invalidate - (void*) 0x00697D2A, //paint + window_peep_thoughts_invalidate, //invalidate + window_peep_thoughts_paint, //paint window_peep_emptysub }; @@ -1805,7 +1810,6 @@ void window_peep_finance_paint(){ rct_peep* peep = GET_PEEP(w->number); - // Not sure why this is not stats widgets //cx int x = w->x + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].left + 4; //dx @@ -1870,4 +1874,105 @@ void window_peep_finance_paint(){ else{ gfx_draw_string_left(dpi, 2303, (void*)0x13CE952, 0, x, y); } +} + +/* rct2: 0x00697E33 */ +void window_peep_thoughts_resize(){ + rct_window* w; + window_get_register(w); + + rct_peep* peep = GET_PEEP(w->number); + if (peep->var_45 & 1){ + peep->var_45 &=~(1 << 0); + window_invalidate(w); + } + + window_set_resize(w, 192, 159, 500, 450); +} + +/* rct2: 0x00697EB4 */ +void window_peep_thoughts_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_5); +} + +/* rct2: 0x00697C8A */ +void window_peep_thoughts_invalidate(){ + rct_window* w; + window_get_register(w); + + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_thoughts_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_thoughts_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_thoughts_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_thoughts_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_thoughts_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697D2A */ +void window_peep_thoughts_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].top + 4; + + gfx_draw_string_left(dpi, 1654, (void*)0, 0, x, y); + + y += 10; + for (rct_peep_thought* thought = peep->thoughts; thought < &peep->thoughts[PEEP_MAX_THOUGHTS]; ++thought){ + if (thought->type == PEEP_THOUGHT_TYPE_NONE) return; + if (thought->var_2 == 0) continue; + + uint32 argument1, argument2; + get_arguments_from_thought(*thought, &argument1, &argument2); + RCT2_GLOBAL(0x13CE952, uint32) = argument1; + RCT2_GLOBAL(0x13CE956, uint32) = argument2; + + int width = window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].right + - window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].left + - 8; + + y += gfx_draw_string_left_wrapped(dpi, (void*)0x13CE952, x, y, width, 1191, 0); + + // If this is the last visable line end drawing. + if (y > w->y + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom - 32) return; + } } \ No newline at end of file From 7127140f1611ad5df42a77b4d60db02c57a2ad08 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 15 Sep 2014 17:42:49 +0100 Subject: [PATCH 29/31] Added window_peep_inventory events. All events finished. --- src/peep.h | 4 +- src/window_peep.c | 205 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 202 insertions(+), 7 deletions(-) diff --git a/src/peep.h b/src/peep.h index baaceb22ad..c9285a2fc9 100644 --- a/src/peep.h +++ b/src/peep.h @@ -406,8 +406,8 @@ typedef struct { uint8 no_of_drinks; // 0xED uint8 no_of_souvenirs; // 0xEE uint8 pad_EF; - uint8 var_F0; - uint8 var_F1; + uint8 var_F0; //voucher_type + uint8 var_F1; //voucher_type arguments i.e. ride_id uint8 pad_F2; uint8 var_F3; uint8 pad_F4[0x02]; diff --git a/src/window_peep.c b/src/window_peep.c index 09aecd6325..de591b9e7e 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -369,14 +369,19 @@ static void* window_peep_thoughts_events[] = { window_peep_emptysub }; +void window_peep_inventory_resize(); +void window_peep_inventory_update(); +void window_peep_inventory_invalidate(); +void window_peep_inventory_paint(); + static void* window_peep_inventory_events[] = { window_peep_emptysub, window_peep_mouse_up, //mouse_up - (void*) 0x00698294, //resize + window_peep_inventory_resize, //resize window_peep_emptysub, window_peep_emptysub, window_peep_unknown_05, - (void*) 0x00698315, + window_peep_inventory_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -395,8 +400,8 @@ static void* window_peep_inventory_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697EE1, //invalidate - (void*) 0x00697F81, //paint + window_peep_inventory_invalidate, //invalidate + window_peep_inventory_paint, //paint window_peep_emptysub }; @@ -1743,7 +1748,7 @@ void window_peep_rides_scroll_paint(){ } } -/* rct2: 0x006C1B2F */ +/* rct2: 0x00697C16 */ void window_peep_finance_resize(){ rct_window* w; window_get_register(w); @@ -1975,4 +1980,194 @@ void window_peep_thoughts_paint(){ // If this is the last visable line end drawing. if (y > w->y + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom - 32) return; } +} + + +/* rct2: 0x00698294 */ +void window_peep_inventory_resize(){ + rct_window* w; + window_get_register(w); + + rct_peep* peep = GET_PEEP(w->number); + if (peep->var_45 & (1<<3)){ + peep->var_45 &= ~(1 << 3); + window_invalidate(w); + } + + window_set_resize(w, 192, 159, 500, 450); +} + +/* rct2: 0x00698315 */ +void window_peep_inventory_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_6); +} + +/* rct2: 0x00697EE1 */ +void window_peep_inventory_invalidate(){ + rct_window* w; + window_get_register(w); + + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_inventory_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_inventory_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_inventory_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_inventory_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_inventory_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697F81 */ +void window_peep_inventory_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].top + 2; + + int max_y = w->y + w->height - 22; + int no_items = 0; + + gfx_draw_string_left(dpi, 1810, (void*)0, 0, x, y); + + y += 10; + + for (int i = 0; y < max_y && i < 28; ++i){ + int item_flag = 1 << i; + if (!(peep->item_standard_flags & item_flag))continue; + no_items++; + + RCT2_GLOBAL(0x13CE952, uint32) = 5061 + i; + + switch (item_flag){ + case PEEP_ITEM_TSHIRT: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->tshirt_colour << 19; + break; + case PEEP_ITEM_HAT: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->hat_colour << 19; + break; + case PEEP_ITEM_BALLOON: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->balloon_colour << 19; + break; + case PEEP_ITEM_UMBRELLA: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->umbrella_colour << 19; + break; + } + + int string_format = 2072 + i; + if (string_format >= 2104) string_format += 84; //??? i is never 32 + + RCT2_GLOBAL(0x13CE956, uint16) = string_format; + RCT2_GLOBAL(0x13CE958, uint16) = RCT2_GLOBAL(0x13573D4, uint16); + RCT2_GLOBAL(0x13CE95A, uint32) = RCT2_GLOBAL(0x13573D8, uint32); + rct_ride* ride; + + switch (item_flag){ + case PEEP_ITEM_PHOTO: + ride = GET_RIDE(peep->photo1_ride_ref); + RCT2_GLOBAL(0x13CE958, uint16) = ride->name; + RCT2_GLOBAL(0x13CE95A, uint32) = ride->name_arguments; + break; + case PEEP_ITEM_VOUCHER: + RCT2_GLOBAL(0x13CE958, uint16) = peep->var_F0 + 2418; + RCT2_GLOBAL(0x13CE95A, uint16) = RCT2_GLOBAL(0x13573D4, uint16); + RCT2_GLOBAL(0x13CE95C, uint32) = RCT2_GLOBAL(0x13573D8, uint32); + + if (peep->var_F0 == 0 || peep->var_F0 == 2)break; + + int voucher_id = peep->var_F1 + 1988; + if (voucher_id >= 2020) voucher_id += 102; + + RCT2_GLOBAL(0x13CE95A, uint16) = voucher_id; + + if (peep->var_F0 == 3)break; + ride = GET_RIDE(peep->var_F1); + RCT2_GLOBAL(0x13CE95A, uint16) = ride->name; + RCT2_GLOBAL(0x13CE95C, uint32) = ride->name_arguments; + break; + } + + int width = window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].right + - window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].left + - 8; + + y += gfx_draw_string_left_wrapped(dpi, (void*)0x13CE952, x, y, width, 1875, 0); + } + + for (int i = 0; y < max_y && i < 22; ++i){ + int item_flag = 1 << i; + + if (!(peep->item_extra_flags & item_flag))continue; + no_items++; + + RCT2_GLOBAL(0x13CE952, uint32) = 5089 + i; + RCT2_GLOBAL(0x13CE956, uint16) = 2188; + RCT2_GLOBAL(0x13CE958, uint16) = RCT2_GLOBAL(0x13573D4, uint16); + RCT2_GLOBAL(0x13CE95A, uint32) = RCT2_GLOBAL(0x13573D8, uint32); + + if (i < 3){ + int ride_id = 0; + switch (item_flag){ + case PEEP_ITEM_PHOTO2: + ride_id = peep->photo2_ride_ref; + break; + case PEEP_ITEM_PHOTO3: + ride_id = peep->photo3_ride_ref; + break; + case PEEP_ITEM_PHOTO4: + ride_id = peep->photo4_ride_ref; + break; + } + + rct_ride* ride = GET_RIDE(ride_id); + RCT2_GLOBAL(0x13CE958, uint16) = ride->name; + RCT2_GLOBAL(0x13CE95A, uint32) = ride->name_arguments; + } + + int width = window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].right + - window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].left + - 8; + + y += gfx_draw_string_left_wrapped(dpi, (void*)0x13CE952, x, y, width, 1875, 0); + } + + if (!no_items){ + gfx_draw_string_left(dpi, 2293, (void*)0, 0, x, y); + } } \ No newline at end of file From 9aee80e5a6ec874dbaa049697765670f48b3e684 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 15 Sep 2014 20:07:16 +0100 Subject: [PATCH 30/31] Added enum name to window flag --- 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 de591b9e7e..a43fc2e5e1 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -501,7 +501,7 @@ void window_peep_open(rct_peep* peep){ window->min_height = 157; window->max_width = 500; window->max_height = 450; - window->flags = 1 << 8; + window->flags = WF_RESIZABLE; window->no_list_items = 0; window->selected_list_item = -1; window->colours[0] = 1; From 7c6a35af7ae5abacb09776a72b434f1b52558d2c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Mon, 15 Sep 2014 20:47:42 +0100 Subject: [PATCH 31/31] Fix graphical bug when drawing inline sprites caused by using strlen instead of get_string_length --- src/gfx.c | 4 ++-- src/string_ids.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ src/string_ids.h | 1 + 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index ffdb445fdb..53c4942d59 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1819,7 +1819,7 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i int half_width = gfx_get_string_width(buffer) / 2; gfx_draw_string(dpi, buffer, 0xFE, x - half_width, line_y); - buffer += strlen(buffer) + 1; + buffer += get_string_length(buffer) + 1; line_y += line_height; } @@ -1874,7 +1874,7 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int for (int line = 0; line <= num_lines; ++line) { gfx_draw_string(dpi, buffer, 0xFE, x, line_y); - buffer += strlen(buffer) + 1; + buffer += get_string_length(buffer) + 1; line_y += line_height; } diff --git a/src/string_ids.c b/src/string_ids.c index 3e1277ab64..aa9d50f568 100644 --- a/src/string_ids.c +++ b/src/string_ids.c @@ -1691,4 +1691,59 @@ void reset_saved_strings() { for (int i = 0; i < 1024; i++) { RCT2_ADDRESS(0x135A8F4, uint8)[i * 32] = 0; } +} + +/** +* Return the length of the string in buffer. +* note you can't use strlen as there can be inline sprites! +* +* buffer (esi) +*/ +int get_string_length(char* buffer) +{ + // Length of string + int length = 0; + + for (uint8* curr_char = (uint8*)buffer; *curr_char != (uint8)0; curr_char++) { + length++; + if (*curr_char >= 0x20) { + continue; + } + switch (*curr_char) { + case FORMAT_MOVE_X: + case FORMAT_ADJUST_PALETTE: + case 3: + case 4: + curr_char++; + length++; + break; + case FORMAT_NEWLINE: + case FORMAT_NEWLINE_SMALLER: + case FORMAT_TINYFONT: + case FORMAT_BIGFONT: + case FORMAT_MEDIUMFONT: + case FORMAT_SMALLFONT: + case FORMAT_OUTLINE: + case FORMAT_OUTLINE_OFF: + case FORMAT_WINDOW_COLOUR_1: + case FORMAT_WINDOW_COLOUR_2: + case FORMAT_WINDOW_COLOUR_3: + case 0x10: + continue; + case FORMAT_INLINE_SPRITE: + length += 4; + curr_char += 4; + break; + default: + if (*curr_char <= 0x16) { //case 0x11? FORMAT_NEW_LINE_X_Y + length += 2; + curr_char += 2; + continue; + } + length += 4; + curr_char += 4;//never happens? + break; + } + } + return length; } \ No newline at end of file diff --git a/src/string_ids.h b/src/string_ids.h index 91d2b031f9..5719fd97aa 100644 --- a/src/string_ids.h +++ b/src/string_ids.h @@ -30,6 +30,7 @@ void error_string_quit(int error, rct_string_id format); char format_get_code(const char *token); const char *format_get_token(char code); +int get_string_length(char* buffer); enum { // Font format codes