diff --git a/CMakeLists.txt b/CMakeLists.txt index ab99fa1..b40c108 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,6 +308,7 @@ if(NOT SKIP_BUILD_EXAMPLES) modetest modetesthires pixelperfect + random-color-background texstream textures vsync diff --git a/examples/random-color-background/random-color-background.c b/examples/random-color-background/random-color-background.c new file mode 100644 index 0000000..bd0b090 --- /dev/null +++ b/examples/random-color-background/random-color-background.c @@ -0,0 +1,55 @@ +// ____ ___ | / _____ _____ +// | __ | |___/ | | +// |___| ___| | \ __|__ | gsKit Open Source Project. +// ---------------------------------------------------------------------- +// Copyright 2024 - Lucas Teles "PS2DEV" +// Licenced under Academic Free License version 2.0 +// Review gsKit README & LICENSE files for further details. +// +// YouTube - https://www.youtube.com/@ps2dev +// Working - PCSX2 v1.7.5530 +// +// random-color-background.c - Example demonstrating random color on background +// + +#include +#include +#include +#include + +int main() { + GSGLOBAL *gsGlobal; + + 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 + ); + + u64 colors[3] = { + GS_SETREG_RGBAQ(50, 168, 90, 0, 0), + GS_SETREG_RGBAQ(222, 20, 30, 0, 0), + GS_SETREG_RGBAQ(240, 218, 26, 0, 0) + }; + + gsGlobal = gsKit_init_global(); + gsKit_init_screen(gsGlobal); + + int counter = 0; + + while (true) { + gsKit_clear(gsGlobal, colors[counter]); + + counter = (counter + 1) % 3; + + gsKit_queue_exec(gsGlobal); + gsKit_sync_flip(gsGlobal); + + sleep(1); + } + + return 0; +} \ No newline at end of file