Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
fix SPS/XPS crash, example icon
Browse files Browse the repository at this point in the history
fix sps/xps parser crash: apparently those 4 bytes were for a third part of metadata for those files. HTML client now shows this information if available.

example icon: id2_example_001 (12 vertices, 4 triangles)

I've saved and included this icon in the .PSU and .SPS formats. .PSV is a bit more complicated for a valid export.

Example icon shows vertex colours with no animation nor includes a texture (texture type 3).

was considering adding new formats, but its not one of the big five (translation: not MAX/PWS or CBS), and I can barely find any examples to test with. Oh well. adding them to gitignore already. If the demand comes up, I've made the related hexpat's for them anyway.

.xpo and .spo (assuming they're like .xpo files) files are out of scope for this project, if anyone asks. Reason being is that they usually exclude icon data, and even icon.sys. This makes it rather useless to me.
  • Loading branch information
yellows111 committed Dec 3, 2023
1 parent 837dffc commit 5738fbb
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Compile documentation with JSDoc
run: npx jsdoc ./icon.js -d ./documentation -R ./README.md
- name: Upload Artifacts
uses: 'actions/upload-artifact@main'
uses: actions/upload-artifact@main
with:
name: JSDoc-compiled Documentation
path: './documentation/*'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ icon.sys
*.psv
*.xps
*.sps
*.npo
*.p2m
*.md

# Unused data

Expand Down
Binary file added examples/example_001/id2_example_001.psu
Binary file not shown.
Binary file added examples/example_001/id2_example_001.sps
Binary file not shown.
19 changes: 19 additions & 0 deletions examples/example_001/raw/description.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# A test 12-vertice icon for testing icondumper2 clients.
# Original Wavefront OBJ file:
o DefaultObject001
v 1.250000 1.000000 0.000000
v -0.750000 1.000000 -1.000000
v -0.750000 1.000000 1.000000
v 0.000000 0.000000 0.000000
vn -0.0000 1.0000 -0.0000
vn -0.8000 -0.6000 -0.0000
vn 0.3904 -0.4880 0.7807
vn 0.3904 -0.4880 -0.7807
vt 0.000000 0.000000
vt 0.875000 0.500000
vt 0.875000 0.750000
s 0
f 1/1/1 2/2/1 3/3/1
f 4/1/2 3/3/2 2/2/2
f 3/3/3 4/1/3 1/1/3
f 4/1/4 2/2/4 1/1/4
Binary file added examples/example_001/raw/example_001.icn
Binary file not shown.
Binary file added examples/example_001/raw/icon.sys
Binary file not shown.
15 changes: 13 additions & 2 deletions icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ICONJS_STRICT = true;
* @constant {string}
* @default
*/
const ICONJS_VERSION = "0.6.0";
const ICONJS_VERSION = "0.6.1";

/**
* Extension of DataView to add shortcuts for datatypes that I use often.
Expand Down Expand Up @@ -576,11 +576,22 @@ function readSharkXPortSxpsFile(input) {
offset += (titleLength + 4);
const descriptionLength = u32le(offset);
const description = input.slice(offset + 4, (offset + 4) + descriptionLength);
offset += (descriptionLength + 8);
offset += (descriptionLength + 4);
const description2Length = u32le(offset);
let description2;
if(description2Length !== 0) {
description2 = input.slice(offset + 4, (offset + 4) + description2Length);
offset += (description2Length + 4);
} else {
offset += 4;
}
const comments = {
"game": stringScrubber((new TextDecoder("utf-8")).decode(title)),
"name": stringScrubber((new TextDecoder("utf-8")).decode(description))
}
if(description2Length !== 0) {
comments.desc = stringScrubber((new TextDecoder("utf-8")).decode(description2));
}
const totalSize = u32le(offset);
offset += 4;
const header = readSxpsDescriptor(input.slice(offset, offset + 250));
Expand Down
8 changes: 6 additions & 2 deletions index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ <h1 id="title2">&#xFF2C;&#xFF4F;&#xFF41;&#xFF44;&#xFF45;&#xFF44;</h1>
<span>Date&nbsp;modified: </span><span id="dateModified">--:--:--&nbsp;--/--/----</span><span> UTC+09:00</span>
</p>
<p>
<span>File comments: </span><span id="fileCommentGame">(no title)</span></span><span> - </span><span id="fileCommentName">(no description)</span>
<span>File comments: </span><span id="fileCommentGame">(no title)</span><span> - </span><span id="fileCommentName">(no description)</span><span> - </span><span id="fileCommentDesc">(no other text)</span>
</p>
<script>
// I usually don't do in-body <script>'s, but I didn't want to do an await onload() again
Expand Down Expand Up @@ -271,6 +271,7 @@ <h1 id="title2">&#xFF2C;&#xFF4F;&#xFF41;&#xFF44;&#xFF45;&#xFF44;</h1>
document.getElementById("dateModified").textContent = "--:--:-- --/--/----";
document.getElementById("fileCommentGame").textContent = "(no title)";
document.getElementById("fileCommentName").textContent = "(no description)";
document.getElementById("fileCommentDesc").textContent = "(no other text)";
//reset globalstate parameters
GlobalState.iconState.cachedIconSys = null;
GlobalState.iconState.currentIcon = null;
Expand Down Expand Up @@ -547,6 +548,9 @@ <h1 id="title2">&#xFF2C;&#xFF4F;&#xFF41;&#xFF44;&#xFF45;&#xFF44;</h1>
document.getElementById("dateModified").textContent = `${mTime.hours.toString().padStart("2","0")}:${mTime.minutes.toString().padStart("2","0")}:${mTime.seconds.toString().padStart("2","0")} ${mTime.day.toString().padStart("2","0")}/${mTime.month.toString().padStart("2","0")}/${mTime.year}`;
document.getElementById("fileCommentGame").textContent = vFilesystem.comments.game;
document.getElementById("fileCommentName").textContent = vFilesystem.comments.name;
if(vFilesystem.comments.hasOwnProperty("desc")) {
document.getElementById("fileCommentDesc").textContent = vFilesystem.comments.desc;
}
console.info("model files (*ps)", output2);
console.info("icon.sys (*ps)", output);
} catch(e) {
Expand Down Expand Up @@ -635,7 +639,7 @@ <h1 id="title2">&#xFF2C;&#xFF4F;&#xFF41;&#xFF44;&#xFF45;&#xFF44;</h1>
<span id="version">icondumper2 <a href="./documentation" id="iconjsVersion">(unknown icon.js version)</a> [C: <span id="clientVersion">Loading...</span>] &mdash; &copy; <span id="currentYear">2023</span> yellows111</span>
<script>
document.getElementById("iconjsVersion").textContent = exports.version;
document.getElementById("clientVersion").textContent = "0.6.5";
document.getElementById("clientVersion").textContent = "0.6.6";
document.getElementById("currentYear").textContent = (new Date()).getFullYear().toString();
</script>
</body>
Expand Down

0 comments on commit 5738fbb

Please sign in to comment.