Merge branch 'reorganise-src'

This commit is contained in:
IntelOrca 2014-10-07 21:33:34 +01:00
commit 6d023dc40c
148 changed files with 6146 additions and 5589 deletions

View File

@ -26,12 +26,12 @@ project(${PROJECT})
add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}")
add_definitions(-DHAVE_CONFIG_H)
# include lodepng header
include_directories("lodepng/")
# include lib
include_directories("lib/")
# include speex header
include_directories("libspeex/")
include_directories("lib/libspeex/")
# add source files
file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "libspeex/*.c" "lodepng/*.c")
file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/*.c")
if (UNIX)
# force 32bit build for now and set necessary flags to compile code as is

View File

@ -14,147 +14,6 @@
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\addresses.h" />
<ClInclude Include="..\src\audio.h" />
<ClInclude Include="..\src\award.h" />
<ClInclude Include="..\src\climate.h" />
<ClInclude Include="..\src\config.h" />
<ClInclude Include="..\src\currency.h" />
<ClInclude Include="..\src\cursors.h" />
<ClInclude Include="..\src\date.h" />
<ClInclude Include="..\src\editor.h" />
<ClInclude Include="..\src\finance.h" />
<ClInclude Include="..\src\game.h" />
<ClInclude Include="..\src\gfx.h" />
<ClInclude Include="..\src\graph.h" />
<ClInclude Include="..\src\hook.h" />
<ClInclude Include="..\src\input.h" />
<ClInclude Include="..\src\intro.h" />
<ClInclude Include="..\src\language.h" />
<ClInclude Include="..\src\map.h" />
<ClInclude Include="..\src\marketing.h" />
<ClInclude Include="..\src\mixer.h" />
<ClInclude Include="..\src\news_item.h" />
<ClInclude Include="..\src\object.h" />
<ClInclude Include="..\src\osinterface.h" />
<ClInclude Include="..\src\park.h" />
<ClInclude Include="..\src\peep.h" />
<ClInclude Include="..\src\rct2.h" />
<ClInclude Include="..\src\research.h" />
<ClInclude Include="..\src\ride.h" />
<ClInclude Include="..\src\ride_data.h" />
<ClInclude Include="..\src\ride_ratings.h" />
<ClInclude Include="..\src\sawyercoding.h" />
<ClInclude Include="..\src\scenario.h" />
<ClInclude Include="..\src\scenery.h" />
<ClInclude Include="..\src\screenshot.h" />
<ClInclude Include="..\src\sprite.h" />
<ClInclude Include="..\src\sprites.h" />
<ClInclude Include="..\src\string_ids.h" />
<ClInclude Include="..\src\title.h" />
<ClInclude Include="..\src\track.h" />
<ClInclude Include="..\src\tutorial.h" />
<ClInclude Include="..\src\util.h" />
<ClInclude Include="..\src\vehicle.h" />
<ClInclude Include="..\src\viewport.h" />
<ClInclude Include="..\src\widget.h" />
<ClInclude Include="..\src\window.h" />
<ClInclude Include="..\src\window_dropdown.h" />
<ClInclude Include="..\src\window_error.h" />
<ClInclude Include="..\src\window_scenery.h" />
<ClInclude Include="..\src\window_tooltip.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="..\src\staff.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\libspeex\resample.c" />
<ClCompile Include="..\lodepng\lodepng.c" />
<ClCompile Include="..\src\audio.c" />
<ClCompile Include="..\src\award.c" />
<ClCompile Include="..\src\climate.c" />
<ClCompile Include="..\src\config.c" />
<ClCompile Include="..\src\currency.c" />
<ClCompile Include="..\src\date.c" />
<ClCompile Include="..\src\editor.c" />
<ClCompile Include="..\src\finance.c" />
<ClCompile Include="..\src\game.c" />
<ClCompile Include="..\src\gfx.c" />
<ClCompile Include="..\src\graph.c" />
<ClCompile Include="..\src\hook.c" />
<ClCompile Include="..\src\input.c" />
<ClCompile Include="..\src\intro.c" />
<ClCompile Include="..\src\language.c" />
<ClCompile Include="..\src\map.c" />
<ClCompile Include="..\src\marketing.c" />
<ClCompile Include="..\src\mixer.cpp" />
<ClCompile Include="..\src\news_item.c" />
<ClCompile Include="..\src\object.c" />
<ClCompile Include="..\src\object_list.c" />
<ClCompile Include="..\src\osinterface.c" />
<ClCompile Include="..\src\park.c" />
<ClCompile Include="..\src\peep.c" />
<ClCompile Include="..\src\rct2.c" />
<ClCompile Include="..\src\research.c" />
<ClCompile Include="..\src\ride.c" />
<ClCompile Include="..\src\ride_data.c" />
<ClCompile Include="..\src\ride_ratings.c" />
<ClCompile Include="..\src\sawyercoding.c" />
<ClCompile Include="..\src\scenario.c" />
<ClCompile Include="..\src\scenario_list.c" />
<ClCompile Include="..\src\screenshot.c" />
<ClCompile Include="..\src\sprite.c" />
<ClCompile Include="..\src\string_ids.c" />
<ClCompile Include="..\src\title.c" />
<ClCompile Include="..\src\track.c" />
<ClCompile Include="..\src\tutorial.c" />
<ClCompile Include="..\src\util.c" />
<ClCompile Include="..\src\vehicle.c" />
<ClCompile Include="..\src\viewport.c" />
<ClCompile Include="..\src\widget.c" />
<ClCompile Include="..\src\window.c" />
<ClCompile Include="..\src\window_about.c" />
<ClCompile Include="..\src\window_banner.c" />
<ClCompile Include="..\src\window_cheats.c" />
<ClCompile Include="..\src\window_clear_scenery.c" />
<ClCompile Include="..\src\window_error.c" />
<ClCompile Include="..\src\window_game_bottom_toolbar.c" />
<ClCompile Include="..\src\window_dropdown.c" />
<ClCompile Include="..\src\window_guest_list.c" />
<ClCompile Include="..\src\window_land.c" />
<ClCompile Include="..\src\window_new_campaign.c" />
<ClCompile Include="..\src\window_news.c" />
<ClCompile Include="..\src\window_park.c" />
<ClCompile Include="..\src\window_finances.c" />
<ClCompile Include="..\src\window_footpath.c" />
<ClCompile Include="..\src\window_map.c" />
<ClCompile Include="..\src\window_new_ride.c" />
<ClCompile Include="..\src\window_options.c" />
<ClCompile Include="..\src\window_peep.c" />
<ClCompile Include="..\src\window_publisher_credits.c" />
<ClCompile Include="..\src\window_research.c" />
<ClCompile Include="..\src\window_ride.c" />
<ClCompile Include="..\src\window_ride_list.c" />
<ClCompile Include="..\src\window_save_prompt.c" />
<ClCompile Include="..\src\window_shortcut_keys.c" />
<ClCompile Include="..\src\window_shortcut_key_change.c" />
<ClCompile Include="..\src\window_staff.c" />
<ClCompile Include="..\src\window_staff_peep.c" />
<ClCompile Include="..\src\window_title_exit.c" />
<ClCompile Include="..\src\window_title_logo.c" />
<ClCompile Include="..\src\window_main.c" />
<ClCompile Include="..\src\window_title_menu.c" />
<ClCompile Include="..\src\window_title_scenarioselect.c" />
<ClCompile Include="..\src\window_game_top_toolbar.c" />
<ClCompile Include="..\src\window_tooltip.c" />
<ClCompile Include="..\src\window_track_list.c" />
<ClCompile Include="..\src\window_track_manage.c" />
<ClCompile Include="..\src\window_track_place.c" />
<ClCompile Include="..\src\window_water.c" />
<ClCompile Include="..\src\staff.c" />
<ClCompile Include="..\src\window_scenery.c" />
<ClCompile Include="..\src\window_music_credits.c" />
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe" />
</ItemGroup>
@ -168,6 +27,169 @@
<Text Include="..\data\language\spanish_sp.txt" />
<Text Include="..\data\language\swedish.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\lib\libspeex\arch.h" />
<ClInclude Include="..\lib\libspeex\config.h" />
<ClInclude Include="..\lib\libspeex\os_support.h" />
<ClInclude Include="..\lib\libspeex\speex\speex_resampler.h" />
<ClInclude Include="..\lib\libspeex\speex\speex_types.h" />
<ClInclude Include="..\lib\libspeex\stack_alloc.h" />
<ClInclude Include="..\lib\lodepng\lodepng.h" />
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c">
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\audio\audio.c" />
<ClCompile Include="..\src\audio\mixer.cpp" />
<ClCompile Include="..\src\config.c" />
<ClCompile Include="..\src\drawing\drawing.c" />
<ClCompile Include="..\src\drawing\line.c" />
<ClCompile Include="..\src\drawing\rect.c" />
<ClCompile Include="..\src\drawing\sprite.c" />
<ClCompile Include="..\src\drawing\string.c" />
<ClCompile Include="..\src\editor.c" />
<ClCompile Include="..\src\game.c" />
<ClCompile Include="..\src\hook.c" />
<ClCompile Include="..\src\input.c" />
<ClCompile Include="..\src\interface\graph.c" />
<ClCompile Include="..\src\interface\screenshot.c" />
<ClCompile Include="..\src\interface\viewport.c" />
<ClCompile Include="..\src\interface\widget.c" />
<ClCompile Include="..\src\interface\window.c" />
<ClCompile Include="..\src\intro.c" />
<ClCompile Include="..\src\localisation\currency.c" />
<ClCompile Include="..\src\localisation\date.c" />
<ClCompile Include="..\src\localisation\language.c" />
<ClCompile Include="..\src\localisation\localisation.c" />
<ClCompile Include="..\src\localisation\real_names.c" />
<ClCompile Include="..\src\management\award.c" />
<ClCompile Include="..\src\management\finance.c" />
<ClCompile Include="..\src\management\marketing.c" />
<ClCompile Include="..\src\management\news_item.c" />
<ClCompile Include="..\src\management\research.c" />
<ClCompile Include="..\src\object.c" />
<ClCompile Include="..\src\object_list.c" />
<ClCompile Include="..\src\peep\peep.c" />
<ClCompile Include="..\src\peep\staff.c" />
<ClCompile Include="..\src\platform\shared.c" />
<ClCompile Include="..\src\platform\unix.c" />
<ClCompile Include="..\src\platform\osinterface.c" />
<ClCompile Include="..\src\platform\osx.c" />
<ClCompile Include="..\src\platform\windows.c" />
<ClCompile Include="..\src\rct2.c" />
<ClCompile Include="..\src\ride\ride.c" />
<ClCompile Include="..\src\ride\ride_data.c" />
<ClCompile Include="..\src\ride\ride_ratings.c" />
<ClCompile Include="..\src\ride\track.c" />
<ClCompile Include="..\src\ride\vehicle.c" />
<ClCompile Include="..\src\scenario.c" />
<ClCompile Include="..\src\scenario_list.c" />
<ClCompile Include="..\src\title.c" />
<ClCompile Include="..\src\tutorial.c" />
<ClCompile Include="..\src\util\sawyercoding.c" />
<ClCompile Include="..\src\util\util.c" />
<ClCompile Include="..\src\windows\about.c" />
<ClCompile Include="..\src\windows\banner.c" />
<ClCompile Include="..\src\windows\cheats.c" />
<ClCompile Include="..\src\windows\clear_scenery.c" />
<ClCompile Include="..\src\windows\dropdown.c" />
<ClCompile Include="..\src\windows\error.c" />
<ClCompile Include="..\src\windows\finances.c" />
<ClCompile Include="..\src\windows\footpath.c" />
<ClCompile Include="..\src\windows\game_bottom_toolbar.c" />
<ClCompile Include="..\src\windows\game_top_toolbar.c" />
<ClCompile Include="..\src\windows\guest_list.c" />
<ClCompile Include="..\src\windows\land.c" />
<ClCompile Include="..\src\windows\main.c" />
<ClCompile Include="..\src\windows\map.c" />
<ClCompile Include="..\src\windows\music_credits.c" />
<ClCompile Include="..\src\windows\news.c" />
<ClCompile Include="..\src\windows\new_campaign.c" />
<ClCompile Include="..\src\windows\new_ride.c" />
<ClCompile Include="..\src\windows\options.c" />
<ClCompile Include="..\src\windows\park.c" />
<ClCompile Include="..\src\windows\guest.c" />
<ClCompile Include="..\src\windows\publisher_credits.c" />
<ClCompile Include="..\src\windows\research.c" />
<ClCompile Include="..\src\windows\ride.c" />
<ClCompile Include="..\src\windows\ride_list.c" />
<ClCompile Include="..\src\windows\save_prompt.c" />
<ClCompile Include="..\src\windows\scenery.c" />
<ClCompile Include="..\src\windows\shortcut_keys.c" />
<ClCompile Include="..\src\windows\shortcut_key_change.c" />
<ClCompile Include="..\src\windows\staff_list.c" />
<ClCompile Include="..\src\windows\staff.c" />
<ClCompile Include="..\src\windows\title_exit.c" />
<ClCompile Include="..\src\windows\title_logo.c" />
<ClCompile Include="..\src\windows\title_menu.c" />
<ClCompile Include="..\src\windows\title_scenarioselect.c" />
<ClCompile Include="..\src\windows\tooltip.c" />
<ClCompile Include="..\src\windows\track_list.c" />
<ClCompile Include="..\src\windows\track_manage.c" />
<ClCompile Include="..\src\windows\track_place.c" />
<ClCompile Include="..\src\windows\water.c" />
<ClCompile Include="..\src\world\climate.c" />
<ClCompile Include="..\src\world\map.c" />
<ClCompile Include="..\src\world\park.c" />
<ClCompile Include="..\src\world\sprite.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\addresses.h" />
<ClInclude Include="..\src\audio\audio.h" />
<ClInclude Include="..\src\audio\mixer.h" />
<ClInclude Include="..\src\common.h" />
<ClInclude Include="..\src\config.h" />
<ClInclude Include="..\src\cursors.h" />
<ClInclude Include="..\src\drawing\drawing.h" />
<ClInclude Include="..\src\editor.h" />
<ClInclude Include="..\src\game.h" />
<ClInclude Include="..\src\hook.h" />
<ClInclude Include="..\src\input.h" />
<ClInclude Include="..\src\interface\graph.h" />
<ClInclude Include="..\src\interface\screenshot.h" />
<ClInclude Include="..\src\interface\viewport.h" />
<ClInclude Include="..\src\interface\widget.h" />
<ClInclude Include="..\src\interface\window.h" />
<ClInclude Include="..\src\intro.h" />
<ClInclude Include="..\src\localisation\currency.h" />
<ClInclude Include="..\src\localisation\date.h" />
<ClInclude Include="..\src\localisation\format_codes.h" />
<ClInclude Include="..\src\localisation\language.h" />
<ClInclude Include="..\src\localisation\localisation.h" />
<ClInclude Include="..\src\localisation\string_ids.h" />
<ClInclude Include="..\src\management\award.h" />
<ClInclude Include="..\src\management\finance.h" />
<ClInclude Include="..\src\management\marketing.h" />
<ClInclude Include="..\src\management\news_item.h" />
<ClInclude Include="..\src\management\research.h" />
<ClInclude Include="..\src\object.h" />
<ClInclude Include="..\src\peep\peep.h" />
<ClInclude Include="..\src\peep\staff.h" />
<ClInclude Include="..\src\platform\osinterface.h" />
<ClInclude Include="..\src\platform\platform.h" />
<ClInclude Include="..\src\rct2.h" />
<ClInclude Include="..\src\ride\ride.h" />
<ClInclude Include="..\src\ride\ride_data.h" />
<ClInclude Include="..\src\ride\ride_ratings.h" />
<ClInclude Include="..\src\ride\track.h" />
<ClInclude Include="..\src\ride\vehicle.h" />
<ClInclude Include="..\src\scenario.h" />
<ClInclude Include="..\src\sprites.h" />
<ClInclude Include="..\src\title.h" />
<ClInclude Include="..\src\tutorial.h" />
<ClInclude Include="..\src\util\sawyercoding.h" />
<ClInclude Include="..\src\util\util.h" />
<ClInclude Include="..\src\windows\dropdown.h" />
<ClInclude Include="..\src\windows\error.h" />
<ClInclude Include="..\src\windows\scenery.h" />
<ClInclude Include="..\src\windows\tooltip.h" />
<ClInclude Include="..\src\world\climate.h" />
<ClInclude Include="..\src\world\map.h" />
<ClInclude Include="..\src\world\park.h" />
<ClInclude Include="..\src\world\scenery.h" />
<ClInclude Include="..\src\world\sprite.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D24D94F6-2A74-480C-B512-629C306CE92F}</ProjectGuid>
<RootNamespace>openrct2</RootNamespace>
@ -204,8 +226,8 @@
<IntDir>$(SolutionDir)..\obj\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)..\lodepng;$(SolutionDir)..\sdl\include;$(SolutionDir)..\libspeex;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)..\sdl\lib\x86;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\lib;$(SolutionDir)..\lib\libspeex;$(SolutionDir)..\lib\sdl\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)..\lib\sdl\lib\x86;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\obj\$(Configuration)\</IntDir>
</PropertyGroup>
@ -237,6 +259,7 @@
</OmitFramePointers>
<BufferSecurityCheck>false</BufferSecurityCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,16 @@
#define RCT2_CALLPROC_4(address, a1, a2, a3, a4, v1, v2, v3, v4) RCT2_CALLFUNC_4(address, void, a1, a2, a3, a4, v1, v2, v3, v4)
#define RCT2_CALLPROC_5(address, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5) RCT2_CALLFUNC_5(address, void, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5)
#pragma region Memory locations
// The following memory locations represent memory in RCT2 that is still used
// by OpenRCT2. Only when the memory is no longer needed due to them being
// stored in a new C module or changed behaviour of code that used them.
// This generally can happen once all functions that referenced the location
// are implemented in C. Sometimes memory locations are still used even if
// they aren't directly referenced, for example when a game is saved and
// loaded, large chunks of data is read and written to.
#define RCT2_ADDRESS_EASTEREGG_NAMES 0x00988C20
#define RCT2_ADDRESS_RIDE_PROPERTIES 0x00997C9D
@ -436,6 +446,24 @@
#define RCT2_ADDRESS_STAFF_MODE_ARRAY 0x013CA672
#pragma endregion
#pragma region Obsolete
// The following addresses relate to memory locations that no longer used by
// OpenRCT2. This may be due to the data at those locations being stored in
// the new C modules or changed behaviour of code that used them.
#define RCT2_ADDRESS_Y_RELATED_GLOBAL_1 0x9E3D12 //uint16
#define RCT2_ADDRESS_Y_END_POINT_GLOBAL 0x9ABDAC //sint16
#define RCT2_ADDRESS_Y_START_POINT_GLOBAL 0xEDF808 //sint16
#define RCT2_ADDRESS_X_RELATED_GLOBAL_1 0x9E3D10 //uint16
#define RCT2_ADDRESS_X_END_POINT_GLOBAL 0x9ABDA8 //sint16
#define RCT2_ADDRESS_X_START_POINT_GLOBAL 0xEDF80C //sint16
#define RCT2_ADDRESS_DPI_LINE_LENGTH_GLOBAL 0x9ABDB0 //uint16 width+pitch
#pragma endregion
static void RCT2_CALLPROC_EBPSAFE(int address)
{
#ifdef _MSC_VER

View File

@ -19,16 +19,14 @@
*****************************************************************************/
#include <SDL.h>
#include "../addresses.h"
#include "../config.h"
#include "../interface/viewport.h"
#include "../interface/window.h"
#include "../platform/osinterface.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "audio.h"
#include "addresses.h"
#include "config.h"
#include "map.h"
#include "mixer.h"
#include "osinterface.h"
#include "rct2.h"
#include "sprite.h"
#include "viewport.h"
#include "window.h"
int gAudioDeviceCount;
audio_device *gAudioDevices = NULL;

