Support custom file parsing
This commit is contained in:
13
examples/PoolBox/application/src/Custom/custom_files.hpp
Normal file
13
examples/PoolBox/application/src/Custom/custom_files.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
enum struct FileType : JabyEngine::CDFileType_t {
|
||||
Jingle,
|
||||
};
|
||||
|
||||
struct CustomCDFileBuilder {
|
||||
static constexpr JabyEngine::CDFile jingle(uint32_t sfx_id) {
|
||||
// TODO: This currently re-loads Paco; We should make this treat it's own file!
|
||||
return JabyEngine::CDFile::custom(0, FileType::Jingle, sfx_id);
|
||||
}
|
||||
};
|
26
examples/PoolBox/application/src/Custom/file_parser.cpp
Normal file
26
examples/PoolBox/application/src/Custom/file_parser.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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::Configuration& config, JingleState& jingle) {
|
||||
printf("Playing jingle: %i\n", jingle.sfx_id);
|
||||
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}, reinterpret_cast<const uint8_t*>(data_adr), parse_jingle);
|
||||
|
||||
default:
|
||||
return FileProcessor::create(data_adr, Nothing());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "Custom/custom_files.hpp"
|
||||
#include "Overlay/Overlays.hpp"
|
||||
#include <PSX/Audio/CDXA.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba.hpp>
|
||||
@@ -58,8 +59,9 @@ namespace Assets {
|
||||
|
||||
namespace Main {
|
||||
static const CDFile Files[] = {
|
||||
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
|
||||
CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim)
|
||||
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
|
||||
CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim),
|
||||
CustomCDFileBuilder::jingle(32),
|
||||
};
|
||||
|
||||
void load() {
|
||||
|
Reference in New Issue
Block a user