Page 1 of 1

Display a variable on the screen[resolved]

Posted: Mon Feb 01, 2021 9:27 am
by izidor
Hello,
I am new to the forum that I have already been browsing for a few weeks, I thank the author of this bookstore (SGDK) who opened the doors to me to programming on Megadrive in C Language, as well as all the participants / members of this forums that enrich this section of the forum, it helps a lot.

So I come to ask for help / advice for something I want to check.
I would like to track the value of a variable of type "int / s16" ingame to realize that it takes the values I want during a collision.

First, I managed to do it using multiple loop if (value == v) {VDP_drawTextBG (plan, "value = v"), x, y}. but it's long and not very clean.

In fact VDP_drawTextBG (), takes a "const * char" as a parameter and as my variable is an s16 that's a problem, there is indeed a FIX16toStr () function which converts an s16 to char * in the string.h file.
Is there a way to convert s16 to const * char?

Re: Display a variable on the screen[resolved]

Posted: Mon Feb 01, 2021 12:00 pm
by izidor
It's resolved with sprintf(), I had not seen this function.

Code: Select all

char str_Region[2] = "0";

void RegionDisplay()
{
	sprintf(str_Region,"%d",indexReg);
	VDP_clearTextAreaBG(BG_B,15,10,2,1);
	VDP_drawTextBG(BG_B,str_Region,15,10);
}

Re: Display a variable on the screen[resolved]

Posted: Wed Feb 03, 2021 11:59 pm
by cloudstrifer
Hi.

You can use Gens Kmod, open degug > messages.

In your code put:

Code: Select all

KLog_U1("test:", intVARIABLE);

Re: Display a variable on the screen[resolved]

Posted: Thu Feb 04, 2021 5:36 am
by izidor
Thank you for the information,
it's not falling on deaf ears !! :wink:

Re: Display a variable on the screen[resolved]

Posted: Thu Feb 04, 2021 10:11 am
by Stef
Yeah GEns Kmod debugging is really more convenient than trying to display value on screen.
Don't forget to enable active debug feature in Gens KMod otherwise message logging won't work !