1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Merge remote-tracking branch 'remotes/remote/master'

This commit is contained in:
zsilencer
2014-08-24 14:50:11 -06:00
17 changed files with 2051 additions and 1818 deletions

View File

@@ -1,20 +1,11 @@
SET(CMAKE_SYSTEM_NAME Windows)
if (APPLE)
SET(COMPILER_PREFIX i586-mingw32)
SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++)
SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres)
SET(CMAKE_PKGCONFIG_EXECUTABLE i686-w64-mingw32-pkg-config)
SET(PKG_CONFIG_EXECUTABLE i686-w64-mingw32-pkg-config)
else()
SET(COMPILER_PREFIX i686-w64-mingw32)
SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++)
SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres)
SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
endif (APPLE)
SET(COMPILER_PREFIX i686-w64-mingw32)
SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc)
SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++)
SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres)
SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
# potential flags to make code more similar to MSVC:
# -fshort-wchar -fshort-enums -mms-bitfields
@@ -22,15 +13,19 @@ endif (APPLE)
set(CMAKE_C_FLAGS "-masm=intel -std=gnu99 -fpack-struct=2" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc" CACHE STRING "" FORCE)
include_directories("/usr/include/wine/windows/")
# find and include SDL2
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS})
if(APPLE)
SET(TARGET_ENVIRONMENT /usr/local/mingw-w32-bin_i686-darwin/i686-w64-mingw32)
else()
SET(TARGET_ENVIRONMENT /usr/i686-w64-mingw32)
endif(APPLE)
# here is the target environment located
#SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX})
SET(CMAKE_FIND_ROOT_PATH ${TARGET_ENVIRONMENT})
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search

View File

@@ -49,18 +49,29 @@ if [[ `uname` == "Darwin" ]]; then
sudo ln -s $wine_path /usr/include
fi
mingw_dmg=gcc-4.8.0-qt-4.8.4-for-mingw32.dmg
mingw_path=/usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin
if [[ ! -f $cachedir/$mingw_dmg ]]; then
wget http://crossgcc.rts-software.org/download/gcc-4.8.0-qt-4.8.4-win32/$mingw_dmg --output-document $cachedir/$mingw_dmg
mingw_name=mingw-w32-bin_i686-darwin
mingw_tar=$mingw_name"_20130531".tar.bz2
mingw_path=/usr/local/$mingw_name
if [[ ! -f $cachedir/$mingw_tar ]]; then
wget "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" --output-document $cachedir/$mingw_tar
fi
if [[ ! -d $ming_path ]]; then
if [[ ! -d $mingw_path ]]; then
echo "Open the DMG file and install its contents"
open $cachedir/$mingw_dmg
pushd /usr/local/
sudo mkdir $mingw_name
popd
echo "Extracting contents of $mingw_tar to $mingw_path"
echo "Don't forget to add $mingw_path to your PATH variable!"
sudo tar -xyf $cachedir/$mingw_tar -C $mingw_path
pushd /usr/local
sudo chmod 755 $mingw_name
pushd $mingw_name
sudo find . -type d -exec chmod 755 {} \;
popd
popd
fi
echo "You will need to add $mingw_path to your \$PATH"
elif [[ `uname` == "Linux" ]]; then
sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686
fi

View File

@@ -28,6 +28,7 @@
<ClInclude Include="..\src\game.h" />
<ClInclude Include="..\src\gfx.h" />
<ClInclude Include="..\src\graph.h" />
<ClInclude Include="..\src\input.h" />
<ClInclude Include="..\src\intro.h" />
<ClInclude Include="..\src\language.h" />
<ClInclude Include="..\src\map.h" />
@@ -74,6 +75,7 @@
<ClCompile Include="..\src\game.c" />
<ClCompile Include="..\src\gfx.c" />
<ClCompile Include="..\src\graph.c" />
<ClCompile Include="..\src\input.c" />
<ClCompile Include="..\src\intro.c" />
<ClCompile Include="..\src\language.c" />
<ClCompile Include="..\src\map.c" />

View File

