Display a variable on the screen[resolved]

SGDK only sub forum

Moderator: Stef

Post Reply
izidor
Interested
Posts: 15
Joined: Tue Jan 26, 2021 12:20 pm

Display a variable on the screen[resolved]

Post by izidor » Mon Feb 01, 2021 9:27 am

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?
Last edited by izidor on Wed Feb 03, 2021 6:19 am, edited 1 time in total.

izidor
Interested
Posts: 15
Joined: Tue Jan 26, 2021 12:20 pm

Re: Display a variable on the screen[resolved]

Post by izidor » Mon Feb 01, 2021 12:00 pm

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

cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Re: Display a variable on the screen[resolved]

Post by cloudstrifer » Wed Feb 03, 2021 11:59 pm

Hi.

You can use Gens Kmod, open degug > messages.

In your code put:

Code: Select all

KLog_U1("test:", intVARIABLE);

izidor
Interested
Posts: 15
Joined: Tue Jan 26, 2021 12:20 pm

Re: Display a variable on the screen[resolved]

Post by izidor » Thu Feb 04, 2021 5:36 am

Thank you for the information,
it's not falling on deaf ears !! :wink:

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Display a variable on the screen[resolved]

Post by Stef » Thu Feb 04, 2021 10:11 am

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 !

Post Reply