diff --git a/src/addresses.h b/src/addresses.h index c59bb061a4..347adaccfd 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -214,6 +214,8 @@ #define RCT2_ADDRESS_MEM_TOTAL_PAGEFILE 0x01423B60 #define RCT2_ADDRESS_MEM_TOTAL_VIRTUAL 0x01423B64 +#define RCT2_ADDRESS_EXPANSION_FLAGS 0x009AB4C0 +#define RCT2_ADDRESS_EXPANSION_NAMES 0x009AACC0 static void RCT2_CALLPROC_EBPSAFE(int address) { diff --git a/src/news_item.c b/src/news_item.c index ed5b19f3e3..71067660fb 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -166,7 +166,7 @@ static int news_item_get_new_history_slot() /** * Get the (x,y,z) coordinates of the subject of a news item. - * If the new item is no longer valid, return 0x8000 in the x-coordinate + * If the new item is no longer valid, return SPRITE_LOCATION_NULL in the x-coordinate * * rct2: 0x0066BA74 */ @@ -180,7 +180,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * case NEWS_ITEM_RIDE: ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[subject]); if (ride->var_050 == 0xFFFF) { - *x = 0x8000; + *x = SPRITE_LOCATION_NULL; break; } { @@ -200,17 +200,17 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *x = sprite->unknown.x; *y = sprite->unknown.y; *z = sprite->unknown.z; - if (*x != 0x8000) + if (*x != SPRITE_LOCATION_NULL) break; if (sprite->peep.state != 3 && sprite->peep.state != 7) { - *x = 0x8000; + *x = SPRITE_LOCATION_NULL; break; } ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[sprite->peep.current_ride]); if (ride->var_1D0 & 1) { - *x = 0x8000; + *x = SPRITE_LOCATION_NULL; break; } @@ -239,7 +239,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * } break; default: - *x = 0x8000; + *x = SPRITE_LOCATION_NULL; break; } } diff --git a/src/sprite.h b/src/sprite.h index b81ea25dd0..eea99b11b3 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -23,7 +23,8 @@ #include "rct2.h" -#define SPRITE_INDEX_NULL 0xFFFF +#define SPRITE_INDEX_NULL 0xFFFF +#define SPRITE_LOCATION_NULL 0x8000 #include "peep.h" diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index c161165956..d24152414d 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -23,6 +23,7 @@ #include "news_item.h" #include "park.h" #include "peep.h" +#include "sprite.h" #include "sprites.h" #include "strings.h" #include "widget.h" @@ -184,7 +185,7 @@ static void window_game_bottom_toolbar_mouseup() news_item_get_subject_location(newsItem->type, subject, &x, &y, &z); - if (x == 0x8000) + if (x == SPRITE_LOCATION_NULL) break; if ((mainWindow = window_get_main()) != NULL) @@ -284,7 +285,7 @@ static void window_game_bottom_toolbar_invalidate() int subject = newsItem->assoc; news_item_get_subject_location(newsItem->type, subject, &x, &y, &z); - if (x == 0x8000) + if (x == SPRITE_LOCATION_NULL) w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE); if (!(((char*)0x0097BE7C)[newsItem->type] & 2)) { diff --git a/src/window_park.c b/src/window_park.c index 84550d2026..5decd55290 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -801,7 +801,7 @@ static void window_park_entrance_toolupdate() RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); RCT2_GLOBAL(0x009DE58A, uint16) &= 0xFFFE; screen_pos_to_map_pos(&x, &y); - if (x != 0x8000) { + if (x != SPRITE_LOCATION_NULL) { RCT2_GLOBAL(0x009DE58A, uint16) |= 1; RCT2_GLOBAL(0x009DE594, uint16) = 4; RCT2_GLOBAL(0x009DE58C, uint16) = x; @@ -998,7 +998,7 @@ static void window_park_init_viewport(rct_window *w) return; for (i = 0; i < 4; i++) { - if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != 0x8000) { + if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) { x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] + 16; y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] + 16; z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, uint16)[i] + 32; diff --git a/src/window_title_exit.c b/src/window_title_exit.c index bcfe070da5..f96943db03 100644 --- a/src/window_title_exit.c +++ b/src/window_title_exit.c @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Ben Pye * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -29,6 +29,41 @@ static rct_widget window_title_exit_widgets[] = { { WIDGETS_END }, }; +static void window_title_exit_emptysub() {} +static void window_title_exit_paint(); +static void window_title_exit_mouseup(); + +static uint32 window_title_exit_events[] = { + window_title_exit_emptysub, + window_title_exit_mouseup, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_emptysub, + window_title_exit_paint, + window_title_exit_emptysub +}; + /** * Creates the window containing the exit button on the title screen. * rct2: 0x0066B624 (part of 0x0066B3E8) @@ -40,7 +75,7 @@ void window_title_exit_open() window = window_create( RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 40, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 64, 40, 64, - 0x0097BEFC, + window_title_exit_events, WC_TITLE_EXIT, WF_STICK_TO_FRONT ); @@ -52,3 +87,37 @@ void window_title_exit_open() window->colours[1] = 140; window->colours[2] = 140; } + +/** +* +* rct2: 0x0066B83C +*/ +static void window_title_exit_mouseup() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + if (RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, int) != 0) + return; + + if (widgetIndex == 0) + RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, 0, 5, 2, 0); +} + +/** +* +* rct2: 0x0066B836 +*/ +static void window_title_exit_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); +} \ No newline at end of file diff --git a/src/window_title_logo.c b/src/window_title_logo.c index 2fde8c1fc6..a81ec804b1 100644 --- a/src/window_title_logo.c +++ b/src/window_title_logo.c @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Ben Pye * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -20,6 +20,7 @@ #include "addresses.h" #include "strings.h" +#include "sprites.h" #include "widget.h" #include "window.h" @@ -28,6 +29,40 @@ static rct_widget window_title_logo_widgets[] = { { WIDGETS_END }, }; +static void window_title_logo_emptysub() {} +static void window_title_logo_paint(); + +static uint32 window_title_logo_events[] = { + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_emptysub, + window_title_logo_paint, + window_title_logo_emptysub +}; + /** * Creates the window containing the logo and the expansion packs on the title screen. * rct2: 0x0066B679 (part of 0x0066B3E8) @@ -40,11 +75,11 @@ void window_title_logo_open() // Count number of expansion packs packs = 0; for (i = 0; i < 16; i++) - if (RCT2_GLOBAL(0x009AB4C0, uint16) & (1 << i)) + if (RCT2_GLOBAL(RCT2_ADDRESS_EXPANSION_FLAGS, uint16) & (1 << i)) packs++; // Create the window - window = window_create(0, 0, 200, 106 + (10 * packs), 0x0097BF6C, WC_TITLE_LOGO, WF_STICK_TO_FRONT); + window = window_create(0, 0, 200, 106 + (10 * packs), window_title_logo_events, WC_TITLE_LOGO, WF_STICK_TO_FRONT); window->widgets = 0x009A9658; // mouse move bug in original game, keep this address and no crash happens window_init_scroll_widgets(window); window->flags |= 16; @@ -52,3 +87,57 @@ void window_title_logo_open() window->colours[1] = 129; window->colours[2] = 129; } + +/** +* +* rct2: 0x0066B872 +*/ +static void window_title_logo_paint() +{ + int packs, x, y, i; + char *buffer, *names; + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + gfx_draw_sprite(dpi, SPR_MENU_LOGO, w->x, w->y); + + x = 0; + y = 105; + + packs = RCT2_GLOBAL(RCT2_ADDRESS_EXPANSION_FLAGS, uint16); + names = RCT2_ADDRESS(RCT2_ADDRESS_EXPANSION_NAMES, char); + + buffer = (char*) 0x0141ED68; + + while (packs != 0) { + if (packs & 1) { + // Prefix for expansion name + buffer[0] = '\n'; + buffer[1] = '\v'; + buffer[2] = FORMAT_YELLOW; // Colour of the text + buffer[3] = '+'; + buffer[4] = ' '; + + i = 0; + + // Copies the expansion name to the buffer, offset by 5 + do { + buffer[5 + i] = names[i]; + i++; + } while (names[i - 1] != 0); + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint32) = 0; + + gfx_draw_string(dpi, buffer, 0, x, y); + + y += 10; + } + + packs = packs >> 1; + + names += 128; + } +} \ No newline at end of file