pico: implement get_type_handler_metadata
diff --git a/32blit-pico/blit_launch.cpp b/32blit-pico/blit_launch.cpp index d922b14..0cafd70 100644 --- a/32blit-pico/blit_launch.cpp +++ b/32blit-pico/blit_launch.cpp
@@ -468,6 +468,23 @@ #endif } +void *get_type_handler_metadata(const char *filetype) { +#ifdef BUILD_LOADER + for(auto &handler : handlers) { + if(strncmp(filetype, handler.type, 4) == 0) { + auto ptr = (const uint8_t *)(FLASH_BASE + handler.offset); + auto header = (const BlitGameHeader *)ptr; + auto metadata_ptr = ptr + header->end; + + // this really shouldn't fail if it's in the list, but be safe + if(memcmp(metadata_ptr, "BLITMETA", 8) == 0) + return (void *)metadata_ptr; + } + } +#endif + return nullptr; +} + // .blit file writer void BlitWriter::init(uint32_t file_len) { this->file_len = file_len;
diff --git a/32blit-pico/blit_launch.hpp b/32blit-pico/blit_launch.hpp index abb7dce..e79bdde 100644 --- a/32blit-pico/blit_launch.hpp +++ b/32blit-pico/blit_launch.hpp
@@ -21,6 +21,8 @@ void erase_game(uint32_t offset); +void *get_type_handler_metadata(const char *filetype); + class BlitWriter final { public: void init(uint32_t file_len);
diff --git a/32blit-pico/main.cpp b/32blit-pico/main.cpp index 4dba8e2..dc1eae9 100644 --- a/32blit-pico/main.cpp +++ b/32blit-pico/main.cpp
@@ -167,7 +167,7 @@ ::launch_file, ::erase_game, - nullptr, // get_type_handler_metadata + ::get_type_handler_metadata, ::get_launch_path,