Ejemplo n.º 1
0
static int title_load_park(const char *path)
{
	rct_window* w;
	int successfulLoad = 0;

	if (_strcmpi(path_get_extension(path), ".sv6") == 0) {
		SDL_RWops* rw = SDL_RWFromFile(path, "rb");
		if (rw != NULL) {
			successfulLoad = game_load_sv6(rw);
			SDL_RWclose(rw);
		}
	} else {
		successfulLoad = scenario_load(path);
	}

	if (!successfulLoad)
		return 0;

	w = window_get_main();
	w->viewport_target_sprite = -1;
	w->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16);
	w->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16);

	{
		char _cl = (RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) & 0xFF) - w->viewport->zoom;
		w->viewport->zoom = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) & 0xFF;
		*((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) >> 8;
		if (_cl != 0) {
			if (_cl < 0) {
				_cl = -_cl;
				w->viewport->view_width >>= _cl;
				w->viewport->view_height >>= _cl;
			} else {
				w->viewport->view_width <<= _cl;
				w->viewport->view_height <<= _cl;
			}
		}
Ejemplo n.º 2
0
/**
 * 
 *  rct2: 0x00678282
 * scenario (ebx)
 */
void scenario_load_and_play(const rct_scenario_basic *scenario)
{
	rct_window *mainWindow;
	rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;

	// Create the scenario pseduo-random seeds using the current time
	uint32 srand0, srand1;
	srand0 = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_0, uint32) ^ timeGetTime();
	srand1 = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_1, uint32) ^ timeGetTime();

	RCT2_CALLPROC_EBPSAFE(0x006CBCC3);

	subsitute_path(
		RCT2_ADDRESS(0x0141EF68, char),
		RCT2_ADDRESS(RCT2_ADDRESS_SCENARIOS_PATH, char),
		scenario->path
	);
	scenario_load((char*)0x0141EF68);
	RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_PLAYING;
	viewport_init_all();
	game_create_windows();
	mainWindow = window_get_main();

	mainWindow->viewport_target_sprite = -1;
	mainWindow->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16);
	mainWindow->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16);

	uint8 _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - mainWindow->viewport->zoom;
	mainWindow->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF;
	*((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8;
	if (_cl != 0) {
		if (_cl < 0) {
			_cl = -_cl;
			mainWindow->viewport->view_width >>= _cl;
			mainWindow->viewport->view_height >>= _cl;
		} else {
Ejemplo n.º 3
0
/**
 *
 *  rct2: 0x00678761
 */
static void title_update_showcase()
{
	rct_window* w;
	uint8 script_opcode, script_operand;
	short x, y;
	int i, _edx;

	if (_scriptWaitCounter <= 0) {
		do {
			script_opcode = *_currentScript++;
			switch (script_opcode) {
			case TITLE_SCRIPT_WAIT:
				_scriptWaitCounter = (*_currentScript++) * 32;
				break;
			case TITLE_SCRIPT_LOAD:
				scenario_load(get_file_path(PATH_ID_SIXFLAGS_MAGICMOUNTAIN));

				w = window_get_main();
				w->var_4B0 = -1;
				w->var_4B2 = RCT2_GLOBAL(0x0138869A, sint16);
				w->var_4B4 = RCT2_GLOBAL(0x0138869C, sint16);

				{
					char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom;
					w->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF;
					*((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8;
					if (_cl != 0) {
						if (_cl < 0) {
							_cl = -_cl;
							w->viewport->view_width >>= _cl;
							w->viewport->view_height >>= _cl;
						} else {
							w->viewport->view_width <<= _cl;
							w->viewport->view_height <<= _cl;
						}
					}
					w->var_4B2 -= w->viewport->view_width >> 1;
					w->var_4B4 -= w->viewport->view_height >> 1;
				}

				window_invalidate(w);
				RCT2_CALLPROC_EBPSAFE(0x0069E9A7);
				RCT2_CALLPROC_EBPSAFE(0x006ACA58);
				RCT2_CALLPROC_EBPSAFE(0x00684AC3);
				RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
				news_item_init_queue();
				gfx_invalidate_screen();
				RCT2_GLOBAL(0x009DEA66, sint16) = 0;
				RCT2_GLOBAL(0x009DEA5C, sint16) = 0x0D6D8;
				break;
			case TITLE_SCRIPT_LOCATION:
				x = (*_currentScript++) * 32 + 16;
				y = (*_currentScript++) * 32 + 16;

				// Set location
				int eax, ebx, ecx, edx, esi, edi, ebp;
				eax = x;
				ecx = y;
				RCT2_CALLFUNC_X(0x00662783, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
				_edx = edx;

				// Update viewport
				w = window_get_main();
				if (w != NULL) {
					window_scroll_to_location(w, x, y, _edx);
					w->flags &= ~0x08;
					viewport_update_position(w);
				}
				break;
			case TITLE_SCRIPT_ROTATE:
				script_operand = (*_currentScript++);
				w = window_get_main();
				if (w != NULL)
					for (i = 0; i < script_operand; i++)
						window_rotate_camera(w);
				break;
			case TITLE_SCRIPT_RESTART:
				_currentScript = _magicMountainScript;
				if (gRandomShowcase) {
					if (_currentScript != NULL)
						free(_currentScript);
					_currentScript = generate_random_script();
				}
				break;
			}
		} while (_scriptWaitCounter == 0);
Ejemplo n.º 4
0
/**
 *
 *  rct2: 0x00678761
 */
static void title_update_showcase()
{
	rct_window* w;
	uint8 script_opcode, script_operand;
	short x, y, z;
	int i;

	if (_scriptWaitCounter <= 0) {
		do {
			script_opcode = *_currentScript++;
			switch (script_opcode) {
			case TITLE_SCRIPT_WAIT:
				_scriptWaitCounter = (*_currentScript++) * 32;
				break;
			case TITLE_SCRIPT_LOAD:
				if (!scenario_load(get_file_path(PATH_ID_SIXFLAGS_MAGICMOUNTAIN))) {
					log_fatal("OpenRCT2 can not currently cope when unable to load title screen scenario.");
					exit(-1);
				}

				w = window_get_main();
				w->viewport_target_sprite = -1;
				w->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16);
				w->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16);

				{
					char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom;
					w->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF;
					*((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8;
					if (_cl != 0) {
						if (_cl < 0) {
							_cl = -_cl;
							w->viewport->view_width >>= _cl;
							w->viewport->view_height >>= _cl;
						} else {
							w->viewport->view_width <<= _cl;
							w->viewport->view_height <<= _cl;
						}
					}
					w->saved_view_x -= w->viewport->view_width >> 1;
					w->saved_view_y -= w->viewport->view_height >> 1;
				}

				window_invalidate(w);
				sub_69E9A7();
				window_new_ride_init_vars();
				sub_684AC3();
				RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
				news_item_init_queue();
				gfx_invalidate_screen();
				RCT2_GLOBAL(0x009DEA66, sint16) = 0;
				RCT2_GLOBAL(0x009DEA5C, sint16) = 0x0D6D8;
				break;
			case TITLE_SCRIPT_LOCATION:
				x = (*_currentScript++) * 32 + 16;
				y = (*_currentScript++) * 32 + 16;
				z = map_element_height(x, y);

				// Update viewport
				w = window_get_main();
				if (w != NULL) {
					window_scroll_to_location(w, x, y, z);
					w->flags &= ~0x08;
					viewport_update_position(w);
				}
				break;
			case TITLE_SCRIPT_ROTATE:
				script_operand = (*_currentScript++);
				w = window_get_main();
				if (w != NULL)
					for (i = 0; i < script_operand; i++)
						window_rotate_camera(w);
				break;
			case TITLE_SCRIPT_RESTART:
				_currentScript = _magicMountainScript;
				if (gRandomShowcase) {
					if (_currentScript != NULL)
						free((uint8*)_currentScript);
					_currentScript = generate_random_script();
				}
				break;
			}
		} while (_scriptWaitCounter == 0);