View File

@ -21,8 +21,8 @@
#ifndef _AUDIO_H_
#define _AUDIO_H_
#include "rct2.h"
#include "sprite.h"
#include "../common.h"
#include "../world/sprite.h"
typedef struct {
char name[256];

View File

@ -23,8 +23,8 @@
#include <string.h>
extern "C" {
#include "../config.h"
#include "audio.h"
#include "config.h"
}
#include "mixer.h"

View File

@ -21,8 +21,8 @@
#ifndef _MIXER_H_
#define _MIXER_H_
#include "../common.h"
#include <SDL.h>
#include "rct2.h"
#define USE_MIXER

26
src/common.h Normal file
View File

@ -0,0 +1,26 @@
/*****************************************************************************
* 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 _COMMON_H_
#define _COMMON_H_
#include "rct2.h"
#endif

View File

@ -23,11 +23,8 @@
#include <ctype.h>
#include "addresses.h"
#include "config.h"
#include "language.h"
#include "rct2.h"
#include "osinterface.h"
#include "localisation/localisation.h"
#include "platform/osinterface.h"
// Current keyboard shortcuts
uint16 gShortcutKeys[SHORTCUT_COUNT];

View File

@ -21,9 +21,9 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include "currency.h"
#include "rct2.h"
#include <windows.h> // for MAX_PATH
#include "common.h"
#include "localisation/currency.h"
enum {
CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES = (1 << 0),

409
src/drawing/drawing.c Normal file
View File

@ -0,0 +1,409 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John, Peter Hill, Duncan Frost
* 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/>.
*****************************************************************************/
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <windows.h>
#include <limits.h>
#include "../addresses.h"
#include "../common.h"
#include "../localisation/localisation.h"
#include "../interface/window.h"
#include "../platform/osinterface.h"
#include "drawing.h"
// HACK These were originally passed back through registers
int gLastDrawStringX;
int gLastDrawStringY;
uint8 _screenDirtyBlocks[5120];
//Originally 0x9ABE0C, 12 elements from 0xF3 are the peep top colour, 12 elements from 0xCA are peep trouser colour
const uint8 peep_palette[0x100] = {
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
};
//Originally 0x9ABE04
uint8 text_palette[0x8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Previously 0x97FCBC use it to get the correct palette from g1_elements
const uint16 palette_to_g1_offset[] = {
0x1333, 0x1334, 0x1335, 0x1336,
0x1337, 0x1338, 0x1339, 0x133A,
0x133B, 0x133C, 0x133D, 0x133E,
0x133F, 0x1340, 0x1341, 0x1342,
0x1343, 0x1344, 0x1345, 0x1346,
0x1347, 0x1348, 0x1349, 0x134A,
0x134B, 0x134C, 0x134D, 0x134E,
0x134F, 0x1350, 0x1351, 0x1352,
0x1353, 0x0C1C, 0x0C1D, 0x0C1E,
0x0C1F, 0x0C20, 0x0C22, 0x0C23,
0x0C24, 0x0C25, 0x0C26, 0x0C21,
0x1354, 0x1355, 0x1356, 0x1357,
0x1358, 0x1359, 0x135A, 0x135B,
0x135C, 0x135D, 0x135E, 0x135F,
0x1360, 0x1361, 0x1362, 0x1363,
0x1364, 0x1365, 0x1366, 0x1367,
0x1368, 0x1369, 0x136A, 0x136B,
0x136C, 0x136D, 0x136E, 0x136F,
0x1370, 0x1371, 0x1372, 0x1373,
0x1374, 0x1375, 0x1376, 0x1377,
0x1378, 0x1379, 0x137A, 0x137B,
0x137C, 0x137D, 0x137E, 0x137F,
0x1380, 0x1381, 0x1382, 0x1383,
0x1384, 0x1385, 0x1386, 0x1387,
0x1388, 0x1389, 0x138A, 0x138B,
0x138C, 0x138D, 0x138E, 0x138F,
0x1390, 0x1391, 0x1392, 0x1393,
0x1394, 0x1395, 0x1396, 0x1397,
0x1398, 0x1399, 0x139A, 0x139B,
0x139C, 0x139D, 0x139E, 0x139F,
0x13A0, 0x13A1, 0x13A2, 0x13A3,
0x13A4, 0x13A5, 0x13A6, 0x13A7,
0x13A8, 0x13A9, 0x13AA, 0x13AB,
0x13AC, 0x13AD, 0x13AE, 0x13AF,
0x13B0, 0x13B1, 0x13B2, 0x13B3,
0x13B4, 0x13B5, 0x13B6, 0x13B7,
};
static void gfx_draw_dirty_blocks(int x, int y, int columns, int rows);
/**
* Clears the screen with the specified colour.
* rct2: 0x00678A9F
*/
void gfx_clear(rct_drawpixelinfo *dpi, int colour)
{
int y, w, h;
char* ptr;
w = dpi->width >> dpi->zoom_level;
h = dpi->height >> dpi->zoom_level;
ptr = dpi->bits;
for (y = 0; y < h; y++) {
memset(ptr, colour, w);
ptr += w + dpi->pitch;
}
}
void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour)
{
gfx_fill_rect(dpi, x, y, x, y, colour);
}
/**
*
* rct2: 0x00683854
* a1 (ebx)
* product (cl)
*/
void gfx_transpose_palette(int pal, unsigned char product)
{
rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[pal];
int width = g1.width;
int x = g1.x_offset;
uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(0x014124680,uint8)[x]);
uint8* source_pointer = g1.offset;
for (; width > 0; width--) {
dest_pointer[0] = (source_pointer[0] * product) >> 8;
dest_pointer[1] = (source_pointer[1] * product) >> 8;
dest_pointer[2] = (source_pointer[2] * product) >> 8;
source_pointer += 3;
dest_pointer += 4;
}
osinterface_update_palette((char*)0x01424680, 10, 236);//Odd would have expected dest_pointer
}
/**
*
* rct2: 0x006ED7E5
*/
void gfx_invalidate_screen()
{
int width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16);
int height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16);
gfx_set_dirty_blocks(0, 0, width, height);
}
/**
*
* rct2: 0x006E732D
* left (ax)
* top (bx)
* right (dx)
* bottom (bp)
*/
void gfx_set_dirty_blocks(int left, int top, int right, int bottom)
{
int x, y;
uint8 *screenDirtyBlocks = RCT2_ADDRESS(0x00EDE408, uint8);
left = max(left, 0);
top = max(top, 0);
right = min(right, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16));
bottom = min(bottom, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16));
if (left >= right)
return;
if (top >= bottom)
return;
right--;
bottom--;
left >>= RCT2_GLOBAL(0x009ABDF0, sint8);
right >>= RCT2_GLOBAL(0x009ABDF0, sint8);
top >>= RCT2_GLOBAL(0x009ABDF1, sint8);
bottom >>= RCT2_GLOBAL(0x009ABDF1, sint8);
for (y = top; y <= bottom; y++)
for (x = left; x <= right; x++)
screenDirtyBlocks[y * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) + x] = 0xFF;
}
/**
*
* rct2: 0x006E73BE
*/
void gfx_draw_all_dirty_blocks()
{
int x, y, xx, yy, columns, rows;
uint8 *screenDirtyBlocks = RCT2_ADDRESS(0x00EDE408, uint8);
for (x = 0; x < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32); x++) {
for (y = 0; y < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32); y++) {
if (screenDirtyBlocks[y * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) + x] == 0)
continue;
// Determine columns
for (xx = x; xx < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32); xx++)
if (screenDirtyBlocks[y * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) + xx] == 0)
break;
columns = xx - x;
// Check rows
for (yy = y; yy < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32); yy++)
for (xx = x; xx < x + columns; xx++)
if (screenDirtyBlocks[yy * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) + xx] == 0)
goto endRowCheck;
endRowCheck:
rows = yy - y;
gfx_draw_dirty_blocks(x, y, columns, rows);
}
}
}
static void gfx_draw_dirty_blocks(int x, int y, int columns, int rows)
{
int left, top, right, bottom;
uint8 *screenDirtyBlocks = RCT2_ADDRESS(0x00EDE408, uint8);
// Unset dirty blocks
for (top = y; top < y + rows; top++)
for (left = x; left < x + columns; left++)
screenDirtyBlocks[top * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) + left] = 0;
// Determine region in pixels
left = max(0, x * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_WIDTH, sint16));
top = max(0, y * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_HEIGHT, sint16));
right = min(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), left + (columns * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_WIDTH, sint16)));
bottom = min(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16), top + (rows * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_HEIGHT, sint16)));
if (right <= left || bottom <= top)
return;
// Draw region
gfx_redraw_screen_rect(left, top, right, bottom);
}
/**
*
* rct2: 0x006E7499
* left (ax)
* top (bx)
* right (dx)
* bottom (bp)
*/
void gfx_redraw_screen_rect(short left, short top, short right, short bottom)
{
rct_window* w;
rct_drawpixelinfo *screenDPI = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
rct_drawpixelinfo *windowDPI = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_DPI, rct_drawpixelinfo);
// Unsure what this does
RCT2_CALLPROC_X(0x00683326, left, top, right - 1, bottom - 1, 0, 0, 0);
windowDPI->bits = screenDPI->bits + left + ((screenDPI->width + screenDPI->pitch) * top);
windowDPI->x = left;
windowDPI->y = top;
windowDPI->width = right - left;
windowDPI->height = bottom - top;
windowDPI->pitch = screenDPI->width + screenDPI->pitch + left - right;
for (w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) {
if (w->flags & WF_TRANSPARENT)
continue;
if (right <= w->x || bottom <= w->y)
continue;
if (left >= w->x + w->width || top >= w->y + w->height)
continue;
window_draw(w, left, top, right, bottom);
}
}
/*
*
* rct2: 0x006EE53B
* left (ax)
* width (bx)
* top (cx)
* height (dx)
* drawpixelinfo (edi)
*/
rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int width, int top, int height)
{
rct_drawpixelinfo* newDrawPixelInfo = rct2_malloc(sizeof(rct_drawpixelinfo));
int right = left + width;
int bottom = top + height;
newDrawPixelInfo->bits = dpi->bits;
newDrawPixelInfo->x = dpi->x;
newDrawPixelInfo->y = dpi->y;
newDrawPixelInfo->width = dpi->width;
newDrawPixelInfo->height = dpi->height;
newDrawPixelInfo->pitch = dpi->pitch;
newDrawPixelInfo->zoom_level = 0;
if (left > newDrawPixelInfo->x) {
uint16 clippedFromLeft = left - newDrawPixelInfo->x;
newDrawPixelInfo->width -= clippedFromLeft;
newDrawPixelInfo->x = left;
newDrawPixelInfo->pitch += clippedFromLeft;
newDrawPixelInfo->bits += clippedFromLeft;
}
int stickOutWidth = newDrawPixelInfo->x + newDrawPixelInfo->width - right;
if (stickOutWidth > 0) {
newDrawPixelInfo->width -= stickOutWidth;
newDrawPixelInfo->pitch += stickOutWidth;
}
if (top > newDrawPixelInfo->y) {
uint16 clippedFromTop = top - newDrawPixelInfo->y;
newDrawPixelInfo->height -= clippedFromTop;
newDrawPixelInfo->y = top;
uint32 bitsPlus = (newDrawPixelInfo->pitch + newDrawPixelInfo->width) * clippedFromTop;
newDrawPixelInfo->bits += bitsPlus;
}
int bp = newDrawPixelInfo->y + newDrawPixelInfo->height - bottom;
if (bp > 0) {
newDrawPixelInfo->height -= bp;
}
if (newDrawPixelInfo->width > 0 && newDrawPixelInfo->height > 0) {
newDrawPixelInfo->x -= left;
newDrawPixelInfo->y -= top;
return newDrawPixelInfo;
}
rct2_free(newDrawPixelInfo);
return NULL;
}
/***
*
* rct2: 0x00684027
*
* ebp used to be a parameter but it is always zero
* left : eax
* top : ebx
* width : ecx
* height : edx
* x_start: edi
* y_start: esi
*/
void gfx_draw_rain(int left, int top, int width, int height, sint32 x_start, sint32 y_start){
uint8* pattern = RCT2_GLOBAL(RCT2_ADDRESS_RAIN_PATTERN, uint8*);
uint8 pattern_x_space = *pattern++;
uint8 pattern_y_space = *pattern++;
uint8 pattern_start_x_offset = x_start % pattern_x_space;
uint8 pattern_start_y_offset = y_start % pattern_y_space;;
rct_drawpixelinfo* dpi = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo);
uint32 pixel_offset = (dpi->pitch + dpi->width)*top + left;
uint8 pattern_y_pos = pattern_start_y_offset;
//Stores the colours of changed pixels
uint32* pixel_store = RCT2_ADDRESS(RCT2_ADDRESS_RAIN_PIXEL_STORE, uint32);
pixel_store += RCT2_GLOBAL(RCT2_ADDRESS_NO_RAIN_PIXELS, uint32);
for (; height != 0; height--){
uint8 pattern_x = pattern[pattern_y_pos * 2];
if (pattern_x != 0xFF){
if (RCT2_GLOBAL(0x9AC00C, uint32) <= 0x1F38){
int final_pixel_offset = width + pixel_offset;
int x_pixel_offset = pixel_offset;
x_pixel_offset += ((uint8)(pattern_x - pattern_start_x_offset)) % pattern_x_space;
uint8 pattern_pixel = pattern[pattern_y_pos * 2 + 1];
for (; x_pixel_offset < final_pixel_offset; x_pixel_offset += pattern_x_space){
uint8 current_pixel = dpi->bits[x_pixel_offset];
dpi->bits[x_pixel_offset] = pattern_pixel;
RCT2_GLOBAL(RCT2_ADDRESS_NO_RAIN_PIXELS, uint32)++;
//Store colour and position
*pixel_store++ = (x_pixel_offset << 8) | current_pixel;
}
}
}
pixel_offset += dpi->pitch + dpi->width;
pattern_y_pos++;
pattern_y_pos %= pattern_y_space;
}
}

