From 7811497e8c4cf4a280eb3a47cdee772647dc2d64 Mon Sep 17 00:00:00 2001 From: anyc Date: Fri, 23 May 2014 11:30:19 +0200 Subject: [PATCH 1/2] rudimentary save prompt --- src/addresses.h | 1 + src/game.c | 9 ++++----- src/widget.h | 2 +- src/window_save_prompt.c | 43 +++++++++++++++++++++++++++++++++------- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index dce526ea9a..a38e57f6da 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -42,6 +42,7 @@ #define RCT2_ADDRESS_RIDE_PROPERTIES 0x00997C9D #define RCT2_ADDRESS_LAND_TOOL_SIZE 0x009A9800 +#define RCT2_ADDRESS_SAVE_PROMPT_MODE 0x009A9802 #define RCT2_ADDRESS_SCENARIO_LIST 0x009A9FF4 #define RCT2_ADDRESS_NUM_SCENARIOS 0x009AA008 diff --git a/src/game.c b/src/game.c index 945d1f7dc9..40698e4560 100644 --- a/src/game.c +++ b/src/game.c @@ -1361,13 +1361,12 @@ static void game_load_or_quit() __asm__ ( "mov %[input_di], di " : [input_di] "+m" (input_di) ); #endif - if (!(input_bl & 1)) return; // 0; - + switch (input_dl) { case 0: - RCT2_GLOBAL(0x009A9802, uint16) = input_di; + RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) = input_di; window_save_prompt_open(); break; case 1: @@ -1603,14 +1602,14 @@ static void rct2_exit() */ void game_load_or_quit_no_save_prompt() { - if (RCT2_GLOBAL(0x009A9802, uint16) < 1) { + if (RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) < 1) { game_do_command(0, 1, 0, 1, 5, 0, 0); tool_cancel(); if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) load_landscape(); else load_game(); - } else if (RCT2_GLOBAL(0x009A9802, uint16) == 1) { + } else if (RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) == 1) { game_do_command(0, 1, 0, 1, 5, 0, 0); if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 5)) { RCT2_CALLPROC_EBPSAFE(0x0040705E); diff --git a/src/widget.h b/src/widget.h index 25215d09d9..310e0877c9 100644 --- a/src/widget.h +++ b/src/widget.h @@ -36,7 +36,7 @@ typedef enum { WWT_FLATBTN = 9, WWT_DROPDOWN_BUTTON = 10, WWT_11, - WWT_12, + WWT_12, // looks like a normal label to me WWT_13, WWT_14, WWT_SPINNER = 15, diff --git a/src/window_save_prompt.c b/src/window_save_prompt.c index b9ca33e570..d2b1796be9 100644 --- a/src/window_save_prompt.c +++ b/src/window_save_prompt.c @@ -32,7 +32,7 @@ enum WINDOW_SAVE_PROMPT_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, WIDX_CLOSE, - WIDX_3, + WIDX_LABEL, WIDX_SAVE, WIDX_DONT_SAVE, WIDX_CANCEL @@ -42,10 +42,10 @@ static rct_widget window_save_prompt_widgets[] = { { WWT_FRAME, 0, 0, 259, 0, 49, -1, STR_NONE }, // panel / background { WWT_CAPTION, 0, 1, 258, 1, 14, 0, STR_WINDOW_TITLE_TIP }, // title bar { WWT_CLOSEBOX, 0, 247, 257, 2, 13, 824, STR_CLOSE_WINDOW_TIP }, // close x button - { WWT_12, 0, 2, 257, 19, 30, 0, STR_NONE }, // - { WWT_DROPDOWN_BUTTON, 0, 8, 85, 35, 46, STR_SAVE_PROMPT_SAVE, STR_NONE }, // save - { WWT_DROPDOWN_BUTTON, 0, 91, 168, 35, 46, STR_SAVE_PROMPT_DONT_SAVE, STR_NONE }, // don't save - { WWT_DROPDOWN_BUTTON, 0, 174, 251, 35, 46, STR_SAVE_PROMPT_CANCEL, STR_NONE }, // cancel + { WWT_12, 0, 2, 257, 19, 30, 0, STR_NONE }, // question/label + { WWT_DROPDOWN_BUTTON, 0, 8, 85, 35, 46, 0, STR_SAVE_PROMPT_SAVE }, // save + { WWT_DROPDOWN_BUTTON, 0, 91, 168, 35, 46, 0, STR_SAVE_PROMPT_DONT_SAVE },// don't save + { WWT_DROPDOWN_BUTTON, 0, 174, 251, 35, 46, 0, STR_SAVE_PROMPT_CANCEL }, // cancel { WIDGETS_END }, }; @@ -123,13 +123,14 @@ void window_save_prompt_open() window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0); } - stringId = RCT2_GLOBAL(0x009A9802, uint16) + STR_LOAD_GAME; + stringId = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) + STR_LOAD_GAME; if (stringId == STR_LOAD_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) stringId = STR_LOAD_LANDSCAPE; if (stringId == STR_QUIT_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) stringId = STR_QUIT_SCENARIO_EDITOR; window_save_prompt_widgets[WIDX_TITLE].image = stringId; - window_save_prompt_widgets[WIDX_3].image = RCT2_GLOBAL(0x009A9802, uint16) + STR_SAVE_BEFORE_LOADING; + window_save_prompt_widgets[WIDX_LABEL].image = + RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) + STR_SAVE_BEFORE_LOADING; if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) { game_load_or_quit_no_save_prompt(); @@ -189,6 +190,20 @@ static void window_save_prompt_mouseup() // TODO + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + window_save_prompt_close(); + break; + case WIDX_SAVE: + break; + case WIDX_DONT_SAVE: + break; + case WIDX_CANCEL: + window_close(w); + window_save_prompt_close(); + break; + } } static void window_save_prompt_paint() @@ -210,4 +225,18 @@ static void window_save_prompt_paint() window_draw_widgets(w, dpi); + + gfx_draw_string_centred(dpi, window_save_prompt_widgets[WIDX_LABEL].image, + w->x + window_save_prompt_widgets[WIDX_LABEL].left + 125, + w->y + window_save_prompt_widgets[WIDX_LABEL].top + 1, 2, w); + + gfx_draw_string_centred(dpi, STR_SAVE_PROMPT_SAVE, + w->x + window_save_prompt_widgets[WIDX_SAVE].left + 38, + w->y + window_save_prompt_widgets[WIDX_SAVE].top + 1, 2, w); + gfx_draw_string_centred(dpi, STR_SAVE_PROMPT_DONT_SAVE, + w->x + window_save_prompt_widgets[WIDX_DONT_SAVE].left + 38, + w->y + window_save_prompt_widgets[WIDX_DONT_SAVE].top + 1, 2, w); + gfx_draw_string_centred(dpi, STR_SAVE_PROMPT_CANCEL, + w->x + window_save_prompt_widgets[WIDX_CANCEL].left + 38, + w->y + window_save_prompt_widgets[WIDX_CANCEL].top + 1, 2, w); } \ No newline at end of file From 03db2f61067101db7c8356fb1101db620a22c63b Mon Sep 17 00:00:00 2001 From: anyc Date: Fri, 23 May 2014 14:29:09 +0200 Subject: [PATCH 2/2] Readme update and small fix for mingw --- readme.md | 12 ++++++++++++ src/rct2.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/readme.md b/readme.md index 22c700cd5f..9feda974fe 100644 --- a/readme.md +++ b/readme.md @@ -50,12 +50,20 @@ The aim is to completely decompile RollerCoaster Tycoon 2 into C so that cross-p # 2 Building the source code ## 2.1 Prerequisites +### Windows: - Windows XP / Vista / 7 / 8 - RollerCoaster Tycoon 2 - Visual Studio 2013 (paid) / [Visual Studio Express 2013](http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop) (free) - [SDL2 development library for Visual C++](http://www.libsdl.org/release/SDL2-devel-2.0.3-VC.zip). +### Linux: +- [MinGW-w64](mingw-w64.sourceforge.net) +- [Wine](http://www.winehq.org/) +- RollerCoaster Tycoon 2 +- libsdl2 compiled with MinGW-w64 + ## 2.2 Compiling and running +### Windows: 1. Check out the repository. This can be done using [GitHub Windows](https://windows.github.com/) or [other tools](https://help.github.com/articles/which-remote-url-should-i-use). 2. Download the [SDL2 development library for Visual C++]((http://www.libsdl.org/release/SDL2-devel-2.0.3-VC.zip)) and copy it to a new directory called "sdl" in the repository. This directory should contain "include". The path should resemble ```\OpenRCT2\sdl\include\```. 3. Open the solution in the projects directory (**openrct2.vcxproj**) with Visual C++. @@ -64,6 +72,10 @@ The aim is to completely decompile RollerCoaster Tycoon 2 into C so that cross-p 6. When OpenRCT2 is run for the first time, it creates a settings file in `My Documents/OpenRCT2`. If it can't find the original installation of RCT2, you will need to edit `config.ini` in that folder and change the value of `game_path` to where RCT2 is installed. 7. If the game crashes, you may need to press the red, square Stop button along the top of VS Express to stop the program. +### Linux: +As the easiest approach depends on your distribution, please take a look at the [wiki](https://github.com/IntelOrca/OpenRCT2/wiki). + + # 3 Contributing ## 3.1 Decompiling diff --git a/src/rct2.c b/src/rct2.c index 52b4f666ff..ea336729fc 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -22,7 +22,9 @@ #include #include +#ifdef _MSC_VER #include +#endif #include #include #include