mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
integrate game palette variables
This commit is contained in:
@@ -165,8 +165,6 @@
|
||||
|
||||
#define RCT2_ADDRESS_LAST_TICK_COUNT 0x009DE580
|
||||
|
||||
#define RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO 0x009DE584
|
||||
|
||||
#define RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE 0x009DE588
|
||||
|
||||
// Flags:
|
||||
@@ -538,8 +536,6 @@
|
||||
|
||||
#define RCT2_ADDRESS_INPUT_QUEUE 0x01424340
|
||||
|
||||
#define RCT2_ADDRESS_PALETTE 0x01424680
|
||||
|
||||
#define RCT2_ADDRESS_AUDIO_INFO 0x01425B40
|
||||
|
||||
#define RCT2_ADDRESS_COMMON_FORMAT_ARGS 0x013CE952
|
||||
@@ -584,6 +580,8 @@
|
||||
#define RCT2_ADDRESS_CURRENT_TOOL 0x009DE545
|
||||
#define RCT2_ADDRESS_TOOL_WIDGETINDEX 0x009DE546
|
||||
|
||||
#define RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO 0x009DE584
|
||||
|
||||
#define RCT2_ADDRESS_SCREEN_AGE 0x009DEA66
|
||||
#define RCT2_ADDRESS_SCREEN_FLAGS 0x009DEA68
|
||||
#define RCT2_ADDRESS_GAME_PAUSED 0x009DEA6E
|
||||
@@ -624,6 +622,8 @@
|
||||
// This is also the end of RCT2_ADDRESS_VIEWPORT_LIST.
|
||||
#define RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY 0x01423570
|
||||
|
||||
#define RCT2_ADDRESS_PALETTE 0x01424680
|
||||
|
||||
#endif
|
||||
#pragma endregion
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ rct_drawpixelinfo gWindowDPI;
|
||||
static uint32 _rainPixels[MAX_RAIN_PIXELS];
|
||||
static uint32 _numRainPixels;
|
||||
|
||||
uint8 gGamePalette[256 * 4];
|
||||
uint32 gPaletteEffectFrame;
|
||||
|
||||
|
||||
//Originally 0x9ABE0C, 12 elements from 0xF3 are the peep top colour, 12 elements from 0xCA are peep trouser colour
|
||||
const uint8 peep_palette[0x100] = {
|
||||
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
@@ -149,7 +153,7 @@ 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(RCT2_ADDRESS_PALETTE, uint8)[x * 4]);
|
||||
uint8* dest_pointer = &gGamePalette[x * 4];
|
||||
uint8* source_pointer = g1.offset;
|
||||
|
||||
for (; width > 0; width--) {
|
||||
@@ -159,7 +163,7 @@ void gfx_transpose_palette(int pal, unsigned char product)
|
||||
source_pointer += 3;
|
||||
dest_pointer += 4;
|
||||
}
|
||||
platform_update_palette((uint8*)RCT2_ADDRESS_PALETTE, 10, 236);
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +182,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(RCT2_ADDRESS_PALETTE, uint8)[x * 4]);
|
||||
uint8* dest_pointer = &gGamePalette[x * 4];
|
||||
uint8* source_pointer = g1.offset;
|
||||
|
||||
for (; width > 0; width--) {
|
||||
@@ -188,7 +192,7 @@ void load_palette(){
|
||||
source_pointer += 3;
|
||||
dest_pointer += 4;
|
||||
}
|
||||
platform_update_palette((uint8*)RCT2_ADDRESS_PALETTE, 10, 236);
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,6 +83,8 @@ typedef struct {
|
||||
#define SPRITE_ID_PALETTE_COLOUR_1(colourId) ((IMAGE_TYPE_USE_PALETTE << 28) | ((colourId) << 19))
|
||||
|
||||
#define PALETTE_TO_G1_OFFSET_COUNT 144
|
||||
extern uint8 gGamePalette[256 * 4];
|
||||
extern uint32 gPaletteEffectFrame;
|
||||
extern const uint16 palette_to_g1_offset[];
|
||||
extern const uint8 peep_palette[];
|
||||
extern uint8 text_palette[];
|
||||
|
||||
26
src/game.c
26
src/game.c
@@ -147,12 +147,13 @@ void update_palette_effects()
|
||||
rct_g1_element g1_element = g1Elements[palette];
|
||||
int xoffset = g1_element.x_offset;
|
||||
xoffset = xoffset * 4;
|
||||
uint8 *paletteOffset = gGamePalette + xoffset;
|
||||
for (int i = 0; i < g1_element.width; i++) {
|
||||
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;
|
||||
paletteOffset[(i * 4) + 0] = -((0xFF - g1_element.offset[(i * 3) + 0]) / 2) - 1;
|
||||
paletteOffset[(i * 4) + 1] = -((0xFF - g1_element.offset[(i * 3) + 1]) / 2) - 1;
|
||||
paletteOffset[(i * 4) + 2] = -((0xFF - g1_element.offset[(i * 3) + 2]) / 2) - 1;
|
||||
}
|
||||
platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 10, 236);
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8)++;
|
||||
} else {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) {
|
||||
@@ -166,10 +167,11 @@ void update_palette_effects()
|
||||
rct_g1_element g1_element = g1Elements[palette];
|
||||
int xoffset = g1_element.x_offset;
|
||||
xoffset = xoffset * 4;
|
||||
uint8 *paletteOffset = gGamePalette + xoffset;
|
||||
for (int i = 0; i < g1_element.width; i++) {
|
||||
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];
|
||||
paletteOffset[(i * 4) + 0] = g1_element.offset[(i * 3) + 0];
|
||||
paletteOffset[(i * 4) + 1] = g1_element.offset[(i * 3) + 1];
|
||||
paletteOffset[(i * 4) + 2] = g1_element.offset[(i * 3) + 2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +184,7 @@ void update_palette_effects()
|
||||
q = 2;
|
||||
}
|
||||
}
|
||||
uint32 j = RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, uint32);
|
||||
uint32 j = gPaletteEffectFrame;
|
||||
j = (((uint16)((~j / 2) * 128) * 15) >> 16);
|
||||
int p = 1533;
|
||||
if ((sint32)water_type != -1) {
|
||||
@@ -190,7 +192,7 @@ void update_palette_effects()
|
||||
}
|
||||
rct_g1_element g1_element = g1Elements[q + p];
|
||||
uint8* vs = &g1_element.offset[j * 3];
|
||||
uint8* vd = RCT2_ADDRESS(0x01424A18, uint8);
|
||||
uint8* vd = &gGamePalette[230 * 4];
|
||||
int n = 5;
|
||||
for (int i = 0; i < n; i++) {
|
||||
vd[0] = vs[0];
|
||||
@@ -221,7 +223,7 @@ void update_palette_effects()
|
||||
vd += 4;
|
||||
}
|
||||
|
||||
j = ((uint16)(RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, uint32) * -960) * 3) >> 16;
|
||||
j = ((uint16)(gPaletteEffectFrame * -960) * 3) >> 16;
|
||||
p = 1539;
|
||||
g1_element = g1Elements[q + p];
|
||||
vs = &g1_element.offset[j * 3];
|
||||
@@ -238,9 +240,9 @@ void update_palette_effects()
|
||||
vd += 4;
|
||||
}
|
||||
|
||||
platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 230, 16);
|
||||
platform_update_palette(gGamePalette, 230, 16);
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) == 2) {
|
||||
platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 10, 236);
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LIGHTNING_ACTIVE, uint8) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,8 +449,9 @@ void rct2_update()
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16) = tick2 = min(tick2, 500);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAST_TICK_COUNT, sint32) = tick;
|
||||
if (game_is_not_paused())
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO, sint32) += tick2;
|
||||
if (game_is_not_paused()) {
|
||||
gPaletteEffectFrame += tick2;
|
||||
}
|
||||
|
||||
// TODO: screenshot countdown process
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ static void scenario_update_daynight_cycle()
|
||||
|
||||
// Only update palette if day / night cycle has changed
|
||||
if (gDayNightCycle != currentDayNightCycle) {
|
||||
platform_update_palette(RCT2_ADDRESS(RCT2_ADDRESS_PALETTE, uint8), 10, 236);
|
||||
platform_update_palette(gGamePalette, 10, 236);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user