add editor loading

This commit is contained in:
IntelOrca 2014-04-09 17:06:47 +01:00
parent 0402ffe6fc
commit 481b8e23c0
12 changed files with 199 additions and 8 deletions

View File

@ -113,6 +113,8 @@
#define RCT2_ADDRESS_NEWS_ITEM_LIST 0x013CA754
#define RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS 0x013CE9A4
#define RCT2_ADDRESS_SCENARIO_NAME 0x0141F5B8
#define RCT2_ADDRESS_SCENARIO_DETAILS 0x0141F5F8

View File

@ -19,7 +19,17 @@
*****************************************************************************/
#include "addresses.h"
#include "date.h"
#include "editor.h"
#include "gfx.h"
#include "map.h"
#include "news_item.h"
#include "park.h"
#include "ride.h"
#include "window.h"
#include "viewport.h"
static void set_all_land_owned();
/**
*
@ -27,7 +37,39 @@
*/
void editor_load()
{
RCT2_CALLPROC_EBPSAFE(0x0066FFE1);
rct_window *mainWindow;
RCT2_CALLPROC_EBPSAFE(0x006BABB4);
RCT2_CALLPROC_EBPSAFE(0x006BABD8);
RCT2_CALLPROC_EBPSAFE(0x006A9CE8);
map_init();
RCT2_CALLPROC_EBPSAFE(0x006B9CB0);
RCT2_CALLPROC_EBPSAFE(0x00667104);
RCT2_CALLPROC_EBPSAFE(0x006C4209);
RCT2_CALLPROC_EBPSAFE(0x0069EB13);
ride_init_all();
RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a
RCT2_CALLPROC_EBPSAFE(0x006BD3A4);
park_init();
RCT2_CALLPROC_EBPSAFE(0x0069DEFB);
date_reset();
RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b
RCT2_CALLPROC_EBPSAFE(0x006BD39C);
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
RCT2_GLOBAL(0x013573E4, uint32) |= 16;
RCT2_CALLPROC_EBPSAFE(0x006ACA58);
RCT2_GLOBAL(0x0141F571, uint8) = 4;
viewport_init_all();
news_item_init_queue();
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
mainWindow = window_get_main();
RCT2_CALLPROC_X(0x006E7C9C, 0x960, 0, 0x960, 0x70, mainWindow, 0, 0);
mainWindow->flags &= ~0x08;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, sint16) = 0;
rct2_endupdate();
}
/**
@ -45,7 +87,36 @@ void editor_convert_save_to_scenario()
*/
void trackdesigner_load()
{
RCT2_CALLPROC_EBPSAFE(0x00672957);
rct_window *mainWindow;
RCT2_CALLPROC_EBPSAFE(0x006A9CE8);
map_init();
set_all_land_owned();
RCT2_CALLPROC_EBPSAFE(0x006B9CB0);
RCT2_CALLPROC_EBPSAFE(0x00667104);
RCT2_CALLPROC_EBPSAFE(0x006C4209);
RCT2_CALLPROC_EBPSAFE(0x0069EB13);
ride_init_all();
RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a
RCT2_CALLPROC_EBPSAFE(0x006BD3A4);
park_init();
RCT2_CALLPROC_EBPSAFE(0x0069DEFB);
date_reset();
RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b
RCT2_CALLPROC_EBPSAFE(0x006BD39C);
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
RCT2_CALLPROC_EBPSAFE(0x006ACA58);
viewport_init_all();
news_item_init_queue();
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
mainWindow = window_get_main();
RCT2_CALLPROC_X(0x006E7C9C, 0x960, 0, 0x960, 0x70, mainWindow, 0, 0);
mainWindow->flags &= ~0x08;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, sint16) = 0;
rct2_endupdate();
}
/**
@ -54,5 +125,45 @@ void trackdesigner_load()
*/
void trackmanager_load()
{
RCT2_CALLPROC_EBPSAFE(0x006729FD);
rct_window *mainWindow;
RCT2_CALLPROC_EBPSAFE(0x006A9CE8);
map_init();
set_all_land_owned();
RCT2_CALLPROC_EBPSAFE(0x006B9CB0);
RCT2_CALLPROC_EBPSAFE(0x00667104);
RCT2_CALLPROC_EBPSAFE(0x006C4209);
RCT2_CALLPROC_EBPSAFE(0x0069EB13);
ride_init_all();
RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a
RCT2_CALLPROC_EBPSAFE(0x006BD3A4);
park_init();
RCT2_CALLPROC_EBPSAFE(0x0069DEFB);
date_reset();
RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b
RCT2_CALLPROC_EBPSAFE(0x006BD39C);
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
RCT2_CALLPROC_EBPSAFE(0x006ACA58);
viewport_init_all();
news_item_init_queue();
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
mainWindow = window_get_main();
RCT2_CALLPROC_X(0x006E7C9C, 0x960, 0, 0x960, 0x70, mainWindow, 0, 0);
mainWindow->flags &= ~0x08;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, sint16) = 0;
rct2_endupdate();
}
/**
*
* rct2: 0x0068ABEC
*/
static void set_all_land_owned()
{
int mapSize = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16);
RCT2_CALLPROC_X(0x006677F2, 64, 1, 64, 2, 56, (mapSize - 2) * 32, (mapSize - 2) * 32);
}

View File

@ -97,7 +97,7 @@ void game_update()
}
}
}
#include "map.h"
void game_logic_update()
{
short _bx, _dx;
@ -108,6 +108,17 @@ void game_logic_update()
if (RCT2_GLOBAL(0x009DEA66, sint16) == 0)
RCT2_GLOBAL(0x009DEA66, sint16)--;
{
int i;
rct_map_element *mapElement = RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element);
for (i = 0; i < MAX_MAP_ELEMENTS; i++) {
if (mapElement->var_0 == 0) {
// mapElement->var_0 = 2;
}
mapElement++;
}
}
RCT2_CALLPROC_EBPSAFE(0x0068B089);
RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective
RCT2_CALLPROC_EBPSAFE(0x006C46B1); // update_climate

View File

@ -24,6 +24,9 @@
#include "map.h"
#define GET_MAP_ELEMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element)[x]))
#define TILE_MAP_ELEMENT_POINTER(x) (RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[x])
static void tiles_init();
/**
*
@ -38,7 +41,7 @@ void map_init()
RCT2_GLOBAL(0x0138B580, sint16) = 0;
RCT2_GLOBAL(0x010E63B8, sint32) = 0;
for (i = 0; i < MAX_MAP_ELEMENTS; i++) {
for (i = 0; i < MAX_TILE_MAP_ELEMENT_POINTERS; i++) {
map_element = GET_MAP_ELEMENT(i);
map_element->var_0 = 0;
map_element->var_1 = 128;
@ -58,8 +61,35 @@ void map_init()
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) = 150;
RCT2_GLOBAL(0x01358836, sint16) = 4767;
RCT2_GLOBAL(0x01359208, sint16) = 7;
RCT2_CALLPROC_EBPSAFE(0x0068AFFD);
tiles_init();
RCT2_CALLPROC_EBPSAFE(0x0068ADBC);
climate_reset(CLIMATE_WARM);
}
/**
*
* rct2: 0x0068AFFD
*/
static void tiles_init()
{
int i, x, y, lastTile;
for (i = 0; i < MAX_TILE_MAP_ELEMENT_POINTERS; i++)
TILE_MAP_ELEMENT_POINTER(i) = TILE_UNDEFINED_MAP_ELEMENT;
rct_map_element *mapElement = RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element);
rct_map_element **tile = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*);
for (y = 0; y < 256; y++) {
for (x = 0; x < 256; x++) {
*tile++ = mapElement;
do {
lastTile = (mapElement->var_1 & 128);
mapElement++;
} while (!lastTile);
}
}
// Possible next free map element
RCT2_GLOBAL(0x0140E9A4, rct_map_element*) = mapElement;
}

View File

@ -50,7 +50,10 @@ enum {
};
#define MAP_ELEMENT_TYPE_MASK 0x3C
#define MAX_MAP_ELEMENTS 65536
#define MAX_MAP_ELEMENTS 196608
#define MAX_TILE_MAP_ELEMENT_POINTERS (256 * 256)
#define TILE_UNDEFINED_MAP_ELEMENT -1
void map_init();

View File

@ -24,6 +24,15 @@
#include "ride.h"
#include "sprite.h"
/**
*
* rct2: 0x00667132
*/
void park_init()
{
RCT2_CALLPROC_EBPSAFE(0x00667132);
}
/**
*
* rct2: 0x00669EAA

View File

@ -26,6 +26,8 @@
#define DECRYPT_MONEY(money) rol32((money) ^ 0xF4EC9621, 13)
#define ENCRYPT_MONEY(money) (ror32((money), 13) ^ 0xF4EC9621)
void park_init();
int calculate_park_rating();
int calculate_park_value();
int calculate_company_value();

View File

@ -215,6 +215,11 @@ void rct2_update_2()
game_update();
}
void rct2_endupdate()
{
longjmp(_end_update_jump, 0);
}
/**
*
* rct2: 0x00674E6C

View File

@ -114,6 +114,7 @@ enum {
};
void rct2_endupdate();
char *get_file_path(int pathId);
void get_system_time();
void *rct2_malloc(size_t numBytes);

View File

@ -424,6 +424,21 @@ rct_window *window_bring_to_front(rct_window *w)
return w;
}
/**
*
* rct2: 0x006EE2E4
*/
rct_window *window_get_main()
{
rct_window* w;
for (w = RCT2_FIRST_WINDOW; w < RCT2_NEW_WINDOW; w++)
if (w->classification == WC_MAIN_WINDOW)
return w;
return NULL;
}
/**
* Draws a window that is in the specified region.
* rct2: 0x006E756C

View File

@ -281,6 +281,8 @@ int window_get_scroll_data_index(rct_window *w, int widget_index);
rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber number);
rct_window *window_bring_to_front(rct_window *w);
rct_window *window_get_main();
void window_draw(rct_window *w, int left, int top, int right, int bottom);
void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi);

View File

@ -146,7 +146,7 @@ void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 fla
_dropdown_highlighted_index = -1;
RCT2_GLOBAL(0x009DED34, sint32) = 0;
RCT2_GLOBAL(0x009DED38, sint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = 5;
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = INPUT_STATE_DROPDOWN_ACTIVE;
// Copy the following properties until all use of it is decompiled
RCT2_GLOBAL(0x009DEBA0, sint16) = _dropdown_num_items;