From 74d0b033df0ec21b4125a8c8e2c29aeb5cf541cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 9 Oct 2015 18:22:37 +0200 Subject: [PATCH] Name RCT2_ADDRESS_PALETTE --- src/addresses.h | 18 +++++++------ src/drawing/drawing.c | 32 +++++++++++------------ src/game.c | 52 +++++++++++++++++++------------------- src/interface/screenshot.c | 18 ++++++------- 4 files changed, 61 insertions(+), 59 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 47c1513827..8b33a6cf47 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (c) 2014 Ted John, Kevin Burke, Matthias Lanzinger * 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 @@ -556,7 +556,7 @@ #define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8 #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC -// Null Terminated list of active viewport pointers. +// Null Terminated list of active viewport pointers. // This is also the end of RCT2_ADDRESS_VIEWPORT_LIST. #define RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY 0x01423570 @@ -632,6 +632,8 @@ #define RCT2_ADDRESS_INPUT_QUEUE 0x01424340 +#define RCT2_ADDRESS_PALETTE 0x01424680 + #define RCT2_ADDRESS_AUDIO_INFO 0x01425B40 #define RCT2_ADDRESS_SOUND_CHANNEL_LIST 0x014262E0 @@ -707,7 +709,7 @@ static int RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, add esp, 4 \n\ pop ebp \n\ pop ebx \n\ - " : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp) + " : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp) : : "eax","ecx","edx","esi","edi" ); @@ -758,7 +760,7 @@ static int RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_e // Call function call [esp] - + // Store output eax push eax push ebp @@ -778,7 +780,7 @@ static int RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_e mov [eax], ecx // Pop ebx reg into ecx - pop ecx + pop ecx mov eax, [_ebx] mov[eax], ecx @@ -796,7 +798,7 @@ static int RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_e lahf // Pop address pop ebp - + pop ebx pop ebp } @@ -866,7 +868,7 @@ static int RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_e \n\ pop ebx \n\ pop ebp \n\ - " : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp) + " : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp) : : "eax","ecx","edx","esi","edi" ); diff --git a/src/drawing/drawing.c b/src/drawing/drawing.c index cc323848b6..c1fac53c64 100644 --- a/src/drawing/drawing.c +++ b/src/drawing/drawing.c @@ -8,12 +8,12 @@ * 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 . *****************************************************************************/ @@ -38,7 +38,7 @@ int _screenDirtyBlocksSize = 0; uint32 rainPixels[MAX_RAIN_PIXELS]; //Originally 0x9ABE0C, 12 elements from 0xF3 are the peep top colour, 12 elements from 0xCA are peep trouser colour -const uint8 peep_palette[0x100] = { +const uint8 peep_palette[0x100] = { 0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, @@ -138,8 +138,8 @@ void gfx_transpose_palette(int pal, unsigned char product) { rct_g1_element g1 = g1Elements[pal]; int width = g1.width; - int x = g1.x_offset; - uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(0x01424680, uint8)[x * 4]); + int x = g1.x_offset; + uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[x * 4]); uint8* source_pointer = g1.offset; for (; width > 0; width--) { @@ -149,7 +149,7 @@ void gfx_transpose_palette(int pal, unsigned char product) source_pointer += 3; dest_pointer += 4; } - platform_update_palette((char*)0x01424680, 10, 236); + platform_update_palette((char*)RCT2_ADDRESS_PALETTE, 10, 236); } /* rct2: 0x006837E3 */ @@ -165,7 +165,7 @@ void load_palette(){ rct_g1_element g1 = g1Elements[palette]; int width = g1.width; int x = g1.x_offset; - uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(0x01424680, uint8)[x * 4]); + uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[x * 4]); uint8* source_pointer = g1.offset; for (; width > 0; width--) { @@ -175,7 +175,7 @@ void load_palette(){ source_pointer += 3; dest_pointer += 4; } - platform_update_palette((char*)0x01424680, 10, 236); + platform_update_palette((char*)RCT2_ADDRESS_PALETTE, 10, 236); } /** @@ -204,7 +204,7 @@ uint8* gfx_get_dirty_blocks() } /** - * + * * rct2: 0x006E732D * left (ax) * top (bx) @@ -264,7 +264,7 @@ void gfx_draw_all_dirty_blocks() for (xx = x; xx < x + columns; xx++) if (screenDirtyBlocks[yy * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, uint32) + xx] == 0) goto endRowCheck; - + endRowCheck: rows = yy - y; gfx_draw_dirty_blocks(x, y, columns, rows); @@ -295,8 +295,8 @@ static void gfx_draw_dirty_blocks(int x, int y, int columns, int rows) } /** - * - * rct2: 0x006E7499 + * + * rct2: 0x006E7499 * left (ax) * top (bx) * right (dx) @@ -435,7 +435,7 @@ void gfx_draw_rain(int left, int top, int width, int height, sint32 x_start, sin //Store colour and position *pixel_store++ = (x_pixel_offset << 8) | current_pixel; - + } } } @@ -460,7 +460,7 @@ void redraw_rain() } rct_window *window = window_get_main(); uint32 numPixels = window->width * window->height; - + uint32 *rain_pixels = rainPixels; if (rain_pixels) { uint8 *screen_pixels = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo)->bits; @@ -485,13 +485,13 @@ void gfx_invalidate_pickedup_peep() int sprite = RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32); if (sprite != -1) { sprite = sprite & 0x7FFFF; - + rct_g1_element *g1_elements = &g1Elements[sprite]; int left = RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_X, sint16) + g1_elements->x_offset; int top = RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_Y, sint16) + g1_elements->y_offset; int right = left + g1_elements->width; int bottom = top + g1_elements->height; - + gfx_set_dirty_blocks(left, top, right, bottom); } } diff --git a/src/game.c b/src/game.c index b55434f975..c9e574bbbe 100644 --- a/src/game.c +++ b/src/game.c @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (c) 2014 Ted John, Peter Hill * 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 @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ - + #include "addresses.h" #include "audio/audio.h" #include "config.h" @@ -104,7 +104,7 @@ void game_reduce_game_speed() } /** - * + * * rct2: 0x0066B5C0 (part of 0x0066B3E8) */ void game_create_windows() @@ -134,12 +134,12 @@ void update_palette_effects() int xoffset = g1_element.x_offset; xoffset = xoffset * 4; for (int i = 0; i < g1_element.width; i++) { - RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 0] = -((0xFF - g1_element.offset[(i * 3) + 0]) / 2) - 1; - RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 1] = -((0xFF - g1_element.offset[(i * 3) + 1]) / 2) - 1; - RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 2] = -((0xFF - g1_element.offset[(i * 3) + 2]) / 2) - 1; + RCT2_ADDRESS(RCT2_ADDRESS_PALETTE + xoffset, uint8)[(i * 4) + 0] = -((0xFF - g1_element.offset[(i * 3) + 0]) / 2) - 1; + RCT2_ADDRESS(RCT2_ADDRESS_PALETTE + xoffset, uint8)[(i * 4) + 1] = -((0xFF - g1_element.offset[(i * 3) + 1]) / 2) - 1; + RCT2_ADDRESS(RCT2_ADDRESS_PALETTE + xoffset, uint8)[(i * 4) + 2] = -((0xFF - g1_element.offset[(i * 3) + 2]) / 2) - 1; } RCT2_GLOBAL(0x014241BC, uint32) = 2; - platform_update_palette(RCT2_ADDRESS(0x01424680, uint8), 10, 236); + platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 10, 236); RCT2_GLOBAL(0x014241BC, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8)++; } else { @@ -155,9 +155,9 @@ void update_palette_effects() int xoffset = g1_element.x_offset; xoffset = xoffset * 4; for (int i = 0; i < g1_element.width; i++) { - RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 0] = g1_element.offset[(i * 3) + 0]; - RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 1] = g1_element.offset[(i * 3) + 1]; - RCT2_ADDRESS(0x01424680 + xoffset, uint8)[(i * 4) + 2] = g1_element.offset[(i * 3) + 2]; + RCT2_ADDRESS(RCT2_ADDRESS_PALETTE + xoffset, uint8)[(i * 4) + 0] = g1_element.offset[(i * 3) + 0]; + RCT2_ADDRESS(RCT2_ADDRESS_PALETTE + xoffset, uint8)[(i * 4) + 1] = g1_element.offset[(i * 3) + 1]; + RCT2_ADDRESS(RCT2_ADDRESS_PALETTE + xoffset, uint8)[(i * 4) + 2] = g1_element.offset[(i * 3) + 2]; } } @@ -227,11 +227,11 @@ void update_palette_effects() } RCT2_GLOBAL(0x014241BC, uint32) = 2; - platform_update_palette(RCT2_ADDRESS(0x01424680, uint8), 230, 16); + platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 230, 16); RCT2_GLOBAL(0x014241BC, uint32) = 0; if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) { RCT2_GLOBAL(0x014241BC, uint32) = 2; - platform_update_palette(RCT2_ADDRESS(0x01424680, uint8), 10, 236); + platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 10, 236); RCT2_GLOBAL(0x014241BC, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) = 0; } @@ -385,7 +385,7 @@ void game_logic_update() } /** - * + * * rct2: 0x0069C62C * * @param cost (ebp) @@ -408,7 +408,7 @@ static uint32 game_do_command_table[58]; static GAME_COMMAND_POINTER* new_game_command_table[58]; /** - * + * * rct2: 0x006677F2 * * @param flags (ebx) @@ -449,13 +449,13 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * (command == GAME_COMMAND_PLACE_FENCE || command == GAME_COMMAND_PLACE_SCENERY || command == GAME_COMMAND_PLACE_LARGE_SCENERY || - command == GAME_COMMAND_PLACE_BANNER || + command == GAME_COMMAND_PLACE_BANNER || command == GAME_COMMAND_PLACE_PATH)) { scenery_remove_ghost_tool_placement(); } *ebx &= ~GAME_COMMAND_FLAG_APPLY; - + // Primary command if (game_do_command_table[command] == 0) { new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp); @@ -517,7 +517,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * if (RCT2_GLOBAL(0x009A8C28, uint8) != 0) return cost; - // + // if (!(flags & 0x20)) { // Update money balance finance_payment(cost, RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) / 4); @@ -555,7 +555,7 @@ void pause_toggle() } /** - * + * * rct2: 0x00667C15 */ void game_pause_toggle(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) @@ -567,7 +567,7 @@ void game_pause_toggle(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *ed } /** - * + * * rct2: 0x0066DB5F */ static void game_load_or_quit(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) @@ -720,7 +720,7 @@ void game_convert_strings_to_rct2(rct_s6_data *s6) } /** - * + * * rct2: 0x00675E1B */ int game_load_sv6(SDL_RWops* rw) @@ -845,7 +845,7 @@ int game_load_network(SDL_RWops* rw) } /** - * + * * rct2: 0x00675E1B */ int game_load_save(const char *path) @@ -939,7 +939,7 @@ void reset_all_sprite_quadrant_placements() } /** - * + * * rct2: 0x0066DBB7 */ static void load_game() @@ -1071,7 +1071,7 @@ void rct2_exit_reason(rct_string_id title, rct_string_id body){ /** - * + * * rct2: 0x006E3879 */ void rct2_exit() @@ -1082,7 +1082,7 @@ void rct2_exit() } /** - * + * * rct2: 0x0066DB79 */ void game_load_or_quit_no_save_prompt() @@ -1134,7 +1134,7 @@ static uint32 game_do_command_table[58] = { 0, 0, // 20 0, - 0, + 0, 0, 0, 0x0068BC01, diff --git a/src/interface/screenshot.c b/src/interface/screenshot.c index be15586f89..43c1584eec 100644 --- a/src/interface/screenshot.c +++ b/src/interface/screenshot.c @@ -203,9 +203,9 @@ int screenshot_dump_bmp() // Palette memset(buffer, 0, 246 * 4); for (i = 0; i < 246; i++) { - buffer[i * 4 + 0] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 0]; - buffer[i * 4 + 1] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 1]; - buffer[i * 4 + 2] = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 2]; + buffer[i * 4 + 0] = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 0]; + buffer[i * 4 + 1] = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 1]; + buffer[i * 4 + 2] = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 2]; } bytesWritten = SDL_RWwrite(fp, buffer, sizeof(char), 246 * 4); @@ -267,9 +267,9 @@ int screenshot_dump_png() padding = dpi->pitch; for (i = 0; i < 256; i++) { - b = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 0]; - g = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 1]; - r = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 2]; + b = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 0]; + g = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 1]; + r = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 2]; lodepng_palette_add(&state.info_raw, r, g, b, a); } @@ -329,9 +329,9 @@ bool screenshot_write_png(rct_drawpixelinfo *dpi, const char *path) for (int i = 0; i < 256; i++) { unsigned char r, g, b, a = 255; - b = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 0]; - g = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 1]; - r = RCT2_ADDRESS(0x01424680, uint8)[i * 4 + 2]; + b = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 0]; + g = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 1]; + r = RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8)[i * 4 + 2]; lodepng_palette_add(&state.info_raw, r, g, b, a); }