View File

@ -18,10 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef _GFX_H_
#define _GFX_H_
#ifndef _DRAWING_H_
#define _DRAWING_H_
#include "rct2.h"
#include "../common.h"
// Size: 0x10
typedef struct {
@ -58,47 +58,58 @@ enum{
IMAGE_TYPE_UNKNOWN = (1<<3)
};
extern const uint16 palette_to_g1_offset[];
extern const uint8 peep_palette[];
extern uint8 text_palette[];
extern int gLastDrawStringX;
extern int gLastDrawStringY;
int gfx_load_g1();
void gfx_load_character_widths();
int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height);
void gfx_clear(rct_drawpixelinfo *dpi, int colour);
void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour);
void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour);
void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bottom, int colour);
void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short right, short bottom, int colour, short _si);
void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint32 tertiary_colour);
void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint8* palette_pointer, uint8* unknown_pointer);
void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, int y);
void gfx_transpose_palette(int pal, unsigned char product);
void gfx_draw_string_left(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
void gfx_draw_string_left_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width);
void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width);
void gfx_draw_string_right(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args);
int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour);
int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour);
int gfx_get_string_width(char *buffer);
int clip_text(char *buffer, int width);
void gfx_fill_rect_inset(rct_drawpixelinfo *dpi, short left, short top, short right, short bottom, int colour, short _si);
//
rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int width, int top, int height);
void gfx_set_dirty_blocks(int left, int top, int right, int bottom);
void gfx_draw_all_dirty_blocks();
void gfx_redraw_screen_rect(short left, short top, short right, short bottom);
void gfx_invalidate_screen();
// palette
void gfx_transpose_palette(int pal, unsigned char product);
// other
void gfx_draw_rain(int left, int top, int width, int height, sint32 x_start, sint32 y_start);
void gfx_clear(rct_drawpixelinfo *dpi, int colour);
void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour);
rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int width, int top, int height);
// line
void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour);
// rect
void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bottom, int colour);
void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short right, short bottom, int colour, short _si);
// sprite
int gfx_load_g1();
void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, uint8* source_pointer, uint8* dest_pointer, rct_g1_element* source_image, rct_drawpixelinfo *dest_dpi, int height, int width, int image_type);
void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_pointer, uint8* palette_pointer, rct_drawpixelinfo *dpi, int image_type, int source_y_start, int height, int source_x_start, int width);
void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint32 tertiary_colour);
void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint8* palette_pointer, uint8* unknown_pointer);
// string
void gfx_load_character_widths();
int clip_text(char *buffer, int width);
int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height);
int gfx_get_string_width(char *buffer);
void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, int y);
void gfx_draw_string_left(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
void gfx_draw_string_left_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width);
int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour);
void draw_string_left_underline(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
void draw_string_right_underline(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args);
void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width);
void draw_string_centred_underline(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour);
void draw_string_centred_raw(rct_drawpixelinfo *dpi, int x, int y, int numLines, char *text);
void gfx_draw_string_right(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
void draw_string_right_underline(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
#endif

150
src/drawing/line.c Normal file
View File

@ -0,0 +1,150 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John, Peter Hill, Duncan Frost
* 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/>.
*****************************************************************************/
#include "drawing.h"
/*
* Draws a horizontal line of specified colour to a buffer.
* rct2: 0x0068474C
*/
void gfx_draw_line_on_buffer(rct_drawpixelinfo *dpi, char colour, int y, int x, int no_pixels)
{
y -= dpi->y;
//Check to make sure point is in the y range
if (y < 0)return;
if (y >= dpi->height)return;
//Check to make sure we are drawing at least a pixel
if (!no_pixels) no_pixels++;
x -= dpi->x;
//If x coord outside range leave
if (x < 0){
//Unless the number of pixels is enough to be in range
no_pixels += x;
if (no_pixels <= 0)return;
//Resets starting point to 0 as we don't draw outside the range
x = 0;
}
//Ensure that the end point of the line is within range
if (x + no_pixels - dpi->width > 0){
//If the end point has any pixels outside range
//cut them off. If there are now no pixels return.
no_pixels -= x + no_pixels - dpi->width;
if (no_pixels <= 0)return;
}
char* bits_pointer;
//Get the buffer we are drawing to and move to the first coordinate.
bits_pointer = dpi->bits + y*(dpi->pitch + dpi->width) + x;
//Draw the line to the specified colour
for (; no_pixels > 0; --no_pixels, ++bits_pointer){
*((uint8*)bits_pointer) = colour;
}
}
/**
* Draws a line on dpi if within dpi boundaries
* rct2: 0x00684466
* dpi (edi)
* x1 (ax)
* y1 (bx)
* x2 (cx)
* y2 (dx)
* colour (ebp)
*/
void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour)
{
// Check to make sure the line is within the drawing area
if ((x1 < dpi->x) && (x2 < dpi->x)){
return;
}
if ((y1 < dpi->y) && (y2 < dpi->y)){
return;
}
if ((x1 >(dpi->x + dpi->width)) && (x2 >(dpi->x + dpi->width))){
return;
}
if ((y1 > (dpi->y + dpi->height)) && (y2 > (dpi->y + dpi->height))){
return;
}
//Bresenhams algorithm
//If vertical plot points upwards
int steep = abs(y2 - y1) > abs(x2 - x1);
if (steep){
int temp_y2 = y2;
int temp_x2 = x2;
y2 = x1;
x2 = y1;
y1 = temp_x2;
x1 = temp_y2;
}
//If line is right to left swap direction
if (x1 > x2){
int temp_y2 = y2;
int temp_x2 = x2;
y2 = y1;
x2 = x1;
y1 = temp_y2;
x1 = temp_x2;
}
int delta_x = x2 - x1;
int delta_y = abs(y2 - y1);
int error = delta_x / 2;
int y_step;
int y = y1;
//Direction of step
if (y1 < y2)y_step = 1;
else y_step = -1;
for (int x = x1, x_start = x1, no_pixels = 1; x < x2; ++x,++no_pixels){
//Vertical lines are drawn 1 pixel at a time
if (steep)gfx_draw_line_on_buffer(dpi, colour, x, y, 1);
error -= delta_y;
if (error < 0){
//Non vertical lines are drawn with as many pixels in a horizontal line as possible
if (!steep)gfx_draw_line_on_buffer(dpi, colour, y, x_start, no_pixels);
//Reset non vertical line vars
x_start = x + 1;
no_pixels = 1;
y += y_step;
error += delta_x;
}
//Catch the case of the last line
if (x + 1 == x2 && !steep){
gfx_draw_line_on_buffer(dpi, colour, y, x_start, no_pixels);
}
}
return;
}

329
src/drawing/rect.c Normal file
View File

@ -0,0 +1,329 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John, Peter Hill, Duncan Frost
* 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/>.
*****************************************************************************/
#include "../addresses.h"
#include "../common.h"
#include "drawing.h"
/**
*
* rct2: 0x00678AD4
* dpi (edi)
* left (ax)
* top (cx)
* right (bx)
* bottom (dx)
* colour (ebp)
*/
void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bottom, int colour)
{
int left_, right_, top_, bottom_;
rct_drawpixelinfo* dpi_;
left_ = left;
right_ = right;
top_ = top;
bottom_ = bottom;
dpi_ = dpi;
if ((left > right) || (top > bottom) || (dpi->x > right) || (left >= (dpi->x + dpi->width)) ||
(bottom < dpi->y) || (top >= (dpi->y + dpi->height)))
return;
colour |= RCT2_GLOBAL(0x009ABD9C, uint32);
uint16 cross_pattern = 0;
int start_x = left - dpi->x;
if (start_x < 0){
start_x = 0;
cross_pattern ^= start_x;
}
int end_x = right - dpi->x;
end_x++;
if (end_x > dpi->width)
end_x = dpi->width;
int width = end_x - start_x;
int start_y = top - dpi->y;
if (start_y < 0){
start_y = 0;
cross_pattern ^= start_y;
}
int end_y = bottom - dpi->y;
end_y++;
if (end_y > dpi->height)
end_y = dpi->height;
int height = end_y - start_y;
if (colour&0x1000000){
// 00678B2E 00678BE5
//Cross hatching
uint8* dest_pointer = (start_y * (dpi->width + dpi->pitch)) + start_x + dpi->bits;
uint32 ecx;
for (int i = 0; i < height; ++i) {
uint8* next_dest_pointer = dest_pointer + dpi->width + dpi->pitch;
ecx = cross_pattern;
// Rotate right
ecx = (ecx >> 1) | (ecx << (sizeof(ecx) * CHAR_BIT - 1));
ecx = (ecx & 0xFFFF0000) | width;
// Fill every other pixel with the colour
for (; (ecx & 0xFFFF) > 0; ecx--) {
ecx = ecx ^ 0x80000000;
if ((int)ecx < 0) {
*dest_pointer = colour & 0xFF;
}
dest_pointer++;
}
cross_pattern ^= 1;
dest_pointer = next_dest_pointer;
}
return;
}
if (colour & 0x2000000){
//0x2000000
// 00678B7E 00678C83
// Location in screen buffer?
uint8* dest_pointer = dpi->bits + (uint32)((start_y >> (dpi->zoom_level)) * ((dpi->width >> dpi->zoom_level) + dpi->pitch) + (start_x >> dpi->zoom_level));
// Find colour in colour table?
uint16 eax = palette_to_g1_offset[(colour & 0xFF)];
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[eax];
// Fill the rectangle with the colours from the colour table
for (int i = 0; i < height>>dpi->zoom_level; ++i) {
uint8* next_dest_pointer = dest_pointer + (dpi->width >> dpi->zoom_level) + dpi->pitch;
for (int j = 0; j < width; ++j) {
*dest_pointer = g1_element.offset[*dest_pointer];
dest_pointer++;
}
dest_pointer = next_dest_pointer;
}
return;
}
if (colour & 0x4000000){
//0x4000000
// 00678B8A 00678E38
char* dest_pointer;
dest_pointer = start_y * (dpi->width + dpi->pitch) + start_x + dpi->bits;
//The pattern loops every 15 lines this is which
//part the pattern is on.
int pattern_y = (start_y + dpi->y) % 16;
//The pattern loops every 15 pixels this is which
//part the pattern is on.
int start_pattern_x = (start_x + dpi_->x) % 16;
int pattern_x = start_pattern_x;
uint16* pattern_pointer;
pattern_pointer = RCT2_ADDRESS(0x0097FEFC,uint16*)[colour >> 28]; // or possibly uint8)[esi*4] ?
for (int no_lines = height; no_lines > 0; no_lines--) {
char* next_dest_pointer = dest_pointer + dpi->width + dpi->pitch;
uint16 pattern = pattern_pointer[pattern_y];
for (int no_pixels = width; no_pixels > 0; --no_pixels) {
if (pattern & (1 << pattern_x))
*dest_pointer = colour & 0xFF;
pattern_x = (pattern_x + 1) % 16;
dest_pointer++;
}
pattern_x = start_pattern_x;
pattern_y = (pattern_y + 1) % 16;
dest_pointer = next_dest_pointer;
}
return;
}
if (colour & 0x8000000){
//0x8000000
// 00678B3A 00678EC9 still to be implemented
//RCT2_CALLPROC_X(0x00678AD4, left, right, top, bottom, 0, dpi, colour);
int esi = left - RCT2_GLOBAL(0x1420070,sint16);
RCT2_GLOBAL(0xEDF824,uint32) = esi;
esi = top - RCT2_GLOBAL(0x1420072,sint16);
RCT2_GLOBAL(0xEDF828,uint32) = esi;
left -= dpi->x;//0x4
if ( left < 0 ){
RCT2_GLOBAL(0xEDF824,sint32) -= left;
left = 0;
}
right -= dpi->x;
right++;
if ( right > dpi->width ){
right = dpi->width;
}
right -= left;
top -= dpi->y;
if ( top < 0 ){
RCT2_GLOBAL(0xEDF828,sint32) -= top;
top = 0;
}
bottom -= dpi->y;
bottom++;
if (bottom > dpi->height){
bottom = dpi->height;
}
bottom -= top;
RCT2_GLOBAL(0xEDF824,sint32) &= 0x3F;
RCT2_GLOBAL(0xEDF828,sint32) &= 0x3F;
esi = dpi->width;
esi += dpi->pitch;
esi *= top;
esi += left;
esi += (uint32)dpi->bits;
RCT2_GLOBAL(0xEDF82C,sint32) = right;
RCT2_GLOBAL(0xEDF830,sint32) = bottom;
left = dpi->width;
left+= dpi->pitch;
left-= right;
RCT2_GLOBAL(0xEDF834,sint32) = left;
colour &= 0xFF;
colour--;
right = colour;
colour <<= 8;
right |= colour;
RCT2_GLOBAL(0xEDF838,sint32) = right;
//right <<= 4;
int edi = esi;
esi = RCT2_GLOBAL(0xEDF828,sint32);
esi *= 0x40;
left = 0;
esi += (uint32)(RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS,rct_g1_element)[right]).offset;//???
//Not finished
//Start of loop
return;
}
//0x0000000
uint8* dest_pointer = start_y * (dpi->width + dpi->pitch) + start_x + dpi->bits;
for (int i = 0; i < height; ++i) {
memset(dest_pointer, (colour & 0xFF), width);
dest_pointer += dpi->width + dpi->pitch;
}
// RCT2_CALLPROC_X(0x00678AD4, left, right, top, bottom, 0, dpi, colour);
}
/**
* Draw a rectangle, with optional border or fill
*
* rct2: 0x006E6F81
* dpi (edi)
* left (ax)
* top (cx)
* right (bx)
* bottom (dx)
* colour (ebp)
* flags (si)
*/
void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short right, short bottom, int colour, short flags)
{
uint8 shadow, fill, hilight;
// Flags
int no_border, no_fill, pressed;
no_border = 8;
no_fill = 0x10;
pressed = 0x20;
if (colour & 0x180) {
if (colour & 0x100) {
colour = colour & 0x7F;
} else {
colour = RCT2_ADDRESS(0x009DEDF4,uint8)[colour];
}
colour = colour | 0x2000000; //Transparent
if (flags & no_border) {
gfx_fill_rect(dpi, left, top, bottom, right, colour);
} else if (flags & pressed) {
// Draw outline of box
gfx_fill_rect(dpi, left, top, left, bottom, colour + 1);
gfx_fill_rect(dpi, left, top, right, top, colour + 1);
gfx_fill_rect(dpi, right, top, right, bottom, colour + 2);
gfx_fill_rect(dpi, left, bottom, right, bottom, colour + 2);
if (!(flags & no_fill)) {
gfx_fill_rect(dpi, left+1, top+1, right-1, bottom-1, colour);
}
} else {
// Draw outline of box
gfx_fill_rect(dpi, left, top, left, bottom, colour + 2);
gfx_fill_rect(dpi, left, top, right, top, colour + 2);
gfx_fill_rect(dpi, right, top, right, bottom, colour + 1);
gfx_fill_rect(dpi, left, bottom, right, bottom, colour + 1);
if (!(flags & no_fill)) {
gfx_fill_rect(dpi, left+1, top+1, right-1, bottom-1, colour);
}
}
} else {
if (flags & 0x80) {
shadow = RCT2_ADDRESS(0x0141FC46, uint8)[colour * 8];
fill = RCT2_ADDRESS(0x0141FC48, uint8)[colour * 8];
hilight = RCT2_ADDRESS(0x0141FC4A, uint8)[colour * 8];
} else {
shadow = RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8];
fill = RCT2_ADDRESS(0x0141FC49, uint8)[colour * 8];
hilight = RCT2_ADDRESS(0x0141FC4B, uint8)[colour * 8];
}
if (flags & no_border) {
gfx_fill_rect(dpi, left, top, right, bottom, fill);
} else if (flags & pressed) {
// Draw outline of box
gfx_fill_rect(dpi, left, top, left, bottom, shadow);
gfx_fill_rect(dpi, left + 1, top, right, top, shadow);
gfx_fill_rect(dpi, right, top + 1, right, bottom - 1, hilight);
gfx_fill_rect(dpi, left + 1, bottom, right, bottom, hilight);
if (!(flags & no_fill)) {
if (!(flags & 0x40)) {
if (flags & 0x04) {
fill = RCT2_ADDRESS(0x0141FC49, uint8)[0];
} else {
fill = RCT2_ADDRESS(0x0141FC4A, uint8)[colour * 8];
}
}
gfx_fill_rect(dpi, left+1, top+1, right-1, bottom-1, fill);
}
} else {
// Draw outline of box
gfx_fill_rect(dpi, left, top, left, bottom - 1, hilight);
gfx_fill_rect(dpi, left + 1, top, right - 1, top, hilight);
gfx_fill_rect(dpi, right, top, right, bottom - 1, shadow);
gfx_fill_rect(dpi, left, bottom, right, bottom, shadow);
if (!(flags & no_fill)) {
if (flags & 0x04) {
fill = RCT2_ADDRESS(0x0141FC49, uint8)[0];
}
gfx_fill_rect(dpi, left+1, top+1, right-1, bottom-1, fill);
}
}
}
}

