Merge pull request #3358 from marijnvdwerf/paint-setup/surface-paint

Paint setup/surface paint
This commit is contained in:
Duncan 2016-05-01 19:29:40 +01:00
commit c1b11743a0
8 changed files with 1926 additions and 43 deletions

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
C61FAAE21CD1643A0010C9D8 /* paint_surface.c in Sources */ = {isa = PBXBuildFile; fileRef = C61FAAE01CD1643A0010C9D8 /* paint_surface.c */; };
C650B2191CCABBDD00B4D91C /* S4Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2151CCABBDD00B4D91C /* S4Importer.cpp */; };
C650B21A1CCABBDD00B4D91C /* tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2171CCABBDD00B4D91C /* tables.cpp */; };
C650B21C1CCABC4400B4D91C /* ConvertCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B21B1CCABC4400B4D91C /* ConvertCommand.cpp */; };
@ -229,6 +230,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
C61FAAE01CD1643A0010C9D8 /* paint_surface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = paint_surface.c; sourceTree = "<group>"; };
C61FAAE11CD1643A0010C9D8 /* paint_surface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = paint_surface.h; sourceTree = "<group>"; };
C650B2151CCABBDD00B4D91C /* S4Importer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = S4Importer.cpp; sourceTree = "<group>"; };
C650B2161CCABBDD00B4D91C /* S4Importer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = S4Importer.h; sourceTree = "<group>"; };
C650B2171CCABBDD00B4D91C /* tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tables.cpp; sourceTree = "<group>"; };
@ -796,6 +799,8 @@
D44271201CC81B3200D84D28 /* graph.h */,
D44271211CC81B3200D84D28 /* keyboard_shortcut.c */,
D44271221CC81B3200D84D28 /* keyboard_shortcut.h */,
C61FAAE01CD1643A0010C9D8 /* paint_surface.c */,
C61FAAE11CD1643A0010C9D8 /* paint_surface.h */,
D44271231CC81B3200D84D28 /* screenshot.c */,
D44271241CC81B3200D84D28 /* screenshot.h */,
D44271251CC81B3200D84D28 /* Theme.cpp */,
@ -1499,6 +1504,7 @@
D44272401CC81B3200D84D28 /* windows.c in Sources */,
D44272881CC81B3200D84D28 /* text_input.c in Sources */,
D442720F1CC81B3200D84D28 /* scrolling_text.c in Sources */,
C61FAAE21CD1643A0010C9D8 /* paint_surface.c in Sources */,
D44271F51CC81B3200D84D28 /* addresses.c in Sources */,
D44272041CC81B3200D84D28 /* Stopwatch.cpp in Sources */,
D44272241CC81B3200D84D28 /* intro.c in Sources */,

View File

@ -57,6 +57,7 @@
<ClCompile Include="src\input.c" />
<ClCompile Include="src\interface\chat.c" />
<ClCompile Include="src\interface\colour.c" />
<ClCompile Include="src\interface\paint_surface.c" />
<ClCompile Include="src\interface\Theme.cpp" />
<ClCompile Include="src\interface\console.c" />
<ClCompile Include="src\interface\graph.c" />
@ -239,6 +240,7 @@
<ClInclude Include="src\input.h" />
<ClInclude Include="src\interface\chat.h" />
<ClInclude Include="src\interface\colour.h" />
<ClInclude Include="src\interface\paint_surface.h" />
<ClInclude Include="src\interface\themes.h" />
<ClInclude Include="src\interface\console.h" />
<ClInclude Include="src\interface\graph.h" />

View File