@@ -159,6 +159,9 @@
<ClInclude Include="..\src\staff.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\input.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\game.c">
@@ -377,6 +380,9 @@
<ClCompile Include="..\src\staff.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\input.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@@ -261,6 +261,7 @@
#define RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY 0x013580E7
#define RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH 0x013580E8
#define RCT2_ADDRESS_MAP_MAXIMUM_X_Y 0x01358832
#define RCT2_ADDRESS_MAP_SIZE 0x01358834
#define RCT2_ADDRESS_PARK_SIZE 0x013580EA

View File

@@ -73,7 +73,7 @@ void editor_load()
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
mainWindow = window_get_main();
window_scroll_to_location(mainWindow, 2400, 2400, 112);
mainWindow->flags &= ~WF_3;
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, sint16) = 0;
@@ -120,7 +120,7 @@ void trackdesigner_load()
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
mainWindow = window_get_main();
window_scroll_to_location(mainWindow, 2400, 2400, 112);
mainWindow->flags &= ~WF_3;
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, sint16) = 0;
@@ -158,7 +158,7 @@ void trackmanager_load()
RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create
mainWindow = window_get_main();
window_scroll_to_location(mainWindow, 2400, 2400, 112);
mainWindow->flags &= ~WF_3;
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
RCT2_CALLPROC_EBPSAFE(0x006837E3);
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, sint16) = 0;

1773
src/game.c

File diff suppressed because it is too large Load Diff

View File

@@ -84,6 +84,8 @@ enum GAME_COMMAND {
typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
extern int gGameSpeed;
void game_create_windows();
void game_update();
void game_logic_update();

1765
src/input.c Normal file

File diff suppressed because it is too large Load Diff

27
src/input.h Normal file
View File

@@ -0,0 +1,27 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* 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/>.
*****************************************************************************/
#ifndef _INPUT_H_
#define _INPUT_H_
void game_handle_input();
void game_handle_keyboard_input();
#endif

View File

@@ -102,7 +102,7 @@ void map_init()
RCT2_GLOBAL(0x013CE774, sint16) = 0;
RCT2_GLOBAL(0x013CE776, sint16) = 0;
RCT2_GLOBAL(0x01358830, sint16) = 4768;
RCT2_GLOBAL(0x01358832, sint16) = 5054;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) = 5054;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) = 150;
RCT2_GLOBAL(0x01358836, sint16) = 4767;
RCT2_GLOBAL(0x01359208, sint16) = 7;
@@ -141,7 +141,7 @@ void map_update_tile_pointers()
/**
* Return the absolute height of an element, given its (x,y) coordinates
*
*
* rct2: 0x00662783
*/
int map_element_height(int x, int y)
@@ -168,7 +168,7 @@ int map_element_height(int x, int y)
// Remove the extra height bit
slope &= 0xF;
uint8 quad, quad_extra; // which quadrant the element is in?
sint8 quad, quad_extra; // which quadrant the element is in?
// quad_extra is for extra height tiles
uint8 xl, yl; // coordinates across this tile
@@ -198,7 +198,7 @@ int map_element_height(int x, int y)
quad = TILE_SIZE - yl - xl;
break;
case 8: // NW corner up
quad = xl - yl;
quad = yl - xl;
break;
}
// If the element is in the quadrant with the slope, raise its height
@@ -210,7 +210,7 @@ int map_element_height(int x, int y)
// One side up
switch (slope) {
case 3: // E side up
height += xl / 2;
height += xl / 2 + 1;
break;
case 6: // S side up
height += (TILE_SIZE - yl) / 2;
@@ -233,15 +233,15 @@ int map_element_height(int x, int y)
break;
case 11: // SW corner down
quad_extra = xl + yl;
quad = xl + yl - TILE_SIZE;
quad = xl + yl - TILE_SIZE - 1;
break;
case 13: // SE corner down
quad_extra = TILE_SIZE - xl + yl;
quad = xl - yl;
quad = yl - xl;
break;
case 14: // NE corner down
quad_extra = (TILE_SIZE - xl) + (TILE_SIZE - yl);
quad = TILE_SIZE - yl - xl;
quad = TILE_SIZE - yl - xl - 1;
break;
}
@@ -255,7 +255,6 @@ int map_element_height(int x, int y)
// so we move *down* the slope
if (quad < 0) {
height += quad / 2;
height += 0xFF00;
}
}