577
src/drawing/sprite.c Normal file
View File

@ -0,0 +1,577 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John, Peter Hill, Duncan Frost
* 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/>.
*****************************************************************************/
#include "../addresses.h"
#include "../common.h"
#include "drawing.h"
typedef struct {
uint32 num_entries;
uint32 total_size;
} rct_g1_header;
void *_g1Buffer = NULL;
/**
*
* rct2: 0x00678998
*/
int gfx_load_g1()
{
FILE *file;
rct_g1_header header;
unsigned int i;
rct_g1_element *g1Elements = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element);
file = fopen(get_file_path(PATH_ID_G1), "rb");
if (file != NULL) {
if (fread(&header, 8, 1, file) == 1) {
// number of elements is stored in g1.dat, but because the entry headers are static, this can't be variable until
// made into a dynamic array
header.num_entries = 29294;
// Read element headers
fread(g1Elements, header.num_entries * sizeof(rct_g1_element), 1, file);
// Read element data
_g1Buffer = rct2_malloc(header.total_size);
fread(_g1Buffer, header.total_size, 1, file);
fclose(file);
// Fix entry data offsets
for (i = 0; i < header.num_entries; i++)
g1Elements[i].offset += (int)_g1Buffer;
// Successful
return 1;
}
fclose(file);
}
// Unsuccessful
RCT2_ERROR("Unable to load g1.dat");
return 0;
}
/**
* Copies a sprite onto the buffer. There is no compression used on the sprite
* image.
* rct2: 0x0067A690
*/
void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, uint8* source_pointer, uint8* dest_pointer, rct_g1_element* source_image, rct_drawpixelinfo *dest_dpi, int height, int width, int image_type){
uint8 zoom_level = dest_dpi->zoom_level;
uint8 zoom_amount = 1 << zoom_level;
//Requires use of palette?
if (image_type & IMAGE_TYPE_USE_PALETTE){
//Mix with another image?? and colour adjusted
if (unknown_pointer!= NULL){ //Not tested. I can't actually work out when this code runs.
unknown_pointer += source_pointer - source_image->offset;// RCT2_GLOBAL(0x9E3CE0, uint32);
for (; height > 0; height -= zoom_amount){
uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_unknown_pointer = unknown_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch;
for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, unknown_pointer += zoom_amount, dest_pointer++){
uint8 pixel = *source_pointer;
pixel = palette_pointer[pixel];
pixel &= *unknown_pointer;
if (pixel){
*dest_pointer = pixel;
}
}
source_pointer = next_source_pointer;
dest_pointer = next_dest_pointer;
unknown_pointer = next_unknown_pointer;
}
return;
}
//image colour adjusted?
for (; height > 0; height -= zoom_amount){
uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch;
for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){
uint8 pixel = *source_pointer;
pixel = palette_pointer[pixel];
if (pixel){
*dest_pointer = pixel;
}
}
source_pointer = next_source_pointer;
dest_pointer = next_dest_pointer;
}
return;
}
//Mix with background. It only uses source pointer for
//telling if it needs to be drawn not for colour.
if (image_type & IMAGE_TYPE_MIX_BACKGROUND){//Not tested
for (; height > 0; height -= zoom_amount){
uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch;
for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){
uint8 pixel = *source_pointer;
if (pixel){
pixel = *dest_pointer;
pixel = palette_pointer[pixel];
*dest_pointer = pixel;
}
}
source_pointer = next_source_pointer;
dest_pointer = next_dest_pointer;
}
return;
}
//Basic bitmap no fancy stuff
if (!(source_image->flags & G1_FLAG_BMP)){//Not tested
for (; height > 0; height -= zoom_amount){
uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch;
for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, dest_pointer++, source_pointer += zoom_amount){
*dest_pointer = *source_pointer;
}
dest_pointer = next_dest_pointer;
source_pointer = next_source_pointer;
}
return;
}
if (RCT2_GLOBAL(0x9E3CDC, uint32) != 0){//Not tested. I can't actually work out when this code runs.
unknown_pointer += source_pointer - source_image->offset;
for (; height > 0; height -= zoom_amount){
uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_unknown_pointer = unknown_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch;
for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, dest_pointer++, source_pointer += zoom_amount, unknown_pointer += zoom_amount){
uint8 pixel = *source_pointer;
pixel &= *unknown_pointer;
if (pixel){
*dest_pointer = pixel;
}
}
dest_pointer = next_dest_pointer;
source_pointer = next_source_pointer;
unknown_pointer = next_unknown_pointer;
}
}
//Basic bitmap with no draw pixels
for (; height > 0; height -= zoom_amount){
uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount);
uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch;
for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, dest_pointer++, source_pointer += zoom_amount){
uint8 pixel = *source_pointer;
if (pixel){
*dest_pointer = pixel;
}
}
dest_pointer = next_dest_pointer;
source_pointer = next_source_pointer;
}
return;
}
/**
* Transfers readied images onto buffers
* This function copies the sprite data onto the screen
* rct2: 0x0067AA18
*/
void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_pointer, uint8* palette_pointer, rct_drawpixelinfo *dpi, int image_type, int source_y_start, int height, int source_x_start, int width){
int zoom_level = dpi->zoom_level;
int zoom_amount = 1 << zoom_level;
uint8* next_source_pointer;
uint8* next_dest_pointer = dest_bits_pointer;
//For every line in the image
for (int y = source_y_start; y < (height + source_y_start); y += zoom_amount){
//The first part of the source pointer is a list of offsets to different lines
//This will move the pointer to the correct source line.
next_source_pointer = source_bits_pointer + ((uint16*)source_bits_pointer)[y];
uint8 last_data_line = 0;
//For every data section in the line
while (!last_data_line){
uint8* source_pointer = next_source_pointer;
uint8* dest_pointer = next_dest_pointer;
int no_pixels = *source_pointer++;
//gap_size is the number of non drawn pixels you require to
//jump over on your destination
uint8 gap_size = *source_pointer++;
//The last bit in no_pixels tells you if you have reached the end of a line
last_data_line = no_pixels & 0x80;
//Clear the last data line bit so we have just the no_pixels
no_pixels &= 0x7f;
//Have our next source pointer point to the next data section
next_source_pointer = source_pointer + no_pixels;
//Calculates the start point of the image
int x_start = gap_size - source_x_start;
if (x_start > 0){
//Since the start is positive
//We need to move the drawing surface to the correct position
dest_pointer += x_start / zoom_amount;
}
else{
//If the start is negative we require to remove part of the image.
//This is done by moving the image pointer to the correct position.
source_pointer -= x_start;
//The no_pixels will be reduced in this operation
no_pixels += x_start;
//If there are no pixels there is nothing to draw this data section
if (no_pixels <= 0) continue;
//Reset the start position to zero as we have taken into account all moves
x_start = 0;
}
int x_end = x_start + no_pixels;
//If the end position is further out than the whole image
//end position then we need to shorten the line again
if (x_end > width){
//Shorten the line
no_pixels -= x_end - width;
//If there are no pixels there is nothing to draw.
if (no_pixels <= 0) continue;
}
//Finally after all those checks, copy the image onto the drawing surface
//If the image type is not a basic one we require to mix the pixels
if (image_type & IMAGE_TYPE_USE_PALETTE){//In the .exe these are all unraveled loops
for (; no_pixels > 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){
uint8 al = *source_pointer;
uint8 ah = *dest_pointer;
if (image_type & IMAGE_TYPE_MIX_BACKGROUND)
al = palette_pointer[(((uint16)al << 8) | ah) - 0x100];
else
al = palette_pointer[al];
*dest_pointer = al;
}
}
else if (image_type & IMAGE_TYPE_MIX_BACKGROUND){//In the .exe these are all unraveled loops
//Doesnt use source pointer ??? mix with background only?
//Not Tested
for (; no_pixels > 0; no_pixels -= zoom_amount, dest_pointer++){
uint8 pixel = *dest_pointer;
pixel = palette_pointer[pixel];
*dest_pointer = pixel;
}
}
else
{
for (; no_pixels > 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){
*dest_pointer = *source_pointer;
}
}
}
//Add a line to the drawing surface pointer
next_dest_pointer += dpi->width / zoom_amount + dpi->pitch;
}
}
/**
*
* rct2: 0x0067A28E
* image_id (ebx)
* image_id as below
* 0b_111X_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX image_type
* 0b_XXX1_11XX_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX image_sub_type (unknown pointer)
* 0b_XXX1_1111_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX secondary_colour
* 0b_XXXX_XXXX_1111_1XXX_XXXX_XXXX_XXXX_XXXX primary_colour
* 0b_XXXX_X111_1111_1XXX_XXXX_XXXX_XXXX_XXXX palette_ref
* 0b_XXXX_XXXX_XXXX_X111_1111_1111_1111_1111 image_id (offset to g1)
* x (cx)
* y (dx)
* dpi (esi)
* tertiary_colour (ebp)
*/
void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint32 tertiary_colour)
{
//RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, (int)dpi, tertiary_colour);
//return;
int image_type = (image_id & 0xE0000000) >> 28;
int image_sub_type = (image_id & 0x1C000000) >> 26;
uint8* palette_pointer = NULL;
uint8 palette[0x100];
RCT2_GLOBAL(0x00EDF81C, uint32) = image_id & 0xE0000000;
uint8* unknown_pointer = (uint8*)(RCT2_ADDRESS(0x9E3CE4, uint32*)[image_sub_type]);
RCT2_GLOBAL(0x009E3CDC, uint32) = (uint32)unknown_pointer;
if (image_type && !(image_type & IMAGE_TYPE_UNKNOWN)) {
uint8 palette_ref = (image_id >> 19) & 0xFF;
if (image_type & IMAGE_TYPE_MIX_BACKGROUND){
unknown_pointer = NULL;
RCT2_GLOBAL(0x009E3CDC, uint32) = 0;
}
else{
palette_ref &= 0x7F;
}
uint16 palette_offset = palette_to_g1_offset[palette_ref];
palette_pointer = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[palette_offset].offset;
RCT2_GLOBAL(0x9ABDA4, uint32) = (uint32)palette_pointer;
}
else if (image_type && !(image_type & IMAGE_TYPE_USE_PALETTE)){
RCT2_GLOBAL(0x9E3CDC, uint32) = 0;
unknown_pointer = NULL;
uint32 primary_offset = palette_to_g1_offset[(image_id >> 19) & 0x1F];
uint32 secondary_offset = palette_to_g1_offset[(image_id >> 24) & 0x1F];
uint32 tertiary_offset = palette_to_g1_offset[tertiary_colour];
rct_g1_element* primary_colour = &RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[primary_offset];
rct_g1_element* secondary_colour = &RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[secondary_offset];
rct_g1_element* tertiary_colour = &RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[tertiary_offset];
memcpy((uint8*)0x9ABFFF, &primary_colour->offset[0xF3], 12);
memcpy((uint8*)0x9ABFD6, &secondary_colour->offset[0xF3], 12);
memcpy((uint8*)0x9ABF3A, &tertiary_colour->offset[0xF3], 12);
//image_id
RCT2_GLOBAL(0xEDF81C, uint32) |= 0x20000000;
image_id |= IMAGE_TYPE_USE_PALETTE << 28;
RCT2_GLOBAL(0x9ABDA4, uint32) = 0x9ABF0C;
palette_pointer = (uint8*)0x9ABF0C;
}
else if (image_type){
RCT2_GLOBAL(0x9E3CDC, uint32) = 0;
unknown_pointer = NULL;
//Copy the peep palette into a new palette.
//Not really required but its nice to make a copy
memcpy(palette, peep_palette, 0x100);
//Top
int top_type = (image_id >> 19) & 0x1f;
uint32 top_offset = palette_to_g1_offset[top_type]; //RCT2_ADDRESS(0x97FCBC, uint32)[top_type];
rct_g1_element top_palette = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[top_offset];
memcpy(palette + 0xF3, top_palette.offset + 0xF3, 12);
//Trousers
int trouser_type = (image_id >> 24) & 0x1f;
uint32 trouser_offset = palette_to_g1_offset[trouser_type]; //RCT2_ADDRESS(0x97FCBC, uint32)[trouser_type];
rct_g1_element trouser_palette = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[trouser_offset];
memcpy(palette + 0xCA, trouser_palette.offset + 0xF3, 12);
//For backwards compatibility until the zooming function is done
RCT2_GLOBAL(0x9ABDA4, uint8*) = palette;
palette_pointer = palette;
}
gfx_draw_sprite_palette_set(dpi, image_id, x, y, palette_pointer, unknown_pointer);
}
/*
* rct: 0x0067A46E
* image_id (ebx) and also (0x00EDF81C)
* palette_pointer (0x9ABDA4)
* unknown_pointer (0x9E3CDC)
* dpi (edi)
* x (cx)
* y (dx)
*/
void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint8* palette_pointer, uint8* unknown_pointer){
int image_element = 0x7FFFF&image_id;
int image_type = (image_id & 0xE0000000) >> 28;
rct_g1_element* g1_source = &(RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[image_element]);
//Zooming code has been integrated into main code.
//if (dpi->zoom_level >= 1){ //These have not been tested
// //something to do with zooming
// if (dpi->zoom_level == 1){
// RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, (int)dpi, 0);
// return;
// }
// if (dpi->zoom_level == 2){
// RCT2_CALLPROC_X(0x0067DADA, 0, (int)g1_source, x, y, 0, (int)dpi, 0);
// return;
// }
// RCT2_CALLPROC_X(0x0067FAAE, 0, (int)g1_source, x, y, 0, (int)dpi, 0);
// return;
//}
if ( dpi->zoom_level && (g1_source->flags & (1<<4)) ){
rct_drawpixelinfo zoomed_dpi = {
.bits = dpi->bits,
.x = dpi->x >> 1,
.y = dpi->y >> 1,
.height = dpi->height>>1,
.width = dpi->width>>1,
.pitch = dpi->pitch,
.zoom_level = dpi->zoom_level - 1
};
gfx_draw_sprite_palette_set(&zoomed_dpi, (image_type << 28) | (image_element - g1_source->zoomed_offset), x >> 1, y >> 1, palette_pointer, unknown_pointer);
return;
}
if ( dpi->zoom_level && (g1_source->flags & (1<<5)) ){
return;
}
//Its used super often so we will define it to a seperate variable.
int zoom_level = dpi->zoom_level;
int zoom_amount = 1 << zoom_level;
int zoom_mask = 0xFFFFFFFF << zoom_level;
//This will be the height of the drawn image
int height = g1_source->height;
//This is the start y coordinate on the destination
sint16 dest_start_y = ((y + g1_source->y_offset)&zoom_mask) - dpi->y;
//This is the start y coordinate on the source
int source_start_y = 0;
if (dest_start_y < 0){
//If the destination y is negative reduce the height of the
//image as we will cut off the bottom
height += dest_start_y;
//If the image is no longer visible nothing to draw
if (height <= 0){
return;
}
//The source image will start a further up the image
source_start_y -= dest_start_y;
//The destination start is now reset to 0
dest_start_y = 0;
}
int dest_end_y = dest_start_y + height;
if (dest_end_y > dpi->height){
//If the destination y is outside of the drawing
//image reduce the height of the image
height -= dest_end_y - dpi->height;
}
//If the image no longer has anything to draw
if (height <= 0)return;
dest_start_y /= zoom_amount;
dest_end_y /= zoom_amount;
//This will be the width of the drawn image
int width = g1_source->width;
//This is the source start x coordinate
int source_start_x = 0;
//This is the destination start x coordinate
sint16 dest_start_x = ((x + g1_source->x_offset) & zoom_mask) - dpi->x;
if (dest_start_x < 0){
//If the destination is negative reduce the width
//image will cut off the side
width += dest_start_x;
//If there is no image to draw
if (width <= 0){
return;
}
//The source start will also need to cut off the side
source_start_x -= dest_start_x;
//Reset the destination to 0
dest_start_x = 0;
}
int dest_end_x = dest_start_x + width;
if (dest_end_x > dpi->width){
//If the destination x is outside of the drawing area
//reduce the image width.
width -= dest_end_x - dpi->width;
//If there is no image to draw.
if (width <= 0)return;
}
dest_start_x /= zoom_amount;
dest_end_x /= zoom_amount;
uint8* dest_pointer = (uint8*)dpi->bits;
//Move the pointer to the start point of the destination
dest_pointer += ((dpi->width / zoom_amount) + dpi->pitch)*dest_start_y + dest_start_x;
if (g1_source->flags & G1_FLAG_RLE_COMPRESSION){
//We have to use a different method to move the source pointer for
//rle encoded sprites so that will be handled within this function
gfx_rle_sprite_to_buffer(g1_source->offset, dest_pointer, palette_pointer, dpi, image_type, source_start_y, height, source_start_x, width);
return;
}
uint8* source_pointer = g1_source->offset;
//Move the pointer to the start point of the source
source_pointer += g1_source->width*source_start_y + source_start_x;
if (!(g1_source->flags & 0x02)){
gfx_bmp_sprite_to_buffer(palette_pointer, unknown_pointer, source_pointer, dest_pointer, g1_source, dpi, height, width, image_type);
return;
}
//0x67A60A Not tested
int total_no_pixels = g1_source->width*g1_source->height;
source_pointer = g1_source->offset;
uint8* new_source_pointer_start = malloc(total_no_pixels);
uint8* new_source_pointer = new_source_pointer_start;// 0x9E3D28;
int ebx, ecx;
while (total_no_pixels>0){
sint8 no_pixels = *source_pointer;
if (no_pixels >= 0){
source_pointer++;
total_no_pixels -= no_pixels;
memcpy((char*)new_source_pointer, (char*)source_pointer, no_pixels);
new_source_pointer += no_pixels;
source_pointer += no_pixels;
continue;
}
ecx = no_pixels;
no_pixels &= 0x7;
ecx >>= 3;//SAR
int eax = ((int)no_pixels)<<8;
ecx = -ecx;//Odd
eax = eax & 0xFF00 + *(source_pointer+1);
total_no_pixels -= ecx;
source_pointer += 2;
ebx = (uint32)new_source_pointer - eax;
eax = (uint32)source_pointer;
source_pointer = (uint8*)ebx;
ebx = eax;
eax = 0;
memcpy((char*)new_source_pointer, (char*)source_pointer, ecx);
new_source_pointer += ecx;
source_pointer += ecx;
source_pointer = (uint8*)ebx;
}
source_pointer = new_source_pointer_start + g1_source->width*source_start_y + source_start_x;
gfx_bmp_sprite_to_buffer(palette_pointer, unknown_pointer, source_pointer, dest_pointer, g1_source, dpi, height, width, image_type);
free(new_source_pointer_start);
return;
}

