From 0f6dd517365894c13eb240fca1afa750fdfa91ae Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 7 Feb 2015 17:40:20 +0000 Subject: [PATCH] Added load_palette. Labelled offset for paused and palette effect frame. Fixed fast moving water. --- src/addresses.h | 7 +++++++ src/drawing/drawing.c | 29 ++++++++++++++++++++++++++++- src/drawing/drawing.h | 1 + src/editor.c | 12 ++++++------ src/game.c | 12 ++++++------ src/interface/window.c | 2 +- src/intro.c | 2 +- src/rct2.c | 12 ++++-------- src/scenario.c | 2 +- src/title.c | 6 +++--- src/windows/game_bottom_toolbar.c | 2 +- src/windows/game_top_toolbar.c | 2 +- src/windows/guest.c | 2 +- src/windows/new_ride.c | 2 +- src/windows/ride.c | 2 +- src/windows/ride_construction.c | 12 ++++++------ src/windows/save_prompt.c | 4 ++-- src/windows/track_list.c | 4 ++-- src/windows/track_place.c | 2 +- src/world/map.c | 4 ++-- 20 files changed, 76 insertions(+), 45 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index a0965b6896..ac99cc1d8c 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -170,6 +170,8 @@ #define RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER 0x009DE55E #define RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX 0x009DE560 +#define RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO 0x009DE584 + #define RCT2_ADDRESS_MAP_SELECTION_FLAGS 0x009DE58A #define RCT2_ADDRESS_MAP_SELECTION_A_X 0x009DE58C #define RCT2_ADDRESS_MAP_SELECTION_B_X 0x009DE58E @@ -179,6 +181,11 @@ #define RCT2_ADDRESS_SCREEN_FLAGS 0x009DEA68 #define RCT2_ADDRESS_SCREENSHOT_COUNTDOWN 0x009DEA6D +// Note: not only the zeroth bit can be set to control pause +// When paused by saving track 2nd bit is set +// When paused by save menu 1st bit is set +// When paused by pause button 0th bit is set +#define RCT2_ADDRESS_GAME_PAUSED 0x009DEA6E #define RCT2_ADDRESS_PLACE_OBJECT_MODIFIER 0x009DEA70 #define RCT2_ADDRESS_ON_TUTORIAL 0x009DEA71 diff --git a/src/drawing/drawing.c b/src/drawing/drawing.c index fdd0be4148..ee625ec7fe 100644 --- a/src/drawing/drawing.c +++ b/src/drawing/drawing.c @@ -23,6 +23,7 @@ #include "../localisation/localisation.h" #include "../interface/window.h" #include "../platform/osinterface.h" +#include "../object.h" #include "drawing.h" // HACK These were originally passed back through registers @@ -146,7 +147,33 @@ void gfx_transpose_palette(int pal, unsigned char product) source_pointer += 3; dest_pointer += 4; } - osinterface_update_palette((char*)0x01424680, 10, 236);//Odd would have expected dest_pointer + osinterface_update_palette((char*)0x01424680, 10, 236); +} + +/* rct2: 0x006837E3 */ +void load_palette(){ + uint8* water_chunk = object_entry_groups[OBJECT_TYPE_WATER].chunks[0]; + + uint32 palette = 0x5FC; + + if (water_chunk != (uint8*)-1){ + palette = *((uint32*)(water_chunk + 2)); + } + + rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette]; + int width = g1.width; + int x = g1.x_offset; + uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(0x01424680, uint8)[x * 4]); + uint8* source_pointer = g1.offset; + + for (; width > 0; width--) { + dest_pointer[0] = source_pointer[0]; + dest_pointer[1] = source_pointer[1]; + dest_pointer[2] = source_pointer[2]; + source_pointer += 3; + dest_pointer += 4; + } + osinterface_update_palette((char*)0x01424680, 10, 236); } /** diff --git a/src/drawing/drawing.h b/src/drawing/drawing.h index ab22bc8f7e..bd593ff621 100644 --- a/src/drawing/drawing.h +++ b/src/drawing/drawing.h @@ -75,6 +75,7 @@ void gfx_invalidate_screen(); // palette void gfx_transpose_palette(int pal, unsigned char product); +void load_palette(); // other void gfx_draw_rain(int left, int top, int width, int height, sint32 x_start, sint32 y_start); diff --git a/src/editor.c b/src/editor.c index 35f2583ce8..0e833d7869 100644 --- a/src/editor.c +++ b/src/editor.c @@ -86,7 +86,7 @@ void editor_load() mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; - RCT2_CALLPROC_EBPSAFE(0x006837E3); + load_palette(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; } @@ -195,7 +195,7 @@ void editor_convert_save_to_scenario() RCT2_CALLPROC_EBPSAFE(0x006DFEE4); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; - RCT2_CALLPROC_EBPSAFE(0x006837E3); // (palette related) + load_palette(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; } @@ -232,7 +232,7 @@ void trackdesigner_load() mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; - RCT2_CALLPROC_EBPSAFE(0x006837E3); + load_palette(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; } @@ -269,7 +269,7 @@ void trackmanager_load() mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; - RCT2_CALLPROC_EBPSAFE(0x006837E3); + load_palette(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; } @@ -565,7 +565,7 @@ static void sub_6A2B62() RCT2_CALLPROC_EBPSAFE(0x006DFEE4); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; - RCT2_CALLPROC_EBPSAFE(0x006837E3); // (palette related) + load_palette(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; @@ -951,7 +951,7 @@ static int editor_read_s6(const char *path) RCT2_CALLPROC_EBPSAFE(0x006DFEE4); window_new_ride_init_vars(); RCT2_GLOBAL(0x009DEB7C, uint16) = 0; - RCT2_CALLPROC_EBPSAFE(0x006837E3); // (palette related) + load_palette(); gfx_invalidate_screen(); return 1; diff --git a/src/game.c b/src/game.c index 286081b574..faa657c547 100644 --- a/src/game.c +++ b/src/game.c @@ -126,7 +126,7 @@ void update_palette_effects() q = 2; } } - uint32 j = RCT2_GLOBAL(0x009DE584, uint32); + uint32 j = RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, uint32); j = (((uint16)((~j / 2) * 128) * 15) >> 16); int p = 1533; if (RCT2_GLOBAL(0x009ADAE0, int) != -1) { @@ -165,7 +165,7 @@ void update_palette_effects() vd += 4; } - j = ((uint16)(RCT2_GLOBAL(0x009DE584, uint32) * -960) * 3) >> 16; + j = ((uint16)(RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, uint32) * -960) * 3) >> 16; p = 1539; g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[q + p]; vs = &g1_element.offset[j * 3]; @@ -220,7 +220,7 @@ void game_update() } // Update the game one or more times - if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) { + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0) { for (i = 0; i < numUpdates; i++) { game_logic_update(); start_title_music(); @@ -477,9 +477,9 @@ void game_pause_toggle() if (input_bl & 1) { - RCT2_GLOBAL(0x009DEA6E, uint32) ^= 1; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) ^= 1; window_invalidate_by_class(WC_TOP_TOOLBAR); - if (RCT2_GLOBAL(0x009DEA6E, uint32) & 1) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) & 1) pause_sounds(); else unpause_sounds(); @@ -725,7 +725,7 @@ int game_load_save(const char *path) if (RCT2_GLOBAL(0x0013587C4, uint32) == 0) // this check is not in scenario play sub_69E869(); - RCT2_CALLPROC_EBPSAFE(0x006837E3); // (palette related) + load_palette(); gfx_invalidate_screen(); return 1; } diff --git a/src/interface/window.c b/src/interface/window.c index 37dbd98615..e6de071d20 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1840,7 +1840,7 @@ void sub_6EA73F() { rct_window *w; - if (RCT2_GLOBAL(0x009DEA6E, uint8) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) RCT2_GLOBAL(0x01423604, uint32)++; for (w = RCT2_LAST_WINDOW; w >= g_window_list; w--) { diff --git a/src/intro.c b/src/intro.c index 17f22c2ce0..2ce2c8f7ce 100644 --- a/src/intro.c +++ b/src/intro.c @@ -262,7 +262,7 @@ void intro_update() (*part) = 0; // Change palette - RCT2_CALLPROC_EBPSAFE(0x006837E3); + load_palette(); RCT2_GLOBAL(0x009E2C78, sint32) = 0; gfx_invalidate_screen(); diff --git a/src/rct2.c b/src/rct2.c index aefa510193..4bb25b8888 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -318,16 +318,12 @@ void rct2_update_2() tick = timeGetTime(); - RCT2_GLOBAL(0x009DE588, sint16) = tick2 = tick - RCT2_GLOBAL(0x009DE580, sint32); - if (RCT2_GLOBAL(0x009DE588, sint16) > 500) - RCT2_GLOBAL(0x009DE588, sint16) = 500; + tick2 = tick - RCT2_GLOBAL(0x009DE580, sint32); + RCT2_GLOBAL(0x009DE588, sint16) = tick2 = min(tick2, 500); RCT2_GLOBAL(0x009DE580, sint32) = tick; - if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) - RCT2_GLOBAL(0x009DE584, sint32) += tick2; - - if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) - RCT2_GLOBAL(0x009DE584, sint32) += tick2; + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0) + RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, sint32) += tick2; if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) RCT2_GLOBAL(0x009DE588, sint16) = 31; diff --git a/src/scenario.c b/src/scenario.c index 1535e8f84c..b5ee0a98ef 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -327,7 +327,7 @@ int scenario_load_and_play_from_path(const char *path) RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_18; - RCT2_CALLPROC_EBPSAFE(0x006837E3); // (palette related) + load_palette(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; diff --git a/src/title.c b/src/title.c index ee75bc2cf3..9988f41381 100644 --- a/src/title.c +++ b/src/title.c @@ -92,7 +92,7 @@ void title_load() { log_verbose("loading title"); - if (RCT2_GLOBAL(0x009DEA6E, uint8) & 1) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) & 1) RCT2_CALLPROC_X(0x00667C15, 0, 1, 0, 0, 0, 0, 0);//Game pause toggle RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; @@ -174,7 +174,7 @@ static void title_update_showcase() if (scenario_load(get_file_path(PATH_ID_SIXFLAGS_MAGICMOUNTAIN))) { log_verbose("loaded title scenario"); } else { - RCT2_CALLPROC_EBPSAFE(0x006837E3); + load_palette(); title_create_windows(); } @@ -270,7 +270,7 @@ void title_update() screenshot_check(); title_handle_keyboard_input(); - if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) { + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0) { title_update_showcase(); game_logic_update(); start_title_music();//title_play_music(); diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index 37764ff1e1..aced7487f4 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -443,7 +443,7 @@ static void window_game_bottom_toolbar_draw_park_rating(rct_drawpixelinfo *dpi, bar_width = (factor * 90) / 256; gfx_fill_rect_inset(dpi, x, y + 1, x + 93, y + 9, w->colours[1], 48); - if (!(colour & 0x80000000) || RCT2_GLOBAL(0x009DEA6E, uint8) != 0 || (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint8) & 8)) { + if (!(colour & 0x80000000) || RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 || (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint8) & 8)) { if (bar_width > 2) gfx_fill_rect_inset(dpi, x + 2, y + 2, x + bar_width - 1, y + 8, colour & 0x7FFFFFFF, 0); } diff --git a/src/windows/game_top_toolbar.c b/src/windows/game_top_toolbar.c index 16863fd0b3..d26e22a26c 100644 --- a/src/windows/game_top_toolbar.c +++ b/src/windows/game_top_toolbar.c @@ -461,7 +461,7 @@ static void window_game_top_toolbar_invalidate() // else // w->pressed_widgets &= ~(1 << WIDX_FASTFORWARD); - if (!(RCT2_GLOBAL(0x009DEA6E, uint32) & 1)) + if (!(RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) & 1)) w->pressed_widgets &= ~(1 << WIDX_PAUSE); else w->pressed_widgets |= (1 << WIDX_PAUSE); diff --git a/src/windows/guest.c b/src/windows/guest.c index 0ee942fefc..954f9973ea 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -1376,7 +1376,7 @@ void window_guest_stats_bars_paint(int value, int x, int y, rct_window *w, rct_d int blink_flag = colour & (1 << 0x1F); //0x80000000 colour &= ~(1 << 0x1F); if (!blink_flag || - RCT2_GLOBAL(0x009DEA6E, uint8) != 0 || + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 || (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 8) == 0) { if (value <= 2) diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index e699f4e293..fead4b696a 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -658,7 +658,7 @@ static void window_new_ride_scrollmousedown() window_scrollmouse_get_registers(w, scrollIndex, x, y); - if (RCT2_GLOBAL(0x009DEA6E, uint8) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) return; item = window_new_ride_scroll_get_ride_list_item_at(w, x, y); diff --git a/src/windows/ride.c b/src/windows/ride.c index da1e980a28..e6624fe5ff 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -3191,7 +3191,7 @@ static void window_ride_maintenance_draw_bar(rct_window *w, rct_drawpixelinfo *d gfx_fill_rect_inset(dpi, x, y, x + 149, y + 8, w->colours[1], 0x30); if (unk & (1 << 31)) { unk &= ~(1 << 31); - if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0 && (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 8)) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0 && (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 8)) return; } diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 7863f81f81..be37ef61c9 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -216,12 +216,12 @@ void window_construction_close(){ rct_map_element* map_element = sub_6CAF80(ride_id, &x, &y); if ((int)map_element == -1){ - int eax = RCT2_GLOBAL(0x009DEA6E, uint8); + int eax = RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8); - RCT2_GLOBAL(0x009DEA6E, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = 0; game_do_command(0, 9, 0, ride_id, GAME_COMMAND_7, 0, 0); - RCT2_GLOBAL(0x009DEA6E, uint8) = eax; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = eax; return; } @@ -247,12 +247,12 @@ void window_construction_maze_close(){ rct_ride* ride = GET_RIDE(ride_id); if (ride->overall_view == 0xFFFF){ - int eax = RCT2_GLOBAL(0x009DEA6E, uint8); + int eax = RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8); - RCT2_GLOBAL(0x009DEA6E, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = 0; game_do_command(0, 9, 0, ride_id, GAME_COMMAND_7, 0, 0); - RCT2_GLOBAL(0x009DEA6E, uint8) = eax; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) = eax; return; } diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 2fb1a9cac1..5bbc3daca1 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -164,7 +164,7 @@ void window_save_prompt_open() window->colours[0] = 154; // Pause the game - RCT2_GLOBAL(0x009DEA6E, uint8) |= 2; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) |= 2; pause_sounds(); window_invalidate_by_class(WC_TOP_TOOLBAR); @@ -215,7 +215,7 @@ void window_save_prompt_open() static void window_save_prompt_close() { // Unpause the game - RCT2_GLOBAL(0x009DEA6E, uint8) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) &= ~2; unpause_sounds(); window_invalidate_by_class(WC_TOP_TOOLBAR); } diff --git a/src/windows/track_list.c b/src/windows/track_list.c index b3f40a8278..c29a799dca 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -316,7 +316,7 @@ static void window_track_list_scrollmousedown() if (w->track_list.var_484 & 1) return; - if (RCT2_GLOBAL(0x009DEA6E, uint8) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) return; i = window_track_list_get_list_item_index_from_position(x, y); @@ -337,7 +337,7 @@ static void window_track_list_scrollmouseover() if (w->track_list.var_484 & 1) return; - if (RCT2_GLOBAL(0x009DEA6E, uint8) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) return; i = window_track_list_get_list_item_index_from_position(x, y); diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 42bf35cc40..73c40c24d7 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -540,7 +540,7 @@ static void window_track_place_toolupdate() // Get base Z position z = window_track_place_get_base_z(x, y); - if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) { + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0) { window_track_place_clear_provisional(); // Try increasing Z until a feasible placement is found diff --git a/src/world/map.c b/src/world/map.c index adc0f219e3..7a1b43913a 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -598,7 +598,7 @@ money32 map_try_clear_scenery(int x, int y, rct_map_element *mapElement, int fla x *= 32; y *= 32; - if (!(flags & 0x40) && RCT2_GLOBAL(0x009DEA6E, uint8) != 0) { + if (!(flags & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } @@ -780,7 +780,7 @@ money32 map_change_surface_style(int x0, int y0, int x1, int y1, uint8 surface_s money32 cur_cost = 0; - if (RCT2_GLOBAL(0x9DEA6E, uint8) != 0){ + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0){ cur_cost += RCT2_GLOBAL(0x9E32B4, uint32); if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){