View File

@@ -24,8 +24,8 @@
#include "rct2.h"
typedef struct {
uint8 slope;
uint8 terrain;
uint8 slope; //4
uint8 terrain; //5
uint8 grass_length;
uint8 ownership;
} rct_map_element_surface_properties;
@@ -92,10 +92,10 @@ typedef union {
* size: 0x08
*/
typedef struct {
uint8 type;
uint8 flags;
uint8 base_height;
uint8 clearance_height;
uint8 type; //0
uint8 flags; //1
uint8 base_height; //2
uint8 clearance_height; //3
rct_map_element_properties properties;
} rct_map_element;
@@ -177,6 +177,8 @@ enum {
#define MAP_ELEMENT_WATER_HEIGHT_MASK 0x1F
#define MAP_ELEMENT_SURFACE_TERRAIN_MASK 0xE0
#define MAP_MINIMUM_X_Y -256
#define MAX_MAP_ELEMENTS 196608
#define MAX_TILE_MAP_ELEMENT_POINTERS (256 * 256)

View File

@@ -18,9 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <assert.h>
#include "addresses.h"
#include "config.h"
#include "gfx.h"
#include "map.h"
#include "string_ids.h"
#include "sprite.h"
#include "sprites.h"
@@ -219,13 +221,166 @@ void viewport_update_pointers()
*vp = NULL;
}
void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){
//RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, &ecx, &curr_rotation, (int*)&window, (int*)&viewport, &ebp);
sint16 start_x = *x;
sint16 start_y = *y;
sint16 height = 0;
switch (curr_rotation){
case 0:
for (int i = 0; i < 6; ++i){
*x = start_y - start_x / 2 + height;
*y = start_y + start_x / 2 + height;
height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y);
}
break;
case 1:
for (int i = 0; i < 6; ++i){
*x = -start_y - start_x / 2 - height;
*y = start_y - start_x / 2 + height;
height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y);
}
break;
case 2:
for (int i = 0; i < 6; ++i){
*x = -start_y + start_x / 2 - height;
*y = -start_y - start_x / 2 - height;
height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y);
}
break;
case 3:
for (int i = 0; i < 6; ++i){
*x = start_x / 2 + start_y + height;
*y = start_x / 2 - start_y - height;
height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y);
}
break;
}
}
/**
*
* rct2: 0x006E7A3A
*/
void viewport_update_position(rct_window *window)
{
RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, (int)window, 0, 0);
//RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, (int)window, 0, 0);
RCT2_CALLPROC_X(window->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)window, 0, 0);
rct_viewport* viewport = window->viewport;
if (!viewport)return;
if (window->viewport_target_sprite != -1){
rct_sprite* sprite = &g_sprite_list[window->viewport_target_sprite];
int height = map_element_height(sprite->unknown.x, sprite->unknown.y) - 16;
int underground = sprite->unknown.z < height;
RCT2_CALLPROC_X(0x6E7A15, sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, underground, (int)window, (int)viewport, 0);
int center_x, center_y;
center_2d_coordinates(sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, &center_x, &center_y, window->viewport);
RCT2_CALLPROC_X(0x6E7DE1, center_x, center_y, 0, 0, (int)window, (int)viewport, 0);
window_invalidate(window);//Added to force a redraw.
return;
}
sint16 x = viewport->view_width / 2 + window->saved_view_x;
sint16 y = viewport->view_height / 2 + window->saved_view_y;
int curr_rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32);
sub_689174(&x, &y, curr_rotation);
RCT2_CALLPROC_X(0x006E7A15, x, y, 0, 0, (int)window, (int)viewport, 0);
//Clamp to the map minimum value
int at_map_edge = 0;
if (x < MAP_MINIMUM_X_Y){
x = MAP_MINIMUM_X_Y;
at_map_edge = 1;
}
if (y < MAP_MINIMUM_X_Y){
y = MAP_MINIMUM_X_Y;
at_map_edge = 1;
}
//Clamp to the map maximum value (scenario specific)
if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){
x = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16);
at_map_edge = 1;
}
if (y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){
y = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16);
at_map_edge = 1;
}
if (at_map_edge) {
// The &0xFFFF is to prevent the sign extension messing the
// function up.
int z = map_element_height(x & 0xFFFF, y & 0xFFFF);
int _2d_x, _2d_y;
center_2d_coordinates(x, y, z, &_2d_x, &_2d_y, viewport);
if (window->saved_view_x > 0){
_2d_x = min(_2d_x, window->saved_view_x);
}
else{
_2d_x = max(_2d_x, window->saved_view_x);
}
if (window->saved_view_y > 0){
_2d_y = min(_2d_y, window->saved_view_y);
}
else{
_2d_y = max(_2d_y, window->saved_view_y);
}
window->saved_view_x = _2d_x;
window->saved_view_y = _2d_y;
}
x = window->saved_view_x;
y = window->saved_view_y;
if (window->flags & WF_SCROLLING_TO_LOCATION){
// Moves the viewport if focusing in on an item
uint8 flags = 0;
x -= viewport->view_x;
if (x < 0){
x = -x;
flags |= 1;
}
y -= viewport->view_y;
if (y < 0){
y = -y;
flags |= 2;
}
x = (x + 7)/8;
y = (y + 7)/8;
//If we are at the final zoom position
if (!x && !y){
window->flags &= ~WF_SCROLLING_TO_LOCATION;
}
if (flags & 1){
x = -x;
}
if (flags & 2){
y = -y;
}
x += viewport->view_x;
y += viewport->view_y;
}
RCT2_CALLPROC_X(0x6E7DE1, x, y, 0, 0, (int)window, (int)viewport, 0);
}
void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, int left, int top, int right, int bottom);

