diff --git a/src/interface/window.h b/src/interface/window.h index 617412338c..6fcc023d25 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -659,6 +659,13 @@ int window_can_resize(rct_window *w); #define window_cursor_set_registers(cursorId) \ __asm mov ebx, cursorId + #define window_tooltip_get_registers(w, widgetIndex) \ + __asm mov widgetIndex, ax \ + __asm mov w, esi + + #define window_tooltip_set_registers(value) \ + __asm mov ax, value + #else #define window_get_register(w) \ __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); @@ -721,6 +728,13 @@ int window_can_resize(rct_window *w); #define window_cursor_set_registers(cursorId) \ __asm__ ( "mov ebx, %[cursorId] " : [cursorId] "+m" (cursorId) ); + + #define window_tooltip_get_registers(w, widgetIndex) \ + __asm__ ( "mov %["#widgetIndex"], ax " : [widgetIndex] "+m" (widgetIndex) ); \ + __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); + + #define window_tooltip_set_registers(value) \ + __asm__ ( "mov ax, %[value] " : [value] "+m" (value) ); #endif #endif diff --git a/src/management/award.c b/src/management/award.c index 90f4d8e719..ccf55a4255 100644 --- a/src/management/award.c +++ b/src/management/award.c @@ -51,6 +51,8 @@ int _awardPositiveMap[] = { POSITIVE, // PARK_AWARD_BEST_GENTLE_RIDES }; +rct_award *gCurrentAwards = (rct_award*)RCT2_ADDRESS_AWARD_LIST; + int award_is_positive(int type) { return _awardPositiveMap[type]; @@ -581,7 +583,7 @@ void award_reset() { int i; for (i = 0; i < MAX_AWARDS; i++) - RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award)[i].time = 0; + gCurrentAwards[i].time = 0; } /** @@ -591,9 +593,6 @@ void award_reset() void award_update_all() { int i, activeAwardTypes, freeAwardEntryIndex; - rct_award *awards; - - awards = RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award); // Only add new awards if park is open if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_PARK_OPEN) { @@ -601,8 +600,8 @@ void award_update_all() activeAwardTypes = 0; freeAwardEntryIndex = -1; for (i = 0; i < MAX_AWARDS; i++) { - if (awards[i].time != 0) - activeAwardTypes |= (1 << awards[i].type); + if (gCurrentAwards[i].time != 0) + activeAwardTypes |= (1 << gCurrentAwards[i].type); else if (freeAwardEntryIndex == -1) freeAwardEntryIndex = i; } @@ -618,8 +617,8 @@ void award_update_all() // Check if award is deserved if (award_is_deserved(awardType, activeAwardTypes)) { // Add award - awards[freeAwardEntryIndex].type = awardType; - awards[freeAwardEntryIndex].time = 5; + gCurrentAwards[freeAwardEntryIndex].type = awardType; + gCurrentAwards[freeAwardEntryIndex].time = 5; news_item_add_to_queue(NEWS_ITEM_AWARD, STR_NEWS_ITEM_AWARD_MOST_UNTIDY + awardType, 0); window_invalidate_by_class(WC_PARK_INFORMATION); } @@ -628,7 +627,7 @@ void award_update_all() // Decrease award times for (i = 0; i < MAX_AWARDS; i++) - if (awards[i].time != 0) - if (--awards[i].time == 0) + if (gCurrentAwards[i].time != 0) + if (--gCurrentAwards[i].time == 0) window_invalidate_by_class(WC_PARK_INFORMATION); } diff --git a/src/management/award.h b/src/management/award.h index 8e7c965f50..faab09d43c 100644 --- a/src/management/award.h +++ b/src/management/award.h @@ -51,6 +51,8 @@ enum { #define MAX_AWARDS 4 +extern rct_award *gCurrentAwards; + int award_is_positive(int type); void award_reset(); void award_update_all(); diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index c4f781b8fb..33727efa7e 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -214,31 +214,20 @@ static void window_game_bottom_toolbar_mouseup() static void window_game_bottom_toolbar_tooltip() { int month, day; - short tool_tip_index; + short widgetIndex, result; rct_window *w; - #ifdef _MSC_VER - __asm mov tool_tip_index, ax - #else - __asm__ ( "mov %[tool_tip_index], ax " : [tool_tip_index] "+m" (tool_tip_index) ); - #endif + window_tooltip_get_registers(w, widgetIndex); - #ifdef _MSC_VER - __asm mov w, esi - #else - __asm__ ( "mov %[w], esi " : [w] "+m" (w) ); - #endif - - - switch (tool_tip_index) { + switch (widgetIndex) { case WIDX_MONEY: RCT2_GLOBAL(0x013CE952, int) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32); RCT2_GLOBAL(0x013CE956, int) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); - tool_tip_index = 0; + result = 0; break; case WIDX_PARK_RATING: RCT2_GLOBAL(0x013CE952, short) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16); - tool_tip_index = 0; + result = 0; break; case WIDX_DATE: month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; @@ -246,15 +235,11 @@ static void window_game_bottom_toolbar_tooltip() RCT2_GLOBAL(0x013CE952, short) = STR_DATE_DAY_1 + day; RCT2_GLOBAL(0x013CE954, short) = STR_MONTH_MARCH + month; - tool_tip_index = 0; + result = 0; break; } -#ifdef _MSC_VER - __asm mov ax, tool_tip_index -#else - __asm__("mov ax, %[tool_tip_index] " :[tool_tip_index] "+m" (tool_tip_index)); -#endif + window_tooltip_set_registers(result); } /** diff --git a/src/windows/guest.c b/src/windows/guest.c index e7f32b44ab..d5c0550956 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -1593,12 +1593,15 @@ void window_guest_rides_tooltip(){ } /* rct2: 0x69784E */ -void window_guest_rides_scroll_get_size(){ +void window_guest_rides_scroll_get_size() +{ rct_window *w; + int width, height; window_get_register(w); - int height = w->no_list_items * 10; + width = 0; + height = w->no_list_items * 10; if (w->selected_list_item != -1){ w->selected_list_item = -1; @@ -1617,17 +1620,7 @@ void window_guest_rides_scroll_get_size(){ 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 + window_scrollsize_set_registers(width, height); } /* rct2: 0x006978CC */ diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index ab844b1047..4fe22575a0 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -418,7 +418,7 @@ static void window_guest_list_update(rct_window *w) */ static void window_guest_list_scrollgetsize() { - int i, y, numGuests, spriteIndex; + int i, y, numGuests, spriteIndex, width, height; rct_window *w; rct_peep *peep; @@ -469,18 +469,10 @@ static void window_guest_list_scrollgetsize() window_invalidate(w); } - #ifdef _MSC_VER - __asm mov ecx, 447 - #else - __asm__ ( "mov ecx, 447 " ); - #endif - - #ifdef _MSC_VER - __asm mov edx, y - #else - __asm__ ( "mov edx, %[y] " : [y] "+m" (y) ); - #endif + width = 447; + height = y; + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/map.c b/src/windows/map.c index d5eef11cad..47f7b03098 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -465,15 +465,13 @@ static void window_map_update(rct_window *w) */ static void window_map_scrollgetsize() { + int width, height; + window_map_invalidate(); - #ifdef _MSC_VER - __asm mov ecx, 512 - __asm mov edx, 512 - #else - __asm__ ( "mov ecx, 512 " ); - __asm__ ( "mov edx, 512 " ); - #endif + width = 512; + height = 512; + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/music_credits.c b/src/windows/music_credits.c index 2c8891308c..4a6f1c9da3 100644 --- a/src/windows/music_credits.c +++ b/src/windows/music_credits.c @@ -130,13 +130,11 @@ static void window_music_credits_mouseup() */ static void window_music_credits_scrollgetsize() { - int y = 560; + int width, height; - #ifdef _MSC_VER - __asm mov edx, y - #else - __asm__("mov edx, %[y] " : [y] "+m" (y)); - #endif + width = 0; + height = 560; + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index 082be03649..4d2fb19bc9 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -634,27 +634,17 @@ static void window_new_ride_update(rct_window *w) static void window_new_ride_scrollgetsize() { ride_list_item *listItem = (ride_list_item*)0x00F43523; - int scrollWidth, scrollHeight; + int width, height; int count = 0; while (listItem->type != 255 || listItem->entry_index != 255) { count++; listItem++; } - scrollWidth = 0; - scrollHeight = ((count + 4) / 5) * 116; + width = 0; + height = ((count + 4) / 5) * 116; - #ifdef _MSC_VER - __asm mov ecx, scrollWidth - #else - __asm__ ( "mov ecx, %[scrollWidth] " : [scrollWidth] "+m" (scrollWidth) ); - #endif - - #ifdef _MSC_VER - __asm mov edx, scrollHeight - #else - __asm__ ( "mov edx, %[scrollHeight] " : [scrollHeight] "+m" (scrollHeight) ); - #endif + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/news.c b/src/windows/news.c index 1d5935bf58..003bb5b7c0 100644 --- a/src/windows/news.c +++ b/src/windows/news.c @@ -184,9 +184,10 @@ static void window_news_update(rct_window *w) */ static void window_news_scrollgetsize() { - int i, height; + int i, width, height; rct_news_item *newsItems = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + width = 0; height = 0; for (i = 11; i < 61; i++) { if (newsItems[i].type == NEWS_ITEM_NULL) @@ -195,12 +196,7 @@ static void window_news_scrollgetsize() height += 42; } - #ifdef _MSC_VER - __asm mov edx, height - #else - __asm__ ( "mov edx, %[height] " : [height] "+m" (height) ); - #endif - + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/park.c b/src/windows/park.c index b1d9b4a917..ddba07d4b0 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1979,7 +1979,7 @@ static void window_park_awards_paint() count = 0; for (i = 0; i < MAX_AWARDS; i++) { - award = &RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award)[i]; + award = &gCurrentAwards[i]; if (award->time == 0) continue; diff --git a/src/windows/publisher_credits.c b/src/windows/publisher_credits.c index 37896872ce..a517c189a0 100644 --- a/src/windows/publisher_credits.c +++ b/src/windows/publisher_credits.c @@ -130,13 +130,11 @@ static void window_publisher_credits_mouseup() */ static void window_publisher_credits_scrollgetsize() { - int y = 820; + int width, height; -#ifdef _MSC_VER - __asm mov edx, y -#else - __asm__("mov edx, %[y] " : [y] "+m" (y)); -#endif + width = 0; + height = 820; + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/ride.c b/src/windows/ride.c index 794fb63314..04c29e33a6 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -5081,18 +5081,7 @@ static void window_ride_graphs_scrollgetheight() if (measurement != NULL) width = max(width, measurement->num_items); - // Return size - #ifdef _MSC_VER - __asm mov ecx, width - #else - __asm__ ( "mov ecx, 0 " ); - #endif - - #ifdef _MSC_VER - __asm mov edx, height - #else - __asm__ ( "mov edx, %[height] " : [height] "+m" (height) ); - #endif + window_scrollsize_set_registers(width, height); } /** @@ -5115,12 +5104,12 @@ static void window_ride_graphs_15() static void window_ride_graphs_tooltip() { rct_window *w; - short unused, widgetIndex, result; + short widgetIndex, result; rct_ride *ride; rct_ride_measurement *measurement; rct_string_id stringId; - window_dropdown_get_registers(w, unused, widgetIndex); + window_tooltip_get_registers(w, widgetIndex); result = -1; if (widgetIndex == WIDX_GRAPH) { @@ -5136,11 +5125,7 @@ static void window_ride_graphs_tooltip() } } - #ifdef _MSC_VER - __asm mov ax, result - #else - __asm__ ( "mov ax, %[result] " : [result] "+m" (result) ); - #endif + window_tooltip_set_registers(result); } /** diff --git a/src/windows/ride_list.c b/src/windows/ride_list.c index f327357a61..c7c068366e 100644 --- a/src/windows/ride_list.c +++ b/src/windows/ride_list.c @@ -307,7 +307,7 @@ static void window_ride_list_update(rct_window *w) */ static void window_ride_list_scrollgetsize() { - int top, height; + int top, width, height; rct_window *w; window_get_register(w); @@ -326,18 +326,8 @@ static void window_ride_list_scrollgetsize() 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 - + width = 0; + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/staff_list.c b/src/windows/staff_list.c index d98c37ccc8..c9bce60061 100644 --- a/src/windows/staff_list.c +++ b/src/windows/staff_list.c @@ -348,8 +348,9 @@ void window_staff_list_toolabort() { * * rct2: 0x006BDBE6 */ -void window_staff_list_scrollgetsize() { - int spriteIndex; +void window_staff_list_scrollgetsize() +{ + int i, width, height, spriteIndex; rct_peep *peep; rct_window *w; @@ -368,8 +369,8 @@ void window_staff_list_scrollgetsize() { window_invalidate(w); } - int scrollHeight = staffCount * 10; - int i = scrollHeight - window_staff_list_widgets[WIDX_STAFF_LIST_LIST].bottom + window_staff_list_widgets[WIDX_STAFF_LIST_LIST].top + 21; + height = staffCount * 10; + i = height - window_staff_list_widgets[WIDX_STAFF_LIST_LIST].bottom + window_staff_list_widgets[WIDX_STAFF_LIST_LIST].top + 21; if (i < 0) i = 0; if (i < w->scrolls[0].v_top) { @@ -377,17 +378,8 @@ void window_staff_list_scrollgetsize() { window_invalidate(w); } - #ifdef _MSC_VER - __asm mov ecx, 420 - #else - __asm__("mov ecx, 420 "); - #endif - - #ifdef _MSC_VER - __asm mov edx, scrollHeight - #else - __asm__("mov edx, %[scrollHeight] " : [scrollHeight] "+m" (scrollHeight)); - #endif + width = 420; + window_scrollsize_set_registers(width, height); } /** diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index 7c8a9000d2..90f94b4c04 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -192,12 +192,13 @@ static void window_scenarioselect_mousedown(int widgetIndex, rct_window*w, rct_w static void window_scenarioselect_scrollgetsize() { - int i, height; + int i, width, height; rct_window *w; rct_scenario_basic *scenario; window_get_register(w); + width = 0; height = 0; for (i = 0; i < gScenarioListCount; i++) { scenario = &gScenarioList[i]; @@ -207,18 +208,7 @@ static void window_scenarioselect_scrollgetsize() height += 24; } - #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 - + window_scrollsize_set_registers(width, height); } /* rct2: 0x6780FE */ diff --git a/src/world/park.c b/src/world/park.c index d487006ad6..2dcdcb164a 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -435,7 +435,7 @@ static int park_calculate_guest_generation_probability() // Reward or penalties for park awards for (i = 0; i < MAX_AWARDS; i++) { - rct_award *award = &RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award)[i]; + rct_award *award = &gCurrentAwards[i]; if (award->time == 0) continue;