1041
src/drawing/string.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,22 +19,22 @@
*****************************************************************************/
#include "addresses.h"
#include "date.h"
#include "audio/audio.h"
#include "drawing/drawing.h"
#include "editor.h"
#include "game.h"
#include "gfx.h"
#include "map.h"
#include "news_item.h"
#include "interface/window.h"
#include "interface/viewport.h"
#include "localisation/date.h"
#include "localisation/localisation.h"
#include "management/finance.h"
#include "management/news_item.h"
#include "object.h"
#include "park.h"
#include "ride.h"
#include "window.h"
#include "viewport.h"
#include "finance.h"
#include "audio.h"
#include "sprite.h"
#include "string_ids.h"
#include "staff.h"
#include "peep/staff.h"
#include "ride/ride.h"
#include "world/map.h"
#include "world/park.h"
#include "world/sprite.h"
static void set_all_land_owned();
@ -63,7 +63,7 @@ void editor_load()
finance_init();
date_reset();
window_guest_list_init_vars_b();
window_staff_init_vars();
window_staff_list_init_vars();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_SCENARIO_EDITOR;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
@ -112,7 +112,7 @@ void trackdesigner_load()
finance_init();
date_reset();
window_guest_list_init_vars_b();
window_staff_init_vars();
window_staff_list_init_vars();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
window_new_ride_init_vars();
@ -150,7 +150,7 @@ void trackmanager_load()
finance_init();
date_reset();
window_guest_list_init_vars_b();
window_staff_init_vars();
window_staff_list_init_vars();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER;
RCT2_GLOBAL(0x0141F570, uint8) = 0;
window_new_ride_init_vars();

