#include "custom_files.hpp"
#include <PSX/File/file_processor_helper.hpp>
#include <stdio.hpp>

namespace JabyEngine {
    namespace FileProcessor {
        struct JingleState {
            uint32_t sfx_id;
        };

        static Progress parse_jingle(State::CDDataProcessor& data_proc, JingleState& jingle) {
            SPU::voice[jingle.sfx_id].play();
            return Progress::Done;
        }

        State create_custom(const uint32_t* data_adr, const CDFileType_t& file_type, const CDFile::Payload& payload) {
            switch(static_cast<FileType>(file_type)) {
                case FileType::Jingle:
                    return State::from(JingleState{.sfx_id = payload.raw}, data_adr, parse_jingle);

                default:
                    return FileProcessor::create(data_adr, Nothing());
            }   
        }
    }
}