diff --git a/src/paint/map_element/scenery.c b/src/paint/map_element/scenery.c index 87519f5ec0..d7fb8e4204 100644 --- a/src/paint/map_element/scenery.c +++ b/src/paint/map_element/scenery.c @@ -25,6 +25,20 @@ #include "../../world/map.h" #include "../../world/scenery.h" +static const rct_xy16 offsets[] = { + { 3, 3 }, + { 3, 17 }, + { 17, 3 }, + { 3, 3 } +}; + +static const rct_xy16 lengths[] = { + { 12, 26 }, + { 26, 12 }, + { 12, 26 }, + { 26, 12 } +}; + /** * * rct2: 0x006DFF47 @@ -58,10 +72,10 @@ void scenery_paint(uint8 direction, int height, rct_map_element* mapElement) { if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE) { if (entry->small_scenery.flags & SMALL_SCENERY_FLAG24) { // 6DFFE3: - boxoffset.x = RCT2_ADDRESS(0x009A3E7C, uint16)[direction * 4]; - boxoffset.y = RCT2_ADDRESS(0x009A3E7E, uint16)[direction * 4]; - boxlength.x = RCT2_ADDRESS(0x009A3E8C, uint16)[direction * 4]; - boxlength.y = RCT2_ADDRESS(0x009A3E8E, uint16)[direction * 4]; + boxoffset.x = offsets[direction].x; + boxoffset.y = offsets[direction].y; + boxlength.x = lengths[direction].x; + boxlength.y = lengths[direction].y; x_offset = 3; y_offset = 3; } else { @@ -79,16 +93,18 @@ void scenery_paint(uint8 direction, int height, rct_map_element* mapElement) { boxlength.y = 30; } } + boxoffset.x = x_offset; + boxoffset.y = y_offset; } } else { // 6DFFC2: uint32 ecx = ((mapElement->type >> 6) + get_current_rotation()) & 3; - x_offset = RCT2_ADDRESS(0x009A3E74, sint8)[ecx * 2]; - y_offset = RCT2_ADDRESS(0x009A3E75, sint8)[ecx * 2]; + x_offset = ScenerySubTileOffsets[ecx].x; + y_offset = ScenerySubTileOffsets[ecx].y; + boxoffset.x = x_offset; + boxoffset.y = y_offset; } - // 6E0074: - boxoffset.x = x_offset; - boxoffset.y = y_offset; + // 6E007F: boxlength.z = entry->small_scenery.height - 4; if (boxlength.z < 0) { boxlength.z = -128; diff --git a/src/paint/map_element/scenery_multiple.c b/src/paint/map_element/scenery_multiple.c index 710ec7656b..4244ae9642 100644 --- a/src/paint/map_element/scenery_multiple.c +++ b/src/paint/map_element/scenery_multiple.c @@ -154,6 +154,31 @@ void scenery_multiple_sign_paint_line(const utf8 *str, rct_large_scenery_text *t } } +typedef struct boundbox { + rct_xy16 offset; + rct_xy16 length; +} boundbox; + +static const boundbox s98E3C4[] = { + { 3, 3, 26, 26 }, + { 17, 17, 12, 12 }, + { 17, 3, 12, 12 }, + { 17, 3, 12, 26 }, + { 3, 3, 12, 12 }, + { 3, 3, 26, 26 }, + { 3, 3, 28, 12 }, + { 3, 3, 26, 26 }, + { 3, 17, 12, 12 }, + { 3, 17, 26, 12 }, + { 3, 3, 26, 26 }, + { 3, 3, 26, 26 }, + { 3, 3, 12, 28 }, + { 3, 3, 26, 26 }, + { 3, 3, 26, 26 }, + { 3, 3, 26, 26 }, + { 1, 1, 30, 30 } +}; + /* * * rct2: 0x006B7F0C @@ -193,14 +218,14 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map int esi = 16; if (edi & 0xF00) { edi &= 0xF000; - edi = (edi << direction) | (edi >> (16 - direction)); // rol + edi = rol16(edi, direction); esi = (edi & 0xF) | (edi >> 12); } - boxoffset.x = RCT2_ADDRESS(0x0098E3C4, uint16)[esi * 4]; - boxoffset.y = RCT2_ADDRESS(0x0098E3C6, uint16)[esi * 4]; + boxoffset.x = s98E3C4[esi].offset.x; + boxoffset.y = s98E3C4[esi].offset.y; boxoffset.z = height; - boxlength.x = RCT2_ADDRESS(0x0098E3C8, uint16)[esi * 4]; - boxlength.y = RCT2_ADDRESS(0x0098E3CA, uint16)[esi * 4]; + boxlength.x = s98E3C4[esi].length.x; + boxlength.y = s98E3C4[esi].length.y; boxlength.z = ah; sub_98197C(image_id, 0, 0, boxlength.x, boxlength.y, ah, height, boxoffset.x, boxoffset.y, boxoffset.z, get_current_rotation()); if (entry->large_scenery.var_11 == 0xFF || direction == 1 || direction == 2) { @@ -250,9 +275,9 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map const utf8 *fitStrPtr = fitStr; strncpy(fitStr, scenery_multiple_sign_fit_text(signString, text, true), sizeof(fitStr) - 1); int height = scenery_multiple_sign_text_height(fitStr, text); - utf8 str[5] = {0}; uint32 codepoint; while ((codepoint = utf8_get_next(fitStrPtr, &fitStrPtr)) != 0) { + utf8 str[5] = {0}; utf8_write_codepoint(str, codepoint); scenery_multiple_sign_paint_line(str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - height); y_offset += scenery_multiple_sign_get_glyph(text, codepoint)->height * 2; diff --git a/src/world/map.c b/src/world/map.c index ddbd7e43da..65e0dc74e1 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -2959,8 +2959,8 @@ void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi x2 += 16; y2 += 16; }else{ - x2 += RCT2_ADDRESS(0x009A3E74, uint8)[(quadrant & 3) * 2] - 1; - y2 += RCT2_ADDRESS(0x009A3E75, uint8)[(quadrant & 3) * 2] - 1; + x2 += ScenerySubTileOffsets[quadrant & 3].x - 1; + y2 += ScenerySubTileOffsets[quadrant & 3].y - 1; } int base_height2 = map_element_height(x2, y2); if(base_height2 & 0xFFFF0000){ diff --git a/src/world/scenery.c b/src/world/scenery.c index 49dff01266..9e28b3e21f 100644 --- a/src/world/scenery.c +++ b/src/world/scenery.c @@ -60,6 +60,14 @@ sint16 gSceneryCtrlPressZ; uint8 gSceneryGroundFlags; +// rct2: 0x009A3E74 +const rct_xy8 ScenerySubTileOffsets[] = { + { 7, 7 }, + { 7, 23 }, + { 23, 23 }, + { 23, 7 } +}; + void scenery_increase_age(int x, int y, rct_map_element *mapElement); void scenery_update_tile(int x, int y) diff --git a/src/world/scenery.h b/src/world/scenery.h index 0cdc474b25..3984dff5fa 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -223,6 +223,8 @@ extern sint16 gSceneryCtrlPressZ; extern uint8 gSceneryGroundFlags; +extern const rct_xy8 ScenerySubTileOffsets[]; + extern sint16 window_scenery_tab_entries[20][SCENERY_ENTRIES_BY_TAB + 1]; void init_scenery();