A little tester routine

Sometimes during the process of coding, you need to drop in a little tester routine to see what numbers are actually popping up.  Such is the case with some of the variables I am using with this game.

Built into the FASE engine is a print string function found in fase.h

void __CALLEE__ PrintStr ( char *string, unsigned int xy )

calling the function is done with

PrintStr(text, 321);

However, this won’t work straight away with pushing an int or short, we will need to perform a recast or provide another function to do the job for us. And built into Z88DK (and into C in general) is the sprintf function. We just need to include it in our #include(s)

#include //being used to convert ints to strings

and now make a function.

void printtester(short info)
	char text[10];
	sprintf(text, "%d", info);	
	//char* text = "bob";//works
	PrintStr("          ", 321);
	PrintStr(text, 321);

and finally, call the function from within our program, calling it with.

printtester(Y1);//calling the print

Now the code should show us any integer signed or unsigned.

Compile and run. Tada, numbers I don’t expect to see, but the premise is correct, just need to fine tune it.

A test case that I want to look at is for our verticalEdge function. I want to see the numbers we are playing with.

So I declare a variable, let’s call it bob and send bob to the printer.

short bob = (scrh);

This should show us our screen height, and indeed it does. Our screen height (scrh) is 10. Since screen width is a constant, let’s try it out as well, and it does show as 15.

So, values I expect to see are correct.

vy is an odd variable, starts out as 0, as soon as you move down, increases.
When you stop it decreases, but not to 0.
When you move up, it does the same in the negative numbers.
This all happens when vy is called at the start of the verticalEdge routine,
let see what happens when we place it near the end.

Pretty much the same thing. Not sure then on how to use this variable. My guess is
that vy stands for Velocity in the Y-axis.

Trying the same of ay,  reveals something similar happening, but with smaller numbers.
ay seems to be more consistent toward going back down to 0. Also seems to work in the
opposite direction, going toward negative number while going down and positive numbers going up.


Checking out y from the same routine, returns something interesting. The variable starts out at 4096. A slight touch downward, the variable moves to 4356. Need to look a little further on.

I also see in the routine that there are references to scrh << 12, let's give that a quick whir. It shows -24576, which is looks familiar, looks like the start of RAM for basic programs, but this may be just a similar number, can't depend on it.

To be continued when I am feeling smarter…..


Author: andydansby

I'm a hobbyist coder working with the ZX Spectrum. Living in New York state near the Syracuse area. I grew up in Virgina. The first computer my parents bought for me was a Timex Sinclair 2068.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s