Skip to content

Commit

Permalink
Change: platform connection behaviour
Browse files Browse the repository at this point in the history
Now by default they automatically connects rather than forming a slope to avoid some embarassing images

Also macros are mass used. I am not very sure if they should be used this much.
  • Loading branch information
WenSimEHRP committed May 3, 2024
1 parent 23445ed commit 54ac120
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 51 deletions.
19 changes: 6 additions & 13 deletions src/templates.pnml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@

// empty templates and sprites will be removed after the release of NML 0.7.5
// currently for maximum compatibility we need to keep them
template template_platform_0 (a) {[POSITION_X * 0, POSITION_Y, SIZE_X, SIZE_Y, -127, -182, PATH]}
template template_platform_1 (a) {[POSITION_X * 1, POSITION_Y, SIZE_X, SIZE_Y, -127, -181, PATH]}
template template_platform_2 (a) {[POSITION_X * 2, POSITION_Y, SIZE_X, SIZE_Y, -207, -222, PATH]}
template template_platform_3 (a) {[POSITION_X * 3, POSITION_Y, SIZE_X, SIZE_Y, -47, -221, PATH]}
template template_platform_4 (a) {[POSITION_X * 4, POSITION_Y, SIZE_X, SIZE_Y, -207, -222, PATH]}
template template_platform_5 (a) {[POSITION_X * 5, POSITION_Y, SIZE_X, SIZE_Y, -47, -221, PATH]}
template template_platform_6 (a) {[POSITION_X * 6, POSITION_Y, SIZE_X, SIZE_Y, -127, -182, PATH]}
template template_platform_7 (a) {[POSITION_X * 7, POSITION_Y, SIZE_X, SIZE_Y, -127, -181, PATH]}

