diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 6818610..89aacf8 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -38,4 +38,13 @@ jobs: uses: actions/upload-artifact@v4 with: name: gsKit-samples-${{ steps.slug.outputs.sha8 }} - path: build/*.elf + path: | + build/**/*.elf + build/**/*.bmp + build/**/*.jpg + build/**/*.png + build/**/*.tiff + build/**/*.raw + build/**/*.fnt + build/**/*.dat + build/**/*.ppm diff --git a/CMakeLists.txt b/CMakeLists.txt index f6ddc18..78f566c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,7 +334,41 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) install(FILES ${GSKIT_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") endif() -if(NOT SKIP_BUILD_EXAMPLES) +# All available examples +set(GSKIT_SAMPLE_DIRS + alpha + atlas + basic + bigtex + coverflow + clut + clutcsm + cube + fb + fhdbg + font + fontm + modetest + modetesthires + pixelperfect + texstream + textures + vsync +) +set(GSKIT_SPECIAL_EXAMPLES hires linuz-texture png-texture) +set(GSKIT_ALL_EXAMPLES ${GSKIT_SAMPLE_DIRS} ${GSKIT_SPECIAL_EXAMPLES}) + +# Option to build specific examples (empty list = skip all, default = build all) +set(BUILD_EXAMPLES "${GSKIT_ALL_EXAMPLES}" CACHE STRING "List of examples to build (e.g., -DBUILD_EXAMPLES='atlas;cube'). Empty list skips all examples.") + +if(BUILD_EXAMPLES) + # Validate requested examples + foreach(example IN LISTS BUILD_EXAMPLES) + if(NOT example IN_LIST GSKIT_ALL_EXAMPLES) + message(FATAL_ERROR "Example '${example}' not found. Available examples: ${GSKIT_ALL_EXAMPLES}") + endif() + endforeach() + set(CMAKE_EXECUTABLE_SUFFIX .elf) set(GSKIT_SAMPLE_LIBS "") list(APPEND GSKIT_SAMPLE_LIBS gskit_toolkit gskit dmakit ${GSKIT_EXTERNAL_LIBS}) @@ -349,70 +383,70 @@ if(NOT SKIP_BUILD_EXAMPLES) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/${targetname}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\.(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$") endmacro (add_executable_example) - set(GSKIT_SAMPLE_DIRS "") - list(APPEND GSKIT_SAMPLE_DIRS - alpha - atlas - basic - bigtex - coverflow - clut - clutcsm - cube - fb - fhdbg - font - fontm - modetest - modetesthires - pixelperfect - texstream - textures - vsync - ) - - foreach(arg IN ITEMS ${GSKIT_SAMPLE_DIRS}) - add_executable_example(${arg}) + # Build standard examples from the list + foreach(example IN LISTS BUILD_EXAMPLES) + if(example IN_LIST GSKIT_SAMPLE_DIRS) + add_executable_example(${example}) + endif() endforeach() - target_link_libraries(cube - draw - math3d - ) - set_property(TARGET modetest APPEND PROPERTY SOURCES examples/modetest/pad.c) - target_link_libraries(modetest - pad - ) - set_property(TARGET modetesthires APPEND PROPERTY SOURCES examples/modetesthires/pad.c) - target_link_libraries(modetesthires - pad - ) + # Additional configuration for specific examples + if(TARGET cube) + target_link_libraries(cube + draw + math3d + ) + endif() - add_executable(hires - examples/hires/main.c - ) - target_link_libraries(hires - ${GSKIT_SAMPLE_LIBS} - draw - graph - math3d - packet - dma - ) + if(TARGET modetest) + set_property(TARGET modetest APPEND PROPERTY SOURCES examples/modetest/pad.c) + target_link_libraries(modetest + pad + ) + endif() - add_executable(linuz-texture - examples/linuz-texture/sample.c - examples/linuz-texture/testorig.s - examples/linuz-texture/texture.c - ) - target_link_libraries(linuz-texture - ${GSKIT_SAMPLE_LIBS} - ) + if(TARGET modetesthires) + set_property(TARGET modetesthires APPEND PROPERTY SOURCES examples/modetesthires/pad.c) + target_link_libraries(modetesthires + pad + ) + endif() - add_executable(png-texture - examples/png-texture/textures.c - ) - target_link_libraries(png-texture - ${GSKIT_SAMPLE_LIBS} - ) + # Special examples with custom source configurations + if("hires" IN_LIST BUILD_EXAMPLES) + add_executable(hires + examples/hires/main.c + ) + target_link_libraries(hires + ${GSKIT_SAMPLE_LIBS} + draw + graph + math3d + packet + dma + ) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/hires/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\.(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$") + endif() + + if("linuz-texture" IN_LIST BUILD_EXAMPLES) + add_executable(linuz-texture + examples/linuz-texture/sample.c + examples/linuz-texture/testorig.s + examples/linuz-texture/texture.c + ) + target_link_libraries(linuz-texture + ${GSKIT_SAMPLE_LIBS} + ) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/linuz-texture/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\.(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$") + endif() + + if("png-texture" IN_LIST BUILD_EXAMPLES) + add_executable(png-texture + examples/png-texture/textures.c + ) + target_link_libraries(png-texture + ${GSKIT_SAMPLE_LIBS} + ) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/png-texture/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILES_MATCHING REGEX "\\.(bmp|dat|fnt|jpg|png|ppm|raw|s|tiff)$") + endif() endif() diff --git a/examples/alpha/alpha.c b/examples/alpha/alpha.c index b87f72f..6b17180 100644 --- a/examples/alpha/alpha.c +++ b/examples/alpha/alpha.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) gsKit_init_screen(gsGlobal); #ifdef HAVE_LIBTIFF Sprite.Delayed = 1; - if(gsKit_texture_tiff(gsGlobal, &Sprite, "host:alpha.tiff") < 0) + if(gsKit_texture_tiff(gsGlobal, &Sprite, "alpha.tiff") < 0) { printf("Loading Failed!\n"); } diff --git a/examples/bigtex/bigtex.c b/examples/bigtex/bigtex.c index 25cb3c4..f3b7c68 100644 --- a/examples/bigtex/bigtex.c +++ b/examples/bigtex/bigtex.c @@ -47,9 +47,9 @@ int main(int argc, char *argv[]) bigtex.Filter = GS_FILTER_NEAREST; bigtex.Delayed = 1; - // gsKit_texture_raw(gsGlobal, &bigtex, "host:bigtex.raw"); - gsKit_texture_bmp(gsGlobal, &bigtex, "host:bigtex.bmp"); - // gsKit_texture_jpeg(gsGlobal, &bigtex, "host:bigtex.jpg"); + // gsKit_texture_raw(gsGlobal, &bigtex, "bigtex.raw"); + gsKit_texture_bmp(gsGlobal, &bigtex, "bigtex.bmp"); + // gsKit_texture_jpeg(gsGlobal, &bigtex, "bigtex.jpg"); x = 0.0f; diff --git a/examples/coverflow/coverflow.c b/examples/coverflow/coverflow.c index 573e6aa..ce91e63 100644 --- a/examples/coverflow/coverflow.c +++ b/examples/coverflow/coverflow.c @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) // Load textures for (i = 0; i < TEXTURE_COUNT; i++) { Tex[i].Delayed = 1; - snprintf(filename, 80, "host:covers/game%d_%d_%d_08bit.bmp", i+1, 512, 512); + snprintf(filename, 80, "covers/game%d_%d_%d_08bit.bmp", i+1, 512, 512); gsKit_texture_bmp(gsGlobal, &Tex[i], filename); Tex[i].Filter = GS_FILTER_LINEAR; } diff --git a/examples/fb/fb.c b/examples/fb/fb.c index d6c6ff4..139d77e 100644 --- a/examples/fb/fb.c +++ b/examples/fb/fb.c @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) #ifdef USEBMP backtex.Delayed = 0; - gsKit_texture_bmp(gsGlobal, &backtex, "host:bsdgirl.bmp"); + gsKit_texture_bmp(gsGlobal, &backtex, "bsdgirl.bmp"); #endif /* print out useless debug information */ diff --git a/examples/fhdbg/fhdbg.c b/examples/fhdbg/fhdbg.c index 8458198..0f3c79e 100644 --- a/examples/fhdbg/fhdbg.c +++ b/examples/fhdbg/fhdbg.c @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) // Load textures for (iTexId = 0; iTexId < TEXTURE_COUNT; iTexId++) { Tex[iTexId].Delayed = 1; - snprintf(filename, 80, "host:images/fhdbg_0%d.jpg", iTexId + 1); + snprintf(filename, 80, "images/fhdbg_0%d.jpg", iTexId + 1); gsKit_texture_jpeg(gsGlobal, &Tex[iTexId], filename); gsKit_hires_prepare_bg(gsGlobal, &Tex[iTexId]); } diff --git a/examples/font/font.c b/examples/font/font.c index 4a31534..8971b4c 100644 --- a/examples/font/font.c +++ b/examples/font/font.c @@ -23,8 +23,8 @@ int main(int argc, char *argv[]) gsGlobal = gsKit_init_global(); - gsFont = gsKit_init_font(GSKIT_FTYPE_BMP_DAT, "host:dejavu.bmp"); - // gsFont = gsKit_init_font(GSKIT_FTYPE_PNG_DAT, "host:dejavu.png"); + gsFont = gsKit_init_font(GSKIT_FTYPE_BMP_DAT, "dejavu.bmp"); + // gsFont = gsKit_init_font(GSKIT_FTYPE_PNG_DAT, "dejavu.png"); dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); diff --git a/examples/fontm/fontm.c b/examples/fontm/fontm.c index 0710408..37649ee 100644 --- a/examples/fontm/fontm.c +++ b/examples/fontm/fontm.c @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) gsFontM->Spacing = 0.95f; test.Delayed = 1; - gsKit_texture_bmp(gsGlobal, &test, "host:test.bmp"); + gsKit_texture_bmp(gsGlobal, &test, "test.bmp"); test.Filter = GS_FILTER_LINEAR; gsKit_mode_switch(gsGlobal, GS_ONESHOT); diff --git a/examples/hires/main.c b/examples/hires/main.c index 0af265a..e0f4488 100644 --- a/examples/hires/main.c +++ b/examples/hires/main.c @@ -89,14 +89,14 @@ int render(GSGLOBAL *gsGlobal) #ifdef TEX_BG bigtex.Filter = GS_FILTER_LINEAR; bigtex.Delayed = 1; - gsKit_texture_jpeg(gsGlobal, &bigtex, "host:bigtex.jpg"); + gsKit_texture_jpeg(gsGlobal, &bigtex, "bigtex.jpg"); #endif #ifdef FHD_BG fhdbg.Filter = GS_FILTER_LINEAR; fhdbg.Delayed = 1; fhdbg.Vram = GSKIT_ALLOC_ERROR; - gsKit_texture_jpeg(gsGlobal, &fhdbg, "host:fhdbg.jpg"); + gsKit_texture_jpeg(gsGlobal, &fhdbg, "fhdbg.jpg"); gsKit_hires_prepare_bg(gsGlobal, &fhdbg); gsKit_hires_set_bg(gsGlobal, &fhdbg); #endif diff --git a/examples/pixelperfect/pixelperfect.c b/examples/pixelperfect/pixelperfect.c index b402844..ae66026 100644 --- a/examples/pixelperfect/pixelperfect.c +++ b/examples/pixelperfect/pixelperfect.c @@ -61,8 +61,8 @@ int main(int argc, char *argv[]) // Load textures tx128.Delayed = 1; tx132.Delayed = 1; - gsKit_texture_png(gsGlobal, &tx128, "host:128x128.png"); - gsKit_texture_png(gsGlobal, &tx132, "host:132x132.png"); + gsKit_texture_png(gsGlobal, &tx128, "128x128.png"); + gsKit_texture_png(gsGlobal, &tx132, "132x132.png"); gsKit_set_clamp(gsGlobal, GS_CMODE_CLAMP); gsKit_set_test(gsGlobal, GS_ZTEST_OFF); diff --git a/examples/png-texture/textures.c b/examples/png-texture/textures.c index b2f898f..92e0235 100644 --- a/examples/png-texture/textures.c +++ b/examples/png-texture/textures.c @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) gsKit_clear(gsGlobal, White); #ifdef HAVE_LIBPNG - gsKit_texture_png(gsGlobal, &Tex1, "host:test.png"); + gsKit_texture_png(gsGlobal, &Tex1, "test.png"); printf("Texture 1 Height: %i\n",Tex1.Height); printf("Texture 1 Width: %i\n",Tex1.Width); diff --git a/examples/texstream/texstream.c b/examples/texstream/texstream.c index 1409703..9bfafa7 100644 --- a/examples/texstream/texstream.c +++ b/examples/texstream/texstream.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) #endif #ifdef HAVE_LIBPNG - if(gsKit_texture_png(gsGlobal, &Sprite, "host:texstream.png") < 0) + if(gsKit_texture_png(gsGlobal, &Sprite, "texstream.png") < 0) { printf("Loading Failed!\n"); } diff --git a/examples/textures/textures.c b/examples/textures/textures.c index c04f919..13931f0 100644 --- a/examples/textures/textures.c +++ b/examples/textures/textures.c @@ -52,11 +52,11 @@ int main(int argc, char *argv[]) Tex1.PSM = GS_PSM_CT24; Tex1.Filter = GS_FILTER_NEAREST; - gsKit_texture_raw(gsGlobal, &Tex1, "host:bitmap.raw"); + gsKit_texture_raw(gsGlobal, &Tex1, "bitmap.raw"); printf("Texture 1 Height: %i\n",Tex1.Height); printf("Texture 1 Width: %i\n",Tex1.Width); - gsKit_texture_bmp(gsGlobal, &Tex2, "host:bsdgirl.bmp"); + gsKit_texture_bmp(gsGlobal, &Tex2, "bsdgirl.bmp"); printf("Texture 2 Height: %i\n",Tex2.Height); printf("Texture 2 Width: %i\n",Tex2.Width); @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) printf("Texure 2 VRAM Range = 0x%X - 0x%X\n",Tex2.Vram, Tex2.Vram +gsKit_texture_size(Tex2.Width, Tex2.Height, Tex2.PSM) - 1); #ifdef HAVE_LIBJPEG - gsKit_texture_jpeg(gsGlobal, &Tex3, "host:ps2dev.jpg"); + gsKit_texture_jpeg(gsGlobal, &Tex3, "ps2dev.jpg"); printf("Texture 3 Height: %i\n",Tex3.Height); printf("Texture 3 Width: %i\n",Tex3.Width);