View File

@ -19,35 +19,33 @@
*****************************************************************************/
#include "addresses.h"
#include "audio.h"
#include "climate.h"
#include "audio/audio.h"
#include "config.h"
#include "finance.h"
#include "game.h"
#include "input.h"
#include "news_item.h"
#include "localisation/localisation.h"
#include "interface/screenshot.h"
#include "interface/viewport.h"
#include "interface/widget.h"
#include "interface/window.h"
#include "management/finance.h"
#include "management/news_item.h"
#include "management/research.h"
#include "object.h"
#include "osinterface.h"
#include "park.h"
#include "peep.h"
#include "rct2.h"
#include "research.h"
#include "ride.h"
#include "sawyercoding.h"
#include "peep/peep.h"
#include "peep/staff.h"
#include "platform/osinterface.h"
#include "ride/ride.h"
#include "ride/vehicle.h"
#include "scenario.h"
#include "screenshot.h"
#include "sprite.h"
#include "string_ids.h"
#include "title.h"
#include "tutorial.h"
#include "vehicle.h"
#include "viewport.h"
#include "widget.h"
#include "window.h"
#include "staff.h"
#include "window_error.h"
#include "window_tooltip.h"
#include "util/sawyercoding.h"
#include "windows/error.h"
#include "windows/tooltip.h"
#include "world/climate.h"
#include "world/park.h"
#include "world/sprite.h"
int gGameSpeed = 1;

2421
src/gfx.c

File diff suppressed because it is too large Load Diff

View File

@ -21,19 +21,19 @@
#include <SDL_keycode.h>
#include <windows.h>
#include "addresses.h"
#include "audio.h"
#include "audio/audio.h"
#include "config.h"
#include "game.h"
#include "input.h"
#include "map.h"
#include "osinterface.h"
#include "sprite.h"
#include "interface/viewport.h"
#include "interface/widget.h"
#include "interface/window.h"
#include "platform/osinterface.h"
#include "tutorial.h"
#include "viewport.h"
#include "widget.h"
#include "window.h"
#include "window_tooltip.h"
#include "window_dropdown.h"
#include "windows/tooltip.h"
#include "windows/dropdown.h"
#include "world/map.h"
#include "world/sprite.h"
POINT _dragPosition;
@ -919,7 +919,7 @@ static void game_handle_input_mouse(int x, int y, int state)
RCT2_CALLPROC_X(0x6ACAC2, eax, ebx, ecx, (int)spr, esi, edi, ebp);
}
else if (spr->unknown.sprite_identifier == SPRITE_IDENTIFIER_PEEP){
window_peep_open(&spr->peep);
window_guest_open(&spr->peep);
}
else if (spr->unknown.sprite_identifier == SPRITE_IDENTIFIER_FLOATING_TEXT){
//Unknown for now

View File

@ -18,10 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "date.h"
#include "../addresses.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "graph.h"
#include "string_ids.h"
static void graph_draw_months_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY)
{

View File

@ -21,8 +21,8 @@
#ifndef _GRAPH_H_
#define _GRAPH_H_
#include "gfx.h"
#include "rct2.h"
#include "../common.h"
#include "../drawing/drawing.h"
void graph_draw_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY);
void graph_draw_money32(rct_drawpixelinfo *dpi, money32 *history, int count, int baseX, int baseY, int modifier, int offset);

View File

@ -19,19 +19,18 @@
*****************************************************************************/
#pragma pack(1)
#include <lodepng.h>
#include <stdio.h>
#include "osinterface.h"
#include "addresses.h"
#include "config.h"
#include "gfx.h"
#include "game.h"
#include "rct2.h"
#include "screenshot.h"
#include "string_ids.h"
#include "window_error.h"
#include <windows.h> // For MAX_PATH
#include <lodepng/lodepng.h>
#include <stdio.h>
#include "../platform/osinterface.h"
#include "../addresses.h"
#include "../config.h"
#include "../drawing/drawing.h"
#include "../game.h"
#include "../localisation/localisation.h"
#include "../windows/error.h"
#include "screenshot.h"
static int screenshot_dump_bmp();

View File

@ -19,13 +19,13 @@
*****************************************************************************/
#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"
#include "../addresses.h"
#include "../config.h"
#include "../drawing/drawing.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "viewport.h"
#include "window.h"

View File

@ -21,9 +21,9 @@
#include <windows.h>
#include <memory.h>
#include <stdlib.h>
#include "addresses.h"
#include "gfx.h"
#include "sprites.h"
#include "../addresses.h"
#include "../drawing/drawing.h"
#include "../sprites.h"
#include "widget.h"
#include "window.h"

View File

@ -19,17 +19,16 @@
*****************************************************************************/
#include <string.h>
#include "addresses.h"
#include "audio.h"
#include "game.h"
#include "gfx.h"
#include "map.h"
#include "osinterface.h"
#include "rct2.h"
#include "../addresses.h"
#include "../audio/audio.h"
#include "../game.h"
#include "../drawing/drawing.h"
#include "../platform/osinterface.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "widget.h"
#include "window.h"
#include "viewport.h"
#include "sprite.h"
#define RCT2_FIRST_WINDOW (RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window))
#define RCT2_LAST_WINDOW (RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*) - 1)

View File

@ -21,11 +21,11 @@
#ifndef _WINDOW_H_
#define _WINDOW_H_
#include "gfx.h"
#include "park.h"
#include "peep.h"
#include "rct2.h"
#include "ride.h"
#include "../common.h"
#include "../drawing/drawing.h"
#include "../peep/peep.h"
#include "../ride/ride.h"
#include "../world/park.h"
struct rct_window;
union rct_window_event;
@ -472,14 +472,14 @@ void window_track_list_open(ride_list_item item);
void window_clear_scenery_open();
void window_land_open();
void window_water_open();
void window_staff_open();
void window_staff_list_open();
void window_guest_list_open();
void window_map_open();
void window_options_open();
void window_shortcut_keys_open();
void window_shortcut_change_open(int selected_key);
void window_peep_open(rct_peep* peep);
void window_staff_peep_open(rct_peep* peep);
void window_guest_open(rct_peep* peep);
void window_staff_open(rct_peep* peep);
void window_park_awards_open();
void window_park_entrance_open();
void window_park_guests_open();
@ -508,7 +508,7 @@ void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id );
void window_new_ride_init_vars();
void window_staff_init_vars();
void window_staff_list_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);

View File

@ -19,13 +19,12 @@
*****************************************************************************/
#include "addresses.h"
#include "audio.h"
#include "gfx.h"
#include "audio/audio.h"
#include "drawing/drawing.h"
#include "intro.h"
#include "rct2.h"
#include "osinterface.h"
#include "localisation/localisation.h"
#include "platform/osinterface.h"
#include "sprites.h"
#include "string_ids.h"
static void screen_intro_process_mouse_input();
static void screen_intro_process_keyboard_input();

View File

@ -18,9 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "../addresses.h"
#include "date.h"
#include "rct2.h"
// rct2: 0x00993988
const sint16 days_in_month[MONTH_COUNT] = { 31, 30, 31, 30, 31, 31, 30, 31 };

View File

