Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add random color background example #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ if(NOT SKIP_BUILD_EXAMPLES)
modetest
modetesthires
pixelperfect
random-color-background
texstream
textures
vsync
Expand Down
55 changes: 55 additions & 0 deletions examples/random-color-background/random-color-background.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ____ ___ | / _____ _____
// | __ | |___/ | |
// |___| ___| | \ __|__ | gsKit Open Source Project.
// ----------------------------------------------------------------------
// Copyright 2024 - Lucas Teles "PS2DEV" <[email protected]>
// Licenced under Academic Free License version 2.0
// Review gsKit README & LICENSE files for further details.
//
// YouTube - https://www.youtube.com/@ps2dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine merging this PR if you use the standard header

// Working - PCSX2 v1.7.5530
//
// random-color-background.c - Example demonstrating random color on background
//

#include <stdio.h>
#include <unistd.h>
#include <gsKit.h>
#include <gsToolkit.h>

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;
}