@ -603,6 +603,7 @@
<ClCompile Include="src\cmdline\ConvertCommand.cpp">
<Filter>Source\CommandLine</Filter>
</ClCompile>
<ClCompile Include="src\interface\paint_surface.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\management\award.h">
@ -923,6 +924,7 @@
<ClInclude Include="src\rct1\Tables.h">
<Filter>Source\RCT1</Filter>
</ClInclude>
<ClInclude Include="src\interface\paint_surface.h" />
</ItemGroup>
<ItemGroup>
<Image Include="resources\logo\icon.ico">

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,89 @@
#ifndef _PAINT_SURFACE_H
#define _PAINT_SURFACE_H
#include "../common.h"
#include "../world/map.h"
enum
{
SPR_TERRAIN_GRASS = 1915,
SPR_TERRAIN_GRASS_GRID = 1934,
SPR_TERRAIN_GRASS_UNDERGROUND = 1953,
SPR_TERRAIN_SAND = 1972,
SPR_TERRAIN_SAND_GRID = 1991,
SPR_TERRAIN_SAND_UNDERGROUND = 2010,
SPR_TERRAIN_SAND_RED = 2029,
SPR_TERRAIN_SAND_RED_GRID = 2048,
SPR_TERRAIN_SAND_RED_UNDERGROUND = 2067,
SPR_TERRAIN_SAND_YELLOW = 2086,
SPR_TERRAIN_SAND_YELLOW_GRID = 2105,
SPR_TERRAIN_SAND_YELLOW_UNDERGROUND = 2124,
SPR_TERRAIN_ICE = 2143,
SPR_TERRAIN_ICE_GRID = 2162,
SPR_TERRAIN_ICE_UNDERGROUND = 2181,
SPR_TERRAIN_GRASS_CLUMPS = 2200,
SPR_TERRAIN_GRASS_CLUMPS_GRID = 2219,
SPR_TERRAIN_GRASS_CLUMPS_UNDERGROUND = 2238,
SPR_TERRAIN_GRID = 2257,
SPR_TERRAIN_GRID_GRID = 2276,
SPR_TERRAIN_GRID_UNDERGROUND = 2295,
SPR_TERRAIN_MARTIAN = 2314,
SPR_TERRAIN_MARTIAN_GRID = 2333,
SPR_TERRAIN_MARTIAN_UNDERGROUND = 2352,
SPR_TERRAIN_CHECKERBOARD = 2371,
SPR_TERRAIN_CHECKERBOARD_GRID = 2390,
SPR_TERRAIN_CHECKERBOARD_UNDERGROUND = 2409,
SPR_TERRAIN_CHECKERBOARD_INVERTED = 2428,
SPR_TERRAIN_CHECKERBOARD_INVERTED_GRID = 2447,
SPR_TERRAIN_CHECKERBOARD_INVERTED_UNDERGROUND = 2466,
SPR_TERRAIN_DIRT = 2485,
SPR_TERRAIN_DIRT_GRID = 2504,
SPR_TERRAIN_DIRT_UNDERGROUND = 2523,
SPR_TERRAIN_ROCK = 2542,
SPR_TERRAIN_ROCK_GRID = 2561,
SPR_TERRAIN_ROCK_UNDERGROUND = 2580,
SPR_TERRAIN_SELECTION_PATROL_AREA = 2599,
SPR_TERRAIN_GRASS_MOWED = 2663,
SPR_TERRAIN_GRASS_MOWED_GRID = 2682,
SPR_TERRAIN_GRASS_MOWED_90 = 2701,
SPR_TERRAIN_GRASS_MOWED_90_GRID = 2720,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_1 = 2739,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_1_GRID = 2758,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_2 = 2777,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_2_GRID = 2796,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_3 = 2815,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_3_GRID = 2834,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_4 = 2853,
SPR_TERRAIN_GRASS_LENGTH_4_VARIANT_4_GRID = 2872,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_1 = 2891,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_1_GRID = 2910,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_2 = 2929,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_2_GRID = 2948,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_3 = 2967,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_3_GRID = 2986,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_4 = 3005,
SPR_TERRAIN_GRASS_LENGTH_6_VARIANT_4_GRID = 3024,
SPR_TERRAIN_SELECTION_CORNER = 3043,
SPR_TERRAIN_SELECTION_EDGE = 3062,
SPR_TERRAIN_SELECTION_QUARTER = 3081,
SPR_WATER_MASK = 5048,
SPR_WATER_OVERLAY = 5053,
SPR_HEIGHT_MARKER_BASE = 5769,
SPR_TERRAIN_EDGE_MASK_TOP_RIGHT = 28883,
SPR_TERRAIN_EDGE_MASK_BOTTOM_RIGHT = 28902,
SPR_TERRAIN_EDGE_MASK_BOTTOM_LEFT = 28921,
SPR_TERRAIN_EDGE_MASK_TOP_LEFT = 28940,
SPR_TERRAIN_PATTERN_GRASS = 28959,
SPR_TERRAIN_PATTERN_SAND = 28965,
SPR_TERRAIN_PATTERN_SAND_RED = 28971,
SPR_TERRAIN_PATTERN_DIRT = 28977,
SPR_TERRAIN_PATTERN_SAND_YELLOW = 28983,
SPR_TERRAIN_PATTERN_ROCK = 28989,
SPR_TERRAIN_PATTERN_MARTIAN = 28995,
SPR_TERRAIN_PATTERN_GRASS_CLUMPS = 29001,
SPR_TERRAIN_PATTERN_ICE = 29007,
};
void viewport_surface_paint_setup(uint8 direction, uint16 height, rct_map_element *mapElement);
#endif //_PAINT_SURFACE_H

View File

