Advanced xLIB, Tips and Tricks
by Luby

xLIB 402 prerequisites: you've read the previous two tutorials or have made (or are making) a game using xLIB

This tutorial teaches how to use xLIB to it's full extent and some little known things you can do with it.

Using the Update LCD Paramater:

Have you ever been playing a game and were annoyed that you had to sit there and watch every sprite being drawn? Well, if you are a smart xLIBer, you know that most drawing commands have a parameter that allows you to update the lcd or not. This would be a perfect time to use that.

Instead of:

real(2,....,1
real(1,...,1
real(1,...,1
real(12,..,1

and getting a staggered effect, you should do this (it is a bit faster):

real(2,....,0
real(1,...,0
real(1,...,0
real(12,..,0
real(6  //updates lcd

with it all being drawn at the same time (or an illusion of such). And to do the same thing but save bytes, you can:

real(2,....,0
real(1,...,0
real(1,...,0
real(12,..{LCD parameter ommited, defaulted to 1}

You can also do this for your moveable character sprite

real(1,....,0,0,1 //puts character on
real(1,....,1,0,0 //xors it off, but no one can see that it's no longer there

Now for a little known command.

Getting unaccessable characters:

As you probably know, real(13 deals with textmode, you can make it normal, inverse, and toggle lowercase, but what's that last function, Display Character? Well, it displays what ever character is in the second parameter.

real(13,4,48 displays a 0.

Big woop, right?

Wrong.

Here is all the characters are possible

0-126

and 127-244 (245-255 are the same as 0)

Testing to see if a program exists:

Let's say you had a program that has a bunch of subroutines and you want to see if all of them are there. You can use xLIB to test this. First, Edit the begining of all your subroutines to have the following:

If Ans=5.1 //or some number
Then
0 //or some number not 5.1{or some number}
Return
End
...rest of code...

Now, we will need a dummy program is empty (named DUMMY). Make sure DUMMY has no code whatsoever in it.

To test if the program is there, we will use real(10 (Use Archived Prog)

real(10,A,B
*note: real(10 reads the name of the prog you want to run from ans.  See example below*
A= 0 for make new prog, 1 for delete prog, 2 = delete all temp prog
B= Which XTEMP prog you want (0 = XTEMP000, 1= XTEMP001 - XTEMP015)
*example*
"A1" //prog A1 is in archive (or wanted to copy)
real(10,0,0  //copies to XTEMP000
prgmXTEMP000

First, we copy the dummy prog to XTEMP000.

"DUMMY
real(10,0,0

Next, we try to copy our test program to XTEMP000 also. If TEST doesn't exist, XTEMP000 isn't overwritten.

"TEST
real(10,0,0

Then, we put in our number (5.1) and run the program.

5.1
prgmXTEMP000

Then we read the ANS. If it is 5.1, the program doesn't exist.

If ANS=5.1
Disp "Program TEST does not exist

Repeat for all subroutines.

A Nice Wave Effect:

Doesn't that look nice? And we can get it using xLIB.

What we do is take advantage of the fact that xLIB clips sprites, meaning we can put a sprite anywhere.

First, we make a pic of our current screen. For this example, we will save it as Pic0(which is Pic10) The whole concept of the wave is we will take the current screen and copy (from our pic) a bar that is 4 pixels high and 96 wide and paste it one pixel to the left, one pixel to the right and then skips down a few pixels (leaving it as original position) (repeat).

This routine will do the wave pattern shown:

real(9,0,0
For(Q,0,2	//does the wave 3 times
For(O,0,8,4
real(3,0,0,0
For(H,-2+O,46+O,12
real(1,-1,H+2(H<0),12,4,0,0,H+2(H<0),0,0,0	//Draws pixel left
real(1,1,H+6,12,4,0,0,H+6,0,0,H=46+O		//draws pixel right down a bit
End:End:End
real(9,1,0		//clean up

Thanks to DJ Omnimaga for that routine.

Well done. I think you have a great understanding of xLIB now, go out and impress the world!