template template_platform_NW (a) {[POSITION_X * 0, POSITION_Y, SIZE_X, SIZE_Y, -127, -182, PATH]}
template template_platform_NE (a) {[POSITION_X * 1, POSITION_Y, SIZE_X, SIZE_Y, -127, -181, PATH]}
Expand All @@ -25,14 +17,15 @@ template template_asymplat_SW (a) {[POSITION_X * 5, POSITION_Y, SIZE_X, SIZE_Y,
template template_asymplat_NW (a) {[POSITION_X * 6, POSITION_Y, SIZE_X, SIZE_Y, -127, -182, PATH]}
template template_asymplat_NE (a) {[POSITION_X * 7, POSITION_Y, SIZE_X, SIZE_Y, -127, -181, PATH]}

template template_bufferstop_0 (a) {[POSITION_X * 0, POSITION_Y, SIZE_X, SIZE_Y, -79, -207, PATH]}
template template_bufferstop_1 (a) {[POSITION_X * 1, POSITION_Y, SIZE_X, SIZE_Y, -176, -207, PATH]}
template template_bufferstop_2 (a) {[POSITION_X * 2, POSITION_Y, SIZE_X, SIZE_Y, -157, -247, PATH]}
template template_bufferstop_3 (a) {[POSITION_X * 3, POSITION_Y, SIZE_X, SIZE_Y, -97, -247, PATH]}

template template_bufferstop_NW (a) {[POSITION_X * 0, POSITION_Y, SIZE_X, SIZE_Y, -79, -207, PATH]}
template template_bufferstop_NE (a) {[POSITION_X * 1, POSITION_Y, SIZE_X, SIZE_Y, -176, -207, PATH]}
template template_bufferstop_SE (a) {[POSITION_X * 2, POSITION_Y, SIZE_X, SIZE_Y, -157, -247, PATH]}
template template_bufferstop_SW (a) {[POSITION_X * 3, POSITION_Y, SIZE_X, SIZE_Y, -97, -247, PATH]}

template template_fence_NW (a) {[POSITION_X * 0, POSITION_Y, SIZE_X, SIZE_Y, -127, -183, PATH]}
template template_fence_NE (a) {[POSITION_X * 1, POSITION_Y, SIZE_X, SIZE_Y, -126, -183, PATH]}
template template_fence_SE (a) {[POSITION_X * 2, POSITION_Y, SIZE_X, SIZE_Y, -257, -245, PATH]}
template template_fence_SW (a) {[POSITION_X * 3, POSITION_Y, SIZE_X, SIZE_Y, 0, -245, PATH]}


template template_platform_zero (pos, a) {[POSITION_X * pos, POSITION_Y, SIZE_X, SIZE_Y, 0, 0, PATH]}
207 changes: 169 additions & 38 deletions src/testing.pnml
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
// these values shouldn't be changed...
#define TILE_X_NE 0
#define TILE_X_SW 1
#define TILE_X_NW 2
#define TILE_X_SE 3
#define TILE_X_N 4
#define TILE_X_S 5
#define TILE_X_W 6
#define TILE_X_E 7
#define TILE_SELF 8

#define TILE_Y_NW TILE_X_NE
#define TILE_Y_SE TILE_X_SW
#define TILE_Y_NE TILE_X_NW
#define TILE_Y_SW TILE_X_SE
#define TILE_Y_N TILE_X_N
#define TILE_Y_S TILE_X_S
#define TILE_Y_W TILE_X_E
#define TILE_Y_E TILE_X_W

// these are fine
#define TEMP_RAIL_CONTINUATION 9
#define TEMP_NEARBY_TILE_STATION 10
#define TEMP_NEARBY_TILE_PERPENDICULAR 11
#define TEMP_NEARBY_TILE_GRF 12

spriteset (s_platform_0, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
template_platform_NW("platforms/platform_concrete")
template_platform_NE("platforms/platform_concrete")
Expand Down Expand Up @@ -51,91 +77,165 @@ spriteset (s_test_bufferstop, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
SW: template_bufferstop_SW("extras/bufferstop")
}

/*
spriteset (s_test_fence, ZOOM_LEVEL_IN_4X, BIT_DEPTH_32BPP) {
NW: template_fence_NW("fences/fence1")
NE: template_fence_NE("fences/fence1")
SE: template_fence_SE("fences/fence1")
SW: template_fence_SW("fences/fence1")
}*/

#define GET_NPLAT_FORMATION(sid, nid) \
((getbits(sid, NPLAT_BIT, 1) | getbits(LOAD_TEMP(TEMP_NEARBY_TILE_GRF), TILE_X_SW, 1)) << 0|\
(getbits(nid, NPLAT_BIT, 1) | getbits(LOAD_TEMP(TEMP_NEARBY_TILE_GRF), TILE_X_NE, 1)) << 1)

#define GET_SPLAT_FORMATION(sid, nid) \
((getbits(sid, SPLAT_BIT, 1) | getbits(LOAD_TEMP(TEMP_NEARBY_TILE_GRF), TILE_X_SW, 1)) << 0|\
(getbits(nid, SPLAT_BIT, 1) | getbits(LOAD_TEMP(TEMP_NEARBY_TILE_GRF), TILE_X_NE, 1)) << 1)

spritelayout sp_test_x(hide_platform_nw, hide_platform_se, hide_shelter) {
ground {sprite: GROUNDSPRITE_RAIL_X;}
building {
sprite: s_test_bufferstop(1);
building { // bufferstop
sprite: s_test_bufferstop(NE);
BUFFERSTOP_BBOX_NE // macro
hide_sprite: getbits(LOAD_TEMP(0), 0, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_NE, 1);
}
building {
sprite: s_test_bufferstop(3);
building { // bufferstop
sprite: s_test_bufferstop(SW);
BUFFERSTOP_BBOX_SW // macro
hide_sprite: getbits(LOAD_TEMP(0), 1, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_SW, 1);
}/*
building { // fence
sprite: s_test_fence(NW);
FENCE_BBOX_NW
hide_sprite: getbits(LOAD_TEMP(10), 2 ,1);
}
building { // fence
sprite: s_test_fence(SE);
FENCE_BBOX_SE
hide_sprite: getbits(LOAD_TEMP(10), 3, 1);
}*/
building { // station platform, macro is used to define the bounding box.
sprite: CUSTOM(0, 0 + (getbits(LOAD_TEMP(3), NPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), NPLAT_BIT, 1) << 1) % 3 * 4);
sprite: CUSTOM(0, 0 + GET_NPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3 * 4);
PLATFORM_BBOX_NW // macro
hide_sprite: hide_platform_nw;
}
childsprite { // shelter
sprite: CUSTOM(1, 0);
hide_sprite: !!((getbits(LOAD_TEMP(3), NPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), NPLAT_BIT, 1) << 1) % 3) || hide_shelter;
hide_sprite: !!(GET_NPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3) || hide_shelter;
}
building {
sprite: CUSTOM(0, 2 + (getbits(LOAD_TEMP(3), SPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), SPLAT_BIT, 1) << 1) % 3 * 4);
sprite: CUSTOM(0, 2 + GET_SPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3 * 4);
PLATFORM_BBOX_SE // macro
hide_sprite: hide_platform_se;
}
childsprite {
sprite: CUSTOM(1, 2);
hide_sprite: !!((getbits(LOAD_TEMP(3), SPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), SPLAT_BIT, 1) << 1) % 3) || hide_shelter;
hide_sprite: !!(GET_SPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3) || hide_shelter;
}
}

spritelayout sp_test_y(hide_platform_ne, hide_platform_sw, hide_shelter) {
ground {sprite: GROUNDSPRITE_RAIL_Y;}
building {
sprite: s_test_bufferstop(0);
sprite: s_test_bufferstop(NW);
BUFFERSTOP_BBOX_NW // macro
hide_sprite: getbits(LOAD_TEMP(0), 0, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_NE, 1);
}
building {
sprite: s_test_bufferstop(2);
sprite: s_test_bufferstop(SE);
BUFFERSTOP_BBOX_SE // macro
hide_sprite: getbits(LOAD_TEMP(0), 1, 1);
hide_sprite: getbits(LOAD_TEMP(TEMP_RAIL_CONTINUATION), TILE_X_SW, 1);
}/*
building {
sprite: s_test_fence(NE);
FENCE_BBOX_NE
hide_sprite: getbits(LOAD_TEMP(10), 2, 1);
}
building {
sprite: s_test_fence(SW);
FENCE_BBOX_SW
hide_sprite: getbits(LOAD_TEMP(10), 3, 1);
}*/
building { // station platform, macros are still used
sprite: CUSTOM(0, 1 + (getbits(LOAD_TEMP(3), NPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), NPLAT_BIT, 1) << 1) % 3 * 4);
sprite: CUSTOM(0, 1 + GET_NPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3 * 4);
PLATFORM_BBOX_NE // macro
hide_sprite: hide_platform_ne;
}
childsprite {
sprite: CUSTOM(1, 1);
hide_sprite: !!((getbits(LOAD_TEMP(3), NPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), NPLAT_BIT, 1) << 1) % 3) || hide_shelter;
hide_sprite: !!(GET_NPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3) || hide_shelter;
}
building {
sprite: CUSTOM(0, 3 + (getbits(LOAD_TEMP(3), SPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), SPLAT_BIT, 1) << 1) % 3 * 4);
sprite: CUSTOM(0, 3 + GET_NPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3 * 4);
PLATFORM_BBOX_SW // macro
hide_sprite: hide_platform_sw;
}
childsprite {
sprite: CUSTOM(1, 3);
hide_sprite: !!((getbits(LOAD_TEMP(3), SPLAT_BIT, 1) << 0 | getbits(LOAD_TEMP(2), SPLAT_BIT, 1) << 1) % 3) || hide_shelter;
hide_sprite: !!(GET_NPLAT_FORMATION(LOAD_TEMP(TILE_X_SW), LOAD_TEMP(TILE_X_NE)) % 3) || hide_shelter;
}
}
/* about registers
* 0: rail continuation, used for bufferstops
*/
*
*/
switch (FEAT_STATIONS, SELF, sw_check_rail_continuation,
hasbit(rail_continuation, 1) << TILE_X_NE|
hasbit(rail_continuation, 0) << TILE_X_SW) {return;}


switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_station,
nearby_tile_is_station(-1, 0) << TILE_X_NE|
nearby_tile_is_station( 1, 0) << TILE_X_SW|
nearby_tile_is_station( 0,-1) << TILE_X_NW|
nearby_tile_is_station( 0, 1) << TILE_X_SE|
nearby_tile_is_station(-1,-1) << TILE_X_N|
nearby_tile_is_station( 1, 1) << TILE_X_S|
nearby_tile_is_station( 1,-1) << TILE_X_W|
nearby_tile_is_station(-1, 1) << TILE_X_E) {return;}

switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_perpendicular,
nearby_tile_perpendicular(-1, 0) << TILE_X_NE|
nearby_tile_perpendicular( 1, 0) << TILE_X_SW|
nearby_tile_perpendicular( 0,-1) << TILE_X_NW|
nearby_tile_perpendicular( 0, 1) << TILE_X_SE|
nearby_tile_perpendicular(-1,-1) << TILE_X_N|
nearby_tile_perpendicular( 1, 1) << TILE_X_S|
nearby_tile_perpendicular( 1,-1) << TILE_X_W|
nearby_tile_perpendicular(-1, 1) << TILE_X_E) {return;}

switch (FEAT_STATIONS, SELF, sw_check_nearby_tile_grf,
nearby_tile_same_grf(-1, 0) << TILE_X_NE|
nearby_tile_same_grf( 1, 0) << TILE_X_SW|
nearby_tile_same_grf( 0,-1) << TILE_X_NW|
nearby_tile_same_grf( 0, 1) << TILE_X_SE|
nearby_tile_same_grf(-1,-1) << TILE_X_N|
nearby_tile_same_grf( 1, 1) << TILE_X_S|
nearby_tile_same_grf( 1,-1) << TILE_X_W|
nearby_tile_same_grf(-1, 1) << TILE_X_E) {return;}

