From 38924ae977492d3438ce887f14470cb160db374f Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Sat, 19 Feb 2022 19:46:20 +0000 Subject: [PATCH 1/5] pico: Add some custom binary info ids --- 32blit-pico/binary_info.hpp | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 32blit-pico/binary_info.hpp 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 From f3c74bf2b965542044bc14a9742a9daa7340858c Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Sat, 19 Feb 2022 19:46:53 +0000 Subject: [PATCH 2/5] pico: Use the tag define in storage.cpp --- 32blit-pico/storage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/32blit-pico/storage.cpp b/32blit-pico/storage.cpp index faec7258b..33b81666a 100644 --- a/32blit-pico/storage.cpp +++ b/32blit-pico/storage.cpp @@ -7,6 +7,8 @@ #include "hardware/sync.h" #include "pico/binary_info.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; @@ -15,7 +17,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, From e0fbf102d9e77cf078a477db5cd390c714fcda5c Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Sat, 19 Feb 2022 19:48:32 +0000 Subject: [PATCH 3/5] pico: Parse the custom 32blit author/category strings --- 32blit-pico/main.cpp | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/32blit-pico/main.cpp b/32blit-pico/main.cpp index 8a435dffe..3656e584d 100644 --- a/32blit-pico/main.cpp +++ b/32blit-pico/main.cpp @@ -7,6 +7,7 @@ #include "pico/stdlib.h" #include "audio.hpp" +#include "binary_info.hpp" #include "config.h" #include "display.hpp" #include "file.hpp" @@ -73,24 +74,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; + } } } From df9ebc4407945a0be88473341b0ee1a238903563 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Wed, 1 Jun 2022 12:24:55 +0100 Subject: [PATCH 4/5] pico: Use metadata tool for binary info --- 32blit-pico/CMakeLists.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/32blit-pico/CMakeLists.txt b/32blit-pico/CMakeLists.txt index c5b5f8549..36e5a862b 100644 --- a/32blit-pico/CMakeLists.txt +++ b/32blit-pico/CMakeLists.txt @@ -113,8 +113,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() From fd24d886a6d386ab411d25fc64a8c03ededa69d5 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Fri, 13 Jan 2023 12:42:09 +0000 Subject: [PATCH 5/5] Require v0.7.3 of tools --- 32blit-config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)