├── src
├── .idea
│ └── .idea.Texim
│ │ └── .idea
│ │ ├── .name
│ │ ├── vcs.xml
│ │ ├── indexLayout.xml
│ │ ├── .gitignore
│ │ └── CakeRider.xml
├── Texim.sln.DotSettings
├── Texim.PerformanceTest
│ ├── Texim.PerformanceTest.csproj
│ ├── Program.cs
│ └── ImageStructures
│ │ ├── Pixel.cs
│ │ └── PixelRgb.cs
├── Texim.Tool
│ ├── Texim.Tool.csproj
│ ├── StandardPaletteFormat.cs
│ ├── StandardImageFormat.cs
│ ├── Program.cs
│ ├── DisgaeaCommandLine.cs
│ ├── BlackRockShooterCommandLine.cs
│ └── StandardImageFormatExtensions.cs
├── Tests.runsettings
├── Texim.Games
│ ├── Texim.Games.csproj
│ ├── Nitro
│ │ ├── CellBankAttributes.cs
│ │ ├── ObjectAttributeMemoryMode.cs
│ │ ├── TileMappingKind.cs
│ │ ├── NitroBackgroundMode.cs
│ │ ├── INitroFormat.cs
│ │ ├── NitroPaletteMode.cs
│ │ ├── NitroTextureFormat.cs
│ │ ├── CellTileMappingKind.cs
│ │ ├── FullImage2NitroCellParams.cs
│ │ ├── Ncer.cs
│ │ ├── CellAttributes.cs
│ │ ├── Nscr2Binary.cs
│ │ ├── Binary2Nscr.cs
│ │ ├── FullImage2ReferenceNitroCellParams.cs
│ │ ├── Nclr2Binary.cs
│ │ └── Cell.cs
│ ├── Raw
│ │ ├── RawConfiguration.cs
│ │ ├── MapConfiguration.cs
│ │ ├── PaletteConfiguration.cs
│ │ └── PixelsConfiguration.cs
│ ├── JumpUltimateStars
│ │ ├── KShapeSprites.cs
│ │ ├── KomaElement.cs
│ │ ├── Koma.cs
│ │ └── Binary2Koma.cs
│ ├── MetalMax
│ │ └── MmTex.cs
│ ├── DevilSurvivor
│ │ ├── DsTex2Palette.cs
│ │ └── DsTex2Image.cs
│ ├── Disgaea
│ │ └── Ykcmp2Image.cs
│ └── LondonLife
│ │ └── Acl2PaletteCollection.cs
├── Texim.Tests
│ └── Texim.Tests.csproj
├── Texim.Formats.ImageMagick
│ ├── Texim.Formats.ImageMagick.csproj
│ └── ImageMagickFormatConverter.cs
├── Directory.Packages.props
├── Texim
│ ├── Texim.csproj
│ ├── Sprites
│ │ ├── IImageSegmentation.cs
│ │ ├── SpriteRelativeCoordinatesKind.cs
│ │ ├── ISprite.cs
│ │ ├── Sprite.cs
│ │ ├── ImageSegment2IndexedImageParams.cs
│ │ ├── IImageSegment.cs
│ │ ├── Sprite2IndexedImageParams.cs
│ │ ├── ImageSegment.cs
│ │ └── SpriteImageUpdaterParams.cs
│ ├── Processing
│ │ ├── FixedPaletteTileQuantizationResult.cs
│ │ ├── IQuantization.cs
│ │ ├── QuantizationResult.cs
│ │ ├── FixedPaletteQuantization.cs
│ │ └── Quantization.cs
│ ├── Animations
│ │ ├── FullImageFrame.cs
│ │ ├── IFullImageFrame.cs
│ │ ├── IAnimatedFullImage.cs
│ │ └── AnimatedFullImage.cs
│ ├── Pixels
│ │ ├── ISwizzling.cs
│ │ ├── Indexed4BppBigEndian.cs
│ │ ├── IIndexedPixelEncoding.cs
│ │ ├── Indexed8Bpp.cs
│ │ ├── Indexed4Bpp.cs
│ │ ├── IndexedA3I5.cs
│ │ ├── IndexedA5I3.cs
│ │ ├── IndexedPixel.cs
│ │ └── IOExtensions.cs
│ ├── Palettes
│ │ ├── IPalette.cs
│ │ ├── IPaletteCollection.cs
│ │ ├── Palette.cs
│ │ └── PaletteCollection.cs
│ ├── Compressions
│ │ └── Nitro
│ │ │ ├── FullImageMapCompressionParams.cs
│ │ │ ├── IScreenMap.cs
│ │ │ ├── MapCompressionParams.cs
│ │ │ ├── MapDecompressionParams.cs
│ │ │ ├── RawScreenMapParams.cs
│ │ │ ├── ScreenMap.cs
│ │ │ ├── IOExtensions.cs
│ │ │ ├── MapInfo.cs
│ │ │ └── FullImageMapCompression.cs
│ ├── Images
│ │ ├── IFullImage.cs
│ │ ├── IIndexedImage.cs
│ │ ├── FullImage.cs
│ │ ├── IndexedPaletteImage.cs
│ │ ├── FullImage2IndexedPalette.cs
│ │ └── ImageExtensions.cs
│ ├── Colors
│ │ ├── Rgb32.cs
│ │ └── IOExtensions.cs
│ ├── Formats
│ │ ├── TiffImage.cs
│ │ ├── Tiff2PlainFullImage.cs
│ │ ├── IndexedImageBitmapParams.cs
│ │ ├── RawPaletteParams.cs
│ │ ├── RawIndexedImageParams.cs
│ │ ├── TiffPage.cs
│ │ ├── Bitmap2FullImage.cs
│ │ ├── PaletteCollection2ContainerBitmap.cs
│ │ └── FullImage2Bitmap.cs
│ └── CollectionExtensions.cs
└── Directory.Build.props
├── docs
├── articles
│ ├── changelog.md
│ ├── getting-started
│ │ ├── tutorial.md
│ │ └── architecture.md
│ └── toc.yml
├── images
│ ├── logo.png
│ ├── favicon.ico
│ ├── logo-50.png
│ └── favicon-128.png
├── api
│ └── .gitignore
├── .gitignore
├── template
│ └── public
│ │ ├── main.js
│ │ └── main.css
├── toc.yml
└── docfx.json
├── .prettierrc.yaml
├── GitVersion.yml
├── SECURITY.md
├── .gitignore
├── .github
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── pull_request_template.md
└── workflows
│ ├── build-and-release.yml
│ ├── build.yml
│ └── deploy.yml
├── .vscode
├── settings.json
├── launch.json
├── tasks.json
└── header-cs.code-snippets
├── .config
└── dotnet-tools.json
├── LICENSE
└── GitReleaseManager.yaml
/src/.idea/.idea.Texim/.idea/.name:
--------------------------------------------------------------------------------
1 | Texim
--------------------------------------------------------------------------------
/docs/articles/changelog.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | To be filled on preview builds.
4 |
--------------------------------------------------------------------------------
/docs/articles/getting-started/tutorial.md:
--------------------------------------------------------------------------------
1 | # Getting started guide
2 |
3 | TODO...
4 |
--------------------------------------------------------------------------------
/docs/articles/getting-started/architecture.md:
--------------------------------------------------------------------------------
1 | # Project architecture
2 |
3 | TODO...
4 |
--------------------------------------------------------------------------------
/docs/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SceneGate/Texim/main/docs/images/logo.png
--------------------------------------------------------------------------------
/.prettierrc.yaml:
--------------------------------------------------------------------------------
1 | overrides:
2 | - files: "*.md"
3 | options:
4 | proseWrap: always
5 |
--------------------------------------------------------------------------------
/docs/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SceneGate/Texim/main/docs/images/favicon.ico
--------------------------------------------------------------------------------
/docs/images/logo-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SceneGate/Texim/main/docs/images/logo-50.png
--------------------------------------------------------------------------------
/docs/api/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # temp file #
3 | ###############
4 | *.yml
5 | .manifest
6 |
--------------------------------------------------------------------------------
/docs/images/favicon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SceneGate/Texim/main/docs/images/favicon-128.png
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | mode: ContinuousDeployment
2 | branches:
3 | main:
4 | tag: preview
5 | increment: Patch
6 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | This is a proof-of-concept project. There are no stable releases, only preview /
4 | alpha releases. There is no support. Use under your own risk.
5 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # folder #
3 | ###############
4 | /**/DROP/
5 | /**/TEMP/
6 | /**/packages/
7 | /**/bin/
8 | /**/obj/
9 | _site
10 |
11 | # DrawIO
12 | .$*.drawio*
13 |
--------------------------------------------------------------------------------
/docs/template/public/main.js:
--------------------------------------------------------------------------------
1 | export default {
2 | iconLinks: [
3 | {
4 | icon: "github",
5 | href: "https://github.com/SceneGate/Texim",
6 | title: "GitHub",
7 | },
8 | ],
9 | };
10 |
--------------------------------------------------------------------------------
/docs/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Guides
2 | href: articles/
3 |
4 | - name: API
5 | href: api/
6 |
7 | - name: Changelog
8 | href: articles/changelog.md
9 |
10 | - name: GitHub
11 | href: https://github.com/SceneGate/Texim
12 |
--------------------------------------------------------------------------------
/src/.idea/.idea.Texim/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/docs/articles/toc.yml:
--------------------------------------------------------------------------------
1 | - name: ✨ Getting started
2 | - name: Introduction
3 | href: ../index.md
4 | - name: 🚧 Getting started guide
5 | href: ./getting-started/tutorial.md
6 | - name: 🚧 Framework architecture
7 | href: ./getting-started/architecture.md
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build outputs
2 | obj/
3 | bin/
4 | build/artifacts/
5 | build/temp/
6 | /CHANGELOG.md
7 | /CHANGELOG.NEXT.md
8 |
9 | # IDEs
10 | .vs/
11 | *.csproj.user
12 | *.DotSettings.user
13 | launchSettings.json
14 |
15 | # Test results
16 | test_results/
17 | BenchmarkDotNet.Artifacts/
18 | resources/
19 |
--------------------------------------------------------------------------------
/src/.idea/.idea.Texim/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ../../Texim
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/.idea/.idea.Texim/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /.idea.Texim.iml
6 | /modules.xml
7 | /contentModel.xml
8 | /projectSettingsUpdater.xml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/src/.idea/.idea.Texim/.idea/CakeRider.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/src/Texim.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | True
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ""
5 | labels: ""
6 | assignees: ""
7 | ---
8 |
9 | ## Goal
10 |
11 | TODO: describe with user stories or a short text the goal of the feature.
12 |
13 | ## Description
14 |
15 | TODO: describe the motivation behind of the idea and what it should do.
16 |
17 | ## Proposed solution
18 |
19 | TODO: add any ideas for the implementation or how it should look like.
20 |
21 | ## Acceptance criteria
22 |
23 | TODO: list of expectations it should pass to close the request.
24 |
--------------------------------------------------------------------------------
/src/Texim.PerformanceTest/Texim.PerformanceTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | true
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ""
5 | labels: ""
6 | assignees: ""
7 | ---
8 |
9 | ## Description
10 |
11 | TODO: describe the issue
12 |
13 | ## Reproducer
14 |
15 | TODO: steps to reproduce the behavior.
16 |
17 | ## Expected behavior
18 |
19 | TODO: description of the expected behavior.
20 |
21 | ## Report info
22 |
23 | TODO: if applicable, the full exception stacktrace that you get.
24 |
25 | TODO: if applicable, add screenshots to help explain your problem.
26 |
27 | TODO: describe your environment like OS, app/lib version
28 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | TODO: description of the PR work.
2 |
3 | This PR closes #
4 |
5 | ## Quality check list
6 |
7 | - [ ] Related code has been tested automatically or manually
8 | - [ ] Related documentation is updated
9 | - [ ] I acknowledge I have read and filled this checklist and accept the
10 | [developer certificate of origin](https://developercertificate.org/)
11 |
12 | ## Acceptance criteria
13 |
14 | TODO: list of expectations it has passed from the related issue.
15 |
16 | ## Follow-up work
17 |
18 | TODO: describe any missing or future required work.
19 |
20 | ## Example
21 |
22 | TODO: small code-snippet or screenshot of the work
23 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.rulers": [
3 | 80,
4 | 120
5 | ],
6 | "editor.renderWhitespace": "boundary",
7 | "editor.defaultFormatter": "esbenp.prettier-vscode",
8 | "[markdown]": {
9 | "editor.formatOnSave": true,
10 | },
11 | "[csharp]": {
12 | "editor.defaultFormatter": "ms-dotnettools.csharp",
13 | "editor.formatOnType": true
14 | },
15 | "cSpell.words": [
16 | "Argb",
17 | "Arity",
18 | "dsig",
19 | "Koma",
20 | "Rgba",
21 | "Texim",
22 | "Unswizzle",
23 | "Vram"
24 | ],
25 | "dotnet.defaultSolution": "src/Texim.sln",
26 | }
--------------------------------------------------------------------------------
/src/Texim.Tool/Texim.Tool.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 |
6 | net8.0
7 | false
8 |
9 | false
10 | disable
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Tests.runsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | cobertura
10 | [.*Tests]*
11 | GeneratedCodeAttribute,ExcludeFromCodeCoverageAttribute
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "gitversion.tool": {
6 | "version": "5.12.0",
7 | "commands": [
8 | "dotnet-gitversion"
9 | ]
10 | },
11 | "thirdlicense": {
12 | "version": "1.3.1",
13 | "commands": [
14 | "thirdlicense"
15 | ]
16 | },
17 | "dotnet-reportgenerator-globaltool": {
18 | "version": "5.2.0",
19 | "commands": [
20 | "reportgenerator"
21 | ]
22 | },
23 | "docfx": {
24 | "version": "2.75.2",
25 | "commands": [
26 | "docfx"
27 | ]
28 | },
29 | "gitreleasemanager.tool": {
30 | "version": "0.16.0",
31 | "commands": [
32 | "dotnet-gitreleasemanager"
33 | ]
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/Texim.Games/Texim.Games.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Image formats and converter for videogames.
5 | true
6 |
7 | net6.0;net8.0
8 |
9 |
10 | false
11 | disable
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Texim.Tests/Texim.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Texim unit tests.
6 |
7 | net6.0;net8.0
8 |
9 | false
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | all
20 | runtime; build; native; contentfiles; analyzers; buildtransitive
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "Build",
12 | "program": "${workspaceFolder}/src/Texim.Tool/bin/Debug/net8.0/Texim.Tool.dll",
13 | "args": [],
14 | "cwd": "${workspaceFolder}",
15 | "stopAtEntry": false,
16 | "console": "internalConsole"
17 | },
18 | {
19 | "name": ".NET Attach",
20 | "type": "coreclr",
21 | "request": "attach",
22 | "processId": "${command:pickProcess}"
23 | }
24 | ]
25 | }
--------------------------------------------------------------------------------
/src/Texim.Formats.ImageMagick/Texim.Formats.ImageMagick.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Convert to ImageMagick formats with Texim.
5 | true
6 |
7 | net6.0;net8.0
8 |
9 |
10 | false
11 | disable
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "type": "process",
6 | "command": "dotnet",
7 | "args": [
8 | "run",
9 | "--project",
10 | "build/orchestrator/",
11 | ],
12 | "group": {
13 | "kind": "build",
14 | "isDefault": true
15 | },
16 | "problemMatcher": ["$msCompile"],
17 | "label": "Build"
18 | },
19 | {
20 | "type": "process",
21 | "command": "dotnet",
22 | "args": [
23 | "run",
24 | "--project",
25 | "build/orchestrator/",
26 | "--",
27 | "--target=Bundle"
28 | ],
29 | "group": {
30 | "kind": "build",
31 | },
32 | "problemMatcher": ["$msCompile"],
33 | "label": "Bundle"
34 | },
35 | ]
36 | }
37 |
--------------------------------------------------------------------------------
/docs/template/public/main.css:
--------------------------------------------------------------------------------
1 | /* Changing the site font */
2 | @import url("https://fonts.googleapis.com/css2?family=Nunito:wght@100;400;700&display=swap");
3 | @import url("https://fonts.googleapis.com/css2?family=Fira Code&display=swap");
4 |
5 | :root {
6 | --bs-font-sans-serif: "Nunito";
7 | --bs-font-monospace: "Fira Code";
8 | }
9 |
10 | /* Hide breadcrum bar on large screen as it only links to itself */
11 | @media (min-width: 768px) {
12 | .actionbar {
13 | display: none !important;
14 | }
15 | }
16 |
17 | /* Give more space for section separation in a doc */
18 | h2 {
19 | margin-top: 2rem !important;
20 | }
21 |
22 | /* Improve TOC with a line for categories (entries without link) */
23 | .toc span.name-only {
24 | border-bottom-color: var(--bs-tertiary-color) !important;
25 | border-bottom-width: 2px !important;
26 | border-bottom-style: solid !important;
27 | margin-bottom: 0 !important;
28 | margin-top: 0.6rem !important;
29 | }
30 |
31 | .toc span.name-only:first() {
32 | margin-top: 0.4rem !important;
33 | }
34 |
--------------------------------------------------------------------------------
/src/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Texim/Texim.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Extensible library for image file format and conversings based on Yarhl.
5 | true
6 |
7 | net6.0;net8.0
8 |
9 |
10 | false
11 | disable
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 SceneGate
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/build-and-release.yml:
--------------------------------------------------------------------------------
1 | name: Build and release
2 |
3 | on:
4 | # Dev
5 | workflow_dispatch:
6 | pull_request:
7 | push:
8 | # Preview
9 | branches: [ main ]
10 | # Stable
11 | tags: [ "v*" ]
12 |
13 | jobs:
14 | build:
15 | name: "Build"
16 | uses: ./.github/workflows/build.yml
17 | with:
18 | dotnet_version: '8.0.101'
19 |
20 | # Preview release on push to main only
21 | # Stable release on version tag push only
22 | deploy:
23 | name: "Deploy"
24 | if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
25 | needs: build
26 | uses: ./.github/workflows/deploy.yml
27 | with:
28 | dotnet_version: '8.0.101'
29 | azure_nuget_feed: 'https://pkgs.dev.azure.com/SceneGate/SceneGate/_packaging/SceneGate-Preview/nuget/v3/index.json'
30 | secrets:
31 | nuget_preview_token: "az" # Dummy values as we use Azure DevOps only - Replace with your token for nuget.org
32 | nuget_stable_token: "az" # Dummy values as we use Azure DevOps only - Replace with your token for nuget.org
33 | azure_nuget_token: ${{ secrets.ADO_NUGET_FEED_TOKEN }}
34 |
--------------------------------------------------------------------------------
/src/Texim.Tool/StandardPaletteFormat.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Tool
21 | {
22 | public enum StandardPaletteFormat
23 | {
24 | Riff,
25 | Png,
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/CellBankAttributes.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | using System;
23 |
24 | [Flags]
25 | public enum CellBankAttributes
26 | {
27 | None = 0,
28 | CellsWithBoundary = 1 << 0,
29 | }
30 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/IImageSegmentation.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using Texim.Images;
23 |
24 | public interface IImageSegmentation
25 | {
26 | (Sprite Sprite, FullImage TrimmedImage) Segment(FullImage frame);
27 | }
28 |
--------------------------------------------------------------------------------
/src/Texim/Processing/FixedPaletteTileQuantizationResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Processing;
21 |
22 | public class FixedPaletteTileQuantizationResult : QuantizationResult
23 | {
24 | public byte[] PaletteIndexes { get; init; }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/ObjectAttributeMemoryMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | public enum ObjectAttributeMemoryMode
23 | {
24 | Normal = 0,
25 | SemiTransparent = 1,
26 | ObjWindow = 2,
27 | Bitmap = 3,
28 | }
29 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/TileMappingKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | public enum TileMappingKind
23 | {
24 | Tile2D,
25 | Tile1D_32k,
26 | Tile1D_64k,
27 | Tile1D_128k,
28 | Tile1D_256k,
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Animations/FullImageFrame.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Animations;
21 |
22 | using Texim.Images;
23 |
24 | public class FullImageFrame : IFullImageFrame
25 | {
26 | public IFullImage Image { get; set; }
27 |
28 | public int Duration { get; set; }
29 | }
30 |
--------------------------------------------------------------------------------
/GitReleaseManager.yaml:
--------------------------------------------------------------------------------
1 | # Configuration values used when creating new releases
2 | create:
3 | include-footer: false
4 | include-sha-section: false
5 | allow-update-to-published: false
6 |
7 | # Configuration values used when exporting release notes
8 | export:
9 | include-created-date-in-title: true
10 | created-date-string-format: MMMM dd, yyyy
11 | perform-regex-removal: false
12 |
13 | # Configuration values used when closing a milestone
14 | close:
15 | use-issue-comments: false
16 | # issue-comment: |-
17 | # :tada: This issue has been resolved in version {milestone} :tada:
18 | #
19 | # The release is available on:
20 | #
21 | # - [GitHub release](https://github.com/{owner}/{repository}/releases/tag/{milestone})
22 | #
23 | # Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket:
24 |
25 | # The labels that will be used to include issues in release notes.
26 | issue-labels-include:
27 | - Breaking
28 | - Bug
29 | - Duplicate
30 | - Documentation
31 | - Enhancement
32 | - Feature
33 | - Improvement
34 | - Question
35 |
36 | # The labels that will NOT be used when including issues in release notes.
37 | issue-labels-exclude:
38 | - Internal Refactoring
39 |
40 | # Overrides default pluralization and header names for specific labels.
41 | issue-labels-alias:
42 | - name: Documentation
43 | header: Documentation
44 | plural: Documentation
45 |
--------------------------------------------------------------------------------
/src/Texim/Animations/IFullImageFrame.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Animations;
21 |
22 | using Texim.Images;
23 | using Yarhl.FileFormat;
24 |
25 | public interface IFullImageFrame : IFormat
26 | {
27 | IFullImage Image { get; }
28 |
29 | int Duration { get; }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/SpriteRelativeCoordinatesKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using System;
23 |
24 | [Obsolete("Use always 0,0 for simplicity")]
25 | public enum SpriteRelativeCoordinatesKind
26 | {
27 | TopLeft,
28 | Center,
29 | Reset,
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/ISwizzling.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | using System.Collections.Generic;
23 |
24 | public interface ISwizzling
25 | {
26 | T[] Swizzle(IEnumerable data);
27 |
28 | T[] Unswizzle(IEnumerable data);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim.Tool/StandardImageFormat.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Tool
21 | {
22 | public enum StandardImageFormat
23 | {
24 | Png,
25 | Bmp,
26 | Gif,
27 | Pbm,
28 | Jpeg,
29 | Tiff,
30 | Tga,
31 | Webp,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim/Processing/IQuantization.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Processing
21 | {
22 | using Texim.Colors;
23 | using Texim.Palettes;
24 | using Texim.Pixels;
25 |
26 | public interface IQuantization
27 | {
28 | QuantizationResult Quantize(Rgb[] pixels);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/NitroBackgroundMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | public enum NitroBackgroundMode
23 | {
24 | Text = 0,
25 | Affine = 1, // Palette must be 8bpp
26 | Extended = 2, // Extended mode -> Text | Affine, not bitmap
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Texim/Palettes/IPalette.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Palettes
21 | {
22 | using System.Collections.ObjectModel;
23 | using Texim.Colors;
24 | using Yarhl.FileFormat;
25 |
26 | public interface IPalette : IFormat
27 | {
28 | Collection Colors { get; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Palettes/IPaletteCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Palettes
21 | {
22 | using System.Collections.ObjectModel;
23 | using Yarhl.FileFormat;
24 |
25 | public interface IPaletteCollection : IFormat
26 | {
27 | Collection Palettes { get; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Texim/Animations/IAnimatedFullImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Animations;
21 |
22 | using System.Collections.ObjectModel;
23 | using Yarhl.FileFormat;
24 |
25 | public interface IAnimatedFullImage : IFormat
26 | {
27 | Collection Frames { get; }
28 |
29 | int Loops { get; }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/FullImageMapCompressionParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | using Texim.Palettes;
23 |
24 | public class FullImageMapCompressionParams : MapCompressionParams
25 | {
26 | public IPaletteCollection Palettes { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Texim/Processing/QuantizationResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Processing;
21 |
22 | using Texim.Palettes;
23 | using Texim.Pixels;
24 |
25 | public class QuantizationResult
26 | {
27 | public IndexedPixel[] Pixels { get; init; }
28 |
29 | public IPaletteCollection Palettes { get; init; }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/INitroFormat.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | using System;
23 | using Yarhl.FileFormat;
24 |
25 | public interface INitroFormat : IFormat
26 | {
27 | Version Version { get; set; }
28 |
29 | byte[] UserExtendedInfo { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/NitroPaletteMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | public enum NitroPaletteMode
23 | {
24 | Palette16x16 = 0, // 16 colors / 16 palettes
25 | Palette256x1 = 1, // 256 colors / 1 palette
26 | Extended = 2, // 256 colors / 16 palettes
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/IScreenMap.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | using Yarhl.FileFormat;
23 |
24 | public interface IScreenMap : IFormat
25 | {
26 | MapInfo[] Maps { get; }
27 |
28 | int Width { get; }
29 |
30 | int Height { get; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Texim/Images/IFullImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Images
21 | {
22 | using Texim.Colors;
23 | using Yarhl.FileFormat;
24 |
25 | public interface IFullImage : IFormat
26 | {
27 | int Width { get; }
28 |
29 | int Height { get; }
30 |
31 | Rgb[] Pixels { get; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/ISprite.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using System.Collections.ObjectModel;
23 | using Yarhl.FileFormat;
24 |
25 | public interface ISprite : IFormat
26 | {
27 | Collection Segments { get; }
28 |
29 | int Width { get; }
30 |
31 | int Height { get; }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Texim/Images/IIndexedImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Images
21 | {
22 | using Texim.Pixels;
23 | using Yarhl.FileFormat;
24 |
25 | public interface IIndexedImage : IFormat
26 | {
27 | int Width { get; }
28 |
29 | int Height { get; }
30 |
31 | IndexedPixel[] Pixels { get; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim/Animations/AnimatedFullImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Animations;
21 |
22 | using System.Collections.ObjectModel;
23 |
24 | public class AnimatedFullImage : IAnimatedFullImage
25 | {
26 | public Collection Frames { get; init; } = new Collection();
27 |
28 | public int Loops { get; set; }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Texim/Colors/Rgb32.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Colors
21 | {
22 | public class Rgb32 : Rgba32
23 | {
24 | private static Rgb32 instance = new Rgb32();
25 |
26 | public Rgb32()
27 | : base(hasAlpha: false)
28 | {
29 | }
30 |
31 | public static new Rgb32 Instance => instance;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/Sprite.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using System.Collections.ObjectModel;
23 |
24 | public class Sprite : ISprite
25 | {
26 | public Collection Segments { get; init; } = new Collection();
27 |
28 | public int Width { get; set; }
29 |
30 | public int Height { get; set; }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/MapCompressionParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | using Texim.Images;
23 |
24 | public class MapCompressionParams
25 | {
26 | public System.Drawing.Size TileSize { get; set; } = new System.Drawing.Size(8, 8);
27 |
28 | public IIndexedImage MergeImage { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/Indexed4BppBigEndian.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels;
21 |
22 | using Yarhl.IO;
23 |
24 | public class Indexed4BppBigEndian : Indexed4Bpp
25 | {
26 | public Indexed4BppBigEndian()
27 | {
28 | Endianness = EndiannessMode.BigEndian;
29 | }
30 |
31 | public static new Indexed4Bpp Instance { get; } = new Indexed4BppBigEndian();
32 | }
33 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/NitroTextureFormat.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | public enum NitroTextureFormat
23 | {
24 | None = 0,
25 | IndexedA3I5 = 1,
26 | Indexed2Bpp = 2,
27 | Indexed4Bpp = 3,
28 | Indexed8Bpp = 4,
29 | Texel4x4 = 5,
30 | IndexedA5I3 = 6,
31 | Abgr555 = 7,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim.Games/Raw/RawConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Raw
21 | {
22 | public class RawConfiguration
23 | {
24 | public string Image { get; set; }
25 |
26 | public PaletteConfiguration Palette { get; set; }
27 |
28 | public PixelsConfiguration Pixels { get; set; }
29 |
30 | public MapConfiguration Map { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/.vscode/header-cs.code-snippets:
--------------------------------------------------------------------------------
1 | {
2 | "Header C#": {
3 | "scope": "csharp",
4 | "prefix": "header",
5 | "description": "Insert the C# file header",
6 | "body": [
7 | "// Copyright (c) 2023 SceneGate",
8 | "",
9 | "// Permission is hereby granted, free of charge, to any person obtaining a copy",
10 | "// of this software and associated documentation files (the \"Software\"), to deal",
11 | "// in the Software without restriction, including without limitation the rights",
12 | "// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell",
13 | "// copies of the Software, and to permit persons to whom the Software is",
14 | "// furnished to do so, subject to the following conditions:",
15 | "",
16 | "// The above copyright notice and this permission notice shall be included in all",
17 | "// copies or substantial portions of the Software.",
18 | "",
19 | "// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
20 | "// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
21 | "// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
22 | "// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
23 | "// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
24 | "// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
25 | "// SOFTWARE.",
26 | "namespace ${1:Texim}",
27 | "{",
28 | " $0",
29 | "}",
30 | ""
31 | ]
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/MapDecompressionParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | public class MapDecompressionParams
23 | {
24 | public IScreenMap Map { get; set; }
25 |
26 | public System.Drawing.Size TileSize { get; set; } = new System.Drawing.Size(8, 8);
27 |
28 | public int OutOfBoundsTileIndex { get; set; } = -1; // megaman
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/IIndexedPixelEncoding.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | using System;
23 | using System.Collections.Generic;
24 | using System.IO;
25 |
26 | public interface IIndexedPixelEncoding
27 | {
28 | IndexedPixel[] Decode(Stream stream, int numPixels);
29 |
30 | IndexedPixel[] Decode(Span data);
31 |
32 | byte[] Encode(IEnumerable pixels);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Texim/Formats/TiffImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats;
21 |
22 | using System.Collections.ObjectModel;
23 | using System.Linq;
24 | using Yarhl.FileFormat;
25 |
26 | public class TiffImage : IFormat
27 | {
28 | public int CanvasWidth { get; set; }
29 |
30 | public int CanvasHeight { get; set; }
31 |
32 | public TiffPage MainImage => Pages.FirstOrDefault();
33 |
34 | public Collection Pages { get; init; } = new();
35 | }
36 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/ImageSegment2IndexedImageParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using Texim.Images;
23 |
24 | public class ImageSegment2IndexedImageParams
25 | {
26 | public System.Drawing.Size TileSize { get; set; } = new System.Drawing.Size(8, 8);
27 |
28 | public IIndexedImage FullImage { get; set; }
29 |
30 | public bool IsTiled { get; set; } = true;
31 |
32 | public int OutOfBoundsTileIndex { get; set; } = -1;
33 | }
34 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/Indexed8Bpp.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | public class Indexed8Bpp : BytePixelEncoding
23 | {
24 | public static Indexed8Bpp Instance { get; } = new Indexed8Bpp();
25 |
26 | public override int BitsPerPixel => 8;
27 |
28 | protected override IndexedPixel BitsToPixel(byte data) => new IndexedPixel(data);
29 |
30 | protected override byte PixelToBits(IndexedPixel pixel) => (byte)pixel.Index;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/Indexed4Bpp.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | public class Indexed4Bpp : BytePixelEncoding
23 | {
24 | public static Indexed4Bpp Instance { get; } = new Indexed4Bpp();
25 |
26 | public override int BitsPerPixel => 4;
27 |
28 | protected override IndexedPixel BitsToPixel(byte data) => new IndexedPixel(data);
29 |
30 | protected override byte PixelToBits(IndexedPixel pixel) => (byte)(pixel.Index & 0x0F);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Texim/Images/FullImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Images
21 | {
22 | using Texim.Colors;
23 |
24 | public class FullImage : IFullImage
25 | {
26 | public FullImage(int width, int height)
27 | {
28 | Width = width;
29 | Height = height;
30 | Pixels = new Rgb[width * height];
31 | }
32 |
33 | public int Width { get; init; }
34 |
35 | public int Height { get; init; }
36 |
37 | public Rgb[] Pixels { get; init; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Texim/Formats/Tiff2PlainFullImage.cs:
--------------------------------------------------------------------------------
1 | namespace Texim.Formats;
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Texim.Colors;
9 | using Texim.Images;
10 | using Texim.Pixels;
11 | using Yarhl.FileFormat;
12 |
13 | public class Tiff2PlainFullImage : IConverter
14 | {
15 | public FullImage Convert(TiffImage source)
16 | {
17 | ArgumentNullException.ThrowIfNull(source);
18 |
19 | var image = new FullImage(source.CanvasWidth, source.CanvasHeight);
20 | foreach (TiffPage page in source.Pages.Reverse()) {
21 | DrawLayer(page, image);
22 | }
23 |
24 | return image;
25 | }
26 |
27 | private static void DrawLayer(TiffPage page, FullImage image)
28 | {
29 | for (int x = 0; x < page.Width; x++) {
30 | for (int y = 0; y < page.Height; y++) {
31 | Rgb pixel = GetColor(page, x, y);
32 | if (pixel.Alpha == 0) {
33 | continue; // don't overwrite other layers.
34 | }
35 |
36 | int imageIdx = ((page.Y + y) * image.Width) + page.X + x;
37 | image.Pixels[imageIdx] = pixel;
38 | }
39 | }
40 | }
41 |
42 | private static Rgb GetColor(TiffPage page, int x, int y)
43 | {
44 | int idx = (y * page.Width) + x;
45 | if (page.IsIndexed) {
46 | IndexedPixel pixel = page.IndexedPixels[idx];
47 | return new Rgb(page.ColorMap[pixel.Index], pixel.Alpha);
48 | }
49 |
50 | return page.RgbPixels[idx];
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/IImageSegment.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using Yarhl.FileFormat;
23 |
24 | public interface IImageSegment : IFormat
25 | {
26 | int Layer { get; set; }
27 |
28 | int CoordinateX { get; set; }
29 |
30 | int CoordinateY { get; set; }
31 |
32 | int Width { get; set; }
33 |
34 | int Height { get; set; }
35 |
36 | int TileIndex { get; set; }
37 |
38 | bool HorizontalFlip { get; set; }
39 |
40 | bool VerticalFlip { get; set; }
41 |
42 | byte PaletteIndex { get; set; }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Texim/Formats/IndexedImageBitmapParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats
21 | {
22 | using SixLabors.ImageSharp.Formats;
23 | using SixLabors.ImageSharp.Formats.Png;
24 | using Texim.Palettes;
25 |
26 | public class IndexedImageBitmapParams
27 | {
28 | public IImageEncoder Encoder { get; set; } = new PngEncoder();
29 |
30 | public IPalette Palette { get; set; }
31 |
32 | public IPaletteCollection Palettes { get; set; }
33 |
34 | public bool FirstColorAsTransparent { get; set; } = false;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/Sprite2IndexedImageParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using Texim.Images;
23 |
24 | public class Sprite2IndexedImageParams
25 | {
26 | public SpriteRelativeCoordinatesKind RelativeCoordinates { get; set; } = SpriteRelativeCoordinatesKind.Center;
27 |
28 | public System.Drawing.Size TileSize { get; set; } = new System.Drawing.Size(8, 8);
29 |
30 | public bool IsTiled { get; set; } = true;
31 |
32 | public IIndexedImage FullImage { get; set; }
33 |
34 | public int OutOfBoundsTileIndex { get; set; } = -1;
35 | }
36 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/RawScreenMapParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | public class RawScreenMapParams
23 | {
24 | public static RawScreenMapParams Default => new RawScreenMapParams {
25 | Offset = 0,
26 | Size = -1,
27 | Width = -1,
28 | Height = -1,
29 | };
30 |
31 | public long Offset { get; set; }
32 |
33 | public int Size { get; set; }
34 |
35 | public int Width { get; set; }
36 |
37 | public int Height { get; set; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/ScreenMap.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | public class ScreenMap : IScreenMap
23 | {
24 | public ScreenMap()
25 | {
26 | }
27 |
28 | public ScreenMap(int width, int height)
29 | {
30 | Width = width;
31 | Height = height;
32 | Maps = new MapInfo[width * height];
33 | }
34 |
35 | public MapInfo[] Maps { get; init; }
36 |
37 | public int Width { get; init; }
38 |
39 | public int Height { get; init; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/IndexedA3I5.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | public class IndexedA3I5 : BytePixelEncoding
23 | {
24 | public static IndexedA3I5 Instance { get; } = new IndexedA3I5();
25 |
26 | public override int BitsPerPixel => 8;
27 |
28 | protected override IndexedPixel BitsToPixel(byte data) =>
29 | new IndexedPixel((short)(data & 0x1F), (byte)((data >> 5) << 3));
30 |
31 | protected override byte PixelToBits(IndexedPixel pixel) =>
32 | (byte)(((pixel.Alpha >> 3) << 5) | (pixel.Index & 0x1F));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/IndexedA5I3.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | public class IndexedA5I3 : BytePixelEncoding
23 | {
24 | public static IndexedA5I3 Instance { get; } = new IndexedA5I3();
25 |
26 | public override int BitsPerPixel => 8;
27 |
28 | protected override IndexedPixel BitsToPixel(byte data) =>
29 | new IndexedPixel((short)(data & 0x07), (byte)((data >> 3) << 5));
30 |
31 | protected override byte PixelToBits(IndexedPixel pixel) =>
32 | (byte)((pixel.Index & 0x07) | ((pixel.Alpha >> 5) << 3));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Texim.Games/JumpUltimateStars/KShapeSprites.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.JumpUltimateStars;
21 |
22 | using System.Collections.Generic;
23 | using Texim.Sprites;
24 | using Yarhl.FileFormat;
25 |
26 | public class KShapeSprites : IFormat
27 | {
28 | private readonly Dictionary<(int, int), Sprite> sprites = new();
29 |
30 | public void AddSprite(int group, int element, Sprite sprite)
31 | {
32 | sprites[(group, element)] = sprite;
33 | }
34 |
35 | public Sprite GetSprite(int group, int element)
36 | {
37 | return sprites[(group, element)];
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Texim/Palettes/Palette.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Palettes
21 | {
22 | using System.Collections.Generic;
23 | using System.Collections.ObjectModel;
24 | using System.Linq;
25 | using Texim.Colors;
26 |
27 | public class Palette : IPalette
28 | {
29 | public Palette()
30 | {
31 | Colors = new Collection();
32 | }
33 |
34 | public Palette(IEnumerable initialColors)
35 | {
36 | Colors = new Collection(initialColors.ToList());
37 | }
38 |
39 | public Collection Colors { get; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/CellTileMappingKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | public enum CellTileMappingKind
23 | {
24 | Tile1D_32k,
25 | Tile1D_64k,
26 | Tile1D_128k,
27 | Tile1D_256k,
28 | Tile2D,
29 | Max,
30 | }
31 |
32 | [System.Diagnostics.CodeAnalysis.SuppressMessage(
33 | "StyleCop.CSharp.DocumentationRules",
34 | "SA1649:File name should match first type name",
35 | Justification = "Extension of the same enum")]
36 | public static class CellTileMappingKindExtensions
37 | {
38 | public static int GetTileBlockSize(this CellTileMappingKind kind) => (1 << (5 + (int)kind)) / 64;
39 | }
40 |
--------------------------------------------------------------------------------
/src/Texim/Formats/RawPaletteParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats
21 | {
22 | using Texim.Colors;
23 |
24 | public class RawPaletteParams
25 | {
26 | public static RawPaletteParams Default => new RawPaletteParams {
27 | Offset = 0,
28 | Size = -1,
29 | ColorEncoding = Bgr555.Instance,
30 | ColorsPerPalette = -1,
31 | };
32 |
33 | public long Offset { get; set; }
34 |
35 | public int Size { get; set; }
36 |
37 | public IColorEncoding ColorEncoding { get; set; }
38 |
39 | public int ColorsPerPalette { get; set; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Texim.Games/JumpUltimateStars/KomaElement.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.JumpUltimateStars
21 | {
22 | public class KomaElement
23 | {
24 | public int ImageId { get; set; }
25 |
26 | public int Unknown2 { get; set; }
27 |
28 | public string KomaName { get; set; }
29 |
30 | public byte Unknown6 { get; set; }
31 |
32 | public byte Unknown7 { get; set; }
33 |
34 | public byte KShapeGroupId { get; set; }
35 |
36 | public byte KShapeElementId { get; set; }
37 |
38 | public byte UnknownA { get; set; }
39 |
40 | public byte UnknownB { get; set; }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Texim/CollectionExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim
21 | {
22 | using System;
23 | using System.Collections.Generic;
24 |
25 | internal static class CollectionExtensions
26 | {
27 | public static void Add(this ICollection collection, IEnumerable source)
28 | {
29 | if (collection == null)
30 | throw new ArgumentNullException(nameof(collection));
31 | if (source == null)
32 | throw new ArgumentNullException(nameof(source));
33 |
34 | foreach (var element in source) {
35 | collection.Add(element);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: "Build"
2 |
3 | on:
4 | workflow_call:
5 | inputs:
6 | dotnet_version:
7 | required: true
8 | type: string
9 |
10 | jobs:
11 | build:
12 | strategy:
13 | matrix:
14 | os: [ ubuntu-latest, macos-latest, windows-latest ]
15 | include:
16 | # By default they are no "main build" but if it matches "os" then yes.
17 | - os: ubuntu-latest
18 | is_main_build: true
19 | name: "${{ matrix.os }}"
20 | runs-on: ${{ matrix.os }}
21 | steps:
22 | - name: "Checkout"
23 | uses: actions/checkout@v4
24 | with:
25 | fetch-depth: 0 # We need full history for version number
26 |
27 | - name: "Setup .NET SDK"
28 | uses: actions/setup-dotnet@v4
29 | with:
30 | dotnet-version: ${{ inputs.dotnet_version }}
31 |
32 | - name: "Build and test"
33 | run: dotnet run --project build/orchestrator -- --target=Default --dotnet-configuration=Release
34 | env:
35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 |
37 | - name: "Bundle"
38 | if: ${{ matrix.is_main_build }}
39 | run: dotnet run --project build/orchestrator -- --target=Bundle --dotnet-configuration=Release
40 | env:
41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 |
43 | - name: "Publish artifacts to CI"
44 | if: ${{ matrix.is_main_build }}
45 | uses: actions/upload-artifact@v4
46 | with:
47 | name: "Artifacts"
48 | retention-days: 7
49 | path: |
50 | build/artifacts/
51 | !build/artifacts/docs
52 |
53 | - name: Publish docs artifact to CI
54 | if: ${{ matrix.is_main_build }}
55 | uses: actions/upload-pages-artifact@v3
56 | with:
57 | path: build/artifacts/docs
58 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/FullImage2NitroCellParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | using Texim.Sprites;
23 |
24 | public record FullImage2NitroCellParams : FullImage2SpriteParams
25 | {
26 | public FullImage2NitroCellParams()
27 | {
28 | Segmentation = new NitroImageSegmentation();
29 | }
30 |
31 | ///
32 | /// Gets the cell to use to copy the metadata into the new.
33 | ///
34 | public Cell ReferenceCell { get; init; }
35 |
36 | ///
37 | /// Gets a value indicating whether the cell image has the format 8 bits per pixel
38 | /// or 4 bits per pixel.
39 | ///
40 | public bool Has8bppDepth { get; init; }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Texim.Games/MetalMax/MmTex.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.MetalMax
21 | {
22 | using System.Collections.ObjectModel;
23 | using Texim.Colors;
24 | using Texim.Images;
25 | using Texim.Palettes;
26 | using Texim.Pixels;
27 |
28 | public class MmTex : IPalette, IIndexedImage
29 | {
30 | public Collection Colors { get; set; } = new Collection();
31 |
32 | public IndexedPixel[] Pixels { get; set; }
33 |
34 | public int Width { get; set; }
35 |
36 | public int Height { get; set; }
37 |
38 | public int NumImages { get; set; }
39 |
40 | public uint UnknownSize { get; set; }
41 |
42 | public uint Unknown { get; set; }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Texim/Images/IndexedPaletteImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Images
21 | {
22 | using System.Collections.ObjectModel;
23 | using Texim.Palettes;
24 | using Texim.Pixels;
25 |
26 | public class IndexedPaletteImage : IIndexedImage, IPaletteCollection
27 | {
28 | public int Width { get; init; }
29 |
30 | public int Height { get; init; }
31 |
32 | public IndexedPixel[] Pixels { get; init; }
33 |
34 | public Collection Palettes { get; init; } = new Collection();
35 |
36 | public FullImage CreateFullImage()
37 | {
38 | var fullImageConverter = new Indexed2FullImage(this);
39 | return fullImageConverter.Convert(this);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Texim.Games/Raw/MapConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Raw
21 | {
22 | using Texim.Compressions.Nitro;
23 |
24 | public class MapConfiguration
25 | {
26 | public string Path { get; set; }
27 |
28 | public long Offset { get; set; }
29 |
30 | public int Size { get; set; }
31 |
32 | public int Width { get; set; }
33 |
34 | public int Height { get; set; }
35 |
36 | public int ErrorTile { get; set; } = -1;
37 |
38 | public RawScreenMapParams GetParams()
39 | {
40 | return new RawScreenMapParams {
41 | Offset = Offset,
42 | Size = Size,
43 | Width = Width,
44 | Height = Height,
45 | };
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Texim.Games/DevilSurvivor/DsTex2Palette.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.DevilSurvivor
21 | {
22 | using System;
23 | using Texim.Colors;
24 | using Texim.Palettes;
25 | using Yarhl.FileFormat;
26 | using Yarhl.IO;
27 |
28 | public class DsTex2Palette : IConverter
29 | {
30 | private const int NumColors = 256;
31 |
32 | public Palette Convert(IBinary source)
33 | {
34 | if (source == null)
35 | throw new ArgumentNullException(nameof(source));
36 |
37 | source.Stream.Position = 0;
38 | DataReader reader = new DataReader(source.Stream);
39 |
40 | var colors = reader.ReadColors(NumColors);
41 | return new Palette(colors);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/Ncer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | using System;
23 | using System.Collections.ObjectModel;
24 | using Yarhl.FileSystem;
25 |
26 | ///
27 | /// Nitro CEll Resource. Format that contains sprite definitions.
28 | ///
29 | public class Ncer : NodeContainerFormat, INitroFormat
30 | {
31 | public Ncer()
32 | {
33 | Version = new Version(1, 0);
34 | }
35 |
36 | public Version Version { get; set; }
37 |
38 | public CellBankAttributes Attributes { get; set; }
39 |
40 | public CellTileMappingKind TileMapping { get; set; }
41 |
42 | public bool HasCellExtendedInfo { get; set; }
43 |
44 | public byte[] UserExtendedInfo { get; set; }
45 |
46 | public Collection Labels { get; init; } = new Collection();
47 | }
48 |
--------------------------------------------------------------------------------
/src/Texim.Games/JumpUltimateStars/Koma.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.JumpUltimateStars
21 | {
22 | using System.Collections.ObjectModel;
23 | using Yarhl.FileFormat;
24 |
25 | public class Koma : Collection, IFormat
26 | {
27 | // From ARM9 pointers at 0x0209E840
28 | public static string[] NameTable { get; } = new[] {
29 | null, "es", "is", "ig",
30 | "tr", "ct", "gt", "kn",
31 | "kk", "cb", "oj", "nb",
32 | "sk", "tc", "jj", "sd",
33 | "ss", "tz", "to", "dg",
34 | "dn", "ds", "tl", "db",
35 | "na", "nk", "hh", "pj",
36 | "bu", "bc", "bl", "hs",
37 | "hk", "bb", "nn", "mo",
38 | "mr", "yo", "yh", "rk",
39 | "rb", "op", "dt",
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Texim/Palettes/PaletteCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Palettes
21 | {
22 | using System.Collections.Generic;
23 | using System.Collections.ObjectModel;
24 | using System.Linq;
25 |
26 | public class PaletteCollection : IPaletteCollection
27 | {
28 | public PaletteCollection()
29 | {
30 | Palettes = new Collection();
31 | }
32 |
33 | public PaletteCollection(IPalette initialPalette)
34 | {
35 | Palettes = new Collection { initialPalette };
36 | }
37 |
38 | public PaletteCollection(IEnumerable initialPalettes)
39 | {
40 | Palettes = new Collection(initialPalettes.ToList());
41 | }
42 |
43 | public Collection Palettes { get; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Texim/Formats/RawIndexedImageParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats
21 | {
22 | using Texim.Pixels;
23 |
24 | public class RawIndexedImageParams
25 | {
26 | public static RawIndexedImageParams Default => new RawIndexedImageParams {
27 | Offset = 0,
28 | Size = -1,
29 | Width = -1,
30 | Height = -1,
31 | PixelEncoding = Indexed8Bpp.Instance,
32 | Swizzling = null,
33 | };
34 |
35 | public long Offset { get; set; }
36 |
37 | public int Size { get; set; }
38 |
39 | public int Width { get; set; }
40 |
41 | public int Height { get; set; }
42 |
43 | public IIndexedPixelEncoding PixelEncoding { get; set; }
44 |
45 | public ISwizzling Swizzling { get; set; }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Texim/Formats/TiffPage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats;
21 |
22 | using Texim.Colors;
23 | using Texim.Pixels;
24 |
25 | public class TiffPage
26 | {
27 | public int Id { get; set; }
28 |
29 | public string Name { get; set; }
30 |
31 | public int X { get; set; }
32 |
33 | public int Y { get; set; }
34 |
35 | public int Width { get; set; }
36 |
37 | public int Height { get; set; }
38 |
39 | public Rgb[] RgbPixels { get; set; }
40 |
41 | public Rgb[] ColorMap { get; set; }
42 |
43 | public IndexedPixel[] IndexedPixels { get; set; }
44 |
45 | // Considered an interface but it will cause boxing which the design of the API tries to avoid.
46 | // https://stackoverflow.com/questions/53889573/array-of-structs-inheriting-interface-appear-to-be-reference-types
47 | public bool IsIndexed { get; set; }
48 | }
49 |
--------------------------------------------------------------------------------
/docs/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "metadata": [
3 | {
4 | "src": [
5 | {
6 | "files": [
7 | "Texim/*.csproj",
8 | "Texim.Formats.ImageMagick/*.csproj",
9 | "Texim.Games/*.csproj"
10 | ],
11 | "src": "../src"
12 | }
13 | ],
14 | "dest": "api",
15 | "includePrivateMembers": false,
16 | "disableGitFeatures": false,
17 | "disableDefaultFilter": false,
18 | "noRestore": false,
19 | "namespaceLayout": "flattened",
20 | "memberLayout": "samePage",
21 | "EnumSortOrder": "alphabetic",
22 | "allowCompilationErrors": false
23 | }
24 | ],
25 | "build": {
26 | "content": [
27 | {
28 | "files": [
29 | "api/**.yml",
30 | "api/index.md"
31 | ]
32 | },
33 | { "files": "**/*.{md,yml}", "src": "articles", "dest": "docs" },
34 | { "files": [ "toc.yml", "*.md" ] }
35 | ],
36 | "resource": [
37 | {
38 | "files": [ "**/images/**", "**/resources/**" ],
39 | "exclude": [ "_site/**", "obj/**" ]
40 | }
41 | ],
42 | "output": "_site",
43 | "globalMetadata": {
44 | "_appTitle": "Texim extensible image API",
45 | "_appName": "Texim",
46 | "_appFooter": "Part of the SceneGate framework. Docs made with docfx",
47 | "_appLogoPath": "images/logo-50.png",
48 | "_appFaviconPath": "images/favicon.ico",
49 | "_enableSearch": true,
50 | "_enableNewTab": true,
51 | "_lang": "en"
52 | },
53 | "fileMetadataFiles": [],
54 | "template": [
55 | "default",
56 | "modern",
57 | "template"
58 | ],
59 | "postProcessors": [],
60 | "keepFileLink": false,
61 | "disableGitFeatures": false,
62 | "sitemap": {
63 | "baseUrl": "https://scenegate.github.io/Texim/",
64 | "priority": 0.5,
65 | "changefreq": "monthly"
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/CellAttributes.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | using System;
23 |
24 | public class CellAttributes
25 | {
26 | public bool UseFlipFlags => throw new NotSupportedException("Unknown flag");
27 |
28 | public int RenderingOptimizationFlags => throw new NotSupportedException("Unknown flags");
29 |
30 | public int UnknownFlags { get; set; }
31 |
32 | public bool IsSquare { get; set; }
33 |
34 | public int SquareDimension { get; set; }
35 |
36 | public static CellAttributes FromBinary(ushort data) =>
37 | new CellAttributes {
38 | IsSquare = ((data >> 11) & 1) == 0,
39 | SquareDimension = (data & 0x3F) * 8,
40 | UnknownFlags = data >> 6,
41 | };
42 |
43 | public ushort ToBinary() =>
44 | (ushort)(((SquareDimension / 8) & 0x3F) |
45 | ((UnknownFlags & 0x1F) << 6) |
46 | (IsSquare ? 0 : 1) << 11);
47 | }
48 |
--------------------------------------------------------------------------------
/src/Texim.PerformanceTest/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.PerformanceTest
21 | {
22 | using System;
23 | using System.Runtime.InteropServices;
24 | using Texim.PerformanceTest.ImageStructures;
25 |
26 | public static class Program
27 | {
28 | public static void Main(string[] args)
29 | {
30 | DisplaySizeOf();
31 | DisplaySizeOf();
32 | DisplaySizeOf();
33 | DisplaySizeOf();
34 | DisplaySizeOf();
35 | Console.WriteLine($"Marshal size of Color: {Marshal.SizeOf()}");
36 | BenchmarkDotNet.Running.BenchmarkRunner.Run();
37 | }
38 |
39 | private static unsafe void DisplaySizeOf()
40 | where T : unmanaged
41 | {
42 | Console.WriteLine($"Size of {typeof(T)} is {sizeof(T)}");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Texim/Formats/Bitmap2FullImage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats
21 | {
22 | using System;
23 | using SixLabors.ImageSharp;
24 | using Texim.Colors;
25 | using Texim.Images;
26 | using Yarhl.FileFormat;
27 | using Yarhl.IO;
28 |
29 | public class Bitmap2FullImage : IConverter
30 | {
31 | public FullImage Convert(IBinary source)
32 | {
33 | ArgumentNullException.ThrowIfNull(source);
34 |
35 | using var image = Image.Load(source.Stream);
36 | var fullImage = new FullImage(image.Width, image.Height);
37 |
38 | for (int x = 0; x < image.Width; x++) {
39 | for (int y = 0; y < image.Height; y++) {
40 | fullImage.Pixels[(y * image.Width) + x] = new Rgb(image[x, y]);
41 | }
42 | }
43 |
44 | return fullImage;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/IndexedPixel.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | using System.Diagnostics;
23 |
24 | [DebuggerDisplay("I:{Index},A:{Alpha},P:{PaletteIndex}")]
25 | public readonly struct IndexedPixel
26 | {
27 | public IndexedPixel(short index)
28 | {
29 | Index = index;
30 | Alpha = 255;
31 | PaletteIndex = 0;
32 | }
33 |
34 | public IndexedPixel(short index, byte alpha)
35 | {
36 | Index = index;
37 | Alpha = alpha;
38 | PaletteIndex = 0;
39 | }
40 |
41 | public IndexedPixel(short index, byte alpha, byte paletteIndex)
42 | {
43 | Index = index;
44 | Alpha = alpha;
45 | PaletteIndex = paletteIndex;
46 | }
47 |
48 | public short Index { get; init; }
49 |
50 | public byte Alpha { get; init; }
51 |
52 | public byte PaletteIndex { get; init; }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Texim.Games/Raw/PaletteConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Raw
21 | {
22 | using System;
23 | using Texim.Colors;
24 | using Texim.Formats;
25 |
26 | public class PaletteConfiguration
27 | {
28 | public string Path { get; set; }
29 |
30 | public long Offset { get; set; }
31 |
32 | public int Size { get; set; }
33 |
34 | public string Encoding { get; set; }
35 |
36 | public int PaletteColors { get; set; }
37 |
38 | public RawPaletteParams GetParams()
39 | {
40 | IColorEncoding encoding = Encoding.ToUpperInvariant() switch {
41 | "BGR555" => Bgr555.Instance,
42 | _ => throw new NotSupportedException("Unknown color encoding"),
43 | };
44 |
45 | return new RawPaletteParams {
46 | Offset = Offset,
47 | Size = Size,
48 | ColorEncoding = encoding,
49 | ColorsPerPalette = PaletteColors,
50 | };
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Texim.Tool/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Tool
21 | {
22 | using System.CommandLine;
23 | using System.Threading.Tasks;
24 |
25 | public static class Program
26 | {
27 | public static async Task Main(string[] args)
28 | {
29 | var root = new RootCommand("Proof-of-concept library and tool for image formats") {
30 | NitroCommandLine.CreateCommand(),
31 | BlackRockShooterCommandLine.CreateCommand(),
32 | DevilSurvivorCommandLine.CreateCommand(),
33 | DisgaeaCommandLine.CreateCommand(),
34 | MetalMaxCommandLine.CreateCommand(),
35 | LondonLifeCommandLine.CreateCommand(),
36 | MegamanCommandLine.CreateCommand(),
37 | JumpUltimateStarsCommandLine.CreateCommand(),
38 | RawCommandLine.CreateCommand(),
39 | DarkoCommandLine.CreateCommand(),
40 | };
41 |
42 | return await root.InvokeAsync(args).ConfigureAwait(false);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/ImageSegment.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | public class ImageSegment : IImageSegment
23 | {
24 | public ImageSegment()
25 | {
26 | }
27 |
28 | public ImageSegment(IImageSegment other)
29 | {
30 | Layer = other.Layer;
31 | CoordinateX = other.CoordinateX;
32 | CoordinateY = other.CoordinateY;
33 | Width = other.Width;
34 | Height = other.Height;
35 | TileIndex = other.TileIndex;
36 | HorizontalFlip = other.HorizontalFlip;
37 | VerticalFlip = other.VerticalFlip;
38 | PaletteIndex = other.PaletteIndex;
39 | }
40 |
41 | public int Layer { get; set; }
42 |
43 | public int CoordinateX { get; set; }
44 |
45 | public int CoordinateY { get; set; }
46 |
47 | public int Width { get; set; }
48 |
49 | public int Height { get; set; }
50 |
51 | public int TileIndex { get; set; }
52 |
53 | public bool HorizontalFlip { get; set; }
54 |
55 | public bool VerticalFlip { get; set; }
56 |
57 | public byte PaletteIndex { get; set; }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/Nscr2Binary.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | using System.Linq;
23 | using Texim.Compressions.Nitro;
24 | using Yarhl.IO;
25 |
26 | public class Nscr2Binary : NitroSerializer
27 | {
28 | public Nscr2Binary()
29 | {
30 | RegisterSection("SCRN", WriteScrn);
31 | }
32 |
33 | protected override string Stamp => "NSCR";
34 |
35 | private void WriteScrn(DataWriter writer, Nscr model)
36 | {
37 | writer.Write((ushort)model.Width);
38 | writer.Write((ushort)model.Height);
39 | writer.Write((ushort)model.PaletteMode);
40 | writer.Write((ushort)model.BackgroundMode);
41 |
42 | if (model.BackgroundMode == NitroBackgroundMode.Affine) {
43 | writer.Write(model.Maps.Length);
44 | writer.Write(model.Maps.Select(m => (byte)m.TileIndex).ToArray());
45 | } else {
46 | writer.Write(model.Maps.Length * 2);
47 | writer.Write(model.Maps);
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/IOExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | using System.Collections.Generic;
23 | using Yarhl.IO;
24 |
25 | public static class IOExtensions
26 | {
27 | public static MapInfo ReadMapInfo(this DataReader reader)
28 | {
29 | return new MapInfo(reader.ReadInt16());
30 | }
31 |
32 | public static MapInfo[] ReadMapInfos(this DataReader reader, int numMaps)
33 | {
34 | var infos = new MapInfo[numMaps];
35 | for (int i = 0; i < numMaps; i++) {
36 | infos[i] = new MapInfo(reader.ReadInt16());
37 | }
38 |
39 | return infos;
40 | }
41 |
42 | public static void Write(this DataWriter writer, MapInfo info)
43 | {
44 | writer.Write(info.ToInt16());
45 | }
46 |
47 | public static void Write(this DataWriter writer, IEnumerable infos)
48 | {
49 | foreach (var info in infos) {
50 | writer.Write(info.ToInt16());
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Texim.Formats.ImageMagick/ImageMagickFormatConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats;
21 |
22 | using System;
23 | using ImageMagick;
24 | using Yarhl.FileFormat;
25 | using Yarhl.IO;
26 |
27 | public class ImageMagickFormatConverter : IConverter
28 | {
29 | private readonly bool isLayered;
30 | private readonly MagickFormat outputFormat;
31 |
32 | public ImageMagickFormatConverter(bool isLayered, MagickFormat outputFormat)
33 | {
34 | this.isLayered = isLayered;
35 | this.outputFormat = outputFormat;
36 | }
37 |
38 | public BinaryFormat Convert(IBinary source)
39 | {
40 | ArgumentNullException.ThrowIfNull(source);
41 |
42 | BinaryFormat outputBinary = new();
43 |
44 | if (isLayered) {
45 | using var image = new MagickImageCollection(source.Stream);
46 | image.Write(outputBinary.Stream, outputFormat);
47 | } else {
48 | using var image = new MagickImage(source.Stream);
49 | image.Write(outputBinary.Stream, outputFormat);
50 | }
51 |
52 | return outputBinary;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Texim/Images/FullImage2IndexedPalette.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Images
21 | {
22 | using System;
23 | using Texim.Processing;
24 | using Yarhl.FileFormat;
25 |
26 | public class FullImage2IndexedPalette : IConverter
27 | {
28 | private readonly IQuantization quantization;
29 |
30 | public FullImage2IndexedPalette(IQuantization parameters)
31 | {
32 | quantization = parameters ?? throw new ArgumentNullException(nameof(parameters));
33 | }
34 |
35 | public IndexedPaletteImage Convert(IFullImage source)
36 | {
37 | if (source == null)
38 | throw new ArgumentNullException(nameof(source));
39 |
40 | var result = quantization.Quantize(source.Pixels);
41 |
42 | var indexed = new IndexedPaletteImage {
43 | Width = source.Width,
44 | Height = source.Height,
45 | Pixels = result.Pixels,
46 | };
47 | indexed.Palettes.Add(result.Palettes.Palettes);
48 |
49 | return indexed;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Texim.Games/Disgaea/Ykcmp2Image.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Benito Palacios Sanchez
2 | //
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 | //
10 | // The above copyright notice and this permission notice shall be included in
11 | // all copies or substantial portions of the Software.
12 | //
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | // THE SOFTWARE.
20 | namespace Texim.Games.Disgaea
21 | {
22 | using System;
23 | using Texim.Colors;
24 | using Texim.Images;
25 | using Texim.Palettes;
26 | using Texim.Pixels;
27 | using Yarhl.FileFormat;
28 | using Yarhl.IO;
29 |
30 | public class Ykcmp2Image : IConverter
31 | {
32 | private const int NumColors = 256;
33 | private const int Width = 256;
34 | private const int Height = 128;
35 |
36 | public FullImage Convert(IBinary source)
37 | {
38 | if (source == null)
39 | throw new ArgumentNullException(nameof(source));
40 |
41 | source.Stream.Position = 0;
42 | var reader = new DataReader(source.Stream);
43 |
44 | Rgb[] colors = reader.ReadColors(NumColors);
45 | var palette = new Palette(colors);
46 |
47 | IndexedPixel[] pixels = reader.ReadPixels(Width * Height);
48 | var indexed = new IndexedImage(Width, Height, pixels);
49 |
50 | return indexed.CreateFullImage(palette);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Texim.Tool/DisgaeaCommandLine.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Tool
21 | {
22 | using System.CommandLine;
23 | using System.CommandLine.Invocation;
24 | using Texim.Formats;
25 | using Texim.Games.Disgaea;
26 | using Yarhl.FileSystem;
27 | using Yarhl.IO;
28 |
29 | public static class DisgaeaCommandLine
30 | {
31 | public static Command CreateCommand()
32 | {
33 | var export = new Command("export", "Export image") {
34 | new Option("--input", "the input file", ArgumentArity.ExactlyOne),
35 | new Option("--output", "the output file", ArgumentArity.ExactlyOne),
36 | };
37 | export.Handler = CommandHandler.Create(Export);
38 |
39 | return new Command("disgaea", "Disgaea game") {
40 | export,
41 | };
42 | }
43 |
44 | private static void Export(string input, string output)
45 | {
46 | NodeFactory.FromFile(input, FileOpenMode.Read)
47 | .TransformWith()
48 | .TransformWith()
49 | .Stream.WriteTo(output);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Texim/Images/ImageExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Images;
21 |
22 | public static class ImageExtensions
23 | {
24 | public static FullImage SubImage(this IFullImage image, int startX, int startY, int width, int height)
25 | {
26 | var subImage = new FullImage(width, height);
27 | CopySubImage(image.Pixels, subImage.Pixels, image.Width, startX, startY, width, height);
28 | return subImage;
29 | }
30 |
31 | public static IndexedImage SubImage(this IIndexedImage image, int startX, int startY, int width, int height)
32 | {
33 | var subImage = new IndexedImage(width, height);
34 | CopySubImage(image.Pixels, subImage.Pixels, image.Width, startX, startY, width, height);
35 | return subImage;
36 | }
37 |
38 | private static void CopySubImage(T[] source, T[] destination, int sourceWidth, int startX, int startY, int width, int height)
39 | {
40 | int idx = 0;
41 | for (int y = 0; y < height; y++) {
42 | for (int x = 0; x < width; x++) {
43 | int fullIndex = ((startY + y) * sourceWidth) + startX + x;
44 | destination[idx++] = source[fullIndex];
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Texim.Tool/BlackRockShooterCommandLine.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Tool
21 | {
22 | using System.CommandLine;
23 | using System.CommandLine.Invocation;
24 | using Texim.Formats;
25 | using Texim.Games.BlackRockShooter;
26 | using Yarhl.FileSystem;
27 | using Yarhl.IO;
28 |
29 | public static class BlackRockShooterCommandLine
30 | {
31 | public static Command CreateCommand()
32 | {
33 | var export = new Command("export", "Export PTMD into an image") {
34 | new Option("--input", "the input PTMD file", ArgumentArity.ExactlyOne),
35 | new Option("--output", "the output image file", ArgumentArity.ExactlyOne),
36 | };
37 | export.Handler = CommandHandler.Create(Export);
38 |
39 | return new Command("blackrockshooter", "Black Rock Shooter game") {
40 | export,
41 | };
42 | }
43 |
44 | private static void Export(string input, string output)
45 | {
46 | NodeFactory.FromFile(input, FileOpenMode.Read)
47 | .TransformWith()
48 | .TransformWith()
49 | .Stream!.WriteTo(output);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/Binary2Nscr.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | using System.Linq;
23 | using Texim.Compressions.Nitro;
24 | using Yarhl.IO;
25 |
26 | public class Binary2Nscr : NitroDeserializer
27 | {
28 | protected override string Stamp => "NSCR";
29 |
30 | protected override void ReadSection(DataReader reader, Nscr model, string id, int size)
31 | {
32 | if (id == "SCRN") {
33 | ReadScrn(reader, model);
34 | }
35 | }
36 |
37 | private void ReadScrn(DataReader reader, Nscr model)
38 | {
39 | model.Width = reader.ReadUInt16();
40 | model.Height = reader.ReadUInt16();
41 | model.PaletteMode = (NitroPaletteMode)reader.ReadUInt16();
42 | model.BackgroundMode = (NitroBackgroundMode)reader.ReadUInt16();
43 |
44 | int length = reader.ReadInt32();
45 | if (model.BackgroundMode == NitroBackgroundMode.Affine) {
46 | model.Maps = reader.ReadBytes(length)
47 | .Select(b => new MapInfo(b))
48 | .ToArray();
49 | } else {
50 | model.Maps = reader.ReadMapInfos(length / 2);
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/MapInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | public readonly struct MapInfo
23 | {
24 | public MapInfo(byte value)
25 | {
26 | TileIndex = value;
27 | HorizontalFlip = false;
28 | VerticalFlip = false;
29 | PaletteIndex = 0;
30 | }
31 |
32 | public MapInfo(ushort value)
33 | {
34 | TileIndex = (short)(value & 0x3FF);
35 | HorizontalFlip = ((value >> 10) & 0x01) == 1;
36 | VerticalFlip = ((value >> 11) & 0x01) == 1;
37 | PaletteIndex = (byte)(value >> 12);
38 | }
39 |
40 | public MapInfo(short value)
41 | : this((ushort)value)
42 | {
43 | }
44 |
45 | public short TileIndex { get; init; }
46 |
47 | public bool HorizontalFlip { get; init; }
48 |
49 | public bool VerticalFlip { get; init; }
50 |
51 | public byte PaletteIndex { get; init; }
52 |
53 | public readonly short ToInt16()
54 | {
55 | return (short)((TileIndex & 0x3FF)
56 | | ((HorizontalFlip ? 1 : 0) << 10)
57 | | ((VerticalFlip ? 1 : 0) << 11)
58 | | ((PaletteIndex & 0x0F) << 12));
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Texim.Games/DevilSurvivor/DsTex2Image.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.DevilSurvivor
21 | {
22 | using System;
23 | using Texim.Images;
24 | using Texim.Pixels;
25 | using Yarhl.FileFormat;
26 | using Yarhl.IO;
27 |
28 | public class DsTex2Image :
29 | IConverter,
30 | IConverter
31 | {
32 | public IndexedImage Convert(IBinary source)
33 | {
34 | if (source == null)
35 | throw new ArgumentNullException(nameof(source));
36 |
37 | source.Stream.Position = 0;
38 | var reader = new DataReader(source.Stream);
39 |
40 | IndexedPixel[] pixels = reader.ReadBytes((int)source.Stream.Length)
41 | .DecodePixelsAs();
42 |
43 | return new IndexedImage(128, 128, pixels);
44 | }
45 |
46 | public BinaryFormat Convert(IIndexedImage source)
47 | {
48 | if (source == null)
49 | throw new ArgumentNullException(nameof(source));
50 |
51 | var binary = new BinaryFormat();
52 | var writer = new DataWriter(binary.Stream);
53 |
54 | writer.Write(source.Pixels);
55 | return binary;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: "Deploy"
2 |
3 | on:
4 | workflow_call:
5 | inputs:
6 | dotnet_version:
7 | required: true
8 | type: string
9 | azure_nuget_feed:
10 | required: false
11 | type: string
12 | secrets:
13 | nuget_preview_token:
14 | required: false
15 | nuget_stable_token:
16 | required: false
17 | azure_nuget_token:
18 | required: false
19 |
20 | jobs:
21 | upload_doc:
22 | name: "Documentation"
23 | runs-on: "ubuntu-latest"
24 | # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
25 | permissions:
26 | pages: write # to deploy to Pages
27 | id-token: write # to verify the deployment originates from an appropriate source
28 | # Deploy to the github-pages environment
29 | environment:
30 | name: github-pages
31 | url: ${{ steps.deployment.outputs.page_url }}
32 | steps:
33 | - name: Deploy to GitHub Pages
34 | id: deployment
35 | uses: actions/deploy-pages@v4
36 |
37 | push_artifacts:
38 | name: "Artifacts"
39 | runs-on: "ubuntu-latest"
40 | steps:
41 | - name: "Checkout"
42 | uses: actions/checkout@v4
43 | with:
44 | fetch-depth: 0 # We need full history for version number
45 |
46 | - name: "Download artifacts"
47 | uses: actions/download-artifact@v4
48 | with:
49 | name: "Artifacts"
50 | path: "./build/artifacts/"
51 |
52 | - name: "Setup .NET SDK"
53 | uses: actions/setup-dotnet@v4
54 | with:
55 | dotnet-version: ${{ inputs.dotnet_version }}
56 |
57 | # Weird way to authenticate in Azure DevOps Artifacts
58 | # Then, we need to setup VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
59 | - name: "Install Azure Artifacts Credential Provider"
60 | run: wget -qO- https://aka.ms/install-artifacts-credprovider.sh | bash
61 |
62 | - name: "Deploy artifacts"
63 | run: dotnet run --project build/orchestrator -- --target=Deploy
64 | env:
65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 | STABLE_NUGET_FEED_TOKEN: ${{ secrets.nuget_stable_token }}
67 | PREVIEW_NUGET_FEED_TOKEN: ${{ secrets.nuget_preview_token }}
68 | VSS_NUGET_EXTERNAL_FEED_ENDPOINTS: '{"endpointCredentials": [{"endpoint":"${{ inputs.azure_nuget_feed }}", "username":"", "password":"${{ secrets.azure_nuget_token }}"}]}'
69 |
--------------------------------------------------------------------------------
/src/Texim/Processing/FixedPaletteQuantization.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Processing
21 | {
22 | using Texim.Colors;
23 | using Texim.Palettes;
24 | using Texim.Pixels;
25 |
26 | public class FixedPaletteQuantization : IQuantization
27 | {
28 | private readonly IPalette palette;
29 | private readonly ExhaustiveColorSearch search;
30 |
31 | public FixedPaletteQuantization(IPalette palette)
32 | {
33 | this.palette = palette;
34 | search = new ExhaustiveColorSearch(palette.Colors);
35 | }
36 |
37 | public int TransparentIndex { get; set; }
38 |
39 | public QuantizationResult Quantize(Rgb[] pixels)
40 | {
41 | var indexed = new IndexedPixel[pixels.Length];
42 |
43 | for (int i = 0; i < pixels.Length; i++) {
44 | int colorIdx = (pixels[i].Alpha <= 128)
45 | ? TransparentIndex
46 | : search.Search(pixels[i]).Index;
47 | indexed[i] = new IndexedPixel((short)colorIdx, pixels[i].Alpha, 0);
48 | }
49 |
50 | var collection = new PaletteCollection(palette);
51 | return new QuantizationResult {
52 | Pixels = indexed,
53 | Palettes = collection,
54 | };
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Texim.PerformanceTest/ImageStructures/Pixel.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.PerformanceTest.ImageStructures
21 | {
22 | using System;
23 |
24 | public readonly struct Pixel
25 | {
26 | private readonly int value;
27 | private readonly bool isIndexed;
28 |
29 | public Pixel(int index, byte alpha)
30 | {
31 | isIndexed = true;
32 | value = index | (alpha << 24);
33 | }
34 |
35 | public Pixel(byte red, byte green, byte blue, byte alpha)
36 | {
37 | isIndexed = false;
38 | value = red | (green << 8) | (blue << 16) | (alpha << 24);
39 | }
40 |
41 | public int Index { get => value & 0x00FFFFFF; }
42 |
43 | public bool IsIndexed { get => isIndexed; }
44 |
45 | public byte Red { get => (byte)value; }
46 |
47 | public byte Green { get => (byte)(value >> 8); }
48 |
49 | public byte Blue { get => (byte)(value >> 16); }
50 |
51 | public byte Alpha { get => (byte)(value >> 24); }
52 |
53 | public readonly System.Drawing.Color ToColor()
54 | {
55 | if (!IsIndexed) {
56 | throw new FormatException("Pixel is indexed");
57 | }
58 |
59 | return System.Drawing.Color.FromArgb(Alpha, Red, Green, Blue);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Texim.Tool/StandardImageFormatExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Tool
21 | {
22 | using System;
23 | using SixLabors.ImageSharp.Formats;
24 | using SixLabors.ImageSharp.Formats.Bmp;
25 | using SixLabors.ImageSharp.Formats.Gif;
26 | using SixLabors.ImageSharp.Formats.Jpeg;
27 | using SixLabors.ImageSharp.Formats.Pbm;
28 | using SixLabors.ImageSharp.Formats.Png;
29 | using SixLabors.ImageSharp.Formats.Tga;
30 | using SixLabors.ImageSharp.Formats.Tiff;
31 | using SixLabors.ImageSharp.Formats.Webp;
32 |
33 | public static class StandardImageFormatExtensions
34 | {
35 | public static IImageEncoder GetEncoder(this StandardImageFormat format) =>
36 | format switch {
37 | StandardImageFormat.Bmp => new BmpEncoder(),
38 | StandardImageFormat.Gif => new GifEncoder(),
39 | StandardImageFormat.Jpeg => new JpegEncoder(),
40 | StandardImageFormat.Pbm => new PbmEncoder(),
41 | StandardImageFormat.Png => new PngEncoder(),
42 | StandardImageFormat.Tiff => new TiffEncoder(),
43 | StandardImageFormat.Tga => new TgaEncoder(),
44 | StandardImageFormat.Webp => new WebpEncoder(),
45 | _ => throw new FormatException("Invalid format"),
46 | };
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Texim.PerformanceTest/ImageStructures/PixelRgb.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.PerformanceTest.ImageStructures
21 | {
22 | using System;
23 |
24 | public readonly struct PixelRgb
25 | {
26 | public PixelRgb(byte index, byte alpha)
27 | {
28 | IsIndexed = true;
29 | Index = index;
30 | Alpha = alpha;
31 | Red = 0;
32 | Green = 0;
33 | Blue = 0;
34 | }
35 |
36 | public PixelRgb(byte red, byte green, byte blue, byte alpha)
37 | {
38 | IsIndexed = false;
39 | Index = 0;
40 | Alpha = alpha;
41 | Red = red;
42 | Green = green;
43 | Blue = blue;
44 | }
45 |
46 | public bool IsIndexed { get; init; }
47 |
48 | public byte Index { get; init; }
49 |
50 | public byte Red { get; init; }
51 |
52 | public byte Green { get; init; }
53 |
54 | public byte Blue { get; init; }
55 |
56 | public byte Alpha { get; init; }
57 |
58 | public readonly System.Drawing.Color ToColor()
59 | {
60 | if (!IsIndexed) {
61 | throw new FormatException("Pixel is indexed");
62 | }
63 |
64 | return System.Drawing.Color.FromArgb(Alpha, Red, Green, Blue);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Texim/Formats/PaletteCollection2ContainerBitmap.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats
21 | {
22 | using System;
23 | using SixLabors.ImageSharp.Formats;
24 | using SixLabors.ImageSharp.Formats.Png;
25 | using Texim.Palettes;
26 | using Yarhl.FileFormat;
27 | using Yarhl.FileSystem;
28 |
29 | public class PaletteCollection2ContainerBitmap : IConverter
30 | {
31 | private readonly IImageEncoder encoder;
32 |
33 | public PaletteCollection2ContainerBitmap()
34 | {
35 | encoder = new PngEncoder();
36 | }
37 |
38 | public PaletteCollection2ContainerBitmap(IImageEncoder parameters)
39 | {
40 | ArgumentNullException.ThrowIfNull(parameters);
41 | encoder = parameters;
42 | }
43 |
44 | public NodeContainerFormat Convert(IPaletteCollection source)
45 | {
46 | ArgumentNullException.ThrowIfNull(source);
47 |
48 | var container = new NodeContainerFormat();
49 | for (int i = 0; i < source.Palettes.Count; i++) {
50 | var child = new Node($"Palette {i}", source.Palettes[i])
51 | .TransformWith(new Palette2Bitmap(encoder));
52 | container.Root.Add(child);
53 | }
54 |
55 | return container;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Texim.Games/Raw/PixelsConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Raw
21 | {
22 | using System;
23 | using Texim.Formats;
24 | using Texim.Pixels;
25 |
26 | public class PixelsConfiguration
27 | {
28 | public string Path { get; set; }
29 |
30 | public long Offset { get; set; }
31 |
32 | public int Size { get; set; }
33 |
34 | public string Encoding { get; set; }
35 |
36 | public string Swizzling { get; set; }
37 |
38 | public bool MissingBgTile { get; set; }
39 |
40 | public RawIndexedImageParams GetParams()
41 | {
42 | IIndexedPixelEncoding encoding = Encoding.ToUpperInvariant() switch {
43 | "8BPP" => Indexed8Bpp.Instance,
44 | "4BPP" => Indexed4Bpp.Instance,
45 | _ => throw new NotSupportedException("Unknown pixel encoding"),
46 | };
47 |
48 | ISwizzling swizzling = null;
49 | if (Swizzling.StartsWith("TILE", StringComparison.InvariantCultureIgnoreCase)) {
50 | swizzling = new TileSwizzling(8);
51 | }
52 |
53 | return new RawIndexedImageParams {
54 | Offset = Offset,
55 | Size = Size,
56 | PixelEncoding = encoding,
57 | Swizzling = swizzling,
58 | };
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/FullImage2ReferenceNitroCellParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | using Texim.Images;
23 | using Texim.Sprites;
24 |
25 | public record FullImage2ReferenceNitroCellParams : FullImage2SpriteParams
26 | {
27 | ///
28 | /// Gets the file path (without extension) to write the original
29 | /// and new images of layers that don't re-use the original image pixels
30 | /// to debug the algorithm.
31 | ///
32 | public string DebugNewLayersPath { get; init; }
33 |
34 | ///
35 | /// Gets a value indicating whether to prioritize new pixels in the
36 | /// top layers (e.g. text over clean button) or put then in
37 | /// the bottom layers (e.g. top layer is yellow border with transparent body).
38 | ///
39 | public bool ImportTopToBottom { get; init; } = true;
40 |
41 | ///
42 | /// Gets the cell to use to copy the metadata into the new.
43 | ///
44 | public Cell ReferenceCell { get; init; }
45 |
46 | ///
47 | /// Gets a value indicating whether the cell image has the format 8 bits per pixel
48 | /// or 4 bits per pixel.
49 | ///
50 | public bool Has8bppDepth { get; init; }
51 |
52 | ///
53 | /// Gets the image to update in the sprite.
54 | ///
55 | public IIndexedImage Image { get; init; }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/Nclr2Binary.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro
21 | {
22 | using System;
23 | using System.Linq;
24 | using Texim.Colors;
25 | using Yarhl.IO;
26 |
27 | public class Nclr2Binary : NitroSerializer
28 | {
29 | public Nclr2Binary()
30 | {
31 | RegisterSection("PLTT", WritePltt);
32 | RegisterSection("PCMP", WritePcmp);
33 | }
34 |
35 | protected override string Stamp => "NCLR";
36 |
37 | private void WritePltt(DataWriter writer, Nclr model)
38 | {
39 | writer.Write((uint)model.TextureFormat);
40 | writer.Write(model.IsExtendedPalette ? 1 : 0);
41 | writer.Write(model.Palettes.Sum(p => p.Colors.Count) * 2);
42 | writer.Write(0x10); // relative offset to data
43 |
44 | var colors = model.Palettes.SelectMany(p => p.Colors);
45 | writer.Write(colors);
46 | }
47 |
48 | private void WritePcmp(DataWriter writer, Nclr model)
49 | {
50 | // TODO: How to compress??
51 | writer.Write((ushort)model.Palettes.Count);
52 | writer.Write((ushort)0xBEEF); // padding
53 | writer.Write(0x08); // relative offset
54 |
55 | for (int i = 0; i < model.Palettes.Count; i++) {
56 | writer.Write((ushort)i);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Texim/Colors/IOExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Colors
21 | {
22 | using System.Collections.Generic;
23 | using Yarhl.IO;
24 |
25 | public static class IOExtensions
26 | {
27 | public static Rgb ReadColor(this DataReader reader)
28 | where T : IColorEncoding, new()
29 | {
30 | T encoding = new T();
31 | return encoding.Decode(reader.Stream);
32 | }
33 |
34 | public static Rgb[] ReadColors(this DataReader reader, int numColors)
35 | where T : IColorEncoding, new()
36 | {
37 | T encoding = new T();
38 | return encoding.Decode(reader.Stream, numColors);
39 | }
40 |
41 | public static Rgb[] DecodeColorsAs(this byte[] data)
42 | where T : IColorEncoding, new()
43 | {
44 | T decoder = new T();
45 | return decoder.Decode(data);
46 | }
47 |
48 | public static void Write(this DataWriter writer, Rgb color)
49 | where T : IColorEncoding, new()
50 | {
51 | T encoding = new T();
52 | writer.Write(encoding.Encode(color));
53 | }
54 |
55 | public static void Write(this DataWriter writer, IEnumerable colors)
56 | where T : IColorEncoding, new()
57 | {
58 | T encoding = new T();
59 | writer.Write(encoding.Encode(colors));
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | SceneGate
4 | SceneGate
5 | None
6 | Copyright (C) 2021 SceneGate
7 |
8 | true
9 |
10 |
12 | false
13 |
14 |
15 |
16 | MIT
17 | https://github.com/SceneGate/Texim
18 | https://github.com/SceneGate/Texim
19 | icon.png
20 | scenegate;yarhl;images
21 | README.md
22 |
23 |
24 |
25 |
26 |
27 | true
28 |
29 |
30 | true
31 |
32 |
38 | embedded
39 |
40 |
41 | true
42 | true
43 |
44 |
45 |
46 |
47 | true
48 | true
49 | latest
50 | true
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/src/Texim/Formats/FullImage2Bitmap.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Formats
21 | {
22 | using System;
23 | using SixLabors.ImageSharp;
24 | using SixLabors.ImageSharp.Formats;
25 | using SixLabors.ImageSharp.Formats.Png;
26 | using SixLabors.ImageSharp.PixelFormats;
27 | using Texim.Images;
28 | using Yarhl.FileFormat;
29 | using Yarhl.IO;
30 |
31 | public class FullImage2Bitmap : IConverter
32 | {
33 | private readonly IImageEncoder encoder;
34 |
35 | public FullImage2Bitmap()
36 | {
37 | encoder = new PngEncoder();
38 | }
39 |
40 | public FullImage2Bitmap(IImageEncoder parameters)
41 | {
42 | ArgumentNullException.ThrowIfNull(parameters);
43 |
44 | encoder = parameters;
45 | }
46 |
47 | public BinaryFormat Convert(IFullImage source)
48 | {
49 | ArgumentNullException.ThrowIfNull(source);
50 |
51 | using var image = new Image(source.Width, source.Height);
52 | for (int x = 0; x < source.Width; x++) {
53 | for (int y = 0; y < source.Height; y++) {
54 | image[x, y] = source.Pixels[(y * source.Width) + x].ToImageSharpColor();
55 | }
56 | }
57 |
58 | var binary = new BinaryFormat();
59 | image.Save(binary.Stream, encoder);
60 | return binary;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Texim/Pixels/IOExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Pixels
21 | {
22 | using System.Collections.Generic;
23 | using Yarhl.IO;
24 |
25 | public static class IOExtensions
26 | {
27 | public static IndexedPixel[] ReadPixels(this DataReader reader, int numPixels)
28 | where T : IIndexedPixelEncoding, new()
29 | {
30 | T decoder = new T();
31 | return decoder.Decode(reader.Stream, numPixels);
32 | }
33 |
34 | public static IndexedPixel[] DecodePixelsAs(this byte[] data)
35 | where T : IIndexedPixelEncoding, new()
36 | {
37 | T decoder = new T();
38 | return decoder.Decode(data);
39 | }
40 |
41 | public static void Write(this DataWriter writer, IEnumerable pixels)
42 | where T : IIndexedPixelEncoding, new()
43 | {
44 | T encoder = new T();
45 | writer.Write(encoder.Encode(pixels));
46 | }
47 |
48 | public static byte[] EncodePixelsAs(this IndexedPixel[] pixels)
49 | where T : IIndexedPixelEncoding, new()
50 | {
51 | T encoder = new T();
52 | return encoder.Encode(pixels);
53 | }
54 |
55 | public static IndexedPixel[] UnswizzleWith(this IndexedPixel[] pixels, ISwizzling swizzling)
56 | {
57 | return swizzling.Unswizzle(pixels);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Texim/Compressions/Nitro/FullImageMapCompression.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Compressions.Nitro
21 | {
22 | using System;
23 | using Texim.Images;
24 | using Texim.Processing;
25 | using Yarhl.FileFormat;
26 | using Yarhl.FileSystem;
27 |
28 | public class FullImageMapCompression : IConverter
29 | {
30 | private readonly FullImageMapCompressionParams parameters;
31 |
32 | public FullImageMapCompression(FullImageMapCompressionParams parameters)
33 | {
34 | ArgumentNullException.ThrowIfNull(parameters);
35 |
36 | this.parameters = parameters;
37 | }
38 |
39 | public NodeContainerFormat Convert(IFullImage source)
40 | {
41 | ArgumentNullException.ThrowIfNull(source);
42 |
43 | // TODO: Avoid several swizzling by providing an argument to quantization
44 | // and compression (in and out, out here too).
45 | var quantization = new FixedPaletteTileQuantization(
46 | parameters.Palettes,
47 | parameters.TileSize,
48 | source.Width);
49 | var result = quantization.Quantize(source.Pixels);
50 |
51 | var fullIndexedImage = new IndexedImage(source.Width, source.Height, result.Pixels);
52 |
53 | var compression = new MapCompression(parameters);
54 | return compression.Convert(fullIndexedImage);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Texim/Sprites/SpriteImageUpdaterParams.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Sprites;
21 |
22 | using System.Collections.Generic;
23 | using Texim.Images;
24 | using Texim.Pixels;
25 |
26 | public record SpriteImageUpdaterParams
27 | {
28 | ///
29 | /// Gets the image to update in the sprite.
30 | ///
31 | public IIndexedImage Image { get; init; }
32 |
33 | ///
34 | /// Gets the sequence of tiles the converter will use to search and add
35 | /// new pixels if not found.
36 | ///
37 | public List PixelSequences { get; init; }
38 |
39 | ///
40 | /// Gets the minimum amount of pixels a sprite segment should have.
41 | /// Usually this is the same as , except in
42 | /// NCER formats where it multiplies by a block size parameter.
43 | ///
44 | public int MinimumPixelsPerSegment { get; init; }
45 |
46 | ///
47 | /// Gets the amount of pixels each segment tile index increments.
48 | /// Usually this is the tile size (64).
49 | ///
50 | public int PixelsPerIndex { get; init; }
51 |
52 | ///
53 | /// Gets a value indicating whether this sprite supports horizontal and
54 | /// vertical flipping.
55 | ///
56 | ///
57 | /// Some games may not support this feature of the segments.
58 | ///
59 | public bool SupportsFlipping { get; init; }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Texim/Processing/Quantization.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Processing
21 | {
22 | using Texim.Colors;
23 | using Texim.Palettes;
24 | using Texim.Pixels;
25 |
26 | public class Quantization : IQuantization
27 | {
28 | public bool FirstAsTransparent { get; set; }
29 |
30 | public Rgb AlphaColor { get; set; }
31 |
32 | public QuantizationResult Quantize(Rgb[] pixels)
33 | {
34 | var indexed = new IndexedPixel[pixels.Length];
35 | var palette = new Palette();
36 |
37 | if (FirstAsTransparent) {
38 | palette.Colors.Add(AlphaColor);
39 | }
40 |
41 | for (int i = 0; i < pixels.Length; i++) {
42 | if (FirstAsTransparent && pixels[i].Alpha <= 128) {
43 | indexed[i] = new IndexedPixel(0, pixels[i].Alpha, 0);
44 | continue;
45 | }
46 |
47 | int colorIdx = palette.Colors.IndexOf(pixels[i]);
48 | if (colorIdx == -1) {
49 | colorIdx = palette.Colors.Count;
50 | palette.Colors.Add(pixels[i]);
51 | }
52 |
53 | indexed[i] = new IndexedPixel((short)colorIdx, pixels[i].Alpha, 0);
54 | }
55 |
56 | var collection = new PaletteCollection(palette);
57 | return new QuantizationResult {
58 | Pixels = indexed,
59 | Palettes = collection,
60 | };
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Texim.Games/JumpUltimateStars/Binary2Koma.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.JumpUltimateStars
21 | {
22 | using System;
23 | using Yarhl.FileFormat;
24 | using Yarhl.IO;
25 |
26 | public class Binary2Koma : IConverter
27 | {
28 | private const int EntrySize = 12;
29 |
30 | public Koma Convert(IBinary source)
31 | {
32 | ArgumentNullException.ThrowIfNull(source);
33 |
34 | var koma = new Koma();
35 | var reader = new DataReader(source.Stream);
36 | source.Stream.Position = 0;
37 |
38 | int numEntries = (int)(source.Stream.Length / EntrySize);
39 | for (int i = 0; i < numEntries; i++) {
40 | var element = new KomaElement {
41 | ImageId = reader.ReadUInt16(),
42 | Unknown2 = reader.ReadUInt16(),
43 | };
44 |
45 | byte nameIdx = reader.ReadByte();
46 | byte nameNum = reader.ReadByte();
47 | element.KomaName = $"{Koma.NameTable[nameIdx]}_{nameNum:D2}";
48 |
49 | element.Unknown6 = reader.ReadByte();
50 | element.Unknown7 = reader.ReadByte();
51 | element.KShapeGroupId = reader.ReadByte();
52 | element.KShapeElementId = reader.ReadByte();
53 | element.UnknownA = reader.ReadByte();
54 | element.UnknownB = reader.ReadByte();
55 |
56 | koma.Add(element);
57 | }
58 |
59 | return koma;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Texim.Games/Nitro/Cell.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.Nitro;
21 |
22 | using System.Collections.Generic;
23 | using System.Collections.ObjectModel;
24 | using Texim.Sprites;
25 |
26 | ///
27 | /// Nitro sprite definition.
28 | ///
29 | public class Cell : ISprite
30 | {
31 | public Cell()
32 | {
33 | }
34 |
35 | public Cell(Cell other, IEnumerable segments)
36 | {
37 | Segments = new Collection();
38 | foreach (IImageSegment segment in segments) {
39 | Segments.Add(segment is ObjectAttributeMemory ? segment : new ObjectAttributeMemory(segment));
40 | }
41 |
42 | Width = other.Width;
43 | Height = other.Height;
44 | Attributes = other.Attributes;
45 | BoundaryXStart = other.BoundaryXStart;
46 | BoundaryXEnd = other.BoundaryXEnd;
47 | BoundaryYStart = other.BoundaryYStart;
48 | BoundaryXEnd = other.BoundaryXEnd;
49 | UserExtendedCellAttribute = other.UserExtendedCellAttribute;
50 | }
51 |
52 | public Collection Segments { get; init; } = new Collection();
53 |
54 | public int Width { get; set; }
55 |
56 | public int Height { get; set; }
57 |
58 | public CellAttributes Attributes { get; set; }
59 |
60 | public int BoundaryXStart { get; set; }
61 |
62 | public int BoundaryXEnd { get; set; }
63 |
64 | public int BoundaryYStart { get; set; }
65 |
66 | public int BoundaryYEnd { get; set; }
67 |
68 | public uint UserExtendedCellAttribute { get; set; }
69 | }
70 |
--------------------------------------------------------------------------------
/src/Texim.Games/LondonLife/Acl2PaletteCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 SceneGate
2 |
3 | // Permission is hereby granted, free of charge, to any person obtaining a copy
4 | // of this software and associated documentation files (the "Software"), to deal
5 | // in the Software without restriction, including without limitation the rights
6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | // copies of the Software, and to permit persons to whom the Software is
8 | // furnished to do so, subject to the following conditions:
9 |
10 | // The above copyright notice and this permission notice shall be included in all
11 | // copies or substantial portions of the Software.
12 |
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | // SOFTWARE.
20 | namespace Texim.Games.LondonLife
21 | {
22 | using System;
23 | using Texim.Colors;
24 | using Texim.Palettes;
25 | using Yarhl.FileFormat;
26 | using Yarhl.IO;
27 |
28 | public class Acl2PaletteCollection : IConverter
29 | {
30 | private const string Stamp = "ACL ";
31 |
32 | public IPaletteCollection Convert(IBinary source)
33 | {
34 | if (source == null)
35 | throw new ArgumentNullException(nameof(source));
36 |
37 | source.Stream.Position = 0;
38 | var reader = new DataReader(source.Stream);
39 |
40 | string stamp = reader.ReadString(4);
41 | if (stamp != Stamp) {
42 | throw new FormatException($"Invalid stamp: {stamp}");
43 | }
44 |
45 | var collection = new PaletteCollection();
46 | int numPalettes = reader.ReadInt32();
47 | for (int i = 0; i < numPalettes; i++) {
48 | long pointerPos = source.Stream.Position;
49 | long pointer = reader.ReadUInt16() + pointerPos;
50 |
51 | source.Stream.PushToPosition(pointer);
52 | int numColors = reader.ReadInt32();
53 | var colors = reader.ReadColors(numColors);
54 | source.Stream.PopPosition();
55 |
56 | var palette = new Palette(colors);
57 | collection.Palettes.Add(palette);
58 | }
59 |
60 | return collection;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------