Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions libraries/picosystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ function(picosystem_executable NAME SOURCES)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.uf2 DESTINATION .)
endfunction()

function(picosystem_asset NAME PATH)
get_filename_component(PATH ${PATH} ABSOLUTE)
get_filename_component(ASSET ${PATH} NAME)
get_filename_component(PATH ${PATH} DIRECTORY)
set(OBJNAME ${ASSET}.o)
message("Building ${OBJNAME}")
add_custom_command(OUTPUT ${OBJNAME}
WORKING_DIRECTORY ${PATH}
COMMAND ${CMAKE_LINKER} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/${OBJNAME} ${ASSET})
# TODO figure out how to make static resources work
## COMMAND ${CMAKE_OBJCOPY} --rename-section .data=.rodata,alloc,load,readonly,data,contents ${CMAKE_CURRENT_BINARY_DIR}/${OBJNAME} ${CMAKE_CURRENT_BINARY_DIR}/${OBJNAME})

target_sources(${NAME} PRIVATE ${OBJNAME})
endfunction()

function(pixel_double NAME)
target_compile_options(${NAME} PRIVATE -DPIXEL_DOUBLE)
endfunction()
Expand Down
3 changes: 3 additions & 0 deletions template/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ picosystem_executable(
${PROJECT_SOURCES}
)

# Link the platformer spritesheet
picosystem_asset(${PROJECT_NAME} ../assets/s4m_ur4i-platformer.16bpp)

# --- End Of Boilerplate ---

# Set your build options here
Expand Down
10 changes: 10 additions & 0 deletions template/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

using namespace picosystem;

extern char _binary_s4m_ur4i_platformer_16bpp_start[];
buffer_t *platformer = buffer(128, 128, (void *)_binary_s4m_ur4i_platformer_16bpp_start);

void init() {
spritesheet(platformer);
}

void update(uint32_t tick) {
}

void draw(uint32_t tick) {
pen(0, 0, 0);
clear();
pen(15, 15, 15);
text("Hello World", 14, 12);
sprite(192, 4, 4);
sprite(192 + 16, 4, 12);
}