From 0dcf6ce87a4f8b718e4ead6c6f5373d4c9aeb056 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 29 Apr 2016 12:55:23 +0200 Subject: [PATCH] Implement `paint_68818E` --- src/interface/paint.c | 49 ++++++++++++++++++++++++++++++++-------- src/interface/paint.h | 18 ++++++++++++++- src/interface/viewport.c | 4 ++++ 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/src/interface/paint.c b/src/interface/paint.c index 60fc0acfb0..b89a2b7924 100644 --- a/src/interface/paint.c +++ b/src/interface/paint.c @@ -1,4 +1,5 @@ #include "paint.h" +#include "../addresses.h" /** * rct2: 0x006881D0 @@ -14,23 +15,23 @@ bool paint_6881D0(uint32 image_id, uint16 x, uint16 y) return paint_68818E(image_id, x, y, NULL); } - paint_struct * ps = RCT2_GLOBAL(0xEE7888, paint_struct * ); + attached_paint_struct * ps = RCT2_GLOBAL(0xEE7888, attached_paint_struct *); if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { return false; } ps->image_id = image_id; - ps->attached_x = x; - ps->attached_y = y; - ps->var_0C = 0; + ps->x = x; + ps->y = y; + ps->flags = 0; - paint_struct * ebx = RCT2_GLOBAL(0xF1AD2C, paint_struct * ); + attached_paint_struct * ebx = RCT2_GLOBAL(0xF1AD2C, attached_paint_struct *); - ps->next_attached_ps = NULL; - ebx->next_attached_ps = ps; + ps->next = NULL; + ebx->next = ps; - RCT2_GLOBAL(0xF1AD2C, paint_struct * ) = ps; + RCT2_GLOBAL(0xF1AD2C, attached_paint_struct *) = ps; RCT2_GLOBAL(0xEE7888, uint32) += 0x12; @@ -46,7 +47,37 @@ bool paint_6881D0(uint32 image_id, uint16 x, uint16 y) * @param[out] paint (ebp) * @return (!CF) success */ -bool paint_68818E(uint32 image_id, uint16 x, uint16 y, paint_struct ** paint) +bool paint_68818E(uint32 image_id, uint16 x, uint16 y, attached_paint_struct ** paint) { + //Not a paint struct but something similar + attached_paint_struct * ps = RCT2_GLOBAL(0xEE7888, attached_paint_struct *); + + if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { + return false; + } + + ps->image_id = image_id; + ps->x = x; + ps->y = y; + ps->flags = 0; + + attached_paint_struct * ebx2 = RCT2_GLOBAL(0xF1AD28, attached_paint_struct *); + if (ebx2 == NULL) { + return false; + } + + RCT2_GLOBAL(0x00EE7888, uint32) += 0x12; + + attached_paint_struct * edi = ebx2->next; + ebx2->next = ps; + + ps->next = edi; + + RCT2_GLOBAL(0xF1AD2C, attached_paint_struct *) = ps; + + if (paint != NULL) { + *paint = ps; + } + return true; } diff --git a/src/interface/paint.h b/src/interface/paint.h index a1d920c478..867b18f10b 100644 --- a/src/interface/paint.h +++ b/src/interface/paint.h @@ -3,7 +3,23 @@ #include "../common.h" +typedef struct attached_paint_struct attached_paint_struct; + +struct attached_paint_struct { + uint32 image_id; // 0x00 + union { + uint32 tertiary_colour; + // If masked image_id is masked_id + uint32 colour_image_id; + }; + uint16 x; // 0x08 + uint16 y; // 0x0A + uint8 flags; // 0x0C + uint8 pad_0D; + attached_paint_struct* next; //0x0E +}; + bool paint_6881D0(uint32 image_id, uint16 x, uint16 y); -bool paint_68818E(uint32 image_id, uint16 x, uint16 y, paint_struct ** paint); +bool paint_68818E(uint32 image_id, uint16 x, uint16 y, attached_paint_struct ** paint); #endif diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 1ed4a23ae8..00d89235c5 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -32,6 +32,10 @@ #include "../world/footpath.h" #include "../world/scenery.h" #include "paint_surface.h" +#include "colour.h" +#include "paint.h" +#include "viewport.h" +#include "window.h" //#define DEBUG_SHOW_DIRTY_BOX