From f384b31b656803b40b7b0ae10893aab1330ee967 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 11 Sep 2014 17:44:23 +0200 Subject: [PATCH 1/4] Initial work on music credits. --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/window.h | 1 + src/window_about.c | 2 +- src/window_credits.c | 93 +++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/window_credits.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 00a5fd1e84..2e207d3cd3 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -140,6 +140,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 525392db46..4e10931727 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -395,6 +395,9 @@ Windows + + Windows + diff --git a/src/window.h b/src/window.h index 0270e5cdc3..bda084e2a5 100644 --- a/src/window.h +++ b/src/window.h @@ -464,6 +464,7 @@ void window_banner_open(); void window_cheats_open(); void window_research_open(); void window_scenery_open(); +void window_music_credits_open(); void window_guest_list_init_vars_a(); void window_guest_list_init_vars_b(); diff --git a/src/window_about.c b/src/window_about.c index 8cf3418380..381e8023ac 100644 --- a/src/window_about.c +++ b/src/window_about.c @@ -125,7 +125,7 @@ static void window_about_mouseup() window_close(w); break; case WIDX_MUSIC_CREDITS: - RCT2_CALLPROC_EBPSAFE(0x0066D55B); + window_music_credits_open(); break; case WIDX_PUBLISHER_CREDITS: RCT2_CALLPROC_EBPSAFE(0x0066D4EC); diff --git a/src/window_credits.c b/src/window_credits.c new file mode 100644 index 0000000000..6de7f01d6f --- /dev/null +++ b/src/window_credits.c @@ -0,0 +1,93 @@ +/***************************************************************************** +* Copyright (c) 2014 Ted John +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include +#include +#include "addresses.h" +#include "string_ids.h" +#include "sprites.h" +#include "widget.h" +#include "window.h" + +static void window_music_credits_emptysub() { } + +static void* window_music_credits_events[] = { + window_music_credits_emptysub, + (void*)0x0066DB2C, // onmouseup + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + (void*)0x0066DB37, //onscrollgetsize + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + window_music_credits_emptysub, + (void*)0x0066D7B9, // paint + (void*)0x0066D7BF //on scroll paint +}; + +/** +* +* rct2: 0x0066D55B +*/ +void window_music_credits_open() +{ + rct_window* window; + + // Check if window is already open + window = window_bring_to_front_by_id(WC_PUBLISHER_CREDITS, 0); + if (window != NULL) + return; + + window = window_create( + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 255, + max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 157), + 510, + 314, + (uint32*)window_music_credits_events, + WC_PUBLISHER_CREDITS, + 0 + ); + + window->widgets = (rct_widget*) 0x009A9704; + window->enabled_widgets = 0x4; + + window_init_scroll_widgets(window); + window->colours[0] = 7; + window->colours[1] = 7; + window->colours[2] = 7; + +} \ No newline at end of file From 361e33d3dda5eeed2c422174954b1b34b07cdf98 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 11 Sep 2014 18:48:40 +0200 Subject: [PATCH 2/4] Finished decompiling window_music_credits. --- src/window_credits.c | 120 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 6 deletions(-) diff --git a/src/window_credits.c b/src/window_credits.c index 6de7f01d6f..1a839b74e6 100644 --- a/src/window_credits.c +++ b/src/window_credits.c @@ -26,11 +26,29 @@ #include "widget.h" #include "window.h" +enum WINDOW_MUSIC_CREDITS_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE +}; + +rct_widget window_music_credits_widgets[] = { + { WWT_FRAME, 0, 0, 509, 0, 313, 0x0FFFFFFFF, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 508, 1, 14, STR_MUSIC_ACKNOWLEDGEMENTS, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 497, 507, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button + { WWT_SCROLL, 0, 4, 505, 18, 309, 2, STR_NONE }, // scroll + { WIDGETS_END }, +}; + static void window_music_credits_emptysub() { } +static void window_music_credits_mouseup(); +static void window_music_credits_scrollgetsize(); +static void window_music_credits_paint(); +static void window_music_credits_scrollpaint(); static void* window_music_credits_events[] = { window_music_credits_emptysub, - (void*)0x0066DB2C, // onmouseup + window_music_credits_mouseup, window_music_credits_emptysub, window_music_credits_emptysub, window_music_credits_emptysub, @@ -44,7 +62,7 @@ static void* window_music_credits_events[] = { window_music_credits_emptysub, window_music_credits_emptysub, window_music_credits_emptysub, - (void*)0x0066DB37, //onscrollgetsize + window_music_credits_scrollgetsize, window_music_credits_emptysub, window_music_credits_emptysub, window_music_credits_emptysub, @@ -55,8 +73,8 @@ static void* window_music_credits_events[] = { window_music_credits_emptysub, window_music_credits_emptysub, window_music_credits_emptysub, - (void*)0x0066D7B9, // paint - (void*)0x0066D7BF //on scroll paint + window_music_credits_paint, + window_music_credits_scrollpaint }; /** @@ -82,12 +100,102 @@ void window_music_credits_open() 0 ); - window->widgets = (rct_widget*) 0x009A9704; - window->enabled_widgets = 0x4; + window->widgets = window_music_credits_widgets; + window->enabled_widgets = 1 << WIDX_CLOSE; window_init_scroll_widgets(window); window->colours[0] = 7; window->colours[1] = 7; window->colours[2] = 7; +} + +/** +* +* rct2: 0x0066DB2C +*/ +static void window_music_credits_mouseup() +{ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + } +} + +/** + * + * rct2: 0x0066DB37 + */ +static void window_music_credits_scrollgetsize() +{ + int y = 560; + + #ifdef _MSC_VER + __asm mov edx, y + #else + __asm__("mov edx, %[y] " : [y] "+m" (y)); + #endif +} + +/** +* +* rct2: 0x0066D7B9 +*/ +static void window_music_credits_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); +} + +/** + * + * rct2: 0x0066D7BF + */ +static void window_music_credits_scrollpaint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + window_paint_get_registers(w, dpi); + + int x = 245; + + int y = 2; + int string = 0xB30; + for (int i = 0; i < 12; i++) { + gfx_draw_string_centred(dpi, string, x, y, 0, 0); + y += 10; + if (i == 10) { // Add 4 more space before "Original recordings ...". + y += 4; + } + string += 1; + } + + // Draw the separator + y += 5; + gfx_fill_rect_inset(dpi, 4, y, 484, y+1, w->colours[1], 0x20); + y += 11; + + for (int i = 0; i < 31; i++) { + if (i == 21) { // Move special courtesy to below Hypothermia. + gfx_draw_string_centred(dpi, string + 4, x, y, 0, 0); + y += 10; + continue; + } else if (i == 25) { // Remove special courtesy and blank line. + string += 2; + } + gfx_draw_string_centred(dpi, string, x, y, 0, 0); + y += 10; + string += 1; + } + } \ No newline at end of file From e0cb2e6abf05ba2f44bde7628730dfe9a2e1e078 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 11 Sep 2014 18:50:37 +0200 Subject: [PATCH 3/4] Fixed padding for widgets. --- src/window_credits.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/window_credits.c b/src/window_credits.c index 1a839b74e6..8dd85fcd17 100644 --- a/src/window_credits.c +++ b/src/window_credits.c @@ -33,11 +33,11 @@ enum WINDOW_MUSIC_CREDITS_WIDGET_IDX { }; rct_widget window_music_credits_widgets[] = { - { WWT_FRAME, 0, 0, 509, 0, 313, 0x0FFFFFFFF, STR_NONE }, // panel / background - { WWT_CAPTION, 0, 1, 508, 1, 14, STR_MUSIC_ACKNOWLEDGEMENTS, STR_WINDOW_TITLE_TIP }, // title bar - { WWT_CLOSEBOX, 0, 497, 507, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button - { WWT_SCROLL, 0, 4, 505, 18, 309, 2, STR_NONE }, // scroll - { WIDGETS_END }, + { WWT_FRAME, 0, 0, 509, 0, 313, 0x0FFFFFFFF, STR_NONE }, // panel / background + { WWT_CAPTION, 0, 1, 508, 1, 14, STR_MUSIC_ACKNOWLEDGEMENTS, STR_WINDOW_TITLE_TIP }, // title bar + { WWT_CLOSEBOX, 0, 497, 507, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button + { WWT_SCROLL, 0, 4, 505, 18, 309, 2, STR_NONE }, // scroll + { WIDGETS_END }, }; static void window_music_credits_emptysub() { } From ac7c204284682f342f4b142a8ad99dc264cff1b9 Mon Sep 17 00:00:00 2001 From: hexdec Date: Thu, 11 Sep 2014 18:55:19 +0200 Subject: [PATCH 4/4] Changed place on WC_MUSIC_CREDITS and WC_PUBLISHER_CREDITS. --- src/window.h | 4 ++-- src/window_credits.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/window.h b/src/window.h index bda084e2a5..c342cb8832 100644 --- a/src/window.h +++ b/src/window.h @@ -330,8 +330,8 @@ enum { WC_TOOLTIP = 5, WC_DROPDOWN = 6, WC_ABOUT = 8, - WC_MUSIC_CREDITS = 9, - WC_PUBLISHER_CREDITS = 10, + WC_PUBLISHER_CREDITS = 9, + WC_MUSIC_CREDITS = 10, WC_ERROR = 11, WC_RIDE = 12, WC_RIDE_CONSTRUCTION = 13, diff --git a/src/window_credits.c b/src/window_credits.c index 8dd85fcd17..9c25b28eb0 100644 --- a/src/window_credits.c +++ b/src/window_credits.c @@ -86,7 +86,7 @@ void window_music_credits_open() rct_window* window; // Check if window is already open - window = window_bring_to_front_by_id(WC_PUBLISHER_CREDITS, 0); + window = window_bring_to_front_by_id(WC_MUSIC_CREDITS, 0); if (window != NULL) return; @@ -96,7 +96,7 @@ void window_music_credits_open() 510, 314, (uint32*)window_music_credits_events, - WC_PUBLISHER_CREDITS, + WC_MUSIC_CREDITS, 0 );