switch (FEAT_STATIONS, SELF, sw_test, [
STORE_TEMP(hasbit(rail_continuation, 1) << 0|
hasbit(rail_continuation, 0) << 1, 0),
STORE_TEMP(nearby_tile_is_station(-1,0) << 0|
nearby_tile_is_station( 1,0) << 1, 1),
STORE_TEMP(nearby_tile_station_id(-1,0), 2),
STORE_TEMP(nearby_tile_station_id( 1,0), 3),
STORE_TEMP(nearby_tile_station_id(0,-1), 4),
STORE_TEMP(nearby_tile_station_id(0, 1), 5),
STORE_TEMP(sw_check_rail_continuation(), TEMP_RAIL_CONTINUATION),
STORE_TEMP(nearby_tile_station_id(-1, 0), TILE_X_NE),
STORE_TEMP(nearby_tile_station_id( 1, 0), TILE_X_SW),
STORE_TEMP(nearby_tile_station_id( 0,-1), TILE_X_NW),
STORE_TEMP(nearby_tile_station_id( 0, 1), TILE_X_SE),
STORE_TEMP(nearby_tile_station_id(-1,-1), TILE_X_N),
STORE_TEMP(nearby_tile_station_id( 1, 1), TILE_X_S),
STORE_TEMP(nearby_tile_station_id( 1,-1), TILE_X_W),
STORE_TEMP(nearby_tile_station_id(-1, 1), TILE_X_E),
STORE_TEMP(nearby_tile_station_id( 0, 0), TILE_SELF),
STORE_TEMP(sw_check_nearby_tile_station(), TEMP_NEARBY_TILE_STATION),
STORE_TEMP(sw_check_nearby_tile_perpendicular(), TEMP_NEARBY_TILE_PERPENDICULAR),
STORE_TEMP(sw_check_nearby_tile_grf(), TEMP_NEARBY_TILE_GRF),
])
{return;}

#define STANDARD_STATION(hide_nplat, hide_splat, hide_shelter, platform_spriteset, shelter_spriteset, hide_fence) \
item (FEAT_STATIONS, i_station_##hide_nplat##hide_splat##hide_shelter##platform_spriteset##shelter_spriteset##hide_fence, \
#define STANDARD_STATION(hide_nplat, hide_splat, hide_shelter, platform_spriteset, shelter_spriteset) \
item (FEAT_STATIONS, i_station_##hide_nplat##hide_splat##hide_shelter##platform_spriteset##shelter_spriteset, \
hide_nplat << NPLAT_BIT | hide_splat << SPLAT_BIT | hide_shelter << SHELTER_BIT |\
platform_spriteset << PLATFORM_SPRITESET_BITS | shelter_spriteset << SHELTER_SPRITESET_BITS|\
hide_fence << FENCE_BIT | STANDARD_PLATFORM_BITS) {\
STANDARD_PLATFORM_BITS) {\
property {\
class: "CNS1";\
classname: string(STR_TEST);\
Expand All @@ -150,17 +250,48 @@ item (FEAT_STATIONS, i_station_##hide_nplat##hide_splat##hide_shelter##platform_


#define STANDARD_STATION_DEFINES(a,b) \
STANDARD_STATION(0,0,0,a,b,0)\
STANDARD_STATION(0,1,0,a,b,0)\
STANDARD_STATION(1,0,0,a,b,0)\
STANDARD_STATION(0,0,1,a,b,0)\
STANDARD_STATION(0,1,1,a,b,0)\
STANDARD_STATION(1,0,1,a,b,0)\
STANDARD_STATION(0,0,0,a,b)\
STANDARD_STATION(0,1,0,a,b)\
STANDARD_STATION(1,0,0,a,b)\
STANDARD_STATION(0,0,1,a,b)\
STANDARD_STATION(0,1,1,a,b)\
STANDARD_STATION(1,0,1,a,b)\

STANDARD_STATION_DEFINES(0,0)
STANDARD_STATION_DEFINES(0,1)
STANDARD_STATION_DEFINES(1,0)
STANDARD_STATION_DEFINES(1,1)

STANDARD_STATION(1,1,1,0,0,1)
STANDARD_STATION(1,1,1,0,0)

#undef STANDARD_STATION
#undef STANDARD_STATION_DEFINES

#undef TILE_SELF
#undef TILE_X_NE
#undef TILE_X_SW
#undef TILE_X_NW
#undef TILE_X_SE
#undef TILE_X_N
#undef TILE_X_S
#undef TILE_X_W
#undef TILE_X_E

#undef TILE_Y_NW
#undef TILE_Y_SE
#undef TILE_Y_NE
#undef TILE_Y_SW
#undef TILE_Y_N
#undef TILE_Y_S
#undef TILE_Y_W
#undef TILE_Y_E

#undef TEMP_RAIL_CONTINUATION
#undef TEMP_NEARBY_TILE_STATION
#undef TEMP_NEARBY_TILE_PERPENDICULAR

#undef GET_NPLAT_FORMATION
#undef GET_SPLAT_FORMATION
#undef NFENCE_HIDE
#undef SFENCE_HIDE

0 comments on commit 54ac120

Please sign in to comment.