diff --git a/32blit-config.cmake b/32blit-config.cmake index c5e124ad5..f2aff3d69 100644 --- a/32blit-config.cmake +++ b/32blit-config.cmake @@ -3,7 +3,7 @@ if (NOT DEFINED BLIT_ONCE) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) - set(BLIT_MINIMUM_TOOLS_VERSION "0.7.2") + set(BLIT_MINIMUM_TOOLS_VERSION "0.7.3") find_package(PythonInterp 3.6 REQUIRED) diff --git a/32blit-pico/CMakeLists.txt b/32blit-pico/CMakeLists.txt index 60b127d40..6d0f65af5 100644 --- a/32blit-pico/CMakeLists.txt +++ b/32blit-pico/CMakeLists.txt @@ -118,8 +118,16 @@ function(blit_metadata TARGET FILE) execute_process(COMMAND ${PYTHON_EXECUTABLE} -m ttblit cmake --config ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake) include(${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake) - pico_set_program_name(${TARGET} "${METADATA_TITLE}") - pico_set_program_description(${TARGET} "${METADATA_DESCRIPTION}") - pico_set_program_version(${TARGET} "${METADATA_VERSION}") - pico_set_program_url(${TARGET} "${METADATA_URL}") + # create metadata/binary info source at build time + set(METADATA_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_binary_info.cpp") + + add_custom_command( + OUTPUT ${METADATA_SOURCE} + COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} -m ttblit metadata --force --config ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} --pico-bi ${METADATA_SOURCE} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} + ) + + # add the generated source + target_sources(${TARGET} PRIVATE ${METADATA_SOURCE}) + endfunction() diff --git a/32blit-pico/binary_info.hpp b/32blit-pico/binary_info.hpp new file mode 100644 index 000000000..05c149b6e --- /dev/null +++ b/32blit-pico/binary_info.hpp @@ -0,0 +1,6 @@ +#pragma once + +#define BINARY_INFO_TAG_32BLIT BINARY_INFO_MAKE_TAG('3', 'B') + +#define BINARY_INFO_ID_32BLIT_AUTHOR 0x79707D17 +#define BINARY_INFO_ID_32BLIT_CATEGORY 0xF02802B0 diff --git a/32blit-pico/main.cpp b/32blit-pico/main.cpp index 052c24e10..000359c2f 100644 --- a/32blit-pico/main.cpp +++ b/32blit-pico/main.cpp @@ -8,6 +8,7 @@ #include "pico/stdlib.h" #include "audio.hpp" +#include "binary_info.hpp" #include "config.h" #include "display.hpp" #include "file.hpp" @@ -74,24 +75,35 @@ static GameMetadata get_metadata() { extern binary_info_t *__binary_info_start, *__binary_info_end; for(auto tag_ptr = &__binary_info_start; tag_ptr != &__binary_info_end ; tag_ptr++) { - if((*tag_ptr)->type != BINARY_INFO_TYPE_ID_AND_STRING || (*tag_ptr)->tag != BINARY_INFO_TAG_RASPBERRY_PI) + if((*tag_ptr)->type != BINARY_INFO_TYPE_ID_AND_STRING) continue; auto id_str_tag = (binary_info_id_and_string_t *)*tag_ptr; - switch(id_str_tag->id) { - case BINARY_INFO_ID_RP_PROGRAM_NAME: - ret.title = id_str_tag->value; - break; - case BINARY_INFO_ID_RP_PROGRAM_VERSION_STRING: - ret.version = id_str_tag->value; - break; - case BINARY_INFO_ID_RP_PROGRAM_URL: - ret.url = id_str_tag->value; - break; - case BINARY_INFO_ID_RP_PROGRAM_DESCRIPTION: - ret.description = id_str_tag->value; - break; + if((*tag_ptr)->tag == BINARY_INFO_TAG_RASPBERRY_PI) { + switch(id_str_tag->id) { + case BINARY_INFO_ID_RP_PROGRAM_NAME: + ret.title = id_str_tag->value; + break; + case BINARY_INFO_ID_RP_PROGRAM_VERSION_STRING: + ret.version = id_str_tag->value; + break; + case BINARY_INFO_ID_RP_PROGRAM_URL: + ret.url = id_str_tag->value; + break; + case BINARY_INFO_ID_RP_PROGRAM_DESCRIPTION: + ret.description = id_str_tag->value; + break; + } + } else if((*tag_ptr)->tag == BINARY_INFO_TAG_32BLIT) { + switch(id_str_tag->id) { + case BINARY_INFO_ID_32BLIT_AUTHOR: + ret.author = id_str_tag->value; + break; + case BINARY_INFO_ID_32BLIT_CATEGORY: + ret.category = id_str_tag->value; + break; + } } } diff --git a/32blit-pico/storage.cpp b/32blit-pico/storage.cpp index 059dc7ffc..265efdc02 100644 --- a/32blit-pico/storage.cpp +++ b/32blit-pico/storage.cpp @@ -8,6 +8,8 @@ #include "pico/binary_info.h" #include "pico/multicore.h" +#include "binary_info.hpp" + static const uint32_t storage_size = PICO_FLASH_SIZE_BYTES / 4; static const uint32_t storage_offset = PICO_FLASH_SIZE_BYTES - storage_size; @@ -18,7 +20,7 @@ void get_storage_size(uint16_t &block_size, uint32_t &num_blocks) { num_blocks = storage_size / FLASH_SECTOR_SIZE; bi_decl(bi_block_device( - BINARY_INFO_MAKE_TAG('3', 'B'), + BINARY_INFO_TAG_32BLIT, "32Blit", XIP_BASE + storage_offset, storage_size,