View File

@@ -1465,3 +1465,34 @@ void window_resize_gui_scenario_editor(int width, int height)
}
}
void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct_widget* widget )
{
#ifdef _MSC_VER
__asm {
push address
push widget
push w
push widgetIndex
mov edi, widget
mov edx, widgetIndex
mov esi, w
call[esp + 12]
add esp, 16
}
#else
__asm__("\
push %[address]\n\
mov edi, %[widget] \n\
mov eax, %[w] \n\
mov edx, %[widgetIndex] \n\
push edi \n\
push eax \n\
push edx \n\
mov esi, %[w] \n\
call [esp+12] \n\
add esp, 16 \n\
" :[address] "+m" (address), [w] "+m" (w), [widget] "+m" (widget), [widgetIndex] "+m" (widgetIndex): : "eax", "esi", "edx", "edi"
);
#endif
}

View File

@@ -260,7 +260,7 @@ typedef enum {
WF_STICK_TO_BACK = (1 << 0),
WF_STICK_TO_FRONT = (1 << 1),
WF_2 = (1 << 2),
WF_3 = (1 << 3),
WF_SCROLLING_TO_LOCATION = (1 << 3),
WF_TRANSPARENT = (1 << 4),
WF_5 = (1 << 5),
WF_RESIZABLE = (1 << 8),
@@ -457,6 +457,7 @@ void window_new_ride_init_vars();
void window_staff_init_vars();
void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event);
void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct_widget* widget);
#ifdef _MSC_VER
#define window_get_register(w) \

View File

@@ -680,6 +680,7 @@ static void window_new_ride_scrollmouseover()
return;
item = window_new_ride_scroll_get_ride_list_item_at(w, x, y);
if (w->new_ride.highlighted_ride_id == *((sint16*)&item))
return;

View File

@@ -521,10 +521,10 @@ void window_peep_viewport_init(rct_window* w){
void window_peep_overview_paint(){
rct_window *w;
rct_drawpixelinfo *dpi;
rct_widget *labelWidget;
//rct_widget *labelWidget;
window_paint_get_registers(w, dpi);
RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, w, dpi, 0);
RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0);
return;
window_draw_widgets(w, dpi);