From 2afb4e12eb542e0aedd42059e7a4e4b34b615854 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Fri, 25 Apr 2014 18:25:34 +0100 Subject: [PATCH] add screenshot and error window base functions --- projects/openrct2.vcxproj | 4 +++ projects/openrct2.vcxproj.filters | 12 +++++++ src/addresses.h | 1 + src/game.c | 25 ++++++++++--- src/screenshot.c | 60 +++++++++++++++++++++++++++++++ src/screenshot.h | 27 ++++++++++++++ src/strings.h | 7 ++++ src/window_error.c | 31 ++++++++++++++++ src/window_error.h | 26 ++++++++++++++ src/window_tooltip.c | 36 +++++++++---------- 10 files changed, 207 insertions(+), 22 deletions(-) create mode 100644 src/screenshot.c create mode 100644 src/screenshot.h create mode 100644 src/window_error.c create mode 100644 src/window_error.h diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index fafab8457f..f42dbdeb6d 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -34,6 +34,7 @@ + @@ -45,6 +46,7 @@ + @@ -67,6 +69,7 @@ + @@ -77,6 +80,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index d3571d737f..80c4dd0124 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -114,6 +114,12 @@ Header Files + + Header Files + + + Header Files + @@ -239,6 +245,12 @@ Windows + + Windows + + + Source Files + diff --git a/src/addresses.h b/src/addresses.h index 01f86ae716..50648f44d7 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -103,6 +103,7 @@ #define RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX 0x009DE560 #define RCT2_ADDRESS_SCREEN_FLAGS 0x009DEA68 +#define RCT2_ADDRESS_SCREENSHOT_COUNTDOWN 0x009DEA6D #define RCT2_ADDRESS_PLACE_OBJECT_MODIFIER 0x009DEA70 #define RCT2_ADDRESS_ON_TUTORIAL 0x009DEA71 diff --git a/src/game.c b/src/game.c index 0182f3ed09..43faabb0d7 100644 --- a/src/game.c +++ b/src/game.c @@ -26,11 +26,15 @@ #include "news_item.h" #include "osinterface.h" #include "peep.h" +#include "screenshot.h" +#include "strings.h" #include "widget.h" #include "window.h" +#include "window_error.h" #include "window_tooltip.h" void game_handle_input(); +void game_handle_keyboard_input(); /** * @@ -50,6 +54,8 @@ void game_update() // 0x006E3AEC // screen_game_process_mouse_input(); // RCT2_CALLPROC_EBPSAFE(0x006E3AEC); // screen_game_process_keyboard_input(); + screenshot_check(); + game_handle_keyboard_input(); // do game logic eax = RCT2_GLOBAL(0x009DE588, uint16) / 31; @@ -119,7 +125,7 @@ void game_update() void game_logic_update() { - short _bx, _dx; + short stringId, _dx; RCT2_GLOBAL(0x013628F4, sint32)++; RCT2_GLOBAL(0x00F663AC, sint32)++; @@ -151,15 +157,15 @@ void game_logic_update() window_dispatch_update_all(); if (RCT2_GLOBAL(0x009AC31B, uint8) != 0) { - _bx = 3010; + stringId = STR_UNABLE_TO_LOAD_FILE; _dx = RCT2_GLOBAL(0x009AC31C, uint16); if (RCT2_GLOBAL(0x009AC31B, uint8) != 254) { - _bx = RCT2_GLOBAL(0x009AC31C, uint16); + stringId = RCT2_GLOBAL(0x009AC31C, uint16); _dx = 0xFFFF; } RCT2_GLOBAL(0x009AC31B, uint8) = 0; - RCT2_CALLPROC_X(0x0066792F, 0, _bx, 0, _dx, 0, 0, 0); + window_error_open(stringId, _dx); } } @@ -753,4 +759,15 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, w, widget, 0); break; } +} + + + +/** + * + * rct2: 0x006E3B43 + */ +void game_handle_keyboard_input() +{ + RCT2_CALLPROC_EBPSAFE(0x006E3B43); } \ No newline at end of file diff --git a/src/screenshot.c b/src/screenshot.c new file mode 100644 index 0000000000..a6cd27d281 --- /dev/null +++ b/src/screenshot.c @@ -0,0 +1,60 @@ +/***************************************************************************** + * 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 "addresses.h" +#include "rct2.h" +#include "screenshot.h" +#include "strings.h" +#include "window_error.h" + +/** + * + * rct2: 0x006E3AEC + */ +void screenshot_check() +{ + int screenshotIndex; + + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, uint8) != 0) { + RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, uint8)--; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, uint8) == 0) { + RCT2_CALLPROC_EBPSAFE(0x00684218); + screenshotIndex = screenshot_dump(); + RCT2_GLOBAL(0x013CE952, uint16) = STR_SCR_BMP; + RCT2_GLOBAL(0x013CE952 + 2, uint16) = screenshotIndex; + RCT2_GLOBAL(0x009A8C29, uint8) |= 1; + + window_error_open(screenshotIndex == -1 ? STR_SCREENSHOT_FAILED : STR_SCREENSHOT_SAVED_AS, -1); + RCT2_GLOBAL(0x009A8C29, uint8) &= ~1; + RCT2_CALLPROC_EBPSAFE(0x006843DC); + } + } +} + +/** + * + * rct2: 0x00683D20 + */ +int screenshot_dump() +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + RCT2_CALLFUNC_X(0x00683D20, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + return eax & 0xFFFF; +} \ No newline at end of file diff --git a/src/screenshot.h b/src/screenshot.h new file mode 100644 index 0000000000..2515ebe79d --- /dev/null +++ b/src/screenshot.h @@ -0,0 +1,27 @@ +/***************************************************************************** + * 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 . + *****************************************************************************/ + +#ifndef _SCREENSHOT_H_ +#define _SCREENSHOT_H_ + +void screenshot_check(); +int screenshot_dump(); + +#endif \ No newline at end of file diff --git a/src/strings.h b/src/strings.h index 703375942e..3743e75d2a 100644 --- a/src/strings.h +++ b/src/strings.h @@ -144,6 +144,11 @@ enum { STR_PAUSE_GAME_TIP = 833, STR_DISC_AND_GAME_OPTIONS_TIP = 834, + STR_SCR_BMP = 890, + STR_SCREENSHOT = 891, + STR_SCREENSHOT_SAVED_AS = 892, + STR_SCREENSHOT_FAILED = 893, + STR_VIEW_OPTIONS_TIP = 937, STR_ADJUST_LAND_TIP = 938, @@ -352,6 +357,8 @@ enum { STR_LICENCE_AGREEMENT_NOTICE_1 = 2969, STR_LICENCE_AGREEMENT_NOTICE_2 = 2970, + STR_UNABLE_TO_LOAD_FILE = 3010, + STR_BEGINNER_PARKS = 3064, STR_CHALLENGING_PARKS = STR_BEGINNER_PARKS + 1, STR_EXPERT_PARKS = STR_BEGINNER_PARKS + 2, diff --git a/src/window_error.c b/src/window_error.c new file mode 100644 index 0000000000..3a31436928 --- /dev/null +++ b/src/window_error.c @@ -0,0 +1,31 @@ +/***************************************************************************** + * 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 "addresses.h" +#include "window_error.h" + +/** + * + * rct2: 0x0066792F + */ +void window_error_open(int stringId, int edx) +{ + RCT2_CALLPROC_X(0x0066792F, 0, stringId, 0, edx, 0, 0, 0); +} \ No newline at end of file diff --git a/src/window_error.h b/src/window_error.h new file mode 100644 index 0000000000..780dccad1a --- /dev/null +++ b/src/window_error.h @@ -0,0 +1,26 @@ +/***************************************************************************** + * 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 . + *****************************************************************************/ + +#ifndef _WINDOW_ERROR_H_ +#define _WINDOW_ERROR_H_ + +void window_error_open(int stringId, int edx); + +#endif \ No newline at end of file diff --git a/src/window_tooltip.c b/src/window_tooltip.c index 00127affb3..bc13d6fbd1 100644 --- a/src/window_tooltip.c +++ b/src/window_tooltip.c @@ -1,22 +1,22 @@ /***************************************************************************** -* 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 . -*****************************************************************************/ + * 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 "addresses.h"