2014-04-02 01:31:55 +02:00
|
|
|
/*****************************************************************************
|
2014-04-27 21:21:55 +02:00
|
|
|
* Copyright (c) 2014 Ted John, Matthias Lanzinger
|
2014-04-02 01:31:55 +02:00
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* This file is part of OpenRCT2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************/
|
2014-05-12 02:45:45 +02:00
|
|
|
|
|
|
|
#pragma warning(disable : 4996) // GetVersionExA deprecated
|
2014-04-02 01:31:55 +02:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <setjmp.h>
|
2014-05-23 14:29:09 +02:00
|
|
|
#ifdef _MSC_VER
|
2014-05-23 01:53:52 +02:00
|
|
|
#include <time.h>
|
2014-05-23 14:29:09 +02:00
|
|
|
#endif
|
2014-04-02 01:31:55 +02:00
|
|
|
#include <windows.h>
|
2014-05-20 12:49:27 +02:00
|
|
|
#include <shlobj.h>
|
2014-04-02 01:31:55 +02:00
|
|
|
#include <SDL.h>
|
|
|
|
#include "addresses.h"
|
2014-05-23 21:04:42 +02:00
|
|
|
#include "audio.h"
|
2014-04-10 01:22:57 +02:00
|
|
|
#include "climate.h"
|
2014-04-08 01:05:05 +02:00
|
|
|
#include "config.h"
|
2014-04-10 01:22:57 +02:00
|
|
|
#include "date.h"
|
2014-04-02 01:31:55 +02:00
|
|
|
#include "game.h"
|
2014-04-02 17:46:58 +02:00
|
|
|
#include "gfx.h"
|
|
|
|
#include "intro.h"
|
2014-04-09 04:09:30 +02:00
|
|
|
#include "map.h"
|
2014-04-08 18:52:39 +02:00
|
|
|
#include "news_item.h"
|
2014-04-10 19:41:35 +02:00
|
|
|
#include "object.h"
|
2014-04-02 17:46:58 +02:00
|
|
|
#include "osinterface.h"
|
2014-04-10 01:22:57 +02:00
|
|
|
#include "park.h"
|
2014-04-02 17:46:58 +02:00
|
|
|
#include "rct2.h"
|
2014-04-09 03:39:28 +02:00
|
|
|
#include "ride.h"
|
2014-04-06 18:45:09 +02:00
|
|
|
#include "scenario.h"
|
2014-04-02 01:31:55 +02:00
|
|
|
#include "title.h"
|
2014-04-23 02:50:40 +02:00
|
|
|
#include "track.h"
|
2014-04-08 18:52:39 +02:00
|
|
|
#include "viewport.h"
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
typedef struct tm tm_t;
|
|
|
|
|
2014-05-23 01:53:52 +02:00
|
|
|
void print_launch_information();
|
2014-04-15 01:50:20 +02:00
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
void rct2_init_directories();
|
|
|
|
void rct2_startup_checks();
|
|
|
|
|
2014-05-03 13:51:45 +02:00
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
static void rct2_init();
|
|
|
|
static void rct2_loop();
|
|
|
|
static void rct2_update();
|
|
|
|
static void rct2_update_2();
|
|
|
|
|
|
|
|
static int _finished;
|
|
|
|
static jmp_buf _end_update_jump;
|
|
|
|
|
|
|
|
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
__declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
|
|
|
{
|
2014-05-23 01:53:52 +02:00
|
|
|
print_launch_information();
|
|
|
|
|
|
|
|
// Begin RCT2
|
2014-04-02 01:31:55 +02:00
|
|
|
RCT2_GLOBAL(0x01423A08, HINSTANCE) = hInstance;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, LPSTR) = lpCmdLine;
|
2014-04-27 13:04:45 +02:00
|
|
|
get_system_info();
|
2014-05-23 21:04:42 +02:00
|
|
|
|
|
|
|
audio_init();
|
|
|
|
audio_get_devices();
|
2014-04-02 01:31:55 +02:00
|
|
|
RCT2_CALLPROC(0x0040502E); // get_dsound_devices()
|
2014-05-03 13:51:45 +02:00
|
|
|
|
2014-05-03 15:04:40 +02:00
|
|
|
config_init();
|
2014-04-02 01:31:55 +02:00
|
|
|
rct2_init();
|
|
|
|
rct2_loop();
|
|
|
|
osinterface_free();
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-23 01:53:52 +02:00
|
|
|
void print_launch_information()
|
|
|
|
{
|
2014-05-23 13:15:08 +02:00
|
|
|
char buffer[32];
|
|
|
|
time_t timer;
|
|
|
|
tm_t* tmInfo;
|
|
|
|
|
2014-05-23 01:53:52 +02:00
|
|
|
// Print version information
|
|
|
|
printf("Starting %s v%s\n", OPENRCT2_NAME, OPENRCT2_VERSION);
|
|
|
|
printf(" %s (%s)\n", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
|
|
|
|
printf(" %s\n\n", OPENRCT2_TIMESTAMP);
|
|
|
|
|
|
|
|
// Print current time
|
2014-05-23 13:15:08 +02:00
|
|
|
time(&timer);
|
|
|
|
tmInfo = localtime(&timer);
|
|
|
|
strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", tmInfo);
|
2014-05-23 01:53:52 +02:00
|
|
|
printf("Time: %s\n", buffer);
|
|
|
|
|
|
|
|
// TODO Print other potential information (e.g. user, hardware)
|
|
|
|
}
|
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
void rct2_loop()
|
|
|
|
{
|
|
|
|
int last_tick = 0;
|
|
|
|
|
|
|
|
_finished = 0;
|
|
|
|
do {
|
|
|
|
if (SDL_GetTicks() - last_tick < 25)
|
|
|
|
continue;
|
|
|
|
last_tick = SDL_GetTicks();
|
|
|
|
|
|
|
|
osinterface_process_messages();
|
|
|
|
rct2_update();
|
|
|
|
osinterface_draw();
|
|
|
|
} while (!_finished);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rct2_finish()
|
|
|
|
{
|
|
|
|
_finished = 1;
|
|
|
|
}
|
|
|
|
|
2014-05-24 01:00:58 +02:00
|
|
|
void rct2_quit() {
|
2014-05-24 21:01:10 +02:00
|
|
|
if (gGeneral_config.confirmation_prompt) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16) = PM_QUIT;
|
|
|
|
window_save_prompt_open();
|
|
|
|
} else
|
|
|
|
rct2_finish();
|
2014-05-24 01:00:58 +02:00
|
|
|
}
|
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
void rct2_init()
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(0x00F663AC, int) = 0;
|
|
|
|
RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*);
|
2014-04-08 18:52:39 +02:00
|
|
|
get_system_time();
|
2014-04-28 22:00:54 +02:00
|
|
|
RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short);
|
|
|
|
RCT2_GLOBAL(0x009DEA6B, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short);
|
2014-04-02 01:31:55 +02:00
|
|
|
rct2_init_directories();
|
|
|
|
rct2_startup_checks();
|
2014-04-26 02:16:32 +02:00
|
|
|
config_reset_shortcut_keys();
|
2014-04-02 01:31:55 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;
|
2014-04-08 01:05:05 +02:00
|
|
|
config_load();
|
2014-04-02 01:31:55 +02:00
|
|
|
// RCT2_CALLPROC_EBPSAFE(0x00674B81); // pointless expansion pack crap
|
2014-05-24 02:34:17 +02:00
|
|
|
object_list_load();
|
2014-04-06 18:45:09 +02:00
|
|
|
scenario_load_list();
|
2014-04-23 02:50:40 +02:00
|
|
|
track_load_list(253);
|
2014-04-04 20:59:32 +02:00
|
|
|
gfx_load_g1();
|
2014-06-12 22:49:59 +02:00
|
|
|
//RCT2_CALLPROC_EBPSAFE(0x006C19AC); //Load character widths
|
2014-06-13 01:02:52 +02:00
|
|
|
gfx_load_character_widths();
|
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
osinterface_init();
|
|
|
|
RCT2_CALLPROC_EBPSAFE(0x006BA8E0); // init_audio();
|
2014-04-08 18:52:39 +02:00
|
|
|
viewport_init_all();
|
2014-04-04 22:46:26 +02:00
|
|
|
news_item_init_queue();
|
2014-05-04 17:31:32 +02:00
|
|
|
get_local_time();
|
2014-05-06 23:04:09 +02:00
|
|
|
reset_park_entrances();
|
|
|
|
reset_saved_strings();
|
2014-06-13 14:04:09 +02:00
|
|
|
RCT2_CALLPROC_EBPSAFE(0x0069EB13); //Sprite list reset/load
|
2014-04-09 03:39:28 +02:00
|
|
|
ride_init_all();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_a();
|
2014-06-13 14:04:09 +02:00
|
|
|
RCT2_CALLPROC_EBPSAFE(0x006BD3A4); //Peep?
|
2014-04-09 04:09:30 +02:00
|
|
|
map_init();
|
2014-04-10 01:22:57 +02:00
|
|
|
park_init();
|
2014-04-02 01:31:55 +02:00
|
|
|
RCT2_CALLPROC_EBPSAFE(0x0066B5C0); // 0x0066B5C0 (part of 0x0066B3E8) screen_game_create_windows()
|
2014-04-10 01:22:57 +02:00
|
|
|
date_reset();
|
|
|
|
climate_reset(CLIMATE_COOL_AND_WET);
|
2014-04-02 01:31:55 +02:00
|
|
|
RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
|
2014-05-10 00:11:51 +02:00
|
|
|
window_new_ride_init_vars();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_b();
|
2014-05-08 22:48:31 +02:00
|
|
|
window_staff_init_vars();
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2014-04-03 04:08:06 +02:00
|
|
|
title_load();
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2014-04-02 17:46:58 +02:00
|
|
|
gfx_clear(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 10);
|
2014-05-20 18:26:02 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) = gGeneral_config.play_intro ? 8 : 255;
|
2014-04-02 01:31:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// rct2: 0x00683499
|
|
|
|
void rct2_init_directories()
|
|
|
|
{
|
2014-05-03 15:04:40 +02:00
|
|
|
// check install directory
|
2014-05-27 16:48:15 +02:00
|
|
|
if ( !osinterface_directory_exists(gGeneral_config.game_path) ) {
|
2014-05-09 11:40:06 +02:00
|
|
|
osinterface_show_messagebox("Invalid RCT2 installation path. Please correct in config.ini.");
|
2014-05-03 15:04:40 +02:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:29:16 +02:00
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char), gGeneral_config.game_path);
|
2014-04-02 01:31:55 +02:00
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
|
|
|
|
strcat(RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), "\\");
|
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
|
|
|
|
strcat(RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH, char), "\\Saved Games\\");
|
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_SCENARIOS_PATH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
|
|
|
|
strcat(RCT2_ADDRESS(RCT2_ADDRESS_SCENARIOS_PATH, char), "\\Scenarios\\*.SC6");
|
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_LANDSCAPES_PATH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
|
|
|
|
strcat(RCT2_ADDRESS(RCT2_ADDRESS_LANDSCAPES_PATH, char), "\\Landscapes\\*.SC6");
|
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_OBJECT_DATA_PATH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
|
|
|
|
strcat(RCT2_ADDRESS(RCT2_ADDRESS_OBJECT_DATA_PATH, char), "\\ObjData\\*.DAT");
|
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char), RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
|
|
|
|
strcat(RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char), "\\Tracks\\*.TD?");
|
|
|
|
|
|
|
|
strcpy(RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2, char), RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH, char));
|
|
|
|
}
|
|
|
|
|
2014-05-24 00:52:13 +02:00
|
|
|
void subsitute_path(char *dest, const char *path, const char *filename)
|
|
|
|
{
|
|
|
|
while (*path != '*') {
|
|
|
|
*dest++ = *path++;
|
|
|
|
}
|
|
|
|
strcpy(dest, filename);
|
|
|
|
}
|
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
// rct2: 0x00674B42
|
|
|
|
void rct2_startup_checks()
|
|
|
|
{
|
2014-06-19 13:51:54 +02:00
|
|
|
// Check if game is already running
|
|
|
|
if (check_mutex())
|
|
|
|
{
|
|
|
|
RCT2_ERROR("Game is already running");
|
|
|
|
RCT2_CALLPROC_X(0x006E3838, 0x343, 0xB2B, 0, 0, 0, 0, 0); // exit_with_error
|
|
|
|
}
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2014-06-19 13:52:34 +02:00
|
|
|
// Check data files
|
|
|
|
// TODO: implement check_file_paths @ 0x00674C95
|
|
|
|
check_files_integrity();
|
2014-04-02 01:31:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void rct2_update()
|
|
|
|
{
|
2014-04-06 18:45:09 +02:00
|
|
|
// Set 0x009DE564 to the value of esp
|
|
|
|
// RCT2 sets the stack pointer to the value of this address when ending the current game tick from anywhere
|
2014-05-19 22:53:14 +02:00
|
|
|
#ifdef _MSC_VER
|
2014-04-02 01:31:55 +02:00
|
|
|
__asm {
|
|
|
|
mov eax, 009DE564h
|
2014-04-06 18:45:09 +02:00
|
|
|
mov [eax], esp
|
2014-04-02 01:31:55 +02:00
|
|
|
}
|
2014-05-19 22:53:14 +02:00
|
|
|
#else
|
|
|
|
__asm__ ( "\
|
|
|
|
\n\
|
|
|
|
mov eax, 0x009DE564 \n\
|
|
|
|
mov [eax], esp \n\
|
|
|
|
" : : : "eax" );
|
|
|
|
#endif
|
2014-04-02 01:31:55 +02:00
|
|
|
|
|
|
|
if (!setjmp(_end_update_jump))
|
|
|
|
rct2_update_2();
|
|
|
|
}
|
|
|
|
|
2014-05-02 14:32:44 +02:00
|
|
|
void check_cmdline_arg()
|
|
|
|
{
|
|
|
|
if(RCT2_GLOBAL(0x009AC310, uint32) == 0xFFFFFFFF)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char *arg = RCT2_GLOBAL(0x009AC310, char *);
|
|
|
|
char processed_arg[255];
|
|
|
|
int len, i, j;
|
|
|
|
int quote = 0;
|
|
|
|
int last_period = 0;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x009AC310, uint32) = 0xFFFFFFFF;
|
|
|
|
len = strlen(arg);
|
|
|
|
|
|
|
|
for(i = 0, j = 0; i < len; i ++)
|
|
|
|
{
|
|
|
|
if(arg[i] == '\"')
|
|
|
|
{
|
|
|
|
if(quote)
|
|
|
|
quote = 0;
|
|
|
|
else
|
|
|
|
quote = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(arg[i] == ' ' && !quote)
|
|
|
|
break;
|
|
|
|
if(arg[i] == '.')
|
|
|
|
last_period = i;
|
|
|
|
processed_arg[j ++] = arg[i];
|
|
|
|
}
|
|
|
|
processed_arg[j ++] = 0;
|
|
|
|
|
2014-05-12 02:45:45 +02:00
|
|
|
if (!_stricmp(processed_arg + last_period, "sv6"))
|
2014-05-02 14:32:44 +02:00
|
|
|
{
|
2014-05-12 02:45:45 +02:00
|
|
|
strcpy((char*)0x00141EF68, processed_arg);
|
2014-05-04 17:21:15 +02:00
|
|
|
game_load_save();
|
2014-05-02 14:32:44 +02:00
|
|
|
}
|
2014-05-12 02:45:45 +02:00
|
|
|
else if (!_stricmp(processed_arg + last_period, "sc6"))
|
2014-05-02 14:32:44 +02:00
|
|
|
{
|
|
|
|
//TODO: scenario install
|
|
|
|
}
|
2014-05-12 02:45:45 +02:00
|
|
|
else if (!_stricmp(processed_arg + last_period, "td6") || !_stricmp(processed_arg + last_period, "td4"))
|
2014-05-02 14:32:44 +02:00
|
|
|
{
|
|
|
|
//TODO: track design install
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-19 13:51:54 +02:00
|
|
|
// rct2: 0x00407DB0
|
|
|
|
int check_mutex()
|
|
|
|
{
|
|
|
|
const char * const mutex_name = "RollerCoaster Tycoon 2_GSKMUTEX"; // rct2 @ 0x009AAC3D + 0x009A8B50
|
|
|
|
|
|
|
|
HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, mutex_name);
|
|
|
|
|
|
|
|
if (mutex != NULL)
|
|
|
|
{
|
|
|
|
// Already running
|
|
|
|
CloseHandle(mutex);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE status = CreateMutex(NULL, FALSE, mutex_name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-19 13:52:34 +02:00
|
|
|
// rct2: 0x00674C0B
|
|
|
|
void check_files_integrity()
|
|
|
|
{
|
|
|
|
int i = 0;
|
2014-06-28 20:44:33 +02:00
|
|
|
while (files_to_check[i].pathId != PATH_ID_END)
|
2014-06-19 13:52:34 +02:00
|
|
|
{
|
|
|
|
WIN32_FIND_DATA find_data;
|
2014-06-28 20:44:33 +02:00
|
|
|
const char * path = get_file_path(files_to_check[i].pathId);
|
2014-06-19 13:52:34 +02:00
|
|
|
HANDLE file = FindFirstFile(path, &find_data);
|
|
|
|
|
2014-06-28 20:44:33 +02:00
|
|
|
if (file == INVALID_HANDLE_VALUE || find_data.nFileSizeLow != files_to_check[i].fileSize)
|
2014-06-19 13:52:34 +02:00
|
|
|
{
|
|
|
|
if (file != INVALID_HANDLE_VALUE)
|
|
|
|
FindClose(file);
|
|
|
|
RCT2_ERROR("Integrity check failed for %s", path);
|
|
|
|
RCT2_CALLPROC_X(0x006E3838, 0x343, 0x337, 0, 0, 0, 0, 0); // exit_with_error
|
|
|
|
}
|
|
|
|
|
|
|
|
FindClose(file);
|
|
|
|
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
void rct2_update_2()
|
|
|
|
{
|
|
|
|
int tick, tick2;
|
|
|
|
|
|
|
|
tick = timeGetTime();
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x009DE588, sint16) = tick2 = tick - RCT2_GLOBAL(0x009DE580, sint32);
|
|
|
|
if (RCT2_GLOBAL(0x009DE588, sint16) > 500)
|
|
|
|
RCT2_GLOBAL(0x009DE588, sint16) = 500;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x009DE580, sint32) = tick;
|
|
|
|
if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0)
|
|
|
|
RCT2_GLOBAL(0x009DE584, sint32) += tick2;
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0)
|
|
|
|
RCT2_GLOBAL(0x009DE584, sint32) += tick2;
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0)
|
|
|
|
RCT2_GLOBAL(0x009DE588, sint16) = 31;
|
|
|
|
|
|
|
|
// TODO: screenshot countdown process
|
|
|
|
|
2014-05-02 14:32:44 +02:00
|
|
|
check_cmdline_arg();
|
2014-04-02 01:31:55 +02:00
|
|
|
// Screens
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) != 0)
|
|
|
|
intro_update();
|
|
|
|
else if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)
|
|
|
|
title_update();
|
|
|
|
else
|
|
|
|
game_update();
|
2014-04-04 20:59:32 +02:00
|
|
|
}
|
|
|
|
|
2014-04-09 18:06:47 +02:00
|
|
|
void rct2_endupdate()
|
|
|
|
{
|
|
|
|
longjmp(_end_update_jump, 0);
|
|
|
|
}
|
|
|
|
|
2014-04-04 20:59:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00674E6C
|
|
|
|
*/
|
2014-06-15 15:10:35 +02:00
|
|
|
const char *get_file_path(int pathId)
|
2014-04-04 20:59:32 +02:00
|
|
|
{
|
2014-06-15 15:10:35 +02:00
|
|
|
static char path[MAX_PATH]; // get_file_path_buffer @ 0x009E3605
|
2014-04-04 20:59:32 +02:00
|
|
|
|
2014-06-15 15:10:35 +02:00
|
|
|
// The original implementation has a check for 0x009AA0B1 here. That flag is set
|
|
|
|
// by check_file_path if the file cannot be found in its default location, but this
|
|
|
|
// only seems to be the case for versions that require a CD-ROM. Therefore it has
|
|
|
|
// been removed.
|
|
|
|
strcpy(path, gGeneral_config.game_path);
|
|
|
|
|
|
|
|
// Make sure base path is terminated with a slash
|
|
|
|
if (strlen(path) == 0 || path[strlen(path) - 1] != '\\')
|
|
|
|
{
|
|
|
|
if (strlen(path) >= MAX_PATH - 1)
|
|
|
|
{
|
|
|
|
RCT2_ERROR("Path for %s too long", file_paths[pathId]);
|
|
|
|
path[0] = '\0';
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcat(path, "\\");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Concatenate file path
|
|
|
|
if (strlen(path) + strlen(file_paths[pathId]) > MAX_PATH)
|
|
|
|
{
|
|
|
|
RCT2_ERROR("Path for %s too long", file_paths[pathId]);
|
|
|
|
path[0] = '\0';
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcat(path, file_paths[pathId]);
|
|
|
|
|
|
|
|
return path;
|
2014-04-08 18:52:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-27 13:04:45 +02:00
|
|
|
/**
|
|
|
|
* Obtains basic system versions and capabilities.
|
|
|
|
* rct2: 0x004076B1
|
|
|
|
*/
|
|
|
|
void get_system_info()
|
|
|
|
{
|
|
|
|
OSVERSIONINFO versionInfo;
|
|
|
|
SYSTEM_INFO sysInfo;
|
|
|
|
MEMORYSTATUS memInfo;
|
|
|
|
|
|
|
|
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
2014-04-27 16:47:52 +02:00
|
|
|
if (GetVersionEx(&versionInfo)) {
|
2014-04-27 13:04:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_PLATFORM_ID, uint32) = versionInfo.dwPlatformId;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_MAJOR_VERSION, uint32) = versionInfo.dwMajorVersion;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_MINOR_VERSION, uint32) = versionInfo.dwMinorVersion;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_BUILD_NUMBER, uint32) = versionInfo.dwBuildNumber;
|
2014-04-27 16:47:52 +02:00
|
|
|
} else {
|
2014-04-27 13:04:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_PLATFORM_ID, uint32) = -1;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_MAJOR_VERSION, uint32) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_MINOR_VERSION, uint32) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_BUILD_NUMBER, uint32) = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetSystemInfo(&sysInfo);
|
|
|
|
// RCT2 only has 2 bytes reserved for OEM_ID even though it should be a DWORD
|
2014-05-12 02:45:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SYS_OEM_ID, uint16) = (uint16)sysInfo.dwOemId;
|
2014-04-27 13:04:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_LEVEL, uint16) = sysInfo.wProcessorLevel;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_REVISION, uint16) = sysInfo.wProcessorRevision;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_NUMBER, uint32) = sysInfo.dwNumberOfProcessors;
|
|
|
|
|
|
|
|
GlobalMemoryStatus(&memInfo);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PHYSICAL, uint32) = memInfo.dwTotalPhys;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_PAGEFILE, uint32) = memInfo.dwTotalPageFile;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_VIRTUAL, uint32) = memInfo.dwTotalVirtual;
|
|
|
|
|
2014-05-20 12:49:27 +02:00
|
|
|
DWORD size = 80;
|
2014-05-12 02:45:45 +02:00
|
|
|
GetUserName((char*)RCT2_ADDRESS_OS_USER_NAME, &size);
|
2014-04-27 13:04:45 +02:00
|
|
|
size = 80;
|
2014-05-12 02:45:45 +02:00
|
|
|
GetComputerName((char*)RCT2_ADDRESS_OS_COMPUTER_NAME, &size);
|
2014-04-27 13:04:45 +02:00
|
|
|
|
|
|
|
// Screen Display Width/Height but RCT_ADDRESS_SCREEN_HEIGHT/WIDTH already taken?
|
|
|
|
RCT2_GLOBAL(0x01423C08, sint32) = GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
RCT2_GLOBAL(0x01423C0C, sint32) = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
|
|
|
|
HDC screenHandle = GetDC(NULL);
|
2014-04-27 16:47:52 +02:00
|
|
|
if (screenHandle) {
|
2014-04-27 13:04:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_CAP_BPP, sint32) = GetDeviceCaps(screenHandle, BITSPIXEL);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_CAP_RASTER_STRETCH, sint32) = GetDeviceCaps(screenHandle, RASTERCAPS) >> 8;
|
|
|
|
ReleaseDC(NULL, screenHandle);
|
2014-04-27 16:47:52 +02:00
|
|
|
} else {
|
2014-04-27 13:04:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_CAP_BPP, sint32) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_CAP_RASTER_STRETCH, sint32) = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x01423C1C, uint32) = (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_CAP_BPP, sint32) >= 8);
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_OS_MAJOR_VERSION, uint32) < 4 || RCT2_GLOBAL(0x1423C10, sint32) < 4)
|
|
|
|
RCT2_GLOBAL(0x1423C18, sint32) = 0;
|
|
|
|
else
|
|
|
|
RCT2_GLOBAL(0x1423C18, sint32) = 1;
|
|
|
|
|
2014-05-19 21:34:54 +02:00
|
|
|
RCT2_GLOBAL(0x01423C20, uint32) = (SDL_HasMMX() == SDL_TRUE);
|
2014-04-27 13:04:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-08 18:52:39 +02:00
|
|
|
/**
|
|
|
|
* Obtains os system time (day, month, year and day of the week).
|
|
|
|
* rct2: 0x00407671
|
|
|
|
*/
|
|
|
|
void get_system_time()
|
|
|
|
{
|
|
|
|
SYSTEMTIME systime;
|
|
|
|
|
|
|
|
GetSystemTime(&systime);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, sint16) = systime.wDay;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, sint16) = systime.wMonth;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_YEAR, sint16) = systime.wYear;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAYOFWEEK, sint16) = systime.wDayOfWeek;
|
2014-04-04 20:59:32 +02:00
|
|
|
}
|
|
|
|
|
2014-05-04 17:31:32 +02:00
|
|
|
/**
|
|
|
|
* Obtains os local time (hour and minute)
|
|
|
|
* rct2: 0x006C45E7;
|
|
|
|
*/
|
|
|
|
void get_local_time()
|
|
|
|
{
|
|
|
|
SYSTEMTIME systime;
|
|
|
|
GetLocalTime(&systime);
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_HOUR, sint16) = systime.wHour;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MINUTE, sint16) = systime.wMinute;
|
|
|
|
}
|
|
|
|
|
2014-04-04 20:59:32 +02:00
|
|
|
/**
|
2014-04-06 18:45:09 +02:00
|
|
|
* RCT2 and this DLL can not free each other's allocated memory blocks. Use this to allocate memory if RCT2 is still able to
|
|
|
|
* free it.
|
2014-04-04 20:59:32 +02:00
|
|
|
* rct2: 0x004068B2
|
|
|
|
*/
|
|
|
|
void *rct2_malloc(size_t numBytes)
|
|
|
|
{
|
|
|
|
return RCT2_CALLFUNC_1(0x004068B2, void*, size_t, numBytes);
|
2014-04-06 18:45:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RCT2 and this DLL can not free each other's allocated memory blocks. Use this to reallocate memory if RCT2 is still able to
|
|
|
|
* free it.
|
|
|
|
* rct2: 0x004068BD
|
|
|
|
*/
|
|
|
|
void *rct2_realloc(void *block, size_t numBytes)
|
|
|
|
{
|
|
|
|
return RCT2_CALLFUNC_2(0x004068BD, void*, void*, size_t, block, numBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RCT2 and this DLL can not free each other's allocated memory blocks. Use this to free memory that was allocated by RCT2.
|
|
|
|
* rct2: 0x004068DE
|
|
|
|
*/
|
|
|
|
void rct2_free(void *block)
|
|
|
|
{
|
2014-04-08 18:52:39 +02:00
|
|
|
RCT2_CALLPROC_1(0x004068DE, void*, block);
|
2014-04-21 11:27:48 +02:00
|
|
|
}
|