Skip to content

Commit 24d28be

Browse files
committedSep 3, 2017
initialized mod and wrote initial ps_tileset_repair_header function
0 parents  commit 24d28be

10 files changed

+57
-0
lines changed
 

‎PS_Tileset/Setup-PS_Tileset.tp2

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
BACKUP ~PS_Tileset\backup~
2+
AUTHOR ~Sam.~
3+
VERSION ~v0.0.0~
4+
5+
ALWAYS
6+
INCLUDE ~%MOD_FOLDER%/lib/ps_tileset_lib.tpa~ // Include the PS_Tileset function library
7+
END
8+
9+
//! Test PS_Tileset /////////////////////////////////////////////////////
10+
BEGIN ~Repair Header~
11+
SUBCOMPONENT ~Test PS_Tileset~
12+
NO_LOG_RECORD
13+
14+
COPY ~%MOD_FOLDER%/tilesets~ ~%MOD_FOLDER%/processed~
15+
LPF ps_tileset_repair_header END
16+
//PRINT "Test"
17+
18+

‎PS_Tileset/backup/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

‎PS_Tileset/lib/ps_tileset_lib.tpa

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//////////////////////////////////////////////////////////////////////////////////
2+
//////////////////////// ps_tileset_repair_header //////////////////////////
3+
//////////////////////////////////////////////////////////////////////////////////
4+
// This is a WeiDU patch function that repairs a couple of uncommon errors in tileset headers caused by other programs.
5+
// 1) An old version of DLTCEP erroneously wrote tilesets with an invalid version string of 'V2 '. This will be fixed.
6+
// 2) Old versions of Near Infinity erroneously exported tilesets without a header. A header can be generated but it requires making
7+
// some assumptions. One assumption is that it is a palette-based tileset, but as PVRz-based tilesets did not come out until after NI
8+
// was fixed, this should be a good assumption. The second assumption is that the tile dimensions are 64x64 px, but I have never seen
9+
// any other value used, so this should also be a reasonably good assumption.
10+
//////////////////////////////////////////////////////////////////////////////////
11+
DEFINE_PATCH_FUNCTION ps_tileset_repair_header BEGIN
12+
READ_ASCII 0x0 Signature (4) // Signature ("TIS ")
13+
PATCH_IF (~%Signature%~ STRING_EQUAL_CASE ~TIZ0~ = 1) OR (~%Signature%~ STRING_EQUAL_CASE ~TBC ~ = 1) OR (~%Signature%~ STRING_EQUAL_CASE ~TISC~ = 1) BEGIN // Tileset is compressed
14+
PATCH_PRINT ~Tileset "%SOURCE_FILESPEC%" is compressed but compressed tilesets are not supported: it will not be processed.~
15+
END ELSE PATCH_IF (~%Signature%~ STRING_EQUAL_CASE ~TIS ~ = 1) BEGIN // Is an uncompressed tileset with a header
16+
READ_ASCII 0x4 Version (4) // Version ("V1 ")
17+
PATCH_IF (~%Version%~ STRING_EQUAL_CASE ~V2 ~ = 1) BEGIN // Tileset has invalid version
18+
WRITE_ASCIIE 0x4 ~V1 ~ // Fix the version
19+
END
20+
END ELSE PATCH_IF (~%SOURCE_EXT%~ STRING_EQUAL_CASE ~tis~ = 1) BEGIN // Appears to be a tileset without a header. A header can be generated but it requires making some assumptions.
21+
INSERT_BYTES 0 24 // Make room for the header
22+
WRITE_ASCIIE 0x0 ~TIS ~ // Signature ("TIS ")
23+
WRITE_ASCIIE 0x4 ~V1 ~ // Version ("V1 ")
24+
WRITE_LONG 0x8 (SOURCE_SIZE / 5120) // Count of tiles within this tileset (FileSize/LengthOfTilesSection)
25+
WRITE_LONG 0xc 5120 // Length of tiles section (1024+DimensionOfTile*DimensionOfTile) - assumption
26+
WRITE_LONG 0x10 24 // Size of the header (24) - assumption, but a very good one
27+
WRITE_LONG 0x14 64 // Dimension of 1 tile in pixels (64x64) - assumption, but a good one
28+
END ELSE BEGIN
29+
PATCH_PRINT ~"%SOURCE_FILESPEC%" does not appear to be a valid tileset: it will not be processed.~
30+
END
31+
END

‎PS_Tileset/processed/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

‎PS_Tileset/tilesets/AR0150.TIS

300 KB
Binary file not shown.

‎PS_Tileset/tilesets/AR0301.WED

13.9 KB
Binary file not shown.

‎PS_Tileset/tilesets/ar0301.TIZ

152 KB
Binary file not shown.

‎PS_Tileset/tilesets/ar0301.tis

1.9 MB
Binary file not shown.

‎PS_Tileset/tilesets/psar04.tis

1.03 MB
Binary file not shown.

‎Setup-PS_Tileset.exe

970 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.