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 hello world example #77

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 @@ -305,6 +305,7 @@ if(NOT SKIP_BUILD_EXAMPLES)
fhdbg
font
fontm
hello-world
modetest
modetesthires
pixelperfect
Expand Down
61 changes: 61 additions & 0 deletions examples/hello-world/hello-world.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// ____ ___ | / _____ _____
// | __ | |___/ | |
// |___| ___| | \ __|__ | 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.

Not sure if we should put your YouTube channel here... @ps2dev/developers @ps2dev/admins

Copy link
Member

Choose a reason for hiding this comment

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

Certainly not with the ps2dev name, at least?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put the YouTube link just so new developers can see this example working in the PS2SDK environment. And I also put "PS2DEV" because that's the name of the channel, which is fair. You can see that before "PS2DEV" there is my name referring to me and not another organization.

But whatever you guys decide is fine 😀

Copy link
Member

Choose a reason for hiding this comment

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

I think we shouldn't modify header and use the common header everywhere, so please put same header as other files and we will merge it

// Working - PCSX2 v1.7.5530
//
// hello-world.c - Example demonstrating Hello World
//

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

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