From c4424664c56c230aee07c7dda41599a7b981fc9c Mon Sep 17 00:00:00 2001 From: Lucas Teles Date: Sat, 9 Mar 2024 22:19:54 -0300 Subject: [PATCH] add hello world example --- CMakeLists.txt | 1 + examples/hello-world/hello-world.c | 61 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 examples/hello-world/hello-world.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ab99fa1..f2efeb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,6 +305,7 @@ if(NOT SKIP_BUILD_EXAMPLES) fhdbg font fontm + hello-world modetest modetesthires pixelperfect diff --git a/examples/hello-world/hello-world.c b/examples/hello-world/hello-world.c new file mode 100644 index 0000000..4366b84 --- /dev/null +++ b/examples/hello-world/hello-world.c @@ -0,0 +1,61 @@ +// ____ ___ | / _____ _____ +// | __ | |___/ | | +// |___| ___| | \ __|__ | 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 +// +// hello-world.c - Example demonstrating Hello World +// + +#include +#include +#include + +int main() { + u64 whiteFont; + + GSGLOBAL *gsGlobal; + GSFONTM *gsFontM; + + 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 + ); + + dmaKit_chan_init(DMA_CHANNEL_GIF); + + whiteFont = GS_SETREG_RGBAQ(255, 255, 255, 0, 0); + + gsGlobal = gsKit_init_global(); + gsFontM = gsKit_init_fontm(); + + gsKit_init_screen(gsGlobal); + gsKit_fontm_upload(gsGlobal, gsFontM); + + while (true) { + gsKit_fontm_print_scaled( + gsGlobal, + gsFontM, + 20, + 20, + 0, + 0.85f, + whiteFont, + "Hello World!" + ); + + gsKit_queue_exec(gsGlobal); + gsKit_sync_flip(gsGlobal); + } + + return 0; +} \ No newline at end of file