mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
palette effects
This commit is contained in:
126
src/game.c
126
src/game.c
@@ -140,12 +140,126 @@ void game_create_windows()
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006838BD
|
||||
*/
|
||||
void update_water_animation()
|
||||
*
|
||||
* rct2: 0x006838BD
|
||||
*/
|
||||
void update_palette_effects()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006838BD);
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 1) {
|
||||
// change palette to lighter color during lightning
|
||||
int palette = 1532;
|
||||
if (RCT2_GLOBAL(0x009ADAE0, sint32) != -1) {
|
||||
palette = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 2, int);
|
||||
}
|
||||
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette];
|
||||
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_GLOBAL(0x014241BC, uint32) = 2;
|
||||
osinterface_update_palette(RCT2_ADDRESS(0x01424680, uint8), 10, 236);
|
||||
RCT2_GLOBAL(0x014241BC, uint32) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8)++;
|
||||
} else {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) {
|
||||
// change palette back to normal after lightning
|
||||
int palette = 1532;
|
||||
if (RCT2_GLOBAL(0x009ADAE0, sint32) != -1) {
|
||||
palette = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 2, int);
|
||||
}
|
||||
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette];
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
// animate the water/lava/chain movement palette
|
||||
int q = 0;
|
||||
int weather_colour = RCT2_ADDRESS(0x98195C, uint32)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_GLOOM, uint8)];
|
||||
if (weather_colour != -1) {
|
||||
q = 1;
|
||||
if (weather_colour != 0x2000031) {
|
||||
q = 2;
|
||||
}
|
||||
}
|
||||
uint32 j = RCT2_GLOBAL(0x009DE584, uint32);
|
||||
j = (((uint16)((~j / 2) * 128) * 15) >> 16);
|
||||
int p = 1533;
|
||||
if (RCT2_GLOBAL(0x009ADAE0, int) != -1) {
|
||||
p = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 0x6, int);
|
||||
}
|
||||
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[q + p];
|
||||
uint8* vs = &g1_element.offset[j * 3];
|
||||
uint8* vd = RCT2_ADDRESS(0x01424A18, uint8);
|
||||
int n = 5;
|
||||
for (int i = 0; i < n; i++) {
|
||||
vd[0] = vs[0];
|
||||
vd[1] = vs[1];
|
||||
vd[2] = vs[2];
|
||||
vs += 9;
|
||||
if (vs >= &g1_element.offset[9 * n]) {
|
||||
vs -= 9 * n;
|
||||
}
|
||||
vd += 4;
|
||||
}
|
||||
|
||||
p = 1536;
|
||||
if (RCT2_GLOBAL(0x009ADAE0, int) != -1) {
|
||||
p = RCT2_GLOBAL(RCT2_GLOBAL(0x009ADAE0, int) + 0xA, int);
|
||||
}
|
||||
g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[q + p];
|
||||
vs = &g1_element.offset[j * 3];
|
||||
n = 5;
|
||||
for (int i = 0; i < n; i++) {
|
||||
vd[0] = vs[0];
|
||||
vd[1] = vs[1];
|
||||
vd[2] = vs[2];
|
||||
vs += 9;
|
||||
if (vs >= &g1_element.offset[9 * n]) {
|
||||
vs -= 9 * n;
|
||||
}
|
||||
vd += 4;
|
||||
}
|
||||
|
||||
j = ((uint16)(RCT2_GLOBAL(0x009DE584, 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];
|
||||
vd += 12;
|
||||
n = 3;
|
||||
for (int i = 0; i < n; i++) {
|
||||
vd[0] = vs[0];
|
||||
vd[1] = vs[1];
|
||||
vd[2] = vs[2];
|
||||
vs += 3;
|
||||
if (vs >= &g1_element.offset[3 * n]) {
|
||||
vs -= 3 * n;
|
||||
}
|
||||
vd += 4;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(0x014241BC, uint32) = 2;
|
||||
osinterface_update_palette(RCT2_ADDRESS(0x01424680, uint8), 230, 16);
|
||||
RCT2_GLOBAL(0x014241BC, uint32) = 0;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) {
|
||||
RCT2_GLOBAL(0x014241BC, uint32) = 2;
|
||||
osinterface_update_palette(RCT2_ADDRESS(0x01424680, uint8), 10, 236);
|
||||
RCT2_GLOBAL(0x014241BC, uint32) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) = 0;
|
||||
}
|
||||
}
|
||||
if (RCT2_GLOBAL(0x009E2C4C, uint32) == 2 || RCT2_GLOBAL(0x009E2C4C, uint32) == 1) {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_CAP_BPP, uint32) != 8) {
|
||||
RCT2_GLOBAL(0x009E2C78, int) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +464,7 @@ void game_update()
|
||||
RCT2_GLOBAL(0x0141F568, uint8) = RCT2_GLOBAL(0x0013CA740, uint8);
|
||||
game_handle_input();
|
||||
|
||||
update_water_animation();
|
||||
update_palette_effects();
|
||||
update_rain_animation();
|
||||
|
||||
if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) {
|
||||
|
||||
@@ -91,7 +91,7 @@ void game_update();
|
||||
void game_logic_update();
|
||||
void sub_0x0069E9A7();
|
||||
void update_rain_animation();
|
||||
void update_water_animation();
|
||||
void update_palette_effects();
|
||||
|
||||
int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *edi, int *esi, int *ebp);
|
||||
|
||||
@@ -276,15 +276,14 @@ void osinterface_update_palette(char* colours, int start_index, int num_colours)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
base[i].r = colours[2];
|
||||
base[i].g = colours[1];
|
||||
base[i].b = colours[0];
|
||||
for (i = start_index; i < start_index + num_colours; i++) {
|
||||
base[i].r = colours[(i * 4) + 2];
|
||||
base[i].g = colours[(i * 4) + 1];
|
||||
base[i].b = colours[(i * 4) + 0];
|
||||
base[i].a = 0;
|
||||
colours += 4;
|
||||
}
|
||||
|
||||
if (SDL_SetPaletteColors(_palette, base, 0, 256)) {
|
||||
if (SDL_SetPaletteColors(_palette, &base[start_index], start_index, num_colours)) {
|
||||
RCT2_ERROR("SDL_SetPaletteColors failed %s", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ void title_update()
|
||||
// RCT2_CALLPROC_EBPSAFE(0x006EA627); // window_manager_handle_input();
|
||||
game_handle_input();
|
||||
|
||||
update_water_animation();
|
||||
update_palette_effects();
|
||||
update_rain_animation();
|
||||
|
||||
if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) {
|
||||
|
||||
Reference in New Issue
Block a user