Merge pull request #755 from duncanspumpkin/palette

Added load_palette
This commit is contained in:
Ted John committed 2015-02-07 17:52:44 +00:00
commit 37675718af
20 files changed
+76 -45

No files matched your search

+7
View File
@@ -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
+28 -1
View File
@@ -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);
}
/**
+1
View File
@@ -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);
+6 -6
View File
@@ -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;
+6 -6
View File
@@ -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;
}
+1 -1
View File
@@ -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--) {
+1 -1
View File
@@ -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();
+4 -8
View File
@@ -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;
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -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();
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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;
}
+6 -6
View File
@@ -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;
}
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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){