diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index fdded5c766..4c8261d196 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -8,12 +8,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ @@ -22,6 +22,8 @@ #include "../interface/window.h" #include "../interface/viewport.h" #include "../game.h" +#include "../ride/track.h" +#include "../drawing/drawing.h" /* move to ride.c */ void sub_6b2fa9(rct_windownumber number){ @@ -47,8 +49,11 @@ enum { void window_construction_emptysub(){} void window_construction_close(); void window_construction_mouseup(); +void window_construction_paint(); void window_construction_maze_close(); +void window_construction_maze_invalidate(); +void window_construction_maze_paint(); // 0x993F6C static void* window_construction_maze_events[] = { @@ -77,8 +82,8 @@ static void* window_construction_maze_events[] = { window_construction_emptysub, window_construction_emptysub, window_construction_emptysub, - (void*)0x6CD435, - (void*)0x6CD45B, + window_construction_maze_invalidate, + window_construction_maze_paint, window_construction_emptysub }; @@ -110,12 +115,12 @@ static void* window_construction_events[] = { window_construction_emptysub, window_construction_emptysub, (void*)0x6C6AD5, - (void*)0x6C6B86, + window_construction_paint,//(void*)0x6C6B86, window_construction_emptysub }; /** - * + * * rct2: 0x006CB481 */ rct_window *window_construction_open() @@ -177,7 +182,7 @@ rct_window *window_construction_open() RCT2_GLOBAL(0xF440CE, uint8) = 30; } - RCT2_GLOBAL(0xF440A0,uint16) = RCT2_ADDRESS(0x0097CC68, uint8)[ride->type * 2] | 0x100; + RCT2_GLOBAL(0xF440A0, uint16) = RCT2_ADDRESS(0x0097CC68, uint8)[ride->type * 2] | 0x100; RCT2_GLOBAL(0x00F440B2, uint8) = 0; RCT2_GLOBAL(0x00F440B3, uint8) = 0; RCT2_GLOBAL(0x00F440B4, uint8) = 0; @@ -240,7 +245,7 @@ void window_construction_maze_close(){ RCT2_GLOBAL(0x9DE58A, uint16) &= 0xFFFD; hide_gridlines(); - + uint8 ride_id = RCT2_GLOBAL(0xF440A7, uint8); rct_ride* ride = GET_RIDE(ride_id); @@ -325,3 +330,164 @@ void window_construction_mouseup_demolish(rct_window* w){ //6c9BFE } +void window_construction_maze_invalidate() +{ + int ride_idx = RCT2_GLOBAL(0x00F440A7, uint8); + RCT2_GLOBAL(0x13CE958, uint32_t) = RCT2_GLOBAL(0x1362944 + ride_idx * 0x260, uint32_t); + RCT2_GLOBAL(0x13CE956, uint16_t) = RCT2_GLOBAL(0x1362942 + ride_idx * 0x260, uint16_t); +} + +//0x6C6B86 +void window_construction_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + window_paint_get_registers(w, dpi); + //RCT2_CALLPROC_X(0x6C6B86, 0, 0, 0, 0, w, dpi, 0); + //return; + window_draw_widgets(w, dpi); + if (RCT2_GLOBAL(0x9D7C00, uint8_t) == 0) return; + uint32_t eax = 0, esi = (uint32_t)w, ebp = 0;//nothing + uint32_t ebx = 0, ecx = 0, edx = 0, edi = (uint32_t)dpi;//returns + if (RCT2_CALLFUNC_X(0x6CA2DF, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp) &0x100) return; + RCT2_GLOBAL(0xF44133, uint8_t) = edx & 0xFF; + RCT2_GLOBAL(0xF44134, uint8_t) = (ebx >> 8) & 0xFF; + RCT2_GLOBAL(0xF44135, uint8_t) = (edx >> 8) & 0xFF; + edx >>= 16; + RCT2_GLOBAL(0xF44136, int16_t) = edx; + eax = RCT2_GLOBAL(0xF44133, uint8_t); + eax *= 0x260; + eax = RCT2_GLOBAL(RCT2_ADDRESS_RIDE_LIST + eax, uint8_t); + eax = RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + eax * 8, uint32_t); + RCT2_GLOBAL(0xF44064, uint32_t) = eax; + rct_drawpixelinfo* clip_dpi = clip_drawpixelinfo( + dpi, + w->x + RCT2_GLOBAL(0x9D7C02, int16_t) + 1, + RCT2_GLOBAL(0x9D7C04, int16_t) - RCT2_GLOBAL(0x9D7C02, int16_t) - 1, + w->y + RCT2_GLOBAL(0x9D7C06, int16_t) + 1, + RCT2_GLOBAL(0x9D7C08, int16_t) - RCT2_GLOBAL(0x9D7C06, int16_t) - 1); + if (clip_dpi != NULL) + { + short bp = RCT2_GLOBAL(0x9D7C04, int16_t) - RCT2_GLOBAL(0x9D7C02, int16_t) - 1; + short si = RCT2_GLOBAL(0x9D7C08, int16_t) - RCT2_GLOBAL(0x9D7C06, int16_t) - 1; + rct_preview_track *trackBlock; + ecx = RCT2_GLOBAL(0xF44135, uint8_t); + if (RCT2_GLOBAL(0xF44064, uint32_t) & 0x80000) + { + trackBlock = RCT2_GLOBAL(0x994A38 + ecx * 4, rct_preview_track*); + } + else trackBlock = RCT2_GLOBAL(0x994638 + ecx * 4, rct_preview_track*); + while (true) + { + if (trackBlock[1].var_00 == 0xFF) break; + trackBlock++; + } + //TODO: change these names + short ax = trackBlock->x; + short dx = ((uint16_t*)&trackBlock->pad_05)[0]; + short cx = trackBlock->y; + if (trackBlock->unk_09 & 2) ax = cx = 0; + short tmp; + switch (RCT2_GLOBAL(0xF44134, uint8_t) & 3) + { + case 1: + tmp = ax; + ax = cx; + cx = -tmp; + break; + case 2: + ax = -ax; + cx = -cx; + break; + case 3: + tmp = ax; + ax = -cx; + cx = tmp; + break; + case 0: + break; + } + //this is actually case 0, but the other cases all jump to it + ax /= 2; + cx /= 2; + ax += 4112; + cx += 4112; + dx += 1024; + ebx = RCT2_GLOBAL(0xF44135, uint8_t); + short bx; + if (RCT2_GLOBAL(0xF44064, uint32_t) & 0x80000) + bx = RCT2_GLOBAL(0x9984A2 + ebx * 8, uint8_t); + else bx = RCT2_GLOBAL(0x997CA2 + ebx * 8, uint8_t); + dx -= bx; + switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) + { + case 0: + bx = ax; + ax = -ax; + ax += cx; + cx += bx; + cx /= 2; + cx -= dx; + break; + case 1: + ax = -ax; + bx = ax; + ax -= cx; + cx += bx; + cx /= 2; + cx -= dx; + break; + case 2: + bx = ax; + ax -= cx; + cx = -cx; + cx -= bx; + cx /= 2; + cx -= dx; + break; + case 3: + bx = ax; + ax += cx; + cx = -cx; + cx += bx; + cx /= 2; + cx -= dx; + break; + } + bp >>= 1; + si >>= 1; + si += 16; + ax -= bp; + cx -= si; + clip_dpi->x += ax; + clip_dpi->y += cx; + RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*) = clip_dpi; + uint32_t d = RCT2_GLOBAL(0xF44136, int16_t) << 16; + d |= RCT2_GLOBAL(0xF44133, uint8_t); + d |= RCT2_GLOBAL(0xF44135, uint8_t) << 8; + RCT2_CALLPROC_X(0x6CBCE2, 0x1000, (((uint16_t)bx) & 0xFF) | (RCT2_GLOBAL(0xF44134, uint8_t) << 8), 0x1000, d, si, 0x400, bp); + } + short cx = (RCT2_GLOBAL(0x9D7C02, int16_t) + RCT2_GLOBAL(0x9D7C04, int16_t)) / 2 + w->x; + short dx = RCT2_GLOBAL(0x9D7C08, int16_t) + w->y - 23; + if (RCT2_GLOBAL(0xF440A6, uint8_t) != 4) + { + gfx_draw_string_centred(dpi, 1407, cx, dx, 0, w); + } + dx += 11; + if (RCT2_GLOBAL(0xF44070, uint32_t) != 0x80000000) + { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32_t) & 0x800)) + { + gfx_draw_string_centred(dpi, 1408, cx, dx, 0, (void*)0xF44070); + } + } +} + +//0x006CD45B +void window_construction_maze_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + window_paint_get_registers(w, dpi); + window_draw_widgets(w, dpi); +} \ No newline at end of file