#include "default_font_data.hpp"
#include <FontWriter/fonts.hpp>
#include <PSX/File/Processor/file_processor.hpp>
#include <PSX/Auxiliary/lz4_decompressor.hpp>
#include <stdio.hpp>

namespace JabyEngine {
    static size_t decompress_font(uint32_t* work_area) {
        LZ4Decompressor lz4_decomp(reinterpret_cast<uint8_t*>(work_area));

        const auto [progress, bytes_ready] = lz4_decomp.process(ArrayRange(default_font_data, sizeof(default_font_data)), true);
        if(progress == Progress::Error) {
            return 0;
        }
        return bytes_ready;
    }

    void DefaultFont :: load(uint32_t* work_area, SimpleTIM vram_dst) {
        const auto bytes_ready = decompress_font(work_area);

        auto processor = FileProcessor::create(work_area, vram_dst);
        processor.process(bytes_ready);
    }
}