@ -21,7 +21,7 @@
#ifndef _DATE_H_
#define _DATE_H_
#include "rct2.h"
#include "../common.h"
enum {
MONTH_MARCH,

View File

@ -0,0 +1,127 @@
/*****************************************************************************
* 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 _FORMAT_CODES_H_
#define _FORMAT_CODES_H_
char format_get_code(const char *token);
const char *format_get_token(char code);
enum {
// Font format codes
// The next byte specifies the X coordinate
FORMAT_MOVE_X = 1,
// The next byte specifies the palette
FORMAT_ADJUST_PALETTE,
// Moves to the next line
FORMAT_NEWLINE = 5,
// Moves less than NEWLINE
FORMAT_NEWLINE_SMALLER,
FORMAT_TINYFONT,
FORMAT_BIGFONT,
FORMAT_MEDIUMFONT,
FORMAT_SMALLFONT,
FORMAT_OUTLINE,
FORMAT_OUTLINE_OFF,
// Changes the colour of the text to a predefined window colour.
FORMAT_WINDOW_COLOUR_1,
FORMAT_WINDOW_COLOUR_2,
FORMAT_WINDOW_COLOUR_3,
// The next 2 bytes specify the X and Y coordinates
FORMAT_NEWLINE_X_Y = 17,
// The next 4 bytes specify the sprite
FORMAT_INLINE_SPRITE = 23,
// Non ascii-characters
FORMAT_ENDQUOTES = 34,
// Argument format codes
FORMAT_ARGUMENT_CODE_START = 123,
FORMAT_COMMA32 = 123,
FORMAT_INT32,
FORMAT_COMMA2DP32,
FORMAT_COMMA16,
FORMAT_UINT16,
FORMAT_CURRENCY2DP,
FORMAT_CURRENCY,
FORMAT_STRINGID,
FORMAT_STRINGID2,
FORMAT_STRING,
FORMAT_MONTHYEAR,
FORMAT_MONTH,
FORMAT_VELOCITY,
FORMAT_POP16,
FORMAT_PUSH16,
FORMAT_DURATION,
FORMAT_REALTIME,
FORMAT_LENGTH,
FORMAT_SPRITE,
// Colour format codes
FORMAT_COLOUR_CODE_START = 142,
FORMAT_BLACK = 142,
FORMAT_GREY,
FORMAT_WHITE,
FORMAT_RED,
FORMAT_GREEN,
FORMAT_YELLOW,
FORMAT_TOPAZ,
FORMAT_CELADON,
FORMAT_BABYBLUE,
FORMAT_PALELAVENDER,
FORMAT_PALEGOLD,
FORMAT_LIGHTPINK,
FORMAT_PEARLAQUA,
FORMAT_PALESILVER,
FORMAT_COLOUR_CODE_END = FORMAT_PALESILVER,
// Extra non-ascii characters
FORMAT_AMINUSCULE = 159,
FORMAT_UP,
FORMAT_POUND = 163,
FORMAT_YEN = 165,
FORMAT_COPYRIGHT = 169,
FORMAT_DOWN,
FORMAT_LEFTGUILLEMET,
FORMAT_TICK,
FORMAT_CROSS,
FORMAT_RIGHT = 175,
FORMAT_DEGREE,
FORMAT_SQUARED = 178,
FORMAT_OPENQUOTES = 180,
FORMAT_EURO = 181,
FORMAT_APPROX = 184,
FORMAT_POWERNEGATIVEONE,
FORMAT_BULLET,
FORMAT_RIGHTGUILLEMET,
FORMAT_SMALLUP,
FORMAT_SMALLDOWN,
FORMAT_LEFT,
FORMAT_INVERTEDQUESTION
};
#endif

View File

@ -20,9 +20,8 @@
#include <stdio.h>
#include <string.h>
#include "addresses.h"
#include "language.h"
#include "string_ids.h"
#include "../addresses.h"
#include "localisation.h"
const char *language_names[LANGUAGE_COUNT] = {
"", // LANGUAGE_UNDEFINED

View File

@ -21,8 +21,7 @@
#ifndef _LANGUAGE_H_
#define _LANGUAGE_H_
#include "rct2.h"
#include "string_ids.h"
#include "../common.h"
enum {
LANGUAGE_UNDEFINED,

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
/*****************************************************************************
* 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 LOCALISATION_H
#define LOCALISATION_H
#include "currency.h"
#include "format_codes.h"
#include "language.h"
#include "string_ids.h"
void format_string(char *dest, rct_string_id format, void *args);
void generate_string_file();
void reset_saved_strings();
void error_string_quit(int error, rct_string_id format);
int get_string_length(char* buffer);
// Real name data
extern const char real_name_initials[16];
extern const char *real_names[1024];
#endif

File diff suppressed because it is too large Load Diff

View File

@ -21,117 +21,6 @@
#ifndef _STRING_IDS_H_
#define _STRING_IDS_H_
typedef unsigned short rct_string_id;
void format_string(char *dest, rct_string_id format, void *args);
void generate_string_file();
void reset_saved_strings();
void error_string_quit(int error, rct_string_id format);
char format_get_code(const char *token);
const char *format_get_token(char code);
int get_string_length(char* buffer);
enum {
// Font format codes
// The next byte specifies the X coordinate
FORMAT_MOVE_X = 1,
// The next byte specifies the palette
FORMAT_ADJUST_PALETTE,
// Moves to the next line
FORMAT_NEWLINE = 5,
// Moves less than NEWLINE
FORMAT_NEWLINE_SMALLER,
FORMAT_TINYFONT,
FORMAT_BIGFONT,
FORMAT_MEDIUMFONT,
FORMAT_SMALLFONT,
FORMAT_OUTLINE,
FORMAT_OUTLINE_OFF,
// Changes the colour of the text to a predefined window colour.
FORMAT_WINDOW_COLOUR_1,
FORMAT_WINDOW_COLOUR_2,
FORMAT_WINDOW_COLOUR_3,
// The next 2 bytes specify the X and Y coordinates
FORMAT_NEWLINE_X_Y = 17,
// The next 4 bytes specify the sprite
FORMAT_INLINE_SPRITE = 23,
// Non ascii-characters
FORMAT_ENDQUOTES = 34,
// Argument format codes
FORMAT_ARGUMENT_CODE_START = 123,
FORMAT_COMMA32 = 123,
FORMAT_INT32,
FORMAT_COMMA2DP32,
FORMAT_COMMA16,
FORMAT_UINT16,
FORMAT_CURRENCY2DP,
FORMAT_CURRENCY,
FORMAT_STRINGID,
FORMAT_STRINGID2,
FORMAT_STRING,
FORMAT_MONTHYEAR,
FORMAT_MONTH,
FORMAT_VELOCITY,
FORMAT_POP16,
FORMAT_PUSH16,
FORMAT_DURATION,
FORMAT_REALTIME,
FORMAT_LENGTH,
FORMAT_SPRITE,
// Colour format codes
FORMAT_COLOUR_CODE_START = 142,
FORMAT_BLACK = 142,
FORMAT_GREY,
FORMAT_WHITE,
FORMAT_RED,
FORMAT_GREEN,
FORMAT_YELLOW,
FORMAT_TOPAZ,
FORMAT_CELADON,
FORMAT_BABYBLUE,
FORMAT_PALELAVENDER,
FORMAT_PALEGOLD,
FORMAT_LIGHTPINK,
FORMAT_PEARLAQUA,
FORMAT_PALESILVER,
FORMAT_COLOUR_CODE_END = FORMAT_PALESILVER,
// Extra non-ascii characters
FORMAT_AMINUSCULE = 159,
FORMAT_UP,
FORMAT_POUND = 163,
FORMAT_YEN = 165,
FORMAT_COPYRIGHT = 169,
FORMAT_DOWN,
FORMAT_LEFTGUILLEMET,
FORMAT_TICK,
FORMAT_CROSS,
FORMAT_RIGHT = 175,
FORMAT_DEGREE,
FORMAT_SQUARED = 178,
FORMAT_OPENQUOTES = 180,
FORMAT_EURO = 181,
FORMAT_APPROX = 184,
FORMAT_POWERNEGATIVEONE,
FORMAT_BULLET,
FORMAT_RIGHTGUILLEMET,
FORMAT_SMALLUP,
FORMAT_SMALLDOWN,
FORMAT_LEFT,
FORMAT_INVERTEDQUESTION
};
enum {
STR_NONE = -1,

View File

@ -18,14 +18,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "../addresses.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../ride/ride.h"
#include "../scenario.h"
#include "../world/sprite.h"
#include "award.h"
#include "news_item.h"
#include "peep.h"
#include "ride.h"
#include "scenario.h"
#include "sprite.h"
#include "window.h"
#define NEGATIVE 0
#define POSITIVE 1

View File

@ -21,7 +21,7 @@
#ifndef _AWARD_H_
#define _AWARD_H_
#include "rct2.h"
#include "../common.h"
typedef struct {
uint16 time;

View File

@ -18,13 +18,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "../addresses.h"
#include "../interface/window.h"
#include "../peep/peep.h"
#include "../ride/ride.h"
#include "../world/park.h"
#include "../world/sprite.h"
#include "finance.h"
#include "sprite.h"
#include "park.h"
#include "peep.h"
#include "ride.h"
#include "window.h"
// Monthly staff wages
const money32 wage_table[4] = {

View File

@ -21,7 +21,7 @@
#ifndef _FINANCE_H_
#define _FINANCE_H_
#include "rct2.h"
#include "../common.h"
typedef int rct_expenditure_type;

View File

@ -18,13 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "../addresses.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/ride.h"
#include "marketing.h"
#include "news_item.h"
#include "rct2.h"
#include "ride.h"
#include "string_ids.h"
#include "window.h"
const money16 AdvertisingCampaignPricePerWeek[] = {
MONEY(50,00), // PARK_ENTRY_FREE,

View File

@ -21,7 +21,8 @@
#ifndef _MARKETING_H_
#define _MARKETING_H_
#include "peep.h"
#include "../common.h"
#include "../peep/peep.h"
enum {
ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE,

View File

@ -19,15 +19,14 @@
*****************************************************************************/
#include <string.h>
#include "addresses.h"
#include "audio.h"
#include "date.h"
#include "../addresses.h"
#include "../audio/audio.h"
#include "../interface/window.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../ride/ride.h"
#include "../world/sprite.h"
#include "news_item.h"
#include "rct2.h"
#include "ride.h"
#include "string_ids.h"
#include "sprite.h"
#include "window.h"
void window_game_bottom_toolbar_invalidate_news_item();
static int news_item_get_new_history_slot();

View File

@ -21,10 +21,7 @@
#ifndef _NEWS_ITEM_H_
#define _NEWS_ITEM_H_
#include "rct2.h"
#include "map.h"
#include "string_ids.h"
#include "../common.h"
enum {
NEWS_ITEM_NULL,

View File

@ -18,11 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "date.h"
#include "../addresses.h"
#include "../interface/window.h"
#include "../localisation/date.h"
#include "research.h"
#include "rct2.h"
#include "window.h"
typedef struct {
sint32 var_0;

View File

@ -21,6 +21,8 @@
#ifndef _RESEARCH_H_
#define _RESEARCH_H_
#include "../common.h"
enum {
RESEARCH_FUNDING_NONE,
RESEARCH_FUNDING_MINIMUM,

View File

@ -23,10 +23,10 @@
#include <string.h>
#include <ctype.h>
#include "addresses.h"
#include "string_ids.h"
#include "localisation/localisation.h"
#include "object.h"
#include "osinterface.h"
#include "sawyercoding.h"
#include "platform/osinterface.h"
#include "util/sawyercoding.h"
int object_entry_compare(rct_object_entry *a, rct_object_entry *b);
int object_calculate_checksum(rct_object_entry *entry, char *data, int dataLength);

View File

@ -21,7 +21,7 @@
#include <windows.h>
#include "addresses.h"
#include "object.h"
#include "sawyercoding.h"
#include "util/sawyercoding.h"
#define OBJECT_ENTRY_GROUP_COUNT 11
#define OBJECT_ENTRY_COUNT 721

View File

@ -19,16 +19,16 @@
*****************************************************************************/
#include <windows.h>
#include "addresses.h"
#include "audio.h"
#include "news_item.h"
#include "../addresses.h"
#include "../audio/audio.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/news_item.h"
#include "../ride/ride.h"
#include "../sprites.h"
#include "../world/sprite.h"
#include "peep.h"
#include "rct2.h"
#include "ride.h"
#include "sprite.h"
#include "sprites.h"
#include "staff.h"
#include "window.h"
static void peep_update(rct_peep *peep);

View File

@ -21,7 +21,7 @@
#ifndef _PEEP_H_
#define _PEEP_H_
#include "rct2.h"
#include "../common.h"
#define PEEP_MAX_THOUGHTS 5

View File

@ -18,15 +18,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "staff.h"
#include "addresses.h"
#include "rct2.h"
#include "game.h"
#include "finance.h"
#include "../addresses.h"
#include "../game.h"
#include "../interface/viewport.h"
#include "../localisation/string_ids.h"
#include "../management/finance.h"
#include "../world/sprite.h"
#include "peep.h"
#include "sprite.h"
#include "string_ids.h"
#include "viewport.h"
#include "staff.h"
/**
*

View File

@ -21,7 +21,7 @@
#ifndef _STAFF_H_
#define _STAFF_H_
#include "rct2.h"
#include "../common.h"
#define STAFF_MAX_COUNT 0xC8
#define STAFF_TYPE_COUNT 0x04

View File

@ -25,15 +25,14 @@
#include <SDL_syswm.h>
#include <windows.h>
#include "addresses.h"
#include "config.h"
#include "gfx.h"
#include "input.h"
#include "../addresses.h"
#include "../config.h"
#include "../cursors.h"
#include "../drawing/drawing.h"
#include "../input.h"
#include "../interface/screenshot.h"
#include "../interface/window.h"
#include "osinterface.h"
#include "screenshot.h"
#include "window.h"
#include "rct2.h"
#include "cursors.h"
typedef void(*update_palette_func)(char*, int, int);

View File

@ -22,7 +22,7 @@
#define _SDL_INTERFACE_H_
#include <windows.h>
#include "rct2.h"
#include "../common.h"
enum {
CURSOR_UP = 0,

36
src/platform/osx.c Normal file
View File

@ -0,0 +1,36 @@
/*****************************************************************************
* 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/>.
*****************************************************************************/
#ifdef __APPLE__
/**
* OSX entry point to OpenRCT2.
*/
// int main(char *argv[], int argc)
// {
// return 0;
// }
char platform_get_path_separator()
{
return '/';
}
#endif

30
src/platform/platform.h Normal file
View File

@ -0,0 +1,30 @@
/*****************************************************************************
* 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 _PLATFORM_H_
#define _PLATFORM_H_
// Platform specific definitions
char platform_get_path_separator();
int platform_directory_exists(const char *path);
int platform_ensure_directory_exists(const char *path);
#endif

20
src/platform/shared.c Normal file
View File

@ -0,0 +1,20 @@
/*****************************************************************************
* 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/>.
*****************************************************************************/

38
src/platform/unix.c Normal file
View File

@ -0,0 +1,38 @@
/*****************************************************************************
* 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 _WIN32
#ifndef __APPLE__
/**
* Unix, linux and fallback entry point to OpenRCT2.
*/
// int main(char *argv[], int argc)
// {
// return 0;
// }
char platform_get_path_separator()
{
return '/';
}
#endif
#endif

76
src/platform/windows.c Normal file
View File

@ -0,0 +1,76 @@
/*****************************************************************************
* 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/>.
*****************************************************************************/
#ifdef _WIN32
#include <windows.h>
/**
* Windows entry point to OpenRCT2 without a console window.
*/
// int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
// {
// return 0;
// }
/**
* Windows entry point to OpenRCT2 with a console window using a traditional C main function.
*/
// int main(char *argv[], int argc)
// {
// return 0;
// }
/**
* Entry point for when the DLL is loaded. This will be removed when OpenRCT2 can be built as a stand alone application.
*/
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
return TRUE;
}
/**
* The function that is called directly from the host application (rct2.exe)'s WinMain. This will be removed when OpenRCT2 can
* be built as a stand alone application.
*/
// __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
// {
// }
char platform_get_path_separator()
{
return '\\';
}
int platform_directory_exists(const char *path)
{
DWORD dwAttrib = GetFileAttributes(path);
return dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
}
int platform_ensure_directory_exists(const char *path)
{
if (platform_directory_exists(path))
return 1;
return CreateDirectory(path, NULL);
}
#endif

View File

@ -29,29 +29,27 @@
#include <shlobj.h>
#include <SDL.h>
#include "addresses.h"
#include "audio.h"
#include "climate.h"
#include "audio/audio.h"
#include "audio/mixer.h"
#include "config.h"
#include "date.h"
#include "drawing/drawing.h"
#include "editor.h"
#include "game.h"
#include "gfx.h"
#include "interface/viewport.h"
#include "intro.h"
#include "language.h"
#include "map.h"
#include "mixer.h"
#include "news_item.h"
#include "localisation/date.h"
#include "localisation/localisation.h"
#include "management/news_item.h"
#include "object.h"
#include "osinterface.h"
#include "park.h"
#include "rct2.h"
#include "ride.h"
#include "platform/osinterface.h"
#include "ride/ride.h"
#include "ride/track.h"
#include "scenario.h"
#include "title.h"
#include "track.h"
#include "viewport.h"
#include "sprite.h"
#include "string_ids.h"
#include "world/map.h"
#include "world/park.h"
#include "world/climate.h"
#include "world/sprite.h"
typedef struct tm tm_t;
@ -69,11 +67,6 @@ 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)
{
print_launch_information();
@ -188,7 +181,7 @@ void rct2_init()
RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
window_new_ride_init_vars();
window_guest_list_init_vars_b();
window_staff_init_vars();
window_staff_list_init_vars();
title_load();

View File

@ -91,6 +91,8 @@ typedef fixed32_1dp money32;
#define MONEY32_UNDEFINED ((money32)0x80000000)
typedef unsigned short rct_string_id;
void rct2_finish();
enum {

45
src/readme.md Normal file
View File

@ -0,0 +1,45 @@
# Source directory structure
- **audio**
Contains files for mixing and playing music and sound.
- **drawing**
Low level drawing logic and palette tables.
- **interface**
Window and widget logic, includes high level drawing and input.
- **localisation**
String IDs, currency and date logic.
- **network**
Network and multiplayer logic, includes management of network games and downloading / uploading of content.
- **management**
Park management logic such as finance, marketing and research.
- **platform**
Compiler and operating system specific code such as type definitions, message handling and file input / output.
- **ride**
Data and logic for rides, vehicles and track.
- **util**
Utility and helper functions.
- **windows**
Definitions and logic for all the windows in the game.
- **world**
World objects and mechanics such as the climate, landscape, sprites and park.

View File

@ -19,18 +19,18 @@
*****************************************************************************/
#include <windows.h>
#include "addresses.h"
#include "game.h"
#include "map.h"
#include "news_item.h"
#include "staff.h"
#include "sprite.h"
#include "../addresses.h"
#include "../game.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/news_item.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../scenario.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "ride.h"
#include "ride_data.h"
#include "scenario.h"
#include "sprite.h"
#include "peep.h"
#include "window.h"
#pragma region Ride classification table

View File

@ -21,10 +21,9 @@
#ifndef _RIDE_H_
#define _RIDE_H_
#include "map.h"
#include "peep.h"
#include "rct2.h"
#include "string_ids.h"
#include "../common.h"
#include "../peep/peep.h"
#include "../world/map.h"
typedef fixed16_2dp ride_rating;

View File

@ -9,7 +9,6 @@
*/
#include <stdbool.h>
#include "rct2.h"
#include "ride.h"
#include "ride_data.h"

View File

@ -22,8 +22,7 @@
#define _RIDE_DATA_H_
#include <stdbool.h>
#include "rct2.h"
#include "string_ids.h"
#include "../common.h"
typedef struct {
rct_string_id vehicle_name;

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "../addresses.h"
#include "ride.h"
#include "ride_data.h"
#include "ride_ratings.h"

View File

@ -21,7 +21,7 @@
#ifndef _RIDE_RATINGS_H_
#define _RIDE_RATINGS_H_
#include "rct2.h"
#include "../common.h"
#include "ride.h"
void crooked_house_excitement(rct_ride *ride);

View File

@ -20,9 +20,9 @@
#include <string.h>
#include <windows.h>
#include "addresses.h"
#include "../addresses.h"
#include "../platform/osinterface.h"
#include "ride.h"
#include "osinterface.h"
#include "track.h"
/**

View File

@ -21,7 +21,7 @@
#ifndef _TRACK_H_
#define _TRACK_H_
#include "rct2.h"
#include "../common.h"
#include "ride.h"
typedef struct {

View File

@ -18,13 +18,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "audio.h"
#include "mixer.h"
#include "../addresses.h"
#include "../audio/audio.h"
#include "../audio/mixer.h"
#include "../interface/viewport.h"
#include "../world/sprite.h"
#include "ride.h"
#include "sprite.h"
#include "vehicle.h"
#include "viewport.h"
static void vehicle_update(rct_vehicle *vehicle);

View File

@ -21,7 +21,7 @@
#ifndef _VEHICLE_H_
#define _VEHICLE_H_
#include "rct2.h"
#include "../common.h"
typedef union {
struct {

View File

@ -21,22 +21,21 @@
#include <windows.h>
#include <string.h>
#include "addresses.h"
#include "award.h"
#include "date.h"
#include "finance.h"
#include "game.h"
#include "map.h"
#include "marketing.h"
#include "news_item.h"
#include "interface/viewport.h"
#include "localisation/date.h"
#include "localisation/localisation.h"
#include "management/award.h"
#include "management/finance.h"
#include "management/marketing.h"
#include "management/news_item.h"
#include "object.h"
#include "park.h"
#include "rct2.h"
#include "ride.h"
#include "sawyercoding.h"
#include "ride/ride.h"
#include "scenario.h"
#include "string_ids.h"
#include "sprite.h"
#include "viewport.h"
#include "util/sawyercoding.h"
#include "world/map.h"
#include "world/park.h"
#include "world/sprite.h"
/**
* Loads only the basic information from a scenario.

View File

@ -22,23 +22,22 @@
#include <string.h>
#include <time.h>
#include "addresses.h"
#include "audio.h"
#include "audio/audio.h"
#include "config.h"
#include "climate.h"
#include "date.h"
#include "game.h"
#include "gfx.h"
#include "intro.h"
#include "map.h"
#include "news_item.h"
#include "park.h"
#include "rct2.h"
#include "ride.h"
#include "scenario.h"
#include "sprite.h"
#include "string_ids.h"
#include "viewport.h"
#include "drawing/drawing.h"
#include "editor.h"
#include "localisation/date.h"
#include "localisation/localisation.h"
#include "game.h"
#include "interface/viewport.h"
#include "intro.h"
#include "management/news_item.h"
#include "ride/ride.h"
#include "scenario.h"
#include "world/climate.h"
#include "world/map.h"
#include "world/park.h"
#include "world/sprite.h"
static const int gOldMusic = 0;
static const int gRandomShowcase = 0;
@ -109,7 +108,7 @@ void title_load()
RCT2_CALLPROC_EBPSAFE(0x006DFEE4);
window_new_ride_init_vars();
window_guest_list_init_vars_b();
window_staff_init_vars();
window_staff_list_init_vars();
map_update_tile_pointers(); //RCT2_CALLPROC_EBPSAFE(0x0068AFFD);
reset_0x69EBE4();// RCT2_CALLPROC_EBPSAFE(0x0069EBE4);
viewport_init_all();

View File

@ -20,8 +20,9 @@
#include <string.h>
#include "addresses.h"
#include "localisation/localisation.h"
#include "tutorial.h"
#include "window_error.h"
#include "windows/error.h"
/**
*

View File

@ -20,8 +20,7 @@
#include <windows.h>
#include <string.h>
#include "addresses.h"
#include "rct2.h"
#include "../addresses.h"
#include "sawyercoding.h"
static int decode_chunk_rle(uint8* src_buffer, uint8* dst_buffer, int length);

View File

@ -22,7 +22,7 @@
#define _SAWYERCODING_H_
#include <stdio.h>
#include "rct2.h"
#include "../common.h"
typedef struct {
uint8 encoding;

View File

@ -20,11 +20,11 @@
#include <windows.h>
#include <string.h>
#include "addresses.h"
#include "string_ids.h"
#include "sprites.h"
#include "widget.h"
#include "window.h"
#include "../addresses.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
enum WINDOW_ABOUT_WIDGET_IDX {
WIDX_BACKGROUND,

View File

@ -19,12 +19,12 @@
*****************************************************************************/
#include <string.h>
#include "addresses.h"
#include "config.h"
#include "string_ids.h"
#include "viewport.h"
#include "widget.h"
#include "window.h"
#include "../addresses.h"
#include "../config.h"
#include "../localisation/localisation.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
enum WINDOW_BANNER_WIDGET_IDX {
WIDX_BACKGROUND,

View File

@ -21,18 +21,18 @@
#include <windows.h>
#include <string.h>
#include <limits.h>
#include "addresses.h"
#include "park.h"
#include "peep.h"
#include "string_ids.h"
#include "sprite.h"
#include "sprites.h"
#include "widget.h"
#include "window.h"
#include "climate.h"
#include "ride.h"
#include "scenario.h"
#include "game.h"
#include "../addresses.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../ride/ride.h"
#include "../scenario.h"
#include "../sprites.h"
#include "../world/climate.h"
#include "../world/park.h"
#include "../world/sprite.h"
//#define WW 200
//#define WH 128

View File

@ -18,12 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "addresses.h"
#include "map.h"
#include "string_ids.h"
#include "sprites.h"
#include "widget.h"
#include "window.h"
#include "../addresses.h"
#include "../world/map.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
enum WINDOW_CLEAR_SCENERY_WIDGET_IDX {
WIDX_BACKGROUND,

View File

@ -20,13 +20,13 @@
#include <windows.h>
#include <memory.h>
#include "addresses.h"
#include "scenario.h"
#include "string_ids.h"
#include "sprites.h"
#include "widget.h"
#include "window.h"
#include "window_dropdown.h"
#include "../addresses.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../scenario.h"
#include "../sprites.h"
#include "dropdown.h"
int gAppropriateImageDropdownItemsPerRow[] = {
1, 1, 1, 1, 2, 2, 3, 3, 4,

Some files were not shown because too many files have changed in this diff Show More