@ -27,7 +27,6 @@
#include "../localisation/localisation.h"
#include "../ride/ride_data.h"
#include "../ride/track_data.h"
#include "../ride/track_paint.h"
#include "../sprites.h"
#include "../world/climate.h"
#include "../world/map.h"
@ -36,51 +35,12 @@
#include "../world/entrance.h"
#include "../world/footpath.h"
#include "../world/scenery.h"
#include "colour.h"
#include "viewport.h"
#include "window.h"
#include "paint_surface.h"
//#define DEBUG_SHOW_DIRTY_BOX
rct_viewport g_viewport_list[MAX_VIEWPORT_COUNT];
typedef struct paint_struct paint_struct;
struct paint_struct{
uint32 image_id; // 0x00
uint32 var_04;
uint16 attached_x; // 0x08
uint16 attached_y; // 0x0A
union {
struct {
uint8 var_0C;
uint8 pad_0D;
paint_struct* next_attached_ps; //0x0E
uint16 pad_12;
};
struct {
uint16 attached_z; // 0x0C
uint16 attached_z_end; // 0x0E
uint16 attached_x_end; // 0x10
uint16 attached_y_end; // 0x12
};
};
uint16 x; // 0x14
uint16 y; // 0x16
uint16 var_18;
uint8 var_1A;
uint8 var_1B;
paint_struct* attached_ps; //0x1C
paint_struct* var_20;
paint_struct* next_quadrant_ps; // 0x24
uint8 sprite_type; //0x28
uint8 var_29;
uint16 pad_2A;
uint16 map_x; // 0x2C
uint16 map_y; // 0x2E
rct_map_element *mapElement; // 0x30 (or sprite pointer)
};
/**
* This is not a viewport function. It is used to setup many variables for
* multiple things.
@ -1277,6 +1237,51 @@ bool sub_98198C(
return !(flags & (1 << 8));
}
/**
* rct2: 68818E
*
* @param image_id (ebx)
* @param x (ax)
* @param y (cx)
* @param[out] paint (ebp)
* @return (!CF) success
*/
bool sub_68818E(uint32 image_id, uint16 x, uint16 y, paint_struct ** paint)
{
//Not a paint struct but something similar
paint_struct * ps = RCT2_GLOBAL(0xEE7888, paint_struct *);
if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) {
return false;
}
ps->image_id = image_id;
ps->attached_x = x;
ps->attached_y = y;
ps->var_0C = 0;
paint_struct * ebx2 = RCT2_GLOBAL(0xF1AD28, paint_struct *);
if (ebx2 == NULL) {
return false;
}
RCT2_GLOBAL(0x00EE7888, uint32) += 0x12;
paint_struct * edi = ebx2->attached_ps;
ebx2->attached_ps = ps;
ps->next_attached_ps = edi;
RCT2_GLOBAL(0xF1AD2C, paint_struct *) = ps;
if (paint != NULL) {
*paint = ps;
}
return true;
}
/**
*
* rct2: 0x006D4244
@ -2003,7 +2008,7 @@ static void sub_68B3FB(int x, int y)
switch (map_element_get_type(map_element))
{
case MAP_ELEMENT_TYPE_SURFACE:
RCT2_CALLPROC_X(0x66062C, 0, 0, direction, height, (int)map_element, 0, 0);
viewport_surface_paint_setup(direction, height, map_element);
break;
case MAP_ELEMENT_TYPE_PATH:
RCT2_CALLPROC_X(0x6A3590, 0, 0, direction, height, (int)map_element, 0, 0);

View File

@ -76,6 +76,43 @@ enum {
VIEWPORT_INTERACTION_MASK_BANNER = ~(1 << (VIEWPORT_INTERACTION_ITEM_BANNER - 2)), // Note the -2 for BANNER
};
typedef struct paint_struct paint_struct;
struct paint_struct{
uint32 image_id; // 0x00
uint32 var_04;
uint16 attached_x; // 0x08
uint16 attached_y; // 0x0A
union {
struct {
uint8 var_0C;
uint8 pad_0D;
paint_struct* next_attached_ps; //0x0E
uint16 pad_12;
};
struct {
uint16 attached_z; // 0x0C
uint16 attached_z_end; // 0x0E
uint16 attached_x_end; // 0x10
uint16 attached_y_end; // 0x12
};
};
uint16 x; // 0x14
uint16 y; // 0x16
uint16 var_18;
uint8 var_1A;
uint8 var_1B;
paint_struct* attached_ps; //0x1C
paint_struct* var_20;
paint_struct* next_quadrant_ps; // 0x24
uint8 sprite_type; //0x28
uint8 var_29;
uint16 pad_2A;
uint16 map_x; // 0x2C
uint16 map_y; // 0x2E
rct_map_element *mapElement; // 0x30 (or sprite pointer)
};
typedef struct {
int type;
int x;
@ -144,6 +181,7 @@ bool sub_98196C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_bo
bool sub_98197C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation);
bool sub_98198C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, uint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation);
bool sub_98199C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, uint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation);
bool sub_68818E(uint32 image_id, uint16 x_offset, uint16 y_offset, paint_struct ** paint);
void viewport_invalidate(rct_viewport *viewport, int left, int top, int right, int bottom);

View File

@ -245,7 +245,7 @@ typedef struct{
uint8 x, y, z, direction;
} rct_xyzd8;
typedef struct {
typedef struct rct_xy16{
sint16 x, y;
} rct_xy16;