From d67afb263b2c03dbf108c0142cdced59cb62dccc Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 14 Aug 2016 15:03:04 +0200 Subject: [PATCH 1/4] Integrate variables for metal supports --- src/paint/supports.c | 105 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 10 deletions(-) diff --git a/src/paint/supports.c b/src/paint/supports.c index ecd0dd475d..d5c6f7e85e 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -44,6 +44,91 @@ const rct_xy16 loc_97B052[] = { {-1, -26} }; +/** rct2: 0x0097B062, 0x0097B063 */ +const rct_xy8 _97B062[] = { + { 18, 3 }, + { 3, 18 }, + { 18, 3 }, + { 3, 18 }, + { 32, 3 }, + { 3, 32 }, + { 32, 3 }, + { 3, 32 } +}; + +/** rct2: 0x0097B072 */ +const uint32 _97B072[][8] = { + { 3370, 3371, 3370, 3371, 3372, 3373, 3372, 3373 }, + { 3374, 3375, 3374, 3375, 3376, 3377, 3376, 3377 }, + { 3374, 3375, 3374, 3375, 3376, 3377, 3376, 3377 }, + { 3370, 3371, 3370, 3371, 3372, 3373, 3372, 3373 }, + { 3374, 3375, 3374, 3375, 3376, 3377, 3376, 3377 }, + { 3374, 3375, 3374, 3375, 3376, 3377, 3376, 3377 }, + { 3378, 3383, 3378, 3383, 3380, 3385, 3380, 3385 }, + { 3378, 3383, 3378, 3383, 3380, 3385, 3380, 3385 }, + { 3382, 3379, 3382, 3379, 3384, 3381, 3384, 3381 }, + { 3382, 3379, 3382, 3379, 3384, 3381, 3384, 3381 }, + { 3378, 3379, 3378, 3379, 3380, 3381, 3380, 3381 }, + { 3386, 3387, 3386, 3387, 3388, 3389, 3388, 3389 }, + { 3370, 3371, 3370, 3371, 3372, 3373, 3372, 3373 }, +}; + +/** rct2: 0x0097B142 */ +static const uint8 word_97B142[] = { + 6, + 3, + 3, + 6, + 3, + 3, + 6, + 6, + 6, + 6, + 4, + 3, + 6, +}; + +/** rct2: 0x0097B15C */ +static const uint32 _97B15C[][2] = { + { 3243, 3209 }, + { 3279, 3262 }, + { 3298, 3262 }, + { 3334, 3317 }, + { 0, 3658 }, + { 0, 3658 }, + { 0, 3141 }, + { 0, 3158 }, + { 0, 3175 }, + { 0, 3192 }, + { 0, 3124 }, + { 3243, 3209 }, + { 3334, 3353 }, +}; + +/** rct2: 0x0097B190 */ +static const uint32 _97B190[][2] = { + { 3243, 3226 }, // 3209 + { 3279, 3262 }, + { 3298, 3262 }, + { 3334, 3317 }, + { 0, 3658 }, + { 0, 3658 }, + { 0, 3141 }, + { 0, 3158 }, + { 0, 3175 }, + { 0, 3192 }, + { 0, 3124 }, + { 3243, 3226 }, // 3209 + { 3334, 3353 }, +}; + +/** rct2: 0x0097B404 */ +static const uint8 metal_supports_slope_image_map[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, + 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 16, 0, 17, 18, 0, +}; typedef struct supports_id_desc { uint16 full; @@ -370,7 +455,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int if (height < gSupportSegments[segment].height){ RCT2_GLOBAL(0x009E3294, sint16) = height; - height -= RCT2_ADDRESS(0x0097B142, sint16)[supportType]; + height -= word_97B142[supportType]; if (height < 0) return false; @@ -402,10 +487,10 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int xOffset += loc_97B052[ebp].x; yOffset += loc_97B052[ebp].y; - sint16 boundBoxLengthX = RCT2_ADDRESS(0x0097B062, uint8)[ebp * 2]; - sint16 boundBoxLengthY = RCT2_ADDRESS(0x0097B062 + 1, uint8)[ebp * 2]; + sint16 boundBoxLengthX = _97B062[ebp].x; + sint16 boundBoxLengthY = _97B062[ebp].y; - uint32 image_id = RCT2_ADDRESS(0x0097B072, uint16)[supportType * 8 + ebp]; + uint32 image_id = _97B072[supportType][ebp]; image_id |= imageColourFlags; sub_98196C(image_id, xOffset, yOffset, boundBoxLengthX, boundBoxLengthY, 1, height, rotation); @@ -414,7 +499,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint16 si = height; if (gSupportSegments[segment].slope & (1 << 5) || height - gSupportSegments[segment].height < 6 || - RCT2_ADDRESS(0x0097B15C, uint16)[supportType * 2] == 0 + _97B15C[supportType][0] == 0 ) { height = gSupportSegments[segment].height; @@ -422,8 +507,8 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = RCT2_ADDRESS(0x0097B15C, uint16)[supportType * 2]; - image_id += RCT2_ADDRESS(0x0097B404, sint16)[gSupportSegments[segment].slope & 0x1F]; + uint32 image_id = _97B15C[supportType][0]; + image_id += metal_supports_slope_image_map[gSupportSegments[segment].slope & 0x1F]; image_id |= imageColourFlags; sub_98196C(image_id, xOffset, yOffset, 0, 0, 5, gSupportSegments[segment].height, rotation); @@ -445,7 +530,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = RCT2_ADDRESS(0x0097B15C + 2, uint16)[supportType * 2]; + uint32 image_id = _97B15C[supportType][1]; image_id += heightDiff - 1; image_id |= imageColourFlags; @@ -472,7 +557,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = RCT2_ADDRESS(0x0097B15C + 2, uint16)[supportType * 2]; + uint32 image_id = _97B15C[supportType][1]; image_id += z - 1; image_id |= imageColourFlags; @@ -514,7 +599,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = RCT2_ADDRESS(0x0097B15C + 2, uint16)[supportType * 2]; + uint32 image_id = _97B190[supportType][1]; image_id += z - 1; image_id |= imageColourFlags; From 3ff3db13f4a2de49f3abc5b4d47c7ea415fcc9b1 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 14 Aug 2016 21:38:30 +0200 Subject: [PATCH 2/4] Integrate data at 0x0097AF32 --- src/paint/supports.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/paint/supports.c b/src/paint/supports.c index d5c6f7e85e..79ab7c7aae 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -32,6 +32,49 @@ const rct_xy8 loc_97AF20[] = { {16, 28} }; +/** rct2: 0x0097AF32 */ +static const uint8 _97AF32[] = { + 5, 2, 5, 2, 5, 2, 5, 2, + 7, 1, 7, 1, 7, 1, 7, 1, + 6, 3, 6, 3, 6, 3, 6, 3, + 8, 0, 8, 0, 8, 0, 8, 0, + 5, 3, 6, 0, 8, 1, 7, 2, + 1, 2, 1, 2, 1, 2, 1, 2, + 0, 3, 0, 3, 0, 3, 0, 3, + 3, 1, 3, 1, 3, 1, 3, 1, + 2, 0, 2, 0, 2, 0, 2, 0, + + 6, 1, 6, 1, 6, 1, 6, 1, + 5, 0, 5, 0, 5, 0, 5, 0, + 8, 2, 8, 2, 8, 2, 8, 2, + 7, 3, 7, 3, 7, 3, 7, 3, + 6, 0, 8, 1, 7, 2, 5, 3, + 0, 0, 0, 0, 0, 0, 0, 0, + 2, 1, 2, 1, 2, 1, 2, 1, + 1, 3, 1, 3, 1, 3, 1, 3, + 3, 2, 3, 2, 3, 2, 3, 2, + + 1, 6, 1, 6, 1, 6, 1, 6, + 3, 5, 3, 5, 3, 5, 3, 5, + 0, 7, 0, 7, 0, 7, 0, 7, + 2, 4, 2, 4, 2, 4, 2, 4, + 8, 1, 7, 2, 5, 3, 6, 0, + 4, 1, 4, 1, 4, 1, 4, 1, + 4, 2, 4, 2, 4, 2, 4, 2, + 4, 0, 4, 0, 4, 0, 4, 0, + 4, 3, 4, 3, 4, 3, 4, 3, + + 2, 5, 2, 5, 2, 5, 2, 5, + 0, 4, 0, 4, 0, 4, 0, 4, + 3, 6, 3, 6, 3, 6, 3, 6, + 1, 7, 1, 7, 1, 7, 1, 7, + 7, 2, 5, 3, 6, 0, 8, 1, + 8, 5, 8, 5, 8, 5, 8, 5, + 7, 6, 7, 6, 7, 6, 7, 6, + 6, 4, 6, 4, 6, 4, 6, 4, + 5, 7, 5, 7, 5, 7, 5, 7, +}; + /** rct2: 0x0097B052, 0x0097B053 */ const rct_xy16 loc_97B052[] = { {-15, -1}, @@ -459,7 +502,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int if (height < 0) return false; - uint8* esi = &(RCT2_ADDRESS(0x0097AF32, uint8)[rotation * 2]); + uint8* esi = &_97AF32[rotation * 2]; uint8 newSegment = esi[segment * 8]; if (height <= gSupportSegments[newSegment].height) { From 30fa5851e511e52772bef13721408c9a99e04cfb Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 14 Aug 2016 21:38:48 +0200 Subject: [PATCH 3/4] Return false if there was no space for supports --- src/paint/supports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/paint/supports.c b/src/paint/supports.c index 79ab7c7aae..e9e1877a2b 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -517,7 +517,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int if (height <= gSupportSegments[newSegment].height) { esi += 72; newSegment = esi[segment * 8]; - return true; + return false; } } } From 98fc9c29b9c6043442adbc37ba91bfd68a4b839c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 14 Aug 2016 22:08:20 +0200 Subject: [PATCH 4/4] Name struct fields --- src/paint/supports.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/paint/supports.c b/src/paint/supports.c index e9e1877a2b..c9f522a677 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -133,8 +133,13 @@ static const uint8 word_97B142[] = { 6, }; +typedef struct metal_supports_images { + uint16 base_id; + uint16 beam_id; +} metal_supports_images; + /** rct2: 0x0097B15C */ -static const uint32 _97B15C[][2] = { +static const metal_supports_images _97B15C[] = { { 3243, 3209 }, { 3279, 3262 }, { 3298, 3262 }, @@ -151,7 +156,7 @@ static const uint32 _97B15C[][2] = { }; /** rct2: 0x0097B190 */ -static const uint32 _97B190[][2] = { +static const metal_supports_images _97B190[] = { { 3243, 3226 }, // 3209 { 3279, 3262 }, { 3298, 3262 }, @@ -502,7 +507,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int if (height < 0) return false; - uint8* esi = &_97AF32[rotation * 2]; + const uint8* esi = &(_97AF32[rotation * 2]); uint8 newSegment = esi[segment * 8]; if (height <= gSupportSegments[newSegment].height) { @@ -542,7 +547,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint16 si = height; if (gSupportSegments[segment].slope & (1 << 5) || height - gSupportSegments[segment].height < 6 || - _97B15C[supportType][0] == 0 + _97B15C[supportType].base_id == 0 ) { height = gSupportSegments[segment].height; @@ -550,7 +555,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = _97B15C[supportType][0]; + uint32 image_id = _97B15C[supportType].base_id; image_id += metal_supports_slope_image_map[gSupportSegments[segment].slope & 0x1F]; image_id |= imageColourFlags; @@ -573,7 +578,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = _97B15C[supportType][1]; + uint32 image_id = _97B15C[supportType].beam_id; image_id += heightDiff - 1; image_id |= imageColourFlags; @@ -600,7 +605,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = _97B15C[supportType][1]; + uint32 image_id = _97B15C[supportType].beam_id; image_id += z - 1; image_id |= imageColourFlags; @@ -642,7 +647,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint8 xOffset = loc_97AF20[segment].x; sint8 yOffset = loc_97AF20[segment].y; - uint32 image_id = _97B190[supportType][1]; + uint32 image_id = _97B190[supportType].beam_id; image_id += z - 1; image_id |= imageColourFlags;