mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Merge pull request #4465 from duncanspumpkin/refactor_paint
Refactor paint
This commit is contained in:
@@ -1022,7 +1022,6 @@ void SoftwareDrawingContext::DrawSpriteSolid(uint32 image, sint32 x, sint32 y, u
|
||||
memset(palette, colour, 256);
|
||||
palette[0] = 0;
|
||||
|
||||
gUnkEDF81C = 0x20000000;
|
||||
image &= 0x7FFFF;
|
||||
gfx_draw_sprite_palette_set_software(_dpi, image | 0x20000000, x, y, palette, nullptr);
|
||||
}
|
||||
|
||||
@@ -914,7 +914,6 @@ static void ttf_draw_character_sprite(rct_drawpixelinfo *dpi, int codepoint, tex
|
||||
|
||||
if (!(info->flags & TEXT_DRAW_FLAG_NO_DRAW)) {
|
||||
unk_9ABDA4 = &info->palette;
|
||||
gUnkEDF81C = IMAGE_TYPE_REMAP;
|
||||
|
||||
int x = info->x;
|
||||
int y = info->y;
|
||||
|
||||
@@ -52,8 +52,8 @@ uint8 gSavedViewZoom;
|
||||
uint8 gSavedViewRotation;
|
||||
|
||||
#ifdef NO_RCT2
|
||||
paint_struct *unk_EE7884;
|
||||
paint_struct *unk_EE7888;
|
||||
paint_entry *unk_EE7884;
|
||||
paint_entry *gNextFreePaintStruct;
|
||||
uint8 gCurrentRotation;
|
||||
uint32 gCurrentViewportFlags = 0;
|
||||
#endif
|
||||
@@ -769,7 +769,7 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, int left, in
|
||||
}
|
||||
gfx_clear(dpi2, colour);
|
||||
}
|
||||
g_ps_EE7880 = &gUnkF1A4CC;
|
||||
gEndOfPaintStructArray = &gPaintStructs[4000 - 1];
|
||||
unk_140E9A8 = dpi2;
|
||||
painter_setup();
|
||||
viewport_paint_setup();
|
||||
@@ -1330,7 +1330,7 @@ static bool sub_679023(rct_drawpixelinfo *dpi, int imageId, int x, int y)
|
||||
static void sub_68862C()
|
||||
{
|
||||
rct_drawpixelinfo *dpi = unk_140E9A8;
|
||||
paint_struct *ps = unk_EE7884, *old_ps, *next_ps;
|
||||
paint_struct *ps = &unk_EE7884->basic, *old_ps, *next_ps;
|
||||
|
||||
while ((ps = ps->next_quadrant_ps) != NULL) {
|
||||
old_ps = ps;
|
||||
@@ -1398,7 +1398,7 @@ void get_map_coordinates_from_pos(int screenX, int screenY, int flags, sint16 *x
|
||||
dpi->zoom_level = _viewportDpi1.zoom_level;
|
||||
dpi->x = _viewportDpi1.x;
|
||||
dpi->width = 1;
|
||||
g_ps_EE7880 = &gUnkF1A4CC;
|
||||
gEndOfPaintStructArray = &gPaintStructs[4000 - 1];
|
||||
unk_140E9A8 = dpi;
|
||||
painter_setup();
|
||||
viewport_paint_setup();
|
||||
|
||||
@@ -105,19 +105,17 @@ extern uint8 gSavedViewZoom;
|
||||
extern uint8 gSavedViewRotation;
|
||||
|
||||
#ifdef NO_RCT2
|
||||
extern paint_struct *unk_EE7884;
|
||||
extern paint_struct *unk_EE7888;
|
||||
extern paint_entry *unk_EE7884;
|
||||
extern paint_entry *gNextFreePaintStruct;
|
||||
extern uint8 gCurrentRotation;
|
||||
extern uint32 gCurrentViewportFlags;
|
||||
#else
|
||||
#define unk_EE7884 RCT2_GLOBAL(0x00EE7884, paint_struct*)
|
||||
#define unk_EE7888 RCT2_GLOBAL(0x00EE7888, paint_struct*)
|
||||
#define unk_EE7884 RCT2_GLOBAL(0x00EE7884, paint_entry*)
|
||||
#define gNextFreePaintStruct RCT2_GLOBAL(0x00EE7888, paint_entry*)
|
||||
#define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)
|
||||
#define gCurrentViewportFlags RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint32)
|
||||
#endif
|
||||
|
||||
extern uint32 gUnkEDF81C;
|
||||
|
||||
void viewport_init_all();
|
||||
void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_viewport* viewport);
|
||||
void viewport_create(rct_window *w, int x, int y, int width, int height, int zoom, int center_x, int center_y, int center_z, char flags, sint16 sprite);
|
||||
|
||||
@@ -33,12 +33,12 @@ paint_string_struct *pss1;
|
||||
paint_string_struct *pss2;
|
||||
|
||||
#ifdef NO_RCT2
|
||||
static paint_struct _unkEE788C[4000];
|
||||
paint_entry gPaintStructs[4000];
|
||||
uint32 _F1AD0C;
|
||||
uint32 _F1AD10;
|
||||
static paint_struct *_paint_structs[512];
|
||||
static paint_struct *_paint_struct_quadrants[512];
|
||||
void *g_currently_drawn_item;
|
||||
paint_struct * g_ps_EE7880;
|
||||
paint_entry * gEndOfPaintStructArray;
|
||||
sint16 gUnk9DE568;
|
||||
sint16 gUnk9DE56C;
|
||||
paint_struct gUnkF1A4CC;
|
||||
@@ -47,8 +47,7 @@ support_height gSupportSegments[9] = { 0 };
|
||||
support_height gSupport;
|
||||
|
||||
#else
|
||||
#define _unkEE788C RCT2_ADDRESS(0x00EE788C, paint_struct)
|
||||
#define _paint_structs (RCT2_ADDRESS(0x00F1A50C, paint_struct*))
|
||||
#define _paint_struct_quadrants (RCT2_ADDRESS(0x00F1A50C, paint_struct*))
|
||||
#define _F1AD0C RCT2_GLOBAL(0xF1AD0C, uint32)
|
||||
#define _F1AD10 RCT2_GLOBAL(0xF1AD10, uint32)
|
||||
#endif
|
||||
@@ -76,11 +75,11 @@ bool gPaintBoundingBoxes;
|
||||
* rct2: 0x0068615B
|
||||
*/
|
||||
void painter_setup() {
|
||||
unk_EE7888 = _unkEE788C;
|
||||
gNextFreePaintStruct = gPaintStructs;
|
||||
g_ps_F1AD28 = NULL;
|
||||
g_aps_F1AD2C = NULL;
|
||||
for (int i = 0; i < 512; i++) {
|
||||
_paint_structs[i] = NULL;
|
||||
_paint_struct_quadrants[i] = NULL;
|
||||
}
|
||||
_F1AD0C = -1;
|
||||
_F1AD10 = 0;
|
||||
@@ -93,9 +92,8 @@ void painter_setup() {
|
||||
*/
|
||||
static paint_struct * sub_9819_c(uint32 image_id, rct_xyz16 offset, rct_xyz16 boundBoxSize, rct_xyz16 boundBoxOffset, uint8 rotation)
|
||||
{
|
||||
paint_struct * ps = unk_EE7888;
|
||||
|
||||
if (ps >= g_ps_EE7880) return NULL;
|
||||
if (gNextFreePaintStruct >= gEndOfPaintStructArray) return NULL;
|
||||
paint_struct * ps = &gNextFreePaintStruct->basic;
|
||||
|
||||
ps->image_id = image_id;
|
||||
|
||||
@@ -206,13 +204,11 @@ paint_struct * sub_98196C(
|
||||
g_ps_F1AD28 = 0;
|
||||
g_aps_F1AD2C = NULL;
|
||||
|
||||
//Not a paint struct but something similar
|
||||
paint_struct *ps = unk_EE7888;
|
||||
|
||||
if (ps >= g_ps_EE7880) {
|
||||
if (gNextFreePaintStruct >= gEndOfPaintStructArray) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
paint_struct *ps = &gNextFreePaintStruct->basic;
|
||||
ps->image_id = image_id;
|
||||
|
||||
uint32 image_element = image_id & 0x7FFFF;
|
||||
@@ -328,8 +324,8 @@ paint_struct * sub_98196C(
|
||||
|
||||
ps->var_18 = edi;
|
||||
|
||||
paint_struct *old_ps = _paint_structs[edi];
|
||||
_paint_structs[edi] = ps;
|
||||
paint_struct *old_ps = _paint_struct_quadrants[edi];
|
||||
_paint_struct_quadrants[edi] = ps;
|
||||
ps->next_quadrant_ps = old_ps;
|
||||
|
||||
if ((uint16)edi < _F1AD0C) {
|
||||
@@ -340,7 +336,7 @@ paint_struct * sub_98196C(
|
||||
_F1AD10 = edi;
|
||||
}
|
||||
|
||||
unk_EE7888 ++;
|
||||
gNextFreePaintStruct++;
|
||||
|
||||
return ps;
|
||||
}
|
||||
@@ -412,8 +408,8 @@ paint_struct * sub_98197C(
|
||||
di = 511;
|
||||
|
||||
ps->var_18 = di;
|
||||
paint_struct* old_ps = _paint_structs[di];
|
||||
_paint_structs[di] = ps;
|
||||
paint_struct* old_ps = _paint_struct_quadrants[di];
|
||||
_paint_struct_quadrants[di] = ps;
|
||||
ps->next_quadrant_ps = old_ps;
|
||||
|
||||
if ((uint16)di < _F1AD0C) {
|
||||
@@ -424,7 +420,7 @@ paint_struct * sub_98197C(
|
||||
_F1AD10 = di;
|
||||
}
|
||||
|
||||
unk_EE7888++;
|
||||
gNextFreePaintStruct++;
|
||||
return ps;
|
||||
}
|
||||
|
||||
@@ -469,7 +465,7 @@ paint_struct * sub_98198C(
|
||||
}
|
||||
|
||||
g_ps_F1AD28 = ps;
|
||||
unk_EE7888++;
|
||||
gNextFreePaintStruct++;
|
||||
return ps;
|
||||
}
|
||||
|
||||
@@ -525,7 +521,7 @@ paint_struct * sub_98199C(
|
||||
old_ps->var_20 = ps;
|
||||
|
||||
g_ps_F1AD28 = ps;
|
||||
unk_EE7888++;
|
||||
gNextFreePaintStruct++;
|
||||
return ps;
|
||||
}
|
||||
|
||||
@@ -542,13 +538,11 @@ bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y)
|
||||
if (g_aps_F1AD2C == NULL) {
|
||||
return paint_attach_to_previous_ps(image_id, x, y);
|
||||
}
|
||||
|
||||
attached_paint_struct * ps = (attached_paint_struct *)unk_EE7888;
|
||||
|
||||
if ((paint_struct *)ps >= g_ps_EE7880) {
|
||||
|
||||
if (gNextFreePaintStruct >= gEndOfPaintStructArray) {
|
||||
return false;
|
||||
}
|
||||
|
||||
attached_paint_struct * ps = &gNextFreePaintStruct->attached;
|
||||
ps->image_id = image_id;
|
||||
ps->x = x;
|
||||
ps->y = y;
|
||||
@@ -561,7 +555,7 @@ bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y)
|
||||
|
||||
g_aps_F1AD2C = ps;
|
||||
|
||||
unk_EE7888++;
|
||||
gNextFreePaintStruct++;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -576,11 +570,10 @@ bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y)
|
||||
*/
|
||||
bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y)
|
||||
{
|
||||
attached_paint_struct * ps = (attached_paint_struct *)unk_EE7888;
|
||||
|
||||
if ((paint_struct *)ps >= g_ps_EE7880) {
|
||||
if (gNextFreePaintStruct >= gEndOfPaintStructArray) {
|
||||
return false;
|
||||
}
|
||||
attached_paint_struct * ps = &gNextFreePaintStruct->attached;
|
||||
|
||||
ps->image_id = image_id;
|
||||
ps->x = x;
|
||||
@@ -592,7 +585,7 @@ bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y)
|
||||
return false;
|
||||
}
|
||||
|
||||
unk_EE7888++;
|
||||
gNextFreePaintStruct++;
|
||||
|
||||
attached_paint_struct * oldFirstAttached = masterPs->attached_ps;
|
||||
masterPs->attached_ps = ps;
|
||||
@@ -616,11 +609,10 @@ bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y)
|
||||
*/
|
||||
void sub_685EBC(money32 amount, rct_string_id string_id, sint16 y, sint16 z, sint8 y_offsets[], sint16 offset_x, uint32 rotation)
|
||||
{
|
||||
paint_string_struct * ps = (paint_string_struct *)unk_EE7888;
|
||||
|
||||
if ((paint_struct *)ps >= g_ps_EE7880) {
|
||||
return;
|
||||
}
|
||||
if (gNextFreePaintStruct >= gEndOfPaintStructArray) {
|
||||
return;
|
||||
}
|
||||
paint_string_struct * ps = &gNextFreePaintStruct->string;
|
||||
|
||||
ps->string_id = string_id;
|
||||
ps->next = 0;
|
||||
@@ -636,7 +628,7 @@ void sub_685EBC(money32 amount, rct_string_id string_id, sint16 y, sint16 z, sin
|
||||
ps->x = coord.x + offset_x;
|
||||
ps->y = coord.y;
|
||||
|
||||
unk_EE7888++;
|
||||
gNextFreePaintStruct++;
|
||||
|
||||
paint_string_struct * oldPs = pss2;
|
||||
|
||||
@@ -763,7 +755,7 @@ void viewport_paint_setup()
|
||||
static void sub_688217_helper(uint16 ax, uint8 flag)
|
||||
{
|
||||
paint_struct *ps, *ps_temp;
|
||||
paint_struct *ps_next = unk_EE7884;
|
||||
paint_struct *ps_next = &unk_EE7884->basic;
|
||||
|
||||
do {
|
||||
ps = ps_next;
|
||||
@@ -872,17 +864,17 @@ static void sub_688217_helper(uint16 ax, uint8 flag)
|
||||
*/
|
||||
void sub_688217()
|
||||
{
|
||||
paint_struct *ps = unk_EE7888;
|
||||
|
||||
paint_struct *ps_next;
|
||||
unk_EE7888++;
|
||||
unk_EE7884 = ps;
|
||||
unk_EE7884 = gNextFreePaintStruct++;
|
||||
paint_struct *ps = &unk_EE7884->basic;
|
||||
ps->next_quadrant_ps = NULL;
|
||||
uint32 edi = _F1AD0C;
|
||||
if (edi == -1)
|
||||
return;
|
||||
|
||||
do {
|
||||
ps_next = _paint_structs[edi];
|
||||
ps_next = _paint_struct_quadrants[edi];
|
||||
if (ps_next != NULL) {
|
||||
ps->next_quadrant_ps = ps_next;
|
||||
do {
|
||||
@@ -952,7 +944,7 @@ static void paint_attached_ps(paint_struct* ps, attached_paint_struct* attached_
|
||||
/* rct2: 0x00688485 */
|
||||
void paint_quadrant_ps() {
|
||||
rct_drawpixelinfo* dpi = unk_140E9A8;
|
||||
paint_struct* ps = unk_EE7884;
|
||||
paint_struct* ps = &unk_EE7884->basic;
|
||||
paint_struct* previous_ps = ps->next_quadrant_ps;
|
||||
|
||||
for (ps = ps->next_quadrant_ps; ps;) {
|
||||
|
||||
@@ -24,22 +24,8 @@
|
||||
#include "../drawing/drawing.h"
|
||||
|
||||
typedef struct attached_paint_struct attached_paint_struct;
|
||||
struct paint_struct;
|
||||
typedef struct paint_struct paint_struct;
|
||||
|
||||
#ifdef NO_RCT2
|
||||
extern void *g_currently_drawn_item;
|
||||
extern paint_struct * g_ps_EE7880;
|
||||
extern sint16 gUnk9DE568;
|
||||
extern sint16 gUnk9DE56C;
|
||||
extern paint_struct gUnkF1A4CC;
|
||||
#else
|
||||
#define g_currently_drawn_item RCT2_GLOBAL(0x009DE578, void*)
|
||||
#define g_ps_EE7880 RCT2_GLOBAL(0x00EE7880, paint_struct *)
|
||||
#define gUnk9DE568 RCT2_GLOBAL(0x009DE568, sint16)
|
||||
#define gUnk9DE56C RCT2_GLOBAL(0x009DE56C, sint16)
|
||||
#define gUnkF1A4CC RCT2_GLOBAL(0x00F1A4CC, paint_struct);
|
||||
#endif
|
||||
typedef union paint_entry paint_entry;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/* size 0x12 */
|
||||
@@ -114,6 +100,12 @@ assert_struct_size(paint_string_struct, 0x1e);
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
|
||||
union paint_entry{
|
||||
paint_struct basic;
|
||||
attached_paint_struct attached;
|
||||
paint_string_struct string;
|
||||
};
|
||||
|
||||
typedef struct sprite_bb {
|
||||
uint32 sprite_id;
|
||||
rct_xyz16 offset;
|
||||
@@ -131,6 +123,20 @@ typedef struct support_height {
|
||||
uint8 pad;
|
||||
} support_height;
|
||||
|
||||
#ifdef NO_RCT2
|
||||
extern void *g_currently_drawn_item;
|
||||
extern paint_entry * gEndOfPaintStructArray;
|
||||
extern sint16 gUnk9DE568;
|
||||
extern sint16 gUnk9DE56C;
|
||||
extern paint_entry gPaintStructs[4000];
|
||||
#else
|
||||
#define gPaintStructs RCT2_ADDRESS(0x00EE788C, paint_entry)
|
||||
#define g_currently_drawn_item RCT2_GLOBAL(0x009DE578, void*)
|
||||
#define gEndOfPaintStructArray RCT2_GLOBAL(0x00EE7880, paint_entry *)
|
||||
#define gUnk9DE568 RCT2_GLOBAL(0x009DE568, sint16)
|
||||
#define gUnk9DE56C RCT2_GLOBAL(0x009DE56C, sint16)
|
||||
#endif
|
||||
|
||||
#ifndef NO_RCT2
|
||||
#define gPaintInteractionType RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8)
|
||||
#define gSupportSegments RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_SUPPORT_SEGMENTS, support_height)
|
||||
|
||||
@@ -2310,7 +2310,7 @@ static void sub_6CBCE2(
|
||||
gCurrentViewportFlags = 0;
|
||||
trackDirection &= 3;
|
||||
|
||||
g_ps_EE7880 = &gUnkF1A4CC;
|
||||
gEndOfPaintStructArray = &gPaintStructs[4000 - 1];
|
||||
painter_setup();
|
||||
|
||||
ride = get_ride(rideIndex);
|
||||
|
||||
Reference in New Issue
Block a user