Skip to content
Merged
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
11 changes: 10 additions & 1 deletion .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
158 changes: 96 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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()
2 changes: 1 addition & 1 deletion examples/alpha/alpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 3 additions & 3 deletions examples/bigtex/bigtex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/coverflow/coverflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fb/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion examples/fhdbg/fhdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/font/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/fontm/fontm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/hires/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/pixelperfect/pixelperfect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/png-texture/textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion examples/texstream/texstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
6 changes: 3 additions & 3 deletions examples/textures/textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ 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);

printf("Texure 1 VRAM Range = 0x%X - 0x%X\n",Tex1.Vram, Tex1.Vram +gsKit_texture_size(Tex1.Width, Tex1.Height, Tex1.PSM) - 1);
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);
Expand Down