ICE:Tips and Tricks
Double buffering is used avoid flickering, when you want to redraw sprites at other coordinates, and need to erase the old ones. In 8bpp, the vRAM area is large enough to hold 2 screen buffers, and you can set which area of the LCD to display, the first half or the second half. To avoid flickering, you must draw to the buffer, which isn't visible yet, and when everything is drawn, swap the LCD pointer, and draw again to the buffer. You can do that with this piece of code:
- While/Repeat <condition>
- <clear buffer>
- <display sprites>
Notice the "SwapDraw" at the very end, this swaps the LCD pointers, and displays the buffer.
ICE only supports rand, but that unfortunately returns a number between 0 and 16777215. If you want to get a number in between A and B where 0<=A<=B<=16777215, you can use remainder( to get the remainder of rand and an expression. Examples:
This gets the remainder of rand and 6, which is a number in between 0 and 5, and increments it with 1, to get a random number in between 1 and 6.
This gets the remainder of rand and B-A+1, which returns a number in between 0 and B-A. Thus, when adding A, it gets a random number A<=X<=B.
As of ICE V2.0, you can now use randInt:
Will return a random number A<=X<=B.
Will return a random number 1<=X<=10.
Sometimes you want to list all the available files on calc, and often those are programs, for example when you create a shell or IDE. This is pretty easy with ICE, but you need to know how to do it, so let's see what the possibilities are. We already have DetectVar( and Detect(, so let's use them. The documentation says the first argument is °POS where it should be 0 if we want to find the first variable. Let's use this to create a small code snippet to find all the available programs, and open them!
- While DetectVar(°POS,0,5)->PROG