From 3d6988b0f79966bb701c865b3b645ccc3d680fb2 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 2 Jul 2015 18:39:32 +0100 Subject: [PATCH] isolate callprocs in rct1.c and add reset cash function --- src/editor.c | 2 +- src/management/finance.c | 11 ++++- src/management/finance.h | 1 + src/rct1.c | 88 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 91 insertions(+), 11 deletions(-) diff --git a/src/editor.c b/src/editor.c index 46707139c2..8209478e56 100644 --- a/src/editor.c +++ b/src/editor.c @@ -475,7 +475,7 @@ static int editor_read_s6(const char *path) ); RCT2_GLOBAL(0x013573DC, uint32) = min(RCT2_GLOBAL(0x013573DC, uint32), 100000); - RCT2_CALLPROC_EBPSAFE(0x0069E89B); + finance_reset_cash_to_initial(); sub_69E869(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) = clamp( diff --git a/src/management/finance.c b/src/management/finance.c index 1de6204ec8..8762949036 100644 --- a/src/management/finance.c +++ b/src/management/finance.c @@ -350,4 +350,13 @@ void finance_shift_expenditure_table() { } // Invalidate the expenditure table window window_invalidate_by_number(0x1C, 0); -} \ No newline at end of file +} + +/** + * + * rct2: 0x0069E89B + */ +void finance_reset_cash_to_initial() +{ + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32) = ENCRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32)); +} diff --git a/src/management/finance.h b/src/management/finance.h index 16291ab7b5..fb4755a0cc 100644 --- a/src/management/finance.h +++ b/src/management/finance.h @@ -62,6 +62,7 @@ void finance_init(); void finance_update_daily_profit(); void finance_shift_expenditure_table(); void sub_69E869(); +void finance_reset_cash_to_initial(); void finance_set_loan(money32 loan); money32 finance_get_initial_cash(); diff --git a/src/rct1.c b/src/rct1.c index da29a29f83..349b2d0768 100644 --- a/src/rct1.c +++ b/src/rct1.c @@ -52,6 +52,13 @@ static void rct1_reset_research(); static void sub_69F06A(); static void sub_666DFD(); +static void sub_69F007(); +static void sub_69F44B(); +static void sub_69F143(); +static void sub_69F2D0(); +static void sub_69F3AB(); +static void sub_6A2730(); +static void sub_69E891(); static void read(void *dst, void *src, int length) { @@ -182,7 +189,7 @@ void rct1_fix_landscape() rct_sprite *sprite; rct_ride *ride; - RCT2_CALLPROC_EBPSAFE(0x0069F007); + sub_69F007(); // Free sprite user strings for (i = 0; i < MAX_SPRITES; i++) { @@ -202,16 +209,16 @@ void rct1_fix_landscape() RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_GUEST_CHANGE_MODIFIER, uint8) = 0; - RCT2_CALLPROC_EBPSAFE(0x0069F44B); + sub_69F44B(); sub_69F06A(); - RCT2_CALLPROC_EBPSAFE(0x0069F143); - RCT2_CALLPROC_EBPSAFE(0x0069F2D0); - RCT2_CALLPROC_EBPSAFE(0x0069F3AB); + sub_69F143(); + sub_69F2D0(); + sub_69F3AB(); rct1_remove_rides(); object_unload_all(); rct1_load_default_objects(); reset_loaded_objects(); - RCT2_CALLPROC_EBPSAFE(0x006A2730); + sub_6A2730(); rct1_fix_scenery(); rct1_fix_terrain(); rct1_fix_entrance_positions(); @@ -252,7 +259,7 @@ void rct1_fix_landscape() MONEY(10000,00), RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32) ); - RCT2_CALLPROC_EBPSAFE(0x0069E89B); + finance_reset_cash_to_initial(); sub_69E869(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) = clamp( @@ -466,7 +473,7 @@ static void sub_69F06A() } if (!(RCT2_GLOBAL(0x013CE770, uint32) & (1 << 6))) { RCT2_GLOBAL(0x013CE770, uint32) |= (1 << 6); - RCT2_CALLPROC_EBPSAFE(0x0069E891); + sub_69E891(); } RCT2_GLOBAL(0x013CE770, uint32) |= (1 << 7); if (!(RCT2_GLOBAL(0x013CE770, uint32) & (1 << 8))) { @@ -475,7 +482,7 @@ static void sub_69F06A() } if (!(RCT2_GLOBAL(0x013CE770, uint32) & (1 << 9))) { RCT2_GLOBAL(0x013CE770, uint32) |= (1 << 9); - RCT2_CALLPROC_EBPSAFE(0x0069E89B); + finance_reset_cash_to_initial(); } if (!(RCT2_GLOBAL(0x013CE770, uint32) & (1 << 13))) { RCT2_GLOBAL(0x013CE770, uint32) |= (1 << 13); @@ -518,6 +525,69 @@ static void sub_666DFD() } while (!map_element_is_last_for_tile(mapElement++)); } +/** + * + * rct2: 0x0069F007 + */ +static void sub_69F007() +{ + RCT2_CALLPROC_EBPSAFE(0x0069F007); +} + +/** + * + * rct2: 0x0069F44B + */ +static void sub_69F44B() +{ + RCT2_CALLPROC_EBPSAFE(0x0069F44B); +} + +/** + * + * rct2: 0x0069F143 + */ +static void sub_69F143() +{ + RCT2_CALLPROC_EBPSAFE(0x0069F143); +} + +/** + * + * rct2: 0x0069F2D0 + */ +static void sub_69F2D0() +{ + RCT2_CALLPROC_EBPSAFE(0x0069F2D0); +} + +/** + * + * rct2: 0x0069F3AB + */ +static void sub_69F3AB() +{ + RCT2_CALLPROC_EBPSAFE(0x0069F3AB); +} + +/** + * + * rct2: 0x006A2730 + */ +static void sub_6A2730() +{ + RCT2_CALLPROC_EBPSAFE(0x006A2730); +} + +/** + * + * rct2: 0x0069E891 + */ +static void sub_69E891() +{ + RCT2_CALLPROC_EBPSAFE(0x0069E891); +} + #pragma region Tables const uint8 RCT1TerrainConvertTable[16] = {