Skip to content

Conversation

@grunt-lucas
Copy link
Owner

@grunt-lucas grunt-lucas commented Aug 30, 2025

Summary

This PR implements fundamental save and load functionality for Porytiles2 tilesets, focusing on JASC palette format support and core I/O infrastructure.

Key Features Added

JASC Palette Support:

  • Complete JASC-PAL (Paintshop Pro) file format implementation
  • JascPalLoader with full validation and error handling
  • JascPalSaver with proper CRLF line endings
  • Robust parsing with detailed error messages for malformed files

Core I/O Infrastructure:

  • File-agnostic FilePalLoader/FilePalSaver interfaces for extensibility
  • Enhanced PorymapTilesetComponent with array-based palette storage (16 palettes)
  • Complete tileset save/load pipeline in TilesetRepo
  • Binary file I/O for metatiles.bin and metatile_attributes.bin
  • PNG tiles loading and saving integration

Error Handling & Robustness:

  • Comprehensive error propagation throughout the I/O stack
  • Detailed error messages with file paths and context
  • Graceful handling of missing optional artifacts
  • Input validation with bounds checking

Code Quality Improvements:

  • New string_utils.hpp template header with parsing utilities
  • Fixed include path inconsistencies across the codebase
  • Corrected error messages in legacy Porytiles1 code
  • Added NoopArtifactChecksumProvider for testing

Technical Details

Architecture Changes:

  • PorymapTilesetComponent now uses std::array<RgbaPal, 16> instead of std::vector
  • Added indexed palette access methods (set_pal(), pal_at()) with bounds checking
  • Extended ProjectTilesetArtifactReader/Writer with palette I/O capabilities

File Format Support:

  • JASC-PAL format with "JASC-PAL", "0100", size declaration parsing
  • Space-separated RGB values (0-255 range) with validation
  • Binary metatile data packed as 16-bit values with tile index, flip flags, and palette index
  • Placeholder metatile attributes (TODO: implement full attribute handling)

Integration Points:

  • Debug command now demonstrates full save/load cycle
  • Configurable greyscale palette for tiles.png export
  • Error handling integration with fmt library formatting

Files Changed

  • 35 files modified with 734 additions and 133 deletions
  • New infrastructure files: JASC loaders/savers, string utilities, checksum provider
  • Enhanced domain model with robust palette management
  • Improved error handling across repository layer

Testing & Validation

The debug command provides end-to-end testing of the save/load pipeline, enabling validation of:

  • JASC palette file round-trip integrity
  • Binary artifact generation and parsing
  • Error handling for malformed input files
  • Integration between all I/O components

This foundational work enables future development of the complete tileset compilation pipeline while maintaining clean architecture and comprehensive error handling.

@grunt-lucas grunt-lucas added porytiles2 Work related to the Porytiles 2 effort mvp Bulk work on the Porytiles2 MVP labels Aug 30, 2025
@grunt-lucas grunt-lucas changed the title Basic save and load implemented. Implement JASC palette save/load and core tileset I/O infrastructure Aug 30, 2025
@grunt-lucas grunt-lucas merged commit c12b2b1 into develop Aug 30, 2025
5 checks passed
@grunt-lucas grunt-lucas deleted the 2/mvp branch August 30, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mvp Bulk work on the Porytiles2 MVP porytiles2 Work related to the